Download FreeRTOS
 

Quality RTOS & Embedded Software

LIBRARIES
WHAT'S NEW
Simplifying Authenticated Cloud Connectivity for Any Device.
Designing an energy efficient and cloud-connected IoT solution with CoAP.
Introducing FreeRTOS Kernel version 11.0.0:
FreeRTOS Roadmap and Code Contribution process.
OPC-UA over TSN with FreeRTOS.
NOTE: This API has been deprecated from FreeRTOS V4.0.0 onwards. Please refer to FreeRTOS_SetEndPointConfiguration 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.

FreeRTOS_SetAddressConfiguration()

[FreeRTOS-Plus-TCP API Reference]

FreeRTOS_IP.h

void FreeRTOS_SetAddressConfiguration( const uint32_t * pulIPAddress,
                                       const uint32_t * pulNetMask,
                                       const uint32_t * pulGatewayAddress,
                                       const uint32_t * pulDNSServerAddress );

This function can be used to update the IPv4 address and netmask, the gateway address, and the DNS server address of the first IPv4 endpoint used by the FreeRTOS-Plus-TCP device after the TCP stack has already been initialized with a call to FreeRTOS_IPInit_Multi(). It will have no effect if an IPv4 endpoint cannot be found.

Parameters:

pulIPAddress  A pointer to the 32-bit IPv4 address, in network endian order, that the device should use. This pointer can be NULL if you want to leave the IP Address unchanged.
pulNetMask  A pointer to the 32-bit IPv4 netmask, in network endian order, that the device should use. This pointer can be NULL if you want to leave the IP netmask unchanged.
pulGatewayAddress  A pointer to the 32-bit IPv4 gateway address, in network endian order, that the device should use. This pointer can be NULL if you want to leave the device gateway address unchanged.
pulDNSServerAddress  A pointer to the 32-bit IPv4 DNS server address that the device should use. This pointer can be NULL if you want to leave the DNS server IP Address in use unchanged.

Caution:

This function is not thread safe and should be used with the taskENTER_CRITICAL/taskEXIT_CRITICAL pair. A call to this function should be made only when there is no active connection (either UDP or TCP), or else that connection might be severed.

Example usage:


void vUserTask( void *pvParameters )
{
/* 32-bit representation of 192.168.1.12. */
uint32_t ulHostEndianIPAddress = 0xC0A8010C;
uint32_t ulNetworkEndianIPAddress = FreeRTOS_htonl( ulHostEndianIPAddress );
/* 32-bit representation of 192.168.1.1. */
uint32_t ulHostEndianGatewayAddress = 0xC0A80101;
uint32_t ulNetworkEndianGatewayAddress = FreeRTOS_htonl( ulHostEndianGatewayAddress );
/* 32-bit representation of OpenDNS server address 208.67.222.222 */
uint32_t ulHostEndianDNSServerAddress = 0xD043DEDE;
uint32_t ulNetworkEndianDNSServerAddress = FreeRTOS_htonl( ulHostEndianDNSServerAddress );
BaseType_t xUserWantsToUpdateConfiguration = pdFALSE;

/* Ignore compiler warnings about unused variables. */
( void ) pvParameters;

for( ; ; )
{
/* Execute some code. */
/*

* .

* .

*/


/* Note: Make sure that there are no active UDP/TCP conenctions. */

/* Check whether the user wants to update the IP address. */
if( xUserWantsToUpdateConfiguration == pdTRUE )
{
/* Make sure that no other task can the current task while the

* IP-address is being set. */

taskENTER_CRITICAL();
{
/* Update the IP address, gateway address and the DNS server address of

* this device but leave the netmask unchanged by passing NULL. */

FreeRTOS_SetAddressConfiguration( &ulNetworkEndianIPAddress ,
NULL,
&ulNetworkEndianGatewayAddress,
&ulNetworkEndianDNSServerAddress );
}
/* Exit critical section. */
taskEXIT_CRITICAL();
}
}
}
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.