XDK API  3.6.0
Documentation
Files | Data Structures | Macros | Typedefs | Enumerations | Functions
Wlan Connection

Module Describes the usage Of Wlan Interface. More...

+ Collaboration diagram for Wlan Connection:

Files

file  BCDS_WlanNetworkConnect.h
 

Data Structures

struct  WlanNetworkConnect_ScanInfo_S
 
struct  WlanNetworkConnect_ScanList_S
 

Macros

#define WLANNWCT_DUMMY_SSID   "XDK110"
 
#define WLANNWCT_ENROLLEE_PIN   "35072317"
 
#define WLANNWCT_INITIALZED   UINT8_C(1)
 
#define WLANNWCT_MAX_MAC_ADDR_LEN   UINT8_C(6)
 
#define WLANNWCT_MAX_SCAN_INFO_BUF   UINT8_C(20)
 
#define WLANNWCT_MAX_SSID_LENGTH   UINT8_C(32)
 
#define WLANNWCT_NOT_INITIALZED   UINT8_C(0)
 
#define WLANNWCT_TIMEOUT_SEC   UINT32_C(180)
 

Typedefs

typedef unsigned long (WlanNetworkConnect_ScanInterval_T)
 
typedef void(* WlanNetworkConnect_Callback_T )(WlanNetworkConnect_Status_T connectStatus)
 
typedef enum
WlanNetworkConnect_IpStatus_E 
WlanNetworkConnect_IpStatus_T
 
typedef signed char * WlanNetworkConnect_PassPhrase_T
 
typedef enum
WlanNetworkConnect_PwrCtrl_E 
WlanNetworkConnect_PwrCtrl_T
 
typedef enum
WlanNetworkConnect_Retcode_E 
WlanNetworkConnect_Retcode_T
 
typedef struct
WlanNetworkConnect_ScanInfo_S 
WlanNetworkConnect_ScanInfo_T
 
typedef struct
WlanNetworkConnect_ScanList_S 
WlanNetworkConnect_ScanList_T
 
typedef signed char * WlanNetworkConnect_SSID_T
 
typedef enum
WlanNetworkConnect_Status_E 
WlanNetworkConnect_Status_T
 
typedef signed char * WlanNetworkConnect_Username_T
 

Enumerations

enum  WlanNetworkConnect_IpStatus_E
 
enum  WlanNetworkConnect_PwrCtrl_E
 Enumeration to represent the different power modes. More...
 
enum  WlanNetworkConnect_Retcode_E
 Enumeration to represent the return codes of WLAN module. More...
 
enum  WlanNetworkConnect_Status_E
 

Functions

Retcode_T WlanNetworkConnect_DeInit (void)
 WLAN driver de-initialization function.
Performs memory deallocation, closes WLAN driver context and shuts down the hardware interfaces. More...
 
Retcode_T WlanNetworkConnect_DeleteAllProfiles (void)
 WLAN Delete All Profiles interface.
This function erases from memory all the stored profiles from WIFI Protected Setup functions. More...
 
Retcode_T WlanNetworkConnect_Disconnect (void)
 WLAN disconnect interface.
This function disconnects from the WLAN network.
Function is configurable in two ways: callback parameter is set to the address of the user function. More...
 
Retcode_T WlanNetworkConnect_EnterpriseWPA (WlanNetworkConnect_SSID_T connectSSID, WlanNetworkConnect_Username_T connectUsername, WlanNetworkConnect_PassPhrase_T connectPassPhrase)
 WLAN Connect to Enterprise WPA Network interface.
This function connects to an WPA2-PSK or WPA-PSK network.
Function is configurable in two ways: More...
 
uint8_t WlanNetworkConnect_GetInitStatus (void)
 Function to get the connection status.
This function return the connection status. More...
 
WlanNetworkConnect_IpStatus_T WlanNetworkConnect_GetIpStatus (void)
 Function to get the current network status This function sets a disconnect callback which is used to notify the user that there has been a disconnection that was not triggered by the user.ed on connection status. More...
 
WlanNetworkConnect_Status_T WlanNetworkConnect_GetStatus (void)
 Function to get the connection status.
This function return the connection status. More...
 
Retcode_T WlanNetworkConnect_Init (WlanNetworkConnect_Callback_T callBack)
 WLAN driver initialization function.
This function initializes WLAN driver context and Hardware interfaces; Also initializes the WLAN Stack. This API should be called first before calling any other API. More...
 
Retcode_T WlanNetworkConnect_Open (WlanNetworkConnect_SSID_T connectSSID)
 WLAN Connect to Open Network interface.
This function connects to an open network.
Function is configurable in two ways: More...
 
Retcode_T WlanNetworkConnect_PersonalWPA (WlanNetworkConnect_SSID_T connectSSID, WlanNetworkConnect_PassPhrase_T connectPass)
 WLAN Connect to Personal WPA Network interface.
This function connects to an WPA2-PSK or WPA-PSK network.
Function is configurable in two ways: More...
 
Retcode_T WlanNetworkConnect_PowerControl (WlanNetworkConnect_PwrCtrl_T mode, void *data)
 Wlan power control function. More...
 
Retcode_T WlanNetworkConnect_ScanNetworks (WlanNetworkConnect_ScanInterval_T scanInterval, WlanNetworkConnect_ScanList_T *scanList)
 Function used to scan the available networks.
Get the available scan information.
List of scan results will be available via the call back function. More...
 
Retcode_T WlanNetworkConnect_WEP_Open (WlanNetworkConnect_SSID_T connectSSID, WlanNetworkConnect_PassPhrase_T connectPass, uint8_t passPhraseLength)
 WLAN Connect to WEP Open Network interface.
This function connects to an WEP Open network.
Function is configurable in two ways: More...
 
Retcode_T WlanNetworkConnect_WPS_PBC (void)
 WLAN Connect using WPS PBC interface.
This function connects to a network by using the Wi-Fi Protected Setup. After calling the function the user must push the connect button of the Router for around 5 seconds.
Function is configurable in two ways: More...
 
Retcode_T WlanNetworkConnect_WPS_PIN (void)
 WLAN Connect using WPS PIN interface.
This function connects to a network by using the Wi-Fi Protected Setup. The function is configured with the following enrollee PIN code: 35072317. This PIN must be entered in the router interface after calling the function.
Function is configurable in two ways: More...
 

Detailed Description

The interface header exports High-level Wlan Interface API's for integrating with the Wlan Interface which are used to Initialize Wlan network connection Open Wlan Connection with the WEP & Wlan Connection Get status by deleting profiles and de-initialize the wlan connection.


Data Structure Documentation

struct WlanNetworkConnect_ScanInfo_S

Type defining scan information. Structure to store single network data after scanning

Data Fields

uint8_t Bssid [WLANNWCT_MAX_MAC_ADDR_LEN]
 
int8_t Rssi
 
uint8_t SecurityType
 
uint8_t Ssid [WLANNWCT_MAX_SSID_LENGTH]
 
uint8_t SsidLength
 

Field Documentation

uint8_t Bssid[WLANNWCT_MAX_MAC_ADDR_LEN]

MAC address of the access point

int8_t Rssi

RSSI value of the access point

uint8_t SecurityType

Security type of the access point

uint8_t Ssid[WLANNWCT_MAX_SSID_LENGTH]

Name of the access point

uint8_t SsidLength

Name of the access point

struct WlanNetworkConnect_ScanList_S

Type defining scan list Structure to store the scan list of all networks, which has the scan info data structure as well as other scan information

+ Collaboration diagram for WlanNetworkConnect_ScanList_S:

Data Fields

int8_t NumOfScanEntries
 
WlanNetworkConnect_ScanInfo_T ScanData [WLANNWCT_MAX_SCAN_INFO_BUF]
 
uint32_t TimeStamp
 

Field Documentation

int8_t NumOfScanEntries

Number of access points after scan

The structure containing the scan data

uint32_t TimeStamp

The last time stamp (seconds from last reset) when the scan was done

Macro Definition Documentation

#define WLANNWCT_DUMMY_SSID   "XDK110"

macro to represent the ssid of the device in WPS_PBC and WPS_PIN Security mode

#define WLANNWCT_ENROLLEE_PIN   "35072317"

This is the Enrollee PIN that must be entered in the router for WPS PIN Connection. The pin code is stored in the SFlash. The default pin code is 35072317.

#define WLANNWCT_INITIALZED   UINT8_C(1)

Macro to represent Initialized state of Wlan

#define WLANNWCT_MAX_MAC_ADDR_LEN   UINT8_C(6)

The max buffer for storing the MAC address length

#define WLANNWCT_MAX_SCAN_INFO_BUF   UINT8_C(20)

The max buffer for storing the scan data

#define WLANNWCT_MAX_SSID_LENGTH   UINT8_C(32)

The max buffer for storing the SSID length

#define WLANNWCT_NOT_INITIALZED   UINT8_C(0)

Macro to represent un-Initialized state of Wlan Macro to represent the blocking connection request timeout

#define WLANNWCT_TIMEOUT_SEC   UINT32_C(180)

Typedef Documentation

typedef unsigned long(WlanNetworkConnect_ScanInterval_T)

Type defining scan interval. This type is used for WlanNetworkConnect_scanNetworks function

typedef void(* WlanNetworkConnect_Callback_T)(WlanNetworkConnect_Status_T connectStatus)

Type defining the prototype which connection call back must conform to. This call back is called to notify the user when connection is established or Disconnection occurs. Returns the connection status as a parameter

typedef signed char* WlanNetworkConnect_PassPhrase_T

Type defining a pointer to char This type is used in order to pass the network Pass Phrase

typedef signed char* WlanNetworkConnect_SSID_T

Type defining a pointer to char. This type is used in order to pass the network SSID

typedef signed char* WlanNetworkConnect_Username_T

Type defining a pointer to char. This type is used in order to pass the network Username

Enumeration Type Documentation

Different status for the Current Network Configuration function callback

Enumerator
WLANNWCT_IPSTATUS_CT_AQRD 

Connected and IPV4 address acquired

WLANNWCT_IPSTATUS_CT_NAQRD 

Connected and IPV4 address not acquired

WLANNWCT_IPSTATUS_DISCT_AQRD 

Disconnected and IPV4 address acquired

WLANNWCT_IPSTATUS_DISCT_NAQRD 

Disconnected and IPV4 address not acquired

Enumerator
WLANNWCT_PWRCTRL_HIBERNATE 

Lowest power mode. Memories are not retained and only RTC will run.

WLANNWCT_PWRCTRL_WAKEUP 

Device wakeup from sleep mode or hibernate mode

WLANNWCT_PWRCTRL_FAST_CONNECT 

Device will first try to reestablish previous connection without scan

WLANNWCT_PWRCTRL_MDNS_PACKET 

Device will start or stop sending the mDNS packets

WLANNWCT_PWRCTRL_MODE_MAX 
Enumerator
RETCODE_NO_NW_AVAILABLE 

No available networks

RETCODE_ALREADY_DISCONNECTED 

Disconnected already

RETCODE_CONNECTION_ERROR 

Connection error

RETCODE_ERROR_WRONG_PASSWORD 

Password error while connecting

RETCODE_ERROR_IP_NOT_ACQ 

IP address not acquired

RETCODE_DISCONNECT_ERROR 

Disconnect error

RETCODE_SIMPLELINK_ERROR 

Error from Simplelink library

RETCODE_TIMERCREATE_FAILURE 

Error while creating timer

RETCODE_TIMERSTART_FAILURE 

Error while starting timer

RETCODE_TIME_NULL 

Error while get timer value

RETCODE_SL_STOP_FAILED 

sl_Stop failed

RETCODE_SL_MODE_FAILED 

Simplelink mode set failed

RETCODE_SL_POLICY_SET_FAILED 

Failed to set simplelink policy

RETCODE_MDNS_ALREADY_STARTED 

mDNS packets send already started

RETCODE_MDNS_ALREADY_STOPPED 

mDNS packets send already stopped

Type defining callback status. This type is used for different connection status for the WLAN Connect function callback.

Enumerator
WLANNWCT_STATUS_CONNECTED 

Wlan status Connected

WLANNWCT_STATUS_DISCONNECTED 

Wlan status Disconnected

WLANNWCT_STATUS_CONNECTERR 

Wlan status Connection error

WLANNWCT_STATUS_PWD_ERROR 

Wlan status password error while connecting

WLANNWCT_STATUS_DISCONNECTERR 

Wlan status Disconnection error

WLANNWCT_STATUS_MAX 

Function Documentation

Retcode_T WlanNetworkConnect_DeInit ( void  )
Parameters
[in]none
Returns
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
RETCODE_OK - Successfully WLAN driver de-initialized.
RETCODE_SIMPLELINK_ERROR - De-initializing WLAN driver failed
RETCODE_UNEXPECTED_BEHAVIOR - FreeRTOS timer delete failure

Example1 usage: Deinitialize the WLAN Stack

1 // Deinitialize WLAN stack
2 WlanNetworkConnect_DeInit();

Example2 usage: Restart Device

