From b4f5d4ccccac071ae0526227d4c8625ec35f7193 Mon Sep 17 00:00:00 2001 From: Carsten Schmiemann Date: Fri, 15 Jan 2021 23:53:51 +0100 Subject: [PATCH] Update README.MD --- README.md | 4 ++- platformio.ini | 5 ++- src/main.cpp | 84 ++------------------------------------------------ 3 files changed, 8 insertions(+), 85 deletions(-) diff --git a/README.md b/README.md index 5a45175..46a98bb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# esp8266_milight_hub [![Build Status](https://travis-ci.org/sidoh/esp8266_milight_hub.svg?branch=master)](https://travis-ci.org/sidoh/esp8266_milight_hub) [![License][shield-license]][info-license] +# esp32_ethernet_milight_hub + +###This is a fork of https://github.com/sidoh/esp8266_milight_hub, to use Olixmes ESP32 Ethernet based boards. This is a replacement for a Milight/LimitlessLED remote/gateway hosted on an ESP8266. Leverages [Henryk Plötz's awesome reverse-engineering work](https://hackaday.io/project/5888-reverse-engineering-the-milight-on-air-protocol). diff --git a/platformio.ini b/platformio.ini index d70b6cc..23406bb 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,12 +8,11 @@ ; Please visit documentation for the other options and examples ; https://docs.platformio.org/page/projectconf.html -[common] +[env:esp32-poe] framework = arduino platform = espressif32 board = esp32-poe -lib_deps_external = - WiFiManager=https://github.com/sidoh/WiFiManager.git#cmidgley +lib_deps = RF24@~1.3.2 ArduinoJson@~6.10.1 PubSubClient@~2.7 diff --git a/src/main.cpp b/src/main.cpp index 1c76567..8a8e792 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,6 @@ #ifndef UNIT_TEST #include -#include #include #include #include @@ -16,8 +15,6 @@ #include #include #include -#include -#include #include #include #include @@ -31,12 +28,6 @@ #include #include -WiFiManager wifiManager; -// because of callbacks, these need to be in the higher scope :( -WiFiManagerParameter* wifiStaticIP = NULL; -WiFiManagerParameter* wifiStaticIPNetmask = NULL; -WiFiManagerParameter* wifiStaticIPGateway = NULL; - static LEDStatus *ledStatus; Settings settings; @@ -275,7 +266,7 @@ void applySettings() { ledStatus->continuous(settings.ledModeOperating); } - WiFi.hostname(settings.hostname); + /*WiFi.hostname(settings.hostname); WiFiPhyMode_t wifiMode; switch (settings.wifiMode) { @@ -291,7 +282,7 @@ void applySettings() { break; } WiFi.setPhyMode(wifiMode); -} +}'*/ /** * @@ -330,86 +321,17 @@ void onGroupDeleted(const BulbId& id) { } void setup() { - Serial.begin(9600); - String ssid = "ESP" + String(ESP.getChipId()); + Serial.begin(115200); // load up our persistent settings from the file system SPIFFS.begin(); Settings::load(settings); applySettings(); - // set up the LED status for wifi configuration - ledStatus = new LEDStatus(settings.ledPin); - ledStatus->continuous(settings.ledModeWifiConfig); - // start up the wifi manager if (! MDNS.begin("milight-hub")) { Serial.println(F("Error setting up MDNS responder")); } - // tell Wifi manager to call us during the setup. Note that this "setSetupLoopCallback" is an addition - // made to Wifi manager in a private fork. As of this writing, WifiManager has a new feature coming that - // allows the "autoConnect" method to be non-blocking which can implement this same functionality. However, - // that change is only on the development branch so we are going to continue to use this fork until - // that is merged and ready. - wifiManager.setSetupLoopCallback(handleLED); - - // Allows us to have static IP config in the captive portal. Yucky pointers to pointers, just to have the settings carry through - wifiManager.setSaveConfigCallback(wifiExtraSettingsChange); - - wifiStaticIP = new WiFiManagerParameter( - "staticIP", - "Static IP (Leave blank for dhcp)", - settings.wifiStaticIP.c_str(), - MAX_IP_ADDR_LEN - ); - wifiManager.addParameter(wifiStaticIP); - - wifiStaticIPNetmask = new WiFiManagerParameter( - "netmask", - "Netmask (required if IP given)", - settings.wifiStaticIPNetmask.c_str(), - MAX_IP_ADDR_LEN - ); - wifiManager.addParameter(wifiStaticIPNetmask); - - wifiStaticIPGateway = new WiFiManagerParameter( - "gateway", - "Default Gateway (optional, only used if static IP)", - settings.wifiStaticIPGateway.c_str(), - MAX_IP_ADDR_LEN - ); - wifiManager.addParameter(wifiStaticIPGateway); - - // We have a saved static IP, let's try and use it. - if (settings.wifiStaticIP.length() > 0) { - Serial.printf_P(PSTR("We have a static IP: %s\n"), settings.wifiStaticIP.c_str()); - - IPAddress _ip, _subnet, _gw; - _ip.fromString(settings.wifiStaticIP); - _subnet.fromString(settings.wifiStaticIPNetmask); - _gw.fromString(settings.wifiStaticIPGateway); - - wifiManager.setSTAStaticIPConfig(_ip,_gw,_subnet); - } - - wifiManager.setConfigPortalTimeout(180); - - if (wifiManager.autoConnect(ssid.c_str(), "milightHub")) { - // set LED mode for successful operation - ledStatus->continuous(settings.ledModeOperating); - Serial.println(F("Wifi connected succesfully\n")); - - // if the config portal was started, make sure to turn off the config AP - WiFi.mode(WIFI_STA); - } else { - // set LED mode for Wifi failed - ledStatus->continuous(settings.ledModeWifiFailed); - Serial.println(F("Wifi failed. Restarting in 10 seconds.\n")); - - delay(10000); - ESP.restart(); - } - MDNS.addService("http", "tcp", 80);