listen broadcast message lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- ProfHarry · 2024-06-05 04:05 Hello, I have several ESP32s on a network which send broadcast messages (ASCII texts of 20 to 30 characters) at more or less regular intervals. What is the easiest way for a beginner to recover these messages in a lazarus application? Could you give me an example? Thanks ---------------------------------------------------------------------- Thaddy · 2024-06-05 04:53 There is a great example I got from Stackoverflow that should be just he ticket for you: https://stackoverflow.com/questions/9786011/delphi-synapse-udp-client- server It uses synapse, but it is light enough. I can probably convert it to fcl-web if required. ---------------------------------------------------------------------- ProfHarry · 2024-06-05 06:13 Thanks, If I've understood correctly, I'm only using the client part. Is that correct? I'll take a look at that and probably come back with my newbie questions. ---------------------------------------------------------------------- Thaddy · 2024-06-05 06:25 It depends on you having control over the software from the esp32's. Since you mentioned broadcasting, I assume the protocol to be UDP, but you can also do that differently as long as it is socket based. But indeed, basically you only need a listener. Take the echo example from stack overflow as an example: instead of echo, you log the identity from the ESP32's and its messages. That takes very few changes to the code. ---------------------------------------------------------------------- MarkMLl · 2024-06-05 07:04 Quote from: Thaddy on June 05, 2024, 08:25:47 amSince you mentioned broadcasting, I assume the protocol to be UDP, but you can also do that differently as long as it is socket based. But indeed, basically you only need a listener. Take the echo example from stack overflow as an example: instead of echo, you log the identity from the ESP32's and its messages. That takes very few changes to the code. Note that UDP broadcasts are generally discarded by routers. MarkMLl ---------------------------------------------------------------------- ProfHarry · 2024-06-05 09:53 Quote from: Thaddy on June 05, 2024, 08:25:47 amIt depends on you having control over the software from the esp32's. I have several ESP32s doing measurements and I have a control of their code but : - they connect via DHCP to the wifi network - I don't know their IP (no access to the DHCP server) - they have no way of displaying their IP addresses (no LCD or other display) - I need their IP to access their web servers to display the measurements taken. The solution I have come up with is to regularly broadcast the name and IP of each ESP32. The lazarus application will be used to locate them and indicate the addresses of each of them. ---------------------------------------------------------------------- ProfHarry · 2024-06-05 09:58 Quote from: MarkMLl on June 05, 2024, 09:04:33 amNote that UDP broadcasts are generally discarded by routers. This is a Wi-Fi network in a school. The lazarus application is on a laptop on the same network as the ESP32s, so it should work.  Fingers crossed ;-) ---------------------------------------------------------------------- MarkMLl · 2024-06-05 10:03 Quote from: ProfHarry on June 05, 2024, 11:58:46 amQuote from: MarkMLl on June 05, 2024, 09:04:33 amNote that UDP broadcasts are generally discarded by routers. This is a Wi-Fi network in a school. The lazarus application is on a laptop on the same network as the ESP32s, so it should work.  Fingers crossed ;-) Yes, but in many cases an access point will behave more like a router rather than like a switch. MarkMLl ---------------------------------------------------------------------- marcov · 2024-06-05 10:18 I do the same with my electronics boards.  They have fixed IP, but I broadcast for other reasons (no need to configure destination IP and sending packets to multiple PCs would require an extra operation to set it) Originally I used a simple UDP listener based on the Indy10 udp client demo to capture them, so that could be a start. If it doesn't work, try to temporarily disable the firewall. ---------------------------------------------------------------------- ProfHarry · 2024-06-05 12:11 Quote from: marcov on June 05, 2024, 12:18:39 pmOriginally I used a simple UDP listener based on the Indy10 udp client demo to capture them, so that could be a start. Thanks, I'll have a look too. ---------------------------------------------------------------------- Curt Carpenter · 2024-06-05 23:28 FWIW my esp's all have an on-board led and I use it during power up to flash the last few digits of their IP address in Morse.   The software required is nothing and it helps me cope with my failing memory. ---------------------------------------------------------------------- Leledumbo · 2024-06-16 17:07 Sounds like a good candidate for SSDP. ---------------------------------------------------------------------- MarkMLl · 2024-06-16 17:35 Quote from: Leledumbo on June 16, 2024, 07:07:46 pmSounds like a good candidate for SSDP. Hmm. I'm not sure whether that's really proportional for the simple job of discovering IP addresses, and partially-implemented protocols (i.e. to take minimal space on an ESP used for labwork) cause innumerable problems. What would work however would be a UDP broadcast from a lab computer to SSDP's port (1900) which should elicit an error response, and then a dump of the computer's ARP cache to get the IP and MAC addresses of everything discovered. But it would be even easier to use a broadcast ping. MarkMLl