-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathESP82XX_WiFi_UART_Bridge.ino
57 lines (46 loc) · 1.32 KB
/
ESP82XX_WiFi_UART_Bridge.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* ESP8285 UDP UART/WiFi bridge example code
by: Greg Tomasch
date: January 24, 2017
license: Beerware - Use this code however you'd like. If you
find it useful you can buy me a beer some time.
Demonstrate UDP packet transfer from the an non-WiFi MCU using the ESP82XX as
WiFi/UART bridge. The Serial protocol is simple (MultiWii MSP). This exapmle was
written directly for the Pesky Products ESP8285 add-on boards
made by Kris Winer. This board is the WiFi access point
*/
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include "WiFi_UDP.h"
#include "WiFiserial.h"
#include "config.h"
extern "C"
{
#include "user_interface.h"
bool wifi_set_sleep_type(sleep_type_t);
sleep_type_t wifi_get_sleep_type(void);
}
// Global variables
float data_update[UPDATE_SIZE];
uint32_t currentTime = 0;
uint32_t previousTime = 0;
uint32_t cycleTime = 0;
void setup()
{
WiFiSerial::SerialOpen(0, 115200);
delay(1000);
WiFi_UDP::WiFi_UDP_init();
delay(1000);
// Enable Light sleep mode
wifi_set_sleep_type(LIGHT_SLEEP_T);
}
void loop()
{
WiFiSerial::serialCom();
// Wait until the loop cycle time has expired
while ((micros() - previousTime) < CYCLETIME_TARGET) {}
currentTime = micros();
cycleTime = currentTime - previousTime;
previousTime = currentTime;
}