Fix firmware2 not being set

This commit is contained in:
cpfeiffer 2016-09-11 21:15:36 +02:00
parent 40e079ad5d
commit e555066ffc
3 changed files with 10 additions and 7 deletions

View File

@ -43,6 +43,7 @@ public class GBDevice implements Parcelable {
public static final String EXTRA_DEVICE = "device"; public static final String EXTRA_DEVICE = "device";
private static final String DEVINFO_HW_VER = "HW: "; private static final String DEVINFO_HW_VER = "HW: ";
private static final String DEVINFO_FW_VER = "FW: "; private static final String DEVINFO_FW_VER = "FW: ";
private static final String DEVINFO_HR_VER = "HR: ";
private static final String DEVINFO_ADDR = "ADDR: "; private static final String DEVINFO_ADDR = "ADDR: ";
private String mName; private String mName;
private final String mAddress; private final String mAddress;
@ -133,6 +134,10 @@ public class GBDevice implements Parcelable {
mFirmwareVersion = firmwareVersion; mFirmwareVersion = firmwareVersion;
} }
/**
* Sets the second firmware version, typically the heart rate firmware version
* @param firmwareVersion2
*/
public void setFirmwareVersion2(String firmwareVersion2) { public void setFirmwareVersion2(String firmwareVersion2) {
mFirmwareVersion2 = firmwareVersion2; mFirmwareVersion2 = firmwareVersion2;
} }
@ -405,6 +410,9 @@ public class GBDevice implements Parcelable {
if (mFirmwareVersion != null) { if (mFirmwareVersion != null) {
result.add(new GenericItem(DEVINFO_FW_VER, mFirmwareVersion)); result.add(new GenericItem(DEVINFO_FW_VER, mFirmwareVersion));
} }
if (mFirmwareVersion2 != null) {
result.add(new GenericItem(DEVINFO_HR_VER, mFirmwareVersion2));
}
if (mAddress != null) { if (mAddress != null) {
result.add(new GenericItem(DEVINFO_ADDR, mAddress)); result.add(new GenericItem(DEVINFO_ADDR, mAddress));
} }

View File

@ -41,7 +41,6 @@ import nodomain.freeyourgadget.gadgetbridge.model.CalendarEvents;
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec; import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec; import nodomain.freeyourgadget.gadgetbridge.model.CannedMessagesSpec;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceService; import nodomain.freeyourgadget.gadgetbridge.model.DeviceService;
import nodomain.freeyourgadget.gadgetbridge.model.GenericItem;
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec; import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec; import nodomain.freeyourgadget.gadgetbridge.model.MusicStateSpec;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec; import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
@ -1062,9 +1061,7 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport {
if (status == BluetoothGatt.GATT_SUCCESS) { if (status == BluetoothGatt.GATT_SUCCESS) {
mDeviceInfo = new DeviceInfo(value); mDeviceInfo = new DeviceInfo(value);
if (getDeviceInfo().supportsHeartrate()) { if (getDeviceInfo().supportsHeartrate()) {
getDevice().addDeviceInfo(new GenericItem( getDevice().setFirmwareVersion2(MiBandFWHelper.formatFirmwareVersion(mDeviceInfo.getHeartrateFirmwareVersion()));
getContext().getString(R.string.DEVINFO_HR_VER),
MiBandFWHelper.formatFirmwareVersion(mDeviceInfo.getHeartrateFirmwareVersion())));
} }
LOG.warn("Device info: " + mDeviceInfo); LOG.warn("Device info: " + mDeviceInfo);
versionCmd.hwVersion = mDeviceInfo.getHwVersion(); versionCmd.hwVersion = mDeviceInfo.getHwVersion();

View File

@ -981,9 +981,7 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
mDeviceInfo = new DeviceInfo(value); mDeviceInfo = new DeviceInfo(value);
mDeviceInfo.setTest1AHRMode(MI_1A_HR_FW_UPDATE_TEST_MODE_ENABLED); mDeviceInfo.setTest1AHRMode(MI_1A_HR_FW_UPDATE_TEST_MODE_ENABLED);
if (getDeviceInfo().supportsHeartrate()) { if (getDeviceInfo().supportsHeartrate()) {
getDevice().addDeviceInfo(new GenericItem( getDevice().setFirmwareVersion2(MiBandFWHelper.formatFirmwareVersion(mDeviceInfo.getHeartrateFirmwareVersion()));
getContext().getString(R.string.DEVINFO_HR_VER),
MiBandFWHelper.formatFirmwareVersion(mDeviceInfo.getHeartrateFirmwareVersion())));
} }
LOG.warn("Device info: " + mDeviceInfo); LOG.warn("Device info: " + mDeviceInfo);
versionCmd.hwVersion = mDeviceInfo.getHwVersion(); versionCmd.hwVersion = mDeviceInfo.getHwVersion();