Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example allways returns OFF #55

Closed
mano1979 opened this issue Mar 10, 2019 · 21 comments
Closed

Example allways returns OFF #55

mano1979 opened this issue Mar 10, 2019 · 21 comments

Comments

@mano1979
Copy link

Every example I tried (on an ESP32) returns OFF whatever command I give.
I am on a new computer so I have the newest libraries installed and also the newest ESP packages.

I saw other issues about it always returning ON, could this also be related to newer libraries not compatible with the examples?

@mano1979
Copy link
Author

I really hope you can answer soon. I am really excited about converting my entire lighting system to this firmware.

@Aircoookie
Copy link
Owner

Hi! So sorry, I must've missed your message! What Echo model do you own and have you tried the discovery with the app or by voice? I can try and see if I can reproduce the issue tomorrow :)

@mano1979
Copy link
Author

I have 4 echo dot 2's. I tried discovery by voice as well as through the app. It allways shows up as philips device.

I tried downgrading the esp8266 package to 2.4.0, but that didn't make a difference either. Also tried the espalexa library version 2.3.3. With this it will only return ON, and won't switch off.

Thank you for looking into it.

@Aircoookie
Copy link
Owner

Got it. It's likely that you are experiencing #6. You can try to write #define ESPALEXA_ASYNC before #include <Espalexa.h>, that will most likely fix it! If on ESP8266, you can alternatively downgrade all the way to core 2.3.0, that will fix it as well (you wrote both about ESP8266 and ESP32, so I'm assuming you tried both)

@mano1979
Copy link
Author

I tried to add the #define etc. to the sketch but then it will not compile for esp8266 (haven't tried yet for esp32)

I will now try to downgrade the esp8266 core to 2.3.0

@mano1979
Copy link
Author

YES!!!! Diwngrading to core 2.3.0 worked. Thank you for your help.

Do you have any insight on "if" and "when" this will work with the 2.5.0 core?

@Aircoookie
Copy link
Owner

Glad that it's working now! If the #define doesn't compile, you probably need to download the ESPAsyncTCP and EspAsyncWebserver libraries. Sorry, forgot to mention that. Newer cores than 2.3.0 don't work becauses Echo Dots (2nd gen) send the wrong content type in their requests. They either work with the async server as described above or once Amazon decides to fix the bug on the Echo side (they already did for Dot Gen3 and big Echos, just gen 2 dots are still problematic).

@mano1979
Copy link
Author

Ah, i see. Weird that they only fixed it for the dot 3 and not the 2.
Anyway, it's working now. Just updated the esp dimmer and hoping to update all of the esp RGB controllers soon.

I think this issue can be closed. Thanks again!

@mano1979
Copy link
Author

Do you happen to have a link to the correct versions of the ESPAsyncTCP and EspAsyncWebserver libraries, aswell as the AsyncTCP for esp32? I tried a couple of versions but I keep getting error messages.
I'm trying to combine the WifiManager library with ESPAlexa in a sketch but wifimanager does not work on esp core 2.3.0 so I need the async libs to work.

@Aircoookie
Copy link
Owner

WiFi Manager works with the standard Esp8266Webserver, and unfortunately is incompatible with the async server (although it should be compatible with core 2.3.0). You could also try using this async version of WiFiManager instead, although I haven't tested it myself: https://github.com/alanswx/ESPAsyncWiFiManager

@mano1979
Copy link
Author

Aaaah, thank you, i will try that.
I will let you know if it works.

@mano1979
Copy link
Author

Still getting errors when I compile the async wifimanager example sketch. See below:

