ShadowUpdateStatusCallback - how best to use shadow to control device

wegunterjr
Posts: 37
Joined: Thu Jun 07, 2018 3:05 am

ShadowUpdateStatusCallback - how best to use shadow to control device

Postby wegunterjr » Thu Apr 25, 2019 2:57 pm

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?

chegewara
Posts: 2362
Joined: Wed Jun 14, 2017 9:00 pm

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

Postby chegewara » Thu Apr 25, 2019 9:40 pm

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.

wegunterjr
Posts: 37
Joined: Thu Jun 07, 2018 3:05 am

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

Postby wegunterjr » Sun Apr 28, 2019 11:27 pm

so, you still have to subscribe even after setting up the shadow?
It doesn't subscribe you to the reserved topics already?


wegunterjr
Posts: 37
Joined: Thu Jun 07, 2018 3:05 am

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

Postby wegunterjr » Sat May 04, 2019 1:24 am

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?

wegunterjr
Posts: 37
Joined: Thu Jun 07, 2018 3:05 am

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

Postby wegunterjr » Thu May 09, 2019 4:55 pm

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?

chegewara
Posts: 2362
Joined: Wed Jun 14, 2017 9:00 pm

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

Postby chegewara » Thu May 09, 2019 6:06 pm

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.

wegunterjr
Posts: 37
Joined: Thu Jun 07, 2018 3:05 am

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

Postby wegunterjr » Thu May 09, 2019 7:10 pm

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 67 guests