batteries enimeration issue (windows) wip

This commit is contained in:
Sebastian Hildebrandt 2025-12-31 13:41:17 +01:00
parent 3b0eae7462
commit 66b37b7a3c

View File

@ -42,6 +42,9 @@ function parseBluetoothType(str) {
if (str.indexOf('trackpad') >= 0) {
result = 'Trackpad';
}
if (str.indexOf('audio') >= 0) {
result = 'Audio';
}
if (str.indexOf('speaker') >= 0) {
result = 'Speaker';
}
@ -273,11 +276,15 @@ function bluetoothDevices(callback) {
});
}
if (_windows) {
util.powerShell('Get-CimInstance Win32_PNPEntity | select PNPClass, Name, Manufacturer | fl').then((stdout, error) => {
util.powerShell('Get-CimInstance Win32_PNPEntity | select PNPClass, Name, Manufacturer, Status, Service, CinfigManagerErrorCode, Present | fl').then((stdout, error) => {
if (!error) {
const parts = stdout.toString().split(/\n\s*\n/);
parts.forEach((part) => {
if (util.getValue(part.split('\n'), 'PNPClass', ':') === 'Bluetooth') {
const lines = part.split('\n');
const service = util.getValue(lines, 'Service', ':');
const errorCode = util.getValue(lines, 'CinfigManagerErrorCode', ':');
const pnpClass = util.getValue(lines, 'PNPClass', ':').toLowerCase();
if (pnpClass === 'Bluetooth' && errorCode === '0' && service === '') {
result.push(parseWindowsBluetooth(part.split('\n')));
}
});