static struct ao_pad_command command;
static struct ao_pad_query query;
static uint8_t ao_pad_armed;
-static uint16_t ao_pad_arm_time;
+static AO_TICK_TYPE ao_pad_arm_time;
static uint8_t ao_pad_box;
static uint8_t ao_pad_disabled;
-static uint16_t ao_pad_packet_time;
+static AO_TICK_TYPE ao_pad_packet_time;
#ifndef AO_PAD_RSSI_MINIMUM
#define AO_PAD_RSSI_MINIMUM -90
prev = cur;
}
- if (ao_pad_armed && (int16_t) (ao_time() - ao_pad_arm_time) > AO_PAD_ARM_TIME)
+ if (ao_pad_armed && (AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > AO_PAD_ARM_TIME)
ao_pad_armed = 0;
if (ao_pad_armed) {
static void
ao_pad(void)
{
- int16_t time_difference;
+ int16_t tick_difference;
int8_t ret;
ao_pad_box = 0;
while (ao_pad_disabled)
ao_sleep(&ao_pad_disabled);
ret = ao_radio_cmac_recv(&command, sizeof (command), 0);
- PRINTD ("cmac_recv %d %d\n", ret, ao_radio_cmac_rssi);
+ PRINTD ("receive packet status %d rssi %d\n", ret, ao_radio_cmac_rssi);
if (ret != AO_RADIO_CMAC_OK)
continue;
ao_pad_packet_time = ao_time();
if (command.channels & ~(AO_PAD_ALL_CHANNELS))
break;
- time_difference = command.tick - ao_time();
- PRINTD ("arm tick %d local tick %d\n", command.tick, ao_time());
- if (time_difference < 0)
- time_difference = -time_difference;
- if (time_difference > 10) {
- PRINTD ("time difference too large %d\n", time_difference);
+ tick_difference = command.tick - (uint16_t) ao_time();
+ PRINTD ("arm tick %d local tick %d\n", command.tick, (uint16_t) ao_time());
+ if (tick_difference < 0)
+ tick_difference = -tick_difference;
+ if (tick_difference > 10) {
+ PRINTD ("tick difference too large %d\n", tick_difference);
+ break;
+ }
+ if (query.arm_status != AO_PAD_ARM_STATUS_ARMED) {
+ PRINTD ("box not armed locally\n");
break;
}
PRINTD ("armed\n");
PRINTD ("not armed\n");
break;
}
- if ((uint16_t) (ao_time() - ao_pad_arm_time) > AO_SEC_TO_TICKS(20)) {
- PRINTD ("late pad arm_time %d time %d\n",
- ao_pad_arm_time, ao_time());
+ if ((AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > AO_SEC_TO_TICKS(20)) {
+ PRINTD ("late pad arm_time %ld time %ld\n",
+ (long) ao_pad_arm_time, ao_time());
break;
}
PRINTD ("ignite\n");
#if HAS_LOG
if (!ao_log_running) ao_log_start();
#endif
- if ((uint16_t) (ao_time() - ao_pad_arm_time) > AO_SEC_TO_TICKS(20)) {
- PRINTD ("late pad arm_time %d time %d\n",
- ao_pad_arm_time, ao_time());
+ if ((AO_TICK_SIGNED) (ao_time() - ao_pad_arm_time) > AO_SEC_TO_TICKS(20)) {
+ PRINTD ("late pad arm_time %ld time %ld\n",
+ (long) ao_pad_arm_time, (long) ao_time());
break;
}
PRINTD ("ignite\n");