From 8e3842660274ac4bcd7b5a78f5db215222b1c4de Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 30 Apr 2014 22:14:37 -0700 Subject: [PATCH] altos: For telelco discovery packets, retry 5 times with shorter timeout A timeout of 10ms is more than enough to receive a query packet, but if we miss it during device discovery, it's a pain, so retry 5 times to make sure we find everyone. Signed-off-by: Keith Packard --- src/drivers/ao_lco_func.c | 2 +- src/telelco-v0.2/ao_lco.c | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/drivers/ao_lco_func.c b/src/drivers/ao_lco_func.c index a5d28e61..9e642836 100644 --- a/src/drivers/ao_lco_func.c +++ b/src/drivers/ao_lco_func.c @@ -36,7 +36,7 @@ ao_lco_query(uint16_t box, struct ao_pad_query *query, uint16_t *tick_offset) command.channels = 0; ao_radio_cmac_send(&command, sizeof (command)); sent_time = ao_time(); - r = ao_radio_cmac_recv(query, sizeof (*query), AO_MS_TO_TICKS(20)); + r = ao_radio_cmac_recv(query, sizeof (*query), AO_MS_TO_TICKS(10)); if (r == AO_RADIO_CMAC_OK) *tick_offset = sent_time - query->tick; ao_mutex_put(&ao_lco_mutex); diff --git a/src/telelco-v0.2/ao_lco.c b/src/telelco-v0.2/ao_lco.c index 0bbb76f1..b3f5bb16 100644 --- a/src/telelco-v0.2/ao_lco.c +++ b/src/telelco-v0.2/ao_lco.c @@ -251,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) -- 2.30.2