Skip to content

Commit

Permalink
WS ETX update
Browse files Browse the repository at this point in the history
ETX attempts update for Unicast and ACK requested messages.

EXT dbm and lqi update added 

EXT remove call added to
  • Loading branch information
Juha Heiskanen authored and juhhei01 committed Mar 12, 2018
1 parent 0efc062 commit 6be455f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
13 changes: 8 additions & 5 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static void ws_bootstrap_state_change(protocol_interface_info_entry_t *cur, icmp
static bool ws_bootstrap_state_active(struct protocol_interface_info_entry *cur);
static bool ws_bootstrap_state_discovery(struct protocol_interface_info_entry *cur);

mac_neighbor_table_entry_t * ws_bootstrap_add_neighbor(struct protocol_interface_info_entry *interface, const uint8_t *src64)
static mac_neighbor_table_entry_t * ws_bootstrap_add_neighbor(struct protocol_interface_info_entry *interface, const uint8_t *src64)
{
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, src64, MAC_ADDR_MODE_64_BIT);
if (!neighbor) {
Expand All @@ -89,7 +89,6 @@ mac_neighbor_table_entry_t * ws_bootstrap_add_neighbor(struct protocol_interface
mac_helper_devicetable_set(&device_desc, interface,neighbor->index, interface->mac_parameters->mac_default_key_index, true);
}
}

return neighbor;
}

Expand Down Expand Up @@ -322,11 +321,13 @@ static void ws_bootstrap_pan_advertisement_analyse(struct protocol_interface_inf
if (!neighbor) {
return;
}

ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&cur->ws_info->neighbor_storage, neighbor->index);
if (!ws_neighbor) {
return;
}

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

Expand Down Expand Up @@ -453,6 +454,7 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
if (!ws_neighbor) {
return;
}
etx_lqi_dbm_update(cur->id, data->mpduLinkQuality, data->signal_dbm, neighbor->index);
//Update Neighbor Broadcast and Unicast Parameters
ws_neighbor_class_neighbor_unicast_time_info_update(ws_neighbor, ws_utt, data->timestamp);
ws_neighbor_class_neighbor_unicast_schedule_set(ws_neighbor, ws_us);
Expand Down Expand Up @@ -491,7 +493,8 @@ static void ws_bootstrap_pan_config_analyse(struct protocol_interface_info_entry
//Broadcast schedule
cur->ws_info->hopping_schdule.fhss_broadcast_interval = ws_bs_ie.broadcast_interval;
cur->ws_info->hopping_schdule.fhss_bsi = ws_bs_ie.broadcast_schedule_identifier;
cur->ws_info->hopping_schdule.fhss_uc_dwell_interval = ws_bs_ie.dwell_interval;
cur->ws_info->hopping_schdule.fhss_bc_dwell_interval = ws_bs_ie.dwell_interval;


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

//TODO Remove ETX neighbor
//etx_neighbor_remove(interface_id, entry);
//SET ETX to infinity
etx_neighbor_remove(cur->id, entry_ptr->index);
}


Expand Down
40 changes: 40 additions & 0 deletions source/6LoWPAN/ws/ws_llc_data_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "6LoWPAN/ws/ws_mpx_header.h"
#include "6LoWPAN/ws/ws_neighbor_class.h"
#include "Service_Libs/mac_neighbor_table/mac_neighbor_table.h"
#include "Service_Libs/etx/etx.h"

#ifdef HAVE_WS

Expand Down Expand Up @@ -73,8 +74,11 @@ typedef struct {
} llc_ie_params_t;

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

protocol_interface_info_entry_t *interface = base->interface_ptr;

llc_message_t *message = llc_message_discover_by_mac_handle(data->msduHandle, &base->llc_message_list);
if (!message) {
return;
Expand All @@ -378,6 +384,34 @@ static void ws_llc_mac_confirm_cb(const mac_api_t* api, const mcps_data_conf_t *
mpx_user_id = MPX_KEY_MANAGEMENT_ENC_USER_ID;
}

//ETX update
if (message->ack_requested && messsage_type == WS_FT_DATA ) {

ws_neighbor_class_entry_t * ws_neighbor = NULL;
mac_neighbor_table_entry_t *neighbor = NULL;
bool success = false;

switch (data->status) {
case MLME_SUCCESS:
case MLME_TX_NO_ACK:
case MLME_NO_DATA:
if (data->status == MLME_SUCCESS ) {
success = true;
}
neighbor = mac_neighbor_table_address_discover(interface->mac_parameters->mac_neighbor_table, message->dst_address, message->dst_address_type);
if (neighbor) {
ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbor->index);
}
if (ws_neighbor) {
etx_transm_attempts_update(interface->id, 1 + data->tx_retries , success, neighbor->index);
//TODO discover RSL from Enchanced ACK Header IE elements
}
break;
default:
break;
}
}

user_cb = ws_llc_mpx_user_discover(&base->mpx_data_base, mpx_user_id);
if (user_cb && user_cb->data_confirm) {
//Call MPX registered call back
Expand Down Expand Up @@ -430,6 +464,7 @@ static void ws_llc_mac_indication_cb(const mac_api_t* api, const mcps_data_ind_t
if (ws_utt.message_type == WS_FT_DATA && data->DstAddrMode && addr_check_broadcast(data->DstAddr, data->DstAddrMode)) {
tr_debug("Refresh neigh index %u", neighbor->index);
mac_neighbor_table_neighbor_refresh(interface->mac_parameters->mac_neighbor_table, neighbor, neighbor->link_lifetime);
etx_lqi_dbm_update(interface->id, data->mpduLinkQuality, data->signal_dbm, neighbor->index);
}
}

Expand Down Expand Up @@ -547,6 +582,11 @@ static void ws_llc_mpx_data_request(const mpx_api_t *api, const struct mcps_data
}
mcps_data_req_t data_req;
message->mpx_user_handle = data->msduHandle;
message->ack_requested = data->TxAckReq;
if (data->TxAckReq) {
message->dst_address_type = data->DstAddrMode;
memcpy(message->dst_address, data->DstAddr, 8);
}
data_req = *data;
data_req.msdu = NULL;
data_req.msduLength = 0;
Expand Down

0 comments on commit 6be455f

Please sign in to comment.