From 5895e04366023bc674bf6e90d241330834ed951c Mon Sep 17 00:00:00 2001 From: Carsten Schmiemann Date: Sat, 16 Jan 2021 03:02:47 +0100 Subject: [PATCH] Build Success, Testing and Optimization needed --- include/README | 0 lib/MQTT/HomeAssistantDiscoveryClient.cpp | 6 +++--- lib/MQTT/MqttClient.cpp | 2 +- lib/Udp/MiLightDiscoveryServer.cpp | 4 ++-- lib/Udp/MiLightUdpServer.cpp | 2 +- lib/Udp/V6MiLightUdpServer.cpp | 2 +- lib/WebServer/MiLightHttpServer.cpp | 2 +- src/main.cpp | 8 ++------ 8 files changed, 11 insertions(+), 15 deletions(-) create mode 100644 include/README diff --git a/include/README b/include/README new file mode 100644 index 0000000..e69de29 diff --git a/lib/MQTT/HomeAssistantDiscoveryClient.cpp b/lib/MQTT/HomeAssistantDiscoveryClient.cpp index 5687a18..4e0de0b 100644 --- a/lib/MQTT/HomeAssistantDiscoveryClient.cpp +++ b/lib/MQTT/HomeAssistantDiscoveryClient.cpp @@ -37,7 +37,7 @@ void HomeAssistantDiscoveryClient::addConfig(const char* alias, const BulbId& bu DynamicJsonDocument config(1024); char uniqidBuffer[30]; - sprintf_P(uniqidBuffer, PSTR("%X-%s"), ESP.getChipId(), alias); + //sprintf_P(uniqidBuffer, PSTR("%X-%s"), ESP.getChipId(), alias); config[F("schema")] = F("json"); config[F("name")] = alias; @@ -50,7 +50,7 @@ void HomeAssistantDiscoveryClient::addConfig(const char* alias, const BulbId& bu deviceMetadata[F("sw_version")] = QUOTE(MILIGHT_HUB_VERSION); JsonArray identifiers = deviceMetadata.createNestedArray(F("identifiers")); - identifiers.add(ESP.getChipId()); + //identifiers.add(ESP.getChipId()); bulbId.serialize(identifiers); // HomeAssistant only supports simple client availability @@ -142,7 +142,7 @@ String HomeAssistantDiscoveryClient::buildTopic(const BulbId& bulbId) { topic += "light/"; // Use a static ID that doesn't depend on configuration. - topic += "milight_hub_" + String(ESP.getChipId()); + topic += "milight_hub_"; //+ String(ESP.getChipId()); // make the object ID based on the actual parameters rather than the alias. topic += "/"; diff --git a/lib/MQTT/MqttClient.cpp b/lib/MQTT/MqttClient.cpp index 095d1eb..f9b2440 100644 --- a/lib/MQTT/MqttClient.cpp +++ b/lib/MQTT/MqttClient.cpp @@ -56,7 +56,7 @@ void MqttClient::begin() { bool MqttClient::connect() { char nameBuffer[30]; - sprintf_P(nameBuffer, PSTR("milight-hub-%u"), ESP.getChipId()); + sprintf_P(nameBuffer, "milight-hub-esp32"); //ESP.getChipId() #ifdef MQTT_DEBUG Serial.println(F("MqttClient - connecting using name")); diff --git a/lib/Udp/MiLightDiscoveryServer.cpp b/lib/Udp/MiLightDiscoveryServer.cpp index 3e501b8..d5ac3af 100644 --- a/lib/Udp/MiLightDiscoveryServer.cpp +++ b/lib/Udp/MiLightDiscoveryServer.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include const char V3_SEARCH_STRING[] = "Link_Wi-Fi"; const char V6_SEARCH_STRING[] = "HF-A11ASSISTHREAD"; @@ -85,6 +85,6 @@ void MiLightDiscoveryServer::sendResponse(char* buffer) { #endif socket.beginPacket(socket.remoteIP(), socket.remotePort()); - socket.write(buffer); + socket.write(int(buffer)); socket.endPacket(); } diff --git a/lib/Udp/MiLightUdpServer.cpp b/lib/Udp/MiLightUdpServer.cpp index 71fa931..0824c20 100644 --- a/lib/Udp/MiLightUdpServer.cpp +++ b/lib/Udp/MiLightUdpServer.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include MiLightUdpServer::MiLightUdpServer(MiLightClient*& client, uint16_t port, uint16_t deviceId) : client(client), diff --git a/lib/Udp/V6MiLightUdpServer.cpp b/lib/Udp/V6MiLightUdpServer.cpp index a1b93fe..2f23924 100644 --- a/lib/Udp/V6MiLightUdpServer.cpp +++ b/lib/Udp/V6MiLightUdpServer.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/lib/WebServer/MiLightHttpServer.cpp b/lib/WebServer/MiLightHttpServer.cpp index 1ca7031..1c57454 100644 --- a/lib/WebServer/MiLightHttpServer.cpp +++ b/lib/WebServer/MiLightHttpServer.cpp @@ -449,7 +449,7 @@ void MiLightHttpServer::handleUpdateGroupAlias(RequestContext& request) { if (config == NULL) { char buffer[40]; - sprintf_P(buffer, PSTR("Unknown device type: %s"), bulbId.deviceType); + sprintf_P(buffer, PSTR("Unknown device type: %u"), bulbId.deviceType); request.response.setCode(400); request.response.json["error"] = buffer; return; diff --git a/src/main.cpp b/src/main.cpp index b66873e..7c0e9ba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,6 +7,7 @@ #include #include #include "SPIFFS.h" +#include #include #include #include @@ -31,7 +32,6 @@ #include #include #include -#include #include #include @@ -454,16 +454,12 @@ void setup() { ledStatus->continuous(settings.ledModeWifiFailed); Serial.println(F("Wifi failed. Restarting in 10 seconds.\n")); */ - delay(10000); - ESP.restart(); - } - MDNS.addService("http", "tcp", 80); SSDP.setSchemaURL("description.xml"); SSDP.setHTTPPort(80); SSDP.setName("ESP8266 MiLight Gateway"); - SSDP.setSerialNumber(ESP.getChipId()); + //SSDP.setSerialNumber(ESP.getChipId()); SSDP.setURL("/"); SSDP.setDeviceType("upnp:rootdevice"); SSDP.begin();