esp8266: split twin callback for device settings and ease ESP WD
This commit is contained in:
Родитель
589979a237
Коммит
22ae8b80d7
|
@ -213,13 +213,15 @@ int getHubHostName(IOTContextInternal* internal, const char* dpsEndpoint,
|
|||
int retval = 0;
|
||||
if ((retval = _getOperationId(internal, dpsEndpoint, scopeId, deviceId,
|
||||
*authHeader, *operationId, NULL)) == 0) {
|
||||
WAITMS(5000);
|
||||
WAITMS(2500);
|
||||
IOTC_LOG(F("- iotc.dps : getting host name..."));
|
||||
WAITMS(2500);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
retval = _getOperationId(internal, dpsEndpoint, scopeId, deviceId,
|
||||
*authHeader, *operationId, hostName);
|
||||
if (retval == 0) break;
|
||||
WAITMS(3000);
|
||||
IOTC_LOG(F("- iotc.dps : getting host name...")); // re-trigger WD
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -334,9 +334,13 @@ static void deviceTwinGetStateCallback(AzureIOT::StringBuffer &topicName,
|
|||
return;
|
||||
}
|
||||
|
||||
jsobject_t desired;
|
||||
jsobject_t desired, outDesired, outReported;
|
||||
jsobject_initialize(&desired, *payload, payload.getLength());
|
||||
|
||||
if (jsobject_get_object_by_name(&desired, "desired", &outDesired) != -1 &&
|
||||
jsobject_get_object_by_name(&desired, "reported", &outReported) != -1) {
|
||||
callDesiredCallback(internal, topicName, "twin", payload);
|
||||
} else {
|
||||
for (unsigned i = 0, count = jsobject_get_count(&desired); i < count;
|
||||
i += 2) {
|
||||
char *itemName = jsobject_get_name_at(&desired, i);
|
||||
|
@ -345,8 +349,10 @@ static void deviceTwinGetStateCallback(AzureIOT::StringBuffer &topicName,
|
|||
}
|
||||
if (itemName) IOTC_FREE(itemName);
|
||||
}
|
||||
|
||||
}
|
||||
jsobject_free(&outReported);
|
||||
jsobject_free(&desired);
|
||||
jsobject_free(&outDesired);
|
||||
}
|
||||
|
||||
void handlePayload(char *msg, unsigned long msg_length, char *topic,
|
||||
|
|
Загрузка…
Ссылка в новой задаче