ESPx evolution (interim) - MDNS

This commit is contained in:
2021-10-20 01:27:42 +03:00
parent 4e22a8f22d
commit 8dd0b57f72
13 changed files with 12970 additions and 12593 deletions

View File

@@ -10,7 +10,7 @@
# - udp errors # - udp errors
-DOTA -DOTA
-DARDUINO_OTA_MDNS_DISABLE -DARDUINO_OTA_MDNS_DISABLE
#-DMDNS_ENABLE -DMDNS_ENABLE
#- ArduinoMDNS didnt working #- ArduinoMDNS didnt working
-DMCP23017 -DMCP23017

View File

@@ -9,7 +9,8 @@
-DW5500_CS_PIN=15 -DW5500_CS_PIN=15
#-DPID_DISABLE #-DPID_DISABLE
-DARDUINO_OTA_MDNS_DISABLE -DARDUINO_OTA_MDNS_DISABLE
##-DMDNS_ENABLE -DMDNS_ENABLE
-DWM_MDNS
-DMCP23017 -DMCP23017
-DFS_STORAGE -DFS_STORAGE

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -71,10 +71,8 @@ EthernetClient ethClient;
#ifdef MDNS_ENABLE #ifdef MDNS_ENABLE
#ifndef WIFI_ENABLE #ifndef WIFI_ENABLE
EthernetUDP mdnsUDP; EthernetUDP mdnsUDP;
#else MDNS mdns(mdnsUDP);
WiFiUDP mdnsUDP;
#endif #endif
MDNS mdns(mdnsUDP);
#endif #endif
StatusLED statusLED(ledRED); StatusLED statusLED(ledRED);
@@ -526,6 +524,18 @@ lan_status lanLoop() {
infoSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl; infoSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl;
wifiInitialized = true; wifiInitialized = true;
lanStatus = HAVE_IP_ADDRESS; 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 else
// if (millis()>WiFiAwaitingTime) // if (millis()>WiFiAwaitingTime)
@@ -828,12 +838,8 @@ void ip_ready_config_loaded_connecting_to_broker() {
deviceName = getStringFromConfig(mqttArr, 0); deviceName = getStringFromConfig(mqttArr, 0);
infoSerial<<F("Device Name:")<<deviceName<<endl; infoSerial<<F("Device Name:")<<deviceName<<endl;
// #ifdef OTA #if defined (MDNS_ENABLE) && ! defined (WIFI_ENABLE)
// ArduinoOTA.setDeviceName(deviceName); mdns.setName(deviceName);
// #endif
#ifdef MDNS_ENABLE
mdns.setName(deviceName);
#endif #endif
//debugSerial<<F("N:")<<n<<endl; //debugSerial<<F("N:")<<n<<endl;
@@ -950,6 +956,7 @@ void onInitialStateInitLAN() {
lanStatus = AWAITING_ADDRESS; lanStatus = AWAITING_ADDRESS;
WiFiAwaitingTime = millis();// + 60000L; WiFiAwaitingTime = millis();// + 60000L;
return; return;
/* /*
if (WiFi.status() == WL_CONNECTED) { if (WiFi.status() == WL_CONNECTED) {
infoSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl; infoSerial<<F("WiFi connected. IP address: ")<<WiFi.localIP()<<endl;
@@ -1015,22 +1022,19 @@ if (WiFi.status() == WL_CONNECTED) {
} }
}//DHCP }//DHCP
#ifdef MDNS_ENABLE #ifdef MDNS_ENABLE
#ifndef OTA_PORT char mdnsName[32] = "LightHub";
#define OTA_PORT 65280 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 #endif
mdns.begin(Ethernet.localIP(), "lighthub"); #endif //Ethernet
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
} }
@@ -2133,8 +2137,10 @@ void loop_main() {
if (artnet) artnet->read(); ///hung if network not initialized if (artnet) artnet->read(); ///hung if network not initialized
#endif #endif
#ifdef MDNS_ENABLE #ifdef MDNS_ENABLE
#ifndef WIFI_ENABLE
yield(); yield();
mdns.run(); mdns.run();
#endif
#endif #endif
} }
@@ -2214,7 +2220,9 @@ void modbusIdle(void) {
ArduinoOTA.poll(); ArduinoOTA.poll();
#endif #endif
#ifdef MDNS_ENABLE #ifdef MDNS_ENABLE
#ifndef WIFI_ENABLE
mdns.run(); mdns.run();
#endif
#endif #endif
} //End network runners } //End network runners

View File

@@ -152,12 +152,14 @@ extern Streamlog errorSerial;
#include <WiFiClientSecure.h> #include <WiFiClientSecure.h>
#include <WiFiManager.h> #include <WiFiManager.h>
#include <WebServer.h> #include <WebServer.h>
#include <ESPmDNS.h>
#else #else
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h> #include <ESP8266HTTPClient.h>
#include <WiFiManager.h> #include <WiFiManager.h>
#include <DNSServer.h> #include <DNSServer.h>
#include <ESP8266WebServer.h> #include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#endif #endif
#define Ethernet WiFi #define Ethernet WiFi
#else //Wired connection #else //Wired connection
@@ -182,7 +184,9 @@ extern Streamlog errorSerial;
#endif #endif
#ifdef MDNS_ENABLE #ifdef MDNS_ENABLE
#include <ArduinoMDNS.h> #ifndef WIFI_ENABLE
#include <ArduinoMDNS.h>
#endif
#endif #endif
#include "Arduino.h" #include "Arduino.h"

View File

@@ -15,6 +15,12 @@
#endif #endif
#ifdef MDNS_ENABLE
#ifndef OTA_PORT
#define OTA_PORT 65280
#endif
#endif
// Configuration of drivers enabled // Configuration of drivers enabled
#define SYSLOG_LOCAL_SOCKET 514 #define SYSLOG_LOCAL_SOCKET 514

View File

@@ -149,8 +149,9 @@ lib_ignore =
HttpClient HttpClient
ArduinoHttpClient ArduinoHttpClient
lib_deps = lib_deps =
https://github.com/ebenolson/WIFIMANAGER-ESP32.git ;https://github.com/ebenolson/WIFIMANAGER-ESP32.git
https://github.com/zhouhan0126/WebServer-esp32.git ;https://github.com/zhouhan0126/WebServer-esp32.git
https://github.com/tzapu/WiFiManager
https://github.com/anklimov/aJson https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino https://github.com/anklimov/CmdArduino
https://github.com/knolleary/pubsubclient.git https://github.com/knolleary/pubsubclient.git
@@ -175,7 +176,7 @@ lib_deps =
Adafruit BusIO Adafruit BusIO
https://github.com/arcao/Syslog.git https://github.com/arcao/Syslog.git
br3ttb/PID@^1.2.1 br3ttb/PID@^1.2.1
ArduinoMDNS ;ArduinoMDNS
https://github.com/khoih-prog/TimerInterrupt_Generic.git https://github.com/khoih-prog/TimerInterrupt_Generic.git
monitor_speed = 115200 monitor_speed = 115200
@@ -216,8 +217,9 @@ lib_ignore =
ArduinoHttpClient ArduinoHttpClient
M5Stack M5Stack
lib_deps = lib_deps =
https://github.com/ebenolson/WIFIMANAGER-ESP32.git ;https://github.com/ebenolson/WIFIMANAGER-ESP32.git
https://github.com/zhouhan0126/WebServer-esp32.git https://github.com/tzapu/WiFiManager
;https://github.com/zhouhan0126/WebServer-esp32.git
https://github.com/anklimov/aJson https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino https://github.com/anklimov/CmdArduino
https://github.com/knolleary/pubsubclient.git https://github.com/knolleary/pubsubclient.git
@@ -240,7 +242,8 @@ lib_deps =
Adafruit BusIO Adafruit BusIO
https://github.com/arcao/Syslog.git https://github.com/arcao/Syslog.git
br3ttb/PID@^1.2.1 br3ttb/PID@^1.2.1
ArduinoMDNS ;ArduinoMDNS
;ESPmDNS
https://github.com/khoih-prog/TimerInterrupt_Generic.git https://github.com/khoih-prog/TimerInterrupt_Generic.git
monitor_speed = 115200 monitor_speed = 115200
@@ -482,6 +485,8 @@ framework = arduino
board = nodemcuv2 board = nodemcuv2
monitor_baud = 115200 monitor_baud = 115200
upload_protocol = esptool upload_protocol = esptool
build_type = debug
monitor_filters = esp8266_exception_decoder
;upload_protocol = espota ;upload_protocol = espota
;upload_port = Lighthub.local ;upload_port = Lighthub.local
@@ -499,11 +504,11 @@ lib_ignore =
DueFlashStorage DueFlashStorage
SD SD
SdFat SdFat
httpClient ;httpClient
HTTPClient ;HTTPClient
HttpClient_ID66 ;HttpClient_ID66
HttpClient ;HttpClient
ArduinoHttpClient ;ArduinoHttpClient
Ethernet3 Ethernet3
Ethernet2 Ethernet2
Ethernet5100 Ethernet5100
@@ -519,7 +524,7 @@ lib_deps =
;COMMENT/UNCOMMENT next line for software 1-wire driver on/off ;COMMENT/UNCOMMENT next line for software 1-wire driver on/off
;https://github.com/anklimov/DS2482_OneWire ;https://github.com/anklimov/DS2482_OneWire
https://github.com/anklimov/ESP-Dmx https://github.com/anklimov/ESP-Dmx
ESP8266HTTPClient ;ESP8266HTTPClient
https://github.com/anklimov/aJson https://github.com/anklimov/aJson
https://github.com/anklimov/CmdArduino https://github.com/anklimov/CmdArduino
https://github.com/anklimov/ModbusMaster https://github.com/anklimov/ModbusMaster
@@ -541,6 +546,8 @@ lib_deps =
Adafruit BusIO Adafruit BusIO
br3ttb/PID@^1.2.1 br3ttb/PID@^1.2.1
;ArduinoMDNS ;ArduinoMDNS
;MDNS
ESP8266mDNS
monitor_speed = 115200 monitor_speed = 115200
[env:mega2560-5100] [env:mega2560-5100]