A simple Firmware Updating program.

Dependencies:   FirmwareUpdater NetServices RPCInterface mbed

Fork of NetServices_HelloWorld by Segundo Equipo

Committer:
Aaronduino
Date:
Sat Mar 09 02:40:16 2013 +0000
Revision:
6:b17ac63d5981
Parent:
5:1e77bdd1a639
A simple Firmware Updater, that will update; the mbed to the newest program.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
segundo 0:2419d81ee03d 1 #include "mbed.h"
Aaronduino 6:b17ac63d5981 2 #include "FirmwareUpdater.h"
segundo 0:2419d81ee03d 3 #include "EthernetNetIf.h"
segundo 0:2419d81ee03d 4 #include "HTTPClient.h"
segundo 1:57f922fe8fb5 5 #include "NTPClient.h"
segundo 2:16857d9ab50d 6 #include "HTTPServer.h"
segundo 2:16857d9ab50d 7 #include "RPCFunction.h"
Aaronduino 6:b17ac63d5981 8
Aaronduino 6:b17ac63d5981 9 EthernetNetIf eth;
Aaronduino 6:b17ac63d5981 10 FirmwareUpdater fwup("http://mbed.org/media/uploads/shintamainjp/", "firm_LPC1768", true);
Aaronduino 6:b17ac63d5981 11
Aaronduino 6:b17ac63d5981 12 // There are 2 files for the firmware.
Aaronduino 6:b17ac63d5981 13 // 1. firm.txt : firmware version file.
Aaronduino 6:b17ac63d5981 14 // 2. firm.bin : firmware binary file.
Aaronduino 6:b17ac63d5981 15
Aaronduino 6:b17ac63d5981 16 void check_newfirm() {
Aaronduino 6:b17ac63d5981 17 if (fwup.exist() == 0) {
Aaronduino 6:b17ac63d5981 18 printf("Found a new firmware.\n");
Aaronduino 6:b17ac63d5981 19 if (fwup.execute() == 0) {
Aaronduino 6:b17ac63d5981 20 printf("Update succeed.\n");
Aaronduino 6:b17ac63d5981 21 printf("Resetting this system...\n\n\n\n\n");
Aaronduino 6:b17ac63d5981 22 fwup.reset();
Aaronduino 6:b17ac63d5981 23 } else {
Aaronduino 6:b17ac63d5981 24 printf("Update failed!\n");
segundo 2:16857d9ab50d 25 }
segundo 2:16857d9ab50d 26 }
Aaronduino 6:b17ac63d5981 27 }
Aaronduino 6:b17ac63d5981 28
Aaronduino 6:b17ac63d5981 29 int main(void) {
Aaronduino 6:b17ac63d5981 30
Aaronduino 6:b17ac63d5981 31 eth.setup();
Aaronduino 6:b17ac63d5981 32
Aaronduino 6:b17ac63d5981 33 check_newfirm();
Aaronduino 6:b17ac63d5981 34 printf("Hi!");
Aaronduino 6:b17ac63d5981 35 // Your application is here.
segundo 0:2419d81ee03d 36 }