EVENT_CHANNEL_CLOSED ?

Dear Members,

How can I scan continously if I loss the sensor,

I have made at this function :

static void ant_evt_handler(ant_evt_t * p_ant_evt, void * p_context)

case EVENT_CHANNEL_CLOSED:
									  NRF_LOG_INFO("EVENT_CHANNEL_CLOSED...\r\n");
								    NRF_LOG_INFO("BSP_INDICATE_SCANNING...\r\n");//31Mar22 Rixtronix LAB
                    
								     err_code = bsp_indication_set(BSP_INDICATE_SCANNING);
					
								    nrf_pwr_mgmt_feed(); //Function for indicating activity.
								    
								
                    break;

but it's not scanning when it loss the sensor ,

Any clues ?

Kind regards,

Rixtronix

  • You can open the channel again by calling sd_ant_channel_open().

    Kenneth

  • Hi Kenneth,

    Thanks for the reply,

    So I call sd_ant_channel_open(); at :

     case EVENT_RX_FAIL:
    									  NRF_LOG_INFO("EVENT_RX_FAIL...\r\n"); 
    								    NRF_LOG_INFO("RIXTRONIX EVENT_RX_FAIL...\r\n"); 
                        err_code = bsp_indication_set(BSP_INDICATE_RCV_ERROR);
    								sd_ant_channel_open();
                        break;
    
                    case EVENT_RX_FAIL_GO_TO_SEARCH:
    									  NRF_LOG_INFO("EVENT_RX_FAIL_GO_TO_SEARCH...\r\n");
    								    NRF_LOG_INFO("RIXTRONIX EVENT_RX_FAIL_GO_TO_SEARCH...\r\n"); 
                        err_code = bsp_indication_set(BSP_INDICATE_SCANNING);
                        sd_ant_channel_open();
                        break;
    
                    case EVENT_CHANNEL_CLOSED:
    									  NRF_LOG_INFO("EVENT_CHANNEL_CLOSED...\r\n");
    								    NRF_LOG_INFO("BSP_INDICATE_SCANNING...\r\n");//31Mar22 Rixtronix LAB
                        //nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_GOTO_SYSOFF); //default
    								     err_code = bsp_indication_set(BSP_INDICATE_SCANNING);
    									  //nrf_pwr_mgmt_shutdown(NRF_PWR_MGMT_SHUTDOWN_CONTINUE);
    								    nrf_pwr_mgmt_feed(); //Function for indicating activity.
    					           sd_ant_channel_open();			    
    								
                        break;
    
                    case EVENT_RX_SEARCH_TIMEOUT:
    									 //Rixtronix LAB
    								   //8 Sept 2021, 
    								   //on search timeout, and idle, make device on if there is a signal from sensor ?
    									  NRF_LOG_INFO("EVENT_RX_SEARCH_TIMEOUT...\r\n");
                        //err_code = bsp_indication_set(BSP_INDICATE_IDLE);//default
    								    err_code = bsp_indication_set(BSP_INDICATE_SCANNING);
    								    nrf_pwr_mgmt_feed(); //Function for indicating activity. default
    								     
                        break;

    Best regards,

    Rixtronix

  • I suggest to check out the api documentation:

    /** @brief This function opens and activates a channel. The channel to open must be in an assigned state. When opening a master channel,
     *         a supplied offset can be provided in order to suggest a minimum channel start time offset (from when the command is issued) to
     *         the ANT stack. Specifying CHANNEL_START_OFFSET_NONE will result in default channel start up behaviour. When opening a slave channel,
     *         CHANNEL_START_OFFSET_NONE must be used.
     *
     * @param[in] ucChannel is an unsigned char (1 octet) denoting the channel to open.
     *  param[in] usOffset is an unsigned short (2 octet) denoting the offset from which to start the channel.  See Channel Start Offset in ant_parameters.h
     *
     * @return  ::NRF_SUCCESS
     *          ::NRF_ANT_ERROR_INVALID_PARAMETER_PROVIDED
     *          ::NRF_ANT_ERROR_CHANNEL_IN_WRONG_STATE
     */
    #define sd_ant_channel_open(ucChannel)      sd_ant_channel_open_with_offset(ucChannel, CHANNEL_START_OFFSET_NONE)
    SVCALL(SVC_ANT_CHANNEL_OPEN, uint32_t, sd_ant_channel_open_with_offset(uint8_t ucChannel, uint16_t usOffset));

  • Hi Kenneth,

    Thanks for the reply,

    Can I make :

     case EVENT_RX_SEARCH_TIMEOUT:
    									 //Rixtronix LAB
    								   //8 Sept 2021, 
    								   //on search timeout, and idle, make device on if there is a signal from sensor ?
    									  NRF_LOG_INFO("EVENT_RX_SEARCH_TIMEOUT...\r\n");
                        //err_code = bsp_indication_set(BSP_INDICATE_IDLE);//default
    								    err_code = bsp_indication_set(BSP_INDICATE_SCANNING);
    								    nrf_pwr_mgmt_feed(); //Function for indicating activity. default
    								     /****21Apr22 Rixtronix LAB****
    								     err_code=sd_ant_channel_open(HRM_CHANNEL_NUM);
    								     err_code=sd_ant_channel_open(BSC_CHANNEL_NUM);
    								     err_code=sd_ant_channel_open(BPWR_CHANNEL_NUM);
    								      *******/
                        break;

    Regards,

    Rixtronix

  • I believe this should work yes, though you should only open the channel that for instanced closed or timeout.

    Kenneth

Related