Skip to content

Commit 6f43f03

Browse files
authored
Merge pull request #14553 from debdeep-arm/reset-ws-stats-master
Added API to reset MAC statistics and Wi-SUN statistics
2 parents d443de3 + 83844f0 commit 6f43f03

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,16 @@ class WisunInterface final : public MeshInterfaceNanostack {
508508
* */
509509
mesh_error_t enable_statistics(void);
510510

511+
/**
512+
* \brief Reset Wi-SUN statistics
513+
*
514+
* Resets MAC statistics and Wi-SUN statistics.
515+
*
516+
* \return MESH_ERROR_NONE on success.
517+
* \return MESH_ERROR_UNKNOWN on error
518+
* */
519+
mesh_error_t reset_statistics(void);
520+
511521
/**
512522
* \brief Reads Wi-SUN network statistics
513523
*

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,16 @@ mesh_error_t WisunInterface::enable_statistics(void)
565565
return ret_val;
566566
}
567567

568+
mesh_error_t WisunInterface::reset_statistics(void)
569+
{
570+
mesh_error_t ret_val = MESH_ERROR_NONE;
571+
int status = wisun_tasklet_statistics_reset();
572+
if (status < 0) {
573+
ret_val = MESH_ERROR_UNKNOWN;
574+
}
575+
return ret_val;
576+
}
577+
568578
mesh_error_t WisunInterface::read_nw_statistics(mesh_nw_statistics_t *statistics)
569579
{
570580
mesh_error_t ret_val = MESH_ERROR_NONE;

connectivity/nanostack/mbed-mesh-api/source/include/wisun_tasklet.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ int wisun_tasklet_remove_trusted_certificates(void);
126126
*/
127127
int wisun_tasklet_statistics_start(void);
128128

129+
/*
130+
* \brief Reset Wi-SUN statistics
131+
*
132+
* \return 0 Statistics start successful
133+
* \return < 0 in case of errors
134+
*/
135+
int wisun_tasklet_statistics_reset(void);
136+
129137
/*
130138
* \brief Reads Wi-SUN network statistics
131139
*

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,18 @@ int wisun_tasklet_statistics_start(void)
625625
return 0;
626626
}
627627

628+
int wisun_tasklet_statistics_reset(void)
629+
{
630+
if (!statistics) {
631+
return -1;
632+
}
633+
634+
memset(&statistics->mac_statistics, 0, sizeof(mac_statistics_t));
635+
memset(&statistics->ws_statistics, 0, sizeof(ws_statistics_t));
636+
637+
return 0;
638+
}
639+
628640
static void wisun_tasklet_statistics_do_start(void)
629641
{
630642
if (!wisun_tasklet_data_ptr || wisun_tasklet_data_ptr->network_interface_id < 0 || !mac_api) {

0 commit comments

Comments
 (0)