diff --git a/Network.cpp b/Network.cpp index d2c095f..aeb9328 100644 --- a/Network.cpp +++ b/Network.cpp @@ -48,19 +48,16 @@ void Network::initialize() bool Network::reconnect() { while (!_mqttClient.connected()) { - Serial.print("Attempting MQTT connection..."); + Serial.println("Attempting MQTT connection"); // Attempt to connect if (_mqttClient.connect("arduinoClient")) { - Serial.println("connected"); + Serial.println("MQTT connected"); // ... and resubscribe _mqttClient.subscribe(mqtt_topc_lockstate_action); } else { - Serial.print("failed, rc="); - Serial.print(_mqttClient.state()); - Serial.println(" try again in 5 seconds"); - // Wait 5 seconds before retrying - delay(5000); + Serial.print("MQTT connect failed, rc="); + Serial.println(_mqttClient.state()); } } } @@ -79,23 +76,11 @@ void Network::update() bool success = reconnect(); if(!success) { + vTaskDelay( 5000 / portTICK_PERIOD_MS); return; } } -// unsigned long ts = millis(); -// if(_publishTs < ts) -// { -// _publishTs = ts + 1000; -// -// ++_count; -// -// char cstr[16]; -// itoa(_count, cstr, 10); -// -// _mqttClient.publish("nuki/counter", cstr); -// } - _mqttClient.loop(); vTaskDelay( 100 / portTICK_PERIOD_MS); diff --git a/Nuki.cpp b/Nuki.cpp index 5dd8ec7..46bcbda 100644 --- a/Nuki.cpp +++ b/Nuki.cpp @@ -44,19 +44,19 @@ void Nuki::update() if(_nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs) { - _nextLockStateUpdateTs = ts + 60000; + _nextLockStateUpdateTs = ts + 5000; updateKeyTurnerState(); } if(_nextBatteryReportTs == 0 || ts > _nextBatteryReportTs) { - _nextBatteryReportTs = ts + 60000 * 30; + _nextBatteryReportTs = ts + 60000 * 5; updateBatteryState(); } if(_nextLockAction != (LockAction)0xff) { _nukiBle.lockAction(_nextLockAction, 0, 0); _nextLockAction = (LockAction)0xff; - _nextLockStateUpdateTs = ts + 11000; +// _nextLockStateUpdateTs = ts + 11000; } } diff --git a/main.cpp b/main.cpp index 65df324..f1bf931 100644 --- a/main.cpp +++ b/main.cpp @@ -2,7 +2,7 @@ #include "Network.h" #include "Nuki.h" #include - +//#include "garbage.h" #define ESP32 @@ -28,7 +28,7 @@ void nukiTask(void *pvParameters) void setupTasks() { xTaskCreate(networkTask, "ntw", 2048, NULL, 1, NULL); - xTaskCreate(nukiTask, "nuki", 4096, NULL, 1, NULL); + xTaskCreate(nukiTask, "nuki", 16384, NULL, 1, NULL); } void setup() @@ -39,6 +39,8 @@ void setup() network->initialize(); nuki->initialize(); setupTasks(); + +// Serial.println(byte_array_dec[0]); } void loop()