mirror of
https://github.com/FreeRTOS/FreeRTOS.git
synced 2025-06-27 12:33:04 +08:00
Support multiple transports in the same compilation unit (#434)
By removing the definition of the NetworkContext struct in the header file, we allow the application to define it. This allows an application writer to use multiple transports in the same compilation unit. That way, multiple .c files do not have to be created for each transport.
This commit is contained in:

committed by
GitHub

parent
a9fd30af94
commit
73b0d1b259
@ -116,6 +116,12 @@ typedef enum
|
||||
ReportStatusAccepted,
|
||||
ReportStatusRejected
|
||||
} ReportStatus_t;
|
||||
|
||||
/* Each compilation unit must define the NetworkContext struct. */
|
||||
struct NetworkContext
|
||||
{
|
||||
TlsTransportParams_t * pParams;
|
||||
};
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@ -128,6 +134,11 @@ static MQTTContext_t xMqttContext;
|
||||
*/
|
||||
static NetworkContext_t xNetworkContext;
|
||||
|
||||
/**
|
||||
* @brief The parameters for the network context using mbedTLS operation.
|
||||
*/
|
||||
static TlsTransportParams_t xTlsTransportParams;
|
||||
|
||||
/**
|
||||
* @brief Static buffer used to hold MQTT messages being sent and received.
|
||||
*/
|
||||
@ -626,6 +637,9 @@ void prvDefenderDemoTask( void * pvParameters )
|
||||
/* Remove compiler warnings about unused parameters. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Set the pParams member of the network context with desired transport. */
|
||||
xNetworkContext.pParams = &xTlsTransportParams;
|
||||
|
||||
/* Start with report not received. */
|
||||
xReportStatus = ReportStatusNotReceived;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.3.0
|
||||
* FreeRTOS V202011.00
|
||||
* 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
|
||||
@ -19,10 +19,9 @@
|
||||
* 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://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/***
|
||||
|
@ -22,7 +22,6 @@
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -162,6 +161,14 @@
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Each compilation unit must define the NetworkContext struct. */
|
||||
struct NetworkContext
|
||||
{
|
||||
TlsTransportParams_t * pParams;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief The MQTT context used for MQTT operation.
|
||||
*/
|
||||
@ -172,6 +179,11 @@ static MQTTContext_t xMqttContext;
|
||||
*/
|
||||
static NetworkContext_t xNetworkContext;
|
||||
|
||||
/**
|
||||
* @brief The parameters for the network context using mbedTLS operation.
|
||||
*/
|
||||
static TlsTransportParams_t xTlsTransportParams;
|
||||
|
||||
/**
|
||||
* @brief Static buffer used to hold MQTT messages being sent and received.
|
||||
*/
|
||||
@ -590,6 +602,9 @@ void prvShadowDemoTask( void * pvParameters )
|
||||
/* Remove compiler warnings about unused parameters. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Set the pParams member of the network context with desired transport. */
|
||||
xNetworkContext.pParams = &xTlsTransportParams;
|
||||
|
||||
/****************************** Connect. ******************************/
|
||||
|
||||
demoStatus = xEstablishMqttSession( &xMqttContext,
|
||||
|
@ -223,6 +223,14 @@ typedef enum JobActionType
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Each compilation unit must define the NetworkContext struct. */
|
||||
struct NetworkContext
|
||||
{
|
||||
TlsTransportParams_t * pParams;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief The MQTT context used for MQTT operation.
|
||||
*/
|
||||
@ -233,6 +241,11 @@ static MQTTContext_t xMqttContext;
|
||||
*/
|
||||
static NetworkContext_t xNetworkContext;
|
||||
|
||||
/**
|
||||
* @brief The parameters for the network context using mbedTLS operation.
|
||||
*/
|
||||
static TlsTransportParams_t xTlsTransportParams;
|
||||
|
||||
/**
|
||||
* @brief Static buffer used to hold MQTT messages being sent and received.
|
||||
*/
|
||||
@ -726,6 +739,9 @@ void prvJobsDemoTask( void * pvParameters )
|
||||
/* Remove compiler warnings about unused parameters. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Set the pParams member of the network context with desired transport. */
|
||||
xNetworkContext.pParams = &xTlsTransportParams;
|
||||
|
||||
/* Establish an MQTT connection with AWS IoT over a mutually authenticated TLS session. */
|
||||
xDemoStatus = xEstablishMqttSession( &xMqttContext,
|
||||
&xNetworkContext,
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.3.0
|
||||
* FreeRTOS V202011.00
|
||||
* 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
|
||||
@ -19,10 +19,9 @@
|
||||
* 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://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/***
|
||||
|
@ -202,6 +202,14 @@ typedef struct PublishPackets
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Each compilation unit must define the NetworkContext struct. */
|
||||
struct NetworkContext
|
||||
{
|
||||
TlsTransportParams_t * pParams;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Global entry time into the application to use as a reference timestamp
|
||||
* in the #prvGetTimeMs function. #prvGetTimeMs will always return the difference
|
||||
@ -583,9 +591,8 @@ BaseType_t xEstablishMqttSession( MQTTContext_t * pxMqttContext,
|
||||
configASSERT( pxMqttContext != NULL );
|
||||
configASSERT( pxNetworkContext != NULL );
|
||||
|
||||
/* Initialize the mqtt context and network context. */
|
||||
/* Initialize the mqtt context. */
|
||||
( void ) memset( pxMqttContext, 0U, sizeof( MQTTContext_t ) );
|
||||
( void ) memset( pxNetworkContext, 0U, sizeof( NetworkContext_t ) );
|
||||
|
||||
if( prvConnectToServerWithBackoffRetries( pxNetworkContext ) != TLS_TRANSPORT_SUCCESS )
|
||||
{
|
||||
|
@ -56,6 +56,15 @@
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Each compilation unit must define the NetworkContext struct.
|
||||
* void * is used as this utility can be used by both plaintext and TLS demos. */
|
||||
struct NetworkContext
|
||||
{
|
||||
void * pParams;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
extern UBaseType_t uxRand();
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.3.0
|
||||
* FreeRTOS V202011.00
|
||||
* 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
|
||||
@ -19,8 +19,8 @@
|
||||
* 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://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -122,6 +122,12 @@
|
||||
*/
|
||||
#define IOT_CORE_ALPN_PROTOCOL_NAME "\x0ex-amzn-http-ca"
|
||||
|
||||
/* Each compilation unit must define the NetworkContext struct. */
|
||||
struct NetworkContext
|
||||
{
|
||||
TlsTransportParams_t * pParams;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A buffer used in the demo for storing HTTP request headers and
|
||||
* HTTP response headers and body.
|
||||
@ -207,6 +213,7 @@ static void prvHTTPDemoTask( void * pvParameters )
|
||||
TransportInterface_t xTransportInterface;
|
||||
/* The network context for the transport layer interface. */
|
||||
NetworkContext_t xNetworkContext = { 0 };
|
||||
TlsTransportParams_t xTlsTransportParams = { 0 };
|
||||
BaseType_t xIsConnectionEstablished = pdFALSE;
|
||||
|
||||
/* The user of this demo must check the logs for any failure codes. */
|
||||
@ -215,6 +222,9 @@ static void prvHTTPDemoTask( void * pvParameters )
|
||||
/* Remove compiler warnings about unused parameters. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Set the pParams member of the network context with desired transport. */
|
||||
xNetworkContext.pParams = &xTlsTransportParams;
|
||||
|
||||
/**************************** Connect. ******************************/
|
||||
|
||||
/* Attempt to connect to the HTTP server. If connection fails, retry after a
|
||||
|
@ -164,6 +164,12 @@
|
||||
*/
|
||||
#define httpexampleNUMBER_HTTP_PATHS ( 4 )
|
||||
|
||||
/* Each compilation unit must define the NetworkContext struct. */
|
||||
struct NetworkContext
|
||||
{
|
||||
PlaintextTransportParams_t * pParams;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A pair containing a path string of the URI and its length.
|
||||
*/
|
||||
@ -269,6 +275,7 @@ static void prvHTTPDemoTask( void * pvParameters )
|
||||
TransportInterface_t xTransportInterface;
|
||||
/* The network context for the transport layer interface. */
|
||||
NetworkContext_t xNetworkContext = { 0 };
|
||||
PlaintextTransportParams_t xPlaintextTransportParams = { 0 };
|
||||
/* An array of HTTP paths to request. */
|
||||
const httpPathStrings_t xHttpMethodPaths[] =
|
||||
{
|
||||
@ -294,6 +301,9 @@ static void prvHTTPDemoTask( void * pvParameters )
|
||||
/* Remove compiler warnings about unused parameters. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Set the pParams member of the network context with desired transport. */
|
||||
xNetworkContext.pParams = &xPlaintextTransportParams;
|
||||
|
||||
/**************************** Connect. ******************************/
|
||||
|
||||
/* Attempt to connect to the HTTP server. If connection fails, retry after a
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.3.0
|
||||
* FreeRTOS V202011.00
|
||||
* 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
|
||||
@ -19,10 +19,9 @@
|
||||
* 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://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/***
|
||||
|
@ -185,6 +185,14 @@
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Each compilation unit must define the NetworkContext struct. */
|
||||
struct NetworkContext
|
||||
{
|
||||
TlsTransportParams_t * pParams;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief The task used to demonstrate the MQTT API.
|
||||
*
|
||||
@ -386,6 +394,7 @@ static void prvMQTTDemoTask( void * pvParameters )
|
||||
uint32_t ulPublishCount = 0U, ulTopicCount = 0U;
|
||||
const uint32_t ulMaxPublishCount = 5UL;
|
||||
NetworkContext_t xNetworkContext = { 0 };
|
||||
TlsTransportParams_t xTlsTransportParams = { 0 };
|
||||
NetworkCredentials_t xNetworkCredentials = { 0 };
|
||||
MQTTContext_t xMQTTContext = { 0 };
|
||||
MQTTStatus_t xMQTTStatus;
|
||||
@ -394,6 +403,9 @@ static void prvMQTTDemoTask( void * pvParameters )
|
||||
/* Remove compiler warnings about unused parameters. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Set the pParams member of the network context with desired transport. */
|
||||
xNetworkContext.pParams = &xTlsTransportParams;
|
||||
|
||||
/* Set the entry time of the demo application. This entry time will be used
|
||||
* to calculate relative time elapsed in the execution of the demo application,
|
||||
* by the timer utility function that is provided to the MQTT library.
|
||||
|
@ -207,6 +207,14 @@
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Each compilation unit must define the NetworkContext struct. */
|
||||
struct NetworkContext
|
||||
{
|
||||
PlaintextTransportParams_t * pParams;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief The task used to demonstrate the MQTT API.
|
||||
*
|
||||
@ -471,6 +479,7 @@ static void prvMQTTDemoTask( void * pvParameters )
|
||||
{
|
||||
uint32_t ulTopicCount = 0U;
|
||||
NetworkContext_t xNetworkContext = { 0 };
|
||||
PlaintextTransportParams_t xPlaintextTransportParams = { 0 };
|
||||
MQTTContext_t xMQTTContext;
|
||||
MQTTStatus_t xMQTTStatus;
|
||||
PlaintextTransportStatus_t xNetworkStatus;
|
||||
@ -479,6 +488,9 @@ static void prvMQTTDemoTask( void * pvParameters )
|
||||
/* Remove compiler warnings about unused parameters. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Set the pParams member of the network context with desired transport. */
|
||||
xNetworkContext.pParams = &xPlaintextTransportParams;
|
||||
|
||||
/* Serialize a PINGREQ packet to send upon invoking the keep-alive timer
|
||||
* callback. */
|
||||
xMQTTStatus = MQTT_SerializePingreq( &xPingReqBuffer );
|
||||
|
@ -375,6 +375,18 @@ typedef struct publishElement
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Each compilation unit must define the NetworkContext struct. */
|
||||
struct NetworkContext
|
||||
{
|
||||
#if defined( democonfigUSE_TLS ) && ( democonfigUSE_TLS == 1 )
|
||||
TlsTransportParams_t * pParams;
|
||||
#else
|
||||
PlaintextTransportParams_t * pParams;
|
||||
#endif
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief Initializes an MQTT context, including transport interface and
|
||||
* network buffer.
|
||||
@ -686,6 +698,20 @@ static MQTTContext_t globalMqttContext;
|
||||
*/
|
||||
static NetworkContext_t xNetworkContext;
|
||||
|
||||
#if defined( democonfigUSE_TLS ) && ( democonfigUSE_TLS == 1 )
|
||||
|
||||
/**
|
||||
* @brief The parameters for the network context using a TLS channel.
|
||||
*/
|
||||
static TlsTransportParams_t xTlsTransportParams;
|
||||
#else
|
||||
|
||||
/**
|
||||
* @brief The parameters for the network context using a non-encrypted channel.
|
||||
*/
|
||||
static PlaintextTransportParams_t xPlaintextTransportParams;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief List of operations that are awaiting an ack from the broker.
|
||||
*/
|
||||
@ -981,6 +1007,8 @@ static BaseType_t prvSocketConnect( NetworkContext_t * pxNetworkContext )
|
||||
BackoffAlgorithmContext_t xReconnectParams;
|
||||
uint16_t usNextRetryBackOff = 0U;
|
||||
|
||||
configASSERT( pxNetworkContext != NULL && pxNetworkContext->pParams != NULL );
|
||||
|
||||
#if defined( democonfigUSE_TLS ) && ( democonfigUSE_TLS == 1 )
|
||||
TlsTransportStatus_t xNetworkStatus = TLS_TRANSPORT_CONNECT_FAILURE;
|
||||
NetworkCredentials_t xNetworkCredentials = { 0 };
|
||||
@ -1079,7 +1107,7 @@ static BaseType_t prvSocketConnect( NetworkContext_t * pxNetworkContext )
|
||||
/* Set the socket wakeup callback. */
|
||||
if( xConnected )
|
||||
{
|
||||
( void ) FreeRTOS_setsockopt( pxNetworkContext->tcpSocket,
|
||||
( void ) FreeRTOS_setsockopt( pxNetworkContext->pParams->tcpSocket,
|
||||
0, /* Level - Unused. */
|
||||
FREERTOS_SO_WAKEUP_CALLBACK,
|
||||
( void * ) prvMQTTClientSocketWakeupCallback,
|
||||
@ -1095,8 +1123,10 @@ static BaseType_t prvSocketDisconnect( NetworkContext_t * pxNetworkContext )
|
||||
{
|
||||
BaseType_t xDisconnected = pdFAIL;
|
||||
|
||||
configASSERT( pxNetworkContext != NULL && pxNetworkContext->pParams != NULL );
|
||||
|
||||
/* Set the wakeup callback to NULL since the socket will disconnect. */
|
||||
( void ) FreeRTOS_setsockopt( pxNetworkContext->tcpSocket,
|
||||
( void ) FreeRTOS_setsockopt( pxNetworkContext->pParams->tcpSocket,
|
||||
0, /* Level - Unused. */
|
||||
FREERTOS_SO_WAKEUP_CALLBACK,
|
||||
( void * ) NULL,
|
||||
@ -2074,6 +2104,13 @@ static void prvMQTTDemoTask( void * pvParameters )
|
||||
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Set the pParams member of the network context with desired transport. */
|
||||
#if defined( democonfigUSE_TLS ) && ( democonfigUSE_TLS == 1 )
|
||||
xNetworkContext.pParams = &xTlsTransportParams;
|
||||
#else
|
||||
xNetworkContext.pParams = &xPlaintextTransportParams;
|
||||
#endif
|
||||
|
||||
ulGlobalEntryTimeMs = prvGetTimeMs();
|
||||
|
||||
/* Create command queue for processing MQTT commands. */
|
||||
|
@ -274,6 +274,14 @@
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Each compilation unit must define the NetworkContext struct. */
|
||||
struct NetworkContext
|
||||
{
|
||||
TlsTransportParams_t * pParams;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief The task used to demonstrate the MQTT API.
|
||||
*
|
||||
@ -475,6 +483,7 @@ static void prvMQTTDemoTask( void * pvParameters )
|
||||
uint32_t ulPublishCount = 0U, ulTopicCount = 0U;
|
||||
const uint32_t ulMaxPublishCount = 5UL;
|
||||
NetworkContext_t xNetworkContext = { 0 };
|
||||
TlsTransportParams_t xTlsTransportParams = { 0 };
|
||||
NetworkCredentials_t xNetworkCredentials = { 0 };
|
||||
MQTTContext_t xMQTTContext = { 0 };
|
||||
MQTTStatus_t xMQTTStatus;
|
||||
@ -489,6 +498,9 @@ static void prvMQTTDemoTask( void * pvParameters )
|
||||
*/
|
||||
ulGlobalEntryTimeMs = prvGetTimeMs();
|
||||
|
||||
/* Set the pParams member of the network context with desired transport. */
|
||||
xNetworkContext.pParams = &xTlsTransportParams;
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
/****************************** Connect. ******************************/
|
||||
|
@ -176,6 +176,14 @@
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Each compilation unit must define the NetworkContext struct. */
|
||||
struct NetworkContext
|
||||
{
|
||||
PlaintextTransportParams_t * pParams;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief The task used to demonstrate the MQTT API.
|
||||
*
|
||||
@ -359,6 +367,7 @@ static void prvMQTTDemoTask( void * pvParameters )
|
||||
uint32_t ulPublishCount = 0U, ulTopicCount = 0U;
|
||||
const uint32_t ulMaxPublishCount = 5UL;
|
||||
NetworkContext_t xNetworkContext = { 0 };
|
||||
PlaintextTransportParams_t xPlaintextTransportParams = { 0 };
|
||||
MQTTContext_t xMQTTContext;
|
||||
MQTTStatus_t xMQTTStatus;
|
||||
PlaintextTransportStatus_t xNetworkStatus;
|
||||
@ -366,6 +375,9 @@ static void prvMQTTDemoTask( void * pvParameters )
|
||||
/* Remove compiler warnings about unused parameters. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Set the pParams member of the network context with desired transport. */
|
||||
xNetworkContext.pParams = &xPlaintextTransportParams;
|
||||
|
||||
ulGlobalEntryTimeMs = prvGetTimeMs();
|
||||
|
||||
for( ; ; )
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.3.0
|
||||
* FreeRTOS V202011.00
|
||||
* 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
|
||||
@ -19,8 +19,9 @@
|
||||
* 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://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -159,6 +160,14 @@
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Each compilation unit must define the NetworkContext struct. */
|
||||
struct NetworkContext
|
||||
{
|
||||
TlsTransportParams_t * pParams;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief The task used to demonstrate the MQTT API.
|
||||
*
|
||||
@ -324,6 +333,7 @@ static void prvMQTTDemoTask( void * pvParameters )
|
||||
uint32_t ulPublishCount = 0U;
|
||||
const uint32_t ulMaxPublishCount = 5UL;
|
||||
NetworkContext_t xNetworkContext = { 0 };
|
||||
TlsTransportParams_t xTlsTransportParams = { 0 };
|
||||
NetworkCredentials_t xNetworkCredentials = { 0 };
|
||||
MQTTContext_t xMQTTContext = { 0 };
|
||||
MQTTStatus_t xMQTTStatus;
|
||||
@ -331,6 +341,9 @@ static void prvMQTTDemoTask( void * pvParameters )
|
||||
/* Remove compiler warnings about unused parameters. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* Set the pParams member of the network context with desired transport. */
|
||||
xNetworkContext.pParams = &xTlsTransportParams;
|
||||
|
||||
/* Set the entry time of the demo application. This entry time will be used
|
||||
* to calculate relative time elapsed in the execution of the demo application,
|
||||
* by the timer utility function that is provided to the MQTT library.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* FreeRTOS Kernel V10.3.0
|
||||
* FreeRTOS V202011.00
|
||||
* 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
|
||||
@ -19,10 +19,9 @@
|
||||
* 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://www.FreeRTOS.org
|
||||
* http://aws.amazon.com/freertos
|
||||
* https://www.FreeRTOS.org
|
||||
* https://github.com/FreeRTOS
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*/
|
||||
|
||||
/***
|
||||
|
Reference in New Issue
Block a user