Skip to content

Commit 68cf724

Browse files
debdeep-armArto Kinnunen
authored andcommitted
Updating mbed-mesh-api.
-Adding new parameters for Wi-SUN interface information.
1 parent afcf91f commit 68cf724

File tree

4 files changed

+92
-12
lines changed

4 files changed

+92
-12
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
* \brief Struct br_information Border router dynamic information.
2222
*/
2323
typedef struct ws_br_info {
24-
/** Address prefix given to devices in network set to 0 if not available*/
25-
uint8_t ipv6_prefix[8];
26-
/** IID of Border router */
27-
uint8_t ipv6_iid[8];
24+
/** Mesh Interface Global Address */
25+
uint8_t global_addr[16];
26+
/** Mesh Interface Link Local Address */
27+
uint8_t link_local_addr[16];
2828
/** Border router dodag id */
2929
uint8_t rpl_dodag_id[16];
3030
/** Border router instance identifier defined in RPL */
@@ -35,6 +35,10 @@ typedef struct ws_br_info {
3535
uint64_t host_timestamp;
3636
/** Amount of devices in the network. */
3737
uint16_t device_count;
38+
/** Backbone IPv6 Global Address */
39+
uint8_t backbone_global_addr[16];
40+
/** Gateway Local Address */
41+
uint8_t gateway_addr[16];
3842
} ws_br_info_t;
3943

4044
/**
@@ -209,6 +213,7 @@ class WisunBorderRouter {
209213

210214
private:
211215
int8_t _mesh_if_id = -1;
216+
int8_t _backbone_if_id = -1;
212217

213218
};
214219

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

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,34 @@
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];
26+
/** IPv6 Global Address of Router Node*/
27+
uint8_t global_addr[16];
28+
/** IPv6 Link Local Address of Router Node*/
29+
uint8_t link_local_addr[16];
3030
/** Router dodag id */
3131
uint8_t rpl_dodag_id[16];
3232
/** Router instance identifier */
3333
uint8_t instance_id;
3434
/** RPL version number */
3535
uint8_t version;
36+
/** RPL DODAG node current Rank */
37+
uint16_t curent_rank;
38+
/** RPL Primary Parent Rank */
39+
uint16_t primary_parent_rank;
40+
/** RPL Primary Parent Address */
41+
uint8_t rpl_parent_addr[16];
3642
} ws_rpl_info_t;
3743

