Skip to content

Commit 9620db8

Browse files
authored
Merge pull request #368 from sivar2311/master
Upgrade to ArduinoJson 7.x
2 parents b324295 + 2f30a49 commit 9620db8

35 files changed

+104
-199
lines changed

README.md

+6-20
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,13 @@
99

1010
[![Build](https://github.com/sinricpro/esp8266-esp32-sdk/actions/workflows/build-esp8266-esp32.yml/badge.svg)](https://github.com/sinricpro/esp8266-esp32-sdk/actions/workflows/build-esp8266-esp32.yml)
1111

12-
## Note
13-
1. Use the latest ESP8226/ESP32/RP2040 Arduino Core!
14-
2. Use the latest WebSocktes library!
15-
3. Use the latest ArduinoJson library!
16-
1712
## Installation
1813

1914
### VS Code & PlatformIO:
2015
1. Install [VS Code](https://code.visualstudio.com/)
2116
2. Install [PlatformIO](https://platformio.org/platformio-ide)
22-
3. Install **SinricPro** library by using [Library Manager](https://docs.platformio.org/en/latest/librarymanager/)
23-
4. Use included [platformio.ini](examples/platformio/platformio.ini) file from examples to ensure that all dependent libraries will installed automaticly.
17+
3. Create a new Project
18+
4. Use the [Library Manager](https://docs.platformio.org/en/latest/librarymanager/) to add the library to your project or add `sinricpro/SinricPro` manually to your `lib_deps` in `platformio.ini`.
2419

2520
![sinricpro library manager](https://raw.githubusercontent.com/sinricpro/images/master/platformio-install-sinricpro.png)
2621

@@ -35,8 +30,8 @@
3530
---
3631

3732
## Dependencies
38-
[ArduinoJson](https://github.com/bblanchon/ArduinoJson) by Benoit Blanchon (minimum Version 6.12.0)
39-
[WebSockets](https://github.com/Links2004/arduinoWebSockets) by Markus Sattler (minimum Version 2.4.0)
33+
- [ArduinoJson](https://github.com/bblanchon/ArduinoJson) by Benoit Blanchon (minimum Version 7.0.3)
34+
- [WebSockets](https://github.com/Links2004/arduinoWebSockets) by Markus Sattler (minimum Version 2.4.0)
4035

4136
---
4237

@@ -98,28 +93,19 @@ Example
9893
```C++
9994
SinricProSwitch& mySwitch = SinricPro["YOUR-SWITCH-ID-HERE"];
10095
```
101-
*Example 2 (alternatively)*
102-
```C++
103-
SinricProSwitch& mySwitch = SinricPro.add<SinricProSwitch>("YOUR-SWITCH-ID-HERE");
104-
```
10596

10697
---
10798
## How to retrieve a device for sending an event?
10899
Syntax is
109100
```C++
110101
DeviceType& myDevice = SinricPro[DEVICE_ID];
111102
```
112-
Example 1
103+
Example
113104
```C++
114105
SinricProDoorbell& myDoorbell = SinricPro["YOUR-DOORBELL-ID-HERE"];
115106
myDoorbell.sendDoorbellEvent();
116107
```
117108

118-
*Example 2 (alternatively)*
119-
```C++
120-
SinricPro["YOUR-DOORBELL-ID-HERE"].as<SinricProDoorbell>().sendDoorbellEvent();
121-
```
122-
123109
## How to send a push notification?
124110
```C++
125111
SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];
@@ -128,7 +114,7 @@ mySwitch.sendPushNotification("Hello SinricPro!");
128114

129115
---
130116

131-
# Devices
117+
## Devices
132118
* Switch
133119
* Dimmable Switch
134120
* Light

changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
## Version 3.1.0
3+
Upgrade:
4+
- Upgrade to ArduinoJson 7
5+
26
## Version 3.0.1
37
Fixed:
48
- SinricPro.isConnected() still returns true if the connection was lost

examples/platformio/platformio.ini

+4-99
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,12 @@
88
; Please visit documentation for the other options and examples
99
; https://docs.platformio.org/page/projectconf.html
1010

11-
[platformio]
12-
; ============================================================
13-
; chose environment:
14-
; ESP8266
15-
; ESP32
16-
; ============================================================
17-
default_envs = ESP8266
18-
;default_envs = ESP32
19-
2011
[env]
21-
; ============================================================
22-
; Serial configuration
23-
; choose upload speed, serial-monitor speed
24-
; ============================================================
12+
framework = arduino
2513
upload_speed = 921600
26-
;upload_port = COM11
2714
monitor_speed = 115200
28-
;monitor_port = COM11
29-
3015
lib_deps =
3116
sinricpro/SinricPro
32-
3317
build_flags =
3418
; set your debug output (default=Serial)
3519
-D DEBUG_ESP_PORT=Serial
@@ -40,95 +24,16 @@ build_flags =
4024
; comment the following line to enable SinricPro debugging
4125
-D NODEBUG_SINRIC
4226

43-
4427
[env:ESP8266]
4528
platform = espressif8266
46-
framework = arduino
47-
; ============================================================
48-
; Board configuration
49-
; choose your board by uncommenting one of the following lines
50-
; ============================================================
51-
;board = gen4iod
52-
;board = huzzah
53-
;board = oak
54-
;board = esp_wroom_02
55-
;board = espduino
56-
;board = espectro
57-
;board = espino
58-
;board = espresso_lite_v1
59-
;board = espresso_lite_v2
60-
;board = esp12e
61-
;board = esp01_1m
62-
;board = esp01
63-
;board = esp07
64-
;board = esp8285
65-
;board = heltec_wifi_kit_8
66-
;board = inventone
67-
;board = nodemcu
68-
board = nodemcuv2
69-
;board = modwifi
70-
;board = phoenix_v1
71-
;board = phoenix_v2
72-
;board = sparkfunBlynk
73-
;board = thing
74-
;board = thingdev
75-
;board = esp210
76-
;board = espinotee
77-
;board = d1
78-
;board = d1_mini
79-
;board = d1_mini_lite
80-
;board = d1_mini_pro
81-
;board = wifi_slot
82-
;board = wifiduino
83-
;board = wifinfo
84-
;board = wio_link
85-
;board = wio_node
86-
;board = xinabox_cw01
87-
;board = esp32doit-devkit-v1
29+
board = esp12e
8830

8931
[env:ESP32]
9032
platform = espressif32
9133
framework = arduino
92-
; ============================================================
93-
; Board configuration
94-
; choose your board by uncommenting one of the following lines
95-
; ============================================================
96-
;board = esp32cam
97-
;board = alksesp32
98-
;board = featheresp32
99-
;board = espea32
100-
;board = bpi-bit
101-
;board = d-duino-32
102-
board = esp32doit-devkit-v1
103-
;board = pocket_32
104-
;board = fm-devkit
105-
;board = pico32
106-
;board = esp32-evb
107-
;board = esp32-gateway
108-
;board = esp32-pro
109-
;board = esp32-poe
110-
;board = oroca_edubot
111-
;board = onehorse32dev
112-
;board = lopy
113-
;board = lopy4
114-
;board = wesp32
115-
;board = esp32thing
116-
;board = sparkfun_lora_gateway_1-channel
117-
;board = ttgo-lora32-v1
118-
;board = ttgo-t-beam
119-
;board = turta_iot_node
120-
;board = lolin_d32
121-
;board = lolin_d32_pro
122-
;board = lolin32
123-
;board = wemosbat
124-
;board = widora-air
125-
;board = xinabox_cw02
126-
;board = iotbusio
127-
;board = iotbusproteus
128-
;board = nina_w10
34+
board = esp32dev
12935

130-
[env:pico]
36+
[env:RP2040]
13137
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
13238
board = pico
133-
framework = arduino
13439
board_build.core = earlephilhower

library.json

+17-7
Original file line numberDiff line numberDiff line change
@@ -13,26 +13,36 @@
1313
"maintainer": true
1414
}
1515
],
16-
"version": "3.0.1",
16+
"version": "3.1.0",
1717
"frameworks": "arduino",
1818
"platforms": [
1919
"espressif8266",
2020
"espressif32",
2121
"raspberrypi"
2222
],
23-
"dependencies":[
24-
{
23+
"dependencies": [
24+
{
2525
"name": "ArduinoJson",
26-
"platforms":["espressif32","espressif8266"]
26+
"version": "^7.0.3",
27+
"platforms": [
28+
"espressif32",
29+
"espressif8266",
30+
"raspberrypi"
31+
]
2732
},
2833
{
2934
"name": "WebSockets",
30-
"platforms":["espressif32","espressif8266"]
35+
"version": "^2.4.0",
36+
"platforms": [
37+
"espressif32",
38+
"espressif8266",
39+
"raspberrypi"
40+
]
3141
}
3242
],
33-
"examples":[
43+
"examples": [
3444
"examples/*/*.ino",
3545
"examples/*/*/*.ino"
3646
],
3747
"license": "CC-BY-SA-4.0"
38-
}
48+
}

library.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SinricPro
2-
version=3.0.1
2+
version=3.1.0
33
author=Boris Jaeger <[email protected]>
44
maintainer=Boris Jaeger <[email protected]>
55
sentence=Library for https://sinric.pro - simple way to connect your device to alexa
@@ -9,5 +9,5 @@ url=https://sinricpro.github.io/esp8266-esp32-sdk/index.html
99
architectures=esp8266,esp32,rp2040
1010
repository=https://github.com/sinricpro/esp8266-esp32-sdk.git
1111
license=CC-BY-SA
12-
depends=ArduinoJson,WebSockets
12+
depends=ArduinoJson@7.0.3,WebSockets@2.4.0
1313
includes=SinricPro.h

src/Capabilities/AirQualitySensor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ bool AirQualitySensor<T>::sendAirQualityEvent(int pm1, int pm2_5, int pm10, Stri
4444
if (event_limiter) return false;
4545
T* device = static_cast<T*>(this);
4646

47-
DynamicJsonDocument eventMessage = device->prepareEvent(FSTR_AIRQUALITY_airQuality, cause.c_str());
47+
JsonDocument eventMessage = device->prepareEvent(FSTR_AIRQUALITY_airQuality, cause.c_str());
4848
JsonObject event_value = eventMessage[FSTR_SINRICPRO_payload][FSTR_SINRICPRO_value];
4949

5050
event_value[FSTR_AIRQUALITY_pm1] = pm1;

src/Capabilities/BrightnessController.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ bool BrightnessController<T>::sendBrightnessEvent(int brightness, String cause)
109109
if (event_limiter) return false;
110110
T* device = static_cast<T*>(this);
111111

112-
DynamicJsonDocument eventMessage = device->prepareEvent(FSTR_BRIGHTNESS_setBrightness, cause.c_str());
112+
JsonDocument eventMessage = device->prepareEvent(FSTR_BRIGHTNESS_setBrightness, cause.c_str());
113113
JsonObject event_value = eventMessage[FSTR_SINRICPRO_payload][FSTR_SINRICPRO_value];
114114
event_value[FSTR_BRIGHTNESS_brightness] = brightness;
115115
return device->sendEvent(eventMessage);

src/Capabilities/ChannelController.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ bool ChannelController<T>::sendChangeChannelEvent(String channelName, String cau
143143
if (event_limiter) return false;
144144
T* device = static_cast<T*>(this);
145145

146-
DynamicJsonDocument eventMessage = device->prepareEvent(FSTR_CHANNEL_changeChannel, cause.c_str());
146+
JsonDocument eventMessage = device->prepareEvent(FSTR_CHANNEL_changeChannel, cause.c_str());
147147
JsonObject event_value = eventMessage[FSTR_SINRICPRO_payload][FSTR_SINRICPRO_value];
148148
event_value[FSTR_CHANNEL_channel][FSTR_CHANNEL_name] = channelName;
149149
return device->sendEvent(eventMessage);

src/Capabilities/ColorController.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ bool ColorController<T>::sendColorEvent(byte r, byte g, byte b, String cause) {
8888
if (event_limiter) return false;
8989
T* device = static_cast<T*>(this);
9090

91-
DynamicJsonDocument eventMessage = device->prepareEvent(FSTR_COLOR_setColor, cause.c_str());
92-
JsonObject event_color = eventMessage[FSTR_SINRICPRO_payload][FSTR_SINRICPRO_value].createNestedObject(FSTR_COLOR_color);
91+
JsonDocument eventMessage = device->prepareEvent(FSTR_COLOR_setColor, cause.c_str());
92+
JsonObject event_color = eventMessage[FSTR_SINRICPRO_payload][FSTR_SINRICPRO_value][FSTR_COLOR_color].to<JsonObject>();
9393
event_color[FSTR_COLOR_r] = r;
9494
event_color[FSTR_COLOR_g] = g;
9595
event_color[FSTR_COLOR_b] = b;
@@ -108,7 +108,7 @@ bool ColorController<T>::handleColorController(SinricProRequest &request) {
108108
g = request.request_value[FSTR_COLOR_color][FSTR_COLOR_g];
109109
b = request.request_value[FSTR_COLOR_color][FSTR_COLOR_b];
110110
success = colorCallback(device->deviceId, r, g, b);
111-
request.response_value.createNestedObject(FSTR_COLOR_color);
111+
request.response_value[FSTR_COLOR_color].to<JsonObject>();
112112
request.response_value[FSTR_COLOR_color][FSTR_COLOR_r] = r;
113113
request.response_value[FSTR_COLOR_color][FSTR_COLOR_g] = g;
114114
request.response_value[FSTR_COLOR_color][FSTR_COLOR_b] = b;

src/Capabilities/ColorTemperatureController.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ bool ColorTemperatureController<T>::sendColorTemperatureEvent(int colorTemperatu
141141
if (event_limiter) return false;
142142
T* device = static_cast<T*>(this);
143143

144-
DynamicJsonDocument eventMessage = device->prepareEvent(FSTR_COLORTEMPERATURE_setColorTemperature, cause.c_str());
144+
JsonDocument eventMessage = device->prepareEvent(FSTR_COLORTEMPERATURE_setColorTemperature, cause.c_str());
145145
JsonObject event_value = eventMessage[FSTR_SINRICPRO_payload][FSTR_SINRICPRO_value];
146146
event_value[FSTR_COLORTEMPERATURE_colorTemperature] = colorTemperature;
147147
return device->sendEvent(eventMessage);

src/Capabilities/ContactSensor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ bool ContactSensor<T>::sendContactEvent(bool detected, String cause) {
4141
if (event_limiter) return false;
4242
T* device = static_cast<T*>(this);
4343

44-
DynamicJsonDocument eventMessage = device->prepareEvent(FSTR_CONTACT_setContactState, cause.c_str());
44+
JsonDocument eventMessage = device->prepareEvent(FSTR_CONTACT_setContactState, cause.c_str());
4545
JsonObject event_value = eventMessage[FSTR_SINRICPRO_payload][FSTR_SINRICPRO_value];
4646
event_value[FSTR_CONTACT_state] = detected ? FSTR_CONTACT_closed : FSTR_CONTACT_open;
4747
return device->sendEvent(eventMessage);

src/Capabilities/DoorController.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ bool DoorController<T>::sendDoorStateEvent(bool state, String cause) {
7979
if (event_limiter) return false;
8080
T* device = static_cast<T*>(this);
8181

82-
DynamicJsonDocument eventMessage = device->prepareEvent(FSTR_DOOR_setMode, cause.c_str());
82+
JsonDocument eventMessage = device->prepareEvent(FSTR_DOOR_setMode, cause.c_str());
8383
JsonObject event_value = eventMessage[FSTR_SINRICPRO_payload][FSTR_SINRICPRO_value];
8484
state ? event_value[FSTR_DOOR_mode] = FSTR_DOOR_Close : event_value[FSTR_DOOR_mode] = FSTR_DOOR_Open;
8585
return device->sendEvent(eventMessage);

src/Capabilities/Doorbell.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ bool Doorbell<T>::sendDoorbellEvent(String cause) {
4040
if (event_limiter) return false;
4141
T* device = static_cast<T*>(this);
4242

43-
DynamicJsonDocument eventMessage = device->prepareEvent(FSTR_DOORBELL_DoorbellPress, cause.c_str());
43+
JsonDocument eventMessage = device->prepareEvent(FSTR_DOORBELL_DoorbellPress, cause.c_str());
4444
JsonObject event_value = eventMessage[FSTR_SINRICPRO_payload][FSTR_SINRICPRO_value];
4545
event_value[FSTR_DOORBELL_state] = FSTR_DOORBELL_pressed;
4646
return device->sendEvent(eventMessage);

0 commit comments

Comments
 (0)