• Listing the WiFI APs

    Using either a PICO or an Espruino Original Board connected via the serial port to and ESP8266.

    The code:

    //GetAPs.js  11Jan2018
    // ESP8266 connected via serial port to PICO or Espruino Board
    
    //espruino board with ESP8266
    //PICO  with ESP8266
    
    //var Hardware=0; //Espruino board
    var Hardware =1; //PICO
    
    var Serial;
    
    //setup serial port
    if(Hardware===1)Serial=Serial2;
    if(Hardware===0)Serial=Serial4;
    
    if(Hardware===1){
     digitalWrite(B9,1); // enable on Pico Shim V2
     Serial.setup(115200, { rx: A3, tx : A2 }); //Pico
    }
    if(Hardware===0)Serial.setup(115200, { rx: C11, tx : C10 }); 
    //espruino board
    
    var cmd="";
    Serial.on('data', function (data) { 
    //  console.log(data);
      cmd+=data;
      var idx = cmd.indexOf("\r");
      while (idx>=0) { 
        var line = cmd.substr(0,idx);
        cmd = cmd.substr(idx+1);
        print(line);
        idx = cmd.indexOf("\r");
      }
    });
    
    function sendAT(){
      Serial.print("AT");
    }//end sendAT
    
    
    sendAT();
    setTimeout(function () {
      console.log("Hello World1");
      Serial.write("+++");
    setTimeout(function () {
      console.log("Hello World2");
      Serial.write("AT+CWLAP\r\n");
    }, 5000);
    }, 5000);
    
    

    Sample Output

     1v94 Copyright 2016 G.Williams
    >
    =undefined
    Garbage Characters
    >
    Ai-Thinker Technology Co. Ltd.
    ready
    >
    WIFI CONNECTED
    >
    WIFI GOT IP
    Hello World1
    Hello World2
    >
    +++AT+CWLAP
    >
    >
    +CWLAP:(4,"faux2",-51,"04:4e:5a:94:24:e4",1,-36,0)
    >
    +CWLAP:(0,"xfinitywifi",-87,"c6:27:95:38:8b:48",1,-19,0)
    >
    +CWLAP:(3,"ATT3x349v4",-91,"cc:65:ad:7e:e2:20",1,-22,0)
    >
    +CWLAP:(0,"xfinitywifi",-48,"16:4e:5a:94:24:e4",1,32767,0)
    >
    +CWLAP:(4,"HOME220-2.4",-83,"70:54:d2:07:7c:c0",6,-17,0)
    >
    +CWLAP:(1,"faux",-50,"20:4e:7f:03:87:cd",6,-24,0)
    >
    +CWLAP:(0,"xfinitywifi",-82,"70:54:d2:07:7c:c2",6,-17,0)
    >
    +CWLAP:(3,"AMKUS146",-93,"9e:d3:6d:bb:a8:5c",7,-17,0)
    >
    +CWLAP:(3,"Gearfam",-93,"78:f2:9e:0e:74:c8",6,-26,0)
    >
    +CWLAP:(4,"ATT6UuI5FT",-88,"f8:18:97:b6:71:32",9,50,0)
    >
    +CWLAP:(0,"xfinitywifi",-79,"0c:54:a5:64:cf:c2",11,-36,0)
    >
    +CWLAP:(4,"HOME-24D1-2.4",-79,"0c:54:a5:64:cf:c0",11,-34,0)
    >
    +CWLAP:(4,"ATT5wAn8b9",-80,"f8:18:97:d5:63:06",11,51,0)
    >
    +CWLAP:(0,"xfinitywifi",-92,"0c:54:a5:6b:f8:aa",11,-21,0)
    OK
    >
    
    

    1 Attachment

About