In case of a bug, do not forget to attach logs!
Pebble 2 disconnects itself. No matter how high I set the reconnect attempt amount, it will never ever reconnect automatically.
Pebble 2
Please specify model and firmware version if possible
silk21(?) v4.3 firmware
7.1.2
0.20.1
This has happened since the first time I used the app. I tried to piggyback off the disconnection issue for another wearable, but apparently the bluetooth stack was different and so it wasn't relevant.
Please let me know if there is more info I can get you, and how I can get it.
Hi,
this is something that might be unrelated to GadgetBridge (GB) because I experience this on the stock pebble app also. I already tried to whitelist the pebble app from battery optimization (together with all bluetooth related system apps). Currently I'm very pleased with GB (also whitelisted for now) when it comes to connectivity and stability. But you have to enable both "connect when bluetooth enabled" and "automatically reconnect" in GB settings otherwise pebble will never reconnect, see #89
I was using the stock app previously with no issues! I have automatically reconnect enabled as well. I even have kept the reconnection attempt value extra high, (2000) with no luck.
Can you please share logs? I understand it's difficult to log the disconnect, if it happens randomly, but the reconnection-attempts-logs might be useful.
Certainly! It's pretty much disconnected whenever I look at my watch, so hopefully there are some good logs.
https://a.doko.moe/teixpc.log here's the log, seems github didn't like the .log and renaming it to .txt didn't work for some reason. This is my most recent log, it looks like there are older ones I can try to get if this doesn't have enough info.
I have set number of reconnection attempts to 9999 to workaround issues with pebble 2 HR (not actively connecting to phone) but a few times (after pebble was disconnected from phone because not in range) I found GB in "disconnected" status. So I manually had to force GB to reconnect. What can trigger GB to go into "disconnected" status while reconnection attempts are set to 9999? Beside this few times it works very well for me: yesterday my watch was out of range for 2 hours and reconnected fine afterwards.
Need any more info from me? Haven't been able to keep it connected since switching to the app a month or two ago. I've been using my watch and phone separately, so no text/email alerts, just timers and stuff.
Please try to force the MTU to 20 in Gadgetbridge settings. It seems the connection is dropped just after the Pebble requests to set the MTU to 339 (and we accept).
On some phones unfortunately this might cause issues.
You find the MTU settings in the Pebble settings screen towards the bottom.
Alright. I've changed that setting. I'll see if it continues to stay connected or not and come back with my results later on.
Stayed connected since I made the change! I'm definitely gonna call that a fix. Thanks for much for the help.
Can you try to set the MTU to 23 , this should be the minimum supported by all devices
Sure. Came back to open the issue anyway, I actually have had two disconnects since my last post, although it seems to stay connected longer than before.
MTU 23 works somewhat. I am still getting disconnects multiple times a day. Hard to say if it's better or worse than MTU 20.
Switched from the OnePlus 2 to the OnePlus 3 and having similar issues with disconnects without tweaking MTU. I'll set MTU to 23 and see how it goes.
I have this issue as well. Was present with my Nexus 5X with LineageOS, and is still present with my Moto X4 with Android 7.1.1. It doesn't disconnect very often, maybe every other day or something.
I know I haven't posted lately. The issue got worse. I can't connect at all. It's been weeks since I could. Tweaking MTU doesn't help. Here's my latest log: https://a.doko.moe/laivmk.log
I'm also being hit with the same problem as @Soundtoxin , I'll gather my log files and report back as well.
Nexus 6P on AEX 4.5 (android 7.1.1)
Sigh, I hear you. I might implement GATT communication the other way round, right now the pebble connects to Gadgerbridge which acts as a SERVER, but newer firmwares have the ability to act as a server as well, so we will be only client. This could help.
My sincere apologies for the delay.
I've put my logs here.
https://mega.nz/#F!wJxnmQzJ!t8XdnTQ1lzFjoeR_yUw42w
Any more news on this? I still cannot get my Pebble 2 to connect to my OnePlus 3 at all.
I am having a similar problem. I seem to be losing the connection to my Pebble Time, and it only reconnects if I manual open gadgetbridge and reconnect. I am going back to the stock Pebble app just to make sure it is not my phone or some android setting. My phone is a little unusual - Unihertz Jelly Pro -- so I want to make sure that is not it. I have now turned on logging so maybe I can catch something. --Chris
This issue has been a lot better, if not entirely gone, since I got Oreo on my Moto X4.
EDIT: Never mind, it still happens occasionally.
I still can't connect at all with my OnePlus 3 on a LineageOS Nightly without gapps and my Pebble 2. The app is stuck on connecting forever.
Provide logs please, they are absolutely needed to solve any issues.
It's also worth keeping in mind that so many devices have buggy Bluetooth drivers that just cause issues like these (my primary phone for example too) and there might be nothing that can be done.
Sure, no problem. Here: http://chunk.io/bard/0c29576f797d47fe85d47d0d475c58e0
Also, I noticed if I watch the bluetooth menu on the watch, it briefly says connected under OnePlus 3, but the GB app never changes from connecting before failing
Please remove pairing in phone and watch then press the + button in Gadgetbridge and pair the pebble though gadgetbridge while NOT being in the Bluetooth menu on the pebble.
Don't you have to be in the bluetooth menu on the watch for it to be discoverable? I get no results while following your instructions.
@Soundtoxin
You can be there when discovering, but from my experience it is better to leave the menu when you actually pair.
Also I think after unpairing you have to switch bluetooth off and on on the pebble once to make it discoverable again.
Wow, I was actually able to pair after all that. I'll keep on eye on things and if I run into problems, I'll adjust MTU and report back.
On the wiki, it says to make the logs as short as possible. Could I avoid having a full day or two of logs to capture the random disconnect? Also, do I need the Bluetooth HCI snoop log?
On February 14, 2018 1:19:53 PM EST, Taavi notifications@github.com wrote:
Provide logs please, they are absolutely needed to solve any issues.
It's also worth keeping in mind that so many devices have buggy
Bluetooth drivers that just cause issues like these (my primary phone
for example too) and there might be nothing that can be done.--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
https://github.com/Freeyourgadget/Gadgetbridge/issues/782#issuecomment-365697794
You can save logs to files (there's a toggle in the settings for this) and extract the problematic rows from there (the logfiles are basically text and begin with a timestamp).
Bluetooth logs are generally not needed.
It is possible that our own log is not enough to get the needed information, in this case you will need to check in the normal logcat output. On my phone I usually get at least a whole day worth of data when running adb logcat from an attached computer, so you can save the output to a file a filter from there.
Any more updates on this ?
I'm having the same issues: I can pair and it connects properly but as soon as I turn the phone off, it's like the GB app is shutdown by Android and the watch loses connection. Turning the phone back on may or may not restore the connection automatically.
I have turned off all the optimizations I found in the phone hoping it will leave GB app alone, but to no avail ...
Not sure what's happening.
Does the GB app acquire that wavelock that allows it to not be closed by the OS ?
One note: the disconnects are happening w/ the Pebble app to and they started with an OS upgrade to 7.1.1. I think something changed in the OS ...
Update: I haven't noticed a disconnect in a while. The only issue I still have is automatic reconnection (like after toggling airplane mode, or a reboot) not working.
@dnastase (and others)
I have pushed experimental "client only" code to master, which could help.
Pebble has implemented this mode (according to a former employee) for problematic Samsung Kitkat phones, but also some more which have problems when acting as a GATT Server.
This code should also be a bit more "correct" than the server code but might be slower. Especially when we receive a lot of big packages we acknowledge all of its gatt chunks which is normally not expected by the pebble (I think only packages are expected to be ACKd where a new pebble protocol chunk begins, but I am not sure)
So there is still a lot of room for improvements. But first let's check for stability...
That's great news :), thank you !
I am looking forward to try it out.
How long until it reaches F-Droid, or how does the release process work ?
@dnastase
When I create a release tag, F-Droid does everything automatically which takes about one day recently.
I plan to fix some at least two other (unrelated) issues and tag this weekend.
Sounds great! thank you!
Just a quick heads-up: I think your "client only" mode is working :)
It's been a couple of hours now with the new version and no disconnect ! (it used to disconnect within minutes).
So it looks very promising !
Thank you !!
@dnastase
Cool, did you also test with the latest commit from today?
1) it seems I spoke too soon; I still have permanent disconnects :(
They are rarer though now ..
I guess still work in progress ...
I will spend some time w/ the code and logs trying to help figuring things out.
2) no, I didn't have your two latest commits, I will update my app.
Does it still disconnect if you turn the screen off?
With my phone the new client only mode seems stable now. :/
Yes, it still disconnects :(
More debugging is needed ;)
I do not have this problem on any device (with screen off = disconnect).
Does this also happen with the official app? (It is now possible to use that completely offline by the way without any account)
Yes, it was happening with the official app too which prompted me to find GB :)
Ok, installed now the latest code ...
So the disconnects happen randomly while the screen is off.
The GB tries to reconnect and mostly it succeeds at the second attempt.
But there seems to be a ~4 min gap between the first reconnection attempt and the second that I don't understand (see 18:07 -> 18:11 below)
18:07:13.083 [Binder:20685_1] INFO n.f.g.s.d.p.b.PebbleGATTClient - onConnectionStateChange() status = 8 newState = 0
18:07:13.084 [Binder:20685_1] INFO n.f.g.s.d.p.b.PebbleLESupport - closing piped inputstream
18:07:13.084 [Thread-18] INFO n.f.g.s.d.p.b.PebbleLESupport - closing piped inputstream
18:07:13.084 [Thread-18] INFO n.f.g.s.d.p.b.PebbleLESupport - null
18:07:13.085 [Thread-18] INFO n.f.g.s.d.p.b.PebbleLESupport - closing piped inputstream
18:07:13.085 [Thread-18] INFO n.f.g.s.d.p.b.PebbleLESupport - Pipereader thread shut down
18:07:13.126 [Thread-9] INFO n.f.g.s.d.p.PebbleIoThread - broken pipe
18:07:13.127 [Thread-9] INFO n.f.g.s.d.p.PebbleIoThread - Trying to reconnect (attempts left 1298)
18:07:13.134 [Thread-9] INFO n.f.g.s.d.p.PebbleIoThread - This is a Pebble 2 or Pebble-LE/Pebble Time LE, will use BLE
18:07:13.326 [main] WARN n.f.g.i.GBDeviceCandidate - no cached services available for Pebble 20C7: 4C:C6:FB:DE:1E:A3 (UNKNOWN)
18:07:13.334 [main] WARN n.f.g.i.GBDeviceCandidate - no cached services available for Pebble 20C7: 4C:C6:FB:DE:1E:A3 (UNKNOWN)
18:07:13.397 [main] INFO n.f.g.s.DeviceCommunicationService - Setting broadcast receivers to: true
18:07:13.585 [main] WARN n.f.g.i.GBDeviceCandidate - no cached services available for Pebble 20C7: 4C:C6:FB:DE:1E:A3 (UNKNOWN)
18:07:13.593 [main] WARN n.f.g.i.GBDeviceCandidate - no cached services available for Pebble 20C7: 4C:C6:FB:DE:1E:A3 (UNKNOWN)
18:07:13.653 [main] INFO n.f.g.s.DeviceCommunicationService - Setting broadcast receivers to: true
18:07:13.677 [Binder:20685_3] INFO n.f.g.s.d.p.b.PebbleGATTClient - onConnectionStateChange() status = 133 newState = 0
18:11:56.600 [Thread-9] WARN n.f.g.s.d.p.PebbleIoThread - error while connecting: connection failed
java.io.IOException: connection failed
at nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.ble.PebbleLESupport.
at nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.PebbleIoThread.connect(PebbleIoThread.java:186) ~[na:0.0]
at nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.PebbleIoThread.run(PebbleIoThread.java:388) ~[na:0.0]
18:11:56.940 [main] WARN n.f.g.i.GBDeviceCandidate - no cached services available for Pebble 20C7: 4C:C6:FB:DE:1E:A3 (UNKNOWN)
18:11:56.948 [main] WARN n.f.g.i.GBDeviceCandidate - no cached services available for Pebble 20C7: 4C:C6:FB:DE:1E:A3 (UNKNOWN)
18:11:57.006 [main] INFO n.f.g.s.DeviceCommunicationService - Setting broadcast receivers to: true
18:11:58.332 [Thread-9] INFO n.f.g.s.d.p.PebbleIoThread - Trying to reconnect (attempts left 1297)
18:11:58.338 [Thread-9] INFO n.f.g.s.d.p.PebbleIoThread - This is a Pebble 2 or Pebble-LE/Pebble Time LE, will use BLE
18:11:58.514 [main] WARN n.f.g.i.GBDeviceCandidate - no cached services available for Pebble 20C7: 4C:C6:FB:DE:1E:A3 (UNKNOWN)
18:11:58.522 [main] WARN n.f.g.i.GBDeviceCandidate - no cached services available for Pebble 20C7: 4C:C6:FB:DE:1E:A3 (UNKNOWN)
18:11:58.581 [main] INFO n.f.g.s.DeviceCommunicationService - Setting broadcast receivers to: true
18:11:59.351 [Binder:20685_1] INFO n.f.g.s.d.p.b.PebbleGATTClient - onConnectionStateChange() status = 0 newState = 2
Can you try adding battery saving exception for gadgetbridge in your OS?
Yes, GB should be excepted from any battery optimization. Provided that those settings work correctly.
I tried my best to turn off anything that might preempt the GB or bluetooth related stuff.
You can set that manually to test (exempt from battery usage)
The following change fixes the ~4min time gap that I mentioned above. It's not always 4 min, it varies, but it's always longer than the 30 sec allowed in the wait(), fact which I can't explain. Regardless, this totally eliminates any time delay.
```diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleGATTClient.java b/app/src/main/java/nodomain/freeyourgadget/gadgetb
index e8df751..145da63 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleGATTClient.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/ble/PebbleGATTClient.java
@@ -115,6 +115,9 @@ class PebbleGATTClient extends BluetoothGattCallback {
gatt.discoverServices();
} else if (newState == BluetoothGatt.STATE_DISCONNECTED) {
mPebbleLESupport.close();
With regards to the battery optimizer, logs that I've added showed that the app was not actually included in the whitelist, even though I was doing so from the Settings.
The following change, even though it still showed the GB as whitelisted in the Settings dialog (ie: no-op), it actually made the app be whitelisted (same logs showed it). I'm guessing it amounts to the user giving his/her approval to whitelisting .. ?!
index 9501733..4ab3e2d 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenterv2.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/ControlCenterv2.java
@@ -44,6 +44,7 @@ import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
+import android.provider.Settings;
import java.util.ArrayList;
import java.util.List;
@@ -187,6 +188,10 @@ public class ControlCenterv2 extends AppCompatActivity
prefs.getPreferences().edit().putBoolean("firstrun", false).apply();
Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
startActivity(enableIntent);
+
+ Intent batOptimizIntent = new Intent();
+ batOptimizIntent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
+ startActivity(batOptimizIntent);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
checkAndRequestPermissions();
This is the log I was checking:
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIo
index 89fb011..9622601 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java
@@ -27,6 +27,7 @@ import android.os.ParcelUuid;
import android.support.v4.content.LocalBroadcastManager;
import android.webkit.ValueCallback;
import android.webkit.WebView;
+import android.os.PowerManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -148,6 +149,10 @@ class PebbleIoThread extends GBDeviceIoThread {
mEnablePebblekit = prefs.getBoolean("pebble_enable_pebblekit", false);
mPebbleProtocol.setAlwaysACKPebbleKit(prefs.getBoolean("pebble_always_ack_pebblekit", false));
mPebbleProtocol.setEnablePebbleKit(mEnablePebblekit);
+
+ PowerManager powermanager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
+ LOG.info("packageName: " + context.getPackageName());
+ LOG.info("isIgnoringBatteryOptimizations: " + powermanager.isIgnoringBatteryOptimizations(context.getPackageName()));
}
Just for the reference: it seems to me now that the issues that I have with my Pebble 2 are because the watch is broken. The connection breaks with status 8 or 133 for no reason.
Seeing that I revived my old Pebble Time and, after several attempts, managed to make it connect via LE only and it works just fine.
Also another reason I think the Pebble 2 is broken is because it didn't seem to have the range that it used to (entire house). It would disconnect at mere meters away from the phone.
I have ordered a new Pebble 2, let's see.
So for those that have similar issues: that's something to consider ...
Yes, it was true: my Pebble 2 was broken in such a subtle way that it didn't seem broken :|
So I got the new Pebble 2 yesterday and it works perfectly ! Paired w/out issues and no connection drop, with the BT range that I was used to.
Super happy now ! ;)
I take the opportunity to thank the developers of this great app for their awesome ideas and hard work !
@dnastase I've set some of your comments to "hidden" since they were not related to the issue. Thanks a lot for the kind words!
Generally speaking to those still having the issue: please try the new "client only" mode for pebble 2 as it seems to make things much better. It's possible you have to pair your watch again before the new mode will work. Our wiki contains instructions.
Sorry I haven't been active in this discussion since the recent change. I'm not so sure the issue was solved. It's tricky, because I've never had 100% functionality with gadgetbridge, but even if my phone restarts, the watch should reconnect itself, right? So if I look down and see my watch disconnected, and I didn't do it myself, I can confirm the issue is still there, right? I believe I enabled the new setting related to client-mode, and it still disconnected and did not reconnect. I don't know if my most recent logs will be helpful if it's been a while since the disconnection, so for now I'm just gonna post this, reconnect my watch, and wait for it to happen again.
edit: had some trouble getting the watch to connect again, manually even. Tried tweaking MTU. No difference at 23 or 512. Returned to 512. Disabled the new client mode setting and then was able to manually reconnect. Not sure if any changes were made to behavior without the new setting, but I guess I'll wait and see if it disconnects again and then report back.
Version 0.26.5 re-adds auto reconnect after boot and has both server and client GATT mode improvements. It should be out on fdroid in a few hours as it was already built by them.
pebble app discconnects allso on s9 phone. when i installed pebble version 4.2.1 - 1316-9f75f41
it stopped disconnecting and every thing works perfectly on pebble 2 HR. can u make changes to the app like there are on older pebble version? something is wrong on the new app and it disconnects always.
Most helpful comment
Sigh, I hear you. I might implement GATT communication the other way round, right now the pebble connects to Gadgerbridge which acts as a SERVER, but newer firmwares have the ability to act as a server as well, so we will be only client. This could help.