Allow for increased number of reporting units, each having 2 seconds of air time and keeping frame within 60 seconds, evenly divided. Example: was 10, now 15, could be 20 or 30.
This commit is contained in:
parent
b5ff96d6a9
commit
0395fed907
3 changed files with 33 additions and 5 deletions
0
docs/gps.md
Normal file
0
docs/gps.md
Normal file
|
|
@ -28,6 +28,7 @@ build_flags =
|
||||||
-D GPS_WAKEUP_PIN=7
|
-D GPS_WAKEUP_PIN=7
|
||||||
-D GPS_1PPS_PIN=6
|
-D GPS_1PPS_PIN=6
|
||||||
-D GPS_L76K
|
-D GPS_L76K
|
||||||
|
-D NODE_SLOT_COUNT=7
|
||||||
-D LORA_CS=10
|
-D LORA_CS=10
|
||||||
-D LORA_MOSI=11
|
-D LORA_MOSI=11
|
||||||
-D LORA_SCK=12
|
-D LORA_SCK=12
|
||||||
|
|
@ -94,4 +95,6 @@ build_flags =
|
||||||
-D NODE_LABEL=\"Guy\"
|
-D NODE_LABEL=\"Guy\"
|
||||||
-D NODE_SHORT=\"G\"
|
-D NODE_SHORT=\"G\"
|
||||||
-D NODE_SLOT_INDEX=6
|
-D NODE_SLOT_INDEX=6
|
||||||
|
-D GPS_UBLOX
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,10 @@
|
||||||
#define NODE_SHORT "?"
|
#define NODE_SHORT "?"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef NODE_SLOT_COUNT
|
||||||
|
#define NODE_SLOT_COUNT 7
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef NODE_SLOT_INDEX
|
#ifndef NODE_SLOT_INDEX
|
||||||
#define NODE_SLOT_INDEX 0
|
#define NODE_SLOT_INDEX 0
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -63,8 +67,8 @@
|
||||||
#define FW_BUILD_UTC "unknown"
|
#define FW_BUILD_UTC "unknown"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (NODE_SLOT_INDEX < 0) || (NODE_SLOT_INDEX > 6)
|
#if (NODE_SLOT_INDEX < 0) || (NODE_SLOT_INDEX >= NODE_SLOT_COUNT)
|
||||||
#error "NODE_SLOT_INDEX must be 0..6"
|
#error "NODE_SLOT_INDEX must be 0..NODE_SLOT_COUNT-1"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const uint32_t kSerialDelayMs = 1000;
|
static const uint32_t kSerialDelayMs = 1000;
|
||||||
|
|
@ -156,6 +160,20 @@ static uint8_t bestSatelliteCount()
|
||||||
return (g_gps.satsUsed > g_gps.satsInView) ? g_gps.satsUsed : g_gps.satsInView;
|
return (g_gps.satsUsed > g_gps.satsInView) ? g_gps.satsUsed : g_gps.satsInView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t computeFrameSeconds(uint32_t requiredSeconds)
|
||||||
|
{
|
||||||
|
uint32_t frame = ((requiredSeconds + 4U) / 5U) * 5U; // round up to 5s
|
||||||
|
while (frame <= 60U && (60U % frame) != 0U)
|
||||||
|
{
|
||||||
|
frame += 5U;
|
||||||
|
}
|
||||||
|
if (frame == 0U || frame > 60U)
|
||||||
|
{
|
||||||
|
frame = 60U; // fallback
|
||||||
|
}
|
||||||
|
return frame;
|
||||||
|
}
|
||||||
|
|
||||||
static void logf(const char *fmt, ...)
|
static void logf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
char msg[256];
|
char msg[256];
|
||||||
|
|
@ -1030,7 +1048,7 @@ static bool initRadio()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
logf("Radio ready for %s (%s), slot=%d sec=%d", NODE_LABEL, NODE_SHORT, NODE_SLOT_INDEX, NODE_SLOT_INDEX * 2);
|
logf("Radio ready for %s (%s), slot=%d/%d (2s each)", NODE_LABEL, NODE_SHORT, NODE_SLOT_INDEX, NODE_SLOT_COUNT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1051,8 +1069,15 @@ static void runTxScheduler()
|
||||||
if (!getCurrentUtc(now, epoch))
|
if (!getCurrentUtc(now, epoch))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int slotSecond = NODE_SLOT_INDEX * (int)kSlotSeconds;
|
uint32_t requiredTxSeconds = (uint32_t)NODE_SLOT_COUNT * kSlotSeconds;
|
||||||
int secInFrame = now.second % 10;
|
uint32_t frameSeconds = computeFrameSeconds(requiredTxSeconds);
|
||||||
|
uint32_t slotSecond = (uint32_t)NODE_SLOT_INDEX * kSlotSeconds;
|
||||||
|
if (slotSecond >= frameSeconds)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint32_t secInFrame = (uint32_t)now.second % frameSeconds;
|
||||||
|
if (secInFrame >= requiredTxSeconds)
|
||||||
|
return; // idle guard interval
|
||||||
if (secInFrame != slotSecond)
|
if (secInFrame != slotSecond)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue