Open vipien opened 5 months ago
Hello @vipien The problem you mention seems to be related to #1197 . Unfortunately, I have a problem with reproducing it because it does not occur on any device I have checked. Could you try to connect to this printer using our example app and confirm that the problem still occurs? Here is the branch where we try to reproduce this issue https://github.com/dotintent/react-native-ble-plx/blob/fix/1197_device_automatically_disconnecting/example/src/screens/MainStack/DisconnectBeforeWrite/DisconnectBeforeWrite.tsx Have you tried connecting to the device using other applications, e.g. nRF Connect? It is possible that the device has a disconnection mechanism on its side when there is no activity after connect.
Hi! Thanks for taking the time to check it.
We tried to run the example app and we could not make it work. Is there a guide that we can follow?
We have also tested it better. We know that is exactly after 30 seconds. It also happens in the Google Pixel we have for testing, not only in iPhones.
The behavior is the same, we search, connect, and keep the app alive. If we do not print in the next 30 seconds it disconnects.
We also know this is not a printer problem because we can connect with another app and it remains connected without printing.
I hope this information is useful for you to find out why. For now we added a wait with 3 seconds after the connection is made and we print a "Connected to printer" label, but we don't like this solution.
What problems do you have with example app? I'm aware of one issue with iOS and to solve it you would have to remove .xcode.env.local
, fix will be added in next patch.
Changing the time span of waiting without performing any operations didn't yield results for me - connection is still open after 40 seconds, tested on iOS
What is another app? Can you confirm that it's not performing any operations to sustain the connection?
First of all I would like to confirm that it's not the printer that is closing connection. To do so I would need you to adjust our example app disconnectBeforeWrite to work with your printer, or test your app agains different device to confirm that connection also will be dropped. Preferably it would be both as one does not confirm the other.
Additionally system level logs from xCode/Logcat could provide more insight. You can collect logs after using setLogLevel with LogLevel.Verbose
. You can reduce the information clutter by filtering out logs for example for Logcat it could be package:mine (tag:BluetoothGatt | tag:ReactNativeJS | RxBle)
Hi @vipien Did you manage to fix the issue? If not, can I help in any way?
Prerequisites
Expected Behavior
We connect to the device and we remain connected even if we do not print a label.
Current Behavior
We connect to the device, in this case a Zebra Printer, and after some seconds (30) it automatically disconnect. We do not receive any error on the onDisconnected listener. If we connect and print (write characteristic) before disconnecting, it remains connected. We do not let the phone turn off the screen.
Library version
3.2.0
Device
Iphone 13 (17.5.1) Google Pixel
Environment info
Steps to reproduce
Formatted code sample or link to a repository
Relevant log output
Additional information
No response