Takehisa Oneta / ESP8266

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 (void)
 Test startup of ESP8266.
bool reset (void)
 Reset ESP8266.
bool wifiMode (int mode)
 Set WiFi mode.
bool multipleConnections (bool enabled)
 Enable/Disable multiple connections.
bool dhcp (int mode, bool enabled)
 Enable/Disable DHCP.
bool connect (const char *ap, const char *passPhrase)
 Connect ESP8266 to AP.
bool disconnect (void)
 Disconnect ESP8266 from AP.
bool getIPAddress (char *ip)
 Get the IP address of ESP8266.
bool isConnected (void)
 Check if ESP8266 is conenected.
bool openSocket (string sockType, int id, int port, const char *addr)
 Open a socketed connection.
bool sendData (int id, const void *data, uint32_t amount)
 Sends data to an open socket.
uint32_t recv (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.

Detailed Description

ESP8266Interface class.

This is an interface to a ESP8266 radio.

Definition at line 26 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 146 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 71 of file ESP8266.cpp.

bool dhcp ( int  mode,
bool  enabled 
)

Enable/Disable DHCP.

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

Definition at line 56 of file ESP8266.cpp.

bool disconnect ( void   )

Disconnect ESP8266 from AP.

Returns:
true only if ESP8266 is disconnected successfully

Definition at line 77 of file ESP8266.cpp.

bool getIPAddress ( char *  ip )

Get the IP address of ESP8266.

Parameters:
ipdata placeholder for IP address
Returns:
true only if ESP8266 is assigned an IP address

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

bool multipleConnections ( bool  enabled )

Enable/Disable multiple connections.

Parameters:
enabledmultiple connections enabled when true
Returns:
true only if ESP8266 enables/disables multiple connections successfully

Definition at line 47 of file ESP8266.cpp.

bool openSocket ( string  sockType,
int  id,
int  port,
const char *  addr 
)

Open a socketed connection.

Parameters:
sockTypethe 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 94 of file ESP8266.cpp.

uint32_t recv ( void *  data,
uint32_t  amount 
)

Receives data from an open socket.

Parameters:
dataplaceholder for returned information
amountnumber of bytes to be received
Returns:
the number of bytes actually received

Definition at line 129 of file ESP8266.cpp.

bool reset ( void   )

Reset ESP8266.

Returns:
true only if ESP8266 resets successfully

Definition at line 29 of file ESP8266.cpp.

bool sendData ( 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 172 of file ESP8266.cpp.

bool startup ( void   )

Test startup of ESP8266.

Returns:
true only if ESP8266 AT system working correctly

Definition at line 24 of file ESP8266.cpp.

bool wifiMode ( int  mode )

Set WiFi mode.

Parameters:
modemode of WiFi 1-client, 2-host, 3-both
Returns:
true only if ESP8266 enables/disables DHCP successfully

Definition at line 34 of file ESP8266.cpp.