mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-23 02:36:35 +00:00
Fix ESP32 ethernet hostname
This commit is contained in:
parent
c533eb1186
commit
da87918d51
@ -684,10 +684,6 @@ const mytmplt kModules PROGMEM =
|
||||
/*********************************************************************************************\
|
||||
Known templates
|
||||
|
||||
{"NAME":"AITHINKER CAM","GPIO":[4992,65504,65504,65504,65504,5088,65504,65504,65504,65504,65504,65504,65504,65504,5089,5090,0,5091,5184,5152,0,5120,5024,5056,0,0,0,0,4928,65504,5094,5095,5092,0,0,5093],"FLAG":0,"BASE":1}
|
||||
{"NAME":"Olimex ESP32-PoE","GPIO":[65504,65504,65504,65504,65504,65504,0,0,5536,65504,65504,65504,65504,0,5600,0,0,0,0,5568,0,0,0,0,0,0,0,0,65504,65504,65504,65504,65504,0,0,65504],"FLAG":0,"BASE":1}
|
||||
{"NAME":"wESP32","GPIO":[65504,65504,65504,65504,65504,65504,0,0,0,65504,65504,65504,5568,5600,0,0,0,0,0,0,0,0,0,0,0,0,0,0,65504,65504,65504,65504,65504,0,0,65504],"FLAG":0,"BASE":1}
|
||||
|
||||
{"NAME":"AITHINKER CAM","GPIO":[4992,1,1,1,1,5088,1,1,1,1,1,1,1,1,5089,5090,0,5091,5184,5152,0,5120,5024,5056,0,0,0,0,4928,1,5094,5095,5092,0,0,5093],"FLAG":0,"BASE":1}
|
||||
{"NAME":"Olimex ESP32-PoE","GPIO":[1,1,1,1,1,1,0,0,5536,1,1,1,1,0,5600,0,0,0,0,5568,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,1],"FLAG":0,"BASE":1}
|
||||
{"NAME":"wESP32","GPIO":[1,1,1,1,1,1,0,0,0,1,1,1,5568,5600,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,1],"FLAG":0,"BASE":1}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* ESP32 webcam based on example in Arduino-ESP32 library
|
||||
*
|
||||
* Template as used on ESP32-CAM WiFi + bluetooth Camera Module Development Board ESP32 With Camera Module OV2640 Geekcreit for Arduino
|
||||
* {"NAME":"AITHINKER CAM No SPI","GPIO":[4992,65504,65504,65504,65504,5088,65504,65504,65504,65504,65504,65504,65504,65504,5089,5090,0,5091,5184,5152,0,5120,5024,5056,0,0,0,0,4928,65504,5094,5095,5092,0,0,5093],"FLAG":0,"BASE":1}
|
||||
* {"NAME":"AITHINKER CAM","GPIO":[4992,1,1,1,1,5088,1,1,1,1,1,1,1,1,5089,5090,0,5091,5184,5152,0,5120,5024,5056,0,0,0,0,4928,1,5094,5095,5092,0,0,5093],"FLAG":0,"BASE":1}
|
||||
*
|
||||
* Supported commands:
|
||||
* WcStream = Control streaming, 0 = stop, 1 = start
|
||||
|
@ -60,22 +60,20 @@
|
||||
|
||||
#include <ETH.h>
|
||||
|
||||
struct {
|
||||
char hostname[33];
|
||||
} Eth;
|
||||
char eth_hostname[sizeof(my_hostname)];
|
||||
|
||||
void EthernetEvent(WiFiEvent_t event) {
|
||||
switch (event) {
|
||||
case SYSTEM_EVENT_ETH_START:
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ETH: " D_ATTEMPTING_CONNECTION));
|
||||
ETH.setHostname(Eth.hostname);
|
||||
ETH.setHostname(eth_hostname);
|
||||
break;
|
||||
case SYSTEM_EVENT_ETH_CONNECTED:
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("ETH: " D_CONNECTED));
|
||||
break;
|
||||
case SYSTEM_EVENT_ETH_GOT_IP:
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ETH: Mac %s, IPAddress %s, Hostname %s"),
|
||||
ETH.macAddress().c_str(), ETH.localIP().toString().c_str(), Eth.hostname);
|
||||
ETH.macAddress().c_str(), ETH.localIP().toString().c_str(), eth_hostname);
|
||||
/*
|
||||
if (ETH.fullDuplex()) {
|
||||
Serial.print(", FULL_DUPLEX");
|
||||
@ -109,7 +107,10 @@ void EthernetInit(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf_P(Eth.hostname, sizeof(Eth.hostname), PSTR("%s_eth"), my_hostname);
|
||||
// snprintf_P(Eth.hostname, sizeof(Eth.hostname), PSTR("%s_eth"), my_hostname);
|
||||
strlcpy(eth_hostname, my_hostname, sizeof(eth_hostname) -5); // Make sure there is room for "_eth"
|
||||
strcat(eth_hostname, "_eth");
|
||||
|
||||
WiFi.onEvent(EthernetEvent);
|
||||
|
||||
int eth_power = (PinUsed(GPIO_ETH_PHY_POWER)) ? Pin(GPIO_ETH_PHY_POWER) : -1;
|
||||
@ -125,7 +126,7 @@ IPAddress EthernetLocalIP(void) {
|
||||
}
|
||||
|
||||
char* EthernetHostname(void) {
|
||||
return Eth.hostname;
|
||||
return eth_hostname;
|
||||
}
|
||||
|
||||
String EthernetMacAddress(void) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user