Refactoring: rename GBDeviceCommand to GBDeviceEvent
This commit is contained in:
parent
c2582e1e1f
commit
73da7fff0a
|
@ -5,8 +5,8 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommand;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandSendBytes;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceProtocol;
|
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceProtocol;
|
||||||
|
|
||||||
public abstract class AbstractBTDeviceSupport extends AbstractDeviceSupport {
|
public abstract class AbstractBTDeviceSupport extends AbstractDeviceSupport {
|
||||||
|
@ -60,22 +60,22 @@ public abstract class AbstractBTDeviceSupport extends AbstractDeviceSupport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleGBDeviceCommand(GBDeviceCommandSendBytes sendBytes) {
|
public void handleGBDeviceEvent(GBDeviceEventSendBytes sendBytes) {
|
||||||
sendToDevice(sendBytes.encodedBytes);
|
sendToDevice(sendBytes.encodedBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void evaluateGBDeviceCommand(GBDeviceCommand deviceCmd) {
|
public void evaluateGBDeviceEvent(GBDeviceEvent deviceEvent) {
|
||||||
|
|
||||||
switch (deviceCmd.commandClass) {
|
switch (deviceEvent.eventClass) {
|
||||||
case SEND_BYTES:
|
case SEND_BYTES:
|
||||||
handleGBDeviceCommand((GBDeviceCommandSendBytes) deviceCmd);
|
handleGBDeviceEvent((GBDeviceEventSendBytes) deviceEvent);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
super.evaluateGBDeviceCommand(deviceCmd);
|
super.evaluateGBDeviceEvent(deviceEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,12 +9,12 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.activities.SleepChartActivity;
|
import nodomain.freeyourgadget.gadgetbridge.activities.SleepChartActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommand;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandAppInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandCallControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandMusicControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandSleepMonitorResult;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSleepMonitorResult;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandVersionInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||||
|
|
||||||
// TODO: support option for a single reminder notification when notifications could not be delivered?
|
// TODO: support option for a single reminder notification when notifications could not be delivered?
|
||||||
// conditions: app was running and received notifications, but device was not connected.
|
// conditions: app was running and received notifications, but device was not connected.
|
||||||
|
@ -56,77 +56,77 @@ public abstract class AbstractDeviceSupport implements DeviceSupport {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void evaluateGBDeviceCommand(GBDeviceCommand deviceCmd) {
|
public void evaluateGBDeviceEvent(GBDeviceEvent deviceEvent) {
|
||||||
|
|
||||||
switch (deviceCmd.commandClass) {
|
switch (deviceEvent.eventClass) {
|
||||||
case MUSIC_CONTROL:
|
case MUSIC_CONTROL:
|
||||||
handleGBDeviceCommand((GBDeviceCommandMusicControl) deviceCmd);
|
handleGBDeviceEvent((GBDeviceEventMusicControl) deviceEvent);
|
||||||
break;
|
break;
|
||||||
case CALL_CONTROL:
|
case CALL_CONTROL:
|
||||||
handleGBDeviceCommand((GBDeviceCommandCallControl) deviceCmd);
|
handleGBDeviceEvent((GBDeviceEventCallControl) deviceEvent);
|
||||||
break;
|
break;
|
||||||
case VERSION_INFO:
|
case VERSION_INFO:
|
||||||
handleGBDeviceCommand((GBDeviceCommandVersionInfo) deviceCmd);
|
handleGBDeviceEvent((GBDeviceEventVersionInfo) deviceEvent);
|
||||||
break;
|
break;
|
||||||
case APP_INFO:
|
case APP_INFO:
|
||||||
handleGBDeviceCommand((GBDeviceCommandAppInfo) deviceCmd);
|
handleGBDeviceEvent((GBDeviceEventAppInfo) deviceEvent);
|
||||||
break;
|
break;
|
||||||
case SLEEP_MONITOR_RES:
|
case SLEEP_MONITOR_RES:
|
||||||
handleGBDeviceCommand((GBDeviceCommandSleepMonitorResult) deviceCmd);
|
handleGBDeviceEvent((GBDeviceEventSleepMonitorResult) deviceEvent);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleGBDeviceCommand(GBDeviceCommandMusicControl musicCmd) {
|
public void handleGBDeviceEvent(GBDeviceEventMusicControl musicEvent) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
LOG.info("Got command for MUSIC_CONTROL");
|
LOG.info("Got event for MUSIC_CONTROL");
|
||||||
Intent musicIntent = new Intent(GBMusicControlReceiver.ACTION_MUSICCONTROL);
|
Intent musicIntent = new Intent(GBMusicControlReceiver.ACTION_MUSICCONTROL);
|
||||||
musicIntent.putExtra("command", musicCmd.command.ordinal());
|
musicIntent.putExtra("event", musicEvent.event.ordinal());
|
||||||
musicIntent.setPackage(context.getPackageName());
|
musicIntent.setPackage(context.getPackageName());
|
||||||
context.sendBroadcast(musicIntent);
|
context.sendBroadcast(musicIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleGBDeviceCommand(GBDeviceCommandCallControl callCmd) {
|
public void handleGBDeviceEvent(GBDeviceEventCallControl callEvent) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
LOG.info("Got command for CALL_CONTROL");
|
LOG.info("Got event for CALL_CONTROL");
|
||||||
Intent callIntent = new Intent(GBCallControlReceiver.ACTION_CALLCONTROL);
|
Intent callIntent = new Intent(GBCallControlReceiver.ACTION_CALLCONTROL);
|
||||||
callIntent.putExtra("command", callCmd.command.ordinal());
|
callIntent.putExtra("event", callEvent.event.ordinal());
|
||||||
callIntent.setPackage(context.getPackageName());
|
callIntent.setPackage(context.getPackageName());
|
||||||
context.sendBroadcast(callIntent);
|
context.sendBroadcast(callIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleGBDeviceCommand(GBDeviceCommandVersionInfo infoCmd) {
|
public void handleGBDeviceEvent(GBDeviceEventVersionInfo infoEvent) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
LOG.info("Got command for VERSION_INFO");
|
LOG.info("Got event for VERSION_INFO");
|
||||||
if (gbDevice == null) {
|
if (gbDevice == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gbDevice.setFirmwareVersion(infoCmd.fwVersion);
|
gbDevice.setFirmwareVersion(infoEvent.fwVersion);
|
||||||
gbDevice.setHardwareVersion(infoCmd.hwVersion);
|
gbDevice.setHardwareVersion(infoEvent.hwVersion);
|
||||||
gbDevice.sendDeviceUpdateIntent(context);
|
gbDevice.sendDeviceUpdateIntent(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleGBDeviceCommand(GBDeviceCommandAppInfo appInfoCmd) {
|
public void handleGBDeviceEvent(GBDeviceEventAppInfo appInfoEvent) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
LOG.info("Got command for APP_INFO");
|
LOG.info("Got event for APP_INFO");
|
||||||
|
|
||||||
Intent appInfoIntent = new Intent(AppManagerActivity.ACTION_REFRESH_APPLIST);
|
Intent appInfoIntent = new Intent(AppManagerActivity.ACTION_REFRESH_APPLIST);
|
||||||
int appCount = appInfoCmd.apps.length;
|
int appCount = appInfoEvent.apps.length;
|
||||||
appInfoIntent.putExtra("app_count", appCount);
|
appInfoIntent.putExtra("app_count", appCount);
|
||||||
for (Integer i = 0; i < appCount; i++) {
|
for (Integer i = 0; i < appCount; i++) {
|
||||||
appInfoIntent.putExtra("app_name" + i.toString(), appInfoCmd.apps[i].getName());
|
appInfoIntent.putExtra("app_name" + i.toString(), appInfoEvent.apps[i].getName());
|
||||||
appInfoIntent.putExtra("app_creator" + i.toString(), appInfoCmd.apps[i].getCreator());
|
appInfoIntent.putExtra("app_creator" + i.toString(), appInfoEvent.apps[i].getCreator());
|
||||||
appInfoIntent.putExtra("app_uuid" + i.toString(), appInfoCmd.apps[i].getUUID().toString());
|
appInfoIntent.putExtra("app_uuid" + i.toString(), appInfoEvent.apps[i].getUUID().toString());
|
||||||
appInfoIntent.putExtra("app_type" + i.toString(), appInfoCmd.apps[i].getType().ordinal());
|
appInfoIntent.putExtra("app_type" + i.toString(), appInfoEvent.apps[i].getType().ordinal());
|
||||||
}
|
}
|
||||||
LocalBroadcastManager.getInstance(context).sendBroadcast(appInfoIntent);
|
LocalBroadcastManager.getInstance(context).sendBroadcast(appInfoIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleGBDeviceCommand(GBDeviceCommandSleepMonitorResult sleepMonitorResult) {
|
public void handleGBDeviceEvent(GBDeviceEventSleepMonitorResult sleepMonitorResult) {
|
||||||
Context context = getContext();
|
Context context = getContext();
|
||||||
LOG.info("Got command for SLEEP_MONIOR_RES");
|
LOG.info("Got event for SLEEP_MONIOR_RES");
|
||||||
Intent sleepMontiorIntent = new Intent(SleepChartActivity.ACTION_REFRESH);
|
Intent sleepMontiorIntent = new Intent(SleepChartActivity.ACTION_REFRESH);
|
||||||
sleepMontiorIntent.putExtra("smartalarm_from", sleepMonitorResult.smartalarm_from);
|
sleepMontiorIntent.putExtra("smartalarm_from", sleepMonitorResult.smartalarm_from);
|
||||||
sleepMontiorIntent.putExtra("smartalarm_to", sleepMonitorResult.smartalarm_to);
|
sleepMontiorIntent.putExtra("smartalarm_to", sleepMonitorResult.smartalarm_to);
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandCallControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||||
|
|
||||||
public class GBCallControlReceiver extends BroadcastReceiver {
|
public class GBCallControlReceiver extends BroadcastReceiver {
|
||||||
public static final String ACTION_CALLCONTROL = "nodomain.freeyourgadget.gadgetbridge.callcontrol";
|
public static final String ACTION_CALLCONTROL = "nodomain.freeyourgadget.gadgetbridge.callcontrol";
|
||||||
|
@ -20,7 +20,7 @@ public class GBCallControlReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
GBDeviceCommandCallControl.Command callCmd = GBDeviceCommandCallControl.Command.values()[intent.getIntExtra("command", 0)];
|
GBDeviceEventCallControl.Event callCmd = GBDeviceEventCallControl.Event.values()[intent.getIntExtra("event", 0)];
|
||||||
switch (callCmd) {
|
switch (callCmd) {
|
||||||
case END:
|
case END:
|
||||||
case START:
|
case START:
|
||||||
|
@ -30,7 +30,7 @@ public class GBCallControlReceiver extends BroadcastReceiver {
|
||||||
Method method = clazz.getDeclaredMethod("getITelephony");
|
Method method = clazz.getDeclaredMethod("getITelephony");
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
ITelephony telephonyService = (ITelephony) method.invoke(telephonyManager);
|
ITelephony telephonyService = (ITelephony) method.invoke(telephonyManager);
|
||||||
if (callCmd == GBDeviceCommandCallControl.Command.END) {
|
if (callCmd == GBDeviceEventCallControl.Event.END) {
|
||||||
telephonyService.endCall();
|
telephonyService.endCall();
|
||||||
} else {
|
} else {
|
||||||
telephonyService.answerRingingCall();
|
telephonyService.answerRingingCall();
|
||||||
|
|
|
@ -10,7 +10,7 @@ import android.view.KeyEvent;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandMusicControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
||||||
|
|
||||||
public class GBMusicControlReceiver extends BroadcastReceiver {
|
public class GBMusicControlReceiver extends BroadcastReceiver {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(GBMusicControlReceiver.class);
|
private static final Logger LOG = LoggerFactory.getLogger(GBMusicControlReceiver.class);
|
||||||
|
@ -19,7 +19,7 @@ public class GBMusicControlReceiver extends BroadcastReceiver {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context context, Intent intent) {
|
||||||
GBDeviceCommandMusicControl.Command musicCmd = GBDeviceCommandMusicControl.Command.values()[intent.getIntExtra("command", 0)];
|
GBDeviceEventMusicControl.Event musicCmd = GBDeviceEventMusicControl.Event.values()[intent.getIntExtra("event", 0)];
|
||||||
int keyCode = -1;
|
int keyCode = -1;
|
||||||
int volumeAdjust = AudioManager.ADJUST_LOWER;
|
int volumeAdjust = AudioManager.ADJUST_LOWER;
|
||||||
|
|
||||||
|
@ -43,8 +43,7 @@ public class GBMusicControlReceiver extends BroadcastReceiver {
|
||||||
// change default and fall through, :P
|
// change default and fall through, :P
|
||||||
volumeAdjust = AudioManager.ADJUST_RAISE;
|
volumeAdjust = AudioManager.ADJUST_RAISE;
|
||||||
case VOLUMEDOWN:
|
case VOLUMEDOWN:
|
||||||
AudioManager audioManager =
|
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
||||||
(AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, volumeAdjust, 0);
|
audioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, volumeAdjust, 0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -13,7 +13,6 @@ import android.view.MenuItem;
|
||||||
|
|
||||||
import com.github.mikephil.charting.animation.Easing;
|
import com.github.mikephil.charting.animation.Easing;
|
||||||
import com.github.mikephil.charting.charts.BarLineChartBase;
|
import com.github.mikephil.charting.charts.BarLineChartBase;
|
||||||
import com.github.mikephil.charting.components.LimitLine;
|
|
||||||
import com.github.mikephil.charting.components.XAxis;
|
import com.github.mikephil.charting.components.XAxis;
|
||||||
import com.github.mikephil.charting.components.YAxis;
|
import com.github.mikephil.charting.components.YAxis;
|
||||||
import com.github.mikephil.charting.data.BarData;
|
import com.github.mikephil.charting.data.BarData;
|
||||||
|
|
|
@ -5,8 +5,6 @@ import android.bluetooth.BluetoothGatt;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBDevice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A special action that checks for an abort-condition, and if met, the currently
|
* A special action that checks for an abort-condition, and if met, the currently
|
||||||
* executing transaction will be aborted by returning false.
|
* executing transaction will be aborted by returning false.
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.btle;
|
package nodomain.freeyourgadget.gadgetbridge.btle;
|
||||||
|
|
||||||
import android.bluetooth.BluetoothGatt;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.protocol;
|
package nodomain.freeyourgadget.gadgetbridge.deviceevents;
|
||||||
|
|
||||||
|
|
||||||
public abstract class GBDeviceCommand {
|
public abstract class GBDeviceEvent {
|
||||||
public CommandClass commandClass = CommandClass.UNKNOWN;
|
public EventClass eventClass = EventClass.UNKNOWN;
|
||||||
|
|
||||||
public enum CommandClass {
|
public enum EventClass {
|
||||||
UNKNOWN,
|
UNKNOWN,
|
||||||
MUSIC_CONTROL,
|
MUSIC_CONTROL,
|
||||||
CALL_CONTROL,
|
CALL_CONTROL,
|
|
@ -0,0 +1,12 @@
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.deviceevents;
|
||||||
|
|
||||||
|
import nodomain.freeyourgadget.gadgetbridge.GBDeviceApp;
|
||||||
|
|
||||||
|
public class GBDeviceEventAppInfo extends GBDeviceEvent {
|
||||||
|
public GBDeviceApp apps[];
|
||||||
|
public byte freeSlot = -1;
|
||||||
|
|
||||||
|
public GBDeviceEventAppInfo() {
|
||||||
|
eventClass = EventClass.APP_INFO;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.deviceevents;
|
||||||
|
|
||||||
|
public class GBDeviceEventAppManagementResult extends GBDeviceEvent {
|
||||||
|
public Result result = Result.UNKNOWN;
|
||||||
|
public EventType type = EventType.UNKNOWN;
|
||||||
|
public int token = -1;
|
||||||
|
|
||||||
|
public GBDeviceEventAppManagementResult() {
|
||||||
|
eventClass = EventClass.APP_MANAGEMENT_RES;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum EventType {
|
||||||
|
UNKNOWN,
|
||||||
|
INSTALL,
|
||||||
|
DELETE,
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Result {
|
||||||
|
UNKNOWN,
|
||||||
|
SUCCESS,
|
||||||
|
ACKNOLEDGE,
|
||||||
|
FAILURE,
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.deviceevents;
|
||||||
|
|
||||||
|
|
||||||
|
public class GBDeviceEventCallControl extends GBDeviceEvent {
|
||||||
|
public Event event = Event.UNKNOWN;
|
||||||
|
|
||||||
|
public GBDeviceEventCallControl() {
|
||||||
|
eventClass = EventClass.CALL_CONTROL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Event {
|
||||||
|
UNKNOWN,
|
||||||
|
ACCEPT,
|
||||||
|
END,
|
||||||
|
INCOMING,
|
||||||
|
OUTGOING,
|
||||||
|
REJECT,
|
||||||
|
START,
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.deviceevents;
|
||||||
|
|
||||||
|
|
||||||
|
public class GBDeviceEventMusicControl extends GBDeviceEvent {
|
||||||
|
public Event event = Event.UNKNOWN;
|
||||||
|
|
||||||
|
public GBDeviceEventMusicControl() {
|
||||||
|
eventClass = EventClass.MUSIC_CONTROL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Event {
|
||||||
|
UNKNOWN,
|
||||||
|
PLAY,
|
||||||
|
PAUSE,
|
||||||
|
PLAYPAUSE,
|
||||||
|
NEXT,
|
||||||
|
PREVIOUS,
|
||||||
|
VOLUMEUP,
|
||||||
|
VOLUMEDOWN,
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package nodomain.freeyourgadget.gadgetbridge.deviceevents;
|
||||||
|
|
||||||
|
public class GBDeviceEventSendBytes extends GBDeviceEvent {
|
||||||
|
public byte[] encodedBytes;
|
||||||
|
|
||||||
|
public GBDeviceEventSendBytes() {
|
||||||
|
eventClass = EventClass.SEND_BYTES;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.protocol;
|
package nodomain.freeyourgadget.gadgetbridge.deviceevents;
|
||||||
|
|
||||||
public class GBDeviceCommandSleepMonitorResult extends GBDeviceCommand {
|
public class GBDeviceEventSleepMonitorResult extends GBDeviceEvent {
|
||||||
// FIXME: this is just the low-level data from Morpheuz, we need something generic
|
// 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_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 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 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
|
public int alarm_gone_off = -1; // time in minutes relative from 0:00 when alarm gone off
|
||||||
|
|
||||||
public GBDeviceCommandSleepMonitorResult() {
|
public GBDeviceEventSleepMonitorResult() {
|
||||||
commandClass = CommandClass.SLEEP_MONITOR_RES;
|
eventClass = EventClass.SLEEP_MONITOR_RES;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.protocol;
|
package nodomain.freeyourgadget.gadgetbridge.deviceevents;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
|
|
||||||
public class GBDeviceCommandVersionInfo extends GBDeviceCommand {
|
public class GBDeviceEventVersionInfo extends GBDeviceEvent {
|
||||||
public String fwVersion = GBApplication.getContext().getString(R.string.n_a);
|
public String fwVersion = GBApplication.getContext().getString(R.string.n_a);
|
||||||
public String hwVersion = GBApplication.getContext().getString(R.string.n_a);
|
public String hwVersion = GBApplication.getContext().getString(R.string.n_a);
|
||||||
|
|
||||||
public GBDeviceCommandVersionInfo() {
|
public GBDeviceEventVersionInfo() {
|
||||||
commandClass = CommandClass.VERSION_INFO;
|
eventClass = EventClass.VERSION_INFO;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -5,8 +5,6 @@ import android.content.SharedPreferences;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
|
||||||
|
|
||||||
public final class MiBandConst {
|
public final class MiBandConst {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(MiBandConst.class);
|
private static final Logger LOG = LoggerFactory.getLogger(MiBandConst.class);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,6 @@ import nodomain.freeyourgadget.gadgetbridge.btle.SetDeviceBusyAction;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.btle.TransactionBuilder;
|
import nodomain.freeyourgadget.gadgetbridge.btle.TransactionBuilder;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.database.ActivityDatabaseHandler;
|
import nodomain.freeyourgadget.gadgetbridge.database.ActivityDatabaseHandler;
|
||||||
|
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_PROFILE;
|
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VALUE_FLASH_COLOUR;
|
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VALUE_FLASH_COLOUR;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VALUE_FLASH_COUNT;
|
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VALUE_FLASH_COUNT;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VALUE_FLASH_DURATION;
|
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VALUE_FLASH_DURATION;
|
||||||
|
@ -37,6 +36,7 @@ import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VA
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_COUNT;
|
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_COUNT;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_DURATION;
|
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_DURATION;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_PAUSE;
|
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_PAUSE;
|
||||||
|
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.DEFAULT_VALUE_VIBRATION_PROFILE;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.FLASH_COLOUR;
|
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.FLASH_COLOUR;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.FLASH_COUNT;
|
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.FLASH_COUNT;
|
||||||
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.FLASH_DURATION;
|
import static nodomain.freeyourgadget.gadgetbridge.miband.MiBandConst.FLASH_DURATION;
|
||||||
|
|
|
@ -13,9 +13,9 @@ import java.util.UUID;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBActivitySample;
|
import nodomain.freeyourgadget.gadgetbridge.GBActivitySample;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommand;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandSendBytes;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandSleepMonitorResult;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSleepMonitorResult;
|
||||||
|
|
||||||
public class MorpheuzSupport {
|
public class MorpheuzSupport {
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public class MorpheuzSupport {
|
||||||
return buf.array();
|
return buf.array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GBDeviceCommand handleMessage(ArrayList<Pair<Integer, Object>> pairs) {
|
public GBDeviceEvent handleMessage(ArrayList<Pair<Integer, Object>> pairs) {
|
||||||
for (Pair<Integer, Object> pair : pairs) {
|
for (Pair<Integer, Object> pair : pairs) {
|
||||||
int ctrl_message = 0;
|
int ctrl_message = 0;
|
||||||
switch (pair.first) {
|
switch (pair.first) {
|
||||||
|
@ -84,7 +84,7 @@ public class MorpheuzSupport {
|
||||||
if (sent_to_gadgetbridge) {
|
if (sent_to_gadgetbridge) {
|
||||||
ctrl_message = MorpheuzSupport.CTRL_VERSION_DONE | MorpheuzSupport.CTRL_GONEOFF_DONE | MorpheuzSupport.CTRL_TRANSMIT_DONE | MorpheuzSupport.CTRL_SET_LAST_SENT;
|
ctrl_message = MorpheuzSupport.CTRL_VERSION_DONE | MorpheuzSupport.CTRL_GONEOFF_DONE | MorpheuzSupport.CTRL_TRANSMIT_DONE | MorpheuzSupport.CTRL_SET_LAST_SENT;
|
||||||
} else {
|
} else {
|
||||||
GBDeviceCommandSleepMonitorResult sleepMonitorResult = new GBDeviceCommandSleepMonitorResult();
|
GBDeviceEventSleepMonitorResult sleepMonitorResult = new GBDeviceEventSleepMonitorResult();
|
||||||
sleepMonitorResult.smartalarm_from = smartalarm_from;
|
sleepMonitorResult.smartalarm_from = smartalarm_from;
|
||||||
sleepMonitorResult.smartalarm_to = smartalarm_to;
|
sleepMonitorResult.smartalarm_to = smartalarm_to;
|
||||||
sleepMonitorResult.alarm_gone_off = alarm_gone_off;
|
sleepMonitorResult.alarm_gone_off = alarm_gone_off;
|
||||||
|
@ -144,12 +144,12 @@ public class MorpheuzSupport {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ctrl_message > 0) {
|
if (ctrl_message > 0) {
|
||||||
GBDeviceCommandSendBytes sendBytes = new GBDeviceCommandSendBytes();
|
GBDeviceEventSendBytes sendBytes = new GBDeviceEventSendBytes();
|
||||||
sendBytes.encodedBytes = encodeMorpheuzMessage(MorpheuzSupport.KEY_CTRL, ctrl_message);
|
sendBytes.encodedBytes = encodeMorpheuzMessage(MorpheuzSupport.KEY_CTRL, ctrl_message);
|
||||||
return sendBytes;
|
return sendBytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GBDeviceCommandSendBytes sendBytes = new GBDeviceCommandSendBytes();
|
GBDeviceEventSendBytes sendBytes = new GBDeviceEventSendBytes();
|
||||||
sendBytes.encodedBytes = mPebbleProtocol.encodeApplicationMessageAck(uuid, mPebbleProtocol.last_id);
|
sendBytes.encodedBytes = mPebbleProtocol.encodeApplicationMessageAck(uuid, mPebbleProtocol.last_id);
|
||||||
return sendBytes;
|
return sendBytes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,9 @@ import nodomain.freeyourgadget.gadgetbridge.AppManagerActivity;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBDevice;
|
import nodomain.freeyourgadget.gadgetbridge.GBDevice;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBDeviceIoThread;
|
import nodomain.freeyourgadget.gadgetbridge.GBDeviceIoThread;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommand;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandAppInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandAppManagementResult;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppManagementResult;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceProtocol;
|
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceProtocol;
|
||||||
|
|
||||||
public class PebbleIoThread extends GBDeviceIoThread {
|
public class PebbleIoThread extends GBDeviceIoThread {
|
||||||
|
@ -245,12 +245,12 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
||||||
bytes += mInStream.read(buffer, bytes + 4, length - bytes);
|
bytes += mInStream.read(buffer, bytes + 4, length - bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
GBDeviceCommand deviceCmd = mPebbleProtocol.decodeResponse(buffer);
|
GBDeviceEvent deviceEvent = mPebbleProtocol.decodeResponse(buffer);
|
||||||
if (deviceCmd == null) {
|
if (deviceEvent == null) {
|
||||||
LOG.info("unhandled message to endpoint " + endpoint + " (" + length + " bytes)");
|
LOG.info("unhandled message to endpoint " + endpoint + " (" + length + " bytes)");
|
||||||
} else {
|
} else {
|
||||||
if (!evaluateGBDeviceCommandPebble(deviceCmd)) {
|
if (!evaluateGBDeviceEventPebble(deviceEvent)) {
|
||||||
mPebbleSupport.evaluateGBDeviceCommand(deviceCmd);
|
mPebbleSupport.evaluateGBDeviceEvent(deviceEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -305,10 +305,9 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: parts are supporsed to be generic code
|
// FIXME: parts are supporsed to be generic code
|
||||||
private boolean evaluateGBDeviceCommandPebble(GBDeviceCommand deviceCmd) {
|
private boolean evaluateGBDeviceEventPebble(GBDeviceEvent deviceEvent) {
|
||||||
Context context = getContext();
|
|
||||||
|
|
||||||
switch (deviceCmd.commandClass) {
|
switch (deviceEvent.eventClass) {
|
||||||
case VERSION_INFO:
|
case VERSION_INFO:
|
||||||
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||||
if (sharedPrefs.getBoolean("datetime_synconconnect", true)) {
|
if (sharedPrefs.getBoolean("datetime_synconconnect", true)) {
|
||||||
|
@ -317,7 +316,7 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
case APP_MANAGEMENT_RES:
|
case APP_MANAGEMENT_RES:
|
||||||
GBDeviceCommandAppManagementResult appMgmtRes = (GBDeviceCommandAppManagementResult) deviceCmd;
|
GBDeviceEventAppManagementResult appMgmtRes = (GBDeviceEventAppManagementResult) deviceEvent;
|
||||||
switch (appMgmtRes.type) {
|
switch (appMgmtRes.type) {
|
||||||
case DELETE:
|
case DELETE:
|
||||||
// right now on the Pebble we also receive this on a failed/successful installation ;/
|
// right now on the Pebble we also receive this on a failed/successful installation ;/
|
||||||
|
@ -371,9 +370,9 @@ public class PebbleIoThread extends GBDeviceIoThread {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case APP_INFO:
|
case APP_INFO:
|
||||||
LOG.info("Got command for APP_INFO");
|
LOG.info("Got event for APP_INFO");
|
||||||
GBDeviceCommandAppInfo appInfoCmd = (GBDeviceCommandAppInfo) deviceCmd;
|
GBDeviceEventAppInfo appInfoEvent = (GBDeviceEventAppInfo) deviceEvent;
|
||||||
setInstallSlot(appInfoCmd.freeSlot);
|
setInstallSlot(appInfoEvent.freeSlot);
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -15,13 +15,13 @@ import java.util.UUID;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBCommand;
|
import nodomain.freeyourgadget.gadgetbridge.GBCommand;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBDeviceApp;
|
import nodomain.freeyourgadget.gadgetbridge.GBDeviceApp;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommand;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandAppInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppInfo;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandAppManagementResult;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventAppManagementResult;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandCallControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandMusicControl;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventMusicControl;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandSendBytes;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandVersionInfo;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventVersionInfo;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceProtocol;
|
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceProtocol;
|
||||||
|
|
||||||
public class PebbleProtocol extends GBDeviceProtocol {
|
public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
|
@ -715,57 +715,57 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GBDeviceCommand decodeResponse(byte[] responseData) {
|
public GBDeviceEvent decodeResponse(byte[] responseData) {
|
||||||
ByteBuffer buf = ByteBuffer.wrap(responseData);
|
ByteBuffer buf = ByteBuffer.wrap(responseData);
|
||||||
buf.order(ByteOrder.BIG_ENDIAN);
|
buf.order(ByteOrder.BIG_ENDIAN);
|
||||||
short length = buf.getShort();
|
short length = buf.getShort();
|
||||||
short endpoint = buf.getShort();
|
short endpoint = buf.getShort();
|
||||||
byte pebbleCmd = buf.get();
|
byte pebbleCmd = buf.get();
|
||||||
GBDeviceCommand cmd = null;
|
GBDeviceEvent devEvt = null;
|
||||||
switch (endpoint) {
|
switch (endpoint) {
|
||||||
case ENDPOINT_MUSICCONTROL:
|
case ENDPOINT_MUSICCONTROL:
|
||||||
GBDeviceCommandMusicControl musicCmd = new GBDeviceCommandMusicControl();
|
GBDeviceEventMusicControl musicCmd = new GBDeviceEventMusicControl();
|
||||||
switch (pebbleCmd) {
|
switch (pebbleCmd) {
|
||||||
case MUSICCONTROL_NEXT:
|
case MUSICCONTROL_NEXT:
|
||||||
musicCmd.command = GBDeviceCommandMusicControl.Command.NEXT;
|
musicCmd.event = GBDeviceEventMusicControl.Event.NEXT;
|
||||||
break;
|
break;
|
||||||
case MUSICCONTROL_PREVIOUS:
|
case MUSICCONTROL_PREVIOUS:
|
||||||
musicCmd.command = GBDeviceCommandMusicControl.Command.PREVIOUS;
|
musicCmd.event = GBDeviceEventMusicControl.Event.PREVIOUS;
|
||||||
break;
|
break;
|
||||||
case MUSICCONTROL_PLAY:
|
case MUSICCONTROL_PLAY:
|
||||||
musicCmd.command = GBDeviceCommandMusicControl.Command.PLAY;
|
musicCmd.event = GBDeviceEventMusicControl.Event.PLAY;
|
||||||
break;
|
break;
|
||||||
case MUSICCONTROL_PAUSE:
|
case MUSICCONTROL_PAUSE:
|
||||||
musicCmd.command = GBDeviceCommandMusicControl.Command.PAUSE;
|
musicCmd.event = GBDeviceEventMusicControl.Event.PAUSE;
|
||||||
break;
|
break;
|
||||||
case MUSICCONTROL_PLAYPAUSE:
|
case MUSICCONTROL_PLAYPAUSE:
|
||||||
musicCmd.command = GBDeviceCommandMusicControl.Command.PLAYPAUSE;
|
musicCmd.event = GBDeviceEventMusicControl.Event.PLAYPAUSE;
|
||||||
break;
|
break;
|
||||||
case MUSICCONTROL_VOLUMEUP:
|
case MUSICCONTROL_VOLUMEUP:
|
||||||
musicCmd.command = GBDeviceCommandMusicControl.Command.VOLUMEUP;
|
musicCmd.event = GBDeviceEventMusicControl.Event.VOLUMEUP;
|
||||||
break;
|
break;
|
||||||
case MUSICCONTROL_VOLUMEDOWN:
|
case MUSICCONTROL_VOLUMEDOWN:
|
||||||
musicCmd.command = GBDeviceCommandMusicControl.Command.VOLUMEDOWN;
|
musicCmd.event = GBDeviceEventMusicControl.Event.VOLUMEDOWN;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmd = musicCmd;
|
devEvt = musicCmd;
|
||||||
break;
|
break;
|
||||||
case ENDPOINT_PHONECONTROL:
|
case ENDPOINT_PHONECONTROL:
|
||||||
GBDeviceCommandCallControl callCmd = new GBDeviceCommandCallControl();
|
GBDeviceEventCallControl callCmd = new GBDeviceEventCallControl();
|
||||||
switch (pebbleCmd) {
|
switch (pebbleCmd) {
|
||||||
case PHONECONTROL_HANGUP:
|
case PHONECONTROL_HANGUP:
|
||||||
callCmd.command = GBDeviceCommandCallControl.Command.END;
|
callCmd.event = GBDeviceEventCallControl.Event.END;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG.info("Unknown PHONECONTROL command" + pebbleCmd);
|
LOG.info("Unknown PHONECONTROL event" + pebbleCmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmd = callCmd;
|
devEvt = callCmd;
|
||||||
break;
|
break;
|
||||||
case ENDPOINT_FIRMWAREVERSION:
|
case ENDPOINT_FIRMWAREVERSION:
|
||||||
GBDeviceCommandVersionInfo versionCmd = new GBDeviceCommandVersionInfo();
|
GBDeviceEventVersionInfo versionCmd = new GBDeviceEventVersionInfo();
|
||||||
|
|
||||||
buf.getInt(); // skip
|
buf.getInt(); // skip
|
||||||
byte[] tmp = new byte[32];
|
byte[] tmp = new byte[32];
|
||||||
|
@ -781,12 +781,12 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
if (hwRev > 0 && hwRev < hwRevisions.length) {
|
if (hwRev > 0 && hwRev < hwRevisions.length) {
|
||||||
versionCmd.hwVersion = hwRevisions[hwRev];
|
versionCmd.hwVersion = hwRevisions[hwRev];
|
||||||
}
|
}
|
||||||
cmd = versionCmd;
|
devEvt = versionCmd;
|
||||||
break;
|
break;
|
||||||
case ENDPOINT_APPMANAGER:
|
case ENDPOINT_APPMANAGER:
|
||||||
switch (pebbleCmd) {
|
switch (pebbleCmd) {
|
||||||
case APPMANAGER_GETAPPBANKSTATUS:
|
case APPMANAGER_GETAPPBANKSTATUS:
|
||||||
GBDeviceCommandAppInfo appInfoCmd = new GBDeviceCommandAppInfo();
|
GBDeviceEventAppInfo appInfoCmd = new GBDeviceEventAppInfo();
|
||||||
int slotCount = buf.getInt();
|
int slotCount = buf.getInt();
|
||||||
int slotsUsed = buf.getInt();
|
int slotsUsed = buf.getInt();
|
||||||
byte[] appName = new byte[32];
|
byte[] appName = new byte[32];
|
||||||
|
@ -820,12 +820,12 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmd = appInfoCmd;
|
devEvt = appInfoCmd;
|
||||||
break;
|
break;
|
||||||
case APPMANAGER_GETUUIDS:
|
case APPMANAGER_GETUUIDS:
|
||||||
GBDeviceCommandSendBytes sendBytes = new GBDeviceCommandSendBytes();
|
GBDeviceEventSendBytes sendBytes = new GBDeviceEventSendBytes();
|
||||||
sendBytes.encodedBytes = encodeSimpleMessage(ENDPOINT_APPMANAGER, APPMANAGER_GETAPPBANKSTATUS);
|
sendBytes.encodedBytes = encodeSimpleMessage(ENDPOINT_APPMANAGER, APPMANAGER_GETAPPBANKSTATUS);
|
||||||
cmd = sendBytes;
|
devEvt = sendBytes;
|
||||||
tmpUUIDS.clear();
|
tmpUUIDS.clear();
|
||||||
slotsUsed = buf.getInt();
|
slotsUsed = buf.getInt();
|
||||||
for (int i = 0; i < slotsUsed; i++) {
|
for (int i = 0; i < slotsUsed; i++) {
|
||||||
|
@ -837,39 +837,39 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case APPMANAGER_REMOVEAPP:
|
case APPMANAGER_REMOVEAPP:
|
||||||
GBDeviceCommandAppManagementResult deleteRes = new GBDeviceCommandAppManagementResult();
|
GBDeviceEventAppManagementResult deleteRes = new GBDeviceEventAppManagementResult();
|
||||||
deleteRes.type = GBDeviceCommandAppManagementResult.CommandType.DELETE;
|
deleteRes.type = GBDeviceEventAppManagementResult.EventType.DELETE;
|
||||||
|
|
||||||
int result = buf.getInt();
|
int result = buf.getInt();
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case APPMANAGER_RES_SUCCESS:
|
case APPMANAGER_RES_SUCCESS:
|
||||||
deleteRes.result = GBDeviceCommandAppManagementResult.Result.SUCCESS;
|
deleteRes.result = GBDeviceEventAppManagementResult.Result.SUCCESS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
deleteRes.result = GBDeviceCommandAppManagementResult.Result.FAILURE;
|
deleteRes.result = GBDeviceEventAppManagementResult.Result.FAILURE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmd = deleteRes;
|
devEvt = deleteRes;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG.info("Unknown APPMANAGER command" + pebbleCmd);
|
LOG.info("Unknown APPMANAGER event" + pebbleCmd);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ENDPOINT_PUTBYTES:
|
case ENDPOINT_PUTBYTES:
|
||||||
GBDeviceCommandAppManagementResult installRes = new GBDeviceCommandAppManagementResult();
|
GBDeviceEventAppManagementResult installRes = new GBDeviceEventAppManagementResult();
|
||||||
installRes.type = GBDeviceCommandAppManagementResult.CommandType.INSTALL;
|
installRes.type = GBDeviceEventAppManagementResult.EventType.INSTALL;
|
||||||
switch (pebbleCmd) {
|
switch (pebbleCmd) {
|
||||||
case PUTBYTES_INIT:
|
case PUTBYTES_INIT:
|
||||||
installRes.token = buf.getInt();
|
installRes.token = buf.getInt();
|
||||||
installRes.result = GBDeviceCommandAppManagementResult.Result.SUCCESS;
|
installRes.result = GBDeviceEventAppManagementResult.Result.SUCCESS;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
installRes.token = buf.getInt();
|
installRes.token = buf.getInt();
|
||||||
installRes.result = GBDeviceCommandAppManagementResult.Result.FAILURE;
|
installRes.result = GBDeviceEventAppManagementResult.Result.FAILURE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cmd = installRes;
|
devEvt = installRes;
|
||||||
break;
|
break;
|
||||||
case ENDPOINT_APPLICATIONMESSAGE:
|
case ENDPOINT_APPLICATIONMESSAGE:
|
||||||
last_id = buf.get();
|
last_id = buf.get();
|
||||||
|
@ -882,10 +882,10 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
LOG.info("got APPLICATIONMESSAGE PUSH from UUID " + uuid);
|
LOG.info("got APPLICATIONMESSAGE PUSH from UUID " + uuid);
|
||||||
if (WeatherNeatSupport.uuid.equals(uuid)) {
|
if (WeatherNeatSupport.uuid.equals(uuid)) {
|
||||||
ArrayList<Pair<Integer, Object>> dict = decodeDict(buf);
|
ArrayList<Pair<Integer, Object>> dict = decodeDict(buf);
|
||||||
cmd = mWeatherNeatSupport.handleMessage(dict);
|
devEvt = mWeatherNeatSupport.handleMessage(dict);
|
||||||
} else if (MorpheuzSupport.uuid.equals(uuid)) {
|
} else if (MorpheuzSupport.uuid.equals(uuid)) {
|
||||||
ArrayList<Pair<Integer, Object>> dict = decodeDict(buf);
|
ArrayList<Pair<Integer, Object>> dict = decodeDict(buf);
|
||||||
cmd = mMorpheuzSupport.handleMessage(dict);
|
devEvt = mMorpheuzSupport.handleMessage(dict);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case APPLICATIONMESSAGE_ACK:
|
case APPLICATIONMESSAGE_ACK:
|
||||||
|
@ -905,9 +905,9 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
if (pebbleCmd != DATALOG_TIMEOUT) {
|
if (pebbleCmd != DATALOG_TIMEOUT) {
|
||||||
byte id = buf.get();
|
byte id = buf.get();
|
||||||
LOG.info("DATALOG id " + id + " - sending 0x85 (ACK?)");
|
LOG.info("DATALOG id " + id + " - sending 0x85 (ACK?)");
|
||||||
GBDeviceCommandSendBytes sendBytes = new GBDeviceCommandSendBytes();
|
GBDeviceEventSendBytes sendBytes = new GBDeviceEventSendBytes();
|
||||||
sendBytes.encodedBytes = encodeDatalog(id, (byte) 0x85);
|
sendBytes.encodedBytes = encodeDatalog(id, (byte) 0x85);
|
||||||
cmd = sendBytes;
|
devEvt = sendBytes;
|
||||||
} else {
|
} else {
|
||||||
LOG.info("DATALOG TIMEOUT - ignoring");
|
LOG.info("DATALOG TIMEOUT - ignoring");
|
||||||
}
|
}
|
||||||
|
@ -916,9 +916,9 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
switch (pebbleCmd) {
|
switch (pebbleCmd) {
|
||||||
case PHONEVERSION_REQUEST:
|
case PHONEVERSION_REQUEST:
|
||||||
LOG.info("Pebble asked for Phone/App Version - repLYING!");
|
LOG.info("Pebble asked for Phone/App Version - repLYING!");
|
||||||
GBDeviceCommandSendBytes sendBytes = new GBDeviceCommandSendBytes();
|
GBDeviceEventSendBytes sendBytes = new GBDeviceEventSendBytes();
|
||||||
sendBytes.encodedBytes = encodePhoneVersion(PHONEVERSION_REMOTE_OS_ANDROID);
|
sendBytes.encodedBytes = encodePhoneVersion(PHONEVERSION_REMOTE_OS_ANDROID);
|
||||||
cmd = sendBytes;
|
devEvt = sendBytes;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -928,7 +928,7 @@ public class PebbleProtocol extends GBDeviceProtocol {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd;
|
return devEvt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setForceProtocol(boolean force) {
|
public void setForceProtocol(boolean force) {
|
||||||
|
|
|
@ -9,8 +9,8 @@ import java.nio.ByteBuffer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommand;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
|
||||||
import nodomain.freeyourgadget.gadgetbridge.protocol.GBDeviceCommandSendBytes;
|
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
|
||||||
|
|
||||||
public class WeatherNeatSupport {
|
public class WeatherNeatSupport {
|
||||||
|
|
||||||
|
@ -48,8 +48,8 @@ public class WeatherNeatSupport {
|
||||||
return buf.array();
|
return buf.array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public GBDeviceCommand handleMessage(ArrayList<Pair<Integer, Object>> pairs) {
|
public GBDeviceEvent handleMessage(ArrayList<Pair<Integer, Object>> pairs) {
|
||||||
GBDeviceCommandSendBytes sendBytes = new GBDeviceCommandSendBytes();
|
GBDeviceEventSendBytes sendBytes = new GBDeviceEventSendBytes();
|
||||||
sendBytes.encodedBytes = encodeWeatherNeatMessage("Berlin", "22 C", "cloudy", 0);
|
sendBytes.encodedBytes = encodeWeatherNeatMessage("Berlin", "22 C", "cloudy", 0);
|
||||||
return sendBytes;
|
return sendBytes;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.protocol;
|
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBDeviceApp;
|
|
||||||
|
|
||||||
public class GBDeviceCommandAppInfo extends GBDeviceCommand {
|
|
||||||
public GBDeviceApp apps[];
|
|
||||||
public byte freeSlot = -1;
|
|
||||||
|
|
||||||
public GBDeviceCommandAppInfo() {
|
|
||||||
commandClass = CommandClass.APP_INFO;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.protocol;
|
|
||||||
|
|
||||||
public class GBDeviceCommandAppManagementResult extends GBDeviceCommand {
|
|
||||||
public Result result = Result.UNKNOWN;
|
|
||||||
public CommandType type = CommandType.UNKNOWN;
|
|
||||||
public int token = -1;
|
|
||||||
|
|
||||||
public GBDeviceCommandAppManagementResult() {
|
|
||||||
commandClass = CommandClass.APP_MANAGEMENT_RES;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum CommandType {
|
|
||||||
UNKNOWN,
|
|
||||||
INSTALL,
|
|
||||||
DELETE,
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Result {
|
|
||||||
UNKNOWN,
|
|
||||||
SUCCESS,
|
|
||||||
ACKNOLEDGE,
|
|
||||||
FAILURE,
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.protocol;
|
|
||||||
|
|
||||||
|
|
||||||
public class GBDeviceCommandCallControl extends GBDeviceCommand {
|
|
||||||
public Command command = Command.UNKNOWN;
|
|
||||||
|
|
||||||
public GBDeviceCommandCallControl() {
|
|
||||||
commandClass = CommandClass.CALL_CONTROL;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Command {
|
|
||||||
UNKNOWN,
|
|
||||||
ACCEPT,
|
|
||||||
END,
|
|
||||||
INCOMING,
|
|
||||||
OUTGOING,
|
|
||||||
REJECT,
|
|
||||||
START,
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,21 +0,0 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.protocol;
|
|
||||||
|
|
||||||
|
|
||||||
public class GBDeviceCommandMusicControl extends GBDeviceCommand {
|
|
||||||
public Command command = Command.UNKNOWN;
|
|
||||||
|
|
||||||
public GBDeviceCommandMusicControl() {
|
|
||||||
commandClass = CommandClass.MUSIC_CONTROL;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Command {
|
|
||||||
UNKNOWN,
|
|
||||||
PLAY,
|
|
||||||
PAUSE,
|
|
||||||
PLAYPAUSE,
|
|
||||||
NEXT,
|
|
||||||
PREVIOUS,
|
|
||||||
VOLUMEUP,
|
|
||||||
VOLUMEDOWN,
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.protocol;
|
|
||||||
|
|
||||||
public class GBDeviceCommandSendBytes extends GBDeviceCommand {
|
|
||||||
public byte[] encodedBytes;
|
|
||||||
|
|
||||||
public GBDeviceCommandSendBytes() {
|
|
||||||
commandClass = CommandClass.SEND_BYTES;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,72 +0,0 @@
|
||||||
package nodomain.freeyourgadget.gadgetbridge.protocol;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import nodomain.freeyourgadget.gadgetbridge.GBCommand;
|
|
||||||
|
|
||||||
public abstract class GBDeviceProtocol {
|
|
||||||
|
|
||||||
public byte[] encodeSMS(String from, String body) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] encodeEmail(String from, String subject, String body) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] encodeGenericNotification(String title, String details) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] encodeSetTime(long ts) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] encodeSetCallState(String number, String name, GBCommand command) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] encodeSetMusicInfo(String artist, String album, String track) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] encodeFirmwareVersionReq() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] encodeBatteryInfoReq() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] encodeAppInfoReq() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] encodeAppDelete(UUID uuid) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] encodeAppStart(UUID uuid) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] encodePhoneVersion(byte os) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] encodeSynchronizeActivityData() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] encodeReboot() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] encodeFindDevice(boolean start) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GBDeviceCommand decodeResponse(byte[] responseData) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue