SQ9MDD / TTGO-T-Beam-LoRa-APRS

Use TTGO T-Beam as LoRa APRS Tracker
64 stars 23 forks source link

position frame rate limiting #93

Closed dl9sau closed 2 years ago

dl9sau commented 2 years ago

I saw a relative high rate of frames sent in between 5s. This is too high for LoRa. 20s is imho a minimum. May be lesser on higher data rates (smaller SF than 12).

In TTGO_T-Beam_LoRa_APRS.ino I added:

After

  average_speed_final = (average_speed[0]+average_speed[1]+average_speed[2]+average_speed[3]+average_speed[4])/5;
   average_course[point_avg_course] = gps.course.deg();   // calculate smart beaconing course
   ++point_avg_course;

..this check:

 // not transmitted due to rate limit in previous round? Try again without recomputing nextTX
if (nextTX && nextTX <= 20000L)
  goto behind_recomputation_of_nextTX;

And:

Instead of

  if ((millis()<sb_max_interval)&&(lastTX == 0)) {
     nextTX = 0;
   }
  if ( (lastTX+nextTX) <= millis()  ) {

this code:

 if ((millis()<sb_max_interval)&&(lastTX == 0)) {
     nextTX = 0;
   }

 behind_recomputation_of_nextTX:

  // rate limit to 20s¶
  if ((lastTX+nextTX) < millis()) && ((millis()-lastTX) >= 20000L)) { 

Btw, last line, I think "if ( (lastTX+nextTX) < millis() )" instead of "if ( (lastTX+nextTX) <= millis() )" is correct, because lastTX is equal to millis(), and nextTX is 0, we just have transmitted.

mi-gri commented 2 years ago

I guess there is a { missing at the end of the last line of the corrected code?

dl9sau commented 2 years ago

I guess there is a { missing at the end of the last line of the corrected code?

Yes. Cut+Paste problem. Because: a new feature I did not mentioned yet: stoping beacon, if kiss client with same call+ssid is connected and sends position reports, we stop sending on our own, until he keeps silent (for beacon max time) or gets disconnected) . That's why my current code part is if (!dont_send_own_position_packets && ((lastTX+nextTX) < millis()) && ((millis()-lastTX) >= 20000L)) { if (gps.location.age() < 2000) { ....

dl9sau commented 2 years ago

Feature is stable in my development version