altos: Use other TeleDongle LED for CRC-invalid packet reporting
[fw/altos] / src / kernel / ao_monitor.c
index 18f170b49912af18c707e2e8780a03db522f2419..cba0d80af603a778c57a7e275b0db7ae72b3b0c6 100644 (file)
@@ -94,9 +94,18 @@ __xdata struct ao_task ao_monitor_blink_task;
 void
 ao_monitor_blink(void)
 {
+#ifdef AO_MONITOR_BAD
+       uint8_t         *recv;
+#endif
        for (;;) {
                ao_sleep(DATA_TO_XDATA(&ao_monitor_head));
-               ao_led_for(AO_MONITOR_LED, AO_MS_TO_TICKS(100));
+#ifdef AO_MONITOR_BAD
+               recv = (uint8_t *) &ao_monitor_ring[ao_monitor_ring_prev(ao_monitor_head)];
+               if (ao_monitoring && !(recv[ao_monitoring + 1] & AO_RADIO_STATUS_CRC_OK))
+                       ao_led_for(AO_MONITOR_BAD, AO_MS_TO_TICKS(100));
+               else
+#endif
+                       ao_led_for(AO_MONITOR_LED, AO_MS_TO_TICKS(100));
        }
 }
 #endif
@@ -115,6 +124,8 @@ ao_monitor_put(void)
 {
 #if LEGACY_MONITOR
        __xdata char callsign[AO_MAX_CALLSIGN+1];
+#endif
+#if LEGACY_MONITOR || HAS_RSSI
        int16_t rssi;
 #endif
        uint8_t ao_monitor_tail;
@@ -240,7 +251,7 @@ ao_monitor_put(void)
                        hex(sum);
                        putchar ('\n');
 #if HAS_RSSI
-                       if (recv_raw.packet[ao_monitoring + 1] & PKT_APPEND_STATUS_1_CRC_OK) {
+                       if (recv_raw.packet[ao_monitoring + 1] & AO_RADIO_STATUS_CRC_OK) {
                                rssi = AO_RSSI_FROM_RADIO(recv_raw.packet[ao_monitoring]);
                                ao_rssi_set(rssi);
                        }