Hello everyone,
I am trying to use the S340 softdevice in order to connect to an ANT+ HR. I would like to use proximity search.
It works fine for the first device in range but afterwards I am not able to change to another hr sensor. I can only reconnect to the same device...
here is the relevant code:
void ANT_Init() { uint32_t err_code = nrf_sdh_ant_enable(); APP_ERROR_CHECK(err_code); err_code = ant_plus_key_set(ANTPLUS_NETWORK_NUMBER); APP_ERROR_CHECK(err_code); /* Set library config to report RSSI and Device ID */ 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); // Register a handler for ANT events. NRF_SDH_ANT_OBSERVER(m_ant_observer, APP_ANT_OBSERVER_PRIO, ant_evt_handler, NULL); // Initialize ANT+ HRM receive channel. err_code = ant_hrm_disp_init(&m_ant_hrm, HRM_DISP_CHANNEL_CONFIG(m_ant_hrm), ant_hrm_evt_handler); APP_ERROR_CHECK(err_code); } void ant_hrm_rx_start(uint8_t treshold) { uint32_t err_code = sd_ant_prox_search_set(m_ant_hrm.channel_number, treshold,0); APP_ERROR_CHECK(err_code); err_code = ant_hrm_disp_open(&m_ant_hrm); APP_ERROR_CHECK(err_code); } void ant_hrm_rx_stop() { uint32_t err_code; sd_ant_channel_close(m_ant_hrm.channel_number); // reset device number? err_code =sd_ant_channel_unassign(m_ant_hrm_channel_hrm_disp_config.channel_number); APP_ERROR_CHECK(err_code); err_code = ant_hrm_disp_init(&m_ant_hrm, HRM_DISP_CHANNEL_CONFIG(m_ant_hrm), ant_hrm_evt_handler); APP_ERROR_CHECK(err_code); // error 0x4015 (wrong state)? }
My guess is that the softdevice stores the device number once it gets connected and after closing connection and starting proximity search again it only allows this device number?
So I tried to close the channel and reintit but I get error 0x4015 (wrong state) even after unassigning it.
Thanks for any help!
Andreas
How can I reset this?