ESP32 UDP read data

ooo that code looks much slimmed down, I think I get the gist of whats happening though, you have gone a bit techno lol..
Your example looks like what I needed when I started the project rather than the sample I modified..

looking at the way I had it, i hit a problem that I hadn't anticipated, reading the packet.data() always returned Heartbeat when checked.
It persists. I originally wrote this with RF24 and Arduino nano.
I used words rather than 0,1 mainly as I am a noobe and this made my code a bit easier reading, as i had a transmitter in my garage and on 3 different garden gates around the bungalow.
But the garage is detached around the back and I sleep in the front and the range was struggling despite upgrading the aerials.
I had a play the other week with an esp8266 and a webhook, and got it working to notify my mobile when the laser stopped at work.
Next i decided to replace my little home alarm with esp32, but all the video examples used a server running html on a esp32 server unit, which I couldn't get my head round how to make a esp32 talk to another esp32.. all the other TCP project examples seem to connect direct from esp32 to esp32 which gave me the same range problems.. then I fount the UDP master and slave examples, and I thought I understood enough of those to achieve, until i hit a block with this packet.data()..
There is a lot in the code I showed you that I will eventually trim out, like the lines printing the ip addresses, as I've started with an example, I am not sure to start whats safe for me to remove lol
This language is a huge learning curve from the days of basic and cobol, I've spent many hours but still feel i haven't learned much of the basics.
Any how thank you again, I hope fully will get an hour or two this evening to give this a try .
Paul