8787extern void vOtaNotActiveHook ( void );
8888extern void vOtaActiveHook ( void );
8989
90+ /* Provides external linkage only when running unit test */
91+ #ifdef UNIT_TESTING
92+ #define STATIC /* as nothing */
93+ #else /* ifdef UNIT_TESTING */
94+ #define STATIC static
95+ #endif /* UNIT_TESTING */
96+
9097/*------------- Demo configurations -------------------------*/
9198
9299/**
@@ -221,6 +228,7 @@ typedef struct OtaTopicFilterCallback
221228 * @brief Buffer used to store the firmware image file path.
222229 * Buffer is passed to the OTA agent during initialization.
223230 */
231+
224232static uint8_t updateFilePath [ otaexampleMAX_FILE_PATH_SIZE ];
225233
226234/**
@@ -281,7 +289,7 @@ extern MQTTAgentContext_t xGlobalMqttAgentContext;
281289 *
282290 * @return A pointer to an unusued buffer. NULL if there are no buffers available.
283291 */
284- static OtaEventData_t * prvOTAEventBufferGet ( void );
292+ STATIC OtaEventData_t * prvOTAEventBufferGet ( void );
285293
286294/**
287295 * @brief Free an event buffer back to pool
@@ -294,7 +302,7 @@ static OtaEventData_t * prvOTAEventBufferGet( void );
294302 *
295303 * @param[in] pxBuffer Pointer to the buffer to be freed.
296304 */
297- static void prvOTAEventBufferFree ( OtaEventData_t * const pxBuffer );
305+ STATIC void prvOTAEventBufferFree ( OtaEventData_t * const pxBuffer );
298306
299307/**
300308 * @brief The function which runs the OTA agent task.
@@ -306,7 +314,7 @@ static void prvOTAEventBufferFree( OtaEventData_t * const pxBuffer );
306314 *
307315 * @param[in] pvParam Any parameters to be passed to OTA agent task.
308316 */
309- static void prvOTAAgentTask ( void * pvParam );
317+ STATIC void prvOTAAgentTask ( void * pvParam );
310318
311319
312320/**
@@ -318,14 +326,14 @@ static void prvOTAAgentTask( void * pvParam );
318326 *
319327 * @param[in] pvParam Any parameters to be passed to OTA Demo task.
320328 */
321- static void vOtaDemoTask ( void * pvParam );
329+ STATIC void vOtaDemoTask ( void * pvParam );
322330
323331/**
324332 * @brief The function which implements the flow for OTA demo.
325333 *
326334 * @return pdPASS if success or pdFAIL.
327335 */
328- static BaseType_t prvRunOTADemo ( void );
336+ STATIC BaseType_t prvRunOTADemo ( void );
329337
330338/**
331339 * @brief Callback registered with the OTA library that notifies the OTA agent
@@ -335,7 +343,7 @@ static BaseType_t prvRunOTADemo( void );
335343 * @param[in] pPublishInfo MQTT packet information which stores details of the
336344 * job document.
337345 */
338- static void prvMqttJobCallback ( void * pContext ,
346+ STATIC void prvMqttJobCallback ( void * pContext ,
339347 MQTTPublishInfo_t * pPublish );
340348
341349
@@ -345,7 +353,7 @@ static void prvMqttJobCallback( void * pContext,
345353 * @param[in] pContext MQTT context which stores the connection.
346354 * @param[in] pPublishInfo MQTT packet that stores the information of the file block.
347355 */
348- static void prvMqttDataCallback ( void * pContext ,
356+ STATIC void prvMqttDataCallback ( void * pContext ,
349357 MQTTPublishInfo_t * pPublish );
350358
351359/**
@@ -359,7 +367,7 @@ static void prvMqttDataCallback( void * pContext,
359367 * @param[in] pvIncomingPublishCallbackContext MQTT context which stores the connection.
360368 * @param[in] pPublishInfo MQTT packet that stores the information of the file block.
361369 */
362- static void prvMqttDefaultCallback ( void * pvIncomingPublishCallbackContext ,
370+ STATIC void prvMqttDefaultCallback ( void * pvIncomingPublishCallbackContext ,
363371 MQTTPublishInfo_t * pxPublishInfo );
364372
365373/**
@@ -369,22 +377,22 @@ static void prvMqttDefaultCallback( void * pvIncomingPublishCallbackContext,
369377 * @param[in] topicFilterLength length of the topic filter.
370378 *
371379 */
372- static void prvRegisterOTACallback ( const char * pTopicFilter ,
380+ STATIC void prvRegisterOTACallback ( const char * pTopicFilter ,
373381 uint16_t topicFilterLength );
374382
375383/**
376384 * @brief Suspend OTA demo.
377385 *
378386 * @return pPASS or pdFAIL.
379387 */
380- static BaseType_t prvSuspendOTA ( void );
388+ STATIC BaseType_t prvSuspendOTA ( void );
381389
382390/**
383391 * @brief Resume OTA demo.
384392 *
385393 * @return pPASS or pdFAIL.
386394 */
387- static BaseType_t prvResumeOTA ( void );
395+ STATIC BaseType_t prvResumeOTA ( void );
388396
389397/**
390398 * @brief Set OTA interfaces.
@@ -393,7 +401,7 @@ static BaseType_t prvResumeOTA( void );
393401 *
394402 * @return None.
395403 */
396- static void setOtaInterfaces ( OtaInterfaces_t * pOtaInterfaces );
404+ STATIC void setOtaInterfaces ( OtaInterfaces_t * pOtaInterfaces );
397405
398406/**
399407 * @brief Structure containing all application allocated buffers used by the OTA agent.
@@ -437,7 +445,7 @@ static OtaTopicFilterCallback_t otaTopicFilterCallbacks[] =
437445
438446/*-----------------------------------------------------------*/
439447
440- static void prvOTAEventBufferFree ( OtaEventData_t * const pxBuffer )
448+ STATIC void prvOTAEventBufferFree ( OtaEventData_t * const pxBuffer )
441449{
442450 if ( xSemaphoreTake ( xBufferSemaphore , portMAX_DELAY ) == pdTRUE )
443451 {
@@ -448,7 +456,7 @@ static void prvOTAEventBufferFree( OtaEventData_t * const pxBuffer )
448456
449457/*-----------------------------------------------------------*/
450458
451- static OtaEventData_t * prvOTAEventBufferGet ( void )
459+ STATIC OtaEventData_t * prvOTAEventBufferGet ( void )
452460{
453461 OtaEventData_t * pFreeBuffer = NULL ;
454462
@@ -493,7 +501,8 @@ static OtaEventData_t * prvOTAEventBufferGet( void )
493501 * @param[in] pData Data associated with the event.
494502 * @return None.
495503 */
496- static void otaAppCallback ( OtaJobEvent_t event ,
504+
505+ STATIC void otaAppCallback ( OtaJobEvent_t event ,
497506 void * pData )
498507{
499508 OtaErr_t err = OtaErrUninitialized ;
@@ -620,7 +629,7 @@ static void otaAppCallback( OtaJobEvent_t event,
620629 }
621630}
622631
623- static void prvMqttJobCallback ( void * pvIncomingPublishCallbackContext ,
632+ STATIC void prvMqttJobCallback ( void * pvIncomingPublishCallbackContext ,
624633 MQTTPublishInfo_t * pxPublishInfo )
625634{
626635 OtaEventData_t * pData ;
@@ -650,7 +659,8 @@ static void prvMqttJobCallback( void * pvIncomingPublishCallbackContext,
650659}
651660
652661/*-----------------------------------------------------------*/
653- static void prvMqttDefaultCallback ( void * pvIncomingPublishCallbackContext ,
662+
663+ STATIC void prvMqttDefaultCallback ( void * pvIncomingPublishCallbackContext ,
654664 MQTTPublishInfo_t * pxPublishInfo )
655665{
656666 bool isMatch = false;
@@ -668,7 +678,8 @@ static void prvMqttDefaultCallback( void * pvIncomingPublishCallbackContext,
668678}
669679
670680/*-----------------------------------------------------------*/
671- static void prvMqttDataCallback ( void * pvIncomingPublishCallbackContext ,
681+
682+ STATIC void prvMqttDataCallback ( void * pvIncomingPublishCallbackContext ,
672683 MQTTPublishInfo_t * pxPublishInfo )
673684{
674685 OtaEventData_t * pxData ;
@@ -699,7 +710,7 @@ static void prvMqttDataCallback( void * pvIncomingPublishCallbackContext,
699710
700711/*-----------------------------------------------------------*/
701712
702- static void prvRegisterOTACallback ( const char * pTopicFilter ,
713+ STATIC void prvRegisterOTACallback ( const char * pTopicFilter ,
703714 uint16_t topicFilterLength )
704715{
705716 bool isMatch = false;
@@ -741,7 +752,7 @@ static void prvRegisterOTACallback( const char * pTopicFilter,
741752 }
742753}
743754
744- static void prvMQTTSubscribeCompleteCallback ( MQTTAgentCommandContext_t * pxCommandContext ,
755+ STATIC void prvMQTTSubscribeCompleteCallback ( MQTTAgentCommandContext_t * pxCommandContext ,
745756 MQTTAgentReturnInfo_t * pxReturnInfo )
746757{
747758 if ( pxReturnInfo -> returnCode == MQTTSuccess )
@@ -763,7 +774,7 @@ static void prvMQTTSubscribeCompleteCallback( MQTTAgentCommandContext_t * pxComm
763774 }
764775}
765776
766- static void prvMQTTUnsubscribeCompleteCallback ( MQTTAgentCommandContext_t * pxCommandContext ,
777+ STATIC void prvMQTTUnsubscribeCompleteCallback ( MQTTAgentCommandContext_t * pxCommandContext ,
767778 MQTTAgentReturnInfo_t * pxReturnInfo )
768779{
769780 /* Store the result in the application defined context so the task that
@@ -779,7 +790,7 @@ static void prvMQTTUnsubscribeCompleteCallback( MQTTAgentCommandContext_t * pxCo
779790 }
780791}
781792
782- static OtaMqttStatus_t prvMQTTSubscribe ( const char * pTopicFilter ,
793+ STATIC OtaMqttStatus_t prvMQTTSubscribe ( const char * pTopicFilter ,
783794 uint16_t topicFilterLength ,
784795 uint8_t ucQoS )
785796{
@@ -848,7 +859,7 @@ static OtaMqttStatus_t prvMQTTSubscribe( const char * pTopicFilter,
848859 return otaRet ;
849860}
850861
851- static void prvOTAPublishCommandCallback ( MQTTAgentCommandContext_t * pxCommandContext ,
862+ STATIC void prvOTAPublishCommandCallback ( MQTTAgentCommandContext_t * pxCommandContext ,
852863 MQTTAgentReturnInfo_t * pxReturnInfo )
853864{
854865 pxCommandContext -> xReturnStatus = pxReturnInfo -> returnCode ;
@@ -859,7 +870,7 @@ static void prvOTAPublishCommandCallback( MQTTAgentCommandContext_t * pxCommandC
859870 }
860871}
861872
862- static OtaMqttStatus_t prvMQTTPublish ( const char * const pacTopic ,
873+ STATIC OtaMqttStatus_t prvMQTTPublish ( const char * const pacTopic ,
863874 uint16_t topicLen ,
864875 const char * pMsg ,
865876 uint32_t msgSize ,
@@ -921,7 +932,7 @@ static OtaMqttStatus_t prvMQTTPublish( const char * const pacTopic,
921932 return otaRet ;
922933}
923934
924- static OtaMqttStatus_t prvMQTTUnsubscribe ( const char * pTopicFilter ,
935+ STATIC OtaMqttStatus_t prvMQTTUnsubscribe ( const char * pTopicFilter ,
925936 uint16_t topicFilterLength ,
926937 uint8_t ucQoS )
927938{
@@ -993,7 +1004,7 @@ static OtaMqttStatus_t prvMQTTUnsubscribe( const char * pTopicFilter,
9931004 return otaRet ;
9941005}
9951006
996- static void setOtaInterfaces ( OtaInterfaces_t * pOtaInterfaces )
1007+ STATIC void setOtaInterfaces ( OtaInterfaces_t * pOtaInterfaces )
9971008{
9981009 configASSERT ( pOtaInterfaces != NULL );
9991010
@@ -1026,7 +1037,7 @@ static void setOtaInterfaces( OtaInterfaces_t * pOtaInterfaces )
10261037
10271038/*-----------------------------------------------------------*/
10281039
1029- static void prvOTAAgentTask ( void * pParam )
1040+ STATIC void prvOTAAgentTask ( void * pParam )
10301041{
10311042 /* Calling OTA agent task. */
10321043 OTA_EventProcessingTask ( pParam );
@@ -1035,7 +1046,7 @@ static void prvOTAAgentTask( void * pParam )
10351046 vTaskDelete ( NULL );
10361047}
10371048
1038- static BaseType_t prvSuspendOTA ( void )
1049+ STATIC BaseType_t prvSuspendOTA ( void )
10391050{
10401051 /* OTA library return status. */
10411052 OtaErr_t otaRet = OtaErrNone ;
@@ -1069,7 +1080,7 @@ static BaseType_t prvSuspendOTA( void )
10691080 return status ;
10701081}
10711082
1072- static BaseType_t prvResumeOTA ( void )
1083+ STATIC BaseType_t prvResumeOTA ( void )
10731084{
10741085 /* OTA library return status. */
10751086 OtaErr_t otaRet = OtaErrNone ;
@@ -1103,7 +1114,7 @@ static BaseType_t prvResumeOTA( void )
11031114 return status ;
11041115}
11051116
1106- static BaseType_t prvRunOTADemo ( void )
1117+ STATIC BaseType_t prvRunOTADemo ( void )
11071118{
11081119 /* Status indicating a successful demo or not. */
11091120 BaseType_t xStatus = pdPASS ;
@@ -1234,7 +1245,7 @@ static BaseType_t prvRunOTADemo( void )
12341245 * the OTA agent. If not, it is simply ignored.
12351246 *
12361247 */
1237- static void vOtaDemoTask ( void * pvParam )
1248+ STATIC void vOtaDemoTask ( void * pvParam )
12381249{
12391250 ( void ) pvParam ;
12401251
0 commit comments