@@ -289,25 +289,6 @@ static OtaMqttStatus_t prvMQTTSubscribe( const char * pTopicFilter,
289289 uint16_t topicFilterLength ,
290290 uint8_t ucQoS );
291291
292- /**
293- * @brief Function is used by OTA agent to unsubscribe a topicfilter from MQTT broker.
294- *
295- * The implementation queues an UNSUBSCRIBE request for the topic filter with the MQTT agent. It then waits
296- * for a successful completion of the request from the agent. Notification along with results of
297- * operation is sent using xTaskNotify API to the caller task. MQTT agent also removes the topic filter
298- * subscription from its memory so any future
299- * packets on this topic will not be routed to the OTA agent.
300- *
301- * @param[in] pTopicFilter Topic filter to be unsubscribed.
302- * @param[in] topicFilterLength Length of the topic filter.
303- * @param[in] ucQos Qos value for the topic.
304- * @return OtaMqttSuccess if successful. Appropriate error code otherwise.
305- *
306- */
307- static OtaMqttStatus_t prvMQTTUnsubscribe ( const char * pTopicFilter ,
308- uint16_t topicFilterLength ,
309- uint8_t ucQoS );
310-
311292/**
312293 * @brief The function which runs the OTA demo task.
313294 *
@@ -319,21 +300,6 @@ static OtaMqttStatus_t prvMQTTUnsubscribe( const char * pTopicFilter,
319300 */
320301static void prvOTADemoTask ( void * pvParam );
321302
322- /**
323- * @brief Matches a client identifier within an OTA topic.
324- * This function is used to validate that topic is valid and intended for this device thing name.
325- *
326- * @param[in] pTopic Pointer to the topic
327- * @param[in] topicNameLength length of the topic
328- * @param[in] pClientIdentifier Client identifier, should be null terminated.
329- * @param[in] clientIdentifierLength Length of the client identifier.
330- * @return true if client identifier is found within the topic at the right index.
331- */
332- static bool prvMatchClientIdentifierInTopic ( const char * pTopic ,
333- size_t topicNameLength ,
334- const char * pClientIdentifier ,
335- size_t clientIdentifierLength );
336-
337303/**
338304 * @brief Suspends the OTA agent.
339305 */
@@ -356,39 +322,6 @@ static void prvCoreMqttAgentEventHandler( void * pvHandlerArg,
356322
357323/* Static function definitions ************************************************/
358324
359- static bool prvMatchClientIdentifierInTopic ( const char * pTopic ,
360- size_t topicNameLength ,
361- const char * pClientIdentifier ,
362- size_t clientIdentifierLength )
363- {
364- bool isMatch = false;
365- size_t idx , matchIdx = 0 ;
366-
367- for ( idx = OTA_TOPIC_CLIENT_IDENTIFIER_START_IDX ; idx < topicNameLength ; idx ++ )
368- {
369- if ( matchIdx == clientIdentifierLength )
370- {
371- if ( pTopic [ idx ] == '/' )
372- {
373- isMatch = true;
374- }
375-
376- break ;
377- }
378- else
379- {
380- if ( pClientIdentifier [ matchIdx ] != pTopic [ idx ] )
381- {
382- break ;
383- }
384- }
385-
386- matchIdx ++ ;
387- }
388-
389- return isMatch ;
390- }
391-
392325static void prvCommandCallback ( MQTTAgentCommandContext_t * pCommandContext ,
393326 MQTTAgentReturnInfo_t * pxReturnInfo )
394327{
@@ -534,80 +467,6 @@ static OtaMqttStatus_t prvMQTTPublish( const char * const pacTopic,
534467 return otaRet ;
535468}
536469
537- static OtaMqttStatus_t prvMQTTUnsubscribe ( const char * pTopicFilter ,
538- uint16_t topicFilterLength ,
539- uint8_t ucQoS )
540- {
541- MQTTStatus_t mqttStatus ;
542- uint32_t ulNotifiedValue ;
543- MQTTAgentSubscribeArgs_t xSubscribeArgs = { 0 };
544- MQTTSubscribeInfo_t xSubscribeInfo = { 0 };
545- BaseType_t result ;
546- MQTTAgentCommandInfo_t xCommandParams = { 0 };
547- MQTTAgentCommandContext_t xApplicationDefinedContext = { 0 };
548- OtaMqttStatus_t otaRet = OtaMqttSuccess ;
549-
550- configASSERT ( pTopicFilter != NULL );
551- configASSERT ( topicFilterLength > 0 );
552-
553- xSubscribeInfo .pTopicFilter = pTopicFilter ;
554- xSubscribeInfo .topicFilterLength = topicFilterLength ;
555- xSubscribeInfo .qos = ucQoS ;
556- xSubscribeArgs .pSubscribeInfo = & xSubscribeInfo ;
557- xSubscribeArgs .numSubscriptions = 1 ;
558-
559-
560- xApplicationDefinedContext .xTaskToNotify = xTaskGetCurrentTaskHandle ();
561-
562- xCommandParams .blockTimeMs = otademoconfigMQTT_TIMEOUT_MS ;
563- xCommandParams .cmdCompleteCallback = prvCommandCallback ;
564- xCommandParams .pCmdCompleteCallbackContext = ( void * ) & xApplicationDefinedContext ;
565-
566- ESP_LOGI ( TAG , "Unsubscribing to topic filter: %s" , pTopicFilter );
567- xTaskNotifyStateClear ( NULL );
568-
569-
570- mqttStatus = MQTTAgent_Unsubscribe ( & xGlobalMqttAgentContext ,
571- & xSubscribeArgs ,
572- & xCommandParams );
573-
574- /* Wait for command to complete so MQTTSubscribeInfo_t remains in scope for the
575- * duration of the command. */
576- if ( mqttStatus == MQTTSuccess )
577- {
578- result = xTaskNotifyWait ( 0 , MAX_UINT32 , & ulNotifiedValue , portMAX_DELAY );
579-
580- if ( result == pdTRUE )
581- {
582- mqttStatus = xApplicationDefinedContext .xReturnStatus ;
583- }
584- else
585- {
586- mqttStatus = MQTTRecvFailed ;
587- }
588- }
589-
590- if ( mqttStatus != MQTTSuccess )
591- {
592- ESP_LOGE ( TAG , "Failed to UNSUBSCRIBE from topic %.*s with error = %u." ,
593- topicFilterLength ,
594- pTopicFilter ,
595- mqttStatus );
596-
597- otaRet = OtaMqttUnsubscribeFailed ;
598- }
599- else
600- {
601- ESP_LOGI ( TAG , "UNSUBSCRIBED from topic %.*s.\n\n" ,
602- topicFilterLength ,
603- pTopicFilter );
604-
605- otaRet = OtaMqttSuccess ;
606- }
607-
608- return otaRet ;
609- }
610-
611470/*-----------------------------------------------------------*/
612471
613472static void requestJobDocumentHandler ( void )
@@ -825,7 +684,7 @@ static OtaPalJobDocProcessingResult_t receivedJobDocumentHandler( OtaJobEventDat
825684{
826685 bool parseJobDocument = false;
827686 bool handled = false;
828- char * jobId ;
687+ const char * jobId ;
829688 const char * * jobIdptr = & jobId ;
830689 size_t jobIdLength = 0U ;
831690 OtaPalStatus_t palStatus ;
@@ -1303,6 +1162,7 @@ static void processOTAEvents( void )
13031162 case OtaAgentEventRequestFileBlock :
13041163 case OtaAgentEventReceivedFileBlock :
13051164 nextEvent .eventId = OtaAgentEventRequestFileBlock ;
1165+ break ;
13061166
13071167 case OtaAgentEventCloseFile :
13081168 nextEvent .eventId = OtaAgentEventActivateImage ;
0 commit comments