Skip to content
Snippets Groups Projects
Commit 7617c063 authored by thiebolt's avatar thiebolt
Browse files

update

parent 8771460f
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
Bumps to esp32 2.0.9 Bumps to esp32 2.0.9
Bumps to esp8266 3.1.2 Bumps to esp8266 3.1.2
- switch WiFi to both 802.11b AND 802.11g (DSI cut down 802.11b !!) - switch WiFi to both 802.11b AND 802.11g (DSI cut down 802.11b !!)
- make use of NVS namespace to save WiFi crdentials (in order to avoid SPIFFS
partitionning issues)
- recompiled lwip for NTP server support from DHCP answer (IDF 4.4.4) - recompiled lwip for NTP server support from DHCP answer (IDF 4.4.4)
...@@ -14,7 +16,7 @@ Bumps to esp32 2.0.6 ...@@ -14,7 +16,7 @@ Bumps to esp32 2.0.6
Bumps to esp8266 3.1.0 Bumps to esp8266 3.1.0
- force 802.11b for both ESP8266 and ESP32 --> solved our DHCP issues :D - force 802.11b for both ESP8266 and ESP32 --> solved our DHCP issues :D
- WARNING: breaks SPIFFS format@ESP32 ==> reformat @ reboot ==> per device setup :'( - WARNING: breaks SPIFFS format@ESP32 ==> reformat @ reboot ==> per device setup :'(
no SPIFFS format change @ ESP8266 (hopefully) no SPIFFS format change @ ESP8266
- WiFiManager 2.0.15-rc1 no debug --> revert to 2.0.14-beta - WiFiManager 2.0.15-rc1 no debug --> revert to 2.0.14-beta
- newer WiFiManager introduces ASYNC SCAN ==> very slow (almost unanswered) - newer WiFiManager introduces ASYNC SCAN ==> very slow (almost unanswered)
[esp32] [esp32]
......
...@@ -29,8 +29,14 @@ ...@@ -29,8 +29,14 @@
#include <WiFi.h> #include <WiFi.h>
#endif /* ESP8266 */ #endif /* ESP8266 */
#include "Preferences.h" // NVS storage (instead of the DEPRECATED eeprom) /* NVS namespace @ EPS32 */
#ifdef ESP32
#include "Preferences.h" // NVS storage (instead of the DEPRECATED eeprom)
#elif defined (ESP8266)
#warning "[esp8266] no NVS namespace available ... grab WiFi ssid/psk from last connection"
#endif
/* neOCampus related includes */
#include "neocampus.h" #include "neocampus.h"
#include "neocampus_debug.h" #include "neocampus_debug.h"
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
* - loadSensoConfig --> avoid data duplication, implement an iterator * - loadSensoConfig --> avoid data duplication, implement an iterator
* - remove DISABLE_SSL compilation flag * - remove DISABLE_SSL compilation flag
* --- * ---
* F.Thiebolt jan.23 some cleanup about MAX_TCP connection that is defined at LWIP compile time * ======= SEE 'ChangeLog.txt' for information about updates starting 2023 =========
* WiFi.setPhyMode(WIFI_PHY_MODE_11G) SOLVE THE looonnngggg DHCP issue
* F.Thiebolt nov.21 corrected timezone definition for esp32 * F.Thiebolt nov.21 corrected timezone definition for esp32
* F.Thiebolt sep.21 added display module support (e.g oled or 7segment displays) * F.Thiebolt sep.21 added display module support (e.g oled or 7segment displays)
* F.Thiebolt aug.21 added digital inputs support (e.g PIR sensor) * F.Thiebolt aug.21 added digital inputs support (e.g PIR sensor)
......
/*
* NVS namespace tests
* Note: no esp8266 NVS support ... instead grab WiFi ssid/psk from
*
* ---
* TODO:
* - add support for JSON structure to embedds several WiFi credentials
* ---
* F.Thiebolt may.23 initial release
*/
/*
* Includes
*/
#include <Arduino.h>
#ifdef ESP8266
#warning "[esp8266] No NVS support, instead trying to read SSID/psk from last WiFi connection
#elif defined (ESP32)
#include "Preferences.h"
#endif
/*
* Definitions
*/
// Debug related definitions
#define SERIAL_BAUDRATE 115200
// NVS namespace
#define WIFI_NVS_NAMESPACE "wifiCredentials" // 15 chars max.
#define WIFI_NVS_SSID_KEY "ssid"
#define WIFI_NVS_PASS_KEY "pass"
/*
* Global variables
*/
bool _need2reboot = false; // flag to tell a reboot is requested
char mySSID[64] = "";
char myPSK[64] = "";
/*
* Functions
*/
void endLoop( void ) {
static unsigned long _lastCheck = 0; // elapsed ms since last check
// check if a reboot has been requested ...
if( _need2reboot ) {
Serial.print(F("\n[REBOOT] a reboot has been asked ..."));Serial.flush();
delay(500);
ESP.restart();
delay(5000); // to avoid an infinite loop
}
// a second elapsed ?
if( ((millis() - _lastCheck) >= (unsigned long)1000UL) == true ) {
_lastCheck = millis();
// serial link activity marker ...
Serial.print(F("."));
}
}
// --- MAIN --------------------------------------------------------------------
void setup() {
delay(5000);
Serial.begin(115200); // debug link
Serial.println(F("\n\n\n[NVS] namespace demo ..."));Serial.flush();
delay(1000);
#ifdef ESP32
/* NVS @ ESP32 */
Preferences nvs_wifi;
if( nvs_wifi.begin(WIFI_NVS_NAMESPACE,true) ) { // readonly mode
Serial.print(F("\n[wifiParams] opened NVS WiFi credentials namespace ..."));Serial.flush();
// retrieve SSID/psk
nvs_wifi.getBytes(WIFI_NVS_SSID_KEY, mySSID, sizeof(mySSID));
nvs_wifi.getBytes(WIFI_NVS_PASS_KEY, myPSK, sizeof(myPSK));
if( strlen(mySSID) and strlen(myPSK) ) {
// using retrived credentials to connect
Serial.print(F("\n[NVS-WiFi] retreieved WiFi credentials from NVS :)"));Serial.flush();
}
else {
Serial.print(F("\n[NVS-WiFi] SSID and/or PSK missing ... cancel :("));Serial.flush();
mySSID[0] = '\0';
myPSK[0] = '\0';
}
#elif defined (ESP8266)
/* ESP8266 retrieve WiFi credentials from previous connexion */
#error "NOT YET IMPLEMENTED
#endif
}
// start WiFi connexion either with DEFAULTS WiFi credentials or from retrieved ones
//to be continued
}
// --- LOOP --------------------------------------------------------------------
void loop() {
/*
* do something here ...
*/
// fin de boucle
endLoop();
// do others stuff
delay(250);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment