Strange issue with wifi!11!!1!

Posted on
  • Gentlemen,

    i've a problem:

     ____                 _
    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v05 (c) 2019 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    Flash map 4MB:512/512, manuf 0x20 chip 0x4016
    

    I try to connect to an ap via:

    var wifi = require("Wifi");
    wifi.connect("Bratatatat-666", {password: "SomeThiNGLIKeTh8t"},
       function(err){
      if(err)console.log(err);
      else console.log("connected!");
    });
    

    and i get "bad password" or stock in "connecting" but i can swear the password is absolutely correct. 100%!11!!1!

    My router is available on 2.4 and 5 GHz and with another MC, wich is not flashed with Espruino, there is no problem to connect.

    Please help!

    If i connect to an mobile-hotspot, wich has password like "espruino1337", the connection is successfull.

  • Add channel and bssid to make it easier to connect to the 2.4 GHz access point and try again.

    http://www.espruino.com/Reference#l_Wifi­_connect

  • Doesn't make any difference, sorry.

    var wifi = require("Wifi");
    wifi.connect("Vodafone-8751", {
      password: "ABCDEfGh1jKLmnoP", //Password is like this
      channel: 1,
      bssid: "2C:58:4F:92:A7:21"}, 
      function(err){
        if (err) console.log(err);
        else console.log("connected!");
    });
    

    Is there any chance, that espruino converts the pw-string not correctly? How i said, it works without any problems at a esp32 with regular firmware. It is really strange because even with the espruino i was able to connect to the hotspot of my mobile-phone. Security-standard of my wlan-router is WPA2-Personal, whatever "Personal" meens ..

  • Hmm, try this to get some info about the access points in your surrounding:

    require("Wifi").scan((arrayOfAcessPoints­) =>{print(arrayOfAcessPoints);});
    
  • What router model are you using?

    Can you change Personal to PSK (pre-shared key)? Or is there only an option to switch between Personal and Enterprise?

  • require("Wifi").scan((arrayOfAcessPoints¬≠) =>{print(arrayOfAcessPoints);});

    Output:

    [
      { "rssi": -60, "channel": 1,
        "authMode": "wpa2",
        "isHidden": false,
        "ssid": "Vodafone-8751",
        "mac": "2c:58:4f:92:a7:21"
       },
      { "rssi": -66, "channel": 11,
        "authMode": "wpa2",
        "isHidden": false,
        "ssid": "Vodafone-3E7C",
        "mac": "88:71:b1:a7:21:d3"
       }
     ]
    
  • Router is a DOCSIS 3.1 and there are just the options "off", "wpa2" and "wpa and wpa2"

  • That mistake I had several years ago
    It turned out that one of my routers was teasing.
    I use the showed up start and since then there have been no problems.
    The other routers have no problems.

      function lan() {
        wlan.connect(logon.ssid, {password: logon.pass}, function (s) {
          boola = true;
          if(s==='bad password') {
            if(debug>0) {console.log('restart lan');}
            lan();
          }
        });
    
        if(debug)console.log("Frida is my watchdog");
        if(debug)console.log(wlan.getIP().ip);
      } // end lan()
    
      setTimeout(lan,400);
    
      
      wlan.on('connected', function(s) {
        if(debug)console.log('Starter test', wlan.getIP().ip);
        if(boola) {
          boola = false;
          startTimeServer();
          //httpSrv.listen(80);
        }
      });
    
    
  • "wpa2" should work
    "wpa and wpa2" could cause problems
    WiFi 6 could cause problems

  • Things like "debug", "logon" are not defined ...

  • May it depends on long password, how do you think? I've never tested Espruino with so long passwords. Some old devices I had require password to be not more then 16 or even 8 symbols, I forget.

  • // lan-test00 - esp8266_01
    
    var ver = 'ver = V1.0';
    
    function onInit(a) {
      debug = (typeof a==='undefined')?0:a;
      var wlan     = require("Wifi");
      var http     = require("http");
      var logon    = require('LOGON');
    
    
      wlan.stopAP();
      wlan.disconnect();
    
    
      var boola;
      function lan() {
        //wlan.connect(yourssid, {password: yourpassword}, function (s) {
        wlan.connect(logon.ssid, {password: logon.pass}, function (s) {
          boola = true;
          if(s==='bad password') {
            if(debug)console.log('restart lan');
            lan();
          }
        });
    
        if(debug)console.log("Frida is my watchdog");
        if(debug)console.log(wlan.getIP().ip);
      } // end lan()
      setTimeout(lan,400);
    
    
      wlan.on('connected', function(s) {
        if(debug)console.log('Starter test', wlan.getIP().ip);
        if(boola) {
          boola = false;
          //do what you need to do.
          if(debug)console.log('tilsluttet lan');
        }
      });
    
    } // end onInit()
    
    onInit(2); // comment or remove before save
    
    
    
    

    You should not use logon and use your own logon values instead. That's because I have my logon values in a module.
    I use debug until the program runs properly.

  • So, here is what i come up with:

    var wifi = require("Wifi");
    var doit;
    
    var ssid = 'Vodafone-8751';
    var passwort = 'ABCDEfGh1jKLmnoP';
    
    wifi.stopAP();
    wifi.disconnect();
    
    function lan() {
      wifi.connect(ssid, {password: passwort}, function(s) {
        if (s === 'bad_password') {
          doit = true;
          console.log('Es ist ein Fehler aufgetreten: ' + s);
          console.log('Verbindungsversuch gestartet ...');
          lan();
        }
        if (s != 'bad_password') {
          console.log('Es ist ein Fehler aufgetreten: ' + s);
          console.log('Verbindungsversuch wird abgebrochen.');
        }
      });
      console.log(wifi.getIP().ip);
    } // Ende: lan()
    setTimeout(lan,500);
    
    wifi.on('connected', function(s) {
      console.log('Es hat endlich geklappt, Verbindungsstatus: ' + s);
      if (doit) {
        doit = false;
      }
    });
    

    and get stock in:

    0.0.0.0
    Es ist ein Fehler aufgetreten: bad_password
    Verbindungsversuch gestartet ...
    0.0.0.0
    Es ist ein Fehler aufgetreten: bad_password
    Verbindungsversuch gestartet ...
    0.0.0.0
    Es ist ein Fehler aufgetreten: bad_password
    Verbindungsversuch gestartet ...
    0.0.0.0
    
  • Btw: WLAN Modus is Mixed 802.11 g/n ...

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

Strange issue with wifi!11!!1!

Posted by Avatar for user111636 @user111636

Actions