本页目录
获取设备状态
读取 Protocol V1 / V2 统一的设备快照。请用本方法,不要再用已废弃的 getFeatures。
getFeatures() 只支持 Protocol V1。Pro 2 / Neo 必须调用 getDeviceState(),读 payload.identity.deviceId。需要固件 / 版本字段时用 scope: 'firmware',不要再用 getOnekeyFeatures。
const res = await HardwareSDK.getDeviceState(connectId);参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
scope | 'runtime' | 'settings' | 'firmware' | 否 | 默认 'runtime'。scope 只决定这次刷新哪些分区,返回值仍是完整快照 |
runtime— 实时锁定 / PIN / passphrase 状态(V1GetFeatures,V2 应用模式下的DeviceStatusGet)settings— 同时刷新设置firmware— 同时刷新身份、版本和校验信息
Bootloader / romloader 会跳过不支持的状态命令,返回当前能拿到的快照。
返回结果
{
success: true,
payload: {
protocol: 'V1' | 'V2',
identity: {
deviceId: string | null, // 种子生命周期 — 作为 SDK 第二个参数传入
serialNo: string,
deviceType: string,
// ...
},
status: { initialized, unlocked, passphraseProtection, attachToPinEnabled, ... },
settings: { language, airgapMode, ... },
versions: { firmware, bootloader, ble, applicationP1, applicationP2, ... },
}
}签名调用的第二个参数读 payload.identity.deviceId。不要把兼容 Features 里的固件 session_id 存下来。
返回值不包含固件钱包 session_id 或原始协议消息。钱包身份来自 openWalletSession。
错误
{
success: false,
payload: {
error: string,
code?: string | number,
}
}最后更新于