@zifeng328573112
2026-04-23T09:09:15.000000Z
字数 15192
阅读 92
本文档基于 ~/StudioProjects/dbs_gp02_control 项目源码整理,面向第三方对接方。
蓝牙相关接口分两层:
| 层级 | 类/对象 | 中文说明 |
|---|---|---|
| 底层接入层 | com.vkson.ble.helper.Ble |
负责 BLE 初始化、扫描、连接、配对、鉴权、通用请求发送 |
| 业务协议层 | com.dbs.gp02.api.ble.BleApi |
负责 DBS 程控仪业务命令封装、请求发送、响应解析 |
主要源码:
| 文件 | 路径 |
|---|---|
BleApi.kt |
BleApi.kt |
JsonBean.kt |
JsonBean.kt |
Ble.kt |
~/.gradle/caches/.../ble-2.0.0-SNAPSHOT-sources.jar |
DeviceInfo| 字段 | 类型 | 中文说明 |
|---|---|---|
mac |
String |
设备 MAC 地址 |
receiveId |
Byte |
协议接收端标识 |
bleDevice |
BleDevice? |
底层 BLE 设备对象 |
ReqData| 字段 | 类型 | 中文说明 |
|---|---|---|
name |
String |
请求名称,通常为命令名 |
cmd |
Int |
协议命令字 |
data |
ByteArray |
请求报文体 |
uuidData |
UUIDData |
当前写通道 UUID 信息 |
desMac |
DeviceInfo |
目标设备 |
Ble| 名称 | 类型 | 中文说明 |
|---|---|---|
mutex |
Mutex |
BLE 请求互斥锁,用于串行化请求 |
currentBleDevice |
DeviceInfo |
当前连接中的目标设备 |
bleInstance |
BleManager |
底层 BLE 管理器实例 |
| 接口 | 中文说明 | 返回类型 |
|---|---|---|
init(...) |
初始化 BLE 框架 | Unit |
startSan(...) |
开始扫描设备 | Unit |
stopScanNow() |
立即停止扫描 | Unit |
bleConnect(...) |
连接设备 | BleDevice? |
disconnectBle(...) |
断开指定设备 | Unit |
disconnectedAll() |
断开所有连接设备 | Unit |
setBleStatus(...) |
监听系统蓝牙开关状态 | Unit |
startBond(...) |
发起蓝牙配对 | Boolean |
setUUIDs(...) |
发现并设置通信 UUID | List<UUIDTAG> |
printServiceData(...) |
打印 GATT Service/Characteristic 信息 | Unit |
requestCommonLock(...) |
带互斥锁的通用请求发送 | ByteBuffer? |
requestCommon(...) |
通用请求发送 | ByteBuffer? |
registerAndAuth(...) |
注册并鉴权 | Boolean |
logSign(...) |
读取日志起止标记 | Array<Long>? |
readLog(...) |
读取日志内容 | MutableList<String>? |
stopReadLog(...) |
停止读取日志 | Unit |
readWave(...) |
读取波形数据 | Unit |
readCheckImu(...) |
读取 IMU 检测数据 | Unit |
stopCheckImu(...) |
停止 IMU 检测 | Boolean |
released() |
释放 BLE 资源 | Unit |
blePermission() |
申请/检查 BLE 权限 | Boolean |
init(context: Application, buId: Byte = 0x02, sendId: Byte = 0x03, connectOverTime: Long = 60000, operateTimeout: Int = 10000): Unit接口说明:初始化 BLE 框架、注册配对广播、配置超时参数。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
context |
Application |
应用上下文 |
buId |
Byte |
业务 ID,默认 0x02 |
sendId |
Byte |
发送端 ID,默认 0x03 |
connectOverTime |
Long |
连接超时时间,单位 ms |
operateTimeout |
Int |
单次操作超时时间,单位 ms |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Unit |
无返回值 |
startSan(cedScanCallback: CedScanCallback, maxTime: Long = 30000): Unit接口说明:开始扫描 BLE 设备。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
cedScanCallback |
CedScanCallback |
扫描结果回调 |
maxTime |
Long |
扫描最长持续时间,单位 ms |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Unit |
无返回值 |
stopScanNow(): Unit接口说明:立即停止扫描。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
| 无 | - | 无入参 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Unit |
无返回值 |
bleConnect(mac: String? = null, bleDevice: BleDevice? = null): BleDevice?接口说明:连接设备,成功时返回连接成功的 BleDevice。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
mac |
String? |
设备 MAC 地址,可空 |
bleDevice |
BleDevice? |
已扫描到的底层设备对象,可空 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | BleDevice? |
连接成功返回设备对象,失败返回 null |
disconnectBle(device: BleDevice): Unit接口说明:断开指定设备连接。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
device |
BleDevice |
要断开的底层设备对象 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Unit |
无返回值 |
disconnectedAll(): Unit接口说明:断开所有已连接设备。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
| 无 | - | 无入参 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Unit |
无返回值 |
setBleStatus(callback: BleStatusCallback): Unit接口说明:监听系统蓝牙开关状态变化。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
callback |
BleStatusCallback |
系统蓝牙状态回调 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Unit |
无返回值 |
startBond(bleDevice: BleDevice): Boolean接口说明:发起设备配对。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
bleDevice |
BleDevice |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Boolean |
true 表示配对成功,false 表示失败 |
setUUIDs(bleDevice: BleDevice): List<UUIDTAG>接口说明:发现并设置通信 UUID。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
bleDevice |
BleDevice |
已连接设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | List<UUIDTAG> |
设置成功的 UUID 标签列表 |
printServiceData(bleDevice: BleDevice): Unit接口说明:打印设备的 GATT 服务和特征信息。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
bleDevice |
BleDevice |
已连接设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Unit |
无返回值 |
requestCommonLock(reqData: ReqData, maxTime: Long = 10000, delayTime: Long = 200, errorMsg: ErrorMsg): ByteBuffer?接口说明:带互斥锁的通用请求发送接口。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
reqData |
ReqData |
请求对象 |
maxTime |
Long |
超时时间,单位 ms |
delayTime |
Long |
发送后等待时间,单位 ms |
errorMsg |
ErrorMsg |
错误回调 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
requestCommon(reqData: ReqData, maxTime: Long = 10000, delayTime: Long = 200, errorMsg: ErrorMsg): ByteBuffer?接口说明:不带互斥锁的通用请求发送接口。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
reqData |
ReqData |
请求对象 |
maxTime |
Long |
超时时间,单位 ms |
delayTime |
Long |
发送后等待时间,单位 ms |
errorMsg |
ErrorMsg |
错误回调 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
registerAndAuth(mac: DeviceInfo, showMsg: (String) -> Unit): Boolean接口说明:执行注册与鉴权流程。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
mac |
DeviceInfo |
目标设备 |
showMsg |
(String) -> Unit |
鉴权过程消息回调 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Boolean |
true 表示鉴权成功,false 表示失败 |
logSign(desMac: DeviceInfo): Array<Long>?接口说明:读取日志起止标记。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Array<Long>? |
成功返回 [startTag, endTag],失败返回 null |
readLog(localStart: Long, maxLen: Int, desMac: DeviceInfo): MutableList<String>?接口说明:读取设备日志内容。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
localStart |
Long |
日志读取起始位置 |
maxLen |
Int |
最大读取长度 |
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | MutableList<String>? |
成功返回日志字符串列表,失败返回 null |
stopReadLog(desMac: DeviceInfo): Unit接口说明:停止读取日志。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Unit |
无返回值 |
readWave(desMac: DeviceInfo, timeout: Long, callBack: (String) -> Unit): Unit接口说明:读取波形数据。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
desMac |
DeviceInfo |
目标设备 |
timeout |
Long |
超时时间 |
callBack |
(String) -> Unit |
状态回调 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Unit |
无返回值 |
readCheckImu(desMac: DeviceInfo, callBack: (String) -> Unit): Unit接口说明:读取 IMU 检测数据。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
desMac |
DeviceInfo |
目标设备 |
callBack |
(String) -> Unit |
状态回调 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Unit |
无返回值 |
stopCheckImu(desMac: DeviceInfo): Boolean接口说明:停止 IMU 检测。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Boolean |
true 表示成功,false 表示失败 |
released(): Unit接口说明:释放 BLE 管理器资源。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
| 无 | - | 无入参 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Unit |
无返回值 |
blePermission(): Boolean接口说明:申请或检查 BLE 所需权限。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
| 无 | - | 无入参 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Boolean |
全部权限通过返回 true,否则返回 false |
BleApi| 名称 | 类型 | 中文说明 |
|---|---|---|
desMacIndirect |
DeviceInfo? |
间接指定目标设备,ipgRequest 会优先使用 |
workInfo |
WorkInfo |
最近一次读取到的工作状态缓存 |
bleDeviceInfo |
BleDeviceInfo |
最近一次读取到的设备信息缓存 |
electrodeInfo |
ElectrodeInfo |
最近一次读取到的电极信息缓存 |
batteryInfo |
BatteryInfo |
最近一次读取到的电池信息缓存 |
patientInfo |
PatientInfo |
最近一次读取到的患者/临床信息缓存 |
| 接口 | 中文说明 | 返回类型 |
|---|---|---|
ipgRequest(...) |
业务统一请求入口 | ByteBuffer? |
activation() |
发送激活命令 | ByteBuffer? |
readWorkStatus() |
读取工作状态 | WorkInfo? |
writeHwVersion(...) |
写硬件版本号 | ByteBuffer? |
writeHwSn(...) |
写硬件编号 | ByteBuffer? |
readSwVersion(...) |
读软件版本号 | DoctorDeviceInfo? |
writeSwVersion(...) |
写软件版本号 | ByteBuffer? |
writeModel(...) |
写产品型号 | ByteBuffer? |
writeSn(...) |
写产品序列号 | ByteBuffer? |
readDeviceAll(...) |
读全部设备信息 | BleDeviceInfo? |
writeElectrodeModel(...) |
写电极型号 | ByteBuffer? |
writeElectrodePos(...) |
写电极植入位置 | ByteBuffer? |
writeImplantPos(...) |
写植入部位 | ByteBuffer? |
writeProdDate(...) |
写生产日期 | ByteBuffer? |
writeImplantDate(...) |
写植入日期 | ByteBuffer? |
writeValidDate(...) |
写有效日期 | ByteBuffer? |
readElectrodeAll(...) |
读全部电极信息 | ElectrodeInfo? |
writeBattVendor(...) |
写电池厂商信息 | ByteBuffer? |
writeBattBatch(...) |
写电池批号 | ByteBuffer? |
writeBattInstall(...) |
写装机日期 | ByteBuffer? |
writeBattValid(...) |
写电池有效期 | ByteBuffer? |
readBatteryAll(...) |
读全部电池信息 | BatteryInfo? |
writeHospital(...) |
写医院名称 | ByteBuffer? |
writeDoctorName(...) |
写医生姓名 | ByteBuffer? |
writePatientName(...) |
写患者姓名 | ByteBuffer? |
writeDoctorContact(...) |
写医生联系方式 | ByteBuffer? |
writeDiagnosis(...) |
写诊断信息 | ByteBuffer? |
writePatientGender(...) |
写患者性别 | ByteBuffer? |
writePatientBirth(...) |
写患者出生日期 | ByteBuffer? |
writePatientSymptoms(...) |
写患者症状/病症信息 | ByteBuffer? |
readPatientAll(...) |
读全部患者/临床信息 | PatientInfo? |
syncRtc(...) |
同步 RTC 时间 | ByteBuffer? |
readRtc(...) |
读取 RTC 时间 | ByteBuffer? |
stopStim(...) |
停止刺激 | ByteBuffer? |
startGroupStim(...) |
启动 Group 刺激 | ByteBuffer? |
resetMcu(...) |
复位 MCU | ByteBuffer? |
disconnectAll(...) |
断开所有主机连接 | ByteBuffer? |
writeGroupParam(...) |
写 Group 参数 | ByteBuffer? |
readGroup(...) |
读单个 Group 参数 | ByteBuffer? |
readAllGroup(...) |
读全部 Group 参数 | ByteBuffer? |
fullImpedanceMeasurement(...) |
全阻抗测量 | MutableList<Int>? |
therapyImpedanceMeasurement(...) |
治疗阻抗测量 | MutableList<Float>? |
readTimeInterval(...) |
读取时段刺激配置 | List<TimeIntervalInfo>? |
writeTimeInterval(...) |
写入时段刺激配置 | Boolean |
ipgRequest(reqData: ReqData, maxTime: Long = 10000, errorMsg: (String) -> Unit): ByteBuffer?接口说明:业务侧统一请求发送入口。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
reqData |
ReqData |
请求对象 |
maxTime |
Long |
超时时间,单位 ms |
errorMsg |
(String) -> Unit |
错误提示回调 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
activation(): ByteBuffer?接口说明:发送激活命令。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
| 无 | - | 无入参 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
readWorkStatus(): WorkInfo?接口说明:读取设备工作状态,并同步更新 workInfo 缓存。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
| 无 | - | 无入参 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | WorkInfo? |
成功返回工作状态对象,失败返回 null |
writeHwVersion(data: ByteArray): ByteBuffer?接口说明:写入设备硬件版本号。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
硬件版本号字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeHwSn(data: ByteArray): ByteBuffer?接口说明:写入设备硬件编号。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
硬件编号字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
readSwVersion(desMac: DeviceInfo = Ble.currentBleDevice): DoctorDeviceInfo?接口说明:读取软件版本信息。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | DoctorDeviceInfo? |
成功返回软件版本对象,失败返回 null |
writeSwVersion(data: ByteArray): ByteBuffer?接口说明:写入软件版本号。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
软件版本号字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeModel(data: ByteArray): ByteBuffer?接口说明:写入产品型号。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
产品型号字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeSn(data: ByteArray): ByteBuffer?接口说明:写入产品序列号。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
产品序列号字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
readDeviceAll(desMac: DeviceInfo = Ble.currentBleDevice): BleDeviceInfo?接口说明:读取全部设备基础信息,并更新 bleDeviceInfo 缓存。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | BleDeviceInfo? |
成功返回设备信息对象,失败返回 null |
writeElectrodeModel(data: ByteArray): ByteBuffer?接口说明:写入电极型号。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
电极型号字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeElectrodePos(data: ByteArray): ByteBuffer?接口说明:写入电极植入位置。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
电极植入位置字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeImplantPos(data: ByteArray): ByteBuffer?接口说明:写入植入部位信息。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
植入部位字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeProdDate(data: ByteArray): ByteBuffer?接口说明:写入生产日期。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
生产日期字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeImplantDate(data: ByteArray): ByteBuffer?接口说明:写入植入日期。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
植入日期字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeValidDate(data: ByteArray): ByteBuffer?接口说明:写入有效日期。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
有效日期字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
readElectrodeAll(desMac: DeviceInfo = Ble.currentBleDevice): ElectrodeInfo?接口说明:读取全部电极信息,并更新 electrodeInfo 缓存。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ElectrodeInfo? |
成功返回电极信息对象,失败返回 null |
writeBattVendor(data: ByteArray): ByteBuffer?接口说明:写入电池厂商信息。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
电池厂商信息字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeBattBatch(data: ByteArray): ByteBuffer?接口说明:写入电池批号。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
电池批号字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeBattInstall(data: ByteArray): ByteBuffer?接口说明:写入电池装机日期。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
电池装机日期字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeBattValid(data: ByteArray): ByteBuffer?接口说明:写入电池有效期。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
电池有效期字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
readBatteryAll(desMac: DeviceInfo = Ble.currentBleDevice): BatteryInfo?接口说明:读取全部电池信息,并更新 batteryInfo 缓存。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | BatteryInfo? |
成功返回电池信息对象,失败返回 null |
writeHospital(data: ByteArray): ByteBuffer?接口说明:写入医院名称。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
医院名称字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeDoctorName(data: ByteArray): ByteBuffer?接口说明:写入医生姓名。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
医生姓名字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writePatientName(data: ByteArray): ByteBuffer?接口说明:写入患者姓名。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
患者姓名字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeDoctorContact(data: ByteArray): ByteBuffer?接口说明:写入医生联系方式。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
医生联系方式字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeDiagnosis(data: ByteArray): ByteBuffer?接口说明:写入诊断信息。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
诊断或备注信息字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writePatientGender(data: ByteArray): ByteBuffer?接口说明:写入患者性别。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
性别字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writePatientBirth(data: ByteArray): ByteBuffer?接口说明:写入患者出生日期。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
患者出生日期字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writePatientSymptoms(data: ByteArray): ByteBuffer?接口说明:写入患者症状或病症信息。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
患者症状/病症字节数据 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
readPatientAll(desMac: DeviceInfo = Ble.currentBleDevice): PatientInfo?接口说明:读取全部患者/临床信息,并更新 patientInfo 缓存。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | PatientInfo? |
成功返回患者信息对象,失败返回 null |
syncRtc(data: ByteArray, desMac: DeviceInfo = Ble.currentBleDevice): ByteBuffer?接口说明:同步 RTC 时间。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
RTC 时间字节数据 |
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
readRtc(desMac: DeviceInfo = Ble.currentBleDevice): ByteBuffer?接口说明:读取 RTC 时间原始字节数据。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回 RTC 原始字节数据,失败返回 null |
stopStim(stopType: Byte = 0x01, desMac: DeviceInfo = Ble.currentBleDevice): ByteBuffer?接口说明:停止刺激。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
stopType |
Byte |
停止类型,常见 0x01=正常停止、0x02=紧急停止 |
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
startGroupStim(data: ByteArray, desMac: DeviceInfo = Ble.currentBleDevice): ByteBuffer?接口说明:启动 Group 刺激。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
启动刺激报文,通常为 Group 类型、编号、模式等组合 |
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
resetMcu(desMac: DeviceInfo = Ble.currentBleDevice): ByteBuffer?接口说明:复位 MCU。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
disconnectAll(desMac: DeviceInfo = Ble.currentBleDevice): ByteBuffer?接口说明:断开所有主机连接。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
writeGroupParam(data: ByteArray, desMac: DeviceInfo = Ble.currentBleDevice): ByteBuffer?接口说明:写入 Group 参数。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
Group 参数报文 |
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
readGroup(byteArray: ByteArray, desMac: DeviceInfo = Ble.currentBleDevice): ByteBuffer?接口说明:读取单个 Group 参数。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
byteArray |
ByteArray |
查询单个 Group 的请求报文 |
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
readAllGroup(byteArray: ByteArray, desMac: DeviceInfo = Ble.currentBleDevice): ByteBuffer?接口说明:读取全部 Group 参数。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
byteArray |
ByteArray |
查询全部 Group 的请求报文 |
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | ByteBuffer? |
成功返回响应字节数据,失败返回 null |
fullImpedanceMeasurement(data: ByteArray, desMac: DeviceInfo = Ble.currentBleDevice): MutableList<Int>?接口说明:执行全阻抗测量。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
测试电流报文,项目里通常传 4 字节 float |
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | MutableList<Int>? |
成功返回阻抗值列表,失败返回 null |
therapyImpedanceMeasurement(data: ByteArray, desMac: DeviceInfo = Ble.currentBleDevice): MutableList<Float>?接口说明:执行治疗阻抗测量。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
data |
ByteArray |
测试电流报文,项目里通常传 4 字节 float |
desMac |
DeviceInfo |
目标设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | MutableList<Float>? |
成功返回浮点阻抗值列表,失败返回 null |
readTimeInterval(desMac: DeviceInfo? = null): List<TimeIntervalInfo>?接口说明:读取时段刺激配置列表。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
desMac |
DeviceInfo? |
目标设备,为空时使用当前设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | List<TimeIntervalInfo>? |
成功返回时段配置列表,失败返回 null |
writeTimeInterval(intervals: List<TimeIntervalInfo>, desMac: DeviceInfo? = null): Boolean接口说明:写入时段刺激配置。
入参说明:
| 入参 | 类型 | 中文说明 |
|---|---|---|
intervals |
List<TimeIntervalInfo> |
待写入的时段刺激列表 |
desMac |
DeviceInfo? |
目标设备,为空时使用当前设备 |
出参说明:
| 出参 | 类型 | 中文说明 |
|---|---|---|
| 返回值 | Boolean |
true 表示写入成功,false 表示失败 |
DoctorDeviceInfo| 字段 | 类型 | 中文说明 |
|---|---|---|
info |
String |
软件版本信息字符串 |
BleDeviceInfo| 字段 | 类型 | 中文说明 |
|---|---|---|
hardwareVersion |
String |
硬件版本号 |
hardwareId |
String |
硬件编号 |
softwareVersion |
String |
软件版本号 |
softwareId |
String |
软件编号 |
productModel |
String |
产品型号 |
productSerial |
String |
产品序列号 |
productionDate |
String |
生产日期 |
ElectrodeInfo| 字段 | 类型 | 中文说明 |
|---|---|---|
electrodeModel |
MStringD |
电极型号 |
implantLocation3D |
MStringD |
三维植入位置 |
implantLocationLR |
ByteArray |
左右侧植入位置编码 |
productionDate |
String |
生产日期 |
implantDate |
MStringD |
植入日期 |
expiryDate |
String |
有效日期 |
brainLeft |
BRAIN_POSITION? |
左侧脑区位置 |
brainRight |
BRAIN_POSITION? |
右侧脑区位置 |
BatteryInfo| 字段 | 类型 | 中文说明 |
|---|---|---|
manufacturer |
String |
电池厂商信息 |
batchNumber |
String |
电池批号 |
installationDate |
String |
电池装机日期 |
expiryDate |
String |
电池有效期 |
PatientInfo| 字段 | 类型 | 中文说明 |
|---|---|---|
hospitalName |
MStringD |
手术医院 |
surgeonName |
MStringD |
手术医生 |
doctorContact |
MStringD |
医生联系方式 |
remarkInfo |
MStringD |
备注信息 |
gender |
MShortD |
性别 |
patientName |
MStringD |
患者姓名 |
patientBirthday |
MStringD |
患者出生日期 |
diagnosisInfo |
MStringD |
病症/诊断信息 |
birthday |
String |
格式化生日字符串 |
age |
Int |
根据生日计算出的年龄 |
WorkInfo| 字段 | 类型 | 中文说明 |
|---|---|---|
chargingStatus |
MShortD |
充电状态 |
vbatVoltage |
MIntD |
VBAT 电压 |
vccVoltage |
MIntD |
VCC 电压 |
deviceTemperature |
MIntD |
设备温度原始值 |
stimulationStatus |
MShortD |
刺激状态 |
stimulationProgramType |
MShortD |
刺激处方类型 |
stimulationProgramId |
MShortD |
刺激处方编号 |
temperatureCelsius |
Float |
摄氏温度 |
stimulationStatusText |
String |
刺激状态中文文本 |
isStimulating |
Pair<Boolean, Int> |
是否刺激中及当前处方编号 |
power |
Int |
计算后的电量百分比 |
TimeIntervalInfo| 字段 | 类型 | 中文说明 |
|---|---|---|
state |
MShortD |
启用状态 |
startHour |
MBCDInt |
开始小时 |
startMinute |
MBCDInt |
开始分钟 |
endHour |
MBCDInt |
结束小时 |
endMinute |
MBCDInt |
结束分钟 |
groupType |
MShortD |
分组类型 |
groupId |
MShortD |
分组编号 |
enabled |
Boolean |
是否启用 |
stimuTypeNum |
String |
刺激类型中文名 |
| 项 | 说明 |
|---|---|
| 默认目标设备 | BleApi 中大多数接口默认依赖 Ble.currentBleDevice |
| 间接指定设备 | 可通过 BleApi.desMacIndirect 在 ipgRequest 中统一覆盖目标设备 |
| 阻抗测量返回 | fullImpedanceMeasurement() 返回 10 个 Int,therapyImpedanceMeasurement() 返回 8 个 Float |
| 时段配置接口 | readTimeInterval() / writeTimeInterval() 是少数显式透传 desMac 的接口 |