Fix crash on valid JSON
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#define NUKI_HUB_VERSION "9.02"
|
#define NUKI_HUB_VERSION "9.02"
|
||||||
#define NUKI_HUB_BUILD "unknownbuildnr"
|
#define NUKI_HUB_BUILD "unknownbuildnr"
|
||||||
#define NUKI_HUB_DATE "2024-11-15"
|
#define NUKI_HUB_DATE "2024-11-18"
|
||||||
|
|
||||||
#define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest"
|
#define GITHUB_LATEST_RELEASE_URL (char*)"https://github.com/technyon/nuki_hub/releases/latest"
|
||||||
#define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"
|
#define GITHUB_OTA_MANIFEST_URL (char*)"https://raw.githubusercontent.com/technyon/nuki_hub/binary/ota/manifest.json"
|
||||||
|
|||||||
@@ -1521,9 +1521,30 @@ void NukiOpenerWrapper::onConfigUpdateReceived(const char *value)
|
|||||||
|
|
||||||
for(int i=0; i < 14; i++)
|
for(int i=0; i < 14; i++)
|
||||||
{
|
{
|
||||||
if(json[basicKeys[i]])
|
if(json[basicKeys[i]].is<JsonVariantConst>())
|
||||||
{
|
{
|
||||||
const char *jsonchar = json[basicKeys[i]].as<const char*>();
|
JsonVariantConst jsonKey = json[basicKeys[i]];
|
||||||
|
char *jsonchar;
|
||||||
|
|
||||||
|
if (jsonKey.is<float>())
|
||||||
|
{
|
||||||
|
itoa(jsonKey, jsonchar, 10);
|
||||||
|
}
|
||||||
|
else if (jsonKey.is<bool>())
|
||||||
|
{
|
||||||
|
if (jsonKey)
|
||||||
|
{
|
||||||
|
itoa(1, jsonchar, 10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itoa(0, jsonchar, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (jsonKey.is<const char*>())
|
||||||
|
{
|
||||||
|
jsonchar = (char*)jsonKey.as<const char*>();
|
||||||
|
}
|
||||||
|
|
||||||
if(strlen(jsonchar) == 0)
|
if(strlen(jsonchar) == 0)
|
||||||
{
|
{
|
||||||
@@ -1848,9 +1869,30 @@ void NukiOpenerWrapper::onConfigUpdateReceived(const char *value)
|
|||||||
|
|
||||||
for(int j=0; j < 21; j++)
|
for(int j=0; j < 21; j++)
|
||||||
{
|
{
|
||||||
if(json[advancedKeys[j]])
|
if(json[advancedKeys[j]].is<JsonVariantConst>())
|
||||||
{
|
{
|
||||||
const char *jsonchar = json[advancedKeys[j]].as<const char*>();
|
JsonVariantConst jsonKey = json[advancedKeys[i]];
|
||||||
|
char *jsonchar;
|
||||||
|
|
||||||
|
if (jsonKey.is<float>())
|
||||||
|
{
|
||||||
|
itoa(jsonKey, jsonchar, 10);
|
||||||
|
}
|
||||||
|
else if (jsonKey.is<bool>())
|
||||||
|
{
|
||||||
|
if (jsonKey)
|
||||||
|
{
|
||||||
|
itoa(1, jsonchar, 10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itoa(0, jsonchar, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (jsonKey.is<const char*>())
|
||||||
|
{
|
||||||
|
jsonchar = (char*)jsonKey.as<const char*>();
|
||||||
|
}
|
||||||
|
|
||||||
if(strlen(jsonchar) == 0)
|
if(strlen(jsonchar) == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1421,6 +1421,10 @@ void NukiWrapper::onConfigUpdateReceived(const char *value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log->println(value);
|
||||||
|
serializeJson(json, _resbuf, sizeof(_resbuf));
|
||||||
|
Log->println(_resbuf);
|
||||||
|
|
||||||
Nuki::CmdResult cmdResult;
|
Nuki::CmdResult cmdResult;
|
||||||
const char *basicKeys[16] = {"name", "latitude", "longitude", "autoUnlatch", "pairingEnabled", "buttonEnabled", "ledEnabled", "ledBrightness", "timeZoneOffset", "dstMode", "fobAction1", "fobAction2", "fobAction3", "singleLock", "advertisingMode", "timeZone"};
|
const char *basicKeys[16] = {"name", "latitude", "longitude", "autoUnlatch", "pairingEnabled", "buttonEnabled", "ledEnabled", "ledBrightness", "timeZoneOffset", "dstMode", "fobAction1", "fobAction2", "fobAction3", "singleLock", "advertisingMode", "timeZone"};
|
||||||
const char *advancedKeys[23] = {"unlockedPositionOffsetDegrees", "lockedPositionOffsetDegrees", "singleLockedPositionOffsetDegrees", "unlockedToLockedTransitionOffsetDegrees", "lockNgoTimeout", "singleButtonPressAction", "doubleButtonPressAction", "detachedCylinder", "batteryType", "automaticBatteryTypeDetection", "unlatchDuration", "autoLockTimeOut", "autoUnLockDisabled", "nightModeEnabled", "nightModeStartTime", "nightModeEndTime", "nightModeAutoLockEnabled", "nightModeAutoUnlockDisabled", "nightModeImmediateLockOnStart", "autoLockEnabled", "immediateAutoLockEnabled", "autoUpdateEnabled", "rebootNuki"};
|
const char *advancedKeys[23] = {"unlockedPositionOffsetDegrees", "lockedPositionOffsetDegrees", "singleLockedPositionOffsetDegrees", "unlockedToLockedTransitionOffsetDegrees", "lockNgoTimeout", "singleButtonPressAction", "doubleButtonPressAction", "detachedCylinder", "batteryType", "automaticBatteryTypeDetection", "unlatchDuration", "autoLockTimeOut", "autoUnLockDisabled", "nightModeEnabled", "nightModeStartTime", "nightModeEndTime", "nightModeAutoLockEnabled", "nightModeAutoUnlockDisabled", "nightModeImmediateLockOnStart", "autoLockEnabled", "immediateAutoLockEnabled", "autoUpdateEnabled", "rebootNuki"};
|
||||||
@@ -1429,9 +1433,30 @@ void NukiWrapper::onConfigUpdateReceived(const char *value)
|
|||||||
|
|
||||||
for(int i=0; i < 16; i++)
|
for(int i=0; i < 16; i++)
|
||||||
{
|
{
|
||||||
if(json[basicKeys[i]])
|
if(json[basicKeys[i]].is<JsonVariantConst>())
|
||||||
{
|
{
|
||||||
const char *jsonchar = json[basicKeys[i]].as<const char*>();
|
JsonVariantConst jsonKey = json[basicKeys[i]];
|
||||||
|
char *jsonchar;
|
||||||
|
|
||||||
|
if (jsonKey.is<float>())
|
||||||
|
{
|
||||||
|
itoa(jsonKey, jsonchar, 10);
|
||||||
|
}
|
||||||
|
else if (jsonKey.is<bool>())
|
||||||
|
{
|
||||||
|
if (jsonKey)
|
||||||
|
{
|
||||||
|
itoa(1, jsonchar, 10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itoa(0, jsonchar, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (jsonKey.is<const char*>())
|
||||||
|
{
|
||||||
|
jsonchar = (char*)jsonKey.as<const char*>();
|
||||||
|
}
|
||||||
|
|
||||||
if(strlen(jsonchar) == 0)
|
if(strlen(jsonchar) == 0)
|
||||||
{
|
{
|
||||||
@@ -1796,9 +1821,30 @@ void NukiWrapper::onConfigUpdateReceived(const char *value)
|
|||||||
|
|
||||||
for(int j=0; j < 23; j++)
|
for(int j=0; j < 23; j++)
|
||||||
{
|
{
|
||||||
if(json[advancedKeys[j]])
|
if(json[advancedKeys[j]].is<JsonVariantConst>())
|
||||||
{
|
{
|
||||||
const char *jsonchar = json[advancedKeys[j]].as<const char*>();
|
JsonVariantConst jsonKey = json[advancedKeys[i]];
|
||||||
|
char *jsonchar;
|
||||||
|
|
||||||
|
if (jsonKey.is<float>())
|
||||||
|
{
|
||||||
|
itoa(jsonKey, jsonchar, 10);
|
||||||
|
}
|
||||||
|
else if (jsonKey.is<bool>())
|
||||||
|
{
|
||||||
|
if (jsonKey)
|
||||||
|
{
|
||||||
|
itoa(1, jsonchar, 10);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
itoa(0, jsonchar, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (jsonKey.is<const char*>())
|
||||||
|
{
|
||||||
|
jsonchar = (char*)jsonKey.as<const char*>();
|
||||||
|
}
|
||||||
|
|
||||||
if(strlen(jsonchar) == 0)
|
if(strlen(jsonchar) == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user