mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-29 12:05:53 +01:00
Merge branch 'master' into feature-weather
This commit is contained in:
commit
9588535004
@ -1,27 +1,38 @@
|
||||
Andreas Shimokawa <shimokawa@fsfe.org>
|
||||
cpfeiffer <cpfeiffer@users.noreply.github.com>
|
||||
Daniele Gobbetti <daniele+github@gobbetti.name>
|
||||
Daniele Gobbetti <daniele@gobbetti.name>
|
||||
danielegobbetti <daniele+github@gobbetti.name>
|
||||
Carsten Pfeiffer <cpfeiffer@users.noreply.github.com>
|
||||
Daniele Gobbetti <daniele@gobbetti.name>
|
||||
Julien Pivotto <roidelapluie@inuits.eu>
|
||||
Steffen Liebergeld <perl@gmx.org>
|
||||
Lem Dulfo <lemuel.dulfo@gmail.com>
|
||||
Sergey Trofimov <sarg@sarg.org.ru>
|
||||
Daniele Gobbetti <daniele.gobbetti@gmail.com>
|
||||
cpfeiffer <cpfeiffer@users.github.com>
|
||||
JohnnySun <bmy001@gmail.com>
|
||||
Uwe Hermann <uwe@hermann-uwe.de>
|
||||
0nse <0nse@users.noreply.github.com>
|
||||
Gergely Peidl <gergely@peidl.net>
|
||||
Christian Fischer <sw-dev@computerlyrik.de>
|
||||
Normano64 <per.bergqwist@gmail.com>
|
||||
Ⲇⲁⲛⲓ Φi <daniphii@outlook.com>
|
||||
xzovy <caleb@caleb-cooper.net>
|
||||
xphnx <xphnx@users.noreply.github.com>
|
||||
Tarik Sekmen <tarik@ilixi.org>
|
||||
Szymon Tomasz Stefanek <s.stefanek@gmail.com>
|
||||
Roman Plevka <rplevka@redhat.com>
|
||||
rober <rober@prtl.nodomain.net>
|
||||
Nicolò Balzarotti <anothersms@gmail.com>
|
||||
Natanael Arndt <arndtn@gmail.com>
|
||||
Marc Schlaich <marc.schlaich@googlemail.com>
|
||||
kevlarcade <kevlarcade@gmail.com>
|
||||
Kevin Richter <me@kevinrichter.nl>
|
||||
Kasha <kasha_malaga@hotmail.com>
|
||||
Ivan <ivan_tizhanin@mail.ru>
|
||||
Gilles MOREL <contact@gilles-morel.fr>
|
||||
Gilles Émilien MOREL <Almtesh@users.noreply.github.com>
|
||||
Chris Perelstein <chris.perelstein@gmail.com>
|
||||
Carlos Ferreira <calbertoferreira@gmail.com>
|
||||
atkyritsis <at.kyritsis@gmail.com>
|
||||
andre <andre.buesgen@yahoo.de>
|
||||
Alexey Afanasev <avafanasiev@gmail.com>
|
||||
6arms1leg <m.brnsfld@googlemail.com>
|
||||
|
||||
And all the Transifex translators, which I cannot automatically list, at the moment.
|
||||
|
||||
|
@ -26,7 +26,7 @@ public class MiBand2Service {
|
||||
public static final UUID UUID_CHARACTERISTIC_3_CONFIGURATION = UUID.fromString("00000003-0000-3512-2118-0009af100700");
|
||||
public static final UUID UUID_UNKNOWN_CHARACTERISTIC4 = UUID.fromString("00000004-0000-3512-2118-0009af100700");
|
||||
public static final UUID UUID_CHARACTERISTIC_5_ACTIVITY_DATA = UUID.fromString("00000005-0000-3512-2118-0009af100700");
|
||||
public static final UUID UUID_UNKNOWN_CHARACTERISTIC6 = UUID.fromString("00000006-0000-3512-2118-0009af100700");
|
||||
public static final UUID UUID_CHARACTERISTIC_6_BATTERY_INFO = UUID.fromString("00000006-0000-3512-2118-0009af100700");
|
||||
public static final UUID UUID_UNKNOWN_CHARACTERISTIC7 = UUID.fromString("00000007-0000-3512-2118-0009af100700");
|
||||
public static final UUID UUID_UNKNOWN_CHARACTERISTIC8 = UUID.fromString("00000008-0000-3512-2118-0009af100700");
|
||||
// service uuid fee1
|
||||
|
@ -11,7 +11,7 @@ import nodomain.freeyourgadget.gadgetbridge.GBException;
|
||||
import nodomain.freeyourgadget.gadgetbridge.R;
|
||||
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.liveview.LiveviewSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.MiBand2Support;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.MiBand2Support;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.MiBandSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.pebble.PebbleSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.vibratissimo.VibratissimoSupport;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.miband2;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.MiBand2Support;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.operations.AbstractMiBandOperation;
|
||||
|
||||
public abstract class AbstractMiBand2Operation extends AbstractMiBandOperation<MiBand2Support> {
|
||||
|
@ -0,0 +1,95 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.miband2;
|
||||
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandDateConverter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.model.BatteryState;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.AbstractInfo;
|
||||
|
||||
//00000006-0000-3512-2118-0009af100700
|
||||
//
|
||||
// f = ?
|
||||
// 30 = 48%
|
||||
// 00 = 00 = STATUS_NORMAL, 01 = STATUS_CHARGING
|
||||
// e0 07 = 2016
|
||||
// 0b = 11
|
||||
// 1a = 26
|
||||
// 12 = 18
|
||||
// 23 = 35
|
||||
// 2c = 44
|
||||
// 04 = 4 // num charges??
|
||||
//
|
||||
// e0 07 = 2016 // last charge time
|
||||
// 0b = 11
|
||||
// 1a = 26
|
||||
// 17 = 23
|
||||
// 2b = 43
|
||||
// 3b = 59
|
||||
// 04 = 4 // num charges??
|
||||
// 64 = 100 // how much was charged
|
||||
|
||||
public class BatteryInfo extends AbstractInfo {
|
||||
public static final byte DEVICE_BATTERY_NORMAL = 0;
|
||||
public static final byte DEVICE_BATTERY_CHARGING = 1;
|
||||
// public static final byte DEVICE_BATTERY_LOW = 1;
|
||||
// public static final byte DEVICE_BATTERY_CHARGING_FULL = 3;
|
||||
// public static final byte DEVICE_BATTERY_CHARGE_OFF = 4;
|
||||
|
||||
public BatteryInfo(byte[] data) {
|
||||
super(data);
|
||||
}
|
||||
|
||||
public int getLevelInPercent() {
|
||||
if (mData.length >= 2) {
|
||||
return mData[1];
|
||||
}
|
||||
return 50; // actually unknown
|
||||
}
|
||||
|
||||
public BatteryState getState() {
|
||||
if (mData.length >= 3) {
|
||||
int value = mData[2];
|
||||
switch (value) {
|
||||
case DEVICE_BATTERY_NORMAL:
|
||||
return BatteryState.BATTERY_NORMAL;
|
||||
case DEVICE_BATTERY_CHARGING:
|
||||
return BatteryState.BATTERY_CHARGING;
|
||||
// case DEVICE_BATTERY_CHARGING:
|
||||
// return BatteryState.BATTERY_CHARGING;
|
||||
// case DEVICE_BATTERY_CHARGING_FULL:
|
||||
// return BatteryState.BATTERY_CHARGING_FULL;
|
||||
// case DEVICE_BATTERY_CHARGE_OFF:
|
||||
// return BatteryState.BATTERY_NOT_CHARGING_FULL;
|
||||
}
|
||||
}
|
||||
return BatteryState.UNKNOWN;
|
||||
}
|
||||
|
||||
public int getLastChargeLevelInParcent() {
|
||||
if (mData.length >= 20) {
|
||||
return mData[19];
|
||||
}
|
||||
return 50; // actually unknown
|
||||
}
|
||||
|
||||
public GregorianCalendar getLastChargeTime() {
|
||||
GregorianCalendar lastCharge = MiBandDateConverter.createCalendar();
|
||||
|
||||
if (mData.length >= 18) {
|
||||
lastCharge = BLETypeConversions.rawBytesToCalendar(new byte[]{
|
||||
mData[10], mData[11], mData[12], mData[13], mData[14], mData[15], mData[16], mData[17]
|
||||
}, true);
|
||||
}
|
||||
|
||||
return lastCharge;
|
||||
}
|
||||
|
||||
public int getNumCharges() {
|
||||
// if (mData.length >= 10) {
|
||||
// return ((0xff & mData[7]) | ((0xff & mData[8]) << 8));
|
||||
//
|
||||
// }
|
||||
return -1;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.miband;
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.miband2;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
@ -68,7 +68,11 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateA
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.WriteAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.deviceinfo.DeviceInfoProfile;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.profiles.heartrate.HeartRateProfile;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.Mi2NotificationStrategy;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.CheckAuthenticationNeededAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.DeviceInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.MiBandSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.NotificationStrategy;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.RealtimeSamplesSupport;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.operations.FetchActivityOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.operations.InitOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.operations.UpdateFirmwareOperation;
|
||||
@ -264,9 +268,9 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||
public MiBand2Support enableFurtherNotifications(TransactionBuilder builder, boolean enable) {
|
||||
// builder.notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_REALTIME_STEPS), enable)
|
||||
// .notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_ACTIVITY_DATA), enable)
|
||||
// .notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_BATTERY), enable)
|
||||
// .notify(getCharacteristic(MiBandService.UUID_CHARACTERISTIC_SENSOR_DATA), enable);
|
||||
builder.notify(getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_3_CONFIGURATION), enable);
|
||||
builder.notify(getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_6_BATTERY_INFO), enable);
|
||||
BluetoothGattCharacteristic heartrateCharacteristic = getCharacteristic(MiBandService.UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT);
|
||||
if (heartrateCharacteristic != null) {
|
||||
builder.notify(heartrateCharacteristic, enable);
|
||||
@ -363,6 +367,13 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||
return this;
|
||||
}
|
||||
|
||||
private MiBand2Support requestBatteryInfo(TransactionBuilder builder) {
|
||||
LOG.debug("Requesting Battery Info!");
|
||||
BluetoothGattCharacteristic characteristic = getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_6_BATTERY_INFO);
|
||||
builder.read(characteristic);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MiBand2Support requestDeviceInfo(TransactionBuilder builder) {
|
||||
LOG.debug("Requesting Device Info!");
|
||||
deviceInfoProfile.requestDeviceInfo(builder);
|
||||
@ -813,7 +824,7 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||
super.onCharacteristicChanged(gatt, characteristic);
|
||||
|
||||
UUID characteristicUUID = characteristic.getUuid();
|
||||
if (MiBandService.UUID_CHARACTERISTIC_BATTERY.equals(characteristicUUID)) {
|
||||
if (MiBand2Service.UUID_CHARACTERISTIC_6_BATTERY_INFO.equals(characteristicUUID)) {
|
||||
handleBatteryInfo(characteristic.getValue(), BluetoothGatt.GATT_SUCCESS);
|
||||
return true;
|
||||
} else if (MiBandService.UUID_CHARACTERISTIC_NOTIFICATION.equals(characteristicUUID)) {
|
||||
@ -852,7 +863,7 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||
if (GattCharacteristic.UUID_CHARACTERISTIC_GAP_DEVICE_NAME.equals(characteristicUUID)) {
|
||||
handleDeviceName(characteristic.getValue(), status);
|
||||
return true;
|
||||
} else if (MiBandService.UUID_CHARACTERISTIC_BATTERY.equals(characteristicUUID)) {
|
||||
} else if (MiBand2Service.UUID_CHARACTERISTIC_6_BATTERY_INFO.equals(characteristicUUID)) {
|
||||
handleBatteryInfo(characteristic.getValue(), status);
|
||||
return true;
|
||||
} else if (MiBandService.UUID_CHARACTERISTIC_HEART_RATE_MEASUREMENT.equals(characteristicUUID)) {
|
||||
@ -1268,11 +1279,11 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
|
||||
public void phase2Initialize(TransactionBuilder builder) {
|
||||
LOG.info("phase2Initialize...");
|
||||
enableFurtherNotifications(builder, true);
|
||||
requestBatteryInfo(builder);
|
||||
setDateDisplay(builder);
|
||||
setWearLocation(builder);
|
||||
setFitnessGoal(builder);
|
||||
setActivateDisplayOnLiftWrist(builder);
|
||||
setHeartrateSleepSupport(builder);
|
||||
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceBusyAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.WaitAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.MiBand2Support;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.MiBand2Support;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.AbstractMiBand2Operation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||
|
@ -25,7 +25,7 @@ import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEOperation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.MiBand2Support;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.MiBand2Support;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.GB;
|
||||
|
||||
public class InitOperation extends AbstractBTLEOperation<MiBand2Support> {
|
||||
|
@ -21,7 +21,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceBusyAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetProgressAction;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.MiBand2Support;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.MiBand2Support;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.AbstractMiBand2Operation;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband2.Mi2FirmwareInfo;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband2.MiBand2FWHelper;
|
||||
|
@ -486,10 +486,11 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
if (bytes == null) {
|
||||
return;
|
||||
}
|
||||
// block writes if app installation in in progress
|
||||
if (mIsConnected && (!mIsInstalling || mInstallState == PebbleAppInstallState.WAIT_SLOT)) {
|
||||
write_real(bytes);
|
||||
// on FW < 3.0 block writes if app installation in in progress
|
||||
if (!mIsConnected || (mPebbleProtocol.mFwMajor < 3 && mIsInstalling && mInstallState != PebbleAppInstallState.WAIT_SLOT)) {
|
||||
return;
|
||||
}
|
||||
write_real(bytes);
|
||||
}
|
||||
|
||||
// FIXME: parts are supporsed to be generic code
|
||||
@ -500,7 +501,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
LOG.info("syncing time");
|
||||
write(mPebbleProtocol.encodeSetTime());
|
||||
}
|
||||
write(mPebbleProtocol.encodeEnableAppLogs(prefs.getBoolean("pebble_enable_applogs",false)));
|
||||
write(mPebbleProtocol.encodeEnableAppLogs(prefs.getBoolean("pebble_enable_applogs", false)));
|
||||
write(mPebbleProtocol.encodeReportDataLogSessions());
|
||||
gbDevice.setState(GBDevice.State.INITIALIZED);
|
||||
return false;
|
||||
@ -603,10 +604,6 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
}
|
||||
|
||||
void installApp(Uri uri, int appId) {
|
||||
if (mIsInstalling) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (uri.equals(Uri.parse("fake://health"))) {
|
||||
write(mPebbleProtocol.encodeActivateHealth(true));
|
||||
write(mPebbleProtocol.encodeSetSaneDistanceUnit(true));
|
||||
@ -617,6 +614,10 @@ class PebbleIoThread extends GBDeviceIoThread {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsInstalling) {
|
||||
return;
|
||||
}
|
||||
|
||||
String platformName = PebbleUtils.getPlatformName(gbDevice.getModel());
|
||||
|
||||
try {
|
||||
|
@ -4,23 +4,17 @@ import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import nodomain.freeyourgadget.gadgetbridge.Logging;
|
||||
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBandDateConverter;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.btle.BLETypeConversions;
|
||||
import nodomain.freeyourgadget.gadgetbridge.service.devices.miband.MiBand2Support;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.CheckSums;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.DateTimeUtils;
|
||||
import nodomain.freeyourgadget.gadgetbridge.util.FileUtils;
|
||||
|
||||
/**
|
||||
* A simple class for trying out things, not actually testing something.
|
||||
*/
|
||||
public class Tryout extends TestBase {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MiBand2Support.class);
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Tryout.class);
|
||||
|
||||
@Test
|
||||
public void blah() {
|
||||
|
Loading…
Reference in New Issue
Block a user