forked from yudi_xiao/expo-ble-app-demo
expo-ble模块测试demo 联调BLE模块 take 3 添加跟多log
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import {BleClient} from '../core/BleClient';
|
||||
import {ProtocolManager} from '../protocol/ProtocolManager';
|
||||
import {BLE_UUIDS, FRAME_CONSTANTS} from '../protocol/Constants';
|
||||
import {BLE_UUIDS, COMMAND_TYPES, FRAME_CONSTANTS} from '../protocol/Constants';
|
||||
import {ProtocolFrame} from '../protocol/types';
|
||||
import {Buffer} from 'buffer';
|
||||
import {Subscription} from 'react-native-ble-plx';
|
||||
@@ -139,7 +139,7 @@ export class BleProtocolService {
|
||||
}
|
||||
}
|
||||
|
||||
public async send(deviceId: string, type: number, data: object | ArrayBuffer, onProgress?: (progress: number) => void): Promise<void> {
|
||||
public async send(deviceId: string, type: COMMAND_TYPES, data: object | ArrayBuffer, onProgress?: (progress: number) => void): Promise<void> {
|
||||
let payload: Uint8Array;
|
||||
if (data instanceof ArrayBuffer) {
|
||||
payload = new Uint8Array(data);
|
||||
|
||||
@@ -15,7 +15,7 @@ export class FileTransferService {
|
||||
return FileTransferService.instance;
|
||||
}
|
||||
|
||||
public async transferFile(deviceId: string, filePath: string, type: number, onProgress?: (progress: number) => void): Promise<void> {
|
||||
public async transferFile(deviceId: string, filePath: string, type: COMMAND_TYPES, onProgress?: (progress: number) => void): Promise<void> {
|
||||
try {
|
||||
const response = await fetch(filePath);
|
||||
if (!response.ok) {
|
||||
|
||||
Reference in New Issue
Block a user