NOTE: These stack initialisation APIs have been deprecated as of FreeRTOS V4.0.0
onwards. Please refer to
Initialising the TCP/IP Stack
for the new APIs supporting IPv6, Multiple Endpoints and Multiple interfaces. To use the deprecated APIs please set
ipconfigIPv4_BACKWARD_COMPATIBLE to 1 in the FreeRTOSIPConfig.h header file.
This page describes
FreeRTOS_IPInit()
and the
callback function that
gets invoked when 'network up' and 'network down' events occur.
FreeRTOS_IPInit()
must be the first FreeRTOS-Plus-TCP function called. FreeRTOS_IPInit() can be called
before or after the RTOS scheduler is started.
FreeRTOS_IPInit() creates the FreeRTOS-Plus-TCP RTOS task. The FreeRTOS-Plus-TCP task
configures and initialises the network interface. If ipconfigUSE_NETWORK_EVENT_HOOK is
set to 1 in FreeRTOSIPConfig.h
then the TCP/IP stack will call the
vIPNetworkEventHook()
callback function when the network is ready for use.
Two examples are provided below. The first demonstrates FreeRTOS_IPInit().
The second demonstrates vIPNetworkEventHook().
static uint8_t ucMACAddress[ 6 ] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
static const uint8_t ucIPAddress[ 4 ] = { 10, 10, 10, 200 };
static const uint8_t ucNetMask[ 4 ] = { 255, 0, 0, 0 };
static const uint8_t ucGatewayAddress[ 4 ] = { 10, 10, 10, 1 };
static const uint8_t ucDNSServerAddress[ 4 ] = { 208, 67, 222, 222 };
int main( void )
{
FreeRTOS_IPInit( ucIPAddress,
ucNetMask,
ucGatewayAddress,
ucDNSServerAddress,
ucMACAddress );
vTaskStartScheduler();
for( ;; );
}
Example use of the FreeRTOS_IPInit() API function
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
static BaseType_t xTasksAlreadyCreated = pdFALSE;
if( eNetworkEvent == eNetworkUp )
{
if( xTasksAlreadyCreated == pdFALSE )
{
xTasksAlreadyCreated = pdTRUE;
}
}
}
Example vApplicationIPNetworkEventHook() definition
<<
Back to the RTOS TCP networking tutorial index
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.