• Hello everybody.

    Faced the problem of reconnecting to the WiFi network through the wifi.on (‘connected’) event.
    Program code:

    var ssid = 'ssid';
    var password = 'password';
    wifi.stopAP();
    wifi.connect(ssid, { password:password },()=>{wifi.save();});
    wifi.on('connected',()=>{console.log(wif­i.getIP());});
    wifi.on('disconnected',()=>{console.log(­"WiFi network lost."); wifi.connect(ssid,{password:password});}­);
    
    

    When you first start wifi.on (‘connected’), it works:
    {
    "ip": "192.168.0.10",
    "netmask": "255.255.255.0",
    "gw": "192.168.0.1",
    "mac": "a4:cf:12:75:38:ec"
    }

    I turn off the router with my hands:

    E (113206) event: post event to user fail!
    E (115622) event: post event to user fail!
    E (118037) event: post event to user fail!
    E (120453) event: post event to user fail!
    WiFi network lost.
    WiFi network lost.
    WiFi network lost.

    Obviously wifi.on (‘disconnected’) - it worked.

    I turn on the router, I get a message from wifi.on (‘connected’):

    {
    "ip": "192.168.0.10",
    "netmask": "255.255.255.0",
    "gw": "192.168.0.1",
    "mac": "a4:cf:12:75:38:ec"
    }

    And that’s it. If I turn off the router again, then no events occur.
    Moreover, if you give the wifi.getIP () command when the router is off, then we get.

    {
    ip: "192.168.0.10",
    netmask: "255.255.255.0",
    gw: "192.168.0.1",
    mac: "a4:cf:12:75:38:ec"
    }

    (the router has been turned off for more than two minutes)
    That is, the board does not understand that wifi / network is no more.

    Question:

    1. So it should be or is it a mistake?
    2. If so, how should it be in this case to determine the absence of a network and reconnect to it?

    PS So far, the only working option I have found is the gateway ping once every 30 seconds, and if (rateTime> 1000) {e.Reboot ()};

    But I think this is not the best option :)
    PPS Sorry for the presentation - English is not my native language.

    I will be glad to any advice. Thanks.

About

Avatar for Homoludens @Homoludens started