Replies: 1 comment 5 replies
-
There is no way to change the connection options once a connection is established. When I was re-writing I didn't see that having much of a use case. Generally if you're working with serial devices, you have a well established communication protocol - so whether you're using a custom device or a vendor device you should know well ahead of time what is required to communicate. This means that if for some reason your device is changing it's own protocol, you should be disconnecting and re-connecting with the new settings. The standard options are documented https://kenjdavidson.com/react-native-bluetooth-classic/react-native/rn-bluetooth-device/#connect as well as available in the source, of which you have full access. You have a
You should NOT be using both methods at the same time, as the read method becomes pretty pointless. The BluetoothClassicExample application has both methods within the Your |
Beta Was this translation helpful? Give feedback.
-
First of all I wanted to thank you for this project. I've used it to send commands between a phone(Android OS) and a device with a Bluetooth adapter.
I'm using react-native-bluetooth-classic 1.60.x version. However once the connection is made using
await RNBluetoothClassic.connectToDevice(address: someAddress, options?: StandardOptions);
how can the DELIMITER and DEVICE_CHARSET be changed? What are the StandardOptions and if no options are given?The reason I asked is because I'm expecting certain ASCII characters at the buffer after a given command but I'm only getting "null" or "0 bytes available"
This is what I'm able to see from my terminal/console from the java side using 'adb logcat' :
05-17 16:39:49.478 21908 15031 D DelimitedStringDeviceConnectionImpl: Received 1 bytes from device 00:01:95:65:77:24
05-17 16:39:49.479 21908 15031 D DelimitedStringDeviceConnectionImpl: BluetoothEvent.READ listener is registered, providing data
Then as expected about 2 seconds later I know I'll get another character:
05-17 16:39:51.502 21908 15031 D DelimitedStringDeviceConnectionImpl: Received 1 bytes from device 00:01:95:65:77:24
05-17 16:39:51.502 21908 15031 D DelimitedStringDeviceConnectionImpl: BluetoothEvent.READ listener is registered, providing data
Reading manually:
let data = await RNBluetoothClassic.readFromDevice(someAddress);
here data = null. why? I do not know, if I can see there is a byte coming every 2 seconds.Any advice would be greatly appreciated.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions