Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 6be455f

Browse files
Juha Heiskanenjuhhei01
authored andcommitted
WS ETX update
ETX attempts update for Unicast and ACK requested messages. EXT dbm and lqi update added EXT remove call added to
1 parent 0efc062 commit 6be455f

File tree

2 files changed

+48
-5
lines changed

2 files changed

+48
-5
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static void ws_bootstrap_state_change(protocol_interface_info_entry_t *cur, icmp
7777
static bool ws_bootstrap_state_active(struct protocol_interface_info_entry *cur);
7878
static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *cur);
7979

80-
mac_neighbor_table_entry_t * ws_bootstrap_add_neighbor(struct protocol_interface_info_entry *interface, const uint8_t *src64)
80+
static mac_neighbor_table_entry_t * ws_bootstrap_add_neighbor(struct protocol_interface_info_entry *interface, const uint8_t *src64)
8181
{
8282
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, src64, MAC_ADDR_MODE_64_BIT);
8383
if (!neighbor) {
@@ -89,7 +89,6 @@ mac_neighbor_table_entry_t * ws_bootstrap_add_neighbor(struct protocol_interface
8989
mac_helper_devicetable_set(&device_desc, interface,neighbor->index, interface->mac_parameters->mac_default_key_index, true);
9090
}
9191
}
92-
9392
return neighbor;
9493
}
9594

@@ -322,11 +321,13 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
322321
if (!neighbor) {
323322
return;
324323
}
324+
325325
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&cur->ws_info->neighbor_storage, neighbor->index);
326326
if (!ws_neighbor) {
327327
return;
328328
}
329329

330+
etx_lqi_dbm_update(cur->id, data->mpduLinkQuality, data->signal_dbm, neighbor->index);
330331
ws_neighbor_class_neighbor_unicast_time_info_update(ws_neighbor, ws_utt, data->timestamp);
331332
ws_neighbor_class_neighbor_unicast_schedule_set(ws_neighbor, ws_us);
332333

@@ -453,6 +454,7 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
453454
if (!ws_neighbor) {
454455
return;
455456
}
457+
etx_lqi_dbm_update(cur->id, data->mpduLinkQuality, data->signal_dbm, neighbor->index);
456458
//Update Neighbor Broadcast and Unicast Parameters
457459
ws_neighbor_class_neighbor_unicast_time_info_update(ws_neighbor, ws_utt, data->timestamp);
458460
ws_neighbor_class_neighbor_unicast_schedule_set(ws_neighbor, ws_us);
@@ -491,7 +493,8 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
491493
//Broadcast schedule
492494
cur->ws_info->hopping_schdule.fhss_broadcast_interval = ws_bs_ie.broadcast_interval;
493495
cur->ws_info->hopping_schdule.fhss_bsi = ws_bs_ie.broadcast_schedule_identifier;
494-
cur->ws_info->hopping_schdule.fhss_uc_dwell_interval = ws_bs_ie.dwell_interval;
496+
cur->ws_info->hopping_schdule.fhss_bc_dwell_interval = ws_bs_ie.dwell_interval;
497+
495498

496499
if (!cur->ws_info->configuration_learned) {
497500
// Generate own hopping schedules Follow first parent broadcast and plans and also use same unicast dwell
@@ -637,8 +640,8 @@ static void ws_neighbor_entry_remove_notify(mac_neighbor_table_entry_t *entry_pt
637640
ws_neighbor_class_entry_remove(&cur->ws_info->neighbor_storage, entry_ptr->index);
638641
topo_trace(TOPOLOGY_MLE, entry_ptr->ext64, TOPO_REMOVE);
639642

640-
//TODO Remove ETX neighbor
641-
//etx_neighbor_remove(interface_id, entry);
643+
//SET ETX to infinity
644+
etx_neighbor_remove(cur->id, entry_ptr->index);
642645
}
643646

644647

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "6LoWPAN/ws/ws_mpx_header.h"
3737
#include "6LoWPAN/ws/ws_neighbor_class.h"
3838
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
39+
#include "Service_Libs/etx/etx.h"
3940

4041
#ifdef HAVE_WS
4142

@@ -73,8 +74,11 @@ typedef struct {
7374
} llc_ie_params_t;
7475

7576
typedef struct {
77+
uint8_t dst_address[8]; /**< Destination address */
7678
unsigned messsage_type:3; /**< Frame type to UTT */
7779
unsigned mpx_id:5; /**< MPX sequence */
80+
bool ack_requested:1; /**< ACK requested */
81+
unsigned dst_address_type:2; /**< Destination address type */
7882
uint8_t msg_handle; /**< LLC genetaed unique MAC handle */
7983
uint8_t mpx_user_handle; /**< This MPX user defined handle */
8084
ns_ie_iovec_t ie_vector_list[3]; /**< IE vectors: 1 for Header's, 1 for Payload and for MPX payload */
@@ -358,6 +362,8 @@ static void ws_llc_mac_confirm_cb(const mac_api_t* api, const mcps_data_conf_t *
358362
return;
359363
}
360364

365+
protocol_interface_info_entry_t *interface = base->interface_ptr;
366+
361367
llc_message_t *message = llc_message_discover_by_mac_handle(data->msduHandle, &base->llc_message_list);
362368
if (!message) {
363369
return;
@@ -378,6 +384,34 @@ static void ws_llc_mac_confirm_cb(const mac_api_t* api, const mcps_data_conf_t *
378384
mpx_user_id = MPX_KEY_MANAGEMENT_ENC_USER_ID;
379385
}
380386

387+
//ETX update
388+
if (message->ack_requested && messsage_type == WS_FT_DATA ) {
389+
390+
ws_neighbor_class_entry_t * ws_neighbor = NULL;
391+
mac_neighbor_table_entry_t *neighbor = NULL;
392+
bool success = false;
393+
394+
switch (data->status) {
395+
case MLME_SUCCESS:
396+
case MLME_TX_NO_ACK:
397+
case MLME_NO_DATA:
398+
if (data->status == MLME_SUCCESS ) {
399+
success = true;
400+
}
401+
neighbor = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, message->dst_address, message->dst_address_type);
402+
if (neighbor) {
403+
ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor->index);
404+
}
405+
if (ws_neighbor) {
406+
etx_transm_attempts_update(interface->id, 1 + data->tx_retries , success, neighbor->index);
407+
//TODO discover RSL from Enchanced ACK Header IE elements
408+
}
409+
break;
410+
default:
411+
break;
412+
}
413+
}
414+
381415
user_cb = ws_llc_mpx_user_discover(&base->mpx_data_base, mpx_user_id);
382416
if (user_cb && user_cb->data_confirm) {
383417
//Call MPX registered call back
@@ -430,6 +464,7 @@ static void ws_llc_mac_indication_cb(const mac_api_t* api, const mcps_data_ind_t
430464
if (ws_utt.message_type == WS_FT_DATA && data->DstAddrMode && addr_check_broadcast(data->DstAddr, data->DstAddrMode)) {
431465
tr_debug("Refresh neigh index %u", neighbor->index);
432466
mac_neighbor_table_neighbor_refresh(interface->mac_parameters->mac_neighbor_table, neighbor, neighbor->link_lifetime);
467+
etx_lqi_dbm_update(interface->id, data->mpduLinkQuality, data->signal_dbm, neighbor->index);
433468
}
434469
}
435470

@@ -547,6 +582,11 @@ static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data
547582
}
548583
mcps_data_req_t data_req;
549584
message->mpx_user_handle = data->msduHandle;
585+
message->ack_requested = data->TxAckReq;
586+
if (data->TxAckReq) {
587+
message->dst_address_type = data->DstAddrMode;
588+
memcpy(message->dst_address, data->DstAddr, 8);
589+
}
550590
data_req = *data;
551591
data_req.msdu = NULL;
552592
data_req.msduLength = 0;

0 commit comments

Comments
 (0)