+static void tncCompressInt(uint8_t *dest, int32_t value, int len) {
+ int i;
+ for (i = len - 1; i >= 0; i--) {
+ dest[i] = value % 91 + 33;
+ value /= 91;
+ }
+}
+
+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 char ao_gps_locked(void)
+{
+ if (ao_gps_data.flags & AO_GPS_VALID)
+ return 'L';
+ else
+ return 'U';
+}
+
+static int tncComment(uint8_t *buf)
+{
+#if HAS_ADC
+ struct ao_data packet;
+
+ ao_arch_critical(ao_data_get(&packet););
+
+ int16_t battery = ao_battery_decivolt(packet.adc.v_batt);
+#ifdef AO_SENSE_DROGUE
+ int16_t apogee = ao_ignite_decivolt(AO_SENSE_DROGUE(&packet));
+#endif
+#ifdef AO_SENSE_MAIN
+ int16_t main = ao_ignite_decivolt(AO_SENSE_MAIN(&packet));
+#endif
+
+ return sprintf((char *) buf,
+ "%c%d B%d.%d"
+#ifdef AO_SENSE_DROGUE
+ " A%d.%d"
+#endif
+#ifdef AO_SENSE_MAIN
+ " M%d.%d"
+#endif
+ , ao_gps_locked(),
+ ao_num_sats(),
+ battery/10,
+ battery % 10
+#ifdef AO_SENSE_DROGUE
+ , apogee/10,
+ apogee%10
+#endif
+#ifdef AO_SENSE_MAIN
+ , main/10,
+ main%10
+#endif
+ );
+#else
+ return sprintf((char *) buf,
+ "%c%d",
+ ao_gps_locked(),
+ ao_num_sats());
+#endif
+}
+