47 #define LOG_MODULE "Orchestra" 48 #define LOG_LEVEL LOG_LEVEL_MAC 52 static uint8_t is_root_rule_used;
53 static uint16_t timeslot_tx;
55 static void set_self_to_root(uint8_t is_root);
62 return tsch_is_coordinator;
66 orchestra_is_root_schedule_active(
const linkaddr_t *
addr)
72 get_node_timeslot(
const linkaddr_t *
addr)
74 if(addr != NULL && ORCHESTRA_ROOT_PERIOD > 0) {
75 return ORCHESTRA_LINKADDR_HASH(addr) % ORCHESTRA_ROOT_PERIOD;
82 get_node_channel_offset(
const linkaddr_t *addr)
84 if(addr != NULL && ORCHESTRA_UNICAST_MAX_CHANNEL_OFFSET >= ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET) {
85 return ORCHESTRA_LINKADDR_HASH(addr) % (ORCHESTRA_UNICAST_MAX_CHANNEL_OFFSET - ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET + 1)
86 + ORCHESTRA_UNICAST_MIN_CHANNEL_OFFSET;
93 select_packet(uint16_t *slotframe, uint16_t *timeslot, uint16_t *channel_offset)
96 const linkaddr_t *dest = packetbuf_addr(PACKETBUF_ADDR_RECEIVER);
99 && packetbuf_attr(PACKETBUF_ATTR_FRAME_TYPE) == FRAME802154_DATAFRAME
101 && orchestra_is_root_schedule_active(dest)) {
102 if(slotframe != NULL) {
103 *slotframe = sf_tx->handle;
105 if(timeslot != NULL) {
106 *timeslot = timeslot_tx;
109 if(channel_offset != NULL) {
110 *channel_offset = get_node_channel_offset(dest);
113 LOG_INFO(
"use the root rule for root node ");
114 LOG_INFO_LLADDR(dest);
122 init(uint16_t sf_handle)
125 is_root_rule_used = 1;
131 LOG_ERR(
"failed to add a slotframe for transmissions\n");
134 if(tsch_is_coordinator) {
141 set_self_to_root(uint8_t is_root)
143 const uint16_t slotframe_rx_handle = (sf_tx == NULL ? (uint16_t)-1 : (sf_tx->handle | 0x8000));
145 if(is_root_rule_used == 0) {
155 LOG_ERR(
"failed to add a slotframe for reception\n");
160 LINK_OPTION_SHARED | LINK_OPTION_RX,
161 LINK_TYPE_NORMAL, &tsch_broadcast_address,
174 root_node_updated(
const linkaddr_t *root, uint8_t is_added)
178 set_self_to_root(is_added);
190 LINK_OPTION_SHARED | LINK_OPTION_TX,
191 LINK_TYPE_NORMAL, root,
192 timeslot_tx, get_node_channel_offset(root), 0);
199 struct orchestra_rule special_for_root = {
207 ORCHESTRA_ROOT_PERIOD,
static uip_ds6_addr_t * addr
Pointer to a nbr cache entry.
802.15.4e slotframe (contains links)
struct tsch_slotframe * tsch_schedule_add_slotframe(uint16_t handle, uint16_t size)
Creates and adds a new slotframe.
linkaddr_t linkaddr_node_addr
The link-layer address of the node.
int tsch_schedule_remove_link_by_timeslot(struct tsch_slotframe *slotframe, uint16_t timeslot, uint16_t channel_offset)
Removes a link from a slotframe and timeslot.
int tsch_roots_is_root(const linkaddr_t *address)
Tests whether a given address belongs to a single-hop reachable root node in this network...
struct tsch_link * tsch_schedule_add_link(struct tsch_slotframe *slotframe, uint8_t link_options, enum link_type link_type, const linkaddr_t *address, uint16_t timeslot, uint16_t channel_offset, uint8_t do_remove)
Adds a link to a slotframe.
int tsch_schedule_remove_slotframe(struct tsch_slotframe *slotframe)
Removes a slotframe.
int linkaddr_cmp(const linkaddr_t *addr1, const linkaddr_t *addr2)
Compare two link-layer addresses.
Header file for the logging system
void tsch_queue_free_packets_to(const linkaddr_t *addr)
Flush packets to a specific address.