UNPKG

3.11 kBTypeScriptView Raw
1import { LibUSBException, Device } from './bindings';
2import { InterfaceDescriptor } from './descriptors';
3import { Endpoint } from './endpoint';
4export declare class Interface {
5 protected device: Device;
6 protected id: number;
7 /** Integer interface number. */
8 interfaceNumber: number;
9 /** Integer alternate setting number. */
10 altSetting: number;
11 /** Object with fields from the interface descriptor -- see libusb documentation or USB spec. */
12 descriptor: InterfaceDescriptor;
13 /** List of endpoints on this interface: InEndpoint and OutEndpoint objects. */
14 endpoints: Endpoint[];
15 releaseAsync: () => Promise<void>;
16 setAltSettingAsync: (alternateSetting: number) => Promise<void>;
17 constructor(device: Device, id: number);
18 protected refresh(): void;
19 /**
20 * Claims the interface. This method must be called before using any endpoints of this interface.
21 *
22 * The device must be open to use this method.
23 */
24 claim(): void;
25 /**
26 * Releases the interface and resets the alternate setting. Calls callback when complete.
27 *
28 * It is an error to release an interface with pending transfers.
29 *
30 * The device must be open to use this method.
31 * @param callback
32 */
33 release(callback?: (error?: LibUSBException) => void): void;
34 /**
35 * Releases the interface and resets the alternate setting. Calls callback when complete.
36 *
37 * It is an error to release an interface with pending transfers. If the optional closeEndpoints
38 * parameter is true, any active endpoint streams are stopped (see `Endpoint.stopStream`),
39 * and the interface is released after the stream transfers are cancelled. Transfers submitted
40 * individually with `Endpoint.transfer` are not affected by this parameter.
41 *
42 * The device must be open to use this method.
43 * @param closeEndpoints
44 * @param callback
45 */
46 release(closeEndpoints?: boolean, callback?: (error?: LibUSBException) => void): void;
47 /**
48 * Returns `false` if a kernel driver is not active; `true` if active.
49 *
50 * The device must be open to use this method.
51 */
52 isKernelDriverActive(): boolean;
53 /**
54 * Detaches the kernel driver from the interface.
55 *
56 * The device must be open to use this method.
57 */
58 detachKernelDriver(): void;
59 /**
60 * Re-attaches the kernel driver for the interface.
61 *
62 * The device must be open to use this method.
63 */
64 attachKernelDriver(): void;
65 /**
66 * Sets the alternate setting. It updates the `interface.endpoints` array to reflect the endpoints found in the alternate setting.
67 *
68 * The device must be open to use this method.
69 * @param altSetting
70 * @param callback
71 */
72 setAltSetting(altSetting: number, callback?: (error: LibUSBException | undefined) => void): void;
73 /**
74 * Return the InEndpoint or OutEndpoint with the specified address.
75 *
76 * The device must be open to use this method.
77 * @param addr
78 */
79 endpoint(addr: number): Endpoint | undefined;
80}