I understand how to update the shadow from the esp32... my current challenge is how do i update the device from the shadow?
The shadow init sets up MQTT and the reserved Shadow topics...
in the esp32, do i subcribe to new topics like /changeValue/ or do i subscribe to /get or /update and read the json document from the shadow that might be in a callback?
Thoughts?
ShadowUpdateStatusCallback - how best to use shadow to control device
-
- Posts: 37
- Joined: Thu Jun 07, 2018 3:05 am
Re: ShadowUpdateStatusCallback - how best to use shadow to control device
Hi,
im just starting with aws IoT shadow but i can share what i found so far. This is good link to start:
https://docs.aws.amazon.com/iot/latest/ ... -mqtt.html
From my play with shadow i found you can subscribe to $aws/things/thingName/shadow/update, which is the right way, then you will need to parse json and get desired values to update or you could subscribe to $aws/things/thingName/shadow/update/delta.
What i found is that aws is publishing delta even if it should be published by your esp32 thing.
Remember to publish on accepted/rejected topic when you receive message on $aws/things/thingName/shadow/update topic.
im just starting with aws IoT shadow but i can share what i found so far. This is good link to start:
https://docs.aws.amazon.com/iot/latest/ ... -mqtt.html
From my play with shadow i found you can subscribe to $aws/things/thingName/shadow/update, which is the right way, then you will need to parse json and get desired values to update or you could subscribe to $aws/things/thingName/shadow/update/delta.
What i found is that aws is publishing delta even if it should be published by your esp32 thing.
Remember to publish on accepted/rejected topic when you receive message on $aws/things/thingName/shadow/update topic.
-
- Posts: 37
- Joined: Thu Jun 07, 2018 3:05 am
Re: ShadowUpdateStatusCallback - how best to use shadow to control device
so, you still have to subscribe even after setting up the shadow?
It doesn't subscribe you to the reserved topics already?
It doesn't subscribe you to the reserved topics already?
-
- Posts: 37
- Joined: Thu Jun 07, 2018 3:05 am
Re: ShadowUpdateStatusCallback - how best to use shadow to control device
Thanks for the assist. I am way past this one. Currently I can update the shadow, but I am having an issue subscribing to the delta.
The feedback in the Serial Monitor says that the JSON is corrupt. Putting in debug logs this weekend to figure out what it is.
Does it have to do with being securely connected?
Anyone comfortable talking about AWS side of things?
The feedback in the Serial Monitor says that the JSON is corrupt. Putting in debug logs this weekend to figure out what it is.
Does it have to do with being securely connected?
Anyone comfortable talking about AWS side of things?
-
- Posts: 37
- Joined: Thu Jun 07, 2018 3:05 am
Re: ShadowUpdateStatusCallback - how best to use shadow to control device
So, I put a debug message in the core esp mqtt and was able to see the JSON message being sent by AWS.
This message is not liked by the jsonparser in the esp and says it fails to parse, and that there are -1 tokens.
If I publish to delta from AWS, the esp32 receives the message, it is parsed and the callback function is hit.
I thought when someone published to update (not from the esp32), the delta was generated and sent, but again, esp idf json parse says it fails to parse and returns -1 tokens.
Thoughts?
This message is not liked by the jsonparser in the esp and says it fails to parse, and that there are -1 tokens.
If I publish to delta from AWS, the esp32 receives the message, it is parsed and the callback function is hit.
I thought when someone published to update (not from the esp32), the delta was generated and sent, but again, esp idf json parse says it fails to parse and returns -1 tokens.
Thoughts?
Re: ShadowUpdateStatusCallback - how best to use shadow to control device
Hi, now when you have some logs in esp mqtt, is it possible to you to catch that message before it is being parsed?
If its possible, could you post it here, it can be string or hex buffer.
If its possible, could you post it here, it can be string or hex buffer.
-
- Posts: 37
- Joined: Thu Jun 07, 2018 3:05 am
Re: ShadowUpdateStatusCallback - how best to use shadow to control device
Code: Select all
{
"version": 11447,
"timestamp": 1557422612,
"state": {
"nickname": "thingNameTest"
},
"metadata": {
"nickname": {
"timestamp": 1557422275
}
}
}
Who is online
Users browsing this forum: No registered users and 134 guests