Skip to main content

Find device

searchDevices is used to enumerate the UKey Wallet devices that the current SDK can access. Usually called after the user completes USB authorization or BLE scanning, it is used to get the connectId needed for subsequent requests.

The information returned by different transmission methods is slightly different. The WebUSB scenario usually returns more complete device information directly; the BLE scenario generally returns the device name and connectId first, and then obtains detailed information such as device_id through getFeatures after connection.

Show the device name on the UI first, allowing the user to select the target device, and then enter the connection and feature reading process.

const requestResult = await ukeySdk.searchDevices();

Inputs

  • none

Reference snippet

ukeySdk.searchDevices().then((result) => {
console.log(`Discovered device list: ${result}`);
});

Output

{
success: true,
payload: [
{
"connectId": string, // Connection handle that usually stays stable for the same device even after reset
"uuid": string, // Note: Unique device ID
"deviceType": string, // Device model category: 'classic' | 'mini' | 'touch' | 'pro'
"deviceId": string, // Wallet ID that may change after reset/erase/restore; only returned by the webusb transport in @ukeyfe/hardware-common-connect-sdk
"path": string, // Note: Device serial number when connecting USB via WebUSB
"name": string, // Note: Bluetooth name of the device
},
]
}

Issues

{
success: false,
payload: {
error: string, // Error message text
code: number // Error code value
}
}