Simple Demo that gets a webpage

Dependencies:   HTTPClient cc3000_hostdriver_mbedsocket mbed

Fork of EECS149_email_notifier by Antonio Iannopollo

Revision:
15:ac15ec676d87
Parent:
14:efd42910791b
Child:
16:d40dee28b02e
--- a/main.cpp	Mon Oct 20 06:58:24 2014 +0000
+++ b/main.cpp	Mon Oct 20 07:00:12 2014 +0000
@@ -1,6 +1,5 @@
 /**
- *  \brief CS294-84 demo
- *  \author Ben Zhang, Antonio Iannopollo
+ *  \brief CS294-84 demo \author Ben Zhang, Antonio Iannopollo
  *
  * This sampel code illustrates how to connect the mbed KL25Z platform to internet
  * thorugh the CC3000 wifi breakout board (http://www.adafruit.com/product/1469).
@@ -28,7 +27,7 @@
 // - SPI CLK  => (pin D13)
 // plus wifi network SSID, password, security level and smart-configuration flag.
 mbed_cc3000::cc3000 wifi(D3, D5, D10, SPI(D11, D12, D13),
-                                                 "EECS-PSK", "Thequickbrown", WPA2, false);
+                         "EECS-PSK", "Thequickbrown", WPA2, false);
 
 // create an http instance
 HTTPClient http;
@@ -44,44 +43,44 @@
 
 int main()
 {
-    // by default, it's red
-    led_red = 0;
-    led_green = 1;
+  // by default, it's red
+  led_red = 0;
+  led_green = 1;
 
-    // print message to indicate the program has started
-    pc.printf("CC3000 Sample Program\r\n");
-    wifi.init();
+  // print message to indicate the program has started
+  pc.printf("CC3000 Sample Program\r\n");
+  wifi.init();
 
-    while(1) {
-        // continuosly check connection status
-        if(wifi.is_connected() == false) {
-            // try to connect
-            if (wifi.connect() == -1) {
-                pc.printf("Failed to connect."
-                             "Please verify connection details and try again. \r\n");
-            } else {
-                pc.printf("IP address: %s \r\n", wifi.getIPAddress());
+  while(1) {
+    // continuosly check connection status
+    if(wifi.is_connected() == false) {
+      // try to connect
+      if (wifi.connect() == -1) {
+        pc.printf("Failed to connect."
+               "Please verify connection details and try again. \r\n");
+      } else {
+        pc.printf("IP address: %s \r\n", wifi.getIPAddress());
 
-                //once connected, turn green LED on and red LED off
-                led_red = 1;
-                led_green = 0;
-            }
-        } else {
-            // get input url and then return the value
-            pc.printf("> ");
-            pc.scanf("%s", url);
+        //once connected, turn green LED on and red LED off
+        led_red = 1;
+        led_green = 0;
+      }
+    } else {
+      // get input url and then return the value
+      pc.printf("> ");
+      pc.scanf("%s", url);
 
-            int ret = http.get(url, str, 128);
-            if (!ret) {
-                pc.printf("Requested %s\r\n", url);
-                pc.printf("Page fetched successfully - read %d characters\r\n",
-                                    strlen(str));
-                pc.printf("Result: %s\r\n", str);
-            } else {
-                pc.printf("Error - ret = %d - HTTP return code = %d\r\n",
-                                    ret,
-                                    http.getHTTPResponseCode());
-            }
-        }
+      int ret = http.get(url, str, 128);
+      if (!ret) {
+        pc.printf("Requested %s\r\n", url);
+        pc.printf("Page fetched successfully - read %d characters\r\n",
+                  strlen(str));
+        pc.printf("Result: %s\r\n", str);
+      } else {
+        pc.printf("Error - ret = %d - HTTP return code = %d\r\n",
+                  ret,
+                  http.getHTTPResponseCode());
+      }
     }
+  }
 }