SWUpdate library to be used with RPC.
Fork of SWUpdate by
SWUpdate_class.cpp@27:c7b275023106, 2018-10-05 (annotated)
- Committer:
- sohaibqamar
- Date:
- Fri Oct 05 07:15:29 2018 +0000
- Revision:
- 27:c7b275023106
To be used the SWUpdate with RPC.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sohaibqamar | 27:c7b275023106 | 1 | #include "mbed.h" // mbed: ver 95, rtos: 64 |
sohaibqamar | 27:c7b275023106 | 2 | #include "SWUpdate_class.h" // ver 1 |
sohaibqamar | 27:c7b275023106 | 3 | #include "SWUpdate.h" // ver 20 |
sohaibqamar | 27:c7b275023106 | 4 | |
sohaibqamar | 27:c7b275023106 | 5 | |
sohaibqamar | 27:c7b275023106 | 6 | // Server url to where the Software will be found. |
sohaibqamar | 27:c7b275023106 | 7 | const char *url = "http://192.168.10.21:8000"; |
sohaibqamar | 27:c7b275023106 | 8 | |
sohaibqamar | 27:c7b275023106 | 9 | // Base filename for the software (e.g. if you save it as "abcdefg.bin", use "abcdefg" here) |
sohaibqamar | 27:c7b275023106 | 10 | // Remember: some servers are case-sensitive! |
sohaibqamar | 27:c7b275023106 | 11 | const char *name = "SWUP"; |
sohaibqamar | 27:c7b275023106 | 12 | |
sohaibqamar | 27:c7b275023106 | 13 | extern "C" void mbed_reset(); |
sohaibqamar | 27:c7b275023106 | 14 | //extern "C" void Thread::wait(); |
sohaibqamar | 27:c7b275023106 | 15 | |
sohaibqamar | 27:c7b275023106 | 16 | int UpdateFirmware::UpdateCheck(void) |
sohaibqamar | 27:c7b275023106 | 17 | { |
sohaibqamar | 27:c7b275023106 | 18 | int res; |
sohaibqamar | 27:c7b275023106 | 19 | //pc.printf("SoftwareUpdateCheck (%s) (%s)\r\n", url, name); |
sohaibqamar | 27:c7b275023106 | 20 | SWUpdate_T su = SoftwareUpdate(url, name, DEFER_REBOOT); |
sohaibqamar | 27:c7b275023106 | 21 | if (SWUP_OK == su) { |
sohaibqamar | 27:c7b275023106 | 22 | //pc.printf(" Update installed, rebooting ...\r\n"); |
sohaibqamar | 27:c7b275023106 | 23 | res = 1; |
sohaibqamar | 27:c7b275023106 | 24 | } |
sohaibqamar | 27:c7b275023106 | 25 | else if (SWUP_SAME_VER == su) { |
sohaibqamar | 27:c7b275023106 | 26 | res = 0; |
sohaibqamar | 27:c7b275023106 | 27 | //pc.printf(" no update available.\r\n"); |
sohaibqamar | 27:c7b275023106 | 28 | } |
sohaibqamar | 27:c7b275023106 | 29 | else { |
sohaibqamar | 27:c7b275023106 | 30 | res = -1; |
sohaibqamar | 27:c7b275023106 | 31 | //pc.printf(" update failed %04X\r\n", su); |
sohaibqamar | 27:c7b275023106 | 32 | } |
sohaibqamar | 27:c7b275023106 | 33 | return res; |
sohaibqamar | 27:c7b275023106 | 34 | } |
sohaibqamar | 27:c7b275023106 | 35 | |
sohaibqamar | 27:c7b275023106 | 36 | void UpdateFirmware::rebootMbed(void) |
sohaibqamar | 27:c7b275023106 | 37 | { |
sohaibqamar | 27:c7b275023106 | 38 | mbed_reset(); |
sohaibqamar | 27:c7b275023106 | 39 | } |