Skip to content

Commit 3bcf2b1

Browse files
committed
Replacing direct storing of ota storage class with injecting it via 'setOTAStorage'
1 parent 1c3fd9e commit 3bcf2b1

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/ArduinoIoTCloudTCP.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ ArduinoIoTCloudTCP::ArduinoIoTCloudTCP():
7777
_dataTopicOut(""),
7878
_dataTopicIn(""),
7979
_ota_topic_in{""},
80-
_ota_topic_out{""}
80+
_ota_topic_out{""},
81+
_ota_storage{nullptr}
8182
{
8283

8384
}
@@ -107,11 +108,9 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort)
107108
_brokerAddress = brokerAddress;
108109
_brokerPort = brokerPort;
109110

110-
#if OTA_STORAGE_MKRMEM
111-
if (!_ota.init()) {
111+
if (_ota_storage && !_ota_storage->init()) {
112112
Debug.print(DBG_ERROR, "OTA storage medium initialisation failed - can't perform OTA");
113113
}
114-
#endif /* OTA_ENABLE */
115114

116115
#ifdef BOARD_HAS_ECCX08
117116
if (!ECCX08.begin()) { Debug.print(DBG_ERROR, "Cryptography processor failure. Make sure you have a compatible board."); return 0; }

src/ArduinoIoTCloudTCP.h

+4-7
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@
3333

3434
#include <ArduinoMqttClient.h>
3535

36-
#include "utility/ota/OTAConfig.h"
37-
#if OTA_STORAGE_MKRMEM
38-
#include "utility/ota/OTAStorage_MKRMEM.h"
39-
#endif /* OTA_STORAGE_MKRMEM */
36+
#include "utility/ota/OTAStorage.h"
4037

4138
/******************************************************************************
4239
CONSTANTS
@@ -78,6 +75,8 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
7875
inline String getBrokerAddress() const { return _brokerAddress; }
7976
inline uint16_t getBrokerPort () const { return _brokerPort; }
8077

78+
inline void setOTAStorage (OTAStorage & ota_storage) { _ota_storage = &ota_storage; }
79+
8180
// Clean up existing Mqtt connection, create a new one and initialize it
8281
int reconnect();
8382

@@ -122,9 +121,7 @@ class ArduinoIoTCloudTCP: public ArduinoIoTCloudClass
122121
String _ota_topic_in;
123122
String _ota_topic_out;
124123

125-
#if OTA_STORAGE_MKRMEM
126-
OTAStorage_MKRMEM _ota;
127-
#endif /* OTA_STORAGE_MKRMEM */
124+
OTAStorage * _ota_storage;
128125

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

0 commit comments

Comments
 (0)