Minor code style fixes to the contikimac and nullrdc code
This commit is contained in:
parent
ef25cc6c58
commit
0670a8e1e2
|
@ -377,7 +377,8 @@ powercycle(struct rtimer *t, void *ptr)
|
||||||
static uint8_t count;
|
static uint8_t count;
|
||||||
|
|
||||||
#if SYNC_CYCLE_STARTS
|
#if SYNC_CYCLE_STARTS
|
||||||
/* Compute cycle start when RTIMER_ARCH_SECOND is not a multiple of CHANNEL_CHECK_RATE */
|
/* Compute cycle start when RTIMER_ARCH_SECOND is not a multiple
|
||||||
|
of CHANNEL_CHECK_RATE */
|
||||||
if(sync_cycle_phase++ == NETSTACK_RDC_CHANNEL_CHECK_RATE) {
|
if(sync_cycle_phase++ == NETSTACK_RDC_CHANNEL_CHECK_RATE) {
|
||||||
sync_cycle_phase = 0;
|
sync_cycle_phase = 0;
|
||||||
sync_cycle_start += RTIMER_ARCH_SECOND;
|
sync_cycle_start += RTIMER_ARCH_SECOND;
|
||||||
|
@ -475,9 +476,10 @@ powercycle(struct rtimer *t, void *ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(RTIMER_CLOCK_LT(RTIMER_NOW() - cycle_start, CYCLE_TIME - CHECK_TIME * 4)) {
|
if(RTIMER_CLOCK_LT(RTIMER_NOW() - cycle_start, CYCLE_TIME - CHECK_TIME * 4)) {
|
||||||
/* Schedule the next powercycle interrupt, or sleep the mcu until then.
|
/* Schedule the next powercycle interrupt, or sleep the mcu
|
||||||
Sleeping will not exit from this interrupt, so ensure an occasional wake cycle
|
until then. Sleeping will not exit from this interrupt, so
|
||||||
or foreground processing will be blocked until a packet is detected */
|
ensure an occasional wake cycle or foreground processing will
|
||||||
|
be blocked until a packet is detected */
|
||||||
#if RDC_CONF_MCU_SLEEP
|
#if RDC_CONF_MCU_SLEEP
|
||||||
static uint8_t sleepcycle;
|
static uint8_t sleepcycle;
|
||||||
if((sleepcycle++ < 16) && !we_are_sending && !radio_is_on) {
|
if((sleepcycle++ < 16) && !we_are_sending && !radio_is_on) {
|
||||||
|
@ -519,7 +521,9 @@ broadcast_rate_drop(void)
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int
|
static int
|
||||||
send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_list *buf_list)
|
send_packet(mac_callback_t mac_callback, void *mac_callback_ptr,
|
||||||
|
struct rdc_buf_list *buf_list,
|
||||||
|
int is_receiver_awake)
|
||||||
{
|
{
|
||||||
rtimer_clock_t t0;
|
rtimer_clock_t t0;
|
||||||
rtimer_clock_t encounter_time = 0;
|
rtimer_clock_t encounter_time = 0;
|
||||||
|
@ -609,7 +613,6 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Make sure that the packet is longer or equal to the shortest
|
/* Make sure that the packet is longer or equal to the shortest
|
||||||
packet length. */
|
packet length. */
|
||||||
transmit_len = packetbuf_totlen();
|
transmit_len = packetbuf_totlen();
|
||||||
|
@ -720,8 +723,9 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_
|
||||||
|
|
||||||
#if !RDC_CONF_HARDWARE_ACK
|
#if !RDC_CONF_HARDWARE_ACK
|
||||||
if(!is_broadcast) {
|
if(!is_broadcast) {
|
||||||
/* Turn radio on to receive expected unicast ack.
|
/* Turn radio on to receive expected unicast ack. Not necessary
|
||||||
Not necessary with hardware ack detection, and may trigger an unnecessary cca or rx cycle */
|
with hardware ack detection, and may trigger an unnecessary cca
|
||||||
|
or rx cycle */
|
||||||
on();
|
on();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -735,14 +739,14 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_
|
||||||
|
|
||||||
watchdog_periodic();
|
watchdog_periodic();
|
||||||
|
|
||||||
if((is_receiver_awake || is_known_receiver) && !RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + MAX_PHASE_STROBE_TIME)) {
|
if(!is_broadcast && (is_receiver_awake || is_known_receiver) &&
|
||||||
|
!RTIMER_CLOCK_LT(RTIMER_NOW(), t0 + MAX_PHASE_STROBE_TIME)) {
|
||||||
PRINTF("miss to %d\n", packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[0]);
|
PRINTF("miss to %d\n", packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
rtimer_clock_t wt;
|
rtimer_clock_t wt;
|
||||||
rtimer_clock_t txtime;
|
rtimer_clock_t txtime;
|
||||||
|
@ -752,7 +756,8 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_
|
||||||
ret = NETSTACK_RADIO.transmit(transmit_len);
|
ret = NETSTACK_RADIO.transmit(transmit_len);
|
||||||
|
|
||||||
#if RDC_CONF_HARDWARE_ACK
|
#if RDC_CONF_HARDWARE_ACK
|
||||||
/* For radios that block in the transmit routine and detect the ACK in hardware */
|
/* For radios that block in the transmit routine and detect the
|
||||||
|
ACK in hardware */
|
||||||
if(ret == RADIO_TX_OK) {
|
if(ret == RADIO_TX_OK) {
|
||||||
if(!is_broadcast) {
|
if(!is_broadcast) {
|
||||||
got_strobe_ack = 1;
|
got_strobe_ack = 1;
|
||||||
|
@ -766,7 +771,7 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_
|
||||||
}
|
}
|
||||||
wt = RTIMER_NOW();
|
wt = RTIMER_NOW();
|
||||||
while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + INTER_PACKET_INTERVAL)) { }
|
while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + INTER_PACKET_INTERVAL)) { }
|
||||||
#else
|
#else /* RDC_CONF_HARDWARE_ACK */
|
||||||
/* Wait for the ACK packet */
|
/* Wait for the ACK packet */
|
||||||
wt = RTIMER_NOW();
|
wt = RTIMER_NOW();
|
||||||
while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + INTER_PACKET_INTERVAL)) { }
|
while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + INTER_PACKET_INTERVAL)) { }
|
||||||
|
@ -829,16 +834,16 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, struct rdc_buf_
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WITH_PHASE_OPTIMIZATION
|
#if WITH_PHASE_OPTIMIZATION
|
||||||
|
|
||||||
if(is_known_receiver && got_strobe_ack) {
|
if(is_known_receiver && got_strobe_ack) {
|
||||||
PRINTF("no miss %d wake-ups %d\n", packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[0],
|
PRINTF("no miss %d wake-ups %d\n",
|
||||||
|
packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[0],
|
||||||
strobes);
|
strobes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_broadcast) {
|
if(!is_broadcast) {
|
||||||
if(collisions == 0 && is_receiver_awake == 0) {
|
if(collisions == 0 && is_receiver_awake == 0) {
|
||||||
phase_update(&phase_list, packetbuf_addr(PACKETBUF_ADDR_RECEIVER), encounter_time,
|
phase_update(&phase_list, packetbuf_addr(PACKETBUF_ADDR_RECEIVER),
|
||||||
ret);
|
encounter_time, ret);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* WITH_PHASE_OPTIMIZATION */
|
#endif /* WITH_PHASE_OPTIMIZATION */
|
||||||
|
@ -903,8 +908,9 @@ qsend_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list)
|
||||||
is_receiver_awake = 0;
|
is_receiver_awake = 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Timer callback triggered when receiving a burst, after having waited for a next
|
/* Timer callback triggered when receiving a burst, after having
|
||||||
packet for a too long time. Turns the radio off and leaves burst reception mode */
|
waited for a next packet for a too long time. Turns the radio off
|
||||||
|
and leaves burst reception mode */
|
||||||
static void
|
static void
|
||||||
recv_burst_off(void *ptr)
|
recv_burst_off(void *ptr)
|
||||||
{
|
{
|
||||||
|
@ -952,7 +958,8 @@ input_packet(void)
|
||||||
we_are_receiving_burst = packetbuf_attr(PACKETBUF_ATTR_PENDING);
|
we_are_receiving_burst = packetbuf_attr(PACKETBUF_ATTR_PENDING);
|
||||||
if(we_are_receiving_burst) {
|
if(we_are_receiving_burst) {
|
||||||
on();
|
on();
|
||||||
/* Set a timer to turn the radio off in case we do not receive a next packet */
|
/* Set a timer to turn the radio off in case we do not receive
|
||||||
|
a next packet */
|
||||||
ctimer_set(&ct, INTER_PACKET_DEADLINE, recv_burst_off, NULL);
|
ctimer_set(&ct, INTER_PACKET_DEADLINE, recv_burst_off, NULL);
|
||||||
} else {
|
} else {
|
||||||
off();
|
off();
|
||||||
|
|
|
@ -110,8 +110,9 @@ static void packet_sent(void *ptr, int status, int num_transmissions);
|
||||||
static void transmit_packet_list(void *ptr);
|
static void transmit_packet_list(void *ptr);
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static struct
|
static struct neighbor_queue *
|
||||||
neighbor_queue *neighbor_queue_from_addr(const rimeaddr_t *addr) {
|
neighbor_queue_from_addr(const rimeaddr_t *addr)
|
||||||
|
{
|
||||||
struct neighbor_queue *n = list_head(neighbor_list);
|
struct neighbor_queue *n = list_head(neighbor_list);
|
||||||
while(n != NULL) {
|
while(n != NULL) {
|
||||||
if(rimeaddr_cmp(&n->addr, addr)) {
|
if(rimeaddr_cmp(&n->addr, addr)) {
|
||||||
|
|
Loading…
Reference in a new issue