Hi,
Indeed there is a problem with the WLAN Info API. I am troubble shooting it for 4 days now. I didn't find a solution yet.
I am using this code:
Code:
/**
* Constants for XML representation
*/
_LIT(KXMLWNETTag, "<Network id=\"%d\">");
_LIT(KXMLWNETEndTag, "</Network>");
_LIT(KXMLWLANSecurityTag, "<Security>");
_LIT(KXMLWLANSecurityEndTag, "</Security>");
_LIT(KXMLWLANTypeTag, "<WLANType>");
_LIT(KXMLWLANTypeEndTag, "</WLANType>");
_LIT(KXMLBSSIDTag, "<BSSID>");
_LIT(KXMLBSSIDEndTag, "</BSSID>");
_LIT(KXMLSSIDTag, "<SSID>");
_LIT(KXMLSSIDEndTag, "</SSID>");
_LIT(KXMLWLANStrengthTag, "<WLANStrength>");
_LIT(KXMLWLANStrengthEndTag, "</WLANStrength>");
void CWLANInfo::GetWLANInfo(TDes &infoBuff)
{
infoBuff.Zero();
if(iWLANMgmtClient == NULL || iScanInfo == NULL)
return;
TInt securityMode;
TInt i=1, k;
TBuf<36> bss;
_LIT(KOPEN, "Open");
_LIT(KWEP, "WEP");
_LIT(K802, "802d1x");
_LIT(KWPA, "WPA");
_LIT(KINFRA, "Infrastructure");
_LIT(KADHOC, "Ad-hoc");
_LIT(KBSSIDFormat, "%02X:");
_LIT(KSSIDUnknown, "SSID Unknown");
for(iScanInfo->First(); !iScanInfo->IsDone(); iScanInfo->Next() )
{
infoBuff.AppendFormat(KXMLWNETTag, i);
i++;
infoBuff.Append(KXMLWLANSecurityTag);
securityMode=iScanInfo->SecurityMode();
if(securityMode==EwlanConnectionSecurityOpen)
infoBuff.Append(KOPEN);
else if(securityMode==EwlanConnectionSecurityWep)
infoBuff.Append(KWEP);
else if(securityMode==EwlanConnectionSecurity802d1x)
infoBuff.Append(K802);
else if(securityMode==EwlanConnectionSecurityWpa)
infoBuff.Append(KWPA);
infoBuff.Append(KXMLWLANSecurityEndTag);
//In general if the least significant bit of the capbility field
//is 1 then the network is of "Infrastructure Type" or else if the
//capability field is 0 then the network is of "Ad-hoc type"
infoBuff.Append(KXMLWLANTypeTag);
TUint16 capability=iScanInfo->Capability();
TInt pad(1);
TInt lanType=capability & pad;
if(lanType==1)
infoBuff.Append(KINFRA);
else
infoBuff.Append(KADHOC);
infoBuff.Append(KXMLWLANTypeEndTag);
infoBuff.Append(KXMLBSSIDTag);
//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(KXMLBSSIDEndTag);
infoBuff.Append(KXMLWLANStrengthTag);
//Get transmision level
TInt8 rxLevel = iScanInfo->RXLevel();
infoBuff.AppendNum(rxLevel);
infoBuff.Append(KXMLWLANStrengthEndTag);
infoBuff.Append(KXMLWNETEndTag);
}
}
The line in red is ok, I mean that WLAN Info API retrieves the information without problems, but the problem is in this code somewhere as my phone crashes randomly but always. I mean that it doesn't crash everytime I use the function, but only sometimes. Anyway, if I try to call the function for lets say 10 times it surely crashes. Sometimes it just crashes (without any error) and sometimes the phone gets restarted. I am using Nokia N95.
paipeng, are you using aprox. the same code as me?
If someone knows what is the problem please advice, it would be very helpful. Also... as I posted before, the guys from Nokia forgot to put a Cancel routing for the asynchronous version of GetScanResults.
If I discover the problem I'll say.
Thanks,
Omar