Embedded C SDK: Not Getting SHADOW_ACKs, only SHADOW_TIMEOUTs -- aws_iot_shadow functions not triggering Callback Function

0

I have been referred here by TI Support given that my issue seems to be caused by AWS Embedded C SDK. I am using CC3235S evaluation board.

I have had success publishing, subscribing, and updating, Shadows/Topics but receiving JSON payloads from a published topic has been a challenge. I am setting breakpoints in my callback function, and they are never being hit, unless I set my timeout seconds to 0, which results in an immediate timeout. The callback is expected to be called upon Timeout, Rejected, or Accepted statuses.

My thing/shadow/get/accepted Topic IS Publishing. The problem is that I'm unable to capture it into my Microcontroller.

I also can tell you that my AWS Iot Core / Thing policies are not the problem. I have set my permissions as loose as possible for testing.

I have Confirmed that the client IS Subscribing to the /shadow/get/rejected + /accepted topics, and I've confirmed that the Shadow is getting updated form my Device/Thing.

I have tried:

  • Adding aws_iot_shadow_yield() / aws_iot_mqtt_yield() after my GET and UPDATE functions
  • Different timeouts
  • Setting persistent subscribe argument to true and false
  • Adjusting permissions then reverting them back to known good

The Return Code always returns SUCCESS for all my aws functions within this routine, and during the GET function I have confirmed that the client IS Connected to AWS.

My GET Function:

IoT_Error_t rcGS;

rcGS = aws_iot_shadow_get(&client, AWS_IOT_MY_THING_NAME, getShadowCallback, NULL, 5, true);

My GET function Callback:

static void getShadowCallback(const char *pThingName, ShadowActions_t action, Shadow_Ack_Status_t status,
        const char *pReceivedJsonDocument, void *pContextData){

    IOT_UNUSED(action);
    IOT_UNUSED(pContextData);
    IOT_UNUSED(pReceivedJsonDocument);
    IOT_UNUSED(pThingName);
    
    nop; // breakpoint

    if (SHADOW_ACK_TIMEOUT == status) {
        IOT_INFO("GET Timeout--");
    } else if (SHADOW_ACK_REJECTED == status) {
        IOT_INFO("GET RejectedXX");
    } else if (SHADOW_ACK_ACCEPTED == status) {
        IOT_INFO("GET Accepted !!");
        GetFromAWS = true;
    }else{
        IOT_INFO("Unknown Update Status");
    }

}

I appreciate any help. Thank you.

asked 2 years ago250 views
2 Answers
0
Accepted Answer

Thank you Greg.

I don't know how I missed this, but even after combing over AWS policy statements for days, I completely missed the "Receive" action. I succeeded with Connect, Publish, Subscribe, GET, and UPDATE, but I completely overlooked Receive.

This is what happens when an Embedded/Hardware Engineer dives into AWS. I'm learning to swim in the deep end.

I feel a bit silly, but that was my problem. I enabled Receiving, and all is well. Thank you for your response. I will keep it in case I run into trouble again.

answered 2 years ago
0

Hi MicroTech. I don't immediately see any obvious issue with your code.

Is this taken from sample code in the SimpleLink SDK? I ask because it's an old version of the AWS IoT Device SDK. Version 3.X. This was superseded by a very different design almost 2 years ago. If you are undertaking a new development, I recommend you use the latest release: https://github.com/aws/aws-iot-device-sdk-embedded-C/releases

Or you can take up the latest FreeRTOS Long Term Support (LTS) release: https://github.com/FreeRTOS/FreeRTOS-LTS/releases . FreeRTOS LTS essentially has the same C SDK libraries, but packaged with the FreeRTOS kernel.

You can find the shadow demo here: https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/main/demos/shadow/shadow_demo_main

Furthermore, we have a reference implementation of the C SDK libraries and FreeRTOS for the CC3220SF: https://github.com/aws/amazon-freertos/tree/main/vendors/ti/boards/cc3220_launchpad

Including a shadow demo: https://github.com/aws/amazon-freertos/tree/main/demos/device_shadow_for_aws

Getting started guide here: https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_ti.html

The 3220 is very similar to your part, so it should not be too hard to adapt as necessary.

If you instead wish to persevere with the old SDK, you can search the repo by tag of course. For example, for 3.1.5: https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/v3.1.5

And find the shadow demo: https://github.com/aws/aws-iot-device-sdk-embedded-C/tree/v3.1.5/samples/linux/shadow_sample

I would suggest though that you probably need to trace through your code, from reception of the get/accepted to figure out why the callback doesn't fire. Alternatively you may consider to create a support case.

profile pictureAWS
EXPERT
Greg_B
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions