diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipEvent.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipEvent.java new file mode 100644 index 000000000..4ab1db74c --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipEvent.java @@ -0,0 +1,27 @@ +/* Copyright (C) 2017 Andreas Shimokawa + + 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.amazfitbip; + + +public class AmazfitBipEvent { + public static final byte BUTTON_PRESSED = 0x04; + public static final byte START_NONWEAR = 0x06; + public static final byte CALL_REJECT = 0x07; + public static final byte CALL_ACCEPT = 0x09; + public static final byte ALARM_TOGGLED = 0x0a; + public static final byte BUTTON_PRESSED_LONG = 0x0b; +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java index 1c456853d..f95db3271 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/amazfitbip/AmazfitBipSupport.java @@ -118,15 +118,30 @@ public class AmazfitBipSupport extends MiBand2Support { } GBDeviceEventCallControl callCmd = new GBDeviceEventCallControl(); - if (value[0] == 0x07) { - callCmd.event = GBDeviceEventCallControl.Event.REJECT; - } else if (value[0] == 0x09) { - callCmd.event = GBDeviceEventCallControl.Event.ACCEPT; - } else { - LOG.info("Unhandled button press: " + Logging.formatBytes(value)); - return; + switch (value[0]) { + case AmazfitBipEvent.CALL_REJECT: + callCmd.event = GBDeviceEventCallControl.Event.REJECT; + evaluateGBDeviceEvent(callCmd); + break; + case AmazfitBipEvent.CALL_ACCEPT: + callCmd.event = GBDeviceEventCallControl.Event.ACCEPT; + evaluateGBDeviceEvent(callCmd); + break; + case AmazfitBipEvent.BUTTON_PRESSED: + LOG.info("button pressed"); + break; + case AmazfitBipEvent.BUTTON_PRESSED_LONG: + LOG.info("button long-pressed "); + break; + case AmazfitBipEvent.START_NONWEAR: + LOG.info("non-wear start detected"); + break; + case AmazfitBipEvent.ALARM_TOGGLED: + LOG.info("An alarm was toggled"); // TODO: sync alarms watch -> GB + break; + default: + LOG.warn("unhandled event " + value[0]); } - evaluateGBDeviceEvent(callCmd); } @Override