Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

Commit

Permalink
v1.0.4
Browse files Browse the repository at this point in the history
#### Major Release v1.0.4

1. Configurable ***Config Portal Title*** to be either HostName, BoardName or default undistinguishable names.
2. Optional default ***Credentials as well as Dynamic parameters to be optionally autoloaded into Config Portal*** to use or change instead of manually input.
3. ***DoubleDetectDetector*** feature to force Config Portal when double reset is detected within predetermined time, default 10s.
4. Examples are redesigned to separate Credentials / Defines / Dynamic Params / Code so that you can change Credentials / Dynamic Params quickly for each device.
5. Add Board Name
  • Loading branch information
khoih-prog authored May 4, 2020
1 parent 6f0cfe9 commit 66415c8
Show file tree
Hide file tree
Showing 37 changed files with 3,850 additions and 1,174 deletions.
610 changes: 524 additions & 86 deletions README.md

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions examples/Mega_WiFiNINA/Credentials.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/****************************************************************************************************************************
Credentials.h
For nRF52 boards using WiFiNINA modules/shields, using much less code to support boards with smaller memory
WiFiManager_NINA_WM_Lite is a library for the Mega, Teensy, SAM DUE, SAMD and STM32 boards
(https://github.com/khoih-prog/WiFiManager_NINA_Lite) to enable store Credentials in EEPROM/LittleFS for easy
configuration/reconfiguration and autoconnect/autoreconnect of WiFi and other services without Hardcoding.
Built by Khoi Hoang https://github.com/khoih-prog/WiFiManager_NINA_Lite
Licensed under MIT license
Version: 1.0.4
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 26/03/2020 Initial coding
1.0.1 K Hoang 27/03/2020 Fix SAMD soft-reset bug. Add support to remaining boards
1.0.2 K Hoang 15/04/2020 Fix bug. Add SAMD51 support.
1.0.3 K Hoang 24/04/2020 Fix bug. Add nRF5 (Adafruit, NINA_B302_ublox, etc.) support. Add MultiWiFi, HostName capability.
SSID password maxlen is 63 now. Permit special chars # and % in input data.
1.0.4 K Hoang 04/05/2020 Add Configurable Config Portal Title, Default Config Data and DRD. Update examples.
*****************************************************************************************************************************/

#ifndef Credentials_h
#define Credentials_h

#include "defines.h"

/// Start Default Config Data //////////////////

/*
#define SSID_MAX_LEN 32
//From v1.0.3, WPA2 passwords can be up to 63 characters long.
#define PASS_MAX_LEN 64
typedef struct
{
char wifi_ssid[SSID_MAX_LEN];
char wifi_pw [PASS_MAX_LEN];
} WiFi_Credentials;
#define NUM_WIFI_CREDENTIALS 2
// Configurable items besides fixed Header, just add board_name
#define NUM_CONFIGURABLE_ITEMS ( ( 2 * NUM_WIFI_CREDENTIALS ) + 1 )
////////////////
typedef struct Configuration
{
char header [16];
WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS];
char board_name [24];
int checkSum;
} WiFiNINA_Configuration;
*/

#define TO_LOAD_DEFAULT_CONFIG_DATA true

#if TO_LOAD_DEFAULT_CONFIG_DATA

bool LOAD_DEFAULT_CONFIG_DATA = true;

WiFiNINA_Configuration defaultConfig =
{
//char header[16], dummy, not used
"WIFININA",
// WiFi_Credentials WiFi_Creds [NUM_WIFI_CREDENTIALS];
// WiFi_Credentials.wifi_ssid and WiFi_Credentials.wifi_pw
"SSID1", "password1",
"SSID2", "password2",
//char board_name [24];
"Air-Control",
// terminate the list
//int checkSum, dummy, not used
0
/////////// End Default Config Data /////////////
};

#else

bool LOAD_DEFAULT_CONFIG_DATA = false;

WiFiNINA_Configuration defaultConfig;

#endif // TO_LOAD_DEFAULT_CONFIG_DATA

/////////// End Default Config Data /////////////


#endif //Credentials_h
90 changes: 9 additions & 81 deletions examples/Mega_WiFiNINA/Mega_WiFiNINA.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
Mega_WiFiNINA.ino
For AVR or Generic boards using WiFiNINA Modules/Shields, using much less code to support boards with smaller memory
WiFiManager_NINA_WM_Lite is a library for the Mega, Teensy, SAM DUE, SAMD and STM32 boards (https://github.com/khoih-prog/WiFiManager_NINA_Lite)
to enable store Credentials in EEPROM to easy configuration/reconfiguration and autoconnect/autoreconnect of WiFi and other services
without Hardcoding.
WiFiManager_NINA_WM_Lite is a library for the Mega, Teensy, SAM DUE, SAMD and STM32 boards
(https://github.com/khoih-prog/WiFiManager_NINA_Lite) to enable store Credentials in EEPROM/LittleFS for easy
configuration/reconfiguration and autoconnect/autoreconnect of WiFi and other services without Hardcoding.
Built by Khoi Hoang https://github.com/khoih-prog/WiFiManager_NINA_Lite
Licensed under MIT license
Version: 1.0.3
Version: 1.0.4
Version Modified By Date Comments
------- ----------- ---------- -----------
Expand All @@ -17,83 +17,11 @@
1.0.2 K Hoang 15/04/2020 Fix bug. Add SAMD51 support.
1.0.3 K Hoang 24/04/2020 Fix bug. Add nRF5 (Adafruit, NINA_B302_ublox, etc.) support. Add MultiWiFi, HostName capability.
SSID password maxlen is 63 now. Permit special chars # and % in input data.
1.0.4 K Hoang 04/05/2020 Add Configurable Config Portal Title, Default Config Data and DRD. Update examples.
*****************************************************************************************************************************/

/* Comment this out to disable prints and save space */
#define DEBUG_WIFI_WEBSERVER_PORT Serial
#define WIFININA_DEBUG_OUTPUT Serial

#if !( defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560) )
#error This code is intended to run only on the Arduino Mega 1280/2560 boards ! Please check your Tools->Board setting.
#endif

#if defined(ARDUINO_AVR_MEGA2560)
#define BOARD_TYPE "AVR Mega2560"
#else
#define BOARD_TYPE "AVR Mega"
#endif

// Start location in EEPROM to store config data. Default 0
// Config data Size currently is 128 bytes)
#define EEPROM_START 0

#include <WiFiManager_NINA_Lite.h>

// Mega might have not enough memory to run dynamic params
#define USE_DYNAMIC_PARAMETERS false //true

/////////////// Start dynamic Credentials ///////////////

//Defined in <WiFiManager_NINA_Lite.h>
/**************************************
#define MAX_ID_LEN 5
#define MAX_DISPLAY_NAME_LEN 16
typedef struct
{
char id [MAX_ID_LEN + 1];
char displayName [MAX_DISPLAY_NAME_LEN + 1];
char *pdata;
uint8_t maxlen;
} MenuItem;
**************************************/

#if USE_DYNAMIC_PARAMETERS

#define MAX_BLYNK_SERVER_LEN 34
#define MAX_BLYNK_TOKEN_LEN 34

char Blynk_Server1 [MAX_BLYNK_SERVER_LEN + 1] = "";
char Blynk_Token1 [MAX_BLYNK_TOKEN_LEN + 1] = "";

char Blynk_Server2 [MAX_BLYNK_SERVER_LEN + 1] = "";
char Blynk_Token2 [MAX_BLYNK_TOKEN_LEN + 1] = "";

#define MAX_BLYNK_PORT_LEN 6
char Blynk_Port [MAX_BLYNK_PORT_LEN + 1] = "";

#define MAX_MQTT_SERVER_LEN 34
char MQTT_Server [MAX_MQTT_SERVER_LEN + 1] = "";

MenuItem myMenuItems [] =
{
{ "sv1", "Blynk Server1", Blynk_Server1, MAX_BLYNK_SERVER_LEN },
{ "tk1", "Token1", Blynk_Token1, MAX_BLYNK_TOKEN_LEN },
{ "sv2", "Blynk Server2", Blynk_Server2, MAX_BLYNK_SERVER_LEN },
{ "tk2", "Token2", Blynk_Token2, MAX_BLYNK_TOKEN_LEN },
{ "pt", "Port", Blynk_Port, MAX_BLYNK_PORT_LEN },
{ "mq", "MQTT Server", MQTT_Server, MAX_MQTT_SERVER_LEN },
};

uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize;

#else

MenuItem myMenuItems [] = {};

uint16_t NUM_MENU_ITEMS = 0;

#endif //USE_DYNAMIC_PARAMETERS
#include "defines.h"
#include "Credentials.h"
#include "dynamicParams.h"

void heartBeatPrint(void)
{
Expand Down Expand Up @@ -146,7 +74,7 @@ void setup()
//WiFiManager_NINA->setConfigPortalChannel(1);

// Set customized DHCP HostName
WiFiManager_NINA->begin("Mega-WiFiNINA-ABCDEF");
WiFiManager_NINA->begin(HOST_NAME);
//Or use default Hostname "Mega-WiFiNINA-XXXXXX"
//WiFiManager_NINA->begin();
}
Expand Down
52 changes: 52 additions & 0 deletions examples/Mega_WiFiNINA/defines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/****************************************************************************************************************************
defines.h for ESP32WM_Config.ino
For nRF52 boards using WiFiNINA modules/shields, using much less code to support boards with smaller memory
WiFiManager_NINA_WM_Lite is a library for the Mega, Teensy, SAM DUE, SAMD and STM32 boards
(https://github.com/khoih-prog/WiFiManager_NINA_Lite) to enable store Credentials in EEPROM/LittleFS for easy
configuration/reconfiguration and autoconnect/autoreconnect of WiFi and other services without Hardcoding.
Built by Khoi Hoang https://github.com/khoih-prog/WiFiManager_NINA_Lite
Licensed under MIT license
Version: 1.0.4
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 26/03/2020 Initial coding
1.0.1 K Hoang 27/03/2020 Fix SAMD soft-reset bug. Add support to remaining boards
1.0.2 K Hoang 15/04/2020 Fix bug. Add SAMD51 support.
1.0.3 K Hoang 24/04/2020 Fix bug. Add nRF5 (Adafruit, NINA_B302_ublox, etc.) support. Add MultiWiFi, HostName capability.
SSID password maxlen is 63 now. Permit special chars # and % in input data.
1.0.4 K Hoang 04/05/2020 Add Configurable Config Portal Title, Default Config Data and DRD. Update examples.
*****************************************************************************************************************************/

#ifndef defines_h
#define defines_h

/* Comment this out to disable prints and save space */
#define DEBUG_WIFI_WEBSERVER_PORT Serial
#define WIFININA_DEBUG_OUTPUT Serial

#define WIFININA_DEBUG false //true

#define DRD_GENERIC_DEBUG false //true

#if !( defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560) )
#error This code is intended to run only on the Arduino Mega 1280/2560 boards ! Please check your Tools->Board setting.
#endif

#if defined(ARDUINO_AVR_MEGA2560)
#define BOARD_TYPE "AVR Mega2560"
#else
#define BOARD_TYPE "AVR Mega"
#endif

// Start location in EEPROM to store config data. Default 0
// Config data Size currently is 128 bytes)
#define EEPROM_START 0

#include <WiFiManager_NINA_Lite.h>

#define HOST_NAME "AVR-Master-Controller"

#endif //defines_h
84 changes: 84 additions & 0 deletions examples/Mega_WiFiNINA/dynamicParams.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/****************************************************************************************************************************
dynamicParams.h
For nRF52 boards using WiFiNINA modules/shields, using much less code to support boards with smaller memory
WiFiManager_NINA_WM_Lite is a library for the Mega, Teensy, SAM DUE, SAMD and STM32 boards
(https://github.com/khoih-prog/WiFiManager_NINA_Lite) to enable store Credentials in EEPROM/LittleFS for easy
configuration/reconfiguration and autoconnect/autoreconnect of WiFi and other services without Hardcoding.
Built by Khoi Hoang https://github.com/khoih-prog/WiFiManager_NINA_Lite
Licensed under MIT license
Version: 1.0.4
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 26/03/2020 Initial coding
1.0.1 K Hoang 27/03/2020 Fix SAMD soft-reset bug. Add support to remaining boards
1.0.2 K Hoang 15/04/2020 Fix bug. Add SAMD51 support.
1.0.3 K Hoang 24/04/2020 Fix bug. Add nRF5 (Adafruit, NINA_B302_ublox, etc.) support. Add MultiWiFi, HostName capability.
SSID password maxlen is 63 now. Permit special chars # and % in input data.
1.0.4 K Hoang 04/05/2020 Add Configurable Config Portal Title, Default Config Data and DRD. Update examples.
*****************************************************************************************************************************/

#ifndef dynamicParams_h
#define dynamicParams_h

#include "defines.h"

#define USE_DYNAMIC_PARAMETERS true

/////////////// Start dynamic Credentials ///////////////

//Defined in <WiFiManager_NINA_Lite_NRF52840.h>
/**************************************
#define MAX_ID_LEN 5
#define MAX_DISPLAY_NAME_LEN 16
typedef struct
{
char id [MAX_ID_LEN + 1];
char displayName [MAX_DISPLAY_NAME_LEN + 1];
char *pdata;
uint8_t maxlen;
} MenuItem;
**************************************/

#if USE_DYNAMIC_PARAMETERS

#define MAX_BLYNK_SERVER_LEN 34
#define MAX_BLYNK_TOKEN_LEN 34

char Blynk_Server1 [MAX_BLYNK_SERVER_LEN + 1] = "account.duckdns.org";
char Blynk_Token1 [MAX_BLYNK_TOKEN_LEN + 1] = "token1";

char Blynk_Server2 [MAX_BLYNK_SERVER_LEN + 1] = "account.ddns.net";
char Blynk_Token2 [MAX_BLYNK_TOKEN_LEN + 1] = "token2";

#define MAX_BLYNK_PORT_LEN 6
char Blynk_Port [MAX_BLYNK_PORT_LEN + 1] = "8080";

#define MAX_MQTT_SERVER_LEN 34
char MQTT_Server [MAX_MQTT_SERVER_LEN + 1] = "mqtt.duckdns.org";

MenuItem myMenuItems [] =
{
{ "sv1", "Blynk Server1", Blynk_Server1, MAX_BLYNK_SERVER_LEN },
{ "tk1", "Token1", Blynk_Token1, MAX_BLYNK_TOKEN_LEN },
{ "sv2", "Blynk Server2", Blynk_Server2, MAX_BLYNK_SERVER_LEN },
{ "tk2", "Token2", Blynk_Token2, MAX_BLYNK_TOKEN_LEN },
{ "pt", "Port", Blynk_Port, MAX_BLYNK_PORT_LEN },
{ "mq", "MQTT Server", MQTT_Server, MAX_MQTT_SERVER_LEN },
};

uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize;

#else

MenuItem myMenuItems [] = {};

uint16_t NUM_MENU_ITEMS = 0;

#endif //USE_DYNAMIC_PARAMETERS


#endif //dynamicParams_h
Loading

0 comments on commit 66415c8

Please sign in to comment.