Skip to content

Commit 10b2cdf

Browse files
New cbor encoder and decoder (#34)
* Importing Provisioning Message struct definition * defining Encoder following cloud utils guidelines * defining Decoder following cloud utils guidelines * adding entrypoint for cbor module * renaming structures from provisiong messages * readaptations for naming and using new utils decoder/encoder * renaming provisioning messages structures * refactor cborAdapter and provisioning messages structures * add test to cbor * clear buffers * remove extraction function from CBORAdapter * update PROVISIONING_JWT_SIZE * add end newline * add packetbuffer virtual destroyer and get_ptr and get_ptrAt methods * remove test_main.cpp * updare ci test * remove edge control from test board not supported --------- Co-authored-by: Andrea Gilardoni <a.gilardoni@arduino.cc>
1 parent d0d2c20 commit 10b2cdf

File tree

18 files changed

+2129
-378
lines changed

18 files changed

+2129
-378
lines changed

.github/workflows/compile-examples.yml

Lines changed: 15 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,20 @@ jobs:
2929
# Install the NetworkConfigurator library from the repository
3030
- source-path: ./
3131
- name: Arduino_DebugUtils
32-
- name: Arduino_ConnectionHandler
33-
- name: ArduinoBLE
34-
- name: ArduinoIoTCloud
32+
- source-url: https://github.com/andreagilardoni/Arduino_ConnectionHandler.git
33+
version: 0ca6d61eb538c5a21983e582ee1c8794442f8c75
34+
- source-url: https://github.com/fabik111/ArduinoBLE.git
35+
version: 82e2a28f871e97b313846cee6d9efed8943dca53
36+
- source-url: https://github.com/andreagilardoni/ArduinoIoTCloud.git
37+
version: e778f3a8e416801102ab38931ac0540ea9b82d80
3538
- name: Arduino_SecureElement
36-
- name: Arduino_CloudUtils
39+
- source-url: https://github.com/andreagilardoni/Arduino_CloudUtils.git
40+
version: a5642c1d6abe770df290f0e17331683b3d479fb7
41+
- source-url: https://github.com/andreagilardoni/ArduinoStorage.git
42+
version: 39f0bd138103967aaafcaa7f5c0e1e237b4ccb4d
43+
- name: ArduinoJson
44+
- source-url: https://github.com/arduino-libraries/Arduino_UniqueHWId.git
45+
version: 8977827eed86dbd25292f861ee8de2b19c16b3a0
3746
SKETCH_PATHS: |
3847
- examples/auto-retry
3948
SKETCHES_REPORTS_PATH: sketches-reports
@@ -42,33 +51,15 @@ jobs:
4251

4352
matrix:
4453
board:
45-
- fqbn: arduino:samd:mkr1000
46-
type: mkr1000
47-
artifact-name-suffix: arduino-samd-mkr1000
4854
- fqbn: arduino:samd:mkrwifi1010
4955
type: nina
5056
artifact-name-suffix: arduino-samd-mkrwifi1010
5157
- fqbn: arduino:samd:nano_33_iot
5258
type: nina
5359
artifact-name-suffix: arduino-samd-nano_33_iot
54-
- fqbn: arduino:samd:mkrwan1300
55-
type: wan
56-
artifact-name-suffix: arduino-samd-mkrwan1300
57-
- fqbn: arduino:samd:mkrgsm1400
58-
type: gsm
59-
artifact-name-suffix: arduino-samd-mkrgsm1400
60-
- fqbn: arduino:samd:mkrnb1500
61-
type: nb
62-
artifact-name-suffix: arduino-samd-mkrnb1500
6360
- fqbn: arduino:mbed_portenta:envie_m7
6461
type: mbed_portenta
6562
artifact-name-suffix: arduino-mbed_portenta-envie_m7
66-
- fqbn: esp8266:esp8266:huzzah
67-
type: esp8266
68-
artifact-name-suffix: esp8266-esp8266-huzzah
69-
- fqbn: esp32:esp32:esp32
70-
type: esp32
71-
artifact-name-suffix: esp32-esp32-esp32
7263
- fqbn: arduino:mbed_nano:nanorp2040connect
7364
type: nina
7465
artifact-name-suffix: arduino-mbed_nano-nanorp2040connect
@@ -87,30 +78,10 @@ jobs:
8778
- fqbn: arduino:renesas_uno:unor4wifi
8879
type: renesas_uno
8980
artifact-name-suffix: arduino-renesas_uno-unor4wifi
90-
- fqbn: arduino:esp32:nano_nora
91-
type: arduino_esp32
92-
artifact-name-suffix: arduino-esp32-nano_nora
93-
- fqbn: arduino:mbed_edge:edge_control
94-
type: mbed_edge
95-
artifact-name-suffix: arduino-mbed_edge-edge_control
9681

9782

9883
# make board type-specific customizations to the matrix jobs
9984
include:
100-
# MKR 1000
101-
- board:
102-
type: mkr1000
103-
platforms: |
104-
# Install samd platform via Boards Manager
105-
- name: arduino:samd
106-
libraries: |
107-
- name: ArduinoECCX08
108-
- name: Blues Wireless Notecard
109-
- name: RTCZero
110-
- name: WiFi101
111-
- name: ArduinoHttpClient
112-
- name: ArduinoMqttClient
113-
- source-url: https://github.com/adafruit/Adafruit_SleepyDog.git
11485
# MKR WiFi 1010, Nano 33 IoT, Nano RP2040 Connect
11586
- board:
11687
type: nina
@@ -122,50 +93,12 @@ jobs:
12293
- name: ArduinoECCX08
12394
- name: Blues Wireless Notecard
12495
- name: RTCZero
125-
- name: WiFiNINA
96+
- source-url: https://github.com/andreagilardoni/WiFiNINA.git
97+
version: ca7a9224f86b9aaf00de4f7feccea583a23b3d53
12698
- name: Arduino_JSON
12799
- name: ArduinoHttpClient
128100
- name: ArduinoMqttClient
129101
- source-url: https://github.com/adafruit/Adafruit_SleepyDog.git
130-
- board:
131-
type: wan
132-
platforms: |
133-
# Install samd platform via Boards Manager
134-
- name: arduino:samd
135-
libraries: |
136-
- name: ArduinoECCX08
137-
- name: Blues Wireless Notecard
138-
- name: RTCZero
139-
- name: MKRWAN
140-
- source-url: https://github.com/adafruit/Adafruit_SleepyDog.git
141-
# GSM boards
142-
- board:
143-
type: gsm
144-
platforms: |
145-
# Install samd platform via Boards Manager
146-
- name: arduino:samd
147-
libraries: |
148-
- name: ArduinoECCX08
149-
- name: Blues Wireless Notecard
150-
- name: RTCZero
151-
- name: MKRGSM
152-
- name: ArduinoHttpClient
153-
- name: ArduinoMqttClient
154-
- source-url: https://github.com/adafruit/Adafruit_SleepyDog.git
155-
# NB boards
156-
- board:
157-
type: nb
158-
platforms: |
159-
# Install samd platform via Boards Manager
160-
- name: arduino:samd
161-
libraries: |
162-
- name: ArduinoECCX08
163-
- name: Blues Wireless Notecard
164-
- name: RTCZero
165-
- name: MKRNB
166-
- name: ArduinoHttpClient
167-
- name: ArduinoMqttClient
168-
- source-url: https://github.com/adafruit/Adafruit_SleepyDog.git
169102
# Portenta
170103
- board:
171104
type: mbed_portenta
@@ -231,45 +164,6 @@ jobs:
231164
- name: Blues Wireless Notecard
232165
- name: ArduinoHttpClient
233166
- name: ArduinoMqttClient
234-
# Nano ESP32
235-
- board:
236-
type: arduino_esp32
237-
platforms: |
238-
# Install arduino_esp32 platform via Boards Manager
239-
- name: arduino:esp32
240-
libraries: |
241-
- name: Blues Wireless Notecard
242-
- name: ArduinoHttpClient
243-
- name: ArduinoMqttClient
244-
# Edge Control
245-
- board:
246-
type: mbed_edge
247-
platforms: |
248-
# Install mbed_edge platform via Boards Manager
249-
- name: arduino:mbed_edge
250-
libraries: |
251-
- name: Blues Wireless Notecard
252-
- name: ArduinoHttpClient
253-
- name: ArduinoMqttClient
254-
# ESP8266 boards
255-
- board:
256-
type: esp8266
257-
platforms: |
258-
# Install ESP8266 platform via Boards Manager
259-
- name: esp8266:esp8266
260-
source-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json
261-
# Use the version currently installed in Arduino Cloud
262-
version: 2.5.0
263-
libraries:
264-
# ESP32 boards
265-
- board:
266-
type: esp32
267-
platforms: |
268-
# Install ESP32 platform via Boards Manager
269-
- name: esp32:esp32
270-
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
271-
libraries: |
272-
- name: Blues Wireless Notecard
273167
274168
steps:
275169
- name: Checkout

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
*.bin
2+
*.elf
3+
*~
4+
.vscode
5+
*.orig
6+
.vs
7+
build
8+
.idea/
9+
### CMake ###
10+
CMakeLists.txt.user
11+
CMakeCache.txt
12+
CMakeFiles
13+
CMakeScripts
14+
Testing
15+
Makefile
16+
cmake_install.cmake
17+
install_manifest.txt
18+
compile_commands.json
19+
CTestTestfile.cmake
20+
_deps
21+
bin
22+
23+
### CMake Patch ###
24+
CMakeUserPresets.json
25+
26+
# External projects
27+
*-prefix/

extras/test/CMakeLists.txt

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
##########################################################################
2+
3+
cmake_minimum_required(VERSION 2.8)
4+
5+
##########################################################################
6+
7+
project(testNetworkConfigurator)
8+
9+
Include(FetchContent)
10+
11+
FetchContent_Declare(
12+
Catch2
13+
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
14+
GIT_TAG v3.4.0
15+
)
16+
17+
FetchContent_Declare(
18+
cloudutils
19+
GIT_REPOSITORY https://github.com/andreagilardoni/Arduino_CloudUtils.git
20+
GIT_TAG cbor-messages
21+
CONFIGURE_COMMAND ""
22+
BUILD_COMMAND ""
23+
)
24+
25+
FetchContent_Declare(
26+
connectionhandler
27+
GIT_REPOSITORY https://github.com/andreagilardoni/Arduino_ConnectionHandler.git
28+
GIT_TAG connectionhandler-settings
29+
CONFIGURE_COMMAND ""
30+
BUILD_COMMAND ""
31+
)
32+
33+
FetchContent_MakeAvailable(Catch2)
34+
35+
FetchContent_GetProperties(cloudutils)
36+
if(NOT cloudutils_POPULATED)
37+
FetchContent_Populate(cloudutils)
38+
endif()
39+
40+
FetchContent_GetProperties(connectionhandler)
41+
if(NOT connectionhandler_POPULATED)
42+
FetchContent_Populate(connectionhandler)
43+
endif()
44+
45+
##########################################################################
46+
47+
include_directories(include)
48+
include_directories(../../src)
49+
include_directories(../../src/ConfiguratorAgents)
50+
include_directories(../../src/ConfiguratorAgents/agents/BoardConfigurationProtocol/cbor)
51+
52+
# add_library(cloudutils STATIC IMPORTED GLOBAL)
53+
add_library(cloudutils INTERFACE)
54+
55+
target_include_directories(
56+
cloudutils INTERFACE
57+
${cloudutils_SOURCE_DIR}/src/
58+
)
59+
60+
target_include_directories(
61+
cloudutils INTERFACE
62+
${cloudutils_SOURCE_DIR}/src/cbor
63+
)
64+
65+
target_include_directories(
66+
cloudutils INTERFACE
67+
${cloudutils_SOURCE_DIR}/src/interfaces
68+
)
69+
70+
add_library(connectionhandler INTERFACE)
71+
72+
target_include_directories(
73+
connectionhandler INTERFACE
74+
${connectionhandler_SOURCE_DIR}/src
75+
)
76+
77+
target_include_directories(
78+
connectionhandler INTERFACE
79+
${connectionhandler_SOURCE_DIR}/src/settings
80+
)
81+
82+
83+
##########################################################################
84+
85+
set(CMAKE_CXX_STANDARD 11)
86+
87+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
88+
89+
##########################################################################
90+
91+
set(TEST_TARGET ${CMAKE_PROJECT_NAME})
92+
93+
##########################################################################
94+
95+
set(TEST_SRCS
96+
src/test_provisioning_command_decode.cpp
97+
src/test_provisioning_command_encode.cpp
98+
)
99+
100+
set(TEST_DUT_SRCS
101+
../../src/ConfiguratorAgents/agents/BoardConfigurationProtocol/cbor/Decoder.cpp
102+
../../src/ConfiguratorAgents/agents/BoardConfigurationProtocol/cbor/Encoder.cpp
103+
104+
${cloudutils_SOURCE_DIR}/src/cbor/tinycbor/src/cborencoder.c
105+
${cloudutils_SOURCE_DIR}/src/cbor/tinycbor/src/cborencoder_close_container_checked.c
106+
${cloudutils_SOURCE_DIR}/src/cbor/tinycbor/src/cborerrorstrings.c
107+
${cloudutils_SOURCE_DIR}/src/cbor/tinycbor/src/cborparser.c
108+
${cloudutils_SOURCE_DIR}/src/cbor/tinycbor/src/cborparser_dup_string.c
109+
${cloudutils_SOURCE_DIR}/src/cbor/tinycbor/src/cborpretty.c
110+
${cloudutils_SOURCE_DIR}/src/cbor/tinycbor/src/cborpretty_stdio.c
111+
${cloudutils_SOURCE_DIR}/src/cbor/tinycbor/src/cbortojson.c
112+
${cloudutils_SOURCE_DIR}/src/cbor/tinycbor/src/cborvalidation.c
113+
${cloudutils_SOURCE_DIR}/src/cbor/tinycbor/src/open_memstream.c
114+
${cloudutils_SOURCE_DIR}/src/cbor/CborDecoder.cpp
115+
${cloudutils_SOURCE_DIR}/src/cbor/CborEncoder.cpp
116+
)
117+
##########################################################################
118+
119+
set(TEST_TARGET_SRCS
120+
src/Arduino.cpp
121+
${TEST_SRCS}
122+
${TEST_UTIL_SRCS}
123+
${TEST_DUT_SRCS}
124+
)
125+
126+
##########################################################################
127+
128+
add_compile_definitions(BOARD_HAS_LORA BOARD_HAS_CATM1_NBIOT BOARD_HAS_WIFI BOARD_HAS_ETHERNET BOARD_HAS_CELLULAR BOARD_HAS_NB BOARD_HAS_GSM)
129+
add_compile_options(-Wextra -Werror)
130+
add_compile_options(-Wno-cast-function-type)
131+
132+
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "--coverage")
133+
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "--coverage -Wno-deprecated-copy")
134+
135+
##########################################################################
136+
137+
add_executable(
138+
${TEST_TARGET}
139+
${TEST_TARGET_SRCS}
140+
)
141+
142+
target_link_libraries( ${TEST_TARGET} connectionhandler)
143+
target_link_libraries( ${TEST_TARGET} cloudutils)
144+
target_link_libraries( ${TEST_TARGET} Catch2WithMain )
145+
146+
##########################################################################
147+

extras/test/include/Arduino.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Copyright (c) 2019 Arduino. All rights reserved.
3+
*/
4+
5+
#ifndef TEST_ARDUINO_H_
6+
#define TEST_ARDUINO_H_
7+
8+
/******************************************************************************
9+
INCLUDE
10+
******************************************************************************/
11+
12+
#include <string>
13+
#include <IPAddress.h>
14+
/******************************************************************************
15+
DEFINES
16+
******************************************************************************/
17+
#ifndef min
18+
#define min(a,b) ((a)<(b)?(a):(b))
19+
#endif
20+
21+
/******************************************************************************
22+
TYPEDEF
23+
******************************************************************************/
24+
25+
typedef std::string String;
26+
27+
/******************************************************************************
28+
FUNCTION PROTOTYPES
29+
******************************************************************************/
30+
31+
void set_millis(unsigned long const millis);
32+
unsigned long millis();
33+
34+
#endif /* TEST_ARDUINO_H_ */

0 commit comments

Comments
 (0)