diff --git a/.github/workflows/build.yml b/.github/workflows/build-esp8266-esp32.yml similarity index 98% rename from .github/workflows/build.yml rename to .github/workflows/build-esp8266-esp32.yml index 0e18dbc3..3d5dfe5d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build-esp8266-esp32.yml @@ -1,4 +1,4 @@ -name: Build +name: Build for ESP8266-ESP32 on: pull_request: diff --git a/.github/workflows/build-rpipicow.yml b/.github/workflows/build-rpipicow.yml new file mode 100644 index 00000000..d2155a86 --- /dev/null +++ b/.github/workflows/build-rpipicow.yml @@ -0,0 +1,38 @@ +name: Build for Raspberry Pi Pico W + +on: + pull_request: + branches: [ master ] + paths: + - src/** + - examples/** + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + example: [examples/ACUnit, examples/AirQualitySensor/AirQualitySensor, examples/Blinds, examples/ContactSensor, examples/DimSwitch, examples/doorbell, examples/Fan, examples/GarageDoor, examples/Light/Light, examples/Lock/Lock, examples/Lock/Lock_with_feedback, examples/MotionSensor, examples/PowerSensor, examples/Relay/MultiRelays_advance, examples/Relay/Relay, examples/Speaker, examples/Switch/MultiSwitch_advance, examples/Switch/MultiSwitch_beginner, examples/Switch/MultiSwitch_intermediate, examples/Switch/Switch, examples/Thermostat, examples/TV] + + steps: + - name: Step 1 - Checkout Repo + uses: actions/checkout@v3 + with: + submodules: "recursive" + - name: Step 2 - Set up Python + uses: actions/setup-python@v3 + with: + python-version: "3.9" + - name: Step 3 - Install dependencies + run: | + pip install -U https://github.com/platformio/platformio/archive/develop.zip + pio pkg install --global --platform https://github.com/maxgerhardt/platform-raspberrypi.git + - name: Step 4 - Install library dependencies + run: | + pio lib --global install "bblanchon/ArduinoJson" + pio lib --global install "links2004/WebSockets" + - name: Step 5 - Run build test using PlatformIO + run: pio ci --lib="." -b rpipicow + env: + PLATFORMIO_CI_SRC: ${{ matrix.example }} diff --git a/README.md b/README.md index 81d087d4..4b12a65c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# SinricPro (ESP8266 / ESP32 SDK) +# SinricPro (ESP8266 / ESP32 / RP2040) [![arduino-library-badge](https://www.ardu-badge.com/badge/SinricPro.svg?)](https://www.ardu-badge.com/SinricPro) [![PlatformIO Registry](https://badges.registry.platformio.org/packages/sinricpro/library/SinricPro.svg)](https://registry.platformio.org/libraries/sinricpro/SinricPro) [![Platform ESP8266](https://img.shields.io/badge/Platform-Espressif8266-orange)](#) [![Platform ESP32](https://img.shields.io/badge/Platform-Espressif32-orange)](#) @@ -10,8 +10,9 @@ [![Build](https://github.com/sinricpro/esp8266-esp32-sdk/actions/workflows/build.yml/badge.svg)](https://github.com/sinricpro/esp8266-esp32-sdk/actions/workflows/build.yml) ## Note -1. Use the latest ESP Arduino Core! +1. Use the latest ESP8226/ESP32/RP2040 Arduino Core! 2. Use the latest WebSocktes library! +3. Use the latest ArduinoJson library! ## Installation @@ -35,7 +36,7 @@ ## Dependencies [ArduinoJson](https://github.com/bblanchon/ArduinoJson) by Benoit Blanchon (minimum Version 6.12.0) -[WebSockets](https://github.com/Links2004/arduinoWebSockets) by Markus Sattler (minimum Version 2.3.5) +[WebSockets](https://github.com/Links2004/arduinoWebSockets) by Markus Sattler (minimum Version 2.4.0) --- diff --git a/changelog.md b/changelog.md index ae961fa4..3957eb52 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,7 @@ # Changelog +## Version 2.11.1 +- Support Raspberry Pi Pico W + ## Version 2.10.3 - Fixed version number for PlatformIO library registry diff --git a/examples/ACUnit/ACUnit.ino b/examples/ACUnit/ACUnit.ino index d4238324..f7eb6565 100644 --- a/examples/ACUnit/ACUnit.ino +++ b/examples/ACUnit/ACUnit.ino @@ -15,17 +15,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino b/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino index ddd6dab8..8c48dea3 100644 --- a/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino +++ b/examples/AirQualitySensor/AirQualitySensor/AirQualitySensor.ino @@ -15,18 +15,17 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino b/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino index 59a95aec..1c3369f9 100644 --- a/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino +++ b/examples/AirQualitySensor/AirQualitySensor_gp2y1014au0f/AirQualitySensor_gp2y1014au0f.ino @@ -17,19 +17,18 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include // https://github.com/luciansabo/GP2YDustSensor #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/Blinds/Blinds.ino b/examples/Blinds/Blinds.ino index ecc0c6a7..77a930ee 100644 --- a/examples/Blinds/Blinds.ino +++ b/examples/Blinds/Blinds.ino @@ -15,17 +15,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/Camera/Camera.ino b/examples/Camera/Camera.ino index 4aeb22ed..b24af01d 100644 --- a/examples/Camera/Camera.ino +++ b/examples/Camera/Camera.ino @@ -20,9 +20,9 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include diff --git a/examples/ContactSensor/ContactSensor.ino b/examples/ContactSensor/ContactSensor.ino index 4e88145c..61e397f8 100644 --- a/examples/ContactSensor/ContactSensor.ino +++ b/examples/ContactSensor/ContactSensor.ino @@ -24,11 +24,10 @@ #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/DimSwitch/DimSwitch.ino b/examples/DimSwitch/DimSwitch.ino index d4ccffc1..ceedb43a 100644 --- a/examples/DimSwitch/DimSwitch.ino +++ b/examples/DimSwitch/DimSwitch.ino @@ -13,17 +13,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/Fan/Fan.ino b/examples/Fan/Fan.ino index cb50f57f..4f490e86 100644 --- a/examples/Fan/Fan.ino +++ b/examples/Fan/Fan.ino @@ -13,17 +13,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/GarageDoor/GarageDoor.ino b/examples/GarageDoor/GarageDoor.ino index 017e034c..c57d0f28 100644 --- a/examples/GarageDoor/GarageDoor.ino +++ b/examples/GarageDoor/GarageDoor.ino @@ -15,17 +15,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/Light/Light/Light.ino b/examples/Light/Light/Light.ino index cf8faa44..b131c512 100644 --- a/examples/Light/Light/Light.ino +++ b/examples/Light/Light/Light.ino @@ -13,17 +13,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/Light/Light_FastLED_WS2812/Light_FastLED_WS2812.ino b/examples/Light/Light_FastLED_WS2812/Light_FastLED_WS2812.ino index eb43c9ee..8be95ff5 100644 --- a/examples/Light/Light_FastLED_WS2812/Light_FastLED_WS2812.ino +++ b/examples/Light/Light_FastLED_WS2812/Light_FastLED_WS2812.ino @@ -13,17 +13,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #define FASTLED_ESP8266_DMA diff --git a/examples/Light/RGB_LED_Stripe_5050/RGB_LED_Stripe_5050.ino b/examples/Light/RGB_LED_Stripe_5050/RGB_LED_Stripe_5050.ino index 2de3f98f..396ef5a5 100644 --- a/examples/Light/RGB_LED_Stripe_5050/RGB_LED_Stripe_5050.ino +++ b/examples/Light/RGB_LED_Stripe_5050/RGB_LED_Stripe_5050.ino @@ -13,9 +13,9 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include diff --git a/examples/Lock/Lock/Lock.ino b/examples/Lock/Lock/Lock.ino index 8fd2c558..3954c492 100644 --- a/examples/Lock/Lock/Lock.ino +++ b/examples/Lock/Lock/Lock.ino @@ -15,17 +15,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/Lock/Lock_with_feedback/Lock_with_feedback.ino b/examples/Lock/Lock_with_feedback/Lock_with_feedback.ino index 14d3017e..477d1006 100644 --- a/examples/Lock/Lock_with_feedback/Lock_with_feedback.ino +++ b/examples/Lock/Lock_with_feedback/Lock_with_feedback.ino @@ -20,17 +20,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" @@ -43,13 +42,12 @@ #define LOCK_ID "YOUR_DEVICE_ID_HERE" // Should look like "5dc1564130xxxxxxxxxxxxxx" #define BAUD_RATE 9600 // Change baudrate to your need -#ifdef ESP8266 -#define LOCK_PIN D1 // PIN where the lock is connected to: HIGH = locked, LOW = unlocked -#define LOCK_STATE_PIN D2 // PIN where the lock feedback is connected to (HIGH:locked, LOW:unlocked) -#endif -#ifdef ESP32 -#define LOCK_PIN 16 // PIN where the lock is connected to: HIGH = locked, LOW = unlocked -#define LOCK_STATE_PIN 17 // PIN where the lock feedback is connected to (HIGH:locked, LOW:unlocked) +#if defined(ESP8266) + #define LOCK_PIN D1 // PIN where the lock is connected to: HIGH = locked, LOW = unlocked + #define LOCK_STATE_PIN D2 // PIN where the lock feedback is connected to (HIGH:locked, LOW:unlocked) +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #define LOCK_PIN 16 // PIN where the lock is connected to: HIGH = locked, LOW = unlocked + #define LOCK_STATE_PIN 17 // PIN where the lock feedback is connected to (HIGH:locked, LOW:unlocked) #endif bool lastLockState; diff --git a/examples/MotionSensor/MotionSensor.ino b/examples/MotionSensor/MotionSensor.ino index 3c5b9eb1..c907a5ae 100644 --- a/examples/MotionSensor/MotionSensor.ino +++ b/examples/MotionSensor/MotionSensor.ino @@ -18,17 +18,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/PowerSensor/PowerSensor.ino b/examples/PowerSensor/PowerSensor.ino index be40df5b..59c52303 100644 --- a/examples/PowerSensor/PowerSensor.ino +++ b/examples/PowerSensor/PowerSensor.ino @@ -17,17 +17,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/Relay/MultiRelays_advance/MultiRelays_advance.ino b/examples/Relay/MultiRelays_advance/MultiRelays_advance.ino index f0b03335..28983f97 100644 --- a/examples/Relay/MultiRelays_advance/MultiRelays_advance.ino +++ b/examples/Relay/MultiRelays_advance/MultiRelays_advance.ino @@ -15,41 +15,39 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include #include -#ifdef ESP8266 -#define RELAYPIN_1 D1 -#define RELAYPIN_2 D2 -#define RELAYPIN_3 D3 -#define RELAYPIN_4 D4 -#define RELAYPIN_5 D5 -#define RELAYPIN_6 D6 -#define RELAYPIN_7 D7 -#define RELAYPIN_8 D8 -#endif -#ifdef ESP32 -#define RELAYPIN_1 16 -#define RELAYPIN_2 17 -#define RELAYPIN_3 18 -#define RELAYPIN_4 19 -#define RELAYPIN_5 21 -#define RELAYPIN_6 22 -#define RELAYPIN_7 23 -#define RELAYPIN_8 25 +#if defined(ESP8266) + #define RELAYPIN_1 D1 + #define RELAYPIN_2 D2 + #define RELAYPIN_3 D3 + #define RELAYPIN_4 D4 + #define RELAYPIN_5 D5 + #define RELAYPIN_6 D6 + #define RELAYPIN_7 D7 + #define RELAYPIN_8 D8 +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #define RELAYPIN_1 16 + #define RELAYPIN_2 17 + #define RELAYPIN_3 18 + #define RELAYPIN_4 19 + #define RELAYPIN_5 21 + #define RELAYPIN_6 22 + #define RELAYPIN_7 23 + #define RELAYPIN_8 25 #endif /***************** diff --git a/examples/Relay/Relay/Relay.ino b/examples/Relay/Relay/Relay.ino index e61230a6..8d673d81 100644 --- a/examples/Relay/Relay/Relay.ino +++ b/examples/Relay/Relay/Relay.ino @@ -13,17 +13,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" @@ -36,12 +35,10 @@ #define SWITCH_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx" #define BAUD_RATE 9600 // Change baudrate to your need -#ifdef ESP8266 -#define RELAY_PIN D5 // Pin where the relay is connected (D5 = GPIO 14 on ESP8266) -#endif - -#ifdef ESP32 -#define RELAY_PIN 16 // Pin where the relay is connected (GPIO 16 on ESP32) +#if defined(ESP8266) + #define RELAY_PIN D5 // Pin where the relay is connected (D5 = GPIO 14 on ESP8266) +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #define RELAY_PIN 16 // Pin where the relay is connected (GPIO 16 on ESP32) #endif bool onPowerState(const String &deviceId, bool &state) { @@ -52,7 +49,10 @@ bool onPowerState(const String &deviceId, bool &state) { void setup() { pinMode(RELAY_PIN, OUTPUT); // set relay-pin to output mode WiFi.begin(WIFI_SSID, WIFI_PASS); // start wifi - + while (WiFi.status() != WL_CONNECTED) { + delay(250); + } + SinricProSwitch& mySwitch = SinricPro[SWITCH_ID]; // create new switch device mySwitch.onPowerState(onPowerState); // apply onPowerState callback SinricPro.begin(APP_KEY, APP_SECRET); // start SinricPro diff --git a/examples/Speaker/Speaker.ino b/examples/Speaker/Speaker.ino index dca7dc52..bc99eba5 100644 --- a/examples/Speaker/Speaker.ino +++ b/examples/Speaker/Speaker.ino @@ -11,12 +11,20 @@ * - visit https://github.com/sinricpro/esp8266-esp32-sdk/issues and check for existing issues or open a new one */ -#include -#ifdef ESP8266 - #include +// Uncomment the following line to enable serial debug output +//#define ENABLE_DEBUG + +#ifdef ENABLE_DEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif -#ifdef ESP32 - #include + +#include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/Switch/MultiSwitch_advance/MultiSwitch_advance.ino b/examples/Switch/MultiSwitch_advance/MultiSwitch_advance.ino index 9e9aebe4..0ef80854 100644 --- a/examples/Switch/MultiSwitch_advance/MultiSwitch_advance.ino +++ b/examples/Switch/MultiSwitch_advance/MultiSwitch_advance.ino @@ -25,17 +25,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" @@ -55,28 +54,26 @@ #define DEBOUNCE_TIME 250 -#ifdef ESP8266 -#define RELAYPIN_1 D1 -#define RELAYPIN_2 D2 -#define RELAYPIN_3 D3 -#define RELAYPIN_4 D4 -#define SWITCHPIN_1 D8 -#define SWITCHPIN_2 D7 -#define SWITCHPIN_3 D6 -#define SWITCHPIN_4 D5 -#endif - -#ifdef ESP32 -#define LED_BUILTIN 2 - -#define RELAYPIN_1 16 -#define RELAYPIN_2 17 -#define RELAYPIN_3 18 -#define RELAYPIN_4 19 -#define SWITCHPIN_1 25 -#define SWITCHPIN_2 26 -#define SWITCHPIN_3 22 -#define SWITCHPIN_4 21 +#if defined(ESP8266) + #define RELAYPIN_1 D1 + #define RELAYPIN_2 D2 + #define RELAYPIN_3 D3 + #define RELAYPIN_4 D4 + #define SWITCHPIN_1 D8 + #define SWITCHPIN_2 D7 + #define SWITCHPIN_3 D6 + #define SWITCHPIN_4 D5 +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #define LED_BUILTIN 2 + + #define RELAYPIN_1 16 + #define RELAYPIN_2 17 + #define RELAYPIN_3 18 + #define RELAYPIN_4 19 + #define SWITCHPIN_1 25 + #define SWITCHPIN_2 26 + #define SWITCHPIN_3 22 + #define SWITCHPIN_4 21 #endif typedef struct { // struct for the std::map below diff --git a/examples/Switch/MultiSwitch_beginner/MultiSwitch_beginner.ino b/examples/Switch/MultiSwitch_beginner/MultiSwitch_beginner.ino index 1f991823..6983410a 100644 --- a/examples/Switch/MultiSwitch_beginner/MultiSwitch_beginner.ino +++ b/examples/Switch/MultiSwitch_beginner/MultiSwitch_beginner.ino @@ -17,17 +17,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/Switch/MultiSwitch_intermediate/MultiSwitch_intermediate.ino b/examples/Switch/MultiSwitch_intermediate/MultiSwitch_intermediate.ino index 54575e00..d4cf2089 100644 --- a/examples/Switch/MultiSwitch_intermediate/MultiSwitch_intermediate.ino +++ b/examples/Switch/MultiSwitch_intermediate/MultiSwitch_intermediate.ino @@ -17,17 +17,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/Switch/Switch/Switch.ino b/examples/Switch/Switch/Switch.ino index 224c3db7..575ec8d7 100644 --- a/examples/Switch/Switch/Switch.ino +++ b/examples/Switch/Switch/Switch.ino @@ -18,17 +18,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/TV/TV.ino b/examples/TV/TV.ino index 370831a8..1b685a7b 100644 --- a/examples/TV/TV.ino +++ b/examples/TV/TV.ino @@ -13,12 +13,20 @@ * - visit https://github.com/sinricpro/esp8266-esp32-sdk/issues and check for existing issues or open a new one */ -#include -#ifdef ESP8266 - #include +// Uncomment the following line to enable serial debug output +//#define ENABLE_DEBUG + +#ifdef ENABLE_DEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif -#ifdef ESP32 - #include + +#include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/Thermostat/Thermostat.ino b/examples/Thermostat/Thermostat.ino index e794f78e..4973f206 100644 --- a/examples/Thermostat/Thermostat.ino +++ b/examples/Thermostat/Thermostat.ino @@ -15,17 +15,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/doorbell/doorbell.ino b/examples/doorbell/doorbell.ino index 12c33725..8dbdf737 100644 --- a/examples/doorbell/doorbell.ino +++ b/examples/doorbell/doorbell.ino @@ -17,17 +17,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/platformio/platformio.ini b/examples/platformio/platformio.ini index 8addee02..328bbfa2 100644 --- a/examples/platformio/platformio.ini +++ b/examples/platformio/platformio.ini @@ -126,3 +126,9 @@ board = esp32doit-devkit-v1 ;board = iotbusio ;board = iotbusproteus ;board = nina_w10 + +[env:pico] +platform = https://github.com/maxgerhardt/platform-raspberrypi.git +board = pico +framework = arduino +board_build.core = earlephilhower \ No newline at end of file diff --git a/examples/temperaturesensor/AHT10/AHT10.ino b/examples/temperaturesensor/AHT10/AHT10.ino index b22416fe..bcd05ed0 100644 --- a/examples/temperaturesensor/AHT10/AHT10.ino +++ b/examples/temperaturesensor/AHT10/AHT10.ino @@ -25,18 +25,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG -#endif - + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG +#endif #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" diff --git a/examples/temperaturesensor/DHT22/DHT22.ino b/examples/temperaturesensor/DHT22/DHT22.ino index a97bd422..aa875bb5 100644 --- a/examples/temperaturesensor/DHT22/DHT22.ino +++ b/examples/temperaturesensor/DHT22/DHT22.ino @@ -21,18 +21,16 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif - #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include "SinricPro.h" @@ -47,10 +45,9 @@ #define BAUD_RATE 9600 // Change baudrate to your need (used for serial monitor) #define EVENT_WAIT_TIME 60000 // send event every 60 seconds -#ifdef ESP8266 +#if defined(ESP8266) #define DHT_PIN D5 -#endif -#ifdef ESP32 +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) #define DHT_PIN 5 #endif diff --git a/examples/temperaturesensor/HTU21D/HTU21D.ino b/examples/temperaturesensor/HTU21D/HTU21D.ino index a647204c..19e339b2 100644 --- a/examples/temperaturesensor/HTU21D/HTU21D.ino +++ b/examples/temperaturesensor/HTU21D/HTU21D.ino @@ -20,19 +20,17 @@ //#define ENABLE_DEBUG #ifdef ENABLE_DEBUG - #define DEBUG_ESP_PORT Serial - #define NODEBUG_WEBSOCKETS - #define NDEBUG + #define DEBUG_ESP_PORT Serial + #define NODEBUG_WEBSOCKETS + #define NDEBUG #endif - #include -#ifdef ESP8266 - #include -#endif -#ifdef ESP32 - #include -#endif +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include +#endiff #include "SinricPro.h" #include "SinricProTemperaturesensor.h" @@ -50,13 +48,12 @@ Adafruit_HTU21DF htu = Adafruit_HTU21DF(); #define BAUD_RATE 9600 // Change baudrate to your need (used for serial monitor) #define EVENT_WAIT_TIME 60000 -#ifdef ESP8266 - #define I2C_SCL 14 //D5 - #define I2C_SDA 12 //D6 -#endif -#ifdef ESP32 - #define I2C_SCL 18 - #define I2C_SDA 19 +#if defined(ESP8266) + #define I2C_SCL 14 //D5 + #define I2C_SDA 12 //D6 +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #define I2C_SCL 18 + #define I2C_SDA 19 #endif bool deviceIsOn; // Temeprature sensor on/off state diff --git a/library.json b/library.json index 3c523772..7ed0d069 100644 --- a/library.json +++ b/library.json @@ -13,11 +13,12 @@ "maintainer": true } ], - "version": "2.10.3", + "version": "2.11.1", "frameworks": "arduino", "platforms": [ "espressif8266", - "espressif32" + "espressif32", + "raspberrypi" ], "dependencies":[ { diff --git a/library.properties b/library.properties index b882c2fc..369abcdf 100644 --- a/library.properties +++ b/library.properties @@ -1,12 +1,12 @@ name=SinricPro -version=2.10.3 +version=2.11.1 author=Boris Jaeger maintainer=Boris Jaeger sentence=Library for https://sinric.pro - simple way to connect your device to alexa paragraph=Simple way to control your IOT development boards like ESP8226 or ESP32 with Amazon Alexa or Google Home category=Communication url=https://sinricpro.github.io/esp8266-esp32-sdk/index.html -architectures=esp8266,esp32 +architectures=esp8266,esp32,rp2040 repository=https://github.com/sinricpro/esp8266-esp32-sdk.git license=CC-BY-SA depends=ArduinoJson,WebSockets diff --git a/src/SinricProSignature.cpp b/src/SinricProSignature.cpp index f355c7e2..46bf9c21 100644 --- a/src/SinricProSignature.cpp +++ b/src/SinricProSignature.cpp @@ -9,7 +9,7 @@ #include #include "SinricProSignature.h" -#if defined (ESP8266) +#if defined (ESP8266) || defined(ARDUINO_ARCH_RP2040) #include #endif #if defined (ESP32) @@ -22,7 +22,7 @@ namespace SINRICPRO_NAMESPACE { String HMACbase64(const String &message, const String &key) { byte hmacResult[32]; -#if defined(ESP8266) +#if defined(ESP8266) || defined(ARDUINO_ARCH_RP2040) br_hmac_key_context keyContext; // Holds general HMAC info br_hmac_context hmacContext; // Holds general HMAC info + specific info for the current operation @@ -42,9 +42,9 @@ String HMACbase64(const String &message, const String &key) { mbedtls_md_hmac_update(&ctx, (const unsigned char*) message.c_str(), message.length()); mbedtls_md_hmac_finish(&ctx, hmacResult); mbedtls_md_free(&ctx); - #endif + base64_encodestate _state; base64_init_encodestate(&_state); #if defined(base64_encode_expected_len_nonewlines) diff --git a/src/SinricProVersion.h b/src/SinricProVersion.h index a1575313..5f39fad9 100644 --- a/src/SinricProVersion.h +++ b/src/SinricProVersion.h @@ -5,8 +5,8 @@ // Version Configuration #define SINRICPRO_VERSION_MAJOR 2 -#define SINRICPRO_VERSION_MINOR 10 -#define SINRICPRO_VERSION_REVISION 3 +#define SINRICPRO_VERSION_MINOR 11 +#define SINRICPRO_VERSION_REVISION 1 #define SINRICPRO_VERSION STR(SINRICPRO_VERSION_MAJOR) "." STR(SINRICPRO_VERSION_MINOR) "." STR(SINRICPRO_VERSION_REVISION) #define SINRICPRO_VERSION_STR "SinricPro (v" SINRICPRO_VERSION ")" #define SINRICPRO_VERISON_INT SINRICPRO_VERSION_MAJOR * 1000000 + SINRICPRO_VERSION_MINOR * 1000 + SINRICPRO_VERSION_REVISION \ No newline at end of file diff --git a/src/SinricProWebsocket.h b/src/SinricProWebsocket.h index 3bc8a3d1..88319200 100644 --- a/src/SinricProWebsocket.h +++ b/src/SinricProWebsocket.h @@ -7,11 +7,10 @@ #pragma once -#if defined ESP8266 -#include -#endif -#if defined ESP32 -#include +#if defined(ESP8266) + #include +#elif defined(ESP32) || defined(ARDUINO_ARCH_RP2040) + #include #endif #include @@ -79,11 +78,12 @@ WebsocketListener::~WebsocketListener() { } void WebsocketListener::setExtraHeaders() { -#ifdef ESP8266 +#if defined(ESP8266) const char* platform = "ESP8266"; -#endif -#ifdef ESP32 +#elif defined(ESP32) const char* platform = "ESP32"; +#elif defined(ARDUINO_ARCH_RP2040) + const char* platform = "RP2040"; #endif String headers = "appkey:" + appKey;