From 1acb69e280b826fc338ac242cd16ef65ddc4373d Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Thu, 23 Jun 2016 18:35:16 +0200 Subject: [PATCH] TSCH: keep track of Rx channel as packetbuf attribute --- core/net/mac/tsch/tsch-slot-operation.c | 5 ++++- core/net/mac/tsch/tsch-slot-operation.h | 3 ++- core/net/mac/tsch/tsch.c | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/net/mac/tsch/tsch-slot-operation.c b/core/net/mac/tsch/tsch-slot-operation.c index be83da4ab..721a5c3db 100644 --- a/core/net/mac/tsch/tsch-slot-operation.c +++ b/core/net/mac/tsch/tsch-slot-operation.c @@ -154,6 +154,9 @@ static rtimer_clock_t volatile current_slot_start; /* Are we currently inside a slot? */ static volatile int tsch_in_slot_operation = 0; +/* If we are inside a slot, this tells the current channel */ +static uint8_t current_channel; + /* Info about the link, packet and neighbor of * the current (or next) slot */ struct tsch_link *current_link = NULL; @@ -780,6 +783,7 @@ PT_THREAD(tsch_rx_slot(struct pt *pt, struct rtimer *t)) NETSTACK_RADIO.get_value(RADIO_PARAM_LAST_RSSI, &radio_last_rssi); current_input->rx_asn = current_asn; current_input->rssi = (signed)radio_last_rssi; + current_input->channel = current_channel; header_len = frame802154_parse((uint8_t *)current_input->payload, current_input->len, &frame); frame_valid = header_len > 0 && frame802154_check_dest_panid(&frame) && @@ -937,7 +941,6 @@ PT_THREAD(tsch_slot_operation(struct rtimer *t, void *ptr)) ); } else { - uint8_t current_channel; int is_active_slot; TSCH_DEBUG_SLOT_START(); tsch_in_slot_operation = 1; diff --git a/core/net/mac/tsch/tsch-slot-operation.h b/core/net/mac/tsch/tsch-slot-operation.h index f74778c00..ec05d8736 100644 --- a/core/net/mac/tsch/tsch-slot-operation.h +++ b/core/net/mac/tsch/tsch-slot-operation.h @@ -89,7 +89,8 @@ struct input_packet { uint8_t payload[TSCH_PACKET_MAX_LEN]; /* Packet payload */ struct asn_t rx_asn; /* ASN when the packet was received */ int len; /* Packet len */ - uint16_t rssi; /* RSSI for this packet */ + int16_t rssi; /* RSSI for this packet */ + uint8_t channel; /* Channel we received the packet on */ }; /***** External Variables *****/ diff --git a/core/net/mac/tsch/tsch.c b/core/net/mac/tsch/tsch.c index 292744ecc..41aa56125 100644 --- a/core/net/mac/tsch/tsch.c +++ b/core/net/mac/tsch/tsch.c @@ -361,6 +361,7 @@ tsch_rx_process_pending() /* Copy to packetbuf for processing */ packetbuf_copyfrom(current_input->payload, current_input->len); packetbuf_set_attr(PACKETBUF_ATTR_RSSI, current_input->rssi); + packetbuf_set_attr(PACKETBUF_ATTR_CHANNEL, current_input->channel); } /* Remove input from ringbuf */