更新记录
1.0.5(2025-09-10) 下载此版本
修复部分console导致的编译报错
1.0.4(2025-08-30) 下载此版本
1.0.4 修复频繁快速创建蓝牙连接时容易失败的bug
1.0.3(2025-05-19) 下载此版本
1.0.3
查看更多平台兼容性
uni-app(4.62)
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | × | × | √ | √ | - | - | √ |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
- | - | - | - | - | - | - | - | - | - | - |
uni-app x(4.62)
Chrome | Safari | Android | iOS | 鸿蒙 | 微信小程序 |
---|---|---|---|---|---|
- | - | - | - | √ | - |
鸿蒙中单独调用
import { createBLEConnection } from '@/uni_modules/srh-BluetoothAdapter';
createBLEConnection({
deviceId: 'xxx',
success: (res) => {
},
fail:(e) => {
}
})
兼容uniapp写法, 新建文件index.ts
import { createBLEConnection } from '@/uni_modules/srh-BluetoothAdapter';
interface UniExtensions {
createBLEConnection : typeof createBLEConnection;
}
const $uni : UniExtensions = {
createBLEConnection
};
export default $uni;
另建一个main.ts文件
// #ifdef APP-HARMONY
import $uni from './index.ts';
// #endif
// #ifdef APP-PLUS
const $uni = uni;
// #endif
export { $uni }
页面中导入main.ts
import {$uni} from '@/main.ts';
$uni.createBLEConnection({
deviceId: 'xxx',
success: (res) => {
},
fail:(e) => {
}
})
支持的API
openBluetoothAdapter,
closeBLEConnection,
closeBluetoothAdapter,
onBluetoothDeviceFound,
createBLEConnection,
getBLEDeviceCharacteristics,
getBLEDeviceServices,
getBluetoothDevices,
notifyBLECharacteristicValueChange,
onBLECharacteristicValueChange,
onBLEConnectionStateChange,
setBLEMTU,
startBluetoothDevicesDiscovery,
stopBluetoothDevicesDiscovery,
writeBLECharacteristicValue,
getBLEDeviceRSSI
注意: 1、插件过滤了uuid,如果需要请在config.uts自行添加 2、插件需要定位权限,请自行配置并获取授权 3、插件需要蓝牙权限,请自行配置并获取授权,获取蓝牙授权可使用srh-openPermission插件 4、权限需要在使用插件前先行获取授权