1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-09 22:57:54 +02:00
Gadgetbridge/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/vivomovehr/BinaryUtils.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

51 lines
2.0 KiB
Java

package nodomain.freeyourgadget.gadgetbridge.service.devices.vivomovehr;
public final class BinaryUtils {
private BinaryUtils() {
}
public static int readByte(byte[] array, int offset) {
return array[offset] & 0xFF;
}
public static int readShort(byte[] array, int offset) {
return (array[offset] & 0xFF) | ((array[offset + 1] & 0xFF) << 8);
}
public static int readInt(byte[] array, int offset) {
return (array[offset] & 0xFF) | ((array[offset + 1] & 0xFF) << 8) | ((array[offset + 2] & 0xFF) << 16) | ((array[offset + 3] & 0xFF) << 24);
}
public static long readLong(byte[] array, int offset) {
return (array[offset] & 0xFFL) | ((array[offset + 1] & 0xFFL) << 8) | ((array[offset + 2] & 0xFFL) << 16) | ((array[offset + 3] & 0xFFL) << 24) |
((array[offset + 4] & 0xFFL) << 32) | ((array[offset + 5] & 0xFFL) << 40) | ((array[offset + 6] & 0xFFL) << 48) | ((array[offset + 7] & 0xFFL) << 56);
}
public static void writeByte(byte[] array, int offset, int value) {
array[offset] = (byte) value;
}
public static void writeShort(byte[] array, int offset, int value) {
array[offset] = (byte) value;
array[offset + 1] = (byte) (value >> 8);
}
public static void writeInt(byte[] array, int offset, int value) {
array[offset] = (byte) value;
array[offset + 1] = (byte) (value >> 8);
array[offset + 2] = (byte) (value >> 16);
array[offset + 3] = (byte) (value >> 24);
}
public static void writeLong(byte[] array, int offset, long value) {
array[offset] = (byte) value;
array[offset + 1] = (byte) (value >> 8);
array[offset + 2] = (byte) (value >> 16);
array[offset + 3] = (byte) (value >> 24);
array[offset + 4] = (byte) (value >> 32);
array[offset + 5] = (byte) (value >> 40);
array[offset + 6] = (byte) (value >> 48);
array[offset + 7] = (byte) (value >> 56);
}
}