Updating mbed-mesh-api.

-Adding new parameters for Wi-SUN interface information.
pull/13496/head
Debdeep Saha 2020-08-18 16:42:47 +05:30 committed by Arto Kinnunen
parent e4350393d2
commit c5386c0cee
4 changed files with 92 additions and 12 deletions

View File

@ -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 */
@ -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;
/**
@ -209,6 +213,7 @@ public:
private:
int8_t _mesh_if_id = -1;
int8_t _backbone_if_id = -1;
};

View File

@ -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.
@ -462,6 +478,19 @@ public:
* */
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;
virtual nsapi_error_t do_initialize();

View File

@ -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"
@ -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) {
@ -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;
@ -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;
}

View File

@ -551,7 +551,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;
@ -585,15 +587,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;
}