factory resets

Dependencies:   WiflyInterface mbed

Fork of Wifly_UpdateFirmware by Samuel Mokrani

Revision:
2:78b3ac0cd2a7
Parent:
1:15ea8cdb6a39
Child:
3:5f4c91e62eea
diff -r 15ea8cdb6a39 -r 78b3ac0cd2a7 main.cpp
--- a/main.cpp	Sat Nov 24 17:05:36 2012 +0000
+++ b/main.cpp	Sat Nov 24 20:16:17 2012 +0000
@@ -6,16 +6,27 @@
 WiflyInterface wifly(p9, p10, p30, p29, "mbed", "password", WPA);
 
 int main() {
+
     wifly.init(); //Use DHCP
     while(!wifly.connect());
     
+    bool success = true;
     // once connected, send command to update firmware
-    wifly.sendCommand("set ftp address 0\r", "AOK");
-    wifly.sendCommand("set dns name rn.microchip.com\r", "AOK");
-    wifly.sendCommand("save\r", "Stor");
-    wifly.sendCommand("ftp update\r", "FTP OK", NULL, 30000);
-    wifly.sendCommand("factory RESET\r");
-    wifly.sendCommand("reboot\r");
+    if (!wifly.sendCommand("set ftp address 0\r", "AOK"))
+        success = false;
+    if (!wifly.sendCommand("set dns name rn.microchip.com\r", "AOK"))
+        success = false;
+    if (!wifly.sendCommand("save\r", "Stor"))
+        success = false;
+    if (!wifly.sendCommand("ftp update\r", "FTP OK", NULL, 30000))
+        success = false;
+    if (!wifly.sendCommand("factory RESET\r"))
+        success = false;
+    if (!wifly.sendCommand("reboot\r"))
+        success = false;
     
-    while(1);
+    if (success)
+        printf("firmware updated successfully!\r\n");
+    else
+        printf("ERROR while updating firmware!\r\n");
 }