Categories: Symbian C++ | Networking | Code Examples | How To | WLAN
This page was last modified 13:59, 19 June 2008.
How to retrieve the SSID and BSSID using WLAN INFO API
From Forum Nokia Wiki
Some of you might want to retrieve the BSSID of the network using WLAN Info API. Others just want to retrieve the SSID so they can use the RConnectionMonitor. But sometimes you need both information for available WLANs.
In the following code I show how to retrieve both SSID and BSSID for all available WLANs. I am presenting a static version with the code that you can just use in a function.
CODE EXAMPLE
Header files: wlanmgmtclient.h
Libraries: You must install the WLAN Info API plug-in
GetSSID
/** * Function that retrieves SSID of current scaned network * * The SSID is the Information Element with ID = 0 * The SSID can be at most 34 bytes, so the aSSID should have the capacity for 34 bytes * * Returns KErrNone if successful or the type of error ocurred */ TInt GetSSID(CWlanScanInfo *scanInfo, TDes8 &aSSID) { TInt error; TUint8 ie; TUint8 length; TUint8 vdata[40]; const TUint8 *data = &vdata[0]; if(scanInfo == NULL) return KErrNullPointerPassed; if(aSSID.MaxLength() < 34) return KErrNoMemory; if((error = scanInfo->FirstIE(ie, length, &data)) == KErrNone) { if(ie == 0) { aSSID.Copy(data, length); return KErrNone; } } else return error; while((error = scanInfo->NextIE(ie, length, &data)) == KErrNone) { if(ie == 0) { aSSID.Copy(data, length); return KErrNone; } } return error; }
GetWLANAPIInfoL
/** * This function is used to list WLAN Info with WLAN Info API * * @infoBuff - when function returns it holds the WLAN Information */ void GetWLANAPIInfoL(TDes &infoBuff) { CWlanScanInfo iScanInfo; CWlanMgmtClient iWLANMgmtClient; iWLANMgmtClient.GetScanResults(iScanInfo); TInt i=1, k; TBuf<36> bss; _LIT(KNetwork, "Network "); _LIT(KNEWLine, "\n"); _LIT(KSeparator, " - "); _LIT(KBSSIDFormat, "%02X:"); _LIT(KSSIDUnknown, "SSID Unknown"); infoBuff.Zero(); for(iScanInfo.First(); !iScanInfo.IsDone(); iScanInfo.Next() ) { infoBuff.Append(KNetwork); infoBuff.AppendNum(i); infoBuff.Append(KSeparator); i++; //Retrieve BSSID TWlanBssid bssid; iScanInfo.Bssid( bssid ); bss.Zero(); for(k = 0; k < bssid.Length(); k++) bss.AppendFormat(KBSSIDFormat, bssid[k]); //remove last : bss.Delete(bss.Length()-1, 1); infoBuff.Append(bss); infoBuff.Append(KSeparator); //Get transmision level TInt8 rxLevel = iScanInfo->RXLevel(); infoBuff.AppendNum(rxLevel); infoBuff.Append(KSeparator); //Get SSID TBuf8<36> ssid; TInt err; err = GetSSID(&iScanInfo, ssid); if(err== KErrNone) { bss.Zero(); bss.Copy(ssid); infoBuff.Append(bss); } else infoBuff.Append(KSSIDUnknown); infoBuff.Append(KNEWLine); } }
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Add WLAN AP | nmnir | General Symbian C++ | 3 | 2007-12-12 07:46 |
| Different between GPRS and WLAN | john_c_ye | Wired and Wireless interfaces | 4 | 2007-06-09 05:22 |
| How to get WLAN IAPs | rihoe | General Symbian C++ | 2 | 2007-04-04 11:54 |
| About WLAN | ab | General Symbian C++ | 2 | 2007-12-24 13:06 |
| WLAN without SIM Card | mrpunkrock | Wired and Wireless interfaces | 5 | 2006-09-18 07:50 |
