Page 1 of 1

ShadowUpdateStatusCallback - how best to use shadow to control device

Posted: Thu Apr 25, 2019 2:57 pm
by wegunterjr
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?

Re: ShadowUpdateStatusCallback - how best to use shadow to control device

Posted: Thu Apr 25, 2019 9:40 pm
by chegewara
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.

Re: ShadowUpdateStatusCallback - how best to use shadow to control device

Posted: Sun Apr 28, 2019 11:27 pm
by wegunterjr
so, you still have to subscribe even after setting up the shadow?
It doesn't subscribe you to the reserved topics already?

Re: ShadowUpdateStatusCallback - how best to use shadow to control device

Posted: Thu May 02, 2019 2:06 pm
by chegewara

Re: ShadowUpdateStatusCallback - how best to use shadow to control device

Posted: Sat May 04, 2019 1:24 am
by wegunterjr
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?

Re: ShadowUpdateStatusCallback - how best to use shadow to control device

Posted: Thu May 09, 2019 4:55 pm
by wegunterjr
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?

Re: ShadowUpdateStatusCallback - how best to use shadow to control device

Posted: Thu May 09, 2019 6:06 pm
by chegewara
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.

Re: ShadowUpdateStatusCallback - how best to use shadow to control device

Posted: Thu May 09, 2019 7:10 pm
by wegunterjr

Code: Select all

{
	"version": 11447,
	"timestamp": 1557422612,
	"state": {
		"nickname": "thingNameTest"
	},
	"metadata": {
		"nickname": {
			"timestamp": 1557422275
		}
	}
}