Skip to content

Commit 00cafd7

Browse files
authored
Merge pull request #14618 from debdeep-arm/ws-stats-nbr-table-5.15
mbed-os-5.15: Add API to get Wi-SUN Neighbor Table
2 parents bfe3d50 + 6935ea3 commit 00cafd7

File tree

4 files changed

+91
-0
lines changed

4 files changed

+91
-0
lines changed

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,36 @@ typedef struct ws_cca_threshold_table {
6767
const int8_t *cca_threshold_table;
6868
} ws_cca_threshold_table_t;
6969

70+
typedef enum {
71+
WISUN_OTHER = 0, /**< temporary or soon to be removed neighbor*/
72+
WISUN_PRIMARY_PARENT, /**< Primary parent used for upward packets and used from Border router downwards*/
73+
WISUN_SECONDARY_PARENT, /**< Secondary parent reported to border router and might be used as alternate route*/
74+
WISUN_CANDIDATE_PARENT, /**< Candidate neighbor that is considered as parent if there is problem with active parents*/
75+
WISUN_CHILD /**< Child with registered address*/
76+
} ws_nbr_type_e;
77+
78+
/**
79+
* \brief Struct ws_nbr_info_t Gives the neighbor information.
80+
*/
81+
typedef struct ws_nbr_info {
82+
/** Link local address*/
83+
uint8_t link_local_address[16];
84+
/** Global address if it is known set to 0 if not available*/
85+
uint8_t global_address[16];
86+
/** parent RSSI Out measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
87+
uint8_t rsl_out;
88+
/** parent RSSI in measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
89+
uint8_t rsl_in;
90+
/** RPL Rank value for parents 0xffff for neighbors RANK is unknown*/
91+
uint16_t rpl_rank;
92+
/** Measured ETX value if known set to 0xFFFF if not known or Child*/
93+
uint16_t etx;
94+
/** Remaining lifetime Link lifetime for parents and ARO lifetime for children*/
95+
uint32_t lifetime;
96+
/** Neighbour type (Primary Parent, Secondary Parent, Candidate parent, child, other(Temporary neighbours))*/
97+
ws_nbr_type_e type;
98+
} ws_nbr_info_t;
99+
70100
/** Wi-SUN mesh network interface class
71101
*
72102
* Configure Nanostack to use Wi-SUN protocol.
@@ -586,6 +616,20 @@ class WisunInterface : public MeshInterfaceNanostack {
586616
* */
587617
mesh_error_t cca_threshold_table_get(ws_cca_threshold_table_t *table);
588618

619+
/**
620+
* \brief Get Wi-SUN Neighbor table information.
621+
*
622+
* To allocate correct amount of memory first use the API with nbr_ptr = NULL to get current amount
623+
* of neighbors in count pointer. Then Allocate the memory and call the function to fill the table.
624+
*
625+
* \param nbr_ptr Pointer to memory where Neighbor table entries can be written.
626+
* \param count amount of neighbor table entries allocated to memory.
627+
*
628+
* \return MESH_ERROR_NONE on success.
629+
* \return MESH_ERROR_UNKNOWN in case of failure.
630+
* */
631+
mesh_error_t nbr_info_get(ws_nbr_info_t *nbr_ptr, uint16_t *count);
632+
589633
protected:
590634
Nanostack::WisunInterface *get_interface() const;
591635
virtual nsapi_error_t do_initialize();

