Skip to content

Commit 0d47fbd

Browse files
committed
OTA: prepare for UNO WiFi rev2
1 parent cf26ab4 commit 0d47fbd

File tree

6 files changed

+25
-5
lines changed

6 files changed

+25
-5
lines changed

src/AIoTC_Config.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@
3030
#define NTP_USE_RANDOM_PORT (1)
3131
#endif
3232

33+
#if defined(ARDUINO_AVR_UNO_WIFI_REV2)
34+
#define DBG_ERROR
35+
#define DBG_WARNING
36+
#define DBG_INFO
37+
#define DBG_DEBUG
38+
#define DBG_VERBOSE
39+
// avoid including debugutils
40+
#define ARDUINO_DEBUG_UTILS_H_
41+
#endif
42+
3343
#ifndef DBG_ERROR
3444
#define DBG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__)
3545
#endif
@@ -54,7 +64,8 @@
5464
* AUTOMATICALLY CONFIGURED DEFINES
5565
******************************************************************************/
5666

57-
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT)
67+
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT) || \
68+
defined(ARDUINO_AVR_UNO_WIFI_REV2)
5869
#define OTA_STORAGE_SNU (1)
5970
#else
6071
#define OTA_STORAGE_SNU (0)
@@ -66,7 +77,7 @@
6677
#define OTA_STORAGE_SSU (0)
6778
#endif
6879

69-
#if OTA_STORAGE_SFU || OTA_STORAGE_SSU || OTA_STORAGE_SNU
80+
#if OTA_STORAGE_SFU || OTA_STORAGE_SSU || OTA_STORAGE_SNU && !defined(ARDUINO_AVR_UNO_WIFI_REV2)
7081
#define OTA_ENABLED (1)
7182
#else
7283
#define OTA_ENABLED (0)

src/ArduinoIoTCloud.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,7 @@ void ArduinoIoTCloudClass::execCloudEventCallback(ArduinoIoTCloudEvent const eve
179179
(*callback)();
180180
}
181181
}
182+
183+
__attribute__((weak)) void setDebugMessageLevel(int const level) {
184+
//do nothing
185+
}

src/ArduinoIoTCloud.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,4 +154,7 @@ class ArduinoIoTCloudClass
154154
#include "ArduinoIoTCloudLPWAN.h"
155155
#endif
156156

157+
// declaration for boards without debug library
158+
void setDebugMessageLevel(int const level);
159+
157160
#endif

src/ArduinoIoTCloudTCP.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort)
103103
_brokerAddress = brokerAddress;
104104
_brokerPort = brokerPort;
105105

106-
#if OTA_ENABLED
106+
#if OTA_ENABLED && !defined(__AVR__)
107107
/* Calculate the SHA256 checksum over the firmware stored in the flash of the
108108
* MCU. Note: As we don't know the length per-se we read chunks of the flash
109109
* until we detect one containing only 0xFF (= flash erased). This only works
@@ -429,9 +429,11 @@ void ArduinoIoTCloudTCP::onOTARequest()
429429
ota_download_success = true;
430430
#endif /* OTA_STORAGE_SNU */
431431

432+
#ifndef __AVR__
432433
/* Perform the reset to reboot to SxU. */
433434
if (ota_download_success)
434435
NVIC_SystemReset();
436+
#endif
435437
}
436438
#endif
437439

src/utility/ota/FlashSHA256.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
******************************************************************************/
2121

2222
#include <AIoTC_Config.h>
23-
#if OTA_ENABLED
23+
#if OTA_ENABLED && !defined(__AVR__)
2424

2525
#include "FlashSHA256.h"
2626

src/utility/ota/OTA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <AIoTC_Config.h>
2626
#if OTA_ENABLED
2727

28-
#if OTA_STORAGE_SNU
28+
#if OTA_STORAGE_SNU && !defined(ARDUINO_AVR_UNO_WIFI_REV2)
2929
#include <SNU.h>
3030
#endif /* OTA_STORAGE_SNU */
3131

0 commit comments

Comments
 (0)