更新记录

1.0.3(2025-05-19) 下载此版本

1.0.3

1.0.2(2025-03-24) 下载此版本

1.0.2

1.0.1(2025-02-19) 下载此版本

1.0.1

查看更多

平台兼容性

uni-app x

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

注意: 插件过滤了uuid,如果需要请在config.uts自行添加

隐私、权限声明

1. 本插件需要申请的系统权限列表:

LOCATION ACCESS_BLUETOOTH

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

下载

许可协议

MIT协议

暂无用户评论。

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问