adding ducy cycling support to the stm32w-based platforms (patch by Chi-Anh La)

This commit is contained in:
simonduq 2012-03-19 14:00:57 +01:00
parent 2aa1f587bd
commit 5da4463236
9 changed files with 287 additions and 56 deletions

View file

@ -454,6 +454,7 @@ send_packet(void)
rtimer_clock_t t;
rtimer_clock_t encounter_time = 0;
int strobes;
int ret;
#if 0
struct xmac_hdr *hdr;
#endif
@ -640,11 +641,11 @@ send_packet(void)
if(is_broadcast) {
#if WITH_STROBE_BROADCAST
NETSTACK_RADIO.send(strobe, strobe_len);
ret = NETSTACK_RADIO.send(strobe, strobe_len);
#else
/* restore the packet to send */
queuebuf_to_packetbuf(packet);
NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen());
ret = NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen());
#endif
off();
} else {
@ -652,7 +653,7 @@ send_packet(void)
rtimer_clock_t wt;
#endif
on();
NETSTACK_RADIO.send(strobe, strobe_len);
ret = NETSTACK_RADIO.send(strobe, strobe_len);
#if 0
/* Turn off the radio for a while to let the other side
respond. We don't need to keep our radio on when we know
@ -661,12 +662,20 @@ send_packet(void)
wt = RTIMER_NOW();
while(RTIMER_CLOCK_LT(RTIMER_NOW(), wt + WAIT_TIME_BEFORE_STROBE_ACK));
#endif /* 0 */
#if RDC_CONF_HARDWARE_ACK
if(ret == RADIO_TX_OK) {
got_strobe_ack = 1;
} else {
off();
}
#else
if(detect_ack()) {
got_strobe_ack = 1;
} else {
off();
}
#endif /* RDC_CONF_HARDWARE_ACK */
}
}
}
@ -693,12 +702,18 @@ send_packet(void)
/* Send the data packet. */
if((is_broadcast || got_strobe_ack || is_streaming) && collisions == 0) {
NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen());
ret = NETSTACK_RADIO.send(packetbuf_hdrptr(), packetbuf_totlen());
if(!is_broadcast) {
#if RDC_CONF_HARDWARE_ACK
if(ret == RADIO_TX_OK) {
got_ack = 1;
}
#else
if(detect_ack()) {
got_ack = 1;
}
#endif /* RDC_CONF_HARDWARE_ACK */
}
}
off();