From ef9d69de2c8a8b58b15f7bcccc98c1e3f37b296d Mon Sep 17 00:00:00 2001
From: pennam <m.pennasilico@arduino.cc>
Date: Fri, 11 Mar 2022 08:52:00 +0100
Subject: [PATCH] Make NINA FW OTA error available as OTA_ERROR property

---
 src/utility/ota/OTA-samd.cpp | 2 +-
 src/utility/ota/OTA.h        | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/utility/ota/OTA-samd.cpp b/src/utility/ota/OTA-samd.cpp
index f555415b..36dde769 100644
--- a/src/utility/ota/OTA-samd.cpp
+++ b/src/utility/ota/OTA-samd.cpp
@@ -52,7 +52,7 @@ int samd_onOTARequest(char const * ota_url)
   if (!WiFiStorage.downloadOTA(ota_url, &nina_ota_err_code))
   {
     DEBUG_ERROR("ArduinoIoTCloudTCP::%s error download to nina: %d", __FUNCTION__, nina_ota_err_code);
-    return static_cast<int>(OTAError::DownloadFailed);
+    return (NINAFW_OTA_ERROR_BASE - nina_ota_err_code);
   }
 
   /* Perform the reset to reboot to SxU. */
diff --git a/src/utility/ota/OTA.h b/src/utility/ota/OTA.h
index d5364242..5483c16f 100644
--- a/src/utility/ota/OTA.h
+++ b/src/utility/ota/OTA.h
@@ -29,6 +29,7 @@
  ******************************************************************************/
 
 #define RP2040_OTA_ERROR_BASE (-100)
+#define NINAFW_OTA_ERROR_BASE (-200)
 
 /******************************************************************************
  * TYPEDEF