mbed Sensor node for Instrumented Booth over ETH.

Dependencies:   EthernetInterface-1 MaxbotixDriver Presence HTU21D_TEMP_HUMID_SENSOR_SAMPLE Resources SHARPIR mbed-rtos mbed-src WDT_K64F nsdl_lib

Fork of Trenton_Switch_LPC1768_ETH by Demo Team

Revision:
8:be68e827aa53
Parent:
7:afaa17c11965
Child:
10:09a1dd3fbd3d
--- a/main.cpp	Tue Oct 08 15:04:55 2013 +0000
+++ b/main.cpp	Wed Oct 09 21:40:48 2013 +0200
@@ -19,6 +19,9 @@
 #include "TCPSocketConnection.h"
 #include "TCPSocketServer.h"
 
+#define STRINGIFY(x) #x
+#define TO_STRING(x) STRINGIFY(x)
+
 using namespace mbed_cc3000;
 
 tUserFS user_info;
@@ -104,7 +107,7 @@
     printf("FTC finished. \r\n");
 }
 
-/** 
+/**
  *  \brief Start smart config
  *  \param none
  *  \return none
@@ -113,7 +116,7 @@
     wifi.start_smart_config(smartconfigkey);
 }
 
-/** 
+/**
  *  \brief Simple socket demo
  *  \param none
  *  \return int
@@ -126,15 +129,18 @@
     printf("cc3000 simple socket demo. \r\n");
     print_cc3000_info();
 
+    printf("User's AP setup: SSID: %s, Password: %s, Security: %s \r\n", TO_STRING(SSID), TO_STRING(AP_KEY), TO_STRING(AP_SECURITY));
+
     printf("\n<0> Normal run. SmartConfig will \r\n    start if no valid connection exists. \r\n");
-    printf("<1> Connect using fixed SSID : %s \r\n", SSID);
-    printf("<2> SmartConfig. \r\n");
+    printf("<1> Connect using fixed SSID without AP_KEY: %s \r\n", SSID);
+    printf("<2> Connect using fixed SSID with AP_KEY: %s \r\n", SSID);
+    printf("<9> SmartConfig. \r\n");
 
     signed char c = getchar();
     switch (c)
     {
         case '0':
-            if(!user_info.FTC)
+            if (!user_info.FTC)
             {
                 do_FTC();
                 wifi._wlan.stop();
@@ -142,17 +148,29 @@
             break;
         case '1':
             printf("Attempting SSID Connection. \r\n");
+
+            wifi._wlan.ioctl_set_connection_policy(0, 0, 0);
+            wait(1);
+            wifi.stop();
+            wait(1);
+            wifi.start(0);
+            connect_to_ssid(SSID);
+            break;
+        case '2':
+            printf("Attempting SSID Connection. \r\n");
+
+            wifi._wlan.ioctl_set_connection_policy(0, 0, 0);
+            wait(1);
+            wifi.stop();
+            wait(1);
+            wifi.start(0);
 #ifndef CC3000_TINY_DRIVER
-    #ifdef AP_KEY
-            connect_to_ssid(SSID, AP_KEY, AP_SECURITY); /* TODO rewrite to const vraiables - NOT MACROS */
-    #else
-            connect_to_ssid(SSID);
-    #endif
+            connect_to_ssid(SSID, AP_KEY, AP_SECURITY);
 #else
             connect_to_ssid(SSID);
 #endif
             break;
-        case '2':
+        case '9':
             printf("Starting Smart Config configuration. \r\n");
             start_smart_config();
             while (wifi.is_dhcp_configured() == false)