Skip to content

Commit c5386c0

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

File tree

4 files changed

+92
-12
lines changed

4 files changed

+92
-12
lines changed

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

features/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.
@@ -462,6 +478,19 @@ class WisunInterface : public MeshInterfaceNanostack {
462478
* */
463479
mesh_error_t info_get(ws_rpl_info_t *info_ptr);
464480

481+
/**
482+
* \brief Get Wi-SUN Radio Quality information.
483+
*
484+
* Function reads Stack information from nanostack.
485+
* Mesh interface must be initialized before calling this function.
486+
*
487+
* \param radio_info_ptr Structure given to stack where information will be stored
488+
*
489+
* \return MESH_ERROR_NONE on success.
490+
* \return MESH_ERROR_UNKNOWN in case of failure.
491+
* */
492+
mesh_error_t radio_info_get(ws_radio_info_t *radio_info_ptr);
493+
465494
protected:
466495
Nanostack::WisunInterface *get_interface() const;
467496
virtual nsapi_error_t do_initialize();

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

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

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

553553
rpl_dodag_info_t dodag_ptr = {0};
554+
ws_stack_info_t stack_info = {0};
554555
uint8_t global_address[16] = {0};
556+
uint8_t link_local_address[16] = {0};
555557
uint8_t rpl_instance_count;
556558
uint8_t instance_id_list[10];
557559
uint8_t instance_id = RPL_INSTANCE_LOCAL;
@@ -585,15 +587,44 @@ mesh_error_t WisunInterface::info_get(ws_rpl_info_t *info_ptr)
585587
return MESH_ERROR_UNKNOWN;
586588
}
587589

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

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

598629
return MESH_ERROR_NONE;
599630
}

0 commit comments

Comments
 (0)