Skip to content

Commit e48b7b9

Browse files
authored
Merge pull request #14552 from debdeep-arm/reset-ws-stats-5.15
mbed-os-5.15: Add API to reset MAC statistics and Wi-SUN statistics
2 parents 32ecdb3 + 41ddf0e commit e48b7b9

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,16 @@ class WisunInterface : public MeshInterfaceNanostack {
556556
* */
557557
mesh_error_t enable_statistics(void);
558558

559+
/**
560+
* \brief Reset Wi-SUN statistics
561+
*
562+
* Resets MAC statistics and Wi-SUN statistics.
563+
*
564+
* \return MESH_ERROR_NONE on success.
565+
* \return MESH_ERROR_UNKNOWN on error
566+
* */
567+
mesh_error_t reset_statistics(void);
568+
559569
/**
560570
* \brief Reads Wi-SUN network statistics
561571
*

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

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)