diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casiogb6900/CasioGB6900Constants.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/CasioConstants.java
similarity index 97%
rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casiogb6900/CasioGB6900Constants.java
rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/CasioConstants.java
index 3d907fbd5..1a2301baf 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casiogb6900/CasioGB6900Constants.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/CasioConstants.java
@@ -15,11 +15,11 @@
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.casiogb6900;
+package nodomain.freeyourgadget.gadgetbridge.devices.casio;
import java.util.UUID;
-public final class CasioGB6900Constants {
+public final class CasioConstants {
public static final UUID CASIO_VIRTUAL_SERVER_SERVICE = UUID.fromString("26eb0007-b012-49a8-b1f8-394fb2032b0f");
public static final UUID CASIO_VIRTUAL_SERVER_FEATURES = UUID.fromString("26eb0008-b012-49a8-b1f8-394fb2032b0f");
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casiogb6900/CasioGB6900DeviceCoordinator.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gb6900/CasioGB6900DeviceCoordinator.java
similarity index 91%
rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casiogb6900/CasioGB6900DeviceCoordinator.java
rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gb6900/CasioGB6900DeviceCoordinator.java
index 36174e84a..d3177f671 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casiogb6900/CasioGB6900DeviceCoordinator.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/casio/gb6900/CasioGB6900DeviceCoordinator.java
@@ -16,7 +16,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.casiogb6900;
+package nodomain.freeyourgadget.gadgetbridge.devices.casio.gb6900;
import android.app.Activity;
import android.content.Context;
@@ -27,9 +27,11 @@ import org.slf4j.LoggerFactory;
import androidx.annotation.NonNull;
import nodomain.freeyourgadget.gadgetbridge.GBException;
+import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
+import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants;
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@@ -43,13 +45,13 @@ public class CasioGB6900DeviceCoordinator extends AbstractDeviceCoordinator {
@NonNull
@Override
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
- if (candidate.supportsService(CasioGB6900Constants.CASIO_VIRTUAL_SERVER_SERVICE)) {
+ if (candidate.supportsService(CasioConstants.CASIO_VIRTUAL_SERVER_SERVICE)) {
return DeviceType.CASIOGB6900;
}
String name = candidate.getDevice().getName();
if (name != null) {
- if (name.startsWith("CASIO")) {
+ if (name.startsWith("CASIO") && (name.endsWith("6900B") || name.endsWith("5600B"))) {
return DeviceType.CASIOGB6900;
}
}
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 c4806ea69..bc9bed08d 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/DeviceSupportFactory.java
@@ -32,7 +32,7 @@ import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.banglejs.BangleJSDeviceSupport;
-import nodomain.freeyourgadget.gadgetbridge.service.devices.casiogb6900.CasioGB6900DeviceSupport;
+import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.CasioGB6900DeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.hplus.HPlusSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband5.AmazfitBand5Support;
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casiogb6900/CasioGB6900DeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioGB6900DeviceSupport.java
similarity index 85%
rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casiogb6900/CasioGB6900DeviceSupport.java
rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioGB6900DeviceSupport.java
index 4d75ff786..7f7b21559 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casiogb6900/CasioGB6900DeviceSupport.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/CasioGB6900DeviceSupport.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.casiogb6900;
+package nodomain.freeyourgadget.gadgetbridge.service.devices.casio;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothGatt;
@@ -38,7 +38,7 @@ import java.util.concurrent.TimeUnit;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventFindPhone;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
-import nodomain.freeyourgadget.gadgetbridge.devices.casiogb6900.CasioGB6900Constants;
+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;
@@ -53,7 +53,7 @@ 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.casiogb6900.operations.InitOperation;
+import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations.InitOperationGB6900;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.StringUtils;
@@ -65,7 +65,7 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
private MusicSpec mBufferMusicSpec = null;
private MusicStateSpec mBufferMusicStateSpec = null;
private BluetoothGatt mBtGatt = null;
- private CasioGB6900Constants.Model mModel = CasioGB6900Constants.Model.MODEL_CASIO_GENERIC;
+ private CasioConstants.Model mModel = CasioConstants.Model.MODEL_CASIO_GENERIC;
private boolean mFirstConnect = false;
private static final int mCasioSleepTime = 50;
@@ -73,26 +73,26 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
public CasioGB6900DeviceSupport() {
super(LOG);
addSupportedService(GattService.UUID_SERVICE_IMMEDIATE_ALERT);
- addSupportedService(CasioGB6900Constants.CASIO_VIRTUAL_SERVER_SERVICE);
- addSupportedService(CasioGB6900Constants.ALERT_SERVICE_UUID);
- addSupportedService(CasioGB6900Constants.CASIO_IMMEDIATE_ALERT_SERVICE_UUID);
- addSupportedService(CasioGB6900Constants.CURRENT_TIME_SERVICE_UUID);
- addSupportedService(CasioGB6900Constants.WATCH_CTRL_SERVICE_UUID);
- addSupportedService(CasioGB6900Constants.WATCH_FEATURES_SERVICE_UUID);
- addSupportedService(CasioGB6900Constants.CASIO_PHONE_ALERT_STATUS_SERVICE);
- addSupportedService(CasioGB6900Constants.MORE_ALERT_SERVICE_UUID);
- addSupportedService(CasioGB6900Constants.TX_POWER_SERVICE_UUID);
- addSupportedService(CasioGB6900Constants.LINK_LOSS_SERVICE);
- addSupportedService(CasioGB6900Constants.IMMEDIATE_ALERT_SERVICE_UUID);
+ addSupportedService(CasioConstants.CASIO_VIRTUAL_SERVER_SERVICE);
+ addSupportedService(CasioConstants.ALERT_SERVICE_UUID);
+ addSupportedService(CasioConstants.CASIO_IMMEDIATE_ALERT_SERVICE_UUID);
+ addSupportedService(CasioConstants.CURRENT_TIME_SERVICE_UUID);
+ addSupportedService(CasioConstants.WATCH_CTRL_SERVICE_UUID);
+ addSupportedService(CasioConstants.WATCH_FEATURES_SERVICE_UUID);
+ addSupportedService(CasioConstants.CASIO_PHONE_ALERT_STATUS_SERVICE);
+ addSupportedService(CasioConstants.MORE_ALERT_SERVICE_UUID);
+ addSupportedService(CasioConstants.TX_POWER_SERVICE_UUID);
+ addSupportedService(CasioConstants.LINK_LOSS_SERVICE);
+ addSupportedService(CasioConstants.IMMEDIATE_ALERT_SERVICE_UUID);
- BluetoothGattService casioGATTService = new BluetoothGattService(CasioGB6900Constants.WATCH_CTRL_SERVICE_UUID, BluetoothGattService.SERVICE_TYPE_PRIMARY);
- BluetoothGattCharacteristic bluetoothGATTCharacteristic = new BluetoothGattCharacteristic(CasioGB6900Constants.KEY_CONTAINER_CHARACTERISTIC_UUID, BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE, BluetoothGattCharacteristic.PERMISSION_WRITE);
+ BluetoothGattService casioGATTService = new BluetoothGattService(CasioConstants.WATCH_CTRL_SERVICE_UUID, BluetoothGattService.SERVICE_TYPE_PRIMARY);
+ BluetoothGattCharacteristic bluetoothGATTCharacteristic = new BluetoothGattCharacteristic(CasioConstants.KEY_CONTAINER_CHARACTERISTIC_UUID, BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE, BluetoothGattCharacteristic.PERMISSION_WRITE);
bluetoothGATTCharacteristic.setValue(new byte[0]);
- BluetoothGattCharacteristic bluetoothGATTCharacteristic2 = new BluetoothGattCharacteristic(CasioGB6900Constants.NAME_OF_APP_CHARACTERISTIC_UUID, BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ | BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED);
- bluetoothGATTCharacteristic2.setValue(CasioGB6900Constants.MUSIC_MESSAGE.getBytes());
+ BluetoothGattCharacteristic bluetoothGATTCharacteristic2 = new BluetoothGattCharacteristic(CasioConstants.NAME_OF_APP_CHARACTERISTIC_UUID, BluetoothGattCharacteristic.PROPERTY_READ, BluetoothGattCharacteristic.PERMISSION_READ | BluetoothGattCharacteristic.PERMISSION_READ_ENCRYPTED);
+ bluetoothGATTCharacteristic2.setValue(CasioConstants.MUSIC_MESSAGE.getBytes());
- BluetoothGattDescriptor bluetoothGattDescriptor = new BluetoothGattDescriptor(CasioGB6900Constants.CCC_DESCRIPTOR_UUID, BluetoothGattDescriptor.PERMISSION_READ | BluetoothGattDescriptor.PERMISSION_WRITE);
+ BluetoothGattDescriptor bluetoothGattDescriptor = new BluetoothGattDescriptor(CasioConstants.CCC_DESCRIPTOR_UUID, BluetoothGattDescriptor.PERMISSION_READ | BluetoothGattDescriptor.PERMISSION_WRITE);
bluetoothGattDescriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
bluetoothGATTCharacteristic2.addDescriptor(bluetoothGattDescriptor);
@@ -147,15 +147,15 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
String name = gbDevice.getName();
if(name.contains("5600B")) {
- mModel = CasioGB6900Constants.Model.MODEL_CASIO_5600B;
+ mModel = CasioConstants.Model.MODEL_CASIO_5600B;
} else if(name.contains("6900B")) {
- mModel = CasioGB6900Constants.Model.MODEL_CASIO_6900B;
+ mModel = CasioConstants.Model.MODEL_CASIO_6900B;
} else {
- mModel = CasioGB6900Constants.Model.MODEL_CASIO_GENERIC;
+ mModel = CasioConstants.Model.MODEL_CASIO_GENERIC;
}
try {
- new InitOperation(this, builder).perform();
+ new InitOperationGB6900(this, builder).perform();
} catch (IOException e) {
GB.toast(getContext(), "Initializing Casio watch failed", Toast.LENGTH_SHORT, GB.ERROR, e);
}
@@ -180,7 +180,7 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
return builder;
}
- CasioGB6900Constants.Model getModel() {
+ CasioConstants.Model getModel() {
return mModel;
}
@@ -192,18 +192,18 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
byte[] value = new byte[]{GattCharacteristic.MILD_ALERT};
- BluetoothGattService llService = mBtGatt.getService(CasioGB6900Constants.LINK_LOSS_SERVICE);
- BluetoothGattCharacteristic charact = llService.getCharacteristic(CasioGB6900Constants.ALERT_LEVEL_CHARACTERISTIC_UUID);
+ BluetoothGattService llService = mBtGatt.getService(CasioConstants.LINK_LOSS_SERVICE);
+ BluetoothGattCharacteristic charact = llService.getCharacteristic(CasioConstants.ALERT_LEVEL_CHARACTERISTIC_UUID);
builder.write(charact, value);
builder.wait(mCasioSleepTime);
}
private void addCharacteristics() {
mCasioCharacteristics.clear();
- mCasioCharacteristics.add(getCharacteristic(CasioGB6900Constants.CASIO_A_NOT_COM_SET_NOT));
- mCasioCharacteristics.add(getCharacteristic(CasioGB6900Constants.CASIO_A_NOT_W_REQ_NOT));
- mCasioCharacteristics.add(getCharacteristic(CasioGB6900Constants.ALERT_LEVEL_CHARACTERISTIC_UUID));
- mCasioCharacteristics.add(getCharacteristic(CasioGB6900Constants.RINGER_CONTROL_POINT));
+ mCasioCharacteristics.add(getCharacteristic(CasioConstants.CASIO_A_NOT_COM_SET_NOT));
+ mCasioCharacteristics.add(getCharacteristic(CasioConstants.CASIO_A_NOT_W_REQ_NOT));
+ mCasioCharacteristics.add(getCharacteristic(CasioConstants.ALERT_LEVEL_CHARACTERISTIC_UUID));
+ mCasioCharacteristics.add(getCharacteristic(CasioConstants.RINGER_CONTROL_POINT));
}
public boolean enableNotifications(TransactionBuilder builder, boolean enable) {
@@ -217,7 +217,7 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
public void readTxPowerLevel() {
try {
TransactionBuilder builder = performInitialized("readTxPowerLevel");
- builder.read(getCharacteristic(CasioGB6900Constants.TX_POWER_LEVEL_CHARACTERISTIC_UUID));
+ builder.read(getCharacteristic(CasioConstants.TX_POWER_LEVEL_CHARACTERISTIC_UUID));
builder.queue(getQueue());
} catch (IOException e) {
LOG.warn("readTxPowerLevel failed: " + e.getMessage());
@@ -243,7 +243,7 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
arr[8] = (byte)(int) TimeUnit.MILLISECONDS.toSeconds(256 * cal.get(Calendar.MILLISECOND));
arr[9] = 1; // or 0?
- BluetoothGattCharacteristic charact = getCharacteristic(CasioGB6900Constants.CURRENT_TIME_CHARACTERISTIC_UUID);
+ BluetoothGattCharacteristic charact = getCharacteristic(CasioConstants.CURRENT_TIME_CHARACTERISTIC_UUID);
if(charact != null) {
charact.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT);
builder.write(charact, arr);
@@ -259,7 +259,7 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
int dstOffset = (int)TimeUnit.MILLISECONDS.toMinutes(cal.get(Calendar.DST_OFFSET));
byte byte0 = (byte)(zoneOffset / 15);
byte byte1 = (byte)(dstOffset / 15);
- BluetoothGattCharacteristic charact = getCharacteristic(CasioGB6900Constants.LOCAL_TIME_CHARACTERISTIC_UUID);
+ BluetoothGattCharacteristic charact = getCharacteristic(CasioConstants.LOCAL_TIME_CHARACTERISTIC_UUID);
if(charact != null) {
builder.write(charact, new byte[]{byte0, byte1});
}
@@ -276,7 +276,7 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
byte0 |= 4; // Casio Phone Alert Status Service
byte0 |= 8; // Casio Immediate Alert Service
- BluetoothGattCharacteristic charact = getCharacteristic(CasioGB6900Constants.CASIO_VIRTUAL_SERVER_FEATURES);
+ BluetoothGattCharacteristic charact = getCharacteristic(CasioConstants.CASIO_VIRTUAL_SERVER_FEATURES);
if(charact != null) {
builder.write(charact, new byte[]{byte0, 0x00});
}
@@ -391,7 +391,7 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
if(data.length == 0)
return true;
- if(characteristicUUID.equals(CasioGB6900Constants.TX_POWER_LEVEL_CHARACTERISTIC_UUID)) {
+ if(characteristicUUID.equals(CasioConstants.TX_POWER_LEVEL_CHARACTERISTIC_UUID)) {
StringBuilder str = new StringBuilder("onCharacteristicRead: Received power level: ");
for(int i=0; i. */
-package nodomain.freeyourgadget.gadgetbridge.service.devices.casiogb6900;
+package nodomain.freeyourgadget.gadgetbridge.service.devices.casio;
import android.content.Context;
diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casiogb6900/operations/InitOperation.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/InitOperationGB6900.java
similarity index 90%
rename from app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casiogb6900/operations/InitOperation.java
rename to app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/InitOperationGB6900.java
index 184532ee0..1f82e2349 100644
--- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casiogb6900/operations/InitOperation.java
+++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/casio/operations/InitOperationGB6900.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.casiogb6900.operations;
+package nodomain.freeyourgadget.gadgetbridge.service.devices.casio.operations;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
@@ -25,21 +25,21 @@ import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.UUID;
-import nodomain.freeyourgadget.gadgetbridge.devices.casiogb6900.CasioGB6900Constants;
+import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants;
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.casiogb6900.CasioGB6900DeviceSupport;
+import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.CasioGB6900DeviceSupport;
-public class InitOperation extends AbstractBTLEOperation {
- private static final Logger LOG = LoggerFactory.getLogger(InitOperation.class);
+public class InitOperationGB6900 extends AbstractBTLEOperation {
+ private static final Logger LOG = LoggerFactory.getLogger(InitOperationGB6900.class);
private final TransactionBuilder builder;
private byte[] mBleSettings = null;
- public InitOperation(CasioGB6900DeviceSupport support, TransactionBuilder builder) {
+ public InitOperationGB6900(CasioGB6900DeviceSupport support, TransactionBuilder builder) {
super(support);
this.builder = builder;
builder.setGattCallback(this);
@@ -50,7 +50,7 @@ public class InitOperation extends AbstractBTLEOperation