From 91415e2500ae53c99529cab0823a782b8d49b59b Mon Sep 17 00:00:00 2001 From: Johannes Krude Date: Thu, 20 Jul 2023 14:28:04 +0200 Subject: [PATCH] Casio: Refactoring --- .../devices/casio/CasioDeviceCoordinator.java | 46 +++++++++++++ .../gb6900/CasioGB6900DeviceCoordinator.java | 14 ++-- .../gbx100/CasioGBX100DeviceCoordinator.java | 15 ++--- .../CasioGBX100SampleProvider.java | 2 +- .../service/DeviceSupportFactory.java | 4 +- .../service/btle/BLETypeConversions.java | 37 +++++++++-- .../devices/casio/Casio2C2DSupport.java | 56 ++++++++++++++++ .../service/devices/casio/CasioSupport.java | 65 +++++++------------ .../CasioGB6900DeviceSupport.java | 23 +++++-- .../CasioGB6900HandlerThread.java} | 10 +-- .../InitOperation.java} | 10 +-- .../SetAlarmOperation.java | 6 +- .../CasioGBX100DeviceSupport.java | 52 ++++++--------- .../FetchStepCountDataOperation.java | 4 +- .../GetConfigurationOperation.java | 4 +- .../InitOperation.java} | 16 +++-- .../SetConfigurationOperation.java | 6 +- .../devices/pinetime/PineTimeJFSupport.java | 2 +- 18 files changed, 237 insertions(+), 135 deletions(-) create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/CasioDeviceCoordinator.java rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/{ => gbx100}/CasioGBX100SampleProvider.java (98%) create mode 100644 app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/Casio2C2DSupport.java rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/{ => gb6900}/CasioGB6900DeviceSupport.java (97%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/{CasioHandlerThread.java => gb6900/CasioGB6900HandlerThread.java} (91%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/{operations/InitOperationGB6900.java => gb6900/InitOperation.java} (96%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/{operations => gb6900}/SetAlarmOperation.java (97%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/{ => gbx100}/CasioGBX100DeviceSupport.java (95%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/{operations => gbx100}/FetchStepCountDataOperation.java (99%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/{operations => gbx100}/GetConfigurationOperation.java (99%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/{operations/InitOperationGBX100.java => gbx100/InitOperation.java} (97%) rename app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/{operations => gbx100}/SetConfigurationOperation.java (99%) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/CasioDeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/CasioDeviceCoordinator.java new file mode 100644 index 000000000..89c50bd0e --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/CasioDeviceCoordinator.java @@ -0,0 +1,46 @@ +/* Copyright (C) 2023 Johannes Krude + + based on code from BlueWatcher, https://github.com/masterjc/bluewatcher + + 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 . */ +package nodomain.freeyourgadget.gadgetbridge.devices.casio; + +import java.util.Collection; +import java.util.Collections; + +import android.bluetooth.le.ScanFilter; +import android.os.ParcelUuid; + +import androidx.annotation.NonNull; + +import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator; + +import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; + +public abstract class CasioDeviceCoordinator extends AbstractBLEDeviceCoordinator { + @NonNull + @Override + public Collection createBLEScanFilters() { + ParcelUuid casioService = new ParcelUuid(CasioConstants.WATCH_FEATURES_SERVICE_UUID); + ScanFilter filter = new ScanFilter.Builder().setServiceUuid(casioService).build(); + return Collections.singletonList(filter); + } + + @Override + public String getManufacturer() { + return "Casio"; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gb6900/CasioGB6900DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gb6900/CasioGB6900DeviceCoordinator.java index c547580b5..196f9d63d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gb6900/CasioGB6900DeviceCoordinator.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gb6900/CasioGB6900DeviceCoordinator.java @@ -1,5 +1,5 @@ -/* Copyright (C) 2016-2021 Andreas Böhler, Andreas Shimokawa, Carsten - Pfeiffer, Daniele Gobbetti, José Rebelo +/* Copyright (C) 2016-2023 Andreas Böhler, Andreas Shimokawa, Carsten + Pfeiffer, Daniele Gobbetti, José Rebelo, Johannes Krude based on code from BlueWatcher, https://github.com/masterjc/bluewatcher @@ -29,10 +29,9 @@ import org.slf4j.LoggerFactory; import androidx.annotation.NonNull; import nodomain.freeyourgadget.gadgetbridge.GBException; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; -import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; +import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioDeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; import nodomain.freeyourgadget.gadgetbridge.entities.Device; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; @@ -40,7 +39,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -public class CasioGB6900DeviceCoordinator extends AbstractBLEDeviceCoordinator { +public class CasioGB6900DeviceCoordinator extends CasioDeviceCoordinator { protected static final Logger LOG = LoggerFactory.getLogger(CasioGB6900DeviceCoordinator.class); @NonNull @@ -132,11 +131,6 @@ public class CasioGB6900DeviceCoordinator extends AbstractBLEDeviceCoordinator { return false; } - @Override - public String getManufacturer() { - return "Casio"; - } - @Override public boolean supportsAppsManagement(final GBDevice device) { return false; 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 41bf050d4..7e3eb69bb 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 @@ -1,5 +1,5 @@ -/* Copyright (C) 2016-2021 Andreas Böhler, Andreas Shimokawa, Carsten - Pfeiffer, Daniele Gobbetti, José Rebelo +/* Copyright (C) 2016-2023 Andreas Böhler, Andreas Shimokawa, Carsten + Pfeiffer, Daniele Gobbetti, José Rebelo, Johannes Krude based on code from BlueWatcher, https://github.com/masterjc/bluewatcher @@ -31,10 +31,10 @@ import androidx.annotation.NonNull; import de.greenrobot.dao.query.QueryBuilder; import nodomain.freeyourgadget.gadgetbridge.GBException; import nodomain.freeyourgadget.gadgetbridge.R; -import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator; import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler; import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider; -import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioGBX100SampleProvider; +import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioDeviceCoordinator; +import nodomain.freeyourgadget.gadgetbridge.devices.casio.gbx100.CasioGBX100SampleProvider; import nodomain.freeyourgadget.gadgetbridge.entities.CasioGBX100ActivitySampleDao; import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession; import nodomain.freeyourgadget.gadgetbridge.entities.Device; @@ -43,7 +43,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate; import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample; import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; -public class CasioGBX100DeviceCoordinator extends AbstractBLEDeviceCoordinator { +public class CasioGBX100DeviceCoordinator extends CasioDeviceCoordinator { protected static final Logger LOG = LoggerFactory.getLogger(CasioGBX100DeviceCoordinator.class); @NonNull @@ -136,11 +136,6 @@ public class CasioGBX100DeviceCoordinator extends AbstractBLEDeviceCoordinator { return false; } - @Override - public String getManufacturer() { - return "Casio"; - } - @Override public boolean supportsAppsManagement(final GBDevice device) { return false; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/CasioGBX100SampleProvider.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gbx100/CasioGBX100SampleProvider.java similarity index 98% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/CasioGBX100SampleProvider.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gbx100/CasioGBX100SampleProvider.java index 068a17167..6eedf5a60 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/CasioGBX100SampleProvider.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gbx100/CasioGBX100SampleProvider.java @@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.devices.casio; +package nodomain.freeyourgadget.gadgetbridge.devices.casio.gbx100; import androidx.annotation.NonNull; import androidx.annotation.Nullable; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java index d23138ace..99bd02638 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java @@ -32,8 +32,8 @@ import nodomain.freeyourgadget.gadgetbridge.model.DeviceType; import nodomain.freeyourgadget.gadgetbridge.service.devices.asteroidos.AsteroidOSDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.banglejs.BangleJSDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.binary_sensor.BinarySensorSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.CasioGB6900DeviceSupport; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.CasioGBX100DeviceSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gb6900.CasioGB6900DeviceSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.CasioGBX100DeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.domyos.DomyosT540Support; import nodomain.freeyourgadget.gadgetbridge.service.devices.fitpro.FitProDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.flipper.zero.support.FlipperZeroSupport; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BLETypeConversions.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BLETypeConversions.java index e83c87624..264459bbc 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BLETypeConversions.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/btle/BLETypeConversions.java @@ -1,5 +1,5 @@ -/* Copyright (C) 2016-2021 Andreas Shimokawa, Carsten Pfeiffer, Daniele - Gobbetti, Lukas Veneziano, Maxim Baz +/* Copyright (C) 2016-2023 Andreas Shimokawa, Carsten Pfeiffer, Daniele + Gobbetti, Lukas Veneziano, Maxim Baz, Johannes Krude This file is part of Gadgetbridge. @@ -22,6 +22,8 @@ import java.util.Calendar; import java.util.GregorianCalendar; import java.util.TimeZone; +import org.threeten.bp.ZonedDateTime; + import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandCoordinator; import nodomain.freeyourgadget.gadgetbridge.model.NotificationType; import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.alertnotification.AlertCategory; @@ -37,10 +39,11 @@ public class BLETypeConversions { * Converts a timestamp to the byte sequence to be sent to the current time characteristic * * @param timestamp + * @param reason * @return * @see GattCharacteristic#UUID_CHARACTERISTIC_CURRENT_TIME */ - public static byte[] calendarToCurrentTime(Calendar timestamp) { + public static byte[] calendarToCurrentTime(Calendar timestamp, int reason) { // year,year,month,dayofmonth,hour,minute,second,dayofweek,fractions256,reason byte[] year = fromUint16(timestamp.get(Calendar.YEAR)); @@ -54,7 +57,33 @@ public class BLETypeConversions { fromUint8(timestamp.get(Calendar.SECOND)), dayOfWeekToRawBytes(timestamp), fromUint8((int) (timestamp.get(Calendar.MILLISECOND) / 1000. * 256)), - 0, // reason (not set) + (byte) reason, // use 0 if unknown reason + }; + } + + /** + * Converts a timestamp to the byte sequence to be sent to the current time characteristic + * + * @param timestamp + * @param reason + * @return + * @see GattCharacteristic#UUID_CHARACTERISTIC_CURRENT_TIME + */ + public static byte[] toCurrentTime(ZonedDateTime timestamp, int reason) { + // year,year,month,dayofmonth,hour,minute,second,dayofweek,fractions256,reason + + byte[] year = fromUint16(timestamp.getYear()); + return new byte[] { + year[0], + year[1], + fromUint8(timestamp.getMonthValue()), + fromUint8(timestamp.getDayOfMonth()), + fromUint8(timestamp.getHour()), + fromUint8(timestamp.getMinute()), + fromUint8(timestamp.getSecond()), + fromUint8(timestamp.getDayOfWeek().getValue()), + fromUint8((int) (timestamp.getNano() / 1000000000. * 256)), + (byte) reason, // use 0 if unknown reason }; } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/Casio2C2DSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/Casio2C2DSupport.java new file mode 100644 index 000000000..9473e4846 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/Casio2C2DSupport.java @@ -0,0 +1,56 @@ +/* Copyright (C) 2016-2023 Andreas Böhler, Andreas Shimokawa, Carsten + Pfeiffer, Sebastian Kranz, Johannes Krude + + 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 . */ +package nodomain.freeyourgadget.gadgetbridge.service.devices.casio; + +import java.util.UUID; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.threeten.bp.ZonedDateTime; + +import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; +import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; + + +// this class is for those Casio watches which request reads on the 2C characteristic and write on the 2D characteristic + +public abstract class Casio2C2DSupport extends CasioSupport { + + public Casio2C2DSupport(Logger logger) { + super(logger); + } + + public void writeAllFeatures(TransactionBuilder builder, byte[] arr) { + builder.write(getCharacteristic(CasioConstants.CASIO_ALL_FEATURES_CHARACTERISTIC_UUID), arr); + } + + public void writeAllFeaturesRequest(TransactionBuilder builder, byte[] arr) { + builder.write(getCharacteristic(CasioConstants.CASIO_READ_REQUEST_FOR_ALL_FEATURES_CHARACTERISTIC_UUID), arr); + } + + public void writeCurrentTime(TransactionBuilder builder, ZonedDateTime time) { + byte[] arr = new byte[11]; + arr[0] = CasioConstants.characteristicToByte.get("CASIO_CURRENT_TIME"); + byte[] tmp = prepareCurrentTime(time); + System.arraycopy(tmp, 0, arr, 1, 10); + + writeAllFeatures(builder, arr); + } + +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioSupport.java index 4e4e3c03e..ea73b4746 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioSupport.java @@ -1,3 +1,19 @@ +/* Copyright (C) 2021-2023 Andreas Böhler, Johannes Krude + + 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 . */ package nodomain.freeyourgadget.gadgetbridge.service.devices.casio; import android.net.Uri; @@ -5,33 +21,19 @@ import android.net.Uri; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.UUID; -import java.util.concurrent.TimeUnit; +import org.threeten.bp.ZonedDateTime; -import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; -import nodomain.freeyourgadget.gadgetbridge.model.Alarm; -import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec; -import nodomain.freeyourgadget.gadgetbridge.model.CallSpec; -import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec; -import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec; -import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec; -import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec; -import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport; +import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions; import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiSupport; +import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; -public class CasioSupport extends AbstractBTLEDeviceSupport { +public abstract class CasioSupport extends AbstractBTLEDeviceSupport { protected boolean mFirstConnect = false; private static final Logger LOG = LoggerFactory.getLogger(HuamiSupport.class); - public CasioSupport() { - this(LOG); - } - public CasioSupport(Logger logger) { super(logger); addSupportedService(CasioConstants.WATCH_FEATURES_SERVICE_UUID); @@ -43,25 +45,9 @@ public class CasioSupport extends AbstractBTLEDeviceSupport { return connect(); } - protected byte[] prepareCurrentTime() { - byte[] arr = new byte[10]; - Calendar cal = Calendar.getInstance(); - - int year = cal.get(Calendar.YEAR); - arr[0] = (byte)((year >>> 0) & 0xff); - arr[1] = (byte)((year >>> 8) & 0xff); - arr[2] = (byte)(1 + cal.get(Calendar.MONTH)); - arr[3] = (byte)cal.get(Calendar.DAY_OF_MONTH); - arr[4] = (byte)cal.get(Calendar.HOUR_OF_DAY); - arr[5] = (byte)cal.get(Calendar.MINUTE); - arr[6] = (byte)(1 + cal.get(Calendar.SECOND)); - byte dayOfWk = (byte)(cal.get(Calendar.DAY_OF_WEEK) - 1); - if(dayOfWk == 0) - dayOfWk = 7; - arr[7] = dayOfWk; - arr[8] = (byte)(int) TimeUnit.MILLISECONDS.toSeconds(256 * cal.get(Calendar.MILLISECOND)); - arr[9] = 1; // or 0? - return arr; + static protected byte[] prepareCurrentTime(ZonedDateTime time) { + // somehow everyone uses reason=1 for Casio watches + return BLETypeConversions.toCurrentTime(time, 1); } public void setInitialized() { @@ -69,9 +55,4 @@ public class CasioSupport extends AbstractBTLEDeviceSupport { gbDevice.setState(GBDevice.State.INITIALIZED); gbDevice.sendDeviceUpdateIntent(getContext()); } - - @Override - public boolean useAutoConnect() { - return true; - } } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioGB6900DeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/CasioGB6900DeviceSupport.java similarity index 97% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioGB6900DeviceSupport.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/CasioGB6900DeviceSupport.java index 2e30bd5ba..1ed30637e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioGB6900DeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/CasioGB6900DeviceSupport.java @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.casio; +package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gb6900; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothGatt; @@ -35,6 +35,8 @@ import java.util.Calendar; import java.util.UUID; import java.util.concurrent.TimeUnit; +import org.threeten.bp.ZonedDateTime; + import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone; @@ -54,8 +56,10 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.GattCharacteristic; import nodomain.freeyourgadget.gadgetbridge.service.btle.GattService; import nodomain.freeyourgadget.gadgetbridge.service.btle.ServerTransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations.InitOperationGB6900; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations.SetAlarmOperation; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.CasioSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gb6900.CasioGB6900HandlerThread; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gb6900.InitOperation; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gb6900.SetAlarmOperation; import nodomain.freeyourgadget.gadgetbridge.util.GB; import nodomain.freeyourgadget.gadgetbridge.util.StringUtils; @@ -65,7 +69,7 @@ public class CasioGB6900DeviceSupport extends CasioSupport { private static final Logger LOG = LoggerFactory.getLogger(CasioGB6900DeviceSupport.class); private final ArrayList mCasioCharacteristics = new ArrayList(); - private CasioHandlerThread mHandlerThread = null; + private CasioGB6900HandlerThread mHandlerThread = null; private MusicSpec mBufferMusicSpec = null; private MusicStateSpec mBufferMusicStateSpec = null; private BluetoothGatt mBtGatt = null; @@ -105,6 +109,11 @@ public class CasioGB6900DeviceSupport extends CasioSupport { addSupportedServerService(casioGATTService); } + @Override + public boolean useAutoConnect() { + return true; + } + @Override public boolean connectFirstTime() { GB.toast(getContext(), "After first connect, disable and enable bluetooth on your Casio watch to really connect", Toast.LENGTH_SHORT, GB.INFO); @@ -161,7 +170,7 @@ public class CasioGB6900DeviceSupport extends CasioSupport { // BLE on the watch. if(mModel != CasioConstants.Model.MODEL_CASIO_STB1000) { try { - new InitOperationGB6900(this, builder).perform(); + new InitOperation(this, builder).perform(); } catch (IOException e) { GB.toast(getContext(), "Initializing Casio watch failed", Toast.LENGTH_SHORT, GB.ERROR, e); } @@ -236,7 +245,7 @@ public class CasioGB6900DeviceSupport extends CasioSupport { } private void writeCasioCurrentTime(TransactionBuilder builder) { - byte[] arr = prepareCurrentTime(); + byte[] arr = prepareCurrentTime(ZonedDateTime.now()); BluetoothGattCharacteristic charact = getCharacteristic(CasioConstants.CURRENT_TIME_CHARACTERISTIC_UUID); if(charact != null) { @@ -291,7 +300,7 @@ public class CasioGB6900DeviceSupport extends CasioSupport { mHandlerThread.interrupt(); } } - mHandlerThread = new CasioHandlerThread(getDevice(), getContext(), this); + mHandlerThread = new CasioGB6900HandlerThread(getDevice(), getContext(), this); mHandlerThread.start(); gbDevice.setState(GBDevice.State.INITIALIZED); gbDevice.sendDeviceUpdateIntent(getContext()); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioHandlerThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/CasioGB6900HandlerThread.java similarity index 91% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioHandlerThread.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/CasioGB6900HandlerThread.java index 452a2ce1d..b6da77088 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioHandlerThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/CasioGB6900HandlerThread.java @@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.casio; +package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gb6900; import android.content.Context; @@ -28,8 +28,8 @@ import java.util.GregorianCalendar; import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceIoThread; -public class CasioHandlerThread extends GBDeviceIoThread { - private static final Logger LOG = LoggerFactory.getLogger(CasioHandlerThread.class); +public class CasioGB6900HandlerThread extends GBDeviceIoThread { + private static final Logger LOG = LoggerFactory.getLogger(CasioGB6900HandlerThread.class); private static final int TX_PERIOD = 60; private final Object waitObject = new Object(); private boolean mQuit; @@ -38,7 +38,7 @@ public class CasioHandlerThread extends GBDeviceIoThread { private Calendar mTxTime = GregorianCalendar.getInstance(); - public CasioHandlerThread(GBDevice gbDevice, Context context, CasioGB6900DeviceSupport deviceSupport) { + public CasioGB6900HandlerThread(GBDevice gbDevice, Context context, CasioGB6900DeviceSupport deviceSupport) { super(gbDevice, context); LOG.info("Initializing Casio Handler Thread"); mQuit = false; @@ -100,7 +100,7 @@ public class CasioHandlerThread extends GBDeviceIoThread { @Override public void quit() { - LOG.info("CasioHandlerThread: Quit Handler Thread"); + LOG.info("CasioGB6900HandlerThread: Quit Handler Thread"); mQuit = true; synchronized (waitObject) { waitObject.notify(); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/InitOperationGB6900.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/InitOperation.java similarity index 96% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/InitOperationGB6900.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/InitOperation.java index e4abdea16..9093d2f0c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/InitOperationGB6900.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/InitOperation.java @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations; +package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gb6900; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; @@ -30,16 +30,16 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.CasioGB6900DeviceSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gb6900.CasioGB6900DeviceSupport; -public class InitOperationGB6900 extends AbstractBTLEOperation { - private static final Logger LOG = LoggerFactory.getLogger(InitOperationGB6900.class); +public class InitOperation extends AbstractBTLEOperation { + private static final Logger LOG = LoggerFactory.getLogger(InitOperation.class); private final TransactionBuilder builder; private byte[] mBleSettings = null; - public InitOperationGB6900(CasioGB6900DeviceSupport support, TransactionBuilder builder) { + public InitOperation(CasioGB6900DeviceSupport support, TransactionBuilder builder) { super(support); this.builder = builder; builder.setCallback(this); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/SetAlarmOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/SetAlarmOperation.java similarity index 97% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/SetAlarmOperation.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/SetAlarmOperation.java index 1965583c2..ffbe7ba1e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/SetAlarmOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gb6900/SetAlarmOperation.java @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations; +package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gb6900; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; @@ -30,11 +30,11 @@ import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; import nodomain.freeyourgadget.gadgetbridge.model.Alarm; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.CasioGB6900DeviceSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gb6900.CasioGB6900DeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus; public class SetAlarmOperation extends AbstractBTLEOperation { - private static final Logger LOG = LoggerFactory.getLogger(GetConfigurationOperation.class); + private static final Logger LOG = LoggerFactory.getLogger(SetAlarmOperation.class); private final ArrayList mAlarms; public SetAlarmOperation(CasioGB6900DeviceSupport support, ArrayList alarms) { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioGBX100DeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/CasioGBX100DeviceSupport.java similarity index 95% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioGBX100DeviceSupport.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/CasioGBX100DeviceSupport.java index 7331bd3b1..7de247086 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioGBX100DeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/CasioGBX100DeviceSupport.java @@ -1,5 +1,5 @@ -/* Copyright (C) 2016-2021 Andreas Böhler, Andreas Shimokawa, Carsten - Pfeiffer, Sebastian Kranz +/* Copyright (C) 2016-2023 Andreas Böhler, Andreas Shimokawa, Carsten + Pfeiffer, Sebastian Kranz, Johannes Krude This file is part of Gadgetbridge. @@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.casio; +package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; @@ -27,16 +27,19 @@ import android.widget.Toast; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.threeten.bp.ZonedDateTime; + import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; -import java.util.Calendar; import java.util.List; import java.util.UUID; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import org.threeten.bp.ZonedDateTime; + import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst; @@ -44,7 +47,7 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHandler; import nodomain.freeyourgadget.gadgetbridge.database.DBHelper; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone; import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; -import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioGBX100SampleProvider; +import nodomain.freeyourgadget.gadgetbridge.devices.casio.gbx100.CasioGBX100SampleProvider; import nodomain.freeyourgadget.gadgetbridge.devices.makibeshr3.MakibesHR3Constants; import nodomain.freeyourgadget.gadgetbridge.entities.CasioGBX100ActivitySample; import nodomain.freeyourgadget.gadgetbridge.entities.Device; @@ -59,12 +62,12 @@ import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec; import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec; import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec; import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec; -import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations.FetchStepCountDataOperation; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations.GetConfigurationOperation; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations.InitOperationGBX100; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations.SetConfigurationOperation; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.Casio2C2DSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.FetchStepCountDataOperation; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.GetConfigurationOperation; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.InitOperation; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.SetConfigurationOperation; import nodomain.freeyourgadget.gadgetbridge.util.GB; import static nodomain.freeyourgadget.gadgetbridge.activities.devicesettings.DeviceSettingsPreferenceConst.PREF_AUTOLIGHT; @@ -84,7 +87,7 @@ import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_ import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_WEIGHT_KG; import static nodomain.freeyourgadget.gadgetbridge.model.ActivityUser.PREF_USER_YEAR_OF_BIRTH; -public class CasioGBX100DeviceSupport extends CasioSupport implements SharedPreferences.OnSharedPreferenceChangeListener { +public class CasioGBX100DeviceSupport extends Casio2C2DSupport implements SharedPreferences.OnSharedPreferenceChangeListener { private static final Logger LOG = LoggerFactory.getLogger(CasioGBX100DeviceSupport.class); @@ -99,14 +102,18 @@ public class CasioGBX100DeviceSupport extends CasioSupport implements SharedPref public CasioGBX100DeviceSupport() { super(LOG); + } + @Override + public boolean useAutoConnect() { + return true; } @Override protected TransactionBuilder initializeDevice(TransactionBuilder builder) { try { - new InitOperationGBX100(this, builder, mFirstConnect).perform(); + new InitOperation(this, builder, mFirstConnect).perform(); } catch (IOException e) { GB.toast(getContext(), "Initializing Casio watch failed", Toast.LENGTH_SHORT, GB.ERROR, e); } @@ -225,7 +232,7 @@ public class CasioGBX100DeviceSupport extends CasioSupport implements SharedPref if(data[1] == 0x00) { try { TransactionBuilder builder = performInitialized("writeCurrentTime"); - writeCurrentTime(builder); + writeCurrentTime(builder, ZonedDateTime.now()); builder.queue(getQueue()); } catch (IOException e) { LOG.warn("writing current time failed: " + e.getMessage()); @@ -423,23 +430,6 @@ public class CasioGBX100DeviceSupport extends CasioSupport implements SharedPref } } - public void writeCurrentTime(TransactionBuilder builder) { - byte[] arr = new byte[11]; - arr[0] = CasioConstants.characteristicToByte.get("CASIO_CURRENT_TIME"); - byte[] tmp = prepareCurrentTime(); - System.arraycopy(tmp, 0, arr, 1, 10); - - writeAllFeatures(builder, arr); - } - - public void writeAllFeatures(TransactionBuilder builder, byte[] arr) { - builder.write(getCharacteristic(CasioConstants.CASIO_ALL_FEATURES_CHARACTERISTIC_UUID), arr); - } - - public void writeAllFeaturesRequest(TransactionBuilder builder, byte[] arr) { - builder.write(getCharacteristic(CasioConstants.CASIO_READ_REQUEST_FOR_ALL_FEATURES_CHARACTERISTIC_UUID), arr); - } - @Override public void onSetAlarms(ArrayList alarms) { byte[] data1 = new byte[5]; @@ -484,7 +474,7 @@ public class CasioGBX100DeviceSupport extends CasioSupport implements SharedPref LOG.debug("onSetTime called"); try { TransactionBuilder builder = performInitialized("onSetTime"); - writeCurrentTime(builder); + writeCurrentTime(builder, ZonedDateTime.now()); builder.queue(getQueue()); } catch (IOException e) { LOG.warn("onSetTime failed: " + e.getMessage()); diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/FetchStepCountDataOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/FetchStepCountDataOperation.java similarity index 99% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/FetchStepCountDataOperation.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/FetchStepCountDataOperation.java index 281cc47bb..53f0a63c3 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/FetchStepCountDataOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/FetchStepCountDataOperation.java @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations; +package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; @@ -34,7 +34,7 @@ import nodomain.freeyourgadget.gadgetbridge.entities.CasioGBX100ActivitySample; import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.CasioGBX100DeviceSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.CasioGBX100DeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus; import nodomain.freeyourgadget.gadgetbridge.util.GB; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/GetConfigurationOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/GetConfigurationOperation.java similarity index 99% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/GetConfigurationOperation.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/GetConfigurationOperation.java index 2ffbc6691..6d502cfed 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/GetConfigurationOperation.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/GetConfigurationOperation.java @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations; +package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; @@ -30,7 +30,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBApplication; import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.CasioGBX100DeviceSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.CasioGBX100DeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus; import nodomain.freeyourgadget.gadgetbridge.util.BcdUtil; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/InitOperationGBX100.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/InitOperation.java similarity index 97% rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/InitOperationGBX100.java rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/InitOperation.java index 6ae304826..f930cae1c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/InitOperationGBX100.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/gbx100/InitOperation.java @@ -14,7 +14,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations; +package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; @@ -22,6 +22,8 @@ import android.bluetooth.BluetoothGattCharacteristic; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.threeten.bp.ZonedDateTime; + import java.io.IOException; import java.util.Calendar; import java.util.UUID; @@ -32,17 +34,17 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.CasioGBX100DeviceSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.CasioGBX100DeviceSupport; -public class InitOperationGBX100 extends AbstractBTLEOperation { - private static final Logger LOG = LoggerFactory.getLogger(InitOperationGBX100.class); +public class InitOperation extends AbstractBTLEOperation { + private static final Logger LOG = LoggerFactory.getLogger(InitOperation.class); private final TransactionBuilder builder; private final CasioGBX100DeviceSupport support; private final boolean mFirstConnect; private boolean mWriteAllFeaturesInitPending = false; - public InitOperationGBX100(CasioGBX100DeviceSupport support, TransactionBuilder builder, boolean firstConnect) { + public InitOperation(CasioGBX100DeviceSupport support, TransactionBuilder builder, boolean firstConnect) { super(support); this.builder = builder; this.support = support; @@ -339,7 +341,7 @@ public class InitOperationGBX100 extends AbstractBTLEOperation. */ -package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations; +package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; @@ -33,7 +33,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants; import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser; import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation; import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder; -import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.CasioGBX100DeviceSupport; +import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.CasioGBX100DeviceSupport; import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus; import nodomain.freeyourgadget.gadgetbridge.util.BcdUtil; import nodomain.freeyourgadget.gadgetbridge.util.GBPrefs; @@ -323,4 +323,4 @@ public class SetConfigurationOperation extends AbstractBTLEOperation