Add getBosDescriptor() and getCapabilities() added in 1.5.0

This commit is contained in:
Rob Moran
2019-01-17 22:21:55 +00:00
parent bf908def12
commit a017ee8ba4
2 changed files with 26 additions and 1 deletions
+24 -1
View File
@@ -1,4 +1,4 @@
// Type definitions for node-usb 1.1
// Type definitions for node-usb 1.5
// Project: https://github.com/tessel/node-usb
// Definitions by: Eric Brody <https://github.com/underscorebrody>
// Rob Moran <https://github.com/thegecko>
@@ -31,6 +31,8 @@ export class Device {
interface(addr: number): Interface;
controlTransfer(bmRequestType: number, bRequest: number, wValue: number, wIndex: number, data_or_length: any, callback: (error?: LibUSBException, buf?: Buffer) => void): Device;
getStringDescriptor(desc_index: number, callback: (error?: string, buf?: Buffer) => void): void;
getBosDescriptor(callback: (error?: string, descriptor?: BosDescriptor) => void): void;
getCapabilities(callback: (error?: string, capabilities?: Capability[]) => void): void;
setConfiguration(desired: number, cb: (err?: string) => void): void;
reset(callback: (err?: string) => void): void;
}
@@ -65,6 +67,27 @@ export class ConfigDescriptor {
interfaces: InterfaceDescriptor[][];
}
export class BosDescriptor {
bLength: number;
bDescriptorType: number;
wTotalLength: number;
bNumDeviceCaps: number;
capabilities: CapabilityDescriptor[];
}
export class CapabilityDescriptor {
bLength: number;
bDescriptorType: number;
bDevCapabilityType: number;
dev_capability_data: Buffer;
}
export class Capability {
descriptor: CapabilityDescriptor;
type: number;
data: Buffer;
}
export class Interface {
interfaceNumber: number;
altSetting: number;
+2
View File
@@ -14,6 +14,8 @@ device.open(true);
device.close();
const xferDevice: usb.Device = device.controlTransfer(1, 1, 1, 1, 1, (error: usb.LibUSBException, buf: Buffer): usb.Device => new usb.Device());
device.getStringDescriptor(1, (error: string, buf: Buffer) => null);
device.getBosDescriptor((error: string, descriptor: usb.BosDescriptor) => null);
device.getCapabilities((error: string, capabilities: usb.Capability[]) => null);
device.setConfiguration(1, (error: string) => null);
device.reset((error: string) => null);