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

Error compiling ContactSensor for ESP8266 #160

Closed medavid008 closed 3 years ago

medavid008 commented 3 years ago

Hello, I have errors compiling ContactSensor.ino, for ESP8266. I'm using even adafruit feather Huzzah ESP8266. For unmodified ContactSensor.ino example I get the following when verifying or compiling:

In file included from ...\Arduino\libraries\SinricPro\examples\ContactSensor\ContactSensor.ino:35:0: ...\Arduino\libraries\SinricPro\src/SinricProContactsensor.h:22:57: error: expected template-name before '<' token public ContactEventSource { ^ ...\Arduino\libraries\SinricPro\src/SinricProContactsensor.h:22:57: error: expected '{' before '<' token ...\Arduino\libraries\SinricPro\src/SinricProContactsensor.h:22:57: error: expected unqualified-id before '<' token exit status 1

I have dependencies libraries installed.

Thanks you very much, any help would be appreciated.

The code of your example is: ////////////////////////////////////////////////////////////////////// /*

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

ifdef ESP8266

   #include <ESP8266WiFi.h>

endif

ifdef ESP32

   #include <WiFi.h>

endif

include "SinricPro.h"

include "SinricProContactsensor.h"

define WIFI_SSID "YOUR-WIFI-SSID"

define WIFI_PASS "YOUR-WIFI-PASSWORD"

define APP_KEY "YOUR-APP-KEY" // Should look like "de0bxxxx-1x3x-4x3x-ax2x-5dabxxxxxxxx"

define APP_SECRET "YOUR-APP-SECRET" // Should look like "5f36xxxx-x3x7-4x3x-xexe-e86724a9xxxx-4c4axxxx-3x3x-x5xe-x9x3-333d65xxxxxx"

define CONTACT_ID "YOUR-DEVICE-ID" // Should look like "5dc1564130xxxxxxxxxxxxxx"

define BAUD_RATE 9600 // Change baudrate to your need

define CONTACT_PIN 5 // PIN where contactsensor is connected to

                                          // LOW  = contact is open
                                          // HIGH = contact is closed

bool myPowerState = true; // assume device is turned on bool lastContactState = false; unsigned long lastChange = 0;

/**

/**

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

// setup function for SinricPro void setupSinricPro() { // add device to SinricPro SinricProContactsensor& myContact = SinricPro[CONTACT_ID];

// set callback function to device myContact.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); }

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

pinMode(CONTACT_PIN, INPUT);

setupWiFi(); setupSinricPro(); }

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

sivar2311 commented 3 years ago

Which SinricPro Version do you use?

medavid008 commented 3 years ago

SinricPro 2.9.0 added to libraries today. image

sivar2311 commented 3 years ago

Ah yes, there is an error in current 2.9.0 (renamed a few components) which is already fixed in dev-2.9.2. Fixed in 2.9.0 now.

Please remove SinricProLibrary from ArduinoIDE. Download ZIP from Github repo and install ZIP file in ArduinoIDE.

sivar2311 commented 3 years ago

Sorry, i missed another line.... please standby

sivar2311 commented 3 years ago

Okay, now it should compile without any issues.

medavid008 commented 3 years ago

I should redownload zip unpack and replace the files in arduino IDE libraries folder. NOT try to reinstall the library?

sivar2311 commented 3 years ago

Uninstall via Libraries Manager: image

Download ZIP file

Install ZIP-File: image

medavid008 commented 3 years ago

Great, thanks. It works now.