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

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

    Kenneth

  • Hi Kenneth,

    Thanks for the reply

    How do we know which channel is closed ? I have HRM and BSC and BPWR ?

    I want to log it to SDcard on different state, but always crashed, any ideas ?

    Regards,

    Rixtronix

  • Hi Kenneth,

    Thanks for the reply, when I make :

     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.
    								   /************REOPEN all channels Rixtronix LAB 4May2022*************/
    								   
    								     err_code=sd_ant_channel_open(HRM_CHANNEL_NUM);
    								       nrf_delay_ms(888);	
    								     err_code=sd_ant_channel_open(BSC_CHANNEL_NUM);

    it keeps restarting,

    but if I do :

     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.
    								   /************REOPEN all channels Rixtronix LAB 4May2022*************/
    								   
    								     err_code=sd_ant_channel_open(HRM_CHANNEL_NUM);
    								       

    It's stable,

    Any clues on solving it ?

    Regards,

    Rixtronix

Reply Children
  • "Restarting"/"crashing" etc simply means that an api call have returned an error code, and that the code jumped to the fault handler, by default the fault handler is setup to execute a system reset, my suggestion is to build with DEBUG and look at the fault handler to find the file name, line number and error code that caused the assert.

    Kenneth

  • 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

Related