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

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

+ Collaboration diagram for Wlan Connection Interfaces:

Files

file  BCDS_WlanConnect.h
 

Data Structures

struct  WlanConnect_ScanInfo_S
 
struct  WlanConnect_ScanList_S
 

Macros

#define WLANCONNECT_DUMMY_SSID   "XDK110"
 
#define WLANCONNECT_ENROLLEE_PIN   "35072317"
 
#define WLANCONNECT_INITIALZED   UINT8_C(1)
 
#define WLANCONNECT_MAX_MAC_ADDR_LEN   UINT8_C(6)
 
#define WLANCONNECT_MAX_SCAN_INFO_BUF   UINT8_C(20)
 
#define WLANCONNECT_MAX_SSID_LENGTH   UINT8_C(32)
 
#define WLANCONNECT_NOT_INITIALZED   UINT8_C(0)
 

Typedefs

typedef unsigned long (WlanConnect_ScanInterval_T)
 
typedef void(* WlanConnect_Callback_T )(WlanConnect_Status_T connectStatus)
 
typedef enum
WlanConnect_CurrentStatus_E 
WlanConnect_CurrentNwStatus_T
 
typedef void(* WlanConnect_DisconnectCallback_T )(WlanConnect_Status_T discconnectStatus)
 
typedef signed char * WlanConnect_PassPhrase_T
 
typedef struct
WlanConnect_ScanInfo_S 
WlanConnect_ScanInfo_T
 
typedef struct
WlanConnect_ScanList_S 
WlanConnect_ScanList_T
 
typedef signed char * WlanConnect_SSID_T
 
typedef enum WlanConnect_Status_E WlanConnect_Status_T
 
typedef signed char * WlanConnect_Username_T
 

Enumerations

enum  WlanConnect_CurrentStatus_E
 
enum  WlanConnect_Retcode_E
 
enum  WlanConnect_Status_E
 

Functions

 BCDS_DEPRECATED (Retcode_T WlanConnect_Init(void))
 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...
 
 BCDS_DEPRECATED (Retcode_T WlanConnect_Open(WlanConnect_SSID_T connectSSID, WlanConnect_Callback_T connectCallback))
 WLI Connect to Open Network interface.
This function connects to an open network.
Function is configurable in two ways: More...
 
 BCDS_DEPRECATED (Retcode_T WlanConnect_WEP_Open(WlanConnect_SSID_T connectSSID, WlanConnect_PassPhrase_T connectPass, uint8_t passPhraseLength, WlanConnect_Callback_T connectCallback))
 WLI Connect to WEP Open Network interface.
This function connects to an WEP Open network.
Function is configurable in two ways: More...
 
 BCDS_DEPRECATED (Retcode_T WlanConnect_WPA(WlanConnect_SSID_T connectSSID, WlanConnect_PassPhrase_T connectPass, WlanConnect_Callback_T connectCallback))
 WLI Connect to WPA Network interface.
This function connects to an WPA2-PSK or WPA-PSK network.
Function is configurable in two ways: More...
 
 BCDS_DEPRECATED (Retcode_T WlanConnect_WPS_PBC(WlanConnect_Callback_T connectCallback))
 WLI 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...
 
 BCDS_DEPRECATED (Retcode_T WlanConnect_EnterpriseWPA(WlanConnect_SSID_T connectSSID, WlanConnect_Username_T connectUsername, WlanConnect_PassPhrase_T connectPassPhrase, WlanConnect_Callback_T connectCallback))
 WLI Connect to Enterprise WPA Network interface.
This function connects to an WPA2-PSK or WPA-PSK network.
Function is configurable in two ways: More...
 
 BCDS_DEPRECATED (Retcode_T WlanConnect_Disconnect(WlanConnect_DisconnectCallback_T disconnectCallback))
 WLI disconnect interface.
