Aircoookie / Espalexa

Alexa voice control for ESP8266/ESP32 (including brightness and color!)
MIT License
531 stars 135 forks source link

ESP32 Callback Compilation error #109

Open jlgoasis opened 4 years ago

jlgoasis commented 4 years ago

Hi Aircoookie

First of all, congratulations for your excellent library

Until now I've working fine under ESP8266, but lately when I've changed to ESP32S I'm having complication error.

For your reference I've tested your library under the following conditions:

The companion error seems to be in the Callback Functions as showing bellow:

_In file included from /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.cpp:3:0: /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.h:8:14: error: 'function' in namespace 'std' does not name a template type typedef std::function<void(uint8_t b)> BrightnessCallbackFunction; ^ /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.h:9:14: error: 'function' in namespace 'std' does not name a template type typedef std::function<void(EspalexaDevice* d)> DeviceCallbackFunction; ^ /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.h:10:14: error: 'function' in namespace 'std' does not name a template type typedef std::function<void(uint8_t br, uint32_t col)> ColorCallbackFunction; ^ /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.h:19:3: error: 'BrightnessCallbackFunction' does not name a type BrightnessCallbackFunction _callback = nullptr; ^ /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.h:20:3: error: 'DeviceCallbackFunction' does not name a type DeviceCallbackFunction _callbackDev = nullptr; ^ /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.h:21:3: error: 'ColorCallbackFunction' does not name a type ColorCallbackFunction _callbackCol = nullptr; ^ /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.h:34:37: error: 'BrightnessCallbackFunction' has not been declared EspalexaDevice(String deviceName, BrightnessCallbackFunction bcb, uint8_t initialValue =0); ^ /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.h:35:37: error: 'DeviceCallbackFunction' has not been declared EspalexaDevice(String deviceName, DeviceCallbackFunction dcb, EspalexaDeviceType t =EspalexaDeviceType::dimmable, uint8_t initialValue =0); ^ In file included from /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.cpp:3:0: /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.h:36:37: error: 'ColorCallbackFunction' has not been declared EspalexaDevice(String deviceName, ColorCallbackFunction ccb, uint8_t initialValue =0); ^ /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.h:36:3: error: 'EspalexaDevice::EspalexaDevice(String, int, uint8_t)' cannot be overloaded EspalexaDevice(String deviceName, ColorCallbackFunction ccb, uint8_t initialValue =0); ^ In file included from /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.cpp:3:0: /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.h:34:3: error: with 'EspalexaDevice::EspalexaDevice(String, int, uint8_t)' EspalexaDevice(String deviceName, BrightnessCallbackFunction bcb, uint8_t initialValue =0); ^ /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.cpp:7:51: error: 'BrightnessCallbackFunction' has not been declared EspalexaDevice::EspalexaDevice(String deviceName, BrightnessCallbackFunction gnCallback, uint8_t initialValue) { //constructor for dimmable device ^ /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.cpp: In constructor 'EspalexaDevice::EspalexaDevice(String, int, uint8_t)': /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.cpp:10:3: error: '_callback' was not declared in this scope _callback = gnCallback; ^ /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.cpp: At global scope: /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.cpp:16:51: error: 'ColorCallbackFunction' has not been declared EspalexaDevice::EspalexaDevice(String deviceName, ColorCallbackFunction gnCallback, uint8_t initialValue) { //constructor for color device ^ /Users/Jacinto/Documents/Arduino/libraries/Espalexa/src/EspalexaDevice.cpp:16:1: error: redefinition of 'EspalexaDevice::EspalexaDevice(String, int, uint8_t)' EspalexaDevice::EspalexaDevice(String deviceName, ColorCallbackFunction gnCallback, uint8t initialValue) { //constructor for color device ^

Any idea?

BR Jacinto

meditant commented 4 years ago

Hello, I have this same issues with PlatformIO 4.3.2 and With AsyncWebServer.

Compiling .pio/build/debug/lib5b8/Espalexa_ID5525/EspalexaDevice.cpp.o In file included from .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:3:0: .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.h:6:15: warning: 'typedef' was ignored in this declaration typedef class EspalexaDevice; ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.h:8:14: error: 'function' in namespace 'std' does not name a template type typedef std::function<void(uint8_t b)> BrightnessCallbackFunction; ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.h:9:14: error: 'function' in namespace 'std' does not name a template type typedef std::function<void(EspalexaDevice* d)> DeviceCallbackFunction; ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.h:10:14: error: 'function' in namespace 'std' does not name a template type typedef std::function<void(uint8_t br, uint32_t col)> ColorCallbackFunction; ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.h:19:3: error: 'BrightnessCallbackFunction' does not name a type BrightnessCallbackFunction _callback = nullptr; ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.h:20:3: error: 'DeviceCallbackFunction' does not name a type DeviceCallbackFunction _callbackDev = nullptr; ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.h:21:3: error: 'ColorCallbackFunction' does not name a type ColorCallbackFunction _callbackCol = nullptr; ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.h:34:37: error: 'BrightnessCallbackFunction' has not been declared EspalexaDevice(String deviceName, BrightnessCallbackFunction bcb, uint8_t initialValue =0); ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.h:35:37: error: 'DeviceCallbackFunction' has not been declared EspalexaDevice(String deviceName, DeviceCallbackFunction dcb, EspalexaDeviceType t =EspalexaDeviceType::dimmable, uint8_t initialValue =0); ^ In file included from .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:3:0: .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.h:36:37: error: 'ColorCallbackFunction' has not been declared EspalexaDevice(String deviceName, ColorCallbackFunction ccb, uint8_t initialValue =0); ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.h:36:3: error: 'EspalexaDevice::EspalexaDevice(String, int, uint8_t)' cannot be overloaded EspalexaDevice(String deviceName, ColorCallbackFunction ccb, uint8_t initialValue =0); ^ In file included from .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:3:0: .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.h:34:3: error: with 'EspalexaDevice::EspalexaDevice(String, int, uint8_t)' EspalexaDevice(String deviceName, BrightnessCallbackFunction bcb, uint8_t initialValue =0); ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:7:51: error: 'BrightnessCallbackFunction' has not been declared EspalexaDevice::EspalexaDevice(String deviceName, BrightnessCallbackFunction gnCallback, uint8_t initialValue) { //constructor for dimmable device ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp: In constructor 'EspalexaDevice::EspalexaDevice(String, int, uint8_t)': .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:10:3: error: '_callback' was not declared in this scope _callback = gnCallback; ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp: At global scope: .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:16:51: error: 'ColorCallbackFunction' has not been declared EspalexaDevice::EspalexaDevice(String deviceName, ColorCallbackFunction gnCallback, uint8_t initialValue) { //constructor for color device ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:16:1: error: redefinition of 'EspalexaDevice::EspalexaDevice(String, int, uint8_t)' EspalexaDevice::EspalexaDevice(String deviceName, ColorCallbackFunction gnCallback, uint8_t initialValue) { //constructor for color device ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:7:1: note: 'EspalexaDevice::EspalexaDevice(String, int, uint8_t)' previously defined here EspalexaDevice::EspalexaDevice(String deviceName, BrightnessCallbackFunction gnCallback, uint8_t initialValue) { //constructor for dimmable device ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:25:51: error: 'DeviceCallbackFunction' has not been declared EspalexaDevice::EspalexaDevice(String deviceName, DeviceCallbackFunction gnCallback, EspalexaDeviceType t, uint8_t initialValue) { //constructor for general device ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp: In constructor 'EspalexaDevice::EspalexaDevice(String, int, EspalexaDeviceType, uint8_t)': .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:28:3: error: '_callbackDev' was not declared in this scope _callbackDev = gnCallback; ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp: In member function 'uint32_t EspalexaDevice::getRGB()': .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:114:9: warning: unused variable 'r' [-Wunused-variable] float r, g, b, w; ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:114:12: warning: unused variable 'g' [-Wunused-variable] float r, g, b, w; ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:114:15: warning: unused variable 'b' [-Wunused-variable] float r, g, b, w; ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:114:18: warning: unused variable 'w' [-Wunused-variable] float r, g, b, w; ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp: In member function 'void EspalexaDevice::doCallback()': .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:333:7: error: '_callback' was not declared in this scope if (_callback != nullptr) {_callback(_val); return;} ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:334:7: error: '_callbackDev' was not declared in this scope if (_callbackDev != nullptr) {_callbackDev(this); return;} ^ .pio/libdeps/debug/Espalexa_ID5525/src/EspalexaDevice.cpp:335:7: error: '_callbackCol' was not declared in this scope if (_callbackCol != nullptr) _callbackCol(_val, getRGB()); ^ Best

meditant commented 4 years ago

I try with juste the https://github.com/Aircoookie/Espalexa/tree/master/examples/EspalexaWithAsyncWebServer and same issues !

Best,

meditant commented 4 years ago

The add of #include <functional> at the top of EspalexaDevices.h solve the problems

Best,