3 接口说明
3.1 蓝牙处理接口
可以通过 JL_BluetoothManager
使用下面接口
方法名 |
参数 |
结果 |
描述 |
---|---|---|---|
addEventListener |
boolean: 结果 |
添加蓝牙事件监听器, 推荐使用 |
|
removeEventListener |
boolean: 结果 |
移除蓝牙事件监听器 |
|
configure |
BluetoothOption: 蓝牙参数 |
void |
配置蓝牙库参数 |
isBluetoothEnabled |
NULL |
boolean: 结果 |
蓝牙是否开启, 推荐使用 |
openOrCloseBluetooth |
isEnable: 是否使能 |
boolean: 结果 |
打开或关闭蓝牙, 推荐使用 |
scan |
timeout: 扫描超时时间(单位: 毫秒) |
int: 结果码 |
扫描BLE设备 |
scan |
type: 扫描类型
* BluetoothConstant#SCAN_TYPE_BLE
* BluetoothConstant#SCAN_TYPE_CLASSIC
timeout: 扫描超时时间(单位: 毫秒)
|
int: 结果码 |
扫描蓝牙设备 |
stopScan |
NULL |
int :结果码 |
停止蓝牙扫描 |
getFoundedBluetoothDevices |
NULL |
ArrayList<BluetoothDevice>:
已发现的蓝牙设备列表
|
获得已发现的蓝牙设备列表 |
isConnectedByProfile |
device: 经典蓝牙设备 |
boolean: 结果 |
是否连接经典蓝牙服务 |
startConnectByBreProfiles |
device: 经典蓝牙设备 |
void |
连接指定的经典蓝牙, 连接状态在 3.2 蓝牙事件监听器 回调 |
disconnectByProfiles |
device: 经典蓝牙设备 |
boolean: 操作结果 |
断开指定的经典蓝牙 |
unpair |
device: 经典蓝牙设备 |
int :结果码 |
解除经典蓝牙的配对, 配对状态在 3.2 蓝牙事件监听器 回调 |
synchronizationBtDeviceStatus |
NULL |
void |
同步系统蓝牙状态 |
getConnectedDevice |
NULL |
BluetoothDevice: 正在使用的设备 |
获取已连接且正在使用的设备 |
connect |
device: 蓝牙设备 |
void |
连接蓝牙设备 |
disconnect |
NULL |
void |
断开已连接的正在使用的蓝牙设备 |
disconnect |
device: 蓝牙设备 |
void |
断开指定的蓝牙设备 |
fastConnect |
NULL |
boolean: 操作结果 |
快速回连 |
getMappedDeviceAddress |
address: 蓝牙设备地址 |
String: 映射设备地址 |
获取指定地址的映射地址 |
getHistoryBluetoothDeviceList |
NULL |
List<HistoryBluetoothDevice>:
连接历史列表
|
获得连接历史列表 |
removeHistoryDevice |
HistoryBluetoothDevice : 连接历史
IActionCallback: 操作结果回调
|
void |
删除指定的连接历史 |
reconnectHistoryBluetoothDevice |
void |
回连指定的连接历史 |
|
clearHistoryDeviceRecord |
NULL |
void |
清除连接历史缓存 |
sendCommandAsync |
void |
发送RCSP命令 |
|
sendData |
device: 已连接的设备
CommandBase: 被响应命令
data: 需要发送的数据
|
void |
发送数据命令 |
sendCommandResponse |
device: 已连接的设备
CommandBase : 回复命令
|
void |
发送回复命令 |
getConnectedDeviceList |
NULL |
List<BluetoothDevice>:
已连接设备列表
|
获取已连接设备列表 |
isConnectedBtDevice |
device: 蓝牙设备 |
boolean: 结果 |
设备是否已连接 |
isUseBtDevice |
device: 蓝牙设备 |
boolean: 结果 |
设备是否正在使用 |
switchConnectedDevice |
device: 已连接的设备 |
void |
切换正在使用的设备 |
destroy |
NULL |
void |
释放资源 |
3.1.1 蓝牙操作接口
public interface IBluetoothOperation {
/*-------------------------------- BluetoothAdapter Op ------------------------*/
/**
* 蓝牙模块是否使能
*
* @return boolean 结果。若为true,蓝牙模块打开; 若为false,蓝牙模块关闭
*/
boolean isBluetoothEnabled();
/**
* 打开蓝牙模块
*
* <p>需要用户动态授权</p>
*
* @return boolean 操作结果
*/
boolean enableBluetooth();
/**
* 关闭蓝牙模块
*
* @return boolean 操作结果
*/
boolean disableBluetooth();
/**
* 注册蓝牙回调监听器
*
* @param bluetoothCallback 蓝牙回调监听器。建议使用{@link BluetoothCallbackImpl}
* @return boolean 操作结果
*/
boolean registerBluetoothCallback(IBluetoothCallback bluetoothCallback);
/**
* 注销蓝牙回调监听器
*
* @param bluetoothCallback 蓝牙回调监听器。建议使用{@link BluetoothCallbackImpl}
* @return boolean 操作结果
*/
boolean unregisterBluetoothCallback(IBluetoothCallback bluetoothCallback);
/**
* 已连接蓝牙设备对象
*
* <p>在BLE方式时,返回BLE设备对象。<br/>
* 在SPP方式时,需要注意,会通过BLE连接转换成Spp连接,
* 所以会先返回BLE的对象,再返回Spp的对象(经典蓝牙的对象)</p>
*
* @return 返回通讯通道的对象, 若通讯通道为建立, 返回null。
*/
BluetoothDevice getConnectedDevice();
/**
* 设置已连接且正在使用的蓝牙设备
*
* @param device 蓝牙设备
*/
void setConnectedDevice(BluetoothDevice device);
/**
* 获取正在使用的BluetoothGatt对象
*
* @return BluetoothGatt 正在使用的BluetoothGatt对象
*/
BluetoothGatt getConnectedBluetoothGatt();
/**
* 获得指定设备的BluetoothGatt对象
*
* @param device BLE设备
* @return BluetoothGatt 已连接的BluetoothGatt对象
*/
BluetoothGatt getDeviceGatt(BluetoothDevice device);
/**
* 获取已连接设备列表
*
* @return List<BluetoothDevice> 已连接设备列表
*/
List<BluetoothDevice> getConnectedDeviceList();
/**
* 判断设备是否已连接
*
* @param device 蓝牙设备
* @return boolean 结果
*/
boolean isConnectedDevice(BluetoothDevice device);
/**
* 设置蓝牙配置信息
*
* @param bluetoothOption 蓝牙配置信息
*/
void setBluetoothOption(BluetoothOption bluetoothOption);
/**
* 获取蓝牙配置信息
*
* @return BluetoothOption 蓝牙配置信息
*/
BluetoothOption getBluetoothOption();
/**
* 获取远端蓝牙设备对象
*
* @param address 蓝牙设备地址
* @return BluetoothDevice 蓝牙设备对象。若蓝牙设备存在,返回设备对象;反之,返回 null.
*/
BluetoothDevice getRemoteDevice(String address);
/**
* 获取缓存的经典蓝牙对象
*
* @param device 蓝牙设备
* @return BluetoothDevice 缓存的经典蓝牙对象
*/
BluetoothDevice getCacheEdrDevice(BluetoothDevice device);
/*-----------------------------------scan device op--------------------------*/
/**
* 是否正在扫描设备
*
* @return boolean 结果
*/
boolean isScanning();
/**
* 获取发现蓝牙设备列表
*
* <p>列表,只会返回要扫描的类型; scan的操作会清空缓存列表;</p>
*
* @return ArrayList<BluetoothDevice> 发现蓝牙设备列表
*/
ArrayList<BluetoothDevice> getDiscoveredBluetoothDevices();
/**
* 当前扫描类型
*
* @return int 扫描类型
* <p>
* {@link com.jieli.bluetooth.constant.BluetoothConstant#SCAN_TYPE_BLE} --- BLE设备 <br/>
* {@link com.jieli.bluetooth.constant.BluetoothConstant#SCAN_TYPE_CLASSIC} --- 经典蓝牙设备
* </p>
*/
int getScanType();
/**
* 开始蓝牙设备扫描
*
* <p>该方法会扫描所有蓝牙设备,SDK只回调经典蓝牙设备</p>
* <p>达到超时值且没扫描到蓝牙设备,会通过{@link IBluetoothCallback#onError(BaseError)}返回扫描超时错误</p>
*
* @param timeout 超时值
* @return int 操作结果码
* <p>
* {@link com.jieli.bluetooth.constant.ErrorCode#ERR_NONE} --- 操作成功<br/>
* {@link com.jieli.bluetooth.constant.ErrorCode#SUB_ERR_OP_FAILED} --- 操作失败<br/>
* {@link com.jieli.bluetooth.constant.ErrorCode#SUB_ERR_REFLECT_WAY} --- 调用反射接口失败<br/>
* <br/>
* 若操作成功,搜索状态将在{@link IBluetoothCallback#onDiscoveryStatus(boolean, boolean)}回调<br/>
* 搜索到的设备也将在{@link IBluetoothCallback#onDiscovery(BluetoothDevice, BleScanMessage)}回调<br/>
* 弹窗产品将在{@link IBluetoothCallback#onShowDialog(BluetoothDevice, BleScanMessage)}回调
* </p>
*/
int startDeviceScan(long timeout);
/**
* 停止蓝牙设备扫描
*
* @return int 操作结果码
* <p>
* {@link com.jieli.bluetooth.constant.ErrorCode#ERR_NONE} --- 操作成功<br/>
* {@link com.jieli.bluetooth.constant.ErrorCode#SUB_ERR_OP_FAILED} --- 操作失败<br/>
* {@link com.jieli.bluetooth.constant.ErrorCode#SUB_ERR_REFLECT_WAY} --- 调用反射接口失败
* </p>
*/
int stopDeviceScan();
/**
* 开始BLE设备扫描
*
* <p>达到超时值且没扫描到蓝牙设备,会通过{@link IBluetoothCallback#onError(BaseError)}返回扫描超时错误</p>
*
* @param timeout 超时时间。单位是毫秒
* @return int 操作结果码
* <p>
* {@link ErrorCode#ERR_NONE} --- 操作成功<br/>
* {@link ErrorCode#SUB_ERR_OP_FAILED} --- 操作失败<br/>
* {@link ErrorCode#SUB_ERR_REFLECT_WAY} --- 调用反射接口失败 <br/>
* <br/>
* 若操作成功,搜索状态将在{@link IBluetoothCallback#onDiscoveryStatus(boolean, boolean)} 回调<br/>
* 搜索到的设备也将在{@link IBluetoothCallback#onDiscovery(BluetoothDevice, BleScanMessage)} 回调<br/>
* 弹窗产品将在{@link IBluetoothCallback#onShowDialog(BluetoothDevice, BleScanMessage)} 回调
* </p>
*/
int startBLEScan(long timeout);
/**
* 停止BLE设备扫描
*
* @return int 操作结果码
* <p>
* {@link ErrorCode#ERR_NONE} --- 操作成功<br/>
* {@link ErrorCode#SUB_ERR_OP_FAILED} --- 操作失败
* </p>
*/
int stopBLEScan();
/*-----------------------------------pair op--------------------------*/
/**
* 指定设备是否正在配对
*
* @param device 蓝牙设备
* @return boolean 结果
*/
boolean isPairing(BluetoothDevice device);
/**
* 指定设备是否已配对
*
* @param device 蓝牙设备
* @return boolean 结果
*/
boolean isPaired(BluetoothDevice device);
/**
* 获取已配对的设备列表
*
* @return List<BluetoothDevice> 已配对的设备列表
*/
List<BluetoothDevice> getPairedDevices();
/**
* 开始指定设备的配对流程
*
* @param device 蓝牙设备
* @return int 结果码
* <p>
* {@link ErrorCode#ERR_NONE} --- 操作成功 <br/>
* {@link ErrorCode#SUB_ERR_OP_FAILED} --- 操作失败 <br/>
* {@link ErrorCode#SUB_ERR_REFLECT_WAY} --- 调用发射接口失败<br/>
* 若操作成功,状态将在{@link OnBtDevicePairListener#onBtDeviceBond(BluetoothDevice, int)}回调
* </p>
*/
int pair(BluetoothDevice device);
/**
* 开始指定设备的配对流程
*
* @param device 蓝牙设备
* @param pairWay 配对方式,取值范围:[0, 2]
* @return int 结果码
* <p>
* {@link ErrorCode#ERR_NONE} --- 操作成功 <br/>
* {@link ErrorCode#SUB_ERR_OP_FAILED} --- 操作失败 <br/>
* {@link ErrorCode#SUB_ERR_REFLECT_WAY} --- 调用发射接口失败<br/>
* 若操作成功,状态将在{@link OnBtDevicePairListener#onBtDeviceBond(BluetoothDevice, int)}回调
* </p>
*/
int pair(BluetoothDevice device, @IntRange(from = 0, to = 2) int pairWay);
/**
* 取消与蓝牙设备的配对
*
* @param device 蓝牙设备
* @return int 操作码
* <p>
* {@link ErrorCode#ERR_NONE} --- 操作成功 <br/>
* {@link ErrorCode#SUB_ERR_OP_FAILED} --- 操作失败 <br/>
* {@link ErrorCode#SUB_ERR_REFLECT_WAY} --- 调用反射接口失败<br/>
* 若操作成功,状态将在{@link OnBtDevicePairListener#onBtDeviceBond(BluetoothDevice, int)}回调
* </p>
*/
int unPair(BluetoothDevice device);
/**
* 尝试开始指定设备的配对流程
*
* <p>队列式执行配对过程,避免过度操作导致蓝牙系统异常。推荐使用该方法进行配对</p>
*
* @param device 蓝牙设备
* @return boolean 操作结果
*/
boolean tryToPair(BluetoothDevice device);
/**
* 尝试开始指定设备的配对流程
*
* <p>队列式执行配对过程,避免过度操作导致蓝牙系统异常。推荐使用该方法进行配对</p>
*
* @param device 蓝牙设备
* @param pairWay 配对方式,取值范围:[0, 2]
* @return boolean 操作结果
*/
boolean tryToPair(BluetoothDevice device, @IntRange(from = 0, to = 2) int pairWay);
/**
* 尝试开始指定设备的解除配对流程
*
* <p>队列式执行配对过程,避免过度操作导致蓝牙系统异常。推荐使用该方法进行配对</p>
*
* @param device 蓝牙设备
* @return boolean 操作结果
*/
boolean tryToUnPair(BluetoothDevice device);
/*-----------------------------------br/edr op--------------------------*/
/**
* 蓝牙设备是否包含hfp服务
*
* @param device 经典蓝牙设备
* @return boolean 结果
*/
boolean deviceHasHfp(BluetoothDevice device);
/**
* 蓝牙设备是否包含a2dp服务
*
* @param device 经典蓝牙设备
* @return boolean 结果
*/
boolean deviceHasA2dp(BluetoothDevice device);
/**
* 蓝牙设备是否已建立hfp服务
*
* @param device 经典蓝牙设备
* @return int 设备连接状态<p>
* {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTED} --- 未连接 <br/>
* {@link android.bluetooth.BluetoothProfile#STATE_CONNECTING} --- 连接中 <br/>
* {@link android.bluetooth.BluetoothProfile#STATE_CONNECTED} --- 已连接 <br/>
* {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTING} --- 断开中
* </p>
*/
int isConnectedByHfp(BluetoothDevice device);
/**
* 蓝牙设备是否已建立a2dp服务
*
* @param device 经典蓝牙设备
* @return int 设备连接状态<p>
* {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTED} --- 未连接 <br/>
* {@link android.bluetooth.BluetoothProfile#STATE_CONNECTING} --- 连接中 <br/>
* {@link android.bluetooth.BluetoothProfile#STATE_CONNECTED} --- 已连接 <br/>
* {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTING} --- 断开中
* </p>
*/
int isConnectedByA2dp(BluetoothDevice device);
/**
* 蓝牙设备是否已建立经典蓝牙服务(a2dp、hfp)
*
* @param device 经典蓝牙设备
* @return int 设备连接状态<p>
* {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTED} --- 未连接 <br/>
* {@link android.bluetooth.BluetoothProfile#STATE_CONNECTING} --- 连接中 <br/>
* {@link android.bluetooth.BluetoothProfile#STATE_CONNECTED} --- 已连接 <br/>
* {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTING} --- 断开中
* </p>
*/
int isConnectedByProfile(BluetoothDevice device);
/**
* 判断经典蓝牙是否连接中
*
* @return boolean 结果
*/
boolean isBrEdrConnecting();
/**
* 获取连接中的经典蓝牙设备
*
* @return BluetoothDevice 经典蓝牙设备
*/
BluetoothDevice getConnectingBrEdrDevice();
/**
* 连接经典蓝牙
*
* @param device 经典蓝牙设备
* @return boolean 操作结果 <p>
* 若操作成功,连接状态将在{@link IBluetoothCallback#onBrEdrConnection(BluetoothDevice, int)} 回调
* </p>
*/
boolean connectByProfiles(BluetoothDevice device);
/**
* 断开经典蓝牙
*
* @param device 经典蓝牙设备
* @return boolean 结果
*/
boolean disconnectByProfiles(BluetoothDevice device);
/**
* 设置指定的设备为音频输出设备
*
* @param device 指定的已连接设备
* @return boolean 结果
*/
boolean setActivityBluetoothDevice(BluetoothDevice device);
/**
* 获取当前音频输出设备对象
*
* @return BluetoothDevice 当前音频输出设备对象
*/
BluetoothDevice getActivityBluetoothDevice();
/**
* 获取已连接SPP列表
*
* @return List<BluetoothDevice> 已连接SPP列表
*/
List<BluetoothDevice> getConnectedSppList();
/**
* 判断设备是否已连接SPP
*
* @param device 蓝牙设备
* @return boolean 结果
*/
boolean isConnectedSppDevice(BluetoothDevice device);
/**
* 连接Spp通道
*
* @param device 经典蓝牙设备
* @return int 操作结果
* <p>
* {@link ErrorCode#ERR_NONE} --- 操作成功 <br/>
* {@link ErrorCode#SUB_ERR_OP_FAILED} --- 操作失败 <br/>
* {@link ErrorCode#SUB_ERR_REFLECT_WAY} --- 调用反射接口失败<br/>
* 若操作成功,连接状态将在{@link IBluetoothCallback#onSppStatus(BluetoothDevice, int)} 回调。
* </p>
*/
int connectSPPDevice(BluetoothDevice device);
/**
* 断开Spp通道
*
* @param device 经典蓝牙设备
* @return boolean 操作结果
* <p>
* 调用成功,连接状态将在{@link IBluetoothCallback#onSppStatus(BluetoothDevice, int)}回调
* </p>
*/
boolean disconnectSPPDevice(BluetoothDevice device);
/**
* 通过Spp通道发送数据包
*
* @param device 经典蓝牙设备
* @param data 数据包
* @return boolean 操作结果
*/
boolean writeDataToSppDevice(BluetoothDevice device, byte[] data);
/**
* 获取已连接经典蓝牙设备列表
*
* @return List<BluetoothDevice> 已连接经典蓝牙设备列表
*/
List<BluetoothDevice> getDevicesConnectedByProfile();
/*----------------------------------ble op----------------------------*/
/**
* 获取已配对的BLE设备列表
*
* @return List<BluetoothDevice> 已配对的BLE设备列表,若没有,则为null
*/
List<BluetoothDevice> getPairedBLEDevices();
/**
* 获取已连接BLE设备的MTU
*
* @param device 已连接BLE设备
* @return int 协商后的BLE MTU
*/
int getBleMtu(BluetoothDevice device);
/**
* 判断是否为已连接的BLE设备
*
* @param device BLE设备
* @return boolean 结果
*/
boolean isConnectedBLEDevice(BluetoothDevice device);
/**
* 请求调节BLE的MTU
*
* @param device 蓝牙设备
* @param mtu 请求调节的MTU
* @return boolean 操作结果
*/
boolean requestBleMtu(BluetoothDevice device, int mtu);
/**
* 开关BLE特征值属性
*
* @param gatt 蓝牙设备
* @param bleCharacteristic BLE特征值
* @return boolean 操作结果
*/
boolean enableBLEDeviceNotification(BluetoothGatt gatt, BleCharacteristic bleCharacteristic);
/**
* 连接BLE设备
*
* @param device BLE设备
* @return int 操作码<p>
* {@link ErrorCode#ERR_NONE} --- 操作成功<br/>
* {@link ErrorCode#SUB_ERR_OP_FAILED} --- 操作失败 <br/>
* {@link ErrorCode#SUB_ERR_BLE_CONNECTING} --- BLE连接中<br/>
* {@link ErrorCode#SUB_ERR_BLE_CONNECT_FAILED} --- BLE连接失败<br/>
* <br/>
* 若操作成功,连接状态将在 {@link IBluetoothCallback#onBleConnection(BluetoothDevice, int)} 回调
* </p>
*/
int connectBLEDevice(BluetoothDevice device);
/**
* 断开BLE设备
*
* @param device BLE设备
* @return boolean 操作结果<p>
* 若操作成功,连接状态将在 {@link IBluetoothCallback#onBleConnection(BluetoothDevice, int)} 回调
* </p>
*/
boolean disconnectBLEDevice(BluetoothDevice device);
/**
* 通过BLE写服务发送数据包
*
* @param device BLE设备
* @param serviceUUID 服务UUID
* @param characteristicUUID 属性UUID
* @param writeData 数据包
* @return boolean 发送结果
*/
boolean writeDataToBLEDevice(BluetoothDevice device, UUID serviceUUID, UUID characteristicUUID, byte[] writeData);
/*---------------------------------- special op ----------------------------*/
/**
* 同步连接历史记录
*/
void syncHistoryBtDeviceRecord();
/**
* 获取当前连接中设备对象
*
* @return BluetoothDevice 连接中设备对象
*/
BluetoothDevice getConnectingDevice();
/**
* 连接蓝牙设备
*
* <p>根据蓝牙设备类型进行连接,BLE设备进行BLE连接,经典蓝牙设备进行经典蓝牙连接</p>
*
* @param device 蓝牙设备
* @return int 结果码<p>
* {@link ErrorCode#ERR_NONE} --- 操作成功<br/>
* {@link ErrorCode#SUB_ERR_OP_FAILED} --- 操作失败 <br/>
* {@link ErrorCode#SUB_ERR_BLE_CONNECTING} --- BLE连接中<br/>
* {@link ErrorCode#SUB_ERR_BLE_CONNECT_FAILED} --- BLE连接失败<br/>
* {@link ErrorCode#SUB_ERR_SPP_CONNECTING} --- SPP连接中<br/>
* {@link ErrorCode#SUB_ERR_REFLECT_WAY} --- 调用反射接口失败 <br/>
* {@link ErrorCode#SUB_ERR_DEVICE_CONNECTING} --- 设备连接中 <br/>
* {@link ErrorCode#SUB_ERR_DEVICE_IS_CONNECTED} --- 设备已连接<br/>
* <br/>
* 若操作成功,连接状态将在 {@link IBluetoothCallback#onConnection(BluetoothDevice, int)} 回调
* </p>
*/
int connectBtDevice(BluetoothDevice device);
/**
* 连接蓝牙设备
*
* <p>根据蓝牙设备类型进行连接,BLE设备进行BLE连接,经典蓝牙设备进行经典蓝牙连接</p>
*
* @param device 蓝牙设备
* @param connectWay 连接方式
* <p>
* {@link com.jieli.bluetooth.constant.BluetoothConstant#PROTOCOL_TYPE_BLE} --- BLE方式 <br/>
* {@link com.jieli.bluetooth.constant.BluetoothConstant#PROTOCOL_TYPE_SPP} --- SPP方式
* </p>
* @return int 结果码<p>
* {@link ErrorCode#ERR_NONE} --- 操作成功<br/>
* {@link ErrorCode#SUB_ERR_OP_FAILED} --- 操作失败 <br/>
* {@link ErrorCode#SUB_ERR_BLE_CONNECTING} --- BLE连接中<br/>
* {@link ErrorCode#SUB_ERR_BLE_CONNECT_FAILED} --- BLE连接失败<br/>
* {@link ErrorCode#SUB_ERR_SPP_CONNECTING} --- SPP连接中<br/>
* {@link ErrorCode#SUB_ERR_REFLECT_WAY} --- 调用反射接口失败 <br/>
* {@link ErrorCode#SUB_ERR_DEVICE_CONNECTING} --- 设备连接中 <br/>
* {@link ErrorCode#SUB_ERR_DEVICE_IS_CONNECTED} --- 设备已连接<br/>
* <br/>
* 若操作成功,连接状态将在 {@link IBluetoothCallback#onConnection(BluetoothDevice, int)} 回调
* </p>
*/
int connectBtDevice(BluetoothDevice device, int connectWay);
/**
* 断开蓝牙设备
*
* <p>连接状态将在 {@link IBluetoothCallback#onConnection(BluetoothDevice, int)} 回调</p>
*
* @param device 蓝牙设备
*/
void disconnectBtDevice(BluetoothDevice device);
/**
* 连接经典蓝牙设备
*
* @param breDevice 蓝牙设备
* @return int 结果码 <p>
* {@link ErrorCode#ERR_NONE} --- 操作成功 <br/>
* {@link ErrorCode#SUB_ERR_PARAMETER} --- 参数错误 <br/>
* {@link ErrorCode#SUB_ERR_EDR_CONNECTING} --- 正在连接经典蓝牙 <br/>
* {@link ErrorCode#SUB_ERR_REFLECT_WAY} --- 调用发射接口失败<br/>
* <br/>
* 若操作成功,连接状态将在 {@link IBluetoothCallback#onBtDeviceConnectStatus(BluetoothDevice, int)} 回调
* </p>
*/
int startConnectByBreProfiles(BluetoothDevice breDevice);
/**
* 是否正在连接设备
*
* @return boolean 结果
*/
boolean isConnecting();
/**
* 检查蓝牙设备是否已过认证
*
* @param device 蓝牙设备
* @return boolean 结果
*/
boolean checkDeviceIsCertify(BluetoothDevice device);
/**
* 快速连接
*
* <p>连接结果通过{@link IBluetoothCallback} 回调。需要通过 {@link #registerBluetoothCallback(IBluetoothCallback)} 注册回调。</p>
*
* @return 若false, 表示没有缓存BLE地址,无法回连。若true,说明开始回连过程
*/
boolean fastConnect();
/**
* 检查BLE设备是否连接
*
* <p>通过同步系统BLE设备连接列表,尝试确认连接BLE是否为本方案认可的设备</p>
*/
void checkBleIsConnected();
/**
* 同步蓝牙设备状态
*
* <p>确认蓝牙设备是否正常连接</p>
*/
void synchronizationBtDeviceStatus(); //同步蓝牙设备状态
/**
* 查询连接历史记录
*
* @param address 设备地址
* @return HistoryBluetoothDevice 连接历史记录
*/
HistoryBluetoothDevice findHistoryBluetoothDevice(String address);
/**
* 删除历史记录设备
*
* <p>同步清除BLE和经典蓝牙的配对,清除映射关系</p>
*
* @param historyBtDevice 历史记录设备
* @param callback 操作回调
*/
void removeHistoryDevice(HistoryBluetoothDevice historyBtDevice, IActionCallback<HistoryBluetoothDevice> callback);
/**
* 是否正在回连
*
* @return boolean 结果
*/
boolean isReconnecting();
/**
* 回连历史记录
*
* @param historyBtDevice 历史记录设备
* @param timeoutMs 超时时间
* @param listener 回连监听器
*/
void reconnectHistoryBluetoothDevice(HistoryBluetoothDevice historyBtDevice, long timeoutMs, OnReconnectHistoryRecordListener listener);
/**
* 停止回连设备
* @return boolean 操作结果
*/
boolean stopReconnect();
/**
* 释放资源
*/
void destroy();
}
3.2 蓝牙事件监听器
public interface IBluetoothEventListener {
/**
* 蓝牙适配器状态回调
*
* @param bEnabled 蓝牙是否打开
* @param bHasBle 是否支持BLE
*/
void onAdapterStatus(boolean bEnabled, boolean bHasBle);
/**
* 发现设备状态回调
*
* @param bBle 是否BLE设备发现
* @param bStart 是否搜索开始
*/
void onDiscoveryStatus(boolean bBle, boolean bStart);
/**
* 发现设备回调
*
* @param device 蓝牙设备
*/
@Deprecated
void onDiscovery(BluetoothDevice device);
/**
* 发现设备回调
*
* @param device 蓝牙设备
* @param bleScanMessage 广播信息
*/
void onDiscovery(BluetoothDevice device, BleScanMessage bleScanMessage);
/**
* 产品弹窗回调
*
* @param device 蓝牙设备
* @param bleScanMessage 广播信息
*/
void onShowDialog(BluetoothDevice device, BleScanMessage bleScanMessage);
/**
* 蓝牙设备配对状态回调
*
* @param device 蓝牙设备
* @param status 配对状态
* <p>参考值如下<br>
* {@link BluetoothDevice#BOND_NONE} or
* {@link BluetoothDevice#BOND_BONDING} or
* {@link BluetoothDevice#BOND_BONDED}
* </p>
*/
void onBondStatus(BluetoothDevice device, int status);
/**
* 蓝牙设备连接状态回调
*
* @param device 蓝牙设备
* @param status 连接状态
* <p>参考值如下<br>
* {@link com.jieli.bluetooth.constant.StateCode#CONNECTION_DISCONNECT} or
* {@link com.jieli.bluetooth.constant.StateCode#CONNECTION_OK} or
* {@link com.jieli.bluetooth.constant.StateCode#CONNECTION_FAILED} or
* {@link com.jieli.bluetooth.constant.StateCode#CONNECTION_CONNECTING} or
* {@link com.jieli.bluetooth.constant.StateCode#CONNECTION_CONNECTED}
* </p>
*/
void onConnection(BluetoothDevice device, int status);
/**
* 切换已连接且正在使用的设备的回调
*
* @param device 已连接设备
*/
void onSwitchConnectedDevice(BluetoothDevice device);
/**
* A2DP服务状态回调
*
* @param device 蓝牙设备
* @param status 连接状态
* <p>参考值如下<br>
* {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTED} or
* {@link android.bluetooth.BluetoothProfile#STATE_CONNECTING} or
* {@link android.bluetooth.BluetoothProfile#STATE_CONNECTED} or
* {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTING}
* </p>
*/
void onA2dpStatus(BluetoothDevice device, int status);
/**
* HFP服务状态回调
*
* @param device 蓝牙设备
* @param status 连接状态
* <p>参考值如下<br>
* {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTED} or
* {@link android.bluetooth.BluetoothProfile#STATE_CONNECTING} or
* {@link android.bluetooth.BluetoothProfile#STATE_CONNECTED} or
* {@link android.bluetooth.BluetoothProfile#STATE_DISCONNECTING}
* </p>
*/
void onHfpStatus(BluetoothDevice device, int status);
/**
* SPP连接状态回调
*
* @param device 蓝牙设备
* @param status 连接状态
* <p>参考值如下<br>
* {@link com.jieli.bluetooth.constant.StateCode#CONNECTION_DISCONNECT} or
* {@link com.jieli.bluetooth.constant.StateCode#CONNECTION_OK} or
* {@link com.jieli.bluetooth.constant.StateCode#CONNECTION_FAILED} or
* {@link com.jieli.bluetooth.constant.StateCode#CONNECTION_CONNECTING} or
* {@link com.jieli.bluetooth.constant.StateCode#CONNECTION_CONNECTED}
* </p>
*/
void onSppStatus(BluetoothDevice device, int status);
/**
* 接收到设备的RCSP命令数据
*
* @param device 蓝牙设备
* @param cmd RCSP命令数据
*/
void onDeviceCommand(BluetoothDevice device, CommandBase cmd);
/**
* 接收到设备的数据包
*
* @param device 蓝牙设备
* @param data 数据包
*/
void onDeviceData(BluetoothDevice device, byte[] data);
/**
* 接收到设备的语音数据
*
* @param device 蓝牙设备
* @param data 语音数据
*/
@Deprecated
void onDeviceVoiceData(BluetoothDevice device, byte[] data);
/**
* 接收到设备的语音数据包
*
* @param device 蓝牙设备
* @param data 语音信息
*/
void onDeviceVoiceData(BluetoothDevice device, VoiceData data);
/**
* 设备VAD结束的回调
*
* @param device 蓝牙设备
*/
void onDeviceVadEnd(BluetoothDevice device);
/**
* 接收到设备的RCSP回复数据
*
* @param device 蓝牙设备
* @param response RCSP命令回复数据
*/
void onDeviceResponse(BluetoothDevice device, CommandBase response);
/**
* 错误事件回调
*
* @param error 错误信息
*/
void onError(BaseError error); //错误事件回调
}
3.3 命令回复回调
public interface RcspCommandCallback {
/**
* 回调回复命令
*
* @param device 已连接设备
* @param cmd 回复命令
*/
void onCommandResponse(BluetoothDevice device, CommandBase cmd);
/**
* 回调错误事件
*
* @param device 已连接设备
* @param error 错误信息
*/
void onErrCode(BluetoothDevice device, BaseError error);
}
3.4 状态码
public class StateCode {
/*---------------------------------------------------------------------
*connection status
* ---------------------------------------------------------------------*/
public final static int CONNECTION_OK = 1; //Connection successful
public final static int CONNECTION_FAILED = 2; //Connection Fail
public final static int CONNECTION_DISCONNECT = 0;//disconnect
public final static int CONNECTION_CONNECTING = 3;//connecting
public final static int CONNECTION_CONNECTED = 4; //connected
/*---------------------------------------------------------------------
* Response Status
* ---------------------------------------------------------------------*/
public final static int STATUS_SUCCESS = 0; //successful
public final static int STATUS_FAIL = 1; //failure
public final static int STATUS_UNKOWN_CMD = 2; //unknown command
public final static int STATUS_BUSY = 3; //device is busy
public final static int STATUS_NO_RESOURCE = 4; //no resource
public final static int STATUS_CRC_ERROR = 5; //CRC check error
public final static int STATUS_ALL_DATA_CRC_ERROR = 6; //all data CRC error
public final static int STATUS_PARAMETER_ERROR = 7; //parameter error
public final static int STATUS_RESPONSE_DATA_OVER_LIMIT = 8; //The reply data exceeded the limit
/*--------------------------------------------------------------------
* TWS
*--------------------------------------------------------------------*/
/* =================== *
* earphone status
* =================== */
//Do not display popovers
public final static int TWS_HEADSET_STATUS_DIMISS = 0;
//Bluetooth is disconnected
public final static int TWS_HEADSET_STATUS_DISCONNECTED = 1;
//Bluetooth is connected
public final static int TWS_HEADSET_STATUS_CONNECTED = 2;
//Bluetooth is connecting
public final static int TWS_HEADSET_STATUS_CONNECTING = 3;
//C0
public final static int ADV_SETTINGS_ERROR_IN_GAME_MODE = 1; //Game mode causes Settings to fail
//The length of bluetooth name exceeds the limit
public final static int ADV_SETTINGS_ERROR_DEVICE_NAME_LENGTH_OVER_LIMIT = 2;
//Failed to set flash in non-Bluetooth mode
public final static int ADV_SETTINGS_ERROR_LED_SETTINGS_FAILED = 3;
}
3.5 功能码
对应的类名: AttrAndFunCode
public class AttrAndFunCode {
//function code
public final static byte SYS_INFO_FUNCTION_PUBLIC = (byte) 0xff; //Common properties
public final static byte SYS_INFO_FUNCTION_BT = (byte) 0x00; //Bluetooth mode information
public final static byte SYS_INFO_FUNCTION_MUSIC = (byte) 0x01; //Music Information
public final static byte SYS_INFO_FUNCTION_RTC = (byte) 0x02; //Clock Information
public final static byte SYS_INFO_FUNCTION_AUX = (byte) 0x03; //AUX Information
public final static byte SYS_INFO_FUNCTION_FM = (byte) 0x04; //FM Information
public final static byte SYS_INFO_FUNCTION_LIGHT = (byte) 0x05; //Light Information
public final static byte SYS_INFO_FUNCTION_FMTX = (byte) 0x06; //FMTTX,[Skip and reuse to public properties]
public final static byte SYS_INFO_FUNCTION_EQ = (byte) 0x07; //EQ Information [Skip and reuse to public properties]
public final static byte SYS_INFO_FUNCTION_LOW_POWER = (byte) 0x16; //Low power mode
//Common properties - SYS_INFO_FUNCTION_PUBLIC
public final static byte SYS_INFO_ATTR_BATTERY = (byte) 0x00; //System capacity
public final static byte SYS_INFO_ATTR_VOLUME = (byte) 0x01; //system volume
public final static byte SYS_INFO_ATTR_MUSIC_DEV_STATUS = (byte) 0x02; //usb/sd status
public final static byte SYS_INFO_ATTR_ERR = (byte) 0x03; //error
public final static byte SYS_INFO_ATTR_EQ = (byte) 0x04; //eq
public final static byte SYS_INFO_ATTR_FILE_TYPE = (byte) 0x05; //Set the file type for directory browsing
public final static byte SYS_INFO_ATTR_CUR_MODE_TYPE = (byte) 0x06; //Schema changes
public final static byte SYS_INFO_ATTR_LIGHT = (byte) 0x07; //State of the light
public final static byte SYS_INFO_ATTR_FM_TX = (byte) 0x08; //Emission frequency
public final static byte SYS_INFO_ATTR_EMITTER_MODE = (byte) 0x09; //Peripheral mode status
public final static byte SYS_INFO_ATTR_EMITTER_CONNECT_STATUS = (byte) 0x0a; //Peripheral connection status
public final static byte SYS_INFO_ATTR_HIGH_AND_BASS = (byte) 0x0b; //Bass setting
public final static byte SYS_INFO_ATTR_EQ_PRESET_VALUE = (byte) 0x0c; //EQ preset value
public final static byte SYS_INFO_ATTR_CURRENT_NOISE_MODE = (byte) 0x0d; //Current noise processing mode
public final static byte SYS_INFO_ATTR_ALL_NOISE_MODE = (byte) 0x0e; //All noise processing mode information
public final static byte SYS_INFO_ATTR_PHONE_STATUS = (byte) 0x0f; //PhoneState
public final static byte SYS_INFO_ATTR_FIXED_LEN_DATA_FUN = (byte) 0x10; //Fixed data length extension function
public final static byte SYS_INFO_ATTR_SOUND_CARD_EQ_FREQ = (byte) 0x11; //Sound card function EQ frequency
public final static byte SYS_INFO_ATTR_SOUND_CARD_EQ_GAIN = (byte) 0x12; //Sound card function EQ gain
public final static byte SYS_INFO_ATTR_SOUND_CARD = (byte) 0x13; //Sound card function
//BT properties - SYS_INFO_FUNCTION_BT
public final static byte SYS_INFO_ATTR_ID3_TITLE = (byte) 0x00; //song name
public final static byte SYS_INFO_ATTR_ID3_ARTIST = (byte) 0x01; //author
public final static byte SYS_INFO_ATTR_ID3_ALBUM = (byte) 0x02; //album
public final static byte SYS_INFO_ATTR_ID3_NUMBER = (byte) 0x03; //serial number
public final static byte SYS_INFO_ATTR_ID3_TOTAL = (byte) 0x04; //Total playlist length
public final static byte SYS_INFO_ATTR_ID3_GENRE = (byte) 0x05; //type
public final static byte SYS_INFO_ATTR_ID3_TOTAL_TIME = (byte) 0x06; //total time
public final static byte SYS_INFO_ATTR_ID3_PLAY_STATUS = (byte) 0x07; //play status
public final static byte SYS_INFO_ATTR_ID3_CURRENT_TIME = (byte) 0x08; //current time
//MUSIC properties
public final static byte SYS_INFO_ATTR_MUSIC_STATUS_INFO = (byte) 0x00; //music state
public final static byte SYS_INFO_ATTR_MUSIC_FILE_NAME_INFO = (byte) 0x01; //Playing File Information
public final static byte SYS_INFO_ATTR_MUSIC_PLAY_MODE = (byte) 0x02; //Play mode
//RTC properties
public final static byte SYS_INFO_ATTR_RTC_TIME = (byte) 0x00; //sync time
public final static byte SYS_INFO_ATTR_RTC_ALARM = (byte) 0x01; //Alarm Information Operation
public final static byte SYS_INFO_ATTR_RTC_CURRENT_ALARM_INDEX = (byte) 0x02; //Current alarm number
public final static byte SYS_INFO_ATTR_RTC_STOP_ALARM = (byte) 0x03; //stop alarm clock
public final static byte SYS_INFO_ATTR_RTC_ALARM_VER = (byte) 0x04; //Alarm clock Structure Version
public final static byte SYS_INFO_ATTR_RTC_ALARM_DEFAULT_BELL_LIST = (byte) 0x05; //Default Ringtones
public final static byte SYS_INFO_ATTR_RTC_ALARM_AUDITION = 0x06; //Listen to the alarm clock
public final static byte SYS_INFO_ATTR_RTC_ALARM_EXPAND_FLAG = 0x07 ; //Support identifier for alarm field extension
//aux properties
public final static byte SYS_INFO_ATTR_AUX_STATU = (byte) 0x00; //aux play status
//fm properties
public final static byte SYS_INFO_ATTR_FM_STATU = (byte) 0x00; //fm play status
public final static byte SYS_INFO_ATTR_FM_FRE_INFO = (byte) 0x01; //fm channel information
/**
* Function Cmd
*/
//ID3 Music control command parameters
public final static byte FUNCTION_BT_CMD_ID3_PLAY_OR_PAUSE = 0x01; //pause/play
public final static byte FUNCTION_BT_CMD_ID3_PLAY_PREV = 0x02; //previous
public final static byte FUNCTION_BT_CMD_ID3_PLAY_NEXT = 0x03; //next
public final static byte FUNCTION_BT_CMD_ID3_DATA_PUSH_SWITCH = 0x04; //push data switch
//device Music control command parameters
public final static byte FUNCTION_MUSIC_CMD_PLAY_OR_PAUSE = 0x01; //pause/play
public final static byte FUNCTION_MUSIC_CMD_PLAY_PREV = 0x02; //previous
public final static byte FUNCTION_MUSIC_CMD_PLAY_NEXT = 0x03; //next
public final static byte FUNCTION_MUSIC_CMD_NEXT_PLAYMODE = 0x04; //next play mode
public final static byte FUNCTION_MUSIC_CMD_NEXT_EQ_MODE = 0x05; //next eq mode
public final static byte FUNCTION_MUSIC_CMD_FAST_FORWARD = 0x07; //fast forward
public final static byte FUNCTION_MUSIC_CMD_RETREAT_QUICKLY = 0x06; //fast reverse
//Command for restoring the AI status
public final static byte FUNCTION_BT_CMD_RESTORE_STATUS = 0x01; //Voice recognition status restored
//The parameters attached to the state recovery command
public final static byte FUNCTION_BT_CMD_RESTORE_STATUS_RESTORE = 0x00; //remain unchanged
public final static byte FUNCTION_BT_CMD_RESTORE_STATUS_RESTORE_MODE = 0x01; //Jump back to original mode
public final static byte FUNCTION_BT_CMD_RESTORE_STATUS_RESTORE_PLAY_PREV = 0x02; //Jump previous
public final static byte FUNCTION_BT_CMD_RESTORE_STATUS_RESTORE_PLAY_NEXT = 0x03; //Jump next
public final static byte FUNCTION_BT_CMD_RESTORE_STATUS_RESTORE_PAUSE = 0x04; //pause
public final static byte FUNCTION_BT_CMD_RESTORE_STATUS_RESTORE_PLAY = 0x05; //play
//aux play control
public final static byte FUNCTION_AUX_CMD_PAUSE_OR_PLAY = 0x01; //pause/play
//fm control
public final static byte FUNCTION_FM_CMD_PLAY_OR_PAUSE = 0x01; //pause/play
public final static byte FUNCTION_FM_CMD_PREV_FREQ = 0x02; //previous frequency
public final static byte FUNCTION_FM_CMD_NEXT_FREQ = 0x03; //next frequency
public final static byte FUNCTION_FM_CMD_PREV_CHANNEL = 0x04; //previous channel
public final static byte FUNCTION_FM_CMD_NEXT_CHANNEL = 0x05; //next channel
// Scan channel:0x00:CHAN HOPPING 0x01:Scan forward 0x02:Backward scan 0x03:Stop scan
public final static byte FUNCTION_FM_CMD_FREQ_SCAN = 0x06;
public final static byte FUNCTION_FM_CMD_SELECT_CHANNEL = 0x07; //Select channel
public final static byte FUNCTION_FM_CMD_DEL_CHANNEL = 0x08; //Delete channel
public final static byte FUNCTION_FM_CMD_SELECT_FREQL = 0x09; //Select frequency
/*--------------------------------------------------------------------
* ADV Info properties
*--------------------------------------------------------------------*/
public final static int ADV_TYPE_BATTERY_QUANTITY = 0; //electric quantity [3 bytes; Don't set]
public final static int ADV_TYPE_DEVICE_NAME = 1; //device name [limitation of length : 32]
public final static int ADV_TYPE_KEY_SETTINGS = 2; //key settings
public final static int ADV_TYPE_LED_SETTINGS = 3; //light settings
public final static int ADV_TYPE_MIC_CHANNEL_SETTINGS = 4; //mic channel settings
public final static int ADV_TYPE_WORK_MODE = 5; //work mode
public final static int ADV_TYPE_PRODUCT_MESSAGE = 6; //product information
public final static int ADV_TYPE_CONNECTED_TIME = 7; //connect time
public final static int ADV_TYPE_IN_EAR_CHECK = 8; //in ear detection
public final static int ADV_TYPE_LANGUAGE = 9; //language Type
public final static int ADV_TYPE_ANC_MODE_LIST = 10; //List of ANC modes
/*key specific mode*/
public final static int KEY_FUNC_ID_SWITCH_ANC_MODE = 255; //Switch the ANC mode function key id
/*--------------------------------------------------------------------
* Fixed length data function
*--------------------------------------------------------------------*/
public final static int FIXED_LEN_DATA_TYPE_REVERBERATION = 0; //reverberation
public final static int FIXED_LEN_DATA_TYPE_DYNAMIC_LIMITER = 1; //Dynamic limiter
public static final int FIXED_LEN_DATA_TYPE_SOUND_CARD_EFFECT = 2; //Sound card features sound effects
public static final int FIXED_LEN_DATA_TYPE_SOUND_CARD_ATMOSPHERE = 3; //Sound card features atmosphere
public static final int FIXED_LEN_DATA_TYPE_SOUND_CARD_MIC_ARG = 4; //Sound card function MIC parameters
}
3.6 错误码
对应的类名: ErrorCode
错误定义 |
错误码 |
错误描述 |
---|---|---|
ERR_UNKNOWN |
-1 |
未知错误 |
ERR_NONE |
0 |
没有错误 |
ERR_COMMON(1 – 通用错误)
错误定义
错误码
错误描述
SUB_ERR_PARAMETER
0x1001(4097)
参数错误。用户必须检查输入参数的正确性
SUB_ERR_BLE_NOT_SUPPORT
0x1002(4098)
设备不支持BLE
SUB_ERR_BLUETOOTH_NOT_ENABLE
0x1003(4099)
蓝牙未打开
SUB_ERR_BLUETOOTH_UN_PAIR_FAILED
0x1006(4102)
设备解绑失败
SUB_ERR_A2DP_NOT_INIT
0x1007(4103)
A2DP管理对象未初始化
SUB_ERR_A2DP_CONNECT_FAILED
0x1008(4104)
A2DP服务连接失败
SUB_ERR_HFP_NOT_INIT
0x1009(4105)
HFP管理对象未初始化
SUB_ERR_HFP_CONNECT_FAILED
0x100A(4106)
HFP服务连接失败
SUB_ERR_NO_SERVER
0x1010(4112)
BLE发现服务失败
SUB_ERR_OP_FAILED
0x1011(4113)
操作失败
SUB_ERR_REFLECT_WAY
0x1014(4116)
调用反射方法失败
SUB_ERR_NO_PERMISSION
0x1015(4117)
缺少对应权限
SUB_ERR_UNSUPPORTED_FUNCTION
0x1016(4118)
不支持功能
SUB_ERR_FUNC_NOT_INIT
0x1017(4119)
功能模块未初始化
ERR_STATUS(2 – 状态错误)
错误定义
错误码
错误描述
SUB_ERR_BLE_CONNECT_FAILED
0x2001(8193)
BLE连接失败
SUB_ERR_CLASSIC_BLUETOOTH_IS_CONNECTED
0x2005(8197)
断开经典蓝牙失败
SUB_ERR_REMOTE_DEVICE_DISCONNECT
0x2006(8198)
远端设备未连接
SUB_ERR_DEVICE_IN_CALL
0x2007(8199)
设备处于通话状态
SUB_ERR_DEVICE_IN_BUSY
0x2008(8200)
设备处于繁忙状态
ERR_COMMUNICATION(3 – 通讯错误)
错误定义
错误码
错误描述
SUB_ERR_CONNECT_TIMEOUT
0x3001(12289)
连接超时
SUB_ERR_SEND_FAILED
0x3002(12290)
发送数据失败
SUB_ERR_PAIR_TIMEOUT
0x3003(12291)
配对超时
SUB_ERR_DATA_FORMAT
0x3004(12292)
数据格式异常
SUB_ERR_PARSE_DATA
0x3005(12293)
解析数据错误
SUB_ERR_SPP_WRITE_DATA_FAIL
0x3006(12294)
SPP发送数据失败
SUB_ERR_SEND_TIMEOUT
0x3007(12295)
发送数据超时
SUB_ERR_RESPONSE_BAD_STATUS
0x3008(12296)
设备回复失败状态。参考 “3.4 状态码”
SUB_ERR_NOT_ALLOW_CONNECT
0x3009(12297)
不允许连接
SUB_ERR_DEVICE_PAIRING
0x300A(12298)
正在配对中
SUB_ERR_EDR_CONNECTING
0x300B(12299)
经典蓝牙连接中
SUB_ERR_SPP_CONNECTING
0x300C(12300)
Spp连接中
SUB_ERR_BLE_CONNECTING
0x300D(12301)
Ble连接中
SUB_ERR_DEVICE_CONNECTING
0x300E(12302)
设备连接中
SUB_ERR_RESPONSE_BAD_RESULT
0x300F(12303)
回复失败原因。具体原因参考“BaseError#getReason()”
SUB_ERR_OPERATION_TIMEOUT
0x3010(12304)
操作超时
SUB_ERR_OPERATION_IN_PROGRESS
0x3011(12305)
操作进行中
SUB_ERR_STORAGE_OFFLINE
0x3012(12306)
存储器下线
SUB_ERR_CRC_CHECK
0x3013(12307)
CRC校验失败
SUB_ERR_MISSING_DATA
0x3014(12308)
丢失数据
SUB_ERR_DATA_OVER_LIMIT
0x3015(12309)
数据超过限制
SUB_ERR_INSUFFICIENT_SPACE
0x3016(12310)
空间不足
SUB_ERR_RENAME_FILE
0x3017(12311)
重命名失败
SUB_ERR_WRITE_DATA
0x3018(12312)
写数据失败
SUB_ERR_OPERATION_CANCEL
0x3019(12313)
操作被取消
ERR_OTA(4 – OTA错误)
错误定义
错误码
错误描述
SUB_ERR_OTA_FAILED
0x4001(16385)
OTA升级失败, 具体错误码参考 杰理OTA在线文档的错误码
ERR_OTHER(5 – 其他错误)
错误定义
错误码
错误描述
SUB_ERR_AUTH_DEVICE
0x5001(20481)
认证设备失败
SUB_ERR_IO_EXCEPTION
0x5002(20482)
IO异常
SUB_ERR_START_AUTH_DEVICE
0x5003(20483)
开始认证设备失败
ERR_FILE_OP(6 – 文件操作错误)
错误定义
错误码
错误描述
SUB_ERR_FILE_LOAD_COMPLETE
0x6000(24576)
文件数据加载完成
SUB_ERR_FOLDER_TOO_DEEP
0x6001(24577)
文件夹层级过深
SUB_ERR_NOT_FOUND_DATA
0x6002(24578)
没有找到缓存
SUB_ERR_FILE_STORAGE_NOT_MATCH
0x6003(24579)
文件与存储器不匹配
3.7 RCSP功能封装接口
3.7.1 基础接口
public interface IBaseOp {
/**
* 注册RCSP事件监听器
*
* @param listener RCSP事件监听器
*/
void registerOnRcspEventListener(OnRcspEventListener listener);
/**
* 注销RCSP事件监听器
*
* @param listener RCSP事件监听器
*/
void unregisterOnRcspEventListener(OnRcspEventListener listener);
/**
* 获取设备系统属性
*
* @param device 操作设备
* @param function 功能号
* @param mask 掩码
* @param callback 结果回调
*/
void getDevSysInfo(BluetoothDevice device, int function, int mask, OnRcspActionCallback<Boolean> callback);
/**
* 设置设备系统属性
*
* @param device 操作设备
* @param function 功能号
* @param list 属性列表
* @param callback 结果回调
*/
void setDevSysInfo(BluetoothDevice device, int function, List<AttrBean> list, OnRcspActionCallback<Boolean> callback);
/**
* 获取设备信息
*
* @param device 操作设备
* @param mask 掩码
* @param callback 结果回调
*/
void requestDeviceInfo(BluetoothDevice device, int mask, OnRcspActionCallback<DeviceInfo> callback);
/**
* 获取当前设备模式信息
*
* @param device 操作设备
* @param callback 结果回调
*/
void getCurrentDevModeInfo(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 获取设备存储器信息
*
* @param device 操作设备
* @param callback 结果回调
*/
void getDevStorageInfo(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 切换设备模式
*
* @param device 操作设备
* @param mode 模式
* @param callback 结果回调
*/
void switchDeviceMode(BluetoothDevice device, int mode, OnRcspActionCallback<Boolean> callback);
/**
* 重启设备
*
* @param device 操作设备
* @param callback 结果回调
*/
void rebootDevice(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 销毁控制类,释放资源
*/
void destroy();
}
3.7.2 音量控制接口
public interface IVolumeOp {
/**
* 获取设备最高音量
*
* @param device 蓝牙设备
* @return 最高音量
*/
int getMaxVolume(BluetoothDevice device);
/**
* 获取当前设备音量
*
* @param device 蓝牙设备
* @param callback 结果回调
*/
void getCurrentVolume(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 调节设备音量
*
* @param device 蓝牙设备
* @param volume 音量值
* @param callback 结果回调
*/
void adjustVolume(BluetoothDevice device, int volume, OnRcspActionCallback<Boolean> callback);
/**
* 获取高低音的值
*
* @param device 蓝牙设备
* @param callback 结果回调
*/
void getHighAndBassValue(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设置高低音的值
*
* @param device 蓝牙设备
* @param high 高音
* @param bass 低音
* @param callback 结果回调
*/
void setHighAndBassValue(BluetoothDevice device, int high, int bass, OnRcspActionCallback<Boolean> callback);
}
3.7.3 设备音乐控制接口
public interface IMusicOp {
/**
* 获取设备音乐信息
*
* @param device 操作设备
* @param callback 结果回调
*/
void getDeviceMusicInfo(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 获取设备音乐状态信息
*
* @param device 操作设备
* @param callback 结果回调
*/
void getDeviceMusicStatusInfo(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 获取设备音乐支持的文件格式
*
* @param device 操作设备
* @param callback 结果回调
*/
void getPlayFileFormat(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设备音乐播放或暂停
*
* @param device 操作设备
* @param callback 结果回调
*/
void musicPlayOrPause(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 播放上一曲
*
* @param device 操作设备
* @param callback 结果回调
*/
void musicPlayPrev(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 播放下一曲
*
* @param device 操作设备
* @param callback 结果回调
*/
void musicPlayNext(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 切换到下一个播放模式
*
* @param device 操作设备
* @param callback 结果回调
*/
void musicSwitchNextPlayMode(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 进度条控制
*
* @param device 操作设备
* @param orientation 方向 (0 -- 快进 1 -- 快退)
* @param time 步进
* @param callback 结果回调
*/
void musicSeekToProgress(BluetoothDevice device, int orientation, short time, OnRcspActionCallback<Boolean> callback);
/**
* 获取完整的ID3信息
*
* @param device 操作设备
* @param callback 结果回调
*/
void getID3MusicInfo(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 开启ID3信息通知
*
* @param device 操作设备
* @param callback 结果回调
*/
void openID3MusicNotification(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 关闭ID3信息通知
*
* @param device 操作设备
* @param callback 结果回调
*/
void closeID3MusicNotification(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* ID3播放或暂停
*
* @param device 操作设备
* @param callback 结果回调
*/
void iD3MusicPlayOrPause(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* ID3播放上一曲
*
* @param device 操作设备
* @param callback 结果回调
*/
void iD3MusicPlayPrev(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* ID3播放下一曲
*
* @param device 操作设备
* @param callback 结果回调
*/
void iD3MusicPlayNext(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
}
3.7.4 均衡器功能接口
public interface IEqOp {
/**
* 获取EQ信息
*
* @param device 操作设备
* @param callback 结果回调
*/
void getEqInfo(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设置EQ信息
*
* @param device 操作设备
* @param eqInfo EQ信息
* @param callback 结果回调
*/
void configEqInfo(BluetoothDevice device, EqInfo eqInfo, OnRcspActionCallback<Boolean> callback);
/**
* 获取拓展数据信息
*
* @param device 操作设备
* @param callback 结果回调
*/
void getExpandDataInfo(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设置拓展数据
*
* @param device 操作设备
* @param mask 掩码
* @param data 拓展数据
* @param callback 结果回调
*/
void setExpandDataInfo(BluetoothDevice device, int mask, byte[] data, OnRcspActionCallback<Boolean> callback);
/**
* 设置混响参数
*
* @param device 操作设备
* @param param 混响参数
* @param callback 结果回调
*/
void setReverberationParameter(BluetoothDevice device, ReverberationParam param, OnRcspActionCallback<Boolean> callback);
/**
* 设置动态限幅参数
*
* @param device 操作设备
* @param param 动态限幅参数
* @param callback 结果回调
*/
void setDynamicLimiterParameter(BluetoothDevice device, DynamicLimiterParam param, OnRcspActionCallback<Boolean> callback);
}
3.7.5 时钟功能接口
public interface IRTCOp {
/**
* 同步时间
*
* @param device 操作设备
* @param callback 结果回调
*/
void syncTime(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 读取闹钟列表
*
* @param device 操作设备
* @param callback 结果回调
*/
void readAlarmList(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 读取闹钟铃声列表
*
* @param device 操作设备
* @param callback 结果回调
*/
void readAlarmDefaultBellList(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 删除闹钟
*
* @param device 操作设备
* @param alarm 闹钟属性
* @param callback 结果回调
*/
void deleteAlarm(BluetoothDevice device, AlarmBean alarm, OnRcspActionCallback<Boolean> callback);
/**
* 添加或者修改闹钟
*
* @param device 操作设备
* @param alarm 闹钟属性
* @param callback 结果回调
*/
void addOrModifyAlarm(BluetoothDevice device, AlarmBean alarm, OnRcspActionCallback<Boolean> callback);
/**
* 停止闹钟铃声
*
* @param device 操作设备
* @param callback 结果回调
*/
void stopAlarmBell(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 读取闹钟铃声参数
*
* @param device 操作设备
* @param mask 闹钟索引掩码
* <p>mask = 0xff, 请求所有的闹钟铃声参数<br/>
* mask的bit位,对应闹钟的index</p>
* @param callback 结果回调
*/
void readAlarmBellArgs(BluetoothDevice device, byte mask, OnRcspActionCallback<List<AlarmExpandCmd.BellArg>> callback);
/**
* 设置指定闹钟铃声参数
*
* @param device 操作设备
* @param arg 闹钟铃声参数
* @param callback 结果回调
*/
void setAlarmBellArg(BluetoothDevice device, AlarmExpandCmd.BellArg arg, OnRcspActionCallback<Boolean> callback);
/**
* 试听闹钟铃声
*
* @param device 操作设备
* @param param 试听参数
* @param callback 结果回调
*/
void auditionAlarmBell(BluetoothDevice device, AuditionParam param, OnRcspActionCallback<Boolean> callback);
/**
* 停止试听闹钟铃声
*
* @param device 操作设备
* @param callback 结果回调
*/
void stopPlayAlarmBell(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
}
3.7.6 外接设备功能接口
public interface IAuxOp {
/**
* 获取外接设备状态
*
* @param device 操作设备
* @param callback 结果回调
*/
void getAuxStatusInfo(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 播放或暂停
*
* @param device 操作设备
* @param callback 结果回调
*/
void auxPlayOrPause(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
}
3.7.7 FM功能接口
public interface IFmOp {
/**
* 获取发射频点
*
* @param device 操作设备
* @param callback 结果回调
*/
void getFmFrequency(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设置发射频点
*
* @param device 操作设备
* @param frequency 频点
* @param callback 结果回调
*/
void setFmFrequency(BluetoothDevice device, float frequency, OnRcspActionCallback<Boolean> callback);
/**
* 获取FM信息
*
* @param device 操作设备
* @param callback 结果回调
*/
void getFmInfo(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 获取FM频道信息
*
* @param device 操作设备
* @param callback 结果回调
*/
void getFmChannels(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 向前搜索频道
*
* @param device 操作设备
* @param callback 结果回调
*/
void fmForwardSearchChannels(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 向后搜索频道
*
* @param device 操作设备
* @param callback 结果回调
*/
void fmBackwardSearchChannels(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 搜索全段频道
*
* @param device 操作设备
* @param callback 结果回调
*/
void fmSearchAllChannels(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 停止频道搜索
*
* @param device 操作设备
* @param callback 结果回调
*/
void fmStopSearch(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 播放指定的频点
*
* @param device 操作设备
* @param frequency 指定的频点
* @param callback 结果回调
*/
void fmPlaySelectedFrequency(BluetoothDevice device, float frequency, OnRcspActionCallback<Boolean> callback);
/**
* 播放或暂停键
*
* @param device 操作设备
* @param callback 结果回调
*/
void fmPlayOrPause(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 播放上一个频道
*
* @param device 操作设备
* @param callback 结果回调
*/
void fmPlayPrevChannel(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 播放下一个频道
*
* @param device 操作设备
* @param callback 结果回调
*/
void fmPlayNextChannel(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 播放上一个频点
*
* @param device 操作设备
* @param callback 结果回调
*/
void fmPlayPrevFrequency(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 播放下一个频点
*
* @param device 操作设备
* @param callback 结果回调
*/
void fmPlayNextFrequency(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
}
3.7.8 灯光控制接口
public interface ILightOp {
/**
* 获取灯光控制信息
*
* @param device 操作设备
* @param callback 结果回调
*/
void getLightControlInfo(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设置灯光控制信息
*
* @param device 操作设备
* @param lightControlInfo 灯光控制信息
* @param callback 结果回调
*/
void setLightControlInfo(BluetoothDevice device, LightControlInfo lightControlInfo, OnRcspActionCallback<Boolean> callback);
}
3.7.9 TWS功能接口
public interface ITwsOp {
/**
* 添加TWS事件监听器
*
* @param listener TWS事件监听器
*/
void addOnTwsEventListener(OnTwsEventListener listener);
/**
* 移除TWS事件监听器
*
* @param listener TWS事件监听器
*/
void removeOnTwsEventListener(OnTwsEventListener listener);
/**
* 获取缓存的ADV信息
*
* @param device 蓝牙设备
* @return ADV信息
*/
ADVInfoResponse getADVInfo(BluetoothDevice device);
/**
* 控制设备信息广播
*
* @param device 蓝牙设备
* @param enable 开关
* @param callback 结果回调
*/
void controlAdvBroadcast(BluetoothDevice device, boolean enable, OnRcspActionCallback<Boolean> callback);
/**
* 获取设备的设置信息
*
* @param device 蓝牙设备
* @param mask 掩码
* @param callback 结果回调
*/
void getDeviceSettingsInfo(BluetoothDevice device, int mask, OnRcspActionCallback<ADVInfoResponse> callback);
/**
* 修改设备的设置信息
*
* @param device 蓝牙设备
* @param type 功能
* @param data 参数
* @param callback 结果回调
*/
void modifyDeviceSettingsInfo(BluetoothDevice device, int type, byte[] data, OnRcspActionCallback<Integer> callback);
/**
* 获取所有噪声处理模式信息
*
* @param device 蓝牙设备
* @param callback 结果回调
*/
void getAllVoiceModes(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 获取当前噪声处理模式信息
*
* @param device 蓝牙设备
* @param callback 结果回调
*/
void getCurrentVoiceMode(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设置当前噪声处理模式
*
* @param device 蓝牙设备
* @param voiceMode 噪声处理模式
* @param callback 结果回调
*/
void setCurrentVoiceMode(BluetoothDevice device, VoiceMode voiceMode, OnRcspActionCallback<Boolean> callback);
/**
* 配置设备名称
*
* @param device 蓝牙设备
* @param name 设备名称
* @param callback 结果回调
*/
void configDeviceName(BluetoothDevice device, String name, OnRcspActionCallback<Integer> callback);
/**
* 配置按键功能设置
*
* @param device 蓝牙设备
* @param list 按键功能列表
* @param callback 结果回调
*/
void configKeySettings(BluetoothDevice device, List<ADVInfoResponse.KeySettings> list, OnRcspActionCallback<Integer> callback);
/**
* 配置灯光效果设置
*
* @param device 蓝牙设备
* @param list 灯光效果设置
* @param callback 结果回调
*/
void configLedSettings(BluetoothDevice device, List<ADVInfoResponse.LedSettings> list, OnRcspActionCallback<Integer> callback);
/**
* 更新接入设备时间
*
* @param device 蓝牙设备
* @param timeSec 接入设备时间(单位是秒)
* @param callback 结果回调
*/
void updateConnectedTime(BluetoothDevice device, int timeSec, OnRcspActionCallback<Integer> callback);
/**
* 更新指定功能的值
*
* @param device 蓝牙设备
* @param type 功能标志
* @param value 功能新值
* @param callback 结果回调
*/
void updateFunctionValue(BluetoothDevice device, int type, byte value, OnRcspActionCallback<Integer> callback);
/**
* 是否支持自适应ANC算法
*
* @param device 蓝牙设备
* @return 结果
*/
boolean isSupportAdaptiveANC(BluetoothDevice device);
/**
* 获取自适应ANC数据
*
* @param device 蓝牙设备
* @param callback 结果回调
* <p>结果通过{@link OnRcspEventListener#onVoiceFunctionChange(BluetoothDevice, VoiceFunc)} 回调</p>
*/
void getAdaptiveANCData(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设置自适应ANC数据
*
* @param device 蓝牙设备
* @param data 数据
* @param callback 操作回调
*/
void setAdaptiveANCData(BluetoothDevice device, AdaptiveData data, OnRcspActionCallback<Boolean> callback);
/**
* 开始自适应ANC算法检测
*
* @param device 蓝牙设备
* @param listener 自适应ANC检测监听器
*/
void startAdaptiveANC(BluetoothDevice device, OnAdaptiveANCListener listener);
/**
* 是否支持智能免摘功能
*
* @param device 蓝牙设备
* @return 结果
*/
boolean isSupportSmartNoPick(BluetoothDevice device);
/**
* 获取智能免摘信息
*
* @param device 蓝牙设备
* @param callback 操作结果回调
* <p>结果通过{@link OnRcspEventListener#onVoiceFunctionChange(BluetoothDevice, VoiceFunc)} 回调</p>
*/
void getSmartNoPick(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设置智能免摘参数
*
* @param device 蓝牙设备
* @param smartNoPick 参数
* @param callback 操作结果回调
*/
void setSmartNoPickParam(BluetoothDevice device, SmartNoPick smartNoPick, OnRcspActionCallback<Boolean> callback);
/**
* 是否支持场景降噪功能
*
* @param device 蓝牙设备
* @return 结果
*/
boolean isSupportSceneDenoising(BluetoothDevice device);
/**
* 获取场景降噪参数
*
* @param device 蓝牙设备
* @param callback 操作结果回调
*/
void getSceneDenoising(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设置场景降噪参数
*
* @param device 蓝牙设备
* @param sceneDenoising 参数
* @param callback 操作结果回调
*/
void setSceneDenoising(BluetoothDevice device, SceneDenoising sceneDenoising, OnRcspActionCallback<Boolean> callback);
/**
* 是否支持风噪检测功能
*
* @param device 蓝牙设备
* @return 结果
*/
boolean isSupportWindNoiseDetection(BluetoothDevice device);
/**
* 获取风噪检测参数
*
* @param device 蓝牙设备
* @param callback 操作结果回调
*/
void getWindNoiseDetection(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设置风噪检测参数
*
* @param device 蓝牙设备
* @param detection 参数
* @param callback 操作结果回调
*/
void setWindNoiseDetection(BluetoothDevice device, WindNoiseDetection detection, OnRcspActionCallback<Boolean> callback);
/**
* 是否支持人声增强功能
*
* @param device 蓝牙设备
* @return 结果
*/
boolean isSupportVocalBooster(BluetoothDevice device);
/**
* 获取人声增强参数
*
* @param device 蓝牙设备
* @param callback 操作结果回调
*/
void getVocalBooster(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设置人声增强参数
*
* @param device 蓝牙设备
* @param vocalBooster 参数
* @param callback 操作结果回调
*/
void setVocalBooster(BluetoothDevice device, VocalBooster vocalBooster, OnRcspActionCallback<Boolean> callback);
/**
* 是否支持设备双连功能
*
* @param device 蓝牙设备
* @return 结果
*/
boolean isSupportDoubleConnection(BluetoothDevice device);
/**
* 查询设备双连的状态
*
* @param device 蓝牙设备
* @param callback 结果回调
*/
void queryDoubleConnectionState(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设置设备双连的状态
*
* @param device 蓝牙设备
* @param state 设备双连的状态
* @param callback 结果回调
*/
void setDoubleConnectionState(BluetoothDevice device, DoubleConnectionState state, OnRcspActionCallback<Boolean> callback);
/**
* 查询设备已连接手机
*
* @param device 蓝牙设备
* @param deviceBtInfo 手机蓝牙信息
* @param callback 结果回调
*/
void queryConnectedPhoneBtInfo(BluetoothDevice device, DeviceBtInfo deviceBtInfo, OnRcspActionCallback<ConnectedBtInfo> callback);
}
3.7.10 声卡功能接口
public interface ISoundCardOp {
/**
* 获取声卡状态
*
* @param device 操作设备
* @param callback 结果回调
*/
void getSoundCardStatusInfo(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 获取声卡信息
*
* @param device 操作设备
* @param callback 结果回调
*/
void getSoundCardEqInfo(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设置声卡信息
*
* @param device 操作设备
* @param value 数值
* @param callback 结果回调
*/
void setSoundCardEqInfo(BluetoothDevice device, byte[] value, OnRcspActionCallback<Boolean> callback);
/**
* 设置声卡功能
*
* @param device 操作设备
* @param index 功能索引
* @param value 功能值
* @param callback 结果回调
*/
void setSoundCardFunction(BluetoothDevice device, byte index, int value, OnRcspActionCallback<Boolean> callback);
}
3.7.11 RCSP控制器接口
public interface IRcspControl {
/**
* 查找设备
*
* @param device 操作设备
* @param op 查找方式
* @param timeoutSec 查找限制时间
* @param playWay 播放方式
* @param player 播放源
* @param callback 结果回调
*/
void searchDev(BluetoothDevice device, int op, int timeoutSec, int playWay, int player, OnRcspActionCallback<Boolean> callback);
/**
* 停止查找设备
*
* @param device 操作设备
* @param callback 结果回调
*/
void stopSearchDevice(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 同步查找设备状态
*
* @param device 操作设备
* @param callback 结果回调
*/
void syncSearchDeviceStatus(BluetoothDevice device, OnRcspActionCallback<SearchDevStatusResponse> callback);
}
3.7.12 录音操作
public interface IRecordOp {
/**
* 添加录音状态回调
*
* @param callback OnRecordStateCallback 录音状态回调
*/
void addOnRecordStateCallback(OnRecordStateCallback callback);
/**
* 移除录音状态回调
*
* @param callback OnRecordStateCallback 录音状态回调
*/
void removeOnRecordStateCallback(OnRecordStateCallback callback);
/**
* 是否正在录音
*
* @param device BluetoothDevice 操作设备
* @return boolean 结果
*/
boolean isRecording(BluetoothDevice device);
/**
* 开始录音
*
* @param device BluetoothDevice 操作设备
* @param param RecordParam 录音参数
* @param callback OnRcspActionCallback<Boolean> 结果回调
*/
void startRecord(BluetoothDevice device, RecordParam param, OnRcspActionCallback<Boolean> callback);
/**
* 结束录音
*
* @param device 操作设备
* @param reason 结束原因
* @param callback 结果回调
*/
void stopRecord(BluetoothDevice device, int reason, OnRcspActionCallback<Boolean> callback);
}
3.7.13 文件操作
public interface IFileOp {
/**
* 正在文件操作
*
* @param device 蓝牙设备
* @return 结果
*/
boolean isFileOperating(BluetoothDevice device);
/**
* 获取在线存储器信息
*
* @return 在线存储器信息
*/
List<SDCardBean> getOnlineStorage();
/**
* 获取当前读取的文件夹
*
* @param storage 存储器信息
* @return 当前读取的文件夹
*/
Folder getCurrentFolder(@NonNull SDCardBean storage);
/**
* 浏览文件夹
*
* @param device 设备对象
* @param folder 文件夹
* @param offset 开始偏移
* @param readNum 读取数量
* @param callback 结果回调
*/
void listFiles(@NonNull BluetoothDevice device, @NonNull Folder folder, int offset, @IntRange(from = 1, to = 30) int readNum, OnFlowStateCallback<List<FileStruct>> callback);
/**
* 播放设备音乐文件
*
* @param device 设备对象
* @param file 音乐文件
* @param callback 结果回调
*/
void playMusic(@NonNull BluetoothDevice device, @NonNull RegFile file, OnRcspActionCallback<Boolean> callback);
/**
* 创建文件
*
* @param param 创建文件参数
* @param listener 状态监听器
*/
void createBigFile(@NonNull CreateFileParam param, OnTaskStateListener listener);
/**
* 读取文件
*
* @param param 读取文件参数
* @param listener 状态监听器
*/
void readBigFile(@NonNull ReadFileParam param, OnTaskStateListener listener);
/**
* 取消数据传输
*
* @param device 设备对象
* @param reason 取消原因
* @param callback 结果回调
*/
void cancelBigFileTransfer(@NonNull BluetoothDevice device, int reason, OnRcspActionCallback<Boolean> callback);
/**
* 删除文件
*
* @param param 删除文件参数
* @param callback 操作结果
*/
void deleteFile(@NonNull DeleteFileParam param, DeleteCallback callback);
/**
* 格式化存储器
*
* @param sdCardBean 存储器信息
* @param callback 操作结果
*/
void formatStorage(@NonNull SDCardBean sdCardBean, OnFlowStateCallback<Integer> callback);
}
3.7.14 SPDIF操作
public interface ISPDIFOp {
/**
* 获取状态信息(播放状态+音源)
*
* @param device 操作设备
* @param callback 结果回调
*/
void getSPDIFInfo(BluetoothDevice device, OnRcspActionCallback<Boolean> callback);
/**
* 设置播放状态
*
* @param device 操作设备
* @param spdifPlayStatusInfo 播放状态信息
* @param callback 结果回调
*/
void setSPDIFPlayStatusInfo(BluetoothDevice device, SPDIFPlayStatusInfo spdifPlayStatusInfo, OnRcspActionCallback<Boolean> callback);
/**
* 设置音源
*
* @param device 操作设备
* @param spdifAudioSourceInfo 音源信息
* @param callback 结果回调
*/
void setSPDIFSPDIFAudioSourceInfo(BluetoothDevice device, SPDIFAudioSourceInfo spdifAudioSourceInfo, OnRcspActionCallback<Boolean> callback);
}
3.8 RCSP事件监听器
public abstract class OnRcspEventListener {
/**
* 设备模式改变回调
*
* @param device 蓝牙设备
* @param mode 设备当前模式
*/
public void onDeviceModeChange(BluetoothDevice device, int mode) {
}
/**
* 设备系统音量改变回调
*
* @param device 蓝牙设备
* @param volume 设备系统音量
*/
public void onVolumeChange(BluetoothDevice device, VolumeInfo volume) {
}
/**
* 设备EQ信息改变回调
*
* @param device 蓝牙设备
* @param eqInfo EQ信息
*/
public void onEqChange(BluetoothDevice device, EqInfo eqInfo) {
}
/**
* 设备外接存储器改变回调
*
* @param device 蓝牙设备
* @param storageInfo 设备信息
*/
public void onDevStorageInfoChange(BluetoothDevice device, DevStorageInfo storageInfo) {
}
/**
* 设备支持文件格式回调
*
* @param device 蓝牙设备
* @param fileFormat 设备支持文件格式
*/
public void onFileFormatChange(BluetoothDevice device, String fileFormat) {
}
/**
* 音乐歌曲改变回调
*
* @param device 蓝牙设备
* @param nameInfo 音乐信息
*/
public void onMusicNameChange(BluetoothDevice device, MusicNameInfo nameInfo) {
}
/**
* 音乐播放状态回调
*
* @param device 蓝牙设备
* @param statusInfo 音乐状态
*/
public void onMusicStatusChange(BluetoothDevice device, MusicStatusInfo statusInfo) {
}
/**
* 播放模式改变回调
*
* @param device 蓝牙设备
* @param playModeInfo 播放模式信息
*/
public void onPlayModeChange(BluetoothDevice device, PlayModeInfo playModeInfo) {
}
/**
* 设备电量改变回调
*
* @param device 蓝牙设备
* @param batteryInfo 电量信息
*/
public void onBatteryChange(BluetoothDevice device, BatteryInfo batteryInfo) {
}
/**
* 外接设备的状态回调
*
* @param device 蓝牙设备
* @param isPlay 是否播放
*/
public void onAuxStatusChange(BluetoothDevice device, boolean isPlay) {
}
/**
* FM频道改变回调
*
* @param device 蓝牙设备
* @param channels 频道信息列表
*/
public void onFmChannelsChange(BluetoothDevice device, List<ChannelInfo> channels) {
}
/**
* FM状态信息改变回调
*
* @param device 蓝牙设备
* @param fmStatusInfo FM状态信息
*/
public void onFmStatusChange(BluetoothDevice device, FmStatusInfo fmStatusInfo) {
}
/**
* 闹钟列表更新回调
*
* @param device 蓝牙设备
* @param alarmListInfo 闹钟列表
*/
public void onAlarmListChange(BluetoothDevice device, AlarmListInfo alarmListInfo) {
}
/**
* 默认闹钟铃声列表
*
* @param device 蓝牙设备
* @param bells 默认闹钟铃声列表
*/
public void onAlarmDefaultBellListChange(BluetoothDevice device, List<DefaultAlarmBell> bells) {
}
/**
* 闹钟提醒回调
*
* @param device 蓝牙设备
* @param alarmBean 闹钟信息
*/
public void onAlarmNotify(BluetoothDevice device, AlarmBean alarmBean) {
}
/**
* 闹钟停止回调
*
* @param device 蓝牙设备
* @param alarmBean 闹钟信息
*/
public void onAlarmStop(BluetoothDevice device, AlarmBean alarmBean) {
}
/**
* 频道发射回调
*
* @param device 蓝牙设备
* @param frequency 频点
*/
public void onFrequencyTx(BluetoothDevice device, float frequency) {
}
/**
* 外设模式改变回调
*
* @param device 蓝牙设备
* @param mode 外设模式
*/
public void onPeripheralsModeChange(BluetoothDevice device, int mode) {
}
/**
* 外设连接状态改变回调
*
* @param device 蓝牙设备
* @param connect 是否连接
* @param mac 设备mac地址
*/
public void onPeripheralsConnectStatusChange(BluetoothDevice device, boolean connect, String mac) {
}
/**
* ID3歌曲info回调
*
* @param device 蓝牙设备
* @param id3MusicInfo id3歌曲信息
*/
public void onID3MusicInfo(BluetoothDevice device, ID3MusicInfo id3MusicInfo) {
}
/**
* 高低音变化回调
*
* @param device 蓝牙设备
* @param high 高音
* @param bass 低音
*/
public void onHighAndBassChange(BluetoothDevice device, int high, int bass) {
}
/**
* Eq预设值变化
*
* @param device 蓝牙设备
* @param eqPresetInfo 预设值
*/
public void onEqPresetChange(BluetoothDevice device, EqPresetInfo eqPresetInfo) {
}
/**
* 通话状态回调
*
* @param device 蓝牙设备
* @param status 通话状态
*/
public void onPhoneCallStatusChange(BluetoothDevice device, int status) {
}
/**
* 拓展功能回调
*
* @param device 蓝牙设备
* @param type 拓展功能
* @param data 拓展有效数据
*/
public void onExpandFunction(BluetoothDevice device, int type, byte[] data) {
}
/**
* 混响参数回调
*
* @param device 蓝牙设备
* @param param 混响参数
*/
public void onReverberation(BluetoothDevice device, ReverberationParam param) {
}
/**
* 动态限幅参数回调
*
* @param device 蓝牙设备
* @param param 动态限幅参数
*/
public void onDynamicLimiter(BluetoothDevice device, DynamicLimiterParam param) {
}
/**
* 灯光控制回调
*
* @param device 蓝牙设备
* @param lightControlInfo 灯光控制信息
*/
public void onLightControlInfo(BluetoothDevice device, LightControlInfo lightControlInfo) {
}
/**
* 声卡EQ信息回调
*
* @param device 蓝牙设备
* @param eqInfo EQ信息
*/
public void onSoundCardEqChange(BluetoothDevice device, EqInfo eqInfo) {
}
/**
* 声卡状态回调
*
* @param device 蓝牙设备
* @param mask 掩码
* @param values 数据
*/
public void onSoundCardStatusChange(BluetoothDevice device, long mask, byte[] values) {
}
/**
* 当前噪声处理模式信息
*
* @param device 设备对象
* @param voiceMode 噪声处理模式
*/
public void onCurrentVoiceMode(BluetoothDevice device, VoiceMode voiceMode) {
}
/**
* 设备所有噪声处理模式信息
*
* @param device 设备对象
* @param voiceModes 噪声处理模式信息列表
*/
public void onVoiceModeList(BluetoothDevice device, List<VoiceMode> voiceModes) {
}
/**
* 辅听验配信息回调
*
* @param device 设备对象
* @param hearingAssistInfo 辅听验配信息
*/
public void onHearingAssistInfo(BluetoothDevice device, HearingAssistInfo hearingAssistInfo) {
}
/**
* 辅听声道状态回调
*
* @param device 设备对象
* @param hearingChannelsStatus 辅听声道状态
*/
public void onHearingChannelsStatus(BluetoothDevice device, HearingChannelsStatus hearingChannelsStatus) {
}
/**
* 声学功能回调
*
* @param device 设备对象
* @param voiceFunc 声学功能数据
*/
public void onVoiceFunctionChange(BluetoothDevice device, VoiceFunc voiceFunc) {
}
/**
* 设备双连状态回调
*
* @param device 设备对象
* @param state 设备双连状态信息
*/
public void onDoubleConnectionChange(BluetoothDevice device, DoubleConnectionState state) {
}
/**
* 设备已连接的手机蓝牙信息回调
*
* @param device 设备对象
* @param info 设备已连接的手机蓝牙信息
*/
public void onConnectedBtInfo(BluetoothDevice device, ConnectedBtInfo info) {
}
}
3.9 TWS事件监听器
public abstract class OnTwsEventListener {
/**
* 设备广播信息回调
*
* @param device 蓝牙设备
* @param broadcast 广播信息
*/
public void onDeviceBroadcast(BluetoothDevice device, DevBroadcastMsg broadcast) {
}
/**
* 设备设置信息回调
*
* @param device 蓝牙设备
* @param mask 掩码
* @param dataInfo 设置信息
*/
public void onDeviceSettingsInfo(BluetoothDevice device, int mask, ADVInfoResponse dataInfo) {
}
/**
* TWS状态回调
*
* @param device 蓝牙设备
* @param isTwsConnected 是否TWS连接
*/
public void onTwsStatusChange(BluetoothDevice device, boolean isTwsConnected) {
}
/**
* 设备请求操作回调
*
* @param device 蓝牙设备
* @param op 请求操作
*/
public void onDeviceRequestOp(BluetoothDevice device, int op) {
}
}
3.10 操作结果回调
public interface OnRcspActionCallback<T> {
/**
* 成功回调
* @param message 信息
*/
void onSuccess(BluetoothDevice device, T message);
/**
* 失败回调
* @param error 错误信息
*/
void onError(BluetoothDevice device, BaseError error);
}