2023-07-13 15:00:12 +02:00
|
|
|
/* Copyright (C) 2020-2023 Petr Kadlec
|
|
|
|
|
|
|
|
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/>. */
|
2023-06-15 15:38:25 +02:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.devices.vivomovehr;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
2023-06-18 16:40:34 +02:00
|
|
|
import android.bluetooth.le.ScanFilter;
|
2023-06-15 15:38:25 +02:00
|
|
|
import android.content.Context;
|
|
|
|
import android.net.Uri;
|
2023-06-18 16:40:34 +02:00
|
|
|
import android.os.ParcelUuid;
|
2023-06-15 15:38:25 +02:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.GBException;
|
2023-06-18 16:40:34 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.devices.AbstractBLEDeviceCoordinator;
|
2023-06-15 15:38:25 +02:00
|
|
|
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;
|
2023-08-20 04:14:06 +02:00
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.DeviceSupport;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.vivomovehr.VivomoveHrSupport;
|
2023-06-15 15:38:25 +02:00
|
|
|
|
2023-06-18 16:40:34 +02:00
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collections;
|
|
|
|
|
|
|
|
public class VivomoveHrCoordinator extends AbstractBLEDeviceCoordinator {
|
2023-06-15 15:38:25 +02:00
|
|
|
@NonNull
|
|
|
|
@Override
|
|
|
|
public DeviceType getSupportedType(GBDeviceCandidate candidate) {
|
|
|
|
if ("vÃvomove HR".equals(candidate.getName())) return DeviceType.VIVOMOVE_HR;
|
|
|
|
|
|
|
|
final boolean hasServiceUuids = candidate.getServiceUuids().length > 0;
|
2023-06-18 16:40:34 +02:00
|
|
|
return hasServiceUuids && candidate.supportsService(VivomoveConstants.UUID_SERVICE_GARMIN_GFDI) ? DeviceType.VIVOMOVE_HR : DeviceType.UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
@NonNull
|
|
|
|
@Override
|
|
|
|
public Collection<? extends ScanFilter> createBLEScanFilters() {
|
|
|
|
final ParcelUuid garminService = new ParcelUuid(VivomoveConstants.UUID_SERVICE_GARMIN_GFDI);
|
|
|
|
final ScanFilter filter = new ScanFilter.Builder().setServiceUuid(garminService).build();
|
|
|
|
return Collections.singletonList(filter);
|
2023-06-15 15:38:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public DeviceType getDeviceType() {
|
|
|
|
return DeviceType.VIVOMOVE_HR;
|
|
|
|
}
|
|
|
|
|
|
|
|
@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 VivomoveHrSampleProvider(device, session);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public InstallHandler findInstallHandler(Uri uri, Context context) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean supportsScreenshots() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
Garmin Vivomove HR support
- communication protocols
- device support implementation
- download FIT file storage
Features:
- basic connectivity: time sync, battery status, HW/FW version info
- real-time activity tracking
- fitness data sync
- find the device, find the phone
- factory reset
Features implemented but not working:
- notifications: fully implemented, seem to communicate correctly, but not shown on watch
Features implemented partially (not expected to work now):
- weather information (and in future possibly weather alerts)
- music info
- firmware update: only the initial file upload implemented, not used
Things to improve/change:
- Device name hardcoded in `VivomoveHrCoordinator.getSupportedType`, service UUIDs not available
- Download FIT file storage: Should be store (and offer the user to export?) the FIT data forever?
- Obviously, various code improvements, cleanup, etc.
2023-06-15 17:47:42 +02:00
|
|
|
public int getAlarmSlotCount(GBDevice device) {
|
2023-06-15 15:38:25 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean supportsSmartWakeup(GBDevice device) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean supportsHeartRateMeasurement(GBDevice device) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getManufacturer() {
|
|
|
|
return "Garmin";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean supportsAppsManagement(GBDevice device) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Class<? extends Activity> getAppsManagementActivity() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean supportsCalendarEvents() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean supportsRealtimeData() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean supportsWeather() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2023-06-17 15:08:11 +02:00
|
|
|
@Override
|
|
|
|
public int[] getSupportedDeviceSpecificSettings(GBDevice device) {
|
|
|
|
// no device-specific settings yet
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2023-08-20 04:14:06 +02:00
|
|
|
@NonNull
|
|
|
|
@Override
|
|
|
|
public Class<? extends DeviceSupport> getDeviceSupportClass() {
|
|
|
|
return VivomoveHrSupport.class;
|
|
|
|
}
|
|
|
|
|
2023-06-15 15:38:25 +02:00
|
|
|
@Override
|
|
|
|
public boolean supportsFindDevice() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void deleteDevice(@NonNull GBDevice gbDevice, @NonNull Device device, @NonNull DaoSession session) throws GBException {
|
|
|
|
// nothing to delete, yet
|
|
|
|
}
|
|
|
|
}
|