Skip to content

Commit 276122b

Browse files
committed
Adding hidden property OTA_ERROR which contains an integer encoded error value if an error occured during OTA update
1 parent c9e0b49 commit 276122b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/ArduinoIoTCloudTCP.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ ArduinoIoTCloudTCP::ArduinoIoTCloudTCP():
7979
_ota_topic_in{""},
8080
_ota_topic_out{""},
8181
_ota_logic{nullptr},
82-
_ota_storage_type{static_cast<int>(OTAStorage::Type::NotAvailable)}
82+
_ota_storage_type{static_cast<int>(OTAStorage::Type::NotAvailable)},
83+
_ota_error{static_cast<int>(OTAError::None)}
8384
{
8485

8586
}
@@ -154,7 +155,8 @@ void ArduinoIoTCloudTCP::update()
154155
* to transition to the OTA logic update states.
155156
*/
156157
if (_ota_logic) {
157-
_ota_logic->update();
158+
OTAError const err = _ota_logic->update();
159+
_ota_error = static_cast<int>(err);
158160
}
159161

160162
// Check if a primitive property wrapper is locally changed
@@ -211,6 +213,7 @@ void ArduinoIoTCloudTCP::setOTAStorage(OTAStorage & ota_storage)
211213
{
212214
_ota_storage_type = static_cast<int>(ota_storage.type());
213215
addPropertyReal(_ota_storage_type, "OTA_STORAGE_TYPE", Permission::Read);
216+
addPropertyReal(_ota_error, "OTA_ERROR", Permission::Read);
214217
if(_ota_logic) delete _ota_logic;
215218
_ota_logic = new OTALogic(ota_storage);
216219
}

src/ArduinoIoTCloudTCP.h

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
124124

125125
OTALogic * _ota_logic;
126126
int _ota_storage_type;
127+
int _ota_error;
127128

128129
inline String getTopic_stdin () { return String("/a/d/" + getDeviceId() + "/s/i"); }
129130
inline String getTopic_stdout () { return String("/a/d/" + getDeviceId() + "/s/o"); }

0 commit comments

Comments
 (0)