expo-ble模块测试demo 联调BLE模块

This commit is contained in:
Yudi Xiao
2025-12-10 12:39:41 +08:00
parent 41f4080264
commit d2dcd39411
17 changed files with 391 additions and 2069 deletions

View File

@@ -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);
}