sinricpro / esp8266-esp32-sdk

Library for https://sinric.pro - simple way to connect your device to Alexa, Google Home, SmartThings and cloud
https://sinric.pro
Other
236 stars 125 forks source link

Can't compile #78

Closed DEADSEC-SECURITY closed 4 years ago

DEADSEC-SECURITY commented 4 years ago

I'm trying to compile my code based on SinricPro but I'm getting a huge error.

Libraries:

Arduino board:

The error:

Arduino: 1.8.13 (Windows Store 1.8.39.0) (Windows 10), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, 115200, 4M (3M SPIFFS)"

In file included from C:\Users\amng8\Documents\ArduinoProjects\Sinric\Sinric.ino:13:0:

C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h:122:5: error: 'vector' in namespace 'std' does not name a type

     std::vector<SinricProDeviceInterface*> devices;

     ^

C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h: In member function 'SinricProDeviceInterface* SinricProClass::getDevice(String)':

C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h:139:23: error: 'devices' was not declared in this scope

   for (auto& device : devices) {

                       ^

In file included from C:\Users\amng8\Documents\ArduinoProjects\Sinric\Sinric.ino:13:0:

C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h: In member function 'DeviceType& SinricProClass::add(const char*, long unsigned int)':

C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h:211:3: error: 'devices' was not declared in this scope

   devices.push_back(newDevice);

   ^

C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h: In member function 'void SinricProClass::add(SinricProDeviceInterface*)':

C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h:219:3: error: 'devices' was not declared in this scope

   devices.push_back(newDevice);

   ^

C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h: In member function 'void SinricProClass::add(SinricProDeviceInterface&)':

C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h:226:3: error: 'devices' was not declared in this scope

   devices.push_back(&newDevice);

   ^

C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h: In member function 'void SinricProClass::handleRequest(ArduinoJson6120_000001::DynamicJsonDocument&, interface_t)':

C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h:305:23: error: 'devices' was not declared in this scope

   for (auto& device : devices) {

                       ^

C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h: In member function 'void SinricProClass::connect()':

C:\Users\amng8\Documents\Arduino\libraries\SinricPro\src/SinricPro.h:391:23: error: 'devices' was not declared in this scope

   for (auto& device : devices) {

                       ^

exit status 1

Error compiling for board NodeMCU 0.9 (ESP-12 Module).

My code:

// 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 

#include <Arduino.h>
#include <ESP8266WiFi.h>

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

#define WIFI_SSID         "DUMMY"    
#define WIFI_PASS         "DUMMY"
#define APP_KEY           "DUMMY"
#define APP_SECRET        "DUMMY"
#define GARAGEDOOR_ID     "DUMMY"
#define SWITCH_LIGHTS_ID  "DUMMY"
#define BAUD_RATE         9600

#define STATUS_LED         D0
#define RELAY_1            D4
#define RELAY_2            D1
#define RELAY_3            D2
#define RELAY_4            D3

bool myPowerState = false;

bool onDoorState(const String& deviceId, bool &doorState) {
  digitalWrite(RELAY_1, LOW);
  delay(500);
  digitalWrite(RELAY_1, HIGH);
  Serial.printf("Garagedoor is %s now.\r\n", doorState?"closed":"open");
  return true;
}

bool onPowerState(const String &deviceId, bool &state) {
  Serial.printf("Device %s turned %s (via SinricPro) \r\n", deviceId.c_str(), state?"on":"off");
  myPowerState = state;
  digitalWrite(RELAY_2, myPowerState?HIGH:LOW);
  return true; // request handled properly
}

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

  while (WiFi.status() != WL_CONNECTED) {
    Serial.printf(".");
    digitalWrite(STATUS_LED, HIGH);
    delay(500);
    digitalWrite(STATUS_LED, LOW);
    delay(500);
  }
  IPAddress localIP = WiFi.localIP();
  Serial.printf("connected!\r\n[WiFi]: IP-Address is %d.%d.%d.%d\r\n", localIP[0], localIP[1], localIP[2], localIP[3]);
  digitalWrite(STATUS_LED, HIGH);
}

void setupSinricPro() {
  SinricProGarageDoor &myGarageDoor = SinricPro[GARAGEDOOR_ID];
  myGarageDoor.onDoorState(onDoorState);

  SinricProSwitch &mySwitch = SinricPro[SWITCH_LIGHTS_ID];
  mySwitch.onPowerState(onPowerState);

  // 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);
}

void setup() {
  pinMode(STATUS_LED, OUTPUT);
  pinMode(RELAY_1, OUTPUT);
  pinMode(RELAY_2, OUTPUT);
  pinMode(RELAY_3, OUTPUT);
  pinMode(RELAY_4, OUTPUT);
  digitalWrite(STATUS_LED, LOW);
  digitalWrite(RELAY_1, HIGH);
  digitalWrite(RELAY_2, HIGH);
  digitalWrite(RELAY_3, HIGH);
  digitalWrite(RELAY_4, HIGH);

  Serial.begin(BAUD_RATE); Serial.printf("\r\n\r\n");
  setupWiFi();
  setupSinricPro();
}

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

This error seems something from the SinricPro libraries and I can't seem to understand why is this error occurring.

sivar2311 commented 4 years ago

It seems that std::vector is not supported in your arduino / esp8266 setup. What ESP Core version do you use? (Maybe an update is required)

Can you compile other sketches which make use of std::vector?

DEADSEC-SECURITY commented 4 years ago

It seems that std::vector is not supported in your arduino / esp8266 setup. What ESP Core version do you use? (Maybe an update is required)

Can you compile other sketches which make use of std::vector?

Could you give me an example of a sketch that uses std::vector since I don't know any right now. I included vector seemed to remove the errors but now I'm getting a new error error: 'class WiFiClientSecure' has no member named 'setCACert'

kakopappa commented 4 years ago

these errors seem to be related to esp core version is out of date. I am on 2.7.2 and I can compile the switch sketch. Please try updating the core

image