Skip to content

Commit ddcfdec

Browse files
committed
Remove OTA::setNetworkAdapter
Add iface parameter to OTA::onRequest
1 parent d0346cb commit ddcfdec

File tree

4 files changed

+10
-38
lines changed

4 files changed

+10
-38
lines changed

src/ArduinoIoTCloudTCP.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,6 @@ int ArduinoIoTCloudTCP::begin(bool const enable_watchdog, String brokerAddress,
209209
_ota_cap = OTA::isCapable();
210210
#endif
211211

212-
#if OTA_ENABLED
213-
OTA::setNetworkAdapter(_connection->getInterface());
214-
#endif
215-
216212
#ifdef BOARD_HAS_OFFLOADED_ECCX08
217213
if (String(WiFi.firmwareVersion()) < String("1.4.4")) {
218214
DEBUG_ERROR("ArduinoIoTCloudTCP::%s In order to connect to Arduino IoT Cloud, NINA firmware needs to be >= 1.4.4, current %s", __FUNCTION__, WiFi.firmwareVersion());
@@ -583,7 +579,7 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Connected()
583579
/* Transmit the cleared request flags to the cloud. */
584580
sendDevicePropertyToCloud("OTA_REQ");
585581
/* Call member function to handle OTA request. */
586-
_ota_error = OTA::onRequest(_ota_url);
582+
_ota_error = OTA::onRequest(_ota_url, _connection->getInterface());
587583
/* If something fails send the OTA error to the cloud */
588584
sendDevicePropertyToCloud("OTA_ERROR");
589585
}

src/utility/ota/OTA-portenta-h7.cpp

+2-13
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@
3535

3636
#include "../watchdog/Watchdog.h"
3737

38-
/******************************************************************************
39-
* LOCAL VARIABLES
40-
******************************************************************************/
41-
42-
static NetworkAdapter _ota_adapter = NetworkAdapter::WIFI;
43-
4438
/******************************************************************************
4539
* EXTERN
4640
******************************************************************************/
@@ -51,7 +45,7 @@ extern RTC_HandleTypeDef RTCHandle;
5145
* FUNCTION DEFINITION
5246
******************************************************************************/
5347

54-
int portenta_h7_onOTARequest(char const * ota_url)
48+
int portenta_h7_onOTARequest(char const * ota_url, NetworkAdapter iface)
5549
{
5650
watchdog_reset();
5751

@@ -82,7 +76,7 @@ int portenta_h7_onOTARequest(char const * ota_url)
8276
/* Download the OTA file from the web storage location. */
8377
MbedSocketClass * download_socket = static_cast<MbedSocketClass*>(&WiFi);
8478
#if defined (BOARD_HAS_ETHERNET)
85-
if(_ota_adapter == NetworkAdapter::ETHERNET) {
79+
if(iface == NetworkAdapter::ETHERNET) {
8680
download_socket = static_cast<MbedSocketClass*>(&Ethernet);
8781
}
8882
#endif
@@ -154,9 +148,4 @@ bool portenta_h7_isOTACapable()
154148
return Arduino_Portenta_OTA::isOtaCapable();
155149
}
156150

157-
void portenta_h7_setNetworkAdapter(NetworkAdapter iface)
158-
{
159-
_ota_adapter = iface;
160-
}
161-
162151
#endif /* BOARD_STM32H7 */

src/utility/ota/OTA.cpp

+6-18
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ bool rp2040_connect_isOTACapable();
4343
#endif
4444

4545
#ifdef BOARD_STM32H7
46-
int portenta_h7_onOTARequest(char const * url);
46+
int portenta_h7_onOTARequest(char const * url, NetworkAdapter iface);
4747
String portenta_h7_getOTAImageSHA256();
4848
void portenta_h7_setNetworkAdapter(NetworkAdapter iface);
4949
bool portenta_h7_isOTACapable();
@@ -59,17 +59,20 @@ bool esp32_isOTACapable();
5959
* PUBLIC MEMBER FUNCTIONS
6060
******************************************************************************/
6161

62-
int OTA::onRequest(String url)
62+
int OTA::onRequest(String url, NetworkAdapter iface)
6363
{
6464
DEBUG_INFO("ArduinoIoTCloudTCP::%s _ota_url = %s", __FUNCTION__, url.c_str());
6565

6666
#if defined (ARDUINO_ARCH_SAMD)
67+
(void)iface;
6768
return samd_onOTARequest(url.c_str());
6869
#elif defined (ARDUINO_NANO_RP2040_CONNECT)
70+
(void)iface;
6971
return rp2040_connect_onOTARequest(url.c_str());
7072
#elif defined (BOARD_STM32H7)
71-
return portenta_h7_onOTARequest(url.c_str());
73+
return portenta_h7_onOTARequest(url.c_str(), iface);
7274
#elif defined (ARDUINO_ARCH_ESP32)
75+
(void)iface;
7376
return esp32_onOTARequest(url.c_str());
7477
#else
7578
#error "OTA not supported for this architecture"
@@ -106,19 +109,4 @@ bool OTA::isCapable()
106109
#endif
107110
}
108111

109-
void OTA::setNetworkAdapter(NetworkAdapter iface)
110-
{
111-
#if defined (ARDUINO_ARCH_SAMD)
112-
/* Only WiFi available */
113-
#elif defined (ARDUINO_NANO_RP2040_CONNECT)
114-
/* Only WiFi available */
115-
#elif defined (BOARD_STM32H7)
116-
portenta_h7_setNetworkAdapter(iface);
117-
#elif defined (ARDUINO_ARCH_ESP32)
118-
/* Only WiFi available */
119-
#else
120-
#error "OTA not supported for this architecture"
121-
#endif
122-
}
123-
124112
#endif /* OTA_ENABLED */

src/utility/ota/OTA.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ class OTA
6262
{
6363
public:
6464

65-
static int onRequest(String url);
65+
static int onRequest(String url, NetworkAdapter iface);
6666
static String getImageSHA256();
67-
static void setNetworkAdapter(NetworkAdapter iface);
6867
static bool isCapable();
6968

7069
};

0 commit comments

Comments
 (0)