- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am running BCM94343W AVN with build 3.7.0 The device can publish consistently from device to AWS iOT . No issues. However, once I do a device update from AWS to the device ( update shadow ) , the client will never want to receive another request. Eventually the device will reset itself. This is with the standard build and not code changes other than starting it working. the web MQTT client will happily receive multiple shadow updates.
On the device it will enter into the GET Semiphore code after it parses the JSON and never return on the next item in the delta topic ( which does make it into the queue as the MQTT client at AWS sees the update.
Anyone see this issue before? I did not change the JSON either .. just out of the box stuff. I have code that modifies the JSON parser but its not causing the problems.
thanks
rob
Solved! Go to Solution.
- Labels:
-
AWS
-
Cloud
-
Interrupts
-
SDK 3.x
-
Wifi+Bluetooth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From another thread here: https://community.cypress.com/message/28971
Wow.. after weeks of debugging... Works like a charm..
Setting QoS to the other value
aws_mqtt_app_subscribe( app_info.mqtt_object, app_info.shadow_delta_topic , WICED_MQTT_QOS_DELIVER_AT_MOST_ONCE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You may want to try the Avnet Forum here as well: Avnet BCM4343W IoT Starter Kit | Avnet CloudConnectKits
I think this is a common issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can someone please answer this question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I had the same problem. So removed the shadow functionality and now just use receive messages functionality.
case WICED_MQTT_EVENT_TYPE_PUBLISH_MSG_RECEIVED:
/* code here to receive and parse messages */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm seeing this issue also, and removing the shadow functionality isn't an option. Has there been a resolution?
ruchitmatalia were you able to determine a fix?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
On removing the shadow feature are you suggesting just the empty case entries? I need the shadow response which is processed in the MSG_RECEIVED code section. Can you provide more details on what you specifically removed>?
switch ( event->type )
{
case WICED_MQTT_EVENT_TYPE_CONNECT_REQ_STATUS:
case WICED_MQTT_EVENT_TYPE_DISCONNECTED:
case WICED_MQTT_EVENT_TYPE_PUBLISHED:
case WICED_MQTT_EVENT_TYPE_SUBCRIBED:
case WICED_MQTT_EVENT_TYPE_UNSUBSCRIBED:
{
app_info.expected_event = event->type;
wiced_rtos_set_semaphore( &app_info.msg_semaphore );
break;
}
case WICED_MQTT_EVENT_TYPE_PUBLISH_MSG_RECEIVED:
{
wiced_mqtt_topic_msg_t msg = event->data.pub_recvd;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok. I did not give my best effort in troubleshooting why shadow functionality was not working.
So i focused on pushing my data to AWS Platform in "aws/data" topic. Also, to receive messages, i posted them to a "aws/databack" topic, which where then received and parsed in the "case WICED_MQTT_EVENT_TYPE_PUBLISH_MSG_RECEIVED:" section. To post messages to "aws/databack", you can use program like MQTT.fx or from use AWS MQTT via Websockets if you want to do it in a Web application.
To below are the changes made.
Hope this helps.
aws_common.h file
#define THING_STATE_TOPIC_STR_BUILDER "$aws/things/%s/shadow/update"
#define THING_DELTA_TOPIC_STR_BUILDER "$aws/things/%s/shadow/update/delta"
#define THING_TOPIC_DATA "aws/data" // topic to send data to AWS
#define THING_TOPIC_DATA "aws/databack" // subscribed topic
typedef struct aws_app_info_s
{
wiced_mqtt_event_type_t expected_event;
wiced_semaphore_t msg_semaphore;
wiced_semaphore_t wake_semaphore;
char thing_name[32];
char shadow_state_topic[64];
char shadow_delta_topic[64];
char thing_topic_data[64];
char thing_topic_databack[64];
char mqtt_client_id[64];
wiced_mqtt_object_t mqtt_object;
} aws_app_info_t;
--------------------------------------------------------------------------
In shadow.c, you are not subscribing to the shadow topic, but to your custom topic
Below is example of changes in application_start()
void application_start( void )
{
wiced_result_t ret = WICED_SUCCESS;
int connection_retries = 0;
char payload[1];
sprintf(payload, "{\"serial\":%s,\"tmptr\":%.1f}","\"S1\"",15.0);
ret = aws_app_init(&app_info);
wiced_gpio_input_irq_enable( WICED_BUTTON1, IRQ_TRIGGER_RISING_EDGE, setpoint_control_keypad_handler, NULL );
do
{
ret = aws_mqtt_conn_open( app_info.mqtt_object, mqtt_connection_event_cb );
connection_retries++ ;
} while ( ( ret != WICED_SUCCESS ) && ( connection_retries < WICED_MQTT_CONNECTION_NUMBER_OF_RETRIES ) );
aws_mqtt_app_publish( app_info.mqtt_object, WICED_MQTT_QOS_DELIVER_AT_LEAST_ONCE, (uint8_t*)app_info.thing_topic_data, (uint8_t*)payload ,strlen(payload) );
wiced_rtos_delay_milliseconds( MQTT_DELAY_IN_MILLISECONDS * 2 );
aws_mqtt_app_subscribe( app_info.mqtt_object, app_info.thing_topic_databack , WICED_MQTT_QOS_DELIVER_AT_LEAST_ONCE );
while ( 1 )
{
/* Wait forever on wake semaphore until the wake button is pressed */
wiced_rtos_get_semaphore( &app_info.wake_semaphore, WICED_NEVER_TIMEOUT );
aws_mqtt_app_publish( app_info.mqtt_object, WICED_MQTT_QOS_DELIVER_AT_LEAST_ONCE, (uint8_t*)app_info.thing_topic_data, (uint8_t*)payload ,strlen(payload) );
}
aws_mqtt_app_unsubscribe( app_info.mqtt_object, app_info.thing_topic_databack);
aws_mqtt_conn_close( app_info.mqtt_object );
wiced_rtos_deinit_semaphore( &app_info.msg_semaphore );
ret = wiced_mqtt_deinit( app_info.mqtt_object );
free( app_info.mqtt_object );
app_info.mqtt_object = NULL;
return;
}
--------------------------------------------------------------------------
In shadow.c, to parse incoming data.
This example has more detail. You can check if the data is meant for the specific device and turn LED ON or OFF based on message content.
case WICED_MQTT_EVENT_TYPE_PUBLISH_MSG_RECEIVED:
{
// MESSAGE Example: {"serial": "S1","LED": "ON"}
cJSON *original, *child, *json;
wiced_mqtt_topic_msg_t msg = event->data.pub_recvd;
WPRINT_APP_INFO(( "[MQTT] Received %.*s for TOPIC : %.*s\n\n", (int) msg.data_len, msg.data, (int) msg.topic_len, msg.topic ));
if ( strncmp( (char*) msg.topic, "aws/databack", msg.topic_len ) == 0 ){
original = cJSON_Parse( strchr( (char*) msg.data, '{' ) );
child = original->child;
json = NULL;
while ( child != NULL )
{
WPRINT_APP_INFO (( "child->string [%s]\n", child->string ));
WPRINT_APP_INFO (( "child->value [%s]\n", child->valuestring ));
if (strcasecmp(child->valuestring,"S1")==0){
WPRINT_APP_INFO (("Serial Matched.\n"));
json = child->next;
break;
}
else{
WPRINT_APP_INFO (("Serial Mismatch.\n"));
}
child = child->next;
}
if ( json != NULL )
{
WPRINT_APP_INFO(("json->string [%s]\n", json->string));
WPRINT_APP_INFO(("json->value [%s]\n", json->valuestring));
if (strcasecmp(json->valuestring,"ON")==0){
wiced_gpio_output_high(WICED_LED1);
lstat = 1;
wiced_rtos_set_semaphore( &app_info.wake_semaphore );
}
else if (strcasecmp(json->valuestring,"OFF")==0){
wiced_gpio_output_low(WICED_LED1);
lstat = 0;
wiced_rtos_set_semaphore( &app_info.wake_semaphore );
}
}
cJSON_Delete( original );
}
}
--------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From another thread here: https://community.cypress.com/message/28971
Wow.. after weeks of debugging... Works like a charm..
Setting QoS to the other value
aws_mqtt_app_subscribe( app_info.mqtt_object, app_info.shadow_delta_topic , WICED_MQTT_QOS_DELIVER_AT_MOST_ONCE