Skip to content

Commit 850a8c0

Browse files
committed
tests: add moc for sid_ep_cfg_metrics
fix ut error in ci Signed-off-by: Krzysztof Taborowski <krzysztof.taborowski@nordicsemi.no>
1 parent c919869 commit 850a8c0

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

tests/unit_tests/sid_dut_shell/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ target_sources(testbinary PRIVATE
1919
${SIDEWALK_BASE}/samples/sid_end_device/src/cli/app_shell.c
2020
$ENV{ZEPHYR_BASE}/lib/utils/hex.c
2121
mock/sidewalk_version.c
22+
mock/stub_ep_cfg_metrics.c
2223
)
2324

2425
add_definitions(--include ztest.h)
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*
6+
* Stub implementations for sid_ep_cfg_* and sid_metrics_core_cli_* symbols
7+
* used by app_shell.c. Required for unit_testing where the full Sidewalk stack
8+
* is not linked.
9+
*/
10+
11+
#include <stdbool.h>
12+
#include <stdint.h>
13+
#include <sid_api.h>
14+
15+
/* Mirror type definitions from app_shell.c (no public API for these). */
16+
struct sid_ep_cap {
17+
uint8_t version;
18+
uint8_t links_enabled;
19+
uint8_t traffic_threshold_id;
20+
uint8_t metrics_periodicity;
21+
uint16_t sdk_version;
22+
uint16_t max_tx_power;
23+
uint16_t qualification_id;
24+
uint32_t features_support;
25+
};
26+
27+
struct sid_ep_cfg_traffic_thresholds {
28+
uint8_t table_id;
29+
uint8_t lora_static_normal_rate;
30+
uint8_t lora_static_burst_rate;
31+
uint8_t lora_mobile_normal_rate;
32+
uint8_t lora_mobile_burst_rate;
33+
uint16_t lora_static_max_packets_per_day;
34+
uint16_t lora_mobile_max_packets_per_day;
35+
uint16_t fsk_min_packets_per_minute;
36+
uint16_t ble_min_packets_per_minute;
37+
};
38+
39+
struct sid_ep_cfg {
40+
uint8_t metrics_enabled;
41+
uint8_t metrics_periodicity;
42+
uint8_t traffic_throttling_enabled;
43+
uint8_t current_traffic_threshold_table_id;
44+
uint32_t tag_enabled_mask;
45+
struct sid_ep_cfg_traffic_thresholds traffic_thresholds_table;
46+
};
47+
48+
enum sid_metrics_category_ids {
49+
SID_METRICS_CAT_CONFIG = 0x00,
50+
SID_METRICS_CAT_LOCATION = 0x12,
51+
SID_METRICS_CAT_ALL = 0x36,
52+
};
53+
54+
enum sid_metrics_core_actions {
55+
SID_METRICS_ACTION_NONE = 0xff,
56+
SID_METRICS_ACTION_CLEAR = 0,
57+
};
58+
59+
void sid_ep_cfg_get_active_cap(struct sid_ep_cap *cap, bool clear)
60+
{
61+
(void)clear;
62+
if (cap) {
63+
cap->version = 0;
64+
cap->links_enabled = 0;
65+
cap->traffic_threshold_id = 0;
66+
cap->metrics_periodicity = 0;
67+
cap->sdk_version = 0;
68+
cap->max_tx_power = 0;
69+
cap->qualification_id = 0;
70+
cap->features_support = 0;
71+
}
72+
}
73+
74+
void sid_ep_cfg_get_active_cfg(struct sid_ep_cfg *cfg, bool clear)
75+
{
76+
(void)clear;
77+
if (cfg) {
78+
cfg->metrics_enabled = 0;
79+
cfg->metrics_periodicity = 0;
80+
cfg->traffic_throttling_enabled = 0;
81+
cfg->current_traffic_threshold_table_id = 0;
82+
cfg->tag_enabled_mask = 0;
83+
cfg->traffic_thresholds_table.table_id = 0;
84+
cfg->traffic_thresholds_table.lora_static_normal_rate = 0;
85+
cfg->traffic_thresholds_table.lora_static_burst_rate = 0;
86+
cfg->traffic_thresholds_table.lora_mobile_normal_rate = 0;
87+
cfg->traffic_thresholds_table.lora_mobile_burst_rate = 0;
88+
cfg->traffic_thresholds_table.lora_static_max_packets_per_day = 0;
89+
cfg->traffic_thresholds_table.lora_mobile_max_packets_per_day = 0;
90+
cfg->traffic_thresholds_table.fsk_min_packets_per_minute = 0;
91+
cfg->traffic_thresholds_table.ble_min_packets_per_minute = 0;
92+
}
93+
}
94+
95+
sid_error_t sid_metrics_core_cli_print_cat_by_priority(enum sid_metrics_category_ids category)
96+
{
97+
(void)category;
98+
return SID_ERROR_NONE;
99+
}
100+
101+
sid_error_t sid_metrics_core_cli_execute_action(enum sid_metrics_core_actions action,
102+
enum sid_metrics_category_ids category,
103+
uint32_t raw_bitmask)
104+
{
105+
(void)action;
106+
(void)category;
107+
(void)raw_bitmask;
108+
return SID_ERROR_NONE;
109+
}

0 commit comments

Comments
 (0)