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

sd_ant_channel_open fails if channel assigned as EXT_PARAM_ASYNC_TX_MODE

Hello,

In the following code, I have tried to assign a channel to be asychronous so that I can transmit 8 byte acknowledged messages immediately following a button press. However, the call to sd_ant_channel_open() fails with error 0x4015. If I remove the EXT_PARAM_ASYNC_TX_MODE parameter from the channel assign function, then I can open the channel. What am I doing wrong?

Once the channel is open, is it the sd_ant_broadcast_message_tx() I should be using to send the 8 byte message? How do I specify how often it retries?

Thanks.

uint32_t err_code;
const uint8_t chan=0;

err_code = sd_ant_lib_config_set( ANT_LIB_CONFIG_MESG_OUT_INC_RSSI | ANT_LIB_CONFIG_MESG_OUT_INC_DEVICE_ID );
APP_ERROR_CHECK(err_code);

// MASTER channel = async Tx
err_code = sd_ant_channel_assign( chan, CHANNEL_TYPE_MASTER, 0, EXT_PARAM_ASYNC_TX_MODE );
APP_ERROR_CHECK(err_code);

// Set Channel id
uint16_t devnum = *(uint32_t *)SERIAL_NUMBER_ADDRESS;
uint8_t devtype = 1;
uint8_t txtype = 0;
err_code = sd_ant_channel_id_set( chan, devnum, devtype, txtype );
APP_ERROR_CHECK(err_code);

// Set channel radio frequency
err_code = sd_ant_channel_radio_freq_set( chan, 77 );
APP_ERROR_CHECK(err_code);

// Channel period = 1000/32768s, but do we need to set this for async Tx???
err_code = sd_ant_channel_period_set( chan, 1000 );
APP_ERROR_CHECK(err_code);

// Set Tx power = 0dBm
err_code = sd_ant_channel_radio_tx_power_set( chan, RADIO_TX_POWER_LVL_3, 0 );
APP_ERROR_CHECK(err_code);

// Open the Tx channel - this fails with error code 0x4015
err_code = sd_ant_channel_open( chan );
APP_ERROR_CHECK(err_code);
Parents
  • You can find the error code in ant_error.h. It is not included in all ANT examples (it should be), but you can find it in the ant_fs example. 0x4015 corresponds to NRF_ANT_ERROR_CHANNEL_IN_WRONG_STATE.

    As you have figured out you get this error code because accourding to the ANT Message Protocol and Usage you shouldn't open the channel:

    In contrast to other channel configurations, a channel using asynchronous transmission does not need to be opened and no channel period needs to be set.

    Regarding how to send the your data, it says:

    All three data types (broadcast, acknowledged and burst) are supported.

    So it seems you can use either of the following:

       sd_ant_broadcast_message_tx()
       sd_ant_acknowledge_message_tx()
       sd_ant_burst_handler_request()
    

    How do I specify how often it retries?

    sd_ant_broadcast_message_tx() will send maximum 8 bytes once. It is not acknowledged, it is not retried.

    sd_ant_acknowledge_message_tx() will send maximum 8 bytes once. It is acknowledged, but it is not retried. The application will be notified if it is success or failure.

    sd_ant_burst_handler_request() will send x bytes. It is acknowledged, it is retried 5 times. The application will be notified if it is success or failure.

Reply
  • You can find the error code in ant_error.h. It is not included in all ANT examples (it should be), but you can find it in the ant_fs example. 0x4015 corresponds to NRF_ANT_ERROR_CHANNEL_IN_WRONG_STATE.

    As you have figured out you get this error code because accourding to the ANT Message Protocol and Usage you shouldn't open the channel:

    In contrast to other channel configurations, a channel using asynchronous transmission does not need to be opened and no channel period needs to be set.

    Regarding how to send the your data, it says:

    All three data types (broadcast, acknowledged and burst) are supported.

    So it seems you can use either of the following:

       sd_ant_broadcast_message_tx()
       sd_ant_acknowledge_message_tx()
       sd_ant_burst_handler_request()
    

    How do I specify how often it retries?

    sd_ant_broadcast_message_tx() will send maximum 8 bytes once. It is not acknowledged, it is not retried.

    sd_ant_acknowledge_message_tx() will send maximum 8 bytes once. It is acknowledged, but it is not retried. The application will be notified if it is success or failure.

    sd_ant_burst_handler_request() will send x bytes. It is acknowledged, it is retried 5 times. The application will be notified if it is success or failure.

Children
No Data
Related