Bladeren bron

Add ability to configure hostname

Christopher Mullins 6 jaren geleden
bovenliggende
commit
a993ce74e1
5 gewijzigde bestanden met toevoegingen van 15 en 3 verwijderingen
  1. 2 2
      dist/index.html.gz.h
  2. 2 0
      lib/Settings/Settings.cpp
  3. 3 1
      lib/Settings/Settings.h
  4. 2 0
      src/main.cpp
  5. 6 0
      web/src/js/script.js

File diff suppressed because it is too large
+ 2 - 2
dist/index.html.gz.h


+ 2 - 0
lib/Settings/Settings.cpp

@@ -106,6 +106,7 @@ void Settings::patch(JsonObject& parsedSettings) {
     this->setIfPresent(parsedSettings, "packet_repeat_minimum", packetRepeatMinimum);
     this->setIfPresent(parsedSettings, "enable_automatic_mode_switching", enableAutomaticModeSwitching);
     this->setIfPresent(parsedSettings, "led_mode_packet_count", ledModePacketCount);
+    this->setIfPresent(parsedSettings, "hostname", hostname);
 
     if (parsedSettings.containsKey("led_mode_wifi_config")) {
       this->ledModeWifiConfig = LEDStatus::stringToLEDMode(parsedSettings["led_mode_wifi_config"]);
@@ -205,6 +206,7 @@ void Settings::serialize(Stream& stream, const bool prettyPrint) {
   root["led_mode_operating"] = LEDStatus::LEDModeToString(this->ledModeOperating);
   root["led_mode_packet"] = LEDStatus::LEDModeToString(this->ledModePacket);
   root["led_mode_packet_count"] = this->ledModePacketCount;
+  root["hostname"] = this->hostname;
 
   if (this->deviceIds) {
     JsonArray& arr = jsonBuffer.createArray();

+ 3 - 1
lib/Settings/Settings.h

@@ -98,7 +98,8 @@ public:
     ledModeWifiFailed(LEDStatus::LEDMode::On),
     ledModeOperating(LEDStatus::LEDMode::SlowBlip),
     ledModePacket(LEDStatus::LEDMode::Flicker),
-    ledModePacketCount(3)
+    ledModePacketCount(3),
+    hostname("milight-hub")
   {
     if (groupStateFields == NULL) {
       numGroupStateFields = size(DEFAULT_GROUP_STATE_FIELDS);
@@ -167,6 +168,7 @@ public:
   LEDStatus::LEDMode ledModeOperating;
   LEDStatus::LEDMode ledModePacket;
   size_t ledModePacketCount;
+  String hostname;
 
 
 protected:

+ 2 - 0
src/main.cpp

@@ -246,6 +246,8 @@ void applySettings() {
     ledStatus->changePin(settings.ledPin);
     ledStatus->continuous(settings.ledModeOperating);
   }
+
+  WiFi.hostname(settings.hostname);
 }
 
 /**

+ 6 - 0
web/src/js/script.js

@@ -35,6 +35,12 @@ var UI_FIELDS = [ {
     type: "string",
     tab: "tab-wifi"
   }, {
+    tag: "hostname",
+    friendly: "Hostname",
+    help: "Self-reported hostname to send along with DCHP request",
+    type: "string",
+    tab: "tab-wifi"
+  }, {
     tag: "ce_pin",
     friendly: "CE / PKT pin",
     help: "Pin on ESP8266 used for 'CE' (for NRF24L01 interface) or 'PKT' (for 'PL1167/LT8900' interface)",