Added the MAC layer callback functionality so that the Rime network layer gets information from the MAC about the status of sent packets: were they successfully transmitted, or was there a collisions? How many retries were there?
This commit is contained in:
parent
f10eedab3e
commit
ca0417a923
11 changed files with 126 additions and 44 deletions
|
@ -34,7 +34,7 @@
|
|||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: runicast.c,v 1.9 2010/01/26 10:19:26 adamdunkels Exp $
|
||||
* $Id: runicast.c,v 1.10 2010/02/23 18:38:05 adamdunkels Exp $
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -73,33 +73,41 @@ static const struct packetbuf_attrlist attributes[] =
|
|||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
static void
|
||||
sent_by_stunicast(struct stunicast_conn *stunicast)
|
||||
sent_by_stunicast(struct stunicast_conn *stunicast, int status, int num_tx)
|
||||
{
|
||||
struct runicast_conn *c = (struct runicast_conn *)stunicast;
|
||||
|
||||
if(c->rxmit != 0) {
|
||||
RIMESTATS_ADD(rexmit);
|
||||
PRINTF("%d.%d: runicast: packet %u resent %u\n",
|
||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
||||
packetbuf_attr(PACKETBUF_ATTR_PACKET_ID), c->rxmit);
|
||||
}
|
||||
PRINTF("runicast: sent_by_stunicast c->rxmit %d num_tx %d\n",
|
||||
c->rxmit, num_tx);
|
||||
|
||||
c->rxmit++;
|
||||
if(c->rxmit >= c->max_rxmit) {
|
||||
RIMESTATS_ADD(timedout);
|
||||
c->is_tx = 0;
|
||||
stunicast_cancel(&c->c);
|
||||
if(c->u->timedout) {
|
||||
c->u->timedout(c, stunicast_receiver(&c->c), c->rxmit);
|
||||
/* Only process data packets, not ACKs. */
|
||||
if(packetbuf_attr(PACKETBUF_ATTR_PACKET_TYPE) == PACKETBUF_ATTR_PACKET_TYPE_DATA) {
|
||||
|
||||
c->rxmit += num_tx;
|
||||
|
||||
if(c->rxmit != 0) {
|
||||
RIMESTATS_ADD(rexmit);
|
||||
PRINTF("%d.%d: runicast: packet %u resent %u\n",
|
||||
rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1],
|
||||
packetbuf_attr(PACKETBUF_ATTR_PACKET_ID), c->rxmit);
|
||||
}
|
||||
if(c->rxmit >= c->max_rxmit) {
|
||||
RIMESTATS_ADD(timedout);
|
||||
c->is_tx = 0;
|
||||
stunicast_cancel(&c->c);
|
||||
if(c->u->timedout) {
|
||||
c->u->timedout(c, stunicast_receiver(&c->c), c->rxmit);
|
||||
}
|
||||
c->rxmit = 0;
|
||||
PRINTF("%d.%d: runicast: packet %d timed out\n",
|
||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
|
||||
c->sndnxt);
|
||||
} else {
|
||||
int shift;
|
||||
|
||||
shift = c->rxmit > 4? 4: c->rxmit;
|
||||
stunicast_set_timer(&c->c, (REXMIT_TIME) << shift);
|
||||
}
|
||||
PRINTF("%d.%d: runicast: packet %d timed out\n",
|
||||
rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1],
|
||||
c->sndnxt);
|
||||
} else {
|
||||
int shift;
|
||||
|
||||
shift = c->rxmit > 4? 4: c->rxmit;
|
||||
stunicast_set_timer(&c->c, (REXMIT_TIME) << shift);
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue