This page describes FreeRTOS_IPInit_Multi()
and the callback function that gets invoked when 'network up' and 'network down' events occur.
Before calling the FreeRTOS_IPInit_Multi() function, the application must add the Network-Interface and at least one of the End-Points
corresponding to a network interface. A Network-Interface is the driver of the EMAC + PHY ( or a WiFi adapter ). An End-Point is a set
of network parameters: an IP-address, MAC-address, Gateway, DNS, and so on. There can be multiple Interfaces, each one owning one or
more end-points.
The function used to initialise an interface is px${port_name}_FillInterfaceDescriptor
(for example,
pxSAM_FillInterfaceDescriptor
). The function used to add an Endpoint is
FreeRTOS_FillEndPoint
or
FreeRTOS_FillEndPoint_IPv6
.
FreeRTOS_IPInit_Multi() 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 vApplicationIPNetworkEventHook_Multi()
callback function when the network is ready for use.
Two examples are provided below. The first demonstrates FreeRTOS_IPInit_Multi(). The second demonstrates
vApplicationIPNetworkEventHook_Multi().
IPv4 Example:
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 )
{
pxWinPcap_FillInterfaceDescriptor( 0, &( xInterfaces[ 0 ] ) );
FreeRTOS_FillEndPoint( &( xInterfaces[ 0 ] ), &( xEndPoints[ 0 ] ), ucIPAddress,
ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
#if ( ipconfigUSE_DHCP != 0 )
{
xEndPoints[ 0 ].bits.bWantDHCP = pdTRUE;
}
#endif /* ( ipconfigUSE_DHCP != 0 ) */
FreeRTOS_IPInit_Multi();
vTaskStartScheduler();
for( ;; );
}
Example use of the FreeRTOS_IPInit_Multi() API function
void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent,
struct xNetworkEndPoint * pxEndPoint )
{
static BaseType_t xTasksAlreadyCreated = pdFALSE;
if( eNetworkEvent == eNetworkUp )
{
if( xTasksAlreadyCreated == pdFALSE )
{
xTasksAlreadyCreated = pdTRUE;
}
}
showEndPoint( pxEndPoint );
}
Example use of the vApplicationIPNetworkEventHook_Multi()definition
IPv6 Example:
static uint8_t ucMACAddress[ 6 ] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
int main( void )
{
IPv6_Address_t xIPAddress;
IPv6_Address_t xPrefix;
IPv6_Address_t xGateWay;
pxWinPcap_FillInterfaceDescriptor( 0, &( xInterfaces[ 0 ] ) );
FreeRTOS_inet_pton6( "2001:470:ed44::", xPrefix.ucBytes );
FreeRTOS_CreateIPv6Address( &xIPAddress, &xPrefix, 64, pdTRUE );
FreeRTOS_inet_pton6( "fe80::ba27:ebff:fe5a:d751", xGateWay.ucBytes );
#if ( ipconfigUSE_RA != 0 )
{
xEndPoints[ 0 ].bits.bWantRA = pdTRUE;
}
#endif
#if ( ipconfigUSE_DHCPv6 != 0 )
{
xEndPoints[ 0 ].bits.bWantDHCP = pdTRUE;
}
FreeRTOS_FillEndPoint_IPv6( &( xInterfaces[ 0 ] ),
&( xEndPoints[ 0] ),
&( xIPAddress ),
&( xPrefix ),
64uL,
&( xGateWay ),
NULL,
ucMACAddress );
FreeRTOS_inet_pton6( "2001:4860:4860::8888", xEndPoints[ 0 ].ipv6_settings.xDNSServerAddresses[ 0 ].ucBytes );
FreeRTOS_inet_pton6( "fe80::1", xEndPoints[ 0 ].ipv6_settings.xDNSServerAddresses[ 1 ].ucBytes );
FreeRTOS_inet_pton6( "2001:4860:4860::8888", xEndPoints[ 0 ].ipv6_defaults.xDNSServerAddresses[ 0 ].ucBytes );
FreeRTOS_inet_pton6( "fe80::1", xEndPoints[ 0 ].ipv6_defaults.xDNSServerAddresses[ 1 ].ucBytes );
FreeRTOS_inet_pton6( "fe80::", xPrefix.ucBytes );
FreeRTOS_inet_pton6( "fe80::7009", xIPAddress.ucBytes );
#if ( ipconfigUSE_DHCPv6 != 0 )
{
xEndPoints[ 1 ].bits.bWantDHCP = pdTRUE;
}
FreeRTOS_FillEndPoint_IPv6(
&( xInterfaces[ 0 ] ),
&( xEndPoints[ 1 ] ),
&( xIPAddress ),
&( xPrefix ),
10U,
NULL,
NULL,
ucMACAddress );
FreeRTOS_IPInit_Multi();
vTaskStartScheduler();
for( ;; );
}
Example use of the FreeRTOS_IPInit_Multi() API function
void vApplicationIPNetworkEventHook_Multi( eIPCallbackEvent_t eNetworkEvent,
struct xNetworkEndPoint * pxEndPoint )
{
static BaseType_t xTasksAlreadyCreated = pdFALSE;
if( eNetworkEvent == eNetworkUp )
{
if( xTasksAlreadyCreated == pdFALSE )
{
xTasksAlreadyCreated = pdTRUE;
}
}
showEndPoint( pxEndPoint );
}
Example use of the vApplicationIPNetworkEventHook_Multi()definition
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.