Closed Arief-AK closed 2 years ago
Did you clean the build directory (PIO CLEAN) after updating PlatformIO ?
Did you clean the build directory (PIO CLEAN) after updating PlatformIO ?
Yes I did perform a PIO CLEAN. Still the same results.
I also updated platformIO to the latest arduino core. No issues here.
Do you have the issues also when using one of the (unmodified) examples?
No issues when compiling the unmodified examples from the repository.
Below is the problems output window from the SinricPro.h file.
Below is my PlatformIO configuration file PlatformIO.ini
No issues when compiling the unmodified examples from the repository.
So there must be a bug in your code. Hard to say without knowing your code. But it seems to me to be a reference / pointer problem.
Please note that you are working with references to devices!
SinricProSwitch& mySwitch = SinricPro[DEVICE_ID];
mySwitch
is a reference to an object created and managed by SinricPro.
Taken from your first post:
const SINRICPRO_2_9_17::SinricProSwitch
Where does this come from?
Are you using const SinricProSwitch
somewhere?
No I have not used a const SinricProSwitch
in my source code.
The error itself originates from the SinricPro.h that is part of my project library dependencies.
In my source code, I have made a single global instance of the SinricProSwitch
using:
SinricProSwitch& mySwitch = SinricPro[SWITCH_ID];
I assign a callback function to the appropiate events onConnected()
and onDisconnect()
similar to the given examples. Then, in multiple stages of my program, I use the sendPowerStateEvent()
function from myswitch
instance to send the state of my switch.
mySwitch.sendPowerStateEvent(myPowerState);
The error itself originates from the SinricPro.h that is part of my project library dependencies.
No, but at this point the error is noticed and the compiler issues a corresponding message.
If the error were in SinricPro.h, the error would also occur in the examples.
Without seeing your code and being able to check it, I cannot help you. The compiler messages alone do not help.
Can you provide your code for analysis?
Great! (I found your repository).
Yeah, here's the link https://github.com/Arief-AK/WakeUpAlarm/blob/main/WakeUpAlarm/src/main.cpp
I found the issue(s) Remove line 114 and 144. You're trying to reassing a reference. This is not possible / not allowed.
Ahh of course!
Trivial mistake, my appologies.
I appreciate your effort and time. Thank you!
No problem. You're welcome :) I'm glad I could help you and the problem is solved.
I think you can also remove line 59 (sendPowerStateEvent). If you want to change the state within a callback, e.g. the device is requested to turn on but it cannot turn on and you want to tell the server that the device is still off, just set the state variable to false. The state variable is a reference (so it can be altered) The the value is passed back to the server after the callback function returns.
I see, I will implement this. Thanks for the feedback!
Hello,
I have been working with SinricPro library for a while now. Initially it was working fine until I recently updated my PlatformIO. When compiling I receive the errors below.
.pio/libdeps/ttgo-t1/SinricPro/src/SinricPro.h:189:3: error: passing 'const SINRICPRO_2_9_17::SinricProSwitch' as 'this' argument discards qualifiers [-fpermissive]
.pio/libdeps/ttgo-t1/SinricPro/src/SinricPro.h:191:3: error: no matching function for call to 'push_back(const SINRICPRO_2_9_17::SinricProSwitch*&)'
.pio/libdeps/ttgo-t1/SinricPro/src/SinricPro.h:191:21: error: invalid conversion from 'const SINRICPRO_2_9_17::SinricProDeviceInterface*' to 'std::vector<SINRICPRO_2_9_17::SinricProDeviceInterface*>::value_type' {aka 'SINRICPRO_2_9_17::SinricProDeviceInterface*'} [-fpermissive]
.pio/libdeps/ttgo-t1/SinricPro/src/SinricPro.h:191:21: error: invalid conversion from 'const SINRICPRO_2_9_17::SinricProDeviceInterface*' to ``'std::vector<SINRICPRO_2_9_17::SinricProDeviceInterface*>::value_type' {aka 'SINRICPRO_2_9_17::SinricProDeviceInterface*'} [-fpermissive]
I am not sure what I did in the background for this occur.
Have any ideas to why this could be?
Thanks. Arief.