Driver for the ESP8266 WiFi module using ATParser library. Espressif Firmware.

Dependencies:   ATParser

Dependents:   ESP8266Interface

Fork of ESP8266 by NetworkSocketAPI

Embed: (wiki syntax)

« Back to documentation index

ESP8266 Class Reference

ESP8266 Class Reference

ESP8266Interface class. More...

#include <ESP8266.h>

Public Member Functions

bool startup (int mode)
 Startup the ESP8266.
bool reset (void)
 Reset ESP8266.
bool dhcp (bool enabled, int mode)
 Enable/Disable DHCP.
bool connect (const char *ap, const char *passPhrase)
 Connect ESP8266 to AP.
bool disconnect (void)
 Disconnect ESP8266 from AP.
const char * getIPAddress (void)
 Get the IP address of ESP8266.
const char * getMACAddress (void)
 Get the MAC address of ESP8266.
bool isConnected (void)
 Check if ESP8266 is conenected.
bool open (const char *type, int id, const char *addr, int port)
 Open a socketed connection.
bool send (int id, const void *data, uint32_t amount)
 Sends data to an open socket.
int32_t recv (int id, void *data, uint32_t amount)
 Receives data from an open socket.
bool close (int id)
 Closes a socket.
void setTimeout (uint32_t timeout_ms)
 Allows timeout to be changed between commands.
bool readable ()
 Checks if data is available.
bool writeable ()
 Checks if data can be written.

Detailed Description

ESP8266Interface class.

This is an interface to a ESP8266 radio.

Definition at line 25 of file ESP8266.h.


Member Function Documentation

bool close ( int  id )

Closes a socket.

Parameters:
idid of socket to close, valid only 0-4
Returns:
true only if socket is closed successfully

Definition at line 142 of file ESP8266.cpp.

bool connect ( const char *  ap,
const char *  passPhrase 
)

Connect ESP8266 to AP.

Parameters:
apthe name of the AP
passPhrasethe password of AP
Returns:
true only if ESP8266 is connected successfully

Definition at line 63 of file ESP8266.cpp.

bool dhcp ( bool  enabled,
int  mode 
)

Enable/Disable DHCP.

Parameters:
enabledDHCP enabled when true
modemode of DHCP 0-softAP, 1-station, 2-both
Returns:
true only if ESP8266 enables/disables DHCP successfully

Definition at line 52 of file ESP8266.cpp.

bool disconnect ( void   )

Disconnect ESP8266 from AP.

Returns:
true only if ESP8266 is disconnected successfully

Definition at line 69 of file ESP8266.cpp.

const char * getIPAddress ( void   )

Get the IP address of ESP8266.

Returns:
null-teriminated IP address or null if no IP address is assigned

Definition at line 74 of file ESP8266.cpp.

const char * getMACAddress ( void   )

Get the MAC address of ESP8266.

Returns:
null-terminated MAC address or null if no MAC address is assigned

Definition at line 85 of file ESP8266.cpp.

bool isConnected ( void   )

Check if ESP8266 is conenected.

Returns:
true only if the chip has an IP address

Definition at line 96 of file ESP8266.cpp.

bool open ( const char *  type,
int  id,
const char *  addr,
int  port 
)

Open a socketed connection.

Parameters:
typethe type of socket to open "UDP" or "TCP"
idid to give the new socket, valid 0-4
portport to open connection with
addrthe IP address of the destination
Returns:
true only if socket opened successfully

Definition at line 101 of file ESP8266.cpp.

bool readable (  )

Checks if data is available.

Definition at line 160 of file ESP8266.cpp.

int32_t recv ( int  id,
void *  data,
uint32_t  amount 
)

Receives data from an open socket.

Parameters:
idid to receive from
dataplaceholder for returned information
amountnumber of bytes to be received
Returns:
the number of bytes received

Definition at line 126 of file ESP8266.cpp.

bool reset ( void   )

Reset ESP8266.

Returns:
true only if ESP8266 resets successfully

Definition at line 40 of file ESP8266.cpp.

bool send ( int  id,
const void *  data,
uint32_t  amount 
)

Sends data to an open socket.

Parameters:
idid of socket to send to
datadata to be sent
amountamount of data to be sent - max 1024
Returns:
true only if data sent successfully

Definition at line 112 of file ESP8266.cpp.

void setTimeout ( uint32_t  timeout_ms )

Allows timeout to be changed between commands.

Parameters:
timeout_mstimeout of the connection

Definition at line 155 of file ESP8266.cpp.

bool startup ( int  mode )

Startup the ESP8266.

Parameters:
modemode of WIFI 1-client, 2-host, 3-both
Returns:
true only if ESP8266 was setup correctly

Definition at line 26 of file ESP8266.cpp.

bool writeable (  )

Checks if data can be written.

Definition at line 165 of file ESP8266.cpp.