1 /* 2 * Copyright (c) 2023 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/bluetooth/mesh.h> 8 9 #include "net.h" 10 #include "statistic.h" 11 12 static struct bt_mesh_statistic stat; 13 bt_mesh_stat_get(struct bt_mesh_statistic * st)14void bt_mesh_stat_get(struct bt_mesh_statistic *st) 15 { 16 memcpy(st, &stat, sizeof(struct bt_mesh_statistic)); 17 } 18 bt_mesh_stat_reset(void)19void bt_mesh_stat_reset(void) 20 { 21 memset(&stat, 0, sizeof(struct bt_mesh_statistic)); 22 } 23 bt_mesh_stat_planned_count(struct bt_mesh_adv_ctx * ctx)24void bt_mesh_stat_planned_count(struct bt_mesh_adv_ctx *ctx) 25 { 26 if (ctx->tag == BT_MESH_ADV_TAG_LOCAL) { 27 stat.tx_local_planned++; 28 } else if (ctx->tag == BT_MESH_ADV_TAG_RELAY) { 29 stat.tx_adv_relay_planned++; 30 } else if (ctx->tag == BT_MESH_ADV_TAG_FRIEND) { 31 stat.tx_friend_planned++; 32 } 33 } 34 bt_mesh_stat_succeeded_count(struct bt_mesh_adv_ctx * ctx)35void bt_mesh_stat_succeeded_count(struct bt_mesh_adv_ctx *ctx) 36 { 37 if (ctx->tag == BT_MESH_ADV_TAG_LOCAL) { 38 stat.tx_local_succeeded++; 39 } else if (ctx->tag == BT_MESH_ADV_TAG_RELAY) { 40 stat.tx_adv_relay_succeeded++; 41 } else if (ctx->tag == BT_MESH_ADV_TAG_FRIEND) { 42 stat.tx_friend_succeeded++; 43 } 44 } 45 bt_mesh_stat_rx(enum bt_mesh_net_if net_if)46void bt_mesh_stat_rx(enum bt_mesh_net_if net_if) 47 { 48 switch (net_if) { 49 case BT_MESH_NET_IF_ADV: 50 stat.rx_adv++; 51 break; 52 case BT_MESH_NET_IF_LOCAL: 53 stat.rx_loopback++; 54 break; 55 case BT_MESH_NET_IF_PROXY: 56 case BT_MESH_NET_IF_PROXY_CFG: 57 stat.rx_proxy++; 58 break; 59 default: 60 stat.rx_uknown++; 61 break; 62 } 63 } 64