Fix WiFi reconnection in WiFi example and change SimpleList with ListLib
This commit is contained in:
@@ -15,6 +15,13 @@ Download [ArduinoProps.zip](https://github.com/fauresystems/ArduinoProps/raw/mas
|
||||
|
||||

|
||||
|
||||
Download library dependencies for Library Manager:
|
||||
* ***PubSubClient***
|
||||
* ***ListLib***
|
||||
|
||||

|
||||
|
||||
|
||||
Add `#include "ArduinoProps.h"` on top of your sketch and start coding. Reading [EXAMPLES.md](EXAMPLES.md) will be helpful.
|
||||
|
||||
|ArduinoProps library documentation |
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
@@ -13,8 +13,8 @@
|
||||
#include "ArduinoProps.h"
|
||||
|
||||
// Setup your WiFi network
|
||||
const char* ssid = "";
|
||||
const char *passphrase = "";
|
||||
const char* ssid = "Livebox-54A0";
|
||||
const char *passphrase = "2ZwEbxpW5L7jthuw3P";
|
||||
|
||||
// Builtin led is not available with the shield
|
||||
#undef LED_BUILTIN
|
||||
@@ -36,6 +36,8 @@ PropsDataLogical led(u8"led");
|
||||
void clignote(); // forward
|
||||
PropsAction clignoteAction = PropsAction(1000, clignote);
|
||||
|
||||
bool wifiBegun(false);
|
||||
|
||||
void setup()
|
||||
{
|
||||
// can do more static IP configuration
|
||||
@@ -43,12 +45,6 @@ void setup()
|
||||
//WiFi.config(IPAddress(), IPAddress());
|
||||
//WiFi.config(IPAddress());
|
||||
|
||||
WiFi.begin(ssid, passphrase);
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
}
|
||||
|
||||
props.addData(&clignoter);
|
||||
props.addData(&led);
|
||||
|
||||
@@ -61,6 +57,19 @@ void setup()
|
||||
|
||||
void loop()
|
||||
{
|
||||
if (!wifiBegun) {
|
||||
WiFi.begin(ssid, passphrase);
|
||||
delay(250); // acceptable freeze for this props (otherwise ues PropsAction)
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
wifiBegun = true;
|
||||
} else {
|
||||
WiFi.end();
|
||||
}
|
||||
} else if (wifiBegun && WiFi.status() != WL_CONNECTED) {
|
||||
WiFi.end();
|
||||
wifiBegun = false;
|
||||
}
|
||||
|
||||
props.loop();
|
||||
|
||||
led.setValue(digitalRead(LED_BUILTIN)); // read I/O
|
||||
|
||||
Reference in New Issue
Block a user