Stability fixes

This commit is contained in:
iranl
2024-04-14 21:54:06 +02:00
parent 8f8666cc75
commit 50b23f2ab2
7 changed files with 22 additions and 82 deletions

View File

@@ -1,6 +1,6 @@
#pragma once
#define NUKI_HUB_VERSION "8.34-pre-2"
#define NUKI_HUB_VERSION "8.34-pre-3"
#define GITHUB_LATEST_RELEASE_URL "https://github.com/technyon/nuki_hub/releases/latest"
#define GITHUB_LATEST_RELEASE_API_URL "https://api.github.com/repos/technyon/nuki_hub/releases/latest"

View File

@@ -592,7 +592,7 @@ void Network::registerMqttReceiver(MqttReceiver* receiver)
void Network::onMqttDataReceivedCallback(const espMqttClientTypes::MessageProperties& properties, const char* topic, const uint8_t* payload, size_t len, size_t index, size_t total)
{
uint8_t value[800] = {0};
uint8_t value[360] = {0};
size_t l = min(len, sizeof(value)-1);
for(int i=0; i<l; i++)

View File

@@ -190,13 +190,12 @@ void NetworkLock::onMqttDataReceived(const char* topic, byte* payload, const uns
if(comparePrefixedPath(topic, mqtt_topic_config_action))
{
if(strcmp(value, "") == 0 || strcmp(value, "--") == 0) return;
Log->print(F("Config action received: "));
Log->println(value);
if(_configUpdateReceivedCallback != NULL)
{
_configUpdateReceivedCallback(value);
}
publishString(mqtt_topic_config_action, "--");
}
@@ -480,7 +479,7 @@ void NetworkLock::publishConfig(const NukiLock::Config &config)
json["name"] = config.name;
//json["latitude"] = config.latitude;
//json["longitude"] = config.longitude;
json["autoUnlatch"] = config.autoUnlatch;
json["autoUnlatch"] = config.autoUnlatch;
json["pairingEnabled"] = config.pairingEnabled;
json["buttonEnabled"] = config.buttonEnabled;
json["ledEnabled"] = config.ledEnabled;

View File

@@ -182,8 +182,7 @@ void NetworkOpener::onMqttDataReceived(const char* topic, byte* payload, const u
if(comparePrefixedPath(topic, mqtt_topic_config_action))
{
if(strcmp(value, "") == 0 || strcmp(value, "--") == 0) return;
Log->print(F("Config action received: "));
Log->println(value);
if(_configUpdateReceivedCallback != NULL)
{
_configUpdateReceivedCallback(value);

View File

@@ -692,7 +692,7 @@ void NukiOpenerWrapper::onConfigUpdateReceived(const char *value)
jsonResult["general"] = "noPinSet";
serializeJson(jsonResult, _resbuf, sizeof(_resbuf));
_network->publishConfigCommandResult(_resbuf);
return;
return;
}
DynamicJsonDocument json(2048);
@@ -706,21 +706,6 @@ void NukiOpenerWrapper::onConfigUpdateReceived(const char *value)
return;
}
updateConfig();
while ((!_nukiConfigValid || !_nukiAdvancedConfigValid) && _retryConfigCount < 11)
{
updateConfig();
}
if(!_nukiConfigValid || !_nukiAdvancedConfigValid)
{
jsonResult["general"] = "invalidConfig";
serializeJson(jsonResult, _resbuf, sizeof(_resbuf));
_network->publishConfigCommandResult(_resbuf);
return;
}
Nuki::CmdResult cmdResult;
const char *basicKeys[] = {"name", "latitude", "longitude", "pairingEnabled", "buttonEnabled", "ledFlashEnabled", "timeZoneOffset", "dstMode", "fobAction1", "fobAction2", "fobAction3", "operatingMode", "advertisingMode", "timeZone"};
const char *advancedKeys[] = {"intercomID", "busModeSwitch", "shortCircuitDuration", "electricStrikeDelay", "randomElectricStrikeDelay", "electricStrikeDuration", "disableRtoAfterRing", "rtoTimeout", "doorbellSuppression", "doorbellSuppressionDuration", "soundRing", "soundOpen", "soundRto", "soundCm", "soundConfirmation", "soundLevel", "singleButtonPressAction", "doubleButtonPressAction", "batteryType", "automaticBatteryTypeDetection"};
@@ -737,9 +722,9 @@ void NukiOpenerWrapper::onConfigUpdateReceived(const char *value)
for(int i=0; i < 16; i++)
{
if(json[basicKeys[i]])
{
{
const char *jsonchar = json[basicKeys[i]].as<const char*>();
if((int)basicOpenerConfigAclPrefs[i] == 1)
{
cmdResult = Nuki::CmdResult::Error;
@@ -914,7 +899,7 @@ void NukiOpenerWrapper::onConfigUpdateReceived(const char *value)
if(json[advancedKeys[i]])
{
const char *jsonchar = json[advancedKeys[i]].as<const char*>();
if((int)advancedOpenerConfigAclPrefs[i] == 1)
{
cmdResult = Nuki::CmdResult::Error;
@@ -1341,24 +1326,10 @@ void NukiOpenerWrapper::onKeypadJsonCommandReceived(const char *value)
_network->publishKeypadJsonCommandResult("keypadNotAvailable");
return;
}
updateConfig();
while (!_nukiConfigValid && _retryConfigCount < 11)
{
updateConfig();
}
if(_configRead && _nukiConfigValid)
{
_network->publishKeypadJsonCommandResult("keypadNotAvailable");
return;
}
_network->publishKeypadJsonCommandResult("invalidConfig");
_network->publishKeypadJsonCommandResult("configNotReady");
return;
}
if(!_keypadEnabled)
{
_network->publishKeypadJsonCommandResult("keypadDisabled");
@@ -1534,7 +1505,7 @@ void NukiOpenerWrapper::onKeypadJsonCommandReceived(const char *value)
return;
}
}
if(allowedWeekdays.indexOf("mon") >= 0) allowedWeekdaysInt += 64;
if(allowedWeekdays.indexOf("tue") >= 0) allowedWeekdaysInt += 32;
if(allowedWeekdays.indexOf("wed") >= 0) allowedWeekdaysInt += 16;
@@ -1543,7 +1514,7 @@ void NukiOpenerWrapper::onKeypadJsonCommandReceived(const char *value)
if(allowedWeekdays.indexOf("sat") >= 0) allowedWeekdaysInt += 2;
if(allowedWeekdays.indexOf("sun") >= 0) allowedWeekdaysInt += 1;
}
if(strcmp(action, "add") == 0)
{
NukiOpener::NewKeypadEntry entry;

View File

@@ -629,7 +629,7 @@ void NukiWrapper::onConfigUpdateReceived(const char *value)
jsonResult["general"] = "noPinSet";
serializeJson(jsonResult, _resbuf, sizeof(_resbuf));
_network->publishConfigCommandResult(_resbuf);
return;
return;
}
DynamicJsonDocument json(2048);
@@ -643,21 +643,6 @@ void NukiWrapper::onConfigUpdateReceived(const char *value)
return;
}
updateConfig();
while ((!_nukiConfigValid || !_nukiAdvancedConfigValid) && _retryConfigCount < 11)
{
updateConfig();
}
if(!_nukiConfigValid || !_nukiAdvancedConfigValid)
{
jsonResult["general"] = "invalidConfig";
serializeJson(jsonResult, _resbuf, sizeof(_resbuf));
_network->publishConfigCommandResult(_resbuf);
return;
}
Nuki::CmdResult cmdResult;
const char *basicKeys[] = {"name", "latitude", "longitude", "autoUnlatch", "pairingEnabled", "buttonEnabled", "ledEnabled", "ledBrightness", "timeZoneOffset", "dstMode", "fobAction1", "fobAction2", "fobAction3", "singleLock", "advertisingMode", "timeZone"};
const char *advancedKeys[] = {"unlockedPositionOffsetDegrees", "lockedPositionOffsetDegrees", "singleLockedPositionOffsetDegrees", "unlockedToLockedTransitionOffsetDegrees", "lockNgoTimeout", "singleButtonPressAction", "doubleButtonPressAction", "detachedCylinder", "batteryType", "automaticBatteryTypeDetection", "unlatchDuration", "autoLockTimeOut", "autoUnLockDisabled", "nightModeEnabled", "nightModeStartTime", "nightModeEndTime", "nightModeAutoLockEnabled", "nightModeAutoUnlockDisabled", "nightModeImmediateLockOnStart", "autoLockEnabled", "immediateAutoLockEnabled", "autoUpdateEnabled"};
@@ -676,7 +661,7 @@ void NukiWrapper::onConfigUpdateReceived(const char *value)
if(json[basicKeys[i]])
{
const char *jsonchar = json[basicKeys[i]].as<const char*>();
if((int)basicLockConfigAclPrefs[i] == 1)
{
cmdResult = Nuki::CmdResult::Error;
@@ -873,7 +858,7 @@ void NukiWrapper::onConfigUpdateReceived(const char *value)
if(json[advancedKeys[i]])
{
const char *jsonchar = json[advancedKeys[i]].as<const char*>();
if((int)advancedLockConfigAclPrefs[i] == 1)
{
cmdResult = Nuki::CmdResult::Error;
@@ -1056,7 +1041,7 @@ void NukiWrapper::onConfigUpdateReceived(const char *value)
if(_nukiAdvancedConfig.nightModeEndTime == keyvalue) jsonResult[advancedKeys[i]] = "unchanged";
else cmdResult = _nukiLock.setNightModeEndTime(keyvalue);
}
else jsonResult[advancedKeys[i]] = "invalidValue";
else jsonResult[advancedKeys[i]] = "invalidValue";
}
else if(strcmp(advancedKeys[i], "nightModeAutoLockEnabled") == 0)
{
@@ -1140,7 +1125,7 @@ void NukiWrapper::onConfigUpdateReceived(const char *value)
nukiLockPreferences->end();
if(basicUpdated || advancedUpdated)
{
{
jsonResult["general"] = "success";
}
else jsonResult["general"] = "noChange";
@@ -1323,21 +1308,7 @@ void NukiWrapper::onKeypadJsonCommandReceived(const char *value)
_network->publishKeypadJsonCommandResult("keypadNotAvailable");
return;
}
updateConfig();
while (!_nukiConfigValid && _retryConfigCount < 11)
{
updateConfig();
}
if(_configRead && _nukiConfigValid)
{
_network->publishKeypadJsonCommandResult("keypadNotAvailable");
return;
}
_network->publishKeypadJsonCommandResult("invalidConfig");
_network->publishKeypadJsonCommandResult("configNotReady");
return;
}

View File

@@ -112,8 +112,8 @@ void setupTasks()
{
// configMAX_PRIORITIES is 25
xTaskCreatePinnedToCore(networkTask, "ntw", 8192, NULL, 3, &networkTaskHandle, 1);
xTaskCreatePinnedToCore(nukiTask, "nuki", 3328, NULL, 2, &nukiTaskHandle, 1);
xTaskCreatePinnedToCore(networkTask, "ntw", 10240, NULL, 3, &networkTaskHandle, 1);
xTaskCreatePinnedToCore(nukiTask, "nuki", 5120, NULL, 2, &nukiTaskHandle, 1);
xTaskCreatePinnedToCore(presenceDetectionTask, "prdet", 896, NULL, 5, &presenceDetectionTaskHandle, 1);
}