features/nanostack/mbed-mesh-api/mbed-mesh-api/mesh_interface_types.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,23 @@ typedef struct {
8383
uint16_t etx_2nd_parent; /*<! Secondary parent ETX. */
8484
uint32_t asynch_tx_count; /*<! Asynch TX counter */
8585
uint32_t asynch_rx_count; /*<! Asynch RX counter */
86+
uint32_t join_state_1; /*<! Time spent in individual Wi-SUN join state 1 Discovery */
87+
uint32_t join_state_2; /*<! Time spent in individual Wi-SUN join state 2 Authentication */
88+
uint32_t join_state_3; /*<! Time spent in individual Wi-SUN join state 3 Configuration learn */
89+
uint32_t join_state_4; /*<! Time spent in individual Wi-SUN join state 4 RPL parent discovery */
90+
uint32_t join_state_5; /*<! Time spent in individual Wi-SUN join state 5 Active state */
91+
uint32_t sent_PAS; /*<! Amount of Wi-SUN Pan Advertisement Solicit Message sent */
92+
uint32_t sent_PA; /*<! Amount of Wi-SUN Pan Advertisement Message sent */
93+
uint32_t sent_PCS; /*<! Amount of Wi-SUN Pan Configuration Solicit Message sent */
94+
uint32_t sent_PC; /*<! Amount of Wi-SUN Pan Configuration Message sent */
95+
uint32_t recv_PAS; /*<! Amount of Wi-SUN Pan Advertisement Solicit Message received */
96+
uint32_t recv_PA; /*<! Amount of Wi-SUN Pan Advertisement Message received */
97+
uint32_t recv_PCS; /*<! Amount of Wi-SUN Pan Configuration Solicit Message received */
98+
uint32_t recv_PC; /*<! Amount of Wi-SUN Pan Configuration Message received */
99+
uint32_t Neighbour_add; /*<! New Neighbours found */
100+
uint32_t Neighbour_remove; /*<! New Neighbours Removed */
101+
uint32_t Child_add; /*<! New Child added */
102+
uint32_t child_remove; /*<! Child lost */
86103
} mesh_nw_statistics_t;
87104

88105
/**

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,19 @@ mesh_error_t WisunInterface::cca_threshold_table_get(ws_cca_threshold_table_t *t
684684
return MESH_ERROR_NONE;
685685
}
686686

687+
mesh_error_t WisunInterface::nbr_info_get(ws_nbr_info_t *nbr_ptr, uint16_t *count)
688+
{
689+
uint16_t nbr_count;
690+
691+
if (count == NULL) {
692+
return MESH_ERROR_UNKNOWN;
693+
}
694+
695+
nbr_count = ws_neighbor_info_get(get_interface_id(), (ws_neighbour_info_t *)nbr_ptr, *count);
696+
*count = nbr_count;
697+
return MESH_ERROR_NONE;
698+
}
699+
687700
#define WISUN 0x2345
688701
#if MBED_CONF_NSAPI_DEFAULT_MESH_TYPE == WISUN && DEVICE_802_15_4_PHY
689702
MBED_WEAK MeshInterface *MeshInterface::get_target_default_instance()

features/nanostack/mbed-mesh-api/source/wisun_tasklet.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,23 @@ int wisun_tasklet_statistics_nw_read(mesh_nw_statistics_t *stats)
646646
stats->etx_2nd_parent = statistics->nwk_stats.etx_2nd_parent;
647647
stats->asynch_tx_count = statistics->ws_statistics.asynch_tx_count;
648648
stats->asynch_rx_count = statistics->ws_statistics.asynch_rx_count;
649+
stats->join_state_1 = statistics->ws_statistics.join_state_1;
650+
stats->join_state_2 = statistics->ws_statistics.join_state_2;
651+
stats->join_state_3 = statistics->ws_statistics.join_state_3;
652+
stats->join_state_4 = statistics->ws_statistics.join_state_4;
653+
stats->join_state_5 = statistics->ws_statistics.join_state_5;
654+
stats->sent_PAS = statistics->ws_statistics.sent_PAS;
655+
stats->sent_PA = statistics->ws_statistics.sent_PA;
656+
stats->sent_PCS = statistics->ws_statistics.sent_PCS;
657+
stats->sent_PC = statistics->ws_statistics.sent_PC;
658+
stats->recv_PAS = statistics->ws_statistics.recv_PAS;
659+
stats->recv_PA = statistics->ws_statistics.recv_PA;
660+
stats->recv_PCS = statistics->ws_statistics.recv_PCS;
661+
stats->recv_PC = statistics->ws_statistics.recv_PC;
662+
stats->Neighbour_add = statistics->ws_statistics.Neighbour_add;
663+
stats->Neighbour_remove = statistics->ws_statistics.Neighbour_remove;
664+
stats->Child_add = statistics->ws_statistics.Child_add;
665+
stats->child_remove = statistics->ws_statistics.child_remove;
649666

650667
return 0;
651668
}

0 commit comments

Comments
 (0)