44+
/**
45+
* \brief Struct ws_radio_info Wi-SUN router Radio Quality information.
46+
*/
47+
typedef struct ws_radio_info {
48+
/** parent RSSI in measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
49+
uint8_t rsl_in;
50+
/** parent RSSI Out measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
51+
uint8_t rsl_out;
52+
} ws_radio_info_t;
53+
3854
/** Wi-SUN mesh network interface class
3955
*
4056
* Configure Nanostack to use Wi-SUN protocol.
@@ -453,6 +469,19 @@ class WisunInterface final : public MeshInterfaceNanostack {
453469
* */
454470
mesh_error_t info_get(ws_rpl_info_t *info_ptr);
455471

472+
/**
473+
* \brief Get Wi-SUN Radio Quality information.
474+
*
475+
* Function reads Stack information from nanostack.
476+
* Mesh interface must be initialized before calling this function.
477+
*
478+
* \param radio_info_ptr Structure given to stack where information will be stored
479+
*
480+
* \return MESH_ERROR_NONE on success.
481+
* \return MESH_ERROR_UNKNOWN in case of failure.
482+
* */
483+
mesh_error_t radio_info_get(ws_radio_info_t *radio_info_ptr);
484+
456485
protected:
457486
Nanostack::WisunInterface *get_interface() const;
458487
nsapi_error_t do_initialize() override;

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

Lines changed: 17 additions & 2 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"
@@ -51,6 +52,7 @@ mesh_error_t WisunBorderRouter::start(NetworkInterface *mesh_if, NetworkInterfac
5152
if (backbone_if_id < 0) {
5253
return MESH_ERROR_UNKNOWN;
5354
}
55+
_backbone_if_id = backbone_if_id;
5456

5557
int ret = ws_bbr_start(mesh_if_id, backbone_if_id);
5658
if (ret < 0) {
@@ -157,6 +159,8 @@ mesh_error_t WisunBorderRouter::validate_pan_configuration(uint16_t pan_id)
157159
mesh_error_t WisunBorderRouter::info_get(ws_br_info_t *info_ptr)
158160
{
159161
bbr_information_t bbr_info = {0};
162+
uint8_t mesh_link_local_addr[16] = {0};
163+
uint8_t backbone_global_addr[16] = {0};
160164

161165
if (info_ptr == NULL) {
162166
return MESH_ERROR_PARAM;
@@ -167,13 +171,24 @@ mesh_error_t WisunBorderRouter::info_get(ws_br_info_t *info_ptr)
167171
return MESH_ERROR_UNKNOWN;
168172
}
169173

174+
if (arm_net_address_get(_mesh_if_id, ADDR_IPV6_LL, mesh_link_local_addr) != 0) {
175+
// No global prefix available, Nothing to do.
176+
}
177+
178+
if (arm_net_address_get(_backbone_if_id, ADDR_IPV6_GP, backbone_global_addr) != 0) {
179+
// No global prefix available, Nothing to do.
180+
}
181+
170182
info_ptr->device_count = bbr_info.devices_in_network;
171183
info_ptr->host_timestamp = bbr_info.timestamp;
172184
info_ptr->instance_id = bbr_info.instance_id;
173185
info_ptr->version = bbr_info.version;
174186
memcpy(info_ptr->rpl_dodag_id, bbr_info.dodag_id, 16);
175-
memcpy(info_ptr->ipv6_prefix, bbr_info.prefix, 8);
176-
memcpy(info_ptr->ipv6_iid, bbr_info.IID, 8);
187+
memcpy(info_ptr->global_addr, bbr_info.prefix, 8);
188+
memcpy(info_ptr->global_addr + 8, bbr_info.IID, 8);
189+
memcpy(info_ptr->gateway_addr, bbr_info.gateway, 16);
190+
memcpy(info_ptr->link_local_addr, mesh_link_local_addr, 16);
191+
memcpy(info_ptr->backbone_global_addr, backbone_global_addr, 16);
177192

178193
return MESH_ERROR_NONE;
179194
}

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

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

555555
rpl_dodag_info_t dodag_ptr = {0};
556+
ws_stack_info_t stack_info = {0};
556557
uint8_t global_address[16] = {0};
558+
uint8_t link_local_address[16] = {0};
557559
uint8_t rpl_instance_count;
558560
uint8_t instance_id_list[10];
559561
uint8_t instance_id = RPL_INSTANCE_LOCAL;
@@ -587,15 +589,44 @@ mesh_error_t WisunInterface::info_get(ws_rpl_info_t *info_ptr)
587589
return MESH_ERROR_UNKNOWN;
588590
}
589591

592+
if (ws_stack_info_get(get_interface_id(), &stack_info)) {
593+
return MESH_ERROR_UNKNOWN;
594+
}
595+
590596
if (arm_net_address_get(get_interface_id(), ADDR_IPV6_GP, global_address) != 0) {
591597
// No global prefix available, Nothing to do.
592598
}
593599

600+
if (arm_net_address_get(get_interface_id(), ADDR_IPV6_LL, link_local_address) != 0) {
601+
// No local prefix available, Nothing to do.
602+
}
603+
594604
info_ptr->instance_id = dodag_ptr.instance_id;
595605
info_ptr->version = dodag_ptr.version_num;
606+
info_ptr->curent_rank = dodag_ptr.curent_rank;
607+
info_ptr->primary_parent_rank = dodag_ptr.primary_parent_rank;
596608
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);
609+
memcpy(info_ptr->global_addr, global_address, 16);
610+
memcpy(info_ptr->link_local_addr, link_local_address, 16);
611+
memcpy(info_ptr->rpl_parent_addr, stack_info.parent, 16);
612+
613+
return MESH_ERROR_NONE;
614+
}
615+
616+
mesh_error_t radio_info_get(ws_radio_info_t *radio_info_ptr)
617+
{
618+
if (radio_info_ptr == NULL) {
619+
return MESH_ERROR_PARAM;
620+
}
621+
622+
ws_stack_info_t stack_info = {0};
623+
624+
if (ws_stack_info_get(get_interface_id(), &stack_info)) {
625+
return MESH_ERROR_UNKNOWN;
626+
}
627+
628+
radio_info_ptr->rsl_in = stack_info.rsl_in;
629+
radio_info_ptr->rsl_out = stack_info.rsl_out;
599630

600631
return MESH_ERROR_NONE;
601632
}

0 commit comments

Comments
 (0)