SimpleLink CC3100/CC3200 Host Driver  Version 1.0.1.6
Simplifies the implementation of Internet connectivity
Netcfg

Functions

_i32 sl_NetCfgSet (const _u8 ConfigId, const _u8 ConfigOpt, const _u8 ConfigLen, const _u8 *pValues)
 Internal function for setting network configurations. More...
 
_i32 sl_NetCfgGet (const _u8 ConfigId, _u8 *pConfigOpt, _u8 *pConfigLen, _u8 *pValues)
 Internal function for getting network configurations. More...
 

Enumerations

enum  Sl_NetCfg_e {
  SL_MAC_ADDRESS_SET = 1,
  SL_MAC_ADDRESS_GET = 2,
  SL_IPV4_STA_P2P_CL_GET_INFO = 3,
  SL_IPV4_STA_P2P_CL_DHCP_ENABLE = 4,
  SL_IPV4_STA_P2P_CL_STATIC_ENABLE = 5,
  SL_IPV4_AP_P2P_GO_GET_INFO = 6,
  SL_IPV4_AP_P2P_GO_STATIC_ENABLE = 7,
  SL_SET_HOST_RX_AGGR = 8,
  SL_IPV4_DHCP_CLIENT = 9,
  SL_IPV4_DNS_CLIENT = 10,
  SL_IPV4_ARP_FLUSH = 11,
  MAX_SETTINGS = 0xFF
}
 
enum  SlNetCfgIpv4DhcpClientState_e {
  SL_NETCFG_DHCP_CLIENT_UNKNOWN = 0,
  SL_NETCFG_DHCP_CLIENT_DISABLED,
  SL_NETCFG_DHCP_CLIENT_ENABLED,
  SL_NETCFG_DHCP_CLIENT_BOUND,
  SL_NETCFG_DHCP_CLIENT_RENEW,
  SL_NETCFG_DHCP_CLIENT_REBIND
}
 

Detailed Description

Function Documentation

_i32 sl_NetCfgGet ( const _u8  ConfigId,
_u8 *  pConfigOpt,
_u8 *  pConfigLen,
_u8 *  pValues 
)

Internal function for getting network configurations.

