1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-24 02:46:50 +01:00

Amazfit Bip 3 Pro: Initial support

This commit is contained in:
José Rebelo 2023-08-16 12:27:00 +01:00
parent 515b9efce8
commit b297e767ad
11 changed files with 440 additions and 0 deletions

View File

@ -38,6 +38,7 @@ vendor's servers.
- [Band 5](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Band-5), [Band 7](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Band-7) [**\[!\]**](#special-pairing-procedures)
- [Bip](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip)
- [Bip Lite](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip-Lite), [Bip S](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip-S), [Bip U](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip-U) [**\[!\]**](#special-pairing-procedures)
- [Bip 3 Pro](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Bip-3-Pro) [**\[!\]**](#special-pairing-procedures)
- [Cor](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Cor), [Cor 2](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-Cor-2)
- [GTR](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR), [GTR 2/2e](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR), [GTR 3](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR-3), [GTR 3 Pro](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR-3-Pro), [GTR 4](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTR-4) [**\[!\]**](#special-pairing-procedures)
- [GTS](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS), [GTS 2/2e](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS), [GTS 3](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS-3), [GTS 4](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS-4), [GTS 4 Mini](https://codeberg.org/Freeyourgadget/Gadgetbridge/wiki/Amazfit-GTS-4-Mini) [**\[!\]**](#special-pairing-procedures)

View File

@ -0,0 +1,169 @@
/* Copyright (C) 2023 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip3pro;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.InstallHandler;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiCoordinator;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDeviceCandidate;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
public class AmazfitBip3ProCoordinator extends HuamiCoordinator {
private static final Logger LOG = LoggerFactory.getLogger(AmazfitBip3ProCoordinator.class);
@Override
public DeviceType getDeviceType() {
return DeviceType.AMAZFITBIP3PRO;
}
@NonNull
@Override
public DeviceType getSupportedType(final GBDeviceCandidate candidate) {
try {
final BluetoothDevice device = candidate.getDevice();
final String name = device.getName();
if (name != null && name.equalsIgnoreCase("Amazfit Bip 3 Pro")) {
return DeviceType.AMAZFITBIP3PRO;
}
} catch (final Exception ex) {
LOG.error("unable to check device support", ex);
}
return DeviceType.UNKNOWN;
}
@Override
public InstallHandler findInstallHandler(final Uri uri, final Context context) {
final AmazfitBip3ProFWInstallHandler handler = new AmazfitBip3ProFWInstallHandler(uri, context);
return handler.isValid() ? handler : null;
}
@Override
public int getBondingStyle() {
return BONDING_STYLE_REQUIRE_KEY;
}
@Override
public boolean supportsHeartRateMeasurement(final GBDevice device) {
return true;
}
@Override
public boolean supportsActivityTracks() {
return true;
}
@Override
public boolean supportsWeather() {
return true;
}
@Override
public boolean supportsMusicInfo() {
return true;
}
@Override
public int getWorldClocksSlotCount() {
return 20; // as enforced by Zepp
}
@Override
public int getWorldClocksLabelLength() {
return 30; // at least
}
@Override
public boolean supportsUnicodeEmojis() {
return true;
}
@Override
public boolean supportsStressMeasurement() {
return true;
}
@Override
public boolean supportsSpo2() {
return true;
}
@Override
public boolean supportsPai() {
return true;
}
public int[] getSupportedDeviceSpecificSettings(final GBDevice device) {
return new int[]{
R.xml.devicesettings_amazfitbip3pro,
R.xml.devicesettings_vibrationpatterns,
R.xml.devicesettings_wearlocation,
R.xml.devicesettings_heartrate_sleep_alert_activity_stress,
R.xml.devicesettings_goal_notification,
R.xml.devicesettings_timeformat,
R.xml.devicesettings_dateformat,
R.xml.devicesettings_world_clocks,
R.xml.devicesettings_liftwrist_display_sensitivity,
R.xml.devicesettings_inactivity_dnd,
R.xml.devicesettings_sync_calendar,
R.xml.devicesettings_reserve_reminders_calendar,
R.xml.devicesettings_expose_hr_thirdparty,
R.xml.devicesettings_bt_connected_advertisement,
R.xml.devicesettings_device_actions,
R.xml.devicesettings_high_mtu,
R.xml.devicesettings_overwrite_settings_on_connection,
R.xml.devicesettings_huami2021_fetch_operation_time_unit,
R.xml.devicesettings_transliteration
};
}
@Override
public String[] getSupportedLanguageSettings(GBDevice device) {
return new String[]{
"auto",
"cs_CZ",
"de_DE",
"el_GR",
"en_US",
"es_ES",
"fr_FR",
"id_ID",
"it_IT",
"ja_JP",
"ko_KO",
"nl_NL",
"pl_PL",
"pt_BR",
"ru_RU",
"th_TH",
"tr_TR",
"uk_UA",
"vi_VN",
"zh_CH",
"zh_TW",
};
}
}

View File

@ -0,0 +1,39 @@
/* Copyright (C) 2023 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip3pro;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip3pro.AmazfitBip3ProFirmwareInfo;
public class AmazfitBip3ProFWHelper extends HuamiFWHelper {
public AmazfitBip3ProFWHelper(final Uri uri, final Context context) throws IOException {
super(uri, context);
}
@Override
protected void determineFirmwareInfo(final byte[] wholeFirmwareBytes) {
firmwareInfo = new AmazfitBip3ProFirmwareInfo(wholeFirmwareBytes);
if (!firmwareInfo.isHeaderValid()) {
throw new IllegalArgumentException("Not an Amazfit Bip 3 Pro firmware");
}
}
}

View File

@ -0,0 +1,49 @@
/* Copyright (C) 2023 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip3pro;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.miband.AbstractMiBandFWInstallHandler;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
class AmazfitBip3ProFWInstallHandler extends AbstractMiBandFWInstallHandler {
AmazfitBip3ProFWInstallHandler(final Uri uri, final Context context) {
super(uri, context);
}
@Override
protected String getFwUpgradeNotice() {
return mContext.getString(R.string.fw_upgrade_notice_amazfitbip3pro, helper.getHumanFirmwareVersion());
}
@Override
protected AbstractMiBandFWHelper createHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitBip3ProFWHelper(uri, context);
}
@Override
protected boolean isSupportedDeviceType(final GBDevice device) {
return device.getType() == DeviceType.AMAZFITBIP3PRO;
}
}

View File

@ -75,6 +75,7 @@ public enum DeviceType {
AMAZFITGTS4MINI(10047, R.drawable.ic_device_amazfit_bip, R.drawable.ic_device_amazfit_bip_disabled, R.string.devicetype_amazfit_gts4_mini),
AMAZFITTREX2(10048, R.drawable.ic_device_zetime, R.drawable.ic_device_zetime_disabled, R.string.devicetype_amazfit_trex_2),
AMAZFITGTR3PRO(10049, R.drawable.ic_device_zetime, R.drawable.ic_device_zetime_disabled, R.string.devicetype_amazfit_gtr3_pro),
AMAZFITBIP3PRO(10051, R.drawable.ic_device_zetime, R.drawable.ic_device_zetime_disabled, R.string.devicetype_amazfit_bip3_pro),
HPLUS(40, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_hplus),
MAKIBESF68(41, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_makibes_f68),
EXRIZUK8(42, R.drawable.ic_device_hplus, R.drawable.ic_device_hplus_disabled, R.string.devicetype_exrizu_k8),

View File

@ -44,6 +44,7 @@ import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband5.A
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitband7.AmazfitBand7Support;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.AmazfitBipLiteSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.AmazfitBipSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip3pro.AmazfitBip3ProSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.AmazfitBipSLiteSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbips.AmazfitBipSSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbipu.AmazfitBipUSupport;
@ -222,6 +223,8 @@ public class DeviceSupportFactory {
return new ServiceDeviceSupport(new AmazfitBipUSupport());
case AMAZFITBIPUPRO:
return new ServiceDeviceSupport(new AmazfitBipUProSupport());
case AMAZFITBIP3PRO:
return new ServiceDeviceSupport(new AmazfitBip3ProSupport());
case AMAZFITPOP:
return new ServiceDeviceSupport(new AmazfitPopSupport());
case AMAZFITPOPPRO:

View File

@ -0,0 +1,82 @@
/* Copyright (C) 2023 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip3pro;
import java.util.HashMap;
import java.util.Map;
import nodomain.freeyourgadget.gadgetbridge.impl.GBDevice;
import nodomain.freeyourgadget.gadgetbridge.model.DeviceType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareInfo;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiFirmwareType;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.miband4.MiBand4FirmwareInfo;
import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils;
public class AmazfitBip3ProFirmwareInfo extends HuamiFirmwareInfo {
private static final Map<Integer, String> crcToVersion = new HashMap<>();
static {
// firmware
// resources
// gps
}
public AmazfitBip3ProFirmwareInfo(final byte[] bytes) {
super(bytes);
}
@Override
protected HuamiFirmwareType determineFirmwareType(final byte[] bytes) {
if (ArrayUtils.equals(bytes, MiBand4FirmwareInfo.FW_HEADER, MiBand4FirmwareInfo.FW_HEADER_OFFSET)) {
if (searchString32BitAligned(bytes, "\0\0Amazfit Bip 3 Pro")) {
return HuamiFirmwareType.FIRMWARE;
}
return HuamiFirmwareType.INVALID;
}
if (ArrayUtils.startsWith(bytes, NEWRES_HEADER)) {
return HuamiFirmwareType.RES;
}
if (ArrayUtils.startsWith(bytes, UIHH_HEADER) && (bytes[4] == 1 || bytes[4] == 2)) {
return HuamiFirmwareType.WATCHFACE;
}
if (ArrayUtils.startsWith(bytes, AGPS_UIHH_HEADER)) {
return HuamiFirmwareType.AGPS_UIHH;
}
for (byte[] gpsHeader : GPS_HEADERS) {
if (ArrayUtils.startsWith(bytes, gpsHeader)) {
return HuamiFirmwareType.GPS;
}
}
return HuamiFirmwareType.INVALID;
}
@Override
public boolean isGenerallyCompatibleWith(final GBDevice device) {
return isHeaderValid() && device.getType() == DeviceType.AMAZFITBIP3PRO;
}
@Override
protected Map<Integer, String> getCrcMap() {
return crcToVersion;
}
}

View File

@ -0,0 +1,79 @@
/* Copyright (C) 2023 José Rebelo
This file is part of Gadgetbridge.
Gadgetbridge is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Gadgetbridge is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip3pro;
import android.content.Context;
import android.net.Uri;
import java.io.IOException;
import nodomain.freeyourgadget.gadgetbridge.R;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.HuamiFWHelper;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip3pro.AmazfitBip3ProFWHelper;
import nodomain.freeyourgadget.gadgetbridge.model.CallSpec;
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.amazfitbip.AmazfitBipSupport;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation;
import nodomain.freeyourgadget.gadgetbridge.service.devices.huami.operations.UpdateFirmwareOperation2020;
public class AmazfitBip3ProSupport extends AmazfitBipSupport {
@Override
public byte getCryptFlags() {
return (byte) 0x80;
}
@Override
protected byte getAuthFlags() {
return 0x00;
}
@Override
protected boolean notificationHasExtraHeader() {
return true;
}
@Override
public boolean supportsSunriseSunsetWindHumidity() {
return true;
}
@Override
public HuamiFWHelper createFWHelper(final Uri uri, final Context context) throws IOException {
return new AmazfitBip3ProFWHelper(uri, context);
}
@Override
public UpdateFirmwareOperation createUpdateFirmwareOperation(final Uri uri) {
return new UpdateFirmwareOperation2020(uri, this);
}
@Override
public void onSetCallState(final CallSpec callSpec) {
onSetCallStateNew(callSpec);
}
@Override
public int getActivitySampleSize() {
return 8;
}
@Override
protected AmazfitBip3ProSupport setDisplayItems(final TransactionBuilder builder) {
setDisplayItemsNew(builder, false, false, R.array.pref_gtsgtr2_display_items_default);
return this;
}
}

View File

@ -81,6 +81,7 @@ import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitgts2.AmazfitGTS
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitneo.AmazfitNeoCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip.AmazfitBipLiteCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbip3pro.AmazfitBip3ProCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbips.AmazfitBipSCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbipu.AmazfitBipUCoordinator;
import nodomain.freeyourgadget.gadgetbridge.devices.huami.amazfitbipupro.AmazfitBipUProCoordinator;
@ -299,6 +300,7 @@ public class DeviceHelper {
result.add(new AmazfitBipSLiteCoordinator());
result.add(new AmazfitBipUCoordinator());
result.add(new AmazfitBipUProCoordinator());
result.add(new AmazfitBip3ProCoordinator());
result.add(new AmazfitPopCoordinator());
result.add(new AmazfitPopProCoordinator());
result.add(new AmazfitBand5Coordinator());

View File

@ -137,6 +137,7 @@
<string name="fw_upgrade_notice">You are about to install the %s.</string>
<string name="fw_upgrade_notice_amazfitbip">You are about to install the %s firmware on your Amazfit Bip.\n\nPlease make sure to install the .fw file, then the .res file, and finally the .gps file. Your watch will reboot after installing the .fw file.\n\nNote: You do not have to install .res and .gps if these files are exactly the same as the ones previously installed.\n\nPROCEED AT YOUR OWN RISK!</string>
<string name="fw_upgrade_notice_amazfitbip_lite">You are about to install the %s firmware on your Amazfit Bip Lite.\n\nPlease make sure to install the .fw file, and after that the .res file. Your watch will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nPROCEED AT YOUR OWN RISK!</string>
<string name="fw_upgrade_notice_amazfitbip3pro">You are about to install the %s firmware on your Amazfit Bip 3 Pro.\n\nPlease make sure to install the .fw file, and after that the .res file. Your watch will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nPROCEED AT YOUR OWN RISK!</string>
<string name="fw_upgrade_notice_amazfitcor">You are about to install the %s firmware on your Amazfit Cor.\n\nPlease make sure to install the .fw file, and after that the .res file. Your band will reboot after installing the .fw file.\n\nNote: You do not have to install .res if it is exactly the same as the one previously installed.\n\nPROCEED AT YOUR OWN RISK!</string>
<string name="fw_upgrade_notice_amazfitcor2">You are about to install the %s firmware on your Amazfit Cor 2.
\n
@ -1275,6 +1276,7 @@
<string name="devicetype_amazfit_gts4_mini">Amazfit GTS 4 Mini</string>
<string name="devicetype_amazfit_gtr3">Amazfit GTR 3</string>
<string name="devicetype_amazfit_gtr3_pro">Amazfit GTR 3 Pro</string>
<string name="devicetype_amazfit_bip3_pro">Amazfit Bip 3 Pro</string>
<string name="devicetype_amazfit_gtr4">Amazfit GTR 4</string>
<string name="devicetype_amazfit_trex_2">Amazfit T-Rex 2</string>
<string name="devicetype_amazfit_band5">Amazfit Band 5</string>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.preference.PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<com.mobeta.android.dslv.DragSortListPreference
android:icon="@drawable/ic_widgets"
android:defaultValue="@array/pref_gtsgtr2_display_items_default"
android:dialogTitle="@string/mi2_prefs_display_items"
android:entries="@array/pref_gtsgtr2_display_items"
android:entryValues="@array/pref_gtsgtr2_display_items_values"
android:key="display_items_sortable"
android:persistent="true"
android:summary="@string/mi2_prefs_display_items_summary"
android:title="@string/mi2_prefs_display_items" />
</androidx.preference.PreferenceScreen>