From 264b0038094898a792b8a8f36e844b603fa4b11f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20B=C3=B6hler?= Date: Thu, 23 Sep 2021 07:09:15 +0200 Subject: [PATCH] Fix connection on GBX-100 --- .../gadgetbridge/activities/DiscoveryActivity.java | 3 ++- .../gadgetbridge/devices/DeviceCoordinator.java | 5 +++++ .../devices/casio/gbx100/CasioGBX100DeviceCoordinator.java | 2 +- .../freeyourgadget/gadgetbridge/util/BondingUtil.java | 3 ++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java index 33cce2ee4..755698866 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/DiscoveryActivity.java @@ -737,7 +737,8 @@ public class DiscoveryActivity extends AbstractGBActivity implements AdapterView intent.putExtra(DeviceCoordinator.EXTRA_DEVICE_CANDIDATE, deviceCandidate); startActivity(intent); } else { - if (coordinator.getBondingStyle() == DeviceCoordinator.BONDING_STYLE_NONE) { + if (coordinator.getBondingStyle() == DeviceCoordinator.BONDING_STYLE_NONE || + coordinator.getBondingStyle() == DeviceCoordinator.BONDING_STYLE_LAZY) { LOG.info("No bonding needed, according to coordinator, so connecting right away"); BondingUtil.connectThenComplete(this, deviceCandidate); return; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java index 50dbafcbd..a07416793 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/DeviceCoordinator.java @@ -70,6 +70,11 @@ public interface DeviceCoordinator { */ int BONDING_STYLE_REQUIRE_KEY = 3; + /** + * Lazy pairing, i.e. device initiated pairing is requested + */ + int BONDING_STYLE_LAZY = 4; + /** * Checks whether this coordinator handles the given candidate. * Returns the supported device type for the given candidate or diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gbx100/CasioGBX100DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gbx100/CasioGBX100DeviceCoordinator.java index e17e6c176..4b9317273 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gbx100/CasioGBX100DeviceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gbx100/CasioGBX100DeviceCoordinator.java @@ -61,7 +61,7 @@ public class CasioGBX100DeviceCoordinator extends AbstractDeviceCoordinator { @Override public int getBondingStyle(){ - return BONDING_STYLE_NONE; + return BONDING_STYLE_LAZY; } @Override diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/BondingUtil.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/BondingUtil.java index 4461f9412..b7279f799 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/BondingUtil.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/BondingUtil.java @@ -190,7 +190,8 @@ public class BondingUtil { */ public static void initiateCorrectBonding(final BondingInterface bondingInterface, final GBDeviceCandidate deviceCandidate) { int bondingStyle = DeviceHelper.getInstance().getCoordinator(deviceCandidate).getBondingStyle(); - if (bondingStyle == DeviceCoordinator.BONDING_STYLE_NONE) { + if (bondingStyle == DeviceCoordinator.BONDING_STYLE_NONE || + bondingStyle == DeviceCoordinator.BONDING_STYLE_LAZY ) { // Do nothing return; } else if (bondingStyle == DeviceCoordinator.BONDING_STYLE_ASK) {