Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Device disconnected after write #1179

Open
4 tasks done
kurogalaxy opened this issue Mar 13, 2024 · 11 comments
Open
4 tasks done

Device disconnected after write #1179

kurogalaxy opened this issue Mar 13, 2024 · 11 comments
Labels

Comments

@kurogalaxy
Copy link

kurogalaxy commented Mar 13, 2024

Prerequisites

  • I checked the documentation and FAQ without finding a solution
  • I checked to make sure that this issue has not already been filed
  • I'm sure that question is related to the library itself and not Bluetooth Low Energy or Classic in general. If that so, please post your question on StackOverflow.
  • I'm running the latest version

Question

After scanning and connecting the device, I call the following

await plxBleManager .writeCharacteristicWithoutResponseForDevice( deviceId, serviceUUIDs.server, serviceUUIDs.write, data, ) .then(algo => { console.log('Write successful'); }) .catch(error => { console.log('Error', error); });

The first time I run the code I get the 'write successful' text but second time returns a
[BleError: Device D8:3A:DD:83:AE:DC is not connected]

I also have the following method but it won't return anything at all

const onDisconnect = (device: Device) => { device.onDisconnected(error => { console.log('device was disconnected', error); }); };

Am I missing something? Do I need to call another method before doing every write? I'd really appreciate any help.

Testing on Android 13.

@EmmaZachara
Copy link
Collaborator

Hi @kurogalaxy,
Thank you for raising this question. We will review it and get back to you soon.

@dominik-czupryna-withintent
Copy link
Collaborator

Yes, we currently have a problem with the onDisconnect listener, especially when the disconnection is initiated from the BLE device, we are working on it.

If you have called functions for:

  • connection to the device
  • discovering characteristics
    you should not experience any problems sending data.

Could you show:

  • how do you declared plxBleManager
  • how you call the function to connect to the device (parameters)
  • the logs from Logcat?

@nhaduongc
Copy link

I got the current issue now. when I sync data from my BLE device, the BLE device send data to the app(Android) the progress take arround 10 - 30 second. But in the latest version 3.1.2 It's fire disconnection event in this case. I'm not sure it is the same case. look like when the BLE device do some busy task. that make the library fire disconnect event

@fustaro
Copy link

fustaro commented Apr 1, 2024

same happening to me after updating from 2.0.3 to 3.1.2 on Android, module fires disconnected event a few seconds after connecting.

@fustaro
Copy link

fustaro commented Apr 1, 2024

for me it basically disconnects after the timeout period, despite it actually connecting successfully and I can send and receive data fine before it happens. E.g. below will connect fine for 30 seconds then disconnect for no reason.

const connectedDevice = await this.manager.connectToDevice(device.id, {
      timeout: 30000
});

@ex3ndr
Copy link

ex3ndr commented Apr 29, 2024

I have the same problem, in my case iOS works fine, but Android disconnects.

@EmmaZachara
Copy link
Collaborator

@fustaro, @ex3ndr, @nhaduongc
Thanks for your patience; we'll need a bit more time to get back to you with a solution.

@PierreHenri123
Copy link

Same problem here. When I try char.writeWithResponse, it fails randomly telling me that device has been disconnected. IOS and Android

@jklimke
Copy link

jklimke commented Jun 3, 2024

Is there any progress here ? I am also experiencing a disconnect after writing and leading several characteristics (so somehow a heavy read). Unfortunately i have to write a little piece of data after each connect.

@gamilrr
Copy link

gamilrr commented Jun 22, 2024

Any update on this issue?. I could make it work putting a small delay (around 50ms) before sending every chunk of data, it happens to me with the writeWithResponse call.

@mikasius
Copy link

Any update on this issue? The same issue, disconnects after 20-30 seconds on Android.

  • Android 12
  • React-Native 0.74.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants