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

when "OnConnectionStateChange: GattStatus: InsufficientAuthorization" is shown, the ble will hang forever #831

Closed
ygl-rg opened this issue Mar 25, 2024 · 5 comments

Comments

@ygl-rg
Copy link

ygl-rg commented Mar 25, 2024

To help us fix your issue, please provide the information in the below template. If something causes a crash, provide as much information as you can gather.
Just imagine: we do not know what you are doing!

Note: There is often little we can do without a minimal reproducible sample of the issue, so please provide that in a standalone git repository and link it here.

Steps to reproduce

  1. connect to a ble device

  2. walk away until it disconnects, and go back reconnect it again

  3. after several times, the trace will print "OnConnectionStateChange: GattStatus: InsufficientAuthorization"

Expected behavior

dispose the device and scan again, everything should be fine.

Actual behavior

the ble is mailfunctional, the only way to bring it back is to restart the app.

Crashlog

Adapter: Already cancelled scan.
2024-03-25 16:31:07.285 +08:00 [INF] connect needs 0.0044007 secs
2024-03-25 16:31:07.305 +08:00 [INF] XXX connected
2024-03-25 16:31:07.307 +08:00 [INF] Characteristic.StartUpdates
2024-03-25 16:31:08.806 +08:00 [INF] OnDescriptorWrite: 00-00
2024-03-25 16:31:08.808 +08:00 [INF] References of parent device and gatt callback device equal? TRUE
2024-03-25 16:31:08.808 +08:00 [INF] OnConnectionStateChange: GattStatus: InsufficientAuthorization
2024-03-25 16:31:08.808 +08:00 [INF] References of parent device gatt and callback gatt equal? TRUE
2024-03-25 16:31:08.811 +08:00 [ERR] disconnect dongle error
System.Exception: GattStatus: 133
at Plugin.BLE.Abstractions.Utils.TaskBuilder.d__111[[System.Boolean, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext() at Plugin.BLE.Abstractions.Utils.TaskBuilder.<FromEvent>d__93[[System.Boolean, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.EventHandler`1[[Plugin.BLE.Android.CallbackEventArgs.DescriptorCallbackEventArgs, Plugin.BLE, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.EventHandler, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
at Plugin.BLE.Android.Characteristic.StopUpdatesNativeAsync(CancellationToken cancellationToken)
2024-03-25 16:31:08.813 +08:00 [INF] Disconnected 'XXX' by lost connection
2024-03-25 16:31:08.813 +08:00 [INF] DisconnectedPeripheral by lost signal: XXX
2024-03-25 16:31:08.813 +08:00 [INF] Removed device from discovered devices list: XXX
2024-03-25 16:31:08.831 +08:00 [INF] [Warning]: Can't disconnect XXX. Gatt is null.
2024-03-25 16:33:05.203 +08:00 [INF] Adapter: Already cancelled scan.

Configuration

Version of the Plugin: e.g. 3.0.0/3.1.0-beta

Platform: e.g. Android 11, 12 and 13

Device: e.g. Samsung S21, Realme 9i, Redmi 9T

@smsissuechecker
Copy link

Hi @ygl-rg,

I'm the friendly issue checker.
Thanks for using the issue template 🌟
I appreciate it very much. I'm sure, the maintainers of this repository will answer, soon.

@ygl-rg
Copy link
Author

ygl-rg commented Mar 26, 2024

I noticed when "[Warning]: Can't disconnect XXX. Gatt is null." is thrown, the BLE won't work anymore.

Do you have an idea what cause the gatt is null?

@axa88
Copy link

axa88 commented Apr 8, 2024

2024-03-25 16:31:08.808 +08:00 [INF] OnConnectionStateChange: GattStatus: InsufficientAuthorization

what happens if you provide sufficient credentials?

@ygl-rg
Copy link
Author

ygl-rg commented Apr 11, 2024

2024-03-25 16:31:08.808 +08:00 [INF] OnConnectionStateChange: GattStatus: InsufficientAuthorization

what happens if you provide sufficient credentials?

I have no idea. It looks like this issue is related to some old samsung phones.

@axa88
Copy link

axa88 commented Apr 12, 2024

I have no idea. It looks like this issue is related to some old samsung phones.

How so?
If so how does that make it a library issue?

It appears to me that as soon as you attempt to Write Characteristic/Descriptor, it is telling you this/these have security enabled and require proper credentials set. To which you have not established thus resulting in the disconnect as reported with an error of InsufficientAuthorization.

Not sure this is an issue whatsoever

@ygl-rg ygl-rg closed this as completed May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants