Hello,
I'm french so my english is not so good and my friend Deepl help me ;-)
I have a set of ESP32 microcontrollers which are HTTP servers and DHCP clients on a wifi network.
The only user interface is the web page, so it is difficult for the user to know the IP addresses of the various microcontrollers. In general, the DHCP server and the list of leases are not accessible to users.
Each ESP32 responds to the URL
http://IP/info.txt with a line containing, among other things, its IP address and hostname.
I therefore tried to develop a Lazarus application to scan the network and make this request to all the addresses.
But it's very, very slow... Because of the timeout for most addresses, it takes more than 10 minutes to scan an entire /24 network. I can't even imagine on a /16 network.
I use this code called in a loop on all IP addresses:
function GetInfos(IP : string) : string;
Var
URL : String;
SL : TStringList;
begin
URL := 'http://' + IP + '/infos.txt';
SL := TStringList.Create();
try
with TFPHttpClient.Create(Nil) do
try
AllowRedirect := True;
Get(URL,SL);
application.processmessages;
finally
Free;
end;
Result := SL[0];
finally
SL.Free;
end;
end;
Do you see a solution to speed up the scan and make it possible on a larger network?
Thanks for your help.