Skip to content

Commit 72c3981

Browse files
author
Arto Kinnunen
authored
Merge pull request #14439 from debdeep-arm/reset-mac-wisun-stats
[feature-wisun] Added API to reset MAC and Wi-SUN statistics.
2 parents e03f3c6 + e686f68 commit 72c3981

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
@@ -559,6 +559,16 @@ class WisunInterface : public MeshInterfaceNanostack {
559559
* */
560560
mesh_error_t enable_statistics(void);
561561

562+
/**
563+
* \brief Reset Wi-SUN statistics
564+
*
565+
* Resets MAC statistics and Wi-SUN statistics.
566+
*
567+
* \return MESH_ERROR_NONE on success.
568+
* \return MESH_ERROR_UNKNOWN on error
569+
* */
570+
mesh_error_t reset_statistics(void);
571+
562572
/**
563573
* \brief Reads Wi-SUN network statistics
564574
*

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,16 @@ mesh_error_t WisunInterface::enable_statistics(void)
603603
return ret_val;
604604
}
605605

606+
mesh_error_t WisunInterface::reset_statistics(void)
607+
{
608+
mesh_error_t ret_val = MESH_ERROR_NONE;
609+
int status = wisun_tasklet_statistics_reset();
610+
if (status < 0) {
611+
ret_val = MESH_ERROR_UNKNOWN;
612+
}
613+
return ret_val;
614+
}
615+
606616
mesh_error_t WisunInterface::read_nw_statistics(mesh_nw_statistics_t *statistics)
607617
{
608618
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)