diff options
author | Archit Aggarwal <architag@amazon.com> | 2020-07-07 15:02:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-07 15:02:52 -0700 |
commit | c5b6d727cfdc8368a91e8e999e419cf612914a74 (patch) | |
tree | 9b50dc3b1f56963396f7fa1aaf5effbb5febb6d0 | |
parent | d67f2ad963e39bceb67f1231b550978a5241f929 (diff) | |
download | freertos-git-c5b6d727cfdc8368a91e8e999e419cf612914a74.tar.gz |
Update uncrustify.cfg to match aws/amazon-freertos style (#128)
* Remove uncrustify config for assignment operator alignment to match aws/aws-iot-embedded-c-device-sdk and aws/amazon-freertos configs; re-format files
84 files changed, 3200 insertions, 3207 deletions
diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/DemoTasks/SimpleHTTPSExamples.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/DemoTasks/SimpleHTTPSExamples.c index ad45bf4cd..316cb48fb 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/DemoTasks/SimpleHTTPSExamples.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/DemoTasks/SimpleHTTPSExamples.c @@ -152,7 +152,7 @@ /** * @brief The HTTPS connection handle used in this example. */ -static IotHttpsConnectionHandle_t xHTTPSConnection = IOT_HTTPS_CONNECTION_HANDLE_INITIALIZER; +static IotHttpsConnectionHandle_t xHTTPSConnection = IOT_HTTPS_CONNECTION_HANDLE_INITIALIZER; /** * @brief A buffer used to store the HTTPS Client library's connection context. @@ -163,13 +163,13 @@ static uint8_t ucHTTPSConnectionUserBuffer[ httpsexampleCONNECTION_USER_BUFFER_L * @brief A buffer used to store the HTTPS Client library's request context and * some headers. */ -static uint8_t ucHTTPSRequestUserBuffer[ httpsexampleREQUEST_USER_BUFFER_LENGTH ] = { 0 }; +static uint8_t ucHTTPSRequestUserBuffer[ httpsexampleREQUEST_USER_BUFFER_LENGTH ] = { 0 }; /** * @brief A buffer used to store the HTTPS Client library's response context and * some headers. */ -static uint8_t ucHTTPSResponseUserBuffer[ httpsexampleRESPONSE_USER_BUFFER_LENGTH ] = { 0 }; +static uint8_t ucHTTPSResponseUserBuffer[ httpsexampleRESPONSE_USER_BUFFER_LENGTH ] = { 0 }; /** * @brief The request body. @@ -179,7 +179,7 @@ static char cHTTPSRequestBodyBuffer[] = httpsexampleREQUEST_BODY_TEXT; /** * @brief A buffer used to receive the HTTPS Client library's response body. */ -static uint8_t ucHTTPSResponseBodyBuffer[ httpsexampleRESPONSE_BODY_BUFFER_LENGTH ] = { 0 }; +static uint8_t ucHTTPSResponseBodyBuffer[ httpsexampleRESPONSE_BODY_BUFFER_LENGTH ] = { 0 }; /** * @brief The task used to demonstrate the HTTPS Client API. @@ -218,7 +218,7 @@ static void prvHTTPSDisconnect( void ); */ static void prvInitialiseLibraries( void ); -static const IotHttpsConnectionInfo_t xConnectionInfo = +static const IotHttpsConnectionInfo_t xConnectionInfo = { /* No connection to the HTTPS server has been established yet and we want to * establish a new connection. */ @@ -366,14 +366,14 @@ static void prvHTTPSRequest( IotHttpsMethod_t xMethod, const char * pcPath, uint32_t ulPathLength ) { - IotHttpsReturnCode_t xHTTPSClientResult; - IotHttpsRequestInfo_t xHTTPSRequestInfo = IOT_HTTPS_REQUEST_INFO_INITIALIZER; - IotHttpsResponseInfo_t xHTTPSResponseInfo = IOT_HTTPS_RESPONSE_INFO_INITIALIZER; - IotHttpsRequestHandle_t xHTTPSRequest = IOT_HTTPS_REQUEST_HANDLE_INITIALIZER; - IotHttpsResponseHandle_t xHTTPSResponse = IOT_HTTPS_RESPONSE_HANDLE_INITIALIZER; - IotHttpsSyncInfo_t xHTTPSSyncRequestInfo = IOT_HTTPS_SYNC_INFO_INITIALIZER; - IotHttpsSyncInfo_t xHTTPSSyncResponseInfo = IOT_HTTPS_SYNC_INFO_INITIALIZER; - uint16_t usResponseStatus = 0; + IotHttpsReturnCode_t xHTTPSClientResult; + IotHttpsRequestInfo_t xHTTPSRequestInfo = IOT_HTTPS_REQUEST_INFO_INITIALIZER; + IotHttpsResponseInfo_t xHTTPSResponseInfo = IOT_HTTPS_RESPONSE_INFO_INITIALIZER; + IotHttpsRequestHandle_t xHTTPSRequest = IOT_HTTPS_REQUEST_HANDLE_INITIALIZER; + IotHttpsResponseHandle_t xHTTPSResponse = IOT_HTTPS_RESPONSE_HANDLE_INITIALIZER; + IotHttpsSyncInfo_t xHTTPSSyncRequestInfo = IOT_HTTPS_SYNC_INFO_INITIALIZER; + IotHttpsSyncInfo_t xHTTPSSyncResponseInfo = IOT_HTTPS_SYNC_INFO_INITIALIZER; + uint16_t usResponseStatus = 0; configASSERT( pcPath != NULL ); @@ -381,28 +381,28 @@ static void prvHTTPSRequest( IotHttpsMethod_t xMethod, if( ( xMethod == IOT_HTTPS_METHOD_PUT ) || ( xMethod == IOT_HTTPS_METHOD_POST ) ) { - xHTTPSSyncRequestInfo.pBody = ( uint8_t * ) cHTTPSRequestBodyBuffer; + xHTTPSSyncRequestInfo.pBody = ( uint8_t * ) cHTTPSRequestBodyBuffer; xHTTPSSyncRequestInfo.bodyLen = sizeof( cHTTPSRequestBodyBuffer ); } else { - xHTTPSSyncRequestInfo.pBody = NULL; + xHTTPSSyncRequestInfo.pBody = NULL; xHTTPSSyncRequestInfo.bodyLen = 0; } - xHTTPSRequestInfo.pHost = httpsexampleHTTPS_SERVER_ADDRESS; - xHTTPSRequestInfo.hostLen = sizeof( httpsexampleHTTPS_SERVER_ADDRESS ) - 1; - xHTTPSRequestInfo.pPath = pcPath; - xHTTPSRequestInfo.pathLen = ulPathLength; - xHTTPSRequestInfo.method = xMethod; - xHTTPSRequestInfo.isNonPersistent = false; - xHTTPSRequestInfo.userBuffer.pBuffer = ucHTTPSRequestUserBuffer; - xHTTPSRequestInfo.userBuffer.bufferLen = sizeof( ucHTTPSRequestUserBuffer ) - 1; - xHTTPSRequestInfo.isAsync = false; - xHTTPSRequestInfo.u.pSyncInfo = &xHTTPSSyncRequestInfo; - - xHTTPSClientResult = IotHttpsClient_InitializeRequest( &( xHTTPSRequest ), - &( xHTTPSRequestInfo ) ); + xHTTPSRequestInfo.pHost = httpsexampleHTTPS_SERVER_ADDRESS; + xHTTPSRequestInfo.hostLen = sizeof( httpsexampleHTTPS_SERVER_ADDRESS ) - 1; + xHTTPSRequestInfo.pPath = pcPath; + xHTTPSRequestInfo.pathLen = ulPathLength; + xHTTPSRequestInfo.method = xMethod; + xHTTPSRequestInfo.isNonPersistent = false; + xHTTPSRequestInfo.userBuffer.pBuffer = ucHTTPSRequestUserBuffer; + xHTTPSRequestInfo.userBuffer.bufferLen = sizeof( ucHTTPSRequestUserBuffer ) - 1; + xHTTPSRequestInfo.isAsync = false; + xHTTPSRequestInfo.u.pSyncInfo = &xHTTPSSyncRequestInfo; + + xHTTPSClientResult = IotHttpsClient_InitializeRequest( &( xHTTPSRequest ), + &( xHTTPSRequestInfo ) ); configASSERT( xHTTPSClientResult == IOT_HTTPS_OK ); /************************** HTTPS response setup. **************************/ @@ -411,28 +411,28 @@ static void prvHTTPSRequest( IotHttpsMethod_t xMethod, if( xMethod == IOT_HTTPS_METHOD_HEAD ) { - xHTTPSSyncResponseInfo.pBody = NULL; + xHTTPSSyncResponseInfo.pBody = NULL; xHTTPSSyncResponseInfo.bodyLen = 0; } else { - xHTTPSSyncResponseInfo.pBody = ucHTTPSResponseBodyBuffer; + xHTTPSSyncResponseInfo.pBody = ucHTTPSResponseBodyBuffer; xHTTPSSyncResponseInfo.bodyLen = sizeof( ucHTTPSResponseBodyBuffer ); } - xHTTPSResponseInfo.userBuffer.pBuffer = ucHTTPSResponseUserBuffer; + xHTTPSResponseInfo.userBuffer.pBuffer = ucHTTPSResponseUserBuffer; xHTTPSResponseInfo.userBuffer.bufferLen = sizeof( ucHTTPSResponseUserBuffer ); - xHTTPSResponseInfo.pSyncInfo = &xHTTPSSyncResponseInfo; + xHTTPSResponseInfo.pSyncInfo = &xHTTPSSyncResponseInfo; /*************************** Send HTTPS request. ***************************/ /* This synchronous send function blocks until the full response is received * from the network. */ - xHTTPSClientResult = IotHttpsClient_SendSync( xHTTPSConnection, - xHTTPSRequest, - &( xHTTPSResponse ), - &( xHTTPSResponseInfo ), - httpsexampleHTTPS_TIMEOUT_MS ); + xHTTPSClientResult = IotHttpsClient_SendSync( xHTTPSConnection, + xHTTPSRequest, + &( xHTTPSResponse ), + &( xHTTPSResponseInfo ), + httpsexampleHTTPS_TIMEOUT_MS ); configASSERT( xHTTPSClientResult == IOT_HTTPS_OK ); /* The response status is only available if the httpsexampleRESPONSE_USER_BUFFER @@ -440,8 +440,8 @@ static void prvHTTPSRequest( IotHttpsMethod_t xMethod, * also the Status-Line of the response. The Status-Line and the response * headers are stored in the provided ucHTTPSResponseUserBuffer right after * the HTTPS Client response context. */ - xHTTPSClientResult = IotHttpsClient_ReadResponseStatus( xHTTPSResponse, - &usResponseStatus ); + xHTTPSClientResult = IotHttpsClient_ReadResponseStatus( xHTTPSResponse, + &usResponseStatus ); configASSERT( xHTTPSClientResult == IOT_HTTPS_OK ); configPRINTF( ( "Response status: %d\r\n", usResponseStatus ) ); @@ -469,10 +469,10 @@ static void prvHTTPSDisconnect( void ) static void prvInitialiseLibraries( void ) { IotHttpsReturnCode_t xHTTPSClientResult; - IotNetworkError_t xNetworkResult; + IotNetworkError_t xNetworkResult; /* Initialize the network stack abstraction for FreeRTOS. */ - xNetworkResult = IotNetworkFreeRTOS_Init(); + xNetworkResult = IotNetworkFreeRTOS_Init(); configASSERT( xNetworkResult == IOT_NETWORK_SUCCESS ); /* HTTPS Client library must be initialized before it can be used. This is diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/atomic.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/atomic.h index ee2402255..56a13838b 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/atomic.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/atomic.h @@ -179,7 +179,7 @@ #else ATOMIC_ENTER_CRITICAL(); - pReturnValue = *ppDestination; + pReturnValue = *ppDestination; *ppDestination = pExchange; @@ -227,7 +227,7 @@ if( *ppDestination == pComparand ) { *ppDestination = pExchange; - ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; } ATOMIC_EXIT_CRITICAL(); #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */ @@ -382,7 +382,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination |= ulValue; @@ -413,7 +413,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination &= ulValue; @@ -444,7 +444,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination = ~( ulCurrent & ulValue ); @@ -475,7 +475,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination ^= ulValue; diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/demo_logging.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/demo_logging.c index 3582eb56b..0a763f254 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/demo_logging.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/demo_logging.c @@ -122,31 +122,31 @@ static void * pvLoggingThreadEvent = NULL; /* Stores the selected logging targets passed in as parameters to the * vLoggingInit() function. */ -BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE; +BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE; /* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32 * thread that is responsible for making Win32 calls (when stdout or a disk log is * used). */ -static StreamBuffer_t * xLogStreamBuffer = NULL; +static StreamBuffer_t * xLogStreamBuffer = NULL; /* Handle to the file used for logging. This is left open while there are * messages waiting to be logged, then closed again in between logs. */ -static FILE * pxLoggingFileHandle = NULL; +static FILE * pxLoggingFileHandle = NULL; /* When true prints are performed directly. After start up xDirectPrint is set * to pdFALSE - at which time prints that require Win32 system calls are done by * the Win32 thread responsible for logging. */ -BaseType_t xDirectPrint = pdTRUE; +BaseType_t xDirectPrint = pdTRUE; /* File names for the in use and complete (full) log files. */ -static const char * pcLogFileName = "RTOSDemo.log"; -static const char * pcFullLogFileName = "RTOSDemo.ful"; +static const char * pcLogFileName = "RTOSDemo.log"; +static const char * pcFullLogFileName = "RTOSDemo.ful"; /* As an optimization, the current file size is kept in a variable. */ -static size_t ulSizeOfLoggingFile = 0ul; +static size_t ulSizeOfLoggingFile = 0ul; /* The UDP socket and address on/to which print messages are sent. */ -Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET; +Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET; struct freertos_sockaddr xPrintUDPAddress; /*-----------------------------------------------------------*/ @@ -165,9 +165,9 @@ void vLoggingInit( BaseType_t xLogToStdout, HANDLE Win32Thread; /* Record which output methods are to be used. */ - xStdoutLoggingUsed = xLogToStdout; + xStdoutLoggingUsed = xLogToStdout; xDiskFileLoggingUsed = xLogToFile; - xUDPLoggingUsed = xLogToUDP; + xUDPLoggingUsed = xLogToUDP; /* If a disk file is used then initialize it now. */ if( xDiskFileLoggingUsed != pdFALSE ) @@ -193,16 +193,16 @@ void vLoggingInit( BaseType_t xLogToStdout, if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) ) { /* Create the buffer. */ - xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 ); + xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 ); configASSERT( xLogStreamBuffer ); memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) ); xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1; /* Create the Windows event. */ - pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" ); + pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" ); /* Create the thread itself. */ - Win32Thread = CreateThread( + Win32Thread = CreateThread( NULL, /* Pointer to thread security attributes. */ 0, /* Initial thread stack size, in bytes. */ prvWin32LoggingThread, /* Pointer to thread function. */ @@ -234,7 +234,7 @@ static void prvCreatePrintSocket( void * pvParameter1, uint32_t ulParameter2 ) { static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 ); - Socket_t xSocket; + Socket_t xSocket; /* The function prototype is that of a deferred function, but the parameters * are not actually used. */ @@ -258,17 +258,17 @@ static void prvCreatePrintSocket( void * pvParameter1, void vLoggingPrintf( const char * pcFormat, ... ) { - char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; - char cOutputString[ dlMAX_PRINT_STRING_LENGTH ]; - char * pcSource, * pcTarget, * pcBegin; - size_t xLength, xLength2, rc; + char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; + char cOutputString[ dlMAX_PRINT_STRING_LENGTH ]; + char * pcSource, * pcTarget, * pcBegin; + size_t xLength, xLength2, rc; static BaseType_t xMessageNumber = 0; - va_list args; - uint32_t ulIPAddress; - const char * pcTaskName; - const char * pcNoTask = "None"; - int iOriginalPriority; - HANDLE xCurrentTask; + va_list args; + uint32_t ulIPAddress; + const char * pcTaskName; + const char * pcNoTask = "None"; + int iOriginalPriority; + HANDLE xCurrentTask; if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) ) @@ -304,7 +304,7 @@ void vLoggingPrintf( const char * pcFormat, if( xLength2 < 0 ) { /* Clean up. */ - xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength; + xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength; cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0'; } @@ -328,7 +328,7 @@ void vLoggingPrintf( const char * pcFormat, *pcTarget = *pcSource; pcTarget++; *pcTarget = '\0'; - pcBegin = pcTarget - 8; + pcBegin = pcTarget - 8; while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) ) { @@ -336,18 +336,18 @@ void vLoggingPrintf( const char * pcFormat, } sscanf( pcTarget, "%8X", &ulIPAddress ); - rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", - ( unsigned long ) ( ulIPAddress >> 24UL ), - ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), - ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ), - ( unsigned long ) ( ulIPAddress & 0xffUL ) ); + rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", + ( unsigned long ) ( ulIPAddress >> 24UL ), + ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), + ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ), + ( unsigned long ) ( ulIPAddress & 0xffUL ) ); pcTarget += rc; pcSource += 3; /* skip "<n>ip" */ } } /* How far through the buffer was written? */ - xLength = ( BaseType_t ) ( pcTarget - cOutputString ); + xLength = ( BaseType_t ) ( pcTarget - cOutputString ); /* If the message is to be logged to a UDP port then it can be sent directly * because it only uses FreeRTOS function (not Win32 functions). */ @@ -393,7 +393,7 @@ void vLoggingPrintf( const char * pcFormat, * as there are potentially multiple writers. The stream buffer is * only thread safe when there is a single writer (likewise for * reading from the buffer). */ - xCurrentTask = GetCurrentThread(); + xCurrentTask = GetCurrentThread(); iOriginalPriority = GetThreadPriority( xCurrentTask ); SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL ); uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) ); @@ -426,7 +426,7 @@ void vLoggingPrintf( const char * pcFormat, static void prvLoggingFlushBuffer( void ) { size_t xLength; - char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; + char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; /* Is there more than the length value stored in the circular buffer * used to pass data from the FreeRTOS simulator into this Win32 thread? */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/main.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/main.c index 89ec2ff33..00dd75ba2 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/main.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/main.c @@ -94,7 +94,7 @@ const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALS * to and from a real network connection on the host PC. See the * configNETWORK_INTERFACE_TO_USE definition for information on how to configure * the real network connection to use. */ -const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 }; +const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 }; /* Use by the pseudo random number generator. */ static UBaseType_t ulNextRand; @@ -139,8 +139,8 @@ int main( void ) * events are only received if implemented in the MAC driver. */ void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent ) { - uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; - char cBuffer[ 16 ]; + uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; + char cBuffer[ 16 ]; static BaseType_t xTasksAlreadyCreated = pdFALSE; /* If the network has just come up...*/ @@ -179,8 +179,8 @@ void vAssertCalled( const char * pcFile, uint32_t ulLine ) { volatile uint32_t ulBlockVariable = 0UL; - volatile char * pcFileName = ( volatile char * ) pcFile; - volatile uint32_t ulLineNumber = ulLine; + volatile char * pcFileName = ( volatile char * ) pcFile; + volatile uint32_t ulLineNumber = ulLine; ( void ) pcFileName; ( void ) ulLineNumber; @@ -225,7 +225,7 @@ static void prvSRand( UBaseType_t ulSeed ) static void prvMiscInitialisation( void ) { - time_t xTimeNow; + time_t xTimeNow; uint32_t ulLoggingIPAddress; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 ); @@ -333,11 +333,11 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, * function then they must be declared static - otherwise they will be allocated on * the stack and so not exists after this function exits. */ static StaticTask_t xIdleTaskTCB; - static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; + static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; /* Pass out a pointer to the StaticTask_t structure in which the Idle task's * state will be stored. */ - *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; /* Pass out the array that will be used as the Idle task's stack. */ *ppxIdleTaskStackBuffer = uxIdleTaskStack; @@ -345,7 +345,7 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; } /*-----------------------------------------------------------*/ @@ -360,11 +360,11 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, * function then they must be declared static - otherwise they will be allocated on * the stack and so not exists after this function exits. */ static StaticTask_t xTimerTaskTCB; - static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; + static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; /* Pass out a pointer to the StaticTask_t structure in which the Timer * task's state will be stored. */ - *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; /* Pass out the array that will be used as the Timer task's stack. */ *ppxTimerTaskStackBuffer = uxTimerTaskStack; @@ -372,6 +372,6 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/printf-stdarg.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/printf-stdarg.c index f9bc5b5b1..ae28ddde0 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/printf-stdarg.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/https/common/printf-stdarg.c @@ -64,7 +64,7 @@ static void strbuf_init( struct SStringBuf * apStr, char * apBuf, const char * apMaxStr ) { - apStr->str = apBuf; + apStr->str = apBuf; apStr->orgStr = apBuf; apStr->nulPos = apMaxStr - 1; apStr->curLen = 0; @@ -158,7 +158,7 @@ static BaseType_t prints( struct SStringBuf * apBuf, const char * apString ) { register int padchar = ' '; - int i, len; + int i, len; if( xApplicationMemoryPermissions( ( uint32_t ) apString ) == 0 ) { @@ -169,7 +169,7 @@ static BaseType_t prints( struct SStringBuf * apBuf, if( apBuf->flags.width > 0 ) { - register int len = 0; + register int len = 0; register const char * ptr; for( ptr = apString; *ptr; ++ptr ) @@ -257,11 +257,11 @@ static BaseType_t prints( struct SStringBuf * apBuf, static BaseType_t printll( struct SStringBuf * apBuf, long long i ) { - char print_buf[ 2 * PRINT_BUF_LEN ]; - register char * s; - register int t, neg = 0; + char print_buf[ 2 * PRINT_BUF_LEN ]; + register char * s; + register int t, neg = 0; register unsigned long long u = i; - lldiv_t lldiv_result; + lldiv_t lldiv_result; /* typedef struct * { @@ -282,26 +282,26 @@ static BaseType_t prints( struct SStringBuf * apBuf, if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) ) { neg = 1; - u = -i; + u = -i; } - s = print_buf + sizeof( print_buf ) - 1; + s = print_buf + sizeof( print_buf ) - 1; - *s = '\0'; + *s = '\0'; /* 18446744073709551616 */ while( u != 0 ) { lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base ); - t = lldiv_result.rem; + t = lldiv_result.rem; if( t >= 10 ) { t += apBuf->flags.letBase - '0' - 10; } - *( --s ) = t + '0'; - u = lldiv_result.quot; + *( --s ) = t + '0'; + u = lldiv_result.quot; } if( neg != 0 ) @@ -329,11 +329,11 @@ static BaseType_t prints( struct SStringBuf * apBuf, static BaseType_t printi( struct SStringBuf * apBuf, int i ) { - char print_buf[ PRINT_BUF_LEN ]; - register char * s; - register int t, neg = 0; - register unsigned int u = i; - register unsigned base = apBuf->flags.base; + char print_buf[ PRINT_BUF_LEN ]; + register char * s; + register int t, neg = 0; + register unsigned int u = i; + register unsigned base = apBuf->flags.base; apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */ @@ -347,12 +347,12 @@ static BaseType_t printi( struct SStringBuf * apBuf, if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) ) { neg = 1; - u = -i; + u = -i; } - s = print_buf + sizeof( print_buf ) - 1; + s = print_buf + sizeof( print_buf ) - 1; - *s = '\0'; + *s = '\0'; switch( base ) { @@ -360,7 +360,7 @@ static BaseType_t printi( struct SStringBuf * apBuf, while( u != 0 ) { - t = u & 0xF; + t = u & 0xF; if( t >= 10 ) { @@ -368,7 +368,7 @@ static BaseType_t printi( struct SStringBuf * apBuf, } *( --s ) = t + '0'; - u >>= 4; + u >>= 4; } break; @@ -379,9 +379,9 @@ static BaseType_t printi( struct SStringBuf * apBuf, /* GCC compiles very efficient */ while( u ) { - t = u % base; + t = u % base; *( --s ) = t + '0'; - u /= base; + u /= base; } break; @@ -487,19 +487,19 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == '-' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.pad = PAD_RIGHT; } while( ch == '0' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.pad |= PAD_ZERO; } if( ch == '*' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.width = va_arg( args, int ); } else @@ -508,7 +508,7 @@ static void tiny_print( struct SStringBuf * apBuf, { apBuf->flags.width *= 10; apBuf->flags.width += ch - '0'; - ch = *( format++ ); + ch = *( format++ ); } } @@ -519,7 +519,7 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == '*' ) { apBuf->flags.printLimit = va_arg( args, int ); - ch = *( format++ ); + ch = *( format++ ); } else { @@ -527,7 +527,7 @@ static void tiny_print( struct SStringBuf * apBuf, { apBuf->flags.printLimit *= 10; apBuf->flags.printLimit += ch - '0'; - ch = *( format++ ); + ch = *( format++ ); } } } @@ -564,19 +564,19 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == 'l' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.long32 = 1; /* Makes not difference as u32 == long */ } if( ch == 'L' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.long64 = 1; /* Does make a difference */ } - apBuf->flags.base = 10; + apBuf->flags.base = 10; apBuf->flags.letBase = 'a'; if( ( ch == 'd' ) || ( ch == 'u' ) ) @@ -601,7 +601,7 @@ static void tiny_print( struct SStringBuf * apBuf, continue; } - apBuf->flags.base = 16; /* From here all hexadecimal */ + apBuf->flags.base = 16; /* From here all hexadecimal */ if( ( ch == 'x' ) && ( format[ 0 ] == 'i' ) && ( format[ 1 ] == 'p' ) ) { @@ -670,7 +670,7 @@ int snprintf( char * apBuf, const char * apFmt, ... ) { - va_list args; + va_list args; va_start( args, apFmt ); struct SStringBuf strBuf; @@ -686,7 +686,7 @@ int sprintf( char * apBuf, const char * apFmt, ... ) { - va_list args; + va_list args; va_start( args, apFmt ); struct SStringBuf strBuf; @@ -716,21 +716,21 @@ const char * mkSize( unsigned long long aSize, int aLen ) { static char retString[ 33 ]; - size_t gb, mb, kb, sb; + size_t gb, mb, kb, sb; if( apBuf == NULL ) { apBuf = retString; - aLen = sizeof( retString ); + aLen = sizeof( retString ); } - gb = aSize / ( 1024 * 1024 * 1024 ); + gb = aSize / ( 1024 * 1024 * 1024 ); aSize -= gb * ( 1024 * 1024 * 1024 ); - mb = aSize / ( 1024 * 1024 ); + mb = aSize / ( 1024 * 1024 ); aSize -= mb * ( 1024 * 1024 ); - kb = aSize / ( 1024 ); + kb = aSize / ( 1024 ); aSize -= kb * ( 1024 ); - sb = aSize; + sb = aSize; if( gb ) { diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/DemoTasks/JobsNotifyNextExamples.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/DemoTasks/JobsNotifyNextExamples.c index afe65dfe2..493649663 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/DemoTasks/JobsNotifyNextExamples.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/DemoTasks/JobsNotifyNextExamples.c @@ -359,7 +359,7 @@ static void prvJobsCallback( void * pCallbackContext, /** * @brief The MQTT connection handle used in this example. */ -static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER; +static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER; /* * @brief The main task handle in this demo. @@ -369,13 +369,13 @@ static TaskHandle_t xMainTaskHandle; /***************** Structures that define the connection. *********************/ -static const struct IotNetworkServerInfo xMQTTBrokerInfo = +static const struct IotNetworkServerInfo xMQTTBrokerInfo = { .pHostName = awsiotdemoprofileAWS_ENDPOINT, .port = awsiotdemoprofileAWS_MQTT_PORT }; -static struct IotNetworkCredentials xNetworkSecurityCredentials = +static struct IotNetworkCredentials xNetworkSecurityCredentials = { /* Optional TLS extensions. For this demo, they are disabled. */ .pAlpnProtos = NULL, @@ -397,7 +397,7 @@ static struct IotNetworkCredentials xNetworkSecurityCredentials = .privateKeySize = sizeof( awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM ) }; -static IotMqttNetworkInfo_t xNetworkInfo = +static IotMqttNetworkInfo_t xNetworkInfo = { /* No connection to the MQTT broker has been established yet and we want to * establish a new connection. */ @@ -416,7 +416,7 @@ static IotMqttNetworkInfo_t xNetworkInfo = .disconnectCallback.function = prvExample_OnDisconnect }; -static const IotMqttConnectInfo_t xConnectInfo = +static const IotMqttConnectInfo_t xConnectInfo = { /* Set this flag to true if connecting to the AWS IoT MQTT broker. */ .awsIotMqttMode = false, @@ -492,30 +492,30 @@ void vStartJobsDemo( void ) static void prvJobsDemoTask( void * pvParameters ) { - IotMqttError_t xResult; - IotNetworkError_t xNetworkInit; - uint32_t ulNotificationValue = 0; - const TickType_t xNoDelay = ( TickType_t ) 0; - AwsIotJobsError_t xStatus = AWS_IOT_JOBS_SUCCESS; - AwsIotJobsCallbackInfo_t xCallbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER; - AwsIotJobsRequestInfo_t xRequestInfo = AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER; + IotMqttError_t xResult; + IotNetworkError_t xNetworkInit; + uint32_t ulNotificationValue = 0; + const TickType_t xNoDelay = ( TickType_t ) 0; + AwsIotJobsError_t xStatus = AWS_IOT_JOBS_SUCCESS; + AwsIotJobsCallbackInfo_t xCallbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER; + AwsIotJobsRequestInfo_t xRequestInfo = AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER; /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; - xMainTaskHandle = xTaskGetCurrentTaskHandle(); + xMainTaskHandle = xTaskGetCurrentTaskHandle(); /* Initialize the network stack abstraction for FreeRTOS. */ - xNetworkInit = IotNetworkFreeRTOS_Init(); + xNetworkInit = IotNetworkFreeRTOS_Init(); configASSERT( xNetworkInit == IOT_NETWORK_SUCCESS ); /* MQTT library must be initialized before it can be used. This is just one * time initialization. */ - xResult = IotMqtt_Init(); + xResult = IotMqtt_Init(); configASSERT( xResult == IOT_MQTT_SUCCESS ); /* Initialize Jobs library. */ - xResult = AwsIotJobs_Init( jobsexampleUSE_DEFAULT_MQTT_TIMEOUT ); + xResult = AwsIotJobs_Init( jobsexampleUSE_DEFAULT_MQTT_TIMEOUT ); configASSERT( xResult == AWS_IOT_JOBS_SUCCESS ); /****************************** Connect. ******************************/ @@ -535,17 +535,17 @@ static void prvJobsDemoTask( void * pvParameters ) prvSetNotifyNextCallback(); /* Call DescribeAsync to see if there are any pending jobs. */ - xRequestInfo.mqttConnection = xMQTTConnection; - xRequestInfo.pThingName = awsiotdemoprofileCLIENT_IDENTIFIER; + xRequestInfo.mqttConnection = xMQTTConnection; + xRequestInfo.pThingName = awsiotdemoprofileCLIENT_IDENTIFIER; xRequestInfo.thingNameLength = jobsexampleCLIENT_IDENTIFIER_LENGTH; - xRequestInfo.pJobId = AWS_IOT_JOBS_NEXT_JOB; - xRequestInfo.jobIdLength = AWS_IOT_JOBS_NEXT_JOB_LENGTH; + xRequestInfo.pJobId = AWS_IOT_JOBS_NEXT_JOB; + xRequestInfo.jobIdLength = AWS_IOT_JOBS_NEXT_JOB_LENGTH; /* Use the same callback as notify-next so any pending jobs will be * executed the same way. */ - xCallbackInfo.function = prvJobsCallback; + xCallbackInfo.function = prvJobsCallback; - xStatus = AwsIotJobs_DescribeAsync( &xRequestInfo, AWS_IOT_JOBS_NO_EXECUTION_NUMBER, true, 0, &xCallbackInfo, NULL ); + xStatus = AwsIotJobs_DescribeAsync( &xRequestInfo, AWS_IOT_JOBS_NO_EXECUTION_NUMBER, true, 0, &xCallbackInfo, NULL ); configPRINTF( ( "Describe queued with result %s.\r\n", AwsIotJobs_strerror( xStatus ) ) ); /* Print out a short user guide to the console. The default logging @@ -655,19 +655,19 @@ static void prvMQTTDisconnect( void ) static void prvSetNotifyNextCallback( void ) { - AwsIotJobsError_t xCallbackStatus = AWS_IOT_JOBS_SUCCESS; - AwsIotJobsCallbackInfo_t xCallbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER; + AwsIotJobsError_t xCallbackStatus = AWS_IOT_JOBS_SUCCESS; + AwsIotJobsCallbackInfo_t xCallbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER; /* Set the jobs callback function. */ xCallbackInfo.function = prvJobsCallback; /************************ Set notify-next callbacks **********************/ - xCallbackStatus = AwsIotJobs_SetNotifyNextCallback( xMQTTConnection, - awsiotdemoprofileCLIENT_IDENTIFIER, - jobsexampleCLIENT_IDENTIFIER_LENGTH, - 0, - &xCallbackInfo ); + xCallbackStatus = AwsIotJobs_SetNotifyNextCallback( xMQTTConnection, + awsiotdemoprofileCLIENT_IDENTIFIER, + jobsexampleCLIENT_IDENTIFIER_LENGTH, + 0, + &xCallbackInfo ); configASSERT( xCallbackStatus == AWS_IOT_JOBS_SUCCESS ); } @@ -776,11 +776,11 @@ static AwsIotJobState_t prvProcessMessage( IotMqttConnection_t xMqttConnection, const char * pcJobDoc, size_t xJobDocLength ) { - AwsIotJobState_t xStatus = AWS_IOT_JOB_STATE_SUCCEEDED; - IotMqttError_t xMqttStatus = IOT_MQTT_STATUS_PENDING; + AwsIotJobState_t xStatus = AWS_IOT_JOB_STATE_SUCCEEDED; + IotMqttError_t xMqttStatus = IOT_MQTT_STATUS_PENDING; IotMqttPublishInfo_t xPublishInfo = IOT_MQTT_PUBLISH_INFO_INITIALIZER; - const char * pcMessage = NULL, * pcTopic = NULL; - size_t xMessageLength = 0, xTopicLength = 0; + const char * pcMessage = NULL, * pcTopic = NULL; + size_t xMessageLength = 0, xTopicLength = 0; configASSERT( pcJobDoc != NULL ); @@ -831,13 +831,13 @@ static AwsIotJobState_t prvProcessMessage( IotMqttConnection_t xMqttConnection, if( xStatus == AWS_IOT_JOB_STATE_SUCCEEDED ) { - xPublishInfo.qos = IOT_MQTT_QOS_0; - xPublishInfo.pTopicName = pcTopic; + xPublishInfo.qos = IOT_MQTT_QOS_0; + xPublishInfo.pTopicName = pcTopic; xPublishInfo.topicNameLength = ( uint16_t ) xTopicLength; - xPublishInfo.pPayload = pcMessage; - xPublishInfo.payloadLength = xMessageLength; + xPublishInfo.pPayload = pcMessage; + xPublishInfo.payloadLength = xMessageLength; - xMqttStatus = IotMqtt_PublishAsync( xMqttConnection, &xPublishInfo, 0, NULL, NULL ); + xMqttStatus = IotMqtt_PublishAsync( xMqttConnection, &xPublishInfo, 0, NULL, NULL ); if( xMqttStatus != IOT_MQTT_SUCCESS ) { @@ -857,13 +857,13 @@ static void prvProcessJob( const AwsIotJobsCallbackParam_t * pxJobInfo, const char * pcJobDoc, size_t xJobDocLength ) { - AwsIotJobsError_t xStatus = AWS_IOT_JOBS_SUCCESS; - AwsIotJobsUpdateInfo_t xUpdateInfo = AWS_IOT_JOBS_UPDATE_INFO_INITIALIZER; + AwsIotJobsError_t xStatus = AWS_IOT_JOBS_SUCCESS; + AwsIotJobsUpdateInfo_t xUpdateInfo = AWS_IOT_JOBS_UPDATE_INFO_INITIALIZER; AwsIotJobsCallbackInfo_t xCallbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER; - const char * pcAction = NULL; - size_t xActionLength = 0; - _jobAction_t xAction = JOB_ACTION_UNKNOWN; - AwsIotJobsRequestInfo_t xRequestInfo = AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER; + const char * pcAction = NULL; + size_t xActionLength = 0; + _jobAction_t xAction = JOB_ACTION_UNKNOWN; + AwsIotJobsRequestInfo_t xRequestInfo = AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER; configASSERT( pxJobInfo != NULL ); configASSERT( pcJobId != NULL ); @@ -871,17 +871,17 @@ static void prvProcessJob( const AwsIotJobsCallbackParam_t * pxJobInfo, configPRINTF( ( "Job document received: %.*s\r\n", xJobDocLength, pcJobDoc ) ); - xRequestInfo.mqttConnection = pxJobInfo->mqttConnection; - xRequestInfo.pThingName = pxJobInfo->pThingName; + xRequestInfo.mqttConnection = pxJobInfo->mqttConnection; + xRequestInfo.pThingName = pxJobInfo->pThingName; xRequestInfo.thingNameLength = pxJobInfo->thingNameLength; - xRequestInfo.pJobId = pcJobId; - xRequestInfo.jobIdLength = xJobIdLength; + xRequestInfo.pJobId = pcJobId; + xRequestInfo.jobIdLength = xJobIdLength; /* Tell the Jobs service that the device has started working on the Job. * Use the StartNext API to set the Job's status to IN_PROGRESS. */ - xCallbackInfo.function = prvOperationCompleteCallback; + xCallbackInfo.function = prvOperationCompleteCallback; - xStatus = AwsIotJobs_StartNextAsync( &xRequestInfo, &xUpdateInfo, 0, &xCallbackInfo, NULL ); + xStatus = AwsIotJobs_StartNextAsync( &xRequestInfo, &xUpdateInfo, 0, &xCallbackInfo, NULL ); configPRINTF( ( "Jobs StartNext queued with result %s.\r\n", AwsIotJobs_strerror( xStatus ) ) ); @@ -899,15 +899,15 @@ static void prvProcessJob( const AwsIotJobsCallbackParam_t * pxJobInfo, { case JOB_ACTION_EXIT: xCallbackInfo.pCallbackContext = jobsexampleSHOULD_EXIT; - xUpdateInfo.newStatus = AWS_IOT_JOB_STATE_SUCCEEDED; + xUpdateInfo.newStatus = AWS_IOT_JOB_STATE_SUCCEEDED; break; case JOB_ACTION_PRINT: case JOB_ACTION_PUBLISH: - xUpdateInfo.newStatus = prvProcessMessage( pxJobInfo->mqttConnection, - xAction, - pcJobDoc, - xJobDocLength ); + xUpdateInfo.newStatus = prvProcessMessage( pxJobInfo->mqttConnection, + xAction, + pcJobDoc, + xJobDocLength ); break; default: @@ -915,7 +915,7 @@ static void prvProcessJob( const AwsIotJobsCallbackParam_t * pxJobInfo, xActionLength, pcAction ) ); - xUpdateInfo.newStatus = AWS_IOT_JOB_STATE_FAILED; + xUpdateInfo.newStatus = AWS_IOT_JOB_STATE_FAILED; break; } } @@ -934,7 +934,7 @@ static void prvProcessJob( const AwsIotJobsCallbackParam_t * pxJobInfo, AwsIotJobs_StateName( xUpdateInfo.newStatus ) ) ); /* Tell the Jobs service that the device has finished the Job. */ - xStatus = AwsIotJobs_UpdateAsync( &xRequestInfo, &xUpdateInfo, 0, &xCallbackInfo, NULL ); + xStatus = AwsIotJobs_UpdateAsync( &xRequestInfo, &xUpdateInfo, 0, &xCallbackInfo, NULL ); configPRINTF( ( "Jobs Update queued with result %s.\r\n", AwsIotJobs_strerror( xStatus ) ) ); } @@ -943,13 +943,13 @@ static void prvProcessJob( const AwsIotJobsCallbackParam_t * pxJobInfo, static void prvJobsCallback( void * pCallbackContext, AwsIotJobsCallbackParam_t * pxCallbackInfo ) { - BaseType_t xIdKeyFound = pdFALSE, xDocKeyFound = pdFALSE; - const char * pcJobId = NULL; - size_t xJobIdLength = 0; - const char * pcJobDoc = NULL; - size_t xJobDocLength = 0; - const char * pcRawDocument = NULL; - size_t xRawDocumentLength = 0; + BaseType_t xIdKeyFound = pdFALSE, xDocKeyFound = pdFALSE; + const char * pcJobId = NULL; + size_t xJobIdLength = 0; + const char * pcJobDoc = NULL; + size_t xJobDocLength = 0; + const char * pcRawDocument = NULL; + size_t xRawDocumentLength = 0; /* Silence warnings about unused parameters. */ ( void ) pCallbackContext; @@ -960,22 +960,22 @@ static void prvJobsCallback( void * pCallbackContext, * due to notify-next. */ if( pxCallbackInfo->callbackType == AWS_IOT_JOBS_DESCRIBE_COMPLETE ) { - pcRawDocument = pxCallbackInfo->u.operation.pResponse; + pcRawDocument = pxCallbackInfo->u.operation.pResponse; xRawDocumentLength = pxCallbackInfo->u.operation.responseLength; } else { - pcRawDocument = pxCallbackInfo->u.callback.pDocument; + pcRawDocument = pxCallbackInfo->u.callback.pDocument; xRawDocumentLength = pxCallbackInfo->u.callback.documentLength; } /* Get the Job ID. */ - xIdKeyFound = prvGetJsonString( pcRawDocument, - xRawDocumentLength, - jobsexampleID_KEY, - jobsexampleID_KEY_LENGTH, - &pcJobId, - &xJobIdLength ); + xIdKeyFound = prvGetJsonString( pcRawDocument, + xRawDocumentLength, + jobsexampleID_KEY, + jobsexampleID_KEY_LENGTH, + &pcJobId, + &xJobIdLength ); if( xIdKeyFound == pdTRUE ) { diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/atomic.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/atomic.h index ee2402255..56a13838b 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/atomic.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/atomic.h @@ -179,7 +179,7 @@ #else ATOMIC_ENTER_CRITICAL(); - pReturnValue = *ppDestination; + pReturnValue = *ppDestination; *ppDestination = pExchange; @@ -227,7 +227,7 @@ if( *ppDestination == pComparand ) { *ppDestination = pExchange; - ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; } ATOMIC_EXIT_CRITICAL(); #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */ @@ -382,7 +382,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination |= ulValue; @@ -413,7 +413,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination &= ulValue; @@ -444,7 +444,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination = ~( ulCurrent & ulValue ); @@ -475,7 +475,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination ^= ulValue; diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_logging.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_logging.c index e6aa16c3e..cd2cf8dfb 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_logging.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/demo_logging.c @@ -122,31 +122,31 @@ static void * pvLoggingThreadEvent = NULL; /* Stores the selected logging targets passed in as parameters to the * vLoggingInit() function. */ -BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE; +BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE; /* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32 * thread that is responsible for making Win32 calls (when stdout or a disk log is * used). */ -static StreamBuffer_t * xLogStreamBuffer = NULL; +static StreamBuffer_t * xLogStreamBuffer = NULL; /* Handle to the file used for logging. This is left open while there are * messages waiting to be logged, then closed again in between logs. */ -static FILE * pxLoggingFileHandle = NULL; +static FILE * pxLoggingFileHandle = NULL; /* When true prints are performed directly. After start up xDirectPrint is set * to pdFALSE - at which time prints that require Win32 system calls are done by * the Win32 thread responsible for logging. */ -BaseType_t xDirectPrint = pdTRUE; +BaseType_t xDirectPrint = pdTRUE; /* File names for the in use and complete (full) log files. */ -static const char * pcLogFileName = "RTOSDemo.log"; -static const char * pcFullLogFileName = "RTOSDemo.ful"; +static const char * pcLogFileName = "RTOSDemo.log"; +static const char * pcFullLogFileName = "RTOSDemo.ful"; /* As an optimization, the current file size is kept in a variable. */ -static size_t ulSizeOfLoggingFile = 0ul; +static size_t ulSizeOfLoggingFile = 0ul; /* The UDP socket and address on/to which print messages are sent. */ -Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET; +Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET; struct freertos_sockaddr xPrintUDPAddress; /*-----------------------------------------------------------*/ @@ -165,9 +165,9 @@ void vLoggingInit( BaseType_t xLogToStdout, HANDLE Win32Thread; /* Record which output methods are to be used. */ - xStdoutLoggingUsed = xLogToStdout; + xStdoutLoggingUsed = xLogToStdout; xDiskFileLoggingUsed = xLogToFile; - xUDPLoggingUsed = xLogToUDP; + xUDPLoggingUsed = xLogToUDP; /* If a disk file is used then initialize it now. */ if( xDiskFileLoggingUsed != pdFALSE ) @@ -193,16 +193,16 @@ void vLoggingInit( BaseType_t xLogToStdout, if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) ) { /* Create the buffer. */ - xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 ); + xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 ); configASSERT( xLogStreamBuffer ); memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) ); xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1; /* Create the Windows event. */ - pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" ); + pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" ); /* Create the thread itself. */ - Win32Thread = CreateThread( + Win32Thread = CreateThread( NULL, /* Pointer to thread security attributes. */ 0, /* Initial thread stack size, in bytes. */ prvWin32LoggingThread, /* Pointer to thread function. */ @@ -234,7 +234,7 @@ static void prvCreatePrintSocket( void * pvParameter1, uint32_t ulParameter2 ) { static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 ); - Socket_t xSocket; + Socket_t xSocket; /* The function prototype is that of a deferred function, but the parameters * are not actually used. */ @@ -258,17 +258,17 @@ static void prvCreatePrintSocket( void * pvParameter1, void vLoggingPrintf( const char * pcFormat, ... ) { - char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; - char cOutputString[ dlMAX_PRINT_STRING_LENGTH ]; - char * pcSource, * pcTarget, * pcBegin; - size_t xLength, xLength2, rc; + char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; + char cOutputString[ dlMAX_PRINT_STRING_LENGTH ]; + char * pcSource, * pcTarget, * pcBegin; + size_t xLength, xLength2, rc; static BaseType_t xMessageNumber = 0; - va_list args; - uint32_t ulIPAddress; - const char * pcTaskName; - const char * pcNoTask = "None"; - int iOriginalPriority; - HANDLE xCurrentTask; + va_list args; + uint32_t ulIPAddress; + const char * pcTaskName; + const char * pcNoTask = "None"; + int iOriginalPriority; + HANDLE xCurrentTask; if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) ) @@ -304,7 +304,7 @@ void vLoggingPrintf( const char * pcFormat, if( xLength2 < 0 ) { /* Clean up. */ - xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength; + xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength; cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0'; } @@ -328,7 +328,7 @@ void vLoggingPrintf( const char * pcFormat, *pcTarget = *pcSource; pcTarget++; *pcTarget = '\0'; - pcBegin = pcTarget - 8; + pcBegin = pcTarget - 8; while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) ) { @@ -336,18 +336,18 @@ void vLoggingPrintf( const char * pcFormat, } sscanf( pcTarget, "%8X", &ulIPAddress ); - rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", - ( unsigned long ) ( ulIPAddress >> 24UL ), - ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), - ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ), - ( unsigned long ) ( ulIPAddress & 0xffUL ) ); + rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", + ( unsigned long ) ( ulIPAddress >> 24UL ), + ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), + ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ), + ( unsigned long ) ( ulIPAddress & 0xffUL ) ); pcTarget += rc; pcSource += 3; /* skip "<n>ip" */ } } /* How far through the buffer was written? */ - xLength = ( BaseType_t ) ( pcTarget - cOutputString ); + xLength = ( BaseType_t ) ( pcTarget - cOutputString ); /* If the message is to be logged to a UDP port then it can be sent directly * because it only uses FreeRTOS function (not Win32 functions). */ @@ -393,7 +393,7 @@ void vLoggingPrintf( const char * pcFormat, * as there are potentially multiple writers. The stream buffer is * only thread safe when there is a single writer (likewise for * reading from the buffer). */ - xCurrentTask = GetCurrentThread(); + xCurrentTask = GetCurrentThread(); iOriginalPriority = GetThreadPriority( xCurrentTask ); SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL ); uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) ); @@ -426,7 +426,7 @@ void vLoggingPrintf( const char * pcFormat, static void prvLoggingFlushBuffer( void ) { size_t xLength; - char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; + char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; /* Is there more than the length value stored in the circular buffer * used to pass data from the FreeRTOS simulator into this Win32 thread? */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/main.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/main.c index 5cfd017ed..6a139d303 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/main.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/main.c @@ -94,7 +94,7 @@ const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALS * to and from a real network connection on the host PC. See the * configNETWORK_INTERFACE_TO_USE definition for information on how to configure * the real network connection to use. */ -const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 }; +const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 }; /* Use by the pseudo random number generator. */ static UBaseType_t ulNextRand; @@ -139,8 +139,8 @@ int main( void ) * events are only received if implemented in the MAC driver. */ void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent ) { - uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; - char cBuffer[ 16 ]; + uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; + char cBuffer[ 16 ]; static BaseType_t xTasksAlreadyCreated = pdFALSE; /* If the network has just come up...*/ @@ -179,8 +179,8 @@ void vAssertCalled( const char * pcFile, uint32_t ulLine ) { volatile uint32_t ulBlockVariable = 0UL; - volatile char * pcFileName = ( volatile char * ) pcFile; - volatile uint32_t ulLineNumber = ulLine; + volatile char * pcFileName = ( volatile char * ) pcFile; + volatile uint32_t ulLineNumber = ulLine; ( void ) pcFileName; ( void ) ulLineNumber; @@ -225,7 +225,7 @@ static void prvSRand( UBaseType_t ulSeed ) static void prvMiscInitialisation( void ) { - time_t xTimeNow; + time_t xTimeNow; uint32_t ulLoggingIPAddress; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 ); @@ -333,11 +333,11 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, * function then they must be declared static - otherwise they will be allocated on * the stack and so not exists after this function exits. */ static StaticTask_t xIdleTaskTCB; - static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; + static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; /* Pass out a pointer to the StaticTask_t structure in which the Idle task's * state will be stored. */ - *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; /* Pass out the array that will be used as the Idle task's stack. */ *ppxIdleTaskStackBuffer = uxIdleTaskStack; @@ -345,7 +345,7 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; } /*-----------------------------------------------------------*/ @@ -360,11 +360,11 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, * function then they must be declared static - otherwise they will be allocated on * the stack and so not exists after this function exits. */ static StaticTask_t xTimerTaskTCB; - static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; + static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; /* Pass out a pointer to the StaticTask_t structure in which the Timer * task's state will be stored. */ - *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; /* Pass out the array that will be used as the Timer task's stack. */ *ppxTimerTaskStackBuffer = uxTimerTaskStack; @@ -372,6 +372,6 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/printf-stdarg.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/printf-stdarg.c index f9bc5b5b1..ae28ddde0 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/printf-stdarg.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/jobs/jobs_notify_next/printf-stdarg.c @@ -64,7 +64,7 @@ static void strbuf_init( struct SStringBuf * apStr, char * apBuf, const char * apMaxStr ) { - apStr->str = apBuf; + apStr->str = apBuf; apStr->orgStr = apBuf; apStr->nulPos = apMaxStr - 1; apStr->curLen = 0; @@ -158,7 +158,7 @@ static BaseType_t prints( struct SStringBuf * apBuf, const char * apString ) { register int padchar = ' '; - int i, len; + int i, len; if( xApplicationMemoryPermissions( ( uint32_t ) apString ) == 0 ) { @@ -169,7 +169,7 @@ static BaseType_t prints( struct SStringBuf * apBuf, if( apBuf->flags.width > 0 ) { - register int len = 0; + register int len = 0; register const char * ptr; for( ptr = apString; *ptr; ++ptr ) @@ -257,11 +257,11 @@ static BaseType_t prints( struct SStringBuf * apBuf, static BaseType_t printll( struct SStringBuf * apBuf, long long i ) { - char print_buf[ 2 * PRINT_BUF_LEN ]; - register char * s; - register int t, neg = 0; + char print_buf[ 2 * PRINT_BUF_LEN ]; + register char * s; + register int t, neg = 0; register unsigned long long u = i; - lldiv_t lldiv_result; + lldiv_t lldiv_result; /* typedef struct * { @@ -282,26 +282,26 @@ static BaseType_t prints( struct SStringBuf * apBuf, if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) ) { neg = 1; - u = -i; + u = -i; } - s = print_buf + sizeof( print_buf ) - 1; + s = print_buf + sizeof( print_buf ) - 1; - *s = '\0'; + *s = '\0'; /* 18446744073709551616 */ while( u != 0 ) { lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base ); - t = lldiv_result.rem; + t = lldiv_result.rem; if( t >= 10 ) { t += apBuf->flags.letBase - '0' - 10; } - *( --s ) = t + '0'; - u = lldiv_result.quot; + *( --s ) = t + '0'; + u = lldiv_result.quot; } if( neg != 0 ) @@ -329,11 +329,11 @@ static BaseType_t prints( struct SStringBuf * apBuf, static BaseType_t printi( struct SStringBuf * apBuf, int i ) { - char print_buf[ PRINT_BUF_LEN ]; - register char * s; - register int t, neg = 0; - register unsigned int u = i; - register unsigned base = apBuf->flags.base; + char print_buf[ PRINT_BUF_LEN ]; + register char * s; + register int t, neg = 0; + register unsigned int u = i; + register unsigned base = apBuf->flags.base; apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */ @@ -347,12 +347,12 @@ static BaseType_t printi( struct SStringBuf * apBuf, if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) ) { neg = 1; - u = -i; + u = -i; } - s = print_buf + sizeof( print_buf ) - 1; + s = print_buf + sizeof( print_buf ) - 1; - *s = '\0'; + *s = '\0'; switch( base ) { @@ -360,7 +360,7 @@ static BaseType_t printi( struct SStringBuf * apBuf, while( u != 0 ) { - t = u & 0xF; + t = u & 0xF; if( t >= 10 ) { @@ -368,7 +368,7 @@ static BaseType_t printi( struct SStringBuf * apBuf, } *( --s ) = t + '0'; - u >>= 4; + u >>= 4; } break; @@ -379,9 +379,9 @@ static BaseType_t printi( struct SStringBuf * apBuf, /* GCC compiles very efficient */ while( u ) { - t = u % base; + t = u % base; *( --s ) = t + '0'; - u /= base; + u /= base; } break; @@ -487,19 +487,19 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == '-' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.pad = PAD_RIGHT; } while( ch == '0' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.pad |= PAD_ZERO; } if( ch == '*' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.width = va_arg( args, int ); } else @@ -508,7 +508,7 @@ static void tiny_print( struct SStringBuf * apBuf, { apBuf->flags.width *= 10; apBuf->flags.width += ch - '0'; - ch = *( format++ ); + ch = *( format++ ); } } @@ -519,7 +519,7 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == '*' ) { apBuf->flags.printLimit = va_arg( args, int ); - ch = *( format++ ); + ch = *( format++ ); } else { @@ -527,7 +527,7 @@ static void tiny_print( struct SStringBuf * apBuf, { apBuf->flags.printLimit *= 10; apBuf->flags.printLimit += ch - '0'; - ch = *( format++ ); + ch = *( format++ ); } } } @@ -564,19 +564,19 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == 'l' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.long32 = 1; /* Makes not difference as u32 == long */ } if( ch == 'L' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.long64 = 1; /* Does make a difference */ } - apBuf->flags.base = 10; + apBuf->flags.base = 10; apBuf->flags.letBase = 'a'; if( ( ch == 'd' ) || ( ch == 'u' ) ) @@ -601,7 +601,7 @@ static void tiny_print( struct SStringBuf * apBuf, continue; } - apBuf->flags.base = 16; /* From here all hexadecimal */ + apBuf->flags.base = 16; /* From here all hexadecimal */ if( ( ch == 'x' ) && ( format[ 0 ] == 'i' ) && ( format[ 1 ] == 'p' ) ) { @@ -670,7 +670,7 @@ int snprintf( char * apBuf, const char * apFmt, ... ) { - va_list args; + va_list args; va_start( args, apFmt ); struct SStringBuf strBuf; @@ -686,7 +686,7 @@ int sprintf( char * apBuf, const char * apFmt, ... ) { - va_list args; + va_list args; va_start( args, apFmt ); struct SStringBuf strBuf; @@ -716,21 +716,21 @@ const char * mkSize( unsigned long long aSize, int aLen ) { static char retString[ 33 ]; - size_t gb, mb, kb, sb; + size_t gb, mb, kb, sb; if( apBuf == NULL ) { apBuf = retString; - aLen = sizeof( retString ); + aLen = sizeof( retString ); } - gb = aSize / ( 1024 * 1024 * 1024 ); + gb = aSize / ( 1024 * 1024 * 1024 ); aSize -= gb * ( 1024 * 1024 * 1024 ); - mb = aSize / ( 1024 * 1024 ); + mb = aSize / ( 1024 * 1024 ); aSize -= mb * ( 1024 * 1024 ); - kb = aSize / ( 1024 ); + kb = aSize / ( 1024 ); aSize -= kb * ( 1024 ); - sb = aSize; + sb = aSize; if( gb ) { diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/LightWeightMQTTExample.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/LightWeightMQTTExample.c index eea317e44..b327197a5 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/LightWeightMQTTExample.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/LightWeightMQTTExample.c @@ -280,7 +280,7 @@ void vStartSimpleMQTTDemo( void ) static void prvGracefulShutDown( Socket_t xSocket ) { - uint8_t ucDummy[ 20 ]; + uint8_t ucDummy[ 20 ]; const TickType_t xShortDelay = pdMS_TO_MIN_TICKS( 250 ); if( xSocket != ( Socket_t ) 0 ) @@ -313,8 +313,8 @@ static void prvGracefulShutDown( Socket_t xSocket ) static IotMqttError_t getNextByte( IotNetworkConnection_t pvContext, uint8_t * pNextByte ) { - Socket_t xMQTTSocket = ( Socket_t ) pvContext; - BaseType_t receivedBytes; + Socket_t xMQTTSocket = ( Socket_t ) pvContext; + BaseType_t receivedBytes; IotMqttError_t result; /* Receive one byte from network. Note the use of this function may be @@ -336,8 +336,8 @@ static IotMqttError_t getNextByte( IotNetworkConnection_t pvContext, static void prvMQTTDemoTask( void * pvParameters ) { - Socket_t xMQTTSocket; - uint32_t ulPublishCount = 0; + Socket_t xMQTTSocket; + uint32_t ulPublishCount = 0; const uint32_t ulMaxPublishCount = 5UL; /* Remove compiler warnings about unused parameters. */ @@ -433,10 +433,10 @@ static void prvMQTTDemoTask( void * pvParameters ) static Socket_t prvCreateTCPConnectionToBroker( void ) { - Socket_t xMQTTSocket = FREERTOS_INVALID_SOCKET; + Socket_t xMQTTSocket = FREERTOS_INVALID_SOCKET; struct freertos_sockaddr xBrokerAddress; - uint32_t ulBrokerIPAddress; - BaseType_t xStatus = pdFAIL; + uint32_t ulBrokerIPAddress; + BaseType_t xStatus = pdFAIL; /* This is the socket used to connect to the MQTT broker. */ xMQTTSocket = FreeRTOS_socket( FREERTOS_AF_INET, @@ -491,11 +491,11 @@ static Socket_t prvCreateTCPConnectionToBroker( void ) static void prvCreateMQTTConnectionWithBroker( Socket_t xMQTTSocket ) { IotMqttConnectInfo_t xConnectInfo; - size_t xRemainingLength; - size_t xPacketSize; - IotMqttError_t xResult; - IotMqttPacketInfo_t xIncomingPacket; - BaseType_t xStatus; + size_t xRemainingLength; + size_t xPacketSize; + IotMqttError_t xResult; + IotMqttPacketInfo_t xIncomingPacket; + BaseType_t xStatus; /*** * For readability, error handling in this function is restricted to the use of @@ -509,26 +509,26 @@ static void prvCreateMQTTConnectionWithBroker( Socket_t xMQTTSocket ) * previous session data. Also, establishing a connection with clean session * will ensure that the broker does not store any data when this client * gets disconnected. */ - xConnectInfo.cleanSession = true; + xConnectInfo.cleanSession = true; /* The client identifier is used to uniquely identify this MQTT client to * the MQTT broker. In a production device the identifier can be something * unique, such as a device serial number. */ - xConnectInfo.pClientIdentifier = mqttexampleCLIENT_IDENTIFIER; + xConnectInfo.pClientIdentifier = mqttexampleCLIENT_IDENTIFIER; xConnectInfo.clientIdentifierLength = ( uint16_t ) strlen( mqttexampleCLIENT_IDENTIFIER ); /* Get size requirement for the connect packet */ - xResult = IotMqtt_GetConnectPacketSize( &xConnectInfo, &xRemainingLength, &xPacketSize ); + xResult = IotMqtt_GetConnectPacketSize( &xConnectInfo, &xRemainingLength, &xPacketSize ); /* Make sure the packet size is less than static buffer size. */ configASSERT( xResult == IOT_MQTT_SUCCESS ); configASSERT( xPacketSize < mqttexampleSHARED_BUFFER_SIZE ); /* Serialize MQTT connect packet into the provided buffer. */ - xResult = IotMqtt_SerializeConnect( &xConnectInfo, xRemainingLength, ucSharedBuffer, xPacketSize ); + xResult = IotMqtt_SerializeConnect( &xConnectInfo, xRemainingLength, ucSharedBuffer, xPacketSize ); configASSERT( xResult == IOT_MQTT_SUCCESS ); - xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 ); + xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 ); configASSERT( xStatus == ( BaseType_t ) xPacketSize ); /* Reset all fields of the incoming packet structure. */ @@ -540,17 +540,17 @@ static void prvCreateMQTTConnectionWithBroker( Socket_t xMQTTSocket ) * this case to keep the example simple error checks are just performed by * asserts. */ - xResult = IotMqtt_GetIncomingMQTTPacketTypeAndLength( &xIncomingPacket, getNextByte, ( void * ) xMQTTSocket ); + xResult = IotMqtt_GetIncomingMQTTPacketTypeAndLength( &xIncomingPacket, getNextByte, ( void * ) xMQTTSocket ); configASSERT( xResult == IOT_MQTT_SUCCESS ); configASSERT( xIncomingPacket.type == MQTT_PACKET_TYPE_CONNACK ); configASSERT( xIncomingPacket.remainingLength <= mqttexampleSHARED_BUFFER_SIZE ); /* Now receive the reset of the packet into the statically allocated buffer. */ - xStatus = FreeRTOS_recv( xMQTTSocket, ( void * ) ucSharedBuffer, xIncomingPacket.remainingLength, 0 ); + xStatus = FreeRTOS_recv( xMQTTSocket, ( void * ) ucSharedBuffer, xIncomingPacket.remainingLength, 0 ); configASSERT( xStatus == ( BaseType_t ) xIncomingPacket.remainingLength ); - xIncomingPacket.pRemainingData = ucSharedBuffer; - xResult = IotMqtt_DeserializeResponse( &xIncomingPacket ); + xIncomingPacket.pRemainingData = ucSharedBuffer; + xResult = IotMqtt_DeserializeResponse( &xIncomingPacket ); configASSERT( xResult == IOT_MQTT_SUCCESS ); @@ -563,11 +563,11 @@ static void prvCreateMQTTConnectionWithBroker( Socket_t xMQTTSocket ) static void prvMQTTSubscribeToTopic( Socket_t xMQTTSocket ) { - IotMqttError_t xResult; + IotMqttError_t xResult; IotMqttSubscription_t xMQTTSubscription[ 1 ]; - size_t xRemainingLength; - size_t xPacketSize; - BaseType_t xStatus; + size_t xRemainingLength; + size_t xPacketSize; + BaseType_t xStatus; /*** * For readability, error handling in this function is restricted to the use of @@ -579,43 +579,43 @@ static void prvMQTTSubscribeToTopic( Socket_t xMQTTSocket ) /* Subscribe to the mqttexampleTOPIC topic filter. This example subscribes to * only one topic and uses QOS0. */ - xMQTTSubscription[ 0 ].qos = IOT_MQTT_QOS_0; - xMQTTSubscription[ 0 ].pTopicFilter = mqttexampleTOPIC; + xMQTTSubscription[ 0 ].qos = IOT_MQTT_QOS_0; + xMQTTSubscription[ 0 ].pTopicFilter = mqttexampleTOPIC; xMQTTSubscription[ 0 ].topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC ); - xResult = IotMqtt_GetSubscriptionPacketSize( IOT_MQTT_SUBSCRIBE, - xMQTTSubscription, - sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ), - &xRemainingLength, &xPacketSize ); + xResult = IotMqtt_GetSubscriptionPacketSize( IOT_MQTT_SUBSCRIBE, + xMQTTSubscription, + sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ), + &xRemainingLength, &xPacketSize ); /* Make sure the packet size is less than static buffer size. */ configASSERT( xResult == IOT_MQTT_SUCCESS ); configASSERT( xPacketSize < mqttexampleSHARED_BUFFER_SIZE ); /* Serialize subscribe into statically allocated ucSharedBuffer. */ - xResult = IotMqtt_SerializeSubscribe( xMQTTSubscription, - sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ), - xRemainingLength, - &usSubscribePacketIdentifier, - ucSharedBuffer, - xPacketSize ); + xResult = IotMqtt_SerializeSubscribe( xMQTTSubscription, + sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ), + xRemainingLength, + &usSubscribePacketIdentifier, + ucSharedBuffer, + xPacketSize ); configASSERT( xResult == IOT_MQTT_SUCCESS ); /* Send Subscribe request to the broker. */ - xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 ); + xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 ); configASSERT( xStatus == ( BaseType_t ) xPacketSize ); } /*-----------------------------------------------------------*/ static void prvMQTTPublishToTopic( Socket_t xMQTTSocket ) { - IotMqttError_t xResult; + IotMqttError_t xResult; IotMqttPublishInfo_t xMQTTPublishInfo; - size_t xRemainingLength; - size_t xPacketSize = 0; - uint8_t * pusPacketIdentifierHigh; - BaseType_t xStatus; + size_t xRemainingLength; + size_t xPacketSize = 0; + uint8_t * pusPacketIdentifierHigh; + BaseType_t xStatus; /*** @@ -627,41 +627,41 @@ static void prvMQTTPublishToTopic( Socket_t xMQTTSocket ) memset( ( void * ) &xMQTTPublishInfo, 0x00, sizeof( xMQTTPublishInfo ) ); /* This demo uses QOS0 */ - xMQTTPublishInfo.qos = IOT_MQTT_QOS_0; - xMQTTPublishInfo.retain = false; - xMQTTPublishInfo.pTopicName = mqttexampleTOPIC; + xMQTTPublishInfo.qos = IOT_MQTT_QOS_0; + xMQTTPublishInfo.retain = false; + xMQTTPublishInfo.pTopicName = mqttexampleTOPIC; xMQTTPublishInfo.topicNameLength = ( uint16_t ) strlen( mqttexampleTOPIC ); - xMQTTPublishInfo.pPayload = mqttexampleMESSAGE; - xMQTTPublishInfo.payloadLength = strlen( mqttexampleMESSAGE ); + xMQTTPublishInfo.pPayload = mqttexampleMESSAGE; + xMQTTPublishInfo.payloadLength = strlen( mqttexampleMESSAGE ); /* Find out length of Publish packet size. */ - xResult = IotMqtt_GetPublishPacketSize( &xMQTTPublishInfo, &xRemainingLength, &xPacketSize ); + xResult = IotMqtt_GetPublishPacketSize( &xMQTTPublishInfo, &xRemainingLength, &xPacketSize ); configASSERT( xResult == IOT_MQTT_SUCCESS ); /* Make sure the packet size is less than static buffer size. */ configASSERT( xPacketSize < mqttexampleSHARED_BUFFER_SIZE ); - xResult = IotMqtt_SerializePublish( &xMQTTPublishInfo, - xRemainingLength, - &usPublishPacketIdentifier, - &pusPacketIdentifierHigh, - ucSharedBuffer, - xPacketSize ); + xResult = IotMqtt_SerializePublish( &xMQTTPublishInfo, + xRemainingLength, + &usPublishPacketIdentifier, + &pusPacketIdentifierHigh, + ucSharedBuffer, + xPacketSize ); configASSERT( xResult == IOT_MQTT_SUCCESS ); /* Send Publish message to the broker. */ - xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 ); + xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 ); configASSERT( xStatus == ( BaseType_t ) xPacketSize ); } /*-----------------------------------------------------------*/ static void prvMQTTUnsubscribeFromTopic( Socket_t xMQTTSocket ) { - IotMqttError_t xResult; + IotMqttError_t xResult; IotMqttSubscription_t xMQTTSubscription[ 1 ]; - size_t xRemainingLength; - size_t xPacketSize; - BaseType_t xStatus; + size_t xRemainingLength; + size_t xPacketSize; + BaseType_t xStatus; /* Some fields not used by this demo so start with everything at 0. */ memset( ( void * ) &xMQTTSubscription, 0x00, sizeof( xMQTTSubscription ) ); @@ -669,29 +669,29 @@ static void prvMQTTUnsubscribeFromTopic( Socket_t xMQTTSocket ) /* Unsubscribe to the mqttexampleTOPIC topic filter. The task handle is passed * as the callback context which is used by the callback to send a task * notification to this task.*/ - xMQTTSubscription[ 0 ].qos = IOT_MQTT_QOS_0; - xMQTTSubscription[ 0 ].pTopicFilter = mqttexampleTOPIC; + xMQTTSubscription[ 0 ].qos = IOT_MQTT_QOS_0; + xMQTTSubscription[ 0 ].pTopicFilter = mqttexampleTOPIC; xMQTTSubscription[ 0 ].topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC ); - xResult = IotMqtt_GetSubscriptionPacketSize( IOT_MQTT_UNSUBSCRIBE, - xMQTTSubscription, - sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ), - &xRemainingLength, - &xPacketSize ); + xResult = IotMqtt_GetSubscriptionPacketSize( IOT_MQTT_UNSUBSCRIBE, + xMQTTSubscription, + sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ), + &xRemainingLength, + &xPacketSize ); configASSERT( xResult == IOT_MQTT_SUCCESS ); /* Make sure the packet size is less than static buffer size */ configASSERT( xPacketSize < mqttexampleSHARED_BUFFER_SIZE ); - xResult = IotMqtt_SerializeUnsubscribe( xMQTTSubscription, - sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ), - xRemainingLength, - &usUnsubscribePacketIdentifier, - ucSharedBuffer, - xPacketSize ); + xResult = IotMqtt_SerializeUnsubscribe( xMQTTSubscription, + sizeof( xMQTTSubscription ) / sizeof( IotMqttSubscription_t ), + xRemainingLength, + &usUnsubscribePacketIdentifier, + ucSharedBuffer, + xPacketSize ); configASSERT( xResult == IOT_MQTT_SUCCESS ); /* Send Unsubscribe request to the broker. */ - xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 ); + xStatus = FreeRTOS_send( xMQTTSocket, ( void * ) ucSharedBuffer, xPacketSize, 0 ); configASSERT( xStatus == ( BaseType_t ) xPacketSize ); } /*-----------------------------------------------------------*/ @@ -699,7 +699,7 @@ static void prvMQTTUnsubscribeFromTopic( Socket_t xMQTTSocket ) static void prvMQTTKeepAlive( Socket_t xMQTTSocket ) { IotMqttError_t xResult; - BaseType_t xStatus; + BaseType_t xStatus; /* PingReq is fixed length packet, therefore there is no need to calculate the size, * just makes sure static buffer can accommodate ping request. */ @@ -718,7 +718,7 @@ static void prvMQTTKeepAlive( Socket_t xMQTTSocket ) static void prvMQTTDisconnect( Socket_t xMQTTSocket ) { IotMqttError_t xResult; - BaseType_t xStatus; + BaseType_t xStatus; /* Disconnect is fixed length packet, therefore there is no need to calculate the size, * just makes sure static buffer can accommodate disconnect request. */ @@ -802,9 +802,9 @@ static void prvMQTTProcessIncomingPublish( IotMqttPacketInfo_t * pxIncomingPacke static void prvMQTTProcessIncomingPacket( Socket_t xMQTTSocket ) { - IotMqttError_t xResult; + IotMqttError_t xResult; IotMqttPacketInfo_t xIncomingPacket; - BaseType_t xStatus; + BaseType_t xStatus; /*** * For readability, error handling in this function is restricted to the use of @@ -814,7 +814,7 @@ static void prvMQTTProcessIncomingPacket( Socket_t xMQTTSocket ) memset( ( void * ) &xIncomingPacket, 0x00, sizeof( IotMqttPacketInfo_t ) ); /* Determine incoming packet type and remaining length. */ - xResult = IotMqtt_GetIncomingMQTTPacketTypeAndLength( &xIncomingPacket, getNextByte, ( void * ) xMQTTSocket ); + xResult = IotMqtt_GetIncomingMQTTPacketTypeAndLength( &xIncomingPacket, getNextByte, ( void * ) xMQTTSocket ); configASSERT( xResult == IOT_MQTT_SUCCESS ); configASSERT( xIncomingPacket.remainingLength <= mqttexampleSHARED_BUFFER_SIZE ); @@ -822,7 +822,7 @@ static void prvMQTTProcessIncomingPacket( Socket_t xMQTTSocket ) * responses ( SUBACK, PINGRESP and UNSUBACK ). */ /* Receive the remaining bytes. */ - xStatus = FreeRTOS_recv( xMQTTSocket, ( void * ) ucSharedBuffer, xIncomingPacket.remainingLength, 0 ); + xStatus = FreeRTOS_recv( xMQTTSocket, ( void * ) ucSharedBuffer, xIncomingPacket.remainingLength, 0 ); configASSERT( xStatus == ( BaseType_t ) xIncomingPacket.remainingLength ); xIncomingPacket.pRemainingData = ucSharedBuffer; diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/SimpleMQTTExamples.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/SimpleMQTTExamples.c index 6fae4b1d2..2ec2e10aa 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/SimpleMQTTExamples.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/DemoTasks/SimpleMQTTExamples.c @@ -231,18 +231,18 @@ static void prvInitialiseLibraries( void ); /** * @brief The MQTT connection handle used in this example. */ -static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER; +static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER; /*-----------------------------------------------------------*/ -static const struct IotNetworkServerInfo xMQTTBrokerInfo = +static const struct IotNetworkServerInfo xMQTTBrokerInfo = { .pHostName = mqttexampleBROKER_ENDPOINT, .port = mqttexampleBROKER_PORT }; #if ( democonfigENABLE_TLS ) - static struct IotNetworkCredentials xNetworkSecurityCredentials = + static struct IotNetworkCredentials xNetworkSecurityCredentials = { /* Optional TLS extensions. For this demo, they are disabled. */ .pAlpnProtos = NULL, @@ -272,7 +272,7 @@ static const struct IotNetworkServerInfo xMQTTBrokerInfo = }; #endif /* if ( democonfigENABLE_TLS ) */ -static IotMqttNetworkInfo_t xNetworkInfo = +static IotMqttNetworkInfo_t xNetworkInfo = { /* No connection to the MQTT broker has been established yet and we want to * establish a new connection. */ @@ -296,7 +296,7 @@ static IotMqttNetworkInfo_t xNetworkInfo = .disconnectCallback.function = prvExample_OnDisconnect }; -static const IotMqttConnectInfo_t xConnectInfo = +static const IotMqttConnectInfo_t xConnectInfo = { /* Set this flag to true if connecting to the AWS IoT MQTT broker. */ #if ( democonfigPROFILE_USE_AWS_IOT == 1 ) @@ -361,9 +361,9 @@ void vStartSimpleMQTTDemo( void ) static void prvMQTTDemoTask( void * pvParameters ) { - uint32_t ulNotificationValue = 0, ulPublishCount; - const uint32_t ulMaxPublishCount = 5UL; - const TickType_t xNoDelay = ( TickType_t ) 0; + uint32_t ulNotificationValue = 0, ulPublishCount; + const uint32_t ulMaxPublishCount = 5UL; + const TickType_t xNoDelay = ( TickType_t ) 0; /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; @@ -537,86 +537,86 @@ static void prvMQTTDisconnect( void ) static void prvMQTTSubscribe( void ) { - IotMqttError_t xResult; + IotMqttError_t xResult; IotMqttSubscription_t xMQTTSubscription; /* Subscribe to the mqttexampleTOPIC topic filter. The task handle is passed * as the callback context, which is then used by the callback to send a task * notification to this task.*/ - xMQTTSubscription.qos = IOT_MQTT_QOS_1; - xMQTTSubscription.pTopicFilter = mqttexampleTOPIC; - xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC ); + xMQTTSubscription.qos = IOT_MQTT_QOS_1; + xMQTTSubscription.pTopicFilter = mqttexampleTOPIC; + xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC ); xMQTTSubscription.callback.pCallbackContext = ( void * ) xTaskGetCurrentTaskHandle(); - xMQTTSubscription.callback.function = prvExample_OnMessageReceived; + xMQTTSubscription.callback.function = prvExample_OnMessageReceived; /* Use the synchronous API to subscribe - It is a blocking call and only * returns when the subscribe operation is complete or a timeout occurs. */ - xResult = IotMqtt_SubscribeSync( xMQTTConnection, - &( xMQTTSubscription ), - 1, /* We are subscribing to one topic filter. */ - 0, /* flags - currently ignored. */ - mqttexampleMQTT_TIMEOUT_MS ); + xResult = IotMqtt_SubscribeSync( xMQTTConnection, + &( xMQTTSubscription ), + 1, /* We are subscribing to one topic filter. */ + 0, /* flags - currently ignored. */ + mqttexampleMQTT_TIMEOUT_MS ); configASSERT( xResult == IOT_MQTT_SUCCESS ); } /*-----------------------------------------------------------*/ static void prvMQTTPublish( void ) { - IotMqttError_t xResult; + IotMqttError_t xResult; IotMqttPublishInfo_t xMQTTPublishInfo; /* Publish a message with QoS1 on the mqttexampleTOPIC topic. Since we are * subscribed to the same topic, the MQTT broker will send the same message * back to us. It is verified in the publish callback. */ - xMQTTPublishInfo.qos = IOT_MQTT_QOS_1; - xMQTTPublishInfo.retain = false; - xMQTTPublishInfo.pTopicName = mqttexampleTOPIC; + xMQTTPublishInfo.qos = IOT_MQTT_QOS_1; + xMQTTPublishInfo.retain = false; + xMQTTPublishInfo.pTopicName = mqttexampleTOPIC; xMQTTPublishInfo.topicNameLength = ( uint16_t ) strlen( mqttexampleTOPIC ); - xMQTTPublishInfo.pPayload = mqttexampleMESSAGE; - xMQTTPublishInfo.payloadLength = strlen( mqttexampleMESSAGE ); - xMQTTPublishInfo.retryMs = mqttexamplePUBLISH_RETRY_MS; - xMQTTPublishInfo.retryLimit = mqttexamplePUBLISH_RETRY_LIMIT; + xMQTTPublishInfo.pPayload = mqttexampleMESSAGE; + xMQTTPublishInfo.payloadLength = strlen( mqttexampleMESSAGE ); + xMQTTPublishInfo.retryMs = mqttexamplePUBLISH_RETRY_MS; + xMQTTPublishInfo.retryLimit = mqttexamplePUBLISH_RETRY_LIMIT; /* Use the synchronous API to publish - It is a blocking call and only * returns when the publish operation is complete or a timeout occurs. */ - xResult = IotMqtt_PublishSync( xMQTTConnection, - &( xMQTTPublishInfo ), - 0, /* flags - currently ignored. */ - mqttexampleMQTT_TIMEOUT_MS ); + xResult = IotMqtt_PublishSync( xMQTTConnection, + &( xMQTTPublishInfo ), + 0, /* flags - currently ignored. */ + mqttexampleMQTT_TIMEOUT_MS ); configASSERT( xResult == IOT_MQTT_SUCCESS ); } /*-----------------------------------------------------------*/ static void prvMQTTUnsubscribe( void ) { - IotMqttError_t xResult; + IotMqttError_t xResult; IotMqttSubscription_t xMQTTSubscription; /* Unsubscribe from the mqttexampleTOPIC topic filter. */ - xMQTTSubscription.pTopicFilter = mqttexampleTOPIC; - xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC ); + xMQTTSubscription.pTopicFilter = mqttexampleTOPIC; + xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC ); /* The following members of the IotMqttSubscription_t are ignored by the * unsubscribe operation. Just initialize them to avoid "use of uninitialized * variable" warnings. */ - xMQTTSubscription.qos = IOT_MQTT_QOS_1; + xMQTTSubscription.qos = IOT_MQTT_QOS_1; xMQTTSubscription.callback.pCallbackContext = NULL; - xMQTTSubscription.callback.function = NULL; + xMQTTSubscription.callback.function = NULL; /* Use the synchronous API to unsubscribe - It is a blocking call and only * returns when the unsubscribe operation is complete or a timeout occurs. */ - xResult = IotMqtt_UnsubscribeSync( xMQTTConnection, - &( xMQTTSubscription ), - 1, /* We are unsubscribing from one topic filter. */ - 0, /* flags - currently ignored. */ - mqttexampleMQTT_TIMEOUT_MS ); + xResult = IotMqtt_UnsubscribeSync( xMQTTConnection, + &( xMQTTSubscription ), + 1, /* We are unsubscribing from one topic filter. */ + 0, /* flags - currently ignored. */ + mqttexampleMQTT_TIMEOUT_MS ); configASSERT( xResult == IOT_MQTT_SUCCESS ); } /*-----------------------------------------------------------*/ static void prvInitialiseLibraries( void ) { - IotMqttError_t xResult; + IotMqttError_t xResult; IotNetworkError_t xNetworkResult; /* Initialize the network stack abstraction for FreeRTOS. */ @@ -625,7 +625,7 @@ static void prvInitialiseLibraries( void ) /* MQTT library must be initialized before it can be used. This is just one * time initialization. */ - xResult = IotMqtt_Init(); + xResult = IotMqtt_Init(); configASSERT( xResult == IOT_MQTT_SUCCESS ); } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/Run-time-stats-utils.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/Run-time-stats-utils.c index 61a68dc82..b62afb3ea 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/Run-time-stats-utils.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/Run-time-stats-utils.c @@ -67,7 +67,7 @@ void vConfigureTimerForRunTimeStats( void ) /* What is the performance counter value now, this will be subtracted * from readings taken at run time. */ QueryPerformanceCounter( &liInitialRunTimeValue ); - llInitialRunTimeCounterValue = liInitialRunTimeValue.QuadPart; + llInitialRunTimeCounterValue = liInitialRunTimeValue.QuadPart; } } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/atomic.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/atomic.h index ee2402255..56a13838b 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/atomic.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/atomic.h @@ -179,7 +179,7 @@ #else ATOMIC_ENTER_CRITICAL(); - pReturnValue = *ppDestination; + pReturnValue = *ppDestination; *ppDestination = pExchange; @@ -227,7 +227,7 @@ if( *ppDestination == pComparand ) { *ppDestination = pExchange; - ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; } ATOMIC_EXIT_CRITICAL(); #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */ @@ -382,7 +382,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination |= ulValue; @@ -413,7 +413,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination &= ulValue; @@ -444,7 +444,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination = ~( ulCurrent & ulValue ); @@ -475,7 +475,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination ^= ulValue; diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/demo_logging.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/demo_logging.c index e6aa16c3e..cd2cf8dfb 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/demo_logging.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/demo_logging.c @@ -122,31 +122,31 @@ static void * pvLoggingThreadEvent = NULL; /* Stores the selected logging targets passed in as parameters to the * vLoggingInit() function. */ -BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE; +BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE; /* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32 * thread that is responsible for making Win32 calls (when stdout or a disk log is * used). */ -static StreamBuffer_t * xLogStreamBuffer = NULL; +static StreamBuffer_t * xLogStreamBuffer = NULL; /* Handle to the file used for logging. This is left open while there are * messages waiting to be logged, then closed again in between logs. */ -static FILE * pxLoggingFileHandle = NULL; +static FILE * pxLoggingFileHandle = NULL; /* When true prints are performed directly. After start up xDirectPrint is set * to pdFALSE - at which time prints that require Win32 system calls are done by * the Win32 thread responsible for logging. */ -BaseType_t xDirectPrint = pdTRUE; +BaseType_t xDirectPrint = pdTRUE; /* File names for the in use and complete (full) log files. */ -static const char * pcLogFileName = "RTOSDemo.log"; -static const char * pcFullLogFileName = "RTOSDemo.ful"; +static const char * pcLogFileName = "RTOSDemo.log"; +static const char * pcFullLogFileName = "RTOSDemo.ful"; /* As an optimization, the current file size is kept in a variable. */ -static size_t ulSizeOfLoggingFile = 0ul; +static size_t ulSizeOfLoggingFile = 0ul; /* The UDP socket and address on/to which print messages are sent. */ -Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET; +Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET; struct freertos_sockaddr xPrintUDPAddress; /*-----------------------------------------------------------*/ @@ -165,9 +165,9 @@ void vLoggingInit( BaseType_t xLogToStdout, HANDLE Win32Thread; /* Record which output methods are to be used. */ - xStdoutLoggingUsed = xLogToStdout; + xStdoutLoggingUsed = xLogToStdout; xDiskFileLoggingUsed = xLogToFile; - xUDPLoggingUsed = xLogToUDP; + xUDPLoggingUsed = xLogToUDP; /* If a disk file is used then initialize it now. */ if( xDiskFileLoggingUsed != pdFALSE ) @@ -193,16 +193,16 @@ void vLoggingInit( BaseType_t xLogToStdout, if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) ) { /* Create the buffer. */ - xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 ); + xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 ); configASSERT( xLogStreamBuffer ); memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) ); xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1; /* Create the Windows event. */ - pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" ); + pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" ); /* Create the thread itself. */ - Win32Thread = CreateThread( + Win32Thread = CreateThread( NULL, /* Pointer to thread security attributes. */ 0, /* Initial thread stack size, in bytes. */ prvWin32LoggingThread, /* Pointer to thread function. */ @@ -234,7 +234,7 @@ static void prvCreatePrintSocket( void * pvParameter1, uint32_t ulParameter2 ) { static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 ); - Socket_t xSocket; + Socket_t xSocket; /* The function prototype is that of a deferred function, but the parameters * are not actually used. */ @@ -258,17 +258,17 @@ static void prvCreatePrintSocket( void * pvParameter1, void vLoggingPrintf( const char * pcFormat, ... ) { - char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; - char cOutputString[ dlMAX_PRINT_STRING_LENGTH ]; - char * pcSource, * pcTarget, * pcBegin; - size_t xLength, xLength2, rc; + char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; + char cOutputString[ dlMAX_PRINT_STRING_LENGTH ]; + char * pcSource, * pcTarget, * pcBegin; + size_t xLength, xLength2, rc; static BaseType_t xMessageNumber = 0; - va_list args; - uint32_t ulIPAddress; - const char * pcTaskName; - const char * pcNoTask = "None"; - int iOriginalPriority; - HANDLE xCurrentTask; + va_list args; + uint32_t ulIPAddress; + const char * pcTaskName; + const char * pcNoTask = "None"; + int iOriginalPriority; + HANDLE xCurrentTask; if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) ) @@ -304,7 +304,7 @@ void vLoggingPrintf( const char * pcFormat, if( xLength2 < 0 ) { /* Clean up. */ - xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength; + xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength; cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0'; } @@ -328,7 +328,7 @@ void vLoggingPrintf( const char * pcFormat, *pcTarget = *pcSource; pcTarget++; *pcTarget = '\0'; - pcBegin = pcTarget - 8; + pcBegin = pcTarget - 8; while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) ) { @@ -336,18 +336,18 @@ void vLoggingPrintf( const char * pcFormat, } sscanf( pcTarget, "%8X", &ulIPAddress ); - rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", - ( unsigned long ) ( ulIPAddress >> 24UL ), - ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), - ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ), - ( unsigned long ) ( ulIPAddress & 0xffUL ) ); + rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", + ( unsigned long ) ( ulIPAddress >> 24UL ), + ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), + ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ), + ( unsigned long ) ( ulIPAddress & 0xffUL ) ); pcTarget += rc; pcSource += 3; /* skip "<n>ip" */ } } /* How far through the buffer was written? */ - xLength = ( BaseType_t ) ( pcTarget - cOutputString ); + xLength = ( BaseType_t ) ( pcTarget - cOutputString ); /* If the message is to be logged to a UDP port then it can be sent directly * because it only uses FreeRTOS function (not Win32 functions). */ @@ -393,7 +393,7 @@ void vLoggingPrintf( const char * pcFormat, * as there are potentially multiple writers. The stream buffer is * only thread safe when there is a single writer (likewise for * reading from the buffer). */ - xCurrentTask = GetCurrentThread(); + xCurrentTask = GetCurrentThread(); iOriginalPriority = GetThreadPriority( xCurrentTask ); SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL ); uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) ); @@ -426,7 +426,7 @@ void vLoggingPrintf( const char * pcFormat, static void prvLoggingFlushBuffer( void ) { size_t xLength; - char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; + char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; /* Is there more than the length value stored in the circular buffer * used to pass data from the FreeRTOS simulator into this Win32 thread? */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/main.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/main.c index 31a420480..af7ebd4e8 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/main.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/main.c @@ -94,7 +94,7 @@ const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALS * to and from a real network connection on the host PC. See the * configNETWORK_INTERFACE_TO_USE definition for information on how to configure * the real network connection to use. */ -const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 }; +const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 }; /* Use by the pseudo random number generator. */ static UBaseType_t ulNextRand; @@ -139,8 +139,8 @@ int main( void ) * events are only received if implemented in the MAC driver. */ void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent ) { - uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; - char cBuffer[ 16 ]; + uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; + char cBuffer[ 16 ]; static BaseType_t xTasksAlreadyCreated = pdFALSE; /* If the network has just come up...*/ @@ -179,8 +179,8 @@ void vAssertCalled( const char * pcFile, uint32_t ulLine ) { volatile uint32_t ulBlockVariable = 0UL; - volatile char * pcFileName = ( volatile char * ) pcFile; - volatile uint32_t ulLineNumber = ulLine; + volatile char * pcFileName = ( volatile char * ) pcFile; + volatile uint32_t ulLineNumber = ulLine; ( void ) pcFileName; ( void ) ulLineNumber; @@ -225,7 +225,7 @@ static void prvSRand( UBaseType_t ulSeed ) static void prvMiscInitialisation( void ) { - time_t xTimeNow; + time_t xTimeNow; uint32_t ulLoggingIPAddress; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 ); @@ -333,11 +333,11 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, * function then they must be declared static - otherwise they will be allocated on * the stack and so not exists after this function exits. */ static StaticTask_t xIdleTaskTCB; - static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; + static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; /* Pass out a pointer to the StaticTask_t structure in which the Idle task's * state will be stored. */ - *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; /* Pass out the array that will be used as the Idle task's stack. */ *ppxIdleTaskStackBuffer = uxIdleTaskStack; @@ -345,7 +345,7 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; } /*-----------------------------------------------------------*/ @@ -360,11 +360,11 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, * function then they must be declared static - otherwise they will be allocated on * the stack and so not exists after this function exits. */ static StaticTask_t xTimerTaskTCB; - static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; + static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; /* Pass out a pointer to the StaticTask_t structure in which the Timer * task's state will be stored. */ - *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; /* Pass out the array that will be used as the Timer task's stack. */ *ppxTimerTaskStackBuffer = uxTimerTaskStack; @@ -372,6 +372,6 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/printf-stdarg.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/printf-stdarg.c index f9bc5b5b1..ae28ddde0 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/printf-stdarg.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/mqtt/common/printf-stdarg.c @@ -64,7 +64,7 @@ static void strbuf_init( struct SStringBuf * apStr, char * apBuf, const char * apMaxStr ) { - apStr->str = apBuf; + apStr->str = apBuf; apStr->orgStr = apBuf; apStr->nulPos = apMaxStr - 1; apStr->curLen = 0; @@ -158,7 +158,7 @@ static BaseType_t prints( struct SStringBuf * apBuf, const char * apString ) { register int padchar = ' '; - int i, len; + int i, len; if( xApplicationMemoryPermissions( ( uint32_t ) apString ) == 0 ) { @@ -169,7 +169,7 @@ static BaseType_t prints( struct SStringBuf * apBuf, if( apBuf->flags.width > 0 ) { - register int len = 0; + register int len = 0; register const char * ptr; for( ptr = apString; *ptr; ++ptr ) @@ -257,11 +257,11 @@ static BaseType_t prints( struct SStringBuf * apBuf, static BaseType_t printll( struct SStringBuf * apBuf, long long i ) { - char print_buf[ 2 * PRINT_BUF_LEN ]; - register char * s; - register int t, neg = 0; + char print_buf[ 2 * PRINT_BUF_LEN ]; + register char * s; + register int t, neg = 0; register unsigned long long u = i; - lldiv_t lldiv_result; + lldiv_t lldiv_result; /* typedef struct * { @@ -282,26 +282,26 @@ static BaseType_t prints( struct SStringBuf * apBuf, if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) ) { neg = 1; - u = -i; + u = -i; } - s = print_buf + sizeof( print_buf ) - 1; + s = print_buf + sizeof( print_buf ) - 1; - *s = '\0'; + *s = '\0'; /* 18446744073709551616 */ while( u != 0 ) { lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base ); - t = lldiv_result.rem; + t = lldiv_result.rem; if( t >= 10 ) { t += apBuf->flags.letBase - '0' - 10; } - *( --s ) = t + '0'; - u = lldiv_result.quot; + *( --s ) = t + '0'; + u = lldiv_result.quot; } if( neg != 0 ) @@ -329,11 +329,11 @@ static BaseType_t prints( struct SStringBuf * apBuf, static BaseType_t printi( struct SStringBuf * apBuf, int i ) { - char print_buf[ PRINT_BUF_LEN ]; - register char * s; - register int t, neg = 0; - register unsigned int u = i; - register unsigned base = apBuf->flags.base; + char print_buf[ PRINT_BUF_LEN ]; + register char * s; + register int t, neg = 0; + register unsigned int u = i; + register unsigned base = apBuf->flags.base; apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */ @@ -347,12 +347,12 @@ static BaseType_t printi( struct SStringBuf * apBuf, if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) ) { neg = 1; - u = -i; + u = -i; } - s = print_buf + sizeof( print_buf ) - 1; + s = print_buf + sizeof( print_buf ) - 1; - *s = '\0'; + *s = '\0'; switch( base ) { @@ -360,7 +360,7 @@ static BaseType_t printi( struct SStringBuf * apBuf, while( u != 0 ) { - t = u & 0xF; + t = u & 0xF; if( t >= 10 ) { @@ -368,7 +368,7 @@ static BaseType_t printi( struct SStringBuf * apBuf, } *( --s ) = t + '0'; - u >>= 4; + u >>= 4; } break; @@ -379,9 +379,9 @@ static BaseType_t printi( struct SStringBuf * apBuf, /* GCC compiles very efficient */ while( u ) { - t = u % base; + t = u % base; *( --s ) = t + '0'; - u /= base; + u /= base; } break; @@ -487,19 +487,19 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == '-' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.pad = PAD_RIGHT; } while( ch == '0' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.pad |= PAD_ZERO; } if( ch == '*' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.width = va_arg( args, int ); } else @@ -508,7 +508,7 @@ static void tiny_print( struct SStringBuf * apBuf, { apBuf->flags.width *= 10; apBuf->flags.width += ch - '0'; - ch = *( format++ ); + ch = *( format++ ); } } @@ -519,7 +519,7 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == '*' ) { apBuf->flags.printLimit = va_arg( args, int ); - ch = *( format++ ); + ch = *( format++ ); } else { @@ -527,7 +527,7 @@ static void tiny_print( struct SStringBuf * apBuf, { apBuf->flags.printLimit *= 10; apBuf->flags.printLimit += ch - '0'; - ch = *( format++ ); + ch = *( format++ ); } } } @@ -564,19 +564,19 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == 'l' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.long32 = 1; /* Makes not difference as u32 == long */ } if( ch == 'L' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.long64 = 1; /* Does make a difference */ } - apBuf->flags.base = 10; + apBuf->flags.base = 10; apBuf->flags.letBase = 'a'; if( ( ch == 'd' ) || ( ch == 'u' ) ) @@ -601,7 +601,7 @@ static void tiny_print( struct SStringBuf * apBuf, continue; } - apBuf->flags.base = 16; /* From here all hexadecimal */ + apBuf->flags.base = 16; /* From here all hexadecimal */ if( ( ch == 'x' ) && ( format[ 0 ] == 'i' ) && ( format[ 1 ] == 'p' ) ) { @@ -670,7 +670,7 @@ int snprintf( char * apBuf, const char * apFmt, ... ) { - va_list args; + va_list args; va_start( args, apFmt ); struct SStringBuf strBuf; @@ -686,7 +686,7 @@ int sprintf( char * apBuf, const char * apFmt, ... ) { - va_list args; + va_list args; va_start( args, apFmt ); struct SStringBuf strBuf; @@ -716,21 +716,21 @@ const char * mkSize( unsigned long long aSize, int aLen ) { static char retString[ 33 ]; - size_t gb, mb, kb, sb; + size_t gb, mb, kb, sb; if( apBuf == NULL ) { apBuf = retString; - aLen = sizeof( retString ); + aLen = sizeof( retString ); } - gb = aSize / ( 1024 * 1024 * 1024 ); + gb = aSize / ( 1024 * 1024 * 1024 ); aSize -= gb * ( 1024 * 1024 * 1024 ); - mb = aSize / ( 1024 * 1024 ); + mb = aSize / ( 1024 * 1024 ); aSize -= mb * ( 1024 * 1024 ); - kb = aSize / ( 1024 ); + kb = aSize / ( 1024 ); aSize -= kb * ( 1024 ); - sb = aSize; + sb = aSize; if( gb ) { diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/DemoTasks/aws_iot_ota_update_demo.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/DemoTasks/aws_iot_ota_update_demo.c index 4ee43aaea..1bf2400bc 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/DemoTasks/aws_iot_ota_update_demo.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/DemoTasks/aws_iot_ota_update_demo.c @@ -121,7 +121,7 @@ static IotMqttError_t _establishMqttConnection( bool awsIotMqttMode, /** * @brief OTA state machine string. */ -static const char * pcStateStr[ eOTA_AgentState_All ] = +static const char * pcStateStr[ eOTA_AgentState_All ] = { "Init", "Ready", @@ -135,13 +135,13 @@ static const char * pcStateStr[ eOTA_AgentState_All ] = "Stopped" }; -static const struct IotNetworkServerInfo xMQTTBrokerInfo = +static const struct IotNetworkServerInfo xMQTTBrokerInfo = { .pHostName = awsiotdemoprofileAWS_ENDPOINT, .port = awsiotdemoprofileAWS_MQTT_PORT }; -static struct IotNetworkCredentials xNetworkSecurityCredentials = +static struct IotNetworkCredentials xNetworkSecurityCredentials = { /* Optional TLS extensions. For this demo, they are disabled. */ .pAlpnProtos = NULL, @@ -163,7 +163,7 @@ static struct IotNetworkCredentials xNetworkSecurityCredentials = .privateKeySize = sizeof( awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM ) }; -static IotMqttNetworkInfo_t xNetworkInfo = +static IotMqttNetworkInfo_t xNetworkInfo = { /* No connection to the MQTT broker has been established yet and we want to * establish a new connection. */ @@ -186,18 +186,18 @@ static IotMqttNetworkInfo_t xNetworkInfo = /** * @brief The MQTT connection handle used in this example. */ -static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER; +static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER; /** * @brief The MQTT connection info used for MQTT connection. */ -IotMqttConnectInfo_t xConnectInfo = IOT_MQTT_CONNECT_INFO_INITIALIZER; +IotMqttConnectInfo_t xConnectInfo = IOT_MQTT_CONNECT_INFO_INITIALIZER; /** * @brief Flag used to unset, during disconnection of currently connected network. This will * trigger a reconnection from the OTA demo task. */ -volatile static bool _networkConnected = false; +volatile static bool _networkConnected = false; /** * @brief Connection retry interval in seconds. @@ -208,7 +208,7 @@ static int _retryInterval = otaDemoCONN_RETRY_BASE_INTERVAL_SECONDS; void vOTAUpdateDemoTask( void * pvParameters ) { - OTA_State_t eState; + OTA_State_t eState; OTA_ConnectionContext_t xOTAConnectionCtx = { 0 }; /* Remove compiler warnings about unused parameters. */ @@ -234,15 +234,15 @@ void vOTAUpdateDemoTask( void * pvParameters ) &xMQTTConnection ) == IOT_MQTT_SUCCESS ) { configPRINTF( ( "Connected to broker.\r\n" ) ); - xOTAConnectionCtx.pvControlClient = xMQTTConnection; - xOTAConnectionCtx.pxNetworkInterface = ( void * ) IOT_NETWORK_INTERFACE_FREERTOS; + xOTAConnectionCtx.pvControlClient = xMQTTConnection; + xOTAConnectionCtx.pxNetworkInterface = ( void * ) IOT_NETWORK_INTERFACE_FREERTOS; xOTAConnectionCtx.pvNetworkCredentials = &xNetworkSecurityCredentials; /* Set the base interval for connection retry.*/ - _retryInterval = otaDemoCONN_RETRY_BASE_INTERVAL_SECONDS; + _retryInterval = otaDemoCONN_RETRY_BASE_INTERVAL_SECONDS; /* Update the connection available flag.*/ - _networkConnected = true; + _networkConnected = true; /* Check if OTA Agent is suspended and resume.*/ if( ( eState = OTA_GetAgentState() ) == eOTA_AgentState_Suspended ) @@ -367,7 +367,7 @@ void vStartOTAUpdateDemo( void ) static void prvInitialiseLibraries( void ) { - IotMqttError_t xResult; + IotMqttError_t xResult; IotNetworkError_t xNetworkResult; /* Initialize the network stack abstraction for FreeRTOS. */ @@ -376,7 +376,7 @@ static void prvInitialiseLibraries( void ) /* MQTT library must be initialized before it can be used. This is just one * time initialization. */ - xResult = IotMqtt_Init(); + xResult = IotMqtt_Init(); configASSERT( xResult == IOT_MQTT_SUCCESS ); } /*-----------------------------------------------------------*/ @@ -444,11 +444,11 @@ static IotMqttError_t _establishMqttConnection( bool awsIotMqttMode, /* Set the members of the connection info not set by the initializer. */ memset( &xConnectInfo, 0, sizeof( xConnectInfo ) ); - xConnectInfo.awsIotMqttMode = awsIotMqttMode; - xConnectInfo.cleanSession = true; - xConnectInfo.keepAliveSeconds = otaDemoKEEPALIVE_SECONDS; + xConnectInfo.awsIotMqttMode = awsIotMqttMode; + xConnectInfo.cleanSession = true; + xConnectInfo.keepAliveSeconds = otaDemoKEEPALIVE_SECONDS; xConnectInfo.clientIdentifierLength = ( uint16_t ) strlen( awsiotdemoprofileCLIENT_IDENTIFIER ); - xConnectInfo.pClientIdentifier = awsiotdemoprofileCLIENT_IDENTIFIER; + xConnectInfo.pClientIdentifier = awsiotdemoprofileCLIENT_IDENTIFIER; /* Establish the MQTT connection. */ configPRINTF( ( "MQTT demo client identifier is %.*s (length %hu).", @@ -456,10 +456,10 @@ static IotMqttError_t _establishMqttConnection( bool awsIotMqttMode, xConnectInfo.pClientIdentifier, xConnectInfo.clientIdentifierLength ) ); - connectStatus = IotMqtt_Connect( &xNetworkInfo, - &xConnectInfo, - otaDemoCONN_TIMEOUT_MS, - pMqttConnection ); + connectStatus = IotMqtt_Connect( &xNetworkInfo, + &xConnectInfo, + otaDemoCONN_TIMEOUT_MS, + pMqttConnection ); if( connectStatus != IOT_MQTT_SUCCESS ) { diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_ota_pal.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_ota_pal.c index 281f2e0d9..6bbbfac83 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_ota_pal.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/aws_ota_pal.c @@ -110,7 +110,7 @@ OTA_Err_t prvPAL_Abort( OTA_FileContext_t * const C ) /* Set default return status to uninitialized. */ OTA_Err_t eResult = kOTA_Err_Uninitialized; - int32_t lFileCloseResult; + int32_t lFileCloseResult; if( NULL != C ) { @@ -119,7 +119,7 @@ OTA_Err_t prvPAL_Abort( OTA_FileContext_t * const C ) { lFileCloseResult = fclose( C->pxFile ); /*lint !e482 !e586 * Context file handle state is managed by this API. */ - C->pxFile = NULL; + C->pxFile = NULL; if( 0 == lFileCloseResult ) { @@ -202,26 +202,26 @@ OTA_Err_t prvPAL_CloseFile( OTA_FileContext_t * const C ) { DEFINE_OTA_METHOD_NAME( "prvPAL_CloseFile" ); - OTA_Err_t eResult = kOTA_Err_None; - int32_t lWindowsError = 0; + OTA_Err_t eResult = kOTA_Err_None; + int32_t lWindowsError = 0; if( prvContextValidate( C ) == pdTRUE ) { #if ( configOTA_ENABLE_CODE_SIGNATURE_VERIFICATION ) /* Verify the file signature, close the file and return the signature verification result. */ - eResult = prvPAL_CheckFileSignature( C ); + eResult = prvPAL_CheckFileSignature( C ); #else /* Code signature verification is disabled so return no error. */ OTA_LOG_L1( "[%s] Warning: Code signature verification is disabled in OTA config , see configOTA_ENABLE_CODE_SIGNATURE_VERIFICATION .\r\n", OTA_METHOD_NAME ); - eResult = kOTA_Err_None; + eResult = kOTA_Err_None; #endif /* Close the file. */ lWindowsError = fclose( C->pxFile ); /*lint !e482 !e586 * C standard library call is being used for portability. */ - C->pxFile = NULL; + C->pxFile = NULL; if( lWindowsError != 0 ) { @@ -262,10 +262,10 @@ static OTA_Err_t prvPAL_CheckFileSignature( OTA_FileContext_t * const C ) DEFINE_OTA_METHOD_NAME( "prvPAL_CheckFileSignature" ); OTA_Err_t eResult = kOTA_Err_None; - uint32_t ulBytesRead; - uint32_t ulSignerCertSize; + uint32_t ulBytesRead; + uint32_t ulSignerCertSize; uint8_t * pucBuf, * pucSignerCert; - void * pvSigVerifyContext; + void * pvSigVerifyContext; if( prvContextValidate( C ) == pdTRUE ) { @@ -353,11 +353,11 @@ static uint8_t * prvPAL_ReadAndAssumeCertificate( const uint8_t * const pucCertN { DEFINE_OTA_METHOD_NAME( "prvPAL_ReadAndAssumeCertificate" ); - FILE * pxFile; + FILE * pxFile; uint8_t * pucSignerCert = NULL; - uint8_t * pucCertData = NULL; - int32_t lSize = 0; /* For MISRA mandatory. */ - int32_t lWindowsError; + uint8_t * pucCertData = NULL; + int32_t lSize = 0; /* For MISRA mandatory. */ + int32_t lWindowsError; pxFile = fopen( ( const char * ) pucCertName, "rb" ); /*lint !e586 * C standard library call is being used for portability. */ @@ -394,7 +394,7 @@ static uint8_t * prvPAL_ReadAndAssumeCertificate( const uint8_t * const pucCertN * C standard library call is being used for portability. */ { /* The crypto code requires the terminating zero to be part of the length so add 1 to the size. */ - *ulSignerCertSize = lSize + 1; + *ulSignerCertSize = lSize + 1; pucSignerCert[ lSize ] = 0; } else @@ -424,9 +424,9 @@ static uint8_t * prvPAL_ReadAndAssumeCertificate( const uint8_t * const pucCertN ( const char * ) pucCertName ); /* Allocate memory for the signer certificate plus a terminating zero so we can copy it and return to the caller. */ - lSize = sizeof( signingcredentialSIGNING_CERTIFICATE_PEM ); - pucSignerCert = pvPortMalloc( lSize ); /*lint !e9029 !e9079 !e838 malloc proto requires void*. */ - pucCertData = ( uint8_t * ) signingcredentialSIGNING_CERTIFICATE_PEM; /*lint !e9005 we don't modify the cert but it could be set by PKCS11 so it's not const. */ + lSize = sizeof( signingcredentialSIGNING_CERTIFICATE_PEM ); + pucSignerCert = pvPortMalloc( lSize ); /*lint !e9029 !e9079 !e838 malloc proto requires void*. */ + pucCertData = ( uint8_t * ) signingcredentialSIGNING_CERTIFICATE_PEM; /*lint !e9005 we don't modify the cert but it could be set by PKCS11 so it's not const. */ if( pucSignerCert != NULL ) { @@ -470,7 +470,7 @@ OTA_Err_t prvPAL_SetPlatformImageState( OTA_ImageState_t eState ) DEFINE_OTA_METHOD_NAME( "prvPAL_SetPlatformImageState" ); OTA_Err_t eResult = kOTA_Err_None; - FILE * pstPlatformImageState; + FILE * pstPlatformImageState; if( ( eState != eOTA_ImageState_Unknown ) && ( eState <= eOTA_LastImageState ) ) { @@ -532,9 +532,9 @@ OTA_PAL_ImageState_t prvPAL_GetPlatformImageState( void ) /* FIXME: This function should return OTA_PAL_ImageState_t, but it doesn't. */ DEFINE_OTA_METHOD_NAME( "prvPAL_GetPlatformImageState" ); - FILE * pstPlatformImageState; - OTA_ImageState_t eSavedAgentState = eOTA_ImageState_Unknown; - OTA_PAL_ImageState_t ePalState = eOTA_PAL_ImageState_Unknown; + FILE * pstPlatformImageState; + OTA_ImageState_t eSavedAgentState = eOTA_ImageState_Unknown; + OTA_PAL_ImageState_t ePalState = eOTA_PAL_ImageState_Unknown; pstPlatformImageState = fopen( "PlatformImageState.txt", "r+b" ); /*lint !e586 * C standard library call is being used for portability. */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/demo_logging.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/demo_logging.c index e6aa16c3e..cd2cf8dfb 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/demo_logging.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/demo_logging.c @@ -122,31 +122,31 @@ static void * pvLoggingThreadEvent = NULL; /* Stores the selected logging targets passed in as parameters to the * vLoggingInit() function. */ -BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE; +BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE; /* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32 * thread that is responsible for making Win32 calls (when stdout or a disk log is * used). */ -static StreamBuffer_t * xLogStreamBuffer = NULL; +static StreamBuffer_t * xLogStreamBuffer = NULL; /* Handle to the file used for logging. This is left open while there are * messages waiting to be logged, then closed again in between logs. */ -static FILE * pxLoggingFileHandle = NULL; +static FILE * pxLoggingFileHandle = NULL; /* When true prints are performed directly. After start up xDirectPrint is set * to pdFALSE - at which time prints that require Win32 system calls are done by * the Win32 thread responsible for logging. */ -BaseType_t xDirectPrint = pdTRUE; +BaseType_t xDirectPrint = pdTRUE; /* File names for the in use and complete (full) log files. */ -static const char * pcLogFileName = "RTOSDemo.log"; -static const char * pcFullLogFileName = "RTOSDemo.ful"; +static const char * pcLogFileName = "RTOSDemo.log"; +static const char * pcFullLogFileName = "RTOSDemo.ful"; /* As an optimization, the current file size is kept in a variable. */ -static size_t ulSizeOfLoggingFile = 0ul; +static size_t ulSizeOfLoggingFile = 0ul; /* The UDP socket and address on/to which print messages are sent. */ -Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET; +Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET; struct freertos_sockaddr xPrintUDPAddress; /*-----------------------------------------------------------*/ @@ -165,9 +165,9 @@ void vLoggingInit( BaseType_t xLogToStdout, HANDLE Win32Thread; /* Record which output methods are to be used. */ - xStdoutLoggingUsed = xLogToStdout; + xStdoutLoggingUsed = xLogToStdout; xDiskFileLoggingUsed = xLogToFile; - xUDPLoggingUsed = xLogToUDP; + xUDPLoggingUsed = xLogToUDP; /* If a disk file is used then initialize it now. */ if( xDiskFileLoggingUsed != pdFALSE ) @@ -193,16 +193,16 @@ void vLoggingInit( BaseType_t xLogToStdout, if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) ) { /* Create the buffer. */ - xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 ); + xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 ); configASSERT( xLogStreamBuffer ); memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) ); xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1; /* Create the Windows event. */ - pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" ); + pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" ); /* Create the thread itself. */ - Win32Thread = CreateThread( + Win32Thread = CreateThread( NULL, /* Pointer to thread security attributes. */ 0, /* Initial thread stack size, in bytes. */ prvWin32LoggingThread, /* Pointer to thread function. */ @@ -234,7 +234,7 @@ static void prvCreatePrintSocket( void * pvParameter1, uint32_t ulParameter2 ) { static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 ); - Socket_t xSocket; + Socket_t xSocket; /* The function prototype is that of a deferred function, but the parameters * are not actually used. */ @@ -258,17 +258,17 @@ static void prvCreatePrintSocket( void * pvParameter1, void vLoggingPrintf( const char * pcFormat, ... ) { - char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; - char cOutputString[ dlMAX_PRINT_STRING_LENGTH ]; - char * pcSource, * pcTarget, * pcBegin; - size_t xLength, xLength2, rc; + char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; + char cOutputString[ dlMAX_PRINT_STRING_LENGTH ]; + char * pcSource, * pcTarget, * pcBegin; + size_t xLength, xLength2, rc; static BaseType_t xMessageNumber = 0; - va_list args; - uint32_t ulIPAddress; - const char * pcTaskName; - const char * pcNoTask = "None"; - int iOriginalPriority; - HANDLE xCurrentTask; + va_list args; + uint32_t ulIPAddress; + const char * pcTaskName; + const char * pcNoTask = "None"; + int iOriginalPriority; + HANDLE xCurrentTask; if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) ) @@ -304,7 +304,7 @@ void vLoggingPrintf( const char * pcFormat, if( xLength2 < 0 ) { /* Clean up. */ - xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength; + xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength; cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0'; } @@ -328,7 +328,7 @@ void vLoggingPrintf( const char * pcFormat, *pcTarget = *pcSource; pcTarget++; *pcTarget = '\0'; - pcBegin = pcTarget - 8; + pcBegin = pcTarget - 8; while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) ) { @@ -336,18 +336,18 @@ void vLoggingPrintf( const char * pcFormat, } sscanf( pcTarget, "%8X", &ulIPAddress ); - rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", - ( unsigned long ) ( ulIPAddress >> 24UL ), - ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), - ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ), - ( unsigned long ) ( ulIPAddress & 0xffUL ) ); + rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", + ( unsigned long ) ( ulIPAddress >> 24UL ), + ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), + ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ), + ( unsigned long ) ( ulIPAddress & 0xffUL ) ); pcTarget += rc; pcSource += 3; /* skip "<n>ip" */ } } /* How far through the buffer was written? */ - xLength = ( BaseType_t ) ( pcTarget - cOutputString ); + xLength = ( BaseType_t ) ( pcTarget - cOutputString ); /* If the message is to be logged to a UDP port then it can be sent directly * because it only uses FreeRTOS function (not Win32 functions). */ @@ -393,7 +393,7 @@ void vLoggingPrintf( const char * pcFormat, * as there are potentially multiple writers. The stream buffer is * only thread safe when there is a single writer (likewise for * reading from the buffer). */ - xCurrentTask = GetCurrentThread(); + xCurrentTask = GetCurrentThread(); iOriginalPriority = GetThreadPriority( xCurrentTask ); SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL ); uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) ); @@ -426,7 +426,7 @@ void vLoggingPrintf( const char * pcFormat, static void prvLoggingFlushBuffer( void ) { size_t xLength; - char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; + char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; /* Is there more than the length value stored in the circular buffer * used to pass data from the FreeRTOS simulator into this Win32 thread? */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_crypto.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_crypto.c index 474092664..12d4c57f1 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_crypto.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/iot_crypto.c @@ -77,8 +77,8 @@ static BaseType_t prvVerifySignature( char * pcSignerCertificate, uint8_t * pucSignature, size_t xSignatureLength ) { - BaseType_t xResult = pdTRUE; - mbedtls_x509_crt xCertCtx; + BaseType_t xResult = pdTRUE; + mbedtls_x509_crt xCertCtx; mbedtls_md_type_t xMbedHashAlg = MBEDTLS_MD_SHA256; @@ -139,7 +139,7 @@ BaseType_t CRYPTO_SignatureVerificationStart( void ** ppvContext, BaseType_t xAsymmetricAlgorithm, BaseType_t xHashAlgorithm ) { - BaseType_t xResult = pdTRUE; + BaseType_t xResult = pdTRUE; SignatureVerificationState_t * pxCtx = NULL; /* @@ -153,13 +153,13 @@ BaseType_t CRYPTO_SignatureVerificationStart( void ** ppvContext, if( pdTRUE == xResult ) { - *ppvContext = pxCtx; + *ppvContext = pxCtx; /* * Store the algorithm identifiers */ pxCtx->xAsymmetricAlgorithm = xAsymmetricAlgorithm; - pxCtx->xHashAlgorithm = xHashAlgorithm; + pxCtx->xHashAlgorithm = xHashAlgorithm; /* * Initialize the requested hash type @@ -216,9 +216,9 @@ BaseType_t CRYPTO_SignatureVerificationFinal( void * pvContext, if( pvContext != NULL ) { SignatureVerificationStatePtr_t pxCtx = ( SignatureVerificationStatePtr_t ) pvContext; /*lint !e9087 Allow casting void* to other types. */ - uint8_t ucSHA1or256[ cryptoSHA256_DIGEST_BYTES ]; /* Reserve enough space for the larger of SHA1 or SHA256 results. */ - uint8_t * pucHash = NULL; - size_t xHashLength = 0; + uint8_t ucSHA1or256[ cryptoSHA256_DIGEST_BYTES ]; /* Reserve enough space for the larger of SHA1 or SHA256 results. */ + uint8_t * pucHash = NULL; + size_t xHashLength = 0; if( ( pcSignerCertificate != NULL ) && ( pucSignature != NULL ) && @@ -231,13 +231,13 @@ BaseType_t CRYPTO_SignatureVerificationFinal( void * pvContext, if( cryptoHASH_ALGORITHM_SHA1 == pxCtx->xHashAlgorithm ) { ( void ) mbedtls_sha1_finish_ret( &pxCtx->xSHA1Context, ucSHA1or256 ); - pucHash = ucSHA1or256; + pucHash = ucSHA1or256; xHashLength = cryptoSHA1_DIGEST_BYTES; } else { ( void ) mbedtls_sha256_finish_ret( &pxCtx->xSHA256Context, ucSHA1or256 ); - pucHash = ucSHA1or256; + pucHash = ucSHA1or256; xHashLength = cryptoSHA256_DIGEST_BYTES; } diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/main.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/main.c index df799191f..6904eeff7 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/main.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/ota/common/main.c @@ -94,7 +94,7 @@ const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALS * to and from a real network connection on the host PC. See the * configNETWORK_INTERFACE_TO_USE definition for information on how to configure * the real network connection to use. */ -const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 }; +const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 }; /* Use by the pseudo random number generator. */ static UBaseType_t ulNextRand; @@ -139,8 +139,8 @@ int main( void ) * events are only received if implemented in the MAC driver. */ void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent ) { - uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; - char cBuffer[ 16 ]; + uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; + char cBuffer[ 16 ]; static BaseType_t xTasksAlreadyCreated = pdFALSE; /* If the network has just come up...*/ @@ -187,8 +187,8 @@ void vAssertCalled( const char * pcFile, uint32_t ulLine ) { volatile uint32_t ulBlockVariable = 0UL; - volatile char * pcFileName = ( volatile char * ) pcFile; - volatile uint32_t ulLineNumber = ulLine; + volatile char * pcFileName = ( volatile char * ) pcFile; + volatile uint32_t ulLineNumber = ulLine; ( void ) pcFileName; ( void ) ulLineNumber; @@ -233,7 +233,7 @@ static void prvSRand( UBaseType_t ulSeed ) static void prvMiscInitialisation( void ) { - time_t xTimeNow; + time_t xTimeNow; uint32_t ulLoggingIPAddress; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 ); @@ -341,11 +341,11 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, * function then they must be declared static - otherwise they will be allocated on * the stack and so not exists after this function exits. */ static StaticTask_t xIdleTaskTCB; - static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; + static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; /* Pass out a pointer to the StaticTask_t structure in which the Idle task's * state will be stored. */ - *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; /* Pass out the array that will be used as the Idle task's stack. */ *ppxIdleTaskStackBuffer = uxIdleTaskStack; @@ -353,7 +353,7 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; } /*-----------------------------------------------------------*/ @@ -368,11 +368,11 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, * function then they must be declared static - otherwise they will be allocated on * the stack and so not exists after this function exits. */ static StaticTask_t xTimerTaskTCB; - static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; + static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; /* Pass out a pointer to the StaticTask_t structure in which the Timer * task's state will be stored. */ - *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; /* Pass out the array that will be used as the Timer task's stack. */ *ppxTimerTaskStackBuffer = uxTimerTaskStack; @@ -380,6 +380,6 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/DemoTasks/PKCSMutualAuthExample.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/DemoTasks/PKCSMutualAuthExample.c index 8977f975b..85c9118ec 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/DemoTasks/PKCSMutualAuthExample.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/DemoTasks/PKCSMutualAuthExample.c @@ -184,17 +184,17 @@ static void prvInitialiseLibraries( void ); /** * @brief The MQTT connection handle used in this example. */ -static IotMqttConnection_t xMQTTConnection = NULL; +static IotMqttConnection_t xMQTTConnection = NULL; /*-----------------------------------------------------------*/ -static const struct IotNetworkServerInfo xMQTTBrokerInfo = +static const struct IotNetworkServerInfo xMQTTBrokerInfo = { .pHostName = mqttexampleBROKER_ENDPOINT, .port = mqttexampleBROKER_PORT }; -static struct IotNetworkCredentials xNetworkSecurityCredentials = +static struct IotNetworkCredentials xNetworkSecurityCredentials = { /* Optional TLS extensions. For this demo, they are disabled. */ .pAlpnProtos = NULL, @@ -209,7 +209,7 @@ static struct IotNetworkCredentials xNetworkSecurityCredentials = .rootCaSize = mqttexampleBROKER_CERTIFICATE_PEM_SIZE, }; -static IotMqttNetworkInfo_t xNetworkInfo = +static IotMqttNetworkInfo_t xNetworkInfo = { /* No connection to the MQTT broker has been established yet and we want to * establish a new connection. */ @@ -227,7 +227,7 @@ static IotMqttNetworkInfo_t xNetworkInfo = .disconnectCallback.function = prvExample_OnDisconnect }; -static const IotMqttConnectInfo_t xConnectInfo = +static const IotMqttConnectInfo_t xConnectInfo = { /* Set this flag to true if connecting to the AWS IoT MQTT broker. */ .awsIotMqttMode = true, @@ -288,9 +288,9 @@ void vStartPKCSMutualAuthDemo( void ) static void prvMQTTDemoTask( void * pvParameters ) { - uint32_t ulNotificationValue = 0, ulPublishCount; - const uint32_t ulMaxPublishCount = 5UL; - const TickType_t xNoDelay = ( TickType_t ) 0; + uint32_t ulNotificationValue = 0, ulPublishCount; + const uint32_t ulMaxPublishCount = 5UL; + const TickType_t xNoDelay = ( TickType_t ) 0; /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; @@ -464,86 +464,86 @@ static void prvMQTTDisconnect( void ) static void prvMQTTSubscribe( void ) { - IotMqttError_t xResult; + IotMqttError_t xResult; IotMqttSubscription_t xMQTTSubscription; /* Subscribe to the mqttexampleTOPIC topic filter. The task handle is passed * as the callback context, which is then used by the callback to send a task * notification to this task.*/ - xMQTTSubscription.qos = IOT_MQTT_QOS_1; - xMQTTSubscription.pTopicFilter = mqttexampleTOPIC; - xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC ); + xMQTTSubscription.qos = IOT_MQTT_QOS_1; + xMQTTSubscription.pTopicFilter = mqttexampleTOPIC; + xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC ); xMQTTSubscription.callback.pCallbackContext = ( void * ) xTaskGetCurrentTaskHandle(); - xMQTTSubscription.callback.function = prvExample_OnMessageReceived; + xMQTTSubscription.callback.function = prvExample_OnMessageReceived; /* Use the synchronous API to subscribe - It is a blocking call and only * returns when the subscribe operation is complete or a timeout occurs. */ - xResult = IotMqtt_SubscribeSync( xMQTTConnection, - &( xMQTTSubscription ), - 1, /* We are subscribing to one topic filter. */ - 0, /* flags - currently ignored. */ - mqttexampleMQTT_TIMEOUT_MS ); + xResult = IotMqtt_SubscribeSync( xMQTTConnection, + &( xMQTTSubscription ), + 1, /* We are subscribing to one topic filter. */ + 0, /* flags - currently ignored. */ + mqttexampleMQTT_TIMEOUT_MS ); configASSERT( xResult == IOT_MQTT_SUCCESS ); } /*-----------------------------------------------------------*/ static void prvMQTTPublish( void ) { - IotMqttError_t xResult; + IotMqttError_t xResult; IotMqttPublishInfo_t xMQTTPublishInfo; /* Publish a message with QoS1 on the mqttexampleTOPIC topic. Since we are * subscribed to the same topic, the MQTT broker will send the same message * back to us. It is verified in the publish callback. */ - xMQTTPublishInfo.qos = IOT_MQTT_QOS_1; - xMQTTPublishInfo.retain = false; - xMQTTPublishInfo.pTopicName = mqttexampleTOPIC; + xMQTTPublishInfo.qos = IOT_MQTT_QOS_1; + xMQTTPublishInfo.retain = false; + xMQTTPublishInfo.pTopicName = mqttexampleTOPIC; xMQTTPublishInfo.topicNameLength = ( uint16_t ) strlen( mqttexampleTOPIC ); - xMQTTPublishInfo.pPayload = mqttexampleMESSAGE; - xMQTTPublishInfo.payloadLength = strlen( mqttexampleMESSAGE ); - xMQTTPublishInfo.retryMs = mqttexamplePUBLISH_RETRY_MS; - xMQTTPublishInfo.retryLimit = mqttexamplePUBLISH_RETRY_LIMIT; + xMQTTPublishInfo.pPayload = mqttexampleMESSAGE; + xMQTTPublishInfo.payloadLength = strlen( mqttexampleMESSAGE ); + xMQTTPublishInfo.retryMs = mqttexamplePUBLISH_RETRY_MS; + xMQTTPublishInfo.retryLimit = mqttexamplePUBLISH_RETRY_LIMIT; /* Use the synchronous API to publish - It is a blocking call and only * returns when the publish operation is complete or a timeout occurs. */ - xResult = IotMqtt_PublishSync( xMQTTConnection, - &( xMQTTPublishInfo ), - 0, /* flags - currently ignored. */ - mqttexampleMQTT_TIMEOUT_MS ); + xResult = IotMqtt_PublishSync( xMQTTConnection, + &( xMQTTPublishInfo ), + 0, /* flags - currently ignored. */ + mqttexampleMQTT_TIMEOUT_MS ); configASSERT( xResult == IOT_MQTT_SUCCESS ); } /*-----------------------------------------------------------*/ static void prvMQTTUnsubscribe( void ) { - IotMqttError_t xResult; + IotMqttError_t xResult; IotMqttSubscription_t xMQTTSubscription; /* Unsubscribe from the mqttexampleTOPIC topic filter. */ - xMQTTSubscription.pTopicFilter = mqttexampleTOPIC; - xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC ); + xMQTTSubscription.pTopicFilter = mqttexampleTOPIC; + xMQTTSubscription.topicFilterLength = ( uint16_t ) strlen( mqttexampleTOPIC ); /* The following members of the IotMqttSubscription_t are ignored by the * unsubscribe operation. Just initialize them to avoid "use of uninitialized * variable" warnings. */ - xMQTTSubscription.qos = IOT_MQTT_QOS_1; + xMQTTSubscription.qos = IOT_MQTT_QOS_1; xMQTTSubscription.callback.pCallbackContext = NULL; - xMQTTSubscription.callback.function = NULL; + xMQTTSubscription.callback.function = NULL; /* Use the synchronous API to unsubscribe - It is a blocking call and only * returns when the unsubscribe operation is complete or a timeout occurs. */ - xResult = IotMqtt_UnsubscribeSync( xMQTTConnection, - &( xMQTTSubscription ), - 1, /* We are unsubscribing from one topic filter. */ - 0, /* flags - currently ignored. */ - mqttexampleMQTT_TIMEOUT_MS ); + xResult = IotMqtt_UnsubscribeSync( xMQTTConnection, + &( xMQTTSubscription ), + 1, /* We are unsubscribing from one topic filter. */ + 0, /* flags - currently ignored. */ + mqttexampleMQTT_TIMEOUT_MS ); configASSERT( xResult == IOT_MQTT_SUCCESS ); } /*-----------------------------------------------------------*/ static void prvInitialiseLibraries( void ) { - IotMqttError_t xResult; + IotMqttError_t xResult; IotNetworkError_t xNetworkResult; /*_RB_ Are three types necessary, one for each lib? */ /* Initialize the network stack abstraction for FreeRTOS. */ @@ -552,7 +552,7 @@ static void prvInitialiseLibraries( void ) /* MQTT library must be initialized before it can be used. This is just one * time initialization. */ - xResult = IotMqtt_Init(); + xResult = IotMqtt_Init(); configASSERT( xResult == IOT_MQTT_SUCCESS ); } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/Run-time-stats-utils.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/Run-time-stats-utils.c index 61a68dc82..b62afb3ea 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/Run-time-stats-utils.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/Run-time-stats-utils.c @@ -67,7 +67,7 @@ void vConfigureTimerForRunTimeStats( void ) /* What is the performance counter value now, this will be subtracted * from readings taken at run time. */ QueryPerformanceCounter( &liInitialRunTimeValue ); - llInitialRunTimeCounterValue = liInitialRunTimeValue.QuadPart; + llInitialRunTimeCounterValue = liInitialRunTimeValue.QuadPart; } } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/atomic.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/atomic.h index 522773bcd..8eb93ad51 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/atomic.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/atomic.h @@ -179,7 +179,7 @@ #else ATOMIC_ENTER_CRITICAL(); - pReturnValue = *ppDestination; + pReturnValue = *ppDestination; *ppDestination = pExchange; @@ -227,7 +227,7 @@ if( *ppDestination == pComparand ) { *ppDestination = pExchange; - ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; } ATOMIC_EXIT_CRITICAL(); #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */ @@ -382,7 +382,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination |= ulValue; @@ -413,7 +413,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination &= ulValue; @@ -444,7 +444,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination = ~( ulCurrent & ulValue ); @@ -475,7 +475,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination ^= ulValue; diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/demo_logging.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/demo_logging.c index cd8116018..db19c6803 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/demo_logging.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/demo_logging.c @@ -122,31 +122,31 @@ static void * pvLoggingThreadEvent = NULL; /* Stores the selected logging targets passed in as parameters to the * vLoggingInit() function. */ -BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE; +BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE; /* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32 * thread that is responsible for making Win32 calls (when stdout or a disk log is * used). */ -static StreamBuffer_t * xLogStreamBuffer = NULL; +static StreamBuffer_t * xLogStreamBuffer = NULL; /* Handle to the file used for logging. This is left open while there are * messages waiting to be logged, then closed again in between logs. */ -static FILE * pxLoggingFileHandle = NULL; +static FILE * pxLoggingFileHandle = NULL; /* When true prints are performed directly. After start up xDirectPrint is set * to pdFALSE - at which time prints that require Win32 system calls are done by * the Win32 thread responsible for logging. */ -BaseType_t xDirectPrint = pdTRUE; +BaseType_t xDirectPrint = pdTRUE; /* File names for the in use and complete (full) log files. */ -static const char * pcLogFileName = "RTOSDemo.log"; -static const char * pcFullLogFileName = "RTOSDemo.ful"; +static const char * pcLogFileName = "RTOSDemo.log"; +static const char * pcFullLogFileName = "RTOSDemo.ful"; /* Keep the current file size in a variable, as an optimisation. */ -static size_t ulSizeOfLoggingFile = 0ul; +static size_t ulSizeOfLoggingFile = 0ul; /* The UDP socket and address on/to which print messages are sent. */ -Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET; +Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET; struct freertos_sockaddr xPrintUDPAddress; /*-----------------------------------------------------------*/ @@ -165,9 +165,9 @@ void vLoggingInit( BaseType_t xLogToStdout, HANDLE Win32Thread; /* Record which output methods are to be used. */ - xStdoutLoggingUsed = xLogToStdout; + xStdoutLoggingUsed = xLogToStdout; xDiskFileLoggingUsed = xLogToFile; - xUDPLoggingUsed = xLogToUDP; + xUDPLoggingUsed = xLogToUDP; /* If a disk file is used then initialise it now. */ if( xDiskFileLoggingUsed != pdFALSE ) @@ -193,16 +193,16 @@ void vLoggingInit( BaseType_t xLogToStdout, if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) ) { /* Create the buffer. */ - xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 ); + xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 ); configASSERT( xLogStreamBuffer ); memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) ); xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1; /* Create the Windows event. */ - pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" ); + pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" ); /* Create the thread itself. */ - Win32Thread = CreateThread( + Win32Thread = CreateThread( NULL, /* Pointer to thread security attributes. */ 0, /* Initial thread stack size, in bytes. */ prvWin32LoggingThread, /* Pointer to thread function. */ @@ -234,7 +234,7 @@ static void prvCreatePrintSocket( void * pvParameter1, uint32_t ulParameter2 ) { static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 ); - Socket_t xSocket; + Socket_t xSocket; /* The function prototype is that of a deferred function, but the parameters * are not actually used. */ @@ -258,17 +258,17 @@ static void prvCreatePrintSocket( void * pvParameter1, void vLoggingPrintf( const char * pcFormat, ... ) { - char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; - char cOutputString[ dlMAX_PRINT_STRING_LENGTH ]; - char * pcSource, * pcTarget, * pcBegin; - size_t xLength, xLength2, rc; + char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; + char cOutputString[ dlMAX_PRINT_STRING_LENGTH ]; + char * pcSource, * pcTarget, * pcBegin; + size_t xLength, xLength2, rc; static BaseType_t xMessageNumber = 0; - va_list args; - uint32_t ulIPAddress; - const char * pcTaskName; - const char * pcNoTask = "None"; - int iOriginalPriority; - HANDLE xCurrentTask; + va_list args; + uint32_t ulIPAddress; + const char * pcTaskName; + const char * pcNoTask = "None"; + int iOriginalPriority; + HANDLE xCurrentTask; if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) ) @@ -304,7 +304,7 @@ void vLoggingPrintf( const char * pcFormat, if( xLength2 < 0 ) { /* Clean up. */ - xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength; + xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength; cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0'; } @@ -328,7 +328,7 @@ void vLoggingPrintf( const char * pcFormat, *pcTarget = *pcSource; pcTarget++; *pcTarget = '\0'; - pcBegin = pcTarget - 8; + pcBegin = pcTarget - 8; while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) ) { @@ -336,18 +336,18 @@ void vLoggingPrintf( const char * pcFormat, } sscanf( pcTarget, "%8X", &ulIPAddress ); - rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", - ( unsigned long ) ( ulIPAddress >> 24UL ), - ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), - ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ), - ( unsigned long ) ( ulIPAddress & 0xffUL ) ); + rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", + ( unsigned long ) ( ulIPAddress >> 24UL ), + ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), + ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ), + ( unsigned long ) ( ulIPAddress & 0xffUL ) ); pcTarget += rc; pcSource += 3; /* skip "<n>ip" */ } } /* How far through the buffer was written? */ - xLength = ( BaseType_t ) ( pcTarget - cOutputString ); + xLength = ( BaseType_t ) ( pcTarget - cOutputString ); /* If the message is to be logged to a UDP port then it can be sent directly * because it only uses FreeRTOS function (not Win32 functions). */ @@ -393,7 +393,7 @@ void vLoggingPrintf( const char * pcFormat, * as there are potentially multiple writers. The stream buffer is * only thread safe when there is a single writer (likewise for * reading from the buffer). */ - xCurrentTask = GetCurrentThread(); + xCurrentTask = GetCurrentThread(); iOriginalPriority = GetThreadPriority( xCurrentTask ); SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL ); uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) ); @@ -426,7 +426,7 @@ void vLoggingPrintf( const char * pcFormat, static void prvLoggingFlushBuffer( void ) { size_t xLength; - char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; + char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; /* Is there more than the length value stored in the circular buffer * used to pass data from the FreeRTOS simulator into this Win32 thread? */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/main.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/main.c index 793f6a4a8..217ffc3a7 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/main.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/main.c @@ -103,7 +103,7 @@ static const uint8_t ucDNSServerAddress[ 4 ] = * FreeRTOSConfig.h) and the port number set by configPRINT_PORT in * FreeRTOSConfig.h. */ const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, - xLogToUDP = pdFALSE; + xLogToUDP = pdFALSE; /* Default MAC address configuration. The demo creates a virtual network * connection that uses this MAC address by accessing the raw Ethernet data @@ -161,8 +161,8 @@ int main( void ) * events are only received if implemented in the MAC driver. */ void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent ) { - uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; - char cBuffer[ 16 ]; + uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; + char cBuffer[ 16 ]; static BaseType_t xTasksAlreadyCreated = pdFALSE; /* If the network has just come up...*/ @@ -204,8 +204,8 @@ void vAssertCalled( const char * pcFile, uint32_t ulLine ) { volatile uint32_t ulBlockVariable = 0UL; - volatile char * pcFileName = ( volatile char * ) pcFile; - volatile uint32_t ulLineNumber = ulLine; + volatile char * pcFileName = ( volatile char * ) pcFile; + volatile uint32_t ulLineNumber = ulLine; ( void ) pcFileName; ( void ) ulLineNumber; @@ -225,10 +225,10 @@ void vAssertCalled( const char * pcFile, /*-----------------------------------------------------------*/ UBaseType_t uxRand( void ) { - uint8_t ulNextRand = 0; - CK_RV xResult = CKR_OK; - static CK_SESSION_HANDLE xSession = CK_INVALID_HANDLE; - CK_FUNCTION_LIST_PTR pxFunctionList; + uint8_t ulNextRand = 0; + CK_RV xResult = CKR_OK; + static CK_SESSION_HANDLE xSession = CK_INVALID_HANDLE; + CK_FUNCTION_LIST_PTR pxFunctionList; xResult = C_GetFunctionList( &pxFunctionList ); @@ -265,7 +265,7 @@ static void prvMiscInitialisation( void ) xLogToStdout, xLogToFile, xLogToUDP, ulLoggingIPAddress, configPRINT_PORT ); - CK_RV xResult; + CK_RV xResult; uint32_t xRandom = 0; /* Set the mutex functions for mbed TLS thread safety. */ @@ -276,14 +276,14 @@ static void prvMiscInitialisation( void ) /* * Initialize the PKCS #11 module and token. */ - xResult = xInitializePkcs11Token(); + xResult = xInitializePkcs11Token(); configASSERT( xResult == CKR_OK ); /* Call for a random number. The first time this is called, it will * create a PKCS #11 session which is shared by all callers to * xGetRandomNumber. Make this call now since randomness session * initialization isn't threadsafe. */ - xRandom = uxRand(); + xRandom = uxRand(); configPRINTF( ( "Successfully Generated Random numbers: %08X %08X %08X %08X\n", ipconfigRAND32(), ipconfigRAND32(), ipconfigRAND32(), @@ -378,11 +378,11 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, * function then they must be declared static - otherwise they will be * allocated on the stack and so not exists after this function exits. */ static StaticTask_t xIdleTaskTCB; - static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; + static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; /* Pass out a pointer to the StaticTask_t structure in which the Idle task's * state will be stored. */ - *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; /* Pass out the array that will be used as the Idle task's stack. */ *ppxIdleTaskStackBuffer = uxIdleTaskStack; @@ -390,7 +390,7 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; } /*-----------------------------------------------------------*/ @@ -405,11 +405,11 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, * function then they must be declared static - otherwise they will be * allocated on the stack and so not exists after this function exits. */ static StaticTask_t xTimerTaskTCB; - static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; + static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; /* Pass out a pointer to the StaticTask_t structure in which the Timer * task's state will be stored. */ - *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; /* Pass out the array that will be used as the Timer task's stack. */ *ppxTimerTaskStackBuffer = uxTimerTaskStack; @@ -417,6 +417,6 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/printf-stdarg.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/printf-stdarg.c index f9bc5b5b1..ae28ddde0 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/printf-stdarg.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/pkcs11/pkcs11_mqtt_tls_mutual_auth/printf-stdarg.c @@ -64,7 +64,7 @@ static void strbuf_init( struct SStringBuf * apStr, char * apBuf, const char * apMaxStr ) { - apStr->str = apBuf; + apStr->str = apBuf; apStr->orgStr = apBuf; apStr->nulPos = apMaxStr - 1; apStr->curLen = 0; @@ -158,7 +158,7 @@ static BaseType_t prints( struct SStringBuf * apBuf, const char * apString ) { register int padchar = ' '; - int i, len; + int i, len; if( xApplicationMemoryPermissions( ( uint32_t ) apString ) == 0 ) { @@ -169,7 +169,7 @@ static BaseType_t prints( struct SStringBuf * apBuf, if( apBuf->flags.width > 0 ) { - register int len = 0; + register int len = 0; register const char * ptr; for( ptr = apString; *ptr; ++ptr ) @@ -257,11 +257,11 @@ static BaseType_t prints( struct SStringBuf * apBuf, static BaseType_t printll( struct SStringBuf * apBuf, long long i ) { - char print_buf[ 2 * PRINT_BUF_LEN ]; - register char * s; - register int t, neg = 0; + char print_buf[ 2 * PRINT_BUF_LEN ]; + register char * s; + register int t, neg = 0; register unsigned long long u = i; - lldiv_t lldiv_result; + lldiv_t lldiv_result; /* typedef struct * { @@ -282,26 +282,26 @@ static BaseType_t prints( struct SStringBuf * apBuf, if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) ) { neg = 1; - u = -i; + u = -i; } - s = print_buf + sizeof( print_buf ) - 1; + s = print_buf + sizeof( print_buf ) - 1; - *s = '\0'; + *s = '\0'; /* 18446744073709551616 */ while( u != 0 ) { lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base ); - t = lldiv_result.rem; + t = lldiv_result.rem; if( t >= 10 ) { t += apBuf->flags.letBase - '0' - 10; } - *( --s ) = t + '0'; - u = lldiv_result.quot; + *( --s ) = t + '0'; + u = lldiv_result.quot; } if( neg != 0 ) @@ -329,11 +329,11 @@ static BaseType_t prints( struct SStringBuf * apBuf, static BaseType_t printi( struct SStringBuf * apBuf, int i ) { - char print_buf[ PRINT_BUF_LEN ]; - register char * s; - register int t, neg = 0; - register unsigned int u = i; - register unsigned base = apBuf->flags.base; + char print_buf[ PRINT_BUF_LEN ]; + register char * s; + register int t, neg = 0; + register unsigned int u = i; + register unsigned base = apBuf->flags.base; apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */ @@ -347,12 +347,12 @@ static BaseType_t printi( struct SStringBuf * apBuf, if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) ) { neg = 1; - u = -i; + u = -i; } - s = print_buf + sizeof( print_buf ) - 1; + s = print_buf + sizeof( print_buf ) - 1; - *s = '\0'; + *s = '\0'; switch( base ) { @@ -360,7 +360,7 @@ static BaseType_t printi( struct SStringBuf * apBuf, while( u != 0 ) { - t = u & 0xF; + t = u & 0xF; if( t >= 10 ) { @@ -368,7 +368,7 @@ static BaseType_t printi( struct SStringBuf * apBuf, } *( --s ) = t + '0'; - u >>= 4; + u >>= 4; } break; @@ -379,9 +379,9 @@ static BaseType_t printi( struct SStringBuf * apBuf, /* GCC compiles very efficient */ while( u ) { - t = u % base; + t = u % base; *( --s ) = t + '0'; - u /= base; + u /= base; } break; @@ -487,19 +487,19 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == '-' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.pad = PAD_RIGHT; } while( ch == '0' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.pad |= PAD_ZERO; } if( ch == '*' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.width = va_arg( args, int ); } else @@ -508,7 +508,7 @@ static void tiny_print( struct SStringBuf * apBuf, { apBuf->flags.width *= 10; apBuf->flags.width += ch - '0'; - ch = *( format++ ); + ch = *( format++ ); } } @@ -519,7 +519,7 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == '*' ) { apBuf->flags.printLimit = va_arg( args, int ); - ch = *( format++ ); + ch = *( format++ ); } else { @@ -527,7 +527,7 @@ static void tiny_print( struct SStringBuf * apBuf, { apBuf->flags.printLimit *= 10; apBuf->flags.printLimit += ch - '0'; - ch = *( format++ ); + ch = *( format++ ); } } } @@ -564,19 +564,19 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == 'l' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.long32 = 1; /* Makes not difference as u32 == long */ } if( ch == 'L' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.long64 = 1; /* Does make a difference */ } - apBuf->flags.base = 10; + apBuf->flags.base = 10; apBuf->flags.letBase = 'a'; if( ( ch == 'd' ) || ( ch == 'u' ) ) @@ -601,7 +601,7 @@ static void tiny_print( struct SStringBuf * apBuf, continue; } - apBuf->flags.base = 16; /* From here all hexadecimal */ + apBuf->flags.base = 16; /* From here all hexadecimal */ if( ( ch == 'x' ) && ( format[ 0 ] == 'i' ) && ( format[ 1 ] == 'p' ) ) { @@ -670,7 +670,7 @@ int snprintf( char * apBuf, const char * apFmt, ... ) { - va_list args; + va_list args; va_start( args, apFmt ); struct SStringBuf strBuf; @@ -686,7 +686,7 @@ int sprintf( char * apBuf, const char * apFmt, ... ) { - va_list args; + va_list args; va_start( args, apFmt ); struct SStringBuf strBuf; @@ -716,21 +716,21 @@ const char * mkSize( unsigned long long aSize, int aLen ) { static char retString[ 33 ]; - size_t gb, mb, kb, sb; + size_t gb, mb, kb, sb; if( apBuf == NULL ) { apBuf = retString; - aLen = sizeof( retString ); + aLen = sizeof( retString ); } - gb = aSize / ( 1024 * 1024 * 1024 ); + gb = aSize / ( 1024 * 1024 * 1024 ); aSize -= gb * ( 1024 * 1024 * 1024 ); - mb = aSize / ( 1024 * 1024 ); + mb = aSize / ( 1024 * 1024 ); aSize -= mb * ( 1024 * 1024 ); - kb = aSize / ( 1024 ); + kb = aSize / ( 1024 ); aSize -= kb * ( 1024 ); - sb = aSize; + sb = aSize; if( gb ) { diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/DemoTasks/ShadowDeviceOperationsExamples.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/DemoTasks/ShadowDeviceOperationsExamples.c index 4093cca64..7db4f25b2 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/DemoTasks/ShadowDeviceOperationsExamples.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/DemoTasks/ShadowDeviceOperationsExamples.c @@ -214,13 +214,13 @@ /** * @brief This is the current state of the shadow used in this demo. */ -static int32_t lDevicePowerOnState = 0; +static int32_t lDevicePowerOnState = 0; /** * @brief This is a Semaphore used to synchronize between delta callback and * Shadow updates. */ -iot_sem_internal_t xDeltaSemaphore = { 0 }; +iot_sem_internal_t xDeltaSemaphore = { 0 }; /** * @brief The task used to demonstrate Shadow. @@ -277,7 +277,7 @@ static void prvInitialiseLibraries( void ); /** * @brief The MQTT connection handle used in this example. */ -static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER; +static IotMqttConnection_t xMQTTConnection = IOT_MQTT_CONNECTION_INITIALIZER; /** * @brief Set the Shadow callback functions used in this demo. @@ -370,13 +370,13 @@ static BaseType_t prvGetUpdatedState( const char * pcUpdatedDocument, /*-----------------------------------------------------------*/ -static const struct IotNetworkServerInfo xMQTTBrokerInfo = +static const struct IotNetworkServerInfo xMQTTBrokerInfo = { .pHostName = awsiotdemoprofileAWS_ENDPOINT, .port = awsiotdemoprofileAWS_MQTT_PORT }; -static struct IotNetworkCredentials xNetworkSecurityCredentials = +static struct IotNetworkCredentials xNetworkSecurityCredentials = { /* Optional TLS extensions. For this demo, they are disabled. */ .pAlpnProtos = NULL, @@ -398,7 +398,7 @@ static struct IotNetworkCredentials xNetworkSecurityCredentials = .privateKeySize = sizeof( awsiotdemoprofileCLIENT_PRIVATE_KEY_PEM ) }; -static IotMqttNetworkInfo_t xNetworkInfo = +static IotMqttNetworkInfo_t xNetworkInfo = { /* No connection to the MQTT broker has been established yet and we want to * establish a new connection. */ @@ -419,7 +419,7 @@ static IotMqttNetworkInfo_t xNetworkInfo = }; -static const IotMqttConnectInfo_t xConnectInfo = +static const IotMqttConnectInfo_t xConnectInfo = { /* Set this flag to true if connecting to the AWS IoT MQTT broker. */ .awsIotMqttMode = true, @@ -479,8 +479,8 @@ void vStartShadowDeviceOperationsDemo( void ) static void prvShadowDemoTask( void * pvParameters ) { - uint32_t ulNotificationValue = 0; - const TickType_t xNoDelay = ( TickType_t ) 0; + uint32_t ulNotificationValue = 0; + const TickType_t xNoDelay = ( TickType_t ) 0; /* Remove compiler warnings about unused parameters. */ ( void ) pvParameters; @@ -620,33 +620,33 @@ static void prvMQTTDisconnect( void ) static void prvSetShadowCallbacks( void ) { - AwsIotShadowError_t xCallbackStatus = AWS_IOT_SHADOW_STATUS_PENDING; - AwsIotShadowCallbackInfo_t xDeltaCallback = AWS_IOT_SHADOW_CALLBACK_INFO_INITIALIZER, + AwsIotShadowError_t xCallbackStatus = AWS_IOT_SHADOW_STATUS_PENDING; + AwsIotShadowCallbackInfo_t xDeltaCallback = AWS_IOT_SHADOW_CALLBACK_INFO_INITIALIZER, xUpdatedCallback = AWS_IOT_SHADOW_CALLBACK_INFO_INITIALIZER; /* Set the functions for callbacks. */ xDeltaCallback.pCallbackContext = &xDeltaSemaphore; - xDeltaCallback.function = prvShadowDeltaCallback; - xUpdatedCallback.function = prvShadowUpdatedCallback; + xDeltaCallback.function = prvShadowDeltaCallback; + xUpdatedCallback.function = prvShadowUpdatedCallback; /************************ Set delta callbacks ****************************/ /* Set the delta callback, which notifies of different desired and reported * Shadow states. */ - xCallbackStatus = AwsIotShadow_SetDeltaCallback( xMQTTConnection, - awsiotdemoprofileCLIENT_IDENTIFIER, - shadowexampleCLIENT_IDENTIFIER_LENGTH, - 0, &xDeltaCallback ); + xCallbackStatus = AwsIotShadow_SetDeltaCallback( xMQTTConnection, + awsiotdemoprofileCLIENT_IDENTIFIER, + shadowexampleCLIENT_IDENTIFIER_LENGTH, + 0, &xDeltaCallback ); configASSERT( xCallbackStatus == AWS_IOT_SHADOW_SUCCESS ); /************************ Set updated callbacks **************************/ /* Set the updated callback, which notifies when a Shadow document is * changed. */ - xCallbackStatus = AwsIotShadow_SetUpdatedCallback( xMQTTConnection, - awsiotdemoprofileCLIENT_IDENTIFIER, - shadowexampleCLIENT_IDENTIFIER_LENGTH, - 0, &xUpdatedCallback ); + xCallbackStatus = AwsIotShadow_SetUpdatedCallback( xMQTTConnection, + awsiotdemoprofileCLIENT_IDENTIFIER, + shadowexampleCLIENT_IDENTIFIER_LENGTH, + 0, &xUpdatedCallback ); configASSERT( xCallbackStatus == AWS_IOT_SHADOW_SUCCESS ); } @@ -675,14 +675,14 @@ static void prvClearShadowCallbacks( void ) static void prvShadowDeltaCallback( void * pCallbackContext, AwsIotShadowCallbackParam_t * pxCallbackParam ) { - BaseType_t xDeltaFound = pdFALSE; - const char * pcDelta = NULL; - size_t xDeltaLength = 0; - IotSemaphore_t * pxDeltaSemaphore = pCallbackContext; - uint32_t ulUpdateDocumentLength = 0; - AwsIotShadowError_t xShadowStatus = AWS_IOT_SHADOW_STATUS_PENDING; - AwsIotShadowDocumentInfo_t xUpdateDocument = AWS_IOT_SHADOW_DOCUMENT_INFO_INITIALIZER; - uint8_t ucNewState = 0; + BaseType_t xDeltaFound = pdFALSE; + const char * pcDelta = NULL; + size_t xDeltaLength = 0; + IotSemaphore_t * pxDeltaSemaphore = pCallbackContext; + uint32_t ulUpdateDocumentLength = 0; + AwsIotShadowError_t xShadowStatus = AWS_IOT_SHADOW_STATUS_PENDING; + AwsIotShadowDocumentInfo_t xUpdateDocument = AWS_IOT_SHADOW_DOCUMENT_INFO_INITIALIZER; + uint8_t ucNewState = 0; configASSERT( pxDeltaSemaphore != NULL ); configASSERT( pxCallbackParam != NULL ); @@ -729,21 +729,21 @@ static void prvShadowDeltaCallback( void * pCallbackContext, lDevicePowerOnState, ucNewState ) ); - lDevicePowerOnState = ucNewState; + lDevicePowerOnState = ucNewState; /* Set the common members to report the new state. */ - xUpdateDocument.pThingName = pxCallbackParam->pThingName; - xUpdateDocument.thingNameLength = pxCallbackParam->thingNameLength; - xUpdateDocument.u.update.pUpdateDocument = cUpdateDocument; + xUpdateDocument.pThingName = pxCallbackParam->pThingName; + xUpdateDocument.thingNameLength = pxCallbackParam->thingNameLength; + xUpdateDocument.u.update.pUpdateDocument = cUpdateDocument; xUpdateDocument.u.update.updateDocumentLength = shadowexampleREPORTED_JSON_SIZE; /* Generate a Shadow document for the reported state. To keep the client * token within 6 characters, it is modded by 1000000. */ - ulUpdateDocumentLength = snprintf( cUpdateDocument, - shadowexampleREPORTED_JSON_SIZE + 1, - shadowexampleREPORTED_JSON, - ( int ) lDevicePowerOnState, - ( long unsigned ) ( IotClock_GetTimeMs() % 1000000 ) ); + ulUpdateDocumentLength = snprintf( cUpdateDocument, + shadowexampleREPORTED_JSON_SIZE + 1, + shadowexampleREPORTED_JSON, + ( int ) lDevicePowerOnState, + ( long unsigned ) ( IotClock_GetTimeMs() % 1000000 ) ); /* Check if the reported state document is generated for Shadow update*/ configASSERT( ( size_t ) ulUpdateDocumentLength == shadowexampleREPORTED_JSON_SIZE ); @@ -753,11 +753,11 @@ static void prvShadowDeltaCallback( void * pCallbackContext, * was successfully updated. As the Shadow is constantly updated * in this demo, the "Keep Subscriptions" flag is passed to this * function. */ - xShadowStatus = AwsIotShadow_UpdateAsync( pxCallbackParam->mqttConnection, - &xUpdateDocument, - AWS_IOT_SHADOW_FLAG_KEEP_SUBSCRIPTIONS, - NULL, - NULL ); + xShadowStatus = AwsIotShadow_UpdateAsync( pxCallbackParam->mqttConnection, + &xUpdateDocument, + AWS_IOT_SHADOW_FLAG_KEEP_SUBSCRIPTIONS, + NULL, + NULL ); configASSERT( xShadowStatus == AWS_IOT_SHADOW_STATUS_PENDING ); configPRINTF( ( "%.*s sent new state report: %.*s\r\n", @@ -775,9 +775,9 @@ static void prvShadowDeltaCallback( void * pCallbackContext, static void prvShadowUpdatedCallback( void * pCallbackContext, AwsIotShadowCallbackParam_t * pxCallbackParam ) { - BaseType_t xPreviousFound = pdFALSE, xCurrentFound = pdFALSE; + BaseType_t xPreviousFound = pdFALSE, xCurrentFound = pdFALSE; const char * pcPrevious = NULL, * pcCurrent = NULL; - size_t xPreviousLength = 0, xCurrentLength = 0; + size_t xPreviousLength = 0, xCurrentLength = 0; /* Silence warnings about unused parameters. */ ( void ) pCallbackContext; @@ -794,11 +794,11 @@ static void prvShadowUpdatedCallback( void * pCallbackContext, /****************** Get current state from Shadow document **************/ /* Find the current Shadow document. */ - xCurrentFound = prvGetUpdatedState( pxCallbackParam->u.callback.pDocument, - pxCallbackParam->u.callback.documentLength, - "current", - &pcCurrent, - &xCurrentLength ); + xCurrentFound = prvGetUpdatedState( pxCallbackParam->u.callback.pDocument, + pxCallbackParam->u.callback.documentLength, + "current", + &pcCurrent, + &xCurrentLength ); configASSERT( ( xPreviousFound == pdTRUE ) || ( xCurrentFound == pdTRUE ) ); @@ -819,10 +819,10 @@ static BaseType_t prvGetDelta( const char * pcDeltaDocument, const char ** pcDelta, size_t * pcDeltaLength ) { - BaseType_t xStateFound = pdFALSE, xDeltaFound = pdFALSE; + BaseType_t xStateFound = pdFALSE, xDeltaFound = pdFALSE; const size_t xDeltaKeyLength = strlen( pcDeltaKey ); - const char * pcState = NULL; - size_t xStateLength = 0; + const char * pcState = NULL; + size_t xStateLength = 0; configASSERT( pcDeltaDocument != NULL ); configASSERT( pcDeltaKey != NULL ); @@ -870,10 +870,10 @@ static BaseType_t prvGetUpdatedState( const char * pcUpdatedDocument, const char ** ppcState, size_t * ppcStateLength ) { - BaseType_t xSectionFound = pdFALSE, xStateFound = pdFALSE; + BaseType_t xSectionFound = pdFALSE, xStateFound = pdFALSE; const size_t xSectionKeyLength = strlen( pcSectionKey ); - const char * pcSection = NULL; - size_t xSectionLength = 0; + const char * pcSection = NULL; + size_t xSectionLength = 0; configASSERT( pcUpdatedDocument != NULL ); configASSERT( pcSectionKey != NULL ); @@ -906,7 +906,7 @@ static BaseType_t prvGetUpdatedState( const char * pcUpdatedDocument, * footprint rather than checking for correctness of the document. This * parser is not meant to be used as a general purpose JSON parser. */ - xStateFound = ( BaseType_t ) AwsIotDocParser_FindValue( + xStateFound = ( BaseType_t ) AwsIotDocParser_FindValue( pcSection, xSectionLength, "state", @@ -937,18 +937,18 @@ static void prvClearShadowDocument( void ) static void prvSendShadowUpdates( void ) { - int32_t lIndex = 0, lDesiredState = 0, lStatus = 0; - AwsIotShadowError_t xShadowStatus = AWS_IOT_SHADOW_STATUS_PENDING; - AwsIotShadowDocumentInfo_t xUpdateDocument = AWS_IOT_SHADOW_DOCUMENT_INFO_INITIALIZER; + int32_t lIndex = 0, lDesiredState = 0, lStatus = 0; + AwsIotShadowError_t xShadowStatus = AWS_IOT_SHADOW_STATUS_PENDING; + AwsIotShadowDocumentInfo_t xUpdateDocument = AWS_IOT_SHADOW_DOCUMENT_INFO_INITIALIZER; /* A buffer containing the update document. It has static duration to prevent * it from being placed on the call stack. */ - static char cUpdateDocument[ shadowexampleDESIRED_JSON_SIZE + 1 ] = { 0 }; + static char cUpdateDocument[ shadowexampleDESIRED_JSON_SIZE + 1 ] = { 0 }; /********** Set the common members of Shadow update document *************/ - xUpdateDocument.pThingName = awsiotdemoprofileCLIENT_IDENTIFIER; - xUpdateDocument.thingNameLength = shadowexampleCLIENT_IDENTIFIER_LENGTH; - xUpdateDocument.u.update.pUpdateDocument = cUpdateDocument; + xUpdateDocument.pThingName = awsiotdemoprofileCLIENT_IDENTIFIER; + xUpdateDocument.thingNameLength = shadowexampleCLIENT_IDENTIFIER_LENGTH; + xUpdateDocument.u.update.pUpdateDocument = cUpdateDocument; xUpdateDocument.u.update.updateDocumentLength = shadowexampleDESIRED_JSON_SIZE; /*************** Publish Shadow updates at a set period. *****************/ @@ -959,11 +959,11 @@ static void prvSendShadowUpdates( void ) /* Generate a Shadow desired state document, using a timestamp for the client * token. To keep the client token within 6 characters, it is modded by 1000000. */ - lStatus = snprintf( cUpdateDocument, - shadowexampleDESIRED_JSON_SIZE + 1, - shadowexampleDESIRED_JSON, - ( int ) lDesiredState, - ( long unsigned ) ( IotClock_GetTimeMs() % 1000000 ) ); + lStatus = snprintf( cUpdateDocument, + shadowexampleDESIRED_JSON_SIZE + 1, + shadowexampleDESIRED_JSON, + ( int ) lDesiredState, + ( long unsigned ) ( IotClock_GetTimeMs() % 1000000 ) ); /* Check for errors from snprintf. The expected value is the length of * the desired JSON document less the format specifier for the state. */ @@ -998,10 +998,10 @@ static void prvSendShadowUpdates( void ) } /* Remove persistent subscriptions. In the AwsIotShadow_UpdateSync call, we have used the */ - xShadowStatus = AwsIotShadow_RemovePersistentSubscriptions( xMQTTConnection, - awsiotdemoprofileCLIENT_IDENTIFIER, - shadowexampleCLIENT_IDENTIFIER_LENGTH, - AWS_IOT_SHADOW_FLAG_REMOVE_UPDATE_SUBSCRIPTIONS ); + xShadowStatus = AwsIotShadow_RemovePersistentSubscriptions( xMQTTConnection, + awsiotdemoprofileCLIENT_IDENTIFIER, + shadowexampleCLIENT_IDENTIFIER_LENGTH, + AWS_IOT_SHADOW_FLAG_REMOVE_UPDATE_SUBSCRIPTIONS ); configASSERT( xShadowStatus == AWS_IOT_SHADOW_SUCCESS ); } @@ -1009,7 +1009,7 @@ static void prvSendShadowUpdates( void ) static void prvInitialiseLibraries( void ) { - IotMqttError_t xResult; + IotMqttError_t xResult; IotNetworkError_t xNetworkResult; /* Initialize the network stack abstraction for FreeRTOS. */ @@ -1018,11 +1018,11 @@ static void prvInitialiseLibraries( void ) /* MQTT library must be initialized before it can be used. This is just one * time initialization. */ - xResult = IotMqtt_Init(); + xResult = IotMqtt_Init(); configASSERT( xResult == IOT_MQTT_SUCCESS ); /* Initialize Shadow library*/ - xResult = AwsIotShadow_Init( shadowexampleUSE_DEFAULT_MQTT_TIMEOUT ); + xResult = AwsIotShadow_Init( shadowexampleUSE_DEFAULT_MQTT_TIMEOUT ); configASSERT( xResult == AWS_IOT_SHADOW_SUCCESS ); } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/atomic.h b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/atomic.h index ee2402255..56a13838b 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/atomic.h +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/atomic.h @@ -179,7 +179,7 @@ #else ATOMIC_ENTER_CRITICAL(); - pReturnValue = *ppDestination; + pReturnValue = *ppDestination; *ppDestination = pExchange; @@ -227,7 +227,7 @@ if( *ppDestination == pComparand ) { *ppDestination = pExchange; - ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; } ATOMIC_EXIT_CRITICAL(); #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */ @@ -382,7 +382,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination |= ulValue; @@ -413,7 +413,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination &= ulValue; @@ -444,7 +444,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination = ~( ulCurrent & ulValue ); @@ -475,7 +475,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination ^= ulValue; diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/demo_logging.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/demo_logging.c index e6aa16c3e..cd2cf8dfb 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/demo_logging.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/demo_logging.c @@ -122,31 +122,31 @@ static void * pvLoggingThreadEvent = NULL; /* Stores the selected logging targets passed in as parameters to the * vLoggingInit() function. */ -BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE; +BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE; /* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32 * thread that is responsible for making Win32 calls (when stdout or a disk log is * used). */ -static StreamBuffer_t * xLogStreamBuffer = NULL; +static StreamBuffer_t * xLogStreamBuffer = NULL; /* Handle to the file used for logging. This is left open while there are * messages waiting to be logged, then closed again in between logs. */ -static FILE * pxLoggingFileHandle = NULL; +static FILE * pxLoggingFileHandle = NULL; /* When true prints are performed directly. After start up xDirectPrint is set * to pdFALSE - at which time prints that require Win32 system calls are done by * the Win32 thread responsible for logging. */ -BaseType_t xDirectPrint = pdTRUE; +BaseType_t xDirectPrint = pdTRUE; /* File names for the in use and complete (full) log files. */ -static const char * pcLogFileName = "RTOSDemo.log"; -static const char * pcFullLogFileName = "RTOSDemo.ful"; +static const char * pcLogFileName = "RTOSDemo.log"; +static const char * pcFullLogFileName = "RTOSDemo.ful"; /* As an optimization, the current file size is kept in a variable. */ -static size_t ulSizeOfLoggingFile = 0ul; +static size_t ulSizeOfLoggingFile = 0ul; /* The UDP socket and address on/to which print messages are sent. */ -Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET; +Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET; struct freertos_sockaddr xPrintUDPAddress; /*-----------------------------------------------------------*/ @@ -165,9 +165,9 @@ void vLoggingInit( BaseType_t xLogToStdout, HANDLE Win32Thread; /* Record which output methods are to be used. */ - xStdoutLoggingUsed = xLogToStdout; + xStdoutLoggingUsed = xLogToStdout; xDiskFileLoggingUsed = xLogToFile; - xUDPLoggingUsed = xLogToUDP; + xUDPLoggingUsed = xLogToUDP; /* If a disk file is used then initialize it now. */ if( xDiskFileLoggingUsed != pdFALSE ) @@ -193,16 +193,16 @@ void vLoggingInit( BaseType_t xLogToStdout, if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) ) { /* Create the buffer. */ - xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 ); + xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 ); configASSERT( xLogStreamBuffer ); memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) ); xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1; /* Create the Windows event. */ - pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" ); + pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" ); /* Create the thread itself. */ - Win32Thread = CreateThread( + Win32Thread = CreateThread( NULL, /* Pointer to thread security attributes. */ 0, /* Initial thread stack size, in bytes. */ prvWin32LoggingThread, /* Pointer to thread function. */ @@ -234,7 +234,7 @@ static void prvCreatePrintSocket( void * pvParameter1, uint32_t ulParameter2 ) { static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 ); - Socket_t xSocket; + Socket_t xSocket; /* The function prototype is that of a deferred function, but the parameters * are not actually used. */ @@ -258,17 +258,17 @@ static void prvCreatePrintSocket( void * pvParameter1, void vLoggingPrintf( const char * pcFormat, ... ) { - char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; - char cOutputString[ dlMAX_PRINT_STRING_LENGTH ]; - char * pcSource, * pcTarget, * pcBegin; - size_t xLength, xLength2, rc; + char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; + char cOutputString[ dlMAX_PRINT_STRING_LENGTH ]; + char * pcSource, * pcTarget, * pcBegin; + size_t xLength, xLength2, rc; static BaseType_t xMessageNumber = 0; - va_list args; - uint32_t ulIPAddress; - const char * pcTaskName; - const char * pcNoTask = "None"; - int iOriginalPriority; - HANDLE xCurrentTask; + va_list args; + uint32_t ulIPAddress; + const char * pcTaskName; + const char * pcNoTask = "None"; + int iOriginalPriority; + HANDLE xCurrentTask; if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) ) @@ -304,7 +304,7 @@ void vLoggingPrintf( const char * pcFormat, if( xLength2 < 0 ) { /* Clean up. */ - xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength; + xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength; cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0'; } @@ -328,7 +328,7 @@ void vLoggingPrintf( const char * pcFormat, *pcTarget = *pcSource; pcTarget++; *pcTarget = '\0'; - pcBegin = pcTarget - 8; + pcBegin = pcTarget - 8; while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) ) { @@ -336,18 +336,18 @@ void vLoggingPrintf( const char * pcFormat, } sscanf( pcTarget, "%8X", &ulIPAddress ); - rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", - ( unsigned long ) ( ulIPAddress >> 24UL ), - ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), - ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ), - ( unsigned long ) ( ulIPAddress & 0xffUL ) ); + rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", + ( unsigned long ) ( ulIPAddress >> 24UL ), + ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), + ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ), + ( unsigned long ) ( ulIPAddress & 0xffUL ) ); pcTarget += rc; pcSource += 3; /* skip "<n>ip" */ } } /* How far through the buffer was written? */ - xLength = ( BaseType_t ) ( pcTarget - cOutputString ); + xLength = ( BaseType_t ) ( pcTarget - cOutputString ); /* If the message is to be logged to a UDP port then it can be sent directly * because it only uses FreeRTOS function (not Win32 functions). */ @@ -393,7 +393,7 @@ void vLoggingPrintf( const char * pcFormat, * as there are potentially multiple writers. The stream buffer is * only thread safe when there is a single writer (likewise for * reading from the buffer). */ - xCurrentTask = GetCurrentThread(); + xCurrentTask = GetCurrentThread(); iOriginalPriority = GetThreadPriority( xCurrentTask ); SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL ); uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) ); @@ -426,7 +426,7 @@ void vLoggingPrintf( const char * pcFormat, static void prvLoggingFlushBuffer( void ) { size_t xLength; - char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; + char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; /* Is there more than the length value stored in the circular buffer * used to pass data from the FreeRTOS simulator into this Win32 thread? */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/main.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/main.c index 2bf56e74c..23d6a1d6b 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/main.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/main.c @@ -95,7 +95,7 @@ const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALS * to and from a real network connection on the host PC. See the * configNETWORK_INTERFACE_TO_USE definition for information on how to configure * the real network connection to use. */ -const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 }; +const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 }; /* Use by the pseudo random number generator. */ static UBaseType_t ulNextRand; @@ -140,8 +140,8 @@ int main( void ) * events are only received if implemented in the MAC driver. */ void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent ) { - uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; - char cBuffer[ 16 ]; + uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; + char cBuffer[ 16 ]; static BaseType_t xTasksAlreadyCreated = pdFALSE; /* If the network has just come up...*/ @@ -180,8 +180,8 @@ void vAssertCalled( const char * pcFile, uint32_t ulLine ) { volatile uint32_t ulBlockVariable = 0UL; - volatile char * pcFileName = ( volatile char * ) pcFile; - volatile uint32_t ulLineNumber = ulLine; + volatile char * pcFileName = ( volatile char * ) pcFile; + volatile uint32_t ulLineNumber = ulLine; ( void ) pcFileName; ( void ) ulLineNumber; @@ -226,7 +226,7 @@ static void prvSRand( UBaseType_t ulSeed ) static void prvMiscInitialisation( void ) { - time_t xTimeNow; + time_t xTimeNow; uint32_t ulLoggingIPAddress; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 ); @@ -334,11 +334,11 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, * function then they must be declared static - otherwise they will be allocated on * the stack and so not exists after this function exits. */ static StaticTask_t xIdleTaskTCB; - static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; + static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; /* Pass out a pointer to the StaticTask_t structure in which the Idle task's * state will be stored. */ - *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; /* Pass out the array that will be used as the Idle task's stack. */ *ppxIdleTaskStackBuffer = uxIdleTaskStack; @@ -346,7 +346,7 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; } /*-----------------------------------------------------------*/ @@ -361,11 +361,11 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, * function then they must be declared static - otherwise they will be allocated on * the stack and so not exists after this function exits. */ static StaticTask_t xTimerTaskTCB; - static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; + static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; /* Pass out a pointer to the StaticTask_t structure in which the Timer * task's state will be stored. */ - *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; /* Pass out the array that will be used as the Timer task's stack. */ *ppxTimerTaskStackBuffer = uxTimerTaskStack; @@ -373,6 +373,6 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/printf-stdarg.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/printf-stdarg.c index f9bc5b5b1..ae28ddde0 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/printf-stdarg.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta1/shadow/shadow_device_operations/printf-stdarg.c @@ -64,7 +64,7 @@ static void strbuf_init( struct SStringBuf * apStr, char * apBuf, const char * apMaxStr ) { - apStr->str = apBuf; + apStr->str = apBuf; apStr->orgStr = apBuf; apStr->nulPos = apMaxStr - 1; apStr->curLen = 0; @@ -158,7 +158,7 @@ static BaseType_t prints( struct SStringBuf * apBuf, const char * apString ) { register int padchar = ' '; - int i, len; + int i, len; if( xApplicationMemoryPermissions( ( uint32_t ) apString ) == 0 ) { @@ -169,7 +169,7 @@ static BaseType_t prints( struct SStringBuf * apBuf, if( apBuf->flags.width > 0 ) { - register int len = 0; + register int len = 0; register const char * ptr; for( ptr = apString; *ptr; ++ptr ) @@ -257,11 +257,11 @@ static BaseType_t prints( struct SStringBuf * apBuf, static BaseType_t printll( struct SStringBuf * apBuf, long long i ) { - char print_buf[ 2 * PRINT_BUF_LEN ]; - register char * s; - register int t, neg = 0; + char print_buf[ 2 * PRINT_BUF_LEN ]; + register char * s; + register int t, neg = 0; register unsigned long long u = i; - lldiv_t lldiv_result; + lldiv_t lldiv_result; /* typedef struct * { @@ -282,26 +282,26 @@ static BaseType_t prints( struct SStringBuf * apBuf, if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) ) { neg = 1; - u = -i; + u = -i; } - s = print_buf + sizeof( print_buf ) - 1; + s = print_buf + sizeof( print_buf ) - 1; - *s = '\0'; + *s = '\0'; /* 18446744073709551616 */ while( u != 0 ) { lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base ); - t = lldiv_result.rem; + t = lldiv_result.rem; if( t >= 10 ) { t += apBuf->flags.letBase - '0' - 10; } - *( --s ) = t + '0'; - u = lldiv_result.quot; + *( --s ) = t + '0'; + u = lldiv_result.quot; } if( neg != 0 ) @@ -329,11 +329,11 @@ static BaseType_t prints( struct SStringBuf * apBuf, static BaseType_t printi( struct SStringBuf * apBuf, int i ) { - char print_buf[ PRINT_BUF_LEN ]; - register char * s; - register int t, neg = 0; - register unsigned int u = i; - register unsigned base = apBuf->flags.base; + char print_buf[ PRINT_BUF_LEN ]; + register char * s; + register int t, neg = 0; + register unsigned int u = i; + register unsigned base = apBuf->flags.base; apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */ @@ -347,12 +347,12 @@ static BaseType_t printi( struct SStringBuf * apBuf, if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) ) { neg = 1; - u = -i; + u = -i; } - s = print_buf + sizeof( print_buf ) - 1; + s = print_buf + sizeof( print_buf ) - 1; - *s = '\0'; + *s = '\0'; switch( base ) { @@ -360,7 +360,7 @@ static BaseType_t printi( struct SStringBuf * apBuf, while( u != 0 ) { - t = u & 0xF; + t = u & 0xF; if( t >= 10 ) { @@ -368,7 +368,7 @@ static BaseType_t printi( struct SStringBuf * apBuf, } *( --s ) = t + '0'; - u >>= 4; + u >>= 4; } break; @@ -379,9 +379,9 @@ static BaseType_t printi( struct SStringBuf * apBuf, /* GCC compiles very efficient */ while( u ) { - t = u % base; + t = u % base; *( --s ) = t + '0'; - u /= base; + u /= base; } break; @@ -487,19 +487,19 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == '-' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.pad = PAD_RIGHT; } while( ch == '0' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.pad |= PAD_ZERO; } if( ch == '*' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.width = va_arg( args, int ); } else @@ -508,7 +508,7 @@ static void tiny_print( struct SStringBuf * apBuf, { apBuf->flags.width *= 10; apBuf->flags.width += ch - '0'; - ch = *( format++ ); + ch = *( format++ ); } } @@ -519,7 +519,7 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == '*' ) { apBuf->flags.printLimit = va_arg( args, int ); - ch = *( format++ ); + ch = *( format++ ); } else { @@ -527,7 +527,7 @@ static void tiny_print( struct SStringBuf * apBuf, { apBuf->flags.printLimit *= 10; apBuf->flags.printLimit += ch - '0'; - ch = *( format++ ); + ch = *( format++ ); } } } @@ -564,19 +564,19 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == 'l' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.long32 = 1; /* Makes not difference as u32 == long */ } if( ch == 'L' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.long64 = 1; /* Does make a difference */ } - apBuf->flags.base = 10; + apBuf->flags.base = 10; apBuf->flags.letBase = 'a'; if( ( ch == 'd' ) || ( ch == 'u' ) ) @@ -601,7 +601,7 @@ static void tiny_print( struct SStringBuf * apBuf, continue; } - apBuf->flags.base = 16; /* From here all hexadecimal */ + apBuf->flags.base = 16; /* From here all hexadecimal */ if( ( ch == 'x' ) && ( format[ 0 ] == 'i' ) && ( format[ 1 ] == 'p' ) ) { @@ -670,7 +670,7 @@ int snprintf( char * apBuf, const char * apFmt, ... ) { - va_list args; + va_list args; va_start( args, apFmt ); struct SStringBuf strBuf; @@ -686,7 +686,7 @@ int sprintf( char * apBuf, const char * apFmt, ... ) { - va_list args; + va_list args; va_start( args, apFmt ); struct SStringBuf strBuf; @@ -716,21 +716,21 @@ const char * mkSize( unsigned long long aSize, int aLen ) { static char retString[ 33 ]; - size_t gb, mb, kb, sb; + size_t gb, mb, kb, sb; if( apBuf == NULL ) { apBuf = retString; - aLen = sizeof( retString ); + aLen = sizeof( retString ); } - gb = aSize / ( 1024 * 1024 * 1024 ); + gb = aSize / ( 1024 * 1024 * 1024 ); aSize -= gb * ( 1024 * 1024 * 1024 ); - mb = aSize / ( 1024 * 1024 ); + mb = aSize / ( 1024 * 1024 ); aSize -= mb * ( 1024 * 1024 ); - kb = aSize / ( 1024 ); + kb = aSize / ( 1024 ); aSize -= kb * ( 1024 ); - sb = aSize; + sb = aSize; if( gb ) { diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta2/mqtt/common/demo_logging.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta2/mqtt/common/demo_logging.c index e6aa16c3e..cd2cf8dfb 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta2/mqtt/common/demo_logging.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta2/mqtt/common/demo_logging.c @@ -122,31 +122,31 @@ static void * pvLoggingThreadEvent = NULL; /* Stores the selected logging targets passed in as parameters to the * vLoggingInit() function. */ -BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE; +BaseType_t xStdoutLoggingUsed = pdFALSE, xDiskFileLoggingUsed = pdFALSE, xUDPLoggingUsed = pdFALSE; /* Circular buffer used to pass messages from the FreeRTOS tasks to the Win32 * thread that is responsible for making Win32 calls (when stdout or a disk log is * used). */ -static StreamBuffer_t * xLogStreamBuffer = NULL; +static StreamBuffer_t * xLogStreamBuffer = NULL; /* Handle to the file used for logging. This is left open while there are * messages waiting to be logged, then closed again in between logs. */ -static FILE * pxLoggingFileHandle = NULL; +static FILE * pxLoggingFileHandle = NULL; /* When true prints are performed directly. After start up xDirectPrint is set * to pdFALSE - at which time prints that require Win32 system calls are done by * the Win32 thread responsible for logging. */ -BaseType_t xDirectPrint = pdTRUE; +BaseType_t xDirectPrint = pdTRUE; /* File names for the in use and complete (full) log files. */ -static const char * pcLogFileName = "RTOSDemo.log"; -static const char * pcFullLogFileName = "RTOSDemo.ful"; +static const char * pcLogFileName = "RTOSDemo.log"; +static const char * pcFullLogFileName = "RTOSDemo.ful"; /* As an optimization, the current file size is kept in a variable. */ -static size_t ulSizeOfLoggingFile = 0ul; +static size_t ulSizeOfLoggingFile = 0ul; /* The UDP socket and address on/to which print messages are sent. */ -Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET; +Socket_t xPrintSocket = FREERTOS_INVALID_SOCKET; struct freertos_sockaddr xPrintUDPAddress; /*-----------------------------------------------------------*/ @@ -165,9 +165,9 @@ void vLoggingInit( BaseType_t xLogToStdout, HANDLE Win32Thread; /* Record which output methods are to be used. */ - xStdoutLoggingUsed = xLogToStdout; + xStdoutLoggingUsed = xLogToStdout; xDiskFileLoggingUsed = xLogToFile; - xUDPLoggingUsed = xLogToUDP; + xUDPLoggingUsed = xLogToUDP; /* If a disk file is used then initialize it now. */ if( xDiskFileLoggingUsed != pdFALSE ) @@ -193,16 +193,16 @@ void vLoggingInit( BaseType_t xLogToStdout, if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) ) { /* Create the buffer. */ - xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 ); + xLogStreamBuffer = ( StreamBuffer_t * ) malloc( sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) + dlLOGGING_STREAM_BUFFER_SIZE + 1 ); configASSERT( xLogStreamBuffer ); memset( xLogStreamBuffer, '\0', sizeof( *xLogStreamBuffer ) - sizeof( xLogStreamBuffer->ucArray ) ); xLogStreamBuffer->LENGTH = dlLOGGING_STREAM_BUFFER_SIZE + 1; /* Create the Windows event. */ - pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" ); + pvLoggingThreadEvent = CreateEvent( NULL, FALSE, TRUE, "StdoutLoggingEvent" ); /* Create the thread itself. */ - Win32Thread = CreateThread( + Win32Thread = CreateThread( NULL, /* Pointer to thread security attributes. */ 0, /* Initial thread stack size, in bytes. */ prvWin32LoggingThread, /* Pointer to thread function. */ @@ -234,7 +234,7 @@ static void prvCreatePrintSocket( void * pvParameter1, uint32_t ulParameter2 ) { static const TickType_t xSendTimeOut = pdMS_TO_TICKS( 0 ); - Socket_t xSocket; + Socket_t xSocket; /* The function prototype is that of a deferred function, but the parameters * are not actually used. */ @@ -258,17 +258,17 @@ static void prvCreatePrintSocket( void * pvParameter1, void vLoggingPrintf( const char * pcFormat, ... ) { - char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; - char cOutputString[ dlMAX_PRINT_STRING_LENGTH ]; - char * pcSource, * pcTarget, * pcBegin; - size_t xLength, xLength2, rc; + char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; + char cOutputString[ dlMAX_PRINT_STRING_LENGTH ]; + char * pcSource, * pcTarget, * pcBegin; + size_t xLength, xLength2, rc; static BaseType_t xMessageNumber = 0; - va_list args; - uint32_t ulIPAddress; - const char * pcTaskName; - const char * pcNoTask = "None"; - int iOriginalPriority; - HANDLE xCurrentTask; + va_list args; + uint32_t ulIPAddress; + const char * pcTaskName; + const char * pcNoTask = "None"; + int iOriginalPriority; + HANDLE xCurrentTask; if( ( xStdoutLoggingUsed != pdFALSE ) || ( xDiskFileLoggingUsed != pdFALSE ) || ( xUDPLoggingUsed != pdFALSE ) ) @@ -304,7 +304,7 @@ void vLoggingPrintf( const char * pcFormat, if( xLength2 < 0 ) { /* Clean up. */ - xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength; + xLength2 = dlMAX_PRINT_STRING_LENGTH - 1 - xLength; cPrintString[ dlMAX_PRINT_STRING_LENGTH - 1 ] = '\0'; } @@ -328,7 +328,7 @@ void vLoggingPrintf( const char * pcFormat, *pcTarget = *pcSource; pcTarget++; *pcTarget = '\0'; - pcBegin = pcTarget - 8; + pcBegin = pcTarget - 8; while( ( pcTarget > pcBegin ) && ( isxdigit( pcTarget[ -1 ] ) != pdFALSE ) ) { @@ -336,18 +336,18 @@ void vLoggingPrintf( const char * pcFormat, } sscanf( pcTarget, "%8X", &ulIPAddress ); - rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", - ( unsigned long ) ( ulIPAddress >> 24UL ), - ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), - ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ), - ( unsigned long ) ( ulIPAddress & 0xffUL ) ); + rc = sprintf( pcTarget, "%lu.%lu.%lu.%lu", + ( unsigned long ) ( ulIPAddress >> 24UL ), + ( unsigned long ) ( ( ulIPAddress >> 16UL ) & 0xffUL ), + ( unsigned long ) ( ( ulIPAddress >> 8UL ) & 0xffUL ), + ( unsigned long ) ( ulIPAddress & 0xffUL ) ); pcTarget += rc; pcSource += 3; /* skip "<n>ip" */ } } /* How far through the buffer was written? */ - xLength = ( BaseType_t ) ( pcTarget - cOutputString ); + xLength = ( BaseType_t ) ( pcTarget - cOutputString ); /* If the message is to be logged to a UDP port then it can be sent directly * because it only uses FreeRTOS function (not Win32 functions). */ @@ -393,7 +393,7 @@ void vLoggingPrintf( const char * pcFormat, * as there are potentially multiple writers. The stream buffer is * only thread safe when there is a single writer (likewise for * reading from the buffer). */ - xCurrentTask = GetCurrentThread(); + xCurrentTask = GetCurrentThread(); iOriginalPriority = GetThreadPriority( xCurrentTask ); SetThreadPriority( GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL ); uxStreamBufferAdd( xLogStreamBuffer, 0, ( const uint8_t * ) &( xLength ), sizeof( xLength ) ); @@ -426,7 +426,7 @@ void vLoggingPrintf( const char * pcFormat, static void prvLoggingFlushBuffer( void ) { size_t xLength; - char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; + char cPrintString[ dlMAX_PRINT_STRING_LENGTH ]; /* Is there more than the length value stored in the circular buffer * used to pass data from the FreeRTOS simulator into this Win32 thread? */ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta2/mqtt/common/main.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta2/mqtt/common/main.c index 31a420480..af7ebd4e8 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta2/mqtt/common/main.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta2/mqtt/common/main.c @@ -94,7 +94,7 @@ const BaseType_t xLogToStdout = pdTRUE, xLogToFile = pdFALSE, xLogToUDP = pdFALS * to and from a real network connection on the host PC. See the * configNETWORK_INTERFACE_TO_USE definition for information on how to configure * the real network connection to use. */ -const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 }; +const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 }; /* Use by the pseudo random number generator. */ static UBaseType_t ulNextRand; @@ -139,8 +139,8 @@ int main( void ) * events are only received if implemented in the MAC driver. */ void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent ) { - uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; - char cBuffer[ 16 ]; + uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress; + char cBuffer[ 16 ]; static BaseType_t xTasksAlreadyCreated = pdFALSE; /* If the network has just come up...*/ @@ -179,8 +179,8 @@ void vAssertCalled( const char * pcFile, uint32_t ulLine ) { volatile uint32_t ulBlockVariable = 0UL; - volatile char * pcFileName = ( volatile char * ) pcFile; - volatile uint32_t ulLineNumber = ulLine; + volatile char * pcFileName = ( volatile char * ) pcFile; + volatile uint32_t ulLineNumber = ulLine; ( void ) pcFileName; ( void ) ulLineNumber; @@ -225,7 +225,7 @@ static void prvSRand( UBaseType_t ulSeed ) static void prvMiscInitialisation( void ) { - time_t xTimeNow; + time_t xTimeNow; uint32_t ulLoggingIPAddress; ulLoggingIPAddress = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0, configECHO_SERVER_ADDR1, configECHO_SERVER_ADDR2, configECHO_SERVER_ADDR3 ); @@ -333,11 +333,11 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, * function then they must be declared static - otherwise they will be allocated on * the stack and so not exists after this function exits. */ static StaticTask_t xIdleTaskTCB; - static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; + static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; /* Pass out a pointer to the StaticTask_t structure in which the Idle task's * state will be stored. */ - *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; /* Pass out the array that will be used as the Idle task's stack. */ *ppxIdleTaskStackBuffer = uxIdleTaskStack; @@ -345,7 +345,7 @@ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer, /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; } /*-----------------------------------------------------------*/ @@ -360,11 +360,11 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, * function then they must be declared static - otherwise they will be allocated on * the stack and so not exists after this function exits. */ static StaticTask_t xTimerTaskTCB; - static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; + static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; /* Pass out a pointer to the StaticTask_t structure in which the Timer * task's state will be stored. */ - *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; /* Pass out the array that will be used as the Timer task's stack. */ *ppxTimerTaskStackBuffer = uxTimerTaskStack; @@ -372,6 +372,6 @@ void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer, /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. * Note that, as the array is necessarily of type StackType_t, * configMINIMAL_STACK_SIZE is specified in words, not bytes. */ - *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta2/mqtt/common/printf-stdarg.c b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta2/mqtt/common/printf-stdarg.c index f9bc5b5b1..ae28ddde0 100644 --- a/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta2/mqtt/common/printf-stdarg.c +++ b/FreeRTOS-Plus/Demo/FreeRTOS-IoT-Libraries-LTS-Beta2/mqtt/common/printf-stdarg.c @@ -64,7 +64,7 @@ static void strbuf_init( struct SStringBuf * apStr, char * apBuf, const char * apMaxStr ) { - apStr->str = apBuf; + apStr->str = apBuf; apStr->orgStr = apBuf; apStr->nulPos = apMaxStr - 1; apStr->curLen = 0; @@ -158,7 +158,7 @@ static BaseType_t prints( struct SStringBuf * apBuf, const char * apString ) { register int padchar = ' '; - int i, len; + int i, len; if( xApplicationMemoryPermissions( ( uint32_t ) apString ) == 0 ) { @@ -169,7 +169,7 @@ static BaseType_t prints( struct SStringBuf * apBuf, if( apBuf->flags.width > 0 ) { - register int len = 0; + register int len = 0; register const char * ptr; for( ptr = apString; *ptr; ++ptr ) @@ -257,11 +257,11 @@ static BaseType_t prints( struct SStringBuf * apBuf, static BaseType_t printll( struct SStringBuf * apBuf, long long i ) { - char print_buf[ 2 * PRINT_BUF_LEN ]; - register char * s; - register int t, neg = 0; + char print_buf[ 2 * PRINT_BUF_LEN ]; + register char * s; + register int t, neg = 0; register unsigned long long u = i; - lldiv_t lldiv_result; + lldiv_t lldiv_result; /* typedef struct * { @@ -282,26 +282,26 @@ static BaseType_t prints( struct SStringBuf * apBuf, if( ( apBuf->flags.isSigned == pdTRUE ) && ( apBuf->flags.base == 10 ) && ( i < 0LL ) ) { neg = 1; - u = -i; + u = -i; } - s = print_buf + sizeof( print_buf ) - 1; + s = print_buf + sizeof( print_buf ) - 1; - *s = '\0'; + *s = '\0'; /* 18446744073709551616 */ while( u != 0 ) { lldiv_result = lldiv( u, ( unsigned long long ) apBuf->flags.base ); - t = lldiv_result.rem; + t = lldiv_result.rem; if( t >= 10 ) { t += apBuf->flags.letBase - '0' - 10; } - *( --s ) = t + '0'; - u = lldiv_result.quot; + *( --s ) = t + '0'; + u = lldiv_result.quot; } if( neg != 0 ) @@ -329,11 +329,11 @@ static BaseType_t prints( struct SStringBuf * apBuf, static BaseType_t printi( struct SStringBuf * apBuf, int i ) { - char print_buf[ PRINT_BUF_LEN ]; - register char * s; - register int t, neg = 0; - register unsigned int u = i; - register unsigned base = apBuf->flags.base; + char print_buf[ PRINT_BUF_LEN ]; + register char * s; + register int t, neg = 0; + register unsigned int u = i; + register unsigned base = apBuf->flags.base; apBuf->flags.isNumber = pdTRUE; /* Parameter for prints */ @@ -347,12 +347,12 @@ static BaseType_t printi( struct SStringBuf * apBuf, if( ( apBuf->flags.isSigned == pdTRUE ) && ( base == 10 ) && ( i < 0 ) ) { neg = 1; - u = -i; + u = -i; } - s = print_buf + sizeof( print_buf ) - 1; + s = print_buf + sizeof( print_buf ) - 1; - *s = '\0'; + *s = '\0'; switch( base ) { @@ -360,7 +360,7 @@ static BaseType_t printi( struct SStringBuf * apBuf, while( u != 0 ) { - t = u & 0xF; + t = u & 0xF; if( t >= 10 ) { @@ -368,7 +368,7 @@ static BaseType_t printi( struct SStringBuf * apBuf, } *( --s ) = t + '0'; - u >>= 4; + u >>= 4; } break; @@ -379,9 +379,9 @@ static BaseType_t printi( struct SStringBuf * apBuf, /* GCC compiles very efficient */ while( u ) { - t = u % base; + t = u % base; *( --s ) = t + '0'; - u /= base; + u /= base; } break; @@ -487,19 +487,19 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == '-' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.pad = PAD_RIGHT; } while( ch == '0' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.pad |= PAD_ZERO; } if( ch == '*' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.width = va_arg( args, int ); } else @@ -508,7 +508,7 @@ static void tiny_print( struct SStringBuf * apBuf, { apBuf->flags.width *= 10; apBuf->flags.width += ch - '0'; - ch = *( format++ ); + ch = *( format++ ); } } @@ -519,7 +519,7 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == '*' ) { apBuf->flags.printLimit = va_arg( args, int ); - ch = *( format++ ); + ch = *( format++ ); } else { @@ -527,7 +527,7 @@ static void tiny_print( struct SStringBuf * apBuf, { apBuf->flags.printLimit *= 10; apBuf->flags.printLimit += ch - '0'; - ch = *( format++ ); + ch = *( format++ ); } } } @@ -564,19 +564,19 @@ static void tiny_print( struct SStringBuf * apBuf, if( ch == 'l' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.long32 = 1; /* Makes not difference as u32 == long */ } if( ch == 'L' ) { - ch = *( format++ ); + ch = *( format++ ); apBuf->flags.long64 = 1; /* Does make a difference */ } - apBuf->flags.base = 10; + apBuf->flags.base = 10; apBuf->flags.letBase = 'a'; if( ( ch == 'd' ) || ( ch == 'u' ) ) @@ -601,7 +601,7 @@ static void tiny_print( struct SStringBuf * apBuf, continue; } - apBuf->flags.base = 16; /* From here all hexadecimal */ + apBuf->flags.base = 16; /* From here all hexadecimal */ if( ( ch == 'x' ) && ( format[ 0 ] == 'i' ) && ( format[ 1 ] == 'p' ) ) { @@ -670,7 +670,7 @@ int snprintf( char * apBuf, const char * apFmt, ... ) { - va_list args; + va_list args; va_start( args, apFmt ); struct SStringBuf strBuf; @@ -686,7 +686,7 @@ int sprintf( char * apBuf, const char * apFmt, ... ) { - va_list args; + va_list args; va_start( args, apFmt ); struct SStringBuf strBuf; @@ -716,21 +716,21 @@ const char * mkSize( unsigned long long aSize, int aLen ) { static char retString[ 33 ]; - size_t gb, mb, kb, sb; + size_t gb, mb, kb, sb; if( apBuf == NULL ) { apBuf = retString; - aLen = sizeof( retString ); + aLen = sizeof( retString ); } - gb = aSize / ( 1024 * 1024 * 1024 ); + gb = aSize / ( 1024 * 1024 * 1024 ); aSize -= gb * ( 1024 * 1024 * 1024 ); - mb = aSize / ( 1024 * 1024 ); + mb = aSize / ( 1024 * 1024 ); aSize -= mb * ( 1024 * 1024 ); - kb = aSize / ( 1024 ); + kb = aSize / ( 1024 ); aSize -= kb * ( 1024 ); - sb = aSize; + sb = aSize; if( gb ) { diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/mbedtls/mbedtls_platform_freertos.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/mbedtls/mbedtls_platform_freertos.c index a10f53250..17a60a399 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/mbedtls/mbedtls_platform_freertos.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/mbedtls/mbedtls_platform_freertos.c @@ -40,7 +40,7 @@ void * mbedtls_platform_calloc( size_t nmemb, size_t size ) { size_t totalSize = nmemb * size; - void * pBuffer = NULL; + void * pBuffer = NULL; /* Check that neither nmemb nor size were 0. */ if( totalSize > 0 ) @@ -147,7 +147,7 @@ int mbedtls_platform_entropy_poll( void * data, size_t len, size_t * olen ) { - int status = 0; + int status = 0; NTSTATUS rngStatus = 0; /* Context is not used by this function. */ @@ -166,7 +166,7 @@ int mbedtls_platform_entropy_poll( void * data, else { /* RNG failure. */ - *olen = 0; + *olen = 0; status = MBEDTLS_ERR_ENTROPY_SOURCE_FAILED; } diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_clock_freertos.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_clock_freertos.c index ae5703321..6d9d59400 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_clock_freertos.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_clock_freertos.c @@ -89,14 +89,14 @@ bool IotClock_GetTimestring( char * pBuffer, size_t bufferSize, size_t * pTimestringLength ) { - uint64_t milliSeconds = IotClock_GetTimeMs(); - int timestringLength = 0; + uint64_t milliSeconds = IotClock_GetTimeMs(); + int timestringLength = 0; configASSERT( pBuffer != NULL ); configASSERT( pTimestringLength != NULL ); /* Convert the localTime struct to a string. */ - timestringLength = snprintf( pBuffer, bufferSize, "%llu", milliSeconds ); + timestringLength = snprintf( pBuffer, bufferSize, "%llu", milliSeconds ); /* Check for error from no string */ if( timestringLength == 0 ) @@ -117,14 +117,14 @@ uint64_t IotClock_GetTimeMs( void ) TimeOut_t xCurrentTime = { 0 }; /* This must be unsigned because the behavior of signed integer overflow is undefined. */ - uint64_t ullTickCount = 0ULL; + uint64_t ullTickCount = 0ULL; /* Get the current tick count and overflow count. vTaskSetTimeOutState() * is used to get these values because they are both static in tasks.c. */ vTaskSetTimeOutState( &xCurrentTime ); /* Adjust the tick count for the number of times a TickType_t has overflowed. */ - ullTickCount = ( uint64_t ) ( xCurrentTime.xOverflowCount ) << ( sizeof( TickType_t ) * 8 ); + ullTickCount = ( uint64_t ) ( xCurrentTime.xOverflowCount ) << ( sizeof( TickType_t ) * 8 ); /* Add the current tick count. */ ullTickCount += xCurrentTime.xTimeOnEntering; @@ -154,18 +154,18 @@ bool IotClock_TimerCreate( IotTimer_t * pNewTimer, /* Set the timer expiration routine, argument and period */ pxTimer->threadRoutine = expirationRoutine; - pxTimer->pArgument = pArgument; - pxTimer->xTimerPeriod = 0; + pxTimer->pArgument = pArgument; + pxTimer->xTimerPeriod = 0; /* Create a new FreeRTOS timer. This call will not fail because the * memory for it has already been allocated, so the output parameter is * also set. */ - pxTimer->timer = ( TimerHandle_t ) xTimerCreateStatic( "timer", /* Timer name. */ - portMAX_DELAY, /* Initial timer period. Timers are created disarmed. */ - pdFALSE, /* Don't auto-reload timer. */ - ( void * ) pxTimer, /* Timer id. */ - prvTimerCallback, /* Timer expiration callback. */ - &pxTimer->xTimerBuffer ); /* Pre-allocated memory for timer. */ + pxTimer->timer = ( TimerHandle_t ) xTimerCreateStatic( "timer", /* Timer name. */ + portMAX_DELAY, /* Initial timer period. Timers are created disarmed. */ + pdFALSE, /* Don't auto-reload timer. */ + ( void * ) pxTimer, /* Timer id. */ + prvTimerCallback, /* Timer expiration callback. */ + &pxTimer->xTimerBuffer ); /* Pre-allocated memory for timer. */ return true; } @@ -202,11 +202,11 @@ bool IotClock_TimerArm( IotTimer_t * pTimer, uint32_t relativeTimeoutMs, uint32_t periodMs ) { - _IotSystemTimer_t * pTimerInfo = ( _IotSystemTimer_t * ) pTimer; + _IotSystemTimer_t * pTimerInfo = ( _IotSystemTimer_t * ) pTimer; configASSERT( pTimerInfo != NULL ); - TimerHandle_t xTimerHandle = pTimerInfo->timer; + TimerHandle_t xTimerHandle = pTimerInfo->timer; IotLogDebug( "Arming timer %p with timeout %llu and period %llu.", pTimer, diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_freertos.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_freertos.c index 2f9f83cd0..9ee3f7769 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_freertos.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_freertos.c @@ -255,10 +255,10 @@ const IotNetworkInterface_t IotNetworkFreeRTOS = /* Initialize the mbed TLS context structures. */ _sslContextInit( pNetworkConnection ); - mbedtlsError = mbedtls_ssl_config_defaults( &( pNetworkConnection->ssl.config ), - MBEDTLS_SSL_IS_CLIENT, - MBEDTLS_SSL_TRANSPORT_STREAM, - MBEDTLS_SSL_PRESET_DEFAULT ); + mbedtlsError = mbedtls_ssl_config_defaults( &( pNetworkConnection->ssl.config ), + MBEDTLS_SSL_IS_CLIENT, + MBEDTLS_SSL_TRANSPORT_STREAM, + MBEDTLS_SSL_PRESET_DEFAULT ); if( mbedtlsError != 0 ) { @@ -290,9 +290,9 @@ const IotNetworkInterface_t IotNetworkFreeRTOS = &( pNetworkConnection->ssl.certProfile ) ); /* Parse the server root CA certificate into the SSL context. */ - mbedtlsError = mbedtls_x509_crt_parse( &( pNetworkConnection->ssl.rootCa ), - ( const unsigned char * ) pCredentials->pRootCa, - pCredentials->rootCaSize ); + mbedtlsError = mbedtls_x509_crt_parse( &( pNetworkConnection->ssl.rootCa ), + ( const unsigned char * ) pCredentials->pRootCa, + pCredentials->rootCaSize ); if( mbedtlsError != 0 ) { @@ -342,8 +342,8 @@ const IotNetworkInterface_t IotNetworkFreeRTOS = } /* Initialize the mbed TLS secured connection context. */ - mbedtlsError = mbedtls_ssl_setup( &( pNetworkConnection->ssl.context ), - &( pNetworkConnection->ssl.config ) ); + mbedtlsError = mbedtls_ssl_setup( &( pNetworkConnection->ssl.context ), + &( pNetworkConnection->ssl.config ) ); if( mbedtlsError != 0 ) { @@ -441,9 +441,9 @@ static BaseType_t _isAnyConnectionActive( void ) static void _networkTask( void * pvParameters ) { _networkConnection_t * pConnection = NULL; - BaseType_t socketEvents = 0, i = 0, socketStatus = 0; - const BaseType_t activeConnectionPresent = 1; - SocketSet_t socketSet = pvParameters; + BaseType_t socketEvents = 0, i = 0, socketStatus = 0; + const BaseType_t activeConnectionPresent = 1; + SocketSet_t socketSet = pvParameters; while( true ) { @@ -528,11 +528,11 @@ IotNetworkError_t IotNetworkFreeRTOS_Init( void ) mbedtls_ctr_drbg_init( &_ctrDrgbContext ); /* Add a strong entropy source. At least one is required. */ - mbedtlsError = mbedtls_entropy_add_source( &_entropyContext, - mbedtls_platform_entropy_poll, - NULL, - 32, - MBEDTLS_ENTROPY_SOURCE_STRONG ); + mbedtlsError = mbedtls_entropy_add_source( &_entropyContext, + mbedtls_platform_entropy_poll, + NULL, + 32, + MBEDTLS_ENTROPY_SOURCE_STRONG ); if( mbedtlsError != 0 ) { @@ -542,11 +542,11 @@ IotNetworkError_t IotNetworkFreeRTOS_Init( void ) } /* Seed the random number generator. */ - mbedtlsError = mbedtls_ctr_drbg_seed( &_ctrDrgbContext, - mbedtls_entropy_func, - &_entropyContext, - NULL, - 0 ); + mbedtlsError = mbedtls_ctr_drbg_seed( &_ctrDrgbContext, + mbedtls_entropy_func, + &_entropyContext, + NULL, + 0 ); if( mbedtlsError != 0 ) { @@ -557,7 +557,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Init( void ) #endif /* if ( IOT_NETWORK_ENABLE_TLS == 1 ) */ /* Create the socket set for the network task. */ - _socketSet = FreeRTOS_CreateSocketSet(); + _socketSet = FreeRTOS_CreateSocketSet(); if( _socketSet == NULL ) { @@ -565,10 +565,10 @@ IotNetworkError_t IotNetworkFreeRTOS_Init( void ) } /* Create the socket set mutex. */ - _socketSetMutex = xSemaphoreCreateMutexStatic( &_socketSetMutexStorage ); + _socketSetMutex = xSemaphoreCreateMutexStatic( &_socketSetMutexStorage ); static StaticTask_t networkTask; - static StackType_t networkTaskStack[ IOT_NETWORK_TASK_STACK_SIZE ]; + static StackType_t networkTaskStack[ IOT_NETWORK_TASK_STACK_SIZE ]; /* Create the network task. Since valid parameters are provided, this should * never fail. */ @@ -609,17 +609,17 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo, IotNetworkConnection_t * pConnection ) { IOT_FUNCTION_ENTRY( IotNetworkError_t, IOT_NETWORK_SUCCESS ); - Socket_t tcpSocket = FREERTOS_INVALID_SOCKET; - BaseType_t socketStatus = 0; - struct freertos_sockaddr serverAddress = { 0 }; - const TickType_t receiveTimeout = IOT_NETWORK_SOCKET_TIMEOUT_TICKS; - _networkConnection_t * pNewNetworkConnection = NULL; + Socket_t tcpSocket = FREERTOS_INVALID_SOCKET; + BaseType_t socketStatus = 0; + struct freertos_sockaddr serverAddress = { 0 }; + const TickType_t receiveTimeout = IOT_NETWORK_SOCKET_TIMEOUT_TICKS; + _networkConnection_t * pNewNetworkConnection = NULL; /* Credentials are not used if TLS is disabled. */ ( void ) pCredentialInfo; /* Check host name length against the maximum length allowed. */ - const size_t hostnameLength = strlen( pServerInfo->pHostName ); + const size_t hostnameLength = strlen( pServerInfo->pHostName ); if( hostnameLength > ( size_t ) MAX_DNS_NAME_LENGTH ) { @@ -628,7 +628,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo, IOT_SET_AND_GOTO_CLEANUP( IOT_NETWORK_BAD_PARAMETER ); } - pNewNetworkConnection = pvPortMalloc( sizeof( _networkConnection_t ) ); + pNewNetworkConnection = pvPortMalloc( sizeof( _networkConnection_t ) ); if( pNewNetworkConnection == NULL ) { @@ -640,9 +640,9 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo, ( void ) memset( pNewNetworkConnection, 0x00, sizeof( _networkConnection_t ) ); /* Create a new TCP socket. */ - tcpSocket = FreeRTOS_socket( FREERTOS_AF_INET, - FREERTOS_SOCK_STREAM, - FREERTOS_IPPROTO_TCP ); + tcpSocket = FreeRTOS_socket( FREERTOS_AF_INET, + FREERTOS_SOCK_STREAM, + FREERTOS_IPPROTO_TCP ); if( tcpSocket == FREERTOS_INVALID_SOCKET ) { @@ -651,11 +651,11 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo, } /* Set the timeout for receive. */ - socketStatus = FreeRTOS_setsockopt( tcpSocket, - 0, - FREERTOS_SO_RCVTIMEO, - &receiveTimeout, - sizeof( TickType_t ) ); + socketStatus = FreeRTOS_setsockopt( tcpSocket, + 0, + FREERTOS_SO_RCVTIMEO, + &receiveTimeout, + sizeof( TickType_t ) ); if( socketStatus != 0 ) { @@ -664,10 +664,10 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo, } /* Establish connection. */ - serverAddress.sin_family = FREERTOS_AF_INET; - serverAddress.sin_port = FreeRTOS_htons( pServerInfo->port ); - serverAddress.sin_addr = FreeRTOS_gethostbyname( pServerInfo->pHostName ); - serverAddress.sin_len = ( uint8_t ) sizeof( serverAddress ); + serverAddress.sin_family = FREERTOS_AF_INET; + serverAddress.sin_port = FreeRTOS_htons( pServerInfo->port ); + serverAddress.sin_addr = FreeRTOS_gethostbyname( pServerInfo->pHostName ); + serverAddress.sin_len = ( uint8_t ) sizeof( serverAddress ); /* Check for errors from DNS lookup. */ if( serverAddress.sin_addr == 0 ) @@ -676,9 +676,9 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo, IOT_SET_AND_GOTO_CLEANUP( IOT_NETWORK_SYSTEM_ERROR ); } - socketStatus = FreeRTOS_connect( tcpSocket, - &serverAddress, - sizeof( serverAddress ) ); + socketStatus = FreeRTOS_connect( tcpSocket, + &serverAddress, + sizeof( serverAddress ) ); if( socketStatus != 0 ) { @@ -721,7 +721,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo, pNewNetworkConnection->socketMutex = xSemaphoreCreateMutexStatic( &( pNewNetworkConnection->socketMutexStorage ) ); /* Set the output parameter. */ - *pConnection = pNewNetworkConnection; + *pConnection = pNewNetworkConnection; IotLogInfo( "(Network connection %p) Connection to %s established.", pNewNetworkConnection, @@ -737,7 +737,7 @@ IotNetworkError_t IotNetworkFreeRTOS_SetReceiveCallback( IotNetworkConnection_t void * pContext ) { IotNetworkError_t status = IOT_NETWORK_SUCCESS; - BaseType_t i = 0; + BaseType_t i = 0; /* Set the receive callback and context. */ pConnection->receiveCallback = receiveCallback; @@ -788,7 +788,7 @@ size_t IotNetworkFreeRTOS_Send( IotNetworkConnection_t pConnection, const uint8_t * pMessage, size_t messageLength ) { - size_t bytesSent = 0; + size_t bytesSent = 0; BaseType_t socketStatus = 0; /* Only one thread at a time may send on the connection. Lock the send @@ -857,7 +857,7 @@ size_t IotNetworkFreeRTOS_Receive( IotNetworkConnection_t pConnection, size_t bytesRequested ) { BaseType_t socketStatus = 0; - size_t bytesReceived = 0, bytesRemaining = bytesRequested; + size_t bytesReceived = 0, bytesRemaining = bytesRequested; /* Block and wait for incoming data. */ while( bytesRemaining > 0 ) @@ -911,7 +911,7 @@ size_t IotNetworkFreeRTOS_Receive( IotNetworkConnection_t pConnection, } else { - bytesReceived += ( size_t ) socketStatus; + bytesReceived += ( size_t ) socketStatus; bytesRemaining -= ( size_t ) socketStatus; configASSERT( bytesReceived + bytesRemaining == bytesRequested ); @@ -941,8 +941,8 @@ size_t IotNetworkFreeRTOS_ReceiveUpto( IotNetworkConnection_t pConnection, uint8_t * pBuffer, size_t bufferSize ) { - int32_t socketStatus = 0; - size_t bytesReceived = 0; + int32_t socketStatus = 0; + size_t bytesReceived = 0; /* Caller should never pass a zero-length buffer. */ configASSERT( bufferSize > 0 ); @@ -996,7 +996,7 @@ size_t IotNetworkFreeRTOS_ReceiveUpto( IotNetworkConnection_t pConnection, IotNetworkError_t IotNetworkFreeRTOS_Close( IotNetworkConnection_t pConnection ) { - BaseType_t socketStatus = 0, i = 0; + BaseType_t socketStatus = 0, i = 0; IotNetworkError_t status = IOT_NETWORK_SUCCESS; #if ( IOT_NETWORK_ENABLE_TLS == 1 ) @@ -1066,8 +1066,8 @@ IotNetworkError_t IotNetworkFreeRTOS_Close( IotNetworkConnection_t pConnection ) IotNetworkError_t IotNetworkFreeRTOS_Destroy( IotNetworkConnection_t pConnection ) { - BaseType_t closeSocketStatus = 0; - IotNetworkError_t status = IOT_NETWORK_SUCCESS; + BaseType_t closeSocketStatus = 0; + IotNetworkError_t status = IOT_NETWORK_SUCCESS; closeSocketStatus = FreeRTOS_closesocket( pConnection->socket ); diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_pkcs11_freertos.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_pkcs11_freertos.c index 9894daa15..41098b067 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_pkcs11_freertos.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_network_pkcs11_freertos.c @@ -159,22 +159,22 @@ static IotNetworkError_t _tlsSetup( _networkConnection_t * pNetworkConnection, const char * pServerName, IotNetworkCredentials_t pCredentials ) { - int mbedtlsError = 0; + int mbedtlsError = 0; - TLSParams_t tlsParams = { 0 }; + TLSParams_t tlsParams = { 0 }; - tlsParams.ulSize = sizeof( tlsParams ); - tlsParams.pcDestination = pServerName; - tlsParams.pcServerCertificate = pCredentials->pRootCa; + tlsParams.ulSize = sizeof( tlsParams ); + tlsParams.pcDestination = pServerName; + tlsParams.pcServerCertificate = pCredentials->pRootCa; tlsParams.ulServerCertificateLength = pCredentials->rootCaSize; - tlsParams.ppcAlpnProtocols = ( const char ** ) pCredentials->pAlpnProtos; - tlsParams.ulAlpnProtocolsCount = 0; - tlsParams.pxNetworkSend = mbedtls_platform_send; - tlsParams.pxNetworkRecv = mbedtls_platform_recv; - tlsParams.pvCallerContext = pNetworkConnection->socket; + tlsParams.ppcAlpnProtocols = ( const char ** ) pCredentials->pAlpnProtos; + tlsParams.ulAlpnProtocolsCount = 0; + tlsParams.pxNetworkSend = mbedtls_platform_send; + tlsParams.pxNetworkRecv = mbedtls_platform_recv; + tlsParams.pvCallerContext = pNetworkConnection->socket; /* Initialize TLS context and underlying crypto libraries */ - mbedtlsError = TLS_Init( &pNetworkConnection->pvTLSContext, &tlsParams ); + mbedtlsError = TLS_Init( &pNetworkConnection->pvTLSContext, &tlsParams ); if( mbedtlsError != CKR_OK ) { @@ -183,7 +183,7 @@ static IotNetworkError_t _tlsSetup( _networkConnection_t * pNetworkConnection, /* Attempt to establish a TLS connection. PKCS is used to acquire * credential objects. */ - mbedtlsError = TLS_Connect( pNetworkConnection->pvTLSContext ); + mbedtlsError = TLS_Connect( pNetworkConnection->pvTLSContext ); if( mbedtlsError == CKR_OK ) { @@ -204,8 +204,8 @@ static IotNetworkError_t _tlsSetup( _networkConnection_t * pNetworkConnection, static void _networkTask( void * pvParameters ) { _networkConnection_t * pConnection = NULL; - BaseType_t socketEvents = 0, i = 0, socketStatus = 0; - SocketSet_t socketSet = pvParameters; + BaseType_t socketEvents = 0, i = 0, socketStatus = 0; + SocketSet_t socketSet = pvParameters; while( true ) { @@ -254,7 +254,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Init( void ) IOT_FUNCTION_ENTRY( IotNetworkError_t, IOT_NETWORK_SUCCESS ); /* Create socket set for network task. */ - _socketSet = FreeRTOS_CreateSocketSet(); + _socketSet = FreeRTOS_CreateSocketSet(); if( _socketSet == NULL ) { @@ -262,7 +262,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Init( void ) } static StaticTask_t networkTask; - static StackType_t networkTaskStack[ IOT_NETWORK_TASK_STACK_SIZE ]; + static StackType_t networkTaskStack[ IOT_NETWORK_TASK_STACK_SIZE ]; /* Create the network task. Since valid parameters are provided, this should * never fail. */ @@ -291,18 +291,18 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo, IotNetworkConnection_t * pConnection ) { IOT_FUNCTION_ENTRY( IotNetworkError_t, IOT_NETWORK_SUCCESS ); - Socket_t tcpSocket = FREERTOS_INVALID_SOCKET; - BaseType_t socketStatus = 0; - struct freertos_sockaddr serverAddress = { 0 }; - const TickType_t receiveTimeout = + Socket_t tcpSocket = FREERTOS_INVALID_SOCKET; + BaseType_t socketStatus = 0; + struct freertos_sockaddr serverAddress = { 0 }; + const TickType_t receiveTimeout = pdMS_TO_TICKS( IOT_NETWORK_SOCKET_TIMEOUT_MS ); - _networkConnection_t * pNewNetworkConnection = NULL; + _networkConnection_t * pNewNetworkConnection = NULL; /* Credentials are not used if TLS is disabled. */ ( void ) pCredentialInfo; /* Check host name length against the maximum length allowed. */ - const size_t hostnameLength = strlen( pServerInfo->pHostName ); + const size_t hostnameLength = strlen( pServerInfo->pHostName ); if( hostnameLength > ( size_t ) MAX_DNS_NAME_LENGTH ) { @@ -312,7 +312,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo, IOT_SET_AND_GOTO_CLEANUP( IOT_NETWORK_BAD_PARAMETER ); } - pNewNetworkConnection = pvPortMalloc( sizeof( _networkConnection_t ) ); + pNewNetworkConnection = pvPortMalloc( sizeof( _networkConnection_t ) ); if( pNewNetworkConnection == NULL ) { @@ -324,7 +324,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo, ( void ) memset( pNewNetworkConnection, 0x00, sizeof( _networkConnection_t ) ); /* Create a new TCP socket. */ - tcpSocket = FreeRTOS_socket( + tcpSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP ); if( tcpSocket == FREERTOS_INVALID_SOCKET ) @@ -334,7 +334,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo, } /* Set the timeout for receive. */ - socketStatus = FreeRTOS_setsockopt( + socketStatus = FreeRTOS_setsockopt( tcpSocket, 0, FREERTOS_SO_RCVTIMEO, &receiveTimeout, sizeof( TickType_t ) ); @@ -345,10 +345,10 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo, } /* Establish connection. */ - serverAddress.sin_family = FREERTOS_AF_INET; - serverAddress.sin_port = FreeRTOS_htons( pServerInfo->port ); - serverAddress.sin_addr = FreeRTOS_gethostbyname( pServerInfo->pHostName ); - serverAddress.sin_len = ( uint8_t ) sizeof( serverAddress ); + serverAddress.sin_family = FREERTOS_AF_INET; + serverAddress.sin_port = FreeRTOS_htons( pServerInfo->port ); + serverAddress.sin_addr = FreeRTOS_gethostbyname( pServerInfo->pHostName ); + serverAddress.sin_len = ( uint8_t ) sizeof( serverAddress ); /* Check for errors from DNS lookup. */ if( serverAddress.sin_addr == 0 ) @@ -357,7 +357,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo, IOT_SET_AND_GOTO_CLEANUP( IOT_NETWORK_SYSTEM_ERROR ); } - socketStatus = + socketStatus = FreeRTOS_connect( tcpSocket, &serverAddress, sizeof( serverAddress ) ); if( socketStatus != 0 ) @@ -369,7 +369,7 @@ IotNetworkError_t IotNetworkFreeRTOS_Create( IotNetworkServerInfo_t pServerInfo, } /* Set the socket. */ - pNewNetworkConnection->socket = tcpSocket; + pNewNetworkConnection->socket = tcpSocket; /* Create the socket mutex. */ pNewNetworkConnection->socketMutex = xSemaphoreCreateMutexStatic( &( pNewNetworkConnection->socketMutexStorage ) ); @@ -416,7 +416,7 @@ IotNetworkError_t IotNetworkFreeRTOS_SetReceiveCallback( IotNetworkConnection_t void * pContext ) { IotNetworkError_t status = IOT_NETWORK_SUCCESS; - BaseType_t i = 0; + BaseType_t i = 0; /* Set the receive callback and context. */ pConnection->receiveCallback = receiveCallback; @@ -452,7 +452,7 @@ size_t IotNetworkFreeRTOS_Send( IotNetworkConnection_t pConnection, const uint8_t * pMessage, size_t messageLength ) { - size_t bytesSent = 0; + size_t bytesSent = 0; BaseType_t socketStatus = 0; /* Only one thread at a time may send on the connection. Lock the send @@ -499,7 +499,7 @@ size_t IotNetworkFreeRTOS_Receive( IotNetworkConnection_t pConnection, size_t bytesRequested ) { BaseType_t socketStatus = 0; - size_t bytesReceived = 0, bytesRemaining = bytesRequested; + size_t bytesReceived = 0, bytesRemaining = bytesRequested; /* Block and wait for incoming data. */ @@ -558,8 +558,8 @@ size_t IotNetworkFreeRTOS_ReceiveUpto( IotNetworkConnection_t pConnection, uint8_t * pBuffer, size_t bufferSize ) { - int32_t socketStatus = 0; - size_t bytesReceived = 0; + int32_t socketStatus = 0; + size_t bytesReceived = 0; /* Caller should never pass a zero-length buffer. */ configASSERT( bufferSize > 0 ); @@ -570,7 +570,7 @@ size_t IotNetworkFreeRTOS_ReceiveUpto( IotNetworkConnection_t pConnection, pConnection->socketMutex, IOT_NETWORK_SOCKET_TIMEOUT_MS ) == pdTRUE ) { - socketStatus = + socketStatus = TLS_Recv( pConnection->pvTLSContext, pBuffer, bufferSize ); bytesReceived = socketStatus; diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_threads_freertos.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_threads_freertos.c index 181d07785..af5cc798c 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_threads_freertos.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/iot_threads_freertos.c @@ -96,7 +96,7 @@ bool Iot_CreateDetachedThread( IotThreadRoutine_t threadRoutine, int32_t priority, size_t stackSize ) { - bool status = true; + bool status = true; configASSERT( threadRoutine != NULL ); @@ -113,7 +113,7 @@ bool Iot_CreateDetachedThread( IotThreadRoutine_t threadRoutine, if( status ) { pThreadInfo->threadRoutine = threadRoutine; - pThreadInfo->pArgument = pArgument; + pThreadInfo->pArgument = pArgument; if( xTaskCreate( _threadRoutineWrapper, "iot_thread", @@ -182,7 +182,7 @@ bool prIotMutexTimedLock( IotMutex_t * pMutex, TickType_t timeout ) { _IotSystemMutex_t * internalMutex = ( _IotSystemMutex_t * ) pMutex; - BaseType_t lockResult; + BaseType_t lockResult; configASSERT( internalMutex != NULL ); @@ -258,7 +258,7 @@ bool IotSemaphore_Create( IotSemaphore_t * pNewSemaphore, uint32_t IotSemaphore_GetCount( IotSemaphore_t * pSemaphore ) { _IotSystemSemaphore_t * internalSemaphore = ( _IotSystemSemaphore_t * ) pSemaphore; - UBaseType_t count = 0; + UBaseType_t count = 0; configASSERT( internalSemaphore != NULL ); @@ -354,7 +354,7 @@ void IotSemaphore_Post( IotSemaphore_t * pSemaphore ) IotLogDebug( "Posting to semaphore %p.", internalSemaphore ); /* Give the semaphore using the FreeRTOS API. */ - BaseType_t result = xSemaphoreGive( ( SemaphoreHandle_t ) &internalSemaphore->xSemaphore ); + BaseType_t result = xSemaphoreGive( ( SemaphoreHandle_t ) &internalSemaphore->xSemaphore ); if( result == pdFALSE ) { diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/private/taskpool/taskpool_freertos.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/private/taskpool/taskpool_freertos.c index feb9bd8c9..1489b73a9 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/private/taskpool/taskpool_freertos.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos/private/taskpool/taskpool_freertos.c @@ -175,11 +175,11 @@ static void timerCallback( TimerHandle_t xTimer ); void taskPoolCreateSystemTaskPool( void ) { BaseType_t running; - uint8_t x; + uint8_t x; /* Has the task pool already been started? */ taskENTER_CRITICAL(); - running = taskPool.running; + running = taskPool.running; taskPool.running = pdTRUE; taskEXIT_CRITICAL(); @@ -201,7 +201,7 @@ void taskPoolCreateSystemTaskPool( void ) for( x = 0; x < ( UBaseType_t ) configTASKPOOL_NUMBER_OF_WORKERS; x++ ) { /* a unique name for the task. */ - char taskName[] = "worker.n"; + char taskName[] = "worker.n"; taskName[ sizeof( taskName ) - 2U ] = '0' + x; /* Coverity suggests adding const qualification to the local variable `task`. @@ -240,8 +240,8 @@ void taskPoolInitializeJob( taskPoolRoutine_t userCallback, /* Initialize the job within the user-provided storage instance. */ jobStorage->userCallback = userCallback; - jobStorage->userContext = userContext; - jobStorage->status = TASKPOOL_JOB_STATUS_READY; + jobStorage->userContext = userContext; + jobStorage->status = TASKPOOL_JOB_STATUS_READY; increment( initialized ); } @@ -259,8 +259,8 @@ taskPoolError_t taskPoolScheduleDeferred( taskPoolJob_t * job, uint32_t timeMs ) { taskPoolError_t status = TASKPOOL_GENERAL_FAILURE; - BaseType_t result; - UBaseType_t savedStatus; + BaseType_t result; + UBaseType_t savedStatus; /* * Check that the timer task priority is higher than that of the calling task. @@ -317,14 +317,14 @@ taskPoolError_t taskPoolScheduleDeferred( taskPoolJob_t * job, else { job->status = TASKPOOL_JOB_STATUS_CANCELLED; - status = TASKPOOL_FAILED_OPERATION; + status = TASKPOOL_FAILED_OPERATION; increment( direct_dispatch_failed ); } } else { /* Software timer will manage the time delay for the deferred job. */ - job->timer = + job->timer = xTimerCreateStatic( NULL, pdMS_TO_TICKS( timeMs ), pdFALSE, @@ -341,11 +341,11 @@ taskPoolError_t taskPoolScheduleDeferred( taskPoolJob_t * job, * priority ) to be executed which ensures that the timer start command has * been processed to start the job's timer. */ - result = xTimerStart( job->timer, portMAX_DELAY ); + result = xTimerStart( job->timer, portMAX_DELAY ); configASSERT( result == pdPASS ); job->status = TASKPOOL_JOB_STATUS_DEFERRED; - status = TASKPOOL_SUCCESS; + status = TASKPOOL_SUCCESS; increment( timer_start ); } } @@ -358,8 +358,8 @@ taskPoolError_t taskPoolScheduleDeferred( taskPoolJob_t * job, taskPoolError_t taskPoolTryCancel( taskPoolJob_t * job ) { taskPoolError_t status = TASKPOOL_GENERAL_FAILURE; - UBaseType_t savedStatus; - BaseType_t result = pdFAIL; + UBaseType_t savedStatus; + BaseType_t result = pdFAIL; /* * Check that the timer task priority is higher than that of the calling task. @@ -383,7 +383,7 @@ taskPoolError_t taskPoolTryCancel( taskPoolJob_t * job ) ( savedStatus == TASKPOOL_JOB_STATUS_CANCELLED ) ) { job->status = TASKPOOL_JOB_STATUS_CANCELLED; - status = TASKPOOL_SUCCESS; + status = TASKPOOL_SUCCESS; increment( cancel ); } else @@ -519,10 +519,10 @@ static void taskPoolWorker( void * pContext ) for( ; ; ) { struct taskPoolJob * job; - BaseType_t result; + BaseType_t result; /* block until a job arrives */ - result = xQueueReceive( taskPool.dispatchQueue, &job, portMAX_DELAY ); + result = xQueueReceive( taskPool.dispatchQueue, &job, portMAX_DELAY ); configASSERT( result == pdTRUE ); configASSERT( ( job != NULL ) && ( job->userCallback != NULL ) ); diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_mbedtls.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_mbedtls.c index 29ec7a979..2fcea4681 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_mbedtls.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_mbedtls.c @@ -76,7 +76,7 @@ static const char * pNoHighLevelMbedTlsCodeStr = "<No-High-Level-Code>"; * @brief Represents string to be logged when mbedTLS returned error * does not contain a low-level code. */ -static const char * pNoLowLevelMbedTlsCodeStr = "<No-Low-Level-Code>"; +static const char * pNoLowLevelMbedTlsCodeStr = "<No-Low-Level-Code>"; /** * @brief Utility for converting the high-level code in an mbedTLS error to string, @@ -476,7 +476,7 @@ static CK_RV prvMbedTLS_Initialize( void ) xP11Context.xObjectList.xMutex = xSemaphoreCreateMutexStatic( &xP11Context.xObjectList.xMutexBuffer ); - xP11Context.xSessionMutex = xSemaphoreCreateMutexStatic( + xP11Context.xSessionMutex = xSemaphoreCreateMutexStatic( &xP11Context.xSessionMutexBuffer ); if( ( xP11Context.xObjectList.xMutex == NULL ) || ( xP11Context.xSessionMutex == NULL ) ) @@ -518,7 +518,7 @@ static CK_RV prvGetObjectClass( const CK_ATTRIBUTE * pxTemplate, CK_ULONG ulCount, CK_OBJECT_CLASS * pxClass ) { - CK_RV xResult = CKR_TEMPLATE_INCOMPLETE; + CK_RV xResult = CKR_TEMPLATE_INCOMPLETE; CK_ULONG ulIndex = 0; /* Search template for class attribute. */ @@ -547,10 +547,10 @@ static CK_RV prvCertAttParse( CK_ATTRIBUTE * pxAttribute, CK_ULONG * pxCertificateLength, CK_ATTRIBUTE ** ppxLabel ) { - CK_RV xResult = CKR_OK; + CK_RV xResult = CKR_OK; /* See explanation in prvCheckValidSessionAndModule for this exception. */ /* coverity[misra_c_2012_rule_10_5_violation] */ - CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE; + CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE; switch( pxAttribute->type ) { @@ -602,7 +602,7 @@ static CK_RV prvCertAttParse( CK_ATTRIBUTE * pxAttribute, break; default: - xResult = CKR_ATTRIBUTE_TYPE_INVALID; + xResult = CKR_ATTRIBUTE_TYPE_INVALID; break; } @@ -616,9 +616,9 @@ static CK_RV prvCertAttParse( CK_ATTRIBUTE * pxAttribute, static CK_RV prvRsaKeyAttParse( const CK_ATTRIBUTE * pxAttribute, const mbedtls_pk_context * pxMbedContext ) { - CK_RV xResult = CKR_OK; - int32_t lMbedReturn = 0; - CK_BBOOL xBool; + CK_RV xResult = CKR_OK; + int32_t lMbedReturn = 0; + CK_BBOOL xBool; mbedtls_rsa_context * pxRsaContext = ( mbedtls_rsa_context * ) pxMbedContext->pk_ctx; switch( pxAttribute->type ) @@ -702,7 +702,7 @@ static CK_RV prvRsaKeyAttParse( const CK_ATTRIBUTE * pxAttribute, default: PKCS11_PRINT( ( "Unknown attribute found for RSA private key. %d \r\n", pxAttribute->type ) ); - xResult = CKR_ATTRIBUTE_TYPE_INVALID; + xResult = CKR_ATTRIBUTE_TYPE_INVALID; break; } @@ -728,10 +728,10 @@ static CK_RV prvRsaKeyAttParse( const CK_ATTRIBUTE * pxAttribute, { /* See explanation in prvCheckValidSessionAndModule for this exception. */ /* coverity[misra_c_2012_rule_10_5_violation] */ - CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE; - int32_t lMbedReturn = 0; - CK_RV xResult = CKR_OK; - mbedtls_ecp_keypair * pxKeyPair = ( mbedtls_ecp_keypair * ) pxMbedContext->pk_ctx; + CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE; + int32_t lMbedReturn = 0; + CK_RV xResult = CKR_OK; + mbedtls_ecp_keypair * pxKeyPair = ( mbedtls_ecp_keypair * ) pxMbedContext->pk_ctx; if( pxAttribute->type == CKA_SIGN ) { @@ -775,10 +775,10 @@ static CK_RV prvRsaKeyAttParse( const CK_ATTRIBUTE * pxAttribute, { /* See explanation in prvCheckValidSessionAndModule for this exception. */ /* coverity[misra_c_2012_rule_10_5_violation] */ - CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE; - int32_t lMbedReturn = 0; - CK_RV xResult = CKR_OK; - mbedtls_ecp_keypair * pxKeyPair = ( mbedtls_ecp_keypair * ) pxMbedContext->pk_ctx; + CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE; + int32_t lMbedReturn = 0; + CK_RV xResult = CKR_OK; + mbedtls_ecp_keypair * pxKeyPair = ( mbedtls_ecp_keypair * ) pxMbedContext->pk_ctx; if( pxAttribute->type == CKA_VERIFY ) { @@ -822,12 +822,12 @@ static CK_RV prvRsaKeyAttParse( const CK_ATTRIBUTE * pxAttribute, const mbedtls_pk_context * pxMbedContext, CK_BBOOL xIsPrivate ) { - CK_RV xResult = CKR_OK; + CK_RV xResult = CKR_OK; /* See explanation in prvCheckValidSessionAndModule for this exception. */ /* coverity[misra_c_2012_rule_10_5_violation] */ - CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE; - const CK_BYTE pxEcCurve[] = pkcs11DER_ENCODED_OID_P256; - const CK_BYTE * pxEcAttVal = NULL; + CK_BBOOL xBool = ( CK_BBOOL ) CK_FALSE; + const CK_BYTE pxEcCurve[] = pkcs11DER_ENCODED_OID_P256; + const CK_BYTE * pxEcAttVal = NULL; const CK_BBOOL * pxEcBoolAtt = NULL; /* Common EC key attributes. */ @@ -854,7 +854,7 @@ static CK_RV prvRsaKeyAttParse( const CK_ATTRIBUTE * pxAttribute, break; case ( CKA_EC_PARAMS ): - pxEcAttVal = ( CK_BYTE * ) pxAttribute->pValue; + pxEcAttVal = ( CK_BYTE * ) pxAttribute->pValue; if( memcmp( pxEcCurve, pxEcAttVal, pxAttribute->ulValueLen ) != 0 ) { @@ -898,7 +898,7 @@ static CK_RV prvRsaKeyAttParse( const CK_ATTRIBUTE * pxAttribute, default: PKCS11_PRINT( ( "Unknown attribute found for an EC public key. %d \r\n", pxAttribute->type ) ); - xResult = CKR_ATTRIBUTE_TYPE_INVALID; + xResult = CKR_ATTRIBUTE_TYPE_INVALID; break; } @@ -958,17 +958,17 @@ static void prvFindObjectInListByHandle( CK_OBJECT_HANDLE xAppHandle, { uint32_t ulIndex = xAppHandle - 1UL; - *ppcLabel = NULL; + *ppcLabel = NULL; *pxLabelLength = 0; - *pxPalHandle = CK_INVALID_HANDLE; + *pxPalHandle = CK_INVALID_HANDLE; if( ulIndex < pkcs11configMAX_NUM_OBJECTS ) { if( xP11Context.xObjectList.xObjects[ ulIndex ].xHandle != CK_INVALID_HANDLE ) { - *ppcLabel = xP11Context.xObjectList.xObjects[ ulIndex ].xLabel; + *ppcLabel = xP11Context.xObjectList.xObjects[ ulIndex ].xLabel; *pxLabelLength = xP11Context.xObjectList.xObjects[ ulIndex ].xLabelSize; - *pxPalHandle = xP11Context.xObjectList.xObjects[ ulIndex ].xHandle; + *pxPalHandle = xP11Context.xObjectList.xObjects[ ulIndex ].xHandle; } } } @@ -983,9 +983,9 @@ static void prvFindObjectInListByHandle( CK_OBJECT_HANDLE xAppHandle, */ static CK_RV prvDeleteObjectFromList( CK_OBJECT_HANDLE xAppHandle ) { - CK_RV xResult = CKR_OK; + CK_RV xResult = CKR_OK; BaseType_t xGotSemaphore = pdFALSE; - uint32_t ulIndex = xAppHandle - 1UL; + uint32_t ulIndex = xAppHandle - 1UL; if( ulIndex >= pkcs11configMAX_NUM_OBJECTS ) { @@ -1033,13 +1033,13 @@ static CK_RV prvAddObjectToList( CK_OBJECT_HANDLE xPalHandle, const CK_BYTE_PTR pcLabel, CK_ULONG xLabelLength ) { - CK_RV xResult = CKR_HOST_MEMORY; + CK_RV xResult = CKR_HOST_MEMORY; BaseType_t xGotSemaphore; xGotSemaphore = xSemaphoreTake( xP11Context.xObjectList.xMutex, portMAX_DELAY ); /* See explanation in prvCheckValidSessionAndModule for this exception. */ /* coverity[misra_c_2012_rule_10_5_violation] */ - CK_BBOOL xObjectFound = ( CK_BBOOL ) CK_FALSE; + CK_BBOOL xObjectFound = ( CK_BBOOL ) CK_FALSE; uint32_t ulSearchIndex = 0; if( pdTRUE == xGotSemaphore ) @@ -1056,7 +1056,7 @@ static CK_RV prvAddObjectToList( CK_OBJECT_HANDLE xPalHandle, /* Object already exists in list. */ /* See explanation in prvCheckValidSessionAndModule for this exception. */ /* coverity[misra_c_2012_rule_10_5_violation] */ - xResult = CKR_OK; + xResult = CKR_OK; xObjectFound = ( CK_BBOOL ) CK_TRUE; } else if( xP11Context.xObjectList.xObjects[ ulSearchIndex ].xHandle == CK_INVALID_HANDLE ) @@ -1075,7 +1075,7 @@ static CK_RV prvAddObjectToList( CK_OBJECT_HANDLE xPalHandle, { if( xLabelLength < pkcs11configMAX_LABEL_LENGTH ) { - xP11Context.xObjectList.xObjects[ ulSearchIndex - 1UL ].xHandle = xPalHandle; + xP11Context.xObjectList.xObjects[ ulSearchIndex - 1UL ].xHandle = xPalHandle; ( void ) memcpy( xP11Context.xObjectList.xObjects[ ulSearchIndex - 1UL ].xLabel, pcLabel, xLabelLength ); xP11Context.xObjectList.xObjects[ ulSearchIndex - 1UL ].xLabelSize = xLabelLength; *pxAppHandle = ulSearchIndex; @@ -1106,12 +1106,12 @@ static CK_RV prvSaveDerKeyToPal( mbedtls_pk_context * pxMbedContext, CK_KEY_TYPE xKeyType, CK_BBOOL xIsPrivate ) { - CK_RV xResult = CKR_OK; - CK_BYTE_PTR pxDerKey; - int32_t lDerKeyLength = 0; - uint32_t ulActualKeyLength = 0; - int32_t lCompare = 0; - CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE; + CK_RV xResult = CKR_OK; + CK_BYTE_PTR pxDerKey; + int32_t lDerKeyLength = 0; + uint32_t ulActualKeyLength = 0; + int32_t lCompare = 0; + CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE; pxDerKey = pvPortMalloc( MAX_PUBLIC_KEY_SIZE ); @@ -1178,7 +1178,7 @@ static CK_RV prvSaveDerKeyToPal( mbedtls_pk_context * pxMbedContext, { /* Do not write the last 6 bytes to key storage. */ pxDerKey[ MAX_LENGTH_KEY - lDerKeyLength + 1 ] -= ( uint8_t ) 6; - ulActualKeyLength -= 6UL; + ulActualKeyLength -= 6UL; } } @@ -1208,21 +1208,21 @@ static CK_RV prvSaveDerKeyToPal( mbedtls_pk_context * pxMbedContext, #if ( pkcs11configPAL_DESTROY_SUPPORTED != 1 ) CK_RV PKCS11_PAL_DestroyObject( CK_OBJECT_HANDLE xHandle ) { - CK_BYTE_PTR pcLabel = NULL; - CK_ULONG xLabelLength = 0; - CK_ULONG ulObjectLength = 0; + CK_BYTE_PTR pcLabel = NULL; + CK_ULONG xLabelLength = 0; + CK_ULONG ulObjectLength = 0; /* See explanation in prvCheckValidSessionAndModule for this exception. */ /* coverity[misra_c_2012_rule_10_5_violation] */ - CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE; - CK_RV xResult = CKR_OK; - CK_BYTE_PTR pxObject = NULL; - CK_ATTRIBUTE xLabel = { 0 }; - CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE; - CK_OBJECT_HANDLE xPalHandle2 = CK_INVALID_HANDLE; - CK_OBJECT_HANDLE xAppHandle2 = CK_INVALID_HANDLE; - CK_BYTE_PTR pxZeroedData = NULL; - CK_BYTE pxPubKeyLabel[] = { pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS }; - CK_BYTE pxPrivKeyLabel[] = { pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS }; + CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE; + CK_RV xResult = CKR_OK; + CK_BYTE_PTR pxObject = NULL; + CK_ATTRIBUTE xLabel = { 0 }; + CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE; + CK_OBJECT_HANDLE xPalHandle2 = CK_INVALID_HANDLE; + CK_OBJECT_HANDLE xAppHandle2 = CK_INVALID_HANDLE; + CK_BYTE_PTR pxZeroedData = NULL; + CK_BYTE pxPubKeyLabel[] = { pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS }; + CK_BYTE pxPrivKeyLabel[] = { pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS }; prvFindObjectInListByHandle( xHandle, &xPalHandle, &pcLabel, &xLabelLength ); @@ -1240,11 +1240,11 @@ static CK_RV prvSaveDerKeyToPal( mbedtls_pk_context * pxMbedContext, /* Zero out the object. */ ( void ) memset( pxZeroedData, 0x0, ulObjectLength ); /* Create an object label attribute. */ - xLabel.type = CKA_LABEL; - xLabel.pValue = pcLabel; + xLabel.type = CKA_LABEL; + xLabel.pValue = pcLabel; xLabel.ulValueLen = xLabelLength; /* Overwrite the object in NVM with zeros. */ - xPalHandle2 = PKCS11_PAL_SaveObject( &xLabel, pxZeroedData, ulObjectLength ); + xPalHandle2 = PKCS11_PAL_SaveObject( &xLabel, pxZeroedData, ulObjectLength ); if( xPalHandle2 != xPalHandle ) { @@ -1409,7 +1409,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_Finalize )( CK_VOID_PTR pReserved ) /* @[declare_pkcs11_mbedtls_c_getfunctionlist] */ CK_DECLARE_FUNCTION( CK_RV, C_GetFunctionList )( CK_FUNCTION_LIST_PTR_PTR ppFunctionList ) { - CK_RV xResult = CKR_OK; + CK_RV xResult = CKR_OK; static CK_FUNCTION_LIST prvP11FunctionList = { @@ -1551,7 +1551,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetSlotList )( CK_BBOOL tokenPresent, else { pSlotList[ 0 ] = pkcs11SLOT_ID; - *pulCount = 1; + *pulCount = 1; } } } @@ -1605,7 +1605,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetMechanismInfo )( CK_SLOT_ID slotID, /* Disable unused parameter warning. */ ( void ) slotID; - CK_RV xResult = CKR_MECHANISM_INVALID; + CK_RV xResult = CKR_MECHANISM_INVALID; if( pInfo == NULL ) { @@ -1627,7 +1627,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetMechanismInfo )( CK_SLOT_ID slotID, #endif { CKM_SHA256, { 0, 0, CKF_DIGEST } } }; - uint32_t ulMech = 0; + uint32_t ulMech = 0; if( xResult == CKR_MECHANISM_INVALID ) { @@ -1700,9 +1700,9 @@ CK_DECLARE_FUNCTION( CK_RV, C_OpenSession )( CK_SLOT_ID slotID, CK_NOTIFY Notify, CK_SESSION_HANDLE_PTR phSession ) { - CK_RV xResult = CKR_OK; - P11Session_t * pxSessionObj = NULL; - uint32_t ulSessionCount = 0; + CK_RV xResult = CKR_OK; + P11Session_t * pxSessionObj = NULL; + uint32_t ulSessionCount = 0; ( void ) ( slotID ); ( void ) ( pApplication ); @@ -1745,8 +1745,8 @@ CK_DECLARE_FUNCTION( CK_RV, C_OpenSession )( CK_SLOT_ID slotID, /* coverity[misra_c_2012_rule_10_5_violation] */ if( pxP11Sessions[ ulSessionCount ].xOpened == ( CK_BBOOL ) CK_FALSE ) { - xResult = CKR_OK; - pxSessionObj = &pxP11Sessions[ ulSessionCount ]; + xResult = CKR_OK; + pxSessionObj = &pxP11Sessions[ ulSessionCount ]; /* coverity[misra_c_2012_rule_10_5_violation] */ pxSessionObj->xOpened = ( CK_BBOOL ) CK_TRUE; break; @@ -1767,7 +1767,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_OpenSession )( CK_SLOT_ID slotID, if( CKR_OK == xResult ) { - pxSessionObj->xSignMutex = xSemaphoreCreateMutex(); + pxSessionObj->xSignMutex = xSemaphoreCreateMutex(); if( NULL == pxSessionObj->xSignMutex ) { @@ -1799,7 +1799,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_OpenSession )( CK_SLOT_ID slotID, { pxSessionObj->xOperationDigestMechanism = pkcs11NO_OPERATION; pxSessionObj->xOperationVerifyMechanism = pkcs11NO_OPERATION; - pxSessionObj->xOperationSignMechanism = pkcs11NO_OPERATION; + pxSessionObj->xOperationSignMechanism = pkcs11NO_OPERATION; } if( CKR_OK != xResult ) @@ -1847,7 +1847,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_OpenSession )( CK_SLOT_ID slotID, CK_DECLARE_FUNCTION( CK_RV, C_CloseSession )( CK_SESSION_HANDLE hSession ) { P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = CKR_OK; + CK_RV xResult = CKR_OK; /* coverity[misra_c_2012_rule_10_5_violation] */ if( xP11Context.xIsInitialized == ( CK_BBOOL ) CK_FALSE ) @@ -1934,13 +1934,13 @@ static CK_RV prvCreateCertificate( CK_ATTRIBUTE * pxTemplate, CK_ULONG ulCount, CK_OBJECT_HANDLE_PTR pxObject ) { - CK_RV xResult = CKR_OK; - CK_BYTE_PTR pxCertificateValue = NULL; - CK_ULONG xCertificateLength = 0; - CK_ATTRIBUTE_PTR pxLabel = NULL; - CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE; - CK_CERTIFICATE_TYPE xCertificateType = 0; - CK_ULONG ulIndex = 0; + CK_RV xResult = CKR_OK; + CK_BYTE_PTR pxCertificateValue = NULL; + CK_ULONG xCertificateLength = 0; + CK_ATTRIBUTE_PTR pxLabel = NULL; + CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE; + CK_CERTIFICATE_TYPE xCertificateType = 0; + CK_ULONG ulIndex = 0; /* Search for the pointer to the certificate VALUE. */ for( ulIndex = 0; ulIndex < ulCount; ulIndex++ ) @@ -1996,7 +1996,7 @@ static void prvGetKeyType( CK_KEY_TYPE * pxKeyType, const CK_ATTRIBUTE * pxTemplate, CK_ULONG ulCount ) { - uint32_t ulIndex; + uint32_t ulIndex; CK_ATTRIBUTE xAttribute; *pxKeyType = PKCS11_INVALID_KEY_TYPE; @@ -2026,7 +2026,7 @@ static void prvGetLabel( CK_ATTRIBUTE ** ppxLabel, CK_ULONG ulCount ) { CK_ATTRIBUTE xAttribute; - CK_ULONG ulIndex; + CK_ULONG ulIndex; *ppxLabel = NULL; @@ -2060,15 +2060,15 @@ static void prvGetLabel( CK_ATTRIBUTE ** ppxLabel, mbedtls_pk_context * pxMbedContext, const CK_ATTRIBUTE * pxLabel ) { - CK_BYTE_PTR pucData = NULL; - CK_ULONG ulDataLength = 0; + CK_BYTE_PTR pucData = NULL; + CK_ULONG ulDataLength = 0; /* See explanation in prvCheckValidSessionAndModule for this exception. */ /* coverity[misra_c_2012_rule_10_5_violation] */ - CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE; - CK_RV xResult = CKR_OK; - int32_t lMbedResult = 0; - CK_BYTE pxPubKeyLabel[] = { pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS }; - CK_BYTE pxPrivKeyLabel[] = { pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS }; + CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE; + CK_RV xResult = CKR_OK; + int32_t lMbedResult = 0; + CK_BYTE pxPubKeyLabel[] = { pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS }; + CK_BYTE pxPrivKeyLabel[] = { pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS }; *pxPalHandle = CK_INVALID_HANDLE; @@ -2081,7 +2081,7 @@ static void prvGetLabel( CK_ATTRIBUTE ** ppxLabel, *pxPalHandle = PKCS11_PAL_FindObject( pxPrivKeyLabel, pxLabel->ulValueLen ); /* See explanation in prvCheckValidSessionAndModule for this exception. */ /* coverity[misra_c_2012_rule_10_5_violation] */ - xIsPrivate = ( CK_BBOOL ) CK_FALSE; + xIsPrivate = ( CK_BBOOL ) CK_FALSE; } else { @@ -2139,12 +2139,12 @@ static void prvGetLabel( CK_ATTRIBUTE ** ppxLabel, { - CK_RV xResult = CKR_OK; - uint32_t ulIndex; - CK_ATTRIBUTE_PTR pxLabel = NULL; - CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE; - int32_t lMbedTLSReturn = 0; - mbedtls_pk_context xMbedContext; + CK_RV xResult = CKR_OK; + uint32_t ulIndex; + CK_ATTRIBUTE_PTR pxLabel = NULL; + CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE; + int32_t lMbedTLSReturn = 0; + mbedtls_pk_context xMbedContext; mbedtls_ecp_keypair * pxKeyPair; mbedtls_pk_init( &xMbedContext ); @@ -2177,13 +2177,13 @@ static void prvGetLabel( CK_ATTRIBUTE ** ppxLabel, xMbedContext.pk_info = &mbedtls_eckey_info; /* Initialize the context. */ - xMbedContext.pk_ctx = pxKeyPair; + xMbedContext.pk_ctx = pxKeyPair; mbedtls_ecp_keypair_init( pxKeyPair ); mbedtls_ecp_group_init( &pxKeyPair->grp ); /* At this time, only P-256 curves are supported. */ - lMbedTLSReturn = mbedtls_ecp_group_load( &pxKeyPair->grp, - MBEDTLS_ECP_DP_SECP256R1 ); + lMbedTLSReturn = mbedtls_ecp_group_load( &pxKeyPair->grp, + MBEDTLS_ECP_DP_SECP256R1 ); if( lMbedTLSReturn != 0 ) { @@ -2243,13 +2243,13 @@ static CK_RV prvCreateRsaPrivateKey( CK_ATTRIBUTE * pxTemplate, CK_ULONG ulCount, CK_OBJECT_HANDLE_PTR pxObject ) { - CK_RV xResult = CKR_OK; - mbedtls_pk_context xMbedContext = { 0 }; - uint32_t ulIndex; - CK_ATTRIBUTE_PTR pxLabel = NULL; + CK_RV xResult = CKR_OK; + mbedtls_pk_context xMbedContext = { 0 }; + uint32_t ulIndex; + CK_ATTRIBUTE_PTR pxLabel = NULL; /* mbedtls_rsa_context must be malloc'ed to use with mbedtls_pk_free function. */ - mbedtls_rsa_context * pxRsaCtx = pvPortMalloc( sizeof( mbedtls_rsa_context ) ); + mbedtls_rsa_context * pxRsaCtx = pvPortMalloc( sizeof( mbedtls_rsa_context ) ); prvGetLabel( &pxLabel, pxTemplate, ulCount ); @@ -2261,7 +2261,7 @@ static CK_RV prvCreateRsaPrivateKey( CK_ATTRIBUTE * pxTemplate, if( pxRsaCtx != NULL ) { mbedtls_pk_init( &xMbedContext ); - xMbedContext.pk_ctx = pxRsaCtx; + xMbedContext.pk_ctx = pxRsaCtx; xMbedContext.pk_info = &mbedtls_rsa_info; mbedtls_rsa_init( pxRsaCtx, MBEDTLS_RSA_PKCS_V15, 0 /*ignored.*/ ); } @@ -2313,7 +2313,7 @@ static CK_RV prvCreatePrivateKey( CK_ATTRIBUTE * pxTemplate, CK_ULONG ulCount, CK_OBJECT_HANDLE_PTR pxObject ) { - CK_RV xResult = CKR_OK; + CK_RV xResult = CKR_OK; CK_KEY_TYPE xKeyType; prvGetKeyType( &xKeyType, pxTemplate, ulCount ); @@ -2359,7 +2359,7 @@ static CK_RV prvCreatePublicKey( CK_ATTRIBUTE * pxTemplate, CK_OBJECT_HANDLE_PTR pxObject ) { CK_KEY_TYPE xKeyType = 0; - CK_RV xResult = CKR_OK; + CK_RV xResult = CKR_OK; #if ( pkcs11configSUPPRESS_ECDSA_MECHANISM == 1 ) /* Suppress unused parameter warning if ECDSA is suppressed. */ @@ -2448,10 +2448,10 @@ CK_DECLARE_FUNCTION( CK_RV, C_CreateObject )( CK_SESSION_HANDLE hSession, CK_ULONG ulCount, CK_OBJECT_HANDLE_PTR phObject ) { - CK_OBJECT_CLASS xClass = 0; + CK_OBJECT_CLASS xClass = 0; const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); + CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); if( ( NULL == pTemplate ) || ( NULL == phObject ) ) @@ -2510,7 +2510,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_DestroyObject )( CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject ) { const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); + CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); if( xResult == CKR_OK ) { @@ -2568,24 +2568,24 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetAttributeValue )( CK_SESSION_HANDLE hSession, { /* See explanation in prvCheckValidSessionAndModule for this exception. */ /* coverity[misra_c_2012_rule_10_5_violation] */ - CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE; - CK_ULONG iAttrib; - mbedtls_pk_context xKeyContext = { 0 }; - mbedtls_pk_type_t xKeyType; + CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE; + CK_ULONG iAttrib; + mbedtls_pk_context xKeyContext = { 0 }; + mbedtls_pk_type_t xKeyType; const mbedtls_ecp_keypair * pxKeyPair; - CK_KEY_TYPE xPkcsKeyType = ( CK_KEY_TYPE ) ~0UL; - CK_OBJECT_CLASS xClass; - CK_BYTE_PTR pxObjectValue = NULL; - CK_ULONG ulLength = 0; - const CK_BYTE ucP256Oid[] = pkcs11DER_ENCODED_OID_P256; - int32_t lMbedTLSResult = 0; - CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE; - CK_ULONG xSize = 0; - size_t xMbedSize = 0; - CK_BYTE_PTR pcLabel = NULL; - - const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); + CK_KEY_TYPE xPkcsKeyType = ( CK_KEY_TYPE ) ~0UL; + CK_OBJECT_CLASS xClass; + CK_BYTE_PTR pxObjectValue = NULL; + CK_ULONG ulLength = 0; + const CK_BYTE ucP256Oid[] = pkcs11DER_ENCODED_OID_P256; + int32_t lMbedTLSResult = 0; + CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE; + CK_ULONG xSize = 0; + size_t xMbedSize = 0; + CK_BYTE_PTR pcLabel = NULL; + + const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); + CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); if( ( CKR_OK == xResult ) && ( ( ( NULL == pTemplate ) ) || ( 0UL == ulCount ) ) ) { @@ -2684,7 +2684,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetAttributeValue )( CK_SESSION_HANDLE hSession, if( xIsPrivate == ( CK_BBOOL ) CK_TRUE ) { pTemplate[ iAttrib ].ulValueLen = CK_UNAVAILABLE_INFORMATION; - xResult = CKR_ATTRIBUTE_SENSITIVE; + xResult = CKR_ATTRIBUTE_SENSITIVE; } else { @@ -2736,7 +2736,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetAttributeValue )( CK_SESSION_HANDLE hSession, break; default: - xResult = CKR_ATTRIBUTE_VALUE_INVALID; + xResult = CKR_ATTRIBUTE_VALUE_INVALID; break; } @@ -2747,7 +2747,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetAttributeValue )( CK_SESSION_HANDLE hSession, case CKA_PRIVATE_EXPONENT: - xResult = CKR_ATTRIBUTE_SENSITIVE; + xResult = CKR_ATTRIBUTE_SENSITIVE; break; @@ -2779,18 +2779,18 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetAttributeValue )( CK_SESSION_HANDLE hSession, } else { - pxKeyPair = ( mbedtls_ecp_keypair * ) xKeyContext.pk_ctx; + pxKeyPair = ( mbedtls_ecp_keypair * ) xKeyContext.pk_ctx; *( ( uint8_t * ) pTemplate[ iAttrib ].pValue ) = 0x04; /* Mark the point as uncompressed. */ /* Copy xSize value to avoid casting a CK_ULONG size pointer * to a size_t sized pointer. */ - xMbedSize = xSize; - lMbedTLSResult = mbedtls_ecp_tls_write_point( &pxKeyPair->grp, - &pxKeyPair->Q, - MBEDTLS_ECP_PF_UNCOMPRESSED, - &xMbedSize, - ( uint8_t * ) pTemplate[ iAttrib ].pValue + 1, - pTemplate[ iAttrib ].ulValueLen - 1UL ); + xMbedSize = xSize; + lMbedTLSResult = mbedtls_ecp_tls_write_point( &pxKeyPair->grp, + &pxKeyPair->Q, + MBEDTLS_ECP_PF_UNCOMPRESSED, + &xMbedSize, + ( uint8_t * ) pTemplate[ iAttrib ].pValue + 1, + pTemplate[ iAttrib ].ulValueLen - 1UL ); xSize = xMbedSize; if( lMbedTLSResult < 0 ) @@ -2813,7 +2813,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_GetAttributeValue )( CK_SESSION_HANDLE hSession, break; default: - xResult = CKR_ATTRIBUTE_TYPE_INVALID; + xResult = CKR_ATTRIBUTE_TYPE_INVALID; break; } } @@ -2856,11 +2856,11 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjectsInit )( CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount ) { - P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); - CK_BYTE * pxFindObjectLabel = NULL; - uint32_t ulIndex; - CK_ATTRIBUTE xAttribute; + P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); + CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); + CK_BYTE * pxFindObjectLabel = NULL; + uint32_t ulIndex; + CK_ATTRIBUTE xAttribute; if( NULL == pTemplate ) { @@ -2888,10 +2888,10 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjectsInit )( CK_SESSION_HANDLE hSession, if( xResult == CKR_OK ) { /* Plus one to leave room for a NULL terminator. */ - pxFindObjectLabel = pvPortMalloc( pTemplate->ulValueLen + 1UL ); + pxFindObjectLabel = pvPortMalloc( pTemplate->ulValueLen + 1UL ); pxSession->xFindObjectLabelLen = pTemplate->ulValueLen; - pxSession->pxFindObjectLabel = pxFindObjectLabel; + pxSession->pxFindObjectLabel = pxFindObjectLabel; if( pxFindObjectLabel != NULL ) { @@ -2931,7 +2931,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjectsInit )( CK_SESSION_HANDLE hSession, if( ( pxSession != NULL ) && ( xResult != CKR_OK ) ) { vPortFree( pxFindObjectLabel ); - pxSession->pxFindObjectLabel = NULL; + pxSession->pxFindObjectLabel = NULL; pxSession->xFindObjectLabelLen = 0; } @@ -2974,17 +2974,17 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjects )( CK_SESSION_HANDLE hSession, CK_ULONG ulMaxObjectCount, CK_ULONG_PTR pulObjectCount ) { - P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); + P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); + CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); - CK_BYTE_PTR pucObjectValue = NULL; - CK_ULONG xObjectLength = 0; + CK_BYTE_PTR pucObjectValue = NULL; + CK_ULONG xObjectLength = 0; /* See explanation in prvCheckValidSessionAndModule for this exception. */ /* coverity[misra_c_2012_rule_10_5_violation] */ - CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE; - CK_BYTE xByte = 0; - CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE; - CK_ULONG ulIndex; + CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE; + CK_BYTE xByte = 0; + CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE; + CK_ULONG ulIndex; /* * Check parameters. @@ -3042,7 +3042,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjects )( CK_SESSION_HANDLE hSession, } else { - xResult = prvAddObjectToList( xPalHandle, phObject, pxSession->pxFindObjectLabel, pxSession->xFindObjectLabelLen ); + xResult = prvAddObjectToList( xPalHandle, phObject, pxSession->pxFindObjectLabel, pxSession->xFindObjectLabelLen ); *pulObjectCount = 1; } @@ -3064,7 +3064,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjects )( CK_SESSION_HANDLE hSession, if( pxSession != NULL ) { vPortFree( pxSession->pxFindObjectLabel ); - pxSession->pxFindObjectLabel = NULL; + pxSession->pxFindObjectLabel = NULL; pxSession->xFindObjectLabelLen = 0; } } @@ -3094,7 +3094,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjects )( CK_SESSION_HANDLE hSession, CK_DECLARE_FUNCTION( CK_RV, C_FindObjectsFinal )( CK_SESSION_HANDLE hSession ) { P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); + CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); /* * Check parameters. @@ -3113,7 +3113,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_FindObjectsFinal )( CK_SESSION_HANDLE hSession ) * Clean-up find objects state. */ vPortFree( pxSession->pxFindObjectLabel ); - pxSession->pxFindObjectLabel = NULL; + pxSession->pxFindObjectLabel = NULL; pxSession->xFindObjectLabelLen = 0; } @@ -3144,7 +3144,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_DigestInit )( CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism ) { P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); + CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); if( pMechanism == NULL ) { @@ -3215,7 +3215,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_DigestUpdate )( CK_SESSION_HANDLE hSession, CK_ULONG ulPartLen ) { P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); + CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); if( pPart == NULL ) { @@ -3235,7 +3235,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_DigestUpdate )( CK_SESSION_HANDLE hSession, { if( 0 != mbedtls_sha256_update_ret( &pxSession->xSHA256Context, pPart, ulPartLen ) ) { - xResult = CKR_FUNCTION_FAILED; + xResult = CKR_FUNCTION_FAILED; pxSession->xOperationDigestMechanism = pkcs11NO_OPERATION; } } @@ -3284,7 +3284,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_DigestFinal )( CK_SESSION_HANDLE hSession, CK_ULONG_PTR pulDigestLen ) { P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); + CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); if( pulDigestLen == NULL ) @@ -3296,7 +3296,7 @@ CK_DECLARE_FUNCTION( CK_RV, C_DigestFinal )( CK_SESSION_HANDLE hSession, { if( pxSession->xOperationDigestMechanism != CKM_SHA256 ) { - xResult = CKR_OPERATION_NOT_INITIALIZED; + xResult = CKR_OPERATION_NOT_INITIALIZED; pxSession->xOperationDigestMechanism = pkcs11NO_OPERATION; } } @@ -3368,17 +3368,17 @@ CK_DECLARE_FUNCTION( CK_RV, C_SignInit )( CK_SESSION_HANDLE hSession, { /* See explanation in prvCheckValidSessionAndModule for this exception. */ /* coverity[misra_c_2012_rule_10_5_violation] */ - CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE; - CK_OBJECT_HANDLE xPalHandle; - CK_BYTE_PTR pxLabel = NULL; - CK_ULONG xLabelLength = 0; + CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE; + CK_OBJECT_HANDLE xPalHandle; + CK_BYTE_PTR pxLabel = NULL; + CK_ULONG xLabelLength = 0; mbedtls_pk_type_t xKeyType; - P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); - CK_BYTE_PTR pulKeyData = NULL; - CK_ULONG ulKeyDataLength = 0; - int32_t lMbedTLSResult = 0; + P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); + CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); + CK_BYTE_PTR pulKeyData = NULL; + CK_ULONG ulKeyDataLength = 0; + int32_t lMbedTLSResult = 0; if( NULL == pMechanism ) @@ -3536,17 +3536,17 @@ CK_DECLARE_FUNCTION( CK_RV, C_Sign )( CK_SESSION_HANDLE hSession, CK_BYTE_PTR pSignature, CK_ULONG_PTR pulSignatureLen ) { - P11Session_t * pxSessionObj = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = prvCheckValidSessionAndModule( pxSessionObj ); + P11Session_t * pxSessionObj = prvSessionPointerFromHandle( hSession ); + CK_RV xResult = prvCheckValidSessionAndModule( pxSessionObj ); - CK_ULONG xSignatureLength = 0; - size_t xExpectedInputLength = 0; - CK_BYTE_PTR pxSignatureBuffer = pSignature; + CK_ULONG xSignatureLength = 0; + size_t xExpectedInputLength = 0; + CK_BYTE_PTR pxSignatureBuffer = pSignature; /* See explanation in prvCheckValidSessionAndModule for this exception. */ /* coverity[misra_c_2012_rule_10_5_violation] */ - CK_BBOOL xSignatureGenerated = ( CK_BBOOL ) CK_FALSE; - uint8_t ecSignature[ pkcs11ECDSA_P256_SIGNATURE_LENGTH + 15 ]; /*TODO: Figure out this length. */ - int32_t lMbedTLSResult; + CK_BBOOL xSignatureGenerated = ( CK_BBOOL ) CK_FALSE; + uint8_t ecSignature[ pkcs11ECDSA_P256_SIGNATURE_LENGTH + 15 ]; /*TODO: Figure out this length. */ + int32_t lMbedTLSResult; if( ( NULL == pulSignatureLen ) || ( NULL == pData ) ) @@ -3559,14 +3559,14 @@ CK_DECLARE_FUNCTION( CK_RV, C_Sign )( CK_SESSION_HANDLE hSession, /* Update the signature length. */ if( pxSessionObj->xOperationSignMechanism == CKM_RSA_PKCS ) { - xSignatureLength = pkcs11RSA_2048_SIGNATURE_LENGTH; + xSignatureLength = pkcs11RSA_2048_SIGNATURE_LENGTH; xExpectedInputLength = pkcs11RSA_SIGNATURE_INPUT_LENGTH; } else if( pxSessionObj->xOperationSignMechanism == CKM_ECDSA ) { - xSignatureLength = pkcs11ECDSA_P256_SIGNATURE_LENGTH; + xSignatureLength = pkcs11ECDSA_P256_SIGNATURE_LENGTH; xExpectedInputLength = pkcs11SHA256_DIGEST_LENGTH; - pxSignatureBuffer = ecSignature; + pxSignatureBuffer = ecSignature; } else { @@ -3599,14 +3599,14 @@ CK_DECLARE_FUNCTION( CK_RV, C_Sign )( CK_SESSION_HANDLE hSession, { if( pdTRUE == xSemaphoreTake( pxSessionObj->xSignMutex, portMAX_DELAY ) ) { - lMbedTLSResult = mbedtls_pk_sign( &pxSessionObj->xSignKey, - MBEDTLS_MD_NONE, - pData, - ulDataLen, - pxSignatureBuffer, - &xExpectedInputLength, - mbedtls_ctr_drbg_random, - &xP11Context.xMbedDrbgCtx ); + lMbedTLSResult = mbedtls_pk_sign( &pxSessionObj->xSignKey, + MBEDTLS_MD_NONE, + pData, + ulDataLen, + pxSignatureBuffer, + &xExpectedInputLength, + mbedtls_ctr_drbg_random, + &xP11Context.xMbedDrbgCtx ); if( lMbedTLSResult != 0 ) { @@ -3691,17 +3691,17 @@ CK_DECLARE_FUNCTION( CK_RV, C_VerifyInit )( CK_SESSION_HANDLE hSession, { /* See explanation in prvCheckValidSessionAndModule for this exception. */ /* coverity[misra_c_2012_rule_10_5_violation] */ - CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE; - P11Session_t * pxSession; - CK_BYTE_PTR pucKeyData = NULL; - CK_ULONG ulKeyDataLength = 0; + CK_BBOOL xIsPrivate = ( CK_BBOOL ) CK_TRUE; + P11Session_t * pxSession; + CK_BYTE_PTR pucKeyData = NULL; + CK_ULONG ulKeyDataLength = 0; mbedtls_pk_type_t xKeyType; - CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE; - CK_BYTE_PTR pxLabel = NULL; - CK_ULONG xLabelLength = 0; + CK_OBJECT_HANDLE xPalHandle = CK_INVALID_HANDLE; + CK_BYTE_PTR pxLabel = NULL; + CK_ULONG xLabelLength = 0; pxSession = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); + CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); if( NULL == pMechanism ) { @@ -3846,10 +3846,10 @@ CK_DECLARE_FUNCTION( CK_RV, C_Verify )( CK_SESSION_HANDLE hSession, CK_ULONG ulSignatureLen ) { P11Session_t * pxSessionObj; - int32_t lMbedTLSResult; + int32_t lMbedTLSResult; pxSessionObj = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = prvCheckValidSessionAndModule( pxSessionObj ); + CK_RV xResult = prvCheckValidSessionAndModule( pxSessionObj ); /* Check parameters. */ if( ( NULL == pData ) || @@ -3927,8 +3927,8 @@ CK_DECLARE_FUNCTION( CK_RV, C_Verify )( CK_SESSION_HANDLE hSession, /* TODO: Refactor w/ test code * An ECDSA signature is comprised of 2 components - R & S. C_Sign returns them one after another. */ mbedtls_ecdsa_context * pxEcdsaContext; - mbedtls_mpi xR; - mbedtls_mpi xS; + mbedtls_mpi xR; + mbedtls_mpi xS; mbedtls_mpi_init( &xR ); mbedtls_mpi_init( &xS ); @@ -4006,14 +4006,14 @@ static CK_RV prvCheckGenerateKeyPairPrivateTemplate( CK_ATTRIBUTE ** ppxLabel, CK_ATTRIBUTE * pxAttribute, uint32_t * pulAttributeMap ) { - CK_RV xResult = CKR_OK; + CK_RV xResult = CKR_OK; CK_BBOOL xBool; CK_ULONG xTemp; switch( pxAttribute->type ) { case ( CKA_LABEL ): - *ppxLabel = pxAttribute; + *ppxLabel = pxAttribute; *pulAttributeMap |= LABEL_IN_TEMPLATE; break; @@ -4070,7 +4070,7 @@ static CK_RV prvCheckGenerateKeyPairPrivateTemplate( CK_ATTRIBUTE ** ppxLabel, break; default: - xResult = CKR_ATTRIBUTE_TYPE_INVALID; + xResult = CKR_ATTRIBUTE_TYPE_INVALID; break; } @@ -4093,16 +4093,16 @@ static CK_RV prvCheckGenerateKeyPairPublicTemplate( CK_ATTRIBUTE ** ppxLabel, CK_ATTRIBUTE * pxAttribute, uint32_t * pulAttributeMap ) { - CK_RV xResult = CKR_OK; - CK_BBOOL xBool; - CK_KEY_TYPE xKeyType; - const CK_BYTE pxEcParams[] = pkcs11DER_ENCODED_OID_P256; + CK_RV xResult = CKR_OK; + CK_BBOOL xBool; + CK_KEY_TYPE xKeyType; + const CK_BYTE pxEcParams[] = pkcs11DER_ENCODED_OID_P256; const CK_BYTE * pxEcAttVal; switch( pxAttribute->type ) { case ( CKA_LABEL ): - *ppxLabel = pxAttribute; + *ppxLabel = pxAttribute; *pulAttributeMap |= LABEL_IN_TEMPLATE; break; @@ -4118,7 +4118,7 @@ static CK_RV prvCheckGenerateKeyPairPublicTemplate( CK_ATTRIBUTE ** ppxLabel, break; case ( CKA_EC_PARAMS ): - pxEcAttVal = ( CK_BYTE * ) pxAttribute->pValue; + pxEcAttVal = ( CK_BYTE * ) pxAttribute->pValue; if( memcmp( pxEcParams, pxEcAttVal, sizeof( pxEcParams ) ) != 0 ) { @@ -4157,7 +4157,7 @@ static CK_RV prvCheckGenerateKeyPairPublicTemplate( CK_ATTRIBUTE ** ppxLabel, break; default: - xResult = CKR_TEMPLATE_INCONSISTENT; + xResult = CKR_TEMPLATE_INCONSISTENT; break; } @@ -4232,20 +4232,20 @@ CK_DECLARE_FUNCTION( CK_RV, C_GenerateKeyPair )( CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE_PTR phPublicKey, CK_OBJECT_HANDLE_PTR phPrivateKey ) { - uint8_t * pucDerFile = pvPortMalloc( pkcs11KEY_GEN_MAX_DER_SIZE ); - int32_t lMbedResult = 0; - uint32_t ulIndex = 0; - mbedtls_pk_context xCtx = { 0 }; - CK_ATTRIBUTE_PTR pxPrivateLabel = NULL; - CK_ATTRIBUTE_PTR pxPublicLabel = NULL; - CK_OBJECT_HANDLE xPalPublic = CK_INVALID_HANDLE; - CK_OBJECT_HANDLE xPalPrivate = CK_INVALID_HANDLE; - uint32_t xPublicRequiredAttributeMap = ( LABEL_IN_TEMPLATE | EC_PARAMS_IN_TEMPLATE | VERIFY_IN_TEMPLATE ); - uint32_t xPrivateRequiredAttributeMap = ( LABEL_IN_TEMPLATE | PRIVATE_IN_TEMPLATE | SIGN_IN_TEMPLATE ); - uint32_t xAttributeMap = 0; - - const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); - CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); + uint8_t * pucDerFile = pvPortMalloc( pkcs11KEY_GEN_MAX_DER_SIZE ); + int32_t lMbedResult = 0; + uint32_t ulIndex = 0; + mbedtls_pk_context xCtx = { 0 }; + CK_ATTRIBUTE_PTR pxPrivateLabel = NULL; + CK_ATTRIBUTE_PTR pxPublicLabel = NULL; + CK_OBJECT_HANDLE xPalPublic = CK_INVALID_HANDLE; + CK_OBJECT_HANDLE xPalPrivate = CK_INVALID_HANDLE; + uint32_t xPublicRequiredAttributeMap = ( LABEL_IN_TEMPLATE | EC_PARAMS_IN_TEMPLATE | VERIFY_IN_TEMPLATE ); + uint32_t xPrivateRequiredAttributeMap = ( LABEL_IN_TEMPLATE | PRIVATE_IN_TEMPLATE | SIGN_IN_TEMPLATE ); + uint32_t xAttributeMap = 0; + + const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); + CK_RV xResult = prvCheckValidSessionAndModule( pxSession ); #if ( pkcs11configSUPPRESS_ECDSA_MECHANISM == 1 ) if( xResult == CKR_OK ) @@ -4415,10 +4415,10 @@ CK_DECLARE_FUNCTION( CK_RV, C_GenerateRandom )( CK_SESSION_HANDLE hSession, CK_BYTE_PTR RandomData, CK_ULONG ulRandomLen ) { - CK_RV xResult = CKR_OK; - int32_t lMbedResult = 0; + CK_RV xResult = CKR_OK; + int32_t lMbedResult = 0; - const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); + const P11Session_t * pxSession = prvSessionPointerFromHandle( hSession ); xResult = prvCheckValidSessionAndModule( pxSession ); diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_pal.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_pal.c index 0883ddd96..a2320981a 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_pal.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/src/iot_pkcs11_pal.c @@ -118,33 +118,33 @@ void prvLabelToFilenameHandle( uint8_t * pcLabel, sizeof( pkcs11configLABEL_DEVICE_CERTIFICATE_FOR_TLS ) ) ) { *pcFileName = pkcs11palFILE_NAME_CLIENT_CERTIFICATE; - *pHandle = eAwsDeviceCertificate; + *pHandle = eAwsDeviceCertificate; } else if( 0 == memcmp( pcLabel, &pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS, sizeof( pkcs11configLABEL_DEVICE_PRIVATE_KEY_FOR_TLS ) ) ) { *pcFileName = pkcs11palFILE_NAME_KEY; - *pHandle = eAwsDevicePrivateKey; + *pHandle = eAwsDevicePrivateKey; } else if( 0 == memcmp( pcLabel, &pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS, sizeof( pkcs11configLABEL_DEVICE_PUBLIC_KEY_FOR_TLS ) ) ) { *pcFileName = pkcs11palFILE_NAME_KEY; - *pHandle = eAwsDevicePublicKey; + *pHandle = eAwsDevicePublicKey; } else if( 0 == memcmp( pcLabel, &pkcs11configLABEL_CODE_VERIFICATION_KEY, sizeof( pkcs11configLABEL_CODE_VERIFICATION_KEY ) ) ) { *pcFileName = pkcs11palFILE_CODE_SIGN_PUBLIC_KEY; - *pHandle = eAwsCodeSigningKey; + *pHandle = eAwsCodeSigningKey; } else { *pcFileName = NULL; - *pHandle = eInvalidHandle; + *pHandle = eInvalidHandle; } } } @@ -160,11 +160,11 @@ CK_OBJECT_HANDLE PKCS11_PAL_SaveObject( CK_ATTRIBUTE_PTR pxLabel, CK_BYTE_PTR pucData, CK_ULONG ulDataSize ) { - uint32_t ulStatus = 0; - HANDLE hFile = INVALID_HANDLE_VALUE; - DWORD lpNumberOfBytesWritten; - char * pcFileName = NULL; - CK_OBJECT_HANDLE xHandle = eInvalidHandle; + uint32_t ulStatus = 0; + HANDLE hFile = INVALID_HANDLE_VALUE; + DWORD lpNumberOfBytesWritten; + char * pcFileName = NULL; + CK_OBJECT_HANDLE xHandle = eInvalidHandle; /* Converts a label to its respective filename and handle. */ prvLabelToFilenameHandle( pxLabel->pValue, @@ -188,7 +188,7 @@ CK_OBJECT_HANDLE PKCS11_PAL_SaveObject( CK_ATTRIBUTE_PTR pxLabel, { ulStatus = GetLastError(); PKCS11_PAL_PRINT( ( "ERROR: Unable to create file %d \r\n", ulStatus ) ); - xHandle = eInvalidHandle; + xHandle = eInvalidHandle; } /* Write the object data. */ @@ -197,7 +197,7 @@ CK_OBJECT_HANDLE PKCS11_PAL_SaveObject( CK_ATTRIBUTE_PTR pxLabel, if( FALSE == WriteFile( hFile, pucData, ulDataSize, &lpNumberOfBytesWritten, NULL ) ) { ulStatus = GetLastError(); - xHandle = eInvalidHandle; + xHandle = eInvalidHandle; } } @@ -220,8 +220,8 @@ CK_OBJECT_HANDLE PKCS11_PAL_FindObject( CK_BYTE_PTR pxLabel, /* Avoid compiler warnings about unused variables. */ ( void ) usLength; - CK_OBJECT_HANDLE xHandle = eInvalidHandle; - char * pcFileName = NULL; + CK_OBJECT_HANDLE xHandle = eInvalidHandle; + char * pcFileName = NULL; /* Converts a label to its respective filename and handle. */ prvLabelToFilenameHandle( pxLabel, @@ -243,32 +243,32 @@ CK_RV PKCS11_PAL_GetObjectValue( CK_OBJECT_HANDLE xHandle, CK_ULONG_PTR pulDataSize, CK_BBOOL * pIsPrivate ) { - CK_RV ulReturn = CKR_OK; + CK_RV ulReturn = CKR_OK; uint32_t ulDriverReturn = 0; - HANDLE hFile = INVALID_HANDLE_VALUE; - uint32_t ulSize = 0; - char * pcFileName = NULL; + HANDLE hFile = INVALID_HANDLE_VALUE; + uint32_t ulSize = 0; + char * pcFileName = NULL; if( xHandle == eAwsDeviceCertificate ) { - pcFileName = pkcs11palFILE_NAME_CLIENT_CERTIFICATE; + pcFileName = pkcs11palFILE_NAME_CLIENT_CERTIFICATE; *pIsPrivate = CK_FALSE; } else if( xHandle == eAwsDevicePrivateKey ) { - pcFileName = pkcs11palFILE_NAME_KEY; + pcFileName = pkcs11palFILE_NAME_KEY; *pIsPrivate = CK_TRUE; } else if( xHandle == eAwsDevicePublicKey ) { /* Public and private key are stored together in same file. */ - pcFileName = pkcs11palFILE_NAME_KEY; + pcFileName = pkcs11palFILE_NAME_KEY; *pIsPrivate = CK_FALSE; } else if( xHandle == eAwsCodeSigningKey ) { - pcFileName = pkcs11palFILE_CODE_SIGN_PUBLIC_KEY; + pcFileName = pkcs11palFILE_CODE_SIGN_PUBLIC_KEY; *pIsPrivate = CK_FALSE; } else @@ -291,7 +291,7 @@ CK_RV PKCS11_PAL_GetObjectValue( CK_OBJECT_HANDLE xHandle, { ulDriverReturn = GetLastError(); PKCS11_PAL_PRINT( ( "ERROR: Unable to open file %d \r\n", ulDriverReturn ) ); - ulReturn = CKR_FUNCTION_FAILED; + ulReturn = CKR_FUNCTION_FAILED; } if( 0 == ulReturn ) @@ -300,7 +300,7 @@ CK_RV PKCS11_PAL_GetObjectValue( CK_OBJECT_HANDLE xHandle, *pulDataSize = GetFileSize( hFile, ( LPDWORD ) ( &ulSize ) ); /* Create a buffer. */ - *ppucData = pvPortMalloc( *pulDataSize ); + *ppucData = pvPortMalloc( *pulDataSize ); if( NULL == *ppucData ) { diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/pkcs11/src/iot_pkcs11.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/pkcs11/src/iot_pkcs11.c index 78f472544..74d050695 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/pkcs11/src/iot_pkcs11.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/pkcs11/src/iot_pkcs11.c @@ -51,7 +51,7 @@ static CK_RV prvOpenSession( CK_SESSION_HANDLE * pxSession, CK_SLOT_ID xSlotId ) { - CK_RV xResult; + CK_RV xResult; CK_FUNCTION_LIST_PTR pxFunctionList; xResult = C_GetFunctionList( &pxFunctionList ); @@ -73,9 +73,9 @@ static CK_RV prvOpenSession( CK_SESSION_HANDLE * pxSession, CK_RV xGetSlotList( CK_SLOT_ID ** ppxSlotId, CK_ULONG * pxSlotCount ) { - CK_RV xResult = CKR_OK; + CK_RV xResult = CKR_OK; CK_FUNCTION_LIST_PTR pxFunctionList; - CK_SLOT_ID * pxSlotId = NULL; + CK_SLOT_ID * pxSlotId = NULL; xResult = C_GetFunctionList( &pxFunctionList ); @@ -125,18 +125,18 @@ CK_RV xGetSlotList( CK_SLOT_ID ** ppxSlotId, CK_RV xInitializePKCS11( void ) { - CK_RV xResult = CKR_OK; + CK_RV xResult = CKR_OK; CK_FUNCTION_LIST_PTR pxFunctionList = NULL; - CK_C_INITIALIZE_ARGS xInitArgs = { 0 }; + CK_C_INITIALIZE_ARGS xInitArgs = { 0 }; - xInitArgs.CreateMutex = NULL; + xInitArgs.CreateMutex = NULL; xInitArgs.DestroyMutex = NULL; - xInitArgs.LockMutex = NULL; - xInitArgs.UnlockMutex = NULL; - xInitArgs.flags = CKF_OS_LOCKING_OK; - xInitArgs.pReserved = NULL; + xInitArgs.LockMutex = NULL; + xInitArgs.UnlockMutex = NULL; + xInitArgs.flags = CKF_OS_LOCKING_OK; + xInitArgs.pReserved = NULL; - xResult = C_GetFunctionList( &pxFunctionList ); + xResult = C_GetFunctionList( &pxFunctionList ); /* Initialize the PKCS #11 module. */ if( xResult == CKR_OK ) @@ -151,13 +151,13 @@ CK_RV xInitializePKCS11( void ) CK_RV xInitializePkcs11Token( void ) { - CK_RV xResult = CKR_OK; + CK_RV xResult = CKR_OK; CK_FUNCTION_LIST_PTR pxFunctionList = NULL; - CK_SLOT_ID * pxSlotId = NULL; - CK_ULONG xSlotCount; - CK_FLAGS xTokenFlags = 0; - CK_TOKEN_INFO_PTR pxTokenInfo = NULL; + CK_SLOT_ID * pxSlotId = NULL; + CK_ULONG xSlotCount; + CK_FLAGS xTokenFlags = 0; + CK_TOKEN_INFO_PTR pxTokenInfo = NULL; xResult = C_GetFunctionList( &pxFunctionList ); @@ -223,10 +223,10 @@ CK_RV xInitializePkcs11Token( void ) CK_RV xInitializePkcs11Session( CK_SESSION_HANDLE * pxSession ) { - CK_RV xResult = CKR_OK; - CK_SLOT_ID * pxSlotId = NULL; + CK_RV xResult = CKR_OK; + CK_SLOT_ID * pxSlotId = NULL; CK_FUNCTION_LIST_PTR pxFunctionList = NULL; - CK_ULONG xSlotCount = 0; + CK_ULONG xSlotCount = 0; xResult = C_GetFunctionList( &pxFunctionList ); @@ -282,10 +282,10 @@ CK_RV xFindObjectWithLabelAndClass( CK_SESSION_HANDLE xSession, CK_OBJECT_CLASS xClass, CK_OBJECT_HANDLE_PTR pxHandle ) { - CK_RV xResult = CKR_OK; - CK_ULONG ulCount = 0; + CK_RV xResult = CKR_OK; + CK_ULONG ulCount = 0; CK_FUNCTION_LIST_PTR pxFunctionList = NULL; - CK_ATTRIBUTE xTemplate[ 2 ] = { 0 }; + CK_ATTRIBUTE xTemplate[ 2 ] = { 0 }; if( ( pcLabelName == NULL ) || ( pxHandle == NULL ) ) { @@ -293,15 +293,15 @@ CK_RV xFindObjectWithLabelAndClass( CK_SESSION_HANDLE xSession, } else { - xTemplate[ 0 ].type = CKA_LABEL; - xTemplate[ 0 ].pValue = ( CK_VOID_PTR ) pcLabelName; + xTemplate[ 0 ].type = CKA_LABEL; + xTemplate[ 0 ].pValue = ( CK_VOID_PTR ) pcLabelName; xTemplate[ 0 ].ulValueLen = strlen( pcLabelName ); - xTemplate[ 1 ].type = CKA_CLASS; - xTemplate[ 1 ].pValue = &xClass; + xTemplate[ 1 ].type = CKA_CLASS; + xTemplate[ 1 ].pValue = &xClass; xTemplate[ 1 ].ulValueLen = sizeof( CK_OBJECT_CLASS ); - xResult = C_GetFunctionList( &pxFunctionList ); + xResult = C_GetFunctionList( &pxFunctionList ); } /* Initialize the FindObject state in the underlying PKCS #11 module based @@ -338,7 +338,7 @@ CK_RV xFindObjectWithLabelAndClass( CK_SESSION_HANDLE xSession, CK_RV vAppendSHA256AlgorithmIdentifierSequence( const uint8_t * puc32ByteHashedMessage, uint8_t * puc51ByteHashOidBuffer ) { - CK_RV xResult = CKR_OK; + CK_RV xResult = CKR_OK; const uint8_t pucOidSequence[] = pkcs11STUFF_APPENDED_TO_RSA_SIG; if( ( puc32ByteHashedMessage == NULL ) || ( puc51ByteHashOidBuffer == NULL ) ) diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/tls/src/iot_tls.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/tls/src/iot_tls.c index 2aae00034..02e380d07 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/tls/src/iot_tls.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/tls/src/iot_tls.c @@ -200,7 +200,7 @@ static int prvGenerateRandomBytes( void * pvCtx, { TLSContext_t * pxCtx = ( TLSContext_t * ) pvCtx; /*lint !e9087 !e9079 Allow casting void* to other types. */ - BaseType_t xResult; + BaseType_t xResult; xResult = pxCtx->pxP11FunctionList->C_GenerateRandom( pxCtx->xP11Session, pucRandom, xRandomLength ); @@ -232,14 +232,14 @@ static int prvCheckCertificate( void * pvCtx, int lPathCount, uint32_t * pulFlags ) { - int lCompilationYear = 0; + int lCompilationYear = 0; #define tlsCOMPILER_DATE_STRING_MONTH_LENGTH 4 #define tlsDATE_STRING_FIELD_COUNT 3 - char cCompilationMonth[ tlsCOMPILER_DATE_STRING_MONTH_LENGTH ]; - int lCompilationMonth = 0; - int lCompilationDay = 0; - const char cMonths[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; + char cCompilationMonth[ tlsCOMPILER_DATE_STRING_MONTH_LENGTH ]; + int lCompilationMonth = 0; + int lCompilationDay = 0; + const char cMonths[] = "JanFebMarAprMayJunJulAugSepOctNovDec"; /* Unreferenced parameters. */ ( void ) ( pvCtx ); @@ -315,12 +315,12 @@ static int prvPrivateKeySigningCallback( void * pvContext, size_t ), /*lint !e955 This parameter is unused. */ void * pvRng ) { - CK_RV xResult = CKR_OK; - int lFinalResult = 0; - TLSContext_t * pxTLSContext = ( TLSContext_t * ) pvContext; - CK_MECHANISM xMech = { 0 }; - CK_BYTE xToBeSigned[ 256 ]; - CK_ULONG xToBeSignedLen = sizeof( xToBeSigned ); + CK_RV xResult = CKR_OK; + int lFinalResult = 0; + TLSContext_t * pxTLSContext = ( TLSContext_t * ) pvContext; + CK_MECHANISM xMech = { 0 }; + CK_BYTE xToBeSigned[ 256 ]; + CK_ULONG xToBeSignedLen = sizeof( xToBeSigned ); /* Unreferenced parameters. */ ( void ) ( piRng ); @@ -342,15 +342,15 @@ static int prvPrivateKeySigningCallback( void * pvContext, * function performs a hash & sign if hash algorithm is specified. This * helper function applies padding indicating data was hashed with * SHA-256 while still allowing pre-hashed data to be provided. */ - xResult = vAppendSHA256AlgorithmIdentifierSequence( + xResult = vAppendSHA256AlgorithmIdentifierSequence( ( uint8_t * ) pucHash, xToBeSigned ); - xToBeSignedLen = pkcs11RSA_SIGNATURE_INPUT_LENGTH; + xToBeSignedLen = pkcs11RSA_SIGNATURE_INPUT_LENGTH; } else if( CKK_EC == pxTLSContext->xKeyType ) { xMech.mechanism = CKM_ECDSA; memcpy( xToBeSigned, pucHash, xHashLen ); - xToBeSignedLen = xHashLen; + xToBeSignedLen = xHashLen; } else { @@ -367,7 +367,7 @@ static int prvPrivateKeySigningCallback( void * pvContext, if( CKR_OK == xResult ) { *pxSigLen = sizeof( xToBeSigned ); - xResult = pxTLSContext->pxP11FunctionList->C_Sign( + xResult = pxTLSContext->pxP11FunctionList->C_Sign( ( CK_SESSION_HANDLE ) pxTLSContext->xP11Session, xToBeSigned, xToBeSignedLen, pucSig, ( CK_ULONG_PTR ) pxSigLen ); } @@ -415,9 +415,9 @@ static int prvReadCertificateIntoContext( TLSContext_t * pxTlsContext, CK_OBJECT_CLASS xClass, mbedtls_x509_crt * pxCertificateContext ) { - BaseType_t xResult = CKR_OK; - CK_ATTRIBUTE xTemplate = { 0 }; - CK_OBJECT_HANDLE xCertObj = 0; + BaseType_t xResult = CKR_OK; + CK_ATTRIBUTE xTemplate = { 0 }; + CK_OBJECT_HANDLE xCertObj = 0; /* Get the handle of the certificate. */ xResult = xFindObjectWithLabelAndClass( @@ -431,10 +431,10 @@ static int prvReadCertificateIntoContext( TLSContext_t * pxTlsContext, /* Query the certificate size. */ if( 0 == xResult ) { - xTemplate.type = CKA_VALUE; + xTemplate.type = CKA_VALUE; xTemplate.ulValueLen = 0; - xTemplate.pValue = NULL; - xResult = + xTemplate.pValue = NULL; + xResult = ( BaseType_t ) pxTlsContext->pxP11FunctionList->C_GetAttributeValue( pxTlsContext->xP11Session, xCertObj, &xTemplate, 1 ); } @@ -489,11 +489,11 @@ static int prvReadCertificateIntoContext( TLSContext_t * pxTlsContext, */ static int prvInitializeClientCredential( TLSContext_t * pxCtx ) { - BaseType_t xResult = CKR_OK; - CK_SLOT_ID * pxSlotIds = NULL; - CK_ULONG xCount = 0; - CK_ATTRIBUTE xTemplate[ 2 ]; - mbedtls_pk_type_t xKeyAlgo = ( mbedtls_pk_type_t ) ~0; + BaseType_t xResult = CKR_OK; + CK_SLOT_ID * pxSlotIds = NULL; + CK_ULONG xCount = 0; + CK_ATTRIBUTE xTemplate[ 2 ]; + mbedtls_pk_type_t xKeyAlgo = ( mbedtls_pk_type_t ) ~0; /* Initialize the mbed contexts. */ mbedtls_x509_crt_init( &pxCtx->xMbedX509Cli ); @@ -557,10 +557,10 @@ static int prvInitializeClientCredential( TLSContext_t * pxCtx ) /* Query the device private key type. */ if( xResult == CKR_OK ) { - xTemplate[ 0 ].type = CKA_KEY_TYPE; - xTemplate[ 0 ].pValue = &pxCtx->xKeyType; + xTemplate[ 0 ].type = CKA_KEY_TYPE; + xTemplate[ 0 ].pValue = &pxCtx->xKeyType; xTemplate[ 0 ].ulValueLen = sizeof( CK_KEY_TYPE ); - xResult = pxCtx->pxP11FunctionList->C_GetAttributeValue( + xResult = pxCtx->pxP11FunctionList->C_GetAttributeValue( pxCtx->xP11Session, pxCtx->xP11PrivateKey, xTemplate, 1 ); } @@ -578,7 +578,7 @@ static int prvInitializeClientCredential( TLSContext_t * pxCtx ) break; default: - xResult = CKR_ATTRIBUTE_VALUE_INVALID; + xResult = CKR_ATTRIBUTE_VALUE_INVALID; break; } } @@ -591,8 +591,8 @@ static int prvInitializeClientCredential( TLSContext_t * pxCtx ) sizeof( mbedtls_pk_info_t ) ); pxCtx->xMbedPkInfo.sign_func = prvPrivateKeySigningCallback; - pxCtx->xMbedPkCtx.pk_info = &pxCtx->xMbedPkInfo; - pxCtx->xMbedPkCtx.pk_ctx = pxCtx; + pxCtx->xMbedPkCtx.pk_info = &pxCtx->xMbedPkInfo; + pxCtx->xMbedPkCtx.pk_ctx = pxCtx; } /* Get the handle of the device client certificate. */ @@ -629,8 +629,8 @@ static int prvInitializeClientCredential( TLSContext_t * pxCtx ) BaseType_t TLS_Init( void ** ppvContext, TLSParams_t * pxParams ) { - BaseType_t xResult = CKR_OK; - TLSContext_t * pxCtx = NULL; + BaseType_t xResult = CKR_OK; + TLSContext_t * pxCtx = NULL; CK_C_GetFunctionList xCkGetFunctionList = NULL; /* Allocate an internal context. */ @@ -641,21 +641,21 @@ BaseType_t TLS_Init( void ** ppvContext, if( NULL != pxCtx ) { memset( pxCtx, 0, sizeof( TLSContext_t ) ); - *ppvContext = pxCtx; + *ppvContext = pxCtx; /* Initialize the context. */ - pxCtx->pcDestination = pxParams->pcDestination; - pxCtx->pcServerCertificate = pxParams->pcServerCertificate; + pxCtx->pcDestination = pxParams->pcDestination; + pxCtx->pcServerCertificate = pxParams->pcServerCertificate; pxCtx->ulServerCertificateLength = pxParams->ulServerCertificateLength; - pxCtx->ppcAlpnProtocols = pxParams->ppcAlpnProtocols; - pxCtx->ulAlpnProtocolsCount = pxParams->ulAlpnProtocolsCount; - pxCtx->xNetworkRecv = pxParams->pxNetworkRecv; - pxCtx->xNetworkSend = pxParams->pxNetworkSend; - pxCtx->pvCallerContext = pxParams->pvCallerContext; + pxCtx->ppcAlpnProtocols = pxParams->ppcAlpnProtocols; + pxCtx->ulAlpnProtocolsCount = pxParams->ulAlpnProtocolsCount; + pxCtx->xNetworkRecv = pxParams->pxNetworkRecv; + pxCtx->xNetworkSend = pxParams->pxNetworkSend; + pxCtx->pvCallerContext = pxParams->pvCallerContext; /* Get the function pointer list for the PKCS#11 module. */ - xCkGetFunctionList = C_GetFunctionList; - xResult = ( BaseType_t ) xCkGetFunctionList( &pxCtx->pxP11FunctionList ); + xCkGetFunctionList = C_GetFunctionList; + xResult = ( BaseType_t ) xCkGetFunctionList( &pxCtx->pxP11FunctionList ); /* Ensure that the PKCS #11 module is initialized. */ if( CKR_OK == xResult ) @@ -700,9 +700,9 @@ BaseType_t TLS_Init( void ** ppvContext, BaseType_t TLS_Connect( void * pvContext ) { - BaseType_t xResult = 0; - TLSContext_t * pxCtx = ( TLSContext_t * ) - pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */ + BaseType_t xResult = 0; + TLSContext_t * pxCtx = ( TLSContext_t * ) + pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */ /* Initialize mbedTLS structures. */ @@ -848,10 +848,10 @@ BaseType_t TLS_Recv( void * pvContext, unsigned char * pucReadBuffer, size_t xReadLength ) { - BaseType_t xResult = 0; - TLSContext_t * pxCtx = ( TLSContext_t * ) - pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */ - size_t xRead = 0; + BaseType_t xResult = 0; + TLSContext_t * pxCtx = ( TLSContext_t * ) + pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */ + size_t xRead = 0; if( ( NULL != pxCtx ) && ( pdTRUE == pxCtx->xTLSHandshakeSuccessful ) ) { @@ -899,10 +899,10 @@ BaseType_t TLS_Send( void * pvContext, const unsigned char * pucMsg, size_t xMsgLength ) { - BaseType_t xResult = 0; - TLSContext_t * pxCtx = ( TLSContext_t * ) - pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */ - size_t xWritten = 0; + BaseType_t xResult = 0; + TLSContext_t * pxCtx = ( TLSContext_t * ) + pvContext; /*lint !e9087 !e9079 Allow casting void* to other types. */ + size_t xWritten = 0; if( ( NULL != pxCtx ) && ( pdTRUE == pxCtx->xTLSHandshakeSuccessful ) ) { diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/utils/src/iot_pki_utils.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/utils/src/iot_pki_utils.c index ad02b77ad..d56fa0ceb 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/utils/src/iot_pki_utils.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/abstractions/platform/freertos_plus/standard/utils/src/iot_pki_utils.c @@ -45,9 +45,9 @@ BaseType_t PKI_mbedTLSSignatureToPkcs11Signature( uint8_t * pxSignaturePKCS, const uint8_t * pxMbedSignature ) { - BaseType_t xReturn = 0; + BaseType_t xReturn = 0; const uint8_t * pxNextLength; - uint8_t ucSigComponentLength; + uint8_t ucSigComponentLength; if( ( pxSignaturePKCS == NULL ) || ( pxMbedSignature == NULL ) ) { @@ -122,9 +122,9 @@ BaseType_t PKI_mbedTLSSignatureToPkcs11Signature( uint8_t * pxSignaturePKCS, BaseType_t PKI_pkcs11SignatureTombedTLSSignature( uint8_t * pucSig, size_t * pxSigLen ) { - BaseType_t xReturn = 0; - uint8_t * pucSigPtr; - uint8_t ucTemp[ 64 ] = { 0 }; /* A temporary buffer for the pre-formatted signature. */ + BaseType_t xReturn = 0; + uint8_t * pucSigPtr; + uint8_t ucTemp[ 64 ] = { 0 }; /* A temporary buffer for the pre-formatted signature. */ if( ( pucSig == NULL ) || ( pxSigLen == NULL ) ) { @@ -145,9 +145,9 @@ BaseType_t PKI_pkcs11SignatureTombedTLSSignature( uint8_t * pucSig, * R[32] + S[32] */ - pucSig[ 0 ] = 0x30; /* Sequence. */ - pucSig[ 1 ] = 0x44; /* The minimum length the signature could be. */ - pucSig[ 2 ] = 0x02; /* Integer. */ + pucSig[ 0 ] = 0x30; /* Sequence. */ + pucSig[ 1 ] = 0x44; /* The minimum length the signature could be. */ + pucSig[ 2 ] = 0x02; /* Integer. */ /*************** R Component. *******************/ @@ -159,18 +159,18 @@ BaseType_t PKI_pkcs11SignatureTombedTLSSignature( uint8_t * pucSig, pucSig[ 3 ] = 0x21; /* Increment the length of the R value to account for the 0x00 pad. */ pucSig[ 4 ] = 0x0; /* Write the 0x00 pad. */ ( void ) memcpy( &pucSig[ 5 ], ucTemp, 32 ); /* Copy the 32-byte R value. */ - pucSigPtr = pucSig + 33; /* Increment the pointer to compensate for padded R length. */ + pucSigPtr = pucSig + 33; /* Increment the pointer to compensate for padded R length. */ } else { pucSig[ 3 ] = 0x20; /* R length with be 32 bytes. */ ( void ) memcpy( &pucSig[ 4 ], ucTemp, 32 ); /* Copy 32 bytes of R into the signature buffer. */ - pucSigPtr = pucSig + 32; /* Increment the pointer for 32 byte R length. */ + pucSigPtr = pucSig + 32; /* Increment the pointer for 32 byte R length. */ } - pucSigPtr += 4; /* Increment the pointer to offset the SEQUENCE, LENGTH, R-INTEGER, LENGTH. */ + pucSigPtr += 4; /* Increment the pointer to offset the SEQUENCE, LENGTH, R-INTEGER, LENGTH. */ pucSigPtr[ 0 ] = 0x02; /* INTEGER tag for S. */ - pucSigPtr += 1; /* Increment over S INTEGER tag. */ + pucSigPtr += 1; /* Increment over S INTEGER tag. */ /******************* S Component. ****************/ @@ -181,7 +181,7 @@ BaseType_t PKI_pkcs11SignatureTombedTLSSignature( uint8_t * pucSig, pucSig[ 1 ]++; /* Increment the length of the structure to account for the 0x00 pad. */ pucSigPtr[ 0 ] = 0x21; /* Increment the length of the S value to account for the 0x00 pad. */ pucSigPtr[ 1 ] = 0x00; /* Write the 0x00 pad. */ - pucSigPtr += 2; /* pucSigPtr was pointing at the S-length. Increment by 2 to hop over length and 0 padding. */ + pucSigPtr += 2; /* pucSigPtr was pointing at the S-length. Increment by 2 to hop over length and 0 padding. */ ( void ) memcpy( pucSigPtr, &ucTemp[ 32 ], 32 ); /* Copy the S value. */ } @@ -194,7 +194,7 @@ BaseType_t PKI_pkcs11SignatureTombedTLSSignature( uint8_t * pucSig, /* The total signature length is the length of the R and S integers plus 2 bytes for * the SEQUENCE and LENGTH wrapping the entire struct. */ - *pxSigLen = pucSig[ 1 ] + 2UL; + *pxSigLen = pucSig[ 1 ] + 2UL; } return xReturn; diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_doc_parser.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_doc_parser.c index 91aec871f..921610440 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_doc_parser.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_doc_parser.c @@ -50,9 +50,9 @@ bool AwsIotDocParser_FindValue( const char * pAwsIotJsonDocument, { size_t i = 0; size_t jsonValueLength = 0; - char openCharacter = '\0', closeCharacter = '\0'; - int nestingLevel = 0; - bool isWithinQuotes = false; + char openCharacter = '\0', closeCharacter = '\0'; + int nestingLevel = 0; + bool isWithinQuotes = false; /* Validate all the arguments.*/ if( ( pAwsIotJsonDocument == NULL ) || ( pAwsIotJsonKey == NULL ) || @@ -163,7 +163,7 @@ bool AwsIotDocParser_FindValue( const char * pAwsIotJsonDocument, ( pAwsIotJsonDocument[ i + 1 ] == '\"' ) ) { /* Skip the characters \" */ - i += 2; + i += 2; jsonValueLength += 2; } else @@ -185,13 +185,13 @@ bool AwsIotDocParser_FindValue( const char * pAwsIotJsonDocument, /* Set the matching opening and closing characters of a JSON object or array. * The length calculation is performed below. */ case '{': - openCharacter = '{'; - closeCharacter = '}'; + openCharacter = '{'; + closeCharacter = '}'; break; case '[': - openCharacter = '['; - closeCharacter = ']'; + openCharacter = '['; + closeCharacter = ']'; break; /* Calculate the length of a JSON primitive. */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_operation.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_operation.c index b4d262b5e..bf4472ace 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_operation.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_operation.c @@ -50,11 +50,11 @@ bool AwsIot_InitLists( IotListDouble_t * pPendingOperationsList, IOT_FUNCTION_ENTRY( bool, true ); /* Flags to track cleanup. */ - bool operationsMutexCreated = false; + bool operationsMutexCreated = false; bool subscriptionsMutexCreated = false; /* Create the mutex guarding the pending operations list. */ - operationsMutexCreated = IotMutex_Create( pPendingOperationsMutex, false ); + operationsMutexCreated = IotMutex_Create( pPendingOperationsMutex, false ); if( operationsMutexCreated == false ) { @@ -93,10 +93,10 @@ bool AwsIot_GenerateOperationTopic( const AwsIotTopicInfo_t * pTopicInfo, char ** pTopicBuffer, uint16_t * pOperationTopicLength ) { - bool status = true; - uint16_t bufferLength = 0; + bool status = true; + uint16_t bufferLength = 0; uint16_t operationTopicLength = 0; - char * pBuffer = NULL; + char * pBuffer = NULL; /* Calculate the required topic buffer length. */ bufferLength = ( uint16_t ) ( AWS_IOT_TOPIC_PREFIX_LENGTH + @@ -124,19 +124,19 @@ bool AwsIot_GenerateOperationTopic( const AwsIotTopicInfo_t * pTopicInfo, { /* Copy the AWS IoT topic prefix into the topic buffer. */ ( void ) memcpy( pBuffer, AWS_IOT_TOPIC_PREFIX, AWS_IOT_TOPIC_PREFIX_LENGTH ); - operationTopicLength = ( uint16_t ) ( operationTopicLength + AWS_IOT_TOPIC_PREFIX_LENGTH ); + operationTopicLength = ( uint16_t ) ( operationTopicLength + AWS_IOT_TOPIC_PREFIX_LENGTH ); /* Copy the Thing Name into the topic buffer. */ ( void ) memcpy( pBuffer + operationTopicLength, pTopicInfo->pThingName, pTopicInfo->thingNameLength ); - operationTopicLength = ( uint16_t ) ( operationTopicLength + pTopicInfo->thingNameLength ); + operationTopicLength = ( uint16_t ) ( operationTopicLength + pTopicInfo->thingNameLength ); /* Copy the Shadow operation string into the topic buffer. */ ( void ) memcpy( pBuffer + operationTopicLength, pTopicInfo->pOperationName, pTopicInfo->operationNameLength ); - operationTopicLength = ( uint16_t ) ( operationTopicLength + pTopicInfo->operationNameLength ); + operationTopicLength = ( uint16_t ) ( operationTopicLength + pTopicInfo->operationNameLength ); /* Set the output parameters. */ if( *pTopicBuffer == NULL ) diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_parser.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_parser.c index 7b9d8c344..d7b6ce0ed 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_parser.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_parser.c @@ -97,7 +97,7 @@ bool AwsIot_ParseThingName( const char * pTopicName, { IOT_FUNCTION_ENTRY( bool, true ); const char * pThingNameStart = NULL; - size_t thingNameLength = 0; + size_t thingNameLength = 0; /* Check that the topic name is at least as long as the minimum allowed. */ if( topicNameLength < MINIMUM_TOPIC_NAME_LENGTH ) @@ -114,7 +114,7 @@ bool AwsIot_ParseThingName( const char * pTopicName, } /* The Thing Name starts immediately after the topic prefix. */ - pThingNameStart = pTopicName + AWS_IOT_TOPIC_PREFIX_LENGTH; + pThingNameStart = pTopicName + AWS_IOT_TOPIC_PREFIX_LENGTH; /* Calculate the length of the Thing Name, which is terminated with a '/'. */ while( ( thingNameLength + AWS_IOT_TOPIC_PREFIX_LENGTH < ( size_t ) topicNameLength ) && @@ -131,7 +131,7 @@ bool AwsIot_ParseThingName( const char * pTopicName, } /* Set the output parameters. */ - *pThingName = pThingNameStart; + *pThingName = pThingNameStart; *pThingNameLength = thingNameLength; IOT_FUNCTION_EXIT_NO_CLEANUP(); diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_subscription.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_subscription.c index b6586f9fc..e0f76df67 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_subscription.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/common/src/aws_iot_subscription.c @@ -65,28 +65,28 @@ static IotMqttError_t _modifySubscriptions( AwsIotMqttFunction_t mqttOperation, const char * pTopicFilter, uint16_t topicFilterLength ) { - IotMqttError_t status = IOT_MQTT_STATUS_PENDING; + IotMqttError_t status = IOT_MQTT_STATUS_PENDING; IotMqttSubscription_t subscription = IOT_MQTT_SUBSCRIPTION_INITIALIZER; /* Per the AWS IoT documentation, topic subscriptions are QoS 1. */ - subscription.qos = IOT_MQTT_QOS_1; + subscription.qos = IOT_MQTT_QOS_1; /* Set the members of the subscription parameter. */ - subscription.pTopicFilter = pTopicFilter; - subscription.topicFilterLength = topicFilterLength; + subscription.pTopicFilter = pTopicFilter; + subscription.topicFilterLength = topicFilterLength; subscription.callback.pCallbackContext = NULL; - subscription.callback.function = pSubscriptionInfo->callbackFunction; + subscription.callback.function = pSubscriptionInfo->callbackFunction; /* Call the MQTT operation function. * Subscription count is 1 in this case. * None of the flags are set in this call. Hence 0 is passed for flags. * Please refer to documentation for AwsIotMqttFunction_t for more details. */ - status = mqttOperation( pSubscriptionInfo->mqttConnection, - &subscription, - 1, - 0, - pSubscriptionInfo->timeout ); + status = mqttOperation( pSubscriptionInfo->mqttConnection, + &subscription, + 1, + 0, + pSubscriptionInfo->timeout ); return status; } @@ -97,8 +97,8 @@ IotMqttError_t AwsIot_ModifySubscriptions( AwsIotMqttFunction_t mqttOperation, const AwsIotSubscriptionInfo_t * pSubscriptionInfo ) { IOT_FUNCTION_ENTRY( IotMqttError_t, IOT_MQTT_STATUS_PENDING ); - IotMqttError_t acceptedStatus = IOT_MQTT_STATUS_PENDING; - uint16_t topicFilterLength = 0; + IotMqttError_t acceptedStatus = IOT_MQTT_STATUS_PENDING; + uint16_t topicFilterLength = 0; /* Place the topic "accepted" suffix at the end of the topic buffer. */ ( void ) memcpy( pSubscriptionInfo->pTopicFilterBase @@ -109,10 +109,10 @@ IotMqttError_t AwsIot_ModifySubscriptions( AwsIotMqttFunction_t mqttOperation, + AWS_IOT_ACCEPTED_SUFFIX_LENGTH ); /* Modify the subscription to the "accepted" topic. */ - acceptedStatus = _modifySubscriptions( mqttOperation, - pSubscriptionInfo, - pSubscriptionInfo->pTopicFilterBase, - topicFilterLength ); + acceptedStatus = _modifySubscriptions( mqttOperation, + pSubscriptionInfo, + pSubscriptionInfo->pTopicFilterBase, + topicFilterLength ); if( acceptedStatus != IOT_MQTT_SUCCESS ) { @@ -128,10 +128,10 @@ IotMqttError_t AwsIot_ModifySubscriptions( AwsIotMqttFunction_t mqttOperation, + AWS_IOT_REJECTED_SUFFIX_LENGTH ); /* Modify the subscription to the "rejected" topic. */ - status = _modifySubscriptions( mqttOperation, - pSubscriptionInfo, - pSubscriptionInfo->pTopicFilterBase, - topicFilterLength ); + status = _modifySubscriptions( mqttOperation, + pSubscriptionInfo, + pSubscriptionInfo->pTopicFilterBase, + topicFilterLength ); IOT_FUNCTION_CLEANUP_BEGIN(); diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/include/types/aws_iot_jobs_types.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/include/types/aws_iot_jobs_types.h index b3924133f..b2886f7c5 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/include/types/aws_iot_jobs_types.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/include/types/aws_iot_jobs_types.h @@ -892,14 +892,14 @@ typedef struct AwsIotJobsUpdateInfo #define AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER \ { .pClientToken = AWS_IOT_JOBS_CLIENT_TOKEN_AUTOGENERATE } /** @brief Initializer for #AwsIotJobsUpdateInfo_t. */ -#define AWS_IOT_JOBS_UPDATE_INFO_INITIALIZER \ - { .newStatus = AWS_IOT_JOB_STATE_IN_PROGRESS, \ - .expectedVersion = AWS_IOT_JOBS_NO_VERSION, \ - .executionNumber = AWS_IOT_JOBS_NO_EXECUTION_NUMBER, \ - .stepTimeoutInMinutes = AWS_IOT_JOBS_NO_TIMEOUT, \ - .includeJobExecutionState = false, \ - .includeJobDocument = false, \ - .pStatusDetails = AWS_IOT_JOBS_NO_STATUS_DETAILS } +#define AWS_IOT_JOBS_UPDATE_INFO_INITIALIZER \ + { .newStatus = AWS_IOT_JOB_STATE_IN_PROGRESS, \ + .expectedVersion = AWS_IOT_JOBS_NO_VERSION, \ + .executionNumber = AWS_IOT_JOBS_NO_EXECUTION_NUMBER, \ + .stepTimeoutInMinutes = AWS_IOT_JOBS_NO_TIMEOUT, \ + .includeJobExecutionState = false, \ + .includeJobDocument = false, \ + .pStatusDetails = AWS_IOT_JOBS_NO_STATUS_DETAILS } #define AWS_IOT_JOBS_OPERATION_INITIALIZER NULL /**< @brief Initializer for #AwsIotJobsOperation_t. */ #define AWS_IOT_JOBS_RESPONSE_INITIALIZER { 0 } /**< @brief Initializer for #AwsIotJobsResponse_t. */ /* @[define_jobs_initializers] */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_api.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_api.c index dd4a01375..a3ba636ed 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_api.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_api.c @@ -190,12 +190,12 @@ static void _callbackWrapperCommon( _jobsCallbackType_t type, * * API functions will fail if @ref jobs_function_init was not called. */ -static uint32_t _initCalled = 0; +static uint32_t _initCalled = 0; /** * @brief Timeout used for MQTT operations. */ -uint32_t _AwsIotJobsMqttTimeoutMs = AWS_IOT_JOBS_DEFAULT_MQTT_TIMEOUT_MS; +uint32_t _AwsIotJobsMqttTimeoutMs = AWS_IOT_JOBS_DEFAULT_MQTT_TIMEOUT_MS; #if LIBRARY_LOG_LEVEL > IOT_LOG_NONE @@ -483,9 +483,9 @@ static AwsIotJobsError_t _setCallbackCommon( IotMqttConnection_t mqttConnection, const AwsIotJobsCallbackInfo_t * pCallbackInfo ) { IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_SUCCESS ); - bool subscriptionMutexLocked = false; - _jobsSubscription_t * pSubscription = NULL; - int32_t callbackIndex = 0; + bool subscriptionMutexLocked = false; + _jobsSubscription_t * pSubscription = NULL; + int32_t callbackIndex = 0; /* Check that AwsIotJobs_Init was called. */ if( _checkInit() == false ) @@ -535,7 +535,7 @@ static AwsIotJobsError_t _setCallbackCommon( IotMqttConnection_t mqttConnection, /* Check for an existing subscription. This function will attempt to allocate * a new subscription if not found. */ - pSubscription = _AwsIotJobs_FindSubscription( pThingName, thingNameLength, true ); + pSubscription = _AwsIotJobs_FindSubscription( pThingName, thingNameLength, true ); if( pSubscription == NULL ) { @@ -545,7 +545,7 @@ static AwsIotJobsError_t _setCallbackCommon( IotMqttConnection_t mqttConnection, } /* Get the index of the callback element to modify. */ - callbackIndex = _getCallbackIndex( type, pSubscription, pCallbackInfo ); + callbackIndex = _getCallbackIndex( type, pSubscription, pCallbackInfo ); switch( callbackIndex ) { @@ -652,29 +652,29 @@ static AwsIotJobsError_t _modifyCallbackSubscriptions( IotMqttConnection_t mqttC AwsIotMqttFunction_t mqttOperation ) { IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_SUCCESS ); - int32_t i = 0; - IotMqttError_t mqttStatus = IOT_MQTT_STATUS_PENDING; - IotMqttSubscription_t subscription = IOT_MQTT_SUBSCRIPTION_INITIALIZER; - AwsIotTopicInfo_t topicInfo = { 0 }; - char * pTopicFilter = NULL; - uint16_t topicFilterLength = 0; + int32_t i = 0; + IotMqttError_t mqttStatus = IOT_MQTT_STATUS_PENDING; + IotMqttSubscription_t subscription = IOT_MQTT_SUBSCRIPTION_INITIALIZER; + AwsIotTopicInfo_t topicInfo = { 0 }; + char * pTopicFilter = NULL; + uint16_t topicFilterLength = 0; /* Lookup table for Jobs callback suffixes. */ - const char * const pCallbackSuffix[ JOBS_CALLBACK_COUNT ] = + const char * const pCallbackSuffix[ JOBS_CALLBACK_COUNT ] = { JOBS_NOTIFY_PENDING_CALLBACK_STRING, /* Notify pending callback. */ JOBS_NOTIFY_NEXT_CALLBACK_STRING /* Notify next callback. */ }; /* Lookup table for Jobs callback suffix lengths. */ - const uint16_t pCallbackSuffixLength[ JOBS_CALLBACK_COUNT ] = + const uint16_t pCallbackSuffixLength[ JOBS_CALLBACK_COUNT ] = { JOBS_NOTIFY_PENDING_CALLBACK_STRING_LENGTH, /* Notify pending callback. */ JOBS_NOTIFY_NEXT_CALLBACK_STRING_LENGTH /* Notify next callback. */ }; /* Lookup table for Jobs callback function wrappers. */ - const AwsIotMqttCallbackFunction_t pCallbackWrapper[ JOBS_CALLBACK_COUNT ] = + const AwsIotMqttCallbackFunction_t pCallbackWrapper[ JOBS_CALLBACK_COUNT ] = { _notifyPendingCallbackWrapper, /* Notify pending callback. */ _notifyNextCallbackWrapper, /* Notify next callback. */ @@ -701,12 +701,12 @@ static AwsIotJobsError_t _modifyCallbackSubscriptions( IotMqttConnection_t mqttC } /* Generate the topic for the MQTT subscription. */ - topicInfo.pThingName = pSubscription->pThingName; - topicInfo.thingNameLength = pSubscription->thingNameLength; - topicInfo.longestSuffixLength = JOBS_LONGEST_SUFFIX_LENGTH; - topicInfo.mallocString = AwsIotJobs_MallocString; - topicInfo.pOperationName = pCallbackSuffix[ type ]; - topicInfo.operationNameLength = pCallbackSuffixLength[ type ]; + topicInfo.pThingName = pSubscription->pThingName; + topicInfo.thingNameLength = pSubscription->thingNameLength; + topicInfo.longestSuffixLength = JOBS_LONGEST_SUFFIX_LENGTH; + topicInfo.mallocString = AwsIotJobs_MallocString; + topicInfo.pOperationName = pCallbackSuffix[ type ]; + topicInfo.operationNameLength = pCallbackSuffixLength[ type ]; if( AwsIot_GenerateOperationTopic( &topicInfo, &pTopicFilter, @@ -721,18 +721,18 @@ static AwsIotJobsError_t _modifyCallbackSubscriptions( IotMqttConnection_t mqttC pTopicFilter ); /* Set the members of the MQTT subscription. */ - subscription.qos = IOT_MQTT_QOS_1; - subscription.pTopicFilter = pTopicFilter; - subscription.topicFilterLength = topicFilterLength; + subscription.qos = IOT_MQTT_QOS_1; + subscription.pTopicFilter = pTopicFilter; + subscription.topicFilterLength = topicFilterLength; subscription.callback.pCallbackContext = NULL; - subscription.callback.function = pCallbackWrapper[ type ]; + subscription.callback.function = pCallbackWrapper[ type ]; /* Call the MQTT operation function. */ - mqttStatus = mqttOperation( mqttConnection, - &subscription, - 1, - 0, - _AwsIotJobsMqttTimeoutMs ); + mqttStatus = mqttOperation( mqttConnection, + &subscription, + 1, + 0, + _AwsIotJobsMqttTimeoutMs ); /* Check the result of the MQTT operation. */ if( mqttStatus != IOT_MQTT_SUCCESS ) @@ -806,12 +806,12 @@ static void _notifyNextCallbackWrapper( void * pArgument, static void _callbackWrapperCommon( _jobsCallbackType_t type, IotMqttCallbackParam_t * pMessage ) { - int32_t callbackIndex = 0; - AwsIotJobsCallbackInfo_t callbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER; + int32_t callbackIndex = 0; + AwsIotJobsCallbackInfo_t callbackInfo = AWS_IOT_JOBS_CALLBACK_INFO_INITIALIZER; AwsIotJobsCallbackParam_t callbackParam = { .callbackType = ( AwsIotJobsCallbackType_t ) 0 }; - _jobsSubscription_t * pSubscription = NULL; - const char * pThingName = NULL; - size_t thingNameLength = 0; + _jobsSubscription_t * pSubscription = NULL; + const char * pThingName = NULL; + size_t thingNameLength = 0; /* Parse the Thing Name from the topic. */ if( AwsIot_ParseThingName( pMessage->u.message.info.pTopicName, @@ -851,13 +851,13 @@ static void _callbackWrapperCommon( _jobsCallbackType_t type, if( callbackInfo.function != NULL ) { /* Set the callback type. Jobs callbacks are enumerated after the operations. */ - callbackParam.callbackType = ( AwsIotJobsCallbackType_t ) ( type + JOBS_OPERATION_COUNT ); + callbackParam.callbackType = ( AwsIotJobsCallbackType_t ) ( type + JOBS_OPERATION_COUNT ); /* Set the remaining members of the callback param. */ - callbackParam.mqttConnection = pMessage->mqttConnection; - callbackParam.pThingName = pThingName; - callbackParam.thingNameLength = thingNameLength; - callbackParam.u.callback.pDocument = pMessage->u.message.info.pPayload; + callbackParam.mqttConnection = pMessage->mqttConnection; + callbackParam.pThingName = pThingName; + callbackParam.thingNameLength = thingNameLength; + callbackParam.u.callback.pDocument = pMessage->u.message.info.pPayload; callbackParam.u.callback.documentLength = pMessage->u.message.info.payloadLength; /* Invoke the callback function. */ @@ -886,8 +886,8 @@ static void _callbackWrapperCommon( _jobsCallbackType_t type, AwsIotJobsError_t AwsIotJobs_Init( uint32_t mqttTimeoutMs ) { - AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS; - bool listInitStatus = false; + AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS; + bool listInitStatus = false; if( _initCalled == 0 ) { @@ -930,7 +930,7 @@ void AwsIotJobs_Cleanup( void ) { if( _initCalled == 1 ) { - _initCalled = 0; + _initCalled = 0; /* Remove and free all items in the Jobs pending operation list. */ IotMutex_Lock( &_AwsIotJobsPendingOperationsMutex ); @@ -1030,7 +1030,7 @@ AwsIotJobsError_t AwsIotJobs_GetPendingSync( const AwsIotJobsRequestInfo_t * pRe uint32_t timeoutMs, AwsIotJobsResponse_t * const pJobsResponse ) { - AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING; + AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING; AwsIotJobsOperation_t getPendingOperation = AWS_IOT_JOBS_OPERATION_INITIALIZER; /* Set the waitable flag. */ @@ -1062,7 +1062,7 @@ AwsIotJobsError_t AwsIotJobs_StartNextAsync( const AwsIotJobsRequestInfo_t * pRe AwsIotJobsOperation_t * const pStartNextOperation ) { IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_STATUS_PENDING ); - _jobsOperation_t * pOperation = NULL; + _jobsOperation_t * pOperation = NULL; _jsonRequestContents_t requestContents = { 0 }; /* Check that AwsIotJobs_Init was called. */ @@ -1072,11 +1072,11 @@ AwsIotJobsError_t AwsIotJobs_StartNextAsync( const AwsIotJobsRequestInfo_t * pRe } /* Check request info. */ - status = _validateRequestInfo( JOBS_START_NEXT, - pRequestInfo, - flags, - pCallbackInfo, - pStartNextOperation ); + status = _validateRequestInfo( JOBS_START_NEXT, + pRequestInfo, + flags, + pCallbackInfo, + pStartNextOperation ); if( status != AWS_IOT_JOBS_SUCCESS ) { @@ -1084,8 +1084,8 @@ AwsIotJobsError_t AwsIotJobs_StartNextAsync( const AwsIotJobsRequestInfo_t * pRe } /* Check update info. */ - status = _validateUpdateInfo( JOBS_START_NEXT, - pUpdateInfo ); + status = _validateUpdateInfo( JOBS_START_NEXT, + pUpdateInfo ); if( status != AWS_IOT_JOBS_SUCCESS ) { @@ -1095,12 +1095,12 @@ AwsIotJobsError_t AwsIotJobs_StartNextAsync( const AwsIotJobsRequestInfo_t * pRe /* Allocate a new Jobs operation. */ requestContents.pUpdateInfo = pUpdateInfo; - status = _AwsIotJobs_CreateOperation( JOBS_START_NEXT, - pRequestInfo, - &requestContents, - flags, - pCallbackInfo, - &pOperation ); + status = _AwsIotJobs_CreateOperation( JOBS_START_NEXT, + pRequestInfo, + &requestContents, + flags, + pCallbackInfo, + &pOperation ); if( status != AWS_IOT_JOBS_SUCCESS ) { @@ -1117,7 +1117,7 @@ AwsIotJobsError_t AwsIotJobs_StartNextAsync( const AwsIotJobsRequestInfo_t * pRe /* Process the Jobs operation. This subscribes to any required topics and * sends the MQTT message for the Jobs operation. */ - status = _AwsIotJobs_ProcessOperation( pRequestInfo, pOperation ); + status = _AwsIotJobs_ProcessOperation( pRequestInfo, pOperation ); /* If the Jobs operation failed, clear the now invalid reference. */ if( ( status != AWS_IOT_JOBS_STATUS_PENDING ) && ( pStartNextOperation != NULL ) ) @@ -1136,7 +1136,7 @@ AwsIotJobsError_t AwsIotJobs_StartNextSync( const AwsIotJobsRequestInfo_t * pReq uint32_t timeoutMs, AwsIotJobsResponse_t * const pJobsResponse ) { - AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING; + AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING; AwsIotJobsOperation_t startNextOperation = AWS_IOT_JOBS_OPERATION_INITIALIZER; /* Set the waitable flag. */ @@ -1170,7 +1170,7 @@ AwsIotJobsError_t AwsIotJobs_DescribeAsync( const AwsIotJobsRequestInfo_t * pReq AwsIotJobsOperation_t * const pDescribeOperation ) { IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_STATUS_PENDING ); - _jobsOperation_t * pOperation = NULL; + _jobsOperation_t * pOperation = NULL; _jsonRequestContents_t requestContents = { 0 }; /* Check that AwsIotJobs_Init was called. */ @@ -1180,11 +1180,11 @@ AwsIotJobsError_t AwsIotJobs_DescribeAsync( const AwsIotJobsRequestInfo_t * pReq } /* Check request info. */ - status = _validateRequestInfo( JOBS_DESCRIBE, - pRequestInfo, - flags, - pCallbackInfo, - pDescribeOperation ); + status = _validateRequestInfo( JOBS_DESCRIBE, + pRequestInfo, + flags, + pCallbackInfo, + pDescribeOperation ); if( status != AWS_IOT_JOBS_SUCCESS ) { @@ -1192,15 +1192,15 @@ AwsIotJobsError_t AwsIotJobs_DescribeAsync( const AwsIotJobsRequestInfo_t * pReq } /* Allocate a new Jobs operation. */ - requestContents.describe.executionNumber = executionNumber; + requestContents.describe.executionNumber = executionNumber; requestContents.describe.includeJobDocument = includeJobDocument; - status = _AwsIotJobs_CreateOperation( JOBS_DESCRIBE, - pRequestInfo, - &requestContents, - flags, - pCallbackInfo, - &pOperation ); + status = _AwsIotJobs_CreateOperation( JOBS_DESCRIBE, + pRequestInfo, + &requestContents, + flags, + pCallbackInfo, + &pOperation ); if( status != AWS_IOT_JOBS_SUCCESS ) { @@ -1217,7 +1217,7 @@ AwsIotJobsError_t AwsIotJobs_DescribeAsync( const AwsIotJobsRequestInfo_t * pReq /* Process the Jobs operation. This subscribes to any required topics and * sends the MQTT message for the Jobs operation. */ - status = _AwsIotJobs_ProcessOperation( pRequestInfo, pOperation ); + status = _AwsIotJobs_ProcessOperation( pRequestInfo, pOperation ); /* If the Jobs operation failed, clear the now invalid reference. */ if( ( status != AWS_IOT_JOBS_STATUS_PENDING ) && ( pDescribeOperation != NULL ) ) @@ -1237,7 +1237,7 @@ AwsIotJobsError_t AwsIotJobs_DescribeSync( const AwsIotJobsRequestInfo_t * pRequ uint32_t timeoutMs, AwsIotJobsResponse_t * const pJobsResponse ) { - AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING; + AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING; AwsIotJobsOperation_t describeOperation = AWS_IOT_JOBS_OPERATION_INITIALIZER; /* Set the waitable flag. */ @@ -1271,7 +1271,7 @@ AwsIotJobsError_t AwsIotJobs_UpdateAsync( const AwsIotJobsRequestInfo_t * pReque AwsIotJobsOperation_t * const pUpdateOperation ) { IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_STATUS_PENDING ); - _jobsOperation_t * pOperation = NULL; + _jobsOperation_t * pOperation = NULL; _jsonRequestContents_t requestContents = { 0 }; /* Check that AwsIotJobs_Init was called. */ @@ -1281,11 +1281,11 @@ AwsIotJobsError_t AwsIotJobs_UpdateAsync( const AwsIotJobsRequestInfo_t * pReque } /* Check request info. */ - status = _validateRequestInfo( JOBS_UPDATE, - pRequestInfo, - flags, - pCallbackInfo, - pUpdateOperation ); + status = _validateRequestInfo( JOBS_UPDATE, + pRequestInfo, + flags, + pCallbackInfo, + pUpdateOperation ); if( status != AWS_IOT_JOBS_SUCCESS ) { @@ -1293,8 +1293,8 @@ AwsIotJobsError_t AwsIotJobs_UpdateAsync( const AwsIotJobsRequestInfo_t * pReque } /* Check update info. */ - status = _validateUpdateInfo( JOBS_UPDATE, - pUpdateInfo ); + status = _validateUpdateInfo( JOBS_UPDATE, + pUpdateInfo ); if( status != AWS_IOT_JOBS_SUCCESS ) { @@ -1304,12 +1304,12 @@ AwsIotJobsError_t AwsIotJobs_UpdateAsync( const AwsIotJobsRequestInfo_t * pReque /* Allocate a new Jobs operation. */ requestContents.pUpdateInfo = pUpdateInfo; - status = _AwsIotJobs_CreateOperation( JOBS_UPDATE, - pRequestInfo, - &requestContents, - flags, - pCallbackInfo, - &pOperation ); + status = _AwsIotJobs_CreateOperation( JOBS_UPDATE, + pRequestInfo, + &requestContents, + flags, + pCallbackInfo, + &pOperation ); if( status != AWS_IOT_JOBS_SUCCESS ) { @@ -1326,7 +1326,7 @@ AwsIotJobsError_t AwsIotJobs_UpdateAsync( const AwsIotJobsRequestInfo_t * pReque /* Process the Jobs operation. This subscribes to any required topics and * sends the MQTT message for the Jobs operation. */ - status = _AwsIotJobs_ProcessOperation( pRequestInfo, pOperation ); + status = _AwsIotJobs_ProcessOperation( pRequestInfo, pOperation ); /* If the Jobs operation failed, clear the now invalid reference. */ if( ( status != AWS_IOT_JOBS_STATUS_PENDING ) && ( pUpdateOperation != NULL ) ) @@ -1345,7 +1345,7 @@ AwsIotJobsError_t AwsIotJobs_UpdateSync( const AwsIotJobsRequestInfo_t * pReques uint32_t timeoutMs, AwsIotJobsResponse_t * const pJobsResponse ) { - AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING; + AwsIotJobsError_t status = AWS_IOT_JOBS_STATUS_PENDING; AwsIotJobsOperation_t updateOperation = AWS_IOT_JOBS_OPERATION_INITIALIZER; /* Set the waitable flag. */ @@ -1439,7 +1439,7 @@ AwsIotJobsError_t AwsIotJobs_Wait( AwsIotJobsOperation_t operation, AwsIotJobs_Assert( operation->pJobsResponse != NULL ); AwsIotJobs_Assert( operation->jobsResponseLength > 0 ); - pJobsResponse->pJobsResponse = operation->pJobsResponse; + pJobsResponse->pJobsResponse = operation->pJobsResponse; pJobsResponse->jobsResponseLength = operation->jobsResponseLength; } diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_operation.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_operation.c index 94c175fa3..8810d4606 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_operation.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_operation.c @@ -173,7 +173,7 @@ static AwsIotJobsError_t _findSubscription( const AwsIotJobsRequestInfo_t * pReq * @brief List of active Jobs operations awaiting a response from the Jobs * service. */ -IotListDouble_t _AwsIotJobsPendingOperations = { 0 }; +IotListDouble_t _AwsIotJobsPendingOperations = { 0 }; /** * @brief Protects #_AwsIotJobsPendingOperations from concurrent access. @@ -189,20 +189,20 @@ static bool _jobsOperation_match( const IotLink_t * pOperationLink, * must never be NULL. */ AwsIotJobs_Assert( pOperationLink != NULL ); - _jobsOperation_t * pOperation = IotLink_Container( _jobsOperation_t, - pOperationLink, - link ); - _operationMatchParams_t * pParam = ( _operationMatchParams_t * ) pMatch; - _jobsSubscription_t * pSubscription = pOperation->pSubscription; - const char * pClientToken = NULL; - size_t clientTokenLength = 0; + _jobsOperation_t * pOperation = IotLink_Container( _jobsOperation_t, + pOperationLink, + link ); + _operationMatchParams_t * pParam = ( _operationMatchParams_t * ) pMatch; + _jobsSubscription_t * pSubscription = pOperation->pSubscription; + const char * pClientToken = NULL; + size_t clientTokenLength = 0; /* Check for matching Thing Name and operation type. */ - bool match = ( pOperation->type == pParam->type ) && - ( pParam->thingNameLength == pSubscription->thingNameLength ) && - ( strncmp( pParam->pThingName, - pSubscription->pThingName, - pParam->thingNameLength ) == 0 ); + bool match = ( pOperation->type == pParam->type ) && + ( pParam->thingNameLength == pSubscription->thingNameLength ) && + ( strncmp( pParam->pThingName, + pSubscription->pThingName, + pParam->thingNameLength ) == 0 ); if( match == true ) { @@ -283,15 +283,15 @@ static void _updateCallback( void * pArgument, static void _commonOperationCallback( _jobsOperationType_t type, IotMqttCallbackParam_t * pMessage ) { - _jobsOperation_t * pOperation = NULL; - IotLink_t * pOperationLink = NULL; - _operationMatchParams_t param = { 0 }; - AwsIotStatus_t status = AWS_IOT_UNKNOWN; - uint32_t flags = 0; + _jobsOperation_t * pOperation = NULL; + IotLink_t * pOperationLink = NULL; + _operationMatchParams_t param = { 0 }; + AwsIotStatus_t status = AWS_IOT_UNKNOWN; + uint32_t flags = 0; /* Set operation type and response. */ - param.type = type; - param.pResponse = pMessage->u.message.info.pPayload; + param.type = type; + param.pResponse = pMessage->u.message.info.pPayload; param.responseLength = pMessage->u.message.info.payloadLength; /* Parse the Thing Name from the MQTT topic name. */ @@ -307,10 +307,10 @@ static void _commonOperationCallback( _jobsOperationType_t type, IotMutex_Lock( &( _AwsIotJobsPendingOperationsMutex ) ); /* Search for a matching pending operation. */ - pOperationLink = IotListDouble_FindFirstMatch( &_AwsIotJobsPendingOperations, - NULL, - _jobsOperation_match, - ¶m ); + pOperationLink = IotListDouble_FindFirstMatch( &_AwsIotJobsPendingOperations, + NULL, + _jobsOperation_match, + ¶m ); /* Find and remove the first Jobs operation of the given type. */ if( pOperationLink == NULL ) @@ -329,7 +329,7 @@ static void _commonOperationCallback( _jobsOperationType_t type, pOperation = IotLink_Container( _jobsOperation_t, pOperationLink, link ); /* Copy the flags from the Jobs operation. */ - flags = pOperation->flags; + flags = pOperation->flags; /* Remove a non-waitable operation from the pending operation list. * Waitable operations are removed by the Wait function. */ @@ -341,8 +341,8 @@ static void _commonOperationCallback( _jobsOperationType_t type, } /* Parse the status from the topic name. */ - status = AwsIot_ParseStatus( pMessage->u.message.info.pTopicName, - pMessage->u.message.info.topicNameLength ); + status = AwsIot_ParseStatus( pMessage->u.message.info.pTopicName, + pMessage->u.message.info.topicNameLength ); switch( status ) { @@ -383,8 +383,8 @@ static void _commonOperationCallback( _jobsOperationType_t type, static void _notifyCompletion( _jobsOperation_t * pOperation ) { - AwsIotJobsCallbackParam_t callbackParam = { .callbackType = ( AwsIotJobsCallbackType_t ) 0 }; - _jobsSubscription_t * pSubscription = pOperation->pSubscription, + AwsIotJobsCallbackParam_t callbackParam = { .callbackType = ( AwsIotJobsCallbackType_t ) 0 }; + _jobsSubscription_t * pSubscription = pOperation->pSubscription, * pRemovedSubscription = NULL; /* If the operation is waiting, post to its wait semaphore and return. */ @@ -415,13 +415,13 @@ static void _notifyCompletion( _jobsOperation_t * pOperation ) if( pOperation->notify.callback.function != NULL ) { /* Set the common members of the callback parameter. */ - callbackParam.callbackType = ( AwsIotJobsCallbackType_t ) pOperation->type; - callbackParam.mqttConnection = pOperation->mqttConnection; - callbackParam.pThingName = pSubscription->pThingName; - callbackParam.thingNameLength = pSubscription->thingNameLength; - callbackParam.u.operation.result = pOperation->status; - callbackParam.u.operation.reference = pOperation; - callbackParam.u.operation.pResponse = pOperation->pJobsResponse; + callbackParam.callbackType = ( AwsIotJobsCallbackType_t ) pOperation->type; + callbackParam.mqttConnection = pOperation->mqttConnection; + callbackParam.pThingName = pSubscription->pThingName; + callbackParam.thingNameLength = pSubscription->thingNameLength; + callbackParam.u.operation.result = pOperation->status; + callbackParam.u.operation.reference = pOperation; + callbackParam.u.operation.pResponse = pOperation->pJobsResponse; callbackParam.u.operation.responseLength = pOperation->jobsResponseLength; pOperation->notify.callback.function( pOperation->notify.callback.pCallbackContext, @@ -446,8 +446,8 @@ static AwsIotJobsError_t _findSubscription( const AwsIotJobsRequestInfo_t * pReq _jobsOperation_t * pOperation, bool * pFreeTopicBuffer ) { - AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS; - _jobsSubscription_t * pSubscription = NULL; + AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS; + _jobsSubscription_t * pSubscription = NULL; /* Lookup table for Jobs operation callbacks. */ const AwsIotMqttCallbackFunction_t jobsCallbacks[ JOBS_OPERATION_COUNT ] = @@ -490,7 +490,7 @@ static AwsIotJobsError_t _findSubscription( const AwsIotJobsRequestInfo_t * pReq pSubscription->pTopicBuffer = pTopicBuffer; /* Don't free the topic buffer if it was allocated to the subscription. */ - *pFreeTopicBuffer = false; + *pFreeTopicBuffer = false; } else { @@ -499,10 +499,10 @@ static AwsIotJobsError_t _findSubscription( const AwsIotJobsRequestInfo_t * pReq /* Increment the reference count for this Jobs operation's * subscriptions. */ - status = _AwsIotJobs_IncrementReferences( pOperation, - pTopicBuffer, - operationTopicLength, - jobsCallbacks[ pOperation->type ] ); + status = _AwsIotJobs_IncrementReferences( pOperation, + pTopicBuffer, + operationTopicLength, + jobsCallbacks[ pOperation->type ] ); if( status != AWS_IOT_JOBS_SUCCESS ) { @@ -529,8 +529,8 @@ AwsIotJobsError_t _AwsIotJobs_CreateOperation( _jobsOperationType_t type, _jobsOperation_t ** pNewOperation ) { IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_SUCCESS ); - size_t operationSize = sizeof( _jobsOperation_t ); - _jobsOperation_t * pOperation = NULL; + size_t operationSize = sizeof( _jobsOperation_t ); + _jobsOperation_t * pOperation = NULL; IotLogDebug( "Creating operation record for Jobs %s.", _pAwsIotJobsOperationNames[ type ] ); @@ -547,7 +547,7 @@ AwsIotJobsError_t _AwsIotJobs_CreateOperation( _jobsOperationType_t type, } /* Allocate memory for a new Jobs operation. */ - pOperation = AwsIotJobs_MallocOperation( operationSize ); + pOperation = AwsIotJobs_MallocOperation( operationSize ); if( pOperation == NULL ) { @@ -561,9 +561,9 @@ AwsIotJobsError_t _AwsIotJobs_CreateOperation( _jobsOperationType_t type, ( void ) memset( pOperation, 0x00, sizeof( _jobsOperation_t ) ); /* Set the remaining common members of the Jobs operation. */ - pOperation->type = type; - pOperation->flags = flags; - pOperation->status = AWS_IOT_JOBS_STATUS_PENDING; + pOperation->type = type; + pOperation->flags = flags; + pOperation->status = AWS_IOT_JOBS_STATUS_PENDING; pOperation->mallocResponse = pRequestInfo->mallocResponse; /* Save the Job ID for DESCRIBE and UPDATE operations. */ @@ -575,10 +575,10 @@ AwsIotJobsError_t _AwsIotJobs_CreateOperation( _jobsOperationType_t type, } /* Generate a Jobs request document. */ - status = _AwsIotJobs_GenerateJsonRequest( type, - pRequestInfo, - pRequestContents, - pOperation ); + status = _AwsIotJobs_GenerateJsonRequest( type, + pRequestInfo, + pRequestContents, + pOperation ); if( status != AWS_IOT_JOBS_SUCCESS ) { @@ -668,13 +668,13 @@ AwsIotJobsError_t _AwsIotJobs_GenerateJobsTopic( _jobsOperationType_t type, char ** pTopicBuffer, uint16_t * pOperationTopicLength ) { - AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS; - AwsIotTopicInfo_t topicInfo = { 0 }; - char pJobOperationName[ JOBS_LONGEST_SUFFIX_LENGTH ] = { 0 }; - uint16_t operationNameLength = 0; + AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS; + AwsIotTopicInfo_t topicInfo = { 0 }; + char pJobOperationName[ JOBS_LONGEST_SUFFIX_LENGTH ] = { 0 }; + uint16_t operationNameLength = 0; /* Lookup table for Jobs operation strings. */ - const char * const pOperationString[ JOBS_OPERATION_COUNT ] = + const char * const pOperationString[ JOBS_OPERATION_COUNT ] = { JOBS_GET_PENDING_OPERATION_STRING, /* Jobs get pending operation. */ JOBS_START_NEXT_OPERATION_STRING, /* Jobs start next operation. */ @@ -683,7 +683,7 @@ AwsIotJobsError_t _AwsIotJobs_GenerateJobsTopic( _jobsOperationType_t type, }; /* Lookup table for Jobs operation string lengths. */ - const uint16_t pOperationStringLength[ JOBS_OPERATION_COUNT ] = + const uint16_t pOperationStringLength[ JOBS_OPERATION_COUNT ] = { JOBS_GET_PENDING_OPERATION_STRING_LENGTH, /* Jobs get pending operation */ JOBS_START_NEXT_OPERATION_STRING_LENGTH, /* Jobs start next operation. */ @@ -696,10 +696,10 @@ AwsIotJobsError_t _AwsIotJobs_GenerateJobsTopic( _jobsOperationType_t type, ( type == JOBS_DESCRIBE ) || ( type == JOBS_UPDATE ) ); /* Set the members needed to generate an operation topic. */ - topicInfo.pThingName = pRequestInfo->pThingName; - topicInfo.thingNameLength = pRequestInfo->thingNameLength; + topicInfo.pThingName = pRequestInfo->pThingName; + topicInfo.thingNameLength = pRequestInfo->thingNameLength; topicInfo.longestSuffixLength = JOBS_LONGEST_SUFFIX_LENGTH; - topicInfo.mallocString = AwsIotJobs_MallocString; + topicInfo.mallocString = AwsIotJobs_MallocString; /* Job operations that require a Job ID require additional processing to * create an operation name with the Job ID. */ @@ -711,24 +711,24 @@ AwsIotJobsError_t _AwsIotJobs_GenerateJobsTopic( _jobsOperationType_t type, /* Construct the Jobs operation name with the Job ID. */ ( void ) memcpy( pJobOperationName, "/jobs/", 6 ); - operationNameLength = 6; + operationNameLength = 6; ( void ) memcpy( pJobOperationName + operationNameLength, pRequestInfo->pJobId, pRequestInfo->jobIdLength ); - operationNameLength = ( uint16_t ) ( pRequestInfo->jobIdLength + operationNameLength ); + operationNameLength = ( uint16_t ) ( pRequestInfo->jobIdLength + operationNameLength ); ( void ) memcpy( pJobOperationName + operationNameLength, pOperationString[ type ], pOperationStringLength[ type ] ); - operationNameLength = ( uint16_t ) ( operationNameLength + pOperationStringLength[ type ] ); + operationNameLength = ( uint16_t ) ( operationNameLength + pOperationStringLength[ type ] ); - topicInfo.pOperationName = pJobOperationName; + topicInfo.pOperationName = pJobOperationName; topicInfo.operationNameLength = operationNameLength; } else { - topicInfo.pOperationName = pOperationString[ type ]; + topicInfo.pOperationName = pOperationString[ type ]; topicInfo.operationNameLength = pOperationStringLength[ type ]; } @@ -748,11 +748,11 @@ AwsIotJobsError_t _AwsIotJobs_ProcessOperation( const AwsIotJobsRequestInfo_t * _jobsOperation_t * pOperation ) { IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_STATUS_PENDING ); - char * pTopicBuffer = NULL; - uint16_t operationTopicLength = 0; - bool freeTopicBuffer = true; - IotMqttPublishInfo_t publishInfo = IOT_MQTT_PUBLISH_INFO_INITIALIZER; - IotMqttError_t publishStatus = IOT_MQTT_STATUS_PENDING; + char * pTopicBuffer = NULL; + uint16_t operationTopicLength = 0; + bool freeTopicBuffer = true; + IotMqttPublishInfo_t publishInfo = IOT_MQTT_PUBLISH_INFO_INITIALIZER; + IotMqttError_t publishStatus = IOT_MQTT_STATUS_PENDING; IotLogDebug( "Processing Jobs operation %s for Thing %.*s.", _pAwsIotJobsOperationNames[ pOperation->type ], @@ -760,13 +760,13 @@ AwsIotJobsError_t _AwsIotJobs_ProcessOperation( const AwsIotJobsRequestInfo_t * pRequestInfo->pThingName ); /* Set the operation's MQTT connection. */ - pOperation->mqttConnection = pRequestInfo->mqttConnection; + pOperation->mqttConnection = pRequestInfo->mqttConnection; /* Generate the operation topic buffer. */ - status = _AwsIotJobs_GenerateJobsTopic( pOperation->type, - pRequestInfo, - &pTopicBuffer, - &operationTopicLength ); + status = _AwsIotJobs_GenerateJobsTopic( pOperation->type, + pRequestInfo, + &pTopicBuffer, + &operationTopicLength ); if( status != AWS_IOT_JOBS_SUCCESS ) { @@ -776,11 +776,11 @@ AwsIotJobsError_t _AwsIotJobs_ProcessOperation( const AwsIotJobsRequestInfo_t * } /* Get a subscription object for this Jobs operation. */ - status = _findSubscription( pRequestInfo, - pTopicBuffer, - operationTopicLength, - pOperation, - &freeTopicBuffer ); + status = _findSubscription( pRequestInfo, + pTopicBuffer, + operationTopicLength, + pOperation, + &freeTopicBuffer ); if( status != AWS_IOT_JOBS_SUCCESS ) { @@ -789,16 +789,16 @@ AwsIotJobsError_t _AwsIotJobs_ProcessOperation( const AwsIotJobsRequestInfo_t * } /* Set the members for PUBLISH retry. */ - publishInfo.qos = pRequestInfo->qos; - publishInfo.retryLimit = pRequestInfo->retryLimit; - publishInfo.retryMs = pRequestInfo->retryMs; + publishInfo.qos = pRequestInfo->qos; + publishInfo.retryLimit = pRequestInfo->retryLimit; + publishInfo.retryMs = pRequestInfo->retryMs; /* Set the payload as the Jobs request. */ - publishInfo.pPayload = pOperation->pJobsRequest; - publishInfo.payloadLength = pOperation->jobsRequestLength; + publishInfo.pPayload = pOperation->pJobsRequest; + publishInfo.payloadLength = pOperation->jobsRequestLength; /* Set the operation topic name. */ - publishInfo.pTopicName = pTopicBuffer; + publishInfo.pTopicName = pTopicBuffer; publishInfo.topicNameLength = operationTopicLength; IotLogDebug( "Jobs %s message will be published to topic %.*s", @@ -813,10 +813,10 @@ AwsIotJobsError_t _AwsIotJobs_ProcessOperation( const AwsIotJobsRequestInfo_t * IotMutex_Unlock( &( _AwsIotJobsPendingOperationsMutex ) ); /* Publish to the Jobs topic name. */ - publishStatus = IotMqtt_PublishSync( pOperation->mqttConnection, - &publishInfo, - 0, - _AwsIotJobsMqttTimeoutMs ); + publishStatus = IotMqtt_PublishSync( pOperation->mqttConnection, + &publishInfo, + 0, + _AwsIotJobsMqttTimeoutMs ); if( publishStatus != IOT_MQTT_SUCCESS ) { diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_serialize.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_serialize.c index 612af6660..6e0209957 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_serialize.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_serialize.c @@ -421,8 +421,8 @@ static size_t _appendClientToken( char * pBuffer, const AwsIotJobsRequestInfo_t * pRequestInfo, _jobsOperation_t * pOperation ) { - int clientTokenLength = 0; - uint32_t clientToken = 0; + int clientTokenLength = 0; + uint32_t clientToken = 0; /* Place the client token key in the buffer. */ APPEND_STRING( pBuffer, @@ -438,14 +438,14 @@ static size_t _appendClientToken( char * pBuffer, { /* Take the address of the given buffer, truncated to 8 characters. This * provides a client token that is very likely to be unique while in use. */ - clientToken = ( uint32_t ) ( ( uint64_t ) pBuffer % 100000000ULL ); + clientToken = ( uint32_t ) ( ( uint64_t ) pBuffer % 100000000ULL ); - clientTokenLength = snprintf( pBuffer + copyOffset, - CLIENT_TOKEN_AUTOGENERATE_LENGTH + 1, - "%08u", clientToken ); + clientTokenLength = snprintf( pBuffer + copyOffset, + CLIENT_TOKEN_AUTOGENERATE_LENGTH + 1, + "%08u", clientToken ); AwsIotJobs_Assert( clientTokenLength == CLIENT_TOKEN_AUTOGENERATE_LENGTH ); - copyOffset += ( size_t ) clientTokenLength; + copyOffset += ( size_t ) clientTokenLength; pOperation->clientTokenLength = CLIENT_TOKEN_AUTOGENERATE_LENGTH + 2; } else @@ -466,10 +466,10 @@ static size_t _appendClientToken( char * pBuffer, static AwsIotJobsError_t _generateGetPendingRequest( const AwsIotJobsRequestInfo_t * pRequestInfo, _jobsOperation_t * pOperation ) { - AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS; - char * pJobsRequest = NULL; - size_t copyOffset = 0; - size_t requestLength = MINIMUM_REQUEST_LENGTH; + AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS; + char * pJobsRequest = NULL; + size_t copyOffset = 0; + size_t requestLength = MINIMUM_REQUEST_LENGTH; /* Add the length of the client token. */ if( pRequestInfo->pClientToken != AWS_IOT_JOBS_CLIENT_TOKEN_AUTOGENERATE ) @@ -498,11 +498,11 @@ static AwsIotJobsError_t _generateGetPendingRequest( const AwsIotJobsRequestInfo /* Construct the request JSON, which consists of just a clientToken key. */ APPEND_STRING( pJobsRequest, copyOffset, "{\"", 2 ); - copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation ); + copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation ); APPEND_STRING( pJobsRequest, copyOffset, "\"}", 2 ); /* Set the output parameters. */ - pOperation->pJobsRequest = pJobsRequest; + pOperation->pJobsRequest = pJobsRequest; pOperation->jobsRequestLength = requestLength; /* Ensure offsets are valid. */ @@ -525,12 +525,12 @@ static AwsIotJobsError_t _generateStartNextRequest( const AwsIotJobsRequestInfo_ const AwsIotJobsUpdateInfo_t * pUpdateInfo, _jobsOperation_t * pOperation ) { - AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS; - char * pJobsRequest = NULL; - size_t copyOffset = 0; - size_t requestLength = MINIMUM_REQUEST_LENGTH; - char pStepTimeout[ STEP_TIMEOUT_STRING_LENGTH ] = { 0 }; - int stepTimeoutLength = 0; + AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS; + char * pJobsRequest = NULL; + size_t copyOffset = 0; + size_t requestLength = MINIMUM_REQUEST_LENGTH; + char pStepTimeout[ STEP_TIMEOUT_STRING_LENGTH ] = { 0 }; + int stepTimeoutLength = 0; /* Add the length of status details if provided. */ if( pUpdateInfo->pStatusDetails != AWS_IOT_JOBS_NO_STATUS_DETAILS ) @@ -613,12 +613,12 @@ static AwsIotJobsError_t _generateStartNextRequest( const AwsIotJobsRequestInfo_ } /* Add client token. */ - copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation ); + copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation ); APPEND_STRING( pJobsRequest, copyOffset, "\"}", 2 ); /* Set the output parameters. */ - pOperation->pJobsRequest = pJobsRequest; + pOperation->pJobsRequest = pJobsRequest; pOperation->jobsRequestLength = requestLength; /* Ensure offsets are valid. */ @@ -642,12 +642,12 @@ static AwsIotJobsError_t _generateDescribeRequest( const AwsIotJobsRequestInfo_t bool includeJobDocument, _jobsOperation_t * pOperation ) { - AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS; - char * pJobsRequest = NULL; - size_t copyOffset = 0; - size_t requestLength = MINIMUM_REQUEST_LENGTH; - char pExecutionNumber[ EXECUTION_NUMBER_STRING_LENGTH ] = { 0 }; - int executionNumberLength = 0; + AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS; + char * pJobsRequest = NULL; + size_t copyOffset = 0; + size_t requestLength = MINIMUM_REQUEST_LENGTH; + char pExecutionNumber[ EXECUTION_NUMBER_STRING_LENGTH ] = { 0 }; + int executionNumberLength = 0; /* Add the "include job document" flag if false. The default value is true, * so the flag is not needed if true. */ @@ -672,8 +672,8 @@ static AwsIotJobsError_t _generateDescribeRequest( const AwsIotJobsRequestInfo_t AwsIotJobs_Assert( executionNumberLength > 0 ); AwsIotJobs_Assert( executionNumberLength < EXECUTION_NUMBER_STRING_LENGTH ); - requestLength += EXECUTION_NUMBER_KEY_LENGTH + 4; - requestLength += ( size_t ) executionNumberLength; + requestLength += EXECUTION_NUMBER_KEY_LENGTH + 4; + requestLength += ( size_t ) executionNumberLength; } /* Add the length of the client token. */ @@ -724,12 +724,12 @@ static AwsIotJobsError_t _generateDescribeRequest( const AwsIotJobsRequestInfo_t } /* Add client token. */ - copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation ); + copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation ); APPEND_STRING( pJobsRequest, copyOffset, "\"}", 2 ); /* Set the output parameters. */ - pOperation->pJobsRequest = pJobsRequest; + pOperation->pJobsRequest = pJobsRequest; pOperation->jobsRequestLength = requestLength; /* Ensure offsets are valid. */ @@ -753,15 +753,15 @@ static AwsIotJobsError_t _generateUpdateRequest( const AwsIotJobsRequestInfo_t * _jobsOperation_t * pOperation ) { AwsIotJobsError_t status = AWS_IOT_JOBS_SUCCESS; - char * pJobsRequest = NULL; - size_t copyOffset = 0; - size_t requestLength = MINIMUM_REQUEST_LENGTH; - const char * pStatus = NULL; - size_t statusLength = 0; - char pExpectedVersion[ EXPECTED_VERSION_STRING_LENGTH ] = { 0 }; - char pExecutionNumber[ EXECUTION_NUMBER_STRING_LENGTH ] = { 0 }; - char pStepTimeout[ STEP_TIMEOUT_STRING_LENGTH ] = { 0 }; - int expectedVersionLength = 0, executionNumberLength = 0, stepTimeoutLength = 0; + char * pJobsRequest = NULL; + size_t copyOffset = 0; + size_t requestLength = MINIMUM_REQUEST_LENGTH; + const char * pStatus = NULL; + size_t statusLength = 0; + char pExpectedVersion[ EXPECTED_VERSION_STRING_LENGTH ] = { 0 }; + char pExecutionNumber[ EXECUTION_NUMBER_STRING_LENGTH ] = { 0 }; + char pStepTimeout[ STEP_TIMEOUT_STRING_LENGTH ] = { 0 }; + int expectedVersionLength = 0, executionNumberLength = 0, stepTimeoutLength = 0; /* Determine the status string and length to report to the Jobs service. * Add 6 for the 4 quotes, colon, and comma. */ @@ -788,7 +788,7 @@ static AwsIotJobsError_t _generateUpdateRequest( const AwsIotJobsRequestInfo_t * break; } - statusLength = strlen( pStatus ); + statusLength = strlen( pStatus ); requestLength += statusLength; /* Add the length of status details if provided. */ @@ -811,8 +811,8 @@ static AwsIotJobsError_t _generateUpdateRequest( const AwsIotJobsRequestInfo_t * AwsIotJobs_Assert( expectedVersionLength < EXPECTED_VERSION_STRING_LENGTH ); /* Add 6 for the 4 quotes, colon, and comma. */ - requestLength += EXPECTED_VERSION_KEY_LENGTH + 6; - requestLength += ( size_t ) expectedVersionLength; + requestLength += EXPECTED_VERSION_KEY_LENGTH + 6; + requestLength += ( size_t ) expectedVersionLength; } /* Add the length of the execution number if present. */ @@ -826,8 +826,8 @@ static AwsIotJobsError_t _generateUpdateRequest( const AwsIotJobsRequestInfo_t * AwsIotJobs_Assert( executionNumberLength > 0 ); AwsIotJobs_Assert( executionNumberLength < EXECUTION_NUMBER_STRING_LENGTH ); - requestLength += EXECUTION_NUMBER_KEY_LENGTH + 4; - requestLength += ( size_t ) executionNumberLength; + requestLength += EXECUTION_NUMBER_KEY_LENGTH + 4; + requestLength += ( size_t ) executionNumberLength; } /* Add the flags if true. The default values are false, so the flags are not @@ -972,12 +972,12 @@ static AwsIotJobsError_t _generateUpdateRequest( const AwsIotJobsRequestInfo_t * } /* Add the client token. */ - copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation ); + copyOffset = _appendClientToken( pJobsRequest, copyOffset, pRequestInfo, pOperation ); APPEND_STRING( pJobsRequest, copyOffset, "\"}", 2 ); /* Set the output parameters. */ - pOperation->pJobsRequest = pJobsRequest; + pOperation->pJobsRequest = pJobsRequest; pOperation->jobsRequestLength = requestLength; /* Ensure offsets are valid. */ @@ -999,9 +999,9 @@ static AwsIotJobsError_t _generateUpdateRequest( const AwsIotJobsRequestInfo_t * static AwsIotJobsError_t _parseErrorDocument( const char * pErrorDocument, size_t errorDocumentLength ) { - AwsIotJobsError_t status = AWS_IOT_JOBS_BAD_RESPONSE; - const char * pCode = NULL; - size_t codeLength = 0; + AwsIotJobsError_t status = AWS_IOT_JOBS_BAD_RESPONSE; + const char * pCode = NULL; + size_t codeLength = 0; /* Find the error code. */ if( AwsIotDocParser_FindValue( pErrorDocument, @@ -1165,7 +1165,7 @@ void _AwsIotJobs_ParseResponse( AwsIotStatus_t status, * info. */ if( ( pOperation->flags & AWS_IOT_JOBS_FLAG_WAITABLE ) == 0 ) { - pOperation->pJobsResponse = pResponse; + pOperation->pJobsResponse = pResponse; pOperation->jobsResponseLength = responseLength; } else diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_static_memory.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_static_memory.c index f13e6dac9..444b9a39f 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_static_memory.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_static_memory.c @@ -89,18 +89,18 @@ /* * Static memory buffers and flags, allocated and zeroed at compile-time. */ - static uint32_t _pInUseJobsOperations[ AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS ] = { 0U }; /**< @brief Jobs operation in-use flags. */ - static char _pJobsOperations[ AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS ][ JOBS_OPERATION_SIZE ] = { { 0 } }; /**< @brief Jobs operations. */ + static uint32_t _pInUseJobsOperations[ AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS ] = { 0U }; /**< @brief Jobs operation in-use flags. */ + static char _pJobsOperations[ AWS_IOT_JOBS_MAX_IN_PROGRESS_OPERATIONS ][ JOBS_OPERATION_SIZE ] = { { 0 } }; /**< @brief Jobs operations. */ - static uint32_t _pInUseJobsSubscriptions[ AWS_IOT_JOBS_SUBSCRIPTIONS ] = { 0U }; /**< @brief Jobs subscription in-use flags. */ - static char _pJobsSubscriptions[ AWS_IOT_JOBS_SUBSCRIPTIONS ][ JOBS_SUBSCRIPTION_SIZE ] = { { 0 } }; /**< @brief Jobs subscriptions. */ + static uint32_t _pInUseJobsSubscriptions[ AWS_IOT_JOBS_SUBSCRIPTIONS ] = { 0U }; /**< @brief Jobs subscription in-use flags. */ + static char _pJobsSubscriptions[ AWS_IOT_JOBS_SUBSCRIPTIONS ][ JOBS_SUBSCRIPTION_SIZE ] = { { 0 } }; /**< @brief Jobs subscriptions. */ /*-----------------------------------------------------------*/ void * AwsIotJobs_MallocOperation( size_t size ) { - int32_t freeIndex = -1; - void * pNewOperation = NULL; + int32_t freeIndex = -1; + void * pNewOperation = NULL; /* Check size argument. */ if( size <= JOBS_OPERATION_SIZE ) @@ -134,8 +134,8 @@ void * AwsIotJobs_MallocSubscription( size_t size ) { - int32_t freeIndex = -1; - void * pNewSubscription = NULL; + int32_t freeIndex = -1; + void * pNewSubscription = NULL; if( size <= JOBS_SUBSCRIPTION_SIZE ) { diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_subscription.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_subscription.c index 2d8c15af8..5fae60072 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_subscription.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/aws_iot_jobs_subscription.c @@ -75,7 +75,7 @@ IotMutex_t _AwsIotJobsSubscriptionsMutex; static bool _jobsSubscription_match( const IotLink_t * pSubscriptionLink, void * pMatch ) { - bool match = false; + bool match = false; /* Because this function is called from a container function, the given link * must never be NULL. */ @@ -84,7 +84,7 @@ static bool _jobsSubscription_match( const IotLink_t * pSubscriptionLink, const _jobsSubscription_t * pSubscription = IotLink_Container( _jobsSubscription_t, pSubscriptionLink, link ); - const AwsIotThingName_t * pThingName = ( AwsIotThingName_t * ) pMatch; + const AwsIotThingName_t * pThingName = ( AwsIotThingName_t * ) pMatch; if( pThingName->thingNameLength == pSubscription->thingNameLength ) { @@ -103,18 +103,18 @@ _jobsSubscription_t * _AwsIotJobs_FindSubscription( const char * pThingName, size_t thingNameLength, bool createIfNotFound ) { - _jobsSubscription_t * pSubscription = NULL; - IotLink_t * pSubscriptionLink = NULL; - AwsIotThingName_t thingName = { 0 }; + _jobsSubscription_t * pSubscription = NULL; + IotLink_t * pSubscriptionLink = NULL; + AwsIotThingName_t thingName = { 0 }; - thingName.pThingName = pThingName; + thingName.pThingName = pThingName; thingName.thingNameLength = thingNameLength; /* Search the list for an existing subscription for Thing Name. */ - pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotJobsSubscriptions ), - NULL, - _jobsSubscription_match, - &thingName ); + pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotJobsSubscriptions ), + NULL, + _jobsSubscription_match, + &thingName ); /* Check if a subscription was found. */ if( pSubscriptionLink == NULL ) @@ -277,10 +277,10 @@ AwsIotJobsError_t _AwsIotJobs_IncrementReferences( _jobsOperation_t * pOperation AwsIotMqttCallbackFunction_t callback ) { IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_SUCCESS ); - const _jobsOperationType_t type = pOperation->type; - _jobsSubscription_t * pSubscription = pOperation->pSubscription; - IotMqttError_t subscriptionStatus = IOT_MQTT_STATUS_PENDING; - AwsIotSubscriptionInfo_t subscriptionInfo = { 0 }; + const _jobsOperationType_t type = pOperation->type; + _jobsSubscription_t * pSubscription = pOperation->pSubscription; + IotMqttError_t subscriptionStatus = IOT_MQTT_STATUS_PENDING; + AwsIotSubscriptionInfo_t subscriptionInfo = { 0 }; /* Do nothing if this operation has persistent subscriptions. */ if( pSubscription->operationReferences[ type ] == AWS_IOT_PERSISTENT_SUBSCRIPTION ) @@ -302,14 +302,14 @@ AwsIotJobsError_t _AwsIotJobs_IncrementReferences( _jobsOperation_t * pOperation if( pSubscription->operationReferences[ type ] == 0 ) { /* Set the parameters needed to add subscriptions. */ - subscriptionInfo.mqttConnection = pOperation->mqttConnection; - subscriptionInfo.callbackFunction = callback; - subscriptionInfo.timeout = _AwsIotJobsMqttTimeoutMs; - subscriptionInfo.pTopicFilterBase = pTopicBuffer; + subscriptionInfo.mqttConnection = pOperation->mqttConnection; + subscriptionInfo.callbackFunction = callback; + subscriptionInfo.timeout = _AwsIotJobsMqttTimeoutMs; + subscriptionInfo.pTopicFilterBase = pTopicBuffer; subscriptionInfo.topicFilterBaseLength = operationTopicLength; - subscriptionStatus = AwsIot_ModifySubscriptions( IotMqtt_SubscribeSync, - &subscriptionInfo ); + subscriptionStatus = AwsIot_ModifySubscriptions( IotMqtt_SubscribeSync, + &subscriptionInfo ); /* Convert MQTT return code to Jobs return code. */ switch( subscriptionStatus ) @@ -365,11 +365,11 @@ void _AwsIotJobs_DecrementReferences( _jobsOperation_t * pOperation, char * pTopicBuffer, _jobsSubscription_t ** pRemovedSubscription ) { - const _jobsOperationType_t type = pOperation->type; - _jobsSubscription_t * pSubscription = pOperation->pSubscription; - uint16_t operationTopicLength = 0; - AwsIotSubscriptionInfo_t subscriptionInfo = { 0 }; - AwsIotJobsRequestInfo_t requestInfo = AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER; + const _jobsOperationType_t type = pOperation->type; + _jobsSubscription_t * pSubscription = pOperation->pSubscription; + uint16_t operationTopicLength = 0; + AwsIotSubscriptionInfo_t subscriptionInfo = { 0 }; + AwsIotJobsRequestInfo_t requestInfo = AWS_IOT_JOBS_REQUEST_INFO_INITIALIZER; /* Do nothing if this Jobs operation has persistent subscriptions. */ if( pSubscription->operationReferences[ type ] != AWS_IOT_PERSISTENT_SUBSCRIPTION ) @@ -391,10 +391,10 @@ void _AwsIotJobs_DecrementReferences( _jobsOperation_t * pOperation, AwsIotJobs_Assert( pSubscription->pTopicBuffer != NULL ); /* Set the parameters needed to generate a Jobs topic. */ - requestInfo.pThingName = pSubscription->pThingName; - requestInfo.thingNameLength = pSubscription->thingNameLength; - requestInfo.pJobId = pOperation->pJobId; - requestInfo.jobIdLength = pOperation->jobIdLength; + requestInfo.pThingName = pSubscription->pThingName; + requestInfo.thingNameLength = pSubscription->thingNameLength; + requestInfo.pJobId = pOperation->pJobId; + requestInfo.jobIdLength = pOperation->jobIdLength; /* Generate the prefix of the Jobs topic. This function will not * fail when given a buffer. */ @@ -404,9 +404,9 @@ void _AwsIotJobs_DecrementReferences( _jobsOperation_t * pOperation, &operationTopicLength ); /* Set the parameters needed to remove subscriptions. */ - subscriptionInfo.mqttConnection = pOperation->mqttConnection; - subscriptionInfo.timeout = _AwsIotJobsMqttTimeoutMs; - subscriptionInfo.pTopicFilterBase = pTopicBuffer; + subscriptionInfo.mqttConnection = pOperation->mqttConnection; + subscriptionInfo.timeout = _AwsIotJobsMqttTimeoutMs; + subscriptionInfo.pTopicFilterBase = pTopicBuffer; subscriptionInfo.topicFilterBaseLength = operationTopicLength; ( void ) AwsIot_ModifySubscriptions( IotMqtt_UnsubscribeSync, @@ -433,15 +433,15 @@ AwsIotJobsError_t AwsIotJobs_RemovePersistentSubscriptions( const AwsIotJobsRequ uint32_t flags ) { IOT_FUNCTION_ENTRY( AwsIotJobsError_t, AWS_IOT_JOBS_SUCCESS ); - int32_t i = 0; - uint16_t operationTopicLength = 0; - IotMqttError_t unsubscribeStatus = IOT_MQTT_STATUS_PENDING; - AwsIotSubscriptionInfo_t subscriptionInfo = { 0 }; - _jobsSubscription_t * pSubscription = NULL; - IotLink_t * pSubscriptionLink = NULL; - AwsIotThingName_t thingName = { 0 }; - - thingName.pThingName = pRequestInfo->pThingName; + int32_t i = 0; + uint16_t operationTopicLength = 0; + IotMqttError_t unsubscribeStatus = IOT_MQTT_STATUS_PENDING; + AwsIotSubscriptionInfo_t subscriptionInfo = { 0 }; + _jobsSubscription_t * pSubscription = NULL; + IotLink_t * pSubscriptionLink = NULL; + AwsIotThingName_t thingName = { 0 }; + + thingName.pThingName = pRequestInfo->pThingName; thingName.thingNameLength = pRequestInfo->thingNameLength; IotLogInfo( "Removing persistent subscriptions for %.*s.", @@ -486,10 +486,10 @@ AwsIotJobsError_t AwsIotJobs_RemovePersistentSubscriptions( const AwsIotJobsRequ IotMutex_Lock( &( _AwsIotJobsSubscriptionsMutex ) ); /* Search the list for an existing subscription for Thing Name. */ - pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotJobsSubscriptions ), - NULL, - _jobsSubscription_match, - &thingName ); + pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotJobsSubscriptions ), + NULL, + _jobsSubscription_match, + &thingName ); if( pSubscriptionLink != NULL ) { @@ -522,13 +522,13 @@ AwsIotJobsError_t AwsIotJobs_RemovePersistentSubscriptions( const AwsIotJobsRequ &operationTopicLength ); /* Set the parameters needed to remove subscriptions. */ - subscriptionInfo.mqttConnection = pRequestInfo->mqttConnection; - subscriptionInfo.timeout = _AwsIotJobsMqttTimeoutMs; - subscriptionInfo.pTopicFilterBase = pSubscription->pTopicBuffer; - subscriptionInfo.topicFilterBaseLength = operationTopicLength; + subscriptionInfo.mqttConnection = pRequestInfo->mqttConnection; + subscriptionInfo.timeout = _AwsIotJobsMqttTimeoutMs; + subscriptionInfo.pTopicFilterBase = pSubscription->pTopicBuffer; + subscriptionInfo.topicFilterBaseLength = operationTopicLength; - unsubscribeStatus = AwsIot_ModifySubscriptions( IotMqtt_UnsubscribeSync, - &subscriptionInfo ); + unsubscribeStatus = AwsIot_ModifySubscriptions( IotMqtt_UnsubscribeSync, + &subscriptionInfo ); /* Convert MQTT return code to Shadow return code. */ switch( unsubscribeStatus ) diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/private/aws_iot_jobs_internal.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/private/aws_iot_jobs_internal.h index 938e0edb0..370bb8e94 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/private/aws_iot_jobs_internal.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/jobs/src/private/aws_iot_jobs_internal.h @@ -425,11 +425,11 @@ typedef struct _jobsOperation #endif /* Declarations of variables for internal Jobs files. */ -extern uint32_t _AwsIotJobsMqttTimeoutMs; -extern IotListDouble_t _AwsIotJobsPendingOperations; -extern IotListDouble_t _AwsIotJobsSubscriptions; -extern IotMutex_t _AwsIotJobsPendingOperationsMutex; -extern IotMutex_t _AwsIotJobsSubscriptionsMutex; +extern uint32_t _AwsIotJobsMqttTimeoutMs; +extern IotListDouble_t _AwsIotJobsPendingOperations; +extern IotListDouble_t _AwsIotJobsSubscriptions; +extern IotMutex_t _AwsIotJobsPendingOperationsMutex; +extern IotMutex_t _AwsIotJobsSubscriptionsMutex; /*------------------------ Jobs operation functions -------------------------*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_agent.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_agent.c index 790f9c55a..2d63d128a 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_agent.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_agent.c @@ -94,11 +94,11 @@ typedef union MultiParmPtr /* Array containing pointer to the OTA event structures used to send events to the OTA task. */ -static OTA_EventMsg_t xQueueData[ OTA_NUM_MSG_Q_ENTRIES ]; +static OTA_EventMsg_t xQueueData[ OTA_NUM_MSG_Q_ENTRIES ]; /* Buffers used to push event data. */ -static OTA_EventData_t xEventBuffer[ otaconfigMAX_NUM_OTA_DATA_BUFFERS ]; +static OTA_EventData_t xEventBuffer[ otaconfigMAX_NUM_OTA_DATA_BUFFERS ]; /* OTA control interface. */ @@ -106,7 +106,7 @@ static OTA_ControlInterface_t xOTA_ControlInterface; /* OTA data interface. */ -static OTA_DataInterface_t xOTA_DataInterface; +static OTA_DataInterface_t xOTA_DataInterface; /* * Test a null terminated string against a JSON string of known length and return whether @@ -264,21 +264,21 @@ static OTA_Err_t prvResumeHandler( OTA_EventData_t * pxEventData ); #define OTA_JOB_CALLBACK_DEFAULT_INITIALIZER \ { \ - .xAbort = prvPAL_Abort, \ - .xActivateNewImage = prvPAL_DefaultActivateNewImage, \ - .xCloseFile = prvPAL_CloseFile, \ - .xCreateFileForRx = prvPAL_CreateFileForRx, \ + .xAbort = prvPAL_Abort, \ + .xActivateNewImage = prvPAL_DefaultActivateNewImage, \ + .xCloseFile = prvPAL_CloseFile, \ + .xCreateFileForRx = prvPAL_CreateFileForRx, \ .xGetPlatformImageState = prvPAL_DefaultGetPlatformImageState, \ - .xResetDevice = prvPAL_DefaultResetDevice, \ + .xResetDevice = prvPAL_DefaultResetDevice, \ .xSetPlatformImageState = prvPAL_DefaultSetPlatformImageState, \ - .xWriteBlock = prvPAL_WriteBlock, \ - .xCompleteCallback = prvDefaultOTACompleteCallback, \ - .xCustomJobCallback = prvDefaultCustomJobCallback \ + .xWriteBlock = prvPAL_WriteBlock, \ + .xCompleteCallback = prvDefaultOTACompleteCallback, \ + .xCustomJobCallback = prvDefaultCustomJobCallback \ } /* This is THE OTA agent context and initialization state. */ -static OTA_AgentContext_t xOTA_Agent = +static OTA_AgentContext_t xOTA_Agent = { .eState = eOTA_AgentState_Stopped, .pcThingName = { 0 }, @@ -298,7 +298,7 @@ static OTA_AgentContext_t xOTA_Agent = .ulRequestMomentum = 0 }; -static OTAStateTableEntry_t OTATransitionTable[] = +static OTAStateTableEntry_t OTATransitionTable[] = { /*STATE , EVENT , ACTION , NEXT STATE */ { eOTA_AgentState_Ready, eOTA_AgentEvent_Start, prvStartHandler, eOTA_AgentState_RequestingJob }, @@ -321,7 +321,7 @@ static OTAStateTableEntry_t OTATransitionTable[] = { eOTA_AgentState_All, eOTA_AgentEvent_Shutdown, prvShutdownHandler, eOTA_AgentState_ShuttingDown }, }; -static const char * pcOTA_AgentState_Strings[ eOTA_AgentState_All ] = +static const char * pcOTA_AgentState_Strings[ eOTA_AgentState_All ] = { "Init", "Ready", @@ -336,7 +336,7 @@ static const char * pcOTA_AgentState_Strings[ eOTA_AgentState_All ] = "Stopped" }; -static const char * pcOTA_Event_Strings[ eOTA_AgentEvent_Max ] = +static const char * pcOTA_Event_Strings[ eOTA_AgentEvent_Max ] = { "Start", "StartSelfTest", @@ -383,8 +383,8 @@ static bool prvInSelftest( void ) static BaseType_t prvStartSelfTestTimer( void ) { DEFINE_OTA_METHOD_NAME( "prvStartSelfTestTimer" ); - static const char pcTimerName[] = "OTA_SelfTest"; - BaseType_t xTimerStarted = pdFALSE; + static const char pcTimerName[] = "OTA_SelfTest"; + BaseType_t xTimerStarted = pdFALSE; static StaticTimer_t xTimerBuffer; if( prvInSelftest() == true ) @@ -473,7 +473,7 @@ static void prvStartRequestTimer( uint32_t xPeriodMS ) DEFINE_OTA_METHOD_NAME( "prvStartRequestTimer" ); static const char pcTimerName[] = "OTA_FileRequest"; - BaseType_t xTimerStarted = pdFALSE; + BaseType_t xTimerStarted = pdFALSE; if( xOTA_Agent.xRequestTimer == NULL ) { @@ -519,8 +519,8 @@ static void prvStopRequestTimer( void ) static OTA_Err_t prvUpdateJobStatusFromImageState( OTA_ImageState_t eState, int32_t lSubReason ) { - OTA_Err_t xErr = kOTA_Err_Uninitialized; - int32_t lReason = 0; + OTA_Err_t xErr = kOTA_Err_Uninitialized; + int32_t lReason = 0; if( eState == eOTA_ImageState_Testing ) { @@ -542,7 +542,7 @@ static OTA_Err_t prvUpdateJobStatusFromImageState( OTA_ImageState_t eState, * doesn't allow us to set REJECTED after the job has been started already). */ lReason = ( eState == eOTA_ImageState_Rejected ) ? eJobReason_Rejected : eJobReason_Aborted; - xErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent, eJobStatus_Failed, lReason, lSubReason ); + xErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent, eJobStatus_Failed, lReason, lSubReason ); } /* @@ -563,7 +563,7 @@ static OTA_Err_t prvSetImageStateWithReason( OTA_ImageState_t eState, configASSERT( ( eState > eOTA_ImageState_Unknown ) && ( eState <= eOTA_LastImageState ) ); /* Call the platform specific code to set the image state. */ - xErr = xOTA_Agent.xPALCallbacks.xSetPlatformImageState( xOTA_Agent.ulServerFileID, eState ); + xErr = xOTA_Agent.xPALCallbacks.xSetPlatformImageState( xOTA_Agent.ulServerFileID, eState ); /* * If the platform image state couldn't be set correctly, force fail the update by setting the @@ -793,7 +793,7 @@ static OTA_Err_t prvStartHandler( OTA_EventData_t * pxEventData ) DEFINE_OTA_METHOD_NAME( "prvStartHandler" ); ( void ) pxEventData; - OTA_Err_t xReturn = kOTA_Err_None; + OTA_Err_t xReturn = kOTA_Err_None; OTA_EventMsg_t xEventMsg = { 0 }; /* Start self-test timer, if platform is in self-test. */ @@ -842,7 +842,7 @@ static OTA_Err_t prvRequestJobHandler( OTA_EventData_t * pxEventData ) DEFINE_OTA_METHOD_NAME( "prvRequestJobHandler" ); ( void ) pxEventData; - OTA_Err_t xReturn = kOTA_Err_Uninitialized; + OTA_Err_t xReturn = kOTA_Err_Uninitialized; OTA_EventMsg_t xEventMsg = { 0 }; /* @@ -898,9 +898,9 @@ static OTA_Err_t prvProcessJobHandler( OTA_EventData_t * pxEventData ) { DEFINE_OTA_METHOD_NAME( "prvProcessJobHandler" ); - OTA_Err_t xReturn = kOTA_Err_Uninitialized; + OTA_Err_t xReturn = kOTA_Err_Uninitialized; OTA_FileContext_t * xOTAFileContext = NULL; - OTA_EventMsg_t xEventMsg = { 0 }; + OTA_EventMsg_t xEventMsg = { 0 }; /* * Parse the job document and update file information in the file context. @@ -983,7 +983,7 @@ static OTA_Err_t prvProcessJobHandler( OTA_EventData_t * pxEventData ) static OTA_Err_t prvInitFileHandler( OTA_EventData_t * pxEventData ) { ( void ) pxEventData; - OTA_Err_t xErr = kOTA_Err_Uninitialized; + OTA_Err_t xErr = kOTA_Err_Uninitialized; OTA_EventMsg_t xEventMsg = { 0 }; xErr = xOTA_DataInterface.prvInitFileTransfer( &xOTA_Agent ); @@ -1022,7 +1022,7 @@ static OTA_Err_t prvInitFileHandler( OTA_EventData_t * pxEventData ) /* Reset the request momentum. */ xOTA_Agent.ulRequestMomentum = 0; - xEventMsg.xEventId = eOTA_AgentEvent_RequestFileBlock; + xEventMsg.xEventId = eOTA_AgentEvent_RequestFileBlock; if( !OTA_SignalEvent( &xEventMsg ) ) { @@ -1036,7 +1036,7 @@ static OTA_Err_t prvInitFileHandler( OTA_EventData_t * pxEventData ) static OTA_Err_t prvRequestDataHandler( OTA_EventData_t * pxEventData ) { ( void ) pxEventData; - OTA_Err_t xErr = kOTA_Err_Uninitialized; + OTA_Err_t xErr = kOTA_Err_Uninitialized; OTA_EventMsg_t xEventMsg = { 0 }; if( xOTA_Agent.pxOTA_Files[ xOTA_Agent.ulFileIndex ].ulBlocksRemaining > 0U ) @@ -1072,7 +1072,7 @@ static OTA_Err_t prvRequestDataHandler( OTA_EventData_t * pxEventData ) { /* Too many requests have been sent without a response or too many failures * when trying to publish the request message. Abort. Store attempt count in low bits. */ - xErr = ( uint32_t ) kOTA_Err_MomentumAbort | ( otaconfigMAX_NUM_REQUEST_MOMENTUM & ( uint32_t ) kOTA_PAL_ErrMask ); + xErr = ( uint32_t ) kOTA_Err_MomentumAbort | ( otaconfigMAX_NUM_REQUEST_MOMENTUM & ( uint32_t ) kOTA_PAL_ErrMask ); /* Reset the request momentum. */ xOTA_Agent.ulRequestMomentum = 0; @@ -1087,18 +1087,18 @@ static OTA_Err_t prvProcessDataHandler( OTA_EventData_t * pxEventData ) { DEFINE_OTA_METHOD_NAME( "prvProcessDataMessage" ); - OTA_Err_t xErr = kOTA_Err_Uninitialized; - OTA_Err_t xCloseResult = kOTA_Err_Uninitialized; - OTA_EventMsg_t xEventMsg = { 0 }; + OTA_Err_t xErr = kOTA_Err_Uninitialized; + OTA_Err_t xCloseResult = kOTA_Err_Uninitialized; + OTA_EventMsg_t xEventMsg = { 0 }; /* Get the file context. */ OTA_FileContext_t * pxFileContext = &xOTA_Agent.pxOTA_Files[ xOTA_Agent.ulFileIndex ]; /* Ingest data blocks received. */ - IngestResult_t xResult = prvIngestDataBlock( pxFileContext, - pxEventData->ucData, - pxEventData->ulDataLength, - &xCloseResult ); + IngestResult_t xResult = prvIngestDataBlock( pxFileContext, + pxEventData->ucData, + pxEventData->ulDataLength, + &xCloseResult ); if( xResult < eIngest_Result_Accepted_Continue ) { @@ -1165,7 +1165,7 @@ static OTA_Err_t prvProcessDataHandler( OTA_EventData_t * pxEventData ) /* We're actively receiving a file so update the job status as needed. */ /* First reset the momentum counter since we received a good block. */ xOTA_Agent.ulRequestMomentum = 0; - xErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent, eJobStatus_InProgress, eJobReason_Receiving, 0 ); + xErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent, eJobStatus_InProgress, eJobReason_Receiving, 0 ); if( xErr != kOTA_Err_None ) { @@ -1281,7 +1281,7 @@ static OTA_Err_t prvResumeHandler( OTA_EventData_t * pxEventData ) /* * Send signal to request job document. */ - xEventMsg.xEventId = eOTA_AgentEvent_RequestJobDocument; + xEventMsg.xEventId = eOTA_AgentEvent_RequestJobDocument; return OTA_SignalEvent( &xEventMsg ) ? kOTA_Err_None : kOTA_Err_EventQueueSendFailed; } @@ -1332,7 +1332,7 @@ OTA_EventData_t * prvOTAEventBufferGet( void ) { DEFINE_OTA_METHOD_NAME( "prvOTAEventBufferGet" ); - uint32_t ulIndex = 0; + uint32_t ulIndex = 0; OTA_EventData_t * pxOTAFreeMsg = NULL; /* Wait at most 1 task switch for a buffer so as not to block the callback. */ @@ -1343,7 +1343,7 @@ OTA_EventData_t * prvOTAEventBufferGet( void ) if( xEventBuffer[ ulIndex ].bBufferUsed == false ) { xEventBuffer[ ulIndex ].bBufferUsed = true; - pxOTAFreeMsg = &xEventBuffer[ ulIndex ]; + pxOTAFreeMsg = &xEventBuffer[ ulIndex ]; break; } } @@ -1452,8 +1452,8 @@ static bool prvOTA_Close( OTA_FileContext_t * const C ) static OTA_FileContext_t * prvGetFreeContext( void ) { - uint32_t ulIndex = 0U; - OTA_FileContext_t * C = NULL; + uint32_t ulIndex = 0U; + OTA_FileContext_t * C = NULL; while( ( ulIndex < OTA_MAX_FILES ) && ( xOTA_Agent.pxOTA_Files[ ulIndex ].pucFilePath != NULL ) ) { @@ -1463,7 +1463,7 @@ static OTA_FileContext_t * prvGetFreeContext( void ) if( ulIndex != OTA_MAX_FILES ) { ( void ) memset( &xOTA_Agent.pxOTA_Files[ ulIndex ], 0, sizeof( OTA_FileContext_t ) ); - C = &xOTA_Agent.pxOTA_Files[ ulIndex ]; + C = &xOTA_Agent.pxOTA_Files[ ulIndex ]; xOTA_Agent.ulFileIndex = ulIndex; } else @@ -1503,7 +1503,7 @@ static DocParseErr_t prvSearchModelForTokenKey( JSON_DocModel_t * pxDocModel, uint16_t * pulMatchingIndexResult ) { DocParseErr_t eErr = eDocParseErr_ParamKeyNotInModel; - uint16_t usParamIndex; + uint16_t usParamIndex; for( usParamIndex = 0; usParamIndex < pxDocModel->usNumModelParams; usParamIndex++ ) { @@ -1519,8 +1519,8 @@ static DocParseErr_t prvSearchModelForTokenKey( JSON_DocModel_t * pxDocModel, { /* Mark parameter as received in the bitmap. */ pxDocModel->ulParamsReceivedBitmap |= ( ( uint32_t ) 1U << usParamIndex ); /*lint !e9032 usParamIndex will never be greater than kDocModel_MaxParams, which is the the size of the bitmap. */ - *pulMatchingIndexResult = usParamIndex; /* Save result index for caller. */ - eErr = eDocParseErr_None; /* We found a matching key in the document model. */ + *pulMatchingIndexResult = usParamIndex; /* Save result index for caller. */ + eErr = eDocParseErr_None; /* We found a matching key in the document model. */ } break; /* We found a key match so stop searching. */ @@ -1539,16 +1539,16 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON, DEFINE_OTA_METHOD_NAME( "prvParseJSONbyModel" ); const JSON_DocParam_t * pxModelParam = NULL; - jsmn_parser xParser; - jsmntok_t * pxTokens = NULL; - const jsmntok_t * pxValTok = NULL; - int32_t jsmn_result = 0; - uint32_t ulNumTokens = 0, ulTokenLen = 0; - MultiParmPtr_t xParamAddr; /*lint !e9018 We intentionally use this union to cast the parameter address to the proper type. */ - uint32_t ulIndex = 0; - uint16_t usModelParamIndex = 0; - uint32_t ulScanIndex = 0; - DocParseErr_t eErr = eDocParseErr_None; + jsmn_parser xParser; + jsmntok_t * pxTokens = NULL; + const jsmntok_t * pxValTok = NULL; + int32_t jsmn_result = 0; + uint32_t ulNumTokens = 0, ulTokenLen = 0; + MultiParmPtr_t xParamAddr; /*lint !e9018 We intentionally use this union to cast the parameter address to the proper type. */ + uint32_t ulIndex = 0; + uint16_t usModelParamIndex = 0; + uint32_t ulScanIndex = 0; + DocParseErr_t eErr = eDocParseErr_None; /* Reset the Jasmine tokenizer. */ jsmn_init( &xParser ); @@ -1596,8 +1596,8 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON, pxModelParam = pxDocModel->pxBodyDef; /* Count the total number of tokens in our JSON document. */ - jsmn_result = jsmn_parse( &xParser, pcJSON, ( size_t ) ulMsgLen, NULL, 1UL ); - ulNumTokens = jsmn_result < 0 ? 0 : ( uint32_t ) jsmn_result; + jsmn_result = jsmn_parse( &xParser, pcJSON, ( size_t ) ulMsgLen, NULL, 1UL ); + ulNumTokens = jsmn_result < 0 ? 0 : ( uint32_t ) jsmn_result; if( ulNumTokens == 0 ) { @@ -1654,7 +1654,7 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON, { /* Search the document model to see if it matches the current key. */ ulTokenLen = ( uint32_t ) pxTokens[ ulIndex ].end - ( uint32_t ) pxTokens[ ulIndex ].start; - eErr = prvSearchModelForTokenKey( pxDocModel, &pcJSON[ pxTokens[ ulIndex ].start ], ulTokenLen, &usModelParamIndex ); + eErr = prvSearchModelForTokenKey( pxDocModel, &pcJSON[ pxTokens[ ulIndex ].start ], ulTokenLen, &usModelParamIndex ); /* If we didn't find a match in the model, skip over it and its descendants. */ if( eErr == eDocParseErr_ParamKeyNotInModel ) @@ -1686,7 +1686,7 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON, OTA_METHOD_NAME, pxModelParam[ usModelParamIndex ].pcSrcKey, ulTokenLen, &pcJSON[ pxValTok->start ], pxValTok->type, pxModelParam[ usModelParamIndex ].eJasmineType ); - eErr = eDocParseErr_FieldTypeMismatch; + eErr = eDocParseErr_FieldTypeMismatch; } else if( OTA_DONT_STORE_PARAM == pxModelParam[ usModelParamIndex ].ulDestOffset ) { @@ -1716,7 +1716,7 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON, if( pvStringCopy != NULL ) { - *xParamAddr.ppvPtr = pvStringCopy; + *xParamAddr.ppvPtr = pvStringCopy; char * pcStringCopy = *xParamAddr.ppcPtr; /* Copy parameter string into newly allocated memory. */ ( void ) memcpy( pcStringCopy, &pcJSON[ pxValTok->start ], ulTokenLen ); @@ -1737,7 +1737,7 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON, /* Copy pointer to source string instead of duplicating the string. */ const char * pcStringInDoc = &pcJSON[ pxValTok->start ]; *xParamAddr.ppccPtr = pcStringInDoc; - ulTokenLen = ( uint32_t ) ( pxValTok->end ) - ( uint32_t ) ( pxValTok->start ); + ulTokenLen = ( uint32_t ) ( pxValTok->end ) - ( uint32_t ) ( pxValTok->start ); OTA_LOG_L1( "[%s] Extracted parameter [ %s: %.*s ]\r\n", OTA_METHOD_NAME, pxModelParam[ usModelParamIndex ].pcSrcKey, @@ -1745,7 +1745,7 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON, } else if( eModelParamType_UInt32 == pxModelParam[ usModelParamIndex ].xModelParamType ) { - char * pEnd; + char * pEnd; const char * pStart = &pcJSON[ pxValTok->start ]; *xParamAddr.pulPtr = strtoul( pStart, &pEnd, 0 ); @@ -1768,10 +1768,10 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON, if( pvSignature != NULL ) { - size_t xActualLen = 0; + size_t xActualLen = 0; *xParamAddr.ppvPtr = pvSignature; - Sig256_t * pxSig256 = *xParamAddr.ppxSig256Ptr; - ulTokenLen = ( uint32_t ) ( pxValTok->end ) - ( uint32_t ) ( pxValTok->start ); + Sig256_t * pxSig256 = *xParamAddr.ppxSig256Ptr; + ulTokenLen = ( uint32_t ) ( pxValTok->end ) - ( uint32_t ) ( pxValTok->start ); if( mbedtls_base64_decode( pxSig256->ucData, sizeof( pxSig256->ucData ), &xActualLen, ( const uint8_t * ) &pcJSON[ pxValTok->start ], ulTokenLen ) != 0 ) @@ -1810,7 +1810,7 @@ static DocParseErr_t prvParseJSONbyModel( const char * pcJSON, if( pvStringCopy != NULL ) { - *xParamAddr.ppvPtr = pvStringCopy; + *xParamAddr.ppvPtr = pvStringCopy; char * pcStringCopy = *xParamAddr.ppcPtr; /* Copy parameter string into newly allocated memory. */ ( void ) memcpy( pcStringCopy, &pcJSON[ pxValTok->start ], ulTokenLen ); @@ -1892,7 +1892,7 @@ static DocParseErr_t prvInitDocModel( JSON_DocModel_t * pxDocModel, DEFINE_OTA_METHOD_NAME( "prvInitDocModel" ); DocParseErr_t eErr = eDocParseErr_Unknown; - uint32_t ulScanIndex; + uint32_t ulScanIndex; /* Sanity check the model pointers and parameter count. Exclude the context base address and size since * it is technically possible to create a model that writes entirely into absolute memory locations. @@ -1914,10 +1914,10 @@ static DocParseErr_t prvInitDocModel( JSON_DocModel_t * pxDocModel, } else { - pxDocModel->ulContextBase = ulContextBaseAddr; - pxDocModel->ulContextSize = ulContextSize; - pxDocModel->pxBodyDef = pxBodyDef; - pxDocModel->usNumModelParams = usNumJobParams; + pxDocModel->ulContextBase = ulContextBaseAddr; + pxDocModel->ulContextSize = ulContextSize; + pxDocModel->pxBodyDef = pxBodyDef; + pxDocModel->usNumModelParams = usNumJobParams; pxDocModel->ulParamsReceivedBitmap = 0; pxDocModel->ulParamsRequiredBitmap = 0; @@ -1931,7 +1931,7 @@ static DocParseErr_t prvInitDocModel( JSON_DocModel_t * pxDocModel, } } - eErr = eDocParseErr_None; + eErr = eDocParseErr_None; } return eErr; @@ -2021,13 +2021,13 @@ static OTA_FileContext_t * prvParseJobDoc( const char * pcJSON, }; OTA_Err_t xOTAErr = kOTA_Err_None; - OTA_JobParseErr_t eErr = eOTA_JobParseErr_Unknown; - OTA_FileContext_t * pxFinalFile = NULL; - OTA_FileContext_t xFileContext = { 0 }; - OTA_FileContext_t * C = &xFileContext; - OTA_Err_t xErrVersionCheck = kOTA_Err_Uninitialized; + OTA_JobParseErr_t eErr = eOTA_JobParseErr_Unknown; + OTA_FileContext_t * pxFinalFile = NULL; + OTA_FileContext_t xFileContext = { 0 }; + OTA_FileContext_t * C = &xFileContext; + OTA_Err_t xErrVersionCheck = kOTA_Err_Uninitialized; - JSON_DocModel_t xOTA_JobDocModel; + JSON_DocModel_t xOTA_JobDocModel; if( prvInitDocModel( &xOTA_JobDocModel, xOTA_JobDocModelParamStructure, @@ -2039,7 +2039,7 @@ static OTA_FileContext_t * prvParseJobDoc( const char * pcJSON, } else if( prvParseJSONbyModel( pcJSON, ulMsgLen, &xOTA_JobDocModel ) == eDocParseErr_None ) { /* Validate the job document parameters. */ - eErr = eOTA_JobParseErr_None; + eErr = eOTA_JobParseErr_None; if( C->ulFileSize == 0U ) { @@ -2071,10 +2071,10 @@ static OTA_FileContext_t * prvParseJobDoc( const char * pcJSON, prvOTA_FreeContext( C ); - pxFinalFile = &xOTA_Agent.pxOTA_Files[ xOTA_Agent.ulFileIndex ]; + pxFinalFile = &xOTA_Agent.pxOTA_Files[ xOTA_Agent.ulFileIndex ]; *pbUpdateJob = true; - eErr = eOTA_JobParseErr_UpdateCurrentJob; + eErr = eOTA_JobParseErr_UpdateCurrentJob; } } else @@ -2086,7 +2086,7 @@ static OTA_FileContext_t * prvParseJobDoc( const char * pcJSON, else { /* Assume control of the job name from the context. */ xOTA_Agent.pcOTA_Singleton_ActiveJobName = C->pucJobName; - C->pucJobName = NULL; + C->pucJobName = NULL; } /* Store the File ID received in the job */ @@ -2167,11 +2167,11 @@ static OTA_FileContext_t * prvParseJobDoc( const char * pcJSON, if( C->pucJobName != NULL ) { xOTA_Agent.pcOTA_Singleton_ActiveJobName = C->pucJobName; - C->pucJobName = NULL; - xOTAErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent, - eJobStatus_Succeeded, - eJobReason_Accepted, - 0 ); + C->pucJobName = NULL; + xOTAErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent, + eJobStatus_Succeeded, + eJobReason_Accepted, + 0 ); if( xOTAErr != kOTA_Err_None ) { @@ -2202,11 +2202,11 @@ static OTA_FileContext_t * prvParseJobDoc( const char * pcJSON, OTA_LOG_L1( "[%s] Rejecting job due to OTA_JobParseErr_t %d\r\n", OTA_METHOD_NAME, eErr ); /* Assume control of the job name from the context. */ xOTA_Agent.pcOTA_Singleton_ActiveJobName = C->pucJobName; - C->pucJobName = NULL; - xOTAErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent, - eJobStatus_FailedWithVal, - ( int32_t ) kOTA_Err_JobParserError, - ( int32_t ) eErr ); + C->pucJobName = NULL; + xOTAErr = xOTA_ControlInterface.prvUpdateJobStatus( &xOTA_Agent, + eJobStatus_FailedWithVal, + ( int32_t ) kOTA_Err_JobParserError, + ( int32_t ) eErr ); if( xOTAErr != kOTA_Err_None ) { @@ -2249,13 +2249,13 @@ static OTA_FileContext_t * prvGetFileContextFromJob( const char * pcRawMsg, { DEFINE_OTA_METHOD_NAME( "prvGetFileContextFromJob" ); - uint32_t ulIndex; - uint32_t ulNumBlocks; /* How many data pages are in the expected update image. */ - uint32_t ulBitmapLen; /* Length of the file block bitmap in bytes. */ + uint32_t ulIndex; + uint32_t ulNumBlocks; /* How many data pages are in the expected update image. */ + uint32_t ulBitmapLen; /* Length of the file block bitmap in bytes. */ OTA_FileContext_t * pstUpdateFile; /* Pointer to an OTA update context. */ - OTA_Err_t xErr = kOTA_Err_Uninitialized; + OTA_Err_t xErr = kOTA_Err_Uninitialized; - bool bUpdateJob = false; + bool bUpdateJob = false; /* Populate an OTA file context from the OTA job document. */ @@ -2277,8 +2277,8 @@ static OTA_FileContext_t * prvGetFileContextFromJob( const char * pcRawMsg, /* Calculate how many bytes we need in our bitmap for tracking received blocks. * The below calculation requires power of 2 page sizes. */ - ulNumBlocks = ( pstUpdateFile->ulFileSize + ( OTA_FILE_BLOCK_SIZE - 1U ) ) >> otaconfigLOG2_FILE_BLOCK_SIZE; - ulBitmapLen = ( ulNumBlocks + ( BITS_PER_BYTE - 1U ) ) >> LOG2_BITS_PER_BYTE; + ulNumBlocks = ( pstUpdateFile->ulFileSize + ( OTA_FILE_BLOCK_SIZE - 1U ) ) >> otaconfigLOG2_FILE_BLOCK_SIZE; + ulBitmapLen = ( ulNumBlocks + ( BITS_PER_BYTE - 1U ) ) >> LOG2_BITS_PER_BYTE; pstUpdateFile->pucRxBlockBitmap = ( uint8_t * ) pvPortMalloc( ulBitmapLen ); /*lint !e9079 FreeRTOS malloc port returns void*. */ if( pstUpdateFile->pucRxBlockBitmap != NULL ) @@ -2293,7 +2293,7 @@ static OTA_FileContext_t * prvGetFileContextFromJob( const char * pcRawMsg, * Files aren't always a multiple of 8 pages (8 bits/pages per byte) so some bits of the * last byte may be out of range and those are the bits we want to clear. */ - uint8_t ulBit = 1U << ( BITS_PER_BYTE - 1U ); + uint8_t ulBit = 1U << ( BITS_PER_BYTE - 1U ); uint32_t ulNumOutOfRange = ( ulBitmapLen * BITS_PER_BYTE ) - ulNumBlocks; for( ulIndex = 0U; ulIndex < ulNumOutOfRange; ulIndex++ ) @@ -2305,7 +2305,7 @@ static OTA_FileContext_t * prvGetFileContextFromJob( const char * pcRawMsg, pstUpdateFile->ulBlocksRemaining = ulNumBlocks; /* Initialize our blocks remaining counter. */ /* Create/Open the OTA file on the file system. */ - xErr = xOTA_Agent.xPALCallbacks.xCreateFileForRx( pstUpdateFile ); + xErr = xOTA_Agent.xPALCallbacks.xCreateFileForRx( pstUpdateFile ); if( xErr != kOTA_Err_None ) { @@ -2336,7 +2336,7 @@ static bool prvValidateDataBlock( const OTA_FileContext_t * C, uint32_t ulBlockIndex, uint32_t ulBlockSize ) { - bool bRet = false; + bool bRet = false; uint32_t ulLastBlock = 0; ulLastBlock = ( ( C->ulFileSize + ( OTA_FILE_BLOCK_SIZE - 1U ) ) >> otaconfigLOG2_FILE_BLOCK_SIZE ) - 1U; @@ -2368,15 +2368,15 @@ static IngestResult_t prvIngestDataBlock( OTA_FileContext_t * C, DEFINE_OTA_METHOD_NAME( "prvIngestDataBlock" ); IngestResult_t eIngestResult = eIngest_Result_Uninitialized; - int32_t lFileId = 0; - int32_t lBlockSize = 0; - int32_t lBlockIndex = 0; - uint32_t ulBlockSize = 0; - uint32_t ulBlockIndex = 0; - uint8_t * pucPayload = NULL; - size_t xPayloadSize = 0; - uint32_t ulByte = 0; - uint8_t ucBitMask = 0; + int32_t lFileId = 0; + int32_t lBlockSize = 0; + int32_t lBlockIndex = 0; + uint32_t ulBlockSize = 0; + uint32_t ulBlockIndex = 0; + uint8_t * pucPayload = NULL; + size_t xPayloadSize = 0; + uint32_t ulByte = 0; + uint8_t ucBitMask = 0; /* Check if the file context is NULL. */ if( C == NULL ) @@ -2422,7 +2422,7 @@ static IngestResult_t prvIngestDataBlock( OTA_FileContext_t * C, else { ulBlockIndex = ( uint32_t ) lBlockIndex; - ulBlockSize = ( uint32_t ) lBlockSize; + ulBlockSize = ( uint32_t ) lBlockSize; } } else @@ -2442,7 +2442,7 @@ static IngestResult_t prvIngestDataBlock( OTA_FileContext_t * C, ucBitMask = 1U << ( ulBlockIndex % BITS_PER_BYTE ); /*lint !e9031 The composite expression will never be greater than BITS_PER_BYTE(8). */ /* Calculate byte offset into bitmap. */ - ulByte = ulBlockIndex >> LOG2_BITS_PER_BYTE; + ulByte = ulBlockIndex >> LOG2_BITS_PER_BYTE; /* Check if we've already received this block. */ if( ( ( C->pucRxBlockBitmap[ ulByte ] ) & ucBitMask ) == 0U ) @@ -2451,7 +2451,7 @@ static IngestResult_t prvIngestDataBlock( OTA_FileContext_t * C, ulBlockIndex, C->ulBlocksRemaining ); - eIngestResult = eIngest_Result_Duplicate_Continue; + eIngestResult = eIngest_Result_Duplicate_Continue; *pxCloseResult = kOTA_Err_None; /* This is a success path. */ } } @@ -2478,8 +2478,8 @@ static IngestResult_t prvIngestDataBlock( OTA_FileContext_t * C, { C->pucRxBlockBitmap[ ulByte ] &= ~ucBitMask; /* Mark this block as received in our bitmap. */ C->ulBlocksRemaining--; - eIngestResult = eIngest_Result_Accepted_Continue; - *pxCloseResult = kOTA_Err_None; + eIngestResult = eIngest_Result_Accepted_Continue; + *pxCloseResult = kOTA_Err_None; } } else @@ -2528,7 +2528,7 @@ static IngestResult_t prvIngestDataBlock( OTA_FileContext_t * C, } } - C->pucFile = NULL; /* File is now closed so clear the file handle in the context. */ + C->pucFile = NULL; /* File is now closed so clear the file handle in the context. */ } else { @@ -2702,9 +2702,9 @@ static void prvOTAAgentTask( void * pvUnused ) ( void ) pvUnused; - OTA_EventMsg_t xEventMsg = { 0 }; - uint32_t ulTransitionTableLen = sizeof( OTATransitionTable ) / sizeof( OTATransitionTable[ 0 ] ); - uint32_t i = 0; + OTA_EventMsg_t xEventMsg = { 0 }; + uint32_t ulTransitionTableLen = sizeof( OTATransitionTable ) / sizeof( OTATransitionTable[ 0 ] ); + uint32_t i = 0; /* * OTA Agent is ready to receive and process events so update the state to ready. @@ -2755,12 +2755,12 @@ static BaseType_t prvStartOTAAgentTask( void * pvConnectionContext, TickType_t xTicksToWait ) { BaseType_t xReturn = 0; - uint32_t ulIndex = 0; + uint32_t ulIndex = 0; /* * The actual OTA Task and queue control structure. Only created once. */ - static TaskHandle_t pxOTA_TaskHandle; + static TaskHandle_t pxOTA_TaskHandle; static StaticQueue_t xStaticQueue; portENTER_CRITICAL(); @@ -2768,17 +2768,17 @@ static BaseType_t prvStartOTAAgentTask( void * pvConnectionContext, /* * The current OTA image state as set by the OTA agent. */ - xOTA_Agent.eImageState = eOTA_ImageState_Unknown; + xOTA_Agent.eImageState = eOTA_ImageState_Unknown; /* * Save the current connection context provided by the user. */ - xOTA_Agent.pvConnectionContext = pvConnectionContext; + xOTA_Agent.pvConnectionContext = pvConnectionContext; /* * Create the queue used to pass event messages to the OTA task. */ - xOTA_Agent.xOTA_EventQueue = xQueueCreateStatic( ( UBaseType_t ) OTA_NUM_MSG_Q_ENTRIES, ( UBaseType_t ) sizeof( OTA_EventMsg_t ), ( uint8_t * ) xQueueData, &xStaticQueue ); + xOTA_Agent.xOTA_EventQueue = xQueueCreateStatic( ( UBaseType_t ) OTA_NUM_MSG_Q_ENTRIES, ( UBaseType_t ) sizeof( OTA_EventMsg_t ), ( uint8_t * ) xQueueData, &xStaticQueue ); configASSERT( xOTA_Agent.xOTA_EventQueue != NULL ); /* @@ -2803,7 +2803,7 @@ static BaseType_t prvStartOTAAgentTask( void * pvConnectionContext, xEventBuffer[ ulIndex ].bBufferUsed = false; } - xReturn = xTaskCreate( prvOTAAgentTask, "OTA Agent Task", otaconfigSTACK_SIZE, NULL, otaconfigAGENT_PRIORITY, &pxOTA_TaskHandle ); + xReturn = xTaskCreate( prvOTAAgentTask, "OTA Agent Task", otaconfigSTACK_SIZE, NULL, otaconfigAGENT_PRIORITY, &pxOTA_TaskHandle ); portEXIT_CRITICAL(); /* Protected elements are initialized. It's now safe to context switch. */ @@ -2826,8 +2826,8 @@ bool OTA_SignalEvent( const OTA_EventMsg_t * const pxEventMsg ) { DEFINE_OTA_METHOD_NAME( "OTA_SignalEvent" ); - bool bReturn = false; - BaseType_t xErr = pdFALSE; + bool bReturn = false; + BaseType_t xErr = pdFALSE; /* * Send event to back of the queue. @@ -2874,7 +2874,7 @@ OTA_State_t OTA_AgentInit( void * pvConnectionContext, /* Set the OTA complete callback. */ xPALCallbacks.xCompleteCallback = xFunc; - xState = OTA_AgentInit_internal( pvConnectionContext, pucThingName, &xPALCallbacks, xTicksToWait ); + xState = OTA_AgentInit_internal( pvConnectionContext, pucThingName, &xPALCallbacks, xTicksToWait ); } /* If OTA agent is already running, just update the CompleteCallback and reset the statistics. */ else @@ -2898,13 +2898,13 @@ OTA_State_t OTA_AgentInit_internal( void * pvConnectionContext, { DEFINE_OTA_METHOD_NAME( "OTA_AgentInit_internal" ); - BaseType_t xReturn = 0; + BaseType_t xReturn = 0; OTA_EventMsg_t xEventMsg = { 0 }; /* * OTA Task is not running yet so update the state to init direclty in OTA context. */ - xOTA_Agent.eState = eOTA_AgentState_Init; + xOTA_Agent.eState = eOTA_AgentState_Init; /* * Check all the callbacks for null values and initialize the values in the ota agent context. @@ -2922,9 +2922,9 @@ OTA_State_t OTA_AgentInit_internal( void * pvConnectionContext, /* * Reset all the statistics counters. */ - xOTA_Agent.xStatistics.ulOTA_PacketsReceived = 0; - xOTA_Agent.xStatistics.ulOTA_PacketsDropped = 0; - xOTA_Agent.xStatistics.ulOTA_PacketsQueued = 0; + xOTA_Agent.xStatistics.ulOTA_PacketsReceived = 0; + xOTA_Agent.xStatistics.ulOTA_PacketsDropped = 0; + xOTA_Agent.xStatistics.ulOTA_PacketsQueued = 0; xOTA_Agent.xStatistics.ulOTA_PacketsProcessed = 0; if( pucThingName == NULL ) @@ -3061,7 +3061,7 @@ OTA_Err_t OTA_CheckForUpdate( void ) { DEFINE_OTA_METHOD_NAME( "OTA_CheckForUpdate" ); - OTA_Err_t xReturn = kOTA_Err_None; + OTA_Err_t xReturn = kOTA_Err_None; OTA_EventMsg_t xEventMsg = { 0 }; OTA_LOG_L1( "[%s] Sending event to check for update.\r\n", OTA_METHOD_NAME ); @@ -3125,7 +3125,7 @@ OTA_Err_t OTA_SetImageState( OTA_ImageState_t eState ) { DEFINE_OTA_METHOD_NAME( "OTA_SetImageState" ); - OTA_Err_t xErr = kOTA_Err_Uninitialized; + OTA_Err_t xErr = kOTA_Err_Uninitialized; OTA_EventMsg_t xEventMsg = { 0 }; switch( eState ) @@ -3139,7 +3139,7 @@ OTA_Err_t OTA_SetImageState( OTA_ImageState_t eState ) /* * Send the event, xOTA_Agent.eImageState will be set later when the event is processed. */ - xErr = OTA_SignalEvent( &xEventMsg ) ? kOTA_Err_None : kOTA_Err_EventQueueSendFailed; + xErr = OTA_SignalEvent( &xEventMsg ) ? kOTA_Err_None : kOTA_Err_EventQueueSendFailed; } else { @@ -3194,7 +3194,7 @@ OTA_Err_t OTA_Suspend( void ) { DEFINE_OTA_METHOD_NAME( "OTA_Suspend" ); - OTA_Err_t xErr = kOTA_Err_Uninitialized; + OTA_Err_t xErr = kOTA_Err_Uninitialized; OTA_EventMsg_t xEventMsg = { 0 }; /* Stop the request timer. */ @@ -3207,7 +3207,7 @@ OTA_Err_t OTA_Suspend( void ) * Send event to OTA agent task. */ xEventMsg.xEventId = eOTA_AgentEvent_Suspend; - xErr = OTA_SignalEvent( &xEventMsg ) ? kOTA_Err_None : kOTA_Err_EventQueueSendFailed; + xErr = OTA_SignalEvent( &xEventMsg ) ? kOTA_Err_None : kOTA_Err_EventQueueSendFailed; } else { @@ -3226,7 +3226,7 @@ OTA_Err_t OTA_Resume( void * pxConnection ) { DEFINE_OTA_METHOD_NAME( "OTA_Resume" ); - OTA_Err_t xErr = kOTA_Err_Uninitialized; + OTA_Err_t xErr = kOTA_Err_Uninitialized; OTA_EventMsg_t xEventMsg = { 0 }; xEventMsg.pxEventData = pxConnection; @@ -3238,7 +3238,7 @@ OTA_Err_t OTA_Resume( void * pxConnection ) * Send event to OTA agent task. */ xEventMsg.xEventId = eOTA_AgentEvent_Resume; - xErr = OTA_SignalEvent( &xEventMsg ) ? kOTA_Err_None : kOTA_Err_EventQueueSendFailed; + xErr = OTA_SignalEvent( &xEventMsg ) ? kOTA_Err_None : kOTA_Err_EventQueueSendFailed; } else { diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_interface.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_interface.c index 6eab921bd..2f9b81ead 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_interface.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/aws_iot_ota_interface.c @@ -72,7 +72,7 @@ void prvSetControlInterface( OTA_ControlInterface_t * pxControlInterface ) { #if ( configENABLED_CONTROL_PROTOCOL == OTA_CONTROL_OVER_MQTT ) - pxControlInterface->prvRequestJob = prvRequestJob_Mqtt; + pxControlInterface->prvRequestJob = prvRequestJob_Mqtt; pxControlInterface->prvUpdateJobStatus = prvUpdateJobStatus_Mqtt; #else #error "Enable MQTT control as control operations are only supported over MQTT." @@ -85,7 +85,7 @@ OTA_Err_t prvSetDataInterface( OTA_DataInterface_t * pxDataInterface, DEFINE_OTA_METHOD_NAME( "prvSetDataInterface" ); OTA_Err_t xErr = kOTA_Err_InvalidDataProtocol; - uint32_t i; + uint32_t i; for( i = 0; i < OTA_DATA_NUM_PROTOCOLS; i++ ) { @@ -96,12 +96,12 @@ OTA_Err_t prvSetDataInterface( OTA_DataInterface_t * pxDataInterface, { pxDataInterface->prvInitFileTransfer = prvInitFileTransfer_Mqtt; pxDataInterface->prvRequestFileBlock = prvRequestFileBlock_Mqtt; - pxDataInterface->prvDecodeFileBlock = prvDecodeFileBlock_Mqtt; - pxDataInterface->prvCleanup = prvCleanup_Mqtt; + pxDataInterface->prvDecodeFileBlock = prvDecodeFileBlock_Mqtt; + pxDataInterface->prvCleanup = prvCleanup_Mqtt; OTA_LOG_L1( "[%s] Data interface is set to MQTT.\r\n", OTA_METHOD_NAME ); - xErr = kOTA_Err_None; + xErr = kOTA_Err_None; break; } #endif /* if ( configENABLED_DATA_PROTOCOLS & OTA_DATA_OVER_MQTT ) */ @@ -111,12 +111,12 @@ OTA_Err_t prvSetDataInterface( OTA_DataInterface_t * pxDataInterface, { pxDataInterface->prvInitFileTransfer = _AwsIotOTA_InitFileTransfer_HTTP; pxDataInterface->prvRequestFileBlock = _AwsIotOTA_RequestDataBlock_HTTP; - pxDataInterface->prvDecodeFileBlock = _AwsIotOTA_DecodeFileBlock_HTTP; - pxDataInterface->prvCleanup = _AwsIotOTA_Cleanup_HTTP; + pxDataInterface->prvDecodeFileBlock = _AwsIotOTA_DecodeFileBlock_HTTP; + pxDataInterface->prvCleanup = _AwsIotOTA_Cleanup_HTTP; OTA_LOG_L1( "[%s] Data interface is set to HTTP.\r\n", OTA_METHOD_NAME ); - xErr = kOTA_Err_None; + xErr = kOTA_Err_None; break; } #endif /* if ( configENABLED_DATA_PROTOCOLS & OTA_DATA_OVER_HTTP ) */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/http/aws_iot_ota_http.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/http/aws_iot_ota_http.c index 654ee9c30..d1a6b6b54 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/http/aws_iot_ota_http.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/http/aws_iot_ota_http.c @@ -202,13 +202,13 @@ typedef struct _httpDownloader } _httpDownloader_t; /* Global HTTP downloader instance. */ -static _httpDownloader_t _httpDownloader = { 0 }; +static _httpDownloader_t _httpDownloader = { 0 }; /* Buffers for HTTP library. */ -uint8_t * pConnectionUserBuffer = NULL; /* Buffer to store the HTTP connection context. */ -uint8_t * pRequestUserBuffer = NULL; /* Buffer to store the HTTP request context and header. */ -uint8_t * pResponseUserBuffer = NULL; /* Buffer to store the HTTP response context and header. */ -uint8_t * pResponseBodyBuffer = NULL; /* Buffer to store the HTTP response body. */ +uint8_t * pConnectionUserBuffer = NULL; /* Buffer to store the HTTP connection context. */ +uint8_t * pRequestUserBuffer = NULL; /* Buffer to store the HTTP request context and header. */ +uint8_t * pResponseUserBuffer = NULL; /* Buffer to store the HTTP response context and header. */ +uint8_t * pResponseBodyBuffer = NULL; /* Buffer to store the HTTP response body. */ /* We need to use this function defined in iot_logging_task_dynamic_buffers.c to print HTTP message * without appending the task name and tick count. */ @@ -229,7 +229,7 @@ static bool _httpAllocateBuffers() isSuccess = false; } - pRequestUserBuffer = pvPortMalloc( HTTPS_REQUEST_USER_BUFFER_SIZE ); + pRequestUserBuffer = pvPortMalloc( HTTPS_REQUEST_USER_BUFFER_SIZE ); if( isSuccess && ( pRequestUserBuffer == NULL ) ) { @@ -237,7 +237,7 @@ static bool _httpAllocateBuffers() isSuccess = false; } - pResponseUserBuffer = pvPortMalloc( HTTPS_RESPONSE_USER_BUFFER_SIZE ); + pResponseUserBuffer = pvPortMalloc( HTTPS_RESPONSE_USER_BUFFER_SIZE ); if( isSuccess && ( pResponseUserBuffer == NULL ) ) { @@ -245,7 +245,7 @@ static bool _httpAllocateBuffers() isSuccess = false; } - pResponseBodyBuffer = pvPortMalloc( HTTPS_RESPONSE_BODY_BUFFER_SIZE ); + pResponseBodyBuffer = pvPortMalloc( HTTPS_RESPONSE_BODY_BUFFER_SIZE ); if( isSuccess && ( pResponseBodyBuffer == NULL ) ) { @@ -293,7 +293,7 @@ static void _httpProcessResponseBody( OTA_AgentContext_t * pAgentCtx, IotLogDebug( "Invoking _httpProcessResponseBody" ); OTA_EventData_t * pMessage; - OTA_EventMsg_t eventMsg = { 0 }; + OTA_EventMsg_t eventMsg = { 0 }; pAgentCtx->xStatistics.ulOTA_PacketsReceived++; @@ -310,8 +310,8 @@ static void _httpProcessResponseBody( OTA_AgentContext_t * pAgentCtx, pMessage->ulDataLength = bufferSize; memcpy( pMessage->ucData, pHTTPResponseBody, pMessage->ulDataLength ); - eventMsg.xEventId = eOTA_AgentEvent_ReceivedFileBlock; - eventMsg.pxEventData = pMessage; + eventMsg.xEventId = eOTA_AgentEvent_ReceivedFileBlock; + eventMsg.pxEventData = pMessage; /* Send job document received event. */ OTA_SignalEvent( &eventMsg ); } @@ -321,7 +321,7 @@ static void _httpProcessResponseBody( OTA_AgentContext_t * pAgentCtx, static void _httpErrorHandler( uint16_t responseCode ) { const char * pResponseBody = ( const char * ) pResponseBodyBuffer; - char * endPos = NULL; + char * endPos = NULL; /* Force the response body to be NULL terminated. */ pResponseBodyBuffer[ HTTPS_RESPONSE_BODY_BUFFER_SIZE - 1 ] = '\0'; @@ -387,14 +387,14 @@ static void _httpAppendHeaderCallback( void * pPrivateData, IotLogDebug( "Invoking _httpAppendHeaderCallback." ); /* Value of the "Range" field in HTTP GET request header, set when requesting the file block. */ - char * pRangeValueStr = ( ( _httpCallbackData_t * ) ( pPrivateData ) )->pRangeValueStr; + char * pRangeValueStr = ( ( _httpCallbackData_t * ) ( pPrivateData ) )->pRangeValueStr; /* Set the header for this range request. */ - IotHttpsReturnCode_t status = IotHttpsClient_AddHeader( requestHandle, - "Range", - sizeof( "Range" ) - 1, - pRangeValueStr, - strlen( pRangeValueStr ) ); + IotHttpsReturnCode_t status = IotHttpsClient_AddHeader( requestHandle, + "Range", + sizeof( "Range" ) - 1, + pRangeValueStr, + strlen( pRangeValueStr ) ); /* If case of error, the request will be canceled, then _httpErrorCallback will be invoked, * followed by _httpResponseCompleteCallback. */ @@ -424,25 +424,25 @@ static void _httpReadReadyCallback( void * pPrivateData, ( void ) returnCode; /* HTTP return status. */ - IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK; + IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK; /* The content length of this HTTP response. */ - uint32_t contentLength = 0; + uint32_t contentLength = 0; /* Size of the response body returned from HTTP API. */ - uint32_t responseBodyLength = 0; + uint32_t responseBodyLength = 0; /* Buffer to read the "Connection" field in HTTP header. */ - char connectionValueStr[ HTTP_HEADER_CONNECTION_VALUE_MAX_LEN ] = { 0 }; + char connectionValueStr[ HTTP_HEADER_CONNECTION_VALUE_MAX_LEN ] = { 0 }; /* A response is received from the server, setting the state to processing response. */ _httpDownloader.state = OTA_HTTP_PROCESSING_RESPONSE; /* Read the data from the network. */ - responseBodyLength = HTTPS_RESPONSE_BODY_BUFFER_SIZE; - httpsStatus = IotHttpsClient_ReadResponseBody( responseHandle, - pResponseBodyBuffer, - &responseBodyLength ); + responseBodyLength = HTTPS_RESPONSE_BODY_BUFFER_SIZE; + httpsStatus = IotHttpsClient_ReadResponseBody( responseHandle, + pResponseBodyBuffer, + &responseBodyLength ); if( httpsStatus != IOT_HTTPS_OK ) { @@ -460,7 +460,7 @@ static void _httpReadReadyCallback( void * pPrivateData, } /* Read the "Content-Length" field from HTTP header. */ - httpsStatus = IotHttpsClient_ReadContentLength( responseHandle, &contentLength ); + httpsStatus = IotHttpsClient_ReadContentLength( responseHandle, &contentLength ); if( ( httpsStatus != IOT_HTTPS_OK ) || ( contentLength == 0 ) ) { @@ -482,11 +482,11 @@ static void _httpReadReadyCallback( void * pPrivateData, /* The connection could be closed by S3 after 100 requests, so we need to check the value * of the "Connection" filed in HTTP header to see if we need to reconnect. */ memset( connectionValueStr, 0, sizeof( connectionValueStr ) ); - httpsStatus = IotHttpsClient_ReadHeader( responseHandle, - "Connection", - sizeof( "Connection" ) - 1, - connectionValueStr, - sizeof( connectionValueStr ) ); + httpsStatus = IotHttpsClient_ReadHeader( responseHandle, + "Connection", + sizeof( "Connection" ) - 1, + connectionValueStr, + sizeof( connectionValueStr ) ); /* Check if there is any other error besides not found when parsing the http header. */ if( ( httpsStatus != IOT_HTTPS_OK ) && ( httpsStatus != IOT_HTTPS_NOT_FOUND ) ) @@ -618,7 +618,7 @@ static IotHttpsReturnCode_t _httpInitUrl( const char * pURL ) IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK; /* HTTP URL information. */ - _httpUrlInfo_t * pUrlInfo = &_httpDownloader.httpUrlInfo; + _httpUrlInfo_t * pUrlInfo = &_httpDownloader.httpUrlInfo; /* Retrieve the resource path from the HTTP URL. pPath will point to the start of this part. */ httpsStatus = IotHttpsClient_GetUrlPath( pURL, @@ -633,10 +633,10 @@ static IotHttpsReturnCode_t _httpInitUrl( const char * pURL ) pUrlInfo->pathLength = strlen( pUrlInfo->pPath ); /* Retrieve the authority part and length from the HTTP URL. */ - httpsStatus = IotHttpsClient_GetUrlAddress( pURL, - strlen( pURL ), - &pUrlInfo->pAddress, - &pUrlInfo->addressLength ); + httpsStatus = IotHttpsClient_GetUrlAddress( pURL, + strlen( pURL ), + &pUrlInfo->pAddress, + &pUrlInfo->addressLength ); if( httpsStatus != IOT_HTTPS_OK ) { @@ -655,60 +655,60 @@ static IotHttpsReturnCode_t _httpConnect( const IotNetworkInterface_t * pNetwork struct IotNetworkCredentials * pNetworkCredentials ) { /* HTTP API return status. */ - IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK; + IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK; /* HTTP connection data. */ - _httpConnection_t * pConnection = &_httpDownloader.httpConnection; + _httpConnection_t * pConnection = &_httpDownloader.httpConnection; /* HTTP connection configuration. */ IotHttpsConnectionInfo_t * pConnectionConfig = &pConnection->connectionConfig; /* HTTP request data. */ - _httpRequest_t * pRequest = &_httpDownloader.httpRequest; + _httpRequest_t * pRequest = &_httpDownloader.httpRequest; /* HTTP response data. */ - _httpResponse_t * pResponse = &_httpDownloader.httpResponse; + _httpResponse_t * pResponse = &_httpDownloader.httpResponse; /* HTTP URL information. */ - _httpUrlInfo_t * pUrlInfo = &_httpDownloader.httpUrlInfo; + _httpUrlInfo_t * pUrlInfo = &_httpDownloader.httpUrlInfo; /* Set the connection configurations. */ - pConnectionConfig->pAddress = pUrlInfo->pAddress; - pConnectionConfig->addressLen = pUrlInfo->addressLength; - pConnectionConfig->port = HTTPS_PORT; - pConnectionConfig->pCaCert = HTTPS_TRUSTED_ROOT_CA; - pConnectionConfig->caCertLen = sizeof( HTTPS_TRUSTED_ROOT_CA ); - pConnectionConfig->userBuffer.pBuffer = pConnectionUserBuffer; - pConnectionConfig->userBuffer.bufferLen = HTTPS_CONNECTION_USER_BUFFER_SIZE; - pConnectionConfig->pClientCert = pNetworkCredentials->pClientCert; - pConnectionConfig->clientCertLen = pNetworkCredentials->clientCertSize; - pConnectionConfig->pPrivateKey = pNetworkCredentials->pPrivateKey; - pConnectionConfig->privateKeyLen = pNetworkCredentials->privateKeySize; - pConnectionConfig->pNetworkInterface = pNetworkInterface; + pConnectionConfig->pAddress = pUrlInfo->pAddress; + pConnectionConfig->addressLen = pUrlInfo->addressLength; + pConnectionConfig->port = HTTPS_PORT; + pConnectionConfig->pCaCert = HTTPS_TRUSTED_ROOT_CA; + pConnectionConfig->caCertLen = sizeof( HTTPS_TRUSTED_ROOT_CA ); + pConnectionConfig->userBuffer.pBuffer = pConnectionUserBuffer; + pConnectionConfig->userBuffer.bufferLen = HTTPS_CONNECTION_USER_BUFFER_SIZE; + pConnectionConfig->pClientCert = pNetworkCredentials->pClientCert; + pConnectionConfig->clientCertLen = pNetworkCredentials->clientCertSize; + pConnectionConfig->pPrivateKey = pNetworkCredentials->pPrivateKey; + pConnectionConfig->privateKeyLen = pNetworkCredentials->privateKeySize; + pConnectionConfig->pNetworkInterface = pNetworkInterface; /* Initialize HTTP request configuration. */ - pRequest->requestConfig.pPath = pUrlInfo->pPath; - pRequest->requestConfig.pathLen = pUrlInfo->pathLength; - pRequest->requestConfig.pHost = pUrlInfo->pAddress; - pRequest->requestConfig.hostLen = pUrlInfo->addressLength; - pRequest->requestConfig.method = IOT_HTTPS_METHOD_GET; - pRequest->requestConfig.userBuffer.pBuffer = pRequestUserBuffer; - pRequest->requestConfig.userBuffer.bufferLen = HTTPS_REQUEST_USER_BUFFER_SIZE; - pRequest->requestConfig.isAsync = true; - pRequest->requestConfig.u.pAsyncInfo = &pRequest->asyncInfo; + pRequest->requestConfig.pPath = pUrlInfo->pPath; + pRequest->requestConfig.pathLen = pUrlInfo->pathLength; + pRequest->requestConfig.pHost = pUrlInfo->pAddress; + pRequest->requestConfig.hostLen = pUrlInfo->addressLength; + pRequest->requestConfig.method = IOT_HTTPS_METHOD_GET; + pRequest->requestConfig.userBuffer.pBuffer = pRequestUserBuffer; + pRequest->requestConfig.userBuffer.bufferLen = HTTPS_REQUEST_USER_BUFFER_SIZE; + pRequest->requestConfig.isAsync = true; + pRequest->requestConfig.u.pAsyncInfo = &pRequest->asyncInfo; /* Initialize HTTP response configuration. */ - pResponse->responseConfig.userBuffer.pBuffer = pResponseUserBuffer; - pResponse->responseConfig.userBuffer.bufferLen = HTTPS_RESPONSE_USER_BUFFER_SIZE; - pResponse->responseConfig.pSyncInfo = NULL; + pResponse->responseConfig.userBuffer.pBuffer = pResponseUserBuffer; + pResponse->responseConfig.userBuffer.bufferLen = HTTPS_RESPONSE_USER_BUFFER_SIZE; + pResponse->responseConfig.pSyncInfo = NULL; /* Initialize HTTP asynchronous configuration. */ - pRequest->asyncInfo.callbacks.appendHeaderCallback = _httpAppendHeaderCallback; - pRequest->asyncInfo.callbacks.readReadyCallback = _httpReadReadyCallback; + pRequest->asyncInfo.callbacks.appendHeaderCallback = _httpAppendHeaderCallback; + pRequest->asyncInfo.callbacks.readReadyCallback = _httpReadReadyCallback; pRequest->asyncInfo.callbacks.responseCompleteCallback = _httpResponseCompleteCallback; - pRequest->asyncInfo.callbacks.errorCallback = _httpErrorCallback; + pRequest->asyncInfo.callbacks.errorCallback = _httpErrorCallback; pRequest->asyncInfo.callbacks.connectionClosedCallback = _httpConnectionClosedCallback; - pRequest->asyncInfo.pPrivData = ( void * ) ( &_httpDownloader.httpCallbackData ); + pRequest->asyncInfo.pPrivData = ( void * ) ( &_httpDownloader.httpCallbackData ); httpsStatus = IotHttpsClient_Connect( &pConnection->connectionHandle, pConnectionConfig ); @@ -722,60 +722,60 @@ static IotHttpsReturnCode_t _httpConnect( const IotNetworkInterface_t * pNetwork static _httpErr _httpGetFileSize( uint32_t * pFileSize ) { /* Return status. */ - _httpErr status = OTA_HTTP_ERR_NONE; - IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK; + _httpErr status = OTA_HTTP_ERR_NONE; + IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK; /* HTTP response code. */ - uint16_t responseStatus = IOT_HTTPS_STATUS_OK; + uint16_t responseStatus = IOT_HTTPS_STATUS_OK; /* HTTP request and response configurations. We're creating local variables here because this is * a temporary synchronous request. */ - IotHttpsRequestInfo_t requestConfig = { 0 }; - IotHttpsResponseInfo_t responseConfig = { 0 }; + IotHttpsRequestInfo_t requestConfig = { 0 }; + IotHttpsResponseInfo_t responseConfig = { 0 }; /* Synchronous request and response configurations. */ - IotHttpsSyncInfo_t requestSyncInfo = { 0 }; - IotHttpsSyncInfo_t responseSyncInfo = { 0 }; + IotHttpsSyncInfo_t requestSyncInfo = { 0 }; + IotHttpsSyncInfo_t responseSyncInfo = { 0 }; /* Handle for HTTP request and response. */ - IotHttpsRequestHandle_t requestHandle = NULL; - IotHttpsResponseHandle_t responseHandle = NULL; + IotHttpsRequestHandle_t requestHandle = NULL; + IotHttpsResponseHandle_t responseHandle = NULL; /* HTTP URL information. */ - _httpUrlInfo_t * pUrlInfo = &_httpDownloader.httpUrlInfo; + _httpUrlInfo_t * pUrlInfo = &_httpDownloader.httpUrlInfo; /* Value of the "Content-Range" field in HTTP response header. The format is "bytes 0-0/FILESIZE". */ - char pContentRange[ sizeof( "bytes 0-0/" ) + OTA_MAX_FILE_SIZE_STR_LEN ] = { 0 }; + char pContentRange[ sizeof( "bytes 0-0/" ) + OTA_MAX_FILE_SIZE_STR_LEN ] = { 0 }; /* Pointer to the location of the file size in pContentRange. */ char * pFileSizeStr = NULL; /* There's no message body in this GET request. */ - requestSyncInfo.pBody = NULL; - requestSyncInfo.bodyLen = 0; + requestSyncInfo.pBody = NULL; + requestSyncInfo.bodyLen = 0; /* Store the response body in case there's any failure. */ - responseSyncInfo.pBody = pResponseBodyBuffer; - responseSyncInfo.bodyLen = HTTPS_RESPONSE_BODY_BUFFER_SIZE; + responseSyncInfo.pBody = pResponseBodyBuffer; + responseSyncInfo.bodyLen = HTTPS_RESPONSE_BODY_BUFFER_SIZE; /* Set the request configurations. */ - requestConfig.pPath = pUrlInfo->pPath; - requestConfig.pathLen = pUrlInfo->pathLength; - requestConfig.pHost = pUrlInfo->pAddress; - requestConfig.hostLen = pUrlInfo->addressLength; - requestConfig.method = IOT_HTTPS_METHOD_GET; - requestConfig.userBuffer.pBuffer = pRequestUserBuffer; - requestConfig.userBuffer.bufferLen = HTTPS_REQUEST_USER_BUFFER_SIZE; - requestConfig.isAsync = false; - requestConfig.u.pSyncInfo = &requestSyncInfo; + requestConfig.pPath = pUrlInfo->pPath; + requestConfig.pathLen = pUrlInfo->pathLength; + requestConfig.pHost = pUrlInfo->pAddress; + requestConfig.hostLen = pUrlInfo->addressLength; + requestConfig.method = IOT_HTTPS_METHOD_GET; + requestConfig.userBuffer.pBuffer = pRequestUserBuffer; + requestConfig.userBuffer.bufferLen = HTTPS_REQUEST_USER_BUFFER_SIZE; + requestConfig.isAsync = false; + requestConfig.u.pSyncInfo = &requestSyncInfo; /* Set the response configurations. */ - responseConfig.userBuffer.pBuffer = pResponseUserBuffer; + responseConfig.userBuffer.pBuffer = pResponseUserBuffer; responseConfig.userBuffer.bufferLen = HTTPS_RESPONSE_USER_BUFFER_SIZE; - responseConfig.pSyncInfo = &responseSyncInfo; + responseConfig.pSyncInfo = &responseSyncInfo; /* Initialize the request to retrieve a request handle. */ - httpsStatus = IotHttpsClient_InitializeRequest( &requestHandle, &requestConfig ); + httpsStatus = IotHttpsClient_InitializeRequest( &requestHandle, &requestConfig ); if( httpsStatus != IOT_HTTPS_OK ) { @@ -785,11 +785,11 @@ static _httpErr _httpGetFileSize( uint32_t * pFileSize ) } /* Set the "Range" field in HTTP header to "bytes=0-0" since we just want the file size. */ - httpsStatus = IotHttpsClient_AddHeader( requestHandle, - "Range", - sizeof( "Range" ) - 1, - "bytes=0-0", - sizeof( "bytes=0-0" ) - 1 ); + httpsStatus = IotHttpsClient_AddHeader( requestHandle, + "Range", + sizeof( "Range" ) - 1, + "bytes=0-0", + sizeof( "bytes=0-0" ) - 1 ); if( httpsStatus != IOT_HTTPS_OK ) { @@ -799,11 +799,11 @@ static _httpErr _httpGetFileSize( uint32_t * pFileSize ) } /* Send the request synchronously. */ - httpsStatus = IotHttpsClient_SendSync( _httpDownloader.httpConnection.connectionHandle, - requestHandle, - &responseHandle, - &responseConfig, - HTTP_SYNC_TIMEOUT ); + httpsStatus = IotHttpsClient_SendSync( _httpDownloader.httpConnection.connectionHandle, + requestHandle, + &responseHandle, + &responseConfig, + HTTP_SYNC_TIMEOUT ); if( httpsStatus != IOT_HTTPS_OK ) { @@ -812,7 +812,7 @@ static _httpErr _httpGetFileSize( uint32_t * pFileSize ) OTA_GOTO_CLEANUP(); } - httpsStatus = IotHttpsClient_ReadResponseStatus( responseHandle, &responseStatus ); + httpsStatus = IotHttpsClient_ReadResponseStatus( responseHandle, &responseStatus ); if( httpsStatus != IOT_HTTPS_OK ) { @@ -830,11 +830,11 @@ static _httpErr _httpGetFileSize( uint32_t * pFileSize ) } /* Parse the HTTP header and retrieve the file size. */ - httpsStatus = IotHttpsClient_ReadHeader( responseHandle, - "Content-Range", - sizeof( "Content-Range" ) - 1, - pContentRange, - sizeof( pContentRange ) ); + httpsStatus = IotHttpsClient_ReadHeader( responseHandle, + "Content-Range", + sizeof( "Content-Range" ) - 1, + pContentRange, + sizeof( pContentRange ) ); if( httpsStatus != IOT_HTTPS_OK ) { @@ -843,7 +843,7 @@ static _httpErr _httpGetFileSize( uint32_t * pFileSize ) OTA_GOTO_CLEANUP(); } - pFileSizeStr = strstr( pContentRange, "/" ); + pFileSizeStr = strstr( pContentRange, "/" ); if( pFileSizeStr == NULL ) { @@ -856,7 +856,7 @@ static _httpErr _httpGetFileSize( uint32_t * pFileSize ) pFileSizeStr += sizeof( char ); } - *pFileSize = ( uint32_t ) strtoul( pFileSizeStr, NULL, 10 ); + *pFileSize = ( uint32_t ) strtoul( pFileSizeStr, NULL, 10 ); if( ( *pFileSize == 0 ) || ( *pFileSize == UINT32_MAX ) ) { @@ -917,28 +917,28 @@ OTA_Err_t _AwsIotOTA_InitFileTransfer_HTTP( OTA_AgentContext_t * pAgentCtx ) IotLogDebug( "Invoking _AwsIotOTA_InitFileTransfer_HTTP" ); /* Return status. */ - OTA_Err_t status = kOTA_Err_None; - IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK; + OTA_Err_t status = kOTA_Err_None; + IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK; /* Cleanup status. */ - bool cleanupRequired = false; + bool cleanupRequired = false; /* Network interface and credentials from OTA agent. */ - OTA_ConnectionContext_t * connContext = pAgentCtx->pvConnectionContext; - const IotNetworkInterface_t * pNetworkInterface = connContext->pxNetworkInterface; + OTA_ConnectionContext_t * connContext = pAgentCtx->pvConnectionContext; + const IotNetworkInterface_t * pNetworkInterface = connContext->pxNetworkInterface; struct IotNetworkCredentials * pNetworkCredentials = connContext->pvNetworkCredentials; /* Pre-signed URL. */ - const char * pURL = NULL; + const char * pURL = NULL; /* File context from OTA agent. */ - OTA_FileContext_t * fileContext = &( pAgentCtx->pxOTA_Files[ pAgentCtx->ulFileIndex ] ); + OTA_FileContext_t * fileContext = &( pAgentCtx->pxOTA_Files[ pAgentCtx->ulFileIndex ] ); /* OTA download file size from OTA agent (parsed from job document). */ - uint32_t otaFileSize = 0; + uint32_t otaFileSize = 0; /* OTA download file size from the HTTP server, this should match otaFileSize. */ - uint32_t httpFileSize = 0; + uint32_t httpFileSize = 0; /* Store the OTA agent for later access. */ _httpDownloader.pAgentCtx = pAgentCtx; @@ -951,14 +951,14 @@ OTA_Err_t _AwsIotOTA_InitFileTransfer_HTTP( OTA_AgentContext_t * pAgentCtx ) } /* Get the file size from OTA agent (parsed from job document). */ - otaFileSize = fileContext->ulFileSize; + otaFileSize = fileContext->ulFileSize; /* Get pre-signed URL from pAgentCtx. */ - pURL = ( const char * ) ( fileContext->pucUpdateUrlPath ); + pURL = ( const char * ) ( fileContext->pucUpdateUrlPath ); IotLogInfo( "Pre-signed URL size: %d.", strlen( pURL ) ); /* Initialize the HTTPS library. */ - httpsStatus = IotHttpsClient_Init(); + httpsStatus = IotHttpsClient_Init(); if( httpsStatus != IOT_HTTPS_OK ) { @@ -975,23 +975,23 @@ OTA_Err_t _AwsIotOTA_InitFileTransfer_HTTP( OTA_AgentContext_t * pAgentCtx ) } /* Connect to the HTTP server and initialize download information. */ - httpsStatus = _httpInitUrl( pURL ); + httpsStatus = _httpInitUrl( pURL ); if( httpsStatus != IOT_HTTPS_OK ) { IotLogError( "Failed to parse the HTTP Url. Error code: %d", httpsStatus ); - status = kOTA_Err_HTTPInitFailed; + status = kOTA_Err_HTTPInitFailed; cleanupRequired = true; OTA_GOTO_CLEANUP(); } - httpsStatus = _httpConnect( pNetworkInterface, pNetworkCredentials ); + httpsStatus = _httpConnect( pNetworkInterface, pNetworkCredentials ); if( httpsStatus != IOT_HTTPS_OK ) { IotLogError( "Failed to connect to %.*s. Error code: %d", _httpDownloader.httpUrlInfo.addressLength, _httpDownloader.httpUrlInfo.pAddress, httpsStatus ); - status = kOTA_Err_HTTPInitFailed; + status = kOTA_Err_HTTPInitFailed; cleanupRequired = true; OTA_GOTO_CLEANUP(); } @@ -1002,7 +1002,7 @@ OTA_Err_t _AwsIotOTA_InitFileTransfer_HTTP( OTA_AgentContext_t * pAgentCtx ) if( _httpGetFileSize( &httpFileSize ) != OTA_HTTP_ERR_NONE ) { IotLogError( "Cannot retrieve the file size from HTTP server." ); - status = kOTA_Err_HTTPInitFailed; + status = kOTA_Err_HTTPInitFailed; cleanupRequired = true; OTA_GOTO_CLEANUP(); } @@ -1013,7 +1013,7 @@ OTA_Err_t _AwsIotOTA_InitFileTransfer_HTTP( OTA_AgentContext_t * pAgentCtx ) "job document (%u bytes).", ( unsigned int ) httpFileSize, ( unsigned int ) otaFileSize ); - status = kOTA_Err_HTTPInitFailed; + status = kOTA_Err_HTTPInitFailed; cleanupRequired = true; OTA_GOTO_CLEANUP(); } @@ -1038,25 +1038,25 @@ OTA_Err_t _AwsIotOTA_RequestDataBlock_HTTP( OTA_AgentContext_t * pAgentCtx ) IotLogDebug( "Invoking _AwsIotOTA_RequestDataBlock_HTTP" ); /* Return status. */ - OTA_Err_t status = kOTA_Err_None; + OTA_Err_t status = kOTA_Err_None; IotHttpsReturnCode_t httpsStatus = IOT_HTTPS_OK; /* HTTP connection data. */ - _httpConnection_t * pConnection = &_httpDownloader.httpConnection; + _httpConnection_t * pConnection = &_httpDownloader.httpConnection; /* HTTP request data. */ - _httpRequest_t * pRequest = &_httpDownloader.httpRequest; + _httpRequest_t * pRequest = &_httpDownloader.httpRequest; /* HTTP response data. */ - _httpResponse_t * pResponse = &_httpDownloader.httpResponse; + _httpResponse_t * pResponse = &_httpDownloader.httpResponse; /* Values for the "Range" field in HTTP header. */ - uint32_t rangeStart = 0; - uint32_t rangeEnd = 0; - int numWritten = 0; + uint32_t rangeStart = 0; + uint32_t rangeEnd = 0; + int numWritten = 0; /* File context from OTA agent. */ - OTA_FileContext_t * fileContext = &( pAgentCtx->pxOTA_Files[ pAgentCtx->ulFileIndex ] ); + OTA_FileContext_t * fileContext = &( pAgentCtx->pxOTA_Files[ pAgentCtx->ulFileIndex ] ); /* Exit if we're still busy downloading or reconnect is required but failed. */ if( _requestDataBlockPreCheck() != OTA_HTTP_ERR_NONE ) @@ -1065,8 +1065,8 @@ OTA_Err_t _AwsIotOTA_RequestDataBlock_HTTP( OTA_AgentContext_t * pAgentCtx ) OTA_GOTO_CLEANUP(); } - _httpDownloader.state = OTA_HTTP_SENDING_REQUEST; - _httpDownloader.err = OTA_HTTP_ERR_NONE; + _httpDownloader.state = OTA_HTTP_SENDING_REQUEST; + _httpDownloader.err = OTA_HTTP_ERR_NONE; if( fileContext == NULL ) { @@ -1079,7 +1079,7 @@ OTA_Err_t _AwsIotOTA_RequestDataBlock_HTTP( OTA_AgentContext_t * pAgentCtx ) pAgentCtx->ulNumOfBlocksToReceive = 1; /* Calculate ranges. */ - rangeStart = _httpDownloader.currBlock * OTA_FILE_BLOCK_SIZE; + rangeStart = _httpDownloader.currBlock * OTA_FILE_BLOCK_SIZE; if( fileContext->ulBlocksRemaining == 1 ) { @@ -1090,14 +1090,14 @@ OTA_Err_t _AwsIotOTA_RequestDataBlock_HTTP( OTA_AgentContext_t * pAgentCtx ) rangeEnd = rangeStart + OTA_FILE_BLOCK_SIZE - 1; } - _httpDownloader.currBlockSize = rangeEnd - rangeStart + 1; + _httpDownloader.currBlockSize = rangeEnd - rangeStart + 1; /* Creating the "range" field in HTTP header. */ - numWritten = snprintf( _httpDownloader.httpCallbackData.pRangeValueStr, - HTTP_HEADER_RANGE_VALUE_MAX_LEN, - "bytes=%u-%u", - ( unsigned int ) rangeStart, - ( unsigned int ) rangeEnd ); + numWritten = snprintf( _httpDownloader.httpCallbackData.pRangeValueStr, + HTTP_HEADER_RANGE_VALUE_MAX_LEN, + "bytes=%u-%u", + ( unsigned int ) rangeStart, + ( unsigned int ) rangeEnd ); if( ( numWritten < 0 ) || ( numWritten >= HTTP_HEADER_RANGE_VALUE_MAX_LEN ) ) { @@ -1107,7 +1107,7 @@ OTA_Err_t _AwsIotOTA_RequestDataBlock_HTTP( OTA_AgentContext_t * pAgentCtx ) } /* Re-initialize the request handle as it could be changed when handling last response. */ - httpsStatus = IotHttpsClient_InitializeRequest( &pRequest->requestHandle, &pRequest->requestConfig ); + httpsStatus = IotHttpsClient_InitializeRequest( &pRequest->requestHandle, &pRequest->requestConfig ); if( httpsStatus != IOT_HTTPS_OK ) { @@ -1118,10 +1118,10 @@ OTA_Err_t _AwsIotOTA_RequestDataBlock_HTTP( OTA_AgentContext_t * pAgentCtx ) /* Send the request asynchronously. Receiving is handled in a callback. */ IotLogInfo( "Sending HTTP request to download block %d.", _httpDownloader.currBlock ); - httpsStatus = IotHttpsClient_SendAsync( pConnection->connectionHandle, - pRequest->requestHandle, - &pResponse->responseHandle, - &pResponse->responseConfig ); + httpsStatus = IotHttpsClient_SendAsync( pConnection->connectionHandle, + pRequest->requestHandle, + &pResponse->responseHandle, + &pResponse->responseConfig ); if( httpsStatus != IOT_HTTPS_OK ) { @@ -1156,14 +1156,14 @@ OTA_Err_t _AwsIotOTA_DecodeFileBlock_HTTP( uint8_t * pMessageBuffer, /* Unused parameters. */ ( void ) messageSize; - *pPayload = pMessageBuffer; - *pFileId = 0; - *pBlockId = _httpDownloader.currBlock; - *pBlockSize = _httpDownloader.currBlockSize; - *pPayloadSize = _httpDownloader.currBlockSize; + *pPayload = pMessageBuffer; + *pFileId = 0; + *pBlockId = _httpDownloader.currBlock; + *pBlockSize = _httpDownloader.currBlockSize; + *pPayloadSize = _httpDownloader.currBlockSize; /* Current block is processed, set the file block to next one and the state to idle. */ - _httpDownloader.state = OTA_HTTP_IDLE; + _httpDownloader.state = OTA_HTTP_IDLE; _httpDownloader.currBlock += 1; return kOTA_Err_None; diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_cbor.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_cbor.c index b304d52cd..8bfa8a101 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_cbor.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_cbor.c @@ -59,9 +59,9 @@ BaseType_t OTA_CBOR_Decode_GetStreamResponseMessage( const uint8_t * pucMessageB uint8_t ** ppucPayload, size_t * pxPayloadSize ) { - CborError xCborResult = CborNoError; + CborError xCborResult = CborNoError; CborParser xCborParser; - CborValue xCborValue, xCborMap; + CborValue xCborValue, xCborMap; /* Initialize the parser. */ xCborResult = cbor_parser_init( pucMessageBuffer, @@ -207,7 +207,7 @@ BaseType_t OTA_CBOR_Encode_GetStreamRequestMessage( uint8_t * pucMessageBuffer, size_t xBlockBitmapSize, int32_t lNumOfBlocksRequested ) { - CborError xCborResult = CborNoError; + CborError xCborResult = CborNoError; CborEncoder xCborEncoder, xCborMapEncoder; /* Initialize the CBOR encoder. */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_mqtt.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_mqtt.c index 55024ae62..21ab6b010 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_mqtt.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/ota/src/mqtt/aws_iot_ota_mqtt.c @@ -63,30 +63,30 @@ /*lint -e830 -e9003 Keep these in one location for easy discovery should they change in the future. */ /* Topic strings used by the OTA process. */ /* These first few are topic extensions to the dynamic base topic that includes the Thing name. */ -static const char pcOTA_JobsGetNextAccepted_TopicTemplate[] = "$aws/things/%s/jobs/$next/get/accepted"; -static const char pcOTA_JobsNotifyNext_TopicTemplate[] = "$aws/things/%s/jobs/notify-next"; -static const char pcOTA_JobsGetNext_TopicTemplate[] = "$aws/things/%s/jobs/$next/get"; -static const char pcOTA_JobStatus_TopicTemplate[] = "$aws/things/%s/jobs/%s/update"; -static const char pcOTA_StreamData_TopicTemplate[] = "$aws/things/%s/streams/%s/data/cbor"; -static const char pcOTA_GetStream_TopicTemplate[] = "$aws/things/%s/streams/%s/get/cbor"; -static const char pcOTA_GetNextJob_MsgTemplate[] = "{\"clientToken\":\"%u:%s\"}"; -static const char pcOTA_JobStatus_StatusTemplate[] = "{\"status\":\"%s\",\"statusDetails\":{"; -static const char pcOTA_JobStatus_ReceiveDetailsTemplate[] = "\"%s\":\"%u/%u\"}}"; -static const char pcOTA_JobStatus_SelfTestDetailsTemplate[] = "\"%s\":\"%s\",\"" OTA_JSON_UPDATED_BY_KEY "\":\"0x%x\"}}"; -static const char pcOTA_JobStatus_ReasonStrTemplate[] = "\"reason\":\"%s: 0x%08x\"}}"; -static const char pcOTA_JobStatus_SucceededStrTemplate[] = "\"reason\":\"%s v%u.%u.%u\"}}"; -static const char pcOTA_JobStatus_ReasonValTemplate[] = "\"reason\":\"0x%08x: 0x%08x\"}}"; -static const char pcOTA_String_Receive[] = "receive"; +static const char pcOTA_JobsGetNextAccepted_TopicTemplate[] = "$aws/things/%s/jobs/$next/get/accepted"; +static const char pcOTA_JobsNotifyNext_TopicTemplate[] = "$aws/things/%s/jobs/notify-next"; +static const char pcOTA_JobsGetNext_TopicTemplate[] = "$aws/things/%s/jobs/$next/get"; +static const char pcOTA_JobStatus_TopicTemplate[] = "$aws/things/%s/jobs/%s/update"; +static const char pcOTA_StreamData_TopicTemplate[] = "$aws/things/%s/streams/%s/data/cbor"; +static const char pcOTA_GetStream_TopicTemplate[] = "$aws/things/%s/streams/%s/get/cbor"; +static const char pcOTA_GetNextJob_MsgTemplate[] = "{\"clientToken\":\"%u:%s\"}"; +static const char pcOTA_JobStatus_StatusTemplate[] = "{\"status\":\"%s\",\"statusDetails\":{"; +static const char pcOTA_JobStatus_ReceiveDetailsTemplate[] = "\"%s\":\"%u/%u\"}}"; +static const char pcOTA_JobStatus_SelfTestDetailsTemplate[] = "\"%s\":\"%s\",\"" OTA_JSON_UPDATED_BY_KEY "\":\"0x%x\"}}"; +static const char pcOTA_JobStatus_ReasonStrTemplate[] = "\"reason\":\"%s: 0x%08x\"}}"; +static const char pcOTA_JobStatus_SucceededStrTemplate[] = "\"reason\":\"%s v%u.%u.%u\"}}"; +static const char pcOTA_JobStatus_ReasonValTemplate[] = "\"reason\":\"0x%08x: 0x%08x\"}}"; +static const char pcOTA_String_Receive[] = "receive"; /* We map all of the above status cases to one of these 4 status strings. * These are the only strings that are supported by the Job Service. You * shall not change them to arbitrary strings or the job will not change * states. * */ -const char pcOTA_String_InProgress[] = "IN_PROGRESS"; -const char pcOTA_String_Failed[] = "FAILED"; -const char pcOTA_String_Succeeded[] = "SUCCEEDED"; -const char pcOTA_String_Rejected[] = "REJECTED"; +const char pcOTA_String_InProgress[] = "IN_PROGRESS"; +const char pcOTA_String_Failed[] = "FAILED"; +const char pcOTA_String_Succeeded[] = "SUCCEEDED"; +const char pcOTA_String_Rejected[] = "REJECTED"; const char * pcOTA_JobStatus_Strings[ eNumJobStatusMappings ] = { @@ -101,7 +101,7 @@ const char * pcOTA_JobStatus_Strings[ eNumJobStatusMappings ] = * the above enums during the OTA update process. The 'Receiving' state is * updated with transfer progress as #blocks received of #total. */ -const char * pcOTA_JobReason_Strings[ eNumJobReasons ] = { "", "ready", "active", "accepted", "rejected", "aborted" }; +const char * pcOTA_JobReason_Strings[ eNumJobReasons ] = { "", "ready", "active", "accepted", "rejected", "aborted" }; /* Queue MQTT callback event for processing. */ @@ -146,26 +146,26 @@ static bool prvSubscribeToJobNotificationTopics( const OTA_AgentContext_t * pxAg { DEFINE_OTA_METHOD_NAME( "prvSubscribeToJobNotificationTopics" ); - bool bResult = false; - char pcJobTopic[ OTA_MAX_TOPIC_LEN ]; - IotMqttSubscription_t stJobsSubscription; - IotMqttError_t eResult = IOT_MQTT_STATUS_PENDING; - uint16_t usTopicLen = 0; + bool bResult = false; + char pcJobTopic[ OTA_MAX_TOPIC_LEN ]; + IotMqttSubscription_t stJobsSubscription; + IotMqttError_t eResult = IOT_MQTT_STATUS_PENDING; + uint16_t usTopicLen = 0; OTA_ConnectionContext_t * pvConnContext = pxAgentCtx->pvConnectionContext; /* Build the first topic. */ - usTopicLen = ( uint16_t ) snprintf( pcJobTopic, /*lint -e586 Intentionally using snprintf. */ - sizeof( pcJobTopic ), - pcOTA_JobsGetNextAccepted_TopicTemplate, - pxAgentCtx->pcThingName ); + usTopicLen = ( uint16_t ) snprintf( pcJobTopic, /*lint -e586 Intentionally using snprintf. */ + sizeof( pcJobTopic ), + pcOTA_JobsGetNextAccepted_TopicTemplate, + pxAgentCtx->pcThingName ); /* Clear subscription struct and set common parameters for job topics used by OTA. */ memset( &stJobsSubscription, 0, sizeof( stJobsSubscription ) ); - stJobsSubscription.qos = IOT_MQTT_QOS_1; - stJobsSubscription.pTopicFilter = ( const char * ) pcJobTopic; /* Point to local string storage. Built below. */ - stJobsSubscription.callback.pCallbackContext = ( void * ) pxAgentCtx; /*lint !e923 The publish callback context is implementing data hiding with a void* type.*/ - stJobsSubscription.callback.function = prvJobPublishCallback; - stJobsSubscription.topicFilterLength = usTopicLen; + stJobsSubscription.qos = IOT_MQTT_QOS_1; + stJobsSubscription.pTopicFilter = ( const char * ) pcJobTopic; /* Point to local string storage. Built below. */ + stJobsSubscription.callback.pCallbackContext = ( void * ) pxAgentCtx; /*lint !e923 The publish callback context is implementing data hiding with a void* type.*/ + stJobsSubscription.callback.function = prvJobPublishCallback; + stJobsSubscription.topicFilterLength = usTopicLen; if( ( usTopicLen > 0U ) && ( usTopicLen < sizeof( pcJobTopic ) ) ) { @@ -195,11 +195,11 @@ static bool prvSubscribeToJobNotificationTopics( const OTA_AgentContext_t * pxAg { /* Subscribe to the second of two jobs topics. */ stJobsSubscription.topicFilterLength = usTopicLen; - eResult = IotMqtt_TimedSubscribe( pvConnContext->pvControlClient, - &stJobsSubscription, - 1, /* Subscriptions count */ - 0, /* flags */ - OTA_SUBSCRIBE_WAIT_MS ); + eResult = IotMqtt_TimedSubscribe( pvConnContext->pvControlClient, + &stJobsSubscription, + 1, /* Subscriptions count */ + 0, /* flags */ + OTA_SUBSCRIBE_WAIT_MS ); if( eResult == IOT_MQTT_SUCCESS ) { @@ -224,8 +224,8 @@ static bool prvUnSubscribeFromDataStream( const OTA_AgentContext_t * pxAgentCtx IotMqttSubscription_t xUnSub; - bool bResult = false; - char pcOTA_RxStreamTopic[ OTA_MAX_TOPIC_LEN ]; + bool bResult = false; + char pcOTA_RxStreamTopic[ OTA_MAX_TOPIC_LEN ]; xUnSub.qos = IOT_MQTT_QOS_0; @@ -273,15 +273,15 @@ static void prvUnSubscribeFromJobNotificationTopic( const OTA_AgentContext_t * p { DEFINE_OTA_METHOD_NAME( "prvUnSubscribeFromJobNotificationTopic" ); - IotMqttSubscription_t xUnSub; - IotMqttOperation_t paUnubscribeOperation[ 2 ] = { NULL }; - char pcJobTopic[ OTA_MAX_TOPIC_LEN ]; + IotMqttSubscription_t xUnSub; + IotMqttOperation_t paUnubscribeOperation[ 2 ] = { NULL }; + char pcJobTopic[ OTA_MAX_TOPIC_LEN ]; - OTA_ConnectionContext_t * pvConnContext = pxAgentCtx->pvConnectionContext; + OTA_ConnectionContext_t * pvConnContext = pxAgentCtx->pvConnectionContext; /* Try to unsubscribe from the first of two job topics. */ - xUnSub.qos = IOT_MQTT_QOS_0; - xUnSub.pTopicFilter = ( const char * ) pcJobTopic; /* Point to local string storage. Built below. */ + xUnSub.qos = IOT_MQTT_QOS_0; + xUnSub.pTopicFilter = ( const char * ) pcJobTopic; /* Point to local string storage. Built below. */ xUnSub.topicFilterLength = ( uint16_t ) snprintf( pcJobTopic, /*lint -e586 Intentionally using snprintf. */ sizeof( pcJobTopic ), pcOTA_JobsNotifyNext_TopicTemplate, @@ -354,20 +354,20 @@ static IotMqttError_t prvPublishMessage( const OTA_AgentContext_t * pxAgentCtx, uint32_t ulMsgSize, IotMqttQos_t eQOS ) { - IotMqttError_t eResult; - IotMqttPublishInfo_t xPublishParams; + IotMqttError_t eResult; + IotMqttPublishInfo_t xPublishParams; OTA_ConnectionContext_t * pvConnContext = pxAgentCtx->pvConnectionContext; - xPublishParams.pTopicName = pacTopic; + xPublishParams.pTopicName = pacTopic; xPublishParams.topicNameLength = usTopicLen; - xPublishParams.qos = eQOS; - xPublishParams.pPayload = pcMsg; - xPublishParams.payloadLength = ulMsgSize; - xPublishParams.retryLimit = OTA_MAX_PUBLISH_RETRIES; - xPublishParams.retryMs = OTA_RETRY_DELAY_MS; - xPublishParams.retain = false; + xPublishParams.qos = eQOS; + xPublishParams.pPayload = pcMsg; + xPublishParams.payloadLength = ulMsgSize; + xPublishParams.retryLimit = OTA_MAX_PUBLISH_RETRIES; + xPublishParams.retryMs = OTA_RETRY_DELAY_MS; + xPublishParams.retain = false; - eResult = IotMqtt_TimedPublish( pvConnContext->pvControlClient, &xPublishParams, 0, OTA_PUBLISH_WAIT_MS ); + eResult = IotMqtt_TimedPublish( pvConnContext->pvControlClient, &xPublishParams, 0, OTA_PUBLISH_WAIT_MS ); return eResult; } @@ -383,9 +383,9 @@ static void prvPublishStatusMessage( OTA_AgentContext_t * pxAgentCtx, { DEFINE_OTA_METHOD_NAME( "prvPublishStatusMessage" ); - uint32_t ulTopicLen = 0; + uint32_t ulTopicLen = 0; IotMqttError_t eResult; - char pcTopicBuffer[ OTA_MAX_TOPIC_LEN ]; + char pcTopicBuffer[ OTA_MAX_TOPIC_LEN ]; /* Try to build the dynamic job status topic . */ ulTopicLen = ( uint32_t ) snprintf( pcTopicBuffer, /*lint -e586 Intentionally using snprintf. */ @@ -429,20 +429,20 @@ static uint32_t prvBuildStatusMessageReceiving( char * pcMsgBuffer, DEFINE_OTA_METHOD_NAME( "prvBuildStatusMessageReceiving" ); uint32_t ulNumBlocks = 0; - uint32_t ulReceived = 0; - uint32_t ulMsgSize = 0; + uint32_t ulReceived = 0; + uint32_t ulMsgSize = 0; if( pxOTAFileCtx != NULL ) { ulNumBlocks = ( pxOTAFileCtx->ulFileSize + ( OTA_FILE_BLOCK_SIZE - 1U ) ) >> otaconfigLOG2_FILE_BLOCK_SIZE; - ulReceived = ulNumBlocks - pxOTAFileCtx->ulBlocksRemaining; + ulReceived = ulNumBlocks - pxOTAFileCtx->ulBlocksRemaining; if( ( ulReceived % OTA_UPDATE_STATUS_FREQUENCY ) == 0U ) /* Output a status update once in a while. */ { - ulMsgSize = ( uint32_t ) snprintf( pcMsgBuffer, /*lint -e586 Intentionally using snprintf. */ - xMsgBufferSize, - pcOTA_JobStatus_StatusTemplate, - pcOTA_JobStatus_Strings[ eStatus ] ); + ulMsgSize = ( uint32_t ) snprintf( pcMsgBuffer, /*lint -e586 Intentionally using snprintf. */ + xMsgBufferSize, + pcOTA_JobStatus_StatusTemplate, + pcOTA_JobStatus_Strings[ eStatus ] ); ulMsgSize += ( uint32_t ) snprintf( &pcMsgBuffer[ ulMsgSize ], /*lint -e586 Intentionally using snprintf. */ xMsgBufferSize - ulMsgSize, pcOTA_JobStatus_ReceiveDetailsTemplate, @@ -466,10 +466,10 @@ static uint32_t prvBuildStatusMessageSelfTest( char * pcMsgBuffer, { uint32_t ulMsgSize = 0; - ulMsgSize = ( uint32_t ) snprintf( pcMsgBuffer, /*lint -e586 Intentionally using snprintf. */ - xMsgBufferSize, - pcOTA_JobStatus_StatusTemplate, - pcOTA_JobStatus_Strings[ eStatus ] ); + ulMsgSize = ( uint32_t ) snprintf( pcMsgBuffer, /*lint -e586 Intentionally using snprintf. */ + xMsgBufferSize, + pcOTA_JobStatus_StatusTemplate, + pcOTA_JobStatus_Strings[ eStatus ] ); ulMsgSize += ( uint32_t ) snprintf( &pcMsgBuffer[ ulMsgSize ], /*lint -e586 Intentionally using snprintf. */ xMsgBufferSize - ulMsgSize, pcOTA_JobStatus_SelfTestDetailsTemplate, @@ -515,13 +515,13 @@ static uint32_t prvBuildStatusMessageFinish( char * pcMsgBuffer, AppVersion32_t xNewVersion; xNewVersion.u.lVersion32 = lSubReason; - ulMsgSize += ( uint32_t ) snprintf( &pcMsgBuffer[ ulMsgSize ], /*lint -e586 Intentionally using snprintf. */ - xMsgBufferSize - ulMsgSize, - pcOTA_JobStatus_SucceededStrTemplate, - pcOTA_JobReason_Strings[ lReason ], - xNewVersion.u.x.ucMajor, - xNewVersion.u.x.ucMinor, - xNewVersion.u.x.usBuild ); + ulMsgSize += ( uint32_t ) snprintf( &pcMsgBuffer[ ulMsgSize ], /*lint -e586 Intentionally using snprintf. */ + xMsgBufferSize - ulMsgSize, + pcOTA_JobStatus_SucceededStrTemplate, + pcOTA_JobReason_Strings[ lReason ], + xNewVersion.u.x.ucMajor, + xNewVersion.u.x.ucMinor, + xNewVersion.u.x.usBuild ); } /* Status updates that are NOT "InProgress" or "Succeeded" or "FailedWithVal" map status and @@ -547,9 +547,9 @@ static void prvSendCallbackEvent( void * pvCallbackContext, OTA_Event_t xEventId ) { DEFINE_OTA_METHOD_NAME( "prvSendCallbackEvent" ); - OTA_EventMsg_t xEventMsg = { 0 }; - BaseType_t xErr = pdFALSE; - OTA_EventData_t * pxData; + OTA_EventMsg_t xEventMsg = { 0 }; + BaseType_t xErr = pdFALSE; + OTA_EventData_t * pxData; /* Get the OTA agent context. */ OTA_AgentContext_t * pxAgentCtx = ( OTA_AgentContext_t * ) pvCallbackContext; @@ -562,12 +562,12 @@ static void prvSendCallbackEvent( void * pvCallbackContext, if( pxData != NULL ) { memcpy( pxData->ucData, pxPublishData->u.message.info.pPayload, pxPublishData->u.message.info.payloadLength ); - pxData->ulDataLength = pxPublishData->u.message.info.payloadLength; - xEventMsg.xEventId = xEventId; + pxData->ulDataLength = pxPublishData->u.message.info.payloadLength; + xEventMsg.xEventId = xEventId; xEventMsg.pxEventData = pxData; /* Send job document received event. */ - xErr = OTA_SignalEvent( &xEventMsg ); + xErr = OTA_SignalEvent( &xEventMsg ); } else { @@ -632,27 +632,27 @@ OTA_Err_t prvRequestJob_Mqtt( OTA_AgentContext_t * pxAgentCtx ) { DEFINE_OTA_METHOD_NAME( "prvRequestJob_Mqtt" ); - char pcJobTopic[ OTA_MAX_TOPIC_LEN ]; + char pcJobTopic[ OTA_MAX_TOPIC_LEN ]; static uint32_t ulReqCounter = 0; - IotMqttError_t eResult; - uint32_t ulMsgLen; - uint16_t usTopicLen; - OTA_Err_t xError = kOTA_Err_PublishFailed; + IotMqttError_t eResult; + uint32_t ulMsgLen; + uint16_t usTopicLen; + OTA_Err_t xError = kOTA_Err_PublishFailed; /* The following buffer is big enough to hold a dynamically constructed $next/get job message. * It contains a client token that is used to track how many requests have been made. */ - char pcMsg[ CONST_STRLEN( pcOTA_GetNextJob_MsgTemplate ) + U32_MAX_PLACES + otaconfigMAX_THINGNAME_LEN ]; + char pcMsg[ CONST_STRLEN( pcOTA_GetNextJob_MsgTemplate ) + U32_MAX_PLACES + otaconfigMAX_THINGNAME_LEN ]; /* Subscribe to the OTA job notification topic. */ if( prvSubscribeToJobNotificationTopics( pxAgentCtx ) ) { OTA_LOG_L1( "[%s] Request #%u\r\n", OTA_METHOD_NAME, ulReqCounter ); /*lint -e586 Intentionally using snprintf. */ - ulMsgLen = ( uint32_t ) snprintf( pcMsg, - sizeof( pcMsg ), - pcOTA_GetNextJob_MsgTemplate, - ulReqCounter, - pxAgentCtx->pcThingName ); + ulMsgLen = ( uint32_t ) snprintf( pcMsg, + sizeof( pcMsg ), + pcOTA_GetNextJob_MsgTemplate, + ulReqCounter, + pxAgentCtx->pcThingName ); ulReqCounter++; usTopicLen = ( uint16_t ) snprintf( pcJobTopic, sizeof( pcJobTopic ), @@ -702,13 +702,13 @@ OTA_Err_t prvUpdateJobStatus_Mqtt( OTA_AgentContext_t * pxAgentCtx, DEFINE_OTA_METHOD_NAME( "prvUpdateJobStatus_Mqtt" ); /* A message size of zero means don't publish anything. */ - uint32_t ulMsgSize = 0; + uint32_t ulMsgSize = 0; /* All job state transitions except streaming progress use QOS 1 since it is required to have status in the job document. */ - IotMqttQos_t eQOS = IOT_MQTT_QOS_1; - char pcMsg[ OTA_STATUS_MSG_MAX_SIZE ]; + IotMqttQos_t eQOS = IOT_MQTT_QOS_1; + char pcMsg[ OTA_STATUS_MSG_MAX_SIZE ]; /* Get the current file context. */ - OTA_FileContext_t * C = &( pxAgentCtx->pxOTA_Files[ pxAgentCtx->ulFileIndex ] ); + OTA_FileContext_t * C = &( pxAgentCtx->pxOTA_Files[ pxAgentCtx->ulFileIndex ] ); if( eStatus == eJobStatus_InProgress ) { @@ -756,20 +756,20 @@ OTA_Err_t prvInitFileTransfer_Mqtt( OTA_AgentContext_t * pxAgentCtx ) { DEFINE_OTA_METHOD_NAME( "prvInitFileTransfer_Mqtt" ); - OTA_Err_t xResult = kOTA_Err_PublishFailed; - char pcOTA_RxStreamTopic[ OTA_MAX_TOPIC_LEN ]; + OTA_Err_t xResult = kOTA_Err_PublishFailed; + char pcOTA_RxStreamTopic[ OTA_MAX_TOPIC_LEN ]; IotMqttSubscription_t xOTAUpdateDataSubscription; memset( &xOTAUpdateDataSubscription, 0, sizeof( xOTAUpdateDataSubscription ) ); - xOTAUpdateDataSubscription.qos = IOT_MQTT_QOS_0; - xOTAUpdateDataSubscription.pTopicFilter = ( const char * ) pcOTA_RxStreamTopic; - xOTAUpdateDataSubscription.callback.pCallbackContext = ( void * ) pxAgentCtx; /*lint !e923 The publish callback context is implementing data hiding with a void* type.*/ - xOTAUpdateDataSubscription.callback.function = prvDataPublishCallback; - xOTAUpdateDataSubscription.topicFilterLength = ( uint16_t ) snprintf( pcOTA_RxStreamTopic, /*lint -e586 Intentionally using snprintf. */ - sizeof( pcOTA_RxStreamTopic ), - pcOTA_StreamData_TopicTemplate, - pxAgentCtx->pcThingName, - ( const char * ) pxAgentCtx->pxOTA_Files->pucStreamName ); + xOTAUpdateDataSubscription.qos = IOT_MQTT_QOS_0; + xOTAUpdateDataSubscription.pTopicFilter = ( const char * ) pcOTA_RxStreamTopic; + xOTAUpdateDataSubscription.callback.pCallbackContext = ( void * ) pxAgentCtx; /*lint !e923 The publish callback context is implementing data hiding with a void* type.*/ + xOTAUpdateDataSubscription.callback.function = prvDataPublishCallback; + xOTAUpdateDataSubscription.topicFilterLength = ( uint16_t ) snprintf( pcOTA_RxStreamTopic, /*lint -e586 Intentionally using snprintf. */ + sizeof( pcOTA_RxStreamTopic ), + pcOTA_StreamData_TopicTemplate, + pxAgentCtx->pcThingName, + ( const char * ) pxAgentCtx->pxOTA_Files->pucStreamName ); if( ( xOTAUpdateDataSubscription.topicFilterLength > 0U ) && ( xOTAUpdateDataSubscription.topicFilterLength < sizeof( pcOTA_RxStreamTopic ) ) ) { @@ -802,19 +802,19 @@ OTA_Err_t prvRequestFileBlock_Mqtt( OTA_AgentContext_t * pxAgentCtx ) { DEFINE_OTA_METHOD_NAME( "prvRequestFileBlock_Mqtt" ); - size_t xMsgSizeFromStream; - uint32_t ulNumBlocks, ulBitmapLen; - uint32_t ulMsgSizeToPublish = 0; - uint32_t ulTopicLen = 0; - IotMqttError_t eResult = IOT_MQTT_STATUS_PENDING; - OTA_Err_t xErr = kOTA_Err_Uninitialized; - char pcMsg[ OTA_REQUEST_MSG_MAX_SIZE ]; - char pcTopicBuffer[ OTA_MAX_TOPIC_LEN ]; + size_t xMsgSizeFromStream; + uint32_t ulNumBlocks, ulBitmapLen; + uint32_t ulMsgSizeToPublish = 0; + uint32_t ulTopicLen = 0; + IotMqttError_t eResult = IOT_MQTT_STATUS_PENDING; + OTA_Err_t xErr = kOTA_Err_Uninitialized; + char pcMsg[ OTA_REQUEST_MSG_MAX_SIZE ]; + char pcTopicBuffer[ OTA_MAX_TOPIC_LEN ]; /* * Get the current file context. */ - OTA_FileContext_t * C = &( pxAgentCtx->pxOTA_Files[ pxAgentCtx->ulFileIndex ] ); + OTA_FileContext_t * C = &( pxAgentCtx->pxOTA_Files[ pxAgentCtx->ulFileIndex ] ); /* Reset number of blocks requested. */ pxAgentCtx->ulNumOfBlocksToReceive = otaconfigMAX_NUM_BLOCKS_REQUEST; @@ -850,11 +850,11 @@ OTA_Err_t prvRequestFileBlock_Mqtt( OTA_AgentContext_t * pxAgentCtx ) ulMsgSizeToPublish = ( uint32_t ) xMsgSizeFromStream; /* Try to build the dynamic data REQUEST topic to publish to. */ - ulTopicLen = ( uint32_t ) snprintf( pcTopicBuffer, /*lint -e586 Intentionally using snprintf. */ - sizeof( pcTopicBuffer ), - pcOTA_GetStream_TopicTemplate, - pxAgentCtx->pcThingName, - ( const char * ) C->pucStreamName ); + ulTopicLen = ( uint32_t ) snprintf( pcTopicBuffer, /*lint -e586 Intentionally using snprintf. */ + sizeof( pcTopicBuffer ), + pcOTA_GetStream_TopicTemplate, + pxAgentCtx->pcThingName, + ( const char * ) C->pucStreamName ); if( ( ulTopicLen > 0U ) && ( ulTopicLen < sizeof( pcTopicBuffer ) ) ) { @@ -928,7 +928,7 @@ OTA_Err_t prvDecodeFileBlock_Mqtt( uint8_t * pucMessageBuffer, vPortFree( *ppucPayload ); *ppucPayload = pucMessageBuffer; - xErr = kOTA_Err_None; + xErr = kOTA_Err_None; } return xErr; diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_api.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_api.c index 4fcab618b..d845e20f2 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_api.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_api.c @@ -163,12 +163,12 @@ static void _updatedCallbackWrapper( void * pArgument, * * API functions will fail if @ref shadow_function_init was not called. */ -static uint32_t _initCalled = 0U; +static uint32_t _initCalled = 0U; /** * @brief Timeout used for MQTT operations. */ -uint32_t _AwsIotShadowMqttTimeoutMs = AWS_IOT_SHADOW_DEFAULT_MQTT_TIMEOUT_MS; +uint32_t _AwsIotShadowMqttTimeoutMs = AWS_IOT_SHADOW_DEFAULT_MQTT_TIMEOUT_MS; #if LIBRARY_LOG_LEVEL > IOT_LOG_NONE @@ -339,7 +339,7 @@ static AwsIotShadowError_t _setCallbackCommon( IotMqttConnection_t mqttConnectio const AwsIotShadowCallbackInfo_t * pCallbackInfo ) { IOT_FUNCTION_ENTRY( AwsIotShadowError_t, AWS_IOT_SHADOW_SUCCESS ); - bool subscriptionMutexLocked = false; + bool subscriptionMutexLocked = false; _shadowSubscription_t * pSubscription = NULL; /* Check that AwsIotShadow_Init was called. */ @@ -349,12 +349,12 @@ static AwsIotShadowError_t _setCallbackCommon( IotMqttConnection_t mqttConnectio } /* Check parameters. */ - status = _validateThingNameFlags( _AwsIotShadow_IntToShadowOperationType( ( ( uint32_t ) type ) + SHADOW_OPERATION_COUNT ), - pThingName, - thingNameLength, - 0, - pCallbackInfo, - NULL ); + status = _validateThingNameFlags( _AwsIotShadow_IntToShadowOperationType( ( ( uint32_t ) type ) + SHADOW_OPERATION_COUNT ), + pThingName, + thingNameLength, + 0, + pCallbackInfo, + NULL ); if( status != AWS_IOT_SHADOW_SUCCESS ) { @@ -373,9 +373,9 @@ static AwsIotShadowError_t _setCallbackCommon( IotMqttConnection_t mqttConnectio /* Check for an existing subscription. This function will attempt to allocate * a new subscription if not found. */ - pSubscription = _AwsIotShadow_FindSubscription( pThingName, - thingNameLength, - true ); + pSubscription = _AwsIotShadow_FindSubscription( pThingName, + thingNameLength, + true ); if( pSubscription == NULL ) { @@ -475,27 +475,27 @@ static AwsIotShadowError_t _modifyCallbackSubscriptions( IotMqttConnection_t mqt AwsIotMqttFunction_t mqttOperation ) { IOT_FUNCTION_ENTRY( AwsIotShadowError_t, AWS_IOT_SHADOW_SUCCESS ); - IotMqttError_t mqttStatus = IOT_MQTT_STATUS_PENDING; - IotMqttSubscription_t subscription = IOT_MQTT_SUBSCRIPTION_INITIALIZER; - char * pTopicFilter = NULL; - uint16_t operationTopicLength = 0; + IotMqttError_t mqttStatus = IOT_MQTT_STATUS_PENDING; + IotMqttSubscription_t subscription = IOT_MQTT_SUBSCRIPTION_INITIALIZER; + char * pTopicFilter = NULL; + uint16_t operationTopicLength = 0; /* Lookup table for Shadow callback suffixes. */ - const char * const pCallbackSuffix[ SHADOW_CALLBACK_COUNT ] = + const char * const pCallbackSuffix[ SHADOW_CALLBACK_COUNT ] = { SHADOW_DELTA_SUFFIX, /* Delta callback. */ SHADOW_UPDATED_SUFFIX /* Updated callback. */ }; /* Lookup table for Shadow callback suffix lengths. */ - const uint16_t pCallbackSuffixLength[ SHADOW_CALLBACK_COUNT ] = + const uint16_t pCallbackSuffixLength[ SHADOW_CALLBACK_COUNT ] = { SHADOW_DELTA_SUFFIX_LENGTH, /* Delta callback. */ SHADOW_UPDATED_SUFFIX_LENGTH /* Updated callback. */ }; /* Lookup table for Shadow callback function wrappers. */ - const AwsIotMqttCallbackFunction_t pCallbackWrapper[ SHADOW_CALLBACK_COUNT ] = + const AwsIotMqttCallbackFunction_t pCallbackWrapper[ SHADOW_CALLBACK_COUNT ] = { _deltaCallbackWrapper, /* Delta callback. */ _updatedCallbackWrapper, /* Updated callback. */ @@ -513,11 +513,11 @@ static AwsIotShadowError_t _modifyCallbackSubscriptions( IotMqttConnection_t mqt /* Generate the prefix portion of the Shadow callback topic filter. Both * callbacks share the same callback as the Shadow Update operation. */ - status = _AwsIotShadow_GenerateShadowTopic( SHADOW_UPDATE, - pSubscription->pThingName, - pSubscription->thingNameLength, - &pTopicFilter, - &operationTopicLength ); + status = _AwsIotShadow_GenerateShadowTopic( SHADOW_UPDATE, + pSubscription->pThingName, + pSubscription->thingNameLength, + &pTopicFilter, + &operationTopicLength ); if( status != AWS_IOT_SHADOW_SUCCESS ) { @@ -535,18 +535,18 @@ static AwsIotShadowError_t _modifyCallbackSubscriptions( IotMqttConnection_t mqt pTopicFilter ); /* Set the members of the MQTT subscription. */ - subscription.qos = IOT_MQTT_QOS_1; - subscription.pTopicFilter = pTopicFilter; - subscription.topicFilterLength = ( uint16_t ) ( operationTopicLength + pCallbackSuffixLength[ type ] ); + subscription.qos = IOT_MQTT_QOS_1; + subscription.pTopicFilter = pTopicFilter; + subscription.topicFilterLength = ( uint16_t ) ( operationTopicLength + pCallbackSuffixLength[ type ] ); subscription.callback.pCallbackContext = NULL; - subscription.callback.function = pCallbackWrapper[ type ]; + subscription.callback.function = pCallbackWrapper[ type ]; /* Call the MQTT operation function. */ - mqttStatus = mqttOperation( mqttConnection, - &subscription, - 1, - 0, - _AwsIotShadowMqttTimeoutMs ); + mqttStatus = mqttOperation( mqttConnection, + &subscription, + 1, + 0, + _AwsIotShadowMqttTimeoutMs ); /* Check the result of the MQTT operation. */ if( mqttStatus != IOT_MQTT_SUCCESS ) @@ -589,11 +589,11 @@ static AwsIotShadowError_t _modifyCallbackSubscriptions( IotMqttConnection_t mqt static void _callbackWrapperCommon( _shadowCallbackType_t type, IotMqttCallbackParam_t * pMessage ) { - AwsIotShadowCallbackInfo_t callbackInfo = AWS_IOT_SHADOW_CALLBACK_INFO_INITIALIZER; + AwsIotShadowCallbackInfo_t callbackInfo = AWS_IOT_SHADOW_CALLBACK_INFO_INITIALIZER; AwsIotShadowCallbackParam_t callbackParam = { .callbackType = AWS_IOT_SHADOW_DELETE_COMPLETE }; - _shadowSubscription_t * pSubscription = NULL; - const char * pThingName = NULL; - size_t thingNameLength = 0; + _shadowSubscription_t * pSubscription = NULL; + const char * pThingName = NULL; + size_t thingNameLength = 0; /* Parse the Thing Name from the topic. */ if( AwsIot_ParseThingName( pMessage->u.message.info.pTopicName, @@ -607,9 +607,9 @@ static void _callbackWrapperCommon( _shadowCallbackType_t type, /* Search for a matching subscription. */ IotMutex_Lock( &_AwsIotShadowSubscriptionsMutex ); - pSubscription = _AwsIotShadow_FindSubscription( pThingName, - thingNameLength, - false ); + pSubscription = _AwsIotShadow_FindSubscription( pThingName, + thingNameLength, + false ); if( pSubscription == NULL ) { @@ -623,18 +623,18 @@ static void _callbackWrapperCommon( _shadowCallbackType_t type, /* Copy the subscription callback info, as the subscription may be modified * when the subscriptions mutex is released. */ - callbackInfo = pSubscription->callbacks[ type ]; + callbackInfo = pSubscription->callbacks[ type ]; IotMutex_Unlock( &_AwsIotShadowSubscriptionsMutex ); /* Set the callback type. Shadow callbacks are enumerated after the operations. */ - callbackParam.callbackType = _AwsIotShadow_IntToShadowCallbackType( ( ( uint32_t ) type ) + SHADOW_OPERATION_COUNT ); + callbackParam.callbackType = _AwsIotShadow_IntToShadowCallbackType( ( ( uint32_t ) type ) + SHADOW_OPERATION_COUNT ); /* Set the remaining members of the callback param. */ - callbackParam.mqttConnection = pMessage->mqttConnection; - callbackParam.pThingName = pThingName; - callbackParam.thingNameLength = thingNameLength; - callbackParam.u.callback.pDocument = pMessage->u.message.info.pPayload; + callbackParam.mqttConnection = pMessage->mqttConnection; + callbackParam.pThingName = pThingName; + callbackParam.thingNameLength = thingNameLength; + callbackParam.u.callback.pDocument = pMessage->u.message.info.pPayload; callbackParam.u.callback.documentLength = pMessage->u.message.info.payloadLength; /* Invoke the callback function. */ @@ -671,8 +671,8 @@ static void _updatedCallbackWrapper( void * pArgument, AwsIotShadowError_t AwsIotShadow_Init( uint32_t mqttTimeoutMs ) { - AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS; - bool listInitStatus = false; + AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS; + bool listInitStatus = false; if( _initCalled == 0U ) { @@ -716,7 +716,7 @@ void AwsIotShadow_Cleanup( void ) { if( _initCalled == 1U ) { - _initCalled = 0U; + _initCalled = 0U; /* Remove and free all items in the Shadow pending operation list. */ IotMutex_Lock( &( _AwsIotShadowPendingOperationsMutex ) ); @@ -829,7 +829,7 @@ AwsIotShadowError_t AwsIotShadow_DeleteSync( IotMqttConnection_t mqttConnection, uint32_t flags, uint32_t timeoutMs ) { - AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING; + AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING; AwsIotShadowOperation_t deleteOperation = AWS_IOT_SHADOW_OPERATION_INITIALIZER; /* Set the waitable flag. */ @@ -873,12 +873,12 @@ AwsIotShadowError_t AwsIotShadow_GetAsync( IotMqttConnection_t mqttConnection, } /* Validate the Thing Name and flags for Shadow GET. */ - status = _validateThingNameFlags( SHADOW_GET, - pGetInfo->pThingName, - pGetInfo->thingNameLength, - flags, - pCallbackInfo, - pGetOperation ); + status = _validateThingNameFlags( SHADOW_GET, + pGetInfo->pThingName, + pGetInfo->thingNameLength, + flags, + pCallbackInfo, + pGetOperation ); if( status != AWS_IOT_SHADOW_SUCCESS ) { @@ -887,9 +887,9 @@ AwsIotShadowError_t AwsIotShadow_GetAsync( IotMqttConnection_t mqttConnection, } /* Validate the document info for Shadow GET. */ - status = _validateDocumentInfo( SHADOW_GET, - flags, - pGetInfo ); + status = _validateDocumentInfo( SHADOW_GET, + flags, + pGetInfo ); if( status != AWS_IOT_SHADOW_SUCCESS ) { @@ -898,10 +898,10 @@ AwsIotShadowError_t AwsIotShadow_GetAsync( IotMqttConnection_t mqttConnection, } /* Allocate a new Shadow operation for GET. */ - status = _AwsIotShadow_CreateOperation( &pOperation, - SHADOW_GET, - flags, - pCallbackInfo ); + status = _AwsIotShadow_CreateOperation( &pOperation, + SHADOW_GET, + flags, + pCallbackInfo ); if( status != AWS_IOT_SHADOW_SUCCESS ) { @@ -927,11 +927,11 @@ AwsIotShadowError_t AwsIotShadow_GetAsync( IotMqttConnection_t mqttConnection, /* Process the Shadow operation. This subscribes to any required topics and * sends the MQTT message for the Shadow operation. */ - status = _AwsIotShadow_ProcessOperation( mqttConnection, - pGetInfo->pThingName, - pGetInfo->thingNameLength, - pOperation, - pGetInfo ); + status = _AwsIotShadow_ProcessOperation( mqttConnection, + pGetInfo->pThingName, + pGetInfo->thingNameLength, + pOperation, + pGetInfo ); /* If the Shadow operation failed, clear the now invalid reference. */ if( ( status != AWS_IOT_SHADOW_STATUS_PENDING ) && ( pGetOperation != NULL ) ) @@ -951,7 +951,7 @@ AwsIotShadowError_t AwsIotShadow_GetSync( IotMqttConnection_t mqttConnection, const char ** const pShadowDocument, size_t * const pShadowDocumentLength ) { - AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING; + AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING; AwsIotShadowOperation_t getOperation = AWS_IOT_SHADOW_OPERATION_INITIALIZER; /* Set the waitable flag. */ @@ -988,9 +988,9 @@ AwsIotShadowError_t AwsIotShadow_UpdateAsync( IotMqttConnection_t mqttConnection AwsIotShadowOperation_t * const pUpdateOperation ) { IOT_FUNCTION_ENTRY( AwsIotShadowError_t, AWS_IOT_SHADOW_STATUS_PENDING ); - _shadowOperation_t * pOperation = NULL; - const char * pClientToken = NULL; - size_t clientTokenLength = 0; + _shadowOperation_t * pOperation = NULL; + const char * pClientToken = NULL; + size_t clientTokenLength = 0; /* Check that AwsIotShadow_Init was called. */ if( _checkInit() == false ) @@ -999,12 +999,12 @@ AwsIotShadowError_t AwsIotShadow_UpdateAsync( IotMqttConnection_t mqttConnection } /* Validate the Thing Name and flags for Shadow UPDATE. */ - status = _validateThingNameFlags( SHADOW_UPDATE, - pUpdateInfo->pThingName, - pUpdateInfo->thingNameLength, - flags, - pCallbackInfo, - pUpdateOperation ); + status = _validateThingNameFlags( SHADOW_UPDATE, + pUpdateInfo->pThingName, + pUpdateInfo->thingNameLength, + flags, + pCallbackInfo, + pUpdateOperation ); if( status != AWS_IOT_SHADOW_SUCCESS ) { @@ -1013,9 +1013,9 @@ AwsIotShadowError_t AwsIotShadow_UpdateAsync( IotMqttConnection_t mqttConnection } /* Validate the document info for Shadow UPDATE. */ - status = _validateDocumentInfo( SHADOW_UPDATE, - flags, - pUpdateInfo ); + status = _validateDocumentInfo( SHADOW_UPDATE, + flags, + pUpdateInfo ); if( status != AWS_IOT_SHADOW_SUCCESS ) { @@ -1035,10 +1035,10 @@ AwsIotShadowError_t AwsIotShadow_UpdateAsync( IotMqttConnection_t mqttConnection } /* Allocate a new Shadow operation for UPDATE. */ - status = _AwsIotShadow_CreateOperation( &pOperation, - SHADOW_UPDATE, - flags, - pCallbackInfo ); + status = _AwsIotShadow_CreateOperation( &pOperation, + SHADOW_UPDATE, + flags, + pCallbackInfo ); if( status != AWS_IOT_SHADOW_SUCCESS ) { @@ -1053,7 +1053,7 @@ AwsIotShadowError_t AwsIotShadow_UpdateAsync( IotMqttConnection_t mqttConnection AwsIotShadow_Assert( pOperation->status == AWS_IOT_SHADOW_STATUS_PENDING ); /* Allocate memory for the client token. */ - pOperation->u.update.pClientToken = AwsIotShadow_MallocString( clientTokenLength ); + pOperation->u.update.pClientToken = AwsIotShadow_MallocString( clientTokenLength ); if( pOperation->u.update.pClientToken == NULL ) { @@ -1079,11 +1079,11 @@ AwsIotShadowError_t AwsIotShadow_UpdateAsync( IotMqttConnection_t mqttConnection /* Process the Shadow operation. This subscribes to any required topics and * sends the MQTT message for the Shadow operation. */ - status = _AwsIotShadow_ProcessOperation( mqttConnection, - pUpdateInfo->pThingName, - pUpdateInfo->thingNameLength, - pOperation, - pUpdateInfo ); + status = _AwsIotShadow_ProcessOperation( mqttConnection, + pUpdateInfo->pThingName, + pUpdateInfo->thingNameLength, + pOperation, + pUpdateInfo ); /* If the Shadow operation failed, clear the now invalid reference. */ if( ( status != AWS_IOT_SHADOW_STATUS_PENDING ) && ( pUpdateOperation != NULL ) ) @@ -1101,7 +1101,7 @@ AwsIotShadowError_t AwsIotShadow_UpdateSync( IotMqttConnection_t mqttConnection, uint32_t flags, uint32_t timeoutMs ) { - AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING; + AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING; AwsIotShadowOperation_t updateOperation = AWS_IOT_SHADOW_OPERATION_INITIALIZER; /* Set the waitable flag. */ @@ -1196,7 +1196,7 @@ AwsIotShadowError_t AwsIotShadow_Wait( AwsIotShadowOperation_t operation, if( ( operation->type == SHADOW_GET ) && ( status == AWS_IOT_SHADOW_SUCCESS ) ) { - *pShadowDocument = operation->u.get.pDocument; + *pShadowDocument = operation->u.get.pDocument; *pShadowDocumentLength = operation->u.get.documentLength; } diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_operation.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_operation.c index b85f40b14..49b38b1f7 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_operation.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_operation.c @@ -175,7 +175,7 @@ static AwsIotShadowError_t _findSubscription( const char * pThingName, * @brief List of active Shadow operations awaiting a response from the Shadow * service. */ -IotListDouble_t _AwsIotShadowPendingOperations = { 0 }; +IotListDouble_t _AwsIotShadowPendingOperations = { 0 }; /** * @brief Protects #_AwsIotShadowPendingOperations from concurrent access. @@ -263,20 +263,20 @@ static bool _shadowOperationMatch( const IotLink_t * pOperationLink, * must never be NULL. */ AwsIotShadow_Assert( pOperationLink != NULL ); - _shadowOperation_t * pOperation = IotLink_Container( _shadowOperation_t, - pOperationLink, - link ); - _operationMatchParams_t * pParam = ( _operationMatchParams_t * ) pMatch; - _shadowSubscription_t * pSubscription = pOperation->pSubscription; - const char * pClientToken = NULL; - size_t clientTokenLength = 0; + _shadowOperation_t * pOperation = IotLink_Container( _shadowOperation_t, + pOperationLink, + link ); + _operationMatchParams_t * pParam = ( _operationMatchParams_t * ) pMatch; + _shadowSubscription_t * pSubscription = pOperation->pSubscription; + const char * pClientToken = NULL; + size_t clientTokenLength = 0; /* Check for matching Thing Name and operation type. */ - bool match = ( pOperation->type == pParam->type ) && - ( pParam->thingNameLength == pSubscription->thingNameLength ) && - ( strncmp( pParam->pThingName, - pSubscription->pThingName, - pParam->thingNameLength ) == 0 ); + bool match = ( pOperation->type == pParam->type ) && + ( pParam->thingNameLength == pSubscription->thingNameLength ) && + ( strncmp( pParam->pThingName, + pSubscription->pThingName, + pParam->thingNameLength ) == 0 ); /* For a Shadow UPDATE operation, compare the client tokens. */ if( ( match == true ) && ( pOperation->type == SHADOW_UPDATE ) ) @@ -321,11 +321,11 @@ static bool _shadowOperationMatch( const IotLink_t * pOperationLink, static void _commonOperationCallback( _shadowOperationType_t type, IotMqttCallbackParam_t * pMessage ) { - _shadowOperation_t * pOperation = NULL; - IotLink_t * pOperationLink = NULL; - AwsIotStatus_t status = AWS_IOT_UNKNOWN; - _operationMatchParams_t param = { .type = SHADOW_DELETE }; - uint32_t flags = 0; + _shadowOperation_t * pOperation = NULL; + IotLink_t * pOperationLink = NULL; + AwsIotStatus_t status = AWS_IOT_UNKNOWN; + _operationMatchParams_t param = { .type = SHADOW_DELETE }; + uint32_t flags = 0; /* Set operation type to search. */ param.type = type; @@ -333,7 +333,7 @@ static void _commonOperationCallback( _shadowOperationType_t type, /* Set the response document for a Shadow UPDATE. */ if( type == SHADOW_UPDATE ) { - param.pDocument = pMessage->u.message.info.pPayload; + param.pDocument = pMessage->u.message.info.pPayload; param.documentLength = pMessage->u.message.info.payloadLength; } @@ -383,8 +383,8 @@ static void _commonOperationCallback( _shadowOperationType_t type, pMessage->u.message.info.pTopicName ); /* Parse the status from the topic name. */ - status = AwsIot_ParseStatus( pMessage->u.message.info.pTopicName, - pMessage->u.message.info.topicNameLength ); + status = AwsIot_ParseStatus( pMessage->u.message.info.pTopicName, + pMessage->u.message.info.topicNameLength ); switch( status ) { @@ -428,7 +428,7 @@ static void _commonOperationCallback( _shadowOperationType_t type, } /* Copy the flags from the Shadow operation. The notify function may delete the operation. */ - flags = pOperation->flags; + flags = pOperation->flags; /* Notify of operation completion. */ _notifyCompletion( pOperation ); @@ -479,7 +479,7 @@ static AwsIotShadowError_t _processAcceptedGet( _shadowOperation_t * pOperation, * info. */ if( ( pOperation->flags & AWS_IOT_SHADOW_FLAG_WAITABLE ) == 0U ) { - pOperation->u.get.pDocument = pPublishInfo->pPayload; + pOperation->u.get.pDocument = pPublishInfo->pPayload; pOperation->u.get.documentLength = pPublishInfo->payloadLength; } else @@ -526,8 +526,8 @@ static void _updateCallback( void * pArgument, static void _notifyCompletion( _shadowOperation_t * pOperation ) { - AwsIotShadowCallbackParam_t callbackParam = { .callbackType = AWS_IOT_SHADOW_DELETE_COMPLETE }; - _shadowSubscription_t * pSubscription = pOperation->pSubscription, + AwsIotShadowCallbackParam_t callbackParam = { .callbackType = AWS_IOT_SHADOW_DELETE_COMPLETE }; + _shadowSubscription_t * pSubscription = pOperation->pSubscription, * pRemovedSubscription = NULL; /* If the operation is waiting, post to its wait semaphore and return. */ @@ -558,17 +558,17 @@ static void _notifyCompletion( _shadowOperation_t * pOperation ) if( pOperation->notify.callback.function != NULL ) { /* Set the common members of the callback parameter. */ - callbackParam.callbackType = _AwsIotShadow_IntToShadowCallbackType( ( uint32_t ) pOperation->type ); - callbackParam.mqttConnection = pOperation->mqttConnection; - callbackParam.u.operation.result = pOperation->status; + callbackParam.callbackType = _AwsIotShadow_IntToShadowCallbackType( ( uint32_t ) pOperation->type ); + callbackParam.mqttConnection = pOperation->mqttConnection; + callbackParam.u.operation.result = pOperation->status; callbackParam.u.operation.reference = pOperation; - callbackParam.pThingName = pSubscription->pThingName; - callbackParam.thingNameLength = pSubscription->thingNameLength; + callbackParam.pThingName = pSubscription->pThingName; + callbackParam.thingNameLength = pSubscription->thingNameLength; /* Set the members of the callback parameter for a received document. */ if( pOperation->type == SHADOW_GET ) { - callbackParam.u.operation.get.pDocument = pOperation->u.get.pDocument; + callbackParam.u.operation.get.pDocument = pOperation->u.get.pDocument; callbackParam.u.operation.get.documentLength = pOperation->u.get.documentLength; } @@ -595,8 +595,8 @@ static AwsIotShadowError_t _findSubscription( const char * pThingName, _shadowOperation_t * pOperation, bool * pFreeTopicBuffer ) { - AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS; - _shadowSubscription_t * pSubscription = NULL; + AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS; + _shadowSubscription_t * pSubscription = NULL; /* Lookup table for Shadow operation callbacks. */ const AwsIotMqttCallbackFunction_t shadowCallbacks[ SHADOW_OPERATION_COUNT ] = @@ -638,7 +638,7 @@ static AwsIotShadowError_t _findSubscription( const char * pThingName, pSubscription->pTopicBuffer = pTopicBuffer; /* Don't free the topic buffer if it was allocated to the subscription. */ - *pFreeTopicBuffer = false; + *pFreeTopicBuffer = false; } else { @@ -647,10 +647,10 @@ static AwsIotShadowError_t _findSubscription( const char * pThingName, /* Increment the reference count for this Shadow operation's * subscriptions. */ - status = _AwsIotShadow_IncrementReferences( pOperation, - pTopicBuffer, - operationTopicLength, - shadowCallbacks[ pOperation->type ] ); + status = _AwsIotShadow_IncrementReferences( pOperation, + pTopicBuffer, + operationTopicLength, + shadowCallbacks[ pOperation->type ] ); if( status != AWS_IOT_SHADOW_SUCCESS ) { @@ -674,7 +674,7 @@ AwsIotShadowError_t _AwsIotShadow_CreateOperation( _shadowOperation_t ** pNewOpe uint32_t flags, const AwsIotShadowCallbackInfo_t * pCallbackInfo ) { - AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS; + AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS; _shadowOperation_t * pOperation = NULL; IotLogDebug( "Creating operation record for Shadow %s.", @@ -689,12 +689,12 @@ AwsIotShadowError_t _AwsIotShadow_CreateOperation( _shadowOperation_t ** pNewOpe ( void ) memset( pOperation, 0x00, sizeof( _shadowOperation_t ) ); /* Set the remaining common members of the Shadow operation. */ - pOperation->type = type; - pOperation->flags = flags; + pOperation->type = type; + pOperation->flags = flags; pOperation->status = AWS_IOT_SHADOW_STATUS_PENDING; /* Set the output parameter. */ - *pNewOperation = pOperation; + *pNewOperation = pOperation; /* Check if the waitable flag is set. If it is, create a semaphore to * wait on. */ @@ -707,7 +707,7 @@ AwsIotShadowError_t _AwsIotShadow_CreateOperation( _shadowOperation_t ** pNewOpe *pNewOperation = NULL; AwsIotShadow_FreeOperation( pOperation ); - status = AWS_IOT_SHADOW_NO_MEMORY; + status = AWS_IOT_SHADOW_NO_MEMORY; } } else @@ -771,11 +771,11 @@ AwsIotShadowError_t _AwsIotShadow_GenerateShadowTopic( _shadowOperationType_t ty char ** pTopicBuffer, uint16_t * pOperationTopicLength ) { - AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS; - AwsIotTopicInfo_t topicInfo = { 0 }; + AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS; + AwsIotTopicInfo_t topicInfo = { 0 }; /* Lookup table for Shadow operation strings. */ - const char * const pOperationString[ SHADOW_OPERATION_COUNT ] = + const char * const pOperationString[ SHADOW_OPERATION_COUNT ] = { SHADOW_DELETE_OPERATION_STRING, /* Shadow delete operation. */ SHADOW_GET_OPERATION_STRING, /* Shadow get operation. */ @@ -783,7 +783,7 @@ AwsIotShadowError_t _AwsIotShadow_GenerateShadowTopic( _shadowOperationType_t ty }; /* Lookup table for Shadow operation string lengths. */ - const uint16_t pOperationStringLength[ SHADOW_OPERATION_COUNT ] = + const uint16_t pOperationStringLength[ SHADOW_OPERATION_COUNT ] = { SHADOW_DELETE_OPERATION_STRING_LENGTH, /* Shadow delete operation. */ SHADOW_GET_OPERATION_STRING_LENGTH, /* Shadow get operation. */ @@ -797,12 +797,12 @@ AwsIotShadowError_t _AwsIotShadow_GenerateShadowTopic( _shadowOperationType_t ty ( type == SHADOW_UPDATE ) ); /* Set the members needed to generate an operation topic. */ - topicInfo.pThingName = pThingName; - topicInfo.thingNameLength = thingNameLength; - topicInfo.pOperationName = pOperationString[ type ]; + topicInfo.pThingName = pThingName; + topicInfo.thingNameLength = thingNameLength; + topicInfo.pOperationName = pOperationString[ type ]; topicInfo.operationNameLength = pOperationStringLength[ type ]; topicInfo.longestSuffixLength = SHADOW_LONGEST_SUFFIX_LENGTH; - topicInfo.mallocString = AwsIotShadow_MallocString; + topicInfo.mallocString = AwsIotShadow_MallocString; if( AwsIot_GenerateOperationTopic( &topicInfo, pTopicBuffer, @@ -822,12 +822,12 @@ AwsIotShadowError_t _AwsIotShadow_ProcessOperation( IotMqttConnection_t mqttConn _shadowOperation_t * pOperation, const AwsIotShadowDocumentInfo_t * pDocumentInfo ) { - AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING; - IotMqttError_t publishStatus = IOT_MQTT_STATUS_PENDING; - char * pTopicBuffer = NULL; - uint16_t operationTopicLength = 0; - bool freeTopicBuffer = true; - IotMqttPublishInfo_t publishInfo = IOT_MQTT_PUBLISH_INFO_INITIALIZER; + AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING; + IotMqttError_t publishStatus = IOT_MQTT_STATUS_PENDING; + char * pTopicBuffer = NULL; + uint16_t operationTopicLength = 0; + bool freeTopicBuffer = true; + IotMqttPublishInfo_t publishInfo = IOT_MQTT_PUBLISH_INFO_INITIALIZER; IotLogDebug( "Processing Shadow operation %s for Thing %.*s.", _pAwsIotShadowOperationNames[ pOperation->type ], @@ -838,11 +838,11 @@ AwsIotShadowError_t _AwsIotShadow_ProcessOperation( IotMqttConnection_t mqttConn pOperation->mqttConnection = mqttConnection; /* Generate the operation topic buffer. */ - status = _AwsIotShadow_GenerateShadowTopic( pOperation->type, - pThingName, - thingNameLength, - &pTopicBuffer, - &operationTopicLength ); + status = _AwsIotShadow_GenerateShadowTopic( pOperation->type, + pThingName, + thingNameLength, + &pTopicBuffer, + &operationTopicLength ); if( status == AWS_IOT_SHADOW_SUCCESS ) { @@ -864,7 +864,7 @@ AwsIotShadowError_t _AwsIotShadow_ProcessOperation( IotMqttConnection_t mqttConn if( status == AWS_IOT_SHADOW_SUCCESS ) { /* Set the operation topic name. */ - publishInfo.pTopicName = pTopicBuffer; + publishInfo.pTopicName = pTopicBuffer; publishInfo.topicNameLength = operationTopicLength; IotLogDebug( "Shadow %s message will be published to topic %.*s", @@ -875,9 +875,9 @@ AwsIotShadowError_t _AwsIotShadow_ProcessOperation( IotMqttConnection_t mqttConn /* Set the document info if this operation is not a Shadow DELETE. */ if( pOperation->type != SHADOW_DELETE ) { - publishInfo.qos = pDocumentInfo->qos; + publishInfo.qos = pDocumentInfo->qos; publishInfo.retryLimit = pDocumentInfo->retryLimit; - publishInfo.retryMs = pDocumentInfo->retryMs; + publishInfo.retryMs = pDocumentInfo->retryMs; IotLogDebug( "Shadow %s message will be published at QoS %d with " "retryLimit %d and retryMs %llu.", @@ -890,7 +890,7 @@ AwsIotShadowError_t _AwsIotShadow_ProcessOperation( IotMqttConnection_t mqttConn /* Set the PUBLISH payload to the update document for Shadow UPDATE. */ if( pOperation->type == SHADOW_UPDATE ) { - publishInfo.pPayload = pDocumentInfo->u.update.pUpdateDocument; + publishInfo.pPayload = pDocumentInfo->u.update.pUpdateDocument; publishInfo.payloadLength = pDocumentInfo->u.update.updateDocumentLength; } @@ -898,7 +898,7 @@ AwsIotShadowError_t _AwsIotShadow_ProcessOperation( IotMqttConnection_t mqttConn * per the Shadow spec. */ else { - publishInfo.pPayload = ""; + publishInfo.pPayload = ""; publishInfo.payloadLength = 0; } @@ -909,10 +909,10 @@ AwsIotShadowError_t _AwsIotShadow_ProcessOperation( IotMqttConnection_t mqttConn IotMutex_Unlock( &( _AwsIotShadowPendingOperationsMutex ) ); /* Publish to the Shadow topic name. */ - publishStatus = IotMqtt_PublishSync( pOperation->mqttConnection, - &publishInfo, - 0, - _AwsIotShadowMqttTimeoutMs ); + publishStatus = IotMqtt_PublishSync( pOperation->mqttConnection, + &publishInfo, + 0, + _AwsIotShadowMqttTimeoutMs ); if( publishStatus == IOT_MQTT_SUCCESS ) { diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_parser.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_parser.c index ee10fa56d..f079dd4ea 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_parser.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_parser.c @@ -131,9 +131,9 @@ AwsIotShadowError_t _AwsIotShadow_ParseErrorDocument( const char * pErrorDocumen size_t errorDocumentLength ) { AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING; - const char * pCode = NULL, * pMessage = NULL; - size_t codeLength = 0, messageLength = 0; - uint32_t code = 0; + const char * pCode = NULL, * pMessage = NULL; + size_t codeLength = 0, messageLength = 0; + uint32_t code = 0; /* Parse the code from the error document. */ if( AwsIotDocParser_FindValue( pErrorDocument, diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_static_memory.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_static_memory.c index 3dcf6082b..af160a717 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_static_memory.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_static_memory.c @@ -80,18 +80,18 @@ /* * Static memory buffers and flags, allocated and zeroed at compile-time. */ - static uint32_t _pInUseShadowOperations[ AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS ] = { 0U }; /**< @brief Shadow operation in-use flags. */ - static _shadowOperation_t _pShadowOperations[ AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS ] = { { .link = { 0 } } }; /**< @brief Shadow operations. */ + static uint32_t _pInUseShadowOperations[ AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS ] = { 0U }; /**< @brief Shadow operation in-use flags. */ + static _shadowOperation_t _pShadowOperations[ AWS_IOT_SHADOW_MAX_IN_PROGRESS_OPERATIONS ] = { { .link = { 0 } } }; /**< @brief Shadow operations. */ - static uint32_t _pInUseShadowSubscriptions[ AWS_IOT_SHADOW_SUBSCRIPTIONS ] = { 0U }; /**< @brief Shadow subscription in-use flags. */ - static char _pShadowSubscriptions[ AWS_IOT_SHADOW_SUBSCRIPTIONS ][ SHADOW_SUBSCRIPTION_SIZE ] = { { '\0' } }; /**< @brief Shadow subscriptions. */ + static uint32_t _pInUseShadowSubscriptions[ AWS_IOT_SHADOW_SUBSCRIPTIONS ] = { 0U }; /**< @brief Shadow subscription in-use flags. */ + static char _pShadowSubscriptions[ AWS_IOT_SHADOW_SUBSCRIPTIONS ][ SHADOW_SUBSCRIPTION_SIZE ] = { { '\0' } }; /**< @brief Shadow subscriptions. */ /*-----------------------------------------------------------*/ void * AwsIotShadow_MallocOperation( size_t size ) { - int32_t freeIndex = -1; - void * pNewOperation = NULL; + int32_t freeIndex = -1; + void * pNewOperation = NULL; /* Check size argument. */ if( size == sizeof( _shadowOperation_t ) ) @@ -125,8 +125,8 @@ void * AwsIotShadow_MallocSubscription( size_t size ) { - int32_t freeIndex = -1; - void * pNewSubscription = NULL; + int32_t freeIndex = -1; + void * pNewSubscription = NULL; if( size <= SHADOW_SUBSCRIPTION_SIZE ) { diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_subscription.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_subscription.c index 0a8818e9d..fd15a7054 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_subscription.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/aws_iot_shadow_subscription.c @@ -72,7 +72,7 @@ IotMutex_t _AwsIotShadowSubscriptionsMutex; static bool _shadowSubscription_match( const IotLink_t * pSubscriptionLink, void * pMatch ) { - bool match = false; + bool match = false; /* Because this function is called from a container function, the given link * must never be NULL. */ @@ -81,7 +81,7 @@ static bool _shadowSubscription_match( const IotLink_t * pSubscriptionLink, const _shadowSubscription_t * pSubscription = IotLink_Container( _shadowSubscription_t, pSubscriptionLink, link ); - const AwsIotThingName_t * pThingName = ( AwsIotThingName_t * ) pMatch; + const AwsIotThingName_t * pThingName = ( AwsIotThingName_t * ) pMatch; if( pThingName->thingNameLength == pSubscription->thingNameLength ) { @@ -100,18 +100,18 @@ _shadowSubscription_t * _AwsIotShadow_FindSubscription( const char * pThingName, size_t thingNameLength, bool createIfNotFound ) { - _shadowSubscription_t * pSubscription = NULL; - IotLink_t * pSubscriptionLink = NULL; - AwsIotThingName_t thingName = { 0 }; + _shadowSubscription_t * pSubscription = NULL; + IotLink_t * pSubscriptionLink = NULL; + AwsIotThingName_t thingName = { 0 }; - thingName.pThingName = pThingName; + thingName.pThingName = pThingName; thingName.thingNameLength = thingNameLength; /* Search the list for an existing subscription for Thing Name. */ - pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotShadowSubscriptions ), - NULL, - _shadowSubscription_match, - &thingName ); + pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotShadowSubscriptions ), + NULL, + _shadowSubscription_match, + &thingName ); /* Check if a subscription was found. */ if( pSubscriptionLink == NULL ) @@ -163,8 +163,8 @@ _shadowSubscription_t * _AwsIotShadow_FindSubscription( const char * pThingName, void _AwsIotShadow_RemoveSubscription( _shadowSubscription_t * pSubscription, _shadowSubscription_t ** pRemovedSubscription ) { - int32_t i = 0; - bool removeSubscription = true; + int32_t i = 0; + bool removeSubscription = true; IotLogDebug( "Checking if subscription object for %.*s can be removed.", pSubscription->thingNameLength, @@ -272,11 +272,11 @@ AwsIotShadowError_t _AwsIotShadow_IncrementReferences( _shadowOperation_t * pOpe uint16_t operationTopicLength, AwsIotMqttCallbackFunction_t callback ) { - AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS; - const _shadowOperationType_t type = pOperation->type; - _shadowSubscription_t * pSubscription = pOperation->pSubscription; - IotMqttError_t subscriptionStatus = IOT_MQTT_STATUS_PENDING; - AwsIotSubscriptionInfo_t subscriptionInfo = { 0 }; + AwsIotShadowError_t status = AWS_IOT_SHADOW_SUCCESS; + const _shadowOperationType_t type = pOperation->type; + _shadowSubscription_t * pSubscription = pOperation->pSubscription; + IotMqttError_t subscriptionStatus = IOT_MQTT_STATUS_PENDING; + AwsIotSubscriptionInfo_t subscriptionInfo = { 0 }; /* Do nothing if this operation has persistent subscriptions. */ if( pSubscription->references[ type ] == AWS_IOT_PERSISTENT_SUBSCRIPTION ) @@ -297,17 +297,17 @@ AwsIotShadowError_t _AwsIotShadow_IncrementReferences( _shadowOperation_t * pOpe if( pSubscription->references[ type ] == 0 ) { /* Set the parameters needed to add subscriptions. */ - subscriptionInfo.mqttConnection = pOperation->mqttConnection; - subscriptionInfo.callbackFunction = callback; - subscriptionInfo.timeout = _AwsIotShadowMqttTimeoutMs; - subscriptionInfo.pTopicFilterBase = pTopicBuffer; + subscriptionInfo.mqttConnection = pOperation->mqttConnection; + subscriptionInfo.callbackFunction = callback; + subscriptionInfo.timeout = _AwsIotShadowMqttTimeoutMs; + subscriptionInfo.pTopicFilterBase = pTopicBuffer; subscriptionInfo.topicFilterBaseLength = operationTopicLength; - subscriptionStatus = AwsIot_ModifySubscriptions( IotMqtt_SubscribeSync, - &subscriptionInfo ); + subscriptionStatus = AwsIot_ModifySubscriptions( IotMqtt_SubscribeSync, + &subscriptionInfo ); /* Convert MQTT return code to Shadow return code. */ - status = SHADOW_CONVERT_STATUS_CODE_MQTT_TO_SHADOW( subscriptionStatus ); + status = SHADOW_CONVERT_STATUS_CODE_MQTT_TO_SHADOW( subscriptionStatus ); } if( status == AWS_IOT_SHADOW_SUCCESS ) @@ -346,10 +346,10 @@ void _AwsIotShadow_DecrementReferences( _shadowOperation_t * pOperation, char * pTopicBuffer, _shadowSubscription_t ** pRemovedSubscription ) { - const _shadowOperationType_t type = pOperation->type; - _shadowSubscription_t * pSubscription = pOperation->pSubscription; - uint16_t operationTopicLength = 0; - AwsIotSubscriptionInfo_t subscriptionInfo = { 0 }; + const _shadowOperationType_t type = pOperation->type; + _shadowSubscription_t * pSubscription = pOperation->pSubscription; + uint16_t operationTopicLength = 0; + AwsIotSubscriptionInfo_t subscriptionInfo = { 0 }; /* Do nothing if this Shadow operation has persistent subscriptions. */ if( pSubscription->references[ type ] != AWS_IOT_PERSISTENT_SUBSCRIPTION ) @@ -379,9 +379,9 @@ void _AwsIotShadow_DecrementReferences( _shadowOperation_t * pOperation, &operationTopicLength ); /* Set the parameters needed to remove subscriptions. */ - subscriptionInfo.mqttConnection = pOperation->mqttConnection; - subscriptionInfo.timeout = _AwsIotShadowMqttTimeoutMs; - subscriptionInfo.pTopicFilterBase = pTopicBuffer; + subscriptionInfo.mqttConnection = pOperation->mqttConnection; + subscriptionInfo.timeout = _AwsIotShadowMqttTimeoutMs; + subscriptionInfo.pTopicFilterBase = pTopicBuffer; subscriptionInfo.topicFilterBaseLength = operationTopicLength; ( void ) AwsIot_ModifySubscriptions( IotMqtt_UnsubscribeSync, @@ -409,16 +409,16 @@ AwsIotShadowError_t AwsIotShadow_RemovePersistentSubscriptions( IotMqttConnectio size_t thingNameLength, uint32_t flags ) { - uint32_t i = 0; - uint16_t operationTopicLength = 0; - AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING; - IotMqttError_t unsubscribeStatus = IOT_MQTT_STATUS_PENDING; - AwsIotSubscriptionInfo_t subscriptionInfo = { 0 }; - _shadowSubscription_t * pSubscription = NULL; - IotLink_t * pSubscriptionLink = NULL; - AwsIotThingName_t thingName = { 0 }; - - thingName.pThingName = pThingName; + uint32_t i = 0; + uint16_t operationTopicLength = 0; + AwsIotShadowError_t status = AWS_IOT_SHADOW_STATUS_PENDING; + IotMqttError_t unsubscribeStatus = IOT_MQTT_STATUS_PENDING; + AwsIotSubscriptionInfo_t subscriptionInfo = { 0 }; + _shadowSubscription_t * pSubscription = NULL; + IotLink_t * pSubscriptionLink = NULL; + AwsIotThingName_t thingName = { 0 }; + + thingName.pThingName = pThingName; thingName.thingNameLength = thingNameLength; IotLogInfo( "Removing persistent subscriptions for %.*s.", @@ -428,10 +428,10 @@ AwsIotShadowError_t AwsIotShadow_RemovePersistentSubscriptions( IotMqttConnectio IotMutex_Lock( &( _AwsIotShadowSubscriptionsMutex ) ); /* Search the list for an existing subscription for Thing Name. */ - pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotShadowSubscriptions ), - NULL, - _shadowSubscription_match, - &thingName ); + pSubscriptionLink = IotListDouble_FindFirstMatch( &( _AwsIotShadowSubscriptions ), + NULL, + _shadowSubscription_match, + &thingName ); /* Unsubscribe from operation subscriptions if found. */ if( pSubscriptionLink != NULL ) @@ -466,16 +466,16 @@ AwsIotShadowError_t AwsIotShadow_RemovePersistentSubscriptions( IotMqttConnectio &operationTopicLength ); /* Set the parameters needed to remove subscriptions. */ - subscriptionInfo.mqttConnection = mqttConnection; - subscriptionInfo.timeout = _AwsIotShadowMqttTimeoutMs; - subscriptionInfo.pTopicFilterBase = pSubscription->pTopicBuffer; + subscriptionInfo.mqttConnection = mqttConnection; + subscriptionInfo.timeout = _AwsIotShadowMqttTimeoutMs; + subscriptionInfo.pTopicFilterBase = pSubscription->pTopicBuffer; subscriptionInfo.topicFilterBaseLength = operationTopicLength; - unsubscribeStatus = AwsIot_ModifySubscriptions( IotMqtt_UnsubscribeSync, - &subscriptionInfo ); + unsubscribeStatus = AwsIot_ModifySubscriptions( IotMqtt_UnsubscribeSync, + &subscriptionInfo ); /* Convert MQTT return code to Shadow return code. */ - status = SHADOW_CONVERT_STATUS_CODE_MQTT_TO_SHADOW( unsubscribeStatus ); + status = SHADOW_CONVERT_STATUS_CODE_MQTT_TO_SHADOW( unsubscribeStatus ); if( status != AWS_IOT_SHADOW_SUCCESS ) { @@ -484,7 +484,7 @@ AwsIotShadowError_t AwsIotShadow_RemovePersistentSubscriptions( IotMqttConnectio /* Clear the persistent subscriptions flag and check if the * subscription can be removed. */ - pSubscription->references[ i ] = 0; + pSubscription->references[ i ] = 0; _AwsIotShadow_RemoveSubscription( pSubscription, NULL ); } else diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/private/aws_iot_shadow_internal.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/private/aws_iot_shadow_internal.h index 6cd613cba..2b9377dd6 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/private/aws_iot_shadow_internal.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/aws/shadow/src/private/aws_iot_shadow_internal.h @@ -377,11 +377,11 @@ typedef struct _shadowOperation #endif /* Declarations of variables for internal Shadow files. */ -extern uint32_t _AwsIotShadowMqttTimeoutMs; -extern IotListDouble_t _AwsIotShadowPendingOperations; -extern IotListDouble_t _AwsIotShadowSubscriptions; -extern IotMutex_t _AwsIotShadowPendingOperationsMutex; -extern IotMutex_t _AwsIotShadowSubscriptionsMutex; +extern uint32_t _AwsIotShadowMqttTimeoutMs; +extern IotListDouble_t _AwsIotShadowPendingOperations; +extern IotListDouble_t _AwsIotShadowSubscriptions; +extern IotMutex_t _AwsIotShadowPendingOperationsMutex; +extern IotMutex_t _AwsIotShadowSubscriptionsMutex; /*----------------------- Shadow operation functions ------------------------*/ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/atomic.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/atomic.h index 9af7e9552..ad49432bf 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/atomic.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/atomic.h @@ -179,7 +179,7 @@ #else ATOMIC_ENTER_CRITICAL(); - pReturnValue = *ppDestination; + pReturnValue = *ppDestination; *ppDestination = pExchange; @@ -227,7 +227,7 @@ if( *ppDestination == pComparand ) { *ppDestination = pExchange; - ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; + ulReturnValue = ATOMIC_COMPARE_AND_SWAP_SUCCESS; } ATOMIC_EXIT_CRITICAL(); #endif /* if defined( configUSE_GCC_BUILTIN_ATOMICS ) && ( configUSE_GCC_BUILTIN_ATOMICS == 1 ) */ @@ -382,7 +382,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination |= ulValue; @@ -413,7 +413,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination &= ulValue; @@ -444,7 +444,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination = ~( ulCurrent & ulValue ); @@ -475,7 +475,7 @@ ATOMIC_ENTER_CRITICAL(); - ulCurrent = *pDestination; + ulCurrent = *pDestination; *pDestination ^= ulValue; diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_linear_containers.h b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_linear_containers.h index ed9b6ed6e..c76ab7060 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_linear_containers.h +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/include/iot_linear_containers.h @@ -243,7 +243,7 @@ static inline void IotListDouble_Create( IotListDouble_t * const pList ) /* An empty list is a link pointing to itself. */ pList->pPrevious = pList; - pList->pNext = pList; + pList->pNext = pList; } /** @@ -363,12 +363,12 @@ static inline void IotListDouble_InsertHead( IotListDouble_t * const pList, IotLink_t * pHead = pList->pNext; /* Place new element before list head. */ - pLink->pNext = pHead; + pLink->pNext = pHead; pLink->pPrevious = pList; /* Assign new list head. */ pHead->pPrevious = pLink; - pList->pNext = pLink; + pList->pNext = pLink; } /** @@ -389,11 +389,11 @@ static inline void IotListDouble_InsertTail( IotListDouble_t * const pList, /* Save current list tail. */ IotLink_t * pTail = pList->pPrevious; - pLink->pNext = pList; + pLink->pNext = pList; pLink->pPrevious = pTail; pList->pPrevious = pLink; - pTail->pNext = pLink; + pTail->pNext = pLink; } /** @@ -457,7 +457,7 @@ static inline void IotListDouble_InsertSorted( IotListDouble_t * const pList, } else { - bool inserted = false; + bool inserted = false; IotLink_t * pCurrent = pList->pNext; /* Iterate through the list to find the correct position. */ @@ -500,8 +500,8 @@ static inline void IotListDouble_Remove( IotLink_t * const pLink ) pLink->pPrevious->pNext = pLink->pNext; pLink->pNext->pPrevious = pLink->pPrevious; - pLink->pPrevious = NULL; - pLink->pNext = NULL; + pLink->pPrevious = NULL; + pLink->pNext = NULL; } /** @@ -624,7 +624,7 @@ static inline IotLink_t * IotListDouble_FindFirstMatch( const IotListDouble_t * /* The const must be cast away to match this function's return value. Nevertheless, * this function will respect the const-ness of pStartPoint. */ IotLink_t * pCurrent = ( IotLink_t * ) pStartPoint, * pMatchedLink = NULL; - bool matchFound = false; + bool matchFound = false; /* This function must not be called with a NULL pList parameter. */ IotContainers_Assert( pList != NULL ); @@ -738,7 +738,7 @@ static inline void IotListDouble_RemoveAllMatches( const IotListDouble_t * const if( pMatchedElement != NULL ) { /* Save pointer to next element. */ - pNextElement = pMatchedElement->pNext; + pNextElement = pMatchedElement->pNext; /* Match found; remove and free. */ IotListDouble_Remove( pMatchedElement ); diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/src/iot_logging.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/src/iot_logging.c index 4a97cb12b..932f4e8f0 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/src/iot_logging.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/common/src/iot_logging.c @@ -161,7 +161,7 @@ static const char * const _pLogLevelStrings[ 5 ] = size_t newSize, size_t oldSize ) { - bool status = false; + bool status = false; /* Allocate a new, larger buffer. */ void * pNewBuffer = IotLogging_Malloc( newSize ); @@ -176,7 +176,7 @@ static const char * const _pLogLevelStrings[ 5 ] = IotLogging_Free( *pOldBuffer ); *pOldBuffer = pNewBuffer; - status = true; + status = true; } return status; @@ -192,10 +192,10 @@ void IotLog_Generic( int32_t libraryLogSetting, const char * const pFormat, ... ) { - int requiredMessageSize = 0; - size_t bufferSize = 0, - bufferPosition = 0, timestringLength = 0; - char * pLoggingBuffer = NULL; + int requiredMessageSize = 0; + size_t bufferSize = 0, + bufferPosition = 0, timestringLength = 0; + char * pLoggingBuffer = NULL; va_list args; /* If the library's log level setting is lower than the message level, @@ -225,7 +225,7 @@ void IotLog_Generic( int32_t libraryLogSetting, } /* Add 64 as an initial (arbitrary) guess for the length of the message. */ - bufferSize += 64; + bufferSize += 64; /* In static memory mode, check that the log message will fit in the a * static buffer. */ @@ -238,11 +238,11 @@ void IotLog_Generic( int32_t libraryLogSetting, } /* Otherwise, update the buffer size to the size of a static buffer. */ - bufferSize = IotLogging_StaticBufferSize(); + bufferSize = IotLogging_StaticBufferSize(); #endif /* Allocate memory for the logging buffer. */ - pLoggingBuffer = ( char * ) IotLogging_Malloc( bufferSize ); + pLoggingBuffer = ( char * ) IotLogging_Malloc( bufferSize ); if( pLoggingBuffer == NULL ) { @@ -270,7 +270,7 @@ void IotLog_Generic( int32_t libraryLogSetting, } /* Update the buffer position. */ - bufferPosition += ( size_t ) requiredMessageSize; + bufferPosition += ( size_t ) requiredMessageSize; } } @@ -292,7 +292,7 @@ void IotLog_Generic( int32_t libraryLogSetting, } /* Update the buffer position. */ - bufferPosition += ( size_t ) requiredMessageSize; + bufferPosition += ( size_t ) requiredMessageSize; } /* Print the timestring if requested. */ @@ -308,7 +308,7 @@ void IotLog_Generic( int32_t libraryLogSetting, ×tringLength ) == true ) { /* If the timestring was successfully generated, add the closing "]". */ - bufferPosition += timestringLength; + bufferPosition += timestringLength; pLoggingBuffer[ bufferPosition ] = ']'; bufferPosition++; } @@ -363,7 +363,7 @@ void IotLog_Generic( int32_t libraryLogSetting, } /* Reallocation successful, update buffer size. */ - bufferSize = ( size_t ) requiredMessageSize + bufferPosition + 1; + bufferSize = ( size_t ) requiredMessageSize + bufferPosition + 1; /* Add the log message to the buffer. Now that the buffer has been * reallocated, this should succeed. */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_client.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_client.c index dd3e79e36..2d8854756 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_client.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_client.c @@ -103,10 +103,10 @@ * internal request context, the HTTP formatted request line, the User-Agent header line, and the part of the Host * header line. */ -const uint32_t requestUserBufferMinimumSize = sizeof( _httpsRequest_t ) + - sizeof( HTTPS_PARTIAL_REQUEST_LINE ) + - sizeof( HTTPS_USER_AGENT_HEADER_LINE ) + - sizeof( HTTPS_PARTIAL_HOST_HEADER_LINE ); +const uint32_t requestUserBufferMinimumSize = sizeof( _httpsRequest_t ) + + sizeof( HTTPS_PARTIAL_REQUEST_LINE ) + + sizeof( HTTPS_USER_AGENT_HEADER_LINE ) + + sizeof( HTTPS_PARTIAL_HOST_HEADER_LINE ); /** * @brief Minimum size of the response user buffer. @@ -115,7 +115,7 @@ const uint32_t requestUserBufferMinimumSize = sizeof( _httpsRequest_t ) + * of the response and then the response headers right after. This minimum size is calculated for the case if no bytes * from the HTTP response headers are to be stored. */ -const uint32_t responseUserBufferMinimumSize = sizeof( _httpsResponse_t ); +const uint32_t responseUserBufferMinimumSize = sizeof( _httpsResponse_t ); /** * @brief Minimum size of the connection user buffer. @@ -640,7 +640,7 @@ static http_parser_settings _httpParserSettings = { 0 }; static int _httpParserOnMessageBeginCallback( http_parser * pHttpParser ) { - int retVal = KEEP_PARSING; + int retVal = KEEP_PARSING; IotLogDebug( "Parser: Start of HTTPS Response message." ); @@ -716,7 +716,7 @@ static int _httpParserOnHeaderValueCallback( http_parser * pHttpParser, const char * pLoc, size_t length ) { - int retVal = KEEP_PARSING; + int retVal = KEEP_PARSING; IotLogDebug( "Parser: HTTPS header value parsed %.*s", length, pLoc ); _httpsResponse_t * pHttpsResponse = ( _httpsResponse_t * ) ( pHttpParser->data ); @@ -733,10 +733,10 @@ static int _httpParserOnHeaderValueCallback( http_parser * pHttpParser, { if( pHttpsResponse->foundHeaderField ) { - pHttpsResponse->pReadHeaderValue = ( char * ) ( pLoc ); + pHttpsResponse->pReadHeaderValue = ( char * ) ( pLoc ); pHttpsResponse->readHeaderValueLength = length; /* We found a header field so we don't want to keep parsing.*/ - retVal = STOP_PARSING; + retVal = STOP_PARSING; } } @@ -749,7 +749,7 @@ static int _httpParserOnHeadersCompleteCallback( http_parser * pHttpParser ) { IotLogDebug( "Parser: End of the headers reached." ); - int retVal = KEEP_PARSING; + int retVal = KEEP_PARSING; _httpsResponse_t * pHttpsResponse = ( _httpsResponse_t * ) ( pHttpParser->data ); pHttpsResponse->parserState = PARSER_STATE_HEADERS_COMPLETE; @@ -779,7 +779,7 @@ static int _httpParserOnHeadersCompleteCallback( http_parser * pHttpParser ) /* For a HEAD method, there is no body expected in the response, so we return 1 to skip body parsing. */ if( ( pHttpsResponse->method == IOT_HTTPS_METHOD_HEAD ) ) { - retVal = STOP_PARSING; + retVal = STOP_PARSING; /* Since the message is considered complete now for a HEAD response, then we set the parser state * to the completed state. */ @@ -823,7 +823,7 @@ static int _httpParserOnBodyCallback( http_parser * pHttpParser, */ if( pHttpsResponse->pBodyInHeaderBuf == NULL ) { - pHttpsResponse->pBodyInHeaderBuf = ( uint8_t * ) ( pLoc ); + pHttpsResponse->pBodyInHeaderBuf = ( uint8_t * ) ( pLoc ); pHttpsResponse->pBodyCurInHeaderBuf = pHttpsResponse->pBodyInHeaderBuf; } @@ -1040,21 +1040,21 @@ static void _networkReceiveCallback( void * pNetworkConnection, { HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); - IotHttpsReturnCode_t flushStatus = IOT_HTTPS_OK; - IotHttpsReturnCode_t disconnectStatus = IOT_HTTPS_OK; - IotHttpsReturnCode_t scheduleStatus = IOT_HTTPS_OK; - _httpsConnection_t * pHttpsConnection = ( _httpsConnection_t * ) pReceiveContext; - _httpsResponse_t * pCurrentHttpsResponse = NULL; - _httpsRequest_t * pNextHttpsRequest = NULL; - IotLink_t * pQItem = NULL; - bool fatalDisconnect = false; + IotHttpsReturnCode_t flushStatus = IOT_HTTPS_OK; + IotHttpsReturnCode_t disconnectStatus = IOT_HTTPS_OK; + IotHttpsReturnCode_t scheduleStatus = IOT_HTTPS_OK; + _httpsConnection_t * pHttpsConnection = ( _httpsConnection_t * ) pReceiveContext; + _httpsResponse_t * pCurrentHttpsResponse = NULL; + _httpsRequest_t * pNextHttpsRequest = NULL; + IotLink_t * pQItem = NULL; + bool fatalDisconnect = false; /* The network connection is already in the connection context. */ ( void ) pNetworkConnection; /* Get the response from the response queue. */ IotMutex_Lock( &( pHttpsConnection->connectionMutex ) ); - pQItem = IotDeQueue_PeekHead( &( pHttpsConnection->respQ ) ); + pQItem = IotDeQueue_PeekHead( &( pHttpsConnection->respQ ) ); IotMutex_Unlock( &( pHttpsConnection->connectionMutex ) ); /* If the receive callback is invoked and there is no response expected, then this a violation of the HTTP/1.1 @@ -1067,7 +1067,7 @@ static void _networkReceiveCallback( void * pNetworkConnection, } /* Set the current HTTP response context to use. */ - pCurrentHttpsResponse = IotLink_Container( _httpsResponse_t, pQItem, link ); + pCurrentHttpsResponse = IotLink_Container( _httpsResponse_t, pQItem, link ); /* If the receive callback has invoked, but the request associated with this response has not finished sending * to the server, then this is a violation of the HTTP/1.1 protocol. */ @@ -1091,7 +1091,7 @@ static void _networkReceiveCallback( void * pNetworkConnection, /* Receive the response from the network. */ /* Receive the headers first. */ - status = _receiveHttpsHeaders( pHttpsConnection, pCurrentHttpsResponse ); + status = _receiveHttpsHeaders( pHttpsConnection, pCurrentHttpsResponse ); if( HTTPS_FAILED( status ) ) { @@ -1245,7 +1245,7 @@ static void _networkReceiveCallback( void * pNetworkConnection, * * All network errors are ignore here because network read will have read the data from network buffer despite * errors. */ - flushStatus = _flushHttpsNetworkData( pHttpsConnection, pCurrentHttpsResponse ); + flushStatus = _flushHttpsNetworkData( pHttpsConnection, pCurrentHttpsResponse ); if( flushStatus == IOT_HTTPS_PARSING_ERROR ) { @@ -1258,7 +1258,7 @@ static void _networkReceiveCallback( void * pNetworkConnection, IotMutex_Lock( &( pHttpsConnection->connectionMutex ) ); /* Get the next request to process. */ - pQItem = IotDeQueue_PeekHead( &( pHttpsConnection->reqQ ) ); + pQItem = IotDeQueue_PeekHead( &( pHttpsConnection->reqQ ) ); IotMutex_Unlock( &( pHttpsConnection->connectionMutex ) ); /* If there is a next request to process, then create a taskpool job to send the request. */ @@ -1332,20 +1332,20 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t * { HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); - IotNetworkError_t networkStatus = IOT_NETWORK_SUCCESS; + IotNetworkError_t networkStatus = IOT_NETWORK_SUCCESS; /* The maximum string length of the ALPN protocols is configured in IOT_HTTPS_MAX_ALPN_PROTOCOLS_LENGTH. * The +1 is for the NULL terminator needed by IotNetworkCredentials_t.pAlpnProtos. */ - char pAlpnProtos[ IOT_HTTPS_MAX_ALPN_PROTOCOLS_LENGTH + 1 ] = { 0 }; + char pAlpnProtos[ IOT_HTTPS_MAX_ALPN_PROTOCOLS_LENGTH + 1 ] = { 0 }; /* The maximum string length of the Server host name is configured in IOT_HTTPS_MAX_HOST_NAME_LENGTH. * This +1 is for the NULL terminator needed by IotNetworkServerInfo_t.pHostName. */ - char pHostName[ IOT_HTTPS_MAX_HOST_NAME_LENGTH + 1 ] = { 0 }; - bool connectionMutexCreated = false; - struct IotNetworkServerInfo networkServerInfo = { 0 }; - struct IotNetworkCredentials networkCredentials = { 0 }; - _httpsConnection_t * pHttpsConnection = NULL; - IotNetworkCredentials_t pNetworkCredentials = NULL; + char pHostName[ IOT_HTTPS_MAX_HOST_NAME_LENGTH + 1 ] = { 0 }; + bool connectionMutexCreated = false; + struct IotNetworkServerInfo networkServerInfo = { 0 }; + struct IotNetworkCredentials networkCredentials = { 0 }; + _httpsConnection_t * pHttpsConnection = NULL; + IotNetworkCredentials_t pNetworkCredentials = NULL; HTTPS_ON_NULL_ARG_GOTO_CLEANUP( pConnInfo->userBuffer.pBuffer ); HTTPS_ON_NULL_ARG_GOTO_CLEANUP( pConnInfo->pNetworkInterface ); @@ -1373,13 +1373,13 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t * pConnInfo->alpnProtocolsLen, IOT_HTTPS_MAX_ALPN_PROTOCOLS_LENGTH ); - pHttpsConnection = ( _httpsConnection_t * ) ( pConnInfo->userBuffer.pBuffer ); + pHttpsConnection = ( _httpsConnection_t * ) ( pConnInfo->userBuffer.pBuffer ); /* Start with the disconnected state. */ - pHttpsConnection->isConnected = false; + pHttpsConnection->isConnected = false; /* Initialize disconnection state keeper. */ - pHttpsConnection->isDestroyed = false; + pHttpsConnection->isDestroyed = false; /* Initialize the queue of responses and requests. */ IotDeQueue_Create( &( pHttpsConnection->reqQ ) ); @@ -1403,10 +1403,10 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t * * is required in IotNetworkServerInfo_t.pHostName. IotNetworkServerInfo_t contains the server information needed * by the network interface to create the connection. */ memcpy( pHostName, pConnInfo->pAddress, pConnInfo->addressLen ); - pHostName[ pConnInfo->addressLen ] = '\0'; + pHostName[ pConnInfo->addressLen ] = '\0'; /* Set it in the IOT network abstractions server information parameter. */ - networkServerInfo.pHostName = pHostName; - networkServerInfo.port = pConnInfo->port; + networkServerInfo.pHostName = pHostName; + networkServerInfo.port = pConnInfo->port; /* If this is TLS connection, then set the network credentials. */ if( ( pConnInfo->flags & IOT_HTTPS_IS_NON_TLS_FLAG ) == 0 ) @@ -1427,7 +1427,7 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t * * terminator. */ memcpy( pAlpnProtos, pConnInfo->pAlpnProtocols, pConnInfo->alpnProtocolsLen ); pAlpnProtos[ pConnInfo->alpnProtocolsLen ] = '\0'; - networkCredentials.pAlpnProtos = pAlpnProtos; + networkCredentials.pAlpnProtos = pAlpnProtos; } else { @@ -1437,14 +1437,14 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t * /* If any of these are NULL a network error will result when trying to make the connection. Because there is * no invalid memory access resulting from these configurations being NULL, it is not check at the start * of the function. */ - networkCredentials.pRootCa = pConnInfo->pCaCert; - networkCredentials.rootCaSize = pConnInfo->caCertLen; - networkCredentials.pClientCert = pConnInfo->pClientCert; + networkCredentials.pRootCa = pConnInfo->pCaCert; + networkCredentials.rootCaSize = pConnInfo->caCertLen; + networkCredentials.pClientCert = pConnInfo->pClientCert; networkCredentials.clientCertSize = pConnInfo->clientCertLen; - networkCredentials.pPrivateKey = pConnInfo->pPrivateKey; + networkCredentials.pPrivateKey = pConnInfo->pPrivateKey; networkCredentials.privateKeySize = pConnInfo->privateKeyLen; - pNetworkCredentials = &networkCredentials; + pNetworkCredentials = &networkCredentials; } else { @@ -1454,9 +1454,9 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t * /* create() will connect to the server specified in addition to creating other network layer * specific resources. */ - networkStatus = pHttpsConnection->pNetworkInterface->create( &networkServerInfo, - pNetworkCredentials, - &( pHttpsConnection->pNetworkConnection ) ); + networkStatus = pHttpsConnection->pNetworkInterface->create( &networkServerInfo, + pNetworkCredentials, + &( pHttpsConnection->pNetworkConnection ) ); /* Check to see if the network connection succeeded. If it did not succeed, * then the output parameter pConnHandle will be used to return NULL and the @@ -1472,13 +1472,13 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t * } /* The connection succeeded so set the state to connected. */ - pHttpsConnection->isConnected = true; + pHttpsConnection->isConnected = true; /* The receive callback is invoked by the network layer when data is ready * to be read from the network. */ - networkStatus = pHttpsConnection->pNetworkInterface->setReceiveCallback( pHttpsConnection->pNetworkConnection, - _networkReceiveCallback, - pHttpsConnection ); + networkStatus = pHttpsConnection->pNetworkInterface->setReceiveCallback( pHttpsConnection->pNetworkConnection, + _networkReceiveCallback, + pHttpsConnection ); if( networkStatus != IOT_NETWORK_SUCCESS ) { @@ -1488,7 +1488,7 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t * /* Connection was successful, so create synchronization primitives. */ - connectionMutexCreated = IotMutex_Create( &( pHttpsConnection->connectionMutex ), false ); + connectionMutexCreated = IotMutex_Create( &( pHttpsConnection->connectionMutex ), false ); if( !connectionMutexCreated ) { @@ -1497,7 +1497,7 @@ static IotHttpsReturnCode_t _createHttpsConnection( IotHttpsConnectionHandle_t * } /* Return the new connection information. */ - *pConnHandle = pHttpsConnection; + *pConnHandle = pHttpsConnection; HTTPS_FUNCTION_CLEANUP_BEGIN(); @@ -1561,8 +1561,8 @@ static IotHttpsReturnCode_t _addHeader( _httpsRequest_t * pHttpsRequest, { HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); - int headerFieldSeparatorLen = HTTPS_HEADER_FIELD_SEPARATOR_LENGTH; - uint32_t additionalLength = nameLen + headerFieldSeparatorLen + valueLen + HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH; + int headerFieldSeparatorLen = HTTPS_HEADER_FIELD_SEPARATOR_LENGTH; + uint32_t additionalLength = nameLen + headerFieldSeparatorLen + valueLen + HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH; uint32_t possibleLastHeaderAdditionalLength = HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH; /* Check if there is enough space to add the header field and value @@ -1602,15 +1602,15 @@ static IotHttpsReturnCode_t _networkSend( _httpsConnection_t * pHttpsConnection, { HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); - size_t numBytesSent = 0; + size_t numBytesSent = 0; size_t numBytesSentTotal = 0; - size_t sendLength = len; + size_t sendLength = len; while( numBytesSentTotal < sendLength ) { - numBytesSent = pHttpsConnection->pNetworkInterface->send( pHttpsConnection->pNetworkConnection, - &( pBuf[ numBytesSentTotal ] ), - sendLength - numBytesSentTotal ); + numBytesSent = pHttpsConnection->pNetworkInterface->send( pHttpsConnection->pNetworkConnection, + &( pBuf[ numBytesSentTotal ] ), + sendLength - numBytesSentTotal ); /* pNetworkInterface->send returns 0 on error. */ if( numBytesSent == 0 ) @@ -1678,11 +1678,11 @@ static IotHttpsReturnCode_t _sendHttpsHeaders( _httpsConnection_t * pHttpsConnec { HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); - const char * connectionHeader = NULL; - int numWritten = 0; - int connectionHeaderLen = 0; + const char * connectionHeader = NULL; + int numWritten = 0; + int connectionHeaderLen = 0; /* The Content-Length header of the form "Content-Length: N\r\n" with a NULL terminator for snprintf. */ - char contentLengthHeaderStr[ HTTPS_MAX_CONTENT_LENGTH_LINE_LENGTH + 1 ]; + char contentLengthHeaderStr[ HTTPS_MAX_CONTENT_LENGTH_LINE_LENGTH + 1 ]; /* The HTTP headers to send after the headers in pHeadersBuf are the Content-Length and the Connection type and * the final "\r\n" to indicate the end of the the header lines. Note that we are using @@ -1692,7 +1692,7 @@ static IotHttpsReturnCode_t _sendHttpsHeaders( _httpsConnection_t * pHttpsConnec char finalHeaders[ HTTPS_MAX_CONTENT_LENGTH_LINE_LENGTH + HTTPS_CONNECTION_KEEP_ALIVE_HEADER_LINE_LENGTH + HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH ] = { 0 }; /* Send the headers passed into this function first. These headers are not terminated with a second set of "\r\n". */ - status = _networkSend( pHttpsConnection, pHeadersBuf, headersLength ); + status = _networkSend( pHttpsConnection, pHeadersBuf, headersLength ); if( HTTPS_FAILED( status ) ) { @@ -1722,12 +1722,12 @@ static IotHttpsReturnCode_t _sendHttpsHeaders( _httpsConnection_t * pHttpsConnec /* Write the connection persistence type to the final headers. */ if( isNonPersistent ) { - connectionHeader = HTTPS_CONNECTION_CLOSE_HEADER_LINE; + connectionHeader = HTTPS_CONNECTION_CLOSE_HEADER_LINE; connectionHeaderLen = FAST_MACRO_STRLEN( HTTPS_CONNECTION_CLOSE_HEADER_LINE ); } else { - connectionHeader = HTTPS_CONNECTION_KEEP_ALIVE_HEADER_LINE; + connectionHeader = HTTPS_CONNECTION_KEEP_ALIVE_HEADER_LINE; connectionHeaderLen = FAST_MACRO_STRLEN( HTTPS_CONNECTION_KEEP_ALIVE_HEADER_LINE ); } @@ -1736,7 +1736,7 @@ static IotHttpsReturnCode_t _sendHttpsHeaders( _httpsConnection_t * pHttpsConnec memcpy( &finalHeaders[ numWritten ], HTTPS_END_OF_HEADER_LINES_INDICATOR, HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH ); numWritten += HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH; - status = _networkSend( pHttpsConnection, ( uint8_t * ) finalHeaders, numWritten ); + status = _networkSend( pHttpsConnection, ( uint8_t * ) finalHeaders, numWritten ); if( HTTPS_FAILED( status ) ) { @@ -1774,9 +1774,9 @@ static IotHttpsReturnCode_t _parseHttpsMessage( _httpParserInfo_t * pHttpParserI { HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); - size_t parsedBytes = 0; - const char * pHttpParserErrorDescription = NULL; - http_parser * pHttpParser = &( pHttpParserInfo->responseParser ); + size_t parsedBytes = 0; + const char * pHttpParserErrorDescription = NULL; + http_parser * pHttpParser = &( pHttpParserInfo->responseParser ); IotLogDebug( "Now parsing HTTP message buffer to process a response." ); parsedBytes = pHttpParserInfo->parseFunc( pHttpParser, &_httpParserSettings, pBuf, len ); @@ -1950,13 +1950,13 @@ static IotHttpsReturnCode_t _receiveHttpsHeaders( _httpsConnection_t * pHttpsCon IotLogDebug( "Now attempting to receive the HTTP response headers into a buffer with length %d.", pHttpsResponse->pHeadersEnd - pHttpsResponse->pHeadersCur ); - status = _receiveHttpsMessage( pHttpsConnection, - &( pHttpsResponse->httpParserInfo ), - &( pHttpsResponse->parserState ), - PARSER_STATE_HEADERS_COMPLETE, - PROCESSING_STATE_FILLING_HEADER_BUFFER, - &( pHttpsResponse->pHeadersCur ), - &( pHttpsResponse->pHeadersEnd ) ); + status = _receiveHttpsMessage( pHttpsConnection, + &( pHttpsResponse->httpParserInfo ), + &( pHttpsResponse->parserState ), + PARSER_STATE_HEADERS_COMPLETE, + PROCESSING_STATE_FILLING_HEADER_BUFFER, + &( pHttpsResponse->pHeadersCur ), + &( pHttpsResponse->pHeadersEnd ) ); if( HTTPS_FAILED( status ) ) { @@ -1980,13 +1980,13 @@ static IotHttpsReturnCode_t _receiveHttpsBody( _httpsConnection_t * pHttpsConnec pHttpsResponse->bufferProcessingState = PROCESSING_STATE_FILLING_BODY_BUFFER; - status = _receiveHttpsMessage( pHttpsConnection, - &( pHttpsResponse->httpParserInfo ), - &( pHttpsResponse->parserState ), - PARSER_STATE_BODY_COMPLETE, - PROCESSING_STATE_FILLING_BODY_BUFFER, - &( pHttpsResponse->pBodyCur ), - &( pHttpsResponse->pBodyEnd ) ); + status = _receiveHttpsMessage( pHttpsConnection, + &( pHttpsResponse->httpParserInfo ), + &( pHttpsResponse->parserState ), + PARSER_STATE_BODY_COMPLETE, + PROCESSING_STATE_FILLING_BODY_BUFFER, + &( pHttpsResponse->pBodyCur ), + &( pHttpsResponse->pBodyEnd ) ); if( HTTPS_FAILED( status ) ) { @@ -2009,11 +2009,11 @@ static IotHttpsReturnCode_t _flushHttpsNetworkData( _httpsConnection_t * pHttpsC { HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); - static uint8_t flushBuffer[ IOT_HTTPS_MAX_FLUSH_BUFFER_SIZE ] = { 0 }; - const char * pHttpParserErrorDescription = NULL; - IotHttpsReturnCode_t parserStatus = IOT_HTTPS_OK; - IotHttpsReturnCode_t networkStatus = IOT_HTTPS_OK; - size_t numBytesRecv = 0; + static uint8_t flushBuffer[ IOT_HTTPS_MAX_FLUSH_BUFFER_SIZE ] = { 0 }; + const char * pHttpParserErrorDescription = NULL; + IotHttpsReturnCode_t parserStatus = IOT_HTTPS_OK; + IotHttpsReturnCode_t networkStatus = IOT_HTTPS_OK; + size_t numBytesRecv = 0; /* Even if there is not body, the parser state will become body complete after the headers finish. */ while( pHttpsResponse->parserState < PARSER_STATE_BODY_COMPLETE ) @@ -2023,7 +2023,7 @@ static IotHttpsReturnCode_t _flushHttpsNetworkData( _httpsConnection_t * pHttpsC /* Run this through the parser so that we can get the end of the HTTP message, instead of simply timing out the socket to stop. * If we relied on the socket timeout to stop reading the network socket, then the server may close the connection. */ - parserStatus = _parseHttpsMessage( &( pHttpsResponse->httpParserInfo ), ( char * ) flushBuffer, numBytesRecv ); + parserStatus = _parseHttpsMessage( &( pHttpsResponse->httpParserInfo ), ( char * ) flushBuffer, numBytesRecv ); if( HTTPS_FAILED( parserStatus ) ) { @@ -2099,13 +2099,13 @@ static void _sendHttpsRequest( taskPoolJob_t * pJob, { HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); - _httpsRequest_t * pHttpsRequest = ( _httpsRequest_t * ) ( pUserContext ); - _httpsConnection_t * pHttpsConnection = pHttpsRequest->pHttpsConnection; - _httpsResponse_t * pHttpsResponse = pHttpsRequest->pHttpsResponse; - IotHttpsReturnCode_t disconnectStatus = IOT_HTTPS_OK; - IotHttpsReturnCode_t scheduleStatus = IOT_HTTPS_OK; - IotLink_t * pQItem = NULL; - _httpsRequest_t * pNextHttpsRequest = NULL; + _httpsRequest_t * pHttpsRequest = ( _httpsRequest_t * ) ( pUserContext ); + _httpsConnection_t * pHttpsConnection = pHttpsRequest->pHttpsConnection; + _httpsResponse_t * pHttpsResponse = pHttpsRequest->pHttpsResponse; + IotHttpsReturnCode_t disconnectStatus = IOT_HTTPS_OK; + IotHttpsReturnCode_t scheduleStatus = IOT_HTTPS_OK; + IotLink_t * pQItem = NULL; + _httpsRequest_t * pNextHttpsRequest = NULL; ( void ) pJob; @@ -2298,7 +2298,7 @@ IotHttpsReturnCode_t _scheduleHttpsRequestSend( _httpsRequest_t * pHttpsRequest { HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); - taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS; + taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS; _httpsConnection_t * pHttpsConnection = pHttpsRequest->pHttpsConnection; /* Set the request to scheduled even if scheduling fails. */ @@ -2308,7 +2308,7 @@ IotHttpsReturnCode_t _scheduleHttpsRequestSend( _httpsRequest_t * pHttpsRequest ( void * ) ( pHttpsRequest ), &( pHttpsConnection->taskPoolJob ) ); - taskPoolStatus = taskPoolSchedule( &( pHttpsConnection->taskPoolJob ) ); + taskPoolStatus = taskPoolSchedule( &( pHttpsConnection->taskPoolJob ) ); if( taskPoolStatus != TASKPOOL_SUCCESS ) { @@ -2326,7 +2326,7 @@ IotHttpsReturnCode_t _addRequestToConnectionReqQ( _httpsRequest_t * pHttpsReques HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); _httpsConnection_t * pHttpsConnection = pHttpsRequest->pHttpsConnection; - bool scheduleRequest = false; + bool scheduleRequest = false; /* Log information about the request*/ IotLogDebug( "Now queueing request %d.", pHttpsRequest ); @@ -2420,18 +2420,18 @@ IotHttpsReturnCode_t IotHttpsClient_Init( void ) http_parser_settings_init( &_httpParserSettings ); /* Set the http-parser callbacks. */ - _httpParserSettings.on_message_begin = _httpParserOnMessageBeginCallback; - _httpParserSettings.on_status = _httpParserOnStatusCallback; - _httpParserSettings.on_header_field = _httpParserOnHeaderFieldCallback; - _httpParserSettings.on_header_value = _httpParserOnHeaderValueCallback; - _httpParserSettings.on_headers_complete = _httpParserOnHeadersCompleteCallback; - _httpParserSettings.on_body = _httpParserOnBodyCallback; - _httpParserSettings.on_message_complete = _httpParserOnMessageCompleteCallback; + _httpParserSettings.on_message_begin = _httpParserOnMessageBeginCallback; + _httpParserSettings.on_status = _httpParserOnStatusCallback; + _httpParserSettings.on_header_field = _httpParserOnHeaderFieldCallback; + _httpParserSettings.on_header_value = _httpParserOnHeaderValueCallback; + _httpParserSettings.on_headers_complete = _httpParserOnHeadersCompleteCallback; + _httpParserSettings.on_body = _httpParserOnBodyCallback; + _httpParserSettings.on_message_complete = _httpParserOnMessageCompleteCallback; /* This code prints debugging information and is, therefore, compiled only when * log level is set to IOT_LOG_DEBUG. */ #if ( LIBRARY_LOG_LEVEL == IOT_LOG_DEBUG ) - _httpParserSettings.on_chunk_header = _httpParserOnChunkHeaderCallback; + _httpParserSettings.on_chunk_header = _httpParserOnChunkHeaderCallback; _httpParserSettings.on_chunk_complete = _httpParserOnChunkCompleteCallback; #endif HTTPS_GOTO_CLEANUP(); @@ -2458,7 +2458,7 @@ static IotHttpsReturnCode_t _initializeResponse( IotHttpsResponseHandle_t * pRes responseUserBufferMinimumSize ); /* Initialize the corresponding response to this request. */ - pHttpsResponse = ( _httpsResponse_t * ) ( pRespInfo->userBuffer.pBuffer ); + pHttpsResponse = ( _httpsResponse_t * ) ( pRespInfo->userBuffer.pBuffer ); /* Clear out the response user buffer. This is important because we * give the whole buffer to the parser as opposed to the actual content @@ -2468,29 +2468,29 @@ static IotHttpsReturnCode_t _initializeResponse( IotHttpsResponseHandle_t * pRes * the HTTP repose, we zero out the buffer here. */ memset( pRespInfo->userBuffer.pBuffer, 0, pRespInfo->userBuffer.bufferLen ); - pHttpsResponse->pHeaders = ( uint8_t * ) ( pHttpsResponse ) + sizeof( _httpsResponse_t ); - pHttpsResponse->pHeadersEnd = ( uint8_t * ) ( pHttpsResponse ) + pRespInfo->userBuffer.bufferLen; - pHttpsResponse->pHeadersCur = pHttpsResponse->pHeaders; + pHttpsResponse->pHeaders = ( uint8_t * ) ( pHttpsResponse ) + sizeof( _httpsResponse_t ); + pHttpsResponse->pHeadersEnd = ( uint8_t * ) ( pHttpsResponse ) + pRespInfo->userBuffer.bufferLen; + pHttpsResponse->pHeadersCur = pHttpsResponse->pHeaders; if( pHttpsRequest->isAsync ) { - pHttpsResponse->isAsync = true; + pHttpsResponse->isAsync = true; /* For an asynchronous request the response body is provided by the application in the * IotHttpsCallbacks_t.readReadyCallback(). These pointers will be updated when IotHttpsClient_ReadResponseBody() * is invoked. */ - pHttpsResponse->pBody = NULL; - pHttpsResponse->pBodyCur = NULL; - pHttpsResponse->pBodyEnd = NULL; + pHttpsResponse->pBody = NULL; + pHttpsResponse->pBodyCur = NULL; + pHttpsResponse->pBodyEnd = NULL; - pHttpsResponse->pCallbacks = pHttpsRequest->pCallbacks; + pHttpsResponse->pCallbacks = pHttpsRequest->pCallbacks; pHttpsResponse->pUserPrivData = pHttpsRequest->pUserPrivData; } else { - pHttpsResponse->isAsync = false; + pHttpsResponse->isAsync = false; /* The request body pointer is allowed to be NULL. u.pSyncInfo was checked for NULL earlier in this function. */ - pHttpsResponse->pBody = pRespInfo->pSyncInfo->pBody; + pHttpsResponse->pBody = pRespInfo->pSyncInfo->pBody; pHttpsResponse->pBodyCur = pHttpsResponse->pBody; pHttpsResponse->pBodyEnd = pHttpsResponse->pBody + pRespInfo->pSyncInfo->bodyLen; @@ -2507,32 +2507,32 @@ static IotHttpsReturnCode_t _initializeResponse( IotHttpsResponseHandle_t * pRes http_parser_init( &( pHttpsResponse->httpParserInfo.responseParser ), HTTP_RESPONSE ); http_parser_init( &( pHttpsResponse->httpParserInfo.readHeaderParser ), HTTP_RESPONSE ); /* Set the third party http parser function. */ - pHttpsResponse->httpParserInfo.parseFunc = http_parser_execute; + pHttpsResponse->httpParserInfo.parseFunc = http_parser_execute; pHttpsResponse->httpParserInfo.readHeaderParser.data = ( void * ) ( pHttpsResponse ); - pHttpsResponse->httpParserInfo.responseParser.data = ( void * ) ( pHttpsResponse ); - - pHttpsResponse->status = 0; - pHttpsResponse->method = pHttpsRequest->method; - pHttpsResponse->parserState = PARSER_STATE_NONE; - pHttpsResponse->bufferProcessingState = PROCESSING_STATE_NONE; - pHttpsResponse->pReadHeaderField = NULL; - pHttpsResponse->readHeaderFieldLength = 0; - pHttpsResponse->pReadHeaderValue = NULL; - pHttpsResponse->readHeaderValueLength = 0; - pHttpsResponse->foundHeaderField = 0; - pHttpsResponse->pHttpsConnection = NULL; - - pHttpsResponse->pBodyInHeaderBuf = NULL; - pHttpsResponse->pBodyCurInHeaderBuf = NULL; - pHttpsResponse->bodyRxStatus = IOT_HTTPS_OK; - pHttpsResponse->cancelled = false; - pHttpsResponse->syncStatus = IOT_HTTPS_OK; + pHttpsResponse->httpParserInfo.responseParser.data = ( void * ) ( pHttpsResponse ); + + pHttpsResponse->status = 0; + pHttpsResponse->method = pHttpsRequest->method; + pHttpsResponse->parserState = PARSER_STATE_NONE; + pHttpsResponse->bufferProcessingState = PROCESSING_STATE_NONE; + pHttpsResponse->pReadHeaderField = NULL; + pHttpsResponse->readHeaderFieldLength = 0; + pHttpsResponse->pReadHeaderValue = NULL; + pHttpsResponse->readHeaderValueLength = 0; + pHttpsResponse->foundHeaderField = 0; + pHttpsResponse->pHttpsConnection = NULL; + + pHttpsResponse->pBodyInHeaderBuf = NULL; + pHttpsResponse->pBodyCurInHeaderBuf = NULL; + pHttpsResponse->bodyRxStatus = IOT_HTTPS_OK; + pHttpsResponse->cancelled = false; + pHttpsResponse->syncStatus = IOT_HTTPS_OK; /* There is no request associated with this response right now, so it is finished sending. */ - pHttpsResponse->reqFinishedSending = true; - pHttpsResponse->isNonPersistent = pHttpsRequest->isNonPersistent; + pHttpsResponse->reqFinishedSending = true; + pHttpsResponse->isNonPersistent = pHttpsRequest->isNonPersistent; /* Set the response handle to return. */ - *pRespHandle = pHttpsResponse; + *pRespHandle = pHttpsResponse; HTTPS_FUNCTION_CLEANUP_BEGIN(); @@ -2597,10 +2597,10 @@ IotHttpsReturnCode_t IotHttpsClient_Disconnect( IotHttpsConnectionHandle_t connH { HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); - _httpsRequest_t * pHttpsRequest = NULL; + _httpsRequest_t * pHttpsRequest = NULL; _httpsResponse_t * pHttpsResponse = NULL; - IotLink_t * pRespItem = NULL; - IotLink_t * pReqItem = NULL; + IotLink_t * pRespItem = NULL; + IotLink_t * pReqItem = NULL; HTTPS_ON_NULL_ARG_GOTO_CLEANUP( connHandle ); @@ -2631,7 +2631,7 @@ IotHttpsReturnCode_t IotHttpsClient_Disconnect( IotHttpsConnectionHandle_t connH if( pHttpsResponse->reqFinishedSending == false ) { IotLogError( "Connection is in use. Disconnected, but cannot destroy the connection." ); - status = IOT_HTTPS_BUSY; + status = IOT_HTTPS_BUSY; /* The request is busy, to as quickly as possible allow a successful retry call of this function we must * cancel the busy request which is the first in the queue. */ @@ -2696,12 +2696,12 @@ IotHttpsReturnCode_t IotHttpsClient_InitializeRequest( IotHttpsRequestHandle_t * { HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); - _httpsRequest_t * pHttpsRequest = NULL; - size_t additionalLength = 0; - size_t spaceLen = 1; - char * pSpace = " "; - size_t httpsMethodLen = 0; - size_t httpsProtocolVersionLen = FAST_MACRO_STRLEN( HTTPS_PROTOCOL_VERSION ); + _httpsRequest_t * pHttpsRequest = NULL; + size_t additionalLength = 0; + size_t spaceLen = 1; + char * pSpace = " "; + size_t httpsMethodLen = 0; + size_t httpsProtocolVersionLen = FAST_MACRO_STRLEN( HTTPS_PROTOCOL_VERSION ); /* Check for NULL parameters in the public API. */ HTTPS_ON_NULL_ARG_GOTO_CLEANUP( pReqHandle ); @@ -2726,25 +2726,25 @@ IotHttpsReturnCode_t IotHttpsClient_InitializeRequest( IotHttpsRequestHandle_t * requestUserBufferMinimumSize ); /* Set the request contet to the start of the userbuffer. */ - pHttpsRequest = ( _httpsRequest_t * ) ( pReqInfo->userBuffer.pBuffer ); + pHttpsRequest = ( _httpsRequest_t * ) ( pReqInfo->userBuffer.pBuffer ); /* Clear out the user buffer. */ memset( pReqInfo->userBuffer.pBuffer, 0, pReqInfo->userBuffer.bufferLen ); /* Set the start of the headers to the end of the request context in the user buffer. */ - pHttpsRequest->pHeaders = ( uint8_t * ) pHttpsRequest + sizeof( _httpsRequest_t ); - pHttpsRequest->pHeadersEnd = ( uint8_t * ) pHttpsRequest + pReqInfo->userBuffer.bufferLen; - pHttpsRequest->pHeadersCur = pHttpsRequest->pHeaders; + pHttpsRequest->pHeaders = ( uint8_t * ) pHttpsRequest + sizeof( _httpsRequest_t ); + pHttpsRequest->pHeadersEnd = ( uint8_t * ) pHttpsRequest + pReqInfo->userBuffer.bufferLen; + pHttpsRequest->pHeadersCur = pHttpsRequest->pHeaders; /* Get the length of the HTTP method. */ - httpsMethodLen = strlen( _pHttpsMethodStrings[ pReqInfo->method ] ); + httpsMethodLen = strlen( _pHttpsMethodStrings[ pReqInfo->method ] ); /* Add the request line to the header buffer. */ - additionalLength = httpsMethodLen + \ - spaceLen + \ - pReqInfo->pathLen + \ - spaceLen + \ - httpsProtocolVersionLen + \ - HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH; + additionalLength = httpsMethodLen + \ + spaceLen + \ + pReqInfo->pathLen + \ + spaceLen + \ + httpsProtocolVersionLen + \ + HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH; if( ( additionalLength + pHttpsRequest->pHeadersCur ) > ( pHttpsRequest->pHeadersEnd ) ) { @@ -2758,27 +2758,27 @@ IotHttpsReturnCode_t IotHttpsClient_InitializeRequest( IotHttpsRequestHandle_t * /* Write "<METHOD> <PATH> HTTP/1.1\r\n" to the start of the header space. */ memcpy( pHttpsRequest->pHeadersCur, _pHttpsMethodStrings[ pReqInfo->method ], httpsMethodLen ); - pHttpsRequest->pHeadersCur += httpsMethodLen; + pHttpsRequest->pHeadersCur += httpsMethodLen; memcpy( pHttpsRequest->pHeadersCur, pSpace, spaceLen ); - pHttpsRequest->pHeadersCur += spaceLen; + pHttpsRequest->pHeadersCur += spaceLen; if( pReqInfo->pPath == NULL ) { - pReqInfo->pPath = HTTPS_EMPTY_PATH; + pReqInfo->pPath = HTTPS_EMPTY_PATH; pReqInfo->pathLen = FAST_MACRO_STRLEN( HTTPS_EMPTY_PATH ); } memcpy( pHttpsRequest->pHeadersCur, pReqInfo->pPath, pReqInfo->pathLen ); - pHttpsRequest->pHeadersCur += pReqInfo->pathLen; + pHttpsRequest->pHeadersCur += pReqInfo->pathLen; memcpy( pHttpsRequest->pHeadersCur, pSpace, spaceLen ); - pHttpsRequest->pHeadersCur += spaceLen; + pHttpsRequest->pHeadersCur += spaceLen; memcpy( pHttpsRequest->pHeadersCur, HTTPS_PROTOCOL_VERSION, httpsProtocolVersionLen ); - pHttpsRequest->pHeadersCur += httpsProtocolVersionLen; + pHttpsRequest->pHeadersCur += httpsProtocolVersionLen; memcpy( pHttpsRequest->pHeadersCur, HTTPS_END_OF_HEADER_LINES_INDICATOR, HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH ); - pHttpsRequest->pHeadersCur += HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH; + pHttpsRequest->pHeadersCur += HTTPS_END_OF_HEADER_LINES_INDICATOR_LENGTH; /* Add the User-Agent header. */ - status = _addHeader( pHttpsRequest, HTTPS_USER_AGENT_HEADER, FAST_MACRO_STRLEN( HTTPS_USER_AGENT_HEADER ), IOT_HTTPS_USER_AGENT, FAST_MACRO_STRLEN( IOT_HTTPS_USER_AGENT ) ); + status = _addHeader( pHttpsRequest, HTTPS_USER_AGENT_HEADER, FAST_MACRO_STRLEN( HTTPS_USER_AGENT_HEADER ), IOT_HTTPS_USER_AGENT, FAST_MACRO_STRLEN( IOT_HTTPS_USER_AGENT ) ); if( HTTPS_FAILED( status ) ) { @@ -2788,7 +2788,7 @@ IotHttpsReturnCode_t IotHttpsClient_InitializeRequest( IotHttpsRequestHandle_t * HTTPS_GOTO_CLEANUP(); } - status = _addHeader( pHttpsRequest, HTTPS_HOST_HEADER, FAST_MACRO_STRLEN( HTTPS_HOST_HEADER ), pReqInfo->pHost, pReqInfo->hostLen ); + status = _addHeader( pHttpsRequest, HTTPS_HOST_HEADER, FAST_MACRO_STRLEN( HTTPS_HOST_HEADER ), pReqInfo->pHost, pReqInfo->hostLen ); if( HTTPS_FAILED( status ) ) { @@ -2801,35 +2801,35 @@ IotHttpsReturnCode_t IotHttpsClient_InitializeRequest( IotHttpsRequestHandle_t * if( pReqInfo->isAsync ) { - pHttpsRequest->isAsync = true; + pHttpsRequest->isAsync = true; /* If this is an asynchronous request then save the callbacks to use. */ - pHttpsRequest->pCallbacks = &( pReqInfo->u.pAsyncInfo->callbacks ); + pHttpsRequest->pCallbacks = &( pReqInfo->u.pAsyncInfo->callbacks ); pHttpsRequest->pUserPrivData = pReqInfo->u.pAsyncInfo->pPrivData; /* The body pointer and body length will be filled in when the application sends data in the writeCallback. */ - pHttpsRequest->pBody = NULL; - pHttpsRequest->bodyLength = 0; + pHttpsRequest->pBody = NULL; + pHttpsRequest->bodyLength = 0; } else { - pHttpsRequest->isAsync = false; + pHttpsRequest->isAsync = false; /* Set the HTTP request entity body. This is allowed to be NULL for no body like for a GET request. */ - pHttpsRequest->pBody = pReqInfo->u.pSyncInfo->pBody; + pHttpsRequest->pBody = pReqInfo->u.pSyncInfo->pBody; pHttpsRequest->bodyLength = pReqInfo->u.pSyncInfo->bodyLen; } /* Save the method of this request. */ - pHttpsRequest->method = pReqInfo->method; + pHttpsRequest->method = pReqInfo->method; /* Set the connection persistence flag for keeping the connection open after receiving a response. */ pHttpsRequest->isNonPersistent = pReqInfo->isNonPersistent; /* Initialize the request cancellation. */ - pHttpsRequest->cancelled = false; + pHttpsRequest->cancelled = false; /* Initialize the status of sending the body over the network in a possible asynchronous request. */ - pHttpsRequest->bodyTxStatus = IOT_HTTPS_OK; + pHttpsRequest->bodyTxStatus = IOT_HTTPS_OK; /* This is a new request and therefore not scheduled yet. */ - pHttpsRequest->scheduled = false; + pHttpsRequest->scheduled = false; /* Set the request handle to return. */ - *pReqHandle = pHttpsRequest; + *pReqHandle = pHttpsRequest; HTTPS_FUNCTION_CLEANUP_BEGIN(); @@ -2919,8 +2919,8 @@ IotHttpsReturnCode_t IotHttpsClient_SendSync( IotHttpsConnectionHandle_t connHan { HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); - bool respFinishedSemCreated = false; - _httpsResponse_t * pHttpsResponse = NULL; + bool respFinishedSemCreated = false; + _httpsResponse_t * pHttpsResponse = NULL; /* Parameter checks. */ HTTPS_ON_NULL_ARG_GOTO_CLEANUP( connHandle ); @@ -2938,7 +2938,7 @@ IotHttpsReturnCode_t IotHttpsClient_SendSync( IotHttpsConnectionHandle_t connHan } /* Initialize the response handle to return. */ - status = _initializeResponse( pRespHandle, pRespInfo, reqHandle ); + status = _initializeResponse( pRespHandle, pRespInfo, reqHandle ); if( HTTPS_FAILED( status ) ) { @@ -2947,14 +2947,14 @@ IotHttpsReturnCode_t IotHttpsClient_SendSync( IotHttpsConnectionHandle_t connHan } /* Set the internal response to use. */ - pHttpsResponse = *pRespHandle; + pHttpsResponse = *pRespHandle; /* The implicit connection passed and we need to the set the connection handle in the request and response. */ - reqHandle->pHttpsConnection = connHandle; + reqHandle->pHttpsConnection = connHandle; pHttpsResponse->pHttpsConnection = connHandle; /* Create the semaphore used to wait on the response to finish being received. */ - respFinishedSemCreated = IotSemaphore_Create( &( pHttpsResponse->respFinishedSem ), 0 /* initialValue */, 1 /* maxValue */ ); + respFinishedSemCreated = IotSemaphore_Create( &( pHttpsResponse->respFinishedSem ), 0 /* initialValue */, 1 /* maxValue */ ); if( respFinishedSemCreated == false ) { @@ -2963,10 +2963,10 @@ IotHttpsReturnCode_t IotHttpsClient_SendSync( IotHttpsConnectionHandle_t connHan } /* Associate the response to the request so that we can schedule it to be received when the request gets scheduled to send. */ - reqHandle->pHttpsResponse = pHttpsResponse; + reqHandle->pHttpsResponse = pHttpsResponse; /* Schedule this request to be sent by adding it to the connection's request queue. */ - status = _addRequestToConnectionReqQ( reqHandle ); + status = _addRequestToConnectionReqQ( reqHandle ); if( HTTPS_FAILED( status ) ) { @@ -3044,12 +3044,12 @@ IotHttpsReturnCode_t IotHttpsClient_WriteRequestBody( IotHttpsRequestHandle_t re } /* Set the pointer to the body and the length for the content-length calculation. */ - reqHandle->pBody = ( uint8_t * ) pBuf; + reqHandle->pBody = ( uint8_t * ) pBuf; reqHandle->bodyLength = len; /* We send the HTTPS headers and body in this function so that the application has the freedom to specify a body * that may be buffer on stack. */ - status = _sendHttpsHeadersAndBody( reqHandle->pHttpsConnection, reqHandle ); + status = _sendHttpsHeadersAndBody( reqHandle->pHttpsConnection, reqHandle ); if( HTTPS_FAILED( status ) ) { @@ -3085,9 +3085,9 @@ IotHttpsReturnCode_t IotHttpsClient_ReadResponseBody( IotHttpsResponseHandle_t r /* Set the current body in the respHandle to use in _receiveHttpsBody(). _receiveHttpsBody is generic * to both async and sync request/response handling. In the sync version the body is configured during * initializing the request. In the async version the body is given in this function on the fly. */ - respHandle->pBody = pBuf; - respHandle->pBodyCur = respHandle->pBody; - respHandle->pBodyEnd = respHandle->pBodyCur + *pLen; + respHandle->pBody = pBuf; + respHandle->pBodyCur = respHandle->pBody; + respHandle->pBodyEnd = respHandle->pBodyCur + *pLen; /* When there is part of the body in the header pBuffer. We need to move that data to this body pBuffer * provided in this function. */ @@ -3097,7 +3097,7 @@ IotHttpsReturnCode_t IotHttpsClient_ReadResponseBody( IotHttpsResponseHandle_t r { uint32_t copyLength = bodyLengthInHeaderBuf > *pLen ? *pLen : bodyLengthInHeaderBuf; memcpy( respHandle->pBodyCur, respHandle->pBodyInHeaderBuf, copyLength ); - respHandle->pBodyCur += copyLength; + respHandle->pBodyCur += copyLength; /* This function may be called multiple times until all of the body that may be present in the header buffer is * moved out. */ @@ -3117,7 +3117,7 @@ IotHttpsReturnCode_t IotHttpsClient_ReadResponseBody( IotHttpsResponseHandle_t r } } - *pLen = respHandle->pBodyCur - respHandle->pBody; + *pLen = respHandle->pBodyCur - respHandle->pBody; HTTPS_FUNCTION_CLEANUP_BEGIN(); @@ -3174,7 +3174,7 @@ IotHttpsReturnCode_t IotHttpsClient_SendAsync( IotHttpsConnectionHandle_t connHa HTTPS_ON_ARG_ERROR_GOTO_CLEANUP( connHandle->isConnected ); /* Initialize the response handle to return. */ - status = _initializeResponse( pRespHandle, pRespInfo, reqHandle ); + status = _initializeResponse( pRespHandle, pRespInfo, reqHandle ); if( HTTPS_FAILED( status ) ) { @@ -3183,16 +3183,16 @@ IotHttpsReturnCode_t IotHttpsClient_SendAsync( IotHttpsConnectionHandle_t connHa } /* Set the connection handle in the request handle so that we can use it in the _writeRequestBody() callback. */ - reqHandle->pHttpsConnection = connHandle; + reqHandle->pHttpsConnection = connHandle; /* Set the connection handle in the response handle sp that we can use it in the _readReadyCallback() callback. */ ( *pRespHandle )->pHttpsConnection = connHandle; /* Associate the response to the request so that we can schedule it to be received when the request gets scheduled to send. */ - reqHandle->pHttpsResponse = *pRespHandle; + reqHandle->pHttpsResponse = *pRespHandle; /* Add the request to the connection's request queue. */ - status = _addRequestToConnectionReqQ( reqHandle ); + status = _addRequestToConnectionReqQ( reqHandle ); if( HTTPS_FAILED( status ) ) { @@ -3232,10 +3232,10 @@ IotHttpsReturnCode_t IotHttpsClient_ReadHeader( IotHttpsResponseHandle_t respHan { HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); - const char * pHttpParserErrorDescription = NULL; + const char * pHttpParserErrorDescription = NULL; IotHttpsResponseBufferState_t savedBufferState = PROCESSING_STATE_NONE; IotHttpsResponseParserState_t savedParserState = PARSER_STATE_NONE; - size_t numParsed = 0; + size_t numParsed = 0; HTTPS_ON_NULL_ARG_GOTO_CLEANUP( respHandle ); HTTPS_ON_NULL_ARG_GOTO_CLEANUP( pName ); @@ -3248,8 +3248,8 @@ IotHttpsReturnCode_t IotHttpsClient_ReadHeader( IotHttpsResponseHandle_t respHan * changed in the response to wherever the parser is currently located in the response. If this function is called * in the middle of processing a response (for example in readReadyCallback() routine of an asynchronous response), * then parsing the response need to be able to start at the same place it was before calling this function. */ - savedBufferState = respHandle->bufferProcessingState; - savedParserState = respHandle->parserState; + savedBufferState = respHandle->bufferProcessingState; + savedParserState = respHandle->parserState; /* The header search parameters in the response handle are used as context in the http-parser callbacks. During * the callback, pReadHeaderField is checked against the currently parsed header name. foundHeaderField is set to @@ -3257,18 +3257,18 @@ IotHttpsReturnCode_t IotHttpsClient_ReadHeader( IotHttpsResponseHandle_t respHan * to skip the logic pertaining to when the response is being parsed for the first time. pReadHeaderValue will store * the header value found. readHeaderValueLength will store the length of the header value found from within the * response headers. */ - respHandle->pReadHeaderField = pName; + respHandle->pReadHeaderField = pName; respHandle->readHeaderFieldLength = nameLen; - respHandle->foundHeaderField = false; + respHandle->foundHeaderField = false; respHandle->bufferProcessingState = PROCESSING_STATE_SEARCHING_HEADER_BUFFER; - respHandle->pReadHeaderValue = NULL; + respHandle->pReadHeaderValue = NULL; respHandle->readHeaderValueLength = 0; /* Start over the HTTP parser so that it will parser from the beginning of the message. */ http_parser_init( &( respHandle->httpParserInfo.readHeaderParser ), HTTP_RESPONSE ); IotLogDebug( "Now parsing HTTP Message buffer to read a header." ); - numParsed = respHandle->httpParserInfo.parseFunc( &( respHandle->httpParserInfo.readHeaderParser ), &_httpParserSettings, ( char * ) ( respHandle->pHeaders ), respHandle->pHeadersCur - respHandle->pHeaders ); + numParsed = respHandle->httpParserInfo.parseFunc( &( respHandle->httpParserInfo.readHeaderParser ), &_httpParserSettings, ( char * ) ( respHandle->pHeaders ), respHandle->pHeadersCur - respHandle->pHeaders ); IotLogDebug( "Parsed %d characters in IotHttpsClient_ReadHeader().", numParsed ); /* There shouldn't be any errors parsing the response body given that the handle is from a validly @@ -3312,7 +3312,7 @@ IotHttpsReturnCode_t IotHttpsClient_ReadHeader( IotHttpsResponseHandle_t respHan if( respHandle != NULL ) { respHandle->bufferProcessingState = savedBufferState; - respHandle->parserState = savedParserState; + respHandle->parserState = savedParserState; } HTTPS_FUNCTION_CLEANUP_END(); @@ -3325,8 +3325,8 @@ IotHttpsReturnCode_t IotHttpsClient_ReadContentLength( IotHttpsResponseHandle_t { HTTPS_FUNCTION_ENTRY( IOT_HTTPS_OK ); - const int CONTENT_LENGTH_NUMBERIC_BASE = 10; - char pContentLengthStr[ HTTPS_MAX_CONTENT_LENGTH_LINE_LENGTH ] = { 0 }; + const int CONTENT_LENGTH_NUMBERIC_BASE = 10; + char pContentLengthStr[ HTTPS_MAX_CONTENT_LENGTH_LINE_LENGTH ] = { 0 }; HTTPS_ON_NULL_ARG_GOTO_CLEANUP( respHandle ); HTTPS_ON_NULL_ARG_GOTO_CLEANUP( pContentLength ); @@ -3334,7 +3334,7 @@ IotHttpsReturnCode_t IotHttpsClient_ReadContentLength( IotHttpsResponseHandle_t /* If there is no content-length header or if we were not able to store it in the header buffer this will be * invalid. We do not use the content-length member of the http-parser state structure to get the content * length as this is a PRIVATE member. Because it is a PRIVATE member it can be any value. */ - status = IotHttpsClient_ReadHeader( respHandle, HTTPS_CONTENT_LENGTH_HEADER, FAST_MACRO_STRLEN( HTTPS_CONTENT_LENGTH_HEADER ), pContentLengthStr, HTTPS_MAX_CONTENT_LENGTH_LINE_LENGTH ); + status = IotHttpsClient_ReadHeader( respHandle, HTTPS_CONTENT_LENGTH_HEADER, FAST_MACRO_STRLEN( HTTPS_CONTENT_LENGTH_HEADER ), pContentLengthStr, HTTPS_MAX_CONTENT_LENGTH_LINE_LENGTH ); if( HTTPS_FAILED( status ) ) { diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_utils.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_utils.c index 402b72673..3b0b5e7c5 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_utils.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/https/src/iot_https_utils.c @@ -44,9 +44,9 @@ IotHttpsReturnCode_t IotHttpsClient_GetUrlPath( const char * pUrl, size_t * pPathLen ) { /* http-parser status. Initialized to 0 to signify success. */ - int parserStatus = 0; + int parserStatus = 0; struct http_parser_url urlParser; - IotHttpsReturnCode_t returnStatus = IOT_HTTPS_OK; + IotHttpsReturnCode_t returnStatus = IOT_HTTPS_OK; /* Sets all members in urlParser to 0. */ http_parser_url_init( &urlParser ); @@ -75,7 +75,7 @@ IotHttpsReturnCode_t IotHttpsClient_GetUrlPath( const char * pUrl, if( *pPathLen == 0 ) { returnStatus = IOT_HTTPS_NOT_FOUND; - *pPath = NULL; + *pPath = NULL; } else { @@ -94,9 +94,9 @@ IotHttpsReturnCode_t IotHttpsClient_GetUrlAddress( const char * pUrl, size_t * pAddressLen ) { /* http-parser status. Initialized to 0 to signify success. */ - int parserStatus = 0; + int parserStatus = 0; struct http_parser_url urlParser; - IotHttpsReturnCode_t returnStatus = IOT_HTTPS_OK; + IotHttpsReturnCode_t returnStatus = IOT_HTTPS_OK; /* Sets all members in urlParser to 0. */ http_parser_url_init( &urlParser ); @@ -125,7 +125,7 @@ IotHttpsReturnCode_t IotHttpsClient_GetUrlAddress( const char * pUrl, if( *pAddressLen == 0 ) { returnStatus = IOT_HTTPS_NOT_FOUND; - *pAddress = NULL; + *pAddress = NULL; } else { diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_api.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_api.c index 6a5f933e6..c9f5ddc87 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_api.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_api.c @@ -413,8 +413,8 @@ static void _mqttSubscription_tryDestroy( void * pData ) static void _mqttOperation_tryDestroy( void * pData ) { - _mqttOperation_t * pOperation = ( _mqttOperation_t * ) pData; - taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS; + _mqttOperation_t * pOperation = ( _mqttOperation_t * ) pData; + taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS; /* Incoming PUBLISH operations may always be freed. */ if( pOperation->incomingPublish == true ) @@ -459,17 +459,17 @@ static bool _createKeepAliveOperation( const IotMqttNetworkInfo_t * pNetworkInfo uint16_t keepAliveSeconds, _mqttConnection_t * pMqttConnection ) { - bool status = true; + bool status = true; IotMqttError_t serializeStatus = IOT_MQTT_SUCCESS; /* Network information is not used when MQTT packet serializers are disabled. */ ( void ) pNetworkInfo; /* Set PINGREQ operation members. */ - pMqttConnection->pingreq.u.operation.type = IOT_MQTT_PINGREQ; + pMqttConnection->pingreq.u.operation.type = IOT_MQTT_PINGREQ; /* Convert the keep-alive interval to milliseconds. */ - pMqttConnection->pingreq.u.operation.periodic.ping.keepAliveMs = ( uint32_t ) keepAliveSeconds * 1000U; + pMqttConnection->pingreq.u.operation.periodic.ping.keepAliveMs = ( uint32_t ) keepAliveSeconds * 1000U; pMqttConnection->pingreq.u.operation.periodic.ping.nextPeriodMs = ( uint32_t ) keepAliveSeconds * 1000U; /* Generate a PINGREQ packet. */ @@ -534,7 +534,7 @@ static IotNetworkError_t _createNetworkConnection( const IotMqttNetworkInfo_t * { /* A connection already exists; the caller should not destroy * it on cleanup. */ - *pNetworkConnection = pNetworkInfo->u.pNetworkConnection; + *pNetworkConnection = pNetworkInfo->u.pNetworkConnection; *pCreatedNewNetworkConnection = false; } @@ -547,9 +547,9 @@ static _mqttConnection_t * _createMqttConnection( bool awsIotMqttMode, const IotMqttNetworkInfo_t * pNetworkInfo, uint16_t keepAliveSeconds ) { - bool status = true; + bool status = true; _mqttConnection_t * pMqttConnection = NULL; - bool referencesMutexCreated = false, subscriptionMutexCreated = false; + bool referencesMutexCreated = false, subscriptionMutexCreated = false; /* Allocate memory for the new MQTT connection. */ pMqttConnection = IotMqtt_MallocConnection( sizeof( _mqttConnection_t ) ); @@ -565,15 +565,15 @@ static _mqttConnection_t * _createMqttConnection( bool awsIotMqttMode, /* Clear the MQTT connection, then copy the MQTT server mode, network * interface, and disconnect callback. */ ( void ) memset( pMqttConnection, 0x00, sizeof( _mqttConnection_t ) ); - pMqttConnection->awsIotMqttMode = awsIotMqttMode; - pMqttConnection->pNetworkInterface = pNetworkInfo->pNetworkInterface; + pMqttConnection->awsIotMqttMode = awsIotMqttMode; + pMqttConnection->pNetworkInterface = pNetworkInfo->pNetworkInterface; pMqttConnection->disconnectCallback = pNetworkInfo->disconnectCallback; /* Start a new MQTT connection with a reference count of 1. */ - pMqttConnection->references = 1; + pMqttConnection->references = 1; /* Create the references mutex for a new connection. It is a recursive mutex. */ - referencesMutexCreated = IotMutex_Create( &( pMqttConnection->referencesMutex ), true ); + referencesMutexCreated = IotMutex_Create( &( pMqttConnection->referencesMutex ), true ); if( referencesMutexCreated == false ) { @@ -649,8 +649,8 @@ static void _destroyMqttConnection( _mqttConnection_t * pMqttConnection ) /* Clear data about the keep-alive. */ pMqttConnection->pingreq.u.operation.periodic.ping.keepAliveMs = 0; - pMqttConnection->pingreq.u.operation.pMqttPacket = NULL; - pMqttConnection->pingreq.u.operation.packetSize = 0; + pMqttConnection->pingreq.u.operation.pMqttPacket = NULL; + pMqttConnection->pingreq.u.operation.packetSize = 0; /* Decrement reference count. */ pMqttConnection->references--; @@ -760,7 +760,7 @@ static IotMqttError_t _subscriptionCreateAndSerialize( IotMqttOperationType_t op const IotMqttCallbackInfo_t * pCallbackInfo, _mqttOperation_t ** ppSubscriptionOperation ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; + IotMqttError_t status = IOT_MQTT_SUCCESS; _mqttOperation_t * pSubscriptionOperation = NULL; /* Create a subscription operation. */ @@ -771,7 +771,7 @@ static IotMqttError_t _subscriptionCreateAndSerialize( IotMqttOperationType_t op if( status == IOT_MQTT_SUCCESS ) { - pSubscriptionOperation = ( *ppSubscriptionOperation ); + pSubscriptionOperation = ( *ppSubscriptionOperation ); /* Check the subscription operation data and set the operation type. */ @@ -780,11 +780,11 @@ static IotMqttError_t _subscriptionCreateAndSerialize( IotMqttOperationType_t op pSubscriptionOperation->u.operation.type = operation; /* Generate a subscription packet from the subscription list. */ - status = serializeSubscription( pSubscriptionList, - subscriptionCount, - &( pSubscriptionOperation->u.operation.pMqttPacket ), - &( pSubscriptionOperation->u.operation.packetSize ), - &( pSubscriptionOperation->u.operation.packetIdentifier ) ); + status = serializeSubscription( pSubscriptionList, + subscriptionCount, + &( pSubscriptionOperation->u.operation.pMqttPacket ), + &( pSubscriptionOperation->u.operation.packetSize ), + &( pSubscriptionOperation->u.operation.packetIdentifier ) ); } if( status == IOT_MQTT_SUCCESS ) @@ -832,7 +832,7 @@ static IotMqttError_t _subscriptionCommon( IotMqttOperationType_t operation, const IotMqttCallbackInfo_t * pCallbackInfo, IotMqttOperation_t * const pOperationReference ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; + IotMqttError_t status = IOT_MQTT_SUCCESS; _mqttOperation_t * pSubscriptionOperation = NULL; /* Create and serialize the subscription operation. */ @@ -966,7 +966,7 @@ static IotMqttError_t _waitForOperation( IotMqttOperation_t operation, static IotMqttError_t _scheduleKeepAlive( IotMqttConnection_t pMqttConnection ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; + IotMqttError_t status = IOT_MQTT_SUCCESS; taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS; /* Check if a keep-alive job should be scheduled. */ @@ -1164,10 +1164,10 @@ void _IotMqtt_DecrementConnectionReferences( _mqttConnection_t * pMqttConnection IotMqttError_t IotMqtt_Init( void ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; - uint32_t allowInitialization = Atomic_CompareAndSwap_u32( &_initCalled, - MQTT_LIBRARY_INITIALIZED, - MQTT_LIBRARY_UNINITIALIZED ); + IotMqttError_t status = IOT_MQTT_SUCCESS; + uint32_t allowInitialization = Atomic_CompareAndSwap_u32( &_initCalled, + MQTT_LIBRARY_INITIALIZED, + MQTT_LIBRARY_UNINITIALIZED ); if( allowInitialization == 1U ) { @@ -1234,12 +1234,12 @@ IotMqttError_t IotMqtt_Connect( const IotMqttNetworkInfo_t * pNetworkInfo, uint32_t timeoutMs, IotMqttConnection_t * const pMqttConnection ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; - bool ownNetworkConnection = false; - IotNetworkError_t networkStatus = IOT_NETWORK_SUCCESS; - IotNetworkConnection_t pNetworkConnection = NULL; - _mqttOperation_t * pOperation = NULL; - _mqttConnection_t * pNewMqttConnection = NULL; + IotMqttError_t status = IOT_MQTT_SUCCESS; + bool ownNetworkConnection = false; + IotNetworkError_t networkStatus = IOT_NETWORK_SUCCESS; + IotNetworkConnection_t pNetworkConnection = NULL; + _mqttOperation_t * pOperation = NULL; + _mqttConnection_t * pNewMqttConnection = NULL; /* Check that IotMqtt_Init was called. */ if( _checkInit() == false ) @@ -1282,19 +1282,19 @@ IotMqttError_t IotMqtt_Connect( const IotMqttNetworkInfo_t * pNetworkInfo, if( status == IOT_MQTT_SUCCESS ) { /* Set the network connection associated with the MQTT connection. */ - pNewMqttConnection->pNetworkConnection = pNetworkConnection; + pNewMqttConnection->pNetworkConnection = pNetworkConnection; pNewMqttConnection->ownNetworkConnection = ownNetworkConnection; /* Set the MQTT packet serializer overrides. */ #if IOT_MQTT_ENABLE_SERIALIZER_OVERRIDES == 1 - pNewMqttConnection->pSerializer = pNetworkInfo->pMqttSerializer; + pNewMqttConnection->pSerializer = pNetworkInfo->pMqttSerializer; #else - pNewMqttConnection->pSerializer = NULL; + pNewMqttConnection->pSerializer = NULL; #endif - networkStatus = pNewMqttConnection->pNetworkInterface->setReceiveCallback( pNetworkConnection, - IotMqtt_ReceiveCallback, - pNewMqttConnection ); + networkStatus = pNewMqttConnection->pNetworkInterface->setReceiveCallback( pNetworkConnection, + IotMqtt_ReceiveCallback, + pNewMqttConnection ); if( networkStatus != IOT_NETWORK_SUCCESS ) { @@ -1332,7 +1332,7 @@ IotMqttError_t IotMqtt_Connect( const IotMqttNetworkInfo_t * pNetworkInfo, if( status == IOT_MQTT_SUCCESS ) { /* Send the CONNECT packet */ - status = _sendConnectRequest( pOperation, timeoutMs ); + status = _sendConnectRequest( pOperation, timeoutMs ); /* The call to wait inside _sendConnectRequest cleans up * the CONNECT operation, so set the pointer to NULL. */ @@ -1372,8 +1372,8 @@ IotMqttError_t IotMqtt_Connect( const IotMqttNetworkInfo_t * pNetworkInfo, void IotMqtt_Disconnect( IotMqttConnection_t mqttConnection, uint32_t flags ) { - bool disconnected = false, initCalled = false; - IotMqttError_t status = IOT_MQTT_SUCCESS; + bool disconnected = false, initCalled = false; + IotMqttError_t status = IOT_MQTT_SUCCESS; _mqttOperation_t * pOperation = NULL; /* Check that IotMqtt_Init was called. */ @@ -1430,8 +1430,8 @@ void IotMqtt_Disconnect( IotMqttConnection_t mqttConnection, pOperation->u.operation.type = IOT_MQTT_DISCONNECT; /* Generate a DISCONNECT packet. */ - status = _getMqttDisconnectSerializer( mqttConnection->pSerializer )( &( pOperation->u.operation.pMqttPacket ), - &( pOperation->u.operation.packetSize ) ); + status = _getMqttDisconnectSerializer( mqttConnection->pSerializer )( &( pOperation->u.operation.pMqttPacket ), + &( pOperation->u.operation.packetSize ) ); } } @@ -1547,7 +1547,7 @@ IotMqttError_t IotMqtt_SubscribeSync( IotMqttConnection_t mqttConnection, uint32_t flags, uint32_t timeoutMs ) { - IotMqttError_t status = IOT_MQTT_STATUS_PENDING; + IotMqttError_t status = IOT_MQTT_STATUS_PENDING; IotMqttOperation_t subscribeOperation = IOT_MQTT_OPERATION_INITIALIZER; /* Flags are not used, but the parameter is present for future compatibility. */ @@ -1617,7 +1617,7 @@ IotMqttError_t IotMqtt_UnsubscribeSync( IotMqttConnection_t mqttConnection, uint32_t flags, uint32_t timeoutMs ) { - IotMqttError_t status = IOT_MQTT_STATUS_PENDING; + IotMqttError_t status = IOT_MQTT_STATUS_PENDING; IotMqttOperation_t unsubscribeOperation = IOT_MQTT_OPERATION_INITIALIZER; /* Flags are not used, but the parameter is present for future compatibility. */ @@ -1651,9 +1651,9 @@ IotMqttError_t IotMqtt_PublishAsync( IotMqttConnection_t mqttConnection, const IotMqttCallbackInfo_t * pCallbackInfo, IotMqttOperation_t * const pPublishOperation ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; - _mqttOperation_t * pOperation = NULL; - uint8_t ** pPacketIdentifierHigh = NULL; + IotMqttError_t status = IOT_MQTT_SUCCESS; + _mqttOperation_t * pOperation = NULL; + uint8_t ** pPacketIdentifierHigh = NULL; /* Check that IotMqtt_Init was called. */ if( _checkInit() == false ) @@ -1690,11 +1690,11 @@ IotMqttError_t IotMqtt_PublishAsync( IotMqttConnection_t mqttConnection, } /* Generate a PUBLISH packet from pPublishInfo. */ - status = _getMqttPublishSerializer( mqttConnection->pSerializer )( pPublishInfo, - &( pOperation->u.operation.pMqttPacket ), - &( pOperation->u.operation.packetSize ), - &( pOperation->u.operation.packetIdentifier ), - pPacketIdentifierHigh ); + status = _getMqttPublishSerializer( mqttConnection->pSerializer )( pPublishInfo, + &( pOperation->u.operation.pMqttPacket ), + &( pOperation->u.operation.packetSize ), + &( pOperation->u.operation.packetIdentifier ), + pPacketIdentifierHigh ); } if( status == IOT_MQTT_SUCCESS ) @@ -1709,7 +1709,7 @@ IotMqttError_t IotMqtt_PublishAsync( IotMqttConnection_t mqttConnection, /* A QoS 0 PUBLISH may not be retried. */ if( pPublishInfo->qos != IOT_MQTT_QOS_0 ) { - pOperation->u.operation.periodic.retry.limit = pPublishInfo->retryLimit; + pOperation->u.operation.periodic.retry.limit = pPublishInfo->retryLimit; pOperation->u.operation.periodic.retry.nextPeriodMs = pPublishInfo->retryMs; } } @@ -1767,11 +1767,11 @@ IotMqttError_t IotMqtt_PublishSync( IotMqttConnection_t mqttConnection, uint32_t flags, uint32_t timeoutMs ) { - IotMqttError_t status = IOT_MQTT_STATUS_PENDING; - IotMqttOperation_t publishOperation = IOT_MQTT_OPERATION_INITIALIZER, + IotMqttError_t status = IOT_MQTT_STATUS_PENDING; + IotMqttOperation_t publishOperation = IOT_MQTT_OPERATION_INITIALIZER, * pPublishOperation = NULL; /* Set only the "serial" flag. */ - uint32_t syncFlags = MQTT_INTERNAL_FLAG_BLOCK_ON_SEND; + uint32_t syncFlags = MQTT_INTERNAL_FLAG_BLOCK_ON_SEND; /* Flags are currently ignored. */ ( void ) flags; @@ -1779,7 +1779,7 @@ IotMqttError_t IotMqtt_PublishSync( IotMqttConnection_t mqttConnection, /* Set the waitable flag and reference for QoS 1 PUBLISH. */ if( pPublishInfo->qos == IOT_MQTT_QOS_1 ) { - syncFlags |= IOT_MQTT_FLAG_WAITABLE; + syncFlags |= IOT_MQTT_FLAG_WAITABLE; pPublishOperation = &publishOperation; } @@ -1807,7 +1807,7 @@ IotMqttError_t IotMqtt_PublishSync( IotMqttConnection_t mqttConnection, IotMqttError_t IotMqtt_Wait( IotMqttOperation_t operation, uint32_t timeoutMs ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; + IotMqttError_t status = IOT_MQTT_SUCCESS; _mqttConnection_t * pMqttConnection = NULL; /* Check that IotMqtt_Init was called. */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_helper.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_helper.c index 4e472ab6d..2690eb411 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_helper.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_helper.c @@ -178,7 +178,7 @@ static uint8_t * _encodeUserNameAndMetrics( uint8_t * pDestination, const IotMqttConnectInfo_t * pConnectInfo, bool * pEncodedUserName ) { - uint8_t * pBuffer = pDestination; + uint8_t * pBuffer = pDestination; #if AWS_IOT_MQTT_ENABLE_METRICS == 1 const char * pMetricsUserName = AWS_IOT_METRICS_USERNAME; @@ -188,27 +188,27 @@ static uint8_t * _encodeUserNameAndMetrics( uint8_t * pDestination, if( ( pConnectInfo->userNameLength + AWS_IOT_METRICS_USERNAME_LENGTH ) <= ( ( uint16_t ) ( UINT16_MAX ) ) ) { /* Write the high byte of the combined length. */ - pBuffer[ 0 ] = UINT16_HIGH_BYTE( ( pConnectInfo->userNameLength + - AWS_IOT_METRICS_USERNAME_LENGTH ) ); + pBuffer[ 0 ] = UINT16_HIGH_BYTE( ( pConnectInfo->userNameLength + + AWS_IOT_METRICS_USERNAME_LENGTH ) ); /* Write the low byte of the combined length. */ - pBuffer[ 1 ] = UINT16_LOW_BYTE( ( pConnectInfo->userNameLength + - AWS_IOT_METRICS_USERNAME_LENGTH ) ); - pBuffer += 2; + pBuffer[ 1 ] = UINT16_LOW_BYTE( ( pConnectInfo->userNameLength + + AWS_IOT_METRICS_USERNAME_LENGTH ) ); + pBuffer += 2; /* Write the identity portion of the username. * As the types of char and uint8_t are of the same size, this memcpy * is acceptable. */ /* coverity[misra_c_2012_rule_21_15_violation] */ ( void ) memcpy( pBuffer, pConnectInfo->pUserName, pConnectInfo->userNameLength ); - pBuffer += pConnectInfo->userNameLength; + pBuffer += pConnectInfo->userNameLength; /* Write the metrics portion of the username. * As the types of char and uint8_t are of the same size, this memcpy * is acceptable. */ /* coverity[misra_c_2012_rule_21_15_violation] */ ( void ) memcpy( pBuffer, pMetricsUserName, AWS_IOT_METRICS_USERNAME_LENGTH ); - pBuffer += AWS_IOT_METRICS_USERNAME_LENGTH; + pBuffer += AWS_IOT_METRICS_USERNAME_LENGTH; *pEncodedUserName = true; } @@ -231,8 +231,8 @@ static uint8_t * _encodeUserNameAndMetrics( uint8_t * pDestination, static uint8_t * _encodeUserName( uint8_t * pDestination, const IotMqttConnectInfo_t * pConnectInfo ) { - bool encodedUserName = false; - uint8_t * pBuffer = pDestination; + bool encodedUserName = false; + uint8_t * pBuffer = pDestination; /* If metrics are enabled, write the metrics username into the CONNECT packet. * Otherwise, write the username and password only when not connecting to the @@ -254,9 +254,9 @@ static uint8_t * _encodeUserName( uint8_t * pDestination, { /* The username is not being used for authentication, but * metrics are enabled. */ - pBuffer = _encodeString( pBuffer, - AWS_IOT_METRICS_USERNAME, - AWS_IOT_METRICS_USERNAME_LENGTH ); + pBuffer = _encodeString( pBuffer, + AWS_IOT_METRICS_USERNAME, + AWS_IOT_METRICS_USERNAME_LENGTH ); encodedUserName = true; } @@ -307,12 +307,12 @@ static uint8_t * _encodeRemainingLength( uint8_t * pDestination, size_t length ) { uint8_t lengthByte = 0, * pLengthEnd = pDestination; - size_t remainingLength = length; + size_t remainingLength = length; /* This algorithm is copied from the MQTT v3.1.1 spec. */ do { - lengthByte = ( uint8_t ) ( remainingLength % 128U ); + lengthByte = ( uint8_t ) ( remainingLength % 128U ); remainingLength = remainingLength / 128U; /* Set the high bit of this byte, indicating that there's more data. */ @@ -322,7 +322,7 @@ static uint8_t * _encodeRemainingLength( uint8_t * pDestination, } /* Output a single encoded byte. */ - *pLengthEnd = lengthByte; + *pLengthEnd = lengthByte; pLengthEnd++; } while( remainingLength > 0U ); @@ -385,8 +385,8 @@ bool _IotMqtt_ConnectPacketSize( const IotMqttConnectInfo_t * pConnectInfo, size_t * pRemainingLength, size_t * pPacketSize ) { - bool status = true; - bool encodedUserName = false; + bool status = true; + bool encodedUserName = false; size_t connectPacketSize = 0, remainingLength = 0; /* The CONNECT packet will always include a 10-byte variable header. */ @@ -409,7 +409,7 @@ bool _IotMqtt_ConnectPacketSize( const IotMqttConnectInfo_t * pConnectInfo, #if AWS_IOT_MQTT_ENABLE_METRICS == 1 connectPacketSize += ( AWS_IOT_METRICS_USERNAME_LENGTH + ( size_t ) ( pConnectInfo->userNameLength ) + sizeof( uint16_t ) ); - encodedUserName = true; + encodedUserName = true; #endif } @@ -427,7 +427,7 @@ bool _IotMqtt_ConnectPacketSize( const IotMqttConnectInfo_t * pConnectInfo, /* At this point, the "Remaining Length" field of the MQTT CONNECT packet has * been calculated. */ - remainingLength = connectPacketSize; + remainingLength = connectPacketSize; /* Calculate the full size of the MQTT CONNECT packet by adding the size of * the "Remaining Length" field plus 1 byte for the "Packet Type" field. */ @@ -441,7 +441,7 @@ bool _IotMqtt_ConnectPacketSize( const IotMqttConnectInfo_t * pConnectInfo, else { *pRemainingLength = remainingLength; - *pPacketSize = connectPacketSize; + *pPacketSize = connectPacketSize; } return status; @@ -454,28 +454,28 @@ void _IotMqtt_SerializeConnectCommon( const IotMqttConnectInfo_t * pConnectInfo, uint8_t * pPacket, size_t connectPacketSize ) { - uint8_t connectFlags = 0; - uint8_t * pBuffer = pPacket; + uint8_t connectFlags = 0; + uint8_t * pBuffer = pPacket; /* Avoid unused variable warning when logging and asserts are disabled. */ ( void ) pPacket; ( void ) connectPacketSize; /* The first byte in the CONNECT packet is the control packet type. */ - *pBuffer = MQTT_PACKET_TYPE_CONNECT; + *pBuffer = MQTT_PACKET_TYPE_CONNECT; pBuffer++; /* The remaining length of the CONNECT packet is encoded starting from the * second byte. The remaining length does not include the length of the fixed * header or the encoding of the remaining length. */ - pBuffer = _encodeRemainingLength( pBuffer, remainingLength ); + pBuffer = _encodeRemainingLength( pBuffer, remainingLength ); /* The string "MQTT" is placed at the beginning of the CONNECT packet's variable * header. This string is 4 bytes long. */ - pBuffer = _encodeString( pBuffer, "MQTT", 4 ); + pBuffer = _encodeString( pBuffer, "MQTT", 4 ); /* The MQTT protocol version is the second byte of the variable header. */ - *pBuffer = MQTT_VERSION_3_1_1; + *pBuffer = MQTT_VERSION_3_1_1; pBuffer++; /* Set the CONNECT flags based on the given parameters. */ @@ -535,18 +535,18 @@ void _IotMqtt_SerializeConnectCommon( const IotMqttConnectInfo_t * pConnectInfo, } } - *pBuffer = connectFlags; + *pBuffer = connectFlags; pBuffer++; /* Write the 2 bytes of the keep alive interval into the CONNECT packet. */ - *pBuffer = UINT16_HIGH_BYTE( pConnectInfo->keepAliveSeconds ); + *pBuffer = UINT16_HIGH_BYTE( pConnectInfo->keepAliveSeconds ); *( pBuffer + 1 ) = UINT16_LOW_BYTE( pConnectInfo->keepAliveSeconds ); - pBuffer += 2; + pBuffer += 2; /* Write the client identifier into the CONNECT packet. */ - pBuffer = _encodeString( pBuffer, - pConnectInfo->pClientIdentifier, - pConnectInfo->clientIdentifierLength ); + pBuffer = _encodeString( pBuffer, + pConnectInfo->pClientIdentifier, + pConnectInfo->clientIdentifierLength ); /* Write the will topic name and message into the CONNECT packet if provided. */ if( pConnectInfo->pWillInfo != NULL ) @@ -561,7 +561,7 @@ void _IotMqtt_SerializeConnectCommon( const IotMqttConnectInfo_t * pConnectInfo, } /* Encode the username if there is one or metrics are enabled. */ - pBuffer = _encodeUserName( pBuffer, pConnectInfo ); + pBuffer = _encodeUserName( pBuffer, pConnectInfo ); /* Encode the password field, if requested by the app. */ if( pConnectInfo->pPassword != NULL ) @@ -615,37 +615,37 @@ void _IotMqtt_SerializeSubscribeCommon( const IotMqttSubscription_t * pSubscript uint8_t * pPacket, size_t subscribePacketSize ) { - uint16_t packetIdentifier = 0; - size_t i = 0; - uint8_t * pBuffer = pPacket; + uint16_t packetIdentifier = 0; + size_t i = 0; + uint8_t * pBuffer = pPacket; /* Avoid unused variable warning when logging and asserts are disabled. */ ( void ) pPacket; ( void ) subscribePacketSize; /* The first byte in SUBSCRIBE is the packet type. */ - *pBuffer = MQTT_PACKET_TYPE_SUBSCRIBE; + *pBuffer = MQTT_PACKET_TYPE_SUBSCRIBE; pBuffer++; /* Encode the "Remaining length" starting from the second byte. */ - pBuffer = _encodeRemainingLength( pBuffer, remainingLength ); + pBuffer = _encodeRemainingLength( pBuffer, remainingLength ); /* Get the next packet identifier. It should always be nonzero. */ - packetIdentifier = _IotMqtt_NextPacketIdentifier(); + packetIdentifier = _IotMqtt_NextPacketIdentifier(); *pPacketIdentifier = packetIdentifier; IotMqtt_Assert( packetIdentifier != 0U ); /* Place the packet identifier into the SUBSCRIBE packet. */ - *pBuffer = UINT16_HIGH_BYTE( packetIdentifier ); - *( pBuffer + 1 ) = UINT16_LOW_BYTE( packetIdentifier ); - pBuffer += 2; + *pBuffer = UINT16_HIGH_BYTE( packetIdentifier ); + *( pBuffer + 1 ) = UINT16_LOW_BYTE( packetIdentifier ); + pBuffer += 2; /* Serialize each subscription topic filter and QoS. */ for( i = 0; i < subscriptionCount; i++ ) { - pBuffer = _encodeString( pBuffer, - pSubscriptionList[ i ].pTopicFilter, - pSubscriptionList[ i ].topicFilterLength ); + pBuffer = _encodeString( pBuffer, + pSubscriptionList[ i ].pTopicFilter, + pSubscriptionList[ i ].topicFilterLength ); /* Place the QoS in the SUBSCRIBE packet. */ *pBuffer = ( uint8_t ) ( pSubscriptionList[ i ].qos ); @@ -668,7 +668,7 @@ bool _IotMqtt_SubscriptionPacketSize( IotMqttOperationType_t type, size_t * pRemainingLength, size_t * pPacketSize ) { - bool status = true; + bool status = true; size_t i = 0, subscriptionPacketSize = 0; /* Only SUBSCRIBE and UNSUBSCRIBE operations should call this function. */ @@ -701,13 +701,13 @@ bool _IotMqtt_SubscriptionPacketSize( IotMqttOperationType_t type, } else { - *pRemainingLength = subscriptionPacketSize; + *pRemainingLength = subscriptionPacketSize; /* Calculate the full size of the subscription packet by adding the size of the * "Remaining length" field plus 1 byte for the "Packet type" field. Set the * pPacketSize output parameter. */ subscriptionPacketSize += 1U + _IotMqtt_RemainingLengthEncodedSize( subscriptionPacketSize ); - *pPacketSize = subscriptionPacketSize; + *pPacketSize = subscriptionPacketSize; } return status; @@ -719,7 +719,7 @@ bool _IotMqtt_PublishPacketSize( const IotMqttPublishInfo_t * pPublishInfo, size_t * pRemainingLength, size_t * pPacketSize ) { - bool status = true; + bool status = true; size_t publishPacketSize = 0, payloadLimit = 0; /* The variable header of a PUBLISH packet always contains the topic name. */ @@ -735,7 +735,7 @@ bool _IotMqtt_PublishPacketSize( const IotMqttPublishInfo_t * pPublishInfo, /* Calculate the maximum allowed size of the payload for the given parameters. * This calculation excludes the "Remaining length" encoding, whose size is not * yet known. */ - payloadLimit = MQTT_MAX_REMAINING_LENGTH - publishPacketSize - 1U; + payloadLimit = MQTT_MAX_REMAINING_LENGTH - publishPacketSize - 1U; /* Ensure that the given payload fits within the calculated limit. */ if( pPublishInfo->payloadLength > payloadLimit ) @@ -750,7 +750,7 @@ bool _IotMqtt_PublishPacketSize( const IotMqttPublishInfo_t * pPublishInfo, /* Now that the "Remaining length" is known, recalculate the payload limit * based on the size of its encoding. */ - payloadLimit -= _IotMqtt_RemainingLengthEncodedSize( publishPacketSize ); + payloadLimit -= _IotMqtt_RemainingLengthEncodedSize( publishPacketSize ); /* Check that the given payload fits within the size allowed by MQTT spec. */ if( pPublishInfo->payloadLength > payloadLimit ) @@ -761,10 +761,10 @@ bool _IotMqtt_PublishPacketSize( const IotMqttPublishInfo_t * pPublishInfo, { /* Set the "Remaining length" output parameter and calculate the full * size of the PUBLISH packet. */ - *pRemainingLength = publishPacketSize; + *pRemainingLength = publishPacketSize; publishPacketSize += 1U + _IotMqtt_RemainingLengthEncodedSize( publishPacketSize ); - *pPacketSize = publishPacketSize; + *pPacketSize = publishPacketSize; } } @@ -780,9 +780,9 @@ void _IotMqtt_SerializePublishCommon( const IotMqttPublishInfo_t * pPublishInfo, uint8_t * pPacket, size_t publishPacketSize ) { - uint8_t publishFlags = 0; - uint16_t packetIdentifier = 0; - uint8_t * pBuffer = pPacket; + uint8_t publishFlags = 0; + uint16_t packetIdentifier = 0; + uint8_t * pBuffer = pPacket; /* Avoid unused variable warning when logging and asserts are disabled. */ ( void ) pPacket; @@ -809,22 +809,22 @@ void _IotMqtt_SerializePublishCommon( const IotMqttPublishInfo_t * pPublishInfo, UINT8_SET_BIT( publishFlags, MQTT_PUBLISH_FLAG_RETAIN ); } - *pBuffer = publishFlags; + *pBuffer = publishFlags; pBuffer++; /* The "Remaining length" is encoded from the second byte. */ - pBuffer = _encodeRemainingLength( pBuffer, remainingLength ); + pBuffer = _encodeRemainingLength( pBuffer, remainingLength ); /* The topic name is placed after the "Remaining length". */ - pBuffer = _encodeString( pBuffer, - pPublishInfo->pTopicName, - pPublishInfo->topicNameLength ); + pBuffer = _encodeString( pBuffer, + pPublishInfo->pTopicName, + pPublishInfo->topicNameLength ); /* A packet identifier is required for QoS 1 and 2 messages. */ if( pPublishInfo->qos > IOT_MQTT_QOS_0 ) { /* Get the next packet identifier. It should always be nonzero. */ - packetIdentifier = _IotMqtt_NextPacketIdentifier(); + packetIdentifier = _IotMqtt_NextPacketIdentifier(); IotMqtt_Assert( packetIdentifier != 0U ); /* Set the packet identifier output parameters. */ @@ -836,9 +836,9 @@ void _IotMqtt_SerializePublishCommon( const IotMqttPublishInfo_t * pPublishInfo, } /* Place the packet identifier into the PUBLISH packet. */ - *pBuffer = UINT16_HIGH_BYTE( packetIdentifier ); - *( pBuffer + 1 ) = UINT16_LOW_BYTE( packetIdentifier ); - pBuffer += 2; + *pBuffer = UINT16_HIGH_BYTE( packetIdentifier ); + *( pBuffer + 1 ) = UINT16_LOW_BYTE( packetIdentifier ); + pBuffer += 2; } /* The payload is placed after the packet identifier. */ @@ -868,30 +868,30 @@ void _IotMqtt_SerializeUnsubscribeCommon( const IotMqttSubscription_t * pSubscri uint8_t * pPacket, size_t unsubscribePacketSize ) { - uint16_t packetIdentifier = 0; - size_t i = 0; - uint8_t * pBuffer = pPacket; + uint16_t packetIdentifier = 0; + size_t i = 0; + uint8_t * pBuffer = pPacket; /* Avoid unused variable warning when logging and asserts are disabled. */ ( void ) pPacket; ( void ) unsubscribePacketSize; /* The first byte in UNSUBSCRIBE is the packet type. */ - *pBuffer = MQTT_PACKET_TYPE_UNSUBSCRIBE; + *pBuffer = MQTT_PACKET_TYPE_UNSUBSCRIBE; pBuffer++; /* Encode the "Remaining length" starting from the second byte. */ - pBuffer = _encodeRemainingLength( pBuffer, remainingLength ); + pBuffer = _encodeRemainingLength( pBuffer, remainingLength ); /* Get the next packet identifier. It should always be nonzero. */ - packetIdentifier = _IotMqtt_NextPacketIdentifier(); + packetIdentifier = _IotMqtt_NextPacketIdentifier(); *pPacketIdentifier = packetIdentifier; IotMqtt_Assert( packetIdentifier != 0U ); /* Place the packet identifier into the UNSUBSCRIBE packet. */ - *pBuffer = UINT16_HIGH_BYTE( packetIdentifier ); - *( pBuffer + 1 ) = UINT16_LOW_BYTE( packetIdentifier ); - pBuffer += 2; + *pBuffer = UINT16_HIGH_BYTE( packetIdentifier ); + *( pBuffer + 1 ) = UINT16_LOW_BYTE( packetIdentifier ); + pBuffer += 2; /* Serialize each subscription topic filter. */ for( i = 0; i < subscriptionCount; i++ ) diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_lightweight_api.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_lightweight_api.c index 2b6a85754..3bbd3a5e2 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_lightweight_api.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_lightweight_api.c @@ -210,9 +210,9 @@ static IotMqttError_t _checkPublishRemainingLength( const IotMqttPacketInfo_t * static IotMqttError_t _readSubackStatus( size_t statusCount, const uint8_t * pStatusStart ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; - uint8_t subscriptionStatus = 0; - size_t i = 0; + IotMqttError_t status = IOT_MQTT_SUCCESS; + uint8_t subscriptionStatus = 0; + size_t i = 0; /* Iterate through each status byte in the SUBACK packet. */ for( i = 0; i < statusCount; i++ ) @@ -274,7 +274,7 @@ static size_t _getRemainingLength( IotNetworkConnection_t pNetworkConnection, IotMqttGetNextByte_t getNextByte ) { uint8_t encodedByte = 0; - size_t remainingLength = 0, multiplier = 1, bytesDecoded = 0, expectedSize = 0; + size_t remainingLength = 0, multiplier = 1, bytesDecoded = 0, expectedSize = 0; /* This algorithm is copied from the MQTT v3.1.1 spec. */ do @@ -288,7 +288,7 @@ static size_t _getRemainingLength( IotNetworkConnection_t pNetworkConnection, if( getNextByte( pNetworkConnection, &encodedByte ) == IOT_MQTT_SUCCESS ) { remainingLength += ( ( size_t ) encodedByte & 0x7FU ) * multiplier; - multiplier *= 128U; + multiplier *= 128U; bytesDecoded++; } else @@ -326,8 +326,8 @@ static size_t _getRemainingLength( IotNetworkConnection_t pNetworkConnection, static IotMqttError_t _deserializeConnack( IotMqttPacketInfo_t * pConnack ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; - const uint8_t * pRemainingData = pConnack->pRemainingData; + IotMqttError_t status = IOT_MQTT_SUCCESS; + const uint8_t * pRemainingData = pConnack->pRemainingData; /* If logging is enabled, declare the CONNACK response code strings. The * fourth byte of CONNACK indexes into this array for the corresponding response. */ @@ -416,8 +416,8 @@ static IotMqttError_t _deserializeConnack( IotMqttPacketInfo_t * pConnack ) static IotMqttError_t _deserializeSuback( IotMqttPacketInfo_t * pSuback ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; - size_t remainingLength = pSuback->remainingLength; + IotMqttError_t status = IOT_MQTT_SUCCESS; + size_t remainingLength = pSuback->remainingLength; const uint8_t * pVariableHeader = pSuback->pRemainingData; /* A SUBACK must have a remaining length of at least 3 to accommodate the @@ -434,8 +434,8 @@ static IotMqttError_t _deserializeSuback( IotMqttPacketInfo_t * pSuback ) IotLogDebug( "Packet identifier %hu.", pSuback->packetIdentifier ); - status = _readSubackStatus( remainingLength - sizeof( uint16_t ), - pVariableHeader + sizeof( uint16_t ) ); + status = _readSubackStatus( remainingLength - sizeof( uint16_t ), + pVariableHeader + sizeof( uint16_t ) ); } return status; @@ -528,15 +528,15 @@ static IotMqttError_t _deserializePuback( IotMqttPacketInfo_t * pPuback ) static IotMqttError_t _deserializePublish( IotMqttPacketInfo_t * pPublish ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; + IotMqttError_t status = IOT_MQTT_SUCCESS; IotMqttPublishInfo_t * pOutput = &( pPublish->pubInfo ); - uint8_t publishFlags = 0; - const uint8_t * pVariableHeader = pPublish->pRemainingData, * pPacketIdentifierHigh = NULL; + uint8_t publishFlags = 0; + const uint8_t * pVariableHeader = pPublish->pRemainingData, * pPacketIdentifierHigh = NULL; /* The flags are the lower 4 bits of the first byte in PUBLISH. */ publishFlags = pPublish->type; - status = _IotMqtt_ProcessPublishFlags( publishFlags, pOutput ); + status = _IotMqtt_ProcessPublishFlags( publishFlags, pOutput ); if( status == IOT_MQTT_SUCCESS ) { @@ -556,15 +556,15 @@ static IotMqttError_t _deserializePublish( IotMqttPacketInfo_t * pPublish ) /* Sanity checks for topic name length and "Remaining length". The remaining * length must be at least as large as the variable length header. */ - status = _checkPublishRemainingLength( pPublish, - pOutput->qos, - pOutput->topicNameLength + sizeof( uint16_t ) ); + status = _checkPublishRemainingLength( pPublish, + pOutput->qos, + pOutput->topicNameLength + sizeof( uint16_t ) ); } if( status == IOT_MQTT_SUCCESS ) { /* Parse the topic. */ - pOutput->pTopicName = ( const char * ) ( pVariableHeader + sizeof( uint16_t ) ); + pOutput->pTopicName = ( const char * ) ( pVariableHeader + sizeof( uint16_t ) ); IotLogDebug( "Topic name length %hu: %.*s", pOutput->topicNameLength, @@ -596,12 +596,12 @@ static IotMqttError_t _deserializePublish( IotMqttPacketInfo_t * pPublish ) if( pOutput->qos == IOT_MQTT_QOS_0 ) { pOutput->payloadLength = ( pPublish->remainingLength - pOutput->topicNameLength - sizeof( uint16_t ) ); - pOutput->pPayload = pPacketIdentifierHigh; + pOutput->pPayload = pPacketIdentifierHigh; } else { pOutput->payloadLength = ( pPublish->remainingLength - pOutput->topicNameLength - 2U * sizeof( uint16_t ) ); - pOutput->pPayload = pPacketIdentifierHigh + sizeof( uint16_t ); + pOutput->pPayload = pPacketIdentifierHigh + sizeof( uint16_t ); } IotLogDebug( "Payload length %hu.", pOutput->payloadLength ); @@ -1026,7 +1026,7 @@ IotMqttError_t IotMqtt_SerializePingreq( uint8_t * pBuffer, IotMqttError_t IotMqtt_DeserializePublish( IotMqttPacketInfo_t * pMqttPacket ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; + IotMqttError_t status = IOT_MQTT_SUCCESS; /* Internal MQTT packet structure */ IotMqttPacketInfo_t mqttPacket = { 0 }; @@ -1043,15 +1043,15 @@ IotMqttError_t IotMqtt_DeserializePublish( IotMqttPacketInfo_t * pMqttPacket ) else { /* Set internal mqtt packet parameters. */ - mqttPacket.pRemainingData = pMqttPacket->pRemainingData; + mqttPacket.pRemainingData = pMqttPacket->pRemainingData; mqttPacket.remainingLength = pMqttPacket->remainingLength; - mqttPacket.type = pMqttPacket->type; - status = _deserializePublish( &mqttPacket ); + mqttPacket.type = pMqttPacket->type; + status = _deserializePublish( &mqttPacket ); } if( status == IOT_MQTT_SUCCESS ) { - pMqttPacket->pubInfo = mqttPacket.pubInfo; + pMqttPacket->pubInfo = mqttPacket.pubInfo; pMqttPacket->packetIdentifier = mqttPacket.packetIdentifier; } @@ -1062,7 +1062,7 @@ IotMqttError_t IotMqtt_DeserializePublish( IotMqttPacketInfo_t * pMqttPacket ) IotMqttError_t IotMqtt_DeserializeResponse( IotMqttPacketInfo_t * pMqttPacket ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; + IotMqttError_t status = IOT_MQTT_SUCCESS; /* Internal MQTT packet structure */ IotMqttPacketInfo_t mqttPacket = { 0 }; @@ -1079,9 +1079,9 @@ IotMqttError_t IotMqtt_DeserializeResponse( IotMqttPacketInfo_t * pMqttPacket ) else { /* Set internal mqtt packet parameters. */ - mqttPacket.pRemainingData = pMqttPacket->pRemainingData; + mqttPacket.pRemainingData = pMqttPacket->pRemainingData; mqttPacket.remainingLength = pMqttPacket->remainingLength; - mqttPacket.type = pMqttPacket->type; + mqttPacket.type = pMqttPacket->type; /* Make sure response packet is a valid packet */ switch( pMqttPacket->type & 0xf0U ) diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_network.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_network.c index 8c3a61e55..1f9703322 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_network.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_network.c @@ -250,8 +250,8 @@ static IotMqttError_t _allocateAndReceivePacket( IotNetworkConnection_t pNetwork const _mqttConnection_t * pMqttConnection, _mqttPacket_t * pIncomingPacket ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; - size_t dataBytesRead = 0; + IotMqttError_t status = IOT_MQTT_SUCCESS; + size_t dataBytesRead = 0; IotMqtt_Assert( pMqttConnection != NULL ); IotMqtt_Assert( pIncomingPacket != NULL ); @@ -360,10 +360,10 @@ static IotMqttError_t _deserializeAck( _mqttConnection_t * pMqttConnection, IotMqttOperationType_t opType, const uint16_t * pPacketIdentifier ) { - IotMqttError_t status = IOT_MQTT_STATUS_PENDING; + IotMqttError_t status = IOT_MQTT_STATUS_PENDING; _mqttOperation_t * pOperation = NULL; - status = _deserializer( pIncomingPacket ); + status = _deserializer( pIncomingPacket ); pOperation = _IotMqtt_FindOperation( pMqttConnection, opType, @@ -383,7 +383,7 @@ static IotMqttError_t _deserializeAck( _mqttConnection_t * pMqttConnection, static IotMqttError_t _deserializePublishPacket( _mqttConnection_t * pMqttConnection, _mqttPacket_t * pIncomingPacket ) { - IotMqttError_t status = IOT_MQTT_STATUS_PENDING; + IotMqttError_t status = IOT_MQTT_STATUS_PENDING; _mqttOperation_t * pOperation = NULL; /* Allocate memory to handle the incoming PUBLISH. */ @@ -398,11 +398,11 @@ static IotMqttError_t _deserializePublishPacket( _mqttConnection_t * pMqttConnec { /* Set the members of the incoming PUBLISH operation. */ ( void ) memset( pOperation, 0x00, sizeof( _mqttOperation_t ) ); - pOperation->incomingPublish = true; - pOperation->pMqttConnection = pMqttConnection; + pOperation->incomingPublish = true; + pOperation->pMqttConnection = pMqttConnection; pIncomingPacket->u.pIncomingPublish = pOperation; /* Deserialize incoming PUBLISH. */ - status = _getPublishDeserializer( pMqttConnection->pSerializer )( pIncomingPacket ); + status = _getPublishDeserializer( pMqttConnection->pSerializer )( pIncomingPacket ); } if( status == IOT_MQTT_SUCCESS ) @@ -415,7 +415,7 @@ static IotMqttError_t _deserializePublishPacket( _mqttConnection_t * pMqttConnec /* Transfer ownership of the received MQTT packet to the PUBLISH operation. */ pOperation->u.publish.pReceivedData = pIncomingPacket->pRemainingData; - pIncomingPacket->pRemainingData = NULL; + pIncomingPacket->pRemainingData = NULL; /* Add the PUBLISH to the list of operations pending processing. * Coverity finds a USE_AFTER_FREE error at this line. This is a false positive. @@ -529,11 +529,11 @@ static IotMqttError_t _deserializeIncomingPacket( _mqttConnection_t * pMqttConne IotLogDebug( "(MQTT connection %p) CONNACK in data stream.", pMqttConnection ); /* Deserialize CONNACK and notify of result. */ - status = _deserializeAck( pMqttConnection, - pIncomingPacket, - _getConnackDeserializer( pMqttConnection->pSerializer ), - IOT_MQTT_CONNECT, - NULL ); + status = _deserializeAck( pMqttConnection, + pIncomingPacket, + _getConnackDeserializer( pMqttConnection->pSerializer ), + IOT_MQTT_CONNECT, + NULL ); break; @@ -541,7 +541,7 @@ static IotMqttError_t _deserializeIncomingPacket( _mqttConnection_t * pMqttConne IotLogDebug( "(MQTT connection %p) PUBLISH in data stream.", pMqttConnection ); /* Deserialize PUBLISH. */ - status = _deserializePublishPacket( pMqttConnection, pIncomingPacket ); + status = _deserializePublishPacket( pMqttConnection, pIncomingPacket ); break; @@ -549,11 +549,11 @@ static IotMqttError_t _deserializeIncomingPacket( _mqttConnection_t * pMqttConne IotLogDebug( "(MQTT connection %p) PUBACK in data stream.", pMqttConnection ); /* Deserialize PUBACK and notify of result. */ - status = _deserializeAck( pMqttConnection, - pIncomingPacket, - _getPubackDeserializer( pMqttConnection->pSerializer ), - IOT_MQTT_PUBLISH_TO_SERVER, - &( pIncomingPacket->packetIdentifier ) ); + status = _deserializeAck( pMqttConnection, + pIncomingPacket, + _getPubackDeserializer( pMqttConnection->pSerializer ), + IOT_MQTT_PUBLISH_TO_SERVER, + &( pIncomingPacket->packetIdentifier ) ); break; @@ -563,11 +563,11 @@ static IotMqttError_t _deserializeIncomingPacket( _mqttConnection_t * pMqttConne /* Deserialize SUBACK and notify of result. */ pIncomingPacket->u.pMqttConnection = pMqttConnection; - status = _deserializeAck( pMqttConnection, - pIncomingPacket, - _getSubackDeserializer( pMqttConnection->pSerializer ), - IOT_MQTT_SUBSCRIBE, - &( pIncomingPacket->packetIdentifier ) ); + status = _deserializeAck( pMqttConnection, + pIncomingPacket, + _getSubackDeserializer( pMqttConnection->pSerializer ), + IOT_MQTT_SUBSCRIBE, + &( pIncomingPacket->packetIdentifier ) ); break; @@ -575,11 +575,11 @@ static IotMqttError_t _deserializeIncomingPacket( _mqttConnection_t * pMqttConne IotLogDebug( "(MQTT connection %p) UNSUBACK in data stream.", pMqttConnection ); /* Deserialize UNSUBACK and notify of result. */ - status = _deserializeAck( pMqttConnection, - pIncomingPacket, - _getUnsubackDeserializer( pMqttConnection->pSerializer ), - IOT_MQTT_UNSUBSCRIBE, - &( pIncomingPacket->packetIdentifier ) ); + status = _deserializeAck( pMqttConnection, + pIncomingPacket, + _getUnsubackDeserializer( pMqttConnection->pSerializer ), + IOT_MQTT_UNSUBSCRIBE, + &( pIncomingPacket->packetIdentifier ) ); break; @@ -590,7 +590,7 @@ static IotMqttError_t _deserializeIncomingPacket( _mqttConnection_t * pMqttConne IotLogDebug( "(MQTT connection %p) PINGRESP in data stream.", pMqttConnection ); /* Deserialize PINGRESP. */ - status = _deserializePingResp( pMqttConnection, pIncomingPacket ); + status = _deserializePingResp( pMqttConnection, pIncomingPacket ); break; } @@ -626,7 +626,7 @@ static IotMqttError_t _deserializeIncomingPacket( _mqttConnection_t * pMqttConne static void _sendPuback( _mqttConnection_t * pMqttConnection, uint16_t packetIdentifier ) { - IotMqttError_t status = IOT_MQTT_STATUS_PENDING; + IotMqttError_t status = IOT_MQTT_STATUS_PENDING; _mqttOperation_t * pPubackOperation = NULL; IotLogDebug( "(MQTT connection %p) Sending PUBACK for received PUBLISH %hu.", @@ -645,9 +645,9 @@ static void _sendPuback( _mqttConnection_t * pMqttConnection, pPubackOperation->u.operation.type = IOT_MQTT_PUBACK; /* Generate a PUBACK packet from the packet identifier. */ - status = _getMqttPubackSerializer( pMqttConnection->pSerializer )( packetIdentifier, - &( pPubackOperation->u.operation.pMqttPacket ), - &( pPubackOperation->u.operation.packetSize ) ); + status = _getMqttPubackSerializer( pMqttConnection->pSerializer )( packetIdentifier, + &( pPubackOperation->u.operation.pMqttPacket ), + &( pPubackOperation->u.operation.packetSize ) ); if( status == IOT_MQTT_SUCCESS ) { @@ -679,7 +679,7 @@ static void _flushPacket( IotNetworkConnection_t pNetworkConnection, const _mqttConnection_t * pMqttConnection, size_t length ) { - size_t bytesFlushed = 0; + size_t bytesFlushed = 0; uint8_t receivedByte = 0; for( bytesFlushed = 0; bytesFlushed < length; bytesFlushed++ ) @@ -696,9 +696,9 @@ bool _IotMqtt_GetNextByte( IotNetworkConnection_t pNetworkConnection, const IotNetworkInterface_t * pNetworkInterface, uint8_t * pIncomingByte ) { - bool status = false; - uint8_t incomingByte = 0; - size_t bytesReceived = 0; + bool status = false; + uint8_t incomingByte = 0; + size_t bytesReceived = 0; /* Attempt to read 1 byte. */ bytesReceived = pNetworkInterface->receive( pNetworkConnection, @@ -709,7 +709,7 @@ bool _IotMqtt_GetNextByte( IotNetworkConnection_t pNetworkConnection, if( bytesReceived == 1U ) { *pIncomingByte = incomingByte; - status = true; + status = true; } else { @@ -725,15 +725,15 @@ bool _IotMqtt_GetNextByte( IotNetworkConnection_t pNetworkConnection, void _IotMqtt_CloseNetworkConnection( IotMqttDisconnectReason_t disconnectReason, _mqttConnection_t * pMqttConnection ) { - taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS; - IotNetworkError_t closeStatus = IOT_NETWORK_SUCCESS; + taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS; + IotNetworkError_t closeStatus = IOT_NETWORK_SUCCESS; IotMqttCallbackParam_t callbackParam = { .u.message = { 0 } }; IotNetworkConnection_t pNetworkConnection = NULL; - void * pDisconnectCallbackContext = NULL; + void * pDisconnectCallbackContext = NULL; /* Disconnect callback function. */ - void ( * disconnectCallback )( void * pContext, - IotMqttCallbackParam_t * pParam ) = NULL; + void ( * disconnectCallback )( void * pContext, + IotMqttCallbackParam_t * pParam ) = NULL; /* Network close function. */ IotNetworkError_t ( * closeConnection) ( IotNetworkConnection_t pConnection ) = NULL; @@ -772,8 +772,8 @@ void _IotMqtt_CloseNetworkConnection( IotMqttDisconnectReason_t disconnectReason /* Clear data about the keep-alive. */ pMqttConnection->pingreq.u.operation.periodic.ping.keepAliveMs = 0U; - pMqttConnection->pingreq.u.operation.pMqttPacket = NULL; - pMqttConnection->pingreq.u.operation.packetSize = 0U; + pMqttConnection->pingreq.u.operation.pMqttPacket = NULL; + pMqttConnection->pingreq.u.operation.packetSize = 0U; /* Keep-alive is cleaned up; decrement reference count. Since this * function must be followed with a call to DISCONNECT, a check to @@ -787,11 +787,11 @@ void _IotMqtt_CloseNetworkConnection( IotMqttDisconnectReason_t disconnectReason /* Copy the function pointers and contexts, as the MQTT connection may be * modified after the mutex is released. */ - disconnectCallback = pMqttConnection->disconnectCallback.function; - pDisconnectCallbackContext = pMqttConnection->disconnectCallback.pCallbackContext; + disconnectCallback = pMqttConnection->disconnectCallback.function; + pDisconnectCallbackContext = pMqttConnection->disconnectCallback.pCallbackContext; - closeConnection = pMqttConnection->pNetworkInterface->close; - pNetworkConnection = pMqttConnection->pNetworkConnection; + closeConnection = pMqttConnection->pNetworkInterface->close; + pNetworkConnection = pMqttConnection->pNetworkConnection; IotMutex_Unlock( &( pMqttConnection->referencesMutex ) ); @@ -821,7 +821,7 @@ void _IotMqtt_CloseNetworkConnection( IotMqttDisconnectReason_t disconnectReason if( disconnectCallback != NULL ) { /* Set the members of the callback parameter. */ - callbackParam.mqttConnection = pMqttConnection; + callbackParam.mqttConnection = pMqttConnection; callbackParam.u.disconnectReason = disconnectReason; disconnectCallback( pDisconnectCallbackContext, @@ -834,8 +834,8 @@ void _IotMqtt_CloseNetworkConnection( IotMqttDisconnectReason_t disconnectReason void IotMqtt_ReceiveCallback( IotNetworkConnection_t pNetworkConnection, void * pReceiveContext ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; - _mqttPacket_t incomingPacket = { .u.pMqttConnection = NULL }; + IotMqttError_t status = IOT_MQTT_SUCCESS; + _mqttPacket_t incomingPacket = { .u.pMqttConnection = NULL }; /* Cast context to correct type. */ _mqttConnection_t * pMqttConnection = ( _mqttConnection_t * ) pReceiveContext; diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_operation.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_operation.c index d731e4501..3e11ce692 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_operation.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_operation.c @@ -161,7 +161,7 @@ static bool _sendPingRequest( _mqttConnection_t * pMqttConnection ); static bool _mqttOperation_match( const IotLink_t * const pOperationLink, void * pMatch ) { - bool match = false; + bool match = false; /* Because this function is called from a container function, the given link * must never be NULL. */ @@ -174,10 +174,10 @@ static bool _mqttOperation_match( const IotLink_t * const pOperationLink, /* coverity[misra_c_2012_rule_11_8_violation] */ /* coverity[misra_c_2012_rule_20_7_violation] */ /* coverity[caretline] */ - const _mqttOperation_t * pOperation = IotLink_Container( _mqttOperation_t, - pOperationLink, - link ); - const _operationMatchParam_t * pParam = ( _operationMatchParam_t * ) pMatch; + const _mqttOperation_t * pOperation = IotLink_Container( _mqttOperation_t, + pOperationLink, + link ); + const _operationMatchParam_t * pParam = ( _operationMatchParam_t * ) pMatch; /* Check for matching operations. */ if( pParam->type == pOperation->u.operation.type ) @@ -201,7 +201,7 @@ static bool _mqttOperation_match( const IotLink_t * const pOperationLink, static bool _checkRetryLimit( _mqttOperation_t * pOperation ) { _mqttConnection_t * pMqttConnection = pOperation->pMqttConnection; - bool status = true, setDup = false; + bool status = true, setDup = false; /* Only PUBLISH may be retried. */ IotMqtt_Assert( pOperation->u.operation.type == IOT_MQTT_PUBLISH_TO_SERVER ); @@ -268,9 +268,9 @@ static bool _checkRetryLimit( _mqttOperation_t * pOperation ) static bool _scheduleNextRetry( _mqttOperation_t * pOperation ) { - bool firstRetry = false; - uint32_t scheduleDelay = 0; - IotMqttError_t status = IOT_MQTT_STATUS_PENDING; + bool firstRetry = false; + uint32_t scheduleDelay = 0; + IotMqttError_t status = IOT_MQTT_STATUS_PENDING; _mqttConnection_t * pMqttConnection = pOperation->pMqttConnection; /* This function should never be called with retry count greater than @@ -296,7 +296,7 @@ static bool _scheduleNextRetry( _mqttOperation_t * pOperation ) } else { - scheduleDelay = pOperation->u.operation.periodic.retry.nextPeriodMs; + scheduleDelay = pOperation->u.operation.periodic.retry.nextPeriodMs; /* Double the retry period, subject to a ceiling value. */ pOperation->u.operation.periodic.retry.nextPeriodMs *= 2U; @@ -366,7 +366,7 @@ static bool _scheduleNextRetry( _mqttOperation_t * pOperation ) static IotMqttError_t _scheduleCallback( _mqttOperation_t * pOperation ) { - IotMqttError_t status = IOT_MQTT_SCHEDULING_ERROR; + IotMqttError_t status = IOT_MQTT_SCHEDULING_ERROR; _mqttConnection_t * pMqttConnection = pOperation->pMqttConnection; /* Non-waitable operation should have job reference of 1. */ @@ -417,7 +417,7 @@ static IotMqttError_t _scheduleCallback( _mqttOperation_t * pOperation ) static bool _completePendingSend( _mqttOperation_t * pOperation, bool * pDestroyOperation ) { - bool networkPending = false, waitable = false; + bool networkPending = false, waitable = false; _mqttConnection_t * pMqttConnection = pOperation->pMqttConnection; /* Check if this operation is waitable. */ @@ -477,8 +477,8 @@ static IotMqttError_t _initializeOperation( _mqttConnection_t * pMqttConnection, uint32_t flags, const IotMqttCallbackInfo_t * pCallbackInfo ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; - bool waitable = ( ( flags & IOT_MQTT_FLAG_WAITABLE ) == IOT_MQTT_FLAG_WAITABLE ); + IotMqttError_t status = IOT_MQTT_SUCCESS; + bool waitable = ( ( flags & IOT_MQTT_FLAG_WAITABLE ) == IOT_MQTT_FLAG_WAITABLE ); IotMqtt_Assert( pMqttConnection != NULL ); IotMqtt_Assert( pOperation != NULL ); @@ -487,10 +487,10 @@ static IotMqttError_t _initializeOperation( _mqttConnection_t * pMqttConnection, ( void ) memset( pOperation, 0x00, sizeof( _mqttOperation_t ) ); /* Initialize some members of the new operation. */ - pOperation->pMqttConnection = pMqttConnection; + pOperation->pMqttConnection = pMqttConnection; pOperation->u.operation.jobReference = 1; - pOperation->u.operation.flags = flags; - pOperation->u.operation.status = IOT_MQTT_STATUS_PENDING; + pOperation->u.operation.flags = flags; + pOperation->u.operation.status = IOT_MQTT_STATUS_PENDING; /* Check if the waitable flag is set. If it is, create a semaphore to * wait on. */ @@ -529,9 +529,9 @@ static IotMqttError_t _initializeOperation( _mqttConnection_t * pMqttConnection, static bool _sendPingRequest( _mqttConnection_t * pMqttConnection ) { - size_t bytesSent = 0; - bool status = true; - uint32_t swapStatus = 0; + size_t bytesSent = 0; + bool status = true; + uint32_t swapStatus = 0; _mqttOperation_t * pPingreqOperation = NULL; IotMqtt_Assert( pMqttConnection != NULL ); @@ -543,9 +543,9 @@ static bool _sendPingRequest( _mqttConnection_t * pMqttConnection ) /* Because PINGREQ may be used to keep the MQTT connection alive, it is * more important than other operations. Bypass the queue of jobs for * operations by directly sending the PINGREQ in this job. */ - bytesSent = pMqttConnection->pNetworkInterface->send( pMqttConnection->pNetworkConnection, - pPingreqOperation->u.operation.pMqttPacket, - pPingreqOperation->u.operation.packetSize ); + bytesSent = pMqttConnection->pNetworkInterface->send( pMqttConnection->pNetworkConnection, + pPingreqOperation->u.operation.pMqttPacket, + pPingreqOperation->u.operation.packetSize ); if( bytesSent != pPingreqOperation->u.operation.packetSize ) { @@ -556,14 +556,14 @@ static bool _sendPingRequest( _mqttConnection_t * pMqttConnection ) { /* Update the timestamp of the last message on successful transmission. */ IotMutex_Lock( &( pMqttConnection->referencesMutex ) ); - pMqttConnection->lastMessageTime = IotClock_GetTimeMs(); + pMqttConnection->lastMessageTime = IotClock_GetTimeMs(); IotMutex_Unlock( &( pMqttConnection->referencesMutex ) ); /* Assume the keep-alive will fail. The network receive callback will * clear the failure flag upon receiving a PINGRESP. */ - swapStatus = Atomic_CompareAndSwap_u32( &( pPingreqOperation->u.operation.periodic.ping.failure ), - 1, - 0 ); + swapStatus = Atomic_CompareAndSwap_u32( &( pPingreqOperation->u.operation.periodic.ping.failure ), + 1, + 0 ); IotMqtt_Assert( swapStatus == 1U ); /* Set the period for scheduling a PINGRESP check. */ @@ -582,10 +582,10 @@ IotMqttError_t _IotMqtt_CreateOperation( _mqttConnection_t * pMqttConnection, const IotMqttCallbackInfo_t * pCallbackInfo, _mqttOperation_t ** pNewOperation ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; - bool decrementOnError = false; - _mqttOperation_t * pOperation = NULL; - bool waitable = ( ( flags & IOT_MQTT_FLAG_WAITABLE ) == IOT_MQTT_FLAG_WAITABLE ); + IotMqttError_t status = IOT_MQTT_SUCCESS; + bool decrementOnError = false; + _mqttOperation_t * pOperation = NULL; + bool waitable = ( ( flags & IOT_MQTT_FLAG_WAITABLE ) == IOT_MQTT_FLAG_WAITABLE ); /* If the waitable flag is set, make sure that there's no callback. */ if( waitable == true ) @@ -675,9 +675,9 @@ IotMqttError_t _IotMqtt_CreateOperation( _mqttConnection_t * pMqttConnection, bool _IotMqtt_DecrementOperationReferences( _mqttOperation_t * pOperation, bool cancelJob ) { - bool destroyOperation = false; - taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS; - _mqttConnection_t * pMqttConnection = pOperation->pMqttConnection; + bool destroyOperation = false; + taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS; + _mqttConnection_t * pMqttConnection = pOperation->pMqttConnection; /* Attempt to cancel the operation's job. */ if( cancelJob == true ) @@ -822,14 +822,14 @@ void _IotMqtt_DestroyOperation( _mqttOperation_t * pOperation ) void _IotMqtt_ProcessKeepAlive( taskPoolJob_t * pKeepAliveJob, void * pContext ) { - bool status = true; - taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS; - uint32_t scheduleDelay = 0; - uint64_t elapsedTime = 0; + bool status = true; + taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS; + uint32_t scheduleDelay = 0; + uint64_t elapsedTime = 0; /* Retrieve the MQTT connection from the context. */ - _mqttConnection_t * pMqttConnection = ( _mqttConnection_t * ) pContext; - _mqttOperation_t * pPingreqOperation = &( pMqttConnection->pingreq ); + _mqttConnection_t * pMqttConnection = ( _mqttConnection_t * ) pContext; + _mqttOperation_t * pPingreqOperation = &( pMqttConnection->pingreq ); /* Check parameters. */ IotMqtt_Assert( pKeepAliveJob == &( pPingreqOperation->job ) ); @@ -1006,7 +1006,7 @@ void _IotMqtt_ProcessKeepAlive( taskPoolJob_t * pKeepAliveJob, void _IotMqtt_ProcessIncomingPublish( taskPoolJob_t * pPublishJob, void * pContext ) { - _mqttOperation_t * pOperation = pContext; + _mqttOperation_t * pOperation = pContext; IotMqttCallbackParam_t callbackParam = { .mqttConnection = NULL }; /* Check parameters. The task pool and job parameter is not used when asserts @@ -1044,9 +1044,9 @@ void _IotMqtt_ProcessIncomingPublish( taskPoolJob_t * pPublishJob, void _IotMqtt_ProcessSend( taskPoolJob_t * pSendJob, void * pContext ) { - size_t bytesSent = 0; - bool destroyOperation = false, waitable = false, networkPending = false; - _mqttOperation_t * pOperation = ( _mqttOperation_t * ) pContext; + size_t bytesSent = 0; + bool destroyOperation = false, waitable = false, networkPending = false; + _mqttOperation_t * pOperation = ( _mqttOperation_t * ) pContext; _mqttConnection_t * pMqttConnection = pOperation->pMqttConnection; /* Check parameters. The task pool and job parameter is not used when asserts @@ -1151,9 +1151,9 @@ void _IotMqtt_ProcessSend( taskPoolJob_t * pSendJob, void _IotMqtt_ProcessCompletedOperation( taskPoolJob_t * pOperationJob, void * pContext ) { - bool destroyOperation = false; - _mqttOperation_t * pOperation = ( _mqttOperation_t * ) pContext; - IotMqttCallbackParam_t callbackParam = { 0 }; + bool destroyOperation = false; + _mqttOperation_t * pOperation = ( _mqttOperation_t * ) pContext; + IotMqttCallbackParam_t callbackParam = { 0 }; /* Check parameters. The task pool and job parameter is not used when asserts * are disabled. */ @@ -1164,10 +1164,10 @@ void _IotMqtt_ProcessCompletedOperation( taskPoolJob_t * pOperationJob, IotMqtt_Assert( pOperation->u.operation.notify.callback.function != NULL ); IotMqtt_Assert( pOperation->u.operation.status != IOT_MQTT_STATUS_PENDING ); - callbackParam.mqttConnection = pOperation->pMqttConnection; - callbackParam.u.operation.type = pOperation->u.operation.type; + callbackParam.mqttConnection = pOperation->pMqttConnection; + callbackParam.u.operation.type = pOperation->u.operation.type; callbackParam.u.operation.reference = pOperation; - callbackParam.u.operation.result = pOperation->u.operation.status; + callbackParam.u.operation.result = pOperation->u.operation.status; /* Invoke the user callback function. */ pOperation->u.operation.notify.callback.function( pOperation->u.operation.notify.callback.pCallbackContext, @@ -1175,7 +1175,7 @@ void _IotMqtt_ProcessCompletedOperation( taskPoolJob_t * pOperationJob, /* Decrement the operation reference count. This function is at the end of the * operation lifecycle, so the operation must be destroyed here. */ - destroyOperation = _IotMqtt_DecrementOperationReferences( pOperation, false ); + destroyOperation = _IotMqtt_DecrementOperationReferences( pOperation, false ); IotMqtt_Assert( destroyOperation == true ); _IotMqtt_DestroyOperation( pOperation ); } @@ -1186,7 +1186,7 @@ IotMqttError_t _IotMqtt_ScheduleOperation( _mqttOperation_t * pOperation, taskPoolRoutine_t jobRoutine, uint32_t delay ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; + IotMqttError_t status = IOT_MQTT_SUCCESS; taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS; /* Check that job routine is valid. */ @@ -1231,16 +1231,16 @@ _mqttOperation_t * _IotMqtt_FindOperation( _mqttConnection_t * pMqttConnection, IotMqttOperationType_t type, const uint16_t * pPacketIdentifier ) { - bool waitable = false; - taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS; - _mqttOperation_t * pResult = NULL; - IotLink_t * pResultLink = NULL; + bool waitable = false; + taskPoolError_t taskPoolStatus = TASKPOOL_SUCCESS; + _mqttOperation_t * pResult = NULL; + IotLink_t * pResultLink = NULL; _operationMatchParam_t operationMatchParams; ( void ) memset( &operationMatchParams, 0, sizeof( _operationMatchParam_t ) ); /* Set the members of the search parameter. */ - operationMatchParams.type = type; + operationMatchParams.type = type; operationMatchParams.pPacketIdentifier = pPacketIdentifier; IotLogDebug( "(MQTT connection %p) Searching for operation %s " @@ -1251,10 +1251,10 @@ _mqttOperation_t * _IotMqtt_FindOperation( _mqttConnection_t * pMqttConnection, /* Find and remove the first matching element in the list. */ IotMutex_Lock( &( pMqttConnection->referencesMutex ) ); - pResultLink = IotListDouble_FindFirstMatch( &( pMqttConnection->pendingResponse ), - NULL, - _mqttOperation_match, - &operationMatchParams ); + pResultLink = IotListDouble_FindFirstMatch( &( pMqttConnection->pendingResponse ), + NULL, + _mqttOperation_match, + &operationMatchParams ); /* Check if a match was found. */ if( pResultLink != NULL ) @@ -1265,7 +1265,7 @@ _mqttOperation_t * _IotMqtt_FindOperation( _mqttConnection_t * pMqttConnection, * because it uses type-casting and offsetof, and would cause compiling errors. */ /* coverity[misra_c_2012_rule_20_7_violation] */ /* coverity[caretline] */ - pResult = IotLink_Container( _mqttOperation_t, pResultLink, link ); + pResult = IotLink_Container( _mqttOperation_t, pResultLink, link ); waitable = ( pResult->u.operation.flags & IOT_MQTT_FLAG_WAITABLE ) == IOT_MQTT_FLAG_WAITABLE; /* Check if the matched operation is a PUBLISH with retry. If it is, cancel @@ -1341,10 +1341,10 @@ _mqttOperation_t * _IotMqtt_FindOperation( _mqttConnection_t * pMqttConnection, void _IotMqtt_Notify( _mqttOperation_t * pOperation ) { - IotMqttError_t status = IOT_MQTT_SCHEDULING_ERROR; + IotMqttError_t status = IOT_MQTT_SCHEDULING_ERROR; /* Check if operation is waitable. */ - bool waitable = ( pOperation->u.operation.flags & IOT_MQTT_FLAG_WAITABLE ) == IOT_MQTT_FLAG_WAITABLE; + bool waitable = ( pOperation->u.operation.flags & IOT_MQTT_FLAG_WAITABLE ) == IOT_MQTT_FLAG_WAITABLE; /* Remove any lingering subscriptions if a SUBSCRIBE failed. Rejected * subscriptions are removed by the deserializer, so not removed here. */ diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_serialize.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_serialize.c index d6ebfc04b..cd2189a88 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_serialize.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_serialize.c @@ -95,9 +95,9 @@ static IotMqttError_t _decodeSubackStatus( size_t statusCount, const uint8_t * pStatusStart, const _mqttPacket_t * pSuback ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; - uint8_t subscriptionStatus = 0; - size_t i = 0; + IotMqttError_t status = IOT_MQTT_SUCCESS; + uint8_t subscriptionStatus = 0; + size_t i = 0; /* Iterate through each status byte in the SUBACK packet. */ for( i = 0; i < statusCount; i++ ) @@ -226,7 +226,7 @@ size_t _IotMqtt_GetRemainingLength( IotNetworkConnection_t pNetworkConnection, const IotNetworkInterface_t * pNetworkInterface ) { uint8_t encodedByte = 0; - size_t remainingLength = 0, multiplier = 1, bytesDecoded = 0, expectedSize = 0; + size_t remainingLength = 0, multiplier = 1, bytesDecoded = 0, expectedSize = 0; /* This algorithm is copied from the MQTT v3.1.1 spec. */ do @@ -242,7 +242,7 @@ size_t _IotMqtt_GetRemainingLength( IotNetworkConnection_t pNetworkConnection, &encodedByte ) == true ) { remainingLength += ( ( size_t ) encodedByte & 0x7FU ) * multiplier; - multiplier *= 128U; + multiplier *= 128U; bytesDecoded++; } else @@ -283,8 +283,8 @@ IotMqttError_t _IotMqtt_SerializeConnect( const IotMqttConnectInfo_t * pConnectI size_t * pPacketSize ) { IotMqttError_t status = IOT_MQTT_SUCCESS; - size_t remainingLength = 0, connectPacketSize = 0; - uint8_t * pBuffer = NULL; + size_t remainingLength = 0, connectPacketSize = 0; + uint8_t * pBuffer = NULL; /* Calculate the "Remaining length" field and total packet size. If it exceeds * what is allowed in the MQTT standard, return an error. */ @@ -317,7 +317,7 @@ IotMqttError_t _IotMqtt_SerializeConnect( const IotMqttConnectInfo_t * pConnectI { /* Set the output parameters. The remainder of this function always succeeds. */ *pConnectPacket = pBuffer; - *pPacketSize = connectPacketSize; + *pPacketSize = connectPacketSize; _IotMqtt_SerializeConnectCommon( pConnectInfo, remainingLength, pBuffer, connectPacketSize ); } @@ -330,8 +330,8 @@ IotMqttError_t _IotMqtt_SerializeConnect( const IotMqttConnectInfo_t * pConnectI IotMqttError_t _IotMqtt_DeserializeConnack( _mqttPacket_t * pConnack ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; - const uint8_t * pRemainingData = pConnack->pRemainingData; + IotMqttError_t status = IOT_MQTT_SUCCESS; + const uint8_t * pRemainingData = pConnack->pRemainingData; /* If logging is enabled, declare the CONNACK response code strings. The * fourth byte of CONNACK indexes into this array for the corresponding response. */ @@ -449,8 +449,8 @@ IotMqttError_t _IotMqtt_SerializePublish( const IotMqttPublishInfo_t * pPublishI uint8_t ** pPacketIdentifierHigh ) { IotMqttError_t status = IOT_MQTT_SUCCESS; - size_t remainingLength = 0, publishPacketSize = 0; - uint8_t * pBuffer = NULL; + size_t remainingLength = 0, publishPacketSize = 0; + uint8_t * pBuffer = NULL; /* Calculate the "Remaining length" field and total packet size. If it exceeds * what is allowed in the MQTT standard, return an error. */ @@ -483,7 +483,7 @@ IotMqttError_t _IotMqtt_SerializePublish( const IotMqttPublishInfo_t * pPublishI { /* Set the output parameters. The remainder of this function always succeeds. */ *pPublishPacket = pBuffer; - *pPacketSize = publishPacketSize; + *pPacketSize = publishPacketSize; /* Serialize publish into buffer pointed to by pBuffer */ _IotMqtt_SerializePublishCommon( pPublishInfo, @@ -513,16 +513,16 @@ void _IotMqtt_PublishSetDup( uint8_t * pPublishPacket, IotMqtt_Assert( pNewPacketIdentifier != NULL ); /* Generate a new packet identifier. */ - newPacketIdentifier = _IotMqtt_NextPacketIdentifier(); + newPacketIdentifier = _IotMqtt_NextPacketIdentifier(); IotLogDebug( "Changing PUBLISH packet identifier %hu to %hu.", UINT16_DECODE( pPacketIdentifierHigh ), newPacketIdentifier ); /* Replace the packet identifier. */ - *pPacketIdentifierHigh = UINT16_HIGH_BYTE( newPacketIdentifier ); + *pPacketIdentifierHigh = UINT16_HIGH_BYTE( newPacketIdentifier ); *( pPacketIdentifierHigh + 1 ) = UINT16_LOW_BYTE( newPacketIdentifier ); - *pNewPacketIdentifier = newPacketIdentifier; + *pNewPacketIdentifier = newPacketIdentifier; } else { @@ -537,15 +537,15 @@ void _IotMqtt_PublishSetDup( uint8_t * pPublishPacket, IotMqttError_t _IotMqtt_DeserializePublish( _mqttPacket_t * pPublish ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; + IotMqttError_t status = IOT_MQTT_SUCCESS; IotMqttPublishInfo_t * pOutput = &( pPublish->u.pIncomingPublish->u.publish.publishInfo ); - uint8_t publishFlags = 0; - const uint8_t * pVariableHeader = pPublish->pRemainingData, * pPacketIdentifierHigh = NULL; + uint8_t publishFlags = 0; + const uint8_t * pVariableHeader = pPublish->pRemainingData, * pPacketIdentifierHigh = NULL; /* The flags are the lower 4 bits of the first byte in PUBLISH. */ publishFlags = pPublish->type; - status = _IotMqtt_ProcessPublishFlags( publishFlags, pOutput ); + status = _IotMqtt_ProcessPublishFlags( publishFlags, pOutput ); if( status == IOT_MQTT_SUCCESS ) { @@ -565,15 +565,15 @@ IotMqttError_t _IotMqtt_DeserializePublish( _mqttPacket_t * pPublish ) /* Sanity checks for topic name length and "Remaining length". The remaining * length must be at least as large as the variable length header. */ - status = _checkRemainingLength( pPublish, - pOutput->qos, - pOutput->topicNameLength + sizeof( uint16_t ) ); + status = _checkRemainingLength( pPublish, + pOutput->qos, + pOutput->topicNameLength + sizeof( uint16_t ) ); } if( status == IOT_MQTT_SUCCESS ) { /* Parse the topic. */ - pOutput->pTopicName = ( const char * ) ( pVariableHeader + sizeof( uint16_t ) ); + pOutput->pTopicName = ( const char * ) ( pVariableHeader + sizeof( uint16_t ) ); IotLog( IOT_LOG_DEBUG, &_logHideAll, @@ -609,12 +609,12 @@ IotMqttError_t _IotMqtt_DeserializePublish( _mqttPacket_t * pPublish ) if( pOutput->qos == IOT_MQTT_QOS_0 ) { pOutput->payloadLength = ( pPublish->remainingLength - pOutput->topicNameLength - sizeof( uint16_t ) ); - pOutput->pPayload = pPacketIdentifierHigh; + pOutput->pPayload = pPacketIdentifierHigh; } else { pOutput->payloadLength = ( pPublish->remainingLength - pOutput->topicNameLength - 2U * sizeof( uint16_t ) ); - pOutput->pPayload = pPacketIdentifierHigh + sizeof( uint16_t ); + pOutput->pPayload = pPacketIdentifierHigh + sizeof( uint16_t ); } IotLog( IOT_LOG_DEBUG, @@ -631,10 +631,10 @@ IotMqttError_t _IotMqtt_SerializePuback( uint16_t packetIdentifier, uint8_t ** pPubackPacket, size_t * pPacketSize ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; + IotMqttError_t status = IOT_MQTT_SUCCESS; /* Allocate memory for PUBACK. */ - uint8_t * pBuffer = IotMqtt_MallocMessage( MQTT_PACKET_PUBACK_SIZE ); + uint8_t * pBuffer = IotMqtt_MallocMessage( MQTT_PACKET_PUBACK_SIZE ); if( pBuffer == NULL ) { @@ -646,13 +646,13 @@ IotMqttError_t _IotMqtt_SerializePuback( uint16_t packetIdentifier, { /* Set the output parameters. The remainder of this function always succeeds. */ *pPubackPacket = pBuffer; - *pPacketSize = MQTT_PACKET_PUBACK_SIZE; + *pPacketSize = MQTT_PACKET_PUBACK_SIZE; /* Set the 4 bytes in PUBACK. */ - pBuffer[ 0 ] = MQTT_PACKET_TYPE_PUBACK; - pBuffer[ 1 ] = MQTT_PACKET_PUBACK_REMAINING_LENGTH; - pBuffer[ 2 ] = UINT16_HIGH_BYTE( packetIdentifier ); - pBuffer[ 3 ] = UINT16_LOW_BYTE( packetIdentifier ); + pBuffer[ 0 ] = MQTT_PACKET_TYPE_PUBACK; + pBuffer[ 1 ] = MQTT_PACKET_PUBACK_REMAINING_LENGTH; + pBuffer[ 2 ] = UINT16_HIGH_BYTE( packetIdentifier ); + pBuffer[ 3 ] = UINT16_LOW_BYTE( packetIdentifier ); /* Print out the serialized PUBACK packet for debugging purposes. */ IotLog_PrintBuffer( "MQTT PUBACK packet:", *pPubackPacket, MQTT_PACKET_PUBACK_SIZE ); @@ -719,8 +719,8 @@ IotMqttError_t _IotMqtt_SerializeSubscribe( const IotMqttSubscription_t * pSubsc uint16_t * pPacketIdentifier ) { IotMqttError_t status = IOT_MQTT_SUCCESS; - size_t subscribePacketSize = 0, remainingLength = 0; - uint8_t * pBuffer = NULL; + size_t subscribePacketSize = 0, remainingLength = 0; + uint8_t * pBuffer = NULL; /* Calculate the "Remaining length" field and total packet size. If it exceeds * what is allowed in the MQTT standard, return an error. */ @@ -756,7 +756,7 @@ IotMqttError_t _IotMqtt_SerializeSubscribe( const IotMqttSubscription_t * pSubsc { /* Set the output parameters. The remainder of this function always succeeds. */ *pSubscribePacket = pBuffer; - *pPacketSize = subscribePacketSize; + *pPacketSize = subscribePacketSize; /* Serialize subscribe into buffer pointed to by pBuffer */ _IotMqtt_SerializeSubscribeCommon( pSubscriptionList, @@ -775,8 +775,8 @@ IotMqttError_t _IotMqtt_SerializeSubscribe( const IotMqttSubscription_t * pSubsc IotMqttError_t _IotMqtt_DeserializeSuback( _mqttPacket_t * pSuback ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; - size_t remainingLength = pSuback->remainingLength; + IotMqttError_t status = IOT_MQTT_SUCCESS; + size_t remainingLength = pSuback->remainingLength; const uint8_t * pVariableHeader = pSuback->pRemainingData; /* A SUBACK must have a remaining length of at least 3 to accommodate the @@ -829,8 +829,8 @@ IotMqttError_t _IotMqtt_SerializeUnsubscribe( const IotMqttSubscription_t * pSub uint16_t * pPacketIdentifier ) { IotMqttError_t status = IOT_MQTT_SUCCESS; - size_t unsubscribePacketSize = 0, remainingLength = 0; - uint8_t * pBuffer = NULL; + size_t unsubscribePacketSize = 0, remainingLength = 0; + uint8_t * pBuffer = NULL; /* Calculate the "Remaining length" field and total packet size. If it exceeds * what is allowed in the MQTT standard, return an error. */ @@ -866,7 +866,7 @@ IotMqttError_t _IotMqtt_SerializeUnsubscribe( const IotMqttSubscription_t * pSub { /* Set the output parameters. The remainder of this function always succeeds. */ *pUnsubscribePacket = pBuffer; - *pPacketSize = unsubscribePacketSize; + *pPacketSize = unsubscribePacketSize; /* Serialize unsubscribe into buffer pointed to by pBuffer */ _IotMqtt_SerializeUnsubscribeCommon( pSubscriptionList, @@ -950,7 +950,7 @@ IotMqttError_t _IotMqtt_SerializePingreq( uint8_t ** pPingreqPacket, /* Set the output parameters. */ *pPingreqPacket = ( uint8_t * ) pPingreq; - *pPacketSize = MQTT_PACKET_PINGREQ_SIZE; + *pPacketSize = MQTT_PACKET_PINGREQ_SIZE; /* Print out the PINGREQ packet for debugging purposes. */ IotLog_PrintBuffer( "MQTT PINGREQ packet:", pPingreq, MQTT_PACKET_PINGREQ_SIZE ); @@ -1011,7 +1011,7 @@ IotMqttError_t _IotMqtt_SerializeDisconnect( uint8_t ** pDisconnectPacket, /* Set the output parameters. */ *pDisconnectPacket = ( uint8_t * ) pDisconnect; - *pPacketSize = MQTT_PACKET_DISCONNECT_SIZE; + *pPacketSize = MQTT_PACKET_DISCONNECT_SIZE; /* Print out the DISCONNECT packet for debugging purposes. */ IotLog_PrintBuffer( "MQTT DISCONNECT packet:", pDisconnect, MQTT_PACKET_DISCONNECT_SIZE ); diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_static_memory.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_static_memory.c index 57ed52b7d..20da385f9 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_static_memory.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_static_memory.c @@ -85,21 +85,21 @@ /* * Static memory buffers and flags, allocated and zeroed at compile-time. */ - static uint32_t _pInUseMqttConnections[ IOT_MQTT_CONNECTIONS ]; /**< @brief MQTT connection in-use flags. */ - static _mqttConnection_t _pMqttConnections[ IOT_MQTT_CONNECTIONS ]; /**< @brief MQTT connections. */ + static uint32_t _pInUseMqttConnections[ IOT_MQTT_CONNECTIONS ]; /**< @brief MQTT connection in-use flags. */ + static _mqttConnection_t _pMqttConnections[ IOT_MQTT_CONNECTIONS ]; /**< @brief MQTT connections. */ - static uint32_t _pInUseMqttOperations[ IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS ]; /**< @brief MQTT operation in-use flags. */ - static _mqttOperation_t _pMqttOperations[ IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS ]; /**< @brief MQTT operations. */ + static uint32_t _pInUseMqttOperations[ IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS ]; /**< @brief MQTT operation in-use flags. */ + static _mqttOperation_t _pMqttOperations[ IOT_MQTT_MAX_IN_PROGRESS_OPERATIONS ]; /**< @brief MQTT operations. */ - static uint32_t _pInUseMqttSubscriptions[ IOT_MQTT_SUBSCRIPTIONS ]; /**< @brief MQTT subscription in-use flags. */ - static char _pMqttSubscriptions[ IOT_MQTT_SUBSCRIPTIONS ][ MQTT_SUBSCRIPTION_SIZE ]; /**< @brief MQTT subscriptions. */ + static uint32_t _pInUseMqttSubscriptions[ IOT_MQTT_SUBSCRIPTIONS ]; /**< @brief MQTT subscription in-use flags. */ + static char _pMqttSubscriptions[ IOT_MQTT_SUBSCRIPTIONS ][ MQTT_SUBSCRIPTION_SIZE ]; /**< @brief MQTT subscriptions. */ /*-----------------------------------------------------------*/ void * IotMqtt_MallocConnection( size_t size ) { - int32_t freeIndex = -1; - void * pNewConnection = NULL; + int32_t freeIndex = -1; + void * pNewConnection = NULL; /* Check size argument. */ if( size == sizeof( _mqttConnection_t ) ) @@ -133,8 +133,8 @@ void * IotMqtt_MallocOperation( size_t size ) { - int32_t freeIndex = -1; - void * pNewOperation = NULL; + int32_t freeIndex = -1; + void * pNewOperation = NULL; /* Check size argument. */ if( size == sizeof( _mqttOperation_t ) ) @@ -168,8 +168,8 @@ void * IotMqtt_MallocSubscription( size_t size ) { - int32_t freeIndex = -1; - void * pNewSubscription = NULL; + int32_t freeIndex = -1; + void * pNewSubscription = NULL; if( size <= MQTT_SUBSCRIPTION_SIZE ) { diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_subscription.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_subscription.c index c2d2a7b17..37b6c6384 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_subscription.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_subscription.c @@ -210,14 +210,14 @@ static bool _matchWildcards( const char * pTopicFilter, /* Subsequent characters don't need to be checked for the * multi-level wildcard. */ *pMatch = true; - status = true; + status = true; } else { /* Any character mismatch other than '+' or '#' means the topic * name does not match the topic filter. */ *pMatch = false; - status = true; + status = true; } return status; @@ -230,7 +230,7 @@ static bool _topicFilterMatch( const char * pTopicName, const char * pTopicFilter, uint16_t topicFilterLength ) { - bool status = false, matchFound = false; + bool status = false, matchFound = false; uint16_t nameIndex = 0, filterIndex = 0; while( ( nameIndex < topicNameLength ) && ( filterIndex < topicFilterLength ) ) @@ -283,7 +283,7 @@ static bool _topicFilterMatch( const char * pTopicName, static bool _topicMatch( const IotLink_t * const pSubscriptionLink, void * pMatch ) { - bool status = false; + bool status = false; /* This function is called from a container function; the caller * will never pass NULL. */ @@ -296,16 +296,16 @@ static bool _topicMatch( const IotLink_t * const pSubscriptionLink, /* coverity[misra_c_2012_rule_11_8_violation] */ /* coverity[misra_c_2012_rule_20_7_violation] */ /* coverity[caretline] */ - const _mqttSubscription_t * pSubscription = IotLink_Container( _mqttSubscription_t, - pSubscriptionLink, - link ); - const _topicMatchParams_t * pParam = ( _topicMatchParams_t * ) pMatch; + const _mqttSubscription_t * pSubscription = IotLink_Container( _mqttSubscription_t, + pSubscriptionLink, + link ); + const _topicMatchParams_t * pParam = ( _topicMatchParams_t * ) pMatch; /* Extract the relevant strings and lengths from parameters. */ - const char * pTopicName = pParam->pTopicName; - const char * pTopicFilter = pSubscription->pTopicFilter; - const uint16_t topicNameLength = pParam->topicNameLength; - const uint16_t topicFilterLength = pSubscription->topicFilterLength; + const char * pTopicName = pParam->pTopicName; + const char * pTopicFilter = pSubscription->pTopicFilter; + const uint16_t topicNameLength = pParam->topicNameLength; + const uint16_t topicFilterLength = pSubscription->topicFilterLength; /* Check for an exact match. */ if( topicNameLength == topicFilterLength ) @@ -328,7 +328,7 @@ static bool _topicMatch( const IotLink_t * const pSubscriptionLink, static bool _packetMatch( const IotLink_t * const pSubscriptionLink, void * pMatch ) { - bool match = false; + bool match = false; /* Because this function is called from a container function, the given link * must never be NULL. */ @@ -341,10 +341,10 @@ static bool _packetMatch( const IotLink_t * const pSubscriptionLink, /* coverity[misra_c_2012_rule_11_8_violation] */ /* coverity[misra_c_2012_rule_20_7_violation] */ /* coverity[caretline] */ - _mqttSubscription_t * pSubscription = IotLink_Container( _mqttSubscription_t, - pSubscriptionLink, - link ); - const _packetMatchParams_t * pParam = ( _packetMatchParams_t * ) pMatch; + _mqttSubscription_t * pSubscription = IotLink_Container( _mqttSubscription_t, + pSubscriptionLink, + link ); + const _packetMatchParams_t * pParam = ( _packetMatchParams_t * ) pMatch; /* Compare packet identifiers. */ if( pParam->packetIdentifier == pSubscription->packetInfo.identifier ) @@ -370,7 +370,7 @@ static bool _packetMatch( const IotLink_t * const pSubscriptionLink, * removed yet because there are subscription callbacks using it. */ if( pSubscription->references > 0 ) { - match = false; + match = false; /* Set the unsubscribed flag. The last active subscription callback * will remove and clean up this subscription. */ @@ -388,23 +388,23 @@ IotMqttError_t _IotMqtt_AddSubscriptions( _mqttConnection_t * pMqttConnection, const IotMqttSubscription_t * pSubscriptionList, size_t subscriptionCount ) { - IotMqttError_t status = IOT_MQTT_SUCCESS; - size_t i = 0; - _mqttSubscription_t * pNewSubscription = NULL; - IotLink_t * pSubscriptionLink = NULL; - _topicMatchParams_t topicMatchParams = { .exactMatchOnly = true }; + IotMqttError_t status = IOT_MQTT_SUCCESS; + size_t i = 0; + _mqttSubscription_t * pNewSubscription = NULL; + IotLink_t * pSubscriptionLink = NULL; + _topicMatchParams_t topicMatchParams = { .exactMatchOnly = true }; IotMutex_Lock( &( pMqttConnection->subscriptionMutex ) ); for( i = 0; i < subscriptionCount; i++ ) { /* Check if this topic filter is already registered. */ - topicMatchParams.pTopicName = pSubscriptionList[ i ].pTopicFilter; + topicMatchParams.pTopicName = pSubscriptionList[ i ].pTopicFilter; topicMatchParams.topicNameLength = pSubscriptionList[ i ].topicFilterLength; - pSubscriptionLink = IotListDouble_FindFirstMatch( &( pMqttConnection->subscriptionList ), - NULL, - _topicMatch, - &topicMatchParams ); + pSubscriptionLink = IotListDouble_FindFirstMatch( &( pMqttConnection->subscriptionList ), + NULL, + _topicMatch, + &topicMatchParams ); if( pSubscriptionLink != NULL ) { @@ -412,21 +412,21 @@ IotMqttError_t _IotMqtt_AddSubscriptions( _mqttConnection_t * pMqttConnection, * because it uses type-casting and offsetof, and would cause compiling errors. */ /* coverity[misra_c_2012_rule_20_7_violation] */ /* coverity[caretline] */ - pNewSubscription = IotLink_Container( _mqttSubscription_t, pSubscriptionLink, link ); + pNewSubscription = IotLink_Container( _mqttSubscription_t, pSubscriptionLink, link ); /* The lengths of exactly matching topic filters must match. */ IotMqtt_Assert( pNewSubscription->topicFilterLength == pSubscriptionList[ i ].topicFilterLength ); /* Replace the callback and packet info with the new parameters. */ - pNewSubscription->callback = pSubscriptionList[ i ].callback; + pNewSubscription->callback = pSubscriptionList[ i ].callback; pNewSubscription->packetInfo.identifier = subscribePacketIdentifier; - pNewSubscription->packetInfo.order = i; + pNewSubscription->packetInfo.order = i; } else { /* Allocate memory for a new subscription. */ - pNewSubscription = IotMqtt_MallocSubscription( sizeof( _mqttSubscription_t ) + - pSubscriptionList[ i ].topicFilterLength ); + pNewSubscription = IotMqtt_MallocSubscription( sizeof( _mqttSubscription_t ) + + pSubscriptionList[ i ].topicFilterLength ); if( pNewSubscription == NULL ) { @@ -441,9 +441,9 @@ IotMqttError_t _IotMqtt_AddSubscriptions( _mqttConnection_t * pMqttConnection, /* Set the members of the new subscription and add it to the list. */ pNewSubscription->packetInfo.identifier = subscribePacketIdentifier; - pNewSubscription->packetInfo.order = i; - pNewSubscription->callback = pSubscriptionList[ i ].callback; - pNewSubscription->topicFilterLength = pSubscriptionList[ i ].topicFilterLength; + pNewSubscription->packetInfo.order = i; + pNewSubscription->callback = pSubscriptionList[ i ].callback; + pNewSubscription->topicFilterLength = pSubscriptionList[ i ].topicFilterLength; ( void ) memcpy( pNewSubscription->pTopicFilter, pSubscriptionList[ i ].pTopicFilter, ( size_t ) ( pSubscriptionList[ i ].topicFilterLength ) ); @@ -472,17 +472,17 @@ void _IotMqtt_InvokeSubscriptionCallback( _mqttConnection_t * pMqttConnection, IotMqttCallbackParam_t * pCallbackParam ) { _mqttSubscription_t * pSubscription = NULL; - IotLink_t * pCurrentLink = NULL, * pNextLink = NULL; - void * pCallbackContext = NULL; + IotLink_t * pCurrentLink = NULL, * pNextLink = NULL; + void * pCallbackContext = NULL; - void ( * callbackFunction )( void * pContext, - IotMqttCallbackParam_t * pParam ) = NULL; - _topicMatchParams_t topicMatchParams = { 0 }; + void ( * callbackFunction )( void * pContext, + IotMqttCallbackParam_t * pParam ) = NULL; + _topicMatchParams_t topicMatchParams = { 0 }; /* Set the members of the search parameter. */ - topicMatchParams.pTopicName = pCallbackParam->u.message.info.pTopicName; + topicMatchParams.pTopicName = pCallbackParam->u.message.info.pTopicName; topicMatchParams.topicNameLength = pCallbackParam->u.message.info.topicNameLength; - topicMatchParams.exactMatchOnly = false; + topicMatchParams.exactMatchOnly = false; /* Prevent any other thread from modifying the subscription list while this * function is searching. */ @@ -492,10 +492,10 @@ void _IotMqtt_InvokeSubscriptionCallback( _mqttConnection_t * pMqttConnection, * the list head. */ while( true ) { - pCurrentLink = IotListDouble_FindFirstMatch( &( pMqttConnection->subscriptionList ), - pCurrentLink, - _topicMatch, - &topicMatchParams ); + pCurrentLink = IotListDouble_FindFirstMatch( &( pMqttConnection->subscriptionList ), + pCurrentLink, + _topicMatch, + &topicMatchParams ); /* No subscription found. Exit loop. */ if( pCurrentLink == NULL ) @@ -509,7 +509,7 @@ void _IotMqtt_InvokeSubscriptionCallback( _mqttConnection_t * pMqttConnection, * because it uses type-casting and offsetof, and would cause compiling errors. */ /* coverity[misra_c_2012_rule_20_7_violation] */ /* coverity[caretline] */ - pSubscription = IotLink_Container( _mqttSubscription_t, pCurrentLink, link ); + pSubscription = IotLink_Container( _mqttSubscription_t, pCurrentLink, link ); /* Subscription validation should not have allowed a NULL callback function. */ IotMqtt_Assert( pSubscription->callback.function != NULL ); @@ -519,15 +519,15 @@ void _IotMqtt_InvokeSubscriptionCallback( _mqttConnection_t * pMqttConnection, /* Copy the necessary members of the subscription before releasing the * subscription list mutex. */ - pCallbackContext = pSubscription->callback.pCallbackContext; - callbackFunction = pSubscription->callback.function; + pCallbackContext = pSubscription->callback.pCallbackContext; + callbackFunction = pSubscription->callback.function; /* Unlock the subscription list mutex. */ IotMutex_Unlock( &( pMqttConnection->subscriptionMutex ) ); /* Set the members of the callback parameter. */ - pCallbackParam->mqttConnection = pMqttConnection; - pCallbackParam->u.message.pTopicFilter = pSubscription->pTopicFilter; + pCallbackParam->mqttConnection = pMqttConnection; + pCallbackParam->u.message.pTopicFilter = pSubscription->pTopicFilter; pCallbackParam->u.message.topicFilterLength = pSubscription->topicFilterLength; /* Invoke the subscription callback. */ @@ -541,7 +541,7 @@ void _IotMqtt_InvokeSubscriptionCallback( _mqttConnection_t * pMqttConnection, IotMqtt_Assert( pSubscription->references >= 0 ); /* Save the pointer to the next link in case this subscription is freed. */ - pNextLink = pCurrentLink->pNext; + pNextLink = pCurrentLink->pNext; /* Remove this subscription if it has no references and the unsubscribed * flag is set. */ @@ -558,7 +558,7 @@ void _IotMqtt_InvokeSubscriptionCallback( _mqttConnection_t * pMqttConnection, } /* Move current link pointer. */ - pCurrentLink = pNextLink; + pCurrentLink = pNextLink; } IotMutex_Unlock( &( pMqttConnection->subscriptionMutex ) ); @@ -576,7 +576,7 @@ void _IotMqtt_RemoveSubscriptionByPacket( _mqttConnection_t * pMqttConnection, /* Set the members of the search parameter. */ packetMatchParams.packetIdentifier = packetIdentifier; - packetMatchParams.order = order; + packetMatchParams.order = order; IotMutex_Lock( &( pMqttConnection->subscriptionMutex ) ); IotListDouble_RemoveAllMatches( &( pMqttConnection->subscriptionList ), @@ -593,10 +593,10 @@ void _IotMqtt_RemoveSubscriptionByTopicFilter( _mqttConnection_t * pMqttConnecti const IotMqttSubscription_t * pSubscriptionList, size_t subscriptionCount ) { - size_t i = 0; - _mqttSubscription_t * pSubscription = NULL; - IotLink_t * pSubscriptionLink = NULL; - _topicMatchParams_t topicMatchParams = { 0 }; + size_t i = 0; + _mqttSubscription_t * pSubscription = NULL; + IotLink_t * pSubscriptionLink = NULL; + _topicMatchParams_t topicMatchParams = { 0 }; /* Prevent any other thread from modifying the subscription list while this * function is running. */ @@ -605,14 +605,14 @@ void _IotMqtt_RemoveSubscriptionByTopicFilter( _mqttConnection_t * pMqttConnecti /* Find and remove each topic filter from the list. */ for( i = 0; i < subscriptionCount; i++ ) { - topicMatchParams.pTopicName = pSubscriptionList[ i ].pTopicFilter; + topicMatchParams.pTopicName = pSubscriptionList[ i ].pTopicFilter; topicMatchParams.topicNameLength = pSubscriptionList[ i ].topicFilterLength; - topicMatchParams.exactMatchOnly = true; + topicMatchParams.exactMatchOnly = true; - pSubscriptionLink = IotListDouble_FindFirstMatch( &( pMqttConnection->subscriptionList ), - NULL, - _topicMatch, - &topicMatchParams ); + pSubscriptionLink = IotListDouble_FindFirstMatch( &( pMqttConnection->subscriptionList ), + NULL, + _topicMatch, + &topicMatchParams ); if( pSubscriptionLink != NULL ) { @@ -654,25 +654,25 @@ bool IotMqtt_IsSubscribed( IotMqttConnection_t mqttConnection, uint16_t topicFilterLength, IotMqttSubscription_t * const pCurrentSubscription ) { - bool status = false; - const _mqttSubscription_t * pSubscription = NULL; - const IotLink_t * pSubscriptionLink = NULL; - _topicMatchParams_t topicMatchParams = { 0 }; + bool status = false; + const _mqttSubscription_t * pSubscription = NULL; + const IotLink_t * pSubscriptionLink = NULL; + _topicMatchParams_t topicMatchParams = { 0 }; /* Set the members of the search parameter. */ - topicMatchParams.pTopicName = pTopicFilter; + topicMatchParams.pTopicName = pTopicFilter; topicMatchParams.topicNameLength = topicFilterLength; - topicMatchParams.exactMatchOnly = true; + topicMatchParams.exactMatchOnly = true; /* Prevent any other thread from modifying the subscription list while this * function is running. */ IotMutex_Lock( &( mqttConnection->subscriptionMutex ) ); /* Search for a matching subscription. */ - pSubscriptionLink = IotListDouble_FindFirstMatch( &( mqttConnection->subscriptionList ), - NULL, - _topicMatch, - &topicMatchParams ); + pSubscriptionLink = IotListDouble_FindFirstMatch( &( mqttConnection->subscriptionList ), + NULL, + _topicMatch, + &topicMatchParams ); /* Check if a matching subscription was found. */ if( pSubscriptionLink != NULL ) @@ -689,13 +689,13 @@ bool IotMqtt_IsSubscribed( IotMqttConnection_t mqttConnection, /* Copy the matching subscription to the output parameter. */ if( pCurrentSubscription != NULL ) { - pCurrentSubscription->pTopicFilter = pTopicFilter; + pCurrentSubscription->pTopicFilter = pTopicFilter; pCurrentSubscription->topicFilterLength = topicFilterLength; - pCurrentSubscription->qos = IOT_MQTT_QOS_0; - pCurrentSubscription->callback = pSubscription->callback; + pCurrentSubscription->qos = IOT_MQTT_QOS_0; + pCurrentSubscription->callback = pSubscription->callback; } - status = true; + status = true; } IotMutex_Unlock( &( mqttConnection->subscriptionMutex ) ); diff --git a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_validate.c b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_validate.c index cb8434799..cdcca62f0 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_validate.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-IoT-Libraries-LTS-Beta1/c_sdk/standard/mqtt/src/iot_mqtt_validate.c @@ -348,8 +348,8 @@ static bool _validateSubscription( bool awsIotMqttMode, IotMqttOperationType_t operation, const IotMqttSubscription_t * pSubscription ) { - bool status = true; - uint16_t i = 0; + bool status = true; + uint16_t i = 0; /* Check for a valid QoS and callback function when subscribing. */ if( operation == IOT_MQTT_SUBSCRIBE ) @@ -499,9 +499,9 @@ static bool _validateWildcardHash( uint16_t index, static bool _validateClientId( const IotMqttConnectInfo_t * pConnectInfo ) { - bool status = true; - uint16_t maxClientIdLength = MQTT_SERVER_MAX_CLIENTID_LENGTH; - bool enforceMaxClientIdLength = false; + bool status = true; + uint16_t maxClientIdLength = MQTT_SERVER_MAX_CLIENTID_LENGTH; + bool enforceMaxClientIdLength = false; /* Check that a client identifier was set. */ if( pConnectInfo->pClientIdentifier == NULL ) @@ -531,7 +531,7 @@ static bool _validateClientId( const IotMqttConnectInfo_t * pConnectInfo ) /* The AWS IoT MQTT service enforces a client ID length limit. */ if( pConnectInfo->awsIotMqttMode == true ) { - maxClientIdLength = AWS_IOT_MQTT_SERVER_MAX_CLIENTID_LENGTH; + maxClientIdLength = AWS_IOT_MQTT_SERVER_MAX_CLIENTID_LENGTH; enforceMaxClientIdLength = true; } @@ -635,7 +635,7 @@ bool _IotMqtt_ValidatePublish( bool awsIotMqttMode, const IotMqttCallbackInfo_t * pCallbackInfo, const IotMqttOperation_t * const pPublishOperation ) { - bool status = true; + bool status = true; size_t maximumPayloadLength = MQTT_SERVER_MAX_PUBLISH_PAYLOAD_LENGTH; if( awsIotMqttMode == true ) @@ -736,8 +736,8 @@ bool _IotMqtt_ValidateSubscriptionList( IotMqttOperationType_t operation, const IotMqttSubscription_t * pListStart, size_t listSize ) { - bool status = true; - size_t i = 0; + bool status = true; + size_t i = 0; /* Operation must be either subscribe or unsubscribe. */ IotMqtt_Assert( ( operation == IOT_MQTT_SUBSCRIBE ) || diff --git a/tools/uncrustify.cfg b/tools/uncrustify.cfg index bfd147d54..0cb7d3fbd 100644 --- a/tools/uncrustify.cfg +++ b/tools/uncrustify.cfg @@ -157,11 +157,4 @@ pp_indent_at_level = true # false/true pp_indent_count = 4 # unsigned number pp_space = remove # ignore/add/remove/force pp_if_indent_code = true # false/true - -align_var_def_span = 4 # align variable name and type -align_assign_span = 80 -align_var_def_gap = 1 # space between type and variable name -align_assign_thresh = 40 # align up to a certain size - - # option(s) with 'not default' value: 158 |