mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-06-09 22:57:54 +02:00
3a58314db6
- 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.
39 lines
1.6 KiB
Java
39 lines
1.6 KiB
Java
package nodomain.freeyourgadget.gadgetbridge.service.devices.vivomovehr.downloads;
|
|
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.vivomovehr.GarminTimeUtils;
|
|
import nodomain.freeyourgadget.gadgetbridge.service.devices.vivomovehr.messages.MessageReader;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
public class DirectoryData {
|
|
public final List<DirectoryEntry> entries;
|
|
|
|
public DirectoryData(List<DirectoryEntry> entries) {
|
|
this.entries = entries;
|
|
}
|
|
|
|
public static DirectoryData parse(byte[] bytes) {
|
|
int size = bytes.length;
|
|
if ((size % 16) != 0) throw new IllegalArgumentException("Invalid directory data length");
|
|
int count = (size - 16) / 16;
|
|
final MessageReader reader = new MessageReader(bytes, 16);
|
|
final List<DirectoryEntry> entries = new ArrayList<>(count);
|
|
for (int i = 0; i < count; ++i) {
|
|
final int fileIndex = reader.readShort();
|
|
final int fileDataType = reader.readByte();
|
|
final int fileSubType = reader.readByte();
|
|
final int fileNumber = reader.readShort();
|
|
final int specificFlags = reader.readByte();
|
|
final int fileFlags = reader.readByte();
|
|
final int fileSize = reader.readInt();
|
|
final Date fileDate = new Date(GarminTimeUtils.garminTimestampToJavaMillis(reader.readInt()));
|
|
|
|
entries.add(new DirectoryEntry(fileIndex, fileDataType, fileSubType, fileNumber, specificFlags, fileFlags, fileSize, fileDate));
|
|
}
|
|
|
|
return new DirectoryData(entries);
|
|
}
|
|
}
|