Skip to content

Commit d963a9a

Browse files
committed
Added API to get Wi-SUN Neighbor Table
1 parent 376fda5 commit d963a9a

File tree

4 files changed

+92
-0
lines changed

4 files changed

+92
-0
lines changed

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,37 @@ 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+
100+
70101
/** Wi-SUN mesh network interface class
71102
*
72103
* Configure Nanostack to use Wi-SUN protocol.
@@ -578,6 +609,20 @@ class WisunInterface final : public MeshInterfaceNanostack {
578609
* */
579610
mesh_error_t cca_threshold_table_get(ws_cca_threshold_table_t *table);
580611

612+
/**
613+
* \brief Get Wi-SUN Neighbor table information.
614+
*
615+
* To allocate correct amount of memory first use the API with nbr_ptr = NULL to get current amount
616+
* of neighbors in count pointer. Then Allocate the memory and call the function to fill the table.
617+
*
618+
* \param nbr_ptr Pointer to memory where Neighbor table entries can be written.
619+
* \param count amount of neighbor table entries allocated to memory.
620+
*
621+
* \return MESH_ERROR_NONE on success.
622+
* \return MESH_ERROR_UNKNOWN in case of failure.
623+
* */
624+
mesh_error_t nbr_info_get(ws_nbr_info_t *nbr_ptr, uint16_t *count);
625+
581626
protected:
582627
Nanostack::WisunInterface *get_interface() const;
583628
nsapi_error_t do_initialize() override;

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

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,19 @@ mesh_error_t WisunInterface::cca_threshold_table_get(ws_cca_threshold_table_t *t
696696
return MESH_ERROR_NONE;
697697
}
698698

699+
mesh_error_t WisunInterface::nbr_info_get(ws_nbr_info_t *nbr_ptr, uint16_t *count)
700+
{
701+
uint16_t nbr_count;
702+
703+
if (count == NULL) {
704+
return MESH_ERROR_UNKNOWN;
705+
}
706+
707+
nbr_count = ws_neighbor_info_get(get_interface_id(), (ws_neighbour_info_t *)nbr_ptr, *count);
708+
*count = nbr_count;
709+
return MESH_ERROR_NONE;
710+
}
711+
699712
#define WISUN 0x2345
700713
#if MBED_CONF_NSAPI_DEFAULT_MESH_TYPE == WISUN && DEVICE_802_15_4_PHY
701714
MBED_WEAK MeshInterface *MeshInterface::get_target_default_instance()

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,23 @@ int wisun_tasklet_statistics_nw_read(mesh_nw_statistics_t *stats)
659659
stats->etx_2nd_parent = statistics->nwk_stats.etx_2nd_parent;
660660
stats->asynch_tx_count = statistics->ws_statistics.asynch_tx_count;
661661
stats->asynch_rx_count = statistics->ws_statistics.asynch_rx_count;
662+
stats->join_state_1 = statistics->ws_statistics.join_state_1;
663+
stats->join_state_2 = statistics->ws_statistics.join_state_2;
664+
stats->join_state_3 = statistics->ws_statistics.join_state_3;
665+
stats->join_state_4 = statistics->ws_statistics.join_state_4;
666+
stats->join_state_5 = statistics->ws_statistics.join_state_5;
667+
stats->sent_PAS = statistics->ws_statistics.sent_PAS;
668+
stats->sent_PA = statistics->ws_statistics.sent_PA;
669+
stats->sent_PCS = statistics->ws_statistics.sent_PCS;
670+
stats->sent_PC = statistics->ws_statistics.sent_PC;
671+
stats->recv_PAS = statistics->ws_statistics.recv_PAS;
672+
stats->recv_PA = statistics->ws_statistics.recv_PA;
673+
stats->recv_PCS = statistics->ws_statistics.recv_PCS;
674+
stats->recv_PC = statistics->ws_statistics.recv_PC;
675+
stats->Neighbour_add = statistics->ws_statistics.Neighbour_add;
676+
stats->Neighbour_remove = statistics->ws_statistics.Neighbour_remove;
677+
stats->Child_add = statistics->ws_statistics.Child_add;
678+
stats->child_remove = statistics->ws_statistics.child_remove;
662679

663680
return 0;
664681
}

0 commit comments

Comments
 (0)