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.
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.