Merge pull request #13497 from artokin/sync_mbed_mesh_api_update_master

Updating mbed-mesh-api
pull/13518/head
Martin Kojtal 2020-08-31 10:57:15 +01:00 committed by GitHub
commit fb3d1aa790
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 10 deletions

View File

@ -35,6 +35,8 @@ typedef struct ws_br_info {
uint64_t host_timestamp; uint64_t host_timestamp;
/** Amount of devices in the network. */ /** Amount of devices in the network. */
uint16_t device_count; uint16_t device_count;
/** Gateway Local Address */
uint8_t gateway_addr[16];
} ws_br_info_t; } ws_br_info_t;
/** /**

View File

@ -23,18 +23,38 @@
* \brief Struct ws_rpl_info Wi-SUN router RPL information. * \brief Struct ws_rpl_info Wi-SUN router RPL information.
*/ */
typedef struct ws_rpl_info { 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];
/** Router dodag id */ /** Router dodag id */
uint8_t rpl_dodag_id[16]; uint8_t rpl_dodag_id[16];
/** Router instance identifier */ /** Router instance identifier */
uint8_t instance_id; uint8_t instance_id;
/** RPL version number */ /** RPL version number */
uint8_t version; uint8_t version;
/** RPL DODAG node current Rank */
uint16_t current_rank;
/** RPL Primary Parent Rank */
uint16_t primary_parent_rank;
} ws_rpl_info_t; } ws_rpl_info_t;
/**
* \brief Struct ws_stack_state Wi-SUN stack information.
*/
typedef struct ws_stack_state {
/** Mesh Interface Global IPv6 Address */
uint8_t global_addr[16];
/** Mesh Interface Link Local IPv6 Address */
uint8_t link_local_addr[16];
/** Parent link local address */
uint8_t parent_addr[16];
/** 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;
/** 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;
/** Wi-SUN join state defined by Wi-SUN specification 1-5 */
uint8_t join_state;
/** Network PAN ID */
uint16_t pan_id;
} ws_stack_state_t;
/** Wi-SUN mesh network interface class /** Wi-SUN mesh network interface class
* *
* Configure Nanostack to use Wi-SUN protocol. * Configure Nanostack to use Wi-SUN protocol.
@ -453,6 +473,19 @@ public:
* */ * */
mesh_error_t info_get(ws_rpl_info_t *info_ptr); mesh_error_t info_get(ws_rpl_info_t *info_ptr);
/**
* \brief Get Wi-SUN Stack information.
*
* Function reads Stack information from nanostack.
* Mesh interface must be initialized before calling this function.
*
* \param stack_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 stack_info_get(ws_stack_state_t *stack_info_ptr);
protected: protected:
Nanostack::WisunInterface *get_interface() const; Nanostack::WisunInterface *get_interface() const;
nsapi_error_t do_initialize() override; nsapi_error_t do_initialize() override;

View File

@ -18,6 +18,7 @@
#include "ns_trace.h" #include "ns_trace.h"
#include "WisunBorderRouter.h" #include "WisunBorderRouter.h"
#include "MeshInterfaceNanostack.h" #include "MeshInterfaceNanostack.h"
#include "net_interface.h"
extern "C" { extern "C" {
#include "ws_bbr_api.h" #include "ws_bbr_api.h"
@ -174,6 +175,7 @@ mesh_error_t WisunBorderRouter::info_get(ws_br_info_t *info_ptr)
memcpy(info_ptr->rpl_dodag_id, bbr_info.dodag_id, 16); memcpy(info_ptr->rpl_dodag_id, bbr_info.dodag_id, 16);
memcpy(info_ptr->ipv6_prefix, bbr_info.prefix, 8); memcpy(info_ptr->ipv6_prefix, bbr_info.prefix, 8);
memcpy(info_ptr->ipv6_iid, bbr_info.IID, 8); memcpy(info_ptr->ipv6_iid, bbr_info.IID, 8);
memcpy(info_ptr->gateway_addr, bbr_info.gateway, 16);
return MESH_ERROR_NONE; return MESH_ERROR_NONE;
} }

View File

@ -553,7 +553,6 @@ mesh_error_t WisunInterface::info_get(ws_rpl_info_t *info_ptr)
} }
rpl_dodag_info_t dodag_ptr = {0}; rpl_dodag_info_t dodag_ptr = {0};
uint8_t global_address[16] = {0};
uint8_t rpl_instance_count; uint8_t rpl_instance_count;
uint8_t instance_id_list[10]; uint8_t instance_id_list[10];
uint8_t instance_id = RPL_INSTANCE_LOCAL; uint8_t instance_id = RPL_INSTANCE_LOCAL;
@ -587,15 +586,44 @@ mesh_error_t WisunInterface::info_get(ws_rpl_info_t *info_ptr)
return MESH_ERROR_UNKNOWN; return MESH_ERROR_UNKNOWN;
} }
info_ptr->instance_id = dodag_ptr.instance_id;
info_ptr->version = dodag_ptr.version_num;
info_ptr->current_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);
return MESH_ERROR_NONE;
}
mesh_error_t WisunInterface::stack_info_get(ws_stack_state_t *stack_info_ptr)
{
if (stack_info_ptr == NULL) {
return MESH_ERROR_PARAM;
}
ws_stack_info_t stack_info = {0};
uint8_t global_address[16] = {0};
uint8_t link_local_address[16] = {0};
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) { if (arm_net_address_get(get_interface_id(), ADDR_IPV6_GP, global_address) != 0) {
// No global prefix available, Nothing to do. // No global prefix available, Nothing to do.
} }
info_ptr->instance_id = dodag_ptr.instance_id; if (arm_net_address_get(get_interface_id(), ADDR_IPV6_LL, link_local_address) != 0) {
info_ptr->version = dodag_ptr.version_num; // No local prefix available, Nothing to do.
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); stack_info_ptr->join_state = stack_info.join_state;
stack_info_ptr->pan_id = stack_info.pan_id;
stack_info_ptr->rsl_in = stack_info.rsl_in;
stack_info_ptr->rsl_out = stack_info.rsl_out;
memcpy(stack_info_ptr->parent_addr, stack_info.parent, 16);
memcpy(stack_info_ptr->global_addr, global_address, 16);
memcpy(stack_info_ptr->link_local_addr, link_local_address, 16);
return MESH_ERROR_NONE; return MESH_ERROR_NONE;
} }