This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SD332 - BUG with 4 byte NRF52 ANT Timestamps

ANT experts,

I have been looking at the nrf52 implementation of the ANT timestamp (and timesync) features. One thing that is rather puzzling is the fact that the documentation for the ANT protocol claims that the timestamp in the extended data will be at-most 2 bytes, while the code in the nrf52 includes seem to hint that we can have the timestamp in 2 byte or 4 byte modes (based on the way the timestamp-ing is configured).

Would this mean that the extended messages coming back from the event could potentially have 12 bytes of extended data (if all bits are set for which features are enabled)?

Edit1:

I think you guys meant to extend ANT_EXT_MESG_TIME_STAMP_FIELD_SIZE to 4 (from 2).

MESG_MAX_EXT_DATA_SIZE has the following definition:

(ANT_EXT_MESG_DEVICE_ID_FIELD_SIZE + ANT_EXT_MESG_RSSI_FIELD_SIZE + ANT_EXT_MESG_ALT_TIME_STAMP_FIELD_SIZE + ANT_EXT_STRING_SIZE)

and this corresponding comment

// ANT device ID (4 bytes) + ANT RSSI (4 bytes) + ANT timestamp (4 bytes) + ANT Ext String Size

Additionally, what happens to the extended fields if advanced burst or encrypted channels are enabled?

Thank you for clearing all this up - you guys rock!

Edit2:

When I enable the following

sd_ant_lib_config_set(ANT_LIB_CONFIG_MESG_OUT_INC_TIME_STAMP |
                      ANT_LIB_CONFIG_MESG_OUT_INC_RSSI |
                      ANT_LIB_CONFIG_MESG_OUT_INC_DEVICE_ID);

ANT_TIME_STAMP_CONFIG tsCfg =
{
    .ucTimeBase         = ANT_TIME_BASE_ALT2,
    .bTimeStampEnabled  = true,
};

err = sd_ant_time_stamp_config_set(&tsCfg);

I only get the top 24 bits of the RTC2 counter. Is this a bug that you guys need to resolve in the softdevice? This pretty much makes the RTC based timestamps un-usable!!

Edit3:

I think we might have a handle on whats afoot. I think the RTC value is being divided by 256 to take it from a 24 bit value to a 16 bit value. Furthermore, it seems like someone then took this adjusted value and writes 24 bits (MS-byte is always 0 due to the previous divide) to the timestamp extended field. This totally smells like a SD bug to me - and whats worse is if I assume that RTC reported in the TS message will always be divided by 256 and you guys fix the bug - our code will now break :) We can put in some detectors to work around this, but I would like confirmation from your side that we are not doing anything incorrectly. Please note that this error only occurs when the RSSI and the timestamp (ALT2 or ALT1) fields are enabled in tandem - is that not expected?

Related