This project is read-only.

How to retrieve beacons data

Jul 13, 2013 at 11:09 AM
I'm looking for a way to retrieve beacons data.
I figured the data should be available in WlanBssEntry however all I can get is it's size and offset.

What I was expecting is something like this:
            WlanClient client = new WlanClient();
            WlanClient.WlanInterface wlanIface = client.Interfaces[0]; // assume this is the only interface I have for the sake of this example

            Wlan.WlanBssEntry[] bssEntries = wlanIface.GetNetworkBssList();
            foreach (Wlan.WlanBssEntry bssEntry in bssEntries)
                uint dataOffset = bssEntry.ieOffset; // this one exists
                uint dataSize = bssEntry.ieSize; // this one exists
                byte[] beaconData = bssEntry.ieData; // this one DOESNT exists!!!
Any alternative to retrieve the beacons data using C# is much appreciated.

Jul 30, 2013 at 6:09 AM

I use the api in including this Function:

Private Bss_Entry As Wlan.WlanBssEntryN()

Private Function ConvertBssListPtr(ByVal bssListPtr As IntPtr) As Wlan.WlanBssEntryN()
    Dim header As Wlan.WlanBssListHeader = DirectCast(Marshal.PtrToStructure(bssListPtr, GetType(Wlan.WlanBssListHeader)), Wlan.WlanBssListHeader)
    Dim num As Long = bssListPtr.ToInt64() + Marshal.SizeOf(GetType(Wlan.WlanBssListHeader))
    Dim entryArray As Wlan.WlanBssEntryN() = New Wlan.WlanBssEntryN(header.numberOfItems - 1) {}

    For i As Integer = 0 To header.numberOfItems - 1
        entryArray(i) = New Wlan.WlanBssEntryN(Marshal.PtrToStructure(New IntPtr(num), GetType(Wlan.WlanBssEntry)))

        Dim size As Integer = CInt(entryArray(i).BaseEntry.ieSize)
        entryArray(i).IEs = New Byte(size - 1) {}

        Marshal.Copy(New IntPtr(num + entryArray(i).BaseEntry.ieOffset), entryArray(i).IEs, 0, size)

        num += Marshal.SizeOf(GetType(Wlan.WlanBssEntry))


    Return entryArray

End Function
In the Form1:


Public Shared Function ByteArrayToString(ByVal ba As Byte()) As String
    Dim hex As New StringBuilder(ba.Length * 2)
    For Each b As Byte In ba
        hex.AppendFormat("{0:x2}", b)
    Return hex.ToString()
End Function