XDK API  3.6.0
Documentation
Files | Data Structures | Macros | Typedefs | Enumerations | Functions
Network Configuration Interface

Interface header for the Network Configuration Interface module. More...

+ Collaboration diagram for Network Configuration Interface:

Files

file  BCDS_NetworkConfig.h
 

Data Structures

struct  NetworkConfig_IpSettings_S
 

Macros

#define NETWORKCONFIG_DHCP_DISABLED   (0)
 
#define NETWORKCONFIG_DHCP_ENABLED   (1)
 
#define NETWORKCONFIG_DHCP_FLG_ACQ   (1)
 
#define NETWORKCONFIG_DHCP_FLG_NOT_ACQ   (0)
 

Typedefs

typedef void(* NetworkConfig_IpCallback_T )(NetworkConfig_IpStatus_T ipStatus)
 
typedef struct
NetworkConfig_IpSettings_S 
NetworkConfig_IpSettings_T
 
typedef enum
NetworkConfig_IpStatus_E 
NetworkConfig_IpStatus_T
 

Enumerations

enum  NetworkConfig_IpStatus_E
 

Functions

 BCDS_DEPRECATED (void NetworkConfig_SetIpStatus(NetworkConfig_IpStatus_T ipStatus))
 Function to set the IP status. More...
 
 BCDS_DEPRECATED (Retcode_T NetworkConfig_GetIpSettings(NetworkConfig_IpSettings_T *myIpSettings))
 Function to handle WLAN IP settings. This function gets the IP settings after a Successful connection. More...
 
 BCDS_DEPRECATED (Retcode_T NetworkConfig_SetIpStatic(NetworkConfig_IpSettings_T myIpSettings))
 Function to handle WLAN IP settings. This function sets the static IP. More...
 
 BCDS_DEPRECATED (Retcode_T NetworkConfig_SetIpDhcp(NetworkConfig_IpCallback_T myIpCallback))
 Function to handle WLAN IP settings. This function sets the IP by using DHCP. More...
 
 BCDS_DEPRECATED (uint32_t NetworkConfig_Ipv4Value(uint8_t add3, uint8_t add2, uint8_t add1, uint8_t add0))
 Function to convert an IP to hexadecimal. More...
 
 BCDS_DEPRECATED (uint8_t NetworkConfig_Ipv4Byte(uint32_t ipValue, uint8_t index))
 Function to convert an hexadecimal to IP. More...
 
 BCDS_DEPRECATED (NetworkConfig_IpStatus_T NetworkConfig_GetIpStatus(void))
 Function to get the IP status. This function return the IP status. More...
 
 BCDS_DEPRECATED (Retcode_T NetworkConfig_GetIpAddress(uint8_t *url, uint32_t *destAddr))
 This API returns back the Ip address by the host name. More...
 

Detailed Description

The interface header exports High-level Network Configuration API's for integrating with the Network Interface which are used to Get & Set IP Settings Set DHCP IP address and to get the IPV4 IpAddress and ipv4 byte value.


Data Structure Documentation

struct NetworkConfig_IpSettings_S

Structure to hold Network Configuration IP settings

Data Fields

uint32_t ipV4
 
uint32_t ipV4DnsServer
 
uint32_t ipV4Gateway
 
uint32_t ipV4Mask
 
uint8_t isDHCP
 

Field Documentation

uint32_t ipV4

IP Address

uint32_t ipV4DnsServer

IP Address DNS Server

uint32_t ipV4Gateway

IP Address Gateway

uint32_t ipV4Mask

IP Address Mask

uint8_t isDHCP

IP settings static or DHCP

Macro Definition Documentation

#define NETWORKCONFIG_DHCP_DISABLED   (0)

Macro for Dynamically Host Configuration Protocol disabled

#define NETWORKCONFIG_DHCP_ENABLED   (1)

Macro for Dynamically Host Configuration Protocol enabled

#define NETWORKCONFIG_DHCP_FLG_ACQ   (1)

Macro for Dynamically Host Configuration Protocol acquired

#define NETWORKCONFIG_DHCP_FLG_NOT_ACQ   (0)

Macro for Dynamically Host Configuration Protocol not acquired

Typedef Documentation

typedef void(* NetworkConfig_IpCallback_T)(NetworkConfig_IpStatus_T ipStatus)

Type defining the prototype which Set IP function call back must conform to. This call back is called to notify the user when the IP is acquired following the call of NetworkConfig_SetIpDhcp(). Returns the NCI IP status as a parameter

Enumeration Type Documentation

Different IP status for the Network Configuration function callback

Enumerator
NETWORKCONFIG_IPV4_ACQUIRED 

IPv4 Address Acquired

NETWORKCONFIG_IPV6_ACQUIRED 

IPv6 Address Acquired

NETWORKCONFIG_IP_NOT_ACQUIRED 

IP Address Not Acquired

Function Documentation

BCDS_DEPRECATED ( void   NetworkConfig_SetIpStatusNetworkConfig_IpStatus_T ipStatus)
Parameters
[in]Statusof IP that needs to be set
BCDS_DEPRECATED ( Retcode_T   NetworkConfig_GetIpSettingsNetworkConfig_IpSettings_T *myIpSettings)
Parameters
[out]myIpSettingsNetwork configuration settings. Pointer contains IP address, Gateway, DNS Server and DHCP information
Returns
RETCODE_NULL_POINTER - if the input parameter passes NULL.
RETCODE_OK - Settings retrieved correctly.
RETCODE_UNINITIALIZED - if WlanConnect_GetInitStatus failed by returning WLANCONNECT_NOT_INITIALZED.
RETCODE_FAILURE - if sl_NetCfgGet failed by returning NETWORKCONFIG_FAILURE .
The return value consist of (First 1 MSByte represents Package ID, Next Byte represents Severity and Last 2 LSBytes represents error code) Below shows the error code(last 2 Bytes) meaning

Example usage: Getting the IP settings

1 // Local variable that stores the IP settings
2 NetworkConfig_IpSettings_T myIpGet;
3 // Local variable for storing the return status
4 Retcode_T retStatus;
5 
6 // retrieve the IP settings
7 retStatus = NetworkConfig_GetIpSettings(&myIpGet);
8 
9 // print a message if the function returned successfully
10 if (RETCODE_OK == retStatus)
11 {
12  printf("The IP was retrieved successfully");
13 }
BCDS_DEPRECATED ( Retcode_T   NetworkConfig_SetIpStaticNetworkConfig_IpSettings_T myIpSettings)
Parameters
[out]myIpSettingsNetwork configuration settings structure. Contains IP address, Gateway, DNS Server and DHCP information
Returns
RETCODE_OK - Settings retrieved correctly.
RETCODE_UNINITIALIZED - if WlanConnect_GetInitStatus failed by returning WLANCONNECT_NOT_INITIALZED.
RETCODE_FAILURE - if sl_NetCfgGet failed by returning NETWORKCONFIG_FAILURE.
RETCODE_FAILURE - if sl_Start failed by returning other than ROLE_STA.
Retcode_T The return value consist of (First 1 MSByte represents Package ID, Next Byte represents Severity and Last 2 LSBytes represents error code) Below shows the error code(last 2 Bytes) meaning Example usage: Setting static IP
1 // Local variables
2 NetworkConfig_IpSettings_T myIpSet;
3 Retcode_T retStatus;
4 
5 // IP settings that will be used.
6 myIpSet.isDHCP = (uint8_t) DHCP_DISABLED;
7 myIpSet.ipV4 = NCI_ipv4Value(192,168,2,120);
8 myIpSet.ipV4DnsServer = NCI_ipv4Value(192,168,2,1);
9 myIpSet.ipV4Gateway = NCI_ipv4Value(192,168,2,1);
10 myIpSet.ipV4Mask = NCI_ipv4Value(255,255,255,0);
11 
12 // Set the static IP
13 retStatus = NetworkConfig_SetIpStatic(myIpSet);
14 
15 // print a message if the function returned successfully
16 if (RETCODE_OK == retStatus)
17 {
18  printf("The static IP was set successfully");
19 }
BCDS_DEPRECATED ( Retcode_T   NetworkConfig_SetIpDhcpNetworkConfig_IpCallback_T myIpCallback)
Parameters
[in]myIpCallbackCallback function for notifying user of IP acquisition using DHCP
Returns
RETCODE_UNINITIALIZED - if WlanConnect_GetInitStatus failed by returning WLANCONNECT_NOT_INITIALZED.
RETCODE_FAILURE - if sl_Start failed by returning other than ROLE_STA.
RETCODE_OK - sets the IP by using DHCP successfully.
Retcode_T The return value consist of (First 1 MSByte represents Package ID, Next Byte represents Severity and Last 2 LSBytes represents error code) Below shows the error code(last 2 Bytes) meaning

Example usage: Setting DHCP IP with Callback

1 // Callback function
2 void myDhcpIpCallbackFunc(NetworkConfig_IpStatus_T returnStatus)
3 {
4  // user can do something inside this callback
5 }
6 
7 // local variables
8 NCI_ipCallback_t myIpCallback;
9 Retcode_T retStatus;
10 
11 // Set the IP callback
12 myIpCallback = myDhcpIpCallbackFunc;
13 
14 // Configure DHCP IP with callback
15 retStatus = NetworkConfig_SetIpDhcp(myIpCallback);

