データの保存、更新、取得ができるWebサービス「milkcocoa」に接続し、データのプッシュ、送信、取得ができるライブラリを使ったサンプルです。 https://mlkcca.com/

Dependencies:   Milkcocoa mbed

Embed: (wiki syntax)

« Back to documentation index

ESP8266Interface Class Reference

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:
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 or WPA key
baudthe 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]

Close a connection.

Returns:
true if successful

Definition at line 192 of file ESP8266.cpp.

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 385 of file ESP8266.cpp.

char getc (  ) [inherited]

Read a character.

Returns:
the character read

Definition at line 371 of file ESP8266.cpp.

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:
thecharacter which will be written

Definition at line 379 of file ESP8266.cpp.

int readable (  ) [inherited]

Check if characters are available.

Returns:
number of available characters

Definition at line 361 of file ESP8266.cpp.

bool reboot (  ) [inherited]

Reboot the wifi module.

Definition at line 334 of file ESP8266.cpp.

void reset (  ) [inherited]

Reset the wifi module.

Definition at line 318 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:
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 390 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:
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 403 of file ESP8266.cpp.

int writeable (  ) [inherited]

Check if characters are available.

Returns:
number of available characters

Definition at line 366 of file ESP8266.cpp.