mirror of
https://github.com/anklimov/lighthub
synced 2026-09-13 05:34:17 +00:00
ESPx evolution (interim) - MDNS
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
# - udp errors
|
||||
-DOTA
|
||||
-DARDUINO_OTA_MDNS_DISABLE
|
||||
#-DMDNS_ENABLE
|
||||
-DMDNS_ENABLE
|
||||
#- ArduinoMDNS didnt working
|
||||
|
||||
-DMCP23017
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
-DW5500_CS_PIN=15
|
||||
#-DPID_DISABLE
|
||||
-DARDUINO_OTA_MDNS_DISABLE
|
||||
##-DMDNS_ENABLE
|
||||
-DMDNS_ENABLE
|
||||
-DWM_MDNS
|
||||
-DMCP23017
|
||||
|
||||
-DFS_STORAGE
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+6372
-6196
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+6534
-6359
File diff suppressed because it is too large
Load Diff
+31
-23
@@ -71,10 +71,8 @@ EthernetClient ethClient;
|
||||
#ifdef MDNS_ENABLE
|
||||
#ifndef WIFI_ENABLE
|
||||
EthernetUDP mdnsUDP;
|
||||
#else
|
||||
WiFiUDP mdnsUDP;
|
||||
MDNS mdns(mdnsUDP);
|
||||
#endif
|
||||
MDNS mdns(mdnsUDP);
|
||||
#endif
|
||||
|
||||
StatusLED statusLED(ledRED);
|
||||
@@ -526,6 +524,18 @@ lan_status lanLoop() {
|
||||
infoSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl;
|
||||
wifiInitialized = true;
|
||||
lanStatus = HAVE_IP_ADDRESS;
|
||||
|
||||
#ifdef MDNS_ENABLE
|
||||
|
||||
char mdnsName[32] = "LightHub";
|
||||
SetBytes(sysConf.mac+4,2,mdnsName+8);
|
||||
|
||||
if (!MDNS.begin(mdnsName))
|
||||
errorSerial<<("Error setting up MDNS responder!")<<endl;
|
||||
else infoSerial<<("mDNS responder started")<<endl;
|
||||
MDNS.addService("http", "tcp", OTA_PORT);
|
||||
|
||||
#endif
|
||||
}
|
||||
else
|
||||
// if (millis()>WiFiAwaitingTime)
|
||||
@@ -828,12 +838,8 @@ void ip_ready_config_loaded_connecting_to_broker() {
|
||||
deviceName = getStringFromConfig(mqttArr, 0);
|
||||
infoSerial<<F("Device Name:")<<deviceName<<endl;
|
||||
|
||||
// #ifdef OTA
|
||||
// ArduinoOTA.setDeviceName(deviceName);
|
||||
// #endif
|
||||
|
||||
#ifdef MDNS_ENABLE
|
||||
mdns.setName(deviceName);
|
||||
#if defined (MDNS_ENABLE) && ! defined (WIFI_ENABLE)
|
||||
mdns.setName(deviceName);
|
||||
#endif
|
||||
|
||||
//debugSerial<<F("N:")<<n<<endl;
|
||||
@@ -950,6 +956,7 @@ void onInitialStateInitLAN() {
|
||||
lanStatus = AWAITING_ADDRESS;
|
||||
WiFiAwaitingTime = millis();// + 60000L;
|
||||
return;
|
||||
|
||||
/*
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
infoSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl;
|
||||
@@ -1015,22 +1022,19 @@ if (WiFi.status() == WL_CONNECTED) {
|
||||
}
|
||||
}//DHCP
|
||||
|
||||
#ifdef MDNS_ENABLE
|
||||
#ifndef OTA_PORT
|
||||
#define OTA_PORT 65280
|
||||
#ifdef MDNS_ENABLE
|
||||
char mdnsName[32] = "LightHub";
|
||||
SetBytes(sysConf.mac+4,2,mdnsName+8);
|
||||
|
||||
mdns.begin(Ethernet.localIP(), mdnsName);
|
||||
char txtRecord[32] = "\x10mac=";
|
||||
SetBytes(sysConf.mac,6,txtRecord+5);
|
||||
|
||||
strncat(mdnsName,"._http",sizeof(mdnsName));
|
||||
mdns.addServiceRecord(mdnsName, OTA_PORT, MDNSServiceTCP, txtRecord);
|
||||
#endif
|
||||
|
||||
mdns.begin(Ethernet.localIP(), "lighthub");
|
||||
|
||||
char txtRecord[32] = "\x10mac=";
|
||||
SetBytes(sysConf.mac,6,txtRecord+5);
|
||||
char mdnsName[32] = "LightHub";
|
||||
SetBytes(sysConf.mac+4,2,mdnsName+8);
|
||||
strncat(mdnsName,"._http",sizeof(mdnsName));
|
||||
mdns.addServiceRecord(mdnsName, OTA_PORT, MDNSServiceTCP, txtRecord);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif //Ethernet
|
||||
}
|
||||
|
||||
|
||||
@@ -2133,8 +2137,10 @@ void loop_main() {
|
||||
if (artnet) artnet->read(); ///hung if network not initialized
|
||||
#endif
|
||||
#ifdef MDNS_ENABLE
|
||||
#ifndef WIFI_ENABLE
|
||||
yield();
|
||||
mdns.run();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2214,7 +2220,9 @@ void modbusIdle(void) {
|
||||
ArduinoOTA.poll();
|
||||
#endif
|
||||
#ifdef MDNS_ENABLE
|
||||
#ifndef WIFI_ENABLE
|
||||
mdns.run();
|
||||
#endif
|
||||
#endif
|
||||
} //End network runners
|
||||
|
||||
|
||||
+5
-1
@@ -152,12 +152,14 @@ extern Streamlog errorSerial;
|
||||
#include <WiFiClientSecure.h>
|
||||
#include <WiFiManager.h>
|
||||
#include <WebServer.h>
|
||||
#include <ESPmDNS.h>
|
||||
#else
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <WiFiManager.h>
|
||||
#include <DNSServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#endif
|
||||
#define Ethernet WiFi
|
||||
#else //Wired connection
|
||||
@@ -182,7 +184,9 @@ extern Streamlog errorSerial;
|
||||
#endif
|
||||
|
||||
#ifdef MDNS_ENABLE
|
||||
#include <ArduinoMDNS.h>
|
||||
#ifndef WIFI_ENABLE
|
||||
#include <ArduinoMDNS.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
@@ -15,6 +15,12 @@
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef MDNS_ENABLE
|
||||
#ifndef OTA_PORT
|
||||
#define OTA_PORT 65280
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Configuration of drivers enabled
|
||||
#define SYSLOG_LOCAL_SOCKET 514
|
||||
|
||||
|
||||
+19
-12
@@ -149,8 +149,9 @@ lib_ignore =
|
||||
HttpClient
|
||||
ArduinoHttpClient
|
||||
lib_deps =
|
||||
https://github.com/ebenolson/WIFIMANAGER-ESP32.git
|
||||
https://github.com/zhouhan0126/WebServer-esp32.git
|
||||
;https://github.com/ebenolson/WIFIMANAGER-ESP32.git
|
||||
;https://github.com/zhouhan0126/WebServer-esp32.git
|
||||
https://github.com/tzapu/WiFiManager
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
@@ -175,7 +176,7 @@ lib_deps =
|
||||
Adafruit BusIO
|
||||
https://github.com/arcao/Syslog.git
|
||||
br3ttb/PID@^1.2.1
|
||||
ArduinoMDNS
|
||||
;ArduinoMDNS
|
||||
https://github.com/khoih-prog/TimerInterrupt_Generic.git
|
||||
|
||||
monitor_speed = 115200
|
||||
@@ -216,8 +217,9 @@ lib_ignore =
|
||||
ArduinoHttpClient
|
||||
M5Stack
|
||||
lib_deps =
|
||||
https://github.com/ebenolson/WIFIMANAGER-ESP32.git
|
||||
https://github.com/zhouhan0126/WebServer-esp32.git
|
||||
;https://github.com/ebenolson/WIFIMANAGER-ESP32.git
|
||||
https://github.com/tzapu/WiFiManager
|
||||
;https://github.com/zhouhan0126/WebServer-esp32.git
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/knolleary/pubsubclient.git
|
||||
@@ -240,7 +242,8 @@ lib_deps =
|
||||
Adafruit BusIO
|
||||
https://github.com/arcao/Syslog.git
|
||||
br3ttb/PID@^1.2.1
|
||||
ArduinoMDNS
|
||||
;ArduinoMDNS
|
||||
;ESPmDNS
|
||||
https://github.com/khoih-prog/TimerInterrupt_Generic.git
|
||||
|
||||
monitor_speed = 115200
|
||||
@@ -482,6 +485,8 @@ framework = arduino
|
||||
board = nodemcuv2
|
||||
monitor_baud = 115200
|
||||
upload_protocol = esptool
|
||||
build_type = debug
|
||||
monitor_filters = esp8266_exception_decoder
|
||||
|
||||
;upload_protocol = espota
|
||||
;upload_port = Lighthub.local
|
||||
@@ -499,11 +504,11 @@ lib_ignore =
|
||||
DueFlashStorage
|
||||
SD
|
||||
SdFat
|
||||
httpClient
|
||||
HTTPClient
|
||||
HttpClient_ID66
|
||||
HttpClient
|
||||
ArduinoHttpClient
|
||||
;httpClient
|
||||
;HTTPClient
|
||||
;HttpClient_ID66
|
||||
;HttpClient
|
||||
;ArduinoHttpClient
|
||||
Ethernet3
|
||||
Ethernet2
|
||||
Ethernet5100
|
||||
@@ -519,7 +524,7 @@ lib_deps =
|
||||
;COMMENT/UNCOMMENT next line for software 1-wire driver on/off
|
||||
;https://github.com/anklimov/DS2482_OneWire
|
||||
https://github.com/anklimov/ESP-Dmx
|
||||
ESP8266HTTPClient
|
||||
;ESP8266HTTPClient
|
||||
https://github.com/anklimov/aJson
|
||||
https://github.com/anklimov/CmdArduino
|
||||
https://github.com/anklimov/ModbusMaster
|
||||
@@ -541,6 +546,8 @@ lib_deps =
|
||||
Adafruit BusIO
|
||||
br3ttb/PID@^1.2.1
|
||||
;ArduinoMDNS
|
||||
;MDNS
|
||||
ESP8266mDNS
|
||||
monitor_speed = 115200
|
||||
|
||||
[env:mega2560-5100]
|
||||
|
||||
Reference in New Issue
Block a user