altos: Use other TeleDongle LED for CRC-invalid packet reporting
authorKeith Packard <keithp@keithp.com>
Fri, 7 Nov 2014 00:02:47 +0000 (16:02 -0800)
committerKeith Packard <keithp@keithp.com>
Fri, 7 Nov 2014 00:03:42 +0000 (16:03 -0800)
Instead of blinking out some fake-o RSSI indication, just blink the
red LED when a packet with a bad CRC is received.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/kernel/ao.h
src/kernel/ao_monitor.c

index 48b06490aebeb8918580f78ae97fa9818110f669..16d600aa08b46319767ebc550e72b7efcb84fdba 100644 (file)
@@ -652,6 +652,7 @@ union ao_monitor {
 extern __xdata union ao_monitor ao_monitor_ring[AO_MONITOR_RING];
 
 #define ao_monitor_ring_next(n)        (((n) + 1) & (AO_MONITOR_RING - 1))
+#define ao_monitor_ring_prev(n)        (((n) - 1) & (AO_MONITOR_RING - 1))
 
 extern __data uint8_t ao_monitoring;
 extern __data uint8_t ao_monitor_head;
index 2d75c41c2c786bf98d7c03c05e4a09f9a58b70a0..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