MAXREFDES143#: DeepCover Embedded Security in IoT Authenticated Sensing & Notification

Dependencies:   MaximInterface mbed

Embed: (wiki syntax)

« Back to documentation index

ESP8266 Class Reference

Interface to the ESP8266 Wi-Fi module. More...

#include <ESP8266.hpp>

Data Structures

class  CmdBuilder
 Builds command strings for the ESP8266 with proper formatting. More...

Public Types

enum  CmdResult
 

Result of sending an AT command.

More...
enum  WifiMode
 

ESP8266 Wi-Fi mode.

More...
enum  ConnType
 

Connection type.

More...

Public Member Functions

 ESP8266 (const PinName tx, const PinName rx, const PinName rst, const PinName CH_PD, const int baud, mbed::Serial *debugMsgIntf=NULL)
void reset ()
 Reset the ESP8266 via the hardware reset pin.
CmdResult performSelfTest ()
 Perform a self-test on the ESP8266.
CmdResult setCurrentWifiMode (const WifiMode mode)
 Set the current Wi-Fi mode.
CmdResult joinCurrentAccessPoint (const std::string &ssid, const std::string &pwd, const std::string &bssid="")
 Join a Wi-Fi access point.
CmdResult quitAccessPoint ()
 Quit the current access point.
CmdResult setMaxRFTXPower (const float power_dBm)
 Set the maximum WiFi tranmission power.
CmdResult ping (const std::string &IP)
 Ping a host via the current access point.
CmdResult openConnection (const ConnType type, const std::string &remoteIP, const unsigned int remotePort)
 Open a connection to a host via the current access point.
CmdResult closeConnection ()
 Close the connection to the current host.
CmdResult sendData (const std::string &data)
 Send data to the currently connected host.
CmdResult sendCommand (const CmdBuilder &cmd)
 Send an AT command to the ESP8266.
bool recvIpDataReadable ()
 Check if received IP data is available in the buffer.
char getcRecvIpData ()
 Get the next character of received IP data from the buffer.
void clearRecvData ()
 Clear all received data from the buffer.
bool powered () const

Static Public Attributes

static const int sendDataRecoveryTimeMs = 1000
 Recovery time between Send Data operation as specified by datasheet.

Detailed Description

Interface to the ESP8266 Wi-Fi module.

Definition at line 44 of file ESP8266.hpp.


Member Enumeration Documentation

enum CmdResult

Result of sending an AT command.

Definition at line 47 of file ESP8266.hpp.

enum ConnType

Connection type.

Definition at line 59 of file ESP8266.hpp.

enum WifiMode

ESP8266 Wi-Fi mode.

Definition at line 56 of file ESP8266.hpp.


Constructor & Destructor Documentation

ESP8266 ( const PinName  tx,
const PinName  rx,
const PinName  rst,
const PinName  CH_PD,
const int  baud,
mbed::Serial *  debugMsgIntf = NULL 
)
Parameters:
txTransmit pin from mbed to ESP8266.
rxReceive pin from ESP8266 to mbed.
rstReset pin on ESP8266.
CH_PDPower-down pin on ESP8266.
baudBaud rate that the ESP8266 is using.
debugMsgIntfOptional serial interface for debugging messages.

Definition at line 42 of file ESP8266.cpp.


Member Function Documentation

void clearRecvData (  )

Clear all received data from the buffer.

Definition at line 177 of file ESP8266.cpp.

ESP8266::CmdResult closeConnection (  )

Close the connection to the current host.

Definition at line 134 of file ESP8266.cpp.

char getcRecvIpData (  )

Get the next character of received IP data from the buffer.

Definition at line 163 of file ESP8266.cpp.

ESP8266::CmdResult joinCurrentAccessPoint ( const std::string &  ssid,
const std::string &  pwd,
const std::string &  bssid = "" 
)

Join a Wi-Fi access point.

Parameters:
ssidNetwork SSID to connect to.
pwdNetwork password.
bssidOptional network BSSID.

Definition at line 91 of file ESP8266.cpp.

ESP8266::CmdResult openConnection ( const ConnType  type,
const std::string &  remoteIP,
const unsigned int  remotePort 
)

Open a connection to a host via the current access point.

Parameters:
typeTCP or UPD connection.
remoteIPIP address or resolvable hostname to connect to.
remotePortPort on the host to connect to.

Definition at line 124 of file ESP8266.cpp.

ESP8266::CmdResult performSelfTest (  )

Perform a self-test on the ESP8266.

Definition at line 81 of file ESP8266.cpp.

ESP8266::CmdResult ping ( const std::string &  IP )

Ping a host via the current access point.

Parameters:
IPIP address or resolvable hostname.

Definition at line 118 of file ESP8266.cpp.

bool powered (  ) const

Control if the ESP8266 is powered via the hardware power-down pin.

Definition at line 66 of file ESP8266.cpp.

ESP8266::CmdResult quitAccessPoint (  )

Quit the current access point.

Definition at line 102 of file ESP8266.cpp.

bool recvIpDataReadable (  )

Check if received IP data is available in the buffer.

Note:
Allow some processing delay to happen between calls to this function.
Returns:
True if data is available.

Definition at line 151 of file ESP8266.cpp.

void reset (  )

Reset the ESP8266 via the hardware reset pin.

Definition at line 57 of file ESP8266.cpp.

ESP8266::CmdResult sendCommand ( const CmdBuilder cmd )

Send an AT command to the ESP8266.

Parameters:
cmdFormatted command to send.

Definition at line 147 of file ESP8266.cpp.

ESP8266::CmdResult sendData ( const std::string &  data )

Send data to the currently connected host.

Parameters:
dataMay be in text or binary form.

Definition at line 138 of file ESP8266.cpp.

ESP8266::CmdResult setCurrentWifiMode ( const WifiMode  mode )

Set the current Wi-Fi mode.

Definition at line 85 of file ESP8266.cpp.

ESP8266::CmdResult setMaxRFTXPower ( const float  power_dBm )

Set the maximum WiFi tranmission power.

Parameters:
power_dBmPower in dBm valid from 0 to 20.5 in 0.25 dBm increments.

Definition at line 106 of file ESP8266.cpp.


Field Documentation

const int sendDataRecoveryTimeMs = 1000 [static]

Recovery time between Send Data operation as specified by datasheet.

Definition at line 62 of file ESP8266.hpp.