• Some comments:
    wifi.setPower(onOrOff, function(err) { ... }) sounds like TX power level to me? We need a function to set the wifi mode, I believe, this could include: none (=off), station, ap, station+ap. Or do you want just on/off and then drive the mode by using connect/disconnect/createAP/deleteAP ?

    For wifi.connect(ssid, key, [options], function(err) { ... }); I would prefer to see callbacks that get the current state. That allows the app to show whether it's waiting to associate or waiting to get a DHCP lease. Unless you want to roll all that into a global wifi state callback.

    wifi.getAPs(function(err, aps) { ... }); I believe this is usually called scan, no? Or put differently, do you expect getAPs to return a list of already-known APs or do you expect it to initiate a scan? If it initiates a scan, can the callback be called multiple times as APs are discovered or only once when the scan finishes?

    Why does wifi.getAPs(function(err, aps) { ... }); need a callback as opposed to just returning the info?

    wifi.createAP(ssid, key, channel, enc, function(err) { ... }) I see a problem with the channel, which is that in sta+ap mode the ap has to be on the same channel as the sta. Maybe allowing channel 0 to stand for any can make this work.

    Additional thoughts:

    Being able to set the IP address and associated network parameters (gateway and mask) is needed.

    A call is needed to set the hostname, which may be used in DHCP to update DNS and in other local host discovery protocols. The hostname needs to be set before connecting to an AP...

    We need calls to disconnect and to shut down the AP.

    How about a call to get RSSI and current data rate? Alternatively, getConnectedAP could return that info.

    I wonder how wifi and low-power modes should interact. It would be good to have a wifiPowerMode call with an extensible set of values, starting with full power and something mapping to PS-Poll (using the DTIM intervals to power down Wifi). This way there's at least some portable way to state that it's desirable to use less power at the expense of throughput and latency.

    One question with the above is what the state at boot should be. Systems like the esp8266 save the wifi config in flash and can automatically connect at boot time. Also, I'd really like to support connecting the IDE to the esprunio via TCP/Wifi and then the espruino has to connect at boot to something on its own (unless that's expected to be driven by startup JS files stored in flash).

About

Avatar for tve @tve started