EspruinoWifi.js getIP()

Posted on
  • Is require("EspruinoWifi").getIP() implemented? I can see the method in the module but it errors for me. Also wifi.scan() seems not to return anything. I know the Espruino Wifi is very new, so just wondered what to expect in terms of this module at the moment?

  • This might help.
    http://forum.espruino.com/conversations/­286139/#comment12965959

    The syntax is different on different implementations for some reason.

  • Yes, that could be it. Or what's the erroir?

    Basically because the Wifi is separate on the Espruino WiFi it can take time for it to respond - so pretty much every function has to be async.

    It should behave like a Pico + ESP8266, but I changed the API a little to try and bring everything into line a little more (currently every implementation of the network API is slightly different)

  • Thanks Gordon.

    
    

    wifi.getIP()
    =undefined
    Uncaught Error: Function "a" not found!
    at line 1 col 165
    ...ce(15,-1);else if("OK"==d){a(null,b);return}return h}

                              ^
    

    in function "b" called from line 1 col 25
    d=void 0;var f;b&&(f=b(a))?(d=p,b=f):clearTimeout(e);­void 0=...

                        ^
    

    in function "d" called from line 1 col 324
    ...c&&(ec,n=!0);n||d&&d(k)}a=a.substr(f+1);"\n"==­a[0]&&(a=...

                              ^
    

    in function called from system
    Uncaught Error: Function "a" not found!
    at line 1 col 15
    if(void 0===d)a("Timeout");else{if("+CIFSR:STAIP­"==d.substr(...

              ^
    

    in function "b" called from line 1 col 15
    d=void 0;b&&b()

              ^
    

    in function called from system

    
    

    wifi``` suggests maybe callback is required:

    wifi
    ={
      "connect": function (a,b,c) { ... },
      "disconnect": function () { ... },
      "getIP": function (a) { ... },
    ....
    

    But this returns null:

    wifi.getIP(function(d){console.log(d);})­
    =undefined
    null
    
  • Thanks for this i shall look through this also

  • Thanks @ClearMemory041063, I can see now, the callback has some additional params. I should have picked that up from the module it is in the comments.

    This will also apply to wifi.scan() looking at it.

  • It does mean that there's some portability issues back to ESP8266 (assuming the code can fit), since the callback seems to just include the a single argument 'data' there..

  • I know. I wonder whether we should change the ESP8266 version - I wonder whether very many people use the callback form anyway.

    The Pico + ESP8266 code behaves the same way as the Espruino WiFi code, as do pretty much all the other functions (like this]. It seems it'd be more confusing to have just one or two functions that didn't (especially when that seemed to be the general form of callbacks for a lot of Node.js libraries as well).

  • On the ESP8226, personally, I don't, I just access the returned object property. But I appreciate this can't be the case with Espriuno + ESP8266. I think a common Wifi API (however the methods must be implemented to make things work), is a good idea though. Save on the confusion and allow script portability where possible. Even when using ESP8266 I've found also running code on the core boards extremely useful to check if an issue is me or a limitation of Espruino on ESP8266.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

EspruinoWifi.js getIP()

Posted by Avatar for Ollie @Ollie

Actions