bluetooth windows, fixes, improvements
This commit is contained in:
parent
143b1abe86
commit
6fdf5ea2ac
@ -155,29 +155,23 @@ si.bluetoothDevices().then(data => console.log(data));</code></pre class="exampl
|
||||
<pre class="example">
|
||||
[
|
||||
{
|
||||
id: 0,
|
||||
name: 'MacBook Microphone',
|
||||
manufacturer: 'Apple Inc.',
|
||||
revision: null,
|
||||
driver: null,
|
||||
default: true,
|
||||
channel: 'Built-In',
|
||||
in: true,
|
||||
out: false,
|
||||
status: 'online'
|
||||
device: 'Magic Mouse 2',
|
||||
name: 'My Maus',
|
||||
manufacturer: 'Broadcom (0x5, 0x240C)',
|
||||
address: '10-XX-XX-XX-XX-XX',
|
||||
batteryPercent: '74%',
|
||||
tyoe: 'Mouse',
|
||||
connected: true
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: 'MacBook Speaker',
|
||||
manufacturer: 'Apple Inc.',
|
||||
revision: null,
|
||||
driver: null,
|
||||
default: true,
|
||||
channel: 'Built-In',
|
||||
in: false,
|
||||
out: true,
|
||||
status: 'online'
|
||||
}
|
||||
device: 'Magic Keyboard with Numeric Keypad',
|
||||
name: 'My Keyboard',
|
||||
manufacturer: 'Broadcom (0x5, 0x240C)',
|
||||
address: '10-XX-XX-XX-XX-XX',
|
||||
batteryPercent: '75%',
|
||||
tyoe: 'Keyboard',
|
||||
connected: true
|
||||
},
|
||||
]</pre>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@ -172,9 +172,11 @@ function audio(callback) {
|
||||
if (!error) {
|
||||
const parts = stdout.toString().split(/\n\s*\n/);
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
if (util.getValue(parts[i].split('\n'), 'name', '=')) {
|
||||
result.push(parseWindowsAudio(parts[i].split('\n'), i))
|
||||
}
|
||||
}
|
||||
}
|
||||
if (callback) {
|
||||
callback(result);
|
||||
}
|
||||
|
||||
@ -106,16 +106,16 @@ function parseDarwinBluetoothDevices(bluetoothObject) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function parseWindowsAudio(lines) {
|
||||
function parseWindowsBluetooth(lines) {
|
||||
const result = {};
|
||||
const status = util.getValue(lines, 'StatusInfo', '=');
|
||||
// const description = util.getValue(lines, 'Description', '=');
|
||||
|
||||
result.id = util.getValue(lines, 'DeviceID', '='); // PNPDeviceID??
|
||||
result.device = null;
|
||||
result.name = util.getValue(lines, 'name', '=');
|
||||
result.manufacturer = util.getValue(lines, 'manufacturer', '=');
|
||||
result.revision = null;
|
||||
result.driver = null
|
||||
result.address = null;
|
||||
result.batteryPercent = null
|
||||
result.default = null
|
||||
result.in = null
|
||||
result.out = null
|
||||
@ -182,11 +182,13 @@ function bluetoothDevices(callback) {
|
||||
});
|
||||
}
|
||||
if (_windows) {
|
||||
util.wmic('path Win32_SoundDevice get /value', function (error, stdout) {
|
||||
util.wmic('path Win32_PNPEntity get /value', function (error, stdout) {
|
||||
if (!error) {
|
||||
const parts = stdout.toString().split(/\n\s*\n/);
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
result.push(parseWindowsAudio(parts[i].split('\n'), i))
|
||||
if (util.getValue(parts[i].split('\n'), 'PNPClass', '=') === 'Bluetooth') {
|
||||
result.push(parseWindowsBluetooth(parts[i].split('\n'), i))
|
||||
}
|
||||
}
|
||||
}
|
||||
if (callback) {
|
||||
|
||||
@ -199,12 +199,12 @@ function fsOpenFiles(callback) {
|
||||
});
|
||||
}
|
||||
if (_sunos) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
if (callback) { callback(null); }
|
||||
resolve(null);
|
||||
}
|
||||
if (_windows) {
|
||||
if (callback) { callback(result); }
|
||||
resolve(result);
|
||||
if (callback) { callback(null); }
|
||||
resolve(null);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -178,7 +178,7 @@ function getFQDN() {
|
||||
if (_windows) {
|
||||
try {
|
||||
const stdout = execSync('echo %COMPUTERNAME%.%USERDNSDOMAIN%');
|
||||
fqdn = stdout.toString().split(os.EOL)[0];
|
||||
fqdn = stdout.toString().replace('.%USERDNSDOMAIN%', '').split(os.EOL)[0];
|
||||
} catch (e) {
|
||||
util.noop();
|
||||
}
|
||||
|
||||
@ -127,11 +127,13 @@ function printer(callback) {
|
||||
const printerHeader = parseLinuxCupsHeader(parts[0]);
|
||||
for (let i = 1; i < parts.length; i++) {
|
||||
const printers = parseLinuxCupsPrinter(parts[i].split('\n'));
|
||||
if (printers.name) {
|
||||
printers.engine = 'CUPS';
|
||||
printers.engineVersion = printerHeader.cupsVersion;
|
||||
result.push(printers);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result.length === 0) {
|
||||
if (_linux) {
|
||||
cmd = 'export LC_ALL=C; lpstat -lp 2>/dev/null; unset LC_ALL';
|
||||
|
||||
63
lib/usb.js
63
lib/usb.js
@ -34,7 +34,7 @@ function getLinuxUsbType(type, name) {
|
||||
if (str.indexOf('camera') >= 0) { result = 'Camera'; }
|
||||
else if (str.indexOf('hub') >= 0) { result = 'Hub'; }
|
||||
else if (str.indexOf('keybrd') >= 0) { result = 'Keyboard'; }
|
||||
else if (str.indexOf('keybroard') >= 0) { result = 'Keyboard'; }
|
||||
else if (str.indexOf('keyboard') >= 0) { result = 'Keyboard'; }
|
||||
else if (str.indexOf('mouse') >= 0) { result = 'Mouse'; }
|
||||
else if (str.indexOf('stora') >= 0) { result = 'Storage'; }
|
||||
else if (str.indexOf('mic') >= 0) { result = 'Microphone'; }
|
||||
@ -164,29 +164,45 @@ function parseDarwinUsb(usb, id) {
|
||||
}
|
||||
}
|
||||
|
||||
function getWindowsUsbType(service) {
|
||||
// function getWindowsUsbType(service) {
|
||||
// let result = ''
|
||||
// if (service.indexOf('usbhub3') >= 0) { result = 'Hub'; }
|
||||
// else if (service.indexOf('usbstor') >= 0) { result = 'Storage'; }
|
||||
// else if (service.indexOf('hidusb') >= 0) { result = 'Input'; }
|
||||
// else if (service.indexOf('usbccgp') >= 0) { result = 'Controller'; }
|
||||
// else if (service.indexOf('usbxhci') >= 0) { result = 'Controller'; }
|
||||
// else if (service.indexOf('usbehci') >= 0) { result = 'Controller'; }
|
||||
// else if (service.indexOf('kbdhid') >= 0) { result = 'Keyboard'; }
|
||||
// else if (service.indexOf('keyboard') >= 0) { result = 'Keyboard'; }
|
||||
// else if (service.indexOf('pointing') >= 0) { result = 'Mouse'; }
|
||||
// else if (service.indexOf('disk') >= 0) { result = 'Storage'; }
|
||||
// else if (service.indexOf('usbhub') >= 0) { result = 'Hub'; }
|
||||
// else if (service.indexOf('bthusb') >= 0) { result = ''; }
|
||||
// else if (service.indexOf('bth') >= 0) { result = ''; }
|
||||
// else if (service.indexOf('rfcomm') >= 0) { result = ''; }
|
||||
// return result;
|
||||
// }
|
||||
|
||||
function getWindowsUsbTypeCreation(creationclass, name) {
|
||||
let result = ''
|
||||
if (service.indexOf('usbhub3') >= 0) { result = 'Hub'; }
|
||||
else if (service.indexOf('usbstor') >= 0) { result = 'Storage'; }
|
||||
else if (service.indexOf('hidUsb') >= 0) { result = 'Input'; }
|
||||
else if (service.indexOf('mouhid') >= 0) { result = 'Mouse'; }
|
||||
else if (service.indexOf('usbccgp') >= 0) { result = 'Controller'; }
|
||||
else if (service.indexOf('kbdhid') >= 0) { result = 'Keyboard'; }
|
||||
else if (service.indexOf('disk') >= 0) { result = 'Storage'; }
|
||||
else if (service.indexOf('bthusb') >= 0) { result = 'Bluetooth'; }
|
||||
else if (service.indexOf('bth') >= 0) { result = 'Bluetooth'; }
|
||||
else if (service.indexOf('rfcomm') >= 0) { result = 'Bluetooth'; }
|
||||
else if (service.indexOf('usbhub') >= 0) { result = 'Hub'; }
|
||||
if (name.indexOf('storage') >= 0) { result = 'Storage'; }
|
||||
else if (name.indexOf('speicher') >= 0) { result = 'Storage'; }
|
||||
else if (creationclass.indexOf('usbhub') >= 0) { result = 'Hub'; }
|
||||
else if (creationclass.indexOf('storage') >= 0) { result = 'Storage'; }
|
||||
else if (creationclass.indexOf('usbcontroller') >= 0) { result = 'Controller'; }
|
||||
else if (creationclass.indexOf('keyboard') >= 0) { result = 'Keyboard'; }
|
||||
else if (creationclass.indexOf('pointing') >= 0) { result = 'Mouse'; }
|
||||
else if (creationclass.indexOf('disk') >= 0) { result = 'Storage'; }
|
||||
return result;
|
||||
}
|
||||
|
||||
function parseWindowsUsb(lines, id) {
|
||||
const usbType = getWindowsUsbType(util.getValue(lines, 'Service', '=').toLowerCase());
|
||||
const usbType = getWindowsUsbTypeCreation(util.getValue(lines, 'CreationClassName', '=').toLowerCase(), util.getValue(lines, 'name', '=').toLowerCase());
|
||||
|
||||
if (usbType) {
|
||||
const result = {};
|
||||
result.bus = null;
|
||||
result.deviceId = null;
|
||||
result.deviceId = util.getValue(lines, 'deviceid', '=');
|
||||
result.id = id;
|
||||
result.name = util.getValue(lines, 'name', '=');
|
||||
result.type = usbType;
|
||||
@ -247,7 +263,7 @@ function usb(callback) {
|
||||
});
|
||||
}
|
||||
if (_windows) {
|
||||
util.powerShell('gwmi Win32_USBControllerDevice |%{[wmi]($_.Dependent)}', function (error, stdout) {
|
||||
util.wmic('Path CIM_LogicalDevice where "Description like \'USB%\'" get /value', function (error, stdout) {
|
||||
if (!error) {
|
||||
const parts = stdout.toString().split(/\n\s*\n/);
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
@ -262,6 +278,21 @@ function usb(callback) {
|
||||
}
|
||||
resolve(result);
|
||||
});
|
||||
|
||||
// util.powerShell("gwmi Win32_USBControllerDevice |\%{[wmi]($_.Dependent)}").then(data => {
|
||||
|
||||
// const parts = data.toString().split(/\n\s*\n/);
|
||||
// for (let i = 0; i < parts.length; i++) {
|
||||
// const usb = parseWindowsUsb(parts[i].split('\n'), i)
|
||||
// if (usb) {
|
||||
// result.push(usb)
|
||||
// }
|
||||
// }
|
||||
// if (callback) {
|
||||
// callback(result);
|
||||
// }
|
||||
// resolve(result);
|
||||
// });
|
||||
}
|
||||
if (_sunos || _freebsd || _openbsd || _netbsd) {
|
||||
resolve(null);
|
||||
|
||||
@ -3,6 +3,7 @@ const si = require('../lib/index');
|
||||
function test(f) {
|
||||
return new Promise((resolve) => {
|
||||
process.nextTick(() => {
|
||||
f = f.replace(/'/g, '');
|
||||
// console.log(f);
|
||||
if (f === 'a') { si.audio().then(data => { if (data !== null) { resolve({ data, title: 'Audio' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === 'b') { si.bios().then(data => { if (data !== null) { resolve({ data, title: 'BIOS' }); } else { resolve('not_supported') } }) }
|
||||
@ -34,8 +35,10 @@ function test(f) {
|
||||
else if (f === 'u') { si.usb().then(data => { if (data !== null) { resolve({ data, title: 'USB' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === 'U') { si.uuid().then(data => { if (data !== null) { resolve({ data, title: 'UUID' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === 'v') { si.versions().then(data => { if (data !== null) { resolve({ data, title: 'Versions' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === 'V') { si.vboxInfo().then(data => { if (data !== null) { resolve({ data, title: 'Virtual Box' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === 'w') { si.wifiNetworks().then(data => { if (data !== null) { resolve({ data, title: 'WIFI Networks' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === 'y') { si.battery().then(data => { if (data !== null) { resolve({ data, title: 'Battery' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === 'y') { si.system().then(data => { if (data !== null) { resolve({ data, title: 'System' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === 'Y') { si.battery().then(data => { if (data !== null) { resolve({ data, title: 'Battery' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === 'z') { si.users().then(data => { if (data !== null) { resolve({ data, title: 'Users' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === '1') { si.networkInterfaceDefault().then(data => { if (data !== null) { resolve({ data, title: 'NET Iface Default' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === '2') { si.networkGatewayDefault().then(data => { if (data !== null) { resolve({ data, title: 'NET Gateway Default' }); } else { resolve('not_supported') } }) }
|
||||
@ -47,7 +50,6 @@ function test(f) {
|
||||
else if (f === '8') { si.dockerContainerStats('1').then(data => { if (data !== null) { resolve({ data, title: 'Docker Cont Stats' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === '9') { si.dockerContainerProcesses('1').then(data => { if (data !== null) { resolve({ data, title: 'Docker Cont Processes' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === '0') { si.dockerAll().then(data => { if (data !== null) { resolve({ data, title: 'Docker All' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === '-') { si.vboxInfo().then(data => { if (data !== null) { resolve({ data, title: 'Virtual Box' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === ',') { si.getStaticData().then(data => { if (data !== null) { resolve({ data, title: 'All Static Data' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === '.') { si.getDynamicData('apache2, postgres').then(data => { if (data !== null) { resolve({ data, title: 'All Dynamic Data' }); } else { resolve('not_supported') } }) }
|
||||
else if (f === '/') { si.getAllData('apache2, postgres').then(data => { if (data !== null) { resolve({ data, title: 'All Data' }); } else { resolve('not_supported') } }) }
|
||||
|
||||
23
test/test.js
23
test/test.js
@ -16,17 +16,18 @@ function printHeader() {
|
||||
function printMenu() {
|
||||
console.log('');
|
||||
console.log('┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐');
|
||||
console.log('│ a ... Audio g ... Graphics r ... Printer 1 ... NET Iface Default ? ... Get Object │');
|
||||
console.log('│ b ... BIOS h ... Bluetooth s ... Services 2 ... NET Gateway Default , ... All Static │');
|
||||
console.log('│ B ... Baseboard i ... INET Latency S ... Shell 3 ... NET Interfaces . ... All Dynamic │');
|
||||
console.log('│ C ... Chassis I ... INET Check Site t ... time 4 ... NET Stats / ... All │');
|
||||
console.log('│ c ... CPU l ... CPU Load T ... CPU Temperature 5 ... NET Connections │');
|
||||
console.log('│ d ... DiskLayout L ... Full Load u ... USB 6 ... Docker Info │');
|
||||
console.log('│ D ... DiskIO m ... Memory U ... UUID 7 ... Docker Container │');
|
||||
console.log('│ e ... Block Devices M ... MEM Layout v ... Versions 8 ... Docker Cont Stats │');
|
||||
console.log('│ E ... Open Files o ... OS Info w ... WIFI networks 9 ... Docker Cont Proc │');
|
||||
console.log('│ f ... FS Size p ... Processes y ... Battery 0 ... Docker All │');
|
||||
console.log('│ F ... FS Stats P ... Process Load z ... Users - ... Virtual Box q >>> QUIT │');
|
||||
console.log('│ a ... Audio h ... Bluetooth S ... Shell 1 ... NET Iface Default ? ... Get Object │');
|
||||
console.log('│ b ... BIOS i ... INET Latency t ... time 2 ... NET Gateway Default , ... All Static │');
|
||||
console.log('│ B ... Baseboard I ... INET Check Site T ... CPU Temperature 3 ... NET Interfaces . ... All Dynamic │');
|
||||
console.log('│ C ... Chassis l ... CPU Load u ... USB 4 ... NET Stats / ... All │');
|
||||
console.log('│ c ... CPU L ... Full Load U ... UUID 5 ... NET Connections │');
|
||||
console.log('│ d ... DiskLayout m ... Memory v ... Versions │');
|
||||
console.log('│ D ... DiskIO M ... MEM Layout V ... Virtual Box 6 ... Docker Info │');
|
||||
console.log('│ e ... Block Devices o ... OS Info w ... WIFI networks 7 ... Docker Container │');
|
||||
console.log('│ E ... Open Files p ... Processes y ... System 8 ... Docker Cont Stats │');
|
||||
console.log('│ f ... FS Size P ... Process Load Y ... Battery 9 ... Docker Cont Proc │');
|
||||
console.log('│ F ... FS Stats r ... Printer z ... Users 0 ... Docker All │');
|
||||
console.log('│ g ... Graphics s ... Services q >>> QUIT │');
|
||||
console.log('└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘');
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user