From da87918d51a8013323ef58cd3881de48fbdac18c Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 18 Jun 2020 17:47:29 +0200 Subject: [PATCH] Fix ESP32 ethernet hostname --- tasmota/tasmota_template_ESP32.h | 4 ---- tasmota/xdrv_81_webcam.ino | 2 +- tasmota/xdrv_82_ethernet.ino | 15 ++++++++------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/tasmota/tasmota_template_ESP32.h b/tasmota/tasmota_template_ESP32.h index 1eb5f02a7..80a015675 100644 --- a/tasmota/tasmota_template_ESP32.h +++ b/tasmota/tasmota_template_ESP32.h @@ -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} diff --git a/tasmota/xdrv_81_webcam.ino b/tasmota/xdrv_81_webcam.ino index 71d81d2ac..b0dab47b7 100644 --- a/tasmota/xdrv_81_webcam.ino +++ b/tasmota/xdrv_81_webcam.ino @@ -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 diff --git a/tasmota/xdrv_82_ethernet.ino b/tasmota/xdrv_82_ethernet.ino index 034c72636..cccac57b7 100644 --- a/tasmota/xdrv_82_ethernet.ino +++ b/tasmota/xdrv_82_ethernet.ino @@ -60,22 +60,20 @@ #include -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) {