now this shit works

Dependencies:   BufferedSerial

Dependents:   IoTWeatherStation

Fork of ESP8266NodeMCUInterface by ESP8266

Embed: (wiki syntax)

« Back to documentation index

ESP8266 Class Reference

The ESP8266 class. More...

#include <ESP8266.h>

Inherited by ESP8266Interface.

Public Member Functions

 ESP8266 (PinName tx, PinName rx, PinName reset, int baud=9600, int timeout=3000)
 Constructor.
bool init ()
 Initialize the wifi hardware.
bool connect (const char *ssid, const char *phrase)
 Connect the wifi module to the specified ssid.
bool is_connected ()
 Check connection to the access point.
bool disconnect ()
 Disconnect the ESP8266 module from the access point.
bool close ()
 Close a connection.
int getc ()
 Read a character or block.
int putc (char c)
 Write a character.
bool send (const char *buffer, int len)
 Write a string.
bool recv (char *buffer, int *len)
 Read a string without blocking.
int writeable ()
 Check if wifi is writable.
int readable ()
 Check if wifi is readable.
const char * getIPAddress ()
 Return the IP address.
bool getHostByName (const char *host, char *ip)
 Return the IP address from host name.
bool reset ()
 Reset the wifi module.
bool command (const char *cmd)
 Send part of a command to the wifi module.

Static Public Member Functions

static ESP8266getInstance ()
 Obtains the current instance of the ESP8266.

Detailed Description

The ESP8266 class.

Definition at line 41 of file ESP8266.h.


Constructor & Destructor Documentation

ESP8266 ( PinName  tx,
PinName  rx,
PinName  reset,
int  baud = 9600,
int  timeout = 3000 
)

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 ()
baudthe baudrate of the serial connection
timeoutthe timeout of the serial connection

Definition at line 44 of file ESP8266.cpp.


Member Function Documentation

bool close (  )

Close a connection.

Returns:
true if successful

Definition at line 198 of file ESP8266.cpp.

bool command ( const char *  cmd )

Send part of a command to the wifi module.

Parameters:
cmdstring to be sent
lenoptional length of cmd
sanitizeflag indicating if cmd is actually payload and needs to be escaped
Returns:
true if successful

Definition at line 402 of file ESP8266.cpp.

bool connect ( const char *  ssid,
const char *  phrase 
)

Connect the wifi module to the specified ssid.

Parameters:
ssidssid of the network
phraseWEP, WPA or WPA2 key
Returns:
true if successful

Reimplemented in ESP8266Interface.

Definition at line 71 of file ESP8266.cpp.

bool disconnect (  )

Disconnect the ESP8266 module from the access point.

Returns:
true if successful

Reimplemented in ESP8266Interface.

Definition at line 119 of file ESP8266.cpp.

int getc (  )

Read a character or block.

Returns:
the character read or -1 on error

Definition at line 275 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 314 of file ESP8266.cpp.

static ESP8266* getInstance (  ) [static]

Obtains the current instance of the ESP8266.

Definition at line 170 of file ESP8266.h.

const char * getIPAddress (  )

Return the IP address.

Returns:
IP address as a string

Reimplemented in ESP8266Interface.

Definition at line 307 of file ESP8266.cpp.

bool init (  )

Initialize the wifi hardware.

Returns:
true if successful

Reimplemented in ESP8266Interface.

Definition at line 66 of file ESP8266.cpp.

bool is_connected (  )

Check connection to the access point.

Returns:
true if successful

Definition at line 133 of file ESP8266.cpp.

int putc ( char  c )

Write a character.

Parameters:
thecharacter which will be written
Returns:
-1 on error

Definition at line 269 of file ESP8266.cpp.

int readable (  )

Check if wifi is readable.

Returns:
number of characters available

Definition at line 296 of file ESP8266.cpp.

bool recv ( char *  buffer,
int *  len 
)

Read a string without blocking.

Parameters:
bufferthe buffer that will be written
lenthe length of the buffer, is replaced by read length
Returns:
true on success

Definition at line 226 of file ESP8266.cpp.

bool reset (  )

Reset the wifi module.

Definition at line 56 of file ESP8266.cpp.

bool send ( const char *  buffer,
int  len 
)

Write a string.

Parameters:
bufferthe buffer that will be written
lenthe length of the buffer
Returns:
true on success

Definition at line 202 of file ESP8266.cpp.

int writeable (  )

Check if wifi is writable.

Returns:
1 if wifi is writable

Definition at line 291 of file ESP8266.cpp.