`C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:259:32: error: field 'call' has incomplete type 'tcpip_api_call_data'

 struct tcpip_api_call_data call;

                            ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:259:12: note: forward declaration of 'struct tcpip_api_call_data'

 struct tcpip_api_call_data call;

        ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp: In function 'esp_err_t _tcp_output(tcp_pcb*)':

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:295:70: error: invalid conversion from 'err_t ()(tcpip_api_call_data) {aka signed char ()(tcpip_api_call_data)}' to 'tcpip_api_call_fn {aka signed char ()(tcpip_api_call)}' [-fpermissive]

 tcpip_api_call(_tcp_output_api, (struct tcpip_api_call_data*)&msg);

                                                                  ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:295:70: error: cannot convert 'tcpip_api_call_data*' to 'tcpip_api_call*' for argument '2' to 'err_t tcpip_api_call(tcpip_api_call_fn, tcpip_api_call*)'

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:259:12: note: class type 'tcpip_api_call_data' is incomplete

 struct tcpip_api_call_data call;

        ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp: In function 'esp_err_t _tcp_write(tcp_pcb*, const char*, size_t, uint8_t)':

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:311:69: error: invalid conversion from 'err_t ()(tcpip_api_call_data) {aka signed char ()(tcpip_api_call_data)}' to 'tcpip_api_call_fn {aka signed char ()(tcpip_api_call)}' [-fpermissive]

 tcpip_api_call(_tcp_write_api, (struct tcpip_api_call_data*)&msg);

                                                                 ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:311:69: error: cannot convert 'tcpip_api_call_data*' to 'tcpip_api_call*' for argument '2' to 'err_t tcpip_api_call(tcpip_api_call_fn, tcpip_api_call*)'

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:259:12: note: class type 'tcpip_api_call_data' is incomplete

 struct tcpip_api_call_data call;

        ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp: In function 'esp_err_t _tcp_recved(tcp_pcb*, size_t)':

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:326:70: error: invalid conversion from 'err_t ()(tcpip_api_call_data) {aka signed char ()(tcpip_api_call_data)}' to 'tcpip_api_call_fn {aka signed char ()(tcpip_api_call)}' [-fpermissive]

 tcpip_api_call(_tcp_recved_api, (struct tcpip_api_call_data*)&msg);

                                                                  ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:326:70: error: cannot convert 'tcpip_api_call_data*' to 'tcpip_api_call*' for argument '2' to 'err_t tcpip_api_call(tcpip_api_call_fn, tcpip_api_call*)'

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:259:12: note: class type 'tcpip_api_call_data' is incomplete

 struct tcpip_api_call_data call;

        ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp: In function 'esp_err_t _tcp_connect(tcp_pcb*, ip_addr_t*, uint16_t, tcp_connected_fn)':

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:342:71: error: invalid conversion from 'err_t ()(tcpip_api_call_data) {aka signed char ()(tcpip_api_call_data)}' to 'tcpip_api_call_fn {aka signed char ()(tcpip_api_call)}' [-fpermissive]

 tcpip_api_call(_tcp_connect_api, (struct tcpip_api_call_data*)&msg);

                                                                   ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:342:71: error: cannot convert 'tcpip_api_call_data*' to 'tcpip_api_call*' for argument '2' to 'err_t tcpip_api_call(tcpip_api_call_fn, tcpip_api_call*)'

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:259:12: note: class type 'tcpip_api_call_data' is incomplete

 struct tcpip_api_call_data call;

        ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp: In function 'esp_err_t _tcp_close(tcp_pcb*)':

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:356:69: error: invalid conversion from 'err_t ()(tcpip_api_call_data) {aka signed char ()(tcpip_api_call_data)}' to 'tcpip_api_call_fn {aka signed char ()(tcpip_api_call)}' [-fpermissive]

 tcpip_api_call(_tcp_close_api, (struct tcpip_api_call_data*)&msg);

                                                                 ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:356:69: error: cannot convert 'tcpip_api_call_data*' to 'tcpip_api_call*' for argument '2' to 'err_t tcpip_api_call(tcpip_api_call_fn, tcpip_api_call*)'

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:259:12: note: class type 'tcpip_api_call_data' is incomplete

 struct tcpip_api_call_data call;

        ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp: In function 'esp_err_t _tcp_abort(tcp_pcb*)':

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:371:69: error: invalid conversion from 'err_t ()(tcpip_api_call_data) {aka signed char ()(tcpip_api_call_data)}' to 'tcpip_api_call_fn {aka signed char ()(tcpip_api_call)}' [-fpermissive]

 tcpip_api_call(_tcp_abort_api, (struct tcpip_api_call_data*)&msg);

                                                                 ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:371:69: error: cannot convert 'tcpip_api_call_data*' to 'tcpip_api_call*' for argument '2' to 'err_t tcpip_api_call(tcpip_api_call_fn, tcpip_api_call*)'

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:259:12: note: class type 'tcpip_api_call_data' is incomplete

 struct tcpip_api_call_data call;

        ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp: In function 'esp_err_t _tcp_bind(tcp_pcb*, ip_addr_t*, uint16_t)':

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:386:68: error: invalid conversion from 'err_t ()(tcpip_api_call_data) {aka signed char ()(tcpip_api_call_data)}' to 'tcpip_api_call_fn {aka signed char ()(tcpip_api_call)}' [-fpermissive]

 tcpip_api_call(_tcp_bind_api, (struct tcpip_api_call_data*)&msg);

                                                                ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:386:68: error: cannot convert 'tcpip_api_call_data*' to 'tcpip_api_call*' for argument '2' to 'err_t tcpip_api_call(tcpip_api_call_fn, tcpip_api_call*)'

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:259:12: note: class type 'tcpip_api_call_data' is incomplete

 struct tcpip_api_call_data call;

        ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp: In function 'tcp_pcb* _tcp_listen_with_backlog(tcp_pcb*, uint8_t)':

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:401:70: error: invalid conversion from 'err_t ()(tcpip_api_call_data) {aka signed char ()(tcpip_api_call_data)}' to 'tcpip_api_call_fn {aka signed char ()(tcpip_api_call)}' [-fpermissive]

 tcpip_api_call(_tcp_listen_api, (struct tcpip_api_call_data*)&msg);

                                                                  ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:401:70: error: cannot convert 'tcpip_api_call_data*' to 'tcpip_api_call*' for argument '2' to 'err_t tcpip_api_call(tcpip_api_call_fn, tcpip_api_call*)'

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:259:12: note: class type 'tcpip_api_call_data' is incomplete

 struct tcpip_api_call_data call;

        ^

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp: In member function 'void AsyncClient::_dns_found(ip_addr*)':

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:643:33: error: invalid use of incomplete type 'struct ip_addr'

     connect(IPAddress(ipaddr->u_addr.ip4.addr), _connect_port);

                             ^

In file included from C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.cpp:24:0:

C:\Users\Mano\Documents\Arduino\libraries\AsyncTCP-master\src\AsyncTCP.h:46:8: note: forward declaration of 'struct ip_addr'

struct ip_addr;

    ^

Multiple libraries were found for "WiFi.h"
Used: C:\Users\Mano\Documents\ArduinoData\packages\esp32\hardware\esp32\1.0.0\libraries\WiFi
Not used: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.21.0_x86__mdqgnx93n4wtt\libraries\WiFi
exit status 1
Error compiling for board ESP32 Dev Module.`

