Merge pull request #1740 from simonduq/pr/tsch-minor
TSCH minor enhancements
This commit is contained in:
commit
7cfbbe97af
|
@ -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;
|
||||
|
|
|
@ -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 *****/
|
||||
|
|
|
@ -349,6 +349,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 */
|
||||
|
@ -549,10 +550,6 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
|
|||
if(n != NULL) {
|
||||
tsch_queue_update_time_source((linkaddr_t *)&frame.src_addr);
|
||||
|
||||
#ifdef TSCH_CALLBACK_JOINING_NETWORK
|
||||
TSCH_CALLBACK_JOINING_NETWORK();
|
||||
#endif
|
||||
|
||||
/* Set PANID */
|
||||
frame802154_set_pan_id(frame.src_pid);
|
||||
|
||||
|
@ -563,9 +560,13 @@ tsch_associate(const struct input_packet *input_eb, rtimer_clock_t timestamp)
|
|||
tsch_is_associated = 1;
|
||||
tsch_is_pan_secured = frame.fcf.security_enabled;
|
||||
|
||||
/* Association done, schedule keepalive messages */
|
||||
/* Start sending keep-alives now that tsch_is_associated is set */
|
||||
tsch_schedule_keepalive();
|
||||
|
||||
#ifdef TSCH_CALLBACK_JOINING_NETWORK
|
||||
TSCH_CALLBACK_JOINING_NETWORK();
|
||||
#endif
|
||||
|
||||
PRINTF("TSCH: association done, sec %u, PAN ID %x, asn-%x.%lx, jp %u, timeslot id %u, hopping id %u, slotframe len %u with %u links, from ",
|
||||
tsch_is_pan_secured,
|
||||
frame.src_pid,
|
||||
|
@ -909,7 +910,10 @@ send_packet(mac_callback_t sent, void *ptr)
|
|||
/* Enqueue packet */
|
||||
p = tsch_queue_add_packet(addr, sent, ptr);
|
||||
if(p == NULL) {
|
||||
PRINTF("TSCH:! can't send packet !tsch_queue_add_packet\n");
|
||||
PRINTF("TSCH:! can't send packet to %u with seqno %u, queue %u %u\n",
|
||||
TSCH_LOG_ID_FROM_LINKADDR(addr), tsch_packet_seqno,
|
||||
packet_count_before,
|
||||
tsch_queue_packet_count(addr));
|
||||
ret = MAC_TX_ERR;
|
||||
} else {
|
||||
p->header_len = hdr_len;
|
||||
|
@ -982,6 +986,11 @@ turn_on(void)
|
|||
static int
|
||||
turn_off(int keep_radio_on)
|
||||
{
|
||||
if(keep_radio_on) {
|
||||
NETSTACK_RADIO.on();
|
||||
} else {
|
||||
NETSTACK_RADIO.off();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in a new issue