You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Someone said, smart-beaconing implementation is not so smooth.
I looked in the code and found situations where the result is negative. The negative result is assigned to unsigned long, which gives us a very high variable -> the next beacon is either in a few weeks, or user drops speed, or drives a curve.
Concrete: sb_max_speed-sb_min_speed is negative i.e. in 100max-120current
Current code
nextTX = (sb_max_interval-sb_min_interval)/(sb_max_speed-sb_min_speed)*(sb_max_speed-average_speed_final)+sb_min_interval;
if (nextTX < sb_min_interval) {nextTX=sb_min_interval;}
if (nextTX > sb_max_interval) {nextTX=sb_max_interval;}
Solution:
either work with signed long variable, do the checks, and afterwards assign the result to nextTX.
Or test it inline.
Also to consider:
If user configures sb_max_speed equal to sb_min_speed, the division (sb_max_interval-sb_min_interval)/(sb_max_speed-sb_min_speed)
may lead to division by zero.
boot code and / webinterface should check that sb_max_speed-sb_min_speed is >= 0, and sb_max_interval-sb_max_interval is > sb_max_speed-sb_min_speed.
The text was updated successfully, but these errors were encountered:
dl9sau
changed the title
smrt beaconing: fix
smart beaconing: fix
Oct 17, 2021
mi-gri
added a commit
to mi-gri/TTGO-T-Beam-LoRa-APRS
that referenced
this issue
Oct 21, 2021
Someone said, smart-beaconing implementation is not so smooth.
I looked in the code and found situations where the result is negative. The negative result is assigned to unsigned long, which gives us a very high variable -> the next beacon is either in a few weeks, or user drops speed, or drives a curve.
Concrete: sb_max_speed-sb_min_speed is negative i.e. in 100max-120current
Current code
Solution:
either work with signed long variable, do the checks, and afterwards assign the result to nextTX.
Or test it inline.
-> My suggestion:
Also to consider:
If user configures sb_max_speed equal to sb_min_speed, the division
(sb_max_interval-sb_min_interval)/(sb_max_speed-sb_min_speed)
may lead to division by zero.
boot code and / webinterface should check that sb_max_speed-sb_min_speed is >= 0, and sb_max_interval-sb_max_interval is > sb_max_speed-sb_min_speed.
The text was updated successfully, but these errors were encountered: