configuration also in production mode, sensing after reconnect handling
This commit is contained in:
parent
ef210ab477
commit
88736f288b
@ -184,10 +184,10 @@ environment/project/io.sloeber.core.toolChain.release.547546691/A.EXTRA.TIME.DTS
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/A.EXTRA.TIME.DTS/value=0
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/A.EXTRA.TIME.LOCAL/delimiter=\:
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/A.EXTRA.TIME.LOCAL/operation=replace
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/A.EXTRA.TIME.LOCAL/value=1517307730
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/A.EXTRA.TIME.LOCAL/value=1517501856
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/A.EXTRA.TIME.UTC/delimiter=\:
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/A.EXTRA.TIME.UTC/operation=replace
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/A.EXTRA.TIME.UTC/value=1517304130
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/A.EXTRA.TIME.UTC/value=1517498256
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/A.EXTRA.TIME.ZONE/delimiter=\:
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/A.EXTRA.TIME.ZONE/operation=replace
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/A.EXTRA.TIME.ZONE/value=3600
|
||||
@ -466,10 +466,10 @@ environment/project/io.sloeber.core.toolChain.release.547546691/JANTJE.BOARD_NAM
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/JANTJE.BOARD_NAME/value=NodeMCU 1.0 (ESP-12E Module)
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/JANTJE.COM_PORT/delimiter=\:
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/JANTJE.COM_PORT/operation=replace
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/JANTJE.COM_PORT/value=/dev/ttyUSB0
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/JANTJE.COM_PORT/value=/dev/ttyUSB1
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/JANTJE.ECLIPSE_LOCATION/delimiter=\:
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/JANTJE.ECLIPSE_LOCATION/operation=replace
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/JANTJE.ECLIPSE_LOCATION/value=${eclipse_home}/////////////////////////////////////
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/JANTJE.ECLIPSE_LOCATION/value=${eclipse_home}//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/JANTJE.EXTRA.ALL/delimiter=\:
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/JANTJE.EXTRA.ALL/operation=replace
|
||||
environment/project/io.sloeber.core.toolChain.release.547546691/JANTJE.EXTRA.ALL/value=
|
||||
|
@ -125,8 +125,9 @@ void showConfiguration() {
|
||||
Serial.println("Configuration is");
|
||||
|
||||
#for $configItem in $configItems
|
||||
Serial.print("$configItem.key = ");
|
||||
Serial.println(configBlock.$configItem.key);
|
||||
Serial.print("$configItem.key = <");
|
||||
Serial.print(configBlock.$configItem.key);
|
||||
Serial.println(">");
|
||||
|
||||
#end for
|
||||
|
||||
|
@ -44,7 +44,8 @@ void setup() {
|
||||
Serial.println("Configuration mode");
|
||||
#endif
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
setupConfiguration();
|
||||
setupConfigurationNetwork();
|
||||
setupConfigurationServer();
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
Serial.println("Production mode");
|
||||
@ -55,6 +56,7 @@ void setup() {
|
||||
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
setupProduction();
|
||||
setupConfigurationServer();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@ -66,6 +68,7 @@ void loop() {
|
||||
if (configMode) {
|
||||
loopConfiguration();
|
||||
} else {
|
||||
loopConfiguration();
|
||||
loopProduction();
|
||||
}
|
||||
}
|
||||
|
@ -325,50 +325,65 @@ void configServeGetConfiguration() {
|
||||
void showConfiguration() {
|
||||
Serial.println("Configuration is");
|
||||
|
||||
Serial.print("magic = ");
|
||||
Serial.println(configBlock.magic);
|
||||
Serial.print("magic = <");
|
||||
Serial.print(configBlock.magic);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("wifiSsid = ");
|
||||
Serial.println(configBlock.wifiSsid);
|
||||
Serial.print("wifiSsid = <");
|
||||
Serial.print(configBlock.wifiSsid);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("wifiKey = ");
|
||||
Serial.println(configBlock.wifiKey);
|
||||
Serial.print("wifiKey = <");
|
||||
Serial.print(configBlock.wifiKey);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttBroker = ");
|
||||
Serial.println(configBlock.mqttBroker);
|
||||
Serial.print("mqttBroker = <");
|
||||
Serial.print(configBlock.mqttBroker);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttUser = ");
|
||||
Serial.println(configBlock.mqttUser);
|
||||
Serial.print("mqttUser = <");
|
||||
Serial.print(configBlock.mqttUser);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttPass = ");
|
||||
Serial.println(configBlock.mqttPass);
|
||||
Serial.print("mqttPass = <");
|
||||
Serial.print(configBlock.mqttPass);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttClientId = ");
|
||||
Serial.println(configBlock.mqttClientId);
|
||||
Serial.print("mqttClientId = <");
|
||||
Serial.print(configBlock.mqttClientId);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttPort = ");
|
||||
Serial.println(configBlock.mqttPort);
|
||||
Serial.print("mqttPort = <");
|
||||
Serial.print(configBlock.mqttPort);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttTopic = ");
|
||||
Serial.println(configBlock.mqttTopic);
|
||||
Serial.print("mqttTopic = <");
|
||||
Serial.print(configBlock.mqttTopic);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttDebugTopic = ");
|
||||
Serial.println(configBlock.mqttDebugTopic);
|
||||
Serial.print("mqttDebugTopic = <");
|
||||
Serial.print(configBlock.mqttDebugTopic);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("mqttBaselineTopic = ");
|
||||
Serial.println(configBlock.mqttBaselineTopic);
|
||||
Serial.print("mqttBaselineTopic = <");
|
||||
Serial.print(configBlock.mqttBaselineTopic);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("debugMode = ");
|
||||
Serial.println(configBlock.debugMode);
|
||||
Serial.print("debugMode = <");
|
||||
Serial.print(configBlock.debugMode);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("period = ");
|
||||
Serial.println(configBlock.period);
|
||||
Serial.print("period = <");
|
||||
Serial.print(configBlock.period);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("calibrationTimeout = ");
|
||||
Serial.println(configBlock.calibrationTimeout);
|
||||
Serial.print("calibrationTimeout = <");
|
||||
Serial.print(configBlock.calibrationTimeout);
|
||||
Serial.println(">");
|
||||
|
||||
Serial.print("threshold = ");
|
||||
Serial.println(configBlock.threshold);
|
||||
Serial.print("threshold = <");
|
||||
Serial.print(configBlock.threshold);
|
||||
Serial.println(">");
|
||||
|
||||
|
||||
Serial.println("---");
|
||||
|
@ -33,13 +33,15 @@ void configServeNotFound() {
|
||||
|
||||
|
||||
|
||||
void setupConfiguration() {
|
||||
void setupConfigurationNetwork() {
|
||||
WiFi.mode(WIFI_AP);
|
||||
WiFi.softAP(CONFIG_SSID);
|
||||
#ifdef DEBUG
|
||||
Serial.println("AP started");
|
||||
#endif
|
||||
}
|
||||
|
||||
void setupConfigurationServer() {
|
||||
webServer.on("/", configServeIndex);
|
||||
webServer.on("/config", configServeGetConfiguration);
|
||||
webServer.onNotFound(configServeNotFound);
|
||||
|
@ -10,7 +10,8 @@
|
||||
|
||||
|
||||
|
||||
void setupConfiguration();
|
||||
void setupConfigurationNetwork();
|
||||
void setupConfigurationServer();
|
||||
void loopConfiguration();
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#ifndef DEFINES_H_
|
||||
#define DEFINES_H_
|
||||
|
||||
//#define DEBUG
|
||||
#define DEBUG
|
||||
|
||||
#define EEPROM_ADDR 0
|
||||
|
||||
@ -17,9 +17,14 @@
|
||||
|
||||
// These both pins are connected via a 470k resistor.
|
||||
// The insulated touchpad is connected to pin TOUCH_PIN_RECEIVE.
|
||||
#if 1
|
||||
#define TOUCH_PIN_RECEIVE 16
|
||||
#define TOUCH_PIN_SEND 5
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
#define TOUCH_PIN_RECEIVE 0
|
||||
#define TOUCH_PIN_SEND 2
|
||||
#endif
|
||||
|
||||
#endif /* DEFINES_H_ */
|
||||
|
@ -105,6 +105,10 @@ void setupProduction() {
|
||||
|
||||
void loopProduction() {
|
||||
bool reconnected = mqtt_connect();
|
||||
static uint32_t reconnectTime = 0;
|
||||
if (reconnected) {
|
||||
reconnectTime = millis();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -137,7 +141,7 @@ void loopProduction() {
|
||||
uint32_t currentMillis = millis();
|
||||
|
||||
|
||||
if ((currentMillis - lastMillis > configBlock.period) && (! reconnected)) {
|
||||
if ((currentMillis - lastMillis > configBlock.period) && (currentMillis - reconnectTime > 1000)) {
|
||||
lastMillis = currentMillis;
|
||||
|
||||
uint32_t chargeCntAvg = chargeCntSum / senseCnt;
|
||||
|
Loading…
x
Reference in New Issue
Block a user