forked from zephyrproject-rtos/zephyr
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbtp_ias.c
82 lines (59 loc) · 1.46 KB
/
btp_ias.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* btp_ias.c - Bluetooth IAS Server Tester */
/*
* Copyright (c) 2022 Codecoup
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <zephyr/autoconf.h>
#include <zephyr/bluetooth/services/ias.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/byteorder.h>
#include "btp/btp.h"
#define LOG_MODULE_NAME bttester_ias
LOG_MODULE_REGISTER(LOG_MODULE_NAME, CONFIG_BTTESTER_LOG_LEVEL);
static bool initialized;
/* Immediate Alert Service */
static void alert_stop(void)
{
struct btp_ias_alert_action_ev ev;
if (!initialized) {
return;
}
ev.alert_lvl = BT_IAS_ALERT_LVL_NO_ALERT;
tester_event(BTP_SERVICE_ID_IAS, BTP_IAS_EV_OUT_ALERT_ACTION,
(uint8_t *)&ev, sizeof(ev));
}
static void alert_start(void)
{
struct btp_ias_alert_action_ev ev;
if (!initialized) {
return;
}
ev.alert_lvl = BT_IAS_ALERT_LVL_MILD_ALERT;
tester_event(BTP_SERVICE_ID_IAS, BTP_IAS_EV_OUT_ALERT_ACTION, &ev, sizeof(ev));
}
static void alert_high_start(void)
{
struct btp_ias_alert_action_ev ev;
if (!initialized) {
return;
}
ev.alert_lvl = BT_IAS_ALERT_LVL_HIGH_ALERT;
tester_event(BTP_SERVICE_ID_IAS, BTP_IAS_EV_OUT_ALERT_ACTION, &ev, sizeof(ev));
}
BT_IAS_CB_DEFINE(ias_callbacks) = {
.no_alert = alert_stop,
.mild_alert = alert_start,
.high_alert = alert_high_start,
};
uint8_t tester_init_ias(void)
{
initialized = true;
return BTP_STATUS_SUCCESS;
}
uint8_t tester_unregister_ias(void)
{
initialized = false;
return BTP_STATUS_SUCCESS;
}