question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent connection to a device not visible in scan

See original GitHub issue

Mobile Device Environment

  • Device: [Samsung Galaxy A8]
  • OS: [Android 9 (Pie)]

Application Environment

  • React Native version: [v0.63.3]
  • RN Bluetooth Classic version: [v1.60.0-rc.20]

Describe the bug Manually connecting to a specific macAddress seems to be inconsistent. Sometimes when it connects it doesn’t actually pass along any data through the bluetooth connection even though the connect/disconnect/writeToDevice returns true as if it were successful.

The app I’m developing needs to connect to a specific macAddress which is always known beforehand (so I don’t need to scan/startDiscovery). So to connect I just call the RNBluetoothClassic.connect(macAddress). However sometimes even when the connection is successful (RNBluetoothClassic.connect(address) has returned true and when checking RNBluetoothClassic.isDeviceConnected(address) it also returns true) none of the data transmissions functions (disconnect, writeToDevice) actually transmits any data to the receiver, even though they return true as if they were successfully called.

I have used the xCode bluetooth packet logger to view incoming transmissions from my macBook, which is how I can see that it sometimes doesn’t send anything. What I’ve noticed from the packet logger is that it sends a “Connection Request” but as soon as it has successfully connected it sends a “Disconnection Request” and then another “Connection Request”, I’m not sure if it could be that it has a reference to the closed socket (just guessing here, I have no idea how the BT works behind the scenes).

Whats interesting is that it sometimes work. For example if I reinstall the app and connect and send messages I can see that everything works and is transmitted correctly. But if I disconnect and reconnect it will never work to writeToDevice. None of the methods throws any errors and they all return true as if they were successfully accomplished which is why I’m so confused.

Worth noting is that the device I’m connecting to is not displayed in the discovered devices whenever I call a startDiscovery. However the device is in the pairedDevice’s list and it successfully works to connect it.

To Reproduce

  1. Manually connect to a computer(macBook/macMini) by its macAddress.
  2. Try to send a message to the device (sometimes works)
  3. Disconnect
  4. Reconnect
  5. Send another message to the device (never works)

Expected behavior It shouldn’t say that the connection and writeMessage are successful when nothing is sent.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kenjdavidsoncommented, Feb 7, 2022

With regard to your other question, I would use a more standard method of communication. A regular socket using normal communication over a network. Or use BLE instead of RFCOMM.

1reaction
kenjdavidsoncommented, Feb 7, 2022

Yes. It will definitely be hit or miss while attempting to connect from React Native (this library) to a Mac/IOS device. This is solely MFi related. I’m going to close this off since it’s working as designed as per the documentation and the limitations of MFi.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fixed: My PC cannot connect to my scanner - HELP!
First, make sure that the scanner is turned on and that the cable is properly connected. If the scanner is plugged into a...
Read more >
Scanner Is Not Working? Here's How To Fix It
Is My Scanner Connected to the PC? · Press the Windows + R key to open Run. · Type control printers to open...
Read more >
Exception message and behavior when device has gone and ...
If the device was not found, in the absence of the non-standard --experimental , a scan or other robust connection approach would be...
Read more >
How To Fix An Intermittent Internet Connection In Windows 10
To do this, right-click Start > Device Manager. Click Network Adapter to expand the category, right-click on your network card and select ...
Read more >
13 Tips to Troubleshoot Your Internet Connection - PCMag
1. Try Another Device or Website ... Start with the obvious: is the problem only happening on one device or all your devices?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found