PlatformIO Community

Trying to use SinricPro code on an esp32 but keep getting the same error

Hi,
I’ve been trying to figure this out for a couple of hours now but nothing I do fixes it.
The error I’m recieving is
*** [.pio/build/esp32dev/lib843/WebSockets/WebSocketsServer.cpp.o] Error 1

This is the code that I’m trying to use:

#ifdef ENABLE_DEBUG
   #define DEBUG_ESP_PORT Serial
   #define NODEBUG_WEBSOCKETS
   #define NDEBUG
#endif 

#include <Arduino.h>
#ifdef ESP8266 
   #include <ESP8266WiFi.h>
#endif 
#ifdef ESP32   
   #include <WiFi.h>
#endif

#include "SinricPro.h"
#include "SinricProSwitch.h"

#define WIFI_SSID         "PGPHAGOO"
#define WIFI_PASS         "SomosPutermanes"
#define APP_KEY           "80bc0420-e237-4d8f-afd5-55ed4b6c8ae6"
#define APP_SECRET        "c6bcf515-fa7f-42eb-bd74-9bb22f8fd540-bc5569e6-3cd4-45cb-8a98-27fd41db3812"

#define SWITCH_ID_1       "62a4cc02fce0b9e02e6db2cf"
#define RELAYPIN_1        15

#define BAUD_RATE         115200                // Change baudrate to your need

bool onPowerState1(const String &deviceId, bool &state) {
 Serial.printf("Device 1 turned %s", state?"on":"off");
 digitalWrite(RELAYPIN_1, state ? HIGH:LOW);
 return true; // request handled properly
}

// setup function for WiFi connection
void setupWiFi() {
  Serial.printf("\r\n[Wifi]: Connecting");
  WiFi.begin(WIFI_SSID, WIFI_PASS);

  while (WiFi.status() != WL_CONNECTED) {
    Serial.printf(".");
    delay(250);
  }

  Serial.printf("connected!\r\n[WiFi]: IP-Address is %s\r\n", WiFi.localIP().toString().c_str());
}

// setup function for SinricPro
void setupSinricPro() {
  // add devices and callbacks to SinricPro
  pinMode(RELAYPIN_1, OUTPUT);
    
  SinricProSwitch& mySwitch1 = SinricPro[SWITCH_ID_1];
  mySwitch1.onPowerState(onPowerState1);
  
  
  // setup SinricPro
  SinricPro.onConnected([](){ Serial.printf("Connected to SinricPro\r\n"); }); 
  SinricPro.onDisconnected([](){ Serial.printf("Disconnected from SinricPro\r\n"); });
   
  SinricPro.begin(APP_KEY, APP_SECRET);
}

// main setup function
void setup() {
  Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n");
  setupWiFi();
  setupSinricPro();
}

void loop() {
  SinricPro.handle();
}

Might be running into sha.h didn't exist anymore with latest core 2.0.3. · Issue #745 · Links2004/arduinoWebSockets · GitHub? Hard to say when you don’t post the real error message that comes before Error 1.

Try and go to your project’s platformio.ini and in the lib_deps expression, instead of

   links2004/WebSockets@^2.3.7

, use

   WebSockets=https://github.com/Links2004/arduinoWebSockets/archive/refs/heads/master.zip

instead.

Your code compiles fine using the latest core 2.0.3

All you need is to have lib_deps = sinric/SinricPro in your platformio.ini.
Dependencies will be installed automatically.

You’ll find an example platformio.ini in the the examples folder.

If you still have problems, please open a new issue in SinricPro github repository.