Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions main/demo_tasks/ota_over_mqtt_demo/ota_over_mqtt_demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@
*/
#define OTA_JOB_NOTIFY_TOPIC_FILTER_LENGTH ( ( uint16_t ) ( sizeof( OTA_JOB_NOTIFY_TOPIC_FILTER ) - 1 ) )

/**
* @brief Job update response topics filter for OTA.
* This is used to route all the packets for OTA reserved topics which OTA agent has not subscribed for.
*/
#define OTA_JOB_UPDATE_RESPONSE_TOPIC_FILTER OTA_TOPIC_PREFIX "jobs/+/update/+"

/**
* @brief Length of Job update response topics filter.
*/
#define OTA_JOB_UPDATE_RESPONSE_TOPIC_FILTER_LENGTH ( ( uint16_t ) ( sizeof( OTA_JOB_UPDATE_RESPONSE_TOPIC_FILTER ) - 1 ) )

/**
* @brief Wildcard topic filter for matching job response messages.
* This topic filter is used to match the responses from OTA service for OTA agent job requests. THe
Expand Down Expand Up @@ -584,6 +595,11 @@ static void prvOtaAppCallback( OtaJobEvent_t event,
xCoreMqttAgentManagerPost( CORE_MQTT_AGENT_OTA_STARTED_EVENT );
break;

case OtaJobEventNoActiveJob:
ESP_LOGI( TAG, "Received OtaJobEventNoActiveJob callback from OTA Agent." );
/* No more jobs available in IoTCore, no further actions on this event. */
break;

default:
ESP_LOGW( TAG, "Received an unhandled callback event from OTA Agent, "
"event = %d", event );
Expand Down Expand Up @@ -1181,5 +1197,21 @@ bool vOTAProcessMessage( void * pvIncomingPublishCallbackContext,
}
}

if( isMatch == false )
{
( void ) MQTT_MatchTopic( pxPublishInfo->pTopicName,
pxPublishInfo->topicNameLength,
OTA_JOB_UPDATE_RESPONSE_TOPIC_FILTER,
OTA_JOB_UPDATE_RESPONSE_TOPIC_FILTER_LENGTH,
&isMatch );

/* Return true if receiving update/accepted or update/rejected to get rid of warning
* message "WARN: Received an unsolicited publish from topic $aws/things/+/jobs/+/update/+". */
if( isMatch == true )
{
ESP_LOGI( TAG, "Received update response: %s.", pxPublishInfo->pTopicName );
}
}

return isMatch;
}