Skip to content

Commit eb327af

Browse files
lylezhu2012kartben
authored andcommitted
Bluetooth: HFP: Divide hfp_internal.h
Divide hfp_internal.h into two parts, HFP HF part hfp_hf_internal.h and HFP common part hfp_internal.h. Includes "hfp_internal.h" in file "hfp_ag_internal.h". Includes "hfp_ag_internal.h" in file "hfp_ag.c". Includes "hfp_internal.h" in file "hfp_hf_internal.h". Includes "hfp_hf_internal.h" in file "hfp_hf.c". Signed-off-by: Lyle Zhu <[email protected]>
1 parent fcedda6 commit eb327af

File tree

5 files changed

+235
-225
lines changed

5 files changed

+235
-225
lines changed

subsys/bluetooth/host/classic/hfp_ag.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
#include "rfcomm_internal.h"
2626
#include "at.h"
2727
#include "sco_internal.h"
28-
29-
#include "hfp_internal.h"
3028
#include "hfp_ag_internal.h"
3129

3230
#define LOG_LEVEL CONFIG_BT_HFP_AG_LOG_LEVEL

subsys/bluetooth/host/classic/hfp_ag_internal.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,7 @@
99
* SPDX-License-Identifier: Apache-2.0
1010
*/
1111

12-
/* HFP AG Features in SDP */
13-
#define BT_HFP_AG_SDP_FEATURE_3WAY_CALL BIT(0) /* Three-way calling */
14-
#define BT_HFP_AG_SDP_FEATURE_ECNR BIT(1) /* EC and/or NR function */
15-
#define BT_HFP_AG_SDP_FEATURE_VOICE_RECG BIT(2) /* Voice recognition */
16-
#define BT_HFP_AG_SDP_FEATURE_INBAND_RINGTONE BIT(3) /* In-band ring tone capability */
17-
#define BT_HFP_AG_SDP_FEATURE_VOICE_TAG BIT(4) /* Attach no. to voice tag */
18-
#define BT_HFP_AG_SDP_FEATURE_WBS BIT(5) /* Wide Band Speech */
19-
#define BT_HFP_AG_SDP_FEATURE_ENH_VOICE_RECG BIT(6) /* Enhanced Voice Recognition Status */
20-
#define BT_HFP_AG_SDP_FEATURE_VOICE_RECG_TEXT BIT(7) /* Voice Recognition Text */
21-
#define BT_HFP_AG_SDP_FEATURE_SUPER_WBS BIT(8) /* Super Wide Band Speech */
12+
#include "hfp_internal.h"
2213

2314
#if defined(CONFIG_BT_HFP_AG_EXT_ERR)
2415
#define BT_HFP_AG_FEATURE_EXT_ERR_ENABLE BT_HFP_AG_FEATURE_EXT_ERR

subsys/bluetooth/host/classic/hfp_hf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include "rfcomm_internal.h"
2727
#include "at.h"
2828
#include "sco_internal.h"
29-
#include "hfp_internal.h"
29+
#include "hfp_hf_internal.h"
3030

