react-native-ble-plx
react-native-ble-plx copied to clipboard
π Long read characteristic
Prerequisites
- [X] I checked the documentation and FAQ without finding a solution
- [X] I checked to make sure that this issue has not already been filed
Expected Behavior
The readCharacteristicForService should perform multiple read (with offset) if the value size is bigger than the MTU.
Current Behavior
The read function performs one request, and the read value has MTU as the maximum size.
Library version
3.4.0
Device
Android 12 and iOS 17.4.1
Environment info
System:
OS: macOS 14.6.1
CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
Memory: 40.66 MB / 8.00 GB
Shell:
version: β5.9β
path: /bin/zsh
Binaries:
Node:
version: 21.7.1
path: ~/.nvm/versions/node/v21.7.1/bin/node
Yarn:
version: 1.22.19
path: ~/.yarn/bin/yarn
npm:
version: 10.8.0
path: ~/.nvm/versions/node/v21.7.1/bin/npm
Watchman:
version: 2024.03.18.00
path: /usr/local/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.1
- iOS 18.1
- macOS 15.1
- tvOS 18.1
- visionOS 2.1
- watchOS 11.1
Android SDK:
API Levels:
- β23"
- β28β
- β29"
- β30β
- β31"
- β32β
- β33"
- β34β
Build Tools:
- 28.0.3
- 30.0.2
- 30.0.3
- 31.0.0
- 32.0.0
- 33.0.0
- 33.0.1
- 33.0.2
- 34.0.0
System Images:
- android-27 | Google Play Intel x86 Atom
- android-28 | Google Play Intel x86 Atom
- android-29 | Google APIs Intel x86 Atom
- android-30 | Intel x86_64 Atom
- android-30 | Google APIs Intel x86 Atom
- android-30 | Google APIs Intel x86_64 Atom
- android-30 | Google Play Intel x86 Atom
- android-30 | Google Play Intel x86 Atom_64
- android-31 | Intel x86_64 Atom
- android-31 | Google APIs Intel x86_64 Atom
- android-31 | Google Play Intel x86_64 Atom
- android-32 | Google APIs Intel x86_64 Atom
- android-32 | Google Play Intel x86 Atom_64
- android-33 | Google APIs Intel x86_64 Atom
- android-UpsideDownCakePrivacySandbox | Google Play ARM 64 v8a
- android-UpsideDownCakePrivacySandbox | Google Play Intel x86_64 Atom
Android NDK: 22.1.7171670
IDEs:
Android Studio: 2024.1 AI-241.15989.150.2411.11948838
Xcode:
version: 16.1/16B40
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.10
path: /usr/local/opt/openjdk@17/bin/javac
Ruby:
version: 2.6.10
path: /usr/bin/ruby
npmPackages:
β@react-native-community/cliβ: Not Found
react:
installed: 18.2.0
wanted: 18.2.0
react-native:
installed: 0.74.5
wanted: 0.74.5
react-native-macos: Not Found
npmGlobalPackages:
β*react-native*β: Not Found
Android:
hermesEnabled: true
newArchEnabled: false
iOS:
hermesEnabled: true
newArchEnabled: false
Steps to reproduce
- β¦
- β¦
Formatted code sample or link to a repository
try {
const isConnected = await device.isConnected()
if (!isConnected) {
await manager.connectToDevice(device.id)
store.dispatch(connectBleDevice({ device }))
try {
await manager.requestMTUForDevice(device.id, MTU)
await manager.requestConnectionPriorityForDevice(device.id, ConnectionPriority.High)
} catch (e) {
log(β[connectToDevice] mtu error:β, e)
}
} else {
store.dispatch(connectBleDevice({ device }))
await manager.requestMTUForDevice(device.id, MTU)
}
} catch (e) {
log(β[connectToDevice]β, e)
await connect()
}
try {
const connected = await device.isConnected()
if (connected) {
await device.discoverAllServicesAndCharacteristics()
const read = await device.readCharacteristicForService(
SERVICE_UUID,
char
)
return read.value
}
} catch (e) {
log(β[readFromGateway] β, e)
}
Relevant log output
No relevant log
Additional information
No response
Hello @ezamp. Thank you for raising this topic. I'll add it to the backlog for future enhancements. If you'd like to contribute, pull requests are always welcome!