decrease nuki polling interval for testing
This commit is contained in:
25
Network.cpp
25
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);
|
||||
|
||||
6
Nuki.cpp
6
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
6
main.cpp
6
main.cpp
@@ -2,7 +2,7 @@
|
||||
#include "Network.h"
|
||||
#include "Nuki.h"
|
||||
#include <FreeRTOS.h>
|
||||
|
||||
//#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()
|
||||
|
||||
Reference in New Issue
Block a user