Improve logging when connecting to scannable or unknown devices

This commit is contained in:
José Rebelo
2025-08-06 18:17:55 +01:00
parent 696a7c73a5
commit ff42c5568c
3 changed files with 49 additions and 2 deletions
@@ -7,7 +7,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.unknown.UnknownDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.scannable.ScannableDeviceSupport;
public class ScannableDeviceCoordinator extends AbstractBLEDeviceCoordinator {
@Override
@@ -35,7 +35,7 @@ public class ScannableDeviceCoordinator extends AbstractBLEDeviceCoordinator {
@NonNull
@Override
public Class<? extends DeviceSupport> getDeviceSupportClass(final GBDevice device) {
return UnknownDeviceSupport.class;
return ScannableDeviceSupport.class;
}
@Override
@@ -0,0 +1,41 @@
/* Copyright (C) 2023-2024 Daniel Dakhno
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.scannable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.service.AbstractDeviceSupport;
public class ScannableDeviceSupport extends AbstractDeviceSupport {
private static final Logger LOG = LoggerFactory.getLogger(ScannableDeviceSupport.class);
@Override
public boolean connect() {
LOG.error("Attempting to connect to a scannable device - this should never happen");
return false;
}
@Override
public void dispose() {
}
@Override
public boolean useAutoConnect() {
return false;
}
}
@@ -16,11 +16,17 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.unknown;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.service.AbstractDeviceSupport;
public class UnknownDeviceSupport extends AbstractDeviceSupport {
private static final Logger LOG = LoggerFactory.getLogger(UnknownDeviceSupport.class);
@Override
public boolean connect() {
LOG.error("Attempting to connect to an unknown device - this should never happen");
return false;
}