Config EEPROM size like other configs
This commit is contained in:
parent
efe135a801
commit
cdfafd2d45
@ -10,12 +10,12 @@ int EepromSaveConfig(uint8_t bootMode, String ssid, String password, String host
|
|||||||
|
|
||||||
eeprom = String(bootMode) + ";" + ssid + ";" + password + ";" + host + ";" + mqttServer + ";" + mqttUser + ";" + mqttPasswd + ";" + String(mqttPort) + ";";
|
eeprom = String(bootMode) + ";" + ssid + ";" + password + ";" + host + ";" + mqttServer + ";" + mqttUser + ";" + mqttPasswd + ";" + String(mqttPort) + ";";
|
||||||
|
|
||||||
if (eeprom.length() > EEPROM_SIZE )
|
if (eeprom.length() > CONFIG_EEPROM_SIZE )
|
||||||
return -EMSGSIZE;
|
return -EMSGSIZE;
|
||||||
|
|
||||||
SKETCH_DEBUG_PRINTLN("Saving " + eeprom);
|
SKETCH_DEBUG_PRINTLN("Saving " + eeprom);
|
||||||
|
|
||||||
for (int i = 0; i < eeprom.length() && i < EEPROM_SIZE; i++) {
|
for (int i = 0; i < eeprom.length() && i < CONFIG_EEPROM_SIZE; i++) {
|
||||||
EEPROM.write(i, eeprom.charAt(i));
|
EEPROM.write(i, eeprom.charAt(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,10 +37,10 @@ void readConfElement(char** element, int &i) {
|
|||||||
do {
|
do {
|
||||||
eeprom[i] = EEPROM.read(i);
|
eeprom[i] = EEPROM.read(i);
|
||||||
i++;
|
i++;
|
||||||
} while (i < EEPROM_SIZE && eeprom[i - 1] != ';');
|
} while (i < CONFIG_EEPROM_SIZE && eeprom[i - 1] != ';');
|
||||||
eeprom[i - 1] = '\0';
|
eeprom[i - 1] = '\0';
|
||||||
|
|
||||||
if (i >= EEPROM_SIZE)
|
if (i >= CONFIG_EEPROM_SIZE)
|
||||||
**element = '\0';
|
**element = '\0';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,8 @@
|
|||||||
#include "Adafruit_MQTT.h"
|
#include "Adafruit_MQTT.h"
|
||||||
#include "Adafruit_MQTT_Client.h"
|
#include "Adafruit_MQTT_Client.h"
|
||||||
|
|
||||||
#define EEPROM_SIZE 256
|
#define CONFIG_EEPROM_SIZE 256
|
||||||
char eeprom[EEPROM_SIZE];
|
char eeprom[CONFIG_EEPROM_SIZE];
|
||||||
|
|
||||||
#define BOOTMODE_SETUP 0
|
#define BOOTMODE_SETUP 0
|
||||||
#define BOOTMODE_NORMAL 1
|
#define BOOTMODE_NORMAL 1
|
||||||
@ -174,7 +174,7 @@ void setup() {
|
|||||||
Serial.swap(); // Switch back on GPIO 1 & 3
|
Serial.swap(); // Switch back on GPIO 1 & 3
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EEPROM.begin(EEPROM_SIZE);
|
EEPROM.begin(CONFIG_EEPROM_SIZE);
|
||||||
EepromReadConfig(mode, &confSsid, &confPassword, &confHost, &mqttServer, &mqttUser, &mqttPasswd, mqttPort);
|
EepromReadConfig(mode, &confSsid, &confPassword, &confHost, &mqttServer, &mqttUser, &mqttPasswd, mqttPort);
|
||||||
|
|
||||||
hostName = confHost;
|
hostName = confHost;
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
/* DO NOT CHANGE THIS FILE */
|
/* DO NOT CHANGE THIS FILE */
|
||||||
/* Contains values that SHOULD be defined to have the sketch working */
|
/* Contains values that SHOULD be defined to have the sketch working */
|
||||||
/* Modify value in config_device.h */
|
/* Modify value in config_device.h instead */
|
||||||
|
|
||||||
#ifndef CONFIG_WEB_DELAY_MS
|
#ifndef CONFIG_WEB_DELAY_MS
|
||||||
#define CONFIG_WEB_DELAY_MS 100
|
#define CONFIG_WEB_DELAY_MS 100
|
||||||
@ -27,3 +27,5 @@
|
|||||||
#define CONFIG_MQTT_CONTROLLED_GPIO {2, 13}
|
#define CONFIG_MQTT_CONTROLLED_GPIO {2, 13}
|
||||||
|
|
||||||
#define CONFIG_WEB_CONTROLLED_GPIO 2
|
#define CONFIG_WEB_CONTROLLED_GPIO 2
|
||||||
|
|
||||||
|
#define CONFIG_EEPROM_SIZE 256
|
||||||
|
@ -26,3 +26,7 @@
|
|||||||
// GPIO that can be set or get by mqtt
|
// GPIO that can be set or get by mqtt
|
||||||
// Should have less value than MAXSUBSCRIPTIONS
|
// Should have less value than MAXSUBSCRIPTIONS
|
||||||
//#define CONFIG_MQTT_CONTROLLED_GPIO {2, 13}
|
//#define CONFIG_MQTT_CONTROLLED_GPIO {2, 13}
|
||||||
|
|
||||||
|
|
||||||
|
// EEPROM SIZE
|
||||||
|
//#CONFIG_EEPROM_SIZE 256
|
||||||
|
Loading…
Reference in New Issue
Block a user