TimeSyncBlock

Wire protocol v1 of the time-sync characteristic (GattUuids.TIME_SYNC_CHARACTERISTIC, firmware 3.8.0+), shared with the device firmware. The device builds the 20-byte value inside its read handler from its own clock and the sample it numbered last, so one timed read ties the host's clock, the device's clock and the ADS1299 sample counter together (see TimeSync in :core). Little-endian:

offtypefieldmeaning
0u8version1; any other value is not understood
1u8flagsFLAG_STREAMING, FLAG_IMPEDANCE, FLAG_SAMPLE_VALID; other bits ignored
2u8stream_genlow 8 bits of the stream generation of the anchored sample
3u8seqincremented on every read the device answers
4u32sample_numbersample numbered last, as the packet footers count; 0 without SAMPLE_VALID
8u32sample_age_usdevice time since that sample's DRDY; SAMPLE_AGE_INVALID without SAMPLE_VALID, SAMPLE_AGE_MAX saturated
12u32t_now_uslow 32 bits of the device's microsecond clock, taken first in the read handler
16u16conn_intervalthe link's connection interval, 1.25 ms units
18u16reserved0

Properties

Link copied to clipboard
const val FLAG_IMPEDANCE: Int

Impedance mode: the sample counter is not uniform in time (it jumps a sweep at a time).

Link copied to clipboard

A sample has been numbered since the stream started.

Link copied to clipboard
const val FLAG_STREAMING: Int

The ADS1299 is converting.

Link copied to clipboard
const val OFFSET_CONN_INTERVAL: Int = 16
Link copied to clipboard
const val OFFSET_FLAGS: Int = 1
Link copied to clipboard
const val OFFSET_SAMPLE_AGE_US: Int = 8
Link copied to clipboard
const val OFFSET_SAMPLE_NUMBER: Int = 4
Link copied to clipboard
const val OFFSET_SEQ: Int = 3
Link copied to clipboard
const val OFFSET_STREAM_GEN: Int = 2
Link copied to clipboard
const val OFFSET_T_NOW_US: Int = 12
Link copied to clipboard
const val OFFSET_VERSION: Int = 0
Link copied to clipboard
const val PROTOCOL_VERSION: Int = 1
Link copied to clipboard
const val REPLY_SIZE: Int = 20
Link copied to clipboard
const val SAMPLE_AGE_INVALID: Long = 4294967295

sample_age_us without FLAG_SAMPLE_VALID.

Link copied to clipboard
const val SAMPLE_AGE_MAX: Long = 4294967294

sample_age_us saturated: this or more, so not a usable point.

Functions

Link copied to clipboard

The reply's fields, or null when value is not a v1 reply: shorter than REPLY_SIZE — an empty read is what both firmware without the characteristic and a failed read return — or of another version. A longer value is read as v1, for whatever a later version appends.