Skip to content

Added API to reset MAC statistics and Wi-SUN statistics #14553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,16 @@ class WisunInterface final : public MeshInterfaceNanostack {
* */
mesh_error_t enable_statistics(void);

/**
* \brief Reset Wi-SUN statistics
*
* Resets MAC statistics and Wi-SUN statistics.
*
* \return MESH_ERROR_NONE on success.
* \return MESH_ERROR_UNKNOWN on error
* */
mesh_error_t reset_statistics(void);

/**
* \brief Reads Wi-SUN network statistics
*
Expand Down
10 changes: 10 additions & 0 deletions connectivity/nanostack/mbed-mesh-api/source/WisunInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,16 @@ mesh_error_t WisunInterface::enable_statistics(void)
return ret_val;
}

mesh_error_t WisunInterface::reset_statistics(void)
{
mesh_error_t ret_val = MESH_ERROR_NONE;
int status = wisun_tasklet_statistics_reset();
if (status < 0) {
ret_val = MESH_ERROR_UNKNOWN;
}
return ret_val;
}

mesh_error_t WisunInterface::read_nw_statistics(mesh_nw_statistics_t *statistics)
{
mesh_error_t ret_val = MESH_ERROR_NONE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ int wisun_tasklet_remove_trusted_certificates(void);
*/
int wisun_tasklet_statistics_start(void);

/*
* \brief Reset Wi-SUN statistics
*
* \return 0 Statistics start successful
* \return < 0 in case of errors
*/
int wisun_tasklet_statistics_reset(void);

/*
* \brief Reads Wi-SUN network statistics
*
Expand Down
12 changes: 12 additions & 0 deletions connectivity/nanostack/mbed-mesh-api/source/wisun_tasklet.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,18 @@ int wisun_tasklet_statistics_start(void)
return 0;
}

int wisun_tasklet_statistics_reset(void)
{
if (!statistics) {
return -1;
}

memset(&statistics->mac_statistics, 0, sizeof(mac_statistics_t));
memset(&statistics->ws_statistics, 0, sizeof(ws_statistics_t));

return 0;
}

static void wisun_tasklet_statistics_do_start(void)
{
if (!wisun_tasklet_data_ptr || wisun_tasklet_data_ptr->network_interface_id < 0 || !mac_api) {
Expand Down