Fix WiFi reconnection in WiFi example and change SimpleList with ListLib

This commit is contained in:
fauresystems
2019-11-08 17:26:02 +01:00
parent d8260d38b5
commit eade46198b
3 changed files with 24 additions and 8 deletions
+7
View File
@@ -15,6 +15,13 @@ Download [ArduinoProps.zip](https://github.com/fauresystems/ArduinoProps/raw/mas
![](install-shot.png)
Download library dependencies for Library Manager:
* ***PubSubClient***
* ***ListLib***
![](dependencies-shot.png)
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

+17 -8
View File
@@ -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