Simple IoT Board用のライブラリです。 ESP8266ライブラリの軽量化 送信のみのソフトシリアルライブラリを含んでいます。

Dependents:   SITB_HttpGetSample SITB_IFTTTSample SITB_INA226PRC AmbientExampleSITB ... more

Embed: (wiki syntax)

« Back to documentation index

ESP8266 Class Reference

ESP8266 Class Reference

The ESP8266 class. More...

#include <ESP8266.h>

Inherited by ESP8266Interface.

Public Member Functions

 ESP8266 (PinName tx, PinName rx, PinName reset, const char *ssid, const char *phrase, uint32_t baud)
 Constructor.
bool join ()
 Connect the wifi module to the ssid contained in the constructor.
bool connect ()
 Same as Join: connect to the ssid and get DHCP settings.
bool is_connected ()
 Check connection to the access point.
bool disconnect ()
 Disconnect the ESP8266 module from the access point.
bool close ()
 Close a connection.
char * getIPAddress ()
 Return the IP address.
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

The ESP8266 class.

Definition at line 41 of file ESP8266.h.


Constructor & Destructor Documentation

ESP8266 ( PinName  tx,
PinName  rx,
PinName  reset,
const char *  ssid,
const char *  phrase,
uint32_t  baud 
)

Constructor.

Parameters:
txmbed pin to use for tx line of Serial interface
rxmbed pin to use for rx line of Serial interface
resetreset pin of the wifi module ()
ssidssid of the network
phraseWEP, WPA or WPA2 key
baudthe baudrate of the serial connection

Definition at line 52 of file ESP8266.cpp.


Member Function Documentation

bool close (  )

Close a connection.

Returns:
true if successful

Definition at line 192 of file ESP8266.cpp.

bool connect (  )

Same as Join: connect to the ssid and get DHCP settings.

Returns:
true if successful

Reimplemented in ESP8266Interface.

Definition at line 85 of file ESP8266.cpp.

bool disconnect (  )

Disconnect the ESP8266 module from the access point.

Returns:
true if successful

Reimplemented in ESP8266Interface.

Definition at line 202 of file ESP8266.cpp.

void flush (  )

Flush the buffer.

Definition at line 384 of file ESP8266.cpp.

char getc (  )

Read a character.

Returns:
the character read

Definition at line 370 of file ESP8266.cpp.

bool gethostbyname ( const char *  host,
char *  ip 
)

Return the IP address from host name.

Returns:
true on success, false on failure

Definition at line 292 of file ESP8266.cpp.

char * getIPAddress (  )

Return the IP address.

Returns:
IP address as a string

Reimplemented in ESP8266Interface.

Definition at line 260 of file ESP8266.cpp.

bool is_connected (  )

Check connection to the access point.

Returns:
true if successful

Definition at line 91 of file ESP8266.cpp.

bool join (  )

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 )

Write a character.

Parameters:
thecharacter which will be written

Definition at line 378 of file ESP8266.cpp.

int readable (  )

Check if characters are available.

Returns:
number of available characters

Definition at line 360 of file ESP8266.cpp.

bool reboot (  )

Reboot the wifi module.

Definition at line 333 of file ESP8266.cpp.

void reset (  )

Reset the wifi module.

Definition at line 317 of file ESP8266.cpp.

int send ( const char *  buf,
int  len 
)

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:
strstring to be sent
lenstring length
ACKstring which must be acknowledge by the wifi module. If ACK == NULL, no string has to be acknoledged. (default: "NO")
resthis 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 
)

Send a command to the wifi module.

Check if the module is in command mode. If not enter in command mode

Parameters:
strstring to be sent
ACKstring which must be acknowledge by the wifi module. If ACK == NULL, no string has to be acknowledged. (default: "NO")
resthis 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 (  )

Check if characters are available.

Returns:
number of available characters

Definition at line 365 of file ESP8266.cpp.