Skip to content

Commit bfc2ff9

Browse files
authored
Merge pull request #156 from arduino-libraries/enable-ota-gsm-all-the-time
Automatically configure SSU/OTA logic for MKR GSM 1400
2 parents a62b28c + 85e7ef7 commit bfc2ff9

File tree

5 files changed

+87
-34
lines changed

5 files changed

+87
-34
lines changed

.github/workflows/compile-examples.yml

+55-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ jobs:
1818

1919
env:
2020
# libraries to install for all boards
21-
UNIVERSAL_LIBRARIES: '"Arduino_ConnectionHandler" "Arduino_DebugUtils" "ArduinoMqttClient"'
21+
UNIVERSAL_LIBRARIES: |
22+
# Install the ArduinoIoTCloud library from the repository
23+
- source-path: ./
24+
- source-url: https://github.com/arduino-libraries/Arduino_ConnectionHandler.git
25+
version: latest
26+
- name: Arduino_DebugUtils
27+
- name: ArduinoMqttClient
2228
# sketch paths to compile (recursive) for all boards
2329
UNIVERSAL_SKETCH_PATHS: '"examples/ArduinoIoTCloud-Advanced" "examples/ArduinoIoTCloud-Basic" "examples/utility/ArduinoIoTCloud_Travis_CI"'
2430

@@ -33,34 +39,73 @@ jobs:
3339
{"fqbn": "arduino:samd:mkrwan1300", "type": "wan"},
3440
{"fqbn": "arduino:samd:mkrgsm1400", "type": "gsm"},
3541
{"fqbn": "arduino:samd:mkrnb1500", "type": "nb"},
36-
{"fqbn": '"esp8266:esp8266:huzzah" "https://arduino.esp8266.com/stable/package_esp8266com_index.json"', "type": "esp8266"}
42+
{"fqbn": "esp8266:esp8266:huzzah", "type": "esp8266"}
3743
]
3844

3945
# make board type-specific customizations to the matrix jobs
4046
include:
4147
# WiFi boards
4248
- board:
4349
type: "wifi"
44-
libraries: '"ArduinoECCX08" "RTCZero" "WiFi101" "WiFiNINA" "Arduino_MKRMEM"'
50+
platforms: |
51+
# Install Arduino SAMD Boards via Boards Manager for the toolchain
52+
- name: arduino:samd
53+
# Overwrite the Arduino SAMD Boards release version with version from the tip of the master branch
54+
- source-url: https://github.com/arduino/ArduinoCore-samd/archive/master.zip
55+
name: arduino:samd
56+
libraries: |
57+
- name: ArduinoECCX08
58+
- name: RTCZero
59+
- name: WiFi101
60+
- name: WiFiNINA
61+
- name: Arduino_MKRMEM
4562
sketch-paths: '"examples/utility/Provisioning" "examples/utility/WiFi_Cloud_Blink"'
4663
# LoRaWAN boards
4764
- board:
4865
type: "wan"
49-
libraries: '"ArduinoECCX08" "RTCZero" "MKRWAN"'
66+
platforms: |
67+
- name: arduino:samd
68+
- source-url: https://github.com/arduino/ArduinoCore-samd/archive/master.zip
69+
name: arduino:samd
70+
libraries: |
71+
- name: ArduinoECCX08
72+
- name: RTCZero
73+
- name: MKRWAN
5074
sketch-paths:
5175
# GSM boards
5276
- board:
5377
type: "gsm"
54-
libraries: '"ArduinoECCX08" "RTCZero" "MKRGSM" "Arduino_MKRMEM"'
78+
platforms: |
79+
- name: arduino:samd
80+
- source-url: https://github.com/arduino/ArduinoCore-samd/archive/master.zip
81+
name: arduino:samd
82+
libraries: |
83+
- name: ArduinoECCX08
84+
- name: RTCZero
85+
# Use the version of MKRGSM from the tip of its repository's default branch
86+
- source-url: https://github.com/arduino-libraries/MKRGSM.git
87+
- name: Arduino_MKRMEM
5588
sketch-paths: '"examples/utility/Provisioning" "examples/utility/GSM_Cloud_Blink"'
5689
# NB boards
5790
- board:
5891
type: "nb"
59-
libraries: '"ArduinoECCX08" "RTCZero" "MKRNB" "Arduino_MKRMEM"'
92+
platforms: |
93+
- name: arduino:samd
94+
- source-url: https://github.com/arduino/ArduinoCore-samd/archive/master.zip
95+
name: arduino:samd
96+
libraries: |
97+
- name: ArduinoECCX08
98+
- name: RTCZero
99+
- name: MKRNB
100+
- name: Arduino_MKRMEM
60101
sketch-paths: '"examples/utility/Provisioning" "examples/utility/NB_Cloud_Blink"'
61102
# ESP8266 boards
62103
- board:
63104
type: "esp8266"
105+
platforms: |
106+
# Install ESP8266 platform via Boards Manager
107+
- name: esp8266:esp8266
108+
source-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json
64109
libraries:
65110
sketch-paths: '"examples/utility/WiFi_Cloud_Blink_with_security_credentials"'
66111

