-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
GATT error with 133 on onConnectionStateChange #18
Comments
Do you have any luck with this issue so far? I'm also having it on my OnePlus 5 (Android-N) + HM10 BLE module. Never had it on Nexus 5 (Android-M). All I managed to find on that matter is this: |
Hi @joe-skb7 My code
hope it may help you B-). |
Thanks for your suggestion, @prasanthmurugan . Unfortunately, this workaround doesn't help in my case. I will try to dig further, and will provide update here if I find something. |
I managed to fix my "status 133" error. In my case, it was happening in case when I was trying to connect to device just after doing The fix is in // Start GATT delay (wait for BLE scan to actually finish)
private static final long START_GATT_DELAY = 500; // msec
private final Handler mStartGattHandler = new Handler();
private final Runnable mStartGattRunnable = new Runnable() {
@Override
public void run() {
Intent gattServiceIntent = new Intent(DeviceControlActivity.this,
BluetoothLeService.class);
bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
}
};
@Override
public void onCreate(Bundle savedInstanceState) {
...
/* Start BluetoothLeService (GATT), so that mGattUpdateReceiver can receive events.
* Start with delay: wait for BLE scan to actually finish; this eliminates "status 133"
* connection error.
*/
mStartGattHandler.postDelayed(mStartGattRunnable, START_GATT_DELAY);
} So instead of calling Btw, after fixing that issue, I found out similar solution here. |
hey ,I always have the same problem,after serveral times test, I get the way to avoid "the status = 133": but I was no idea after "the status =133 " has happened, I tried to use " mBluetoothGatt.close()" but it not worked ,when I retry to scan the device ,it cannot find this device only I interrupt the power of the device, have someone meet this problem? |
@designerMichael Just for your information: adding the delay is just a workaround, and frankly is a dirty hack. It doesn't fix "status 133" error in all cases, just makes it harder to reproduce. This issue is a real curse... If somebody knows the proper solution (or at least a root cause for that error), please share it with us! |
add TRANSPORT_LE for Android greater than N. |
@pedrovarela86 Can you please share more details, like the link to relevant documentation? I wasn't able to find TRANSPORT_LTE mentioning anywhere... |
@joe-skb7 . ConnectGATT has 4 parameters. The last one is BluetoothDevice.TRANSPORT_LE. that will fix it. |
@pedrovarela86 Cool! Thank you very much for the input, Pedro, I'll try it! Found relevant article here: |
@pedrovarela86 Seems like your hint helped, finally I'm not seeing "status 133" error anymore... Thanks again, Pedro! |
I tried |
I am still fighting this shit. Similar to my above post, while debugging my non-trivial [location, maps, network, etc] private production app's use of my private BLE library and getting gatt 133 status errors, I went off and wrote a very simple [no location, maps, network, etc] stand-alone test/demo app in Kotlin to work with my same BLE library. Same phone, same BLE devices, different apps that use the same BLE library almost identically, consistent results that the production app fails and the test app succeeds. The production app used to work. I still have a theory that restoring my user account to the phone somehow restores some problematic meta-data that causes my production app to stop working. I have no idea [yet] why the only variation that matters for BLE connection success or failure is which of two seemingly identically performing apps the code runs from. |
@paulpv check your email. |
@pedrovarela86 Sorry to intrude, but if your mail has solution to this problem, can I have it too? Despite all tried workarounds, I'm still observing this "status 133" issue, and frankly it seems like some race condition inside of Android's Bluetooth framework (judging from how not related stuff can influence the bug reproducing)... If it's so, I'm not sure it could be fixed in app code. Do you have any new ideas? Thanks! |
@joe-skb7 I didn't want to post my code because it is private, and it doesn't work like a 100% android bluetooth stack is a pain in the ass and behaves different in every phone and android every android version. I kinda solved it making the connection calls on the main thread, and implemented some delays while communicating to the ble device. Still, my code it is not the best either, but at least. Nevertheless, check your email. |
Update: I have factory reset my phone (Nexus 6P) and added a virgin account to it and my production app still cannot connect to my BLE device, but my "stand-alone" test app (that uses my same library as the production app) can. I am leaning toward thinking there is some sort of working "timebomb" on the phone, that after a certain amount of time/usage the BLE stops working for some devices and/or for some apps. |
Occam's razor: Upon changing the batteries in my BLE devices the apps/library/software are performing much close to as expected. |
Guys, https://hellsoft.se/bluetooth-low-energy-on-android-part-1-1aa8bf60717d Hope this helps you. It did for me. |
@paulpv You could try installing the SweetBlue Toolbox app to check as well.. I'm doing similar testing at the moment and found error 133 with this library but not with the toolbox app. |
@paulpv in fact, on my Samsung S5 it seems to be related to the scan. When scan is active, I can connect without error (and very fast). When the scan has been stopped, the connection will not always establish. |
Another non solution that worked for me was to restart the BLE peripheral device i was trying to connect to. Hope it helps someone. |
Hi all, When errors are persistent (you only need to do this once if the software is properly managing the connections):
Additionally, setup a connection in your software as follows:
If found out that I can do a .startScan() and connectGatt() simultaneously, but connecting several devices with connectGatt() increased the amount of 133 statuses to almost 100%. I use android studio and have configured: minSdkVersion=21 and targetSdkVersion=28 Hope this helps some of you! |
I am having the same issue. I have create a BLE peripheral running on my Linux PC and trying to connect from an Android 7 tablet. Eventually I would like to make it a MIDI peripheral, but I cannot even connect. The funny thing is that other apps, (GATTBrowser, Bluetooth LE Gatt) can connect and browse my peripheral. The same happens from a Samsung Tab 2 and Moto G4. Has anyone reached a robust conclusion? |
I am having the same issue and solved by manually clear Bluetooth data & cache in "Setting -> Applications" Device: HUAWEI Mate10 (Android 8.0.0) Try to connect to my company's device but got 133. (But my app got SUCCESS before....) |
Hi. In my case When I start receive 133, issue was solved by phisically restarting BLE device. So I also assume this error may caused when BLE device got some freeze. |
Updated my answer, in my project, after status 133 or 22, I call
"gatt.disconnect; gatt.connect;", will re-connect and get success.
vanitu <[email protected]> 於 2019年6月13日 週四 上午3:23寫道:
… Hi. In my case When I start receive 133, issue was solved by phisically
restarting BLE device. So I also assume this error may caused when BLE
device got some freeze.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://github.com/googlesamples/android-BluetoothLeGatt/issues/44?email_source=notifications&email_token=AENV2JXUG2MWA3HXZNH2GHDP2FEMPA5CNFSM4EBEBDFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXRRIFQ#issuecomment-501421078>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AENV2JQ4R5KK2F3LMRTDY4TP2FEMPANCNFSM4EBEBDFA>
.
|
404, both blog postings no longer exist. |
|
Hi guys! |
Hi Guys, I also faced similar issues. While I didn't manage to fix the issue, I managed to work around it to avoid it. I noticed that my issues disappeared when I did the following:
My only explaination for this behavior is buggy implementations on the phone vendor's side. Some phones are more buggy than others. Hope this info helps someone. |
Thanks to comment by @pederovarela86 android/connectivity-samples#18 (comment)
this didn't fix my issue. |
My two cents. Was working with Heart Rate BLE device, device was advertising, had no problems with scanning it but always got 133 when trying to connect. |
If 133 happens, then use the existing gatt to connect again, do not try to create a new gatt. |
I see you all are still facing this nightmare. |
We have recently updated our samples. Have you been able to resolve the issue you had encountered? If not might you be able to clarify based on our latest samples?
Also we have a blog post series that may be helpful |
Seeing such a little friend fighting against this shit, I was so cool in my heart, hey, god, help me |
I was having this problem consistently whenever there were 2 BLE devices nearby. Changing the autoconnect parameter on connectGatt() to true fixed the problem. |
Many years later, does this proble have new solutation? |
2 thing I have learned:
|
After testing and trying many scenarios, to solve this issue I need to restart the device's BT programming:
Normally this solution can help to reconnect in the first attempt. sometimes in the third attempt |
No and will never have fixed solution. Different chips on different devices are not easy to handle since Google have decided to give manufacturers freedom on their chipset design. So this will always be "resolves my problem on XXX devices but still have the same problem on million other devices" |
Here are the new links my friend: https://www.hellsoft.se/bluetooth-le-for-modern-android-development-part-1/ |
Hello, I am facing an error regarding Bluetooth. ca anyone suggest me what should i do ? |
Thanks Mr Pedro, it was Soluted my problem. |
My Problem
i am stuck with this problem for more then a week if any Googler out there can you help me !
After few attempt the GATT service is getting disconnected i don't know the reason.I found that the onConnectionStateChange i got the status as 62 and 133.But i don't know the exact reason or solution to solve the problem.
Connection Code:
CallBack
The text was updated successfully, but these errors were encountered: