ESP8266 uart wifi module via AT command

Dependents:   mbed_esp8266_demo

Embed: (wiki syntax)

« Back to documentation index

Esp8266 Class Reference

Esp8266 Class Reference

Esp8266 WiFi serial module. More...

#include <Esp8266.h>

Public Member Functions

 Esp8266 (PinName tx, PinName rx, PinName ch_pd, PinName rst, int baudrate=115200)
int read_until (char *buf, int max, const char *p_ok="OK\r\n", const char *p_error="ERROR\r\n")
 Read data until match or reach max size return size of data -3: timeout -1: get error pattern.
int cmd_data (const char *cmd, char *ret=NULL, int size=0, int timeout_ms=WIFI_TIME_OUT, const char *end="OK\r\n", const char *echo=NULL)
 every command has to end with "\r\n"

Detailed Description

Esp8266 WiFi serial module.

Warnning: CH_PD pin has to connect VCC to boot from internal flash! Command has to end with "\r\n" If you can't get full AT output, set console same baudrate or higher, or set wifi baudrate low!!! DO NOT print console if you want get a long result from internet. Some bad data at beginning because the baudrate changed to 74880 : 0xd
: 0xa

Definition at line 29 of file Esp8266.h.


Constructor & Destructor Documentation

Esp8266 ( PinName  tx,
PinName  rx,
PinName  ch_pd,
PinName  rst,
int  baudrate = 115200 
)
Parameters:
pinLED pin with PWM support
timeTime for the brightness transition
holdTime for holding the brightness before next transition. Effective for loop mode.

Definition at line 39 of file Esp8266.h.


Member Function Documentation

int cmd_data ( const char *  cmd,
char *  ret = NULL,
int  size = 0,
int  timeout_ms = WIFI_TIME_OUT,
const char *  end = "OK\r\n",
const char *  echo = NULL 
)

every command has to end with "\r\n"

>>>cmd <<<cmd <<<data <<<OK/ERROR <<<

return size of result 0: ok -1: if error -2: if buffer overflow -3: timeout others: size of content

Definition at line 266 of file Esp8266.h.

int read_until ( char *  buf,
int  max,
const char *  p_ok = "OK\r\n",
const char *  p_error = "ERROR\r\n" 
)

Read data until match or reach max size return size of data -3: timeout -1: get error pattern.

Definition at line 150 of file Esp8266.h.