3131
#define LOG_LEVEL CONFIG_BT_HFP_HF_LOG_LEVEL
3232
#include <zephyr/logging/log.h>
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
/** @file
2+
* @brief Internal APIs for Bluetooth Handsfree profile handling.
3+
*/
4+
5+
/*
6+
* Copyright (c) 2015-2016 Intel Corporation
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*/
10+
11+
#include "hfp_internal.h"
12+
13+
#if defined(CONFIG_BT_HFP_HF_CLI)
14+
#define BT_HFP_HF_FEATURE_CLI_ENABLE BT_HFP_HF_FEATURE_CLI
15+
#define BT_HFP_HF_SDP_FEATURE_CLI_ENABLE BT_HFP_HF_SDP_FEATURE_CLI
16+
#else
17+
#define BT_HFP_HF_FEATURE_CLI_ENABLE 0
18+
#define BT_HFP_HF_SDP_FEATURE_CLI_ENABLE 0
19+
#endif /* CONFIG_BT_HFP_HF_CLI */
20+
21+
#if defined(CONFIG_BT_HFP_HF_VOLUME)
22+
#define BT_HFP_HF_FEATURE_VOLUME_ENABLE BT_HFP_HF_FEATURE_VOLUME
23+
#define BT_HFP_HF_SDP_FEATURE_VOLUME_ENABLE BT_HFP_HF_SDP_FEATURE_VOLUME
24+
#else
25+
#define BT_HFP_HF_FEATURE_VOLUME_ENABLE 0
26+
#define BT_HFP_HF_SDP_FEATURE_VOLUME_ENABLE 0
27+
#endif /* CONFIG_BT_HFP_HF_VOLUME */
28+
29+
#if defined(CONFIG_BT_HFP_HF_CODEC_NEG)
30+
#define BT_HFP_HF_CODEC_NEG_ENABLE BT_HFP_HF_FEATURE_CODEC_NEG
31+
#else
32+
#define BT_HFP_HF_CODEC_NEG_ENABLE 0
33+
#endif /* CONFIG_BT_HFP_HF_CODEC_NEG */
34+
35+
#if defined(CONFIG_BT_HFP_HF_ECNR)
36+
#define BT_HFP_HF_FEATURE_ECNR_ENABLE BT_HFP_HF_FEATURE_ECNR
37+
#define BT_HFP_HF_SDP_FEATURE_ECNR_ENABLE BT_HFP_HF_SDP_FEATURE_ECNR
38+
#else
39+
#define BT_HFP_HF_FEATURE_ECNR_ENABLE 0
40+
#define BT_HFP_HF_SDP_FEATURE_ECNR_ENABLE 0
41+
#endif /* CONFIG_BT_HFP_HF_CODEC_NEG */
42+
43+
#if defined(CONFIG_BT_HFP_HF_3WAY_CALL)
44+
#define BT_HFP_HF_FEATURE_3WAY_CALL_ENABLE BT_HFP_HF_FEATURE_3WAY_CALL
45+
#define BT_HFP_HF_SDP_FEATURE_3WAY_CALL_ENABLE BT_HFP_HF_SDP_FEATURE_3WAY_CALL
46+
#else
47+
#define BT_HFP_HF_FEATURE_3WAY_CALL_ENABLE 0
48+
#define BT_HFP_HF_SDP_FEATURE_3WAY_CALL_ENABLE 0
49+
#endif /* CONFIG_BT_HFP_HF_3WAY_CALL */
50+
51+
#if defined(CONFIG_BT_HFP_HF_ECS)
52+
#define BT_HFP_HF_FEATURE_ECS_ENABLE BT_HFP_HF_FEATURE_ECS
53+
#else
54+
#define BT_HFP_HF_FEATURE_ECS_ENABLE 0
55+
#endif /* CONFIG_BT_HFP_HF_ECS */
56+
57+
#if defined(CONFIG_BT_HFP_HF_ECC)
58+
#define BT_HFP_HF_FEATURE_ECC_ENABLE BT_HFP_HF_FEATURE_ECC
59+
#else
60+
#define BT_HFP_HF_FEATURE_ECC_ENABLE 0
61+
#endif /* CONFIG_BT_HFP_HF_ECC */
62+
63+
#if defined(CONFIG_BT_HFP_HF_VOICE_RECG)
64+
#define BT_HFP_HF_FEATURE_VOICE_RECG_ENABLE BT_HFP_HF_FEATURE_VOICE_RECG
65+
#define BT_HFP_HF_SDP_FEATURE_VOICE_RECG_ENABLE BT_HFP_HF_SDP_FEATURE_VOICE_RECG
66+
#else
67+
#define BT_HFP_HF_FEATURE_VOICE_RECG_ENABLE 0
68+
#define BT_HFP_HF_SDP_FEATURE_VOICE_RECG_ENABLE 0
69+
#endif /* CONFIG_BT_HFP_HF_VOICE_RECG */
70+
71+
#if defined(CONFIG_BT_HFP_HF_ENH_VOICE_RECG)
72+
#define BT_HFP_HF_FEATURE_ENH_VOICE_RECG_ENABLE BT_HFP_HF_FEATURE_ENH_VOICE_RECG
73+
#define BT_HFP_HF_SDP_FEATURE_ENH_VOICE_RECG_ENABLE BT_HFP_HF_SDP_FEATURE_ENH_VOICE_RECG
74+
#else
75+
#define BT_HFP_HF_FEATURE_ENH_VOICE_RECG_ENABLE 0
76+
#define BT_HFP_HF_SDP_FEATURE_ENH_VOICE_RECG_ENABLE 0
77+
#endif /* CONFIG_BT_HFP_HF_ENH_VOICE_RECG */
78+
79+
#if defined(CONFIG_BT_HFP_HF_VOICE_RECG_TEXT)
80+
#define BT_HFP_HF_FEATURE_VOICE_RECG_TEXT_ENABLE BT_HFP_HF_FEATURE_VOICE_RECG_TEXT
81+
#define BT_HFP_HF_SDP_FEATURE_VOICE_RECG_TEXT_ENABLE BT_HFP_HF_SDP_FEATURE_VOICE_RECG_TEXT
82+
#else
83+
#define BT_HFP_HF_FEATURE_VOICE_RECG_TEXT_ENABLE 0
84+
#define BT_HFP_HF_SDP_FEATURE_VOICE_RECG_TEXT_ENABLE 0
85+
#endif /* CONFIG_BT_HFP_HF_VOICE_RECG_TEXT */
86+
87+
#if defined(CONFIG_BT_HFP_HF_HF_INDICATORS)
88+
#define BT_HFP_HF_FEATURE_HF_IND_ENABLE BT_HFP_HF_FEATURE_HF_IND
89+
#else
90+
#define BT_HFP_HF_FEATURE_HF_IND_ENABLE 0
91+
#endif /* CONFIG_BT_HFP_HF_HF_INDICATORS */
92+
93+
/* HFP HF Supported features */
94+
#define BT_HFP_HF_SUPPORTED_FEATURES (\
95+
BT_HFP_HF_FEATURE_CLI_ENABLE | \
96+
BT_HFP_HF_SDP_FEATURE_VOLUME_ENABLE |\
97+
BT_HFP_HF_CODEC_NEG_ENABLE | \
98+
BT_HFP_HF_FEATURE_ECNR_ENABLE | \
99+
BT_HFP_HF_FEATURE_3WAY_CALL_ENABLE | \
100+
BT_HFP_HF_FEATURE_ECS_ENABLE | \
101+
BT_HFP_HF_FEATURE_ECC_ENABLE | \
102+
BT_HFP_HF_FEATURE_VOICE_RECG_ENABLE | \
103+
BT_HFP_HF_FEATURE_ENH_VOICE_RECG_ENABLE | \
104+
BT_HFP_HF_FEATURE_VOICE_RECG_TEXT_ENABLE | \
105+
BT_HFP_HF_FEATURE_HF_IND_ENABLE)
106+
107+
/* HFP HF Supported features in SDP */
108+
#define BT_HFP_HF_SDP_SUPPORTED_FEATURES (\
109+
BT_HFP_HF_SDP_FEATURE_CLI_ENABLE | \
110+
BT_HFP_HF_SDP_FEATURE_VOLUME_ENABLE | \
111+
BT_HFP_HF_SDP_FEATURE_ECNR_ENABLE | \
112+
BT_HFP_HF_SDP_FEATURE_3WAY_CALL_ENABLE | \
113+
BT_HFP_HF_SDP_FEATURE_VOICE_RECG_ENABLE | \
114+
BT_HFP_HF_SDP_FEATURE_ENH_VOICE_RECG_ENABLE | \
115+
BT_HFP_HF_SDP_FEATURE_VOICE_RECG_TEXT_ENABLE)
116+
117+
#define BT_HFP_HF_CODEC_CVSD_MASK BIT(BT_HFP_HF_CODEC_CVSD)
118+
119+
#if defined(CONFIG_BT_HFP_HF_CODEC_MSBC)
120+
#define BT_HFP_HF_CODEC_MSBC_ENABLE BIT(BT_HFP_HF_CODEC_MSBC)
121+
#else
122+
#define BT_HFP_HF_CODEC_MSBC_ENABLE 0
123+
#endif /* CONFIG_BT_HFP_HF_CODEC_MSBC */
124+
125+
#if defined(CONFIG_BT_HFP_HF_CODEC_LC3_SWB)
126+
#define BT_HFP_HF_CODEC_LC3_SWB_ENABLE BIT(BT_HFP_HF_CODEC_LC3_SWB)
127+
#else
128+
#define BT_HFP_HF_CODEC_LC3_SWB_ENABLE 0
129+
#endif /* CONFIG_BT_HFP_HF_CODEC_LC3_SWB */
130+
131+
/* HFP HF Supported Codec IDs*/
132+
#define BT_HFP_HF_SUPPORTED_CODEC_IDS \
133+
BT_HFP_HF_CODEC_CVSD_MASK | \
134+
BT_HFP_HF_CODEC_MSBC_ENABLE | \
135+
BT_HFP_HF_CODEC_LC3_SWB_ENABLE
136+
137+
/* bt_hfp_hf flags: the flags defined here represent hfp hf parameters */
138+
enum {
139+
BT_HFP_HF_FLAG_CONNECTED, /* HFP HF SLC Established */
140+
BT_HFP_HF_FLAG_TX_ONGOING, /* HFP HF TX is ongoing */
141+
BT_HFP_HF_FLAG_RX_ONGOING, /* HFP HF RX is ongoing */
142+
BT_HFP_HF_FLAG_CODEC_CONN, /* HFP HF codec connection setup */
143+
BT_HFP_HF_FLAG_CLCC_PENDING, /* HFP HF CLCC is pending */
144+
BT_HFP_HF_FLAG_VRE_ACTIVATE, /* VRE is activated */
145+
BT_HFP_HF_FLAG_BINP, /* +BINP result code is received */
146+
/* Total number of flags - must be at the end of the enum */
147+
BT_HFP_HF_NUM_FLAGS,
148+
};
149+
150+
/* bt_hfp_hf_call flags: the flags defined here represent hfp hf call parameters */
151+
enum {
152+
BT_HFP_HF_CALL_IN_USING, /* Object is in using */
153+
BT_HFP_HF_CALL_CLCC, /* CLCC report received */
154+
BT_HFP_HF_CALL_INCOMING, /* Incoming call */
155+
BT_HFP_HF_CALL_INCOMING_HELD, /* Incoming call held */
156+
BT_HFP_HF_CALL_OUTGOING_3WAY, /* Outgoing 3 way call */
157+
BT_HFP_HF_CALL_INCOMING_3WAY, /* Incoming 3 way call */
158+
159+
/* Total number of flags - must be at the end of the enum */
160+
BT_HFP_HF_CALL_NUM_FLAGS,
161+
};
162+
163+
/* bt_hfp_hf_call state: the flags defined here represent hfp hf call state parameters */
164+
enum {
165+
/* Call state flags */
166+
BT_HFP_HF_CALL_STATE_TERMINATE, /* Call terminate */
167+
BT_HFP_HF_CALL_STATE_OUTGOING, /* Call outgoing */
168+
BT_HFP_HF_CALL_STATE_INCOMING, /* Call incoming */
169+
BT_HFP_HF_CALL_STATE_ALERTING, /* Call alerting */
170+
BT_HFP_HF_CALL_STATE_WAITING, /* Call waiting */
171+
BT_HFP_HF_CALL_STATE_ACTIVE, /* Call active */
172+
BT_HFP_HF_CALL_STATE_HELD, /* Call held */
173+
174+
/* Total number of flags - must be at the end of the enum */
175+
BT_HFP_HF_CALL_STATE_NUM_FLAGS,
176+
};
177+
178+
struct bt_hfp_hf_call {
179+
struct bt_hfp_hf *hf;
180+
uint8_t index;
181+
182+
ATOMIC_DEFINE(flags, BT_HFP_HF_CALL_NUM_FLAGS);
183+
ATOMIC_DEFINE(state, BT_HFP_HF_CALL_STATE_NUM_FLAGS);
184+
};
185+
186+
struct bt_hfp_hf {
187+
struct bt_rfcomm_dlc rfcomm_dlc;
188+
/* ACL connection handle */
189+
struct bt_conn *acl;
190+
/* AT command sending queue */
191+
at_finish_cb_t backup_finish;
192+
struct k_fifo tx_pending;
193+
/* SCO Channel */
194+
struct bt_sco_chan chan;
195+
char hf_buffer[HF_MAX_BUF_LEN];
196+
struct at_client at;
197+
uint32_t hf_features;
198+
uint32_t ag_features;
199+
uint8_t hf_codec_ids;
200+
uint8_t vgm;
201+
uint8_t vgs;
202+
int8_t ind_table[HF_MAX_AG_INDICATORS];
203+
204+
uint32_t hf_ind;
205+
uint32_t ag_ind;
206+
uint32_t ind_enable;
207+
208+
/* AT command initialization indicator */
209+
uint8_t cmd_init_seq;
210+
211+
/* The features supported by AT+CHLD */
212+
uint32_t chld_features;
213+
214+
/* Worker for pending TX */
215+
struct k_work work;
216+
217+
struct k_work_delayable deferred_work;
218+
219+
/* calls */
220+
struct bt_hfp_hf_call calls[CONFIG_BT_HFP_HF_MAX_CALLS];
221+
222+
ATOMIC_DEFINE(flags, BT_HFP_HF_NUM_FLAGS);
223+
};

0 commit comments

Comments
 (0)