Skip to content

Commit 11418a2

Browse files
authored
Merge pull request #13496 from artokin/sync_mbed_mesh_api_update_5_15
[mbedos-5.15] Updating mbed-mesh-api
2 parents 0445b6a + b0c2443 commit 11418a2

File tree

4 files changed

+75
-10
lines changed

4 files changed

+75
-10
lines changed

features/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
/**

features/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.
@@ -462,6 +482,19 @@ class WisunInterface : public MeshInterfaceNanostack {
462482
* */
463483
mesh_error_t info_get(ws_rpl_info_t *info_ptr);
464484

485+
/**
486+
* \brief Get Wi-SUN Stack information.
487+
*
488+
* Function reads Stack information from nanostack.
489+
* Mesh interface must be initialized before calling this function.
490+
*
491+
* \param stack_info_ptr Structure given to stack where information will be stored
492+
*
493+
* \return MESH_ERROR_NONE on success.
494+
* \return MESH_ERROR_UNKNOWN in case of failure.
495+
* */
496+
mesh_error_t stack_info_get(ws_stack_state_t *stack_info_ptr);
497+
465498
protected:
466499
Nanostack::WisunInterface *get_interface() const;
467500
virtual nsapi_error_t do_initialize();

features/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
}

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

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

553553
rpl_dodag_info_t dodag_ptr = {0};
554-
uint8_t global_address[16] = {0};
555554
uint8_t rpl_instance_count;
556555
uint8_t instance_id_list[10];
557556
uint8_t instance_id = RPL_INSTANCE_LOCAL;
@@ -585,15 +584,44 @@ mesh_error_t WisunInterface::info_get(ws_rpl_info_t *info_ptr)
585584
return MESH_ERROR_UNKNOWN;
586585
}
587586

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

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

598626
return MESH_ERROR_NONE;
599627
}

0 commit comments

Comments
 (0)