SimpleLink Host Driver  0.0.5.1
 All Data Structures Functions Variables Groups
Netcfg

Data Structures

struct  _NetCfgIpV4Args_t
 

Macros

#define SL_MAC_ADDR_LEN   6
 
#define SL_IPV4_VAL(add_3, add_2, add_1, add_0)   ( (((unsigned long)add_3 << 24) & 0xFF000000) | (((unsigned long)add_2 << 16) & 0xFF0000) | (((unsigned long)add_1 << 8) & 0xFF00) | ((unsigned long)add_0 & 0xFF) )
 
#define SL_IPV4_BYTE(val, index)   ( (val >> (index*8)) & 0xFF )
 

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,
  MAX_SETTINGS = 0xFF
}
 

Functions

long sl_NetCfgSet (unsigned char ConfigId, unsigned char ConfigOpt, unsigned char ConfigLen, unsigned char *pValues)
 Internal function for setting network configurations. More...
 
long sl_NetCfgGet (unsigned char ConfigId, unsigned char *pConfigOpt, unsigned char *pConfigLen, unsigned char *pValues)
 Internal function for getting network configurations. More...
 

Detailed Description

Function Documentation

long sl_NetCfgGet ( unsigned char  ConfigId,
unsigned char *  pConfigOpt,
unsigned char *  pConfigLen,
unsigned char *  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:
SL_MAC_ADDRESS_GET:
Get the device MAC address.
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
is retreived from HW.
unsigned char macAddressVal[SL_MAC_ADDR_LEN];
unsigned char macAddressLen = SL_MAC_ADDR_LEN;
sl_NetCfgGet(SL_MAC_ADDRESS_GET,NULL,&macAddressLen,(unsigned char *)macAddressVal);
SL_IPV4_STA_P2P_CL_GET_INFO:
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.
unsigned char len = sizeof(_NetCfgIpV4Args_t);
unsigned char dhcpIsOn = 0;
_NetCfgIpV4Args_t ipV4 = {0};
sl_NetCfgGet(SL_IPV4_STA_P2P_CL_GET_INFO,&dhcpIsOn,&len,(unsigned char *)&ipV4);
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",
(dhcpIsOn > 0) ? "ON" : "OFF",
SL_IPV4_BYTE(ipV4.ipV4,3),SL_IPV4_BYTE(ipV4.ipV4,2),SL_IPV4_BYTE(ipV4.ipV4,1),SL_IPV4_BYTE(ipV4.ipV4,0),
SL_IPV4_BYTE(ipV4.ipV4Mask,3),SL_IPV4_BYTE(ipV4.ipV4Mask,2),SL_IPV4_BYTE(ipV4.ipV4Mask,1),SL_IPV4_BYTE(ipV4.ipV4Mask,0),
SL_IPV4_BYTE(ipV4.ipV4Gateway,3),SL_IPV4_BYTE(ipV4.ipV4Gateway,2),SL_IPV4_BYTE(ipV4.ipV4Gateway,1),SL_IPV4_BYTE(ipV4.ipV4Gateway,0),
SL_IPV4_BYTE(ipV4.ipV4DnsServer,3),SL_IPV4_BYTE(ipV4.ipV4DnsServer,2),SL_IPV4_BYTE(ipV4.ipV4DnsServer,1),SL_IPV4_BYTE(ipV4.ipV4DnsServer,0));
SL_IPV4_AP_P2P_GO_GET_INFO:
Get static IP address for AP or P2P go.
unsigned char len = sizeof(_NetCfgIpV4Args_t);
unsigned char dhcpIsOn = 0; // thig flag is meaningless on AP/P2P go.
_NetCfgIpV4Args_t ipV4 = {0};
sl_NetCfgGet(SL_IPV4_AP_P2P_GO_GET_INFO,&dhcpIsOn,&len,(unsigned char *)&ipV4);
printf("IP %d.%d.%d.%d MASK %d.%d.%d.%d GW %d.%d.%d.%d DNS %d.%d.%d.%d\n",
SL_IPV4_BYTE(ipV4.ipV4,3),SL_IPV4_BYTE(ipV4.ipV4,2),SL_IPV4_BYTE(ipV4.ipV4,1),SL_IPV4_BYTE(ipV4.ipV4,0),
SL_IPV4_BYTE(ipV4.ipV4Mask,3),SL_IPV4_BYTE(ipV4.ipV4Mask,2),SL_IPV4_BYTE(ipV4.ipV4Mask,1),SL_IPV4_BYTE(ipV4.ipV4Mask,0),
SL_IPV4_BYTE(ipV4.ipV4Gateway,3),SL_IPV4_BYTE(ipV4.ipV4Gateway,2),SL_IPV4_BYTE(ipV4.ipV4Gateway,1),SL_IPV4_BYTE(ipV4.ipV4Gateway,0),
SL_IPV4_BYTE(ipV4.ipV4DnsServer,3),SL_IPV4_BYTE(ipV4.ipV4DnsServer,2),SL_IPV4_BYTE(ipV4.ipV4DnsServer,1),SL_IPV4_BYTE(ipV4.ipV4DnsServer,0));
long sl_NetCfgSet ( unsigned char  ConfigId,
unsigned char  ConfigOpt,
unsigned char  ConfigLen,
unsigned char *  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:
SL_MAC_ADDRESS_SET:
Setting MAC address to the Device.
The new MAC address will override the default MAC address and it be saved in the FileSystem.
Requires restarting the device for updating this setting.
unsigned char MAC_Address[6];
MAC_Address[0] = 0x8;
MAC_Address[1] = 0x0;
MAC_Address[2] = 0x28;
MAC_Address[3] = 0x22;
MAC_Address[4] = 0x69;
MAC_Address[5] = 0x31;
sl_NetCfgSet(SL_MAC_ADDRESS_SET,1,SL_MAC_ADDR_LEN,(unsigned char *)newMacAddress);
sl_Start(NULL,NULL,NULL);
SL_IPV4_STA_P2P_CL_STATIC_ENABLE:
Setting a static IP address to the device working in STA mode or P2P client.
The IP address will be stored in the FileSystem.
In order to disable the static IP and get the address assigned from DHCP one should use SL_STA_P2P_CL_IPV4_DHCP_SET
ipV4.ipV4 = (unsigned long)SL_IPV4_VAL(10,1,1,201); // unsigned long IP address
ipV4.ipV4Mask = (unsigned long)SL_IPV4_VAL(255,255,255,0); // unsigned long Subnet mask for this STA/P2P
ipV4.ipV4Gateway = (unsigned long)SL_IPV4_VAL(10,1,1,1); // unsigned long Default gateway address
ipV4.ipV4DnsServer = (unsigned long)SL_IPV4_VAL(8,16,32,64); // unsigned long DNS server address
sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE,1,sizeof(_NetCfgIpV4Args_t),(unsigned char *)&ipV4);
SL_IPV4_STA_P2P_CL_DHCP_ENABLE:
Setting IP address by DHCP to FileSystem using WLAN sta mode or P2P client.
This should be done once if using Serial Flash.
This is the system's default mode for acquiring an IP address after WLAN connection.
unsigned char val = 1;
sl_NetCfgSet(SL_IPV4_STA_P2P_CL_DHCP_ENABLE,1,1,&val);
SL_IPV4_AP_P2P_GO_STATIC_ENABLE:
Setting a static IP address to the device working in AP mode or P2P go.
The IP address will be stored in the FileSystem. Requires restart.
ipV4.ipV4 = (unsigned long)SL_IPV4_VAL(10,1,1,201); // unsigned long IP address
ipV4.ipV4Mask = (unsigned long)SL_IPV4_VAL(255,255,255,0); // unsigned long Subnet mask for this AP/P2P
ipV4.ipV4Gateway = (unsigned long)SL_IPV4_VAL(10,1,1,1); // unsigned long Default gateway address
ipV4.ipV4DnsServer = (unsigned long)SL_IPV4_VAL(8,16,32,64); // unsigned long DNS server address
sl_NetCfgSet(SL_IPV4_AP_P2P_GO_STATIC_ENABLE,1,sizeof(_NetCfgIpV4Args_t),(unsigned char *)&ipV4);
sl_Start(NULL,NULL,NULL);