sohaib qamar / SWUpdate_RPC

Fork of SWUpdate by David Smart

Revision:
24:e400edb8d2ee
Parent:
23:cfe84db2b2cb
Child:
25:af99bdcca2b4
diff -r cfe84db2b2cb -r e400edb8d2ee SWUpdate.cpp
--- a/SWUpdate.cpp	Thu Jun 01 11:35:49 2017 +0000
+++ b/SWUpdate.cpp	Fri Nov 10 12:32:04 2017 +0000
@@ -31,6 +31,33 @@
     bad_crc
 } Integrity_t;
 
+
+const char * SWErrorMsg[] = {
+    "OK",               // SWUP_OK               = 0x00,   ///< Software Update succeeded as planned.
+    "Same version",     // SWUP_SAME_VER         = 0x01,   ///< Online version is the same as the installed version.
+    "Get bin error",    // SWUP_HTTP_BIN         = 0x02,   ///< HTTP get returned an error while trying to fetch the bin file.
+    "Old file stuck",   // SWUP_OLD_STUCK        = 0x04,   ///< Old file could not be removed.
+    "Old vers stuck",   // SWUP_VER_STUCK        = 0x08,   ///< Old version number could not be updated.
+    "Ver write fail",   // SWUP_VWRITE_FAILED    = 0x10,   ///< Can't open for write the version tracking file.
+    "Integrity fail",   // SWUP_INTEGRITY_FAILED = 0x20,   ///< Integrity check of downloaded file failed.
+    "Get ver fail",     // SWUP_HTTP_VER         = 0x40,   ///< HTTP get returned an error while trying to fetch the version file.
+    "Filesys full",     // SWUP_NO_SPACE         = 0x80,   ///< No space on file system for new version.
+};
+
+const char * SoftwareUpdateGetHTTPErrorMsg(HTTPResult r)
+{
+    const char * p = "invalid result code";
+    if (r >= 0 && r <= SWUP_NO_SPACE)
+        p = SWErrorMsg[r];
+    return p;
+}
+
+HTTPResult SoftwareUpdateGetHTTPErrorCode(void)
+{
+    return HTTPErrorCode;
+}
+
+
 static Integrity_t PassesIntegrityCheck(const char * fname, int cksum, int fsize)
 {
     Integrity_t res = bad_crc;    // assume things go wrong...
@@ -139,11 +166,6 @@
     return noFailed;
 }
 
-HTTPResult SoftwareUpdateGetHTTPErrorCode(void)
-{
-    return HTTPErrorCode;
-}
-
 SWUpdate_T SoftwareUpdate(const char *url, const char * name, Reboot_T action)
 {
     HTTPClient http;