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

Parents
  • Hi

    Unfortunately our ANT expert is out of office for the Easter vacation. They'll get back to you on Tuesday April 19th. Happy Easter!

    Best regards,

    Simon

  • Hi Simon,

    Thanks for the reply,

    From this ant_evt_handler,

    static void ant_evt_handler(ant_evt_t * p_ant_evt, void * p_context)
    {
        ret_code_t err_code = NRF_SUCCESS;
    
        if (m_channel != p_ant_evt->channel)
        {
            return;
        }
    
        switch (m_channel_type)
        {
            case CHANNEL_TYPE_SLAVE:
                /* fall through */
            case CHANNEL_TYPE_SLAVE_RX_ONLY:
                switch (p_ant_evt->event)
                {
                    case EVENT_RX:
    									  NRF_LOG_INFO("EVENT_RX...\r\n"); 
                        err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
    								    
    								    nrf_pwr_mgmt_feed(); //Function for indicating activity.
                        break;
    
                    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);
    								
                        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);
                        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.
    								    
    								
                        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;
                }
                break;
        }
        APP_ERROR_CHECK(err_code);
    }

    on EVENT_CHANNEL_CLOSED:

    How can I rescan again ?

    Best regards,

    Rixtronix LAB

  • Hi Kenneth,

    Thanks for the reply,

    I can't get error code that caused the assert,

    Code and output :

    when I commented out : 

     //err_code=sd_ant_channel_open(BSC_CHANNEL_NUM);
                                         //APP_ERROR_CHECK(err_code);

    It's running and scanning for HRM, but will not work if I open BSC and BPW,

    Could you help us ?

    Kind regards,

    Rixtronix

  • In your project, there should be a file called app_error_weak.c (and likely also app_error_handler_keil.c since you are using Keil IDE), app_error_weak.c contain a fault handler: app_error_fault_handler()

    This fault hault handler is called when an api return an error code, if you have added DEBUG to your preprocessor (as I can see you have) then this file should provide information about file name, line number and error code.

    Kenneth

  • Hi Kenneth,

    Thanks for the reply,

    I saw :

    SVCALL(SVC_ANT_CHANNEL_SEARCH_TIMEOUT_SET, uint32_t, sd_ant_channel_search_timeout_set (uint8_t ucChannel, uint8_t ucTimeout));

    at

    nRF5_SDK_17.0.2_d674dde\components\softdevice\SoftDevice\headers\include\ant_interface.h LINE 457

    can I change

    uint8_t ucTimeout; to

    int32_t Timeout

    and Timeout =10000 ?

    Regards,

    Rixtronix

  • Looking at the description in ant_interface.h

    /** @brief This function sets the channel search timeout. For a slave channel, the configuration applies to rx search
     *         timeout. For a master channel, the configuration applies to timeout for starting a transmitter using group transmitter
     *         initiation requirements.
     *
     * @param[in] ucChannel is an unsigned char (1 octet) denoting the channel number to set.
     * @param[in] ucTimeout is an unsigned char (1 octet) denoting the timeout value.
                  When applied to an assigned slave channel, ucTimeout is in 2.5 second increments. Default = 10 (25s) at channel assignment
                  When applied to an assigned master channel, ucTimeout is in 250ms increments. Default = 0 (disabled) at channel assignment
     *
     * @return  ::NRF_SUCCESS
     *          ::NRF_ANT_ERROR_INVALID_PARAMETER_PROVIDED
     */
    #define sd_ant_channel_rx_search_timeout_set(ucChannel, ucTimeout)      sd_ant_channel_search_timeout_set(ucChannel, ucTimeout)
    SVCALL(SVC_ANT_CHANNEL_SEARCH_TIMEOUT_SET, uint32_t, sd_ant_channel_search_timeout_set (uint8_t ucChannel, uint8_t ucTimeout));

    ucTimeout is an unsigned char (1 octet) denoting the timeout value, the increment is mentioned in the description depending on slave or master channel.

    Best regards,
    Kenneth

  • Hi Kenneth,

    Thanks for the reply,

    Is it possible that I reload the timeout with timer,

    For example I set timer every 60s, and call  

    sd_ant_channel_rx_search_timeout_set(ucChannel, ucTimeout)

    So I can get long timeout ?

    Kind regards,

    Rixtronix

Reply Children
  • The intention is that when the ANT search timeout you start again if you want to, in other words it's event driven what the application does based on the events that occurs. It's the same for instance in BLE, if the advertisment or scanning timeout, the application can start again or go to sleep. You can do what you ask about also, but then you can get error codes for instance because it's already in the progress of searching when you call search from the timer.

    Kenneth

  • Hi Kenneth,

    Thanks for the reply,

    but I can not put "extra time out" when the "EVENT_CLOSED" runs?

    Regards,

    RIxtronix

  • Sorry to ask, but what you asking about? You totally free to call this api whenever you like with the parameters supported, you can call it as frequently as you like (though it sounds strange to call it if it's already running). What extra time are you asking about?

    Best regards,
    Kenneth

  • Hi Kenneth,

    Thanks for the reply,

    I made like this :

    on main ()
    	create_timers_ANT_HRM();//create timer for ANT Sensor Timeout Extension 11 May 22 Rixtronix LAB
    	/*****************ANT SENSOR TIMER*************11May22*************BEGIN***********/
    	   app_timer_start(m_repeated_timer_ANT_timeout, APP_TIMER_TICKS(60000), NULL);  // timeout extenstion ANT SENSOR 11 May 22 Rixtronix LAB
    	/**************************END*****************/
    	//Timer configuration
    	static void create_timers_ANT_HRM()
    {
        ret_code_t err_code;
    	
        // Create timers ANT HRM
        err_code = app_timer_create(&m_repeated_timer_ANT_timeout,
                                    APP_TIMER_MODE_REPEATED,
                                    repeated_timer_handler_ANT_HRM);
        APP_ERROR_CHECK(err_code);
    }
    //timer handler
    static void repeated_timer_handler_ANT_HRM(void * p_context)
    {
    	ret_code_t err_code;
    	 
    	 //Process ANT_HRM every x seconds  here 24 Dec 21 Rixtronix LAB
    	 //ANT_HRM_flag_timer =0;
    	 //GPS_flag_timer =0;
    	//Start GPS again singleshot
    	//app_timer_start(m_repeated_timer_GPS_Start, APP_TIMER_TICKS(10), NULL);  // 29 Dec 21 Rixtronix LAB
    	
    	/********Rixtronix LAB timer event for increasing timeout ANT Sensor 11May22*********/
    	/******E:\nRF5_SDK_17.0.2_d674dde\components\softdevice\SoftDevice\headers\include\ant_interface.h LINE 457*******/
     err_code = sd_ant_channel_search_timeout_set(HRM_CHANNEL_NUM, 88);
        APP_ERROR_CHECK(err_code);
    	/******E:\nRF5_SDK_17.0.2_d674dde\components\softdevice\SoftDevice\headers\include\ant_interface.h LINE 457*******/	
     err_code = sd_ant_channel_search_timeout_set(BSC_CHANNEL_NUM, 88);
        APP_ERROR_CHECK(err_code);	
    	
    	/******E:\nRF5_SDK_17.0.2_d674dde\components\softdevice\SoftDevice\headers\include\ant_interface.h LINE 457*******/
    	  err_code = sd_ant_channel_search_timeout_set(BPWR_CHANNEL_NUM, 88);
        APP_ERROR_CHECK(err_code);
    	
    }
    

    I want to extend the timeout, so the receiver always waits

    Regards,

    Rixtronix

  • I believe waiting for the closed event and open channel again is the fastest. In any case I recommend to check out some of the application notes that describe different types of search and scanning in ANT if you haven't already:

    https://www.thisisant.com/resources/an14-continuous-scanning-mode/ 
    https://www.thisisant.com/resources/an11-ant-channel-search-and-background-scanning-channel/ 

    Kenneth

Related