2023-06-29 22:14:27 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2023 Nordic Semiconductor ASA
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <zephyr/bluetooth/mesh.h>
|
|
|
|
|
|
|
|
#include "net.h"
|
|
|
|
#include "statistic.h"
|
|
|
|
|
|
|
|
static struct bt_mesh_statistic stat;
|
|
|
|
|
|
|
|
void bt_mesh_stat_get(struct bt_mesh_statistic *st)
|
|
|
|
{
|
|
|
|
memcpy(st, &stat, sizeof(struct bt_mesh_statistic));
|
|
|
|
}
|
|
|
|
|
|
|
|
void bt_mesh_stat_reset(void)
|
|
|
|
{
|
|
|
|
memset(&stat, 0, sizeof(struct bt_mesh_statistic));
|
|
|
|
}
|
|
|
|
|
2023-12-05 10:01:19 +08:00
|
|
|
void bt_mesh_stat_planned_count(struct bt_mesh_adv_ctx *ctx)
|
2023-06-29 22:14:27 +08:00
|
|
|
{
|
2023-12-05 10:01:19 +08:00
|
|
|
if (ctx->tag == BT_MESH_ADV_TAG_LOCAL) {
|
2023-06-29 22:14:27 +08:00
|
|
|
stat.tx_local_planned++;
|
2023-12-05 10:01:19 +08:00
|
|
|
} else if (ctx->tag == BT_MESH_ADV_TAG_RELAY) {
|
2023-06-29 22:14:27 +08:00
|
|
|
stat.tx_adv_relay_planned++;
|
2023-12-05 10:01:19 +08:00
|
|
|
} else if (ctx->tag == BT_MESH_ADV_TAG_FRIEND) {
|
2023-06-29 22:14:27 +08:00
|
|
|
stat.tx_friend_planned++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-05 10:01:19 +08:00
|
|
|
void bt_mesh_stat_succeeded_count(struct bt_mesh_adv_ctx *ctx)
|
2023-06-29 22:14:27 +08:00
|
|
|
{
|
2023-12-05 10:01:19 +08:00
|
|
|
if (ctx->tag == BT_MESH_ADV_TAG_LOCAL) {
|
2023-06-29 22:14:27 +08:00
|
|
|
stat.tx_local_succeeded++;
|
2023-12-05 10:01:19 +08:00
|
|
|
} else if (ctx->tag == BT_MESH_ADV_TAG_RELAY) {
|
2023-06-29 22:14:27 +08:00
|
|
|
stat.tx_adv_relay_succeeded++;
|
2023-12-05 10:01:19 +08:00
|
|
|
} else if (ctx->tag == BT_MESH_ADV_TAG_FRIEND) {
|
2023-06-29 22:14:27 +08:00
|
|
|
stat.tx_friend_succeeded++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void bt_mesh_stat_rx(enum bt_mesh_net_if net_if)
|
|
|
|
{
|
|
|
|
switch (net_if) {
|
|
|
|
case BT_MESH_NET_IF_ADV:
|
|
|
|
stat.rx_adv++;
|
|
|
|
break;
|
|
|
|
case BT_MESH_NET_IF_LOCAL:
|
|
|
|
stat.rx_loopback++;
|
|
|
|
break;
|
|
|
|
case BT_MESH_NET_IF_PROXY:
|
|
|
|
case BT_MESH_NET_IF_PROXY_CFG:
|
|
|
|
stat.rx_proxy++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
stat.rx_uknown++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|