First message from ANT sensor ?

Dear Members,

Can we do this to capture the first message from ANT transmitter ?

void ant_bsc_disp_evt_handler(ant_evt_t * p_ant_evt, void * p_context)
{
    ant_bsc_profile_t * p_profile = (ant_bsc_profile_t *)p_context;
    NRF_LOG_INFO("ant_bsc_disp_evt_handler\r\n"); 
    if (p_ant_evt->channel == p_profile->channel_number)
    {
        switch (p_ant_evt->event)
        {
            case EVENT_RX:
                if (p_ant_evt->message.ANT_MESSAGE_ucMesgID == SEQUENCE_FIRST_MESSAGE)
								 {
								   1st message;
								 }

Kind regards,

Rixtronix LAB

Parents
  • Hi Sigurd, thanks for the reply,

    Will it be :

    #define MESG_BURST_DATA_ID                   ((uint8_t)0x50) ///< ANT stack - burst message ID

    == 1 ?

    Pseudo code :

     void ant_bsc_disp_evt_handler(ant_evt_t * p_ant_evt, void * p_context)
    {
        ant_bsc_profile_t * p_profile = (ant_bsc_profile_t *)p_context;
        NRF_LOG_INFO("ant_bsc_disp_evt_handler\r\n"); 
        if (p_ant_evt->channel == p_profile->channel_number)
        {
            switch (p_ant_evt->event)
            {
                case EVENT_RX:
     
     if (p_ant_evt->message.ANT_MESSAGE_ucMesgID.MESG_BURST_DATA_ID==1).............
    								 {
    									 //
    									 NRF_LOG_INFO("MESG_BURST_DATA_ID==1!\r\n");
    									 NRF_LOG_INFO("First message from sensor!\r\n"); 
    								 }	
    								 .
    								 .
    								 .

    Kind regards,

    Rixtronix

  • RixtronixLAB said:

    Will it be :

    #define MESG_BURST_DATA_ID                   ((uint8_t)0x50) ///< ANT stack - burst message ID

    == 1 ?

    That does not look valid. If ANT_MESSAGE_ucMesgID is equal to MESG_BURST_DATA_ID(0x50), then it's a burst message.

  • Hi Sigurd,

    Thanks for the reply,

    How can we decide that it is the first message from the sensor ?

    If ANT_MESSAGE_ucMesgID = ??

    Kind regards,

    Rixtronix

  • Take a look at how it's done in SDK_folder\examples\ant\ ant_advanced_burst.c

    Snippet:

    /**@brief Function to handle received burst data
     *
     * @param[in] p_burst_message  Buffer containing burst message, including channel/sequence number.
     */
    static void burst_data_process(uint8_t * p_burst_message)
    {
        // If this is the first packet
        if ((p_burst_message[0] & SEQUENCE_NUMBER_MASK) == SEQUENCE_FIRST_MESSAGE)
        {
            bsp_board_led_on(BSP_BOARD_LED_0);  // Turn on LED 0 to indicate burst started
            bsp_board_led_off(BSP_BOARD_LED_1); // Clear error indication
            m_burst_rx = true;
        }
        else if ((p_burst_message[0] & SEQUENCE_LAST_MESSAGE) != 0) // If this is the last packet
        {
            bsp_board_led_off(BSP_BOARD_LED_0);   // Turn off LED 0 to indicate burst ended
            m_burst_rx = false;
        }
        // The burst data is available in p_burst_message[1] to p_burst_message[8]
    }

  • Hi Sigurd and Members,

    Thanks for the reply,

    We got "SEQUENCE_FIRST_MESSAGE" but it's repeating for every messages, have a look on the output :

    <info> ant_bsc: p_ant_evt->message.ANT_MESSAGE_ucMesgID 0x4E
    
    <info> nrf_sdh_ant: ANT Event 0x80 Channel 0x01 Message 0x20007E34 Checksum 0x03 
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ulForceAlign 0x7D014E09
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucSize 0x09
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucFramedData 0x20007E35
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucMesgID 0x4E
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucMesgData 0x20007E36
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucChannel 0x01
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucSubID 0x01
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucPayload 0x20007E37
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucExtMesgBF  0x00
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucExtData  0x20007E40
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucCheckSum  0x03
    
    <info> ant_bsc: ant_bsc_disp_evt_handler
    
    
    
    <info> ant_bsc: p_ant_evt->message.ANT_MESSAGE_ucMesgID 0x4E
    
    <info> ant_bsc: If this is the first packet SEQUENCE_FIRST_MESSAGE
    
    
    
    <info> ant_bsc: BSC RX Page Number: "Combined Speed & Cadence Page"
    
    <info> ant_bcs_combined_page_0: Cadence Revolution count: 36153
    
    <info> ant_bcs_combined_page_0: Cadence event time:       16.122s
    
    <info> ant_bcs_combined_page_0: Speed Revolution count:   54392
    
    <info> ant_bcs_combined_page_0: Speed event time:         0.306s
    
    
    
    
    <info> app: Manufacturer ID:     BSC_COMB_PAGE_0      0
    
    <info> app: Serial No:        BSC_COMB_PAGE_0   0
    
    <info> app: rev_cnt : 54392
    
    
    
    <info> app: Computed speed value:                         1325913 kph
    
    <info> app: rev_cnt : 54392
    
    
    
    Speed in float 1325913.000 
    <info> app: rev_cnt : 54392
    
    
    
    <info> app: rev_cnt : 54392
    
    
    
    <info> app: Speed value sample average :  0 
    
    
    <info> app: Speed value sample minimum :  0 
    
    
    <info> app: Speed value sample maximum :  0 
    
    
    <info> app: Computed cadence value:                       4294841685 rpms
    
    <info> app: Cadence value sample average :  85 
    
    
    <info> app: Cadence value sample minimum :  85 
    
    
    <info> app: Cadence value sample maximum :  85 
    
    
    <info> ant_bsc: p_ant_evt->message.ANT_MESSAGE_ucMesgID 0x4E
    
    <info> nrf_sdh_ant: ANT Event 0x09 Channel 0x01 Message 0x20007E6C Checksum 0x03 
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ulForceAlign 0x1014003
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucSize 0x03
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucFramedData 0x20007E6D
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucMesgID 0x40
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucMesgData 0x20007E6E
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucChannel 0x01
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucSubID 0x01
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucPayload 0x20007E6F
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucExtMesgBF  0x00
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucExtData  0x20007E78
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucCheckSum  0x03
    
    <info> ant_bsc: ant_bsc_disp_evt_handler
    
    
    
    <info> nrf_sdh_ant: ANT Event 0x80 Channel 0x01 Message 0x20007E74 Checksum 0x03 
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ulForceAlign 0x7D014E09
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucSize 0x09
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucFramedData 0x20007E75
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucMesgID 0x4E
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucMesgData 0x20007E76
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucChannel 0x01
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucSubID 0x01
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucPayload 0x20007E77
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucExtMesgBF  0x00
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucExtData  0x20007E80
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucCheckSum  0x03
    
    <info> ant_bsc: ant_bsc_disp_evt_handler
    
    
    
    <info> ant_bsc: p_ant_evt->message.ANT_MESSAGE_ucMesgID 0x4E
    
    <info> ant_bsc: If this is the first packet SEQUENCE_FIRST_MESSAGE
    
    
    
    <info> ant_bsc: BSC RX Page Number: "Combined Speed & Cadence Page"
    
    <info> ant_bcs_combined_page_0: Cadence Revolution count: 36153
    
    <info> ant_bcs_combined_page_0: Cadence event time:       16.122s
    
    <info> ant_bcs_combined_page_0: Speed Revolution count:   54396
    
    <info> ant_bcs_combined_page_0: Speed event time:         49.134s
    
    
    
    
    <info> app: Manufacturer ID:     BSC_COMB_PAGE_0      0
    
    <info> app: Serial No:        BSC_COMB_PAGE_0   0
    
    <info> app: rev_cnt : 54396
    
    
    
    <info> app: m_speed_calc_data.acc_rev_cnt value : 54396 
    
    
    
    <info> app: rev_cnt_start value : 20 
    
    
    
    <info> app: Distance : 108752 m
    
    
    
    <info> app: Distance km: 108.75 km
    
    
    
    <info> app: Time : 50313 mS
    
    
    
    <info> app: Time : 50 S
    
    
    
    <info> app: Float number: 2175.04
    
    
    
    <info> app: Avg m/s: 2175.04 m/s
    
    
    
    <info> app: Avg km/h: 7830.14 km/h
    
    
    
    <info> app: Computed speed value:                         0 kph
    
    <info> app: rev_cnt : 54396
    
    
    
    Speed in float 0.000 
    <info> app: rev_cnt : 54396
    
    
    
    <info> app: rev_cnt : 54396
    
    
    
    <info> app: Speed value sample average :  0 
    
    
    <info> app: Speed value sample minimum :  0 
    
    
    <info> app: Speed value sample maximum :  0 
    
    
    <info> app: Computed cadence value:                       4294841685 rpms
    
    <info> app: Cadence value sample average :  85 
    
    
    <info> app: Cadence value sample minimum :  85 
    
    
    <info> app: Cadence value sample maximum :  85 
    
    
    <info> ant_bsc: p_ant_evt->message.ANT_MESSAGE_ucMesgID 0x4E
    
    <info> nrf_sdh_ant: ANT Event 0x80 Channel 0x01 Message 0x20007DF4 Checksum 0x03 
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ulForceAlign 0x7D014E09
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucSize 0x09
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucFramedData 0x20007DF5
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucMesgID 0x4E
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucMesgData 0x20007DF6
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucChannel 0x01
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucSubID 0x01
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucPayload 0x20007DF7
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucExtMesgBF  0x00
    
    <info> nrf_sdh_ant: ANT_MESSAGE_aucExtData  0x20007E00
    
    <info> nrf_sdh_ant: ANT_MESSAGE_ucCheckSum  0x03
    
    <info> ant_bsc: ant_bsc_disp_evt_handler
    
    
    
    <info> ant_bsc: p_ant_evt->message.ANT_MESSAGE_ucMesgID 0x4E
    
    <info> ant_bsc: If this is the first packet SEQUENCE_FIRST_MESSAGE
    

    The code :

    at main.c
    static void softdevice_setup(void)
    {
    	/*******************advance burst setup 8Aug22 Rixtronix LAB BEGIN**********************/
    	 uint8_t adv_burst_config[] =
        {
            ADV_BURST_MODE_ENABLE,
            ADV_BURST_MODES_MAX_SIZE,
            0,
            0,
            0,
            0,
            0,
            0
        };
    	/*******************advance burst setup 8Aug22 Rixtronix LAB BEGIN**********************/
    	  //NRF_LOG_INFO("softdevice_setup main\r\n");
        ret_code_t err_code = nrf_sdh_enable_request();
    	  APP_ERROR_CHECK(err_code);
        ASSERT(nrf_sdh_is_enabled());
    	
    	
    	  /*******************advance burst setup 8Aug22 Rixtronix LAB BEGIN**********************/
    	   err_code = sd_ant_adv_burst_config_set(adv_burst_config, sizeof(adv_burst_config));
          APP_ERROR_CHECK(err_code);
    	  /*******************advance burst setup 8Aug22 Rixtronix LAB END**********************/
    
    ...
    the event handler at ant_bsc.c
    
    /**@brief Function to handle received burst data
     *
     * @param[in] p_burst_message  Buffer containing burst message, including channel/sequence number.
     *  Rixtronix LAB 8 Aug 22
     */
    static void burst_data_process(uint8_t * p_burst_message)
    {
        // If this is the first packet
        if ((p_burst_message[0] & SEQUENCE_NUMBER_MASK) == SEQUENCE_FIRST_MESSAGE)
        {
            
    			  NRF_LOG_INFO("If this is the first packet SEQUENCE_FIRST_MESSAGE\r\n");	//8Aug22 Rixtronix LAB	
            
        }
        else if ((p_burst_message[0] & SEQUENCE_LAST_MESSAGE) != 0) // If this is the last packet
        {
            
    			  NRF_LOG_INFO("If this is the last packet \r\n");	//8Aug22 Rixtronix LAB	
            
        }
        // The burst data is available in p_burst_message[1] to p_burst_message[8]
    }
    
    void ant_bsc_disp_evt_handler(ant_evt_t * p_ant_evt, void * p_context)
    {
        ant_bsc_profile_t * p_profile = (ant_bsc_profile_t *)p_context;
    	  uint8_t p_burst_message[BURST_PACKET_TOTAL_SIZE];
    	
        NRF_LOG_INFO("ant_bsc_disp_evt_handler\r\n"); 
        if (p_ant_evt->channel == p_profile->channel_number)
        {
            switch (p_ant_evt->event)
            {
                case EVENT_RX:
    							  /*********************DEBUG THE message Rixtronix LAB 4Aug22*****************/
    						
    						      NRF_LOG_INFO("p_ant_evt->message.ANT_MESSAGE_ucMesgID 0x%02X", p_ant_evt->message.ANT_MESSAGE_ucMesgID);   
    						    p_burst_message[0] = p_ant_evt->message.ANT_MESSAGE_ucChannel;
                        memcpy(&p_burst_message[1],
                               p_ant_evt->message.ANT_MESSAGE_aucPayload,
                               BURST_PACKET_SIZE);
                        m_sequence_number =
                            SEQUENCE_NUMBER_MASK & p_ant_evt->message.ANT_MESSAGE_ucChannel;
    						    burst_data_process(p_burst_message);//Rixtronix LAB 8Aug22 SEQUENCE_FIRST_MESSAGE
                    
    
    

    Can you help us ?

    Await for your reply,

    Kind regards,

    Rixtronix

Reply Children
No Data
Related