A WiFiDipCortex based robot. Control is via sockets over WiFi. See also: https://github.com/mfurseman/robo-android

Dependencies:   Motordriver USBDevice cc3000_hostdriver_mbedsocket_hacked mbed

Revision:
1:b66a2d756c8a
Parent:
0:993d6b65e255
Child:
2:50c151183047
diff -r 993d6b65e255 -r b66a2d756c8a main.cpp
--- a/main.cpp	Sat Oct 18 02:28:52 2014 +0000
+++ b/main.cpp	Tue Oct 21 14:03:50 2014 +0000
@@ -2,6 +2,7 @@
 #include "cc3000.h"
 #include "USBSerial.h"
 
+
 /* Quickly change debug flag to remove blocking serial code */
 #define DEBUG
 #ifdef DEBUG
@@ -11,8 +12,10 @@
 #define debug(x, ...)
 #endif
 
+
 using namespace mbed_cc3000;
 
+
 /* On board LED */
 DigitalOut led(P0_1);
 
@@ -23,6 +26,7 @@
 tNetappIpconfigRetArgs ipinfo;
 
 
+/* Prints CC3000 connection info */
 void printConnectionInfo() {
     if (( wifi.is_enabled() ) && ( wifi.is_dhcp_configured() )) {
         wifi.get_ip_config(&ipinfo);
@@ -43,7 +47,9 @@
     }
 }
 
-int main(void) {
+
+/* WiFi DipCortex board setup */
+void init() {
     NVIC_SetPriority(SSP1_IRQn, 0x0); 
     NVIC_SetPriority(PIN_INT0_IRQn, 0x1);
     
@@ -52,17 +58,24 @@
     
     // Enable RAM1
     LPC_SYSCON->SYSAHBCLKCTRL |= (0x1 << 26);
-        
+    
+    // This may be neccassary for CC3000
     wait(1);
-    printConnectionInfo();
+}
+
 
+/* Connects WiFi assuming existing SmartConfig */
+void connectWifi() {
     wifi.start(0);
-    printConnectionInfo();
-    
     wait_ms(750);
+    wifi._wlan.ioctl_set_connection_policy(0, 0, 1);
+    // TODO: Timeout and switch on smart config here
+}
 
-    wifi._wlan.ioctl_set_connection_policy(0, 0, 1);
-    printConnectionInfo();
+
+int main(void) {
+    init();    
+    connectWifi();
 
     while(1) {
         printConnectionInfo();