Hi Everybody.
I need help with this project.
I have one of this ESP32 board, and I’m trying to figure out, how can i get DNS-name of the machine, when I’m doing LAN scan?
Like in the in Windows, you can do " nbtstat -A xxx.xxx.xxx.xxx (where x is the ip address) " to get machine name.
Here is my code, which is scanning my LAN
#include <ETH.h>
#include <WiFi.h>
#include "ping.h"
void setup()
{
Serial.begin(9600);
WiFi.begin("my-ssid","my-password");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.begin(115200);
}
bool pingtest (IPAddress ia) {
IPAddress adr = IPAddress(ia[0], ia[1], ia[2], ia[3]);
Serial.printf("Ping : %d.%d.%d.%d : ", ia[0], ia[1], ia[2], ia[3]);
if (ping_start(adr, 1, 0, 0, 1)) {
Serial.println("OK");
return true;
} else {
Serial.println("Request time out");
return false;
}
}
void loop(){
for(int i = 100; i <= 150; i++){
pingtest( IPAddress(192,168,1,i));
}
}
and this is my outputs
Ping : 192.168.1.100 : Request time out
Ping : 192.168.1.101 : Request time out
Ping : 192.168.1.102 : Request time out
Ping : 192.168.1.103 : Request time out
Ping : 192.168.1.104 : Request time out
Ping : 192.168.1.105 : Request time out
Ping : 192.168.1.106 : OK
Ping : 192.168.1.107 : Request time out
Ping : 192.168.1.108 : OK
Ping : 192.168.1.109 : OK
Ping : 192.168.1.110 : OK
So instead of “OK” I would like to see machine names, if possible.
Thank you Very Much