Skip to content

Sensor log

Maciej Janiszewski edited this page Mar 16, 2019 · 1 revision

Introduction

The way Band tracks your health data is by collecting a raw sensor log. According to intercepted traffic with mitmproxy, sensors included in the log are:

  • Device Contact sensor,
  • Calories,
  • Distance,
  • Steps,
  • Heart Rate.

Example intercepted response:

GET https://prodphsweu.dns-cargo.com/v2/UserDailySummary(timeZoneUtcOffset=60,startDate='2019-03-10',endDate='2019-03-17') HTTP/1.1

{
    "odata.metadata": "https://prodphsweu.dns-cargo.com/v2/$metadata#UserDailySummary",
    "value": [
        ...
        {
            ...
            "SourceDevices": [
                {
                    "DeviceGroups": [
                        {
                            "DeviceIds": [
                                "[redacted]"
                            ],
                            "DeviceMetadataHint": "Band",
                            "SourceType": "Band"
                        }
                    ],
                    "SensorType": "Calories"
                },
                {
                    "DeviceGroups": [
                        {
                            "DeviceIds": [
                                "[redacted]"
                            ],
                            "DeviceMetadataHint": "ios",
                            "SourceType": "PhoneSensor"
                        },
                        {
                            "DeviceIds": [
                                "[redacted]"
                            ],
                            "DeviceMetadataHint": "Band",
                            "SourceType": "Band"
                        }
                    ],
                    "SensorType": "Distance"
                },
                {
                    "DeviceGroups": [
                        {
                            "DeviceIds": [
                                "[redacted]"
                            ],
                            "DeviceMetadataHint": "ios",
                            "SourceType": "PhoneSensor"
                        },
                        {
                            "DeviceIds": [
                                "[redacted]"
                            ],
                            "DeviceMetadataHint": "Band",
                            "SourceType": "Band"
                        }
                    ],
                    "SensorType": "Steps"
                },
                {
                    "DeviceGroups": [
                        {
                            "DeviceIds": [
                                "[redacted]"
                            ],
                            "DeviceMetadataHint": "Band",
                            "SourceType": "Band"
                        }
                    ],
                    "SensorType": "HeartRate"
                },
                {
                    "DeviceGroups": [
                        {
                            "DeviceIds": [
                                "[redacted]"
                            ],
                            "DeviceMetadataHint": "Band",
                            "SourceType": "Band"
                        }
                    ],
                    "SensorType": "BandWorn"
                }
            ],
            ...
        },
        ...
    ]
}

Sync process

Sync process consists of a few steps:

  1. Phone sends 'Flush' command to Band.
  2. Phone sends 'GetRemainingChunks' command to Band, response is a chunk count.
  3. Phone grabs remaining chunks from phone. Max. 128 per 1 loop iteration. 3.1. Phone sends 'GetChunkRangeMetadata' command to Band with requested chunk count as argument. 3.2. Band replies with 3 values - beginning/end sequence numbers and byte count. 3.3. Phone sends 'GetChunkRangeData' command to Band with these 3 values as argument. 3.4. Band replies with a huge chunk of raw sensor data.
  4. Phone uploads the chunk to the cloud with metadata attached as HTTP headers (what device, log version etc.).
  5. Phone sends 'DeleteChunkRange' command to avoid downloading the same data on next sync.

Log format

Because the log is processed completely in the cloud, the format itself is a bit tricky to figure out, as we can't really use decompiled .NET code as reference.

Clone this wiki locally