-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathAdafruit_ESP8266.h
48 lines (40 loc) · 1.87 KB
/
Adafruit_ESP8266.h
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
/*!
* @file Adafruit_ESP8266.h
*/
#ifndef _ADAFRUIT_ESP8266_H_
#define _ADAFRUIT_ESP8266_H_
#include <Arduino.h>
#define ESP_RECEIVE_TIMEOUT 1000L //!< Receive timeout for ESP8266
#define ESP_RESET_TIMEOUT 5000L //!< Reset timeout for ESP8266
#define ESP_CONNECT_TIMEOUT 15000L //!< Connection timeout for ESP8266
#define ESP_IPD_TIMEOUT 120000L //!< Receive network data timeout for ESP8266
typedef const __FlashStringHelper Fstr; //!< PROGMEM/flash-resident string
typedef const PROGMEM char Pchr; //!< Ditto, kindasorta
#define defaultBootMarker F("ready\r\n") //!< Default ESP8266 boot marker string
/*! Subclassing Print makes debugging easier -- output en route to WiFi module
* can be duplicated on a second stream (e.g. Serial). !*/
class Adafruit_ESP8266 : public Print {
public:
Adafruit_ESP8266(Stream *s = &Serial, Stream *d = NULL, int8_t r = -1);
boolean hardReset(void), softReset(void),
find(Fstr *str = NULL, boolean ipd = false),
connectToAP(Fstr *ssid, Fstr *pass), connectTCP(Fstr *host, int port),
requestURL(Fstr *url), requestURL(char *url);
int readLine(char *buf, int bufSiz);
void closeAP(void), closeTCP(void), debugLoop(void),
setTimeouts(uint32_t rcv = ESP_RECEIVE_TIMEOUT,
uint32_t rst = ESP_RESET_TIMEOUT,
uint32_t con = ESP_CONNECT_TIMEOUT,
uint32_t ipd = ESP_IPD_TIMEOUT),
setBootMarker(Fstr *s = NULL);
private:
Stream *stream, // -> ESP8266, e.g. SoftwareSerial or Serial1
*debug; // -> host, e.g. Serial
uint32_t receiveTimeout, resetTimeout, connectTimeout, ipdTimeout;
int8_t reset_pin; // -1 if RST not connected
Fstr *host, // Non-NULL when TCP connection open
*bootMarker; // String indicating successful boot
boolean writing;
virtual size_t write(uint8_t); // Because Print subclass
};
#endif // _ADAFRUIT_ESP8266_H_