arduino - ameba - wifi scan

git : https://github.com/neojou/arduino-ameba.git

Ameba WiFi 描述
Ameba IC 本身含有 wifi, 並不需要另外加 wifi shield.
所以並不需要 SPI.h 和 SPI 相關介面處理


wifi scan example :

從 1.0.6 板之後, 可以從 library 的範例程式拉出來, 直接執行 ( ScanNetworks )
https://github.com/neojou/arduino-ameba/tree/master/hardware/libraries/WiFi/examples/ScanNetworks





MAC address : 屬於網路 OSI 第二層. 每個網路設備需要有一個專屬的 MAC 地址

void printMacAddress() {
// the MAC address of your Wifi shield
byte mac[6];
// print your MAC address:
WiFi1.macAddress(mac);
Serial.print("MAC: ");
Serial.print(mac[5],HEX);
Serial.print(":");
Serial.print(mac[4],HEX);
Serial.print(":");
Serial.print(mac[3],HEX);
Serial.print(":");
Serial.print(mac[2],HEX);
Serial.print(":");
Serial.print(mac[1],HEX);
Serial.print(":");
Serial.println(mac[0],HEX);
}


Scan :

void listNetworks() {
// scan for nearby networks:
Serial.println("** Scan Networks **");
int numSsid = WiFi.scanNetworks();
if (numSsid == -1) {
Serial.println("Couldn't get a wifi connection");
while (true);
}
// print the list of networks seen:
Serial.print("number of available networks:");
Serial.println(numSsid);
// print the network number and name for each network found:
for (int thisNet = 0; thisNet<numSsid; thisNet++) {
Serial.print(thisNet);
Serial.print(") ");
Serial.print(WiFi.SSID(thisNet));
Serial.print("\tSignal: ");
Serial.print(WiFi.RSSI(thisNet));
Serial.print(" dBm");
Serial.print("\tEncryption: ");
printEncryptionType(WiFi.encryptionType(thisNet));
}
}

AP 是否加密

void printEncryptionType(int thisType) {
// read the encryption type and print out the name:
switch (thisType) {
case ENC_TYPE_WEP:
Serial.println("WEP");
break;
case ENC_TYPE_TKIP:
Serial.println("WPA");
break;
case ENC_TYPE_CCMP:
Serial.println("WPA2");
break;
case ENC_TYPE_NONE:
Serial.println("None");
break;
case ENC_TYPE_AUTO:
Serial.println("Auto");
break;
}
}


--
執行結果, 每 10 秒會重新 scan 一次.

Scanning available networks...
** Scan Networks **
number of available networks:9
0) BBHOME163594 Signal: -70 dBm Encryption: WPA2
1) alexanny_2G  Signal: -74 dBm Encryption: WPA2
2) B3504X       Signal: -88 dBm Encryption: WPA2
3) KUO-HOME     Signal: -82 dBm Encryption: WPA
4) NAN SHAN     Signal: -91 dBm Encryption: WPA2
5) billwang     Signal: -66 dBm Encryption: WPA2
6) snowdragon   Signal: -51 dBm Encryption: WPA2
7) MA   Signal: -71 dBm Encryption: WPA2
8) DSL-7740C    Signal: -80 dBm Encryption: WPA2

Scanning available networks...
** Scan Networks **
number of available networks:11
0) BBHOME163594 Signal: -71 dBm Encryption: WPA2
1) alexanny_2G  Signal: -74 dBm Encryption: WPA2
2) B3504X       Signal: -88 dBm Encryption: WPA2
3) KUO-HOME     Signal: -82 dBm Encryption: WPA
4) billwang     Signal: -65 dBm Encryption: WPA2
5) snowdragon   Signal: -58 dBm Encryption: WPA2
6) MA   Signal: -72 dBm Encryption: WPA2
7) DSL-7740C    Signal: -81 dBm Encryption: WPA2
8) DSL-7740C    Signal: -96 dBm Encryption: WPA2
9) Malcolm_ASUS Signal: -91 dBm Encryption: WPA2
10) NAN SHAN    Signal: -92 dBm Encryption: WPA2

Scanning available networks...
** Scan Networks **
number of available networks:13
0) BBHOME163594 Signal: -72 dBm Encryption: WPA2
1) B3504X       Signal: -88 dBm Encryption: WPA2
2) KUO-HOME     Signal: -82 dBm Encryption: WPA
3) billwang     Signal: -64 dBm Encryption: WPA2
4) snowdragon   Signal: -56 dBm Encryption: WPA2
5) MA   Signal: -70 dBm Encryption: WPA2
6) DSL-7740C    Signal: -79 dBm Encryption: WPA2
7) DSL-7740C    Signal: -96 dBm Encryption: WPA2
8) Malcolm_ASUS Signal: -91 dBm Encryption: WPA2
9) NAN SHAN     Signal: -92 dBm Encryption: WPA2
10) QEF Signal: -92 dBm Encryption: WPA
11) WiFi8781    Signal: -92 dBm Encryption: WPA2
12) yuchen      Signal: -86 dBm Encryption: WPA




-- 相關 Arduino wifi API :

Arduino API : macAddress()

https://www.arduino.cc/en/Reference/WiFiMACAddress


Arduino API : scanNetworks()

https://www.arduino.cc/en/Reference/WiFiScanNetworks


另外官網原本的教學 :

https://www.arduino.cc/en/Tutorial/ScanNetworks


留言

  1. does this work? I do not see anything in my serial monitor

    回覆刪除
  2. does this work? I do not see anything in my serial monitor

    回覆刪除
  3. Please let me double confirm it and reply you next week.

    回覆刪除
  4. Dear Harsh Munshi,

    Not sure if you can understand Chinese, if not, I can rewrite the article in English for you.

    Recently, I changed to use the board manager mechanism and retesting now. Excuse me for this inconvenience.

    You can try to use 1.6.6 with installing Ameba board with board manager. The procedure in detail is as below.
    http://njiot.blogspot.tw/2015/12/arduino-windows-installation-by-using.html

    And also I did some change in this example ( not include WiFi1.h at the example file, but moved to Arduino.h ) You can do it with the installation and try it again.

    If can not see from serial monitor. please
    1. please check the device manager to see if you have a com port named mbed serial port, if not, please check or reinstall the mbed serial driver ( described in the installation web page also )
    2. Please try the ASCII Table example first to see if serial monitor works fine.

    FYI. If still any problem, please feel free to let me know. Thanks.

    Regards,
    Neo Jou

    回覆刪除

張貼留言

熱門文章