
Security News
Node.js TSC Declines to Endorse Feature Bounty Program
The Node.js TSC opted not to endorse a feature bounty program, citing concerns about incentives, governance, and project neutrality.
github.com/ekstrand/ESP8266wifi
A simple ESP8266 Arduino library with built in re-connect functionality.
#include <SerialESP8266wifi.h>
SerialESP8266wifi(Stream serialIn, Stream serialOut, byte resetPin)
SerialESP8266wifi wifi(swSerial, swSerial, 10);
SerialESP8266wifi(Stream serialIn, Stream serialOut, byte resetPin, Stream debugSerial)
SerialESP8266wifi wifi(swSerial, swSerial, 10, Serial);
boolean begin() calling this method will do a hw reset on the ESP8266 and set basic parameters
boolean esp8266started = wifi.begin();
boolean connectToAP(char * ssid, char password)* tells the ESP8266 to connect to an accesspoint
boolean apConnected = wifi.connectToAP("myaccesspoint", "password123");
boolean isConnectedToAP() checks if the module is connected with a valid IP
boolean apConnected = wifi.isConnectedToAP();
boolean connectToServer(char ip, char port)** tells the ESP8266 to open a connection to a server
boolean serverConnected = wifi.connectToServer("192.168.5.123", "2121");
boolean isConnectedToServer() checks if a server is connected
boolean serverConnected = wifi.isConnectedToServer();
setTransportToTCP() AND setTransportToUDP() tells the ESP8266 which transport to use when connecting to a server. Default is TCP.
disconnectFromServer() tells the ESP8266 to close the server connection
wifi.disconnectFromServer();
boolean send(char channel, char * message) sends a message - alias for send(char channel, char * message, true)
boolean sendOk = wifi.send(SERVER, "Hello World!");
boolean send(char channel, char * message, boolean sendNow) sends or queues a message for later sending
wifi.send(SERVER, "You", false);
wifi.send(SERVER, " are ", false);
wifi.send(SERVER, "fantastic!", true); // ie wifi.send(SERVER, "fantastic!");
endSendWithNewline(bool endSendWithNewline) by default all messages are sent with newline and carrage return (println), you can disable this
wifi.endSendWithNewline(false);
boolean checkConnections(&connections) - Updates pre-initialised pointer to WifiConnection *connections.
send
.WifiConnection *connections;
wifi.checkConnections(&connections);
for (int i = 0; i < MAX_CONNECTIONS; i++) {
if (connections[i].connected) {
// See if there is a message
WifiMessage msg = wifi.getIncomingMessage();
// Check message is there
if (msg.hasData) {
processCommand(msg);
}
}
}
boolean isConnection(void) - Returns true if client is connected, otherwise false. Use as above without WifiConnection pointer if not bothered about multi-client.
WifiMessage getIncomingMessage(void) - checks serial buffer for messages. Return is WifiMessage type as below. See example Check Client Connection example for usage.
WifiMessage listenForIncomingMessage(int timeoutMillis) will listen for new messages up to timeoutMillis milliseconds. Call this method as often as possible and with as large timeoutMillis as possible to be able to catch as many messages as possible..
void loop(){
WifiMessage in = wifi.listenForIncomingMessage(6000);
if (in.hasData) {
Serial.print("Incoming message:");
Serial.println(in.message);
if(in.channel == SERVER)
Serial.println("From server");
else{
Serial.print("From channel:");
Serial.println(in.channel);
}
}
// Do other stuff
}
boolean startLocalAPAndServer(char ssid, char password, char* channel, char* port)** will create an local access point and start a local server
boolean localAPAndServerStarted = wifi.startLocalAPAndServer("my_ap", "secret_pwd", "5", "2121");
boolean stopLocalAPAndServer() disable the accesspoint (the server will not be stopped, since a restart is needed)
boolean localAPAndServerStopped = wifi.stopLocalAPAndServer();
boolean isLocalAPAndServerRunning() check if local access point and server is running
boolean localAPAndServerRunning = wifi.isLocalAPAndServerRunning();
Everytime send(...) and listenForIncomingMessage(..) is called a watchdog checks that the configured access point, server and local access point and server is still running, if not they will be restarted or re-connected. The same thing happens if the ESP8266 should reset. Note: It is really only the send method that can detect a lost connection to the server. To be sure you are connected, do a send once in a while..
In SerialESP8266wifi.h you can change some stuff:
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Node.js TSC opted not to endorse a feature bounty program, citing concerns about incentives, governance, and project neutrality.
Research
Security News
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.