Skip to content

Commit

Permalink
Updating mbed-mesh-api.
Browse files Browse the repository at this point in the history
-Adding new parameters for Wi-SUN interface information.
  • Loading branch information
debdeep-arm authored and Arto Kinnunen committed Aug 26, 2020
1 parent afcf91f commit 68cf724
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
* \brief Struct br_information Border router dynamic information.
*/
typedef struct ws_br_info {
/** Address prefix given to devices in network set to 0 if not available*/
uint8_t ipv6_prefix[8];
/** IID of Border router */
uint8_t ipv6_iid[8];
/** Mesh Interface Global Address */
uint8_t global_addr[16];
/** Mesh Interface Link Local Address */
uint8_t link_local_addr[16];
/** Border router dodag id */
uint8_t rpl_dodag_id[16];
/** Border router instance identifier defined in RPL */
Expand All @@ -35,6 +35,10 @@ typedef struct ws_br_info {
uint64_t host_timestamp;
/** Amount of devices in the network. */
uint16_t device_count;
/** Backbone IPv6 Global Address */
uint8_t backbone_global_addr[16];
/** Gateway Local Address */
uint8_t gateway_addr[16];
} ws_br_info_t;

/**
Expand Down Expand Up @@ -209,6 +213,7 @@ class WisunBorderRouter {

private:
int8_t _mesh_if_id = -1;
int8_t _backbone_if_id = -1;

};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,34 @@
* \brief Struct ws_rpl_info Wi-SUN router RPL information.
*/
typedef struct ws_rpl_info {
/** Address prefix given to devices in network set to 0 if not available*/
uint8_t ipv6_prefix[8];
/** IID of router */
uint8_t ipv6_iid[8];
/** IPv6 Global Address of Router Node*/
uint8_t global_addr[16];
/** IPv6 Link Local Address of Router Node*/
uint8_t link_local_addr[16];
/** Router dodag id */
uint8_t rpl_dodag_id[16];
/** Router instance identifier */
uint8_t instance_id;
/** RPL version number */
uint8_t version;
/** RPL DODAG node current Rank */
uint16_t curent_rank;
/** RPL Primary Parent Rank */
uint16_t primary_parent_rank;
/** RPL Primary Parent Address */
uint8_t rpl_parent_addr[16];
} ws_rpl_info_t;

/**
* \brief Struct ws_radio_info Wi-SUN router Radio Quality information.
*/
typedef struct ws_radio_info {
/** parent RSSI in measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
uint8_t rsl_in;
/** parent RSSI Out measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
uint8_t rsl_out;
} ws_radio_info_t;

/** Wi-SUN mesh network interface class
*
* Configure Nanostack to use Wi-SUN protocol.
Expand Down Expand Up @@ -453,6 +469,19 @@ class WisunInterface final : public MeshInterfaceNanostack {
* */
mesh_error_t info_get(ws_rpl_info_t *info_ptr);

/**
* \brief Get Wi-SUN Radio Quality information.
*
* Function reads Stack information from nanostack.
* Mesh interface must be initialized before calling this function.
*
* \param radio_info_ptr Structure given to stack where information will be stored
*
* \return MESH_ERROR_NONE on success.
* \return MESH_ERROR_UNKNOWN in case of failure.
* */
mesh_error_t radio_info_get(ws_radio_info_t *radio_info_ptr);

protected:
Nanostack::WisunInterface *get_interface() const;
nsapi_error_t do_initialize() override;
Expand Down
19 changes: 17 additions & 2 deletions connectivity/nanostack/mbed-mesh-api/source/WisunBorderRouter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "ns_trace.h"
#include "WisunBorderRouter.h"
#include "MeshInterfaceNanostack.h"
#include "net_interface.h"

extern "C" {
#include "ws_bbr_api.h"
Expand Down Expand Up @@ -51,6 +52,7 @@ mesh_error_t WisunBorderRouter::start(NetworkInterface *mesh_if, NetworkInterfac
if (backbone_if_id < 0) {
return MESH_ERROR_UNKNOWN;
}
_backbone_if_id = backbone_if_id;

int ret = ws_bbr_start(mesh_if_id, backbone_if_id);
if (ret < 0) {
Expand Down Expand Up @@ -157,6 +159,8 @@ mesh_error_t WisunBorderRouter::validate_pan_configuration(uint16_t pan_id)
mesh_error_t WisunBorderRouter::info_get(ws_br_info_t *info_ptr)
{
bbr_information_t bbr_info = {0};
uint8_t mesh_link_local_addr[16] = {0};
uint8_t backbone_global_addr[16] = {0};

if (info_ptr == NULL) {
return MESH_ERROR_PARAM;
Expand All @@ -167,13 +171,24 @@ mesh_error_t WisunBorderRouter::info_get(ws_br_info_t *info_ptr)
return MESH_ERROR_UNKNOWN;
}

if (arm_net_address_get(_mesh_if_id, ADDR_IPV6_LL, mesh_link_local_addr) != 0) {
// No global prefix available, Nothing to do.
}

if (arm_net_address_get(_backbone_if_id, ADDR_IPV6_GP, backbone_global_addr) != 0) {
// No global prefix available, Nothing to do.
}

info_ptr->device_count = bbr_info.devices_in_network;
info_ptr->host_timestamp = bbr_info.timestamp;
info_ptr->instance_id = bbr_info.instance_id;
info_ptr->version = bbr_info.version;
memcpy(info_ptr->rpl_dodag_id, bbr_info.dodag_id, 16);
memcpy(info_ptr->ipv6_prefix, bbr_info.prefix, 8);
memcpy(info_ptr->ipv6_iid, bbr_info.IID, 8);
memcpy(info_ptr->global_addr, bbr_info.prefix, 8);
memcpy(info_ptr->global_addr + 8, bbr_info.IID, 8);
memcpy(info_ptr->gateway_addr, bbr_info.gateway, 16);
memcpy(info_ptr->link_local_addr, mesh_link_local_addr, 16);
memcpy(info_ptr->backbone_global_addr, backbone_global_addr, 16);

return MESH_ERROR_NONE;
}
Expand Down
35 changes: 33 additions & 2 deletions connectivity/nanostack/mbed-mesh-api/source/WisunInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,9 @@ mesh_error_t WisunInterface::info_get(ws_rpl_info_t *info_ptr)
}

rpl_dodag_info_t dodag_ptr = {0};
ws_stack_info_t stack_info = {0};
uint8_t global_address[16] = {0};
uint8_t link_local_address[16] = {0};
uint8_t rpl_instance_count;
uint8_t instance_id_list[10];
uint8_t instance_id = RPL_INSTANCE_LOCAL;
Expand Down Expand Up @@ -587,15 +589,44 @@ mesh_error_t WisunInterface::info_get(ws_rpl_info_t *info_ptr)
return MESH_ERROR_UNKNOWN;
}

if (ws_stack_info_get(get_interface_id(), &stack_info)) {
return MESH_ERROR_UNKNOWN;
}

if (arm_net_address_get(get_interface_id(), ADDR_IPV6_GP, global_address) != 0) {
// No global prefix available, Nothing to do.
}

if (arm_net_address_get(get_interface_id(), ADDR_IPV6_LL, link_local_address) != 0) {
// No local prefix available, Nothing to do.
}

info_ptr->instance_id = dodag_ptr.instance_id;
info_ptr->version = dodag_ptr.version_num;
info_ptr->curent_rank = dodag_ptr.curent_rank;
info_ptr->primary_parent_rank = dodag_ptr.primary_parent_rank;
memcpy(info_ptr->rpl_dodag_id, dodag_ptr.dodag_id, 16);
memcpy(info_ptr->ipv6_prefix, global_address, 8);
memcpy(info_ptr->ipv6_iid, global_address + 8, 8);
memcpy(info_ptr->global_addr, global_address, 16);
memcpy(info_ptr->link_local_addr, link_local_address, 16);
memcpy(info_ptr->rpl_parent_addr, stack_info.parent, 16);

return MESH_ERROR_NONE;
}

mesh_error_t radio_info_get(ws_radio_info_t *radio_info_ptr)
{
if (radio_info_ptr == NULL) {
return MESH_ERROR_PARAM;
}

ws_stack_info_t stack_info = {0};

if (ws_stack_info_get(get_interface_id(), &stack_info)) {
return MESH_ERROR_UNKNOWN;
}

radio_info_ptr->rsl_in = stack_info.rsl_in;
radio_info_ptr->rsl_out = stack_info.rsl_out;

return MESH_ERROR_NONE;
}
Expand Down

0 comments on commit 68cf724

Please sign in to comment.