Example2 usage: Setting DHCP IP without Callback

1 // Configure DHCP IP without callback.
2 // Note that this is the default function in case no other
3 // function is used in order to set the IP
4 retStatus = NetworkConfig_SetIpDhcp(NULL);
BCDS_DEPRECATED ( uint32_t   NetworkConfig_Ipv4Valueuint8_t add3, uint8_t add2, uint8_t add1, uint8_t add0)
Parameters
[in]add3Decimal value of the first byte (MSB) of an IPV4
[in]add2Decimal value of the second byte of an IPV4
[in]add1Decimal value of the third byte of an IPV4
[in]add0Decimal value of the last byte (LSB) of an IPV4
Returns
On success returns the integer value of IP from given hexadecimal value
any error value refer SL_IPV4_VAL error codes

Example usage: Transform IPV4 to hexadecimal value

1 // Local variables
2 NetworkConfig_IpSettings_T myIpSet;
3 
4 // After calling the function the IPV4 values shall be :
5 // 0xc0a80278, the equivalent for 192.168.2.120
6 // 0xc0a80201, the equivalent for 192.168.2.1
7 // 0xffffff00, the equivalent for 255.255.255.0
8 myIpSet.ipv4 = NetworkConfig_Ipv4Value(192,168,2,120);
9 myIpSet.ipV4DnsServer = NetworkConfig_Ipv4Value(192,168,2,1);
10 myIpSet.ipV4Gateway = NetworkConfig_Ipv4Value(192,168,2,1);
11 myIpSet.ipV4Mask = NetworkConfig_Ipv4Value(255,255,255,0);
BCDS_DEPRECATED ( uint8_t   NetworkConfig_Ipv4Byteuint32_t ipValue, uint8_t index)
Parameters
[in]ipValueHexadecimal value of the IP V4
[in]indexDetermines which byte of the IPV4 will be returned.It should be from 0 to 3
Returns
On success returns the integer value of IP from given hexadecimal value
any error value refer SL_IPV4_BYTE error codes

Example usage: Extract IPV4 byte from the hexadecimal IP value and print it

1 // Get the IP settings
2 NetworkConfig_GetIpSettings(&myIpGet);
3 
4 // Print the retrieved IP address. The Gateway, DNS and Mask
5 // can also be extracted in the same manner
6 printf(" - The static IP was retrieved : %u.%u.%u.%u \n\r",
7  (unsigned int) (NetworkConfig_Ipv4Byte(myIpGet.ipV4, 3)),
8  (unsigned int) (NetworkConfig_Ipv4Byte(myIpGet.ipV4, 2)),
9  (unsigned int) (NetworkConfig_Ipv4Byte(myIpGet.ipV4, 1)),
10  (unsigned int) (NetworkConfig_Ipv4Byte(myIpGet.ipV4, 0)));
BCDS_DEPRECATED ( NetworkConfig_IpStatus_T   NetworkConfig_GetIpStatusvoid)
Parameters
[in]none
Returns
NETWORKCONFIG_IPV4_ACQUIRED - IPv4 was acquired
NETWORKCONFIG_IPV6_ACQUIRED - IPv6 was acquired (currently not supported)
NETWORKCONFIG_IP_NOT_ACQUIRED - IP was not acquired

Example usage: Block until IP status is acquired and Wlan is connected

1 while ((WLI_DISCONNECTED == WlanConnect_GetStatus())
2  || (NETWORKCONFIG_IP_NOT_ACQUIRED == NetworkConfig_GetIpStatus()))
3 {
4  // Stay here until connected and ip acquired.
5  // Timeout logic can be added here.
6 }
Warning
This API must be called only after initialization
BCDS_DEPRECATED ( Retcode_T   NetworkConfig_GetIpAddressuint8_t *url, uint32_t *destAddr)
Parameters
[in]url The string pointer holding the host name
[out]destAddr The variable in which IP address to be stored
Returns
RETCODE_OK IP address returned succesffuly
RETCODE_FAILURE Error occurred in fetching the ip address
RETCODE_NULL_POINTER if the input parameter passes NULL

Example usage:

1 uint8_t url[] = "www.google.com"
2 uint32_t ipAddress = 0x00;
3 Retcode_T ret;
4 ret = NetworkConfig_GetIpaddress(url, &ipAddress);
5 if(RETCODE_OK != ret)
6 {
7  //handle error
8 }

All rights reserved. The use is subject to the XDK SDK EULA by Bosch Connected Devices and Solutions GmbH.
This documentation file has been automatically generated on Thu Mar 14 2019 19:12:51 by doxygen 1.8.8