altos: For telelco discovery packets, retry 5 times with shorter timeout
[fw/altos] / src / telelco-v0.2 / ao_lco.c
index e8d16ca93cfdaf24b0c9a237b2f407571bb0899e..b3f5bb169cab5bf7a8a573672c1baf87d37f7991 100644 (file)
@@ -37,7 +37,6 @@ static uint8_t        ao_lco_debug;
 #define AO_LCO_BOX_DIGIT_10    2
 
 static uint8_t ao_lco_min_box, ao_lco_max_box;
-static uint8_t ao_lco_mutex;
 static uint8_t ao_lco_pad;
 static uint8_t ao_lco_box;
 static uint8_t ao_lco_armed;
@@ -252,18 +251,22 @@ ao_lco_search(void)
 {
        uint16_t        tick_offset;
        int8_t          r;
+       int8_t          try;
        uint8_t         box;
 
        ao_lco_box_reset_present();
        for (box = 0; box < AO_PAD_MAX_BOXES; box++) {
                if ((box % 10) == 0)
                        ao_lco_set_box(box);
-               tick_offset = 0;
-               r = ao_lco_query(box, &ao_pad_query, &tick_offset);
-               PRINTD("box %d result %d\n", box, r);
-               if (r == AO_RADIO_CMAC_OK) {
-                       ao_lco_box_set_present(box);
-                       ao_delay(AO_MS_TO_TICKS(30));
+               for (try = 0; try < 5; try++) {
+                       tick_offset = 0;
+                       r = ao_lco_query(box, &ao_pad_query, &tick_offset);
+                       PRINTD("box %d result %d\n", box, r);
+                       if (r == AO_RADIO_CMAC_OK) {
+                               ao_lco_box_set_present(box);
+                               ao_delay(AO_MS_TO_TICKS(30));
+                               break;
+                       }
                }
        }
        if (ao_lco_min_box <= ao_lco_max_box)
@@ -281,12 +284,9 @@ static void
 ao_lco_igniter_status(void)
 {
        uint8_t         c;
-       uint16_t        delay;
 
        for (;;) {
-//             ao_alarm(delay);
                ao_sleep(&ao_pad_query);
-//             ao_clear_alarm();
                if (!ao_lco_valid) {
                        ao_led_on(AO_LED_RED);
                        ao_led_off(AO_LED_GREEN|AO_LED_AMBER);