This function disconnects from the WLAN network.
Function is configurable in two ways: More...
 
 BCDS_DEPRECATED (Retcode_T WlanConnect_ScanNetworks(WlanConnect_ScanInterval_T scanInterval, WlanConnect_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...
 
 BCDS_DEPRECATED (WlanConnect_CurrentNwStatus_T WlanConnect_GetCurrentNwStatus(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...
 
 BCDS_DEPRECATED (WlanConnect_Status_T WlanConnect_GetStatus(void))
 Function to get the connection status.
This function return the connection status. More...
 
 BCDS_DEPRECATED (uint8_t WlanConnect_GetInitStatus(void))
 Function to get the connection status.
This function return the connection status. 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 connection Open Wlan Connection with the WEP & Wlan Connection Get status by deleting profiles and de-initialize the wlan connection.


Data Structure Documentation

struct WlanConnect_ScanInfo_S

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

Data Fields

uint8_t Bssid [WLANCONNECT_MAX_MAC_ADDR_LEN]
 
int8_t Rssi
 
uint8_t SecurityType
 
uint8_t Ssid [WLANCONNECT_MAX_SSID_LENGTH]
 
uint8_t SsidLength
 

Field Documentation

MAC address of the access point

int8_t Rssi

RSSI value of the access point

uint8_t SecurityType

Security type of the access point

Name of the access point

uint8_t SsidLength

Name of the access point

struct WlanConnect_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 WlanConnect_ScanList_S:

Data Fields

int8_t NumOfScanEntries
 
WlanConnect_ScanInfo_T ScanData [WLANCONNECT_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 WLANCONNECT_DUMMY_SSID   "XDK110"

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

#define WLANCONNECT_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 WLANCONNECT_INITIALZED   UINT8_C(1)

Macro to represent Initialized state of Wlan

#define WLANCONNECT_MAX_MAC_ADDR_LEN   UINT8_C(6)

The max buffer for storing the MAC address length

#define WLANCONNECT_MAX_SCAN_INFO_BUF   UINT8_C(20)

The max buffer for storing the scan data

#define WLANCONNECT_MAX_SSID_LENGTH   UINT8_C(32)

The max buffer for storing the SSID length

#define WLANCONNECT_NOT_INITIALZED   UINT8_C(0)

Macro to represent un-Initialized state of Wlan

Typedef Documentation

typedef unsigned long(WlanConnect_ScanInterval_T)

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

typedef void(* WlanConnect_Callback_T)(WlanConnect_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 Returns the connection status as a parameter

typedef void(* WlanConnect_DisconnectCallback_T)(WlanConnect_Status_T discconnectStatus)

Type defining the prototype which disconnection call back must conform to. This call back is called to notify the user when connection is terminated following the call to WlanConnect_disconnect(). Returns the connection status as a parameter

typedef signed char* WlanConnect_PassPhrase_T

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

typedef signed char* WlanConnect_SSID_T

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

typedef signed char* WlanConnect_Username_T

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

Enumeration Type Documentation

Enumerator
CONNECTED_AND_IPV4_ACQUIRED 
CONNECTED_AND_IP_NOT_ACQUIRED 
DISCONNECTED_AND_IPV4_ACQUIRED 
DISCONNECTED_IP_NOT_ACQUIRED 

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

Enumerator
RETCODE_SIMPLELINK_STOP_FAILED 
RETCODE_SIMPLELINK_STA_MODE_FAILED 
Enumerator
WLAN_CONNECTED 
WLAN_DISCONNECTED 
WLAN_CONNECTION_ERROR 
WLAN_CONNECTION_PWD_ERROR 
WLAN_DISCONNECT_ERROR 

Function Documentation

BCDS_DEPRECATED ( Retcode_T   WlanConnect_Initvoid)

starts a LoRa join process

WLI Delete All Profiles interface.
This function erases from memory all the stored profiles from WIFI Protected Setup functions.

WLAN driver de-initialization function.
Performs memory deallocation, closes WLAN driver context and shuts down the hardware interfaces.

Note
By default device is configured to STA mode even if device is in different modes (Like AP, P2P). If user want to change the mode, they need to use the Simple link API directly
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 initialized.
RETCODE_SIMPLELINK_ERROR - Not initialized WLAN driver.

Example1 usage: Initialize the WLAN Stack and the WLAN Driver

1 // Initialize WLAN driver and WLAN stack
2 WlanConnect_Init();

Example2 usage: Restart Device

1 // Local API return status
2 Retcode_T retStatus[2];
3 
4 retStatus[0] = WlanConnect_DeInit();
5 retStatus[1] = WlanConnect_Init();
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 }
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

Example1 usage: Deinitialize the WLAN Stack

1 // Deinitialize WLAN stack
2 WlanConnect_DeInit();

Example2 usage: Restart Device

1 // Local API return status
2 Retcode_T retStatus[2];
3 
4 retStatus[0] = WlanConnect_DeInit();
5 retStatus[1] = WlanConnect_Init();
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 }
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 WLI profiles
1 Retcode_T retStatus;
2 
3 retStatus = WlanConnect_DeleteAllProfiles();
4 
5 if (RETCODE_OK != retStatus)
6 {
7  printf("Profiles were not deleted correctly");
8 }
Deprecated:
since version vxx.xx.xx

RETCODE_OK: join procedure successfully started RECODE_FAILURE: join error

BCDS_DEPRECATED ( Retcode_T   WlanConnect_OpenWlanConnect_SSID_T connectSSID, WlanConnect_Callback_T connectCallback)
Parameters
[in]connectSSIDPointer to char containing the network SSID to connect to.
[in]connectCallbackPointer to user function callback.
Returns the WLI connection status as a parameter.
Returns
RETCODE_OK - Successfully connected to the AP.In case of API success return value after calling a blocking function, the WLI_SUCCESS implicitly confirms to the user that the WLI connection is done
RETCODE_SIMPLELINK_ERROR - Failure returned by simplelink API.
WLAN_CONNECTION_ERROR - 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

Example1 usage: Connect to an open WLAN network with callback (non-blocking)

1 // Callback function
2 void myConnectCallbackFunc(WlanConnect_ConnectionStatus_T returnStatus)
3 {
4  if (WLI_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 WlanConnect_SSID_T connectSSID;
19 Retcode_T retStatus;
20 WlanConnect_Callback_T connectCallback;
21 
22 // Open wireless network settings
23 connectSSID = (WlanConnect_SSID_T)"Name-Of-Open-Network";
24 
25 // Set callback functions
26 connectCallback = myConnectCallbackFunc;
27 
28 // Connect to network --> non blocking function with callback
29 retStatus = WlanConnect_Open(connectSSID, connectCallback);

Example2 usage: Connect to an open WLAN network in blocking mode

1 // local variables
2 WlanConnect_SSID_T connectSSID;
3 Retcode_T retStatus;
4 
5 // Open wireless network settings
6 connectSSID = (WlanConnect_SSID_T)"Name-Of-Open-Network";
7 
8 // Connect to network --> blocking function without callback
9 // Task will be blocked here until connection is done and IP acquired
10 retStatus = WlanConnect_Open(connectSSID, NULL);
BCDS_DEPRECATED ( Retcode_T   WlanConnect_WEP_OpenWlanConnect_SSID_T connectSSID, WlanConnect_PassPhrase_T connectPass, uint8_t passPhraseLength, WlanConnect_Callback_T connectCallback)
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
[in]connectionCallbackPointer to char containing the connection callback.
Returns
RETCODE_OK - API return code for success. In case of API success return value after calling a blocking function, the WLI_SUCCESS implicitly confirms to the user that the WLI connection is done
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

Example1 usage: Connect to an WEP Open network with callback (non-blocking)

1 // Callback function
2 void myConnectCallbackFunc(WlanConnect_ConnectionStatus_T returnStatus)
3 {
4  if (WLI_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 WlanConnect_SSID_T connectSSID;
21 Retcode_T retStatus;
22 WlanConnect_Callback_T connectCallback;
23 WlanConnect_PassPhrase_T connectPassPhrase;
24 uint8_t passPhraseLength;[Don't use strlen() in order not to bump on zero/NULL in the passPhrase]
25 
26 // WEP encrypted wireless network settings
27 connectSSID = (WlanConnect_SSID_T)"WEP-OPEN-NETWORK-NAME";
28 connectPassPhrase = (WlanConnect_PassPhrase_T)passPhrase;
29 passPhraseLength = UINT8_C(5);
30 // Set callback functions
31 connectCallback = myConnectCallbackFunc;
32 
33 // Connect to network --> non blocking function with callback
34 retStatus = WlanConnect_WEP_Open(connectSSID, connectPassPhrase,passPhraseLength, connectCallback);

Example2 usage: Connect to an WEP Open network in blocking mode

1 // local variables
2 //For example if AP is configured to WEP with 40bit Hex password of: "FFFFFFFFFF"
3 char passPhrase[5] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
4 WlanConnect_SSID_T connectSSID;
5 Retcode_T retStatus;
6 WlanConnect_PassPhrase_T connectPassPhrase;
7 uint8_t passPhraseLength;[Don't use strlen() in order not to bump on zero/NULL in the passPhrase]
8 
9 // WEP encrypted wireless network settings
10 connectSSID = (WlanConnect_SSID_T)"WEP-OPEN-NETWORK-NAME";
11 connectPassPhrase = (WlanConnect_PassPhrase_T)passPhrase;
12 passPhraseLength = UINT8_C(5);
13 
14 // Connect to network --> blocking function without callback
15 retStatus = WlanConnect_WEP_Open(connectSSID, connectPassPhrase,passPhraseLength, NULL);
BCDS_DEPRECATED ( Retcode_T   WlanConnect_WPAWlanConnect_SSID_T connectSSID, WlanConnect_PassPhrase_T connectPass, WlanConnect_Callback_T connectCallback)
Parameters
[in]connectionSSIDPointer to char containing the network SSID to connect to.
[in]connectionPassPointer to char containing the network Pass Phrase.
[in]connectionCallbackPointer to char containing the connection callback.
Returns
RETCODE_OK - API return code for success. In case of API success return value after calling a blocking function, the WLI_SUCCESS implicitly confirms to the user that the WLI connection is done
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

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

1 // Callback function
2 void myConnectCallbackFunc(WlanConnect_ConnectionStatus_T returnStatus)
3 {
4  if (WLI_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 WlanConnect_SSID_T connectSSID;
19 Retcode_T retStatus;
20 WlanConnect_Callback_T connectCallback;
21 WlanConnect_PassPhrase_T connectPassPhrase;
22 
23 // WPA/WPA2 encrypted wireless network settings
24 connectSSID = (WlanConnect_SSID_T)"WPA-NETWORK-NAME";
25 connectPassPhrase = (WlanConnect_PassPhrase_T)"WPA-PASSWORD";
26 
27 // Set callback functions
28 connectCallback = myConnectCallbackFunc;
29 
30 // Connect to network --> non blocking function with callback
31 retStatus = WlanConnect_WPA(connectSSID, connectPassPhrase, connectCallback);

Example2 usage: Connect to WPA/WPA2 network in blocking mode

1 // local variables
2 WlanConnect_SSID_T connectSSID;
3 Retcode_T retStatus;
4 WlanConnect_PassPhrase_T connectPassPhrase;
5 
6 // WPA/WPA2 encrypted wireless network settings
7 connectSSID = (WlanConnect_SSID_T)"WPA-NETWORK-NAME";
8 connectPassPhrase = (WlanConnect_PassPhrase_T)"WPA-PASSWORD";
9 
10 // Connect to network --> blocking function without callback
11 retStatus = WlanConnect_WPA(connectSSID, connectPassPhrase, NULL);
BCDS_DEPRECATED ( Retcode_T   WlanConnect_WPS_PBCWlanConnect_Callback_T connectCallback)

WLI 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:

Parameters
[in]connectionCallbackPointer to char containing the connection callback.
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. In case of API success return value after calling a blocking function, the WLI_SUCCESS implicitly confirms to the user that the WLI connection is done.
RETCODE_SIMPLELINK_ERROR - Failure returned by simplelink API.
RETCODE_CONNECTION_ERROR - connection Failure .
RETCODE_ERROR_IP_NOT_ACQ - Connected but ip not acquired

Example1 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(WlanConnect_ConnectionStatus_T returnStatus)
3  {
4  if (WLI_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  WlanConnect_Callback_T connectCallback;
20 
21  // Set callback functions
22  connectCallback = myConnectCallbackFunc;
23 
24 // Because the board connects to network very fast, the user
25  // must disconnect and delete all stored profiles before
26  // retrying to connect with WPS PBC
27  retStatus[0] = WlanConnect_Disconnect(NULL);
28 
29  // Delete all stored profiles in order to connect WPS by pushing
30  // the button all the time. Remove this line if you want to
31  // keep profile after running once the function.
32  retStatus[1] = WlanConnect_DeleteAllProfiles();
33 
34  // Connect to network --> non blocking function with callback
35  retStatus[2] = WlanConnect_WPS_PBC(connectCallback);

Example2 usage: Connect to a wireless network using WPS (WiFi Protected Setup) PBC (Push Button Connect) in blocking mode (without callback)

1 // local variables
2 Retcode_T retStatus[3];
3 
4 // Because the board connects to network very fast, the user
5 // must disconnect and delete all stored profiles before
6 // retrying to connect with WPS PBC
7 retStatus[0] = WlanConnect_Disconnect(NULL);
8 
9 // Delete all stored profiles in order to connect WPS by pushing
10 // the button all the time. Remove this line if you want to
11 // keep profile after running once the function.
12 retStatus[1] = WlanConnect_DeleteAllProfiles();
13 
14 // Connect to network --> blocking function without callback
15 retStatus[2] = WlanConnect_WPS_PBC(NULL);
Parameters
[in]connectionCallback- Pointer to char containing the connection callback.
Returns
RETCODE_OK - API return code for success. In case of API success return value after calling a blocking function, the WLI_SUCCESS implicitly confirms to the user that the WLI connection is done
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 Example1 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(WlanConnect_ConnectionStatus_T returnStatus)
3  {
4  if (WLI_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  WlanConnect_Callback_T connectCallback;
20 
21  // Set callback functions
22  connectCallback = myConnectCallbackFunc;
23 
24 // Because the board connects to network very fast, the user
25  // must disconnect and delete all stored profiles before
26  // retrying to connect with WPS PIN
27  retStatus[0] = WlanConnect_Disconnect(NULL);
28 
29  // Delete all stored profiles in order to connect WPS using
30  // enrollee PIN all the time. Remove this line if you want to
31  // keep profile after running once the function.
32  retStatus[1] = WlanConnect_DeleteAllProfiles();
33 
34  // Connect to network --> non blocking function with callback
35  retStatus[2] = WlanConnect_WPS_PIN(connectCallback);

Example2 usage: Connect to a wireless network using WPS (WiFi Protected Setup) PIN (Personal Identification Number) in blocking mode

1 // local variables
2 Retcode_T retStatus[3];
3 
4 // Because the board connects to network very fast, the user
5 // must disconnect and delete all stored profiles before
6 // retrying to connect with WPS PIN
7 retStatus[0] = WlanConnect_Disconnect(NULL);
8 
9 // Delete all stored profiles in order to connect WPS using
10 // enrollee PIN all the time. Remove this line if you want to
11 // keep profile after running once the function.
12 retStatus[1] = WlanConnect_DeleteAllProfiles();
13 
14 // Connect to network --> blocking function without callback
15 retStatus[2] = WlanConnect_WPS_PIN(NULL);
BCDS_DEPRECATED ( Retcode_T   WlanConnect_EnterpriseWPAWlanConnect_SSID_T connectSSID, WlanConnect_Username_T connectUsername, WlanConnect_PassPhrase_T connectPassPhrase, WlanConnect_Callback_T connectCallback)
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.
[in]blockingCallbool value to define the calling type as blocking or non-blocking
Returns
RETCODE_OK - API return code for success. In case of API success return value after calling a blocking function, the WLI_SUCCESS implicitly confirms to the user that the WLI connection is done
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

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

1 // Callback function
2 void myConnectCallbackFunc(WlanConnect_ConnectionStatus_T returnStatus)
3 {
4  if (WLI_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 WlanConnect_SSID_T connectSSID;
19 Retcode_T retStatus;
20 WlanConnect_PassPhrase_T connectPassPhrase;
21 
22 // WPA/WPA2 encrypted wireless network settings
23 connectSSID = (WlanConnect_SSID_T)"WPA-NETWORK-NAME";
24 connectUsername = (WlanConnect_Username_T)"WPA-USERNAME-NAME";
25 connectPassPhrase = (WlanConnect_PassPhrase_T)"WPA-PASSWORD";
26 
27 // Set callback functions
28 connectCallback = myConnectCallbackFunc;
29 
30 // Connect to network --> non blocking function with callback
31 retStatus = WlanConnect_EnterpriseWPA(connectSSID, connectUsername, connectPassPhrase, myConnectCallbackFunc);

Example2 usage: Connect to Enterprise WPA/WPA2 network in blocking mode

1 // local variables
2 WlanConnect_SSID_T connectSSID;
3 Retcode_T retStatus;
4 WlanConnect_PassPhrase_T connectPassPhrase;
5 
6 // WPA/WPA2 encrypted wireless network settings
7 connectSSID = (WlanConnect_SSID_T)"WPA-NETWORK-NAME";
8 connectUsername = (WlanConnect_Username_T)"WPA-USERNAME-NAME";
9 connectPassPhrase = (WlanConnect_PassPhrase_T)"WPA-PASSWORD";
10 
11 // Connect to network --> blocking function without callback
12 retStatus = WlanConnect_EnterpriseWPA(connectSSID, connectUsername, connectPassPhrase, NULL);
BCDS_DEPRECATED ( Retcode_T   WlanConnect_DisconnectWlanConnect_DisconnectCallback_T disconnectCallback)
  • blocking : callback parameter is set to WLI_NULL(maximum blocking in error case will be 15seconds)
  • non-blocking : callback parameter is set to the address of the user function
Parameters
[in]disconnectCallbackPointer to user function callback
Returns the WLI connection status as a parameter.
Returns
RETCODE_OK successfully disconnected from Access point. In case of API success return value after calling a blocking function, the WLI_SUCCESS implicitly confirms to the user that WLAN disconnection is done.
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 Example1 usage: Disconnect with callback (non-blocking)
1 void myDisconnectCallbackFunc(WlanConnect_ConnectionStatus_T returnStatus)
2 {
3  if (WLAN_DISCONNECTED == returnStatus)
4  {
5  // Network disconnection successfully from WlanConnect_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 WlanConnect_DisconnectCallback_T disconnectCallback;
17 
18 // Set disconnect callback function
19 disconnectCallback = myDisconnectCallbackFunc;
20 
21 // disconnect from network with callback --> non-blocking
22 retStatus = WlanConnect_Disconnect(disconnectCallback);

Example2 usage: Disconnect without callback

1 // local variables
2 Retcode_T retStatus;
3 
4 // disconnect from network in blocking mode
5 retStatus = WlanConnect_Disconnect(NULL);
6 
7 if (RETCODE_OK == retStatus)
8 {
9  // Disconnect has completed successfully
10  printf("Disconnected successfully!\n\r");
11 }
BCDS_DEPRECATED ( Retcode_T   WlanConnect_ScanNetworksWlanConnect_ScanInterval_T scanInterval, WlanConnect_ScanList_T *scanList)
Parameters
[in]scanIntervalTime interval between network scan.
[out]scanListStructure pointer hold the WLI 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 WLI_scanReturnCode_t retScanStatus;
3 WlanConnect_ScanInterval_T scanInterval;
4 WlanConnect_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 = WlanConnect_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 }
BCDS_DEPRECATED ( WlanConnect_CurrentNwStatus_T   WlanConnect_GetCurrentNwStatusvoid)

This API must be called only after initialization

Parameters
[in]allDisconnectCallbackPointer to user function callback. Returns the WLI connection status as a parameter.
Returns
CONNECTED_AND_IPV4_ACQUIRED - currently WLAN connected and IP acquired.
CONNECTED_AND_IP_NOT_ACQUIRED - currently WLAN connected and IP not acquired.
DISCONNECTED_AND_IPV4_ACQUIRED - currently WLAN disconnected and IP acquired
DISCONNECTED_IP_NOT_ACQUIRED - 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(WlanConnect_ConnectionStatus_T returnStatus)
2 {
3  if (WLI_DISCONNECTED == returnStatus)
4  {
5  // Network disconnection successfully from WlanConnect_Disconnect function
6  printf("Callback Function : A disconnect event has happened!\n\r");
7  }
8 }
9 
10 // local variables
11 Retcode_T retStatus;
12 WlanConnect_DisconnectCallback_T myAllDisconnectCallback;
13 
14 // Set callback function
15 myAllDisconnectCallback = myAllDisconnectCallbackFunc;
16 
17 if (DISCONNECTED_IP_NOT_ACQUIRED
18  != WlanConnect_GetCurrentNwStatus()
19  && (DISCONNECTED_AND_IPV4_ACQUIRED
20  != WlanConnect_GetCurrentNwStatus()))
21 {
22  retStatus = WlanConnect_Disconnect(myAllDisconnectCallback);
23  printf("Finished disconnection successfully \n\r");
24 }
BCDS_DEPRECATED ( WlanConnect_Status_T   WlanConnect_GetStatusvoid)
Parameters
[in]none
Returns
WLI_CONNECTED - WLI connected obtained after calling connect function.
WLI_DISCONNECTED - WLI disconnected obtained after calling disconnect function.

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 ( uint8_t   WlanConnect_GetInitStatusvoid)
Parameters
[in]none
Returns
WLANCONNECT_INITIALZED - Wlan module is initialized.
WLANCONNECT_NOT_INITIALZED - Wlan module is not initialized.

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