mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 18:15:49 +01:00
Add alarm configuration and fix a few small bugs
This commit is contained in:
parent
dad7ba7aaa
commit
510d13037a
@ -74,6 +74,7 @@ public final class CasioGB6900Constants {
|
||||
public static final UUID TX_POWER_LEVEL_CHARACTERISTIC_UUID = UUID.fromString("00002a07-0000-1000-8000-00805f9b34fb");
|
||||
// Settings
|
||||
public static final UUID CASIO_SETTING_FOR_BLE_CHARACTERISTIC_UUID = UUID.fromString("26eb000f-b012-49a8-b1f8-394fb2032b0f");
|
||||
public static final UUID CASIO_SETTING_FOR_ALM_CHARACTERISTIC_UUID = UUID.fromString("26eb0013-b012-49a8-b1f8-394fb2032b0f");
|
||||
|
||||
// Notification Types
|
||||
|
||||
|
@ -118,7 +118,7 @@ public class CasioGB6900DeviceCoordinator extends AbstractDeviceCoordinator {
|
||||
|
||||
@Override
|
||||
public int getAlarmSlotCount() {
|
||||
return 0; // 4 regular and one snooze but not yet implemented
|
||||
return 5; // 4 regular and one snooze but not yet implemented
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -148,7 +148,6 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
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.FUNCTION_SWITCH_CHARACTERISTIC));
|
||||
mCasioCharacteristics.add(getCharacteristic(CasioGB6900Constants.ALERT_LEVEL_CHARACTERISTIC_UUID));
|
||||
mCasioCharacteristics.add(getCharacteristic(CasioGB6900Constants.RINGER_CONTROL_POINT));
|
||||
}
|
||||
@ -239,8 +238,8 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
LOG.info("Initialization done, setting state to INITIALIZED");
|
||||
if(mHandlerThread == null) {
|
||||
mHandlerThread = new CasioHandlerThread(getDevice(), getContext(), this);
|
||||
mHandlerThread.start();
|
||||
}
|
||||
mHandlerThread.start();
|
||||
gbDevice.setState(GBDevice.State.INITIALIZED);
|
||||
gbDevice.sendDeviceUpdateIntent(getContext());
|
||||
handled = true;
|
||||
@ -445,7 +444,30 @@ public class CasioGB6900DeviceSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
@Override
|
||||
public void onSetAlarms(ArrayList<? extends Alarm> alarms) {
|
||||
|
||||
int alarmOffset = 4;
|
||||
byte[] data = new byte[20];
|
||||
for(int i=0; i<alarms.size(); i++)
|
||||
{
|
||||
Alarm alm = alarms.get(i);
|
||||
if(alm.getEnabled()) {
|
||||
data[i * alarmOffset] = 0x40;
|
||||
} else {
|
||||
data[i * alarmOffset] = 0;
|
||||
}
|
||||
if(alm.getRepetition(Alarm.ALARM_ONCE)) {
|
||||
data[i * alarmOffset] |= 0x20;
|
||||
}
|
||||
data[i * alarmOffset + 1] = 0;
|
||||
data[i * alarmOffset + 2] = (byte)alm.getHour();
|
||||
data[i * alarmOffset + 3] = (byte)alm.getMinute();
|
||||
}
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("setAlarm");
|
||||
builder.write(getCharacteristic(CasioGB6900Constants.CASIO_SETTING_FOR_ALM_CHARACTERISTIC_UUID), data);
|
||||
builder.queue(getQueue());
|
||||
} catch(IOException e) {
|
||||
LOG.error("Error setting alarm: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,8 +75,11 @@ public class CasioHandlerThread extends GBDeviceIoThread {
|
||||
break;
|
||||
}
|
||||
|
||||
if (gbDevice.getState() == GBDevice.State.NOT_CONNECTED) {
|
||||
GBDevice.State state = gbDevice.getState();
|
||||
if (state == GBDevice.State.NOT_CONNECTED || state == GBDevice.State.WAITING_FOR_RECONNECT) {
|
||||
LOG.debug("Closing handler thread, state not connected or waiting for reconnect.");
|
||||
quit();
|
||||
continue;
|
||||
}
|
||||
|
||||
Calendar now = GregorianCalendar.getInstance();
|
||||
|
Loading…
Reference in New Issue
Block a user