Merge pull request #11855 from s-hadinger/hue_fix_esp32

Fix Hue for ESP32
This commit is contained in:
Theo Arends 2021-04-23 16:20:24 +02:00 committed by GitHub
commit 0820109d5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -200,21 +200,24 @@ void HueRespondToMSearch(void)
if (PortUdp.beginPacket(udp_remote_ip, udp_remote_port)) {
UnishoxStrings msg(HUE_RESP_MSG);
char response[320];
snprintf_P(response, sizeof(response), msg[HUE_RESP_RESPONSE], WiFi.localIP().toString().c_str(), HueBridgeId().c_str());
snprintf_P(response, sizeof(response), msg[HUE_RESP_RESPONSE], NetworkAddress().toString().c_str(), HueBridgeId().c_str());
int len = strlen(response);
String uuid = HueUuid();
snprintf_P(response + len, sizeof(response) - len, msg[HUE_RESP_ST1], uuid.c_str());
PortUdp.write(response);
PortUdp.endPacket();
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response);
snprintf_P(response + len, sizeof(response) - len, msg[HUE_RESP_ST2], uuid.c_str(), uuid.c_str());
PortUdp.write(response);
PortUdp.endPacket();
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response);
snprintf_P(response + len, sizeof(response) - len, msg[HUE_RESP_ST3], uuid.c_str());
PortUdp.write(response);
PortUdp.endPacket();
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_UPNP "UDP resp=%s"), response);
snprintf_P(message, sizeof(message), PSTR(D_3_RESPONSE_PACKETS_SENT));
} else {

View File

@ -239,7 +239,12 @@ void ZigbeeHandleHue(uint16_t shortaddr, uint32_t device_id, String &response) {
if (Webserver->args()) {
response = "[";
#ifdef ESP82666 // ESP8266 memory is limited, avoid copying and modify in place
JsonParser parser((char*) Webserver->arg((Webserver->args())-1).c_str());
#else // does not work on ESP32, we need to get a fresh copy of the string
String request_arg = Webserver->arg((Webserver->args())-1);
JsonParser parser((char*) request_arg.c_str());
#endif
JsonParserObject root = parser.getRootObject();
JsonParserToken hue_on = root[PSTR("on")];