Skip to content

Commit aa33699

Browse files
committed
Update coding style and comments
Update coding style and comments
1 parent fe7eb3f commit aa33699

11 files changed

Lines changed: 267 additions & 67 deletions

source/MutualAuthMQTTExample.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146

147147
/**
148148
* @brief Time in ticks to wait between each cycle of the demo implemented
149-
* by prvMQTTDemoTask().
149+
* by RunMQTTTask().
150150
*/
151151
#define mqttexampleDELAY_BETWEEN_DEMO_ITERATIONS_TICKS ( pdMS_TO_TICKS( 5000U ) )
152152

@@ -256,7 +256,7 @@
256256
* @param[in] pvParameters Parameters as passed at the time of task creation. Not
257257
* used in this example.
258258
*/
259-
void MQTTDemoTask( void * pvParameters );
259+
void RunMQTTTask( void * pvParameters );
260260

261261
/**
262262
* @brief Connect to MQTT broker with reconnection retries.
@@ -427,7 +427,7 @@ static MQTTFixedBuffer_t xBuffer =
427427
* subscribed to, so it will expect all the messages it sends to the broker to be
428428
* sent back to it from the broker.
429429
*/
430-
void MQTTDemoTask( void * pvParameters )
430+
void RunMQTTTask( void * pvParameters )
431431
{
432432
uint32_t ulPublishCount = 0U, ulTopicCount = 0U;
433433
const uint32_t ulMaxPublishCount = 5UL;
@@ -522,7 +522,7 @@ void MQTTDemoTask( void * pvParameters )
522522

523523
/* Wait for some time between two iterations to ensure that we do not
524524
* bombard the broker. */
525-
LogInfo( ( "prvMQTTDemoTask() completed an iteration successfully. "
525+
LogInfo( ( "RunMQTTTask() completed an iteration successfully. "
526526
"Total free heap is %u.\r\n",
527527
xPortGetFreeHeapSize() ) );
528528
LogInfo( ( "Demo completed successfully.\r\n" ) );

source/cellular/bg96/cellular_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
/**
3838
* Cellular comm interface make use of COM port on computer to communicate with
3939
* cellular module on windows simulator, for example "COM5".
40-
* #define CELLULAR_COMM_INTERFACE_PORT "...insert here..."
40+
* #define CELLULAR_COMM_INTERFACE_PORT "...insert here..."
4141
*/
4242

4343
/*

source/cellular/cellular_platform.c

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static void prvThreadRoutineWrapper( void * pArgument );
5151
* @brief Lock mutex with timeout.
5252
*
5353
* @param[in] pMutex Mutex to lock.
54-
* @param[in] timeout timeout value to lock mutex.
54+
* @param[in] timeout Timeout value to lock mutex.
5555
*
5656
* @return ture if mutex is locked successfully. Otherwise false.
5757
*/
@@ -76,7 +76,7 @@ static void prvThreadRoutineWrapper( void * pArgument )
7676
static bool prIotMutexTimedLock( PlatformMutex_t * pMutex,
7777
TickType_t timeout )
7878
{
79-
BaseType_t lockResult;
79+
BaseType_t lockResult = pdTRUE;
8080

8181
configASSERT( pMutex != NULL );
8282

@@ -103,11 +103,13 @@ bool Platform_CreateDetachedThread( void ( *threadRoutine )( void * ),
103103
size_t stackSize )
104104
{
105105
bool status = true;
106+
threadInfo_t * pThreadInfo = NULL;
106107

107108
configASSERT( threadRoutine != NULL );
108109

109110
CellularLogDebug( "Creating new thread." );
110-
threadInfo_t * pThreadInfo = Platform_Malloc( sizeof( threadInfo_t ) );
111+
112+
pThreadInfo = Platform_Malloc( sizeof( threadInfo_t ) );
111113

112114
if( pThreadInfo == NULL )
113115
{
@@ -116,7 +118,7 @@ bool Platform_CreateDetachedThread( void ( *threadRoutine )( void * ),
116118
}
117119

118120
/* Create the FreeRTOS task that will run the thread. */
119-
if( status )
121+
if( status == true )
120122
{
121123
pThreadInfo->threadRoutine = threadRoutine;
122124
pThreadInfo->pArgument = pArgument;
@@ -133,6 +135,10 @@ bool Platform_CreateDetachedThread( void ( *threadRoutine )( void * ),
133135
Platform_Free( pThreadInfo );
134136
status = false;
135137
}
138+
else
139+
{
140+
CellularLogDebug( "New thread created." );
141+
}
136142
}
137143

138144
return status;
@@ -143,21 +149,24 @@ bool Platform_CreateDetachedThread( void ( *threadRoutine )( void * ),
143149
bool PlatformMutex_Create( PlatformMutex_t * pNewMutex,
144150
bool recursive )
145151
{
152+
SemaphoreHandle_t xSemaphore = NULL;
153+
bool retMutexCreate = false;
154+
146155
configASSERT( pNewMutex != NULL );
147156

148157
CellularLogDebug( "Creating new mutex %p.", pNewMutex );
149158

150-
if( recursive )
159+
if( recursive == true )
151160
{
152-
( void ) xSemaphoreCreateRecursiveMutexStatic( &pNewMutex->xMutex );
161+
xSemaphore = xSemaphoreCreateRecursiveMutexStatic( &pNewMutex->xMutex );
153162
}
154163
else
155164
{
156-
( void ) xSemaphoreCreateMutexStatic( &pNewMutex->xMutex );
165+
xSemaphore = xSemaphoreCreateMutexStatic( &pNewMutex->xMutex );
157166
}
158167

159-
/* remember the type of mutex */
160-
if( recursive )
168+
/* Remember the type of mutex. */
169+
if( recursive == true )
161170
{
162171
pNewMutex->recursive = pdTRUE;
163172
}
@@ -166,7 +175,17 @@ bool PlatformMutex_Create( PlatformMutex_t * pNewMutex,
166175
pNewMutex->recursive = pdFALSE;
167176
}
168177

169-
return true;
178+
/* Check the handle value returned by the mutex create function. */
179+
if( xSemaphore == NULL )
180+
{
181+
retMutexCreate = false;
182+
}
183+
else
184+
{
185+
retMutexCreate = true;
186+
}
187+
188+
return retMutexCreate;
170189
}
171190

172191
/*-----------------------------------------------------------*/

source/cellular/cellular_platform.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ bool Platform_CreateDetachedThread( void ( * threadRoutine )( void * ),
7676
size_t stackSize );
7777

7878
#define PLATFORM_THREAD_DEFAULT_STACK_SIZE ( 2048U )
79-
#define PLATFORM_THREAD_DEFAULT_PRIORITY ( 5U )
79+
#define PLATFORM_THREAD_DEFAULT_PRIORITY ( tskIDLE_PRIORITY + 5U )
8080

8181
/*-----------------------------------------------------------*/
8282

@@ -85,7 +85,8 @@ bool Platform_CreateDetachedThread( void ( * threadRoutine )( void * ),
8585
*
8686
* Cellular library use platform mutex to protect resource.
8787
*
88-
* The IotMutex_ functions can be refernced as function prototype.
88+
* The IotMutex_ functions can be refernced as function prototype for
89+
* PlatfromMutex_ prefix function in the following link.
8990
* https://docs.aws.amazon.com/freertos/latest/lib-ref/c-sdk/platform/platform_threads_functions.html
9091
*
9192
*/

0 commit comments

Comments
 (0)