Olá pessoal...
Sei que para funcionar corretamente o hostname no ESP8266 preciso seguir esses requisitos;
1- A função WiFi.hostname() precisa ser executada antes de WiFi.begin();
2- Só funciona se o ESP8266 estiver configurado para obter IP por dhcp, ou se amarrarmos o IP à MAC no roteador.
Se setarmos o ip manualmente no ESP, tipo:
WiFi.config (STA_IP, STA_DNS, STA_GTW, STA_NET);
ele desconfigura o hostname setado em WiFi.hostname(), e passa a emitir o hostname:
ESP-(MAC).
// Set Hostname.
String hostname(HOSTNAME);
hostname += String(ESP.getChipId(), HEX);
WiFi.hostname(hostname);
A pergunta que faço é: Exite uma maneira de editar esse hostname quando usamos ip fixo para o STATION MODE ?
Tipo assim:
WiFi.hostname("HELIO_(MAC)");
HELIO-(MAC)
ou simplesmente:
WiFi.hostname("MEU PROJETO");
MEU_PROJETO
Aceito qualquer ajuda, obrigado.
Tags:
Boa tarde HRCF,
não sei se ajuda, mas extrai estas informações deste link:
https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/statio...
RV
Get the DHCP hostname assigned to ESP station.
WiFi.hostname()
Function returns String
type. Default hostname is in format ESP_24xMAC
where 24xMAC are the last 24 bits of module’s MAC address.
The hostname may be changed using the following function:
WiFi.hostname(aHostname)
Input parameter aHostname
may be a type of char*
, const char*
or String
. Maximum length of assigned hostname is 32 characters. Function returns either true
or false
depending on result. For instance, if the limit of 32 characters is exceeded, function will return false
without assigning the new hostname.
Example code:
Serial.printf("Default hostname: %s\n", WiFi.hostname().c_str()); WiFi.hostname("Station_Tester_02"); Serial.printf("New hostname: %s\n", WiFi.hostname().c_str());
Example output:
Default hostname: ESP_081117 New hostname: Station_Tester_02
Então, o problema é que quando coloco o ESP com ip fixo ele volta pra ESP-(MAC), só funciona se tiver em dhcp client.
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
© 2024 Criado por Marcelo Rodrigues. Ativado por