1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-10 07:07:57 +02:00
Gadgetbridge/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/vivomovehr/messages/DeviceInformationMessage.java
Mormegil 3a58314db6 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-07-20 20:30:14 +00:00

47 lines
2.1 KiB
Java

package nodomain.freeyourgadget.gadgetbridge.service.devices.vivomovehr.messages;
import java.util.Locale;
public class DeviceInformationMessage {
public final int protocolVersion;
public final int productNumber;
public final String unitNumber;
public final int softwareVersion;
public final int maxPacketSize;
public final String bluetoothFriendlyName;
public final String deviceName;
public final String deviceModel;
// dual-pairing flags & MAC addresses...
public DeviceInformationMessage(int protocolVersion, int productNumber, String unitNumber, int softwareVersion, int maxPacketSize, String bluetoothFriendlyName, String deviceName, String deviceModel) {
this.protocolVersion = protocolVersion;
this.productNumber = productNumber;
this.unitNumber = unitNumber;
this.softwareVersion = softwareVersion;
this.maxPacketSize = maxPacketSize;
this.bluetoothFriendlyName = bluetoothFriendlyName;
this.deviceName = deviceName;
this.deviceModel = deviceModel;
}
public static DeviceInformationMessage parsePacket(byte[] packet) {
final MessageReader reader = new MessageReader(packet, 4);
final int protocolVersion = reader.readShort();
final int productNumber = reader.readShort();
final String unitNumber = Long.toString(reader.readInt() & 0xFFFFFFFFL);
final int softwareVersion = reader.readShort();
final int maxPacketSize = reader.readShort();
final String bluetoothFriendlyName = reader.readString();
final String deviceName = reader.readString();
final String deviceModel = reader.readString();
return new DeviceInformationMessage(protocolVersion, productNumber, unitNumber, softwareVersion, maxPacketSize, bluetoothFriendlyName, deviceName, deviceModel);
}
public String getSoftwareVersionStr() {
int softwareVersionMajor = softwareVersion / 100;
int softwareVersionMinor = softwareVersion % 100;
return String.format(Locale.ROOT, "%d.%02d", softwareVersionMajor, softwareVersionMinor);
}
}