@Aircoookie
Copy link
Owner

Your compilation was for ESP32. The Wifi manager I linked only seems to be compatible with ESP8266 at the moment... does it work for that?

@mano1979
Copy link
Author

oh ok, let me check.

@mano1979
Copy link
Author

I got it to work! Thanks for your help.

@Aircoookie
Copy link
Owner

Awesome, good work! Closing, feel free to reply if you have any more questions :)

@mano1979
Copy link
Author

mano1979 commented Mar 24, 2019

Unrelated to the library itself, but one more question:

How do I mix the brightness with the color values? I have a RGB ledstrip connected and all colors work. But how do I correctly subtract the brightness value from the rgb values?

I tried to do it like this: red - (255-brightness)

but then, when I lower the brightness, some values (depending on the set color) will drop below 0 and I get -128 for example, wich is messing up the colors.

so then I tried to stop the values from going lower than 0, but then the color also changes when one or more colors go below 0.

here is the section of my sketch where I did all this:

void colorLightChanged(uint8_t brightness, uint32_t rgb) {
  //do what you need to do here, for example control RGB LED strip
  Serial.print("Brightness: ");
  Serial.print(brightness);
  //Serial.print(", Red: ");
  //Serial.print((rgb >> 16) & 0xFF); //get red component
  targetColor[0]=((rgb >> 16) & 0xFF);
  //Serial.print(", Green: ");
  //Serial.print(((rgb >> 8) & 0xFF)); //get green
  targetColor[1]=((rgb >> 8) & 0xFF);
  //Serial.print(", Blue: ");
  //Serial.println(rgb & 0xFF); //get blue
  targetColor[2]=(rgb & 0xFF);
  
  targetColor[0]=(targetColor[0]*4)-(1023-(brightness*4));
  targetColor[1]=(targetColor[1]*4)-(1023-(brightness*4));
  targetColor[2]=(targetColor[2]*4)-(1023-(brightness*4));

  if(targetColor[0]<0){
    targetColor[0]=0;
  }
  if(targetColor[1]<0){
    targetColor[1]=0;
  }
  if(targetColor[2]<0){
    targetColor[2]=0;
  }

  Serial.print(", Red: ");
  Serial.print(targetColor[0]);
  Serial.print(", Green: ");
  Serial.print(targetColor[1]);
  Serial.print(", Blue: ");
  Serial.println(targetColor[2]);
  
  adjustColor();

@Aircoookie
Copy link
Owner

I'd recommend you just use a multiplication/division formula here. Try something like:

targetColor[0] = ((uint32_t)brightness) * ((uint32_t)targetColor[0]) /255;

Should do exactly what you need :)

