Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
J
jensen
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Skye Yu
jensen
Commits
458fb496
Commit
458fb496
authored
Dec 01, 2025
by
martin hou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 调整过滤规则
parent
992d2444
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
7 deletions
+27
-7
jensen.js
src/utils/jensen.js
+27
-7
No files found.
src/utils/jensen.js
View file @
458fb496
...
@@ -1699,15 +1699,35 @@ Jensen.registerHandler(BT_DEV_LIST, (msg, jensen) => {
...
@@ -1699,15 +1699,35 @@ Jensen.registerHandler(BT_DEV_LIST, (msg, jensen) => {
});
});
function
__is_headset_or_mic
(
cod
)
{
function
__is_headset_or_mic
(
cod
)
{
const
SERVICE_AUDIO
=
1
<<
21
;
// Audio bit (bit 21)
if
(
typeof
cod
!==
'number'
)
return
false
;
const
SERVICE_TELEPHONY
=
1
<<
22
;
// Telephony bit (bit 22)
const
SERVICE_CAPTURING
=
1
<<
19
;
// Capturing (mic / scanner) bit (optional)
const
serviceMask
=
cod
&
0x00FFE000
;
// --- 定义 service-class bits (Major Service Classes) ---
// Explanation: bits 13–23 correspond to mask 0x00FFE000 (binary: 0000 0000 1111 1111 1110 0000 0000 0000)
const
SERVICE_RENDERING
=
1
<<
18
;
// Rendering (speaker, etc.) :contentReference[oaicite:1]{index=1}
// Alternatively you can directly mask bits 19,21,22 as above.
const
SERVICE_CAPTURING
=
1
<<
19
;
// Capturing (microphone / scanner) :contentReference[oaicite:2]{index=2}
const
SERVICE_AUDIO
=
1
<<
21
;
// Audio (speaker, mic, headset-service, ...) :contentReference[oaicite:3]{index=3}
const
SERVICE_TELEPHONY
=
1
<<
22
;
// Telephony (headset / hands-free / phone service) :contentReference[oaicite:4]{index=4}
return
(
serviceMask
&
(
SERVICE_AUDIO
|
SERVICE_TELEPHONY
|
SERVICE_CAPTURING
))
!==
0
;
// --- 提取 major device class (bits 12–8) ---
const
MAJOR_DEVICE_MASK
=
0x1F00
;
// per BluetoothClass definition :contentReference[oaicite:5]{index=5}
const
major
=
cod
&
MAJOR_DEVICE_MASK
;
// 常见 major classes 的定义 (值与 BluetoothClass.Device.Major 的常量一致) :contentReference[oaicite:6]{index=6}
const
MAJOR_AUDIO_VIDEO
=
0x0400
;
const
MAJOR_PHONE
=
0x0200
;
// 你也可以考虑 “Wearable” / “Peripheral” 等,但对于 headset/mic 最主要是 Audio/Video 或 Phone
// --- 提取 service bits ---
const
serviceBits
=
cod
&
0x00FFE000
;
// bits 13–23 是 service-class field :contentReference[oaicite:7]{index=7}
// --- 判断 logic ---
// 条件 A: major class 是 Audio/Video 或 Phone(这两类设备比较可能是耳机 / 耳麦 / hands-free / audio 设备)
const
majorIsAudioOrPhone
=
(
major
===
MAJOR_AUDIO_VIDEO
)
||
(
major
===
MAJOR_PHONE
);
// 条件 B: service-class 中至少有 Audio / Rendering / Capturing / Telephony 中的一个 bit
const
serviceIndicatesAudio
=
(
serviceBits
&
(
SERVICE_AUDIO
|
SERVICE_RENDERING
|
SERVICE_CAPTURING
|
SERVICE_TELEPHONY
))
!==
0
;
return
majorIsAudioOrPhone
&&
serviceIndicatesAudio
;
}
}
export
{
Jensen
};
export
{
Jensen
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment