Test version

Files at this revision

API Documentation at this revision

Comitter:
a2824256
Date:
Tue Mar 20 02:21:49 2018 +0000
Parent:
0:4be500de690c
Commit message:
repair main.cpp

Changed in this revision

WIFI.cpp Show annotated file Show diff for this revision Revisions of this file
WIFI.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- 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();
--- a/WIFI.h	Tue Mar 20 02:09:21 2018 +0000
+++ b/WIFI.h	Tue Mar 20 02:21:49 2018 +0000
@@ -5,4 +5,5 @@
 const char *sec2str(nsapi_security_t sec);
 void scan_demo(WiFiInterface *wifi);
 void http_demo(NetworkInterface *net);
+
 #endif
--- a/main.cpp	Tue Mar 20 02:09:21 2018 +0000
+++ b/main.cpp	Tue Mar 20 02:21:49 2018 +0000
@@ -3,8 +3,12 @@
 #include "MAX30102.h"
 #include "LEDS.h"
 #include "WIFI.h"
+#include "ESP8266Interface.h"
+#define MAX_BRIGHTNESS 255
 
-#define MAX_BRIGHTNESS 255
+#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
 extern int* ReadDS1621(void);
 uint32_t aun_ir_buffer[500]; //IR LED sensor data
 int32_t n_ir_buffer_length;    //data length
@@ -16,7 +20,7 @@
 uint8_t uch_dummy;
 
 Serial pc(USBTX, USBRX);    //initializes the serial port, TX-PA2, RX-PA3
-
+ESP8266Interface wifi(MBED_CONF_EASY_CONNECT_WIFI_ESP8266_TX, MBED_CONF_EASY_CONNECT_WIFI_ESP8266_RX);
 PwmOut pwmled(PA_10);  //initializes the pwm output PB3 that connects to the LED
 DigitalIn INT(PC_5);  //pin PB7 connects to the interrupt output pin of the MAX30102
 DigitalOut led(PC_9); //PC13 connects to the on board user LED