Dependencies:   Motor

(notes)

Revision:
30:889aff39caa8
Parent:
29:1d568c399cb7
Child:
31:0d925d69cbe2
--- a/main.cpp	Wed Dec 12 21:25:53 2018 +0000
+++ b/main.cpp	Wed Dec 12 22:02:18 2018 +0000
@@ -1,4 +1,6 @@
 #include "mbed.h"
+#include "TCPSocket.h"
+#include "ESP8266Interface.h"
 #include "Motor.h"
 #include "rgbled.h"
 #include "rgbSensor.h"
@@ -181,6 +183,19 @@
 int main() {
     pc.printf("Initializing ");
     
+    // Connect to Wifi
+    int ret = wifi.connect(MBED_CONF_APP_WIFI_SSID, MBED_CONF_APP_WIFI_PASSWORD, NSAPI_SECURITY_WPA_WPA2);
+    if (ret != 0) {
+        pc.printf("\r\nConnection error\r\n");
+    } else {
+        printf("Success\r\n\r\n");
+        printf("MAC: %s\r\n", wifi.get_mac_address());
+        printf("IP: %s\r\n", wifi.get_ip_address());
+        printf("Netmask: %s\r\n", wifi.get_netmask());
+        printf("Gateway: %s\r\n", wifi.get_gateway());
+        printf("RSSI: %d\r\n\r\n", wifi.get_rssi());
+    }
+    
     // Start threads
     thread1.start(check_RGB);
     thread2.start(speed_control); // Since we're stopped, this won't do anything
@@ -188,7 +203,7 @@
     // Bluetooth controller code
     char bnum=0;
     char bhit=0;
-    while(1) {
+    while(running) {
         if (blue.getc()=='!') {
             if (blue.getc()=='B') { //button data packet
                 bnum = blue.getc(); //button number
@@ -259,4 +274,5 @@
             }
         }
     }
+    wifi.disconnect();
 }
\ No newline at end of file