1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-26 10:35:50 +01:00

Pebble 2/LE: Add setting to limit the MTU (for debugging broken BLE stacks)

This commit is contained in:
Andreas Shimokawa 2016-12-19 23:28:06 +01:00
parent 771ca948a4
commit bd5dc6bfbc
3 changed files with 16 additions and 1 deletions

View File

@ -10,6 +10,8 @@ import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
public class PebbleLESupport {
private static final Logger LOG = LoggerFactory.getLogger(PebbleLESupport.class);
private final BluetoothDevice mBtDevice;
@ -19,6 +21,7 @@ public class PebbleLESupport {
private PipedInputStream mPipedInputStream;
private PipedOutputStream mPipedOutputStream;
private int mMTU = 20;
private int mMTULimit = Integer.MAX_VALUE;
boolean mIsConnected = false;
public PebbleLESupport(Context context, final BluetoothDevice btDevice, PipedInputStream pipedInputStream, PipedOutputStream pipedOutputStream) throws IOException {
@ -31,6 +34,9 @@ public class PebbleLESupport {
} catch (IOException e) {
LOG.warn("could not connect input stream");
}
mMTULimit = GBApplication.getPrefs().getInt("pebble_mtu_limit", 512);
mMTULimit = Math.max(mMTULimit, 20);
mMTULimit = Math.min(mMTULimit, 512);
mPebbleGATTServer = new PebbleGATTServer(this, context, mBtDevice);
if (mPebbleGATTServer.initialize()) {
@ -99,7 +105,7 @@ public class PebbleLESupport {
}
void setMTU(int mtu) {
mMTU = mtu;
mMTU = Math.min(mtu, mMTULimit);
}
private class PipeReader extends Thread {

View File

@ -120,6 +120,8 @@
<string name="pref_summary_pebble_forceuntested">Enable features that are untested. ENABLE ONLY IF YOU KNOW WHAT YOU ARE DOING!</string>
<string name="pref_title_pebble_forcele">Always prefer BLE</string>
<string name="pref_summary_pebble_forcele">Use experimental Pebble LE support for all Pebbles instead of BT classic, requires paring a "Pebble LE" after non LE had been connected once</string>
<string name="pref_title_pebble_mtu_limit">Pebble 2/LE GATT MTU limit</string>
<string name="pref_summary_pebble_mtu_limit">If your Pebble 2/Pebble LE does not work as expected, try this setting to limit the MTU (valid range 20512)</string>
<string name="pref_title_pebble_enable_applogs">Enable Watch App Logging</string>
<string name="pref_summary_pebble_enable_applogs">Will cause logs from watch apps to be logged by Gadgetbridge (requires reconnect)</string>

View File

@ -341,6 +341,13 @@
android:key="pebble_force_le"
android:summary="@string/pref_summary_pebble_forcele"
android:title="@string/pref_title_pebble_forcele" />
<EditTextPreference
android:inputType="number"
android:key="pebble_mtu_limit"
android:maxLength="3"
android:defaultValue="512"
android:title="@string/pref_title_pebble_mtu_limit"
android:summary="@string/pref_summary_pebble_mtu_limit" />
<CheckBoxPreference
android:defaultValue="false"
android:key="pebble_enable_applogs"