mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-08-17 13:29:10 +00:00
longer send period + forcing example to wait until an ongoing transmission is finished before initiating a new transmission
This commit is contained in:
parent
90691eb6a2
commit
3033201d24
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: example-runicast.c,v 1.1 2008/07/03 21:52:25 adamdunkels Exp $
|
* $Id: example-runicast.c,v 1.2 2008/11/11 13:50:21 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,6 +53,7 @@
|
|||||||
PROCESS(test_runicast_process, "runicast test");
|
PROCESS(test_runicast_process, "runicast test");
|
||||||
AUTOSTART_PROCESSES(&test_runicast_process);
|
AUTOSTART_PROCESSES(&test_runicast_process);
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static uint8_t in_tx;
|
||||||
static void
|
static void
|
||||||
recv_runicast(struct runicast_conn *c, rimeaddr_t *from, uint8_t seqno)
|
recv_runicast(struct runicast_conn *c, rimeaddr_t *from, uint8_t seqno)
|
||||||
{
|
{
|
||||||
@ -62,12 +63,14 @@ recv_runicast(struct runicast_conn *c, rimeaddr_t *from, uint8_t seqno)
|
|||||||
static void
|
static void
|
||||||
sent_runicast(struct runicast_conn *c, rimeaddr_t *to, uint8_t retransmissions)
|
sent_runicast(struct runicast_conn *c, rimeaddr_t *to, uint8_t retransmissions)
|
||||||
{
|
{
|
||||||
|
in_tx = 0;
|
||||||
printf("runicast message sent to %d.%d, retransmissions %d\n",
|
printf("runicast message sent to %d.%d, retransmissions %d\n",
|
||||||
to->u8[0], to->u8[1], retransmissions);
|
to->u8[0], to->u8[1], retransmissions);
|
||||||
}
|
}
|
||||||
static void
|
static void
|
||||||
timedout_runicast(struct runicast_conn *c, rimeaddr_t *to, uint8_t retransmissions)
|
timedout_runicast(struct runicast_conn *c, rimeaddr_t *to, uint8_t retransmissions)
|
||||||
{
|
{
|
||||||
|
in_tx = 0;
|
||||||
printf("runicast message timed out when sending to %d.%d, retransmissions %d\n",
|
printf("runicast message timed out when sending to %d.%d, retransmissions %d\n",
|
||||||
to->u8[0], to->u8[1], retransmissions);
|
to->u8[0], to->u8[1], retransmissions);
|
||||||
}
|
}
|
||||||
@ -79,24 +82,37 @@ static struct runicast_conn runicast;
|
|||||||
PROCESS_THREAD(test_runicast_process, ev, data)
|
PROCESS_THREAD(test_runicast_process, ev, data)
|
||||||
{
|
{
|
||||||
PROCESS_EXITHANDLER(runicast_close(&runicast);)
|
PROCESS_EXITHANDLER(runicast_close(&runicast);)
|
||||||
|
|
||||||
PROCESS_BEGIN();
|
PROCESS_BEGIN();
|
||||||
|
|
||||||
runicast_open(&runicast, 128, &runicast_callbacks);
|
runicast_open(&runicast, 128, &runicast_callbacks);
|
||||||
|
in_tx = 0;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
static struct etimer et;
|
static struct etimer et;
|
||||||
rimeaddr_t addr;
|
|
||||||
|
etimer_set(&et, 10*CLOCK_SECOND);
|
||||||
etimer_set(&et, CLOCK_SECOND);
|
|
||||||
|
|
||||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||||
|
|
||||||
rimebuf_copyfrom("Hello", 5);
|
if(!in_tx &&
|
||||||
addr.u8[0] = 41;
|
!(rimeaddr_node_addr.u8[0] == 1 &&
|
||||||
addr.u8[1] = 41;
|
rimeaddr_node_addr.u8[1] == 0)) {
|
||||||
runicast_send(&runicast, &addr, MAX_RETRANSMISSIONS);
|
rimeaddr_t recv;
|
||||||
|
|
||||||
|
rimebuf_copyfrom("Hello", 5);
|
||||||
|
recv.u8[0] = 1;
|
||||||
|
recv.u8[1] = 0;
|
||||||
|
|
||||||
|
/*printf("%u.%u: sending runicast to address %u.%u\n",
|
||||||
|
rimeaddr_node_addr.u8[0],
|
||||||
|
rimeaddr_node_addr.u8[1],
|
||||||
|
recv.u8[0],
|
||||||
|
recv.u8[1]);*/
|
||||||
|
|
||||||
|
in_tx = 1;
|
||||||
|
runicast_send(&runicast, &recv, MAX_RETRANSMISSIONS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PROCESS_END();
|
PROCESS_END();
|
||||||
|
Loading…
Reference in New Issue
Block a user