Enlarge stack and check for valid config on JSON command
This commit is contained in:
@@ -767,9 +767,18 @@ Nuki::BatteryType NukiOpenerWrapper::batteryTypeToEnum(const char* str)
|
|||||||
|
|
||||||
void NukiOpenerWrapper::onConfigUpdateReceived(const char *value)
|
void NukiOpenerWrapper::onConfigUpdateReceived(const char *value)
|
||||||
{
|
{
|
||||||
|
|
||||||
JsonDocument jsonResult;
|
JsonDocument jsonResult;
|
||||||
char _resbuf[2048];
|
char _resbuf[2048];
|
||||||
|
|
||||||
|
if(!_configRead || !_nukiConfigValid)
|
||||||
|
{
|
||||||
|
jsonResult["general"] = "configNotReady";
|
||||||
|
serializeJson(jsonResult, _resbuf, sizeof(_resbuf));
|
||||||
|
_network->publishConfigCommandResult(_resbuf);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(_nukiOpener.getSecurityPincode() == 0)
|
if(_nukiOpener.getSecurityPincode() == 0)
|
||||||
{
|
{
|
||||||
jsonResult["general"] = "noPinSet";
|
jsonResult["general"] = "noPinSet";
|
||||||
@@ -1744,6 +1753,12 @@ void NukiOpenerWrapper::onKeypadJsonCommandReceived(const char *value)
|
|||||||
|
|
||||||
void NukiOpenerWrapper::onTimeControlCommandReceived(const char *value)
|
void NukiOpenerWrapper::onTimeControlCommandReceived(const char *value)
|
||||||
{
|
{
|
||||||
|
if(!_configRead || !_nukiConfigValid)
|
||||||
|
{
|
||||||
|
_network->publishTimeControlCommandResult("configNotReady");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(_nukiOpener.getSecurityPincode() == 0)
|
if(_nukiOpener.getSecurityPincode() == 0)
|
||||||
{
|
{
|
||||||
_network->publishTimeControlCommandResult("noPinSet");
|
_network->publishTimeControlCommandResult("noPinSet");
|
||||||
|
|||||||
@@ -489,7 +489,7 @@ void NukiWrapper::updateKeypad()
|
|||||||
{
|
{
|
||||||
std::list<NukiLock::KeypadEntry> entries;
|
std::list<NukiLock::KeypadEntry> entries;
|
||||||
_nukiLock.getKeypadEntries(&entries);
|
_nukiLock.getKeypadEntries(&entries);
|
||||||
|
|
||||||
Log->print(F("Lock keypad codes: "));
|
Log->print(F("Lock keypad codes: "));
|
||||||
Log->println(entries.size());
|
Log->println(entries.size());
|
||||||
|
|
||||||
@@ -533,7 +533,7 @@ void NukiWrapper::updateTimeControl(bool retrieved)
|
|||||||
{
|
{
|
||||||
std::list<NukiLock::TimeControlEntry> timeControlEntries;
|
std::list<NukiLock::TimeControlEntry> timeControlEntries;
|
||||||
_nukiLock.getTimeControlEntries(&timeControlEntries);
|
_nukiLock.getTimeControlEntries(&timeControlEntries);
|
||||||
|
|
||||||
Log->print(F("Lock time control entries: "));
|
Log->print(F("Lock time control entries: "));
|
||||||
Log->println(timeControlEntries.size());
|
Log->println(timeControlEntries.size());
|
||||||
|
|
||||||
@@ -548,7 +548,7 @@ void NukiWrapper::updateTimeControl(bool retrieved)
|
|||||||
_timeControlIds.push_back(entry.entryId);
|
_timeControlIds.push_back(entry.entryId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
postponeBleWatchdog();
|
postponeBleWatchdog();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -574,13 +574,13 @@ NukiLock::LockAction NukiWrapper::lockActionToEnum(const char *str)
|
|||||||
LockActionResult NukiWrapper::onLockActionReceivedCallback(const char *value)
|
LockActionResult NukiWrapper::onLockActionReceivedCallback(const char *value)
|
||||||
{
|
{
|
||||||
NukiLock::LockAction action;
|
NukiLock::LockAction action;
|
||||||
|
|
||||||
if(value)
|
if(value)
|
||||||
{
|
{
|
||||||
if(strlen(value) > 0)
|
if(strlen(value) > 0)
|
||||||
{
|
{
|
||||||
action = nukiInst->lockActionToEnum(value);
|
action = nukiInst->lockActionToEnum(value);
|
||||||
|
|
||||||
if((int)action == 0xff)
|
if((int)action == 0xff)
|
||||||
{
|
{
|
||||||
return LockActionResult::UnknownAction;
|
return LockActionResult::UnknownAction;
|
||||||
@@ -589,7 +589,7 @@ LockActionResult NukiWrapper::onLockActionReceivedCallback(const char *value)
|
|||||||
else return LockActionResult::UnknownAction;
|
else return LockActionResult::UnknownAction;
|
||||||
}
|
}
|
||||||
else return LockActionResult::UnknownAction;
|
else return LockActionResult::UnknownAction;
|
||||||
|
|
||||||
nukiLockPreferences = new Preferences();
|
nukiLockPreferences = new Preferences();
|
||||||
nukiLockPreferences->begin("nukihub", true);
|
nukiLockPreferences->begin("nukihub", true);
|
||||||
uint32_t aclPrefs[17];
|
uint32_t aclPrefs[17];
|
||||||
@@ -707,6 +707,14 @@ void NukiWrapper::onConfigUpdateReceived(const char *value)
|
|||||||
JsonDocument jsonResult;
|
JsonDocument jsonResult;
|
||||||
char _resbuf[2048];
|
char _resbuf[2048];
|
||||||
|
|
||||||
|
if(!_configRead || !_nukiConfigValid)
|
||||||
|
{
|
||||||
|
jsonResult["general"] = "configNotReady";
|
||||||
|
serializeJson(jsonResult, _resbuf, sizeof(_resbuf));
|
||||||
|
_network->publishConfigCommandResult(_resbuf);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(_nukiLock.getSecurityPincode() == 0)
|
if(_nukiLock.getSecurityPincode() == 0)
|
||||||
{
|
{
|
||||||
jsonResult["general"] = "noPinSet";
|
jsonResult["general"] = "noPinSet";
|
||||||
@@ -744,7 +752,7 @@ void NukiWrapper::onConfigUpdateReceived(const char *value)
|
|||||||
if(json[basicKeys[i]])
|
if(json[basicKeys[i]])
|
||||||
{
|
{
|
||||||
const char *jsonchar = json[basicKeys[i]].as<const char*>();
|
const char *jsonchar = json[basicKeys[i]].as<const char*>();
|
||||||
|
|
||||||
if(strlen(jsonchar) == 0)
|
if(strlen(jsonchar) == 0)
|
||||||
{
|
{
|
||||||
jsonResult[basicKeys[i]] = "noValueSet";
|
jsonResult[basicKeys[i]] = "noValueSet";
|
||||||
@@ -947,7 +955,7 @@ void NukiWrapper::onConfigUpdateReceived(const char *value)
|
|||||||
if(json[advancedKeys[i]])
|
if(json[advancedKeys[i]])
|
||||||
{
|
{
|
||||||
const char *jsonchar = json[advancedKeys[i]].as<const char*>();
|
const char *jsonchar = json[advancedKeys[i]].as<const char*>();
|
||||||
|
|
||||||
if(strlen(jsonchar) == 0)
|
if(strlen(jsonchar) == 0)
|
||||||
{
|
{
|
||||||
jsonResult[advancedKeys[i]] = "noValueSet";
|
jsonResult[advancedKeys[i]] = "noValueSet";
|
||||||
@@ -1651,13 +1659,13 @@ void NukiWrapper::onKeypadJsonCommandReceived(const char *value)
|
|||||||
_network->publishKeypadJsonCommandResult("noCodeIdSet");
|
_network->publishKeypadJsonCommandResult("noCodeIdSet");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!idExists)
|
if(!idExists)
|
||||||
{
|
{
|
||||||
_network->publishKeypadJsonCommandResult("noExistingCodeIdSet");
|
_network->publishKeypadJsonCommandResult("noExistingCodeIdSet");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NukiLock::UpdatedKeypadEntry entry;
|
NukiLock::UpdatedKeypadEntry entry;
|
||||||
memset(&entry, 0, sizeof(entry));
|
memset(&entry, 0, sizeof(entry));
|
||||||
entry.codeId = codeId;
|
entry.codeId = codeId;
|
||||||
@@ -1731,6 +1739,12 @@ void NukiWrapper::onKeypadJsonCommandReceived(const char *value)
|
|||||||
|
|
||||||
void NukiWrapper::onTimeControlCommandReceived(const char *value)
|
void NukiWrapper::onTimeControlCommandReceived(const char *value)
|
||||||
{
|
{
|
||||||
|
if(!_configRead || !_nukiConfigValid)
|
||||||
|
{
|
||||||
|
_network->publishTimeControlCommandResult("configNotReady");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(_nukiLock.getSecurityPincode() == 0)
|
if(_nukiLock.getSecurityPincode() == 0)
|
||||||
{
|
{
|
||||||
_network->publishTimeControlCommandResult("noPinSet");
|
_network->publishTimeControlCommandResult("noPinSet");
|
||||||
@@ -1772,7 +1786,7 @@ void NukiWrapper::onTimeControlCommandReceived(const char *value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(action)
|
if(action)
|
||||||
{
|
{
|
||||||
bool idExists = false;
|
bool idExists = false;
|
||||||
@@ -1861,7 +1875,7 @@ void NukiWrapper::onTimeControlCommandReceived(const char *value)
|
|||||||
_network->publishTimeControlCommandResult("noExistingEntryIdSet");
|
_network->publishTimeControlCommandResult("noExistingEntryIdSet");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NukiLock::TimeControlEntry entry;
|
NukiLock::TimeControlEntry entry;
|
||||||
memset(&entry, 0, sizeof(entry));
|
memset(&entry, 0, sizeof(entry));
|
||||||
entry.entryId = entryId;
|
entry.entryId = entryId;
|
||||||
|
|||||||
@@ -112,9 +112,9 @@ void setupTasks()
|
|||||||
{
|
{
|
||||||
// configMAX_PRIORITIES is 25
|
// configMAX_PRIORITIES is 25
|
||||||
|
|
||||||
xTaskCreatePinnedToCore(networkTask, "ntw", 10240, NULL, 3, &networkTaskHandle, 1);
|
xTaskCreatePinnedToCore(networkTask, "ntw", 12288, NULL, 3, &networkTaskHandle, 1);
|
||||||
xTaskCreatePinnedToCore(nukiTask, "nuki", 5120, NULL, 2, &nukiTaskHandle, 1);
|
xTaskCreatePinnedToCore(nukiTask, "nuki", 8192, NULL, 2, &nukiTaskHandle, 1);
|
||||||
xTaskCreatePinnedToCore(presenceDetectionTask, "prdet", 896, NULL, 5, &presenceDetectionTaskHandle, 1);
|
xTaskCreatePinnedToCore(presenceDetectionTask, "prdet", 1024, NULL, 5, &presenceDetectionTaskHandle, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initEthServer(const NetworkDeviceType device)
|
void initEthServer(const NetworkDeviceType device)
|
||||||
|
|||||||
Reference in New Issue
Block a user