How to scan a Wifi network

hi guys,

I would like to use the description like: https://github.com/cesanta/mongoose-os/blob/master/docs/javascript-api/wifi.md

But when I use Wifi.scan the console says

MJS callback error: Wifi is not defined

I didn't find a api_wifi.js

I tried it with the following example

https://github.com/cesanta/mongoose-os/issues/115

thanks for helping

Comments

  • What do I wrong?

    let Wifi = {
      scan: ffi('void mgos_wifi_scan(void(*)(char**, userdata), userdata)')
    };

    Wifi.scan(function(data, args){
      print(data);
    },args);

    for the following c-definition:

    typedef void (*mgos_wifi_scan_cb_t)(const char **ssids, void *arg);
    void mgos_wifi_scan(mgos_wifi_scan_cb_t cb, void *arg);

    I get in the console:

    MJS callback error: failed to call FFI signature "void mgos_wifi_scan(void(*)(char**, userdata), userdata)": cannot resolve function l : invalid JSON string

    thanks for helping

  • SergeySergey Dublin, Ireland

    add mgos_wifi_scan to mos.yml and rebuild the firmware

  • Hi Sergey thanks for helping. That did the trick to call the function, but it isn't clear - especially with this function - how to access the returned char-list of ssids. I've tried now many possibilities, but none of them worked.

    I've tried

    scan: ffi('void mgos_wifi_scan(void(*)(char **, userdata), userdata)')

    or

    scan: ffi('void mgos_wifi_scan(void(*)(char *, userdata), userdata)')

    because the documentation says just only char * are allowed.

    When I do

    let callback = function(ssids, data){
          print(ssids);
    };
    Wifi.scan(callback, {});

    I don't know how to get the correct data from ssids. I don't find another function that seems similar with egos_wifi_scan, but nothing found.

    It seems some other people used Wifi.scan already but is there an api_wifi.js somewhere I can use? Does exist another trick how to scan for ssids?

    thanks for helping

  • someone an idea, how to access skids in the callback? There is no definition for const char list to access in mjs.

    thanks for any help

Sign In or Register to comment.