Sending p2p after system#boot [solved]

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Sending p2p after system#boot [solved]

#1 Post by Wiki » 21 Mar 2021, 12:52

After Boot / Reboot I want to send an information to another device that this one is online again.

My Nextion display interferes with the WIFI of the pretty close mounted Wemos D1 - I don't know why, but its a fact.

If I try the following:

Code: Select all

On WiFi#Connected Do
  Timerset,1,60
EndOn
On Rules#Timer=1 Do
  SendTo 63,'event,NextionInit'
EndOn
the event is sometimes triggered in the other device, sometimes not.

If I try

Code: Select all

on WiFi#Connected do
  Timerset,1,5
EndOn
On Rules#Timer=1 Do
  SendToHTTP <ipofthedevice>,80,'/control?cmd=event,NextionInit'
EndOn
The event is triggered immediately.

I figured out, that it takes sometimes minutes for the booting Nextion device to get known to the other devices in the network. So I suppose, that for sending the event using p2p the booting device has missing informations or whatever. Is there a way to actively scan / search the udp network for another device using rules?
Last edited by Wiki on 21 Mar 2021, 15:29, edited 1 time in total.

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

User avatar
Ath
Normal user
Posts: 3418
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Sending p2p after system#boot

#2 Post by Ath » 21 Mar 2021, 13:25

The disadvantage of any UDP transmission is that it's 'fire and forget', there is no acknowledge of the recipient, so if the receiver is too busy, or Wifi is distorted or whatever, it may be missed by the receiver. That is by design for UDP.
Switching to SendToHTTP solves that, as http is guaranteed to be delivered (or error out), and if you enable the 'SendToHTTP wait for ack' setting, the unit continues after receiving that ack, to avoid 'over-feeding' if the receiver needs time to handle the request.
If you need reliable, use the http route, if it doesn't matter much, like sending some measurements, use udp.

NB:
I'd personally do the init of a display on the unit the display is connected to, unless that is required before sending any updates (never used a Nextion, so I don't know), not from an external source, to avoid snags like these.

For displaying the IP of any unit in the p2p network, I added a variable %c_u2ip(63,2) but that uses the cache of the p2p, so it won't be very reliable to detect if the unit is still there, it can take up to (I think) 10 minutes before a disappeared unit is removed from the list.
/Ton (PayPal.me)

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Sending p2p after system#boot

#3 Post by Wiki » 21 Mar 2021, 14:57

I feared that this will be the answer, I know that UDP isn't reliable by design. I was hoping that there might be a hidden feature to initiate the broadcast messages in the network aside the normal 30 seconds.

I am using the communication between the devices by device id because the devices are installed in my motorhome and have to connect to my home network automatically when the vehicle is parked and the mobile network is switched off. Works so far pretty good, but different netmasks are in use and make it hard to use hard coded ip addresses.

The device handling the communication with the Nextion display itself doesn't know anything about whats going on in the motorhome and has to be switched off during long parking time due to high power consumption of the display. Switched on it shows on different pages GPS data, temperatures, speed, altitude, average speed, trip distance, trip time, water level, onboard voltages, battery capacities, levelling of the vehicle, local time a.s.o. The goal is to get as many informations about the vehicles data as possible and this as fast as possible and independent from the ip range and netmask.

So I will try to set up a kind of ping pong game between the devices using device ids.

Thanks anyway.

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Sending p2p after system#boot [solved]

#4 Post by Wiki » 21 Mar 2021, 15:34

OK, and here we are.

Not very nice, but works:

Booting device (ID: 28):

Code: Select all

on WiFi#Connected do
  Timerset,1,1
EndOn
On InitDone Do
  TimerSet,1,0
EndOn
On Rules#Timer=1 Do
    SendTo 63,'event,NextionInit'
    Timerset,1,1
EndOn
Data device (ID: 63):

Code: Select all

On NextionInit Do
  SendTo 28,'event,InitDone'
  SendTo 28,....... //data
.
.
.
.
.
  SendTo 28,...... //last data
EndOn
Generates a bit of network traffic, but who cares......

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Sending p2p after system#boot [solved]

#5 Post by TD-er » 21 Mar 2021, 16:34

Enabling Gratuituous ARP may also help here.
And for debugging to see if it might be solved (or at least be related to these issues) you may want to send a ping continuously from whatever computer on your network to the node that's problematic in receiving p2p packets.

Wiki
Normal user
Posts: 413
Joined: 23 Apr 2018, 17:55
Location: Germany

Re: Sending p2p after system#boot [solved]

#6 Post by Wiki » 21 Mar 2021, 17:10

The problem only occurs at first boot of the Nextion attached Wemos device - in combination with my impatience that I want to see something useful on the screen as fast as possible. Once it has sent its own broadcast successfully and received the ones from the other devices the udp cache of the last 10 minutes is absolutely sufficient for a more or less stable communication.

And the problem is absolutely not ESPEasy or anything in relation with it. The problem is the interference of the Nextion display - I suppose the electronical emmissions of its background illumination - with the WIFI antenna of the Wemos if the Wemos is mounted too close to the display. I do have three different types of Nextion displays working (2x4.3", 1x 7") and they all produce this interference. Best practice would be to mount the Wemos app. 0.5m away from the display. But that's not possible in my motorhome.

[edit]
...and with the solution I've posted, I do have the informations in between 6 to 28 seconds on my display after power on.
[/edit]

Code: Select all

pi@raspberrypi:~ $ man woman
No manual entry for woman
pi@raspberrypi:~ $

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 28 guests