Amazfit Bip: more debug output for events coming from the watch

master
Andreas Shimokawa 2017-09-16 00:20:33 +02:00
parent d49db12a0d
commit e5a8ca5374
2 changed files with 50 additions and 8 deletions

View File

@ -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 <http://www.gnu.org/licenses/>. */
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;
}

View File

@ -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