mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 04:46:51 +01:00
Casio2C2D: refactor CasioConstants.characteristicToByte
This commit is contained in:
parent
ad7b50793a
commit
b6ba421a62
@ -145,29 +145,4 @@ public final class CasioConstants {
|
||||
|
||||
public static final int CASIO_AUTOREMOVE_MESSAGE_DELAY = 10000;
|
||||
|
||||
public static Map<String, Byte> characteristicToByte = new HashMap<String, Byte>() {
|
||||
{
|
||||
put("CASIO_WATCH_NAME", (byte) 0x23);
|
||||
put("CASIO_APP_INFORMATION", (byte) 0x22);
|
||||
put("CASIO_BLE_FEATURES", (byte) 0x10);
|
||||
put("CASIO_SETTING_FOR_BLE", (byte) 0x11);
|
||||
put("CASIO_ADVERTISE_PARAMETER_MANAGER", (byte) 0x3b);
|
||||
put("CASIO_CONNECTION_PARAMETER_MANAGER", (byte) 0x3a);
|
||||
put("CASIO_MODULE_ID", (byte) 0x26);
|
||||
put("CASIO_WATCH_CONDITION", (byte) 0x28);
|
||||
put("CASIO_VERSION_INFORMATION", (byte) 0x20);
|
||||
put("CASIO_DST_WATCH_STATE", (byte) 0x1d);
|
||||
put("CASIO_DST_SETTING", (byte) 0x1e);
|
||||
put("CASIO_WORLD_CITY", (byte) 0x1f);
|
||||
put("CASIO_SERVICE_DISCOVERY_MANAGER", (byte) 0x47);
|
||||
put("CASIO_CURRENT_TIME", (byte) 0x09);
|
||||
put("CASIO_SETTING_FOR_USER_PROFILE", (byte) 0x45);
|
||||
put("CASIO_SETTING_FOR_TARGET_VALUE", (byte) 0x43);
|
||||
put("ALERT_LEVEL", (byte) 0x0a);
|
||||
put("CASIO_SETTING_FOR_ALM", (byte) 0x15);
|
||||
put("CASIO_SETTING_FOR_ALM2", (byte) 0x16);
|
||||
put("CASIO_SETTING_FOR_BASIC", (byte) 0x13);
|
||||
put("CASIO_CURRENT_TIME_MANAGER", (byte) 0x39);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -30,6 +30,29 @@ import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants;
|
||||
|
||||
public abstract class Casio2C2DSupport extends CasioSupport {
|
||||
|
||||
public static final byte FEATURE_CURRENT_TIME = 0x09;
|
||||
public static final byte FEATURE_ALERT_LEVEL = 0x0a;
|
||||
public static final byte FEATURE_BLE_FEATURES = 0x10;
|
||||
public static final byte FEATURE_SETTING_FOR_BLE = 0x11;
|
||||
public static final byte FEATURE_SETTING_FOR_BASIC = 0x13;
|
||||
public static final byte FEATURE_SETTING_FOR_ALM = 0x15;
|
||||
public static final byte FEATURE_SETTING_FOR_ALM2 = 0x16;
|
||||
public static final byte FEATURE_VERSION_INFORMATION = 0x20;
|
||||
public static final byte FEATURE_APP_INFORMATION = 0x22;
|
||||
public static final byte FEATURE_WATCH_NAME = 0x23;
|
||||
public static final byte FEATURE_MODULE_ID = 0x26;
|
||||
public static final byte FEATURE_WATCH_CONDITION = 0x28;
|
||||
public static final byte FEATURE_DST_WATCH_STATE = 0x1d;
|
||||
public static final byte FEATURE_DST_SETTING = 0x1e;
|
||||
public static final byte FEATURE_WORLD_CITY = 0x1f;
|
||||
public static final byte FEATURE_CURRENT_TIME_MANAGER = 0x39;
|
||||
public static final byte FEATURE_CONNECTION_PARAMETER_MANAGER = 0x3a;
|
||||
public static final byte FEATURE_ADVERTISE_PARAMETER_MANAGER = 0x3b;
|
||||
public static final byte FEATURE_SETTING_FOR_TARGET_VALUE = 0x43;
|
||||
public static final byte FEATURE_SETTING_FOR_USER_PROFILE = 0x45;
|
||||
public static final byte FEATURE_SERVICE_DISCOVERY_MANAGER = 0x47;
|
||||
|
||||
|
||||
public Casio2C2DSupport(Logger logger) {
|
||||
super(logger);
|
||||
}
|
||||
@ -44,7 +67,7 @@ public abstract class Casio2C2DSupport extends CasioSupport {
|
||||
|
||||
public void writeCurrentTime(TransactionBuilder builder, ZonedDateTime time) {
|
||||
byte[] arr = new byte[11];
|
||||
arr[0] = CasioConstants.characteristicToByte.get("CASIO_CURRENT_TIME");
|
||||
arr[0] = FEATURE_CURRENT_TIME;
|
||||
byte[] tmp = prepareCurrentTime(time);
|
||||
System.arraycopy(tmp, 0, arr, 1, 10);
|
||||
|
||||
|
@ -211,14 +211,14 @@ public class CasioGBX100DeviceSupport extends Casio2C2DSupport implements Shared
|
||||
return true;
|
||||
|
||||
if (characteristicUUID.equals(CasioConstants.CASIO_ALL_FEATURES_CHARACTERISTIC_UUID)) {
|
||||
if(data[0] == CasioConstants.characteristicToByte.get("ALERT_LEVEL")) {
|
||||
if(data[0] == FEATURE_ALERT_LEVEL) {
|
||||
if(data[1] == 0x02) {
|
||||
onReverseFindDevice(true);
|
||||
} else {
|
||||
onReverseFindDevice(false);
|
||||
}
|
||||
return true;
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_CURRENT_TIME_MANAGER")) {
|
||||
} else if(data[0] == FEATURE_CURRENT_TIME_MANAGER) {
|
||||
if(data[1] == 0x00) {
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("writeCurrentTime");
|
||||
@ -509,8 +509,8 @@ public class CasioGBX100DeviceSupport extends Casio2C2DSupport implements Shared
|
||||
if(!isConnected())
|
||||
return;
|
||||
|
||||
data1[0] = CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_ALM");
|
||||
data2[0] = CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_ALM2");
|
||||
data1[0] = FEATURE_SETTING_FOR_ALM;
|
||||
data2[0] = FEATURE_SETTING_FOR_ALM2;
|
||||
|
||||
for(int i=0; i<alarms.size(); i++)
|
||||
{
|
||||
|
@ -30,6 +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.Casio2C2DSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.CasioGBX100DeviceSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.BcdUtil;
|
||||
@ -59,7 +60,7 @@ public class GetConfigurationOperation extends AbstractBTLEOperation<CasioGBX100
|
||||
@Override
|
||||
protected void doPerform() throws IOException {
|
||||
byte[] command = new byte[1];
|
||||
command[0] = CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_USER_PROFILE");
|
||||
command[0] = Casio2C2DSupport.FEATURE_SETTING_FOR_USER_PROFILE;
|
||||
TransactionBuilder builder = performInitialized("getConfiguration");
|
||||
builder.setCallback(this);
|
||||
support.writeAllFeaturesRequest(builder, command);
|
||||
@ -85,7 +86,7 @@ public class GetConfigurationOperation extends AbstractBTLEOperation<CasioGBX100
|
||||
|
||||
private void requestBasicSettings() {
|
||||
byte[] command = new byte[1];
|
||||
command[0] = CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_BASIC");
|
||||
command[0] = Casio2C2DSupport.FEATURE_SETTING_FOR_BASIC;
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("getConfiguration");
|
||||
builder.setCallback(this);
|
||||
@ -106,7 +107,7 @@ public class GetConfigurationOperation extends AbstractBTLEOperation<CasioGBX100
|
||||
return true;
|
||||
|
||||
if (characteristicUUID.equals(CasioConstants.CASIO_ALL_FEATURES_CHARACTERISTIC_UUID)) {
|
||||
if (data[0] == CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_USER_PROFILE")) {
|
||||
if (data[0] == Casio2C2DSupport.FEATURE_SETTING_FOR_USER_PROFILE) {
|
||||
boolean female = ((data[1] & 0x01) == 0x01);
|
||||
boolean right = ((data[1] & 0x02) == 0x02);
|
||||
byte[] compData = new byte[data.length];
|
||||
@ -129,7 +130,7 @@ public class GetConfigurationOperation extends AbstractBTLEOperation<CasioGBX100
|
||||
requestBasicSettings();
|
||||
|
||||
return true;
|
||||
} else if (data[0] == CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_BASIC")) {
|
||||
} else if (data[0] == Casio2C2DSupport.FEATURE_SETTING_FOR_BASIC) {
|
||||
boolean timeformat = ((data[1] & 0x01) == 0x01);
|
||||
boolean autolight = ((data[1] & 0x04) == 0x00);
|
||||
boolean key_vibration = (data[10] == 0x01);
|
||||
|
@ -31,6 +31,8 @@ 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.Casio2C2DSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.CasioGBX100DeviceSupport;
|
||||
|
||||
public class InitOperation extends AbstractBTLEOperation<CasioGBX100DeviceSupport> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(InitOperation.class);
|
||||
@ -91,47 +93,47 @@ public class InitOperation extends AbstractBTLEOperation<CasioGBX100DeviceSuppor
|
||||
}
|
||||
|
||||
private void requestWatchName(TransactionBuilder builder) {
|
||||
support.writeAllFeaturesRequest(builder, new byte[]{CasioConstants.characteristicToByte.get("CASIO_WATCH_NAME")});
|
||||
support.writeAllFeaturesRequest(builder, new byte[]{Casio2C2DSupport.FEATURE_WATCH_NAME});
|
||||
}
|
||||
|
||||
private void requestWatchName() {
|
||||
writeAllFeaturesRequest(new byte[]{CasioConstants.characteristicToByte.get("CASIO_WATCH_NAME")});
|
||||
writeAllFeaturesRequest(new byte[]{Casio2C2DSupport.FEATURE_WATCH_NAME});
|
||||
}
|
||||
|
||||
private void requestBleConfiguration() {
|
||||
writeAllFeaturesRequest(new byte[]{CasioConstants.characteristicToByte.get("CASIO_BLE_FEATURES")});
|
||||
writeAllFeaturesRequest(new byte[]{Casio2C2DSupport.FEATURE_BLE_FEATURES});
|
||||
}
|
||||
|
||||
private void requestBleSettings() {
|
||||
writeAllFeaturesRequest(new byte[]{CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_BLE")});
|
||||
writeAllFeaturesRequest(new byte[]{Casio2C2DSupport.FEATURE_SETTING_FOR_BLE});
|
||||
}
|
||||
|
||||
private void requestAdvertisingParameters() {
|
||||
writeAllFeaturesRequest(new byte[]{CasioConstants.characteristicToByte.get("CASIO_ADVERTISE_PARAMETER_MANAGER")});
|
||||
writeAllFeaturesRequest(new byte[]{Casio2C2DSupport.FEATURE_ADVERTISE_PARAMETER_MANAGER});
|
||||
}
|
||||
|
||||
private void requestConnectionParameters() {
|
||||
writeAllFeaturesRequest(new byte[]{CasioConstants.characteristicToByte.get("CASIO_CONNECTION_PARAMETER_MANAGER")});
|
||||
writeAllFeaturesRequest(new byte[]{Casio2C2DSupport.FEATURE_CONNECTION_PARAMETER_MANAGER});
|
||||
}
|
||||
|
||||
private void requestModuleId() {
|
||||
writeAllFeaturesRequest(new byte[]{CasioConstants.characteristicToByte.get("CASIO_MODULE_ID")});
|
||||
writeAllFeaturesRequest(new byte[]{Casio2C2DSupport.FEATURE_MODULE_ID});
|
||||
}
|
||||
|
||||
private void requestWatchCondition() {
|
||||
writeAllFeaturesRequest(new byte[]{CasioConstants.characteristicToByte.get("CASIO_WATCH_CONDITION")});
|
||||
writeAllFeaturesRequest(new byte[]{Casio2C2DSupport.FEATURE_WATCH_CONDITION});
|
||||
}
|
||||
|
||||
private void requestVersionInformation() {
|
||||
writeAllFeaturesRequest(new byte[]{CasioConstants.characteristicToByte.get("CASIO_VERSION_INFORMATION")});
|
||||
writeAllFeaturesRequest(new byte[]{Casio2C2DSupport.FEATURE_VERSION_INFORMATION});
|
||||
}
|
||||
|
||||
private void requestDstWatchState() {
|
||||
writeAllFeaturesRequest(new byte[]{CasioConstants.characteristicToByte.get("CASIO_DST_WATCH_STATE")});
|
||||
writeAllFeaturesRequest(new byte[]{Casio2C2DSupport.FEATURE_DST_WATCH_STATE});
|
||||
}
|
||||
|
||||
private void requestDstSetting() {
|
||||
writeAllFeaturesRequest(new byte[]{CasioConstants.characteristicToByte.get("CASIO_DST_SETTING")});
|
||||
writeAllFeaturesRequest(new byte[]{Casio2C2DSupport.FEATURE_DST_SETTING});
|
||||
}
|
||||
|
||||
private void writeAppInformation() {
|
||||
@ -139,7 +141,7 @@ public class InitOperation extends AbstractBTLEOperation<CasioGBX100DeviceSuppor
|
||||
// preferences instead of hard-coding it here
|
||||
// CASIO_APP_INFORMATION:
|
||||
byte arr[] = new byte[12];
|
||||
arr[0] = CasioConstants.characteristicToByte.get("CASIO_APP_INFORMATION");
|
||||
arr[0] = Casio2C2DSupport.FEATURE_APP_INFORMATION;
|
||||
for(int i=0; i<10; i++)
|
||||
arr[i+1] = (byte) (i & 0xff);
|
||||
arr[11] = 2;
|
||||
@ -196,7 +198,7 @@ public class InitOperation extends AbstractBTLEOperation<CasioGBX100DeviceSuppor
|
||||
// arr[18] = advertiseParamPeriodUntilSuspensionOfAutoAdvertise >> 8 & 0xff;
|
||||
|
||||
byte arr[] = new byte[20];
|
||||
arr[0] = CasioConstants.characteristicToByte.get("CASIO_ADVERTISE_PARAMETER_MANAGER");
|
||||
arr[0] = Casio2C2DSupport.FEATURE_ADVERTISE_PARAMETER_MANAGER;
|
||||
arr[1] = (byte)0x50;
|
||||
arr[2] = (byte)0x00;
|
||||
arr[3] = (byte)0x0a;
|
||||
@ -236,7 +238,7 @@ public class InitOperation extends AbstractBTLEOperation<CasioGBX100DeviceSuppor
|
||||
// arr[8] = connectionParamSupervisionTimeout >> 8 & 0xff;
|
||||
|
||||
byte[] arr = new byte[10];
|
||||
arr[0] = CasioConstants.characteristicToByte.get("CASIO_CONNECTION_PARAMETER_MANAGER");
|
||||
arr[0] = Casio2C2DSupport.FEATURE_CONNECTION_PARAMETER_MANAGER;
|
||||
arr[1] = (byte)0x00;
|
||||
arr[2] = (byte)0x34;
|
||||
arr[3] = (byte)0x01;
|
||||
@ -292,43 +294,43 @@ public class InitOperation extends AbstractBTLEOperation<CasioGBX100DeviceSuppor
|
||||
}
|
||||
|
||||
if(characteristicUUID.equals(CasioConstants.CASIO_ALL_FEATURES_CHARACTERISTIC_UUID)) {
|
||||
if(data[0] == CasioConstants.characteristicToByte.get("CASIO_WATCH_NAME")) {
|
||||
if(data[0] == Casio2C2DSupport.FEATURE_WATCH_NAME) {
|
||||
LOG.debug("Got watch name, requesting BLE features; should write CASIO_APP_INFORMATION");
|
||||
writeAppInformation();
|
||||
// The rest of the init sequence is not strictly needed; we keep
|
||||
// it here for future reference.
|
||||
if(mFirstConnect)
|
||||
requestBleConfiguration();
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_BLE_FEATURES")) {
|
||||
} else if(data[0] == Casio2C2DSupport.FEATURE_BLE_FEATURES) {
|
||||
LOG.debug("Got BLE features, requesting BLE settings");
|
||||
requestBleSettings();
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_BLE")) {
|
||||
} else if(data[0] == Casio2C2DSupport.FEATURE_SETTING_FOR_BLE) {
|
||||
LOG.debug("Got BLE settings, requesting advertisement parameters; should write BLE settings");
|
||||
writeBleSettings(data);
|
||||
requestAdvertisingParameters();
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_ADVERTISE_PARAMETER_MANAGER")) {
|
||||
} else if(data[0] == Casio2C2DSupport.FEATURE_ADVERTISE_PARAMETER_MANAGER) {
|
||||
LOG.debug("Got advertisement parameters, requesting connection parameters; should write advertisement parameters");
|
||||
writeAdvertisingParameters();
|
||||
requestConnectionParameters();
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_CONNECTION_PARAMETER_MANAGER")) {
|
||||
} else if(data[0] == Casio2C2DSupport.FEATURE_CONNECTION_PARAMETER_MANAGER) {
|
||||
LOG.debug("Got connection parameters, requesting module ID; should write connection parameters");
|
||||
writeConnectionParameters();
|
||||
requestModuleId();
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_MODULE_ID")) {
|
||||
} else if(data[0] == Casio2C2DSupport.FEATURE_MODULE_ID) {
|
||||
LOG.debug("Got module ID, requesting watch condition");
|
||||
requestWatchCondition();
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_WATCH_CONDITION")) {
|
||||
} else if(data[0] == Casio2C2DSupport.FEATURE_WATCH_CONDITION) {
|
||||
LOG.debug("Got watch condition, requesting version information");
|
||||
requestVersionInformation();
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_VERSION_INFORMATION")) {
|
||||
} else if(data[0] == Casio2C2DSupport.FEATURE_VERSION_INFORMATION) {
|
||||
LOG.debug("Got version information, requesting DST watch state");
|
||||
requestDstWatchState();
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_DST_WATCH_STATE")) {
|
||||
} else if(data[0] == Casio2C2DSupport.FEATURE_DST_WATCH_STATE) {
|
||||
LOG.debug("Got DST watch state, requesting DST setting; should write DST watch state");
|
||||
requestDstSetting();
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_DST_SETTING")) {
|
||||
} else if(data[0] == Casio2C2DSupport.FEATURE_DST_SETTING) {
|
||||
LOG.debug("Got DST setting, waiting...; should write DST setting and location and radio information");
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_SERVICE_DISCOVERY_MANAGER")) {
|
||||
} else if(data[0] == Casio2C2DSupport.FEATURE_SERVICE_DISCOVERY_MANAGER) {
|
||||
if(data[1] == 0x02) {
|
||||
// The writeAllFeaturesInit request triggers bonding. However, the transaction
|
||||
// never completes. Instead, the watch sends 0x4701 notification and we abort
|
||||
|
@ -33,6 +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.Casio2C2DSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gbx100.CasioGBX100DeviceSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.BcdUtil;
|
||||
@ -65,7 +66,7 @@ public class SetConfigurationOperation extends AbstractBTLEOperation<CasioGBX10
|
||||
@Override
|
||||
protected void doPerform() throws IOException {
|
||||
byte[] command = new byte[1];
|
||||
command[0] = CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_USER_PROFILE");
|
||||
command[0] = Casio2C2DSupport.FEATURE_SETTING_FOR_USER_PROFILE;
|
||||
TransactionBuilder builder = performInitialized("getConfiguration");
|
||||
builder.setCallback(this);
|
||||
support.writeAllFeaturesRequest(builder, command);
|
||||
@ -85,7 +86,7 @@ public class SetConfigurationOperation extends AbstractBTLEOperation<CasioGBX10
|
||||
byte[] oldData = new byte[data.length];
|
||||
System.arraycopy(data, 0, oldData, 0, data.length);
|
||||
|
||||
if (data[0] == CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_USER_PROFILE")) {
|
||||
if (data[0] == Casio2C2DSupport.FEATURE_SETTING_FOR_USER_PROFILE) {
|
||||
|
||||
ActivityUser user = new ActivityUser();
|
||||
boolean all = (option == CasioConstants.ConfigurationOption.OPTION_ALL);
|
||||
@ -158,7 +159,7 @@ public class SetConfigurationOperation extends AbstractBTLEOperation<CasioGBX10
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (data[0] == CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_TARGET_VALUE")) {
|
||||
} else if (data[0] == Casio2C2DSupport.FEATURE_SETTING_FOR_TARGET_VALUE) {
|
||||
ActivityUser user = new ActivityUser();
|
||||
boolean all = (option == CasioConstants.ConfigurationOption.OPTION_ALL);
|
||||
|
||||
@ -199,7 +200,7 @@ public class SetConfigurationOperation extends AbstractBTLEOperation<CasioGBX10
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if(data[0] == CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_BASIC")) {
|
||||
} else if(data[0] == Casio2C2DSupport.FEATURE_SETTING_FOR_BASIC) {
|
||||
SharedPreferences sharedPreferences = GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress());
|
||||
GBPrefs gbPrefs = new GBPrefs(new Prefs(GBApplication.getDeviceSpecificSharedPrefs(getDevice().getAddress())));
|
||||
|
||||
@ -274,7 +275,7 @@ public class SetConfigurationOperation extends AbstractBTLEOperation<CasioGBX10
|
||||
|
||||
private void requestBasicSettings() {
|
||||
byte[] command = new byte[1];
|
||||
command[0] = CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_BASIC");
|
||||
command[0] = Casio2C2DSupport.FEATURE_SETTING_FOR_BASIC;
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("getConfiguration");
|
||||
builder.setCallback(this);
|
||||
@ -287,7 +288,7 @@ public class SetConfigurationOperation extends AbstractBTLEOperation<CasioGBX10
|
||||
|
||||
private void requestTargetSettings() {
|
||||
byte[] command = new byte[1];
|
||||
command[0] = CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_TARGET_VALUE");
|
||||
command[0] = Casio2C2DSupport.FEATURE_SETTING_FOR_TARGET_VALUE;
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("getConfiguration");
|
||||
builder.setCallback(this);
|
||||
@ -308,15 +309,15 @@ public class SetConfigurationOperation extends AbstractBTLEOperation<CasioGBX10
|
||||
return true;
|
||||
|
||||
if (characteristicUUID.equals(CasioConstants.CASIO_ALL_FEATURES_CHARACTERISTIC_UUID)) {
|
||||
if(data[0] == CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_USER_PROFILE")) {
|
||||
if(data[0] == Casio2C2DSupport.FEATURE_SETTING_FOR_USER_PROFILE) {
|
||||
requestTargetSettings();
|
||||
return true;
|
||||
}
|
||||
if(data[0] == CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_TARGET_VALUE")) {
|
||||
if(data[0] == Casio2C2DSupport.FEATURE_SETTING_FOR_TARGET_VALUE) {
|
||||
requestBasicSettings();
|
||||
return true;
|
||||
}
|
||||
if(data[0] == CasioConstants.characteristicToByte.get("CASIO_SETTING_FOR_BASIC")) {
|
||||
if(data[0] == Casio2C2DSupport.FEATURE_SETTING_FOR_BASIC) {
|
||||
operationFinished();
|
||||
return true;
|
||||
}
|
||||
|
@ -69,4 +69,5 @@ public class CasioGWB5600DeviceSupport extends Casio2C2DSupport {
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,8 @@ import java.time.zone.ZoneRules;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.Casio2C2DSupport;
|
||||
|
||||
|
||||
public class CasioGWB5600TimeZone {
|
||||
|
||||
@ -130,13 +131,13 @@ PONTA DELGADA E4 00 FC 04 02
|
||||
static public byte[] dstWatchStateRequest(int slot) {
|
||||
// request only even slots, the response will also contain the next odd slot
|
||||
return new byte[] {
|
||||
CasioConstants.characteristicToByte.get("CASIO_DST_WATCH_STATE"),
|
||||
Casio2C2DSupport.FEATURE_DST_WATCH_STATE,
|
||||
(byte) slot};
|
||||
}
|
||||
|
||||
static public byte[] dstWatchStateBytes(int slotA, CasioGWB5600TimeZone zoneA, int slotB, CasioGWB5600TimeZone zoneB) {
|
||||
return new byte[] {
|
||||
CasioConstants.characteristicToByte.get("CASIO_DST_WATCH_STATE"),
|
||||
Casio2C2DSupport.FEATURE_DST_WATCH_STATE,
|
||||
(byte) slotA,
|
||||
(byte) slotB,
|
||||
zoneA.dstSetting,
|
||||
@ -150,13 +151,13 @@ PONTA DELGADA E4 00 FC 04 02
|
||||
|
||||
static public byte[] dstSettingRequest(int slot) {
|
||||
return new byte[] {
|
||||
CasioConstants.characteristicToByte.get("CASIO_DST_SETTING"),
|
||||
Casio2C2DSupport.FEATURE_DST_SETTING,
|
||||
(byte) slot};
|
||||
}
|
||||
|
||||
public byte[] dstSettingBytes(int slot) {
|
||||
return new byte[] {
|
||||
CasioConstants.characteristicToByte.get("CASIO_DST_SETTING"),
|
||||
Casio2C2DSupport.FEATURE_DST_SETTING,
|
||||
(byte) slot,
|
||||
number[0],
|
||||
number[1],
|
||||
@ -167,13 +168,13 @@ PONTA DELGADA E4 00 FC 04 02
|
||||
|
||||
static public byte[] worldCityRequest(int slot) {
|
||||
return new byte[] {
|
||||
CasioConstants.characteristicToByte.get("CASIO_WORLD_CITY"),
|
||||
Casio2C2DSupport.FEATURE_WORLD_CITY,
|
||||
(byte) slot};
|
||||
}
|
||||
|
||||
public byte[] worldCityBytes(int slot) {
|
||||
byte[] bytes = {
|
||||
CasioConstants.characteristicToByte.get("CASIO_WORLD_CITY"),
|
||||
Casio2C2DSupport.FEATURE_WORLD_CITY,
|
||||
(byte) slot,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
|
||||
System.arraycopy(name, 0, bytes, 2, Math.min(name.length, 18));
|
||||
@ -189,7 +190,7 @@ PONTA DELGADA E4 00 FC 04 02
|
||||
byte dstSetting = 0;
|
||||
|
||||
for (byte[] response: responses) {
|
||||
if (response[0] == CasioConstants.characteristicToByte.get("CASIO_DST_WATCH_STATE") && response.length >= 9) {
|
||||
if (response[0] == Casio2C2DSupport.FEATURE_DST_WATCH_STATE && response.length >= 9) {
|
||||
if (response[1] == slot) {
|
||||
dstSetting = response[3];
|
||||
number = new byte[] {response[5], response[6]};
|
||||
@ -198,12 +199,12 @@ PONTA DELGADA E4 00 FC 04 02
|
||||
dstSetting = response[4];
|
||||
number = new byte[] {response[7], response[8]};
|
||||
}
|
||||
} else if (response[0] == CasioConstants.characteristicToByte.get("CASIO_DST_SETTING") && response.length >= 7 && response[1] == slot) {
|
||||
} else if (response[0] == Casio2C2DSupport.FEATURE_DST_SETTING && response.length >= 7 && response[1] == slot) {
|
||||
number = new byte[] {response[2], response[3]};
|
||||
offset = response[4];
|
||||
dstOffset = response[5];
|
||||
dstRules = response[6];
|
||||
} else if (response[0] == CasioConstants.characteristicToByte.get("CASIO_WORLD_CITY") && response.length >= 2 && response[1] == slot) {
|
||||
} else if (response[0] == Casio2C2DSupport.FEATURE_WORLD_CITY && response.length >= 2 && response[1] == slot) {
|
||||
int size;
|
||||
for (size = 0; size < response.length-2; size++) {
|
||||
if (response[2+size] == 0) {
|
||||
|
@ -39,6 +39,10 @@ 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.miband.operations.OperationStatus;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.casio.CasioConstants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.Casio2C2DSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gwb5600.CasioGWB5600DeviceSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.casio.gwb5600.CasioGWB5600TimeZone;
|
||||
|
||||
public class InitOperation extends AbstractBTLEOperation<CasioGWB5600DeviceSupport> {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(InitOperation.class);
|
||||
@ -79,9 +83,9 @@ public class InitOperation extends AbstractBTLEOperation<CasioGWB5600DeviceSuppo
|
||||
byte[] data = characteristic.getValue();
|
||||
|
||||
if (characteristicUUID.equals(CasioConstants.CASIO_ALL_FEATURES_CHARACTERISTIC_UUID) && data.length > 0 &&
|
||||
(data[0] == CasioConstants.characteristicToByte.get("CASIO_DST_WATCH_STATE") ||
|
||||
data[0] == CasioConstants.characteristicToByte.get("CASIO_DST_SETTING") ||
|
||||
data[0] == CasioConstants.characteristicToByte.get("CASIO_WORLD_CITY"))) {
|
||||
(data[0] == Casio2C2DSupport.FEATURE_DST_WATCH_STATE ||
|
||||
data[0] == Casio2C2DSupport.FEATURE_DST_SETTING ||
|
||||
data[0] == Casio2C2DSupport.FEATURE_WORLD_CITY)) {
|
||||
responses.add(data);
|
||||
if (responses.size() == 13) {
|
||||
TransactionBuilder builder = createTransactionBuilder("setClocks");
|
||||
|
Loading…
Reference in New Issue
Block a user