Search in sources :

Example 1 with BipActivitySummary

use of nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.BipActivitySummary in project Gadgetbridge by Freeyourgadget.

the class HuamiActivityDetailsParserTest method testGPXExport.

@Test
public void testGPXExport() throws Exception {
    BipActivitySummary summary = createSummary();
    int baseLongi = BLETypeConversions.toUint32((byte) 0xd6, (byte) 0xc4, (byte) 0x62, (byte) 0x02);
    int baseLati = BLETypeConversions.toUint32((byte) 0xff, (byte) 0xa9, (byte) 0x61, (byte) 0x9);
    int baseAlti = BLETypeConversions.toUint32((byte) 0x30, (byte) 0x0, (byte) 0x0, (byte) 0x0);
    summary.setBaseLongitude(baseLongi);
    summary.setBaseLatitude(baseLati);
    summary.setBaseAltitude(baseAlti);
    HuamiActivityDetailsParser parser = new HuamiActivityDetailsParser(summary);
    parser.setSkipCounterByte(true);
    try (InputStream in = getContents(DETAILS_1)) {
        ActivityTrack track = parser.parse(FileUtils.readAll(in, MAX_DETAILS));
        List<ActivityPoint> trackPoints = track.getTrackPoints();
        assertEquals(972, trackPoints.size());
        GPXExporter exporter = new GPXExporter();
        exporter.setIncludeHeartRate(false);
        exporter.setCreator(getClass().getName());
        File targetFile = File.createTempFile("gadgetbridge-track", ".gpx");
        System.out.println("Writing GPX file: " + targetFile);
        exporter.performExport(track, targetFile);
        assertTrue(targetFile.length() > 1024);
    }
}
Also used : GPXExporter(nodomain.freeyourgadget.gadgetbridge.export.GPXExporter) InputStream(java.io.InputStream) ActivityPoint(nodomain.freeyourgadget.gadgetbridge.model.ActivityPoint) BipActivitySummary(nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.BipActivitySummary) HuamiActivityDetailsParser(nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiActivityDetailsParser) ActivityTrack(nodomain.freeyourgadget.gadgetbridge.model.ActivityTrack) File(java.io.File) ActivityPoint(nodomain.freeyourgadget.gadgetbridge.model.ActivityPoint) Test(org.junit.Test)

Example 2 with BipActivitySummary

use of nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.BipActivitySummary in project Gadgetbridge by Freeyourgadget.

the class HuamiActivityDetailsParserTest method testActivityDetails.

@Test
public void testActivityDetails() throws Exception {
    BipActivitySummary summary = createSummary();
    HuamiActivityDetailsParser parser = new HuamiActivityDetailsParser(summary);
    parser.setSkipCounterByte(true);
    try (InputStream in = getContents(DETAILS_1)) {
        ActivityTrack track = parser.parse(FileUtils.readAll(in, MAX_DETAILS));
        assertEquals("SuperBand 2000", track.getDevice().getName());
        assertEquals("Elvis", track.getUser().getName());
        List<ActivityPoint> trackPoints = track.getTrackPoints();
        assertEquals(972, trackPoints.size());
    }
}
Also used : InputStream(java.io.InputStream) ActivityPoint(nodomain.freeyourgadget.gadgetbridge.model.ActivityPoint) BipActivitySummary(nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.BipActivitySummary) HuamiActivityDetailsParser(nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiActivityDetailsParser) ActivityTrack(nodomain.freeyourgadget.gadgetbridge.model.ActivityTrack) Test(org.junit.Test)

Example 3 with BipActivitySummary

use of nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.BipActivitySummary in project Gadgetbridge by Freeyourgadget.

the class HuamiActivityDetailsParserTest method createSummary.

private BipActivitySummary createSummary() {
    BipActivitySummary summary = new BipActivitySummary();
    summary.setBaseLongitude(1);
    summary.setBaseLatitude(1);
    summary.setBaseAltitude(1);
    summary.setStartTime(baseTime);
    User dummyUser = new User(0L);
    dummyUser.setName("Elvis");
    summary.setName("testtrack");
    summary.setUser(dummyUser);
    Device device = new Device(0l);
    device.setName("SuperBand 2000");
    summary.setDevice(device);
    return summary;
}
Also used : User(nodomain.freeyourgadget.gadgetbridge.entities.User) Device(nodomain.freeyourgadget.gadgetbridge.entities.Device) BipActivitySummary(nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.BipActivitySummary)

Aggregations

BipActivitySummary (nodomain.freeyourgadget.gadgetbridge.devices.amazfitbip.BipActivitySummary)3 InputStream (java.io.InputStream)2 ActivityPoint (nodomain.freeyourgadget.gadgetbridge.model.ActivityPoint)2 ActivityTrack (nodomain.freeyourgadget.gadgetbridge.model.ActivityTrack)2 HuamiActivityDetailsParser (nodomain.freeyourgadget.gadgetbridge.service.devices.huami.HuamiActivityDetailsParser)2 Test (org.junit.Test)2 File (java.io.File)1 Device (nodomain.freeyourgadget.gadgetbridge.entities.Device)1 User (nodomain.freeyourgadget.gadgetbridge.entities.User)1 GPXExporter (nodomain.freeyourgadget.gadgetbridge.export.GPXExporter)1