@@ -71,8 +116,11 @@ jobs:
71116
- name: Compile examples
72117
uses: arduino/actions/libraries/compile-examples@master
73118
with:
119+
platforms: ${{ matrix.platforms }}
74120
fqbn: ${{ matrix.board.fqbn }}
75-
libraries: "${{ env.UNIVERSAL_LIBRARIES }} ${{ matrix.libraries }}"
121+
libraries: |
122+
${{ env.UNIVERSAL_LIBRARIES }}
123+
${{ matrix.libraries }}
76124
sketch-paths: "${{ env.UNIVERSAL_SKETCH_PATHS }} ${{ matrix.sketch-paths }}"
77125
size-report-sketch: 'ArduinoIoTCloud_Travis_CI'
78126
enable-size-deltas-report: 'true'

src/ArduinoIoTCloudTCP.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "tls/utility/CryptoUtil.h"
3030
#endif
3131

32+
#include "utility/ota/OTAStorage_SSU.h"
3233
#include "utility/ota/OTAStorage_MKRMEM.h"
3334

3435
#include "cbor/CBOREncoder.h"
@@ -39,9 +40,11 @@
3940

4041
TimeService time_service;
4142

42-
#if OTA_STORAGE_MKRMEM
43+
#if OTA_STORAGE_SSU
44+
static OTAStorage_SSU ota_storage_ssu;
45+
#elif OTA_STORAGE_MKRMEM
4346
static OTAStorage_MKRMEM ota_storage_sfu;
44-
#endif /* OTA_STORAGE_MKRMEM */
47+
#endif
4548

4649
/******************************************************************************
4750
GLOBAL CONSTANTS
@@ -141,7 +144,9 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort)
141144

142145
printConnectionStatus(_iot_status);
143146

144-
#if OTA_STORAGE_MKRMEM
147+
#if OTA_STORAGE_SSU
148+
setOTAStorage(ota_storage_ssu);
149+
#elif OTA_STORAGE_MKRMEM
145150
setOTAStorage(ota_storage_sfu);
146151
#endif /* OTA_STORAGE_MKRMEM */
147152

src/ArduinoIoTCloud_Config.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,17 @@
2626
#define OTA_STORAGE_MKRMEM (0)
2727
#endif
2828

29-
#ifndef OTA_STORAGE_MKRGSM
30-
#define OTA_STORAGE_MKRGSM (0)
29+
#ifdef ARDUINO_SAMD_MKRGSM1400
30+
#define OTA_STORAGE_SSU (1)
31+
#else
32+
#define OTA_STORAGE_SSU (0)
3133
#endif
3234

3335
/******************************************************************************
3436
* AUTOMATIC CONFIGURED DEFINES
3537
******************************************************************************/
3638

37-
#if !defined(ARDUINO_SAMD_MKR1000) && !defined(ARDUINO_SAMD_MKRWIFI1010) && !defined(ARDUINO_SAMD_MKRGSM1400) && !defined(ARDUINO_SAMD_MKRNB1500)
38-
#define OTA_STORAGE_MKRMEM (0)
39-
#endif
40-
41-
#if OTA_STORAGE_MKRMEM || OTA_STORAGE_MKRGSM
39+
#if OTA_STORAGE_MKRMEM || OTA_STORAGE_SSU
4240
#define OTA_ENABLED (1)
4341
#else
4442
#define OTA_ENABLED (0)

src/utility/ota/OTAStorage_MKRGSM.cpp renamed to src/utility/ota/OTAStorage_SSU.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
******************************************************************************/
2121

2222
#include <ArduinoIoTCloud_Config.h>
23-
#if OTA_STORAGE_MKRGSM
23+
#if OTA_STORAGE_SSU
2424

