From 6367ab2dec718c512073f70dfab86dbd1656b1fe Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 8 Feb 2014 20:02:54 -0800 Subject: [PATCH 1/1] 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 --- src/drivers/ao_aprs.c | 26 +++++++++++++++++++------- 1 file 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; } -- 2.30.2