更新记录
1.0.0(2025-01-15)
1.0.0
平台兼容性
Vue2 | Vue3 |
---|---|
× | √ |
App | 快应用 | 微信小程序 | 支付宝小程序 | 百度小程序 | 字节小程序 | QQ小程序 |
---|---|---|---|---|---|---|
HBuilderX 4.34,Android:4.4,iOS:9,HarmonyNext:支持 | × | × | × | × | × | × |
钉钉小程序 | 快手小程序 | 飞书小程序 | 京东小程序 | 鸿蒙元服务 |
---|---|---|---|---|
× | × | × | × | × |
H5-Safari | Android Browser | 微信浏览器(Android) | QQ浏览器(Android) | Chrome | IE | Edge | Firefox | PC-Safari |
---|---|---|---|---|---|---|---|---|
× | × | × | × | × | × | × | × | × |
鸿蒙中单独调用
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