mirror of
https://github.com/yume-chan/ya-webadb.git
synced 2025-10-03 09:49:24 +02:00
33 lines
839 B
TypeScript
33 lines
839 B
TypeScript
import { AoaRequestType } from "./type.js";
|
|
|
|
export async function aoaGetProtocol(device: USBDevice) {
|
|
const result = await device.controlTransferIn(
|
|
{
|
|
recipient: "device",
|
|
requestType: "vendor",
|
|
request: AoaRequestType.GetProtocol,
|
|
value: 0,
|
|
index: 0,
|
|
},
|
|
2
|
|
);
|
|
const version = result.data!.getUint16(0, true);
|
|
return version;
|
|
}
|
|
|
|
/**
|
|
* The device will reset (disconnect) after this call.
|
|
* @param device The Android device.
|
|
*/
|
|
export async function aoaStartAccessory(device: USBDevice) {
|
|
await device.controlTransferOut(
|
|
{
|
|
recipient: "device",
|
|
requestType: "vendor",
|
|
request: AoaRequestType.Start,
|
|
value: 0,
|
|
index: 0,
|
|
},
|
|
new ArrayBuffer(0)
|
|
);
|
|
}
|