Widget: Also update for Pebble Misfit and Morpheuz

This commit also removes GBDeviceEventSleepMonitorResult since it was unused and highly Morpheuz specific
This commit is contained in:
Andreas Shimokawa 2019-09-16 22:48:21 +02:00
parent a63cd90876
commit fcc9ad8f95
4 changed files with 6 additions and 50 deletions

View File

@ -1,25 +0,0 @@
/* Copyright (C) 2015-2019 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.deviceevents;
public class GBDeviceEventSleepMonitorResult extends GBDeviceEvent {
// FIXME: this is just the low-level data from Morpheuz, we need something generic
public int smartalarm_from = -1; // time in minutes relative from 0:00 for smart alarm (earliest)
public int smartalarm_to = -1;// time in minutes relative from 0:00 for smart alarm (latest)
public int recording_base_timestamp = -1; // timestamp for the first "point", all folowing are +10 minutes offset each
public int alarm_gone_off = -1; // time in minutes relative from 0:00 when alarm gone off
}

View File

@ -58,7 +58,6 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventLEDColor;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventNotificationControl;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventScreenshot;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSleepMonitorResult;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
import nodomain.freeyourgadget.gadgetbridge.externalevents.NotificationListener;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
@ -151,8 +150,6 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
handleGBDeviceEvent((GBDeviceEventVersionInfo) deviceEvent);
} else if (deviceEvent instanceof GBDeviceEventAppInfo) {
handleGBDeviceEvent((GBDeviceEventAppInfo) deviceEvent);
} else if (deviceEvent instanceof GBDeviceEventSleepMonitorResult) {
handleGBDeviceEvent((GBDeviceEventSleepMonitorResult) deviceEvent);
} else if (deviceEvent instanceof GBDeviceEventScreenshot) {
handleGBDeviceEvent((GBDeviceEventScreenshot) deviceEvent);
} else if (deviceEvent instanceof GBDeviceEventNotificationControl) {
@ -258,18 +255,6 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
LocalBroadcastManager.getInstance(context).sendBroadcast(appInfoIntent);
}
private void handleGBDeviceEvent(GBDeviceEventSleepMonitorResult sleepMonitorResult) {
Context context = getContext();
LOG.info("Got event for SLEEP_MONIOR_RES");
Intent sleepMonitorIntent = new Intent(ChartsHost.REFRESH);
sleepMonitorIntent.putExtra("smartalarm_from", sleepMonitorResult.smartalarm_from);
sleepMonitorIntent.putExtra("smartalarm_to", sleepMonitorResult.smartalarm_to);
sleepMonitorIntent.putExtra("recording_base_timestamp", sleepMonitorResult.recording_base_timestamp);
sleepMonitorIntent.putExtra("alarm_gone_off", sleepMonitorResult.alarm_gone_off);
LocalBroadcastManager.getInstance(context).sendBroadcast(sleepMonitorIntent);
}
private void handleGBDeviceEvent(GBDeviceEventScreenshot screenshot) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-hhmmss", Locale.US);
String filename = "screenshot_" + dateFormat.format(new Date()) + ".bmp";

View File

@ -36,6 +36,7 @@ import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleMisfitSampleProvider;
import nodomain.freeyourgadget.gadgetbridge.entities.PebbleMisfitSample;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import nodomain.freeyourgadget.gadgetbridge.util.Prefs;
class AppMessageHandlerMisfit extends AppMessageHandler {
@ -71,6 +72,7 @@ class AppMessageHandlerMisfit extends AppMessageHandler {
LOG.info("incoming data start");
break;
case KEY_INCOMING_DATA_END:
GB.signalActivityDataFinish();
LOG.info("incoming data end");
break;
case KEY_INCOMING_DATA:

View File

@ -35,7 +35,6 @@ import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSleepMonitorResult;
import nodomain.freeyourgadget.gadgetbridge.devices.pebble.PebbleMorpheuzSampleProvider;
import nodomain.freeyourgadget.gadgetbridge.entities.PebbleMorpheuzSample;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
@ -70,7 +69,7 @@ class AppMessageHandlerMorpheuz extends AppMessageHandler {
private static final Logger LOG = LoggerFactory.getLogger(AppMessageHandlerMorpheuz.class);
public AppMessageHandlerMorpheuz(UUID uuid, PebbleProtocol pebbleProtocol) {
AppMessageHandlerMorpheuz(UUID uuid, PebbleProtocol pebbleProtocol) {
super(uuid, pebbleProtocol);
try {
@ -108,16 +107,11 @@ class AppMessageHandlerMorpheuz extends AppMessageHandler {
@Override
public GBDeviceEvent[] handleMessage(ArrayList<Pair<Integer, Object>> pairs) {
int ctrl_message = 0;
GBDeviceEventSleepMonitorResult sleepMonitorResult = null;
for (Pair<Integer, Object> pair : pairs) {
if (Objects.equals(pair.first, keyTransmit)) {
sleepMonitorResult = new GBDeviceEventSleepMonitorResult();
sleepMonitorResult.smartalarm_from = smartalarm_from;
sleepMonitorResult.smartalarm_to = smartalarm_to;
sleepMonitorResult.alarm_gone_off = alarm_gone_off;
sleepMonitorResult.recording_base_timestamp = recording_base_timestamp;
ctrl_message |= CTRL_TRANSMIT_DONE;
GB.signalActivityDataFinish();
} else if (pair.first.equals(keyGoneoff)) {
alarm_gone_off = (int) pair.second;
LOG.info("got gone off: " + alarm_gone_off / 60 + ":" + alarm_gone_off % 60);
@ -187,7 +181,7 @@ class AppMessageHandlerMorpheuz extends AppMessageHandler {
sendBytesCtrl.encodedBytes = encodeMorpheuzMessage(keyCtrl, ctrl_message);
}
// ctrl and sleep monitor might be null, thats okay
return new GBDeviceEvent[]{sendBytesAck, sendBytesCtrl, sleepMonitorResult};
// ctrl might be null, thats okay
return new GBDeviceEvent[]{sendBytesAck, sendBytesCtrl};
}
}