summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2012-09-09 13:50:56 -0700
committerKeith Packard <keithp@keithp.com>2012-09-09 13:50:56 -0700
commit3fa71c497a5bf576974e70af06762f75734e6699 (patch)
treee2e2e5ce5881db1a8262b979fea456f8fc9d808d /src
parent27ab744c6eec9243b7aa14161eec2fbf7003531e (diff)
altos: Try to get remote cmac time closer to reality
Record the time after the packet was sent, but before the return packet arrives to try and more closely approximate the time the packet arrived at the other end. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
-rw-r--r--src/drivers/ao_lco_func.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/drivers/ao_lco_func.c b/src/drivers/ao_lco_func.c
index 152b5d1b..99e58b76 100644
--- a/src/drivers/ao_lco_func.c
+++ b/src/drivers/ao_lco_func.c
@@ -28,18 +28,18 @@ ao_lco_query(uint16_t box, struct ao_pad_query *query, uint16_t *tick_offset)
{
uint8_t i;
int8_t r;
- uint16_t time;
+ uint16_t sent_time;
ao_mutex_get(&ao_lco_mutex);
- time = ao_time();
- command.tick = time;
+ command.tick = ao_time() - *tick_offset;
command.box = box;
command.cmd = AO_LAUNCH_QUERY;
command.channels = 0;
ao_radio_cmac_send(&command, sizeof (command));
- r = ao_radio_cmac_recv(query, sizeof (*query), AO_MS_TO_TICKS(500));
+ sent_time = ao_time();
+ r = ao_radio_cmac_recv(query, sizeof (*query), AO_MS_TO_TICKS(20));
if (r == AO_RADIO_CMAC_OK)
- *tick_offset = time - query->tick;
+ *tick_offset = sent_time - query->tick;
ao_mutex_put(&ao_lco_mutex);
return r;
}