ThingPulse / esp8266-weather-station-color

ESP8266 Weather Station in Color using ILI9341 TFT 240x320 display
https://thingpulse.com/product/esp8266-wifi-color-display-kit-2-4/
MIT License
569 stars 222 forks source link

WiFi will not connect for the Color model #170

Closed sonofcy closed 5 months ago

sonofcy commented 5 months ago

Use one of the two templates below and delete the rest.

8<------------------------ BUG REPORT -----------------------------------------

Expected behavior

WiFi should connect

Actual behavior

Wifi Status is WL_STATUS 7 forever

Test code

Reduce the HOSTNAME from 32 chars to at least 1 less.

// add code here
#define WIFI_HOSTNAME "ThingPulseWeatherStationColor"

Weather Station Color version

Which branch are you on? If you know the Git revision then add it here as well. I don't know

Hardware

Describe whether you run the code on the ThingPulse Weather Station Color kit or on some custom hardware. I am using the ThingPulse Weather Station Color kit

8<------------------------ END BUG REPORT -------------------------------------

8<------------------------ FEATURE REQUEST ------------------------------------

Missing feature

Justification

Tell us why you would like to see this feature added.

Workarounds

Are there any workarounds you currently have in place because the feature is missing?

8<------------------------ END FEATURE REQUEST --------------------------------

sonofcy commented 5 months ago

I have tested this fix with both the Color model, and a simple Client Sketch. It always fails when HOSTNAME is 32 chars, and works when less. I suspect that some code is adding a null terminator to turn the char array into a null terminated string and when they did that it stepped on some memory of another variable or code.

marcelstoer commented 5 months ago

Thanks. Here they state that the max be 32 chars: https://arduino-esp8266.readthedocs.io/en/3.1.2/esp8266wifi/station-class.html#hostname

sonofcy commented 5 months ago

Yes, 32 as in char[32] if it is a String 32 then you need 33 bytes. Some code somewhere is converting the variable to a string by adding a /00 to the end thus overwriting some random memory location. I have 2 different sketches, one simple one more complex and they both fail consistently with a 32 byte HOSTNAME and never fail to connect with a HOSTNAME less than 32. The bug may in fact be in library code, but the avoidance is to limit the HostName to 31 or less.

On Apr 24, 2024, at 02:01, Marcel Stör @.***> wrote:

Thanks. Here they state the max be 32 chars: https://arduino-esp8266.readthedocs.io/en/3.1.2/esp8266wifi/station-class.html#hostname

— Reply to this email directly, view it on GitHub https://github.com/ThingPulse/esp8266-weather-station-color/issues/170#issuecomment-2074106697, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK3P74HY7BJYBZ23UAUIVODY65DEHAVCNFSM6AAAAABGVYRTMWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZUGEYDMNRZG4. You are receiving this because you modified the open/close state.

sonofcy commented 5 months ago

Yes, 32 CHARS, NOT a String of 32 (33rd will be /00)

On Apr 24, 2024, at 02:01, Marcel Stör @.***> wrote:

Thanks. Here they state the max be 32 chars: https://arduino-esp8266.readthedocs.io/en/3.1.2/esp8266wifi/station-class.html#hostname

— Reply to this email directly, view it on GitHub https://github.com/ThingPulse/esp8266-weather-station-color/issues/170#issuecomment-2074106697, or unsubscribe https://github.com/notifications/unsubscribe-auth/AK3P74HY7BJYBZ23UAUIVODY65DEHAVCNFSM6AAAAABGVYRTMWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZUGEYDMNRZG4. You are receiving this because you modified the open/close state.