物聯網開發硬體應用
Would you like to react to this message? Create an account in a few clicks or log in to continue.
物聯網開發硬體應用

提升國內高職學生物聯網開發硬體應用入門技術 待進入科技大學再升級為物聯網開發硬體設計人員


您沒有登錄。 請登錄註冊

7697板wifi測試

2 posters

向下  內容 [第1頁(共1頁)]

17697板wifi測試 Empty 7697板wifi測試 周一 12月 11, 2017 11:26 pm

Admin


Admin

利用7697板燒入以下碼 即可測試
#include <LWiFi.h>


char ssid[] = "cp401a"; //  your network SSID (name)
char pass[] = "123456789";    // your network password (use for WPA, or use as key for WEP)

int keyIndex = 0;               // your network key Index number (needed only for WEP)

int status = WL_IDLE_STATUS;
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(117,185,24,248);
char server[] = "download.labs.mediatek.com";   // http://download.labs.mediatek.com/linkit_7697_ascii.txt

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
WiFiClient client;

void setup() {
   //Initialize serial and wait for port to open:
   Serial.begin(9600);
   while (!Serial)
   {
       ; // wait for serial port to connect. Needed for native USB port only
   }

   // attempt to connect to Wifi network:
   while (status != WL_CONNECTED)
   {
       Serial.print("Attempting to connect to SSID: ");
       Serial.println(ssid);
       // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
       status = WiFi.begin(ssid, pass);
   }
   Serial.println("Connected to wifi");
   printWifiStatus();

   Serial.println("\nStarting connection to server...");
   // if you get a connection, report back via serial:
   if (client.connect(server, 80))
   {
       Serial.println("connected to server (GET)");
       // Make a HTTP request:
       client.println("GET /linkit_7697_ascii.txt HTTP/1.0");
       client.println("Host: download.labs.mediatek.com");
       client.println("Accept: */*");
       client.println("Connection: close");
       client.println();
       delay(10);
   }
}

void loop()
{
   // if there are incoming bytes available
   // from the server, read them and print them:
   while (client.available())
   {
       char c = client.read();
       Serial.write(c);
   }

   // if the server's disconnected, stop the client:
   if (!client.connected())
   {
       Serial.println();
       Serial.println("disconnecting from server.");
       client.stop();
       // do nothing forevermore:
       while (true);
   }
}


void printWifiStatus()
{
   // print the SSID of the network you're attached to:
   Serial.print("SSID: ");
   Serial.println(WiFi.SSID());

   // print your WiFi shield's IP address:
   IPAddress ip = WiFi.localIP();
   Serial.print("IP Address: ");
   Serial.println(ip);

   // print the received signal strength:
   long rssi = WiFi.RSSI();
   Serial.print("signal strength (RSSI):");
   Serial.print(rssi);
   Serial.println(" dBm");
}


利用工具中序列port監控視窗 即可顯示如下
7697板wifi測試 2017-110

其中ssid及pass為所可使用的wifi router堤供



Admin 在 周四 五月 10, 2018 7:15 pm 作了第 1 次修改

https://iotboard.666forum.com

27697板wifi測試 Empty 回復: 7697板wifi測試 周一 12月 25, 2017 8:43 pm

Yn



希望路由器能設定好,就可以測試了!

https://yunlab.blogspot.com

回頂端  內容 [第1頁(共1頁)]

這個論壇的權限:
無法 在這個版面回復文章