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.
Fork of SWUpdate by
Revision 27:c7b275023106, committed 2018-10-05
- Comitter:
- sohaibqamar
- Date:
- Fri Oct 05 07:15:29 2018 +0000
- Parent:
- 20:cf73b0d75bb7
- Commit message:
- To be used the SWUpdate with RPC.
Changed in this revision
| SWUpdate_class.cpp | Show annotated file Show diff for this revision Revisions of this file |
| SWUpdate_class.h | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SWUpdate_class.cpp Fri Oct 05 07:15:29 2018 +0000
@@ -0,0 +1,39 @@
+#include "mbed.h" // mbed: ver 95, rtos: 64
+#include "SWUpdate_class.h" // ver 1
+#include "SWUpdate.h" // ver 20
+
+
+// Server url to where the Software will be found.
+const char *url = "http://192.168.10.21:8000";
+
+// Base filename for the software (e.g. if you save it as "abcdefg.bin", use "abcdefg" here)
+// Remember: some servers are case-sensitive!
+const char *name = "SWUP";
+
+extern "C" void mbed_reset();
+//extern "C" void Thread::wait();
+
+int UpdateFirmware::UpdateCheck(void)
+{
+ int res;
+ //pc.printf("SoftwareUpdateCheck (%s) (%s)\r\n", url, name);
+ SWUpdate_T su = SoftwareUpdate(url, name, DEFER_REBOOT);
+ if (SWUP_OK == su) {
+ //pc.printf(" Update installed, rebooting ...\r\n");
+ res = 1;
+ }
+ else if (SWUP_SAME_VER == su) {
+ res = 0;
+ //pc.printf(" no update available.\r\n");
+ }
+ else {
+ res = -1;
+ //pc.printf(" update failed %04X\r\n", su);
+ }
+ return res;
+}
+
+void UpdateFirmware::rebootMbed(void)
+{
+ mbed_reset();
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SWUpdate_class.h Fri Oct 05 07:15:29 2018 +0000
@@ -0,0 +1,23 @@
+#ifndef __SWUPDATE_CLASS_H__
+#define __SWUPDATE_CLASS_H__
+
+class UpdateFirmware
+{
+ public:
+ int UpdateCheck(void);
+ void rebootMbed(void);
+
+ /*private:
+ // ===================================================
+ // SWUpdate
+ // ===================================================
+ // Server url to where the Software will be found.
+ const char *url = "http://192.168.10.21:8000";
+
+ // Base filename for the software (e.g. if you save it as "abcdefg.bin", use "abcdefg" here)
+ // Remember: some servers are case-sensitive!
+ const char *name = "SWUP";*/
+ // ===================================================
+};
+
+ #endif //__SWUPDATE_CLASS_H__
\ No newline at end of file
