Skip to content

[mbedos-5.15] Updating mbed-mesh-api #13496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ typedef struct ws_br_info {
uint64_t host_timestamp;
/** Amount of devices in the network. */
uint16_t device_count;
/** Gateway Local Address */
uint8_t gateway_addr[16];
} ws_br_info_t;

/**
Expand Down
41 changes: 37 additions & 4 deletions features/nanostack/mbed-mesh-api/mbed-mesh-api/WisunInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,38 @@
* \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];
/** 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 current_rank;
/** RPL Primary Parent Rank */
uint16_t primary_parent_rank;
} 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
*
* Configure Nanostack to use Wi-SUN protocol.
Expand Down Expand Up @@ -462,6 +482,19 @@ class WisunInterface : public MeshInterfaceNanostack {
* */
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:
Nanostack::WisunInterface *get_interface() const;
virtual nsapi_error_t do_initialize();
Expand Down
2 changes: 2 additions & 0 deletions features/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 @@ -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->ipv6_prefix, bbr_info.prefix, 8);
memcpy(info_ptr->ipv6_iid, bbr_info.IID, 8);
memcpy(info_ptr->gateway_addr, bbr_info.gateway, 16);

return MESH_ERROR_NONE;
}
Expand Down
40 changes: 34 additions & 6 deletions features/nanostack/mbed-mesh-api/source/WisunInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ mesh_error_t WisunInterface::info_get(ws_rpl_info_t *info_ptr)
}

rpl_dodag_info_t dodag_ptr = {0};
uint8_t global_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 @@ -585,15 +584,44 @@ mesh_error_t WisunInterface::info_get(ws_rpl_info_t *info_ptr)
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) {
// No global prefix available, Nothing to do.
}

info_ptr->instance_id = dodag_ptr.instance_id;
info_ptr->version = dodag_ptr.version_num;
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);
if (arm_net_address_get(get_interface_id(), ADDR_IPV6_LL, link_local_address) != 0) {
// No local prefix available, Nothing to do.
}

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;
}
Expand Down