diff --git a/README.md b/README.md index df7326a..33bd40b 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,26 @@ 安装 bun https://bun.com/docs/installation#windows -```bash +```powershell powershell -c "irm bun.sh/install.ps1|iex" ``` +检查bun是否正确安装 + +```powershell +& "$env:USERPROFILE\.bun\bin\bun" --version +``` + +添加bun到系统路径 + +```powershell +[System.Environment]::SetEnvironmentVariable( + "Path", + [System.Environment]::GetEnvironmentVariable("Path", "User") + ";$env:USERPROFILE\.bun\bin", + [System.EnvironmentVariableTarget]::User +) +``` + 安装项目依赖 ```bash diff --git a/ble/core/BleClient.ts b/ble/core/BleClient.ts index 1aea076..f72a540 100644 --- a/ble/core/BleClient.ts +++ b/ble/core/BleClient.ts @@ -1,6 +1,7 @@ import {BleManager, Device, Characteristic, BleError as PlxError, ScanOptions} from 'react-native-ble-plx'; import {Platform, PermissionsAndroid} from 'react-native'; import {BleDevice, ConnectionState, BleError, ScanResult} from './types'; +import {BLE_UUIDS} from "@/ble"; export class BleClient { private static instance: BleClient; @@ -90,7 +91,8 @@ export class BleClient { if (!this.manager) throw new Error('BLE not supported on web'); try { this.emit('connectionStateChange', {deviceId, state: ConnectionState.CONNECTING}); - const device = await this.manager.connectToDevice(deviceId); + const device = await this.manager.connectToDevice(deviceId, {requestMTU: BLE_UUIDS.REQUEST_MTU}); + console.log("Connected to device with MTU = ", device.mtu); this.connectedDevice = await device.discoverAllServicesAndCharacteristics(); this.emit('connectionStateChange', {deviceId, state: ConnectionState.CONNECTED}); diff --git a/ble/protocol/Constants.ts b/ble/protocol/Constants.ts index 95b07ca..7a917b7 100644 --- a/ble/protocol/Constants.ts +++ b/ble/protocol/Constants.ts @@ -6,6 +6,7 @@ export const BLE_UUIDS = { BROADCAST_CHARACTERISTIC: "000002c1-0000-1000-8000-00805f9b34fb", WRITE_CHARACTERISTIC: '000002c5-0000-1000-8000-00805f9b34fb', READ_CHARACTERISTIC: '000002c6-0000-1000-8000-00805f9b34fb', + REQUEST_MTU: 517, } as const; export const FRAME_CONSTANTS = {