mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 21:06:50 +01:00
commit
098d3091cc
@ -70,6 +70,7 @@ public class GBDaoGenerator {
|
||||
addNo1F1ActivitySample(schema, user, device);
|
||||
addXWatchActivitySample(schema, user, device);
|
||||
addZeTimeActivitySample(schema, user, device);
|
||||
addID115ActivitySample(schema, user, device);
|
||||
|
||||
addCalendarSyncState(schema, device);
|
||||
|
||||
@ -301,6 +302,18 @@ public class GBDaoGenerator {
|
||||
return activitySample;
|
||||
}
|
||||
|
||||
private static Entity addID115ActivitySample(Schema schema, Entity user, Entity device) {
|
||||
Entity activitySample = addEntity(schema, "ID115ActivitySample");
|
||||
activitySample.implementsSerializable();
|
||||
addCommonActivitySampleProperties("AbstractActivitySample", activitySample, user, device);
|
||||
activitySample.addIntProperty(SAMPLE_STEPS).notNull().codeBeforeGetterAndSetter(OVERRIDE);
|
||||
activitySample.addIntProperty(SAMPLE_RAW_KIND).notNull().codeBeforeGetterAndSetter(OVERRIDE);
|
||||
activitySample.addIntProperty("caloriesBurnt");
|
||||
activitySample.addIntProperty("distanceMeters");
|
||||
activitySample.addIntProperty("activeTimeMinutes");
|
||||
return activitySample;
|
||||
}
|
||||
|
||||
private static void addCommonActivitySampleProperties(String superClass, Entity activitySample, Entity user, Entity device) {
|
||||
activitySample.setSuperclass(superClass);
|
||||
activitySample.addImport(MAIN_PACKAGE + ".devices.SampleProvider");
|
||||
|
@ -0,0 +1,94 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.id115;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
||||
|
||||
import static nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport.BASE_UUID;
|
||||
|
||||
public class ID115Constants {
|
||||
public static final String PREF_WRIST = "id115_wrist";
|
||||
public static final String PREF_SCREEN_ORIENTATION = "id115_screen_orientation";
|
||||
|
||||
public static final UUID UUID_SERVICE_ID115 = UUID.fromString(String.format(BASE_UUID, "0AF0"));
|
||||
public static final UUID UUID_CHARACTERISTIC_WRITE_NORMAL = UUID.fromString(String.format(BASE_UUID, "0AF6"));
|
||||
public static final UUID UUID_CHARACTERISTIC_NOTIFY_NORMAL = UUID.fromString(String.format(BASE_UUID, "0AF7"));
|
||||
public static final UUID UUID_CHARACTERISTIC_WRITE_HEALTH = UUID.fromString(String.format(BASE_UUID, "0AF1"));
|
||||
public static final UUID UUID_CHARACTERISTIC_NOTIFY_HEALTH = UUID.fromString(String.format(BASE_UUID, "0AF2"));
|
||||
|
||||
public static final byte CMD_ID_WARE_UPDATE = 0x01;
|
||||
public static final byte CMD_ID_GET_INFO = 0x02;
|
||||
public static final byte CMD_ID_SETTINGS = 0x03;
|
||||
public static final byte CMD_ID_BIND_UNBIND = 0x04;
|
||||
public static final byte CMD_ID_NOTIFY = 0x05;
|
||||
public static final byte CMD_ID_APP_CONTROL = 0x06;
|
||||
public static final byte CMD_ID_BLE_CONTROL = 0x07;
|
||||
public static final byte CMD_ID_HEALTH_DATA = 0x08;
|
||||
public static final byte CMD_ID_DUMP_STACK = 0x20;
|
||||
public static final byte CMD_ID_LOG = 0x21;
|
||||
public static final byte CMD_ID_FACTORY = (byte)0xaa;
|
||||
public static final byte CMD_ID_DEVICE_RESTART = (byte)0xf0;
|
||||
|
||||
// CMD_ID_SETTINGS
|
||||
public static final byte CMD_KEY_SET_TIME = 0x01;
|
||||
public static final byte CMD_KEY_SET_GOAL = 0x03;
|
||||
public static final byte CMD_KEY_SET_HAND = 0x22;
|
||||
public static final byte CMD_ARG_LEFT = 0x00;
|
||||
public static final byte CMD_ARG_RIGHT = 0x01;
|
||||
public static final byte CMD_KEY_SET_DISPLAY_MODE = 0x2B;
|
||||
public static final byte CMD_ARG_HORIZONTAL = 0x00;
|
||||
public static final byte CMD_ARG_VERTICAL = 0x02;
|
||||
|
||||
// CMD_ID_NOTIFY
|
||||
public static final byte CMD_KEY_NOTIFY_CALL = 0x01;
|
||||
public static final byte CMD_KEY_NOTIFY_STOP = 0x02;
|
||||
public static final byte CMD_KEY_NOTIFY_MSG = 0x03;
|
||||
|
||||
// CMD_ID_HEALTH_DATA
|
||||
public static final byte CMD_KEY_FETCH_ACTIVITY_TODAY = 0x03;
|
||||
|
||||
// CMD_ID_DEVICE_RESTART
|
||||
public static final byte CMD_KEY_REBOOT = 0x01;
|
||||
|
||||
public static byte getNotificationType(NotificationType type) {
|
||||
switch (type) {
|
||||
// case GENERIC_EMAIL:
|
||||
// return 2; // Icon is not supported
|
||||
case WECHAT:
|
||||
return 3;
|
||||
// case QQ:
|
||||
// return 4;
|
||||
case FACEBOOK:
|
||||
return 6;
|
||||
case TWITTER:
|
||||
return 7;
|
||||
case WHATSAPP:
|
||||
return 8;
|
||||
case FACEBOOK_MESSENGER:
|
||||
return 9;
|
||||
case INSTAGRAM:
|
||||
return 10;
|
||||
case LINKEDIN:
|
||||
return 11;
|
||||
// case GENERIC_CALENDAR:
|
||||
// return 12; // Icon is not supported
|
||||
// case SKYPE:
|
||||
// return 13; // Icon is not supported
|
||||
// case LINE:
|
||||
// return 17; // Icon is not supported
|
||||
// case VIBER:
|
||||
// return 18; // Icon is not supported
|
||||
// case KAKAO_TALK:
|
||||
// return 19; // Icon is not supported
|
||||
// case VK:
|
||||
// return 16; // Icon is not supported
|
||||
// case GMAIL:
|
||||
// return 20; // Icon is not supported
|
||||
// case OUTLOOK:
|
||||
// return 21; // Icon is not supported
|
||||
// case SNAPCHAT:
|
||||
// return 22; // Icon is not supported
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
@ -0,0 +1,140 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.id115;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.bluetooth.le.ScanFilter;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.ParcelUuid;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractDeviceCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.SampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.Device;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
|
||||
public class ID115Coordinator extends AbstractDeviceCoordinator {
|
||||
@NonNull
|
||||
@Override
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
public Collection<? extends ScanFilter> createBLEScanFilters() {
|
||||
ParcelUuid service = new ParcelUuid(ID115Constants.UUID_SERVICE_ID115);
|
||||
ScanFilter filter = new ScanFilter.Builder().setServiceUuid(service).build();
|
||||
return Collections.singletonList(filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
|
||||
if (candidate.supportsService(ID115Constants.UUID_SERVICE_ID115)) {
|
||||
return DeviceType.ID115;
|
||||
}
|
||||
return DeviceType.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBondingStyle(GBDevice deviceCandidate){
|
||||
return BONDING_STYLE_NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceType getDeviceType() {
|
||||
return DeviceType.ID115;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Class<? extends Activity> getPairingActivity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsActivityDataFetching() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsActivityTracking() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SampleProvider<? extends ActivitySample> getSampleProvider(GBDevice device, DaoSession session) {
|
||||
return new ID115SampleProvider(device, session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstallHandler findInstallHandler(Uri uri, Context context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsScreenshots() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAlarmConfiguration() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsSmartWakeup(GBDevice device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsHeartRateMeasurement(GBDevice device) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManufacturer() {
|
||||
return "VeryFit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAppsManagement() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Activity> getAppsManagementActivity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsCalendarEvents() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsRealtimeData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsWeather() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsFindDevice() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.devices.id115;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import de.greenrobot.dao.AbstractDao;
|
||||
import de.greenrobot.dao.Property;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractSampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.DaoSession;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.ID115ActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.ID115ActivitySampleDao;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
|
||||
public class ID115SampleProvider extends AbstractSampleProvider<ID115ActivitySample> {
|
||||
public ID115SampleProvider(GBDevice device, DaoSession session) {
|
||||
super(device, session);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractDao<ID115ActivitySample, ?> getSampleDao() {
|
||||
return getSession().getID115ActivitySampleDao();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected Property getRawKindSampleProperty() {
|
||||
return ID115ActivitySampleDao.Properties.RawKind;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Property getTimestampSampleProperty() {
|
||||
return ID115ActivitySampleDao.Properties.Timestamp;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Property getDeviceIdentifierSampleProperty() {
|
||||
return ID115ActivitySampleDao.Properties.DeviceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int normalizeType(int rawType) {
|
||||
return rawType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int toRawActivityKind(int activityKind) {
|
||||
return activityKind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float normalizeIntensity(int rawIntensity) {
|
||||
return rawIntensity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ID115ActivitySample createActivitySample() {
|
||||
return new ID115ActivitySample();
|
||||
}
|
||||
}
|
@ -47,6 +47,7 @@ public enum DeviceType {
|
||||
TECLASTH30(60, R.drawable.ic_device_h30_h10, R.drawable.ic_device_h30_h10_disabled, R.string.devicetype_teclast_h30),
|
||||
XWATCH(70, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled, R.string.devicetype_xwatch),
|
||||
ZETIME(80, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled, R.string.devicetype_mykronoz_zetime),
|
||||
ID115(90, R.drawable.ic_device_h30_h10, R.drawable.ic_device_h30_h10_disabled, R.string.devicetype_id115),
|
||||
TEST(1000, R.drawable.ic_device_default, R.drawable.ic_device_default_disabled, R.string.devicetype_test);
|
||||
|
||||
private final int key;
|
||||
|
@ -31,6 +31,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitcor.AmazfitCorSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband3.MiBand3Support;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.id115.ID115Support;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.liveview.LiveviewSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband2.MiBand2Support;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.AmazfitBipSupport;
|
||||
@ -156,6 +157,9 @@ public class DeviceSupportFactory {
|
||||
case ZETIME:
|
||||
deviceSupport = new ServiceDeviceSupport(new ZeTimeDeviceSupport(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
||||
break;
|
||||
case ID115:
|
||||
deviceSupport = new ServiceDeviceSupport(new ID115Support(), EnumSet.of(ServiceDeviceSupport.Flags.BUSY_CHECKING));
|
||||
break;
|
||||
}
|
||||
if (deviceSupport != null) {
|
||||
deviceSupport.setContext(gbDevice, mBtAdapter, mContext);
|
||||
|
@ -0,0 +1,80 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.id115;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.id115.ID115Constants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.OperationStatus;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public abstract class AbstractID115Operation extends AbstractBTLEOperation<ID115Support> {
|
||||
protected BluetoothGattCharacteristic controlCharacteristic = null;
|
||||
protected BluetoothGattCharacteristic notifyCharacteristic = null;
|
||||
|
||||
protected AbstractID115Operation(ID115Support support) {
|
||||
super(support);
|
||||
|
||||
if (isHealthOperation()) {
|
||||
controlCharacteristic = getCharacteristic(ID115Constants.UUID_CHARACTERISTIC_WRITE_HEALTH);
|
||||
notifyCharacteristic = getCharacteristic(ID115Constants.UUID_CHARACTERISTIC_NOTIFY_HEALTH);
|
||||
} else {
|
||||
controlCharacteristic = getCharacteristic(ID115Constants.UUID_CHARACTERISTIC_WRITE_NORMAL);
|
||||
notifyCharacteristic = getCharacteristic(ID115Constants.UUID_CHARACTERISTIC_NOTIFY_NORMAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prePerform() throws IOException {
|
||||
super.prePerform();
|
||||
getDevice().setBusyTask("AbstractID115Operation starting..."); // mark as busy quickly to avoid interruptions from the outside
|
||||
TransactionBuilder builder = performInitialized("disabling some notifications");
|
||||
enableNotifications(builder, true);
|
||||
builder.queue(getQueue());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void operationFinished() {
|
||||
operationStatus = OperationStatus.FINISHED;
|
||||
if (getDevice() != null && getDevice().isConnected()) {
|
||||
unsetBusy();
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("reenabling disabled notifications");
|
||||
enableNotifications(builder, false);
|
||||
builder.setGattCallback(null); // unset ourselves from being the queue's gatt callback
|
||||
builder.queue(getQueue());
|
||||
} catch (IOException ex) {
|
||||
GB.toast(getContext(), "Error enabling ID115 notifications, you may need to connect and disconnect", Toast.LENGTH_LONG, GB.ERROR, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCharacteristicChanged(BluetoothGatt gatt,
|
||||
BluetoothGattCharacteristic characteristic) {
|
||||
UUID characteristicUUID = characteristic.getUuid();
|
||||
if (notifyCharacteristic.getUuid().equals(characteristicUUID)) {
|
||||
handleResponse(characteristic.getValue());
|
||||
return true;
|
||||
} else {
|
||||
return super.onCharacteristicChanged(gatt, characteristic);
|
||||
}
|
||||
}
|
||||
|
||||
void enableNotifications(TransactionBuilder builder, boolean enable) {
|
||||
if (isHealthOperation()) {
|
||||
builder.notify(getCharacteristic(ID115Constants.UUID_CHARACTERISTIC_NOTIFY_HEALTH), enable);
|
||||
} else {
|
||||
builder.notify(getCharacteristic(ID115Constants.UUID_CHARACTERISTIC_NOTIFY_NORMAL), enable);
|
||||
}
|
||||
}
|
||||
|
||||
abstract boolean isHealthOperation();
|
||||
|
||||
abstract void handleResponse(byte[] data);
|
||||
}
|
@ -0,0 +1,160 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.id115;
|
||||
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHandler;
|
||||
import nodomain.freeyourgadget.gadgetbridge.database.DBHelper;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.id115.ID115Constants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.id115.ID115SampleProvider;
|
||||
import nodomain.freeyourgadget.gadgetbridge.entities.ID115ActivitySample;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityKind;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class FetchActivityOperation extends AbstractID115Operation {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(FetchActivityOperation.class);
|
||||
private byte expectedCmd;
|
||||
private byte expectedSeq;
|
||||
private ArrayList<byte[]> packets;
|
||||
|
||||
protected FetchActivityOperation(ID115Support support) {
|
||||
super(support);
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isHealthOperation() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPerform() throws IOException {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
outputStream.write(ID115Constants.CMD_ID_HEALTH_DATA);
|
||||
outputStream.write(ID115Constants.CMD_KEY_FETCH_ACTIVITY_TODAY);
|
||||
outputStream.write(0x01);
|
||||
outputStream.write(0x00);
|
||||
outputStream.write(0x00);
|
||||
byte cmd[] = outputStream.toByteArray();
|
||||
|
||||
expectedCmd = ID115Constants.CMD_KEY_FETCH_ACTIVITY_TODAY;
|
||||
expectedSeq = 1;
|
||||
packets = new ArrayList<>();
|
||||
|
||||
TransactionBuilder builder = performInitialized("send activity fetch request");
|
||||
builder.write(controlCharacteristic, cmd);
|
||||
builder.queue(getQueue());
|
||||
}
|
||||
|
||||
@Override
|
||||
void handleResponse(byte[] data) {
|
||||
if (!isOperationRunning()) {
|
||||
LOG.error("ignoring notification because operation is not running. Data length: " + data.length);
|
||||
getSupport().logMessageContent(data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.length < 4) {
|
||||
LOG.warn("short GATT response");
|
||||
return;
|
||||
}
|
||||
|
||||
if (data[0] == ID115Constants.CMD_ID_HEALTH_DATA) {
|
||||
if (data[1] == (byte)0xEE) {
|
||||
LOG.info("Activity data transfer has finished.");
|
||||
parseAndStore();
|
||||
operationFinished();
|
||||
} else {
|
||||
if ((data[1] != expectedCmd) || (data[2] != expectedSeq)) {
|
||||
GB.toast(getContext(), "Error fetching ID115 activity data, you may need to connect and disconnect", Toast.LENGTH_LONG, GB.ERROR);
|
||||
operationFinished();
|
||||
return;
|
||||
}
|
||||
expectedSeq += 1;
|
||||
|
||||
byte payload[] = new byte[data.length - 4];
|
||||
System.arraycopy(data, 4, payload, 0, payload.length);
|
||||
packets.add(payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void parseAndStore() {
|
||||
if (packets.size() <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] header = packets.get(0);
|
||||
int year = ((header[1] & 0xFF) << 8) | (header[0] & 0xFF);
|
||||
int month = header[2] & 0xFF;
|
||||
int day = header[3] & 0xFF;
|
||||
int sampleDurationMinutes = header[6] & 0xFF;
|
||||
Calendar calendar = new GregorianCalendar(year, month - 1, day);
|
||||
int ts = (int)(calendar.getTimeInMillis() / 1000);
|
||||
int dt = sampleDurationMinutes * 60;
|
||||
|
||||
ArrayList<ID115ActivitySample> samples = new ArrayList<>();
|
||||
|
||||
for (int i = 2; i < packets.size(); i++) {
|
||||
byte[] packet = packets.get(i);
|
||||
for (int j = 0; j <= packet.length - 5; j += 5) {
|
||||
byte[] sampleData = new byte[5];
|
||||
System.arraycopy(packet, j, sampleData, 0, sampleData.length);
|
||||
|
||||
ID115ActivitySample sample = parseSample(sampleData);
|
||||
if (sample != null) {
|
||||
sample.setTimestamp(ts);
|
||||
sample.setRawKind(ActivityKind.TYPE_ACTIVITY);
|
||||
samples.add(sample);
|
||||
}
|
||||
ts += dt;
|
||||
}
|
||||
}
|
||||
|
||||
try (DBHandler dbHandler = GBApplication.acquireDB()) {
|
||||
ID115ActivitySample[] sampleArray = samples.toArray(new ID115ActivitySample[0]);
|
||||
long userId = DBHelper.getUser(dbHandler.getDaoSession()).getId();
|
||||
long deviceId = DBHelper.getDevice(getDevice(), dbHandler.getDaoSession()).getId();
|
||||
for (ID115ActivitySample sample: sampleArray) {
|
||||
sample.setUserId(userId);
|
||||
sample.setDeviceId(deviceId);
|
||||
}
|
||||
|
||||
ID115SampleProvider provider = new ID115SampleProvider(getDevice(), dbHandler.getDaoSession());
|
||||
provider.addGBActivitySamples(sampleArray);
|
||||
} catch (Exception ex) {
|
||||
GB.toast(getContext(), "Error saving activity data: " + ex.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
ID115ActivitySample parseSample(byte[] data) {
|
||||
int d01 = ((data[1] & 0xFF) << 8) | (data[0] & 0xFF);
|
||||
int d12 = ((data[2] & 0xFF) << 8) | (data[1] & 0xFF);
|
||||
int d23 = ((data[3] & 0xFF) << 8) | (data[2] & 0xFF);
|
||||
int d34 = ((data[4] & 0xFF) << 8) | (data[3] & 0xFF);
|
||||
int stepCount = (d01 >> 2) & 0xFFF;
|
||||
int activeTime = (d12 >> 6) & 0xF;
|
||||
int calories = (d23 >> 2) & 0x3FF;
|
||||
int distance = (d34 >> 4);
|
||||
|
||||
if (stepCount == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ID115ActivitySample sample = new ID115ActivitySample();
|
||||
sample.setSteps(stepCount);
|
||||
sample.setActiveTimeMinutes(activeTime);
|
||||
sample.setCaloriesBurnt(calories);
|
||||
sample.setDistanceMeters(distance);
|
||||
return sample;
|
||||
}
|
||||
}
|
@ -0,0 +1,342 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.id115;
|
||||
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.id115.ID115Constants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.ActivityUser;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.Alarm;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.GattService;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction;
|
||||
|
||||
public class ID115Support extends AbstractBTLEDeviceSupport {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ID115Support.class);
|
||||
|
||||
public BluetoothGattCharacteristic normalWriteCharacteristic = null;
|
||||
public BluetoothGattCharacteristic healthWriteCharacteristic = null;
|
||||
|
||||
public ID115Support() {
|
||||
super(LOG);
|
||||
addSupportedService(GattService.UUID_SERVICE_GENERIC_ACCESS);
|
||||
addSupportedService(GattService.UUID_SERVICE_GENERIC_ATTRIBUTE);
|
||||
addSupportedService(ID115Constants.UUID_SERVICE_ID115);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
|
||||
normalWriteCharacteristic = getCharacteristic(ID115Constants.UUID_CHARACTERISTIC_WRITE_NORMAL);
|
||||
healthWriteCharacteristic = getCharacteristic(ID115Constants.UUID_CHARACTERISTIC_WRITE_HEALTH);
|
||||
|
||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext()));
|
||||
|
||||
setTime(builder)
|
||||
.setWrist(builder)
|
||||
.setScreenOrientation(builder)
|
||||
.setGoal(builder)
|
||||
.setInitialized(builder);
|
||||
|
||||
getDevice().setFirmwareVersion("N/A");
|
||||
getDevice().setFirmwareVersion2("N/A");
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useAutoConnect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotification(NotificationSpec notificationSpec) {
|
||||
try {
|
||||
new SendNotificationOperation(this, notificationSpec).perform();
|
||||
} catch (IOException ex) {
|
||||
LOG.error("Unable to send ID115 notification", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteNotification(int id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetTime() {
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("time");
|
||||
setTime(builder);
|
||||
performConnected(builder.getTransaction());
|
||||
} catch(IOException e) {
|
||||
LOG.warn("Unable to send current time", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetAlarms(ArrayList<? extends Alarm> alarms) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetCallState(CallSpec callSpec) {
|
||||
if (callSpec.command == CallSpec.CALL_INCOMING) {
|
||||
try {
|
||||
new SendNotificationOperation(this, callSpec).perform();
|
||||
} catch (IOException ex) {
|
||||
LOG.error("Unable to send ID115 notification", ex);
|
||||
}
|
||||
} else {
|
||||
sendStopCallNotification();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetCannedMessages(CannedMessagesSpec cannedMessagesSpec) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetMusicState(MusicStateSpec stateSpec) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetMusicInfo(MusicSpec musicSpec) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnableRealtimeSteps(boolean enable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInstallApp(Uri uri) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppInfoReq() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppStart(UUID uuid, boolean start) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppDelete(UUID uuid) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppConfiguration(UUID appUuid, String config, Integer id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAppReorder(UUID[] uuids) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFetchRecordedData(int dataTypes) {
|
||||
try {
|
||||
new FetchActivityOperation(this).perform();
|
||||
} catch (IOException ex) {
|
||||
LOG.error("Unable to fetch ID115 activity data", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReboot() {
|
||||
try {
|
||||
getQueue().clear();
|
||||
|
||||
TransactionBuilder builder = performInitialized("reboot");
|
||||
builder.write(normalWriteCharacteristic, new byte[] {
|
||||
ID115Constants.CMD_ID_DEVICE_RESTART, ID115Constants.CMD_KEY_REBOOT
|
||||
});
|
||||
performConnected(builder.getTransaction());
|
||||
} catch(Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHeartRateTest() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnableRealtimeHeartRateMeasurement(boolean enable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFindDevice(boolean start) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetConstantVibration(int integer) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScreenshotReq() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnableHeartRateSleepSupport(boolean enable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetHeartRateMeasurementInterval(int seconds) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddCalendarEvent(CalendarEventSpec calendarEventSpec) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeleteCalendarEvent(byte type, long id) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSendConfiguration(String config) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTestNewFunction() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSendWeather(WeatherSpec weatherSpec) {
|
||||
|
||||
}
|
||||
|
||||
private void setInitialized(TransactionBuilder builder) {
|
||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZED, getContext()));
|
||||
}
|
||||
|
||||
ID115Support setTime(TransactionBuilder builder) {
|
||||
Calendar c = Calendar.getInstance(TimeZone.getDefault());
|
||||
|
||||
int day = c.get(Calendar.DAY_OF_WEEK);
|
||||
|
||||
byte dayOfWeek;
|
||||
if (day == Calendar.SUNDAY) {
|
||||
dayOfWeek = 6;
|
||||
} else {
|
||||
dayOfWeek = (byte)(day - 2);
|
||||
}
|
||||
|
||||
int year = c.get(Calendar.YEAR);
|
||||
builder.write(normalWriteCharacteristic, new byte[] {
|
||||
ID115Constants.CMD_ID_SETTINGS, ID115Constants.CMD_KEY_SET_TIME,
|
||||
(byte)(year & 0xff),
|
||||
(byte)(year >> 8),
|
||||
(byte)(1 + c.get(Calendar.MONTH)),
|
||||
(byte)c.get(Calendar.DAY_OF_MONTH),
|
||||
(byte)c.get(Calendar.HOUR_OF_DAY),
|
||||
(byte)c.get(Calendar.MINUTE),
|
||||
(byte)c.get(Calendar.SECOND),
|
||||
dayOfWeek
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
ID115Support setWrist(TransactionBuilder builder) {
|
||||
String value = GBApplication.getPrefs().getString(ID115Constants.PREF_WRIST,
|
||||
"left");
|
||||
|
||||
byte wrist;
|
||||
if (value.equals("left")) {
|
||||
wrist = ID115Constants.CMD_ARG_LEFT;
|
||||
} else {
|
||||
wrist = ID115Constants.CMD_ARG_RIGHT;
|
||||
}
|
||||
|
||||
builder.write(normalWriteCharacteristic, new byte[] {
|
||||
ID115Constants.CMD_ID_SETTINGS, ID115Constants.CMD_KEY_SET_HAND,
|
||||
wrist
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
ID115Support setScreenOrientation(TransactionBuilder builder) {
|
||||
String value = GBApplication.getPrefs().getString(ID115Constants.PREF_SCREEN_ORIENTATION,
|
||||
"horizontal");
|
||||
|
||||
byte orientation;
|
||||
if (value.equals("horizontal")) {
|
||||
orientation = ID115Constants.CMD_ARG_HORIZONTAL;
|
||||
} else {
|
||||
orientation = ID115Constants.CMD_ARG_VERTICAL;
|
||||
}
|
||||
|
||||
builder.write(normalWriteCharacteristic, new byte[] {
|
||||
ID115Constants.CMD_ID_SETTINGS, ID115Constants.CMD_KEY_SET_DISPLAY_MODE,
|
||||
orientation
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
private ID115Support setGoal(TransactionBuilder transaction) {
|
||||
ActivityUser activityUser = new ActivityUser();
|
||||
int value = activityUser.getStepsGoal();
|
||||
|
||||
transaction.write(normalWriteCharacteristic, new byte[]{
|
||||
ID115Constants.CMD_ID_SETTINGS,
|
||||
ID115Constants.CMD_KEY_SET_GOAL,
|
||||
0,
|
||||
(byte) (value & 0xff),
|
||||
(byte) ((value >> 8) & 0xff),
|
||||
(byte) ((value >> 16) & 0xff),
|
||||
(byte) ((value >> 24) & 0xff),
|
||||
0, 0
|
||||
});
|
||||
return this;
|
||||
}
|
||||
|
||||
void sendStopCallNotification() {
|
||||
try {
|
||||
TransactionBuilder builder = performInitialized("stop_call_notification");
|
||||
builder.write(normalWriteCharacteristic, new byte[] {
|
||||
ID115Constants.CMD_ID_NOTIFY,
|
||||
ID115Constants.CMD_KEY_NOTIFY_STOP,
|
||||
1
|
||||
});
|
||||
performConnected(builder.getTransaction());
|
||||
} catch(IOException e) {
|
||||
LOG.warn("Unable to stop call notification", e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,193 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.id115;
|
||||
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.id115.ID115Constants;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class SendNotificationOperation extends AbstractID115Operation {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(SendNotificationOperation.class);
|
||||
|
||||
byte[] currentNotificationBuffer;
|
||||
int currentNotificationSize;
|
||||
int currentNotificationIndex;
|
||||
byte currentNotificationType;
|
||||
|
||||
SendNotificationOperation(ID115Support support, NotificationSpec notificationSpec)
|
||||
{
|
||||
super(support);
|
||||
|
||||
String phone = "";
|
||||
if (notificationSpec.phoneNumber != null) {
|
||||
phone = notificationSpec.phoneNumber;
|
||||
}
|
||||
|
||||
String title = "";
|
||||
if (notificationSpec.sender != null) {
|
||||
title = notificationSpec.sender;
|
||||
} else if (notificationSpec.title != null) {
|
||||
title = notificationSpec.title;
|
||||
} else if (notificationSpec.subject != null) {
|
||||
title = notificationSpec.subject;
|
||||
}
|
||||
|
||||
String text = "";
|
||||
if (notificationSpec.body != null) {
|
||||
text = notificationSpec.body;
|
||||
}
|
||||
|
||||
currentNotificationBuffer = encodeMessageNotification(notificationSpec.type, title, phone, text);
|
||||
currentNotificationSize = (currentNotificationBuffer.length + 15) / 16;
|
||||
currentNotificationType = ID115Constants.CMD_KEY_NOTIFY_MSG;
|
||||
}
|
||||
|
||||
SendNotificationOperation(ID115Support support, CallSpec callSpec)
|
||||
{
|
||||
super(support);
|
||||
|
||||
String number = "";
|
||||
if (callSpec.number != null) {
|
||||
number = callSpec.number;
|
||||
}
|
||||
|
||||
String name = "";
|
||||
if (callSpec.name != null) {
|
||||
name = callSpec.name;
|
||||
}
|
||||
|
||||
currentNotificationBuffer = encodeCallNotification(name, number);
|
||||
currentNotificationSize = (currentNotificationBuffer.length + 15) / 16;
|
||||
currentNotificationType = ID115Constants.CMD_KEY_NOTIFY_CALL;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean isHealthOperation() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPerform() throws IOException {
|
||||
sendNotificationChunk(1);
|
||||
}
|
||||
|
||||
void sendNotificationChunk(int chunkIndex) throws IOException {
|
||||
currentNotificationIndex = chunkIndex;
|
||||
|
||||
int offset = (chunkIndex - 1) * 16;
|
||||
int tailSize = currentNotificationBuffer.length - offset;
|
||||
int chunkSize = (tailSize > 16)? 16 : tailSize;
|
||||
|
||||
byte raw[] = new byte[16];
|
||||
System.arraycopy(currentNotificationBuffer, offset, raw, 0, chunkSize);
|
||||
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
outputStream.write(ID115Constants.CMD_ID_NOTIFY);
|
||||
outputStream.write(currentNotificationType);
|
||||
outputStream.write((byte)currentNotificationSize);
|
||||
outputStream.write((byte)currentNotificationIndex);
|
||||
outputStream.write(raw);
|
||||
byte cmd[] = outputStream.toByteArray();
|
||||
|
||||
TransactionBuilder builder = performInitialized("send notification chunk");
|
||||
builder.write(controlCharacteristic, cmd);
|
||||
builder.queue(getQueue());
|
||||
}
|
||||
|
||||
void handleResponse(byte[] data) {
|
||||
if (!isOperationRunning()) {
|
||||
LOG.error("ignoring notification because operation is not running. Data length: " + data.length);
|
||||
getSupport().logMessageContent(data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.length < 2) {
|
||||
LOG.warn("short GATT response");
|
||||
return;
|
||||
}
|
||||
if (data[0] == ID115Constants.CMD_ID_NOTIFY) {
|
||||
if (data.length < 4) {
|
||||
LOG.warn("short GATT response for NOTIFY");
|
||||
return;
|
||||
}
|
||||
if (data[1] == currentNotificationType) {
|
||||
if (data[3] == currentNotificationIndex) {
|
||||
if (currentNotificationIndex != currentNotificationSize) {
|
||||
try {
|
||||
sendNotificationChunk(currentNotificationIndex + 1);
|
||||
} catch (IOException ex) {
|
||||
GB.toast(getContext(), "Error sending ID115 notification, you may need to connect and disconnect", Toast.LENGTH_LONG, GB.ERROR, ex);
|
||||
}
|
||||
} else {
|
||||
LOG.info("Notification transfer has finished.");
|
||||
operationFinished();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
byte[] encodeCallNotification(String name, String phone) {
|
||||
if (name.length() > 20) {
|
||||
name = name.substring(0, 20);
|
||||
}
|
||||
if (phone.length() > 20) {
|
||||
phone = phone.substring(0, 20);
|
||||
}
|
||||
|
||||
byte[] name_bytes = name.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] phone_bytes = phone.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
outputStream.write((byte) phone_bytes.length);
|
||||
outputStream.write((byte) name_bytes.length);
|
||||
outputStream.write(phone_bytes);
|
||||
outputStream.write(name_bytes);
|
||||
return outputStream.toByteArray();
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
byte[] encodeMessageNotification(NotificationType type, String title, String phone, String text) {
|
||||
if (title.length() > 20) {
|
||||
title = title.substring(0, 20);
|
||||
}
|
||||
if (phone.length() > 20) {
|
||||
phone = phone.substring(0, 20);
|
||||
}
|
||||
if (text.length() > 20) {
|
||||
text = text.substring(0, 20);
|
||||
}
|
||||
byte[] title_bytes = title.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] phone_bytes = phone.getBytes(StandardCharsets.UTF_8);
|
||||
byte[] text_bytes = text.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
byte nativeType = ID115Constants.getNotificationType(type);
|
||||
|
||||
try {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
outputStream.write(nativeType);
|
||||
outputStream.write((byte) text_bytes.length);
|
||||
outputStream.write((byte) phone_bytes.length);
|
||||
outputStream.write((byte) title_bytes.length);
|
||||
outputStream.write(phone_bytes);
|
||||
outputStream.write(title_bytes);
|
||||
outputStream.write(text_bytes);
|
||||
return outputStream.toByteArray();
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -50,6 +50,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitcor.AmazfitCorC
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband2.MiBand2Coordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband2.MiBand2HRXCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.huami.miband3.MiBand3Coordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.id115.ID115Coordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.jyou.TeclastH30Coordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.liveview.LiveviewCoordinator;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandConst;
|
||||
@ -213,6 +214,7 @@ public class DeviceHelper {
|
||||
result.add(new TeclastH30Coordinator());
|
||||
result.add(new XWatchCoordinator());
|
||||
result.add(new ZeTimeCoordinator());
|
||||
result.add(new ID115Coordinator());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -86,6 +86,15 @@
|
||||
<item>right</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="orientation">
|
||||
<item>@string/horizontal</item>
|
||||
<item>@string/vertical</item>
|
||||
</string-array>
|
||||
<string-array name="orientation_values">
|
||||
<item>horizontal</item>
|
||||
<item>vertical</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="vibration_profile">
|
||||
<item>@string/vibration_profile_staccato</item>
|
||||
<item>@string/vibration_profile_short</item>
|
||||
|
@ -192,6 +192,10 @@
|
||||
<string name="prefs_title_all_day_heart_rate">All day heart rate measurement</string>
|
||||
<string name="preferences_hplus_settings">HPlus/Makibes settings</string>
|
||||
|
||||
<!-- ID115 Preferences -->
|
||||
<string name="preferences_id115_settings">ID115 settings</string>
|
||||
<string name="prefs_screen_orientation">Screen orientation</string>
|
||||
|
||||
<!-- Auto export preferences -->
|
||||
<string name="pref_header_auto_export">Auto export</string>
|
||||
<string name="pref_title_auto_export_enabled">Auto export enabled</string>
|
||||
@ -252,6 +256,8 @@
|
||||
<string name="other">Other</string>
|
||||
<string name="left">Left</string>
|
||||
<string name="right">Right</string>
|
||||
<string name="horizontal">Horizontal</string>
|
||||
<string name="vertical">Vertical</string>
|
||||
<string name="miband_pairing_using_dummy_userdata">No valid user data given, using dummy user data for now.</string>
|
||||
<string name="miband_pairing_tap_hint">When your Mi Band vibrates and blinks, tap it a few times in a row.</string>
|
||||
<string name="appinstaller_install">Install</string>
|
||||
@ -567,6 +573,7 @@
|
||||
<string name="devicetype_teclast_h30">Teclast H30</string>
|
||||
<string name="devicetype_xwatch">XWatch</string>
|
||||
<string name="devicetype_mykronoz_zetime">MyKronoz ZeTime</string>
|
||||
<string name="devicetype_id115">ID115</string>
|
||||
|
||||
<string name="choose_auto_export_location">Choose export location</string>
|
||||
<string name="notification_channel_name">Gadgetbridge notifications</string>
|
||||
|
@ -507,6 +507,31 @@
|
||||
</PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
<PreferenceScreen
|
||||
android:icon="@drawable/ic_device_h30_h10"
|
||||
android:key="pref_key_id115"
|
||||
android:title="@string/preferences_id115_settings">
|
||||
<PreferenceCategory
|
||||
android:key="pref_category_id115_general"
|
||||
android:title="@string/pref_header_general">
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="left"
|
||||
android:entries="@array/wearside"
|
||||
android:entryValues="@array/wearside_values"
|
||||
android:key="id115_wrist"
|
||||
android:title="@string/miband_prefs_wearside"
|
||||
android:summary="%s" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="horizontal"
|
||||
android:entries="@array/orientation"
|
||||
android:entryValues="@array/orientation_values"
|
||||
android:key="id115_screen_orientation"
|
||||
android:title="@string/prefs_screen_orientation"
|
||||
android:summary="%s" />
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
Loading…
Reference in New Issue
Block a user