diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 2b22feb01..5ca9b3962 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -18,7 +18,13 @@ jobs: env: # libraries to install for all boards - UNIVERSAL_LIBRARIES: '"Arduino_ConnectionHandler" "Arduino_DebugUtils" "ArduinoMqttClient"' + UNIVERSAL_LIBRARIES: | + # Install the ArduinoIoTCloud library from the repository + - source-path: ./ + - source-url: https://github.com/arduino-libraries/Arduino_ConnectionHandler.git + version: latest + - name: Arduino_DebugUtils + - name: ArduinoMqttClient # sketch paths to compile (recursive) for all boards UNIVERSAL_SKETCH_PATHS: '"examples/ArduinoIoTCloud-Advanced" "examples/ArduinoIoTCloud-Basic" "examples/utility/ArduinoIoTCloud_Travis_CI"' @@ -33,7 +39,7 @@ jobs: {"fqbn": "arduino:samd:mkrwan1300", "type": "wan"}, {"fqbn": "arduino:samd:mkrgsm1400", "type": "gsm"}, {"fqbn": "arduino:samd:mkrnb1500", "type": "nb"}, - {"fqbn": '"esp8266:esp8266:huzzah" "https://arduino.esp8266.com/stable/package_esp8266com_index.json"', "type": "esp8266"} + {"fqbn": "esp8266:esp8266:huzzah", "type": "esp8266"} ] # make board type-specific customizations to the matrix jobs @@ -41,26 +47,65 @@ jobs: # WiFi boards - board: type: "wifi" - libraries: '"ArduinoECCX08" "RTCZero" "WiFi101" "WiFiNINA" "Arduino_MKRMEM"' + platforms: | + # Install Arduino SAMD Boards via Boards Manager for the toolchain + - name: arduino:samd + # Overwrite the Arduino SAMD Boards release version with version from the tip of the master branch + - source-url: https://github.com/arduino/ArduinoCore-samd/archive/master.zip + name: arduino:samd + libraries: | + - name: ArduinoECCX08 + - name: RTCZero + - name: WiFi101 + - name: WiFiNINA + - name: Arduino_MKRMEM sketch-paths: '"examples/utility/Provisioning" "examples/utility/WiFi_Cloud_Blink"' # LoRaWAN boards - board: type: "wan" - libraries: '"ArduinoECCX08" "RTCZero" "MKRWAN"' + platforms: | + - name: arduino:samd + - source-url: https://github.com/arduino/ArduinoCore-samd/archive/master.zip + name: arduino:samd + libraries: | + - name: ArduinoECCX08 + - name: RTCZero + - name: MKRWAN sketch-paths: # GSM boards - board: type: "gsm" - libraries: '"ArduinoECCX08" "RTCZero" "MKRGSM" "Arduino_MKRMEM"' + platforms: | + - name: arduino:samd + - source-url: https://github.com/arduino/ArduinoCore-samd/archive/master.zip + name: arduino:samd + libraries: | + - name: ArduinoECCX08 + - name: RTCZero + # Use the version of MKRGSM from the tip of its repository's default branch + - source-url: https://github.com/arduino-libraries/MKRGSM.git + - name: Arduino_MKRMEM sketch-paths: '"examples/utility/Provisioning" "examples/utility/GSM_Cloud_Blink"' # NB boards - board: type: "nb" - libraries: '"ArduinoECCX08" "RTCZero" "MKRNB" "Arduino_MKRMEM"' + platforms: | + - name: arduino:samd + - source-url: https://github.com/arduino/ArduinoCore-samd/archive/master.zip + name: arduino:samd + libraries: | + - name: ArduinoECCX08 + - name: RTCZero + - name: MKRNB + - name: Arduino_MKRMEM sketch-paths: '"examples/utility/Provisioning" "examples/utility/NB_Cloud_Blink"' # ESP8266 boards - board: type: "esp8266" + platforms: | + # Install ESP8266 platform via Boards Manager + - name: esp8266:esp8266 + source-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json libraries: sketch-paths: '"examples/utility/WiFi_Cloud_Blink_with_security_credentials"' @@ -71,8 +116,11 @@ jobs: - name: Compile examples uses: arduino/actions/libraries/compile-examples@master with: + platforms: ${{ matrix.platforms }} fqbn: ${{ matrix.board.fqbn }} - libraries: "${{ env.UNIVERSAL_LIBRARIES }} ${{ matrix.libraries }}" + libraries: | + ${{ env.UNIVERSAL_LIBRARIES }} + ${{ matrix.libraries }} sketch-paths: "${{ env.UNIVERSAL_SKETCH_PATHS }} ${{ matrix.sketch-paths }}" size-report-sketch: 'ArduinoIoTCloud_Travis_CI' enable-size-deltas-report: 'true' diff --git a/src/ArduinoIoTCloudTCP.cpp b/src/ArduinoIoTCloudTCP.cpp index 705f5d36b..732b39b17 100644 --- a/src/ArduinoIoTCloudTCP.cpp +++ b/src/ArduinoIoTCloudTCP.cpp @@ -29,6 +29,7 @@ #include "tls/utility/CryptoUtil.h" #endif +#include "utility/ota/OTAStorage_SSU.h" #include "utility/ota/OTAStorage_MKRMEM.h" #include "cbor/CBOREncoder.h" @@ -39,9 +40,11 @@ TimeService time_service; -#if OTA_STORAGE_MKRMEM +#if OTA_STORAGE_SSU + static OTAStorage_SSU ota_storage_ssu; +#elif OTA_STORAGE_MKRMEM static OTAStorage_MKRMEM ota_storage_sfu; -#endif /* OTA_STORAGE_MKRMEM */ +#endif /****************************************************************************** GLOBAL CONSTANTS @@ -141,7 +144,9 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort) printConnectionStatus(_iot_status); -#if OTA_STORAGE_MKRMEM +#if OTA_STORAGE_SSU + setOTAStorage(ota_storage_ssu); +#elif OTA_STORAGE_MKRMEM setOTAStorage(ota_storage_sfu); #endif /* OTA_STORAGE_MKRMEM */ diff --git a/src/ArduinoIoTCloud_Config.h b/src/ArduinoIoTCloud_Config.h index 2d05b8d9e..821755b4c 100644 --- a/src/ArduinoIoTCloud_Config.h +++ b/src/ArduinoIoTCloud_Config.h @@ -26,19 +26,17 @@ #define OTA_STORAGE_MKRMEM (0) #endif -#ifndef OTA_STORAGE_MKRGSM - #define OTA_STORAGE_MKRGSM (0) +#ifdef ARDUINO_SAMD_MKRGSM1400 + #define OTA_STORAGE_SSU (1) +#else + #define OTA_STORAGE_SSU (0) #endif /****************************************************************************** * AUTOMATIC CONFIGURED DEFINES ******************************************************************************/ -#if !defined(ARDUINO_SAMD_MKR1000) && !defined(ARDUINO_SAMD_MKRWIFI1010) && !defined(ARDUINO_SAMD_MKRGSM1400) && !defined(ARDUINO_SAMD_MKRNB1500) - #define OTA_STORAGE_MKRMEM (0) -#endif - -#if OTA_STORAGE_MKRMEM || OTA_STORAGE_MKRGSM +#if OTA_STORAGE_MKRMEM || OTA_STORAGE_SSU #define OTA_ENABLED (1) #else #define OTA_ENABLED (0) diff --git a/src/utility/ota/OTAStorage_MKRGSM.cpp b/src/utility/ota/OTAStorage_SSU.cpp similarity index 82% rename from src/utility/ota/OTAStorage_MKRGSM.cpp rename to src/utility/ota/OTAStorage_SSU.cpp index 07731bacb..e060f92ba 100644 --- a/src/utility/ota/OTAStorage_MKRGSM.cpp +++ b/src/utility/ota/OTAStorage_SSU.cpp @@ -20,9 +20,9 @@ ******************************************************************************/ #include -#if OTA_STORAGE_MKRGSM +#if OTA_STORAGE_SSU -#include "OTAStorage_MKRGSM.h" +#include "OTAStorage_SSU.h" /****************************************************************************** CONSTANTS @@ -35,7 +35,7 @@ static char const SSU_CHECK_FILE_NAME[] = "UPDATE.OK"; PUBLIC MEMBER FUNCTIONS ******************************************************************************/ -bool OTAStorage_MKRGSM::init() +bool OTAStorage_SSU::init() { if (!_fileUtils.begin()) return false; @@ -49,28 +49,28 @@ bool OTAStorage_MKRGSM::init() return false; } -bool OTAStorage_MKRGSM::open(char const * /* file_name */) +bool OTAStorage_SSU::open(char const * /* file_name */) { return true; } -size_t OTAStorage_MKRGSM::write(uint8_t const* const buf, size_t const num_bytes) +size_t OTAStorage_SSU::write(uint8_t const* const buf, size_t const num_bytes) { _fileUtils.appendFile(SSU_UPDATE_FILENAME, (const char*)buf, num_bytes); return num_bytes; } -void OTAStorage_MKRGSM::close() +void OTAStorage_SSU::close() { /* Nothing to do */ } -void OTAStorage_MKRGSM::remove(char const * /* file_name */) +void OTAStorage_SSU::remove(char const * /* file_name */) { _fileUtils.deleteFile(SSU_UPDATE_FILENAME); } -bool OTAStorage_MKRGSM::rename(char const * /* old_file_name */, char const * /* new_file_name */) +bool OTAStorage_SSU::rename(char const * /* old_file_name */, char const * /* new_file_name */) { /* Create a file 'UPDATE.OK' which is used by the SSU * 2nd stage bootloader to recognise that the update @@ -82,9 +82,9 @@ bool OTAStorage_MKRGSM::rename(char const * /* old_file_name */, char const * /* return (_fileUtils.appendFile(SSU_CHECK_FILE_NAME, &c, sizeof(c)) == sizeof(c)); } -void OTAStorage_MKRGSM::deinit() +void OTAStorage_SSU::deinit() { /* Nothing to do */ } -#endif /* OTA_STORAGE_MKRGSM */ +#endif /* OTA_STORAGE_SSU */ diff --git a/src/utility/ota/OTAStorage_MKRGSM.h b/src/utility/ota/OTAStorage_SSU.h similarity index 86% rename from src/utility/ota/OTAStorage_MKRGSM.h rename to src/utility/ota/OTAStorage_SSU.h index d775b94df..9ab681a5f 100644 --- a/src/utility/ota/OTAStorage_MKRGSM.h +++ b/src/utility/ota/OTAStorage_SSU.h @@ -15,15 +15,17 @@ a commercial license, send an email to license@arduino.cc. */ -#ifndef ARDUINO_OTA_STORAGE_MKRGSM_H_ -#define ARDUINO_OTA_STORAGE_MKRGSM_H_ +#ifndef ARDUINO_OTA_STORAGE_SSU_H_ +#define ARDUINO_OTA_STORAGE_SSU_H_ /****************************************************************************** * INCLUDE ******************************************************************************/ #include -#if OTA_STORAGE_MKRGSM +#if OTA_STORAGE_SSU + +#include #include "OTAStorage.h" @@ -33,11 +35,11 @@ * CLASS DECLARATION ******************************************************************************/ -class OTAStorage_MKRGSM : public OTAStorage +class OTAStorage_SSU : public OTAStorage { public: - virtual ~OTAStorage_MKRGSM() { } + virtual ~OTAStorage_SSU() { } virtual bool init () override; @@ -54,6 +56,6 @@ class OTAStorage_MKRGSM : public OTAStorage }; -#endif /* OTA_STORAGE_MKRGSM */ +#endif /* OTA_STORAGE_SSU */ -#endif /* ARDUINO_OTA_STORAGE_MKRGSM_H_ */ +#endif /* ARDUINO_OTA_STORAGE_SSU_H_ */