Scanning BSSID and RSSI for surrounding networks

Hi,

In the past we have implemented a method to scan for the MAC addresses and RSSI for all access points within range of the radio for the Sparkfun CC3000 wifi shield:

We love the Spark Core, and would like to do the same thing. Our hope was that the core’s library would include functions like the CC3000’s library to perform the scan, like
wifi.scanaccesspoints which would return BSSID and RSSI.

Is our only hope to port the SparkFun CC3000 library to the Spark Core? Or are there already native functions which support this type of scanning?

Thank you so much!

Erik

HI @ewSUTD

There is already a WiFi.RSSI that returns the signal strength of the current access point. That way that works is by asking the TI C3000 for the scan table and looking for the entry with the SSID that matches the current access point.

You can build off this code to look at more fields in the scan table as you would like. If the SparkFun code is open source, it would probably just work on the Spark since both are just accessing a feature of the TI WiFi chip.


int8_t WiFiClass::RSSI()
{
        _functionStart = millis();
        _returnValue = 0;
        while ((millis() - _functionStart) < 1000)
        {
                _loopCount = 0;
                while (_loopCount++ < 16)
                {
                        unsigned char wlan_scan_results_table[50];
                        char wlan_scan_results_ssid[32];
                        if(wlan_ioctl_get_scan_results(0, wlan_scan_results_table) != 0) return(1);
                        for (int i = 12; i <= 43; i++)
                        {
                                int arrayPos = i - 12;
                                wlan_scan_results_ssid[arrayPos] = wlan_scan_results_table[i];
                        }
                        if (*wlan_scan_results_ssid == *ip_config.uaSSID) _returnValue = ((wlan_scan_results_table[8] >> 1) - 127);
                        if (wlan_scan_results_table[0] == 0) break;
                }
                if (_returnValue != 0) return(_returnValue);
        }
        return(2);
}

2 Likes

I have some rudimentary code for this here:

Thanks,
David

2 Likes

Hi @Dave and @bko, thank you so much for you replies. I have the code working based on this library, which is really similar to what you pointed me to Dave, thanks again!

I now have the wifi scan results being written to an SD card and correlated with various sensor measurements. I’m planning on publishing the code soon, and will update this thread in a week or so.

Thanks!

2 Likes

Hello @ewSUTD . Would you be able to help with this ; apparently it does not work on new firmware

@Dave, has the bssid capability been removed from the spark core? Would you be able to advise on reviving this?

Hi @tomkut,

Good question! I think much of the wifi scan code has been given some friendly wrappers in the system code. Checkout the new docs here - https://docs.particle.io/reference/firmware/core/#scan-

Thanks,
David

1 Like

@Dave, BSSID is not mentioned there at all. Is there no hope?

Disregarding the fact that you’re cross-posting over different topics, which is generally frowned upon, it seems as though you don’t want to hear the answers that have been given to you if you don’t like them.
Seems as though this question has been answered already:


3 Likes

Thank you @Moors7. I realised that I had confused BSSID of any AP with the one to which a core is connected.
Perhaps you know, if the spark core project is finished and hence no hope for BSSID of scanned networks?

Which part of these posts is unclear to you?

1 Like

@Moors7, I understand the posts. Do you know if there is a possibility of BSSID of scanned networks being exposed in the functions?

Yes, there is a possibility, obviously, but I don’t think it has priority at the moment, nor any time in the nearby future. If you really need it, you can implement it the way @bko explained it. While you’re at it, why not make a pull request, so it’ll become available for others as well? It’s open source after all :wink:

Thanks @Moors7 for clarification. bko explained to me that in order to implement it, one has to know what they are doing, and I don’t, unfortunately.

Hey Gang,

Sorry if this was posted elsewhere, posting here in case it makes it easier to find. For reference that Wifi.scan call returns an instance of WiFiAccessPoint, that struct is:

typedef struct WiFiAccessPoint {
   size_t size;
   char ssid[33];
   uint8_t ssidLength;
   uint8_t bssid[6];
   WLanSecurityType security;
   WLanSecurityCipher cipher;
   uint8_t channel;
   int maxDataRate;   // the mdr in bits/s
   int rssi;        // when scanning

} WiFiAccessPoint;

so bssid should be in there. :slight_smile:

Thanks,
David