I have problems to get the MAC address of the connected access point on a MC65. I was wordering why this isn't included in the FUSION sample. I think I will get it in the FAPI_SSIDInformation_1 structure, but I don't know who to call it. The Adapter and SSID I get successfully. I tried the following code, but I don't get the size of WLAN_SSID_LIST_GET_BUFFER_SIZE. I am not sure if that is the right way what I am doing here. Please help with a sample code how to get the access point MAC. void CMC65::WLANGetAccessPointMAC(DWORD dwAdapter) { DWORD dwBufLen, dwResult = 0; PBYTE pFusionData = NULL; FAPI_SSIDListQuery_1 fapiSSIDListQuery; FAPI_SSIDListHeader_1 fapiSSIDListHeader; FAPI_SSIDInformation_1 fapiSSIDInformation; fapiSSIDListQuery.dwAdapterHandle = dwAdapter; dwResult = lpfn_CommandFusionAPI( g_hInstFusionMode, WLAN_SSID_LIST_GET_BUFFER_SIZE, &dwAdapter, sizeof(DWORD), &dwBufLen, sizeof(DWORD), NULL); if( dwResult == FAPI_SUCCESS ) { pFusionData = (PBYTE)calloc( 1, dwBufLen ); if( pFusionData != NULL) { dwResult = lpfn_CommandFusionAPI( g_hInstFusionMode, WLAN_SSID_LIST_GET_DATA, &fapiSSIDListQuery, sizeof(fapiSSIDListQuery), pFusionData, dwBufLen, NULL); if( dwResult == FAPI_SUCCESS ) { ... } free( pFusionData ); } } }
How to get Access Point MAC from Fusion WLAN for C// Expert user has replied. |
5 Replies
Sorry, I didn't noticed that. Perhaps you can help me with another issue. I want to check every few seconds if there is a WLAN connection available. I implemented that with the CONNECTION_STATUS_WLAN_GET command, but this seems to make the whole device very slow. Do you know a fast way to check this?
I would recommend using the IP address to check status if you are just looking for connected vs. not connected. Microsoft provides GetAdaptersInfo for querying and NotifyAddrChange to actually register for notification of the IP change. When WLAN gets disconnected, you will get a notification and you can then use GetAdaptersInfo to check for the specific adapter to see if there is a valid IP address.
This is the way I have implemented it and it works indeed:
bool FusionGetBSSID(DWORD dwAdapterHandle, WCHAR pMac[18]) { DWORD dwStatBufLen, dwResult; PBYTE pFusionData = NULL; FAPI_AdapterNDISStat StatData;
if ( lpfn_CommandFusionAPI == NULL ) return FALSE;
swprintf(pMac, L"00:00:00:00:00:00");
StatData.dwVersion = FAPI_ADAPTER_NDIS_STAT_VERSION; StatData.dwType = FAPI_ADAPTER_NDIS_STAT_TYPE; StatData.dwAdapterHandle = dwAdapterHandle; StatData.dwOid = OID_802_11_BSSID;
dwResult = lpfn_CommandFusionAPI( g_hInstFusionDLL, NDIS_STAT_WLAN_GET_BUFFER_SIZE, &StatData, sizeof(FAPI_AdapterNDISStat), &dwStatBufLen, sizeof(DWORD), NULL); if( dwResult == FAPI_SUCCESS ) { pFusionData = (PBYTE)calloc(1, dwStatBufLen); if( pFusionData != NULL) { dwResult = lpfn_CommandFusionAPI( g_hInstFusionDLL, NDIS_STAT_WLAN_GET_DATA, &StatData, sizeof(FAPI_AdapterNDISStat), pFusionData, dwStatBufLen, NULL);
if( dwResult == FAPI_SUCCESS ) { swprintf(pMac, L"%02X:%02X:%02X:%02X:%02X:%02X", pFusionData[0], pFusionData[1], pFusionData[2], pFusionData[3], pFusionData[4], pFusionData[5]); } free( pFusionData ); return TRUE; } } return FALSE; } Good luck!
Thank you for the code. This worked for me. I used exactly the same code to get the SSID. The only different is dwOid = OID_802_11_BSSID. It is annoying that there is no information about this in the help file.
Of course not on Motorola's EMDK documentation! It's Microsoft's so one has to search on their sites, such as in: http://msdn.microsoft.com/en-us/library/ff543936%28v=VS.85%29.aspx