Resources | Resources |



Manual Connection using wlan_IConnMgr

You can manage connection to access points using wlan_IConnMgr_Connect(). In this case, the access point information provided in wlan_IConnMgr_Connect() is cached for maintaining the connection (e.g. roaming between access points of the same SSID) and stored in net_user_manual_sys file to reacquire the connection upon power-cycle.

The process for using a WLAN in manual mode is:

  1. Scanning for access points is accomplished with wlan_IConnMgr_StartScan(). After scanning completes, the application calls wlan_IConnMgr_GetNetworks() to get the list of available access points.
  2. wlan_IConnMgr_OnConnectStatusChange() is used to register for notification when the WLAN status changes (e.g. when WLAN is connected or disconnected).
  3. wlan_IConnMgr_GetConnectStatus() is used to query for the current status of WLAN.
  4. When displaying the list of access points, the application should filter out duplicate access points (access points of the same SSID).
  5. The application should connect to the BSSID (MAC address of the access point) with the strongest RSSI.

Brew MP versions prior to 1.2 do not support disconnecting from access points. Calling wlan_IConnMgr_Disconnect() results in WLAN getting turned off, which is the same as removing WLAN from the system preference.

  • Before scanning after a disconnect, the application must turn on WLAN by adding the WLAN to the system mode preference.
  • WLAN and telephony operations are asynchronous. Applications must listen to AEET_EVENT_PH_SYSTEM_PREF to make sure that WLAN has been removed from the system mode preference before trying to add WLAN back to system mode preference.
  • On certain devices, enabling WLAN may trigger the previously connected access point to be reconnected. This behavior can be disabled by the manufacturer and therefore is manufacturer dependent.

The sequence of events for manually connecting to a network can be seen in this diagram.

To connect to a WLAN using authentication information:

  1. Create wlan_AEECLSID_ConnMgr and create a signal to be set when there is a change in the connection status.
    nErr = IEnv_CreateInstance(pMe->piEnv, wlan_AEECLSID_ConnMgr,
    if(AEE_SUCCESS != nErr)   
               "Could not instantiate wlan_AEECLSID_ConnMgr - %d", nErr);
        goto bail;
    nErr = IEnv__CreateSignal(pMe->piEnv, CMTConnect_ConnStatusCB, pMe,
                              &piSignal, &pMe->pisctlConnStatus);
  2. Fill in the key authentication information. This example code is for WEP_40 authentication type.
    wlan_AuthInfo *pAuth;
    pAuth->_d = wlan_AUTH_ENCRYPT_WEP_40;
    pAuth->_u.wep40Bit.ucKeyID = 0;
    pAuth->_u.wep40Bit.ucaKey1[0] = 'a';
    pAuth->_u.wep40Bit.ucaKey1[1] = 'b';
    pAuth->_u.wep40Bit.ucaKey1[2] = 'c';
    pAuth->_u.wep40Bit.ucaKey1[3] = 'd';
    pAuth->_u.wep40Bit.ucaKey1[4] = 'e'; 
  3. Fill in the Network information:
    wlan_Network         wlanNW;
    wlanNW.ssID.nLen   = 10;
    std_memmove(wlanNW.ssID.ucSSid, "Mobilemark", 10);     = 65535;
    wlanNW.bandClass   = tapi_SYS_BAND_WLAN_US_2400;
    wlanNW.bss         = wlan_BSS_TYPE_ANY;        = wlan_TECH_80211G;
    wlanNW.auth        = wlan_AUTH_NONE;
    wlanNW.authKeyMgmt = wlan_AKM_NONE;
    wlanNW.encryption  = wlan_ENCRY_NONE;
    wlanNW->bssID.ucUnivAddr[0] = 0x00;
    wlanNW->bssID.ucUnivAddr[1] = 0x00;
    wlanNW->bssID.ucUnivAddr[2] = 0x00;
    wlanNW->bssID.ucUnivAddr[3] = 0x00;
    wlanNW->bssID.ucUnivAddr[4] = 0x00;
    wlanNW->bssID.ucUnivAddr[5] = 0x00;
    wlanNW.nRssi = 0; 
  4. Associate the signal with the wlan_IConnMgr object. The signal is set when there is a change in the WLAN status.
    nErr = wlan_IConnMgr_OnConnectStatusChange(pMe->piConnMgr,
    if(AEE_SUCCESS != nErr) 
                  "Could not register for connection status change - %d", 
        goto bail;
  5. Attempt to connect to a WLAN network:
    nErr = wlan_IConnMgr_Connect(pMe->piConnMgr, &wlanNW, 
                                 wlan_SCAN_AUTO, enc, &authInfo);
  6. Check for the result of connect operation:
     nErr = wlan_IConnMgr_GetConnectStatus(pMe->piConnMgr, &status, 
                                     &failReason, &bAvail, &nw);
     if( wlan_CONN_STATUS_CONNECTED == status )
        // succesfully connected to network
        WCM_DisplayMsg(pMe, "Successfully Connected \n" );
     else if (wlan_CONN_STATUS_CONNECTING == status) 
        WCM_DisplayMsg(pMe, "Connecting ... \n" );   
        WCM_DisplayMsg(pMe, "Unable to connect PRESS CLR\n");  

To use other authentication values:

//To set authentication information for Open security 
 wlanNW.authKeyMgmt = wlan_AKM_NONE;
	wlanNW.encryption = wlan_ENCRY_NONE;

 case wlan_AUTH_ENCRYPT_NONE: 
     pAuth->_u.noInfo =  TRUE;

//To set authentication information for WEP_104 security

wlanNW.authKeyMgmt = wlan_AKM_NONE;
wlanNW.encryption = wlan_ENCRY_WEP_104_BIT;
case wlan_AUTH_ENCRYPT_WEP_104_BIT: {
    pAuth->_u.wep104Bit.ucKeyID = 0;
	   pAuth->_u.wep104Bit.ucaKey1[0]  = 0x61;//'A';
    pAuth->_u.wep104Bit.ucaKey1[1]  = 0x62;//'B';
    pAuth->_u.wep104Bit.ucaKey1[2]  = 0x63;//'C';
    pAuth->_u.wep104Bit.ucaKey1[3]  = 0x64;//'D';
    pAuth->_u.wep104Bit.ucaKey1[4]  = 0x65;//'E';
	   pAuth->_u.wep104Bit.ucaKey1[5]  = 0x66;//'F';
    pAuth->_u.wep104Bit.ucaKey1[6]  = 0x67;//'G';
    pAuth->_u.wep104Bit.ucaKey1[7]  = 0x68;//'H';
    pAuth->_u.wep104Bit.ucaKey1[8]  = 0x69;//'I';
    pAuth->_u.wep104Bit.ucaKey1[9]  = 0x6a;//'J';
	   pAuth->_u.wep104Bit.ucaKey1[10] = 0x6b;//'K';
    pAuth->_u.wep104Bit.ucaKey1[11] = 0x6c;//'L';
    pAuth->_u.wep104Bit.ucaKey1[12] = 0x6d;//'M';       
// To set authentication information for C_8021X_PASSWD security
 wlanNW.authKeyMgmt = wlan_AKM_PSK;
	wlanNW.encryption = wlan_ENCRY_TKIP;

 case wlan_AUTH_ENCRYPT_8021X_PASSWD: {
     pAuth->_u.password.nLen = 32;
     std_memmove( pAuth->_u.password.ucaPass, pswd, 32);

// To set authentication information for C_8021X_MD5_RADIUS security

wlanNW.authKeyMgmt = wlan_AKM_8021X;
wlanNW.encryption = wlan_ENCRY_TKIP;

case wlan_AUTH_ENCRYPT_8021X_MD5_RADIUS: {//inner
    pAuth->_u.password.nLen = 32;
    std_memmove( pAuth->_u.password.ucaPass, "password",sizeof("password"));  

 // To set authentication information for C_8021X_TLS_CERT security
 case wlan_AUTH_ENCRYPT_8021X_TLS_CERT: {  
     pAuth->_u.userIDCert.nUserIDLen = 8;
     std_memmove(pAuth->_u.userIDCert.ucaUserID, "sta_qcom", 8);
     pAuth->_u.userIDCert.ucCertID = 0;
     pAuth->_u.userIDCert.server.nLen = 12;
                 "", 12);

// To set authentication information for AKA/SIM security

wlanNW.authKeyMgmt = wlan_AKM_8021X;
wlanNW.encryption = wlan_ENCRY_TKIP;
      pAuth->_u.userID.nLen = 9;
      std_memmove( pAuth->_u.userID.ucaUserID, "anonymous", 9 );