Hi,
I am testing some code where I look up the device based on its host name which is registered
in a GL.iNet router. The first time it works ok, and every time I change the Mac Address it works correctly but for some reason the router is not clearing the device name after it powers down or if the host name changes.
I set the hostname as below, but after running this the first time I am unable to change the
client hostname which I view in the GL.iNet (openWrt) router. iPhone sets/unsets the hostname
in the client list properly so what is wrong???
I have tried multiple variations of the code below but once set it is very difficult to clear the
hostname for the ESP32 unless I change its MAC. It then works ok but needs the MAC to change
for things to update in the router.
Can anyone shed light on this ?
#include <WiFi.h>
#include "esp_wifi.h"
const char* ssid = "IOTgli";
const char* password = "12345678";
void setup()
{ Serial.begin(115200);
while(!Serial); // Is this needed for FT232R ?
Serial.println("Connected at 115200");
while(!Serial)
WiFi.begin(); // Enable wifi to deinit the device prior to new hostname
int i = 20;
while(i--)
{ Serial.print("ESP counting down for disconnect:");
Serial.println(i, DEC);
esp_wifi_deinit();
delay(2000);
}
byte code = WiFi.disconnect();
Serial.print("DEBUG:disconnect code:");
Serial.println(code, DEC);
delay(3000);
WiFi.begin(ssid, password);
WiFi.setHostname("GLiESPclient");
// Need this to be ready prior to call to WiFI.begin
WiFi.setSleep(false); // Stop suppression of network beacons
delay(500);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
delay(60000); // Wait for 60 seconds , to test following commands to deauthenticate
//esp_wifi_deinit(); // These cause things to reboot ?
//esp_wifi_stop();
}
void loop() {}
Problem clearing ESP hostname from router client list
-
- Posts: 1
- Joined: Thu Nov 26, 2020 4:21 pm
Who is online
Users browsing this forum: No registered users and 72 guests