Returns
On success, zero is returned. On error, -1 is returned
Parameters
[in]ConfigIdconfiguration id
[out]pConfigOptGet configurations option
[out]pConfigLenThe length of the allocated memory as input, when the function complete, the value of this parameter would be the len that actually read from the device.
If the device return length that is longer from the input value, the function will cut the end of the returned structure and will return ESMALLBUF
[out]pValues- get configurations values
See also
Note
Warning
Examples:
1 SL_MAC_ADDRESS_GET:
2 
3 Get the device MAC address.
4 The returned MAC address is taken from FileSystem first. If the MAC address was not set by SL_MAC_ADDRESS_SET, the default MAC address
5 is retrieved from HW.
6 
7 _u8 macAddressVal[SL_MAC_ADDR_LEN];
8 _u8 macAddressLen = SL_MAC_ADDR_LEN;
9 sl_NetCfgGet(SL_MAC_ADDRESS_GET,NULL,&macAddressLen,(_u8 *)macAddressVal);
1 SL_IPV4_STA_P2P_CL_GET_INFO:
2 
3 Get IP address from WLAN station or P2P client. A DHCP flag is returned to indicate if the IP address is static or from DHCP.
4 
5 _u8 len = sizeof(SlNetCfgIpV4Args_t);
6 _u8 dhcpIsOn = 0;
7 SlNetCfgIpV4Args_t ipV4 = {0};
8 sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&dhcpIsOn,&len,(_u8 *)&ipV4);
9 
10 printf("DHCP is %s IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n",
11  (dhcpIsOn > 0) ? "ON" : "OFF",
12  SL_IPV4_BYTE(ipV4.ipV4,3),SL_IPV4_BYTE(ipV4.ipV4,2),SL_IPV4_BYTE(ipV4.ipV4,1),SL_IPV4_BYTE(ipV4.ipV4,0),
13  SL_IPV4_BYTE(ipV4.ipV4Mask,3),SL_IPV4_BYTE(ipV4.ipV4Mask,2),SL_IPV4_BYTE(ipV4.ipV4Mask,1),SL_IPV4_BYTE(ipV4.ipV4Mask,0),
14  SL_IPV4_BYTE(ipV4.ipV4Gateway,3),SL_IPV4_BYTE(ipV4.ipV4Gateway,2),SL_IPV4_BYTE(ipV4.ipV4Gateway,1),SL_IPV4_BYTE(ipV4.ipV4Gateway,0),
15  SL_IPV4_BYTE(ipV4.ipV4DnsServer,3),SL_IPV4_BYTE(ipV4.ipV4DnsServer,2),SL_IPV4_BYTE(ipV4.ipV4DnsServer,1),SL_IPV4_BYTE(ipV4.ipV4DnsServer,0));
1 SL_IPV4_AP_P2P_GO_GET_INFO:
2 
3 Get static IP address for AP or P2P go.
4 
5 _u8 len = sizeof(SlNetCfgIpV4Args_t);
6 _u8 dhcpIsOn = 0; // this flag is meaningless on AP/P2P go.
7 SlNetCfgIpV4Args_t ipV4 = {0};
8 sl_NetCfgGet(SL_IPV4_AP_P2P_GO_GET_INFO,&dhcpIsOn,&len,(_u8 *)&ipV4);
9 
10 printf("IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n",
11  SL_IPV4_BYTE(ipV4.ipV4,3),SL_IPV4_BYTE(ipV4.ipV4,2),SL_IPV4_BYTE(ipV4.ipV4,1),SL_IPV4_BYTE(ipV4.ipV4,0),
12  SL_IPV4_BYTE(ipV4.ipV4Mask,3),SL_IPV4_BYTE(ipV4.ipV4Mask,2),SL_IPV4_BYTE(ipV4.ipV4Mask,1),SL_IPV4_BYTE(ipV4.ipV4Mask,0),
13  SL_IPV4_BYTE(ipV4.ipV4Gateway,3),SL_IPV4_BYTE(ipV4.ipV4Gateway,2),SL_IPV4_BYTE(ipV4.ipV4Gateway,1),SL_IPV4_BYTE(ipV4.ipV4Gateway,0),
14  SL_IPV4_BYTE(ipV4.ipV4DnsServer,3),SL_IPV4_BYTE(ipV4.ipV4DnsServer,2),SL_IPV4_BYTE(ipV4.ipV4DnsServer,1),SL_IPV4_BYTE(ipV4.ipV4DnsServer,0));
1 SL_IPV4_DHCP_CLIENT:
2 
3 Get DHCP client inforamtion, when DhcpState is SL_NETCFG_DHCP_CLIENT_BOUND, SL_NETCFG_DHCP_CLIENT_RENEW or SL_NETCFG_DHCP_CLIENT_REBIND, dhcp inforamtion is not zeroed
4 
5 _u8 ConfigOpt = 0, ConfigLen = sizeof(SlNetCfgIpV4DhcpClientArgs_t);
6 _i32 Status;
7 SlNetCfgIpV4DhcpClientArgs_t Dhcp;
8 Status = sl_NetCfgGet(SL_IPV4_DHCP_CLIENT,&ConfigOpt,&ConfigLen,(_u8 *)&Dhcp);
9 if( Status )
10 {
11  // error
12 }
1 SL_IPV4_DNS_CLIENT:
2 
3 Get DNS max retries and secondary DNS address (DHCP and static configuration)
4 
5 _u8 ConfigOpt;
6 _i32 Status;
7 _u8 pConfigLen = sizeof(SlNetCfgIpV4DnsClientArgs_t);
8 SlNetCfgIpV4DnsClientArgs_t DnsOpt;
9 Status = sl_NetCfgGet(SL_IPV4_DNS_CLIENT,&ConfigOpt,&pConfigLen,&DnsOpt);
10 if( Status )
11 {
12  // error
13 }
_i32 sl_NetCfgSet ( const _u8  ConfigId,
const _u8  ConfigOpt,
const _u8  ConfigLen,
const _u8 *  pValues 
)

Internal function for setting network configurations.

