Commit 69c13e32 authored by martin hou's avatar martin hou

fix: 使用major device class来识别音频设备

parent 62561199
......@@ -1686,15 +1686,24 @@ 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);
devices.push({
name: decoder.decode(jensen.truncateIncompleteUtf8(sname)),
name: (isAudio ? '🎧' : '🚫') + decoder.decode(jensen.truncateIncompleteUtf8(sname)),
mac: mac.join('-'),
rssi: rssi,
cod: cod
cod: cod,
audio: isAudio
});
}
return devices;
});
function __is_headset_or_mic(cod)
{
if (typeof cod !== 'number') return false;
const major_device_class = (cod & 0x1F00) >> 8;
return major_device_class === 0x04;
}
export { Jensen };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment