diff options
| author | Keith Packard <keithp@keithp.com> | 2014-04-30 22:14:37 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2014-04-30 22:14:37 -0700 | 
| commit | 8e3842660274ac4bcd7b5a78f5db215222b1c4de (patch) | |
| tree | b465454a9ba9af402a63020d30b5cec909b92b20 /src | |
| parent | 0223fced2c6d2b9f63ede6258afae46c3f55c200 (diff) | |
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 <keithp@keithp.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/drivers/ao_lco_func.c | 2 | ||||
| -rw-r--r-- | 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) | 
