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:
Oscar Michael Abrina
2020-12-01 17:24:18 -08:00
committed by GitHub
parent a9fd30af94
commit 73b0d1b259
27 changed files with 406 additions and 106 deletions

View File

@ -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 )
{