|
113 | 113 | */ |
114 | 114 | #define OTA_JOB_NOTIFY_TOPIC_FILTER_LENGTH ( ( uint16_t ) ( sizeof( OTA_JOB_NOTIFY_TOPIC_FILTER ) - 1 ) ) |
115 | 115 |
|
| 116 | +/** |
| 117 | + * @brief Job update response topics filter for OTA. |
| 118 | + * This is used to route all the packets for OTA reserved topics which OTA agent has not subscribed for. |
| 119 | + */ |
| 120 | +#define OTA_JOB_UPDATE_RESPONSE_TOPIC_FILTER OTA_TOPIC_PREFIX "jobs/+/update/+" |
| 121 | + |
| 122 | +/** |
| 123 | + * @brief Length of Job update response topics filter. |
| 124 | + */ |
| 125 | +#define OTA_JOB_UPDATE_RESPONSE_TOPIC_FILTER_LENGTH ( ( uint16_t ) ( sizeof( OTA_JOB_UPDATE_RESPONSE_TOPIC_FILTER ) - 1 ) ) |
| 126 | + |
116 | 127 | /** |
117 | 128 | * @brief Wildcard topic filter for matching job response messages. |
118 | 129 | * This topic filter is used to match the responses from OTA service for OTA agent job requests. THe |
@@ -584,6 +595,11 @@ static void prvOtaAppCallback( OtaJobEvent_t event, |
584 | 595 | xCoreMqttAgentManagerPost( CORE_MQTT_AGENT_OTA_STARTED_EVENT ); |
585 | 596 | break; |
586 | 597 |
|
| 598 | + case OtaJobEventNoActiveJob: |
| 599 | + ESP_LOGI( TAG, "Received OtaJobEventNoActiveJob callback from OTA Agent." ); |
| 600 | + /* No more jobs available in IoTCore, no further actions on this event. */ |
| 601 | + break; |
| 602 | + |
587 | 603 | default: |
588 | 604 | ESP_LOGW( TAG, "Received an unhandled callback event from OTA Agent, " |
589 | 605 | "event = %d", event ); |
@@ -1181,5 +1197,21 @@ bool vOTAProcessMessage( void * pvIncomingPublishCallbackContext, |
1181 | 1197 | } |
1182 | 1198 | } |
1183 | 1199 |
|
| 1200 | + if( isMatch == false ) |
| 1201 | + { |
| 1202 | + ( void ) MQTT_MatchTopic( pxPublishInfo->pTopicName, |
| 1203 | + pxPublishInfo->topicNameLength, |
| 1204 | + OTA_JOB_UPDATE_RESPONSE_TOPIC_FILTER, |
| 1205 | + OTA_JOB_UPDATE_RESPONSE_TOPIC_FILTER_LENGTH, |
| 1206 | + &isMatch ); |
| 1207 | + |
| 1208 | + /* Return true if receiving update/accepted or update/rejected to get rid of warning |
| 1209 | + * message "WARN: Received an unsolicited publish from topic $aws/things/+/jobs/+/update/+". */ |
| 1210 | + if( isMatch == true ) |
| 1211 | + { |
| 1212 | + ESP_LOGI( TAG, "Received update response: %s.", pxPublishInfo->pTopicName ); |
| 1213 | + } |
| 1214 | + } |
| 1215 | + |
1184 | 1216 | return isMatch; |
1185 | 1217 | } |
0 commit comments