1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-25 11:26:47 +01:00

Amazfit Bip: get and display gps version

Currenty this is displayed as HR (heart rate firmware)
This commit is contained in:
Andreas Shimokawa 2017-08-29 22:16:59 +02:00
parent f855dc5d45
commit 23fa37d99d
3 changed files with 49 additions and 2 deletions

View File

@ -21,4 +21,7 @@ import java.util.UUID;
public class AmazfitBipService { public class AmazfitBipService {
public static final UUID UUID_CHARACTERISTIC_WEATHER = UUID.fromString("0000000e-0000-3512-2118-0009af100700"); public static final UUID UUID_CHARACTERISTIC_WEATHER = UUID.fromString("0000000e-0000-3512-2118-0009af100700");
// goes to UUID_CHARACTERISTIC_3_CONFIGURATION, TODO: validate this for Mi Band 2, it maybe triggers more than only GPS version...
public static final byte[] COMMAND_REQUEST_GPS_VERSION = new byte[]{0x0e};
} }

View File

@ -50,7 +50,7 @@ public class AmazfitBipFirmwareInfo extends Mi2FirmwareInfo {
crcToVersion.put(12586, "RES 0.0.8.74"); crcToVersion.put(12586, "RES 0.0.8.74");
// gps // gps
crcToVersion.put(61520, "GPS 0.0.8.xx"); crcToVersion.put(61520, "GPS 9367,8f79a91,0,0,");
} }
public AmazfitBipFirmwareInfo(byte[] bytes) { public AmazfitBipFirmwareInfo(byte[] bytes) {

View File

@ -16,6 +16,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.amazfitbip; package nodomain.freeyourgadget.gadgetbridge.service.devices.amazfitbip;
import android.bluetooth.BluetoothGatt;
import android.bluetooth.BluetoothGattCharacteristic;
import android.net.Uri; import android.net.Uri;
import android.widget.Toast; import android.widget.Toast;
@ -26,11 +28,13 @@ import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.util.SimpleTimeZone; import java.util.SimpleTimeZone;
import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl; import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventCallControl;
import nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.AmazfitBipIcon; import nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.AmazfitBipIcon;
import nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.AmazfitBipService; import nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.AmazfitBipService;
import nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.AmazfitBipWeatherConditions; import nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.AmazfitBipWeatherConditions;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.MiBand2Service;
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec; import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec; import nodomain.freeyourgadget.gadgetbridge.model.NotificationSpec;
import nodomain.freeyourgadget.gadgetbridge.model.NotificationType; import nodomain.freeyourgadget.gadgetbridge.model.NotificationType;
@ -181,4 +185,44 @@ public class AmazfitBipSupport extends MiBand2Support {
} catch (IOException ignore) { } catch (IOException ignore) {
} }
} }
@Override
public boolean onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic) {
boolean handled = super.onCharacteristicChanged(gatt, characteristic);
if (!handled) {
UUID characteristicUUID = characteristic.getUuid();
if (MiBand2Service.UUID_CHARACTERISTIC_3_CONFIGURATION.equals(characteristicUUID)) {
return handleConfigurationInfo(characteristic.getValue());
}
}
return false;
}
private boolean handleConfigurationInfo(byte[] value) {
if (value == null || value.length < 4) {
return false;
}
if (value[0] == 0x10 && value[1] == 0x0e && value[2] == 0x01) {
String gpsVersion = new String(value, 3, value.length - 3);
LOG.info("got gps version = " + gpsVersion);
gbDevice.setFirmwareVersion2(gpsVersion);
return true;
}
return false;
}
// this probably does more than only getting the GPS version...
private AmazfitBipSupport requestGPSVersion(TransactionBuilder builder) {
LOG.info("Requesting GPS version");
builder.write(getCharacteristic(MiBand2Service.UUID_CHARACTERISTIC_3_CONFIGURATION), AmazfitBipService.COMMAND_REQUEST_GPS_VERSION);
return this;
}
@Override
public void phase2Initialize(TransactionBuilder builder) {
super.phase2Initialize(builder);
LOG.info("phase2Initialize...");
requestGPSVersion(builder);
}
} }