ESP8266
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ESP8266WiFiMesh Class Reference

Public Member Functions

 ESP8266WiFiMesh (uint32_t chip_id, std::function< String(String)> handler)
 
void begin ()
 
void attemptScan (String message)
 
void acceptRequest ()
 

Private Member Functions

void connectToNode (String target_ssid, String message)
 
bool exchangeInfo (String message, WiFiClient curr_client)
 
bool waitForClient (WiFiClient curr_client, int max_wait)
 

Private Attributes

String _ssid
 
String _ssid_prefix
 
uint32_t _chip_id
 
std::function< String(String)> _handler
 
WiFiServer _server
 
WiFiClient _client
 

Constructor & Destructor Documentation

ESP8266WiFiMesh::ESP8266WiFiMesh ( uint32_t  chip_id,
std::function< String(String)>  handler 
)

WiFiMesh Constructor method. Creates a WiFi Mesh Node, ready to be initialised.

A unique identifier number for the node. The callback handler for dealing with received messages. Takes a string as an argument which is the string received from another node and returns the string to send back.

Member Function Documentation

void ESP8266WiFiMesh::acceptRequest ( )

If any clients are connected, accept their requests and call the hander function for each one.

void ESP8266WiFiMesh::attemptScan ( String  message)

Scan for other nodes, and exchange the chosen message with any that are found.

The message to send to all other nodes.

void ESP8266WiFiMesh::begin ( )

Initialises the node.

void ESP8266WiFiMesh::connectToNode ( String  target_ssid,
String  message 
)
private

Connect to the AP at ssid, send them a message then disconnect.

The name of the AP the other node has set up. The string to send to the node.

bool ESP8266WiFiMesh::exchangeInfo ( String  message,
WiFiClient  curr_client 
)
private

Send the supplied message then read back the other node's response and pass that to the user-supplied handler.

The name of the AP the other node has set up. The string to send to the node.

Returns
: True if the exchange was a succes, false otherwise.
bool ESP8266WiFiMesh::waitForClient ( WiFiClient  curr_client,
int  max_wait 
)
private

Wait for a WiFiClient to connect

Returns
: True if the client is ready, false otherwise.

Member Data Documentation

uint32_t ESP8266WiFiMesh::_chip_id
private
WiFiClient ESP8266WiFiMesh::_client
private
std::function<String(String)> ESP8266WiFiMesh::_handler
private
WiFiServer ESP8266WiFiMesh::_server
private
String ESP8266WiFiMesh::_ssid
private
String ESP8266WiFiMesh::_ssid_prefix
private