static void *etx_beacon(void *arg) { (void) arg; /* * Sends a message every ETX_INTERVAL +/- a jitter-value (default is 10%) . * A correcting variable is needed to stay at a base interval of * ETX_INTERVAL between the wakeups. It takes the old jittervalue in account * and modifies the time to wait accordingly. */ etx_probe_t *packet = etx_get_send_buf(); uint8_t p_length = 0; while (true) { thread_sleep(); mutex_lock(&etx_mutex); //Build etx packet p_length = 0; for (uint8_t i = 0; i < ETX_BEST_CANDIDATES; i++) { if (candidates[i].used != 0) { packet->data[i * ETX_TUPLE_SIZE] = candidates[i].addr.uint8[ETX_IPV6_LAST_BYTE]; packet->data[i * ETX_TUPLE_SIZE + ETX_PKT_REC_OFFSET] = etx_count_packet_tx(&candidates[i]); p_length = p_length + ETX_PKT_HDR_LEN; } } packet->length = p_length; /* will be send broadcast, so if_id and destination address will be * ignored (see documentation) */ sixlowpan_mac_send_ieee802154_frame(0, NULL, 8, &etx_send_buf[0], ETX_DATA_MAXLEN + ETX_PKT_HDR_LEN, 1); DEBUG("sent beacon!\n"); etx_set_packets_received(); cur_round++; if (cur_round == ETX_WINDOW) { if (reached_window != 1) { //first round is through reached_window = 1; } cur_round = 0; } mutex_unlock(&etx_mutex); } return NULL; }
void etx_beacon(void) { /* * Sends a message every ETX_INTERVAL +/- a jitter-value (default is 10%) . * A correcting variable is needed to stay at a base interval of * ETX_INTERVAL between the wakeups. It takes the old jittervalue in account * and modifies the time to wait accordingly. */ etx_probe_t * packet = etx_get_send_buf(); uint8_t p_length = 0; /* * xxx If you get a -Wmissing-braces warning here: * A -Wmissing-braces warning at this point is a gcc-bug! * Please delete this information once it's fixed * See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119 */ ieee_802154_long_t empty_addr = { 0 }; while (true) { thread_sleep(); mutex_lock(&etx_mutex); //Build etx packet p_length = 0; for (uint8_t i = 0; i < ETX_BEST_CANDIDATES; i++) { if (candidates[i].used != 0) { packet->data[i * ETX_TUPLE_SIZE] = candidates[i].addr.uint8[ETX_IPV6_LAST_BYTE]; packet->data[i * ETX_TUPLE_SIZE + ETX_PKT_REC_OFFSET] = etx_count_packet_tx(&candidates[i]); p_length = p_length + ETX_PKT_HDR_LEN; } } packet->length = p_length; send_ieee802154_frame(&empty_addr, &etx_send_buf[0], ETX_DATA_MAXLEN+ETX_PKT_HDR_LEN, 1); DEBUG("sent beacon!\n"); etx_set_packets_received(); cur_round++; if (cur_round == ETX_WINDOW) { if (reached_window != 1) { //first round is through reached_window = 1; } cur_round = 0; } mutex_unlock(&etx_mutex,0); } }