Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed FirmwareUpdater EthernetNetIf
Diff: main.cpp
- Revision:
- 2:2e46d5aef428
- Parent:
- 1:fea31c96b5e4
- Child:
- 4:e742ea7a3d20
--- a/main.cpp Wed Nov 03 14:56:43 2010 +0000
+++ b/main.cpp Wed Nov 03 22:04:09 2010 +0000
@@ -1,6 +1,6 @@
/**
* =============================================================================
- * A test program for firmware updater (Version 0.0.1)
+ * A test program for firmware updater (Version 0.0.2)
* =============================================================================
* Copyright (c) 2010 Shinichiro Nakamura (CuBeatSystems)
*
@@ -29,30 +29,47 @@
#include "EthernetNetIf.h"
EthernetNetIf eth;
-FirmwareUpdater fwup("http://mbed.org/media/uploads/shintamainjp/", "firmware", true);
-// There are 2 files for the firmware on a server and your mbed.
-// 1. firmware.txt : firmware version file.
-// 2. firmware.bin : firmware binary file.
+FirmwareUpdater fwup("http://mbed.org/media/uploads/shintamainjp/", "firm", true);
+
+// [On a server]
+// 1. firm.txt : firmware version file.
+// 2. firm.bin : firmware binary file.
+//
+// [On a mbed]
+// 1. firm.txt : firmware version file.
+// 2. firm.bin : firmware binary file.
int main() {
eth.setup();
#if 1
+ /*
+ * Please put this version on your mbed local storage.
+ */
printf("This is local version.\n");
#else
+ /*
+ * Please put this version on a server for debugging purpose.
+ */
printf("This is server version.\n");
#endif
- if (fwup.exist() == 0) {
+ const int a = fwup.exist();
+ if (a == 0) {
printf("Found a new firmware.\n");
- if (fwup.execute() == 0) {
+ const int b = fwup.execute();
+ if (b == 0) {
printf("Update succeed.\n");
printf("Resetting this system...\n\n\n\n\n");
fwup.reset();
} else {
- printf("Update failed!\n");
+ printf("Failed execute() [Code=%d]\n", b);
}
} else {
- printf("Up to date.\n");
+ if (a < 0) {
+ printf("Failed exist() [Code=%d]\n", a);
+ } else {
+ printf("Up to date.\n");
+ }
}
}