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
97d374b0
Commit
97d374b0
authored
Dec 03, 2025
by
martin hou
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v2.2.10-bluetooth' into v2.2.11-live
parents
3c281c51
6bd96f39
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
30 deletions
+9
-30
jensen.js
src/utils/jensen.js
+9
-30
No files found.
src/utils/jensen.js
View file @
97d374b0
...
...
@@ -1573,6 +1573,7 @@ Jensen.registerHandler(BLUETOOTH_SCAN, (msg, jensen) => {
let
m
=
(
msg
.
body
[
k
++
]
&
0xff
).
toString
(
16
).
toUpperCase
();
mac
.
push
(
m
.
length
==
1
?
'0'
+
m
:
m
);
}
if
(
len
==
0
)
continue
;
devices
.
push
({
name
:
decoder
.
decode
(
jensen
.
truncateIncompleteUtf8
(
sname
)),
mac
:
mac
.
join
(
'-'
)
...
...
@@ -1598,8 +1599,10 @@ Jensen.registerHandler(BT_GET_PAIRED_DEV_LIST, (msg, jensen) => {
mac
.
push
(
m
.
length
==
1
?
'0'
+
m
:
m
);
}
let
seq
=
msg
.
body
[
k
++
]
&
0xff
;
let
name
=
decoder
.
decode
(
jensen
.
truncateIncompleteUtf8
(
sname
));
if
(
name
==
'UUUUUUUUUUUUUUUUUUUUUUUUUUUUU'
)
continue
;
devices
.
push
({
name
:
decoder
.
decode
(
jensen
.
truncateIncompleteUtf8
(
sname
))
,
name
:
name
,
mac
:
mac
.
join
(
'-'
),
sequence
:
seq
});
...
...
@@ -1693,6 +1696,7 @@ Jensen.registerHandler(BT_DEV_LIST, (msg, jensen) => {
let
rssi
=
msg
.
body
[
k
++
]
&
0xff
;
let
cod
=
((
msg
.
body
[
k
++
]
&
0xff
)
<<
16
)
|
((
msg
.
body
[
k
++
]
&
0xff
)
<<
8
)
|
(
msg
.
body
[
k
++
]
&
0xff
);
let
isAudio
=
__is_headset_or_mic
(
cod
);
if
(
len
==
0
)
continue
;
devices
.
push
({
name
:
(
isAudio
?
'🎧'
:
'🚫'
)
+
decoder
.
decode
(
jensen
.
truncateIncompleteUtf8
(
sname
)),
mac
:
mac
.
join
(
'-'
),
...
...
@@ -1704,36 +1708,11 @@ Jensen.registerHandler(BT_DEV_LIST, (msg, jensen) => {
return
devices
;
});
function
__is_headset_or_mic
(
cod
)
{
function
__is_headset_or_mic
(
cod
)
{
if
(
typeof
cod
!==
'number'
)
return
false
;
// --- 定义 service-class bits (Major Service Classes) ---
const
SERVICE_RENDERING
=
1
<<
18
;
// Rendering (speaker, etc.) :contentReference[oaicite:1]{index=1}
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}
// --- 提取 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
;
const
major_device_class
=
(
cod
&
0x1F00
)
>>
8
;
return
major_device_class
===
0x04
;
}
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