-->
Page 1 of 2

Problem scanning/detecting available networks

PostPosted: Wed May 31, 2017 9:34 am
by alex_g
Hi

Although up to now I have mainly been a Lua/NodeMCU user, I have also taken up the Arduino IDE for my current project as it's the only one with proper support for 433MHz radio.

Basically, I will be using MQTT to report on 433MHz signals from various physical locations. To do this, I need to be able to detect which WiFi networks are available, so that I can select the strongest.

I tried using WiFi.scanNetworksAsync(callbackfn), as given in this example:
https://arduino-esp8266.readthedocs.io/ ... class.html
but I get the following back
Code: Select all/home/moi/Code/Arduino/sketch_may30a/sketch_may30a.ino: In function 'void setup()':
sketch_may30a:35: error: 'class ESP8266WiFiClass' has no member named 'scanNetworksAsync'
   WiFi.scanNetworksAsync(prinScanResult);
        ^
exit status 1
'class ESP8266WiFiClass' has no member named 'scanNetworksAsync'

Seems like the function is not included in the library! Huh?

Any advice? I have not been able to find anything that makes sense on the Web so far.
My Arduino installation is recent (a month old, or less) and the read-the-docs-page doen't seem that old either. Has there been some update I missed?

Re: Problem scanning/detecting available networks

PostPosted: Wed May 31, 2017 11:26 am
by alex_g
Hm, OK, I see I can do an async scan with the first parameter of scanNetworks, albeit without a callback facility (using getNetworkInfo() ). I guess that will have to do.

Re: Problem scanning/detecting available networks

PostPosted: Wed May 31, 2017 1:11 pm
by schufti
hmmm, looking at ESP8266WiFiScan.h I see
Code: Select allclass ESP8266WiFiScanClass {

        // ----------------------------------------------------------------------------------------------
        // ----------------------------------------- scan function --------------------------------------
        // ----------------------------------------------------------------------------------------------

    public:

        int8_t scanNetworks(bool async = false, bool show_hidden = false);
        void scanNetworksAsync(std::function<void(int)> onComplete, bool show_hidden = false);

        int8_t scanComplete();
        void scanDelete();

        // scan result
        bool getNetworkInfo(uint8_t networkItem, String &ssid, uint8_t &encryptionType, int32_t &RSSI, uint8_t* &BSSID, int32_t &channel, bool &isHidden);

        String SSID(uint8_t networkItem);
        uint8_t encryptionType(uint8_t networkItem);
        int32_t RSSI(uint8_t networkItem);
        uint8_t * BSSID(uint8_t networkItem);
        String BSSIDstr(uint8_t networkItem);
        int32_t channel(uint8_t networkItem);
        bool isHidden(uint8_t networkItem);


so it should be accessible ...

Re: Problem scanning/detecting available networks

PostPosted: Wed May 31, 2017 1:42 pm
by alex_g
hmmm, looking at ESP8266WiFiScan.h I see....


Interesting, thanks!
I didn't include ESP8266WiFiScan.h, since that's not what's given in the example. I'll try it like that.