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()
|
bool Network::reconnect()
|
||||||
{
|
{
|
||||||
while (!_mqttClient.connected()) {
|
while (!_mqttClient.connected()) {
|
||||||
Serial.print("Attempting MQTT connection...");
|
Serial.println("Attempting MQTT connection");
|
||||||
// Attempt to connect
|
// Attempt to connect
|
||||||
if (_mqttClient.connect("arduinoClient")) {
|
if (_mqttClient.connect("arduinoClient")) {
|
||||||
Serial.println("connected");
|
Serial.println("MQTT connected");
|
||||||
|
|
||||||
// ... and resubscribe
|
// ... and resubscribe
|
||||||
_mqttClient.subscribe(mqtt_topc_lockstate_action);
|
_mqttClient.subscribe(mqtt_topc_lockstate_action);
|
||||||
} else {
|
} else {
|
||||||
Serial.print("failed, rc=");
|
Serial.print("MQTT connect failed, rc=");
|
||||||
Serial.print(_mqttClient.state());
|
Serial.println(_mqttClient.state());
|
||||||
Serial.println(" try again in 5 seconds");
|
|
||||||
// Wait 5 seconds before retrying
|
|
||||||
delay(5000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,23 +76,11 @@ void Network::update()
|
|||||||
bool success = reconnect();
|
bool success = reconnect();
|
||||||
if(!success)
|
if(!success)
|
||||||
{
|
{
|
||||||
|
vTaskDelay( 5000 / portTICK_PERIOD_MS);
|
||||||
return;
|
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();
|
_mqttClient.loop();
|
||||||
|
|
||||||
vTaskDelay( 100 / portTICK_PERIOD_MS);
|
vTaskDelay( 100 / portTICK_PERIOD_MS);
|
||||||
|
|||||||
6
Nuki.cpp
6
Nuki.cpp
@@ -44,19 +44,19 @@ void Nuki::update()
|
|||||||
|
|
||||||
if(_nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs)
|
if(_nextLockStateUpdateTs == 0 || ts >= _nextLockStateUpdateTs)
|
||||||
{
|
{
|
||||||
_nextLockStateUpdateTs = ts + 60000;
|
_nextLockStateUpdateTs = ts + 5000;
|
||||||
updateKeyTurnerState();
|
updateKeyTurnerState();
|
||||||
}
|
}
|
||||||
if(_nextBatteryReportTs == 0 || ts > _nextBatteryReportTs)
|
if(_nextBatteryReportTs == 0 || ts > _nextBatteryReportTs)
|
||||||
{
|
{
|
||||||
_nextBatteryReportTs = ts + 60000 * 30;
|
_nextBatteryReportTs = ts + 60000 * 5;
|
||||||
updateBatteryState();
|
updateBatteryState();
|
||||||
}
|
}
|
||||||
if(_nextLockAction != (LockAction)0xff)
|
if(_nextLockAction != (LockAction)0xff)
|
||||||
{
|
{
|
||||||
_nukiBle.lockAction(_nextLockAction, 0, 0);
|
_nukiBle.lockAction(_nextLockAction, 0, 0);
|
||||||
_nextLockAction = (LockAction)0xff;
|
_nextLockAction = (LockAction)0xff;
|
||||||
_nextLockStateUpdateTs = ts + 11000;
|
// _nextLockStateUpdateTs = ts + 11000;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
main.cpp
6
main.cpp
@@ -2,7 +2,7 @@
|
|||||||
#include "Network.h"
|
#include "Network.h"
|
||||||
#include "Nuki.h"
|
#include "Nuki.h"
|
||||||
#include <FreeRTOS.h>
|
#include <FreeRTOS.h>
|
||||||
|
//#include "garbage.h"
|
||||||
|
|
||||||
#define ESP32
|
#define ESP32
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ void nukiTask(void *pvParameters)
|
|||||||
void setupTasks()
|
void setupTasks()
|
||||||
{
|
{
|
||||||
xTaskCreate(networkTask, "ntw", 2048, NULL, 1, NULL);
|
xTaskCreate(networkTask, "ntw", 2048, NULL, 1, NULL);
|
||||||
xTaskCreate(nukiTask, "nuki", 4096, NULL, 1, NULL);
|
xTaskCreate(nukiTask, "nuki", 16384, NULL, 1, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
@@ -39,6 +39,8 @@ void setup()
|
|||||||
network->initialize();
|
network->initialize();
|
||||||
nuki->initialize();
|
nuki->initialize();
|
||||||
setupTasks();
|
setupTasks();
|
||||||
|
|
||||||
|
// Serial.println(byte_array_dec[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
|
|||||||
Reference in New Issue
Block a user