@mano1979
Copy link
Author

Wonderfull! Thank you.

@mano1979
Copy link
Author

mano1979 commented Mar 26, 2019

In the former firmware for my ledstrip controller I had a fade-over function to led the color change graduatly instead of instant. I implemented this function in my current sketch, but somehow the color changes instantly whatever I try. all values go through this function before they're written to "analogWrite" and when I disable this fade function, the ledstrip doesn't lit.

I even tried another fade function, hoping it would be something in the code that was misbehaving, but no. same results.
i'm at a loss here. do you know why these functions don't work? I pasted the code of both functions below:

function 1 (original)

void adjustColor() {
  int i;
  int changed = 0;
  do {
    changed = 0;
    for (i = 0; i < 3; i++) {
      if (currentColor[i] != targetColor[i]) {
        int dir = currentColor[i] > targetColor[i] ? -1 : +1;
        currentColor[i] += dir;
        analogWrite(colorPin[i], currentColor[i]);    
        changed = 1;
      }
      delay(1);
    }
  } while(changed != 0);
}

function 2

int r = 0;
int g = 0;
int b = 0;

void adjustColor(int red, int green, int blue) {
  while ( r != red || g != green || b != blue ) {
    if ( r < red ) r += 1;
    if ( r > red ) r -= 1;

    if ( g < green ) g += 1;
    if ( g > green ) g -= 1;

    if ( b < blue ) b += 1;
    if ( b > blue ) b -= 1;
   
    analogWrite(REDPIN, r);
    analogWrite(GREENPIN, g);
    analogWrite(BLUEPIN, b); 
    delay(100);
  }
}

@mano1979
Copy link
Author

I opened a new issue for this last question, since it has nothing to do with the original issue and other might benefit from any answers to it.

https://github.com/Aircoookie/Espalexa/issues/59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants