Skip to content

Commit fb3d1aa

Browse files
authored
Merge pull request ARMmbed#13497 from artokin/sync_mbed_mesh_api_update_master
Updating mbed-mesh-api
2 parents 31ff368 + 0258c89 commit fb3d1aa

File tree

4 files changed

+75
-10
lines changed

4 files changed

+75
-10
lines changed

connectivity/nanostack/mbed-mesh-api/mbed-mesh-api/WisunBorderRouter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ typedef struct ws_br_info {
3535
uint64_t host_timestamp;
3636
/** Amount of devices in the network. */
3737
uint16_t device_count;
38+
/** Gateway Local Address */
39+
uint8_t gateway_addr[16];
3840
} ws_br_info_t;
3941

4042
/**

connectivity/nanostack/mbed-mesh-api/mbed-mesh-api/WisunInterface.h

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,38 @@
2323
* \brief Struct ws_rpl_info Wi-SUN router RPL information.
2424
*/
2525
typedef struct ws_rpl_info {
26-
/** Address prefix given to devices in network set to 0 if not available*/
27-
uint8_t ipv6_prefix[8];
28-
/** IID of router */
29-
uint8_t ipv6_iid[8];
3026
/** Router dodag id */
3127
uint8_t rpl_dodag_id[16];
3228
/** Router instance identifier */
3329
uint8_t instance_id;
3430
/** RPL version number */
3531
uint8_t version;
32+
/** RPL DODAG node current Rank */
33+
uint16_t current_rank;
34+
/** RPL Primary Parent Rank */
35+
uint16_t primary_parent_rank;
3636
} ws_rpl_info_t;
3737

38+
/**
39+
* \brief Struct ws_stack_state Wi-SUN stack information.
40+
*/
41+
typedef struct ws_stack_state {
42+
/** Mesh Interface Global IPv6 Address */
43+
uint8_t global_addr[16];
44+
/** Mesh Interface Link Local IPv6 Address */
45+
uint8_t link_local_addr[16];
46+
/** Parent link local address */
47+
uint8_t parent_addr[16];
48+
/** parent RSSI Out measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
49+
uint8_t rsl_out;
50+
/** parent RSSI in measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
51+
uint8_t rsl_in;
52+
/** Wi-SUN join state defined by Wi-SUN specification 1-5 */
53+
uint8_t join_state;
54+
/** Network PAN ID */
55+
uint16_t pan_id;
56+
} ws_stack_state_t;
57+
3858
/** Wi-SUN mesh network interface class
3959
*
4060
* Configure Nanostack to use Wi-SUN protocol.
@@ -453,6 +473,19 @@ class WisunInterface final : public MeshInterfaceNanostack {
453473
* */
454474
mesh_error_t info_get(ws_rpl_info_t *info_ptr);
455475

476+
/**
477+
* \brief Get Wi-SUN Stack information.
478+
*
479+
* Function reads Stack information from nanostack.
480+
* Mesh interface must be initialized before calling this function.
481+
*
482+
* \param stack_info_ptr Structure given to stack where information will be stored
483+
*
484+
* \return MESH_ERROR_NONE on success.
485+
* \return MESH_ERROR_UNKNOWN in case of failure.
486+
* */
487+
mesh_error_t stack_info_get(ws_stack_state_t *stack_info_ptr);
488+
456489
protected:
457490
Nanostack::WisunInterface *get_interface() const;
458491
nsapi_error_t do_initialize() override;

connectivity/nanostack/mbed-mesh-api/source/WisunBorderRouter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "ns_trace.h"
1919
#include "WisunBorderRouter.h"
2020
#include "MeshInterfaceNanostack.h"
21+
#include "net_interface.h"
2122

2223
extern "C" {
2324
#include "ws_bbr_api.h"
@@ -174,6 +175,7 @@ mesh_error_t WisunBorderRouter::info_get(ws_br_info_t *info_ptr)
174175
memcpy(info_ptr->rpl_dodag_id, bbr_info.dodag_id, 16);
175176
memcpy(info_ptr->ipv6_prefix, bbr_info.prefix, 8);
176177
memcpy(info_ptr->ipv6_iid, bbr_info.IID, 8);
178+
memcpy(info_ptr->gateway_addr, bbr_info.gateway, 16);
177179

178180
return MESH_ERROR_NONE;
179181
}

connectivity/nanostack/mbed-mesh-api/source/WisunInterface.cpp

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,6 @@ mesh_error_t WisunInterface::info_get(ws_rpl_info_t *info_ptr)
553553
}
554554

555555
rpl_dodag_info_t dodag_ptr = {0};
556-
uint8_t global_address[16] = {0};
557556
uint8_t rpl_instance_count;
558557
uint8_t instance_id_list[10];
559558
uint8_t instance_id = RPL_INSTANCE_LOCAL;
@@ -587,15 +586,44 @@ mesh_error_t WisunInterface::info_get(ws_rpl_info_t *info_ptr)
587586
return MESH_ERROR_UNKNOWN;
588587
}
589588

589+
info_ptr->instance_id = dodag_ptr.instance_id;
590+
info_ptr->version = dodag_ptr.version_num;
591+
info_ptr->current_rank = dodag_ptr.curent_rank;
592+
info_ptr->primary_parent_rank = dodag_ptr.primary_parent_rank;
593+
memcpy(info_ptr->rpl_dodag_id, dodag_ptr.dodag_id, 16);
594+
595+
return MESH_ERROR_NONE;
596+
}
597+
598+
mesh_error_t WisunInterface::stack_info_get(ws_stack_state_t *stack_info_ptr)
599+
{
600+
if (stack_info_ptr == NULL) {
601+
return MESH_ERROR_PARAM;
602+
}
603+
604+
ws_stack_info_t stack_info = {0};
605+
uint8_t global_address[16] = {0};
606+
uint8_t link_local_address[16] = {0};
607+
608+
if (ws_stack_info_get(get_interface_id(), &stack_info)) {
609+
return MESH_ERROR_UNKNOWN;
610+
}
611+
590612
if (arm_net_address_get(get_interface_id(), ADDR_IPV6_GP, global_address) != 0) {
591613
// No global prefix available, Nothing to do.
592614
}
593615

594-
info_ptr->instance_id = dodag_ptr.instance_id;
595-
info_ptr->version = dodag_ptr.version_num;
596-
memcpy(info_ptr->rpl_dodag_id, dodag_ptr.dodag_id, 16);
597-
memcpy(info_ptr->ipv6_prefix, global_address, 8);
598-
memcpy(info_ptr->ipv6_iid, global_address + 8, 8);
616+
if (arm_net_address_get(get_interface_id(), ADDR_IPV6_LL, link_local_address) != 0) {
617+
// No local prefix available, Nothing to do.
618+
}
619+
620+
stack_info_ptr->join_state = stack_info.join_state;
621+
stack_info_ptr->pan_id = stack_info.pan_id;
622+
stack_info_ptr->rsl_in = stack_info.rsl_in;
623+
stack_info_ptr->rsl_out = stack_info.rsl_out;
624+
memcpy(stack_info_ptr->parent_addr, stack_info.parent, 16);
625+
memcpy(stack_info_ptr->global_addr, global_address, 16);
626+
memcpy(stack_info_ptr->link_local_addr, link_local_address, 16);
599627

600628
return MESH_ERROR_NONE;
601629
}

0 commit comments

Comments
 (0)