Skip to content

Commit 1f327a4

Browse files
authored
Merge pull request #223 from MathewHDYT/master
Overhaul Library API Design
2 parents 1527449 + 621e32c commit 1f327a4

96 files changed

Lines changed: 6308 additions & 5273 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/arduino-compile.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ jobs:
3030
- source-path: ./
3131
- name: TBPubSubClient
3232
- name: ArduinoHttpClient
33-
- { name: ArduinoJson, version: 6.21.4 }
33+
- { name: ArduinoJson, version: 6.21.5 }
3434
- name: StreamUtils
3535
- name: WiFiEsp
3636
- name: TinyGSM
37+
- name: Seeed_Arduino_mbedtls
38+
- name: arduino-timer
3739
3840
strategy:
3941
matrix:

.github/workflows/esp32-compile.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ jobs:
3030
- source-path: ./
3131
- name: TBPubSubClient
3232
- name: ArduinoHttpClient
33-
- { name: ArduinoJson, version: 6.21.4 }
34-
- name: StreamUtils
33+
- { name: ArduinoJson, version: 6.21.5 }
3534
3635
strategy:
3736
matrix:

.github/workflows/esp8266-compile.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ jobs:
2828
LIBRARIES: |
2929
# Install the additionally needed dependency from the respository
3030
- source-path: ./
31+
- name: arduino-timer
3132
- name: TBPubSubClient
3233
- name: ArduinoHttpClient
33-
- { name: ArduinoJson, version: 6.21.4 }
34+
- { name: ArduinoJson, version: 6.21.5 }
3435
- name: Seeed_Arduino_mbedtls
35-
- name: StreamUtils
3636
3737
strategy:
3838
matrix:

.github/workflows/espidf-compile-v4.4.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,21 @@ jobs:
3636
esp_idf_version: v4.4
3737
target: esp32
3838
path: 'examples/0015-espressif_esp32_process_OTA_MQTT'
39+
- name: Build process RPC example on v4.4
40+
uses: espressif/esp-idf-ci-action@v1
41+
with:
42+
esp_idf_version: v4.4
43+
target: esp32
44+
path: 'examples/0016-espressif_esp32_rpc'
45+
- name: Build process Shared Attribute example on v4.4
46+
uses: espressif/esp-idf-ci-action@v1
47+
with:
48+
esp_idf_version: v4.4
49+
target: esp32
50+
path: 'examples/0017-espressif_esp32_process_shared_attribute_update'
51+
- name: Build process Provision example on v4.4
52+
uses: espressif/esp-idf-ci-action@v1
53+
with:
54+
esp_idf_version: v4.4
55+
target: esp32
56+
path: 'examples/0018-espressif_esp32_provision_device'

.github/workflows/espidf-compile-v5.1.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,21 @@ jobs:
3636
esp_idf_version: v5.1
3737
target: esp32
3838
path: 'examples/0015-espressif_esp32_process_OTA_MQTT'
39+
- name: Build process RPC example on v5.1
40+
uses: espressif/esp-idf-ci-action@v1
41+
with:
42+
esp_idf_version: v5.1
43+
target: esp32
44+
path: 'examples/0016-espressif_esp32_rpc'
45+
- name: Build process Shared Attribute example on v5.1
46+
uses: espressif/esp-idf-ci-action@v1
47+
with:
48+
esp_idf_version: v5.1
49+
target: esp32
50+
path: 'examples/0017-espressif_esp32_process_shared_attribute_update'
51+
- name: Build process Provision example on v5.1
52+
uses: espressif/esp-idf-ci-action@v1
53+
with:
54+
esp_idf_version: v5.1
55+
target: esp32
56+
path: 'examples/0018-espressif_esp32_provision_device'

CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@ cmake_minimum_required(VERSION 3.12)
33
set(srcs
44
src/Arduino_HTTP_Client.cpp
55
src/Arduino_MQTT_Client.cpp
6-
src/Callback_Watchdog.cpp
76
src/Arduino_ESP32_Updater.cpp
87
src/Arduino_ESP8266_Updater.cpp
9-
src/Espressif_Updater.cpp
10-
src/SDCard_Updater.cpp
11-
src/Espressif_MQTT_Client.cpp
128
src/HashGenerator.cpp
139
src/Helper.cpp
1410
src/OTA_Update_Callback.cpp
@@ -41,4 +37,4 @@ if(ESP_PLATFORM)
4137
return()
4238
endif()
4339

44-
project(ThingsBoardClientSDK VERSION 0.13.0)
40+
project(ThingsBoardClientSDK VERSION 0.14.0)

Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ menu "ThingsBoard Client SDK Configurations"
44
bool "Replace static with dynami library usage"
55
default n
66
help
7-
If this is enabled the library will use DynamicJsonDocument to receive messages from the MQTT broker and use Vector to hold Subscription data instead of Arrays. Removing the need to declare MaxFieldsAmount, MaxSubscribtions, MaxAttributes and MaxRPC template arguments. But instead increasing heap allocation and usage drastically.
7+
If this is enabled the library will use DynamicJsonDocument to receive messages from the MQTT broker and use Vector to hold Subscription data instead of Arrays. Removing the need to declare MaxResponse, MaxSubscriptions, MaxAttributes, MaxRPC and MaxRequestRPC template arguments. But instead increasing heap allocation and usage drastically.
88

99
config THINGSBOARD_ENABLE_DEBUG
1010
bool "Enable additional debug log messages"

README.md

Lines changed: 232 additions & 87 deletions
Large diffs are not rendered by default.

docs/Doxyfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "ThingsBoard Client SDK"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 0.13.0
41+
PROJECT_NUMBER = 0.14.0
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a
@@ -1978,7 +1978,7 @@ ENABLE_PREPROCESSING = YES
19781978
# The default value is: NO.
19791979
# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
19801980

1981-
MACRO_EXPANSION = NO
1981+
MACRO_EXPANSION = YES
19821982

19831983
# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES then
19841984
# the macro expansion is limited to the macros specified with the PREDEFINED and
@@ -2124,7 +2124,7 @@ DIA_PATH =
21242124
# and usage relations if the target is undocumented or is not a class.
21252125
# The default value is: YES.
21262126

2127-
HIDE_UNDOC_RELATIONS = YES
2127+
HIDE_UNDOC_RELATIONS = NO
21282128

21292129
# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
21302130
# available from the path. This tool is part of Graphviz (see:
@@ -2133,7 +2133,7 @@ HIDE_UNDOC_RELATIONS = YES
21332133
# set to NO
21342134
# The default value is: NO.
21352135

2136-
HAVE_DOT = NO
2136+
HAVE_DOT = YES
21372137

21382138
# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is allowed
21392139
# to run in parallel. When set to 0 doxygen will base this on the number of
@@ -2220,7 +2220,7 @@ UML_LIMIT_NUM_FIELDS = 10
22202220
# The default value is: NO.
22212221
# This tag requires that the tag HAVE_DOT is set to YES.
22222222

2223-
TEMPLATE_RELATIONS = NO
2223+
TEMPLATE_RELATIONS = YES
22242224

22252225
# If the INCLUDE_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are set to
22262226
# YES then doxygen will generate a graph for each documented file showing the
@@ -2293,7 +2293,7 @@ DIRECTORY_GRAPH = YES
22932293
# The default value is: png.
22942294
# This tag requires that the tag HAVE_DOT is set to YES.
22952295

2296-
DOT_IMAGE_FORMAT = png
2296+
DOT_IMAGE_FORMAT = svg
22972297

22982298
# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to
22992299
# enable generation of interactive SVG images that allow zooming and panning.
@@ -2305,7 +2305,7 @@ DOT_IMAGE_FORMAT = png
23052305
# The default value is: NO.
23062306
# This tag requires that the tag HAVE_DOT is set to YES.
23072307

2308-
INTERACTIVE_SVG = NO
2308+
INTERACTIVE_SVG = YES
23092309

23102310
# The DOT_PATH tag can be used to specify the path where the dot tool can be
23112311
# found. If left blank, it is assumed the dot tool can be found in the path.

examples/0000-arduino_send_telemetry/0000-arduino_send_telemetry.ino

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -12,64 +12,32 @@
1212
#include <SoftwareSerial.h>
1313

1414

15-
#if THINGSBOARD_ENABLE_PROGMEM
16-
constexpr char WIFI_SSID[] PROGMEM = "YOUR_WIFI_SSID";
17-
constexpr char WIFI_PASSWORD[] PROGMEM = "YOUR_WIFI_PASSWORD";
18-
#else
1915
constexpr char WIFI_SSID[] = "YOUR_WIFI_SSID";
2016
constexpr char WIFI_PASSWORD[] = "YOUR_WIFI_PASSWORD";
21-
#endif
2217

2318
// See https://thingsboard.io/docs/getting-started-guides/helloworld/
2419
// to understand how to obtain an access token
25-
#if THINGSBOARD_ENABLE_PROGMEM
26-
constexpr char TOKEN[] PROGMEM = "YOUR_DEVICE_ACCESS_TOKEN";
27-
#else
2820
constexpr char TOKEN[] = "YOUR_DEVICE_ACCESS_TOKEN";
29-
#endif
3021

3122
// Thingsboard we want to establish a connection too
32-
#if THINGSBOARD_ENABLE_PROGMEM
33-
constexpr char THINGSBOARD_SERVER[] PROGMEM = "demo.thingsboard.io";
34-
#else
3523
constexpr char THINGSBOARD_SERVER[] = "demo.thingsboard.io";
36-
#endif
3724

3825
// MQTT port used to communicate with the server, 1883 is the default unencrypted MQTT port,
3926
// whereas 8883 would be the default encrypted SSL MQTT port
40-
#if THINGSBOARD_ENABLE_PROGMEM
41-
constexpr uint16_t THINGSBOARD_PORT PROGMEM = 1883U;
42-
#else
4327
constexpr uint16_t THINGSBOARD_PORT = 1883U;
44-
#endif
4528

4629
// Maximum size packets will ever be sent or received by the underlying MQTT client,
4730
// if the size is to small messages might not be sent or received messages will be discarded
48-
#if THINGSBOARD_ENABLE_PROGMEM
49-
constexpr uint16_t MAX_MESSAGE_SIZE PROGMEM = 128U;
50-
#else
5131
constexpr uint16_t MAX_MESSAGE_SIZE = 128U;
52-
#endif
5332

5433
// Baud rate for the debugging serial connection
5534
// If the Serial output is mangled, ensure to change the monitor speed accordingly to this variable
56-
#if THINGSBOARD_ENABLE_PROGMEM
57-
constexpr uint32_t SERIAL_DEBUG_BAUD PROGMEM = 9600U;
58-
constexpr uint32_t SERIAL_ESP8266_DEBUG_BAUD PROGMEM = 9600U;
59-
#else
6035
constexpr uint32_t SERIAL_DEBUG_BAUD = 9600U;
6136
constexpr uint32_t SERIAL_ESP8266_DEBUG_BAUD = 9600U;
62-
#endif
6337

64-
#if THINGSBOARD_ENABLE_PROGMEM
65-
constexpr char CONNECTING_MSG[] PROGMEM = "Connecting to: (%s) with token (%s)";
66-
constexpr char TEMPERATURE_KEY[] PROGMEM = "temperature";
67-
constexpr char HUMIDITY_KEY[] PROGMEM = "humidity";
68-
#else
6938
constexpr char CONNECTING_MSG[] = "Connecting to: (%s) with token (%s)";
7039
constexpr char TEMPERATURE_KEY[] = "temperature";
7140
constexpr char HUMIDITY_KEY[] = "humidity";
72-
#endif
7341

7442

7543
// Serial driver for ESP
@@ -78,34 +46,22 @@ SoftwareSerial soft(2U, 3U); // RX, TX
7846
WiFiEspClient espClient;
7947
// Initalize the Mqtt client instance
8048
Arduino_MQTT_Client mqttClient(espClient);
81-
// Initialize ThingsBoard instance
49+
// Initialize ThingsBoard instance with the maximum needed buffer size
8250
ThingsBoard tb(mqttClient, MAX_MESSAGE_SIZE);
8351

8452

8553
/// @brief Initalizes WiFi connection,
8654
// will endlessly delay until a connection has been successfully established
8755
void InitWiFi() {
88-
#if THINGSBOARD_ENABLE_PROGMEM
89-
Serial.println(F("Connecting to AP ..."));
90-
#else
9156
Serial.println("Connecting to AP ...");
92-
#endif
9357
// Attempting to establish a connection to the given WiFi network
9458
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
9559
while (WiFi.status() != WL_CONNECTED) {
9660
// Delay 500ms until a connection has been successfully established
9761
delay(500);
98-
#if THINGSBOARD_ENABLE_PROGMEM
99-
Serial.print(F("."));
100-
#else
10162
Serial.print(".");
102-
#endif
10363
}
104-
#if THINGSBOARD_ENABLE_PROGMEM
105-
Serial.println(F("Connected to AP"));
106-
#else
10764
Serial.println("Connected to AP");
108-
#endif
10965
#if ENCRYPTED
11066
espClient.setCACert(ROOT_CERT);
11167
#endif
@@ -141,11 +97,7 @@ void setup() {
14197
WiFi.init(&soft);
14298
// check for the presence of the shield
14399
if (WiFi.status() == WL_NO_SHIELD) {
144-
#if THINGSBOARD_ENABLE_PROGMEM
145-
Serial.println(F("WiFi shield not present"));
146-
#else
147100
Serial.println("WiFi shield not present");
148-
#endif
149101
// don't continue
150102
while (true);
151103
}
@@ -166,20 +118,12 @@ void loop() {
166118
snprintf(message, sizeof(message), CONNECTING_MSG, THINGSBOARD_SERVER, TOKEN);
167119
Serial.println(message);
168120
if (!tb.connect(THINGSBOARD_SERVER, TOKEN, THINGSBOARD_PORT)) {
169-
#if THINGSBOARD_ENABLE_PROGMEM
170-
Serial.println(F("Failed to connect"));
171-
#else
172121
Serial.println("Failed to connect");
173-
#endif
174122
return;
175123
}
176124
}
177125

178-
#if THINGSBOARD_ENABLE_PROGMEM
179-
Serial.println(F("Sending telemetry data..."));
180-
#else
181126
Serial.println("Sending telemetry data...");
182-
#endif
183127
// Uploads new telemetry to ThingsBoard using MQTT.
184128
// See https://thingsboard.io/docs/reference/mqtt-api/#telemetry-upload-api
185129
// for more details

0 commit comments

Comments
 (0)