25-
#include "OTAStorage_MKRGSM.h"
25+
#include "OTAStorage_SSU.h"
2626

2727
/******************************************************************************
2828
CONSTANTS
@@ -35,7 +35,7 @@ static char const SSU_CHECK_FILE_NAME[] = "UPDATE.OK";
3535
PUBLIC MEMBER FUNCTIONS
3636
******************************************************************************/
3737

38-
bool OTAStorage_MKRGSM::init()
38+
bool OTAStorage_SSU::init()
3939
{
4040
if (!_fileUtils.begin())
4141
return false;
@@ -49,28 +49,28 @@ bool OTAStorage_MKRGSM::init()
4949
return false;
5050
}
5151

52-
bool OTAStorage_MKRGSM::open(char const * /* file_name */)
52+
bool OTAStorage_SSU::open(char const * /* file_name */)
5353
{
5454
return true;
5555
}
5656

57-
size_t OTAStorage_MKRGSM::write(uint8_t const* const buf, size_t const num_bytes)
57+
size_t OTAStorage_SSU::write(uint8_t const* const buf, size_t const num_bytes)
5858
{
5959
_fileUtils.appendFile(SSU_UPDATE_FILENAME, (const char*)buf, num_bytes);
6060
return num_bytes;
6161
}
6262

63-
void OTAStorage_MKRGSM::close()
63+
void OTAStorage_SSU::close()
6464
{
6565
/* Nothing to do */
6666
}
6767

68-
void OTAStorage_MKRGSM::remove(char const * /* file_name */)
68+
void OTAStorage_SSU::remove(char const * /* file_name */)
6969
{
7070
_fileUtils.deleteFile(SSU_UPDATE_FILENAME);
7171
}
7272

73-
bool OTAStorage_MKRGSM::rename(char const * /* old_file_name */, char const * /* new_file_name */)
73+
bool OTAStorage_SSU::rename(char const * /* old_file_name */, char const * /* new_file_name */)
7474
{
7575
/* Create a file 'UPDATE.OK' which is used by the SSU
7676
* 2nd stage bootloader to recognise that the update
@@ -82,9 +82,9 @@ bool OTAStorage_MKRGSM::rename(char const * /* old_file_name */, char const * /*
8282
return (_fileUtils.appendFile(SSU_CHECK_FILE_NAME, &c, sizeof(c)) == sizeof(c));
8383
}
8484

85-
void OTAStorage_MKRGSM::deinit()
85+
void OTAStorage_SSU::deinit()
8686
{
8787
/* Nothing to do */
8888
}
8989

90-
#endif /* OTA_STORAGE_MKRGSM */
90+
#endif /* OTA_STORAGE_SSU */

src/utility/ota/OTAStorage_MKRGSM.h renamed to src/utility/ota/OTAStorage_SSU.h

+9-7
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@
1515
a commercial license, send an email to [email protected].
1616
*/
1717

18-
#ifndef ARDUINO_OTA_STORAGE_MKRGSM_H_
19-
#define ARDUINO_OTA_STORAGE_MKRGSM_H_
18+
#ifndef ARDUINO_OTA_STORAGE_SSU_H_
19+
#define ARDUINO_OTA_STORAGE_SSU_H_
2020

2121
/******************************************************************************
2222
* INCLUDE
2323
******************************************************************************/
2424

2525
#include <ArduinoIoTCloud_Config.h>
26-
#if OTA_STORAGE_MKRGSM
26+
#if OTA_STORAGE_SSU
27+
28+
#include <SSU.h>
2729

2830
#include "OTAStorage.h"
2931

@@ -33,11 +35,11 @@
3335
* CLASS DECLARATION
3436
******************************************************************************/
3537

36-
class OTAStorage_MKRGSM : public OTAStorage
38+
class OTAStorage_SSU : public OTAStorage
3739
{
3840
public:
3941

40-
virtual ~OTAStorage_MKRGSM() { }
42+
virtual ~OTAStorage_SSU() { }
4143

4244

4345
virtual bool init () override;
@@ -54,6 +56,6 @@ class OTAStorage_MKRGSM : public OTAStorage
5456

5557
};
5658

57-
#endif /* OTA_STORAGE_MKRGSM */
59+
#endif /* OTA_STORAGE_SSU */
5860

59-
#endif /* ARDUINO_OTA_STORAGE_MKRGSM_H_ */
61+
#endif /* ARDUINO_OTA_STORAGE_SSU_H_ */

0 commit comments

Comments
 (0)