Update README.MD
This commit is contained in:
parent
9ed0e801b7
commit
b4f5d4cccc
|
@ -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).
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
84
src/main.cpp
84
src/main.cpp
|
@ -1,7 +1,6 @@
|
|||
#ifndef UNIT_TEST
|
||||
|
||||
#include <SPI.h>
|
||||
#include <WiFiManager.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <stdlib.h>
|
||||
#include <FS.h>
|
||||
|
@ -16,8 +15,6 @@
|
|||
#include <MiLightRemoteType.h>
|
||||
#include <Settings.h>
|
||||
#include <MiLightUdpServer.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <ESP8266SSDP.h>
|
||||
#include <MqttClient.h>
|
||||
#include <RGBConverter.h>
|
||||
#include <MiLightDiscoveryServer.h>
|
||||
|
@ -31,12 +28,6 @@
|
|||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue