Simple program to update the firmware of a wifly module
Dependencies: WiflyInterface mbed
main.cpp@2:78b3ac0cd2a7, 2012-11-24 (annotated)
- Committer:
- samux
- Date:
- Sat Nov 24 20:16:17 2012 +0000
- Revision:
- 2:78b3ac0cd2a7
- Parent:
- 1:15ea8cdb6a39
print if firmware has been updated successfully
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 | |
samux | 1:15ea8cdb6a39 | 6 | WiflyInterface wifly(p9, p10, p30, p29, "mbed", "password", WPA); |
samux | 0:da9cea9f791c | 7 | |
samux | 0:da9cea9f791c | 8 | int main() { |
samux | 2:78b3ac0cd2a7 | 9 | |
samux | 0:da9cea9f791c | 10 | wifly.init(); //Use DHCP |
samux | 0:da9cea9f791c | 11 | while(!wifly.connect()); |
samux | 0:da9cea9f791c | 12 | |
samux | 2:78b3ac0cd2a7 | 13 | bool success = true; |
samux | 0:da9cea9f791c | 14 | // once connected, send command to update firmware |
samux | 2:78b3ac0cd2a7 | 15 | if (!wifly.sendCommand("set ftp address 0\r", "AOK")) |
samux | 2:78b3ac0cd2a7 | 16 | success = false; |
samux | 2:78b3ac0cd2a7 | 17 | if (!wifly.sendCommand("set dns name rn.microchip.com\r", "AOK")) |
samux | 2:78b3ac0cd2a7 | 18 | success = false; |
samux | 2:78b3ac0cd2a7 | 19 | if (!wifly.sendCommand("save\r", "Stor")) |
samux | 2:78b3ac0cd2a7 | 20 | success = false; |
samux | 2:78b3ac0cd2a7 | 21 | if (!wifly.sendCommand("ftp update\r", "FTP OK", NULL, 30000)) |
samux | 2:78b3ac0cd2a7 | 22 | success = false; |
samux | 2:78b3ac0cd2a7 | 23 | if (!wifly.sendCommand("factory RESET\r")) |
samux | 2:78b3ac0cd2a7 | 24 | success = false; |
samux | 2:78b3ac0cd2a7 | 25 | if (!wifly.sendCommand("reboot\r")) |
samux | 2:78b3ac0cd2a7 | 26 | success = false; |
samux | 0:da9cea9f791c | 27 | |
samux | 2:78b3ac0cd2a7 | 28 | if (success) |
samux | 2:78b3ac0cd2a7 | 29 | printf("firmware updated successfully!\r\n"); |
samux | 2:78b3ac0cd2a7 | 30 | else |
samux | 2:78b3ac0cd2a7 | 31 | printf("ERROR while updating firmware!\r\n"); |
samux | 0:da9cea9f791c | 32 | } |