Test version

Revision:
1:bd9f39f9d91c
Parent:
0:4be500de690c
--- a/WIFI.cpp	Tue Mar 20 02:09:21 2018 +0000
+++ b/WIFI.cpp	Tue Mar 20 02:21:49 2018 +0000
@@ -1,12 +1,10 @@
+
+#include "WIFI.h"
 #include "mbed.h"
 #include "TCPSocket.h"
 
-#include "ESP8266Interface.h"
-#define MBED_CONF_APP_NETWORK_INTERFACE WIFI_ESP8266
-#define MBED_CONF_EASY_CONNECT_WIFI_ESP8266_TX PC_10
-#define MBED_CONF_EASY_CONNECT_WIFI_ESP8266_RX PC_11
 
-ESP8266Interface wifi(MBED_CONF_EASY_CONNECT_WIFI_ESP8266_TX, MBED_CONF_EASY_CONNECT_WIFI_ESP8266_RX);
+
 const char *sec2str(nsapi_security_t sec)
 {
     switch (sec) {
@@ -30,7 +28,7 @@
 {
     WiFiAccessPoint *ap;
 
-    pc.printf("Scan:\r\n");
+//    pc.printf("Scan:\r\n");
 
     int count = wifi->scan(NULL,0);
 
@@ -39,13 +37,13 @@
 
     ap = new WiFiAccessPoint[count];
     count = wifi->scan(ap, count);
-    for (int i = 0; i < count; i++)
-    {
-        pc.printf("Network: %s secured: %s BSSID: %hhX:%hhX:%hhX:%hhx:%hhx:%hhx RSSI: %hhd Ch: %hhd\r\n", ap[i].get_ssid(),
-               sec2str(ap[i].get_security()), ap[i].get_bssid()[0], ap[i].get_bssid()[1], ap[i].get_bssid()[2],
-               ap[i].get_bssid()[3], ap[i].get_bssid()[4], ap[i].get_bssid()[5], ap[i].get_rssi(), ap[i].get_channel());
-    }
-    pc.printf("%d networks available.\r\n", count);
+    //for (int i = 0; i < count; i++)
+//    {
+//        pc.printf("Network: %s secured: %s BSSID: %hhX:%hhX:%hhX:%hhx:%hhx:%hhx RSSI: %hhd Ch: %hhd\r\n", ap[i].get_ssid(),
+//               sec2str(ap[i].get_security()), ap[i].get_bssid()[0], ap[i].get_bssid()[1], ap[i].get_bssid()[2],
+//               ap[i].get_bssid()[3], ap[i].get_bssid()[4], ap[i].get_bssid()[5], ap[i].get_rssi(), ap[i].get_channel());
+//    }
+//    pc.printf("%d networks available.\r\n", count);
 
     delete[] ap;
 }
@@ -54,7 +52,7 @@
 {
     TCPSocket socket;
 
-    pc.printf("Sending HTTP request to 192.168.8.100...\r\n");
+//    pc.printf("Sending HTTP request to 192.168.8.100...\r\n");
 
     // Open a socket on the network interface, and create a TCP connection to www.arm.com
     socket.open(net);
@@ -63,12 +61,12 @@
     // Send a simple http request
     char sbuffer[] = "GET / HTTP/1.1\r\nHost: 192.168.8.100\r\n\r\n";
     int scount = socket.send(sbuffer, sizeof sbuffer);
-    pc.printf("sent %d [%.*s]\r\n", scount, strstr(sbuffer, "\r\n")-sbuffer, sbuffer);
+//    pc.printf("sent %d [%.*s]\r\n", scount, strstr(sbuffer, "\r\n")-sbuffer, sbuffer);
 
     // Recieve a simple http response and print out the response line
     char rbuffer[64];
     int rcount = socket.recv(rbuffer, sizeof rbuffer);
-    pc.printf("recv %d [%.*s]\r\n", rcount, strstr(rbuffer, "\r\n")-rbuffer, rbuffer);
+//    pc.printf("recv %d [%.*s]\r\n", rcount, strstr(rbuffer, "\r\n")-rbuffer, rbuffer);
 
     // Close the socket to return its memory and bring down the network interface
     socket.close();