TSCH: keep track of Rx channel as packetbuf attribute

This commit is contained in:
Simon Duquennoy 2016-06-23 18:35:16 +02:00
parent a8989f9f1c
commit 1acb69e280
3 changed files with 7 additions and 2 deletions

View File

@ -154,6 +154,9 @@ static rtimer_clock_t volatile current_slot_start;
/* Are we currently inside a slot? */ /* Are we currently inside a slot? */
static volatile int tsch_in_slot_operation = 0; 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 /* Info about the link, packet and neighbor of
* the current (or next) slot */ * the current (or next) slot */
struct tsch_link *current_link = NULL; 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); NETSTACK_RADIO.get_value(RADIO_PARAM_LAST_RSSI, &radio_last_rssi);
current_input->rx_asn = current_asn; current_input->rx_asn = current_asn;
current_input->rssi = (signed)radio_last_rssi; 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); header_len = frame802154_parse((uint8_t *)current_input->payload, current_input->len, &frame);
frame_valid = header_len > 0 && frame_valid = header_len > 0 &&
frame802154_check_dest_panid(&frame) && frame802154_check_dest_panid(&frame) &&
@ -937,7 +941,6 @@ PT_THREAD(tsch_slot_operation(struct rtimer *t, void *ptr))
); );
} else { } else {
uint8_t current_channel;
int is_active_slot; int is_active_slot;
TSCH_DEBUG_SLOT_START(); TSCH_DEBUG_SLOT_START();
tsch_in_slot_operation = 1; tsch_in_slot_operation = 1;

View File

@ -89,7 +89,8 @@ struct input_packet {
uint8_t payload[TSCH_PACKET_MAX_LEN]; /* Packet payload */ uint8_t payload[TSCH_PACKET_MAX_LEN]; /* Packet payload */
struct asn_t rx_asn; /* ASN when the packet was received */ struct asn_t rx_asn; /* ASN when the packet was received */
int len; /* Packet len */ 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 *****/ /***** External Variables *****/

View File

@ -361,6 +361,7 @@ tsch_rx_process_pending()
/* Copy to packetbuf for processing */ /* Copy to packetbuf for processing */
packetbuf_copyfrom(current_input->payload, current_input->len); packetbuf_copyfrom(current_input->payload, current_input->len);
packetbuf_set_attr(PACKETBUF_ATTR_RSSI, current_input->rssi); packetbuf_set_attr(PACKETBUF_ATTR_RSSI, current_input->rssi);
packetbuf_set_attr(PACKETBUF_ATTR_CHANNEL, current_input->channel);
} }
/* Remove input from ringbuf */ /* Remove input from ringbuf */