Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
248 changes: 248 additions & 0 deletions .github/workflows/compile-provisioning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
name: Compile Provisioning

on:
pull_request:
paths:
- ".github/workflows/compile-provisioning.yml"
- "examples/**"
- "src/**"
push:
paths:
- ".github/workflows/compile-provisioning.yml"
- "examples/**"
- "src/**"

jobs:
build:
runs-on: ubuntu-latest

env:
# libraries to install for all boards
UNIVERSAL_LIBRARIES: |
# Install the ArduinoIoTCloud library from the repository
- source-path: ./
- source-url: https://github.com/pennam/ArduinoBLE.git
version: 5915fa2df776e6eb7e9e5afd896ed3d1c048c9c0
- name: ArduinoHttpClient
version: 0.6.1
- name: Arduino_DebugUtils
version: 1.4.0
- name: ArduinoMqttClient
version: 0.1.8
- name: Arduino_KVStore
version: 1.0.0
- source-url: https://github.com/pennam/Arduino_ConnectionHandler.git
version: 0f0f4a4ce718fcf2066a092a92cc2fdcd4d8bedd
- name: Arduino_SecureElement
version: 0.4.0
- name: Arduino_CloudUtils
version: 1.1.1
- source-url: https://github.com/arduino-libraries/Arduino_UniqueHWId.git
version: 7e1bfeb586cac00f043c39997a1e9937ed8152b0
- source-url: https://github.com/arduino-libraries/Arduino_NetworkConfigurator.git
version: 3499628000f2b652e856db406e4e02140bf267a6
# sketch paths to compile (recursive) for all boards
UNIVERSAL_SKETCH_PATHS: |
- examples/utility/Provisioning_2.0
SKETCHES_REPORTS_PATH: sketches-reports

strategy:
fail-fast: false

matrix:
board:
- fqbn: arduino:samd:mkrwifi1010
type: nina
artifact-name-suffix: arduino-samd-mkrwifi1010
- fqbn: arduino:samd:nano_33_iot
type: nina
artifact-name-suffix: arduino-samd-nano_33_iot
- fqbn: arduino:mbed_portenta:envie_m7:split=100_0
type: mbed_portenta
artifact-name-suffix: arduino-mbed_portenta-envie_m7
- fqbn: arduino:mbed_nano:nanorp2040connect
type: nina
artifact-name-suffix: arduino-mbed_nano-nanorp2040connect
- fqbn: arduino:mbed_nicla:nicla_vision
type: mbed_nicla
artifact-name-suffix: arduino-mbed_nicla-nicla_vision
- fqbn: arduino:mbed_opta:opta
type: mbed_opta
artifact-name-suffix: arduino-mbed_opta-opta
- fqbn: arduino:mbed_giga:giga
type: mbed_giga
artifact-name-suffix: arduino-mbed_giga-giga
- fqbn: arduino:renesas_portenta:portenta_c33
type: renesas_portenta
artifact-name-suffix: arduino-renesas_portenta-portenta_c33
- fqbn: arduino:renesas_uno:unor4wifi
type: renesas_uno
artifact-name-suffix: arduino-renesas_uno-unor4wifi

