Aircoookie / Espalexa

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

ESP32 discovery issue with color device #50

Open eos1d3 opened 5 years ago

eos1d3 commented 5 years ago

ESP32 discovery problem is still there with device supporting Color. When using example, EspalexaColor.ino, I never get color device discovered once!

The this is the log after discovery:

Connecting to WiFi
Connecting.............
Connected to xxx
IP address: 192.168.2.134
Constructing device 1
Adding device 1
Espalexa Begin...
MAXDEVICES 10
Done

And after 30 seconds or more, I saw there were more log suddenly appended to the above while I did not do anything. More similar messages will appear later.

Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: urn:schemas-upnp-org:device:InternetGatewayDevice:1
MAN: "ssdp:discover"
MX: 2

Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: urn:schemas-upnp-org:service:WANIPConnection:1
MAN: "ssdp:discover"
MX: 2

Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: urn:schemas-upnp-org:service:WANPPPConnection:1
MAN: "ssdp:discover"
MX: 2

Got UDP!
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
ST: upnp:rootdevice
MAN: "ssdp:discover"
MX: 2

Responding search req...

PS: There is no problem for ESP8266, and Alexa app still works with ESP8266 color device.

PyxelFox commented 5 years ago

The ESP logs every packet that it receives via udp broadcast. This only means that there are more devices in your network that use udp broadcasting to comunicate with each other. Alexa sends specific packets like:

M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 15
ST: urn:Belkin:device:**

or

M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 15
ST: urn:schemas-upnp-org:device:basic:1
eos1d3 commented 5 years ago

Definitely not. There is always only one device at a time. I have one ESP8266 and one ESP32. But with just one USB cable to supply the power. So I never use both of them at the same time.

The packets are likely from the testing ESP32 module. They were received but not processed properly, and were delayed for more than 30 seconds and showed up later in the log.

PyxelFox commented 5 years ago

These packets have nothing to do with the count of esp devices, it could be any device in your network, even my router is sending packets via udp broadcast: image

If you try to discover the esp do you see any packets like the ones I mentioned above?

eos1d3 commented 5 years ago

During discovering, I see nothing at all with Color Device using latest version of the library. This was the log just after discovery.

Connecting to WiFi
Connecting.............
Connected to xxx
IP address: 192.168.2.134
Constructing device 1
Adding device 1
Espalexa Begin...
MAXDEVICES 10
Done

But for non-color devices (with just on/off/dim), both ESP8266 and ESP32 can be discovered normally and all messages are there.

ps: ESP8266 works with color device. Only ESP32 can't be discovered.

Aircoookie commented 5 years ago

I'll look into this. Can you still access the /espalexa page with color example on ESP32?

eos1d3 commented 5 years ago

@Aircoookie Thanks for your reminder. So I just tested again to check /espalexa page and it is so strange that ESP32 color device can be discovered now. I did the test more than 10 times and never failed once.

Nothing has been changed except that my router has been rebooted before tests. Tested with mobile phone on 5GHz and 2.4GHz, Echo Dot Gen 3 on 5GHz. UPnP is always disabled.

But I can't tell what happened. Some days ago when I tested color device with both ESP8266 and ESP32, ESP8266 always worked and only ESP32 never worked with the same router.

I will test this for a few days to see if problem might come again. Will report later.

Thanks a lot for everyone!

Aircoookie commented 5 years ago

@eos1d3 How weird! If it were a network or Echo issue, it wouldn't be affected by whether we have a color or brightness device (the discovery process is 100% the same though)

eos1d3 commented 5 years ago

@Aircoookie Yes it is. This was what I tested color devices some days ago.

  1. Flash ESP8266 color device project, discovery, found!
  2. Flash ESP32 color device project, discovery, NOT found!
  3. repeat 1, found!
  4. repeat 2, not found again!
  5. repeat 1, found!
  6. repeat 2, not found again!
  7. stopped testing

For the first tests, all network settings and the INO files were the same. And all tests were conducted within 1 or 2 hours.

Right now, ESP32 never fails once during discovery! And I never change any code for the tests. I suspected it was WIFI 5GHz or 2.4GHz issue, so I tested both just a while ago. And I found no problem for both.

Some days ago, I do not find notifications on Alexa app any more. And Echo dot also does not have the voice announcement for new devices too. This is the only Amazon change I noticed recently.

eos1d3 commented 5 years ago

@Aircoookie Tonight I tested both ESP8266 and ESP32, with basic and color devices. None of any combinations worked! Resetting router also does not help.

After a lot of tests, I found it is Echo Dot Gen 3 issue. After powering off and on the Echo dot, discovery works again every time!

All the strange problems can be caused by Echo Dot itself. I suggest adding this information in README when people can't discover devices. This took so much time to find the problem.