This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3220SF: Pending AWS Shadow updates ignored at Power-On

Part Number: CC3220SF


The AWS Plugin "shadow_sample_console" example is working in the sense that any change that occurs to the Shadow when the device is running will be reported via UART print.

However, if there is a pending change when the device powers up, it will be ignored until an additional change is made. For example, in the following Shadow document, the "windowOpen" field was changed to true and AWS IoT added a "delta" record to indicate the changed field.

{
  "desired": {
    "welcome": "aws-iot",
    "windowOpen": true,
    "indication": false
  },
  "reported": {
    "welcome": "aws-iot",
    "temperature": 31.5,
    "windowOpen": false,
    "indication": false
  },
  "delta": {
    "windowOpen": true
  }
}

When the "shadow_sample_console" example starts, the pending delta is ignored. Another change to the Shadow will cause the demo to print out the accumulated deltas if the Thing is running.

For my application, the end-user is likely to reconfigure the device via the Shadow when the device is not connected. How can the sample code be updated to check for Shadow deltas at power-up?

Thank you,

Mark





  • Hi Mark,

    You'll have to use the aws_iot_shadow_get() API in order to retrieve the current state of the shadow at power up. You can see more info about that API here:

    http://aws-iot-device-sdk-embedded-c-docs.s3-website-us-east-1.amazonaws.com/aws__iot__shadow__interface_8h.html#a8d5bac9f2b56664cb600139635aca383

    Thanks,
    Gerardo

  • Hi Gerardo,

    The 'aws_iot_shadow_get()' API call will get the entire shadow which will provide the necessary information.  What I was looking for though was a way to just get the delta information which occurred when the radio was off.  This is the normal use case for a battery-operated product.  The only way I have found to do this is to send a dummy message to trigger the delta message.  The code below will set 'trigger' to be 'true'.  It already was true and never gets set to anything else but doing so will cause any pending delta to be transmitted.

            // This is necessary to get a shadow delta message after power-up.
            // Any publish should be fine, "trigger" is not otherwise used.
            pJson = "{ \"state\": { \"reported\": { \"trigger\": \"true\" } } }";
            rc = publishToShadowAction(AWS_IOT_MY_THING_NAME, SHADOW_UPDATE, pJson);
            IOT_INFO("trigger: publishToShadowAction() returned %d", rc);

    If there is a better way of getting the pending messages, please let me know.  This does seem to be a hack.

    Mark