zephyr/subsys/bluetooth/mesh/statistic.c
Lingao Meng 141467a261 Bluetooth: Mesh: Rename adv relay to adv simultaneous
Since notice that simultaneous advertising is not only used
by relay message, provision over pb-adv can also be used.
so it was changed to a more general name.

refs:https://github.com/zephyrproject-rtos/zephyr/pull/48903

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2023-10-20 14:54:17 +02:00

65 lines
1.3 KiB
C

/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/bluetooth/mesh.h>
#include "adv.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));
}
void bt_mesh_stat_planned_count(struct bt_mesh_adv *adv)
{
if (adv->tag == BT_MESH_ADV_TAG_LOCAL) {
stat.tx_local_planned++;
} else if (adv->tag == BT_MESH_ADV_TAG_RELAY) {
stat.tx_adv_relay_planned++;
} else if (adv->tag == BT_MESH_ADV_TAG_FRIEND) {
stat.tx_friend_planned++;
}
}
void bt_mesh_stat_succeeded_count(struct bt_mesh_adv *adv)
{
if (adv->tag == BT_MESH_ADV_TAG_LOCAL) {
stat.tx_local_succeeded++;
} else if (adv->tag == BT_MESH_ADV_TAG_RELAY) {
stat.tx_adv_relay_succeeded++;
} else if (adv->tag == BT_MESH_ADV_TAG_FRIEND) {
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;
}
}