# make board type-specific customizations to the matrix jobs
include:
# MKR WiFi 1010, Nano 33 IoT, Nano RP2040 Connect
- board:
type: nina
platforms: |
# Install samd and mbed_nano platform via Boards Manager
- name: arduino:samd
version: 1.8.14
- name: arduino:mbed_nano
version: 4.3.1
libraries: |
- name: RTCZero
version: 1.6.0
- name: ArduinoECCX08
version: 1.3.9
- name: Adafruit SleepyDog Library
version: 1.6.5
- name: ArduinoBearSSL
version: 1.7.6
- source-url: https://github.com/pennam/WiFiNINA.git
version: b9a8d705f85fef8c19862c32e314367d4bba5734
- source-url: https://github.com/arduino-libraries/SpiNINA.git
version: 4c8f2956b1b9cd421583393421c6c9276ba27614
# Portenta
- board:
type: mbed_portenta
platforms: |
# Install mbed_portenta platform via Boards Manager
- name: arduino:mbed_portenta
version: 4.3.1
libraries: |
- source-url: https://github.com/pennam/Arduino_Cellular.git
version: bfbd25791d200b113d640e16eed43ce547ab0b0c
- name: ArduinoECCX08
version: 1.3.9
- name: StreamDebugger
version: 1.0.1
- name: TinyGsm
version: 0.12.0
- name: ArduinoBearSSL
version: 1.7.6
# Nicla Vision
- board:
type: mbed_nicla
platforms: |
# Install mbed_nicla platform via Boards Manager
- name: arduino:mbed_nicla
version: 4.3.1
# Opta
- board:
type: mbed_opta
platforms: |
# Install mbed_opta platform via Boards Manager
- name: arduino:mbed_opta
version: 4.3.1
libraries: |
- name: ArduinoECCX08
version: 1.3.9
- name: ArduinoBearSSL
version: 1.7.6
# GIGA
- board:
type: mbed_giga
platforms: |
# Install mbed_giga platform via Boards Manager
- name: arduino:mbed_giga
version: 4.3.1
libraries: |
- name: ArduinoECCX08
version: 1.3.9
- name: ArduinoBearSSL
version: 1.7.6
# Portenta C33
- board:
type: renesas_portenta
platforms: |
# Install renesas_portenta platform via Boards Manager
- name: arduino:renesas_portenta
version: 1.4.1
libraries: |
- source-url: https://github.com/pennam/Arduino_Cellular.git
version: bfbd25791d200b113d640e16eed43ce547ab0b0c
- name: StreamDebugger
version: 1.0.1
- name: TinyGsm
version: 0.12.0
# UNO R4 WiFi
- board:
type: renesas_uno
platforms: |
# Install renesas_uno platform via Boards Manager
- name: arduino:renesas_uno
version: 1.4.1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Clear cache
run: |
rm -rf ~/.cache
- name: Compile production provisioning sketch
uses: arduino/compile-sketches@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
platforms: ${{ matrix.platforms }}
fqbn: ${{ matrix.board.fqbn }}
libraries: |
${{ env.UNIVERSAL_LIBRARIES }}
${{ matrix.libraries }}
sketch-paths: |
${{ env.UNIVERSAL_SKETCH_PATHS }}
${{ matrix.sketch-paths }}
enable-deltas-report: "false"
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
cli-compile-flags: |
- --clean
- --verbose
- --output-dir
- ${{ runner.temp }}/provisioning-prod
- name: Compile staging provisioning sketch
uses: arduino/compile-sketches@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
platforms: ${{ matrix.platforms }}
fqbn: ${{ matrix.board.fqbn }}
libraries: |
${{ env.UNIVERSAL_LIBRARIES }}
${{ matrix.libraries }}
sketch-paths: |
${{ env.UNIVERSAL_SKETCH_PATHS }}
${{ matrix.sketch-paths }}
enable-deltas-report: "false"
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
cli-compile-flags: |
- --clean
- --verbose
- --build-property
- "compiler.cpp.extra_flags=-DCOMPILE_TEST=1"
- --output-dir
- ${{ runner.temp }}/provisioning-staging
- name: Write data to size trends report spreadsheet
# Update report on every push to the master branch
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: arduino/report-size-trends@main
with:
sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }}
google-key-file: ${{ secrets.GOOGLE_KEY_FILE }}
spreadsheet-id: 1I6NZkpZpf8KugBkE92adB1Z3_b7ZepOpCdYTOigJpN4

- name: Save memory usage change report as artifact
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: sketches-report-${{ matrix.board.artifact-name-suffix }}
path: ${{ env.SKETCHES_REPORTS_PATH }}

- name: Save production artifact
uses: actions/upload-artifact@v4
with:
name: provisioning-prod-${{ matrix.board.artifact-name-suffix }}
path: ${{ runner.temp }}/provisioning-prod/

- name: Save staging artifact
uses: actions/upload-artifact@v4
with:
name: provisioning-staging-${{ matrix.board.artifact-name-suffix }}
path: ${{ runner.temp }}/provisioning-staging/
38 changes: 37 additions & 1 deletion examples/utility/Provisioning_2.0/CSRHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,42 @@ uint32_t CSRHandlerClass::getTimestamp() {
return ts;
}

