Merge pull request #14619 from debdeep-arm/ws-stats-nbr-table-master

Add API to get Wi-SUN Neighbor Table
pull/14661/head
Martin Kojtal 2021-05-12 16:28:33 +02:00 committed by GitHub
commit 541ae06545
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 92 additions and 0 deletions

View File

@ -67,6 +67,37 @@ typedef struct ws_cca_threshold_table {
const int8_t *cca_threshold_table;
} ws_cca_threshold_table_t;
typedef enum {
WISUN_OTHER = 0, /**< temporary or soon to be removed neighbor*/
WISUN_PRIMARY_PARENT, /**< Primary parent used for upward packets and used from Border router downwards*/
WISUN_SECONDARY_PARENT, /**< Secondary parent reported to border router and might be used as alternate route*/
WISUN_CANDIDATE_PARENT, /**< Candidate neighbor that is considered as parent if there is problem with active parents*/
WISUN_CHILD /**< Child with registered address*/
} ws_nbr_type_e;
/**
* \brief Struct ws_nbr_info_t Gives the neighbor information.
*/
typedef struct ws_nbr_info {
/** Link local address*/
uint8_t link_local_address[16];
/** Global address if it is known set to 0 if not available*/
uint8_t global_address[16];
/** parent RSSI Out measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
uint8_t rsl_out;
/** parent RSSI in measured RSSI value calculated using EWMA specified by Wi-SUN from range of -174 (0) to +80 (254) dBm.*/
uint8_t rsl_in;
/** RPL Rank value for parents 0xffff for neighbors RANK is unknown*/
uint16_t rpl_rank;
/** Measured ETX value if known set to 0xFFFF if not known or Child*/
uint16_t etx;
/** Remaining lifetime Link lifetime for parents and ARO lifetime for children*/
uint32_t lifetime;
/** Neighbour type (Primary Parent, Secondary Parent, Candidate parent, child, other(Temporary neighbours))*/
ws_nbr_type_e type;
} ws_nbr_info_t;
/** Wi-SUN mesh network interface class
*
* Configure Nanostack to use Wi-SUN protocol.
@ -578,6 +609,20 @@ public:
* */
mesh_error_t cca_threshold_table_get(ws_cca_threshold_table_t *table);
/**
* \brief Get Wi-SUN Neighbor table information.
*
* To allocate correct amount of memory first use the API with nbr_ptr = NULL to get current amount
* of neighbors in count pointer. Then Allocate the memory and call the function to fill the table.
*
* \param nbr_ptr Pointer to memory where Neighbor table entries can be written.
* \param count amount of neighbor table entries allocated to memory.
*
* \return MESH_ERROR_NONE on success.
* \return MESH_ERROR_UNKNOWN in case of failure.
* */
mesh_error_t nbr_info_get(ws_nbr_info_t *nbr_ptr, uint16_t *count);
protected:
Nanostack::WisunInterface *get_interface() const;
nsapi_error_t do_initialize() override;

View File

@ -83,6 +83,23 @@ typedef struct {
uint16_t etx_2nd_parent; /*<! Secondary parent ETX. */
uint32_t asynch_tx_count; /*<! Asynch TX counter */
uint32_t asynch_rx_count; /*<! Asynch RX counter */
uint32_t join_state_1; /*<! Time spent in individual Wi-SUN join state 1 Discovery */
uint32_t join_state_2; /*<! Time spent in individual Wi-SUN join state 2 Authentication */
uint32_t join_state_3; /*<! Time spent in individual Wi-SUN join state 3 Configuration learn */
uint32_t join_state_4; /*<! Time spent in individual Wi-SUN join state 4 RPL parent discovery */
uint32_t join_state_5; /*<! Time spent in individual Wi-SUN join state 5 Active state */
uint32_t sent_PAS; /*<! Amount of Wi-SUN Pan Advertisement Solicit Message sent */
uint32_t sent_PA; /*<! Amount of Wi-SUN Pan Advertisement Message sent */
uint32_t sent_PCS; /*<! Amount of Wi-SUN Pan Configuration Solicit Message sent */
uint32_t sent_PC; /*<! Amount of Wi-SUN Pan Configuration Message sent */
uint32_t recv_PAS; /*<! Amount of Wi-SUN Pan Advertisement Solicit Message received */
uint32_t recv_PA; /*<! Amount of Wi-SUN Pan Advertisement Message received */
uint32_t recv_PCS; /*<! Amount of Wi-SUN Pan Configuration Solicit Message received */
uint32_t recv_PC; /*<! Amount of Wi-SUN Pan Configuration Message received */
uint32_t Neighbour_add; /*<! New Neighbours found */
uint32_t Neighbour_remove; /*<! New Neighbours Removed */
uint32_t Child_add; /*<! New Child added */
uint32_t child_remove; /*<! Child lost */
} mesh_nw_statistics_t;
/**

View File

@ -696,6 +696,19 @@ mesh_error_t WisunInterface::cca_threshold_table_get(ws_cca_threshold_table_t *t
return MESH_ERROR_NONE;
}
mesh_error_t WisunInterface::nbr_info_get(ws_nbr_info_t *nbr_ptr, uint16_t *count)
{
uint16_t nbr_count;
if (count == NULL) {
return MESH_ERROR_UNKNOWN;
}
nbr_count = ws_neighbor_info_get(get_interface_id(), (ws_neighbour_info_t *)nbr_ptr, *count);
*count = nbr_count;
return MESH_ERROR_NONE;
}
#define WISUN 0x2345
#if MBED_CONF_NSAPI_DEFAULT_MESH_TYPE == WISUN && DEVICE_802_15_4_PHY
MBED_WEAK MeshInterface *MeshInterface::get_target_default_instance()

View File

@ -659,6 +659,23 @@ int wisun_tasklet_statistics_nw_read(mesh_nw_statistics_t *stats)
stats->etx_2nd_parent = statistics->nwk_stats.etx_2nd_parent;
stats->asynch_tx_count = statistics->ws_statistics.asynch_tx_count;
stats->asynch_rx_count = statistics->ws_statistics.asynch_rx_count;
stats->join_state_1 = statistics->ws_statistics.join_state_1;
stats->join_state_2 = statistics->ws_statistics.join_state_2;
stats->join_state_3 = statistics->ws_statistics.join_state_3;
stats->join_state_4 = statistics->ws_statistics.join_state_4;
stats->join_state_5 = statistics->ws_statistics.join_state_5;
stats->sent_PAS = statistics->ws_statistics.sent_PAS;
stats->sent_PA = statistics->ws_statistics.sent_PA;
stats->sent_PCS = statistics->ws_statistics.sent_PCS;
stats->sent_PC = statistics->ws_statistics.sent_PC;
stats->recv_PAS = statistics->ws_statistics.recv_PAS;
stats->recv_PA = statistics->ws_statistics.recv_PA;
stats->recv_PCS = statistics->ws_statistics.recv_PCS;
stats->recv_PC = statistics->ws_statistics.recv_PC;
stats->Neighbour_add = statistics->ws_statistics.Neighbour_add;
stats->Neighbour_remove = statistics->ws_statistics.Neighbour_remove;
stats->Child_add = statistics->ws_statistics.Child_add;
stats->child_remove = statistics->ws_statistics.child_remove;
return 0;
}