From 101575fbe2cc04b9aea7e2899e27f54e0bf31b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Corbal=C3=A1n?= Date: Wed, 1 Jun 2016 00:31:08 +0100 Subject: [PATCH] RIME: Extend unicast example to include a sent callback. This PR simply adds a packet sent callback to the unicast connection used in the example. Every time a packet is sent the callback is called and prints the linkaddr_t dest, the MAC status of the message sent, and the link layer number of transmissions of the packet. This can be used to compute link quality estimations. --- examples/rime/example-unicast.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/rime/example-unicast.c b/examples/rime/example-unicast.c index 5d28ef66f..7ee764a54 100644 --- a/examples/rime/example-unicast.c +++ b/examples/rime/example-unicast.c @@ -39,11 +39,6 @@ #include "contiki.h" #include "net/rime/rime.h" - -#include "dev/button-sensor.h" - -#include "dev/leds.h" - #include /*---------------------------------------------------------------------------*/ @@ -56,7 +51,19 @@ recv_uc(struct unicast_conn *c, const linkaddr_t *from) printf("unicast message received from %d.%d\n", from->u8[0], from->u8[1]); } -static const struct unicast_callbacks unicast_callbacks = {recv_uc}; +/*---------------------------------------------------------------------------*/ +static void +sent_uc(struct unicast_conn *c, int status, int num_tx) +{ + const linkaddr_t *dest = packetbuf_addr(PACKETBUF_ADDR_RECEIVER); + if(linkaddr_cmp(dest, &linkaddr_null)) { + return; + } + printf("unicast message sent to %d.%d: status %d num_tx %d\n", + dest->u8[0], dest->u8[1], status, num_tx); +} +/*---------------------------------------------------------------------------*/ +static const struct unicast_callbacks unicast_callbacks = {recv_uc, sent_uc}; static struct unicast_conn uc; /*---------------------------------------------------------------------------*/ PROCESS_THREAD(example_unicast_process, ev, data)