bool CSRHandlerClass::parseDateFromStr(char *str) {
char *tok[3];
int i = 1;
tok[0] = strtok(str, "-");
for (; i < 3; i++) {
char *t = strtok(NULL, "-");
if(t == NULL){
break;
}
tok[i] = t;
}
if (i < 3) {
return false;
}

char *day = strtok(tok[2], "T");
char *time = strtok(NULL, "T");

if(time == NULL){
return false;
}

char *hour = strtok(time, ":");

if(strlen(tok[0]) != 4 || strlen(tok[1]) != 2 || strlen(day) != 2 || strlen(hour) != 2){
return false;
}

_issueYear = atoi(tok[0]);
_issueMonth = atoi(tok[1]);
_issueDay = atoi(day);
_issueHour = atoi(hour);

return true;
}

CSRHandlerClass::CSRHandlerStates CSRHandlerClass::handleBuildCSR() {
if (!_certForCSR) {
_certForCSR = new ECP256Certificate();
Expand Down Expand Up @@ -296,7 +332,7 @@ CSRHandlerClass::CSRHandlerStates CSRHandlerClass::handleParseResponse() {
if(i < 6 || strlen(token[0]) != 36 || strlen(token[1]) != 40
|| strlen(token[2]) < 10 || strlen(token[3]) != 32
|| strlen(token[4]) != 64 || strlen(token[5]) != 64
|| sscanf(token[2], "%4d-%2d-%2dT%2d", &_issueYear, &_issueMonth, &_issueDay, &_issueHour) != 4){
|| !parseDateFromStr(token[2])){
updateNextRequestAt();
DEBUG_ERROR("CSRH::%s Error parsing response, retrying in %d ms", __FUNCTION__, _nextRequestAt - millis());
return CSRHandlerStates::REQUEST_SIGNATURE;
Expand Down
1 change: 1 addition & 0 deletions examples/utility/Provisioning_2.0/CSRHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class CSRHandlerClass {
uint32_t jitter(uint32_t base = JITTER_BASE, uint32_t max = JITTER_MAX);
bool postRequest(const char *url, String &postData);
uint32_t getTimestamp();
bool parseDateFromStr(char *str);
CSRHandlerStates handleBuildCSR();
CSRHandlerStates handleRequestSignature();
CSRHandlerStates handleWaitingResponse();
Expand Down
2 changes: 1 addition & 1 deletion examples/utility/Provisioning_2.0/Provisioning_2.0.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <utility/SElementArduinoCloudCertificate.h>
#include "utility/LEDFeedback.h"

const char *SKETCH_VERSION = "0.3.3";
const char *SKETCH_VERSION = "0.4.1";

enum class DeviceState {
HARDWARE_CHECK,
Expand Down
5 changes: 5 additions & 0 deletions examples/utility/Provisioning_2.0/SecretsHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
inline String GetUHWID() {
UniqueHWId Id;
if (Id.begin()) {
#ifdef ARDUINO_NANO_RP2040_CONNECT
/*Delay added for avoiding device crashes
on Nano RP2040 Connect when reading the UHWID */
delay(100);
#endif
return Id.get();
}
return "";
Expand Down
1 change: 1 addition & 0 deletions examples/utility/Provisioning_2.0/thingProperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <ArduinoIoTCloud.h>
#include <GenericConnectionHandler.h>
#include <Arduino_KVStore.h>
#include "Arduino_NetworkConfigurator.h"
#include "configuratorAgents/agents/BLEAgent.h"
#include "configuratorAgents/agents/SerialAgent.h"

Expand Down
3 changes: 2 additions & 1 deletion src/AIoTC_Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@
#endif

#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_NICLA_VISION) || defined(ARDUINO_OPTA) || defined(ARDUINO_GIGA) \
|| defined(ARDUINO_UNOR4_WIFI) || defined(ARDUINO_PORTENTA_C33)
|| defined(ARDUINO_UNOR4_WIFI) || defined(ARDUINO_PORTENTA_C33) || defined(ARDUINO_NANO_RP2040_CONNECT) \
|| defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT)
#define NETWORK_CONFIGURATOR_ENABLED (1)
#else
#define NETWORK_CONFIGURATOR_ENABLED (0)
Expand Down
Loading