mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 19:56:30 +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
|
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":"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":"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}
|
{"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
|
* 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
|
* 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:
|
* Supported commands:
|
||||||
* WcStream = Control streaming, 0 = stop, 1 = start
|
* WcStream = Control streaming, 0 = stop, 1 = start
|
||||||
|
@ -60,22 +60,20 @@
|
|||||||
|
|
||||||
#include <ETH.h>
|
#include <ETH.h>
|
||||||
|
|
||||||
struct {
|
char eth_hostname[sizeof(my_hostname)];
|
||||||
char hostname[33];
|
|
||||||
} Eth;
|
|
||||||
|
|
||||||
void EthernetEvent(WiFiEvent_t event) {
|
void EthernetEvent(WiFiEvent_t event) {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case SYSTEM_EVENT_ETH_START:
|
case SYSTEM_EVENT_ETH_START:
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ETH: " D_ATTEMPTING_CONNECTION));
|
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ETH: " D_ATTEMPTING_CONNECTION));
|
||||||
ETH.setHostname(Eth.hostname);
|
ETH.setHostname(eth_hostname);
|
||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_ETH_CONNECTED:
|
case SYSTEM_EVENT_ETH_CONNECTED:
|
||||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("ETH: " D_CONNECTED));
|
AddLog_P2(LOG_LEVEL_INFO, PSTR("ETH: " D_CONNECTED));
|
||||||
break;
|
break;
|
||||||
case SYSTEM_EVENT_ETH_GOT_IP:
|
case SYSTEM_EVENT_ETH_GOT_IP:
|
||||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ETH: Mac %s, IPAddress %s, Hostname %s"),
|
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()) {
|
if (ETH.fullDuplex()) {
|
||||||
Serial.print(", FULL_DUPLEX");
|
Serial.print(", FULL_DUPLEX");
|
||||||
@ -109,7 +107,10 @@ void EthernetInit(void) {
|
|||||||
return;
|
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);
|
WiFi.onEvent(EthernetEvent);
|
||||||
|
|
||||||
int eth_power = (PinUsed(GPIO_ETH_PHY_POWER)) ? Pin(GPIO_ETH_PHY_POWER) : -1;
|
int eth_power = (PinUsed(GPIO_ETH_PHY_POWER)) ? Pin(GPIO_ETH_PHY_POWER) : -1;
|
||||||
@ -125,7 +126,7 @@ IPAddress EthernetLocalIP(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char* EthernetHostname(void) {
|
char* EthernetHostname(void) {
|
||||||
return Eth.hostname;
|
return eth_hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
String EthernetMacAddress(void) {
|
String EthernetMacAddress(void) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user