This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to change new device_number when ANT device is working

Hello,

I use nrf51422 to connect the ANT device(Heart rate monitor) and it can work .

My question is , I want to assign a new device_number to 51422 and use this new device_number to search second ANT+ device ,but I found the 51422 will be reset.

I don't want 51422 to reset ,how could I do?

I use below function to assign a new device_number

void change_device_number(uint16_t device_number) {

uint32_t err_code;

err_code = sd_ant_channel_close(ANT_HRMRX_ANT_CHANNEL);
APP_ERROR_CHECK(err_code);

err_code = sd_ant_network_address_set(ANTPLUS_NETWORK_NUMBER, m_ant_network_key);
APP_ERROR_CHECK(err_code);

err_code = sd_ant_channel_assign(ANT_HRMRX_ANT_CHANNEL,
                                 ANT_HRMRX_CHANNEL_TYPE,
                                 ANTPLUS_NETWORK_NUMBER,
                                 ANT_HRMRX_EXT_ASSIGN);

APP_ERROR_CHECK(err_code);

err_code = sd_ant_channel_id_set(ANT_HRMRX_ANT_CHANNEL,
                                 device_number,
                                 ANT_HRMRX_DEVICE_TYPE,
                                 ANT_HRMRX_TRANS_TYPE);


APP_ERROR_CHECK(err_code);

err_code = sd_ant_channel_radio_freq_set(ANT_HRMRX_ANT_CHANNEL, ANTPLUS_RF_FREQ);


APP_ERROR_CHECK(err_code);

err_code = sd_ant_channel_period_set(ANT_HRMRX_ANT_CHANNEL, ANT_HRMRX_MSG_PERIOD);


APP_ERROR_CHECK(err_code);

err_code = sd_ant_channel_open(ANT_HRMRX_ANT_CHANNEL);
APP_ERROR_CHECK(err_code);


}
Parents
  • #define NRF_ANT_ERROR_CHANNEL_IN_WRONG_STATE          NRF_ANT_ERROR_OFFSET + CHANNEL_IN_WRONG_STATE  ///< Response on attempt to perform an action from the wrong channel state.
    

    It seems like you haven't closed the channel you are trying to re-configure. Make sure that the channel is closed before you modify the parameters.

    edit: You have do add a delay to ensure that the channel is closed before you change any parameters on it. I tested the routine you sent me here and it works, but it needs a delay. I did a nasty little for-loop to add a delay quickly, I would recommend you to wait for the callback and make sure that the channel is closed correctly before you change the device number and you should be fine.

  • how to know channel is closed or not? I get error code from "sd_ant_channel_close" is 0x00.

Reply Children
No Data
Related