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

ANT+ sd_ant_channel_close reseting

Hi,

We are using nrf52832 for ANT and BLE for which we use SDK_17.0.2 and s332_nrf52_7.0.1

Our objective is to pair and un-pair ANT sensors. So far pairing multiple ANT sensors and snding the data via BLE works fine. But when we do try to un-pair sensors by closing the channel, the device does restarts.

For that we did try to use sd_ant_channel_close() function. We did use it in our event and in main while loop with a dalay as well. We did try with sd_ant_channel_unassign() function after closing the channel as well.

Is there some sequence that we are missing? Below is our channel init code. Thank you.

static void ANT_profile_HRM_setup(uint8_t ant_channel_no, uint32_t ant_device_no)
{
/** @snippet [ANT HRM RX Profile Setup] */
       
    uint32_t err_code = sd_ant_lib_config_set(ANT_LIB_CONFIG_MESG_OUT_INC_DEVICE_ID);
    APP_ERROR_CHECK(err_code);

        ant_channel_config_t channel_config =
    {
        .channel_number     = ant_channel_no,
        .channel_type       = CHANNEL_TYPE_SLAVE,
        .ext_assign         = HRM_EXT_ASSIGN,
        .rf_freq            = HRM_ANTPLUS_RF_FREQ,
        .transmission_type  = CHAN_ID_TRANS_TYPE,
        .device_type        = HRM_DEVICE_TYPE,
        .device_number      = ant_device_no,
        .channel_period     = HRM_MSG_PERIOD_1Hz,
        .network_number     = ANTPLUS_NETWORK_NUM,
    };

    const ant_search_config_t ant_search_config =
    {
        .channel_number        = ant_channel_no,
        .low_priority_timeout  = ANT_LOW_PRIORITY_TIMEOUT_DISABLE,
        .high_priority_timeout = ANT_HIGH_PRIORITY_SEARCH_DISABLE,
        .search_sharing_cycles = ANT_SEARCH_SHARING_CYCLES_DISABLE,
        .search_priority       = ANT_SEARCH_PRIORITY_DEFAULT,
        .waveform              = ANT_WAVEFORM_DEFAULT,
    };


    err_code = ant_hrm_disp_init(&m_ant_hrm, &channel_config, ant_tmp_evt_handler);
    APP_ERROR_CHECK(err_code);

        // Set search timeout
        err_code = ant_search_init(&ant_search_config);
        APP_ERROR_CHECK(err_code);

    err_code = sd_ant_channel_open(ant_channel_no);
    APP_ERROR_CHECK(err_code);


    err_code = ant_state_indicator_channel_opened();
    APP_ERROR_CHECK(err_code);

/** @snippet [ANT HRM RX Profile Setup] */
}

Best regards, Ram

Parents
  • But when we do try to un-pair sensors by closing the channel, the device does restarts.

    This means you likely have an assert, it will default do a soft reset if any api call return an error code. If you build with DEBUG (not RELEASE) then you should fint the actual error code, line number and file name causing the error in app_error_fault_handler(). Can you provide this information? 

    Thanks,
    Kenneth

  • Sorry, I should send that earlier.It stops in:

    nRF5_SDK_17.0.2_d674dde\components\libraries\log\src\nrf_log_frontend.c in line 999 (nrf_log_backend_enable(p_backend);)

    void nrf_log_panic(void)
    {
        nrf_log_backend_t const * p_backend = m_log_data.p_backend_head;
        m_log_data.autoflush = true;
        while (p_backend)
        {
            nrf_log_backend_enable(p_backend);
            nrf_log_backend_panic_set(p_backend);
            p_backend = p_backend->p_cb->p_next;
        }
    }

    Does that help?

  • It seems to run fine here, what do you expect should happen if I run the HRM RX example project with your additional ant_close_channel()?

  • In a debug mode.

    It does stop because of some error. Please have a look at the video, 1. with ant_channel_close() counter stops and in video 2. when comentig out that function it counts normaly.

  • I believe this is because when the channel is closed it will go to system OFF mode, see ant_evt_handler() in ant_state_indicator.c where the switch case EVENT_CHANNEL_CLOSED will call nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF);

    Edit: Please comment out this line if you don't want to go to system OFF.

    Kenneth

Reply Children
No Data
Related