![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
factory resets
Dependencies: WiflyInterface mbed
Fork of Wifly_UpdateFirmware by
main.cpp@3:5f4c91e62eea, 2013-08-06 (annotated)
- Committer:
- ddollar
- Date:
- Tue Aug 06 02:21:57 2013 +0000
- Revision:
- 3:5f4c91e62eea
- Parent:
- 2:78b3ac0cd2a7
factory resets
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
samux | 0:da9cea9f791c | 1 | // this program updates to the latest firmware a wifly module |
samux | 0:da9cea9f791c | 2 | |
samux | 0:da9cea9f791c | 3 | #include "mbed.h" |
samux | 0:da9cea9f791c | 4 | #include "WiflyInterface.h" |
samux | 0:da9cea9f791c | 5 | |
ddollar | 3:5f4c91e62eea | 6 | WiflyInterface wifly(p9, p10, p30, p29, "periodic.lab", "", NONE); |
samux | 0:da9cea9f791c | 7 | |
samux | 0:da9cea9f791c | 8 | int main() { |
ddollar | 3:5f4c91e62eea | 9 | bool success = true; |
samux | 2:78b3ac0cd2a7 | 10 | |
ddollar | 3:5f4c91e62eea | 11 | printf("wifly init\r\n"); |
samux | 0:da9cea9f791c | 12 | wifly.init(); //Use DHCP |
ddollar | 3:5f4c91e62eea | 13 | |
ddollar | 3:5f4c91e62eea | 14 | while(!wifly.connect()) { |
ddollar | 3:5f4c91e62eea | 15 | printf("wifly connecting (%s)...\r\n", wifly.getIPAddress()); |
ddollar | 3:5f4c91e62eea | 16 | } |
samux | 0:da9cea9f791c | 17 | |
ddollar | 3:5f4c91e62eea | 18 | // once connected, send command to update firmware |
ddollar | 3:5f4c91e62eea | 19 | printf("set ftp address\r\n"); |
samux | 2:78b3ac0cd2a7 | 20 | if (!wifly.sendCommand("set ftp address 0\r", "AOK")) |
samux | 2:78b3ac0cd2a7 | 21 | success = false; |
ddollar | 3:5f4c91e62eea | 22 | printf("set dns name\r\n"); |
samux | 2:78b3ac0cd2a7 | 23 | if (!wifly.sendCommand("set dns name rn.microchip.com\r", "AOK")) |
samux | 2:78b3ac0cd2a7 | 24 | success = false; |
ddollar | 3:5f4c91e62eea | 25 | printf("save\r\n"); |
samux | 2:78b3ac0cd2a7 | 26 | if (!wifly.sendCommand("save\r", "Stor")) |
samux | 2:78b3ac0cd2a7 | 27 | success = false; |
ddollar | 3:5f4c91e62eea | 28 | printf("ftp update\r\n"); |
ddollar | 3:5f4c91e62eea | 29 | if (!wifly.sendCommand("ftp update \r", "FTP OK", NULL, 30000)) |
samux | 2:78b3ac0cd2a7 | 30 | success = false; |
ddollar | 3:5f4c91e62eea | 31 | printf("factory reset\r\n"); |
samux | 2:78b3ac0cd2a7 | 32 | if (!wifly.sendCommand("factory RESET\r")) |
samux | 2:78b3ac0cd2a7 | 33 | success = false; |
ddollar | 3:5f4c91e62eea | 34 | printf("reboot\r\n"); |
samux | 2:78b3ac0cd2a7 | 35 | if (!wifly.sendCommand("reboot\r")) |
samux | 2:78b3ac0cd2a7 | 36 | success = false; |
samux | 0:da9cea9f791c | 37 | |
samux | 2:78b3ac0cd2a7 | 38 | if (success) |
samux | 2:78b3ac0cd2a7 | 39 | printf("firmware updated successfully!\r\n"); |
samux | 2:78b3ac0cd2a7 | 40 | else |
samux | 2:78b3ac0cd2a7 | 41 | printf("ERROR while updating firmware!\r\n"); |
samux | 0:da9cea9f791c | 42 | } |