-
Notifications
You must be signed in to change notification settings - Fork 3
Sensor log
Maciej Janiszewski edited this page Mar 16, 2019
·
1 revision
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 consists of a few steps:
- Phone sends 'Flush' command to Band.
- Phone sends 'GetRemainingChunks' command to Band, response is a chunk count.
- 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.
- Phone uploads the chunk to the cloud with metadata attached as HTTP headers (what device, log version etc.).
- Phone sends 'DeleteChunkRange' command to avoid downloading the same data on next sync.
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.