Simple IoT Board用のライブラリです。 ESP8266ライブラリの軽量化 送信のみのソフトシリアルライブラリを含んでいます。
Dependents: SITB_HttpGetSample SITB_IFTTTSample SITB_INA226PRC AmbientExampleSITB ... more
ESP8266Interface Class Reference
Interface using ESP8266 to connect to an IP-based network. More...
#include <ESP8266Interface.h>
Inherits ESP8266.
Public Member Functions | |
ESP8266Interface (PinName tx, PinName rx, PinName reset, const char *ssid, const char *phrase, uint32_t baud=115200) | |
Constructor. | |
int | init () |
Initialize the interface with DHCP. | |
bool | connect () |
Connect Bring the interface up, start DHCP if needed. | |
int | disconnect () |
Disconnect Bring the interface down. | |
char * | getIPAddress () |
Get IP address. | |
bool | join () |
Connect the wifi module to the ssid contained in the constructor. | |
bool | is_connected () |
Check connection to the access point. | |
bool | close () |
Close a connection. | |
bool | gethostbyname (const char *host, char *ip) |
Return the IP address from host name. | |
void | reset () |
Reset the wifi module. | |
bool | reboot () |
Reboot the wifi module. | |
int | readable () |
Check if characters are available. | |
int | writeable () |
Check if characters are available. | |
char | getc () |
Read a character. | |
int | putc (char c) |
Write a character. | |
void | flush () |
Flush the buffer. | |
bool | sendCommand (const char *cmd, const char *ack=NULL, char *res=NULL, int timeout=DEFAULT_WAIT_RESP_TIMEOUT) |
Send a command to the wifi module. | |
int | send (const char *buf, int len) |
Send a string to the wifi module by serial port. |
Detailed Description
Interface using ESP8266 to connect to an IP-based network.
Definition at line 29 of file ESP8266Interface.h.
Constructor & Destructor Documentation
ESP8266Interface | ( | PinName | tx, |
PinName | rx, | ||
PinName | reset, | ||
const char * | ssid, | ||
const char * | phrase, | ||
uint32_t | baud = 115200 |
||
) |
Constructor.
- Parameters:
-
tx mbed pin to use for tx line of Serial interface rx mbed pin to use for rx line of Serial interface reset reset pin of the wifi module () ssid ssid of the network phrase WEP or WPA key baud the baudrate of the serial connection (defaults to 115200, diff revs of the firmware use diff baud rates
Definition at line 3 of file ESP8266Interface.cpp.
Member Function Documentation
bool close | ( | ) | [inherited] |
bool connect | ( | ) |
Connect Bring the interface up, start DHCP if needed.
- Returns:
- 0 on success, a negative number on failure
Reimplemented from ESP8266.
Definition at line 15 of file ESP8266Interface.cpp.
int disconnect | ( | ) |
Disconnect Bring the interface down.
- Returns:
- 0 on success, a negative number on failure
Reimplemented from ESP8266.
Definition at line 20 of file ESP8266Interface.cpp.
void flush | ( | ) | [inherited] |
Flush the buffer.
Definition at line 384 of file ESP8266.cpp.
char getc | ( | ) | [inherited] |
bool gethostbyname | ( | const char * | host, |
char * | ip | ||
) | [inherited] |
Return the IP address from host name.
- Returns:
- true on success, false on failure
Definition at line 292 of file ESP8266.cpp.
char * getIPAddress | ( | ) |
Get IP address.
- Returns:
- ip address
Reimplemented from ESP8266.
Definition at line 25 of file ESP8266Interface.cpp.
int init | ( | ) |
Initialize the interface with DHCP.
Initialize the interface and configure it to use DHCP (no connection at this point).
- Returns:
- 0 on success, a negative number on failure
Definition at line 9 of file ESP8266Interface.cpp.
bool is_connected | ( | ) | [inherited] |
Check connection to the access point.
- Returns:
- true if successful
Definition at line 91 of file ESP8266.cpp.
bool join | ( | ) | [inherited] |
Connect the wifi module to the ssid contained in the constructor.
- Returns:
- true if connected, false otherwise
Definition at line 70 of file ESP8266.cpp.
int putc | ( | char | c ) | [inherited] |
Write a character.
- Parameters:
-
the character which will be written
Definition at line 378 of file ESP8266.cpp.
int readable | ( | ) | [inherited] |
Check if characters are available.
- Returns:
- number of available characters
Definition at line 360 of file ESP8266.cpp.
bool reboot | ( | ) | [inherited] |
Reboot the wifi module.
Definition at line 333 of file ESP8266.cpp.
void reset | ( | ) | [inherited] |
Reset the wifi module.
Definition at line 317 of file ESP8266.cpp.
int send | ( | const char * | buf, |
int | len | ||
) | [inherited] |
Send a string to the wifi module by serial port.
This function desactivates the user interrupt handler when a character is received to analyze the response from the wifi module. Useful to send a command to the module and wait a response.
- Parameters:
-
str string to be sent len string length ACK string which must be acknowledge by the wifi module. If ACK == NULL, no string has to be acknoledged. (default: "NO") res this field will contain the response from the wifi module, result of a command sent. This field is available only if ACK = "NO" AND res != NULL (default: NULL)
- Returns:
- true if ACK has been found in the response from the wifi module. False otherwise or if there is no response in 5s.
Definition at line 389 of file ESP8266.cpp.
bool sendCommand | ( | const char * | cmd, |
const char * | ack = NULL , |
||
char * | res = NULL , |
||
int | timeout = DEFAULT_WAIT_RESP_TIMEOUT |
||
) | [inherited] |
Send a command to the wifi module.
Check if the module is in command mode. If not enter in command mode
- Parameters:
-
str string to be sent ACK string which must be acknowledge by the wifi module. If ACK == NULL, no string has to be acknowledged. (default: "NO") res this field will contain the response from the wifi module, result of a command sent. This field is available only if ACK = "NO" AND res != NULL (default: NULL)
- Returns:
- true if successful
Definition at line 402 of file ESP8266.cpp.
int writeable | ( | ) | [inherited] |
Check if characters are available.
- Returns:
- number of available characters
Definition at line 365 of file ESP8266.cpp.
Generated on Tue Jul 12 2022 18:13:35 by