Returns
On success, zero is returned. On error, -1 is returned
Parameters
[in]ConfigIdconfiguration id
[in]ConfigOptconfigurations option
[in]ConfigLenconfigurations len
[in]pValuesconfigurations values
See also
Note
Warning
Examples:
1 SL_MAC_ADDRESS_SET:
2 
3 Setting MAC address to the Device.
4 The new MAC address will override the default MAC address and it be saved in the FileSystem.
5 Requires restarting the device for updating this setting.
6 
7 _u8 MAC_Address[6];
8 MAC_Address[0] = 0x8;
9 MAC_Address[1] = 0x0;
10 MAC_Address[2] = 0x28;
11 MAC_Address[3] = 0x22;
12 MAC_Address[4] = 0x69;
13 MAC_Address[5] = 0x31;
14 sl_NetCfgSet(SL_MAC_ADDRESS_SET,1,SL_MAC_ADDR_LEN,(_u8 *)newMacAddress);
15 sl_Stop(0);
16 sl_Start(NULL,NULL,NULL);
1 SL_IPV4_STA_P2P_CL_STATIC_ENABLE:
2 
3 Setting a static IP address to the device working in STA mode or P2P client.
4 The IP address will be stored in the FileSystem.
5 In order to disable the static IP and get the address assigned from DHCP one should use SL_STA_P2P_CL_IPV4_DHCP_SET
6 
7 SlNetCfgIpV4Args_t ipV4;
8 ipV4.ipV4 = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address
9 ipV4.ipV4Mask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this STA/P2P
10 ipV4.ipV4Gateway = (_u32)SL_IPV4_VAL(10,1,1,1); // _u32 Default gateway address
11 ipV4.ipV4DnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); // _u32 DNS server address
12 
13 sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&ipV4);
14 sl_Stop(0);
15 sl_Start(NULL,NULL,NULL);
1 SL_IPV4_STA_P2P_CL_DHCP_ENABLE:
2 
3 Setting IP address by DHCP to FileSystem using WLAN sta mode or P2P client.
4  This should be done once if using Serial Flash.
5  This is the system's default mode for acquiring an IP address after WLAN connection.
6 _u8 val = 1;
7 sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,1,&val);
8 sl_Stop(0);
9 sl_Start(NULL,NULL,NULL);
1 SL_IPV4_AP_P2P_GO_STATIC_ENABLE:
2 
3 Setting a static IP address to the device working in AP mode or P2P go.
4 The IP address will be stored in the FileSystem. Requires restart.
5 
6 SlNetCfgIpV4Args_t ipV4;
7 ipV4.ipV4 = (_u32)SL_IPV4_VAL(10,1,1,201); // _u32 IP address
8 ipV4.ipV4Mask = (_u32)SL_IPV4_VAL(255,255,255,0); // _u32 Subnet mask for this AP/P2P
9 ipV4.ipV4Gateway = (_u32)SL_IPV4_VAL(10,1,1,1); // _u32 Default gateway address
10 ipV4.ipV4DnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); // _u32 DNS server address
11 
12 sl_NetCfgSet(SL_IPV4_AP_P2P_GO_STATIC_ENABLE,IPCONFIG_MODE_ENABLE_IPV4,sizeof(SlNetCfgIpV4Args_t),(_u8 *)&ipV4);
13 sl_Stop(0);
14 sl_Start(NULL,NULL,NULL);
1  SL_IPV4_DNS_CLIENT:
2 
3 Set DNS max retries (range 5-32, default 32 retries) and secondary DNS address (DHCP and static configuration)
4  changes not saved on the internal flash.
5 
6 _i32 Status;
7  SlNetCfgIpV4DnsClientArgs_t DnsOpt;
8 DnsOpt.DnsSecondServerAddr = SL_IPV4_VAL(8,8,8,8); ;
9 DnsOpt.DnsMaxRetries = 12;
10 Status = sl_NetCfgSet(SL_IPV4_DNS_CLIENT,0,sizeof(SlNetCfgIpV4DnsClientArgs_t),(unsigned char *)&DnsOpt);
11 if( Status )
12 {
13  // error
14 }
1  SL_IPV4_ARP_FLUSH:
2 
3 Flush ARP table
4 
5  _i32 Status;
6  Status = sl_NetCfgSet(SL_IPV4_ARP_FLUSH,0,0,NULL);
7  if( Status )
8  {
9  //
10  }

Data Structure Documentation

struct SlNetCfgIpV4Args_t

Definition at line 92 of file netcfg.h.

Data Fields
_u32 ipV4
_u32 ipV4DnsServer
_u32 ipV4Gateway
_u32 ipV4Mask
struct SlNetCfgIpV4DhcpClientArgs_t

Definition at line 100 of file netcfg.h.

Data Fields
_u32 DhcpServer
_u8 DhcpState
_u32 Dns[2]
_u32 Gateway
_u32 Ip
_u32 LeaseTime
_u32 Mask
_u8 Reserved[3]
struct SlNetCfgIpV4DnsClientArgs_t

Definition at line 122 of file netcfg.h.

Data Fields
_u32 DnsMaxRetries
_u32 DnsSecondServerAddr