mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-17 18:27:47 -04:00
Add cellular library submodule path and demo (#695)
* [Cellular] Add cellulr lib submodule and demo app * [Cellular] Fix memory violation in transport layer and add using LoggingPrintf * Update FreeRTOS Cellular Interface * Change the mbedtls usage in FreeRTOS-Plus * [Cellular] Fix missing spell * [Cellular] Add manifest.yml * Fix missing spell * Update manifest.yml * [Cellular] Add integration test * Modify the demo log level to LOG_INFO * Update cellular interface * The modification of the folder structure for cellular library * Rename the naming of demo * Adjust the location of using_mbedtls and socket_wrapper * Adjust project setting for relocating using_mbedtls and socket_wrapper * Turn off PSM mode * Add start marker for CI validation. * The modification for mbedtls platform send/recv function for cellular * Change the project file due to the changes of mbedtls platform send/recv function for cellular * Fix missing newline and remove unused file * Add missing configuration. * Make cellular and freertos tcp plus use the same transport implementation * Add comment for the macro MBEDTLS_SSL_SEND and MBEDTLS_SSL_RECV * Make changes from the github comment.
This commit is contained in:
parent
223d2d0e21
commit
957fb26dbe
142 changed files with 45928 additions and 14758 deletions
|
@ -0,0 +1,233 @@
|
|||
/*
|
||||
* Amazon FreeRTOS CELLULAR Preview Release
|
||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* http://aws.amazon.com/freertos
|
||||
* http://www.FreeRTOS.org
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "cellular_platform.h"
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
typedef QueueHandle_t SemaphoreHandle_t;
|
||||
|
||||
typedef struct threadInfo
|
||||
{
|
||||
void * pArgument; /**< @brief Argument to `threadRoutine`. */
|
||||
void ( * threadRoutine )( void * ); /**< @brief Thread function to run. */
|
||||
} threadInfo_t;
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Sends provided buffer to network using transport send.
|
||||
*
|
||||
* @param[in] pArgument Argument passed to threadRoutine function.
|
||||
*
|
||||
*/
|
||||
static void prvThreadRoutineWrapper( void * pArgument );
|
||||
|
||||
/**
|
||||
* @brief Lock mutex with timeout.
|
||||
*
|
||||
* @param[in] pMutex Mutex to lock.
|
||||
* @param[in] timeout Timeout value to lock mutex.
|
||||
*
|
||||
* @return true if mutex is locked successfully. Otherwise false.
|
||||
*/
|
||||
static bool prIotMutexTimedLock( PlatformMutex_t * pMutex,
|
||||
TickType_t timeout );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvThreadRoutineWrapper( void * pArgument )
|
||||
{
|
||||
threadInfo_t * pThreadInfo = ( threadInfo_t * ) pArgument;
|
||||
|
||||
/* Run the thread routine. */
|
||||
pThreadInfo->threadRoutine( pThreadInfo->pArgument );
|
||||
Platform_Free( pThreadInfo );
|
||||
|
||||
vTaskDelete( NULL );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static bool prIotMutexTimedLock( PlatformMutex_t * pMutex,
|
||||
TickType_t timeout )
|
||||
{
|
||||
BaseType_t lockResult = pdTRUE;
|
||||
|
||||
configASSERT( pMutex != NULL );
|
||||
|
||||
LogDebug( ( "Locking mutex %p.", pMutex ) );
|
||||
|
||||
/* Call the correct FreeRTOS mutex take function based on mutex type. */
|
||||
if( pMutex->recursive == pdTRUE )
|
||||
{
|
||||
lockResult = xSemaphoreTakeRecursive( ( SemaphoreHandle_t ) &pMutex->xMutex, timeout );
|
||||
}
|
||||
else
|
||||
{
|
||||
lockResult = xSemaphoreTake( ( SemaphoreHandle_t ) &pMutex->xMutex, timeout );
|
||||
}
|
||||
|
||||
return( lockResult == pdTRUE );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
bool Platform_CreateDetachedThread( void ( * threadRoutine )( void * ),
|
||||
void * pArgument,
|
||||
int32_t priority,
|
||||
size_t stackSize )
|
||||
{
|
||||
bool status = true;
|
||||
threadInfo_t * pThreadInfo = NULL;
|
||||
|
||||
configASSERT( threadRoutine != NULL );
|
||||
|
||||
LogDebug( ( "Creating new thread." ) );
|
||||
|
||||
pThreadInfo = Platform_Malloc( sizeof( threadInfo_t ) );
|
||||
|
||||
if( pThreadInfo == NULL )
|
||||
{
|
||||
LogDebug( ( "Unable to allocate memory for threadRoutine %p.", threadRoutine ) );
|
||||
status = false;
|
||||
}
|
||||
|
||||
/* Create the FreeRTOS task that will run the thread. */
|
||||
if( status == true )
|
||||
{
|
||||
pThreadInfo->threadRoutine = threadRoutine;
|
||||
pThreadInfo->pArgument = pArgument;
|
||||
|
||||
if( xTaskCreate( prvThreadRoutineWrapper,
|
||||
"Cellular_Thread",
|
||||
( configSTACK_DEPTH_TYPE ) stackSize,
|
||||
pThreadInfo,
|
||||
priority,
|
||||
NULL ) != pdPASS )
|
||||
{
|
||||
/* Task creation failed. */
|
||||
LogWarn( ( "Failed to create thread." ) );
|
||||
Platform_Free( pThreadInfo );
|
||||
status = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogDebug( ( "New thread created." ) );
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
bool PlatformMutex_Create( PlatformMutex_t * pNewMutex,
|
||||
bool recursive )
|
||||
{
|
||||
SemaphoreHandle_t xSemaphore = NULL;
|
||||
bool retMutexCreate = false;
|
||||
|
||||
configASSERT( pNewMutex != NULL );
|
||||
|
||||
LogDebug( ( "Creating new mutex %p.", pNewMutex ) );
|
||||
|
||||
if( recursive == true )
|
||||
{
|
||||
xSemaphore = xSemaphoreCreateRecursiveMutexStatic( &pNewMutex->xMutex );
|
||||
}
|
||||
else
|
||||
{
|
||||
xSemaphore = xSemaphoreCreateMutexStatic( &pNewMutex->xMutex );
|
||||
}
|
||||
|
||||
/* Remember the type of mutex. */
|
||||
if( recursive == true )
|
||||
{
|
||||
pNewMutex->recursive = pdTRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
pNewMutex->recursive = pdFALSE;
|
||||
}
|
||||
|
||||
/* Check the handle value returned by the mutex create function. */
|
||||
if( xSemaphore == NULL )
|
||||
{
|
||||
retMutexCreate = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
retMutexCreate = true;
|
||||
}
|
||||
|
||||
return retMutexCreate;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void PlatformMutex_Destroy( PlatformMutex_t * pMutex )
|
||||
{
|
||||
configASSERT( pMutex != NULL );
|
||||
|
||||
vSemaphoreDelete( ( SemaphoreHandle_t ) &pMutex->xMutex );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void PlatformMutex_Lock( PlatformMutex_t * pMutex )
|
||||
{
|
||||
prIotMutexTimedLock( pMutex, portMAX_DELAY );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
bool PlatformMutex_TryLock( PlatformMutex_t * pMutex )
|
||||
{
|
||||
return prIotMutexTimedLock( pMutex, 0 );
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void PlatformMutex_Unlock( PlatformMutex_t * pMutex )
|
||||
{
|
||||
configASSERT( pMutex != NULL );
|
||||
|
||||
LogDebug( ( "Unlocking mutex %p.", pMutex ) );
|
||||
|
||||
/* Call the correct FreeRTOS mutex unlock function based on mutex type. */
|
||||
if( pMutex->recursive == pdTRUE )
|
||||
{
|
||||
( void ) xSemaphoreGiveRecursive( ( SemaphoreHandle_t ) &pMutex->xMutex );
|
||||
}
|
||||
else
|
||||
{
|
||||
( void ) xSemaphoreGive( ( SemaphoreHandle_t ) &pMutex->xMutex );
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------*/
|
Loading…
Add table
Add a link
Reference in a new issue