From b1ed8f8e0dde45dbf4329fe68a7ce5835b2ffa35 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Fri, 23 Apr 2021 15:21:16 +0200 Subject: [PATCH] Fix Hue for ESP32 --- tasmota/xdrv_20_hue.ino | 5 ++++- tasmota/xdrv_23_zigbee_3_hue.ino | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tasmota/xdrv_20_hue.ino b/tasmota/xdrv_20_hue.ino index c93ccbb75..4b742bf65 100644 --- a/tasmota/xdrv_20_hue.ino +++ b/tasmota/xdrv_20_hue.ino @@ -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 { diff --git a/tasmota/xdrv_23_zigbee_3_hue.ino b/tasmota/xdrv_23_zigbee_3_hue.ino index 9204285ae..d6347b9b4 100644 --- a/tasmota/xdrv_23_zigbee_3_hue.ino +++ b/tasmota/xdrv_23_zigbee_3_hue.ino @@ -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")];