It appears that there is a bug in the antfs.c sample code in version 15.3.0
nRF5_SDK_15.3.0_59ac345\components\ant\ant_fs\antfs.c
It the transport_layer_cmd_decode() function in the ANTFS_CMD_DOWNLOAD_ID: case there is the following If statement (the second one) that appears to be attempting to determine if this is the first burst packet.
case ANTFS_CMD_DOWNLOAD_ID: if (m_current_state.sub_state.trans_sub_state != ANTFS_TRANS_SUBSTATE_NONE) { // Ignore the command if we are busy. break; } if ((control_byte & ~SEQUENCE_LAST_MESSAGE) == 0x00) { // First burst packet. ...
The control byte appears to have the 5 least significant bits representing the channel number that the message was received on and the 3 most significant bits representing the sequence number. I'm basing this on the following defines
// //////////////////////////////////////////// /** @name Rx Burst Message Sequencing Defines * @{ */ // //////////////////////////////////////////// #define CHANNEL_NUMBER_MASK ((uint8_t)0x1F) ///< Valid bitfields for channel number #define SEQUENCE_NUMBER_MASK ((uint8_t)0xE0) ///< Valid bitfields for burst sequence #define SEQUENCE_NUMBER_ROLLOVER ((uint8_t)0x60) ///< Sequence rollover #define SEQUENCE_FIRST_MESSAGE ((uint8_t)0x00) ///< Sequence indicating first burst message #define SEQUENCE_LAST_MESSAGE ((uint8_t)0x80) ///< Sequence indicating last burst message #define SEQUENCE_NUMBER_INC ((uint8_t)0x20) ///< Incremental sequence value
ANDing the control byte with the complement of the SEQUENCE_LAST_MESSAGE seems to be a mistake. The code seems to function properly when the channel number is 0, but it does not function properly (it never gets inside the IF statement) if the channel number is something other than 0.
I'm guessing that the proper code would probably be something like the following.
if ((control_byte & SEQUENCE_NUMBER_MASK) == SEQUENCE_FIRST_MESSAGE)
However, I don't understand the details of the code precisely so I'm not certain this is the correct fix. Can someone comment on what the correct fix for this problem should be?