expo-ble模块测试demo 联调BLE模块
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import {BleClient} from '../core/BleClient';
|
||||
import {ProtocolManager} from '../protocol/ProtocolManager';
|
||||
import {BLE_UUIDS} from '../protocol/Constants';
|
||||
import {BLE_UUIDS, FRAME_CONSTANTS} from '../protocol/Constants';
|
||||
import {ProtocolFrame} from '../protocol/types';
|
||||
import {Buffer} from 'buffer';
|
||||
import {Subscription} from 'react-native-ble-plx';
|
||||
@@ -156,6 +156,7 @@ export class BleProtocolService {
|
||||
console.debug(`Writing frame ${i + 1}/${total}, length = ${frame.length}`);
|
||||
const base64 = Buffer.from(frame).toString('base64');
|
||||
const result = await this.client.write(deviceId, BLE_UUIDS.SERVICE, BLE_UUIDS.WRITE_CHARACTERISTIC, base64, false);
|
||||
await new Promise(resolve => setTimeout(resolve, FRAME_CONSTANTS.FRAME_INTERVAL));
|
||||
if (onProgress) {
|
||||
onProgress((i + 1) / total);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user