summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-02-08 20:02:54 -0800
committerKeith Packard <keithp@keithp.com>2014-02-08 20:13:38 -0800
commit6367ab2dec718c512073f70dfab86dbd1656b1fe (patch)
treee2045a0929a78fa49a11812a7491cedc05992891
parent8ddbbdcdc498a19ebf4a440bbf5d73b6538e0a57 (diff)
altos: Report nsat in view in APRS packet
This adds the number of sats in view (as opposed to the number of sats in solution) to the APRS packet. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src/drivers/ao_aprs.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/drivers/ao_aprs.c b/src/drivers/ao_aprs.c
index 25a651ca..c327c897 100644
--- a/src/drivers/ao_aprs.c
+++ b/src/drivers/ao_aprs.c
@@ -488,9 +488,21 @@ static void tncCompressInt(uint8_t *dest, int32_t value, int len) {
}
}
-#if HAS_ADC
+static int ao_num_sats(void)
+{
+ int i;
+ int n = 0;
+
+ for (i = 0; i < ao_gps_tracking_data.channels; i++) {
+ if (ao_gps_tracking_data.sats[i].svid)
+ n++;
+ }
+ return n;
+}
+
static int tncComment(uint8_t *buf)
{
+#if HAS_ADC
struct ao_data packet;
ao_arch_critical(ao_data_get(&packet););
@@ -500,15 +512,19 @@ static int tncComment(uint8_t *buf)
int16_t main = ao_ignite_decivolt(AO_SENSE_MAIN(&packet));
return sprintf((char *) buf,
- "B:%d.%d A:%d.%d M:%d.%d",
+ "S: %d B:%d.%d A:%d.%d M:%d.%d",
+ ao_num_sats(),
battery/10,
battery % 10,
apogee/10,
apogee%10,
main/10,
main%10);
-}
+#else
+ return sprintf((char *) buf,
+ "S: %d", ao_num_sats());
#endif
+}
/**
* Generate the plain text position packet.
@@ -556,11 +572,7 @@ static int tncPositionPacket(void)
*buf++ = 33 + ((1 << 5) | (2 << 3));
-#if HAS_ADC
buf += tncComment(buf);
-#else
- *buf = '\0';
-#endif
return buf - tncBuffer;
}