1 // Callback function
2 void myConnectCallbackFunc(WlanNetworkConnect_Status_T returnStatus)
3 {
4  if (WLANNWCT_STATUS_DISCONNECTED == returnStatus)
5  {
6  // Network dis-connection successfully
7  printf("Callback Function : DisConnect OK!\n\r");
8  // User may add logic once the connection is done
9  // E.g launch another OS Timer
10  }
11  else
12  {
13  // user may retry to connect
14  }
15 }
16 Retcode_T retStatus;
17 // Initialize WLAN driver and WLAN stack
18 retStatus = WlanNetworkConnect_Init(myConnectCallbackFunc);
19 if (RETCODE_OK != retStatus)
20 {
21  printf("WLAN driver initialization failure");
22 }
23 
24 // Local API return status
25 Retcode_T retStatus[2];
26 
27 retStatus[0] = WlanNetworkConnect_DeInit();
28 retStatus[1] = WlanNetworkConnect_Init(myConnectCallbackFunc);
29 
30 // Check if device restart has finished with error
31 if ((RETCODE_OK != retStatus[0]) || (RETCODE_OK != retStatus[1]))
32 {
33  printf("Restart device failed");
34 }

+ Here is the caller graph for this function:

Retcode_T WlanNetworkConnect_DeleteAllProfiles ( void  )
Parameters
[in]none
Returns
RETCODE_OK - successfully erased all profiles.
RETCODE_SIMPLELINK_ERROR - error during erase
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: Delete all stored WLAN profiles
1 Retcode_T retStatus;
2 
3 retStatus = WlanNetworkConnect_DeleteAllProfiles();
4 
5 if (RETCODE_OK != retStatus)
6 {
7  printf("Profiles were not deleted correctly");
8 }
Retcode_T WlanNetworkConnect_Disconnect ( void  )
Returns
RETCODE_OK successfully disconnected from Access point.
RETCODE_DISCONNECT_ERROR Error in disconnecting
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: Disconnect with callback (non-blocking)
1 void myDisconnectCallbackFunc(WlanNetworkConnect_Status_T returnStatus)
2 {
3  if (WLANNWCT_STATUS_CONNECTED == returnStatus)
4  {
5  // Network disconnection successfully from WlanNetworkConnect_Disconnect function
6  printf("Callback Function : Disconnect OK!\n\r");
7  }
8  else
9  {
10  //user can retry
11  }
12 }
13 
14 // local variables
15 Retcode_T retStatus;
16 retStatus = WlanNetworkConnect_Init(myConnectCallbackFunc);
17 if(RETCODE_OK == retStatus)
18 {
19  // disconnect from network in non-blocking mode
20  retStatus = WlanNetworkConnect_Disconnect();
21 
22  if (RETCODE_OK == retStatus)
23  {
24  // Disconnect has completed successfully
25  printf("Disconnected successfully!\n\r");
26  }
27 }

+ Here is the caller graph for this function:

Retcode_T WlanNetworkConnect_EnterpriseWPA ( WlanNetworkConnect_SSID_T  connectSSID,
WlanNetworkConnect_Username_T  connectUsername,
WlanNetworkConnect_PassPhrase_T  connectPassPhrase 
)
Parameters
[in]connectionSSIDPointer to char containing the network SSID to connect to.
[in]connectUsernamePointer to char containing the network Username to connect to.
[in]connectionPassPointer to char containing the network Pass Phrase.
Returns
RETCODE_OK - API return code for success.
RETCODE_SIMPLELINK_ERROR - Failure returned by simplelink API.
RETCODE_ERROR_SSID_NOT_FOUND - Failure because of incorrect SSID.
RETCODE_ERROR_WRONG_PASSWORD - Failure because of incorrect Pass phrase.
RETCODE_ERROR_IP_NOT_ACQ - Connected but ip not acquired
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
Note
It uses index 0 for certificate. The Host must have been programmed with the certificate in this Index prior. It uses PEAP0-MSCHAPv2 as EAP method. It uses the connectUsername for default and anonymous user names

Example usage: Connect to Enterprise WPA/WPA2 network with callback (non-blocking)

1 // Callback function
2 void myConnectCallbackFunc(WlanNetworkConnect_Status_T returnStatus)
3 {
4  if (WLANNWCT_STATUS_CONNECTED == returnStatus)
5  {
6  // Network connection successfully
7  printf("Callback Function : Connect OK!\n\r");
8  // User may add logic once the connection is done
9  // E.g launch another OS Timer
10  }
11  else
12  {
13  // user may retry to connect
14  }
15 }
16 
17 // local variables
18 WlanNetworkConnect_SSID_T connectSSID;
19 Retcode_T retStatus;
20 WlanNetworkConnect_PassPhrase_T connectPassPhrase;
21 
22 // WPA/WPA2 encrypted wireless network settings
23 connectSSID = (WlanNetworkConnect_SSID_T)"WPA-NETWORK-NAME";
24 connectUsername = (WlanNetworkConnect_Username_T)"WPA-USERNAME-NAME";
25 connectPassPhrase = (WlanNetworkConnect_PassPhrase_T)"WPA-PASSWORD";
26 
27 // Set callback functions
28 connectCallback = myConnectCallbackFunc;
29 
30 // Connect to network --> non blocking function with callback
31 retStatus = WlanNetworkConnect_EnterpriseWPA(connectSSID, connectUsername, connectPassPhrase);
uint8_t WlanNetworkConnect_GetInitStatus ( void  )
Parameters
[in]none
Returns
WLANNWCT_INITIALZED - Wlan module is initialized.
WLANNWCT_NOT_INITIALZED - Wlan module is not initialized.

+ Here is the caller graph for this function:

WlanNetworkConnect_IpStatus_T WlanNetworkConnect_GetIpStatus ( void  )

This API must be called only after initialization

Parameters
[in]allDisconnectCallbackPointer to user function callback. Returns the WLAN connection status as a parameter.
Returns
WLANNWCT_IPSTATUS_CT_AQRD - currently WLAN connected and IP acquired.
WLANNWCT_IPSTATUS_CT_NAQRD - currently WLAN connected and IP not acquired.
WLANNWCT_IPSTATUS_DISCT_AQRD - currently WLAN disconnected and IP acquired
WLANNWCT_IPSTATUS_DISCT_NAQRD - currently WLAN disconnected and IP not acquired.

Example usage: Get current status of a network and set a callback for any disconnect events

1 void myAllDisconnectCallbackFunc(WlanNetworkConnect_Status_T returnStatus)
2 {
3  if (WLANNWCT_STATUS_DISCONNECTED == returnStatus)
4  {
5  // Network disconnection successfully from WlanNetworkConnect_Disconnect function
6  printf("Callback Function : A disconnect event has happened!\n\r");
7  }
8 }
9 
10 // local variables
11 Retcode_T retStatus;
12 
13 if (WLANNWCT_IPSTATUS_DISCT_NAQRD
14  != WlanNetworkConnect_GetIpStatus()
15  && (WLANNWCT_IPSTATUS_DISCT_AQRD
16  != WlanNetworkConnect_GetIpStatus()))
17 {
18  retStatus = WlanNetworkConnect_Disconnect();
19  printf("Finished disconnection successfully \n\r");
20 }

+ Here is the caller graph for this function:

WlanNetworkConnect_Status_T WlanNetworkConnect_GetStatus ( void  )
Parameters
[in]none
Returns
WLANNWCT_STATUS_CONNECTED - WLAN connected obtained after calling connect function.
WLANNWCT_STATUS_DISCONNECTED - WLAN disconnected obtained after calling disconnect function.

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

1 while ((WLANNWCT_STATUS_DISCONNECTED == WlanNetworkConnect_GetStatus())
2  || (WLANNWCNF_IPSTATUS_IP_NOTAQRD == WlanNetworkConfig_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

+ Here is the caller graph for this function:

Retcode_T WlanNetworkConnect_Init ( WlanNetworkConnect_Callback_T  callBack)
Note
By default device is configured to STA mode if user want to change the mode, they need to use the Simple link API directly
Parameters
[in]callBackcall poiner to notify the connection status
Returns
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
RETCODE_OK - Successfully WLAN driver initialized.
RETCODE_SIMPLELINK_ERROR - Not initialized WLAN driver.
RETCODE_NULL_POINTER - Invalid callBack passed
RETCODE_TIMERCREATE_FAILURE - Failure in s/w timer creation

Example1 usage: Initialize the WLAN Stack and the WLAN Driver

1 // Callback function
2 void myConnectCallbackFunc(WlanNetworkConnect_Status_T returnStatus)
3 {
4  if (WLANNWCT_STATUS_CONNECTED == returnStatus)
5  {
6  // Network connection successfully
7  printf("Callback Function : Connect OK!\n\r");
8  // User may add logic once the connection is done
9  // E.g launch another OS Timer
10  }
11  else
12  {
13  // user may retry to connect
14  }
15 }
16 Retcode_T retStatus;
17 // Initialize WLAN driver and WLAN stack
18 retStatus = WlanNetworkConnect_Init(myConnectCallbackFunc);
19 if (RETCODE_OK != retStatus)
20 {
21  printf("WLAN driver initialization failure");
22 }

Example2 usage: Restart Device

1 // Local API return status
2 Retcode_T retStatus[2];
3 
4 retStatus[0] = WlanNetworkConnect_DeInit();
5 retStatus[1] = WlanNetworkConnect_Init(myConnectCallbackFunc);
6 
7 // Check if device restart has finished with error
8 if ((RETCODE_OK != retStatus[0]) || (RETCODE_OK != retStatus[1]))
9 {
10  printf("Restart device failed");
11 }

+ Here is the caller graph for this function:

Retcode_T WlanNetworkConnect_Open ( WlanNetworkConnect_SSID_T  connectSSID)
Parameters
[in]connectSSIDPointer to char containing the network SSID to connect to.
Returns
RETCODE_OK - Successfully connected to the AP.
RETCODE_SIMPLELINK_ERROR - Failure returned by simplelink API.
WLANNWCT_STATUS_CONNECTERR - Failure because of incorrect SSID.
RETCODE_ERROR_IP_NOT_ACQ - Connected but ip not acquired.
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: Connect to an open WLAN network with callback (non-blocking)

1 // Callback function
2 void myConnectCallbackFunc(WlanNetworkConnect_Status_T returnStatus)
3 {
4  if (WLANNWCT_STATUS_CONNECTED == returnStatus)
5  {
6  // Network connection successfully
7  printf("Callback Function : Connect OK!\n\r");
8  // User may add logic once the connection is done
9  // E.g launch another OS Timer
10  }
11  else
12  {
13  // user may retry to connect
14  }
15 }
16 
17 // local variables
18 WlanNetworkConnect_SSID_T connectSSID;
19 Retcode_T retStatus;
20 retStatus = WlanNetworkConnect_Init(myConnectCallbackFunc);
21 
22 // Open wireless network settings
23 connectSSID = (WlanNetworkConnect_SSID_T)"Name-Of-Open-Network";
24 
25 
26 // Connect to network --> non blocking function with callback
27 retStatus = WlanNetworkConnect_Open(connectSSID, false);
Retcode_T WlanNetworkConnect_PersonalWPA ( WlanNetworkConnect_SSID_T  connectSSID,
WlanNetworkConnect_PassPhrase_T  connectPass 
)
Parameters
[in]connectionSSIDPointer to char containing the network SSID to connect to.
[in]connectionPassPointer to char containing the network Pass Phrase.
Returns
RETCODE_OK - API return code for success.
RETCODE_SIMPLELINK_ERROR - Failure returned by simplelink API.
RETCODE_ERROR_SSID_NOT_FOUND - Failure because of incorrect SSID.
RETCODE_ERROR_WRONG_PASSWORD - Failure because of incorrect Pass phrase.
RETCODE_ERROR_IP_NOT_ACQ - Connected but ip not acquired
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: Connect to Personal WPA/WPA2 network with callback (non-blocking)

1 // Callback function
2 void myConnectCallbackFunc(WlanNetworkConnect_Status_T returnStatus)
3 {
4  if (WLANNWCT_STATUS_CONNECTED == returnStatus)
5  {
6  // Network connection successfully
7  printf("Callback Function : Connect OK!\n\r");
8  // User may add logic once the connection is done
9  // E.g launch another OS Timer
10  }
11  else
12  {
13  // user may retry to connect
14  }
15 }
16 
17 // local variables
18 WlanNetworkConnect_SSID_T connectSSID;
19 Retcode_T retStatus;
20 WlanNetworkConnect_PassPhrase_T connectPassPhrase;
21 
22 // WPA/WPA2 encrypted wireless network settings
23 connectSSID = (WlanNetworkConnect_SSID_T)"WPA-NETWORK-NAME";
24 connectPassPhrase = (WlanNetworkConnect_PassPhrase_T)"WPA-PASSWORD";
25 
26 // Set callback functions
27 connectCallback = myConnectCallbackFunc;
28 
29 // Connect to network --> non blocking function with callback
30 retStatus = WlanNetworkConnect_PersonalWPA(connectSSID, connectPassPhrase);

+ Here is the caller graph for this function:

Retcode_T WlanNetworkConnect_PowerControl ( WlanNetworkConnect_PwrCtrl_T  mode,
void *  data 
)
Parameters
[in]mode- Wlan power modes
[in]data- data based on the power mode that is being notified

| mode | data |

| WLANNWCT_PWRCTRL_HIBERNATE | not used |

| WLANNWCT_PWRCTRL_WAKEUP | not used |

| WLANNWCT_PWRCTRL_FAST_CONNECT | bool |

| WLANNWCT_PWRCTRL_MDNS_PACKET | bool |

Example1 usage: Hibernate mode

1 // This is the lowest power mode. If the device enter into hibernate mode, device is powered off except RTC clock keeps running.
2 // In this mode, memory is not retained, and wake up requires a cold boot initialization.
3 WlanNetworkConnect_PowerControl(WLANNWCT_PWRCTRL_HIBERNATE, NULL);
Note
If the network is in connected mode, then disconnect from network and enter into hibernate mode. If the device is in hibernate mode, then system won't connected to the specified network.

Example2 usage: Wakeup mode

1 // In this mode, device will wakeup from sleep mode or hibernate mode. Ensure that, if the device is in hibernate mode, then wakeup
2 // requires boot initialization
3 WlanNetworkConnect_PowerControl(WLANNWCT_PWRCTRL_WAKEUP, NULL);
Note
If the device is in hibernate mode, then wakeup the device and connect to the specified network.

Example3 usage: Fast connect mode

1 // In fast connect policy, in the event of disconnect or upon initialization, the network subsystem immediately tries to connect the
2 // last access point that it was connected. it remembers the last ssid, security credentials and channel info of last access point.
3 // The main advantage of fast connect over auto connect is that the system skips the scan. If the last access point connection fails,
4 // then it runs the scan process and look for the highest priority profile and connect to it.
5 
6 // To enable fast connect policy
7 bool statusFlag = true;
8 WlanNetworkConnect_PowerControl(WLANNWCT_PWRCTRL_FAST_CONNECT, (void *)&statusFlag);
9 
10 // To disable fast connect policy
11 bool statusFlag = false;
12 WlanNetworkConnect_PowerControl(WLANNWCT_PWRCTRL_FAST_CONNECT, (void *)&statusFlag);

Example4 usage: mDNS mode

1 // After connecting to access point, network processor will send the mDNS packets for service discovery. Stop sending this mDNS packets
2 // when it not required by the system application for power optimization.
3 
4 // To enable mDNS protocol enable
5 bool statusFlag = true;
6 WlanNetworkConnect_PowerControl(WLANNWCT_PWRCTRL_MDNS_PACKET, (void *)&statusFlag);
7 
8 // To enable mDNS protocol disable
9 bool statusFlag = false;
10 WlanNetworkConnect_PowerControl(WLANNWCT_PWRCTRL_MDNS_PACKET, (void *)&statusFlag);
Returns
RETCODE_OK in the case of success or an error code otherwise.
Retcode_T WlanNetworkConnect_ScanNetworks ( WlanNetworkConnect_ScanInterval_T  scanInterval,
WlanNetworkConnect_ScanList_T scanList 
)
Parameters
[in]scanIntervalTime interval between network scan.
[out]scanListStructure pointer hold the WLAN scan information data.
Returns
RETCODE_OK - scan done successful.
RETCODE_SIMPLELINK_ERROR - scan was not successful.
RETCODE_NO_NW_AVAILABLE - No network available to scan.
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: Scan networks and print SSIDs
1 // local variables
2 Retcode_T retScanStatus;
3 WlanNetworkConnect_ScanInterval_T scanInterval;
4 WlanNetworkConnect_ScanList_T scanList;
5 
6 // Set scan interval
7 scanInterval = 5;
8 
9 // Fill out the scan list by calling the scan network function
10 retScanStatus = WlanNetworkConnect_ScanNetworks(scanInterval, &scanList);
11 
12 // Set the number of entries
13 int nbEntries = scanList.numOfScanEntries;
14 
15 // Print all the non-empty SSIDs
16 for (int i = 0; i < nbEntries; i++)
17 {
18  if (0 != scanList.scanData[i].ssidLength)
19  {
20  printf(" - found SSID number %d is : %s\n\r", i, scanList.scanData[i].ssid);
21 
22  // Delay each printf with 0,5 seconds
23  vTaskDelay(DELAY_500_MSEC);
24  }
25 }

+ Here is the caller graph for this function:

Retcode_T WlanNetworkConnect_WEP_Open ( WlanNetworkConnect_SSID_T  connectSSID,
WlanNetworkConnect_PassPhrase_T  connectPass,
uint8_t  passPhraseLength 
)
Parameters
[in]connectionSSIDPointer to char containing the network SSID to connect to.
[in]connectionPassPointer to char containing the network Pass Phrase.
[in]passPhraseLengthLength of the Pass Phrase
Returns
RETCODE_OK - API return code for success.
RETCODE_SIMPLELINK_ERROR - Failure returned by simplelink API.
RETCODE_ERROR_SSID_NOT_FOUND - Failure because of incorrect SSID.
RETCODE_ERROR_WRONG_PASSWORD - Failure because of incorrect Pass phrase.
RETCODE_ERROR_IP_NOT_ACQ - Connected but ip not acquired
RETCODE_INVALID_PARAM - passPhraseLength is zero
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: Connect to an WEP Open network with callback (non-blocking)

1 // Callback function
2 void myConnectCallbackFunc(WlanNetworkConnect_Status_T returnStatus)
3 {
4  if (WLANNWCT_STATUS_CONNECTED == returnStatus)
5  {
6  // Network connection successfully
7  printf("Callback Function : Connect OK!\n\r");
8  // User may add logic once the connection is done
9  // E.g launch another OS Timer
10  }
11  else
12  {
13  // user may retry to connect
14  }
15 }
16 
17 // local variables
18 //For example if AP is configured to WEP with 40bit Hex password of: "FFFFFFFFFF"
19 char passPhrase[5] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
20 WlanNetworkConnect_SSID_T connectSSID;
21 Retcode_T retStatus;
22 WlanNetworkConnect_PassPhrase_T connectPassPhrase;
23 uint8_t passPhraseLength;[Don't use strlen() in order not to bump on zero/NULL in the passPhrase]
24 
25 // WEP encrypted wireless network settings
26 connectSSID = (WlanNetworkConnect_SSID_T)"WEP-OPEN-NETWORK-NAME";
27 connectPassPhrase = (WlanNetworkConnect_PassPhrase_T)passPhrase;
28 passPhraseLength = UINT8_C(5);
29 
30 // Connect to network --> non blocking function with callback
31 retStatus = WlanNetworkConnect_WEP_Open(connectSSID, connectPassPhrase,passPhraseLength, false);
Retcode_T WlanNetworkConnect_WPS_PBC ( void  )
Returns
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
RETCODE_OK - API return code for success.
RETCODE_SIMPLELINK_ERROR - Failure returned by simplelink API.
RETCODE_CONNECTION_ERROR - connection Failure .
RETCODE_ERROR_IP_NOT_ACQ - Connected but ip not acquired

Example usage: Connect to a wireless network using WPS (WiFi Protected Setup) PBC (Push Button Connect) with callback (non-blocking)

1  // Callback function
2  void myConnectCallbackFunc(WlanNetworkConnect_Status_T returnStatus)
3  {
4  if (WLANNWCT_STATUS_CONNECTED == returnStatus)
5  {
6  // Network connection successfully
7  printf("Callback Function : Connect OK!\n\r");
8  // User may add logic once the connection is done
9  // E.g launch another OS Timer
10  }
11  else
12  {
13  // user may retry to connect
14  }
15  }
16 
17  // local variables
18  Retcode_T retStatus[3];
19 
20  // Set callback functions
21 
22 // Because the board connects to network very fast, the user
23  // must disconnect and delete all stored profiles before
24  // retrying to connect with WPS PBC
25  retStatus[0] = WlanNetworkConnect_Disconnect();
26 
27  // Delete all stored profiles in order to connect WPS by pushing
28  // the button all the time. Remove this line if you want to
29  // keep profile after running once the function.
30  retStatus[1] = WlanNetworkConnect_DeleteAllProfiles();
31 
32  // Connect to network --> non blocking function with callback
33  retStatus[2] = WlanNetworkConnect_WPS_PBC();
Retcode_T WlanNetworkConnect_WPS_PIN ( void  )
Returns
RETCODE_OK - API return code for success.
RETCODE_SIMPLELINK_ERROR - Failure returned by simplelink API.
RETCODE_CONNECTION_ERROR - Connection Failure because of incorrect Pin.
RETCODE_ERROR_IP_NOT_ACQ - Connected but IP not acquired
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: Connect to a wireless network using WPS (WiFi Protected Setup) PIN (Personal Identify. Number) with callback (non-blocking)
1  // Callback function
2  void myConnectCallbackFunc(WlanNetworkConnect_Status_T returnStatus)
3  {
4  if (WLANNWCT_STATUS_CONNECTED == returnStatus)
5  {
6  // Network connection successfully
7  printf("Callback Function : Connect OK!\n\r");
8  // User may add logic once the connection is done
9  // E.g launch another OS Timer
10  }
11  else
12  {
13  // user may retry to connect
14  }
15  }
16 
17  // local variables
18  Retcode_T retStatus[3];
19 
20 
21 // Because the board connects to network very fast, the user
22  // must disconnect and delete all stored profiles before
23  // retrying to connect with WPS PIN
24  retStatus[0] = WlanNetworkConnect_Disconnect();
25 
26  // Delete all stored profiles in order to connect WPS using
27  // enrollee PIN all the time. Remove this line if you want to
28  // keep profile after running once the function.
29  retStatus[1] = WlanNetworkConnect_DeleteAllProfiles();
30 
31  // Connect to network --> non blocking function with callback
32  retStatus[2] = WlanNetworkConnect_WPS_PIN();

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:53 by doxygen 1.8.8