Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

setting up ANT+ as display

Hello,

I'm developing FW based on nRF52832, SDK 17.1.0 and SD S332. I need to set up ANT+ comunication to use my device as a display for LEV profile (I started modifying the HRM RX example).

ANT+_Device_Profile_-_LEV_Rev_1.1.pdf

I setted up al the ANT+ (as for another project) but I cant figure out how to check communication: I'm using SimulANT+ software by ThiIsAnt, broadcasting LEV profile data, but I can't see anything on my device. Also the ANT event handler is never called.

Here it is my init routine:

/**					Source file #include												**/
#include <nrf_log.h>
#include <nrf_log_ctrl.h>
#include <nrf_log_default_backends.h>

#include <nrf_sdh.h>
#include <nrf_sdh_ant.h>
#include <ant_channel_config.h>
#include <ant_key_manager.h>
#include <ant_interface.h>


// LEV profile structure.
typedef __packed struct ant_sh_profile_s {
	uint8_t				channel_number;		// Channel number assigned to the profile.
	ant_sh_page1_t		page_1;					// page 1
	ant_sh_page2_t		page_2;					// page 2
	ant_sh_page3_t		page_3;					// page 3
	ant_sh_page4_t		page_4;					// page 4
	ant_sh_page5_t		page_5;					// page 5
	ant_sh_page16_t	page_16;					// page 16
	ant_sh_page34_t	page_34;					// page 34
	ant_sh_page70_t	page_70;					// page 70
	ant_sh_page80_t	page_80;					// page 80
	ant_sh_page81_t	page_81;					// page 81
} ant_sh_profile_t;


/**					Internal Variable Declaration									**/
static ant_sh_profile_t m_ant_sh;


/**					Internal Function Prototypes									**/
void ant_sh_evt_handler( ant_evt_t *p_ant_evt, void *p_context );


/**					Library Functions													**/

/*  */
void vInit_ANT( void ) {
	ret_code_t err_code;
	NRF_SDH_ANT_OBSERVER( m_ant_observer, 1, ant_sh_evt_handler, &m_ant_sh );
	err_code = nrf_sdh_ant_enable();
	APP_ERROR_CHECK( err_code );
	err_code = ant_plus_key_set( ANTPLUS_NETWORK_NUM );
	APP_ERROR_CHECK( err_code );
	// Initialize an ANT channel configuration structure for the SH profile (Sensor).
	static ant_channel_config_t ant_channel_config = {
		.channel_number		= 0x00,									// Number of the channel assigned to the profile instance.
		.channel_type			= CHANNEL_TYPE_SLAVE,
		.ext_assign				= 0x00,									// Extended Assign Channel Parameters
		.rf_freq					= 0x39u,									// RF Channel 57 (2457MHz) is used for the ANT+ LEV.,
		.transmission_type	= 0,										// The transmission type must be set to 0 for a pairing search.
		.device_type			= 0x14u,									// An LEV device shall transmit its device type as 20 (0x14).
		.device_number			= 123456,								// Channel ID: Device Number.
		.channel_period		= ANT_MSG_PERIOD_4Hz,
		.network_number		= ANTPLUS_NETWORK_NUM,				// Number of the network assigned to the profile instance.
	};
	err_code = ant_channel_init( &ant_channel_config );
	APP_ERROR_CHECK( err_code );
	err_code = sd_ant_channel_open( ant_channel_config.channel_number );
	APP_ERROR_CHECK( err_code );
	return;
}

/*  */
static void ant_sh_evt_handler( ant_evt_t *p_ant_evt, void *p_context ) {
	ant_sh_profile_t *p_profile = ( ant_sh_profile_t * )p_context;

	if( p_ant_evt->channel == p_profile->channel_number ) {
		NRF_LOG_RAW_INFO( "%6ums\t%s(): evt= %u\tch= %u\t", xTaskGetTickCount(), __func__, p_ant_evt->event, p_ant_evt->channel );

		switch( p_ant_evt->event ) {
			case EVENT_TX:													// ANT stack generated event when synchronous tx channel has occurred
				NRF_LOG_RAW_INFO( "ANT TX event\n" );
				break;

			case EVENT_RX_SEARCH_TIMEOUT:								// ANT stack generated event when rx searching state for the channel has timed out
				NRF_LOG_RAW_INFO( "ANT RX search timeout\n" );
				break;

			case EVENT_CHANNEL_CLOSED:									// ANT stack generated event when channel has closed
				NRF_LOG_RAW_INFO( "ANT channel closed\n" );
				break;

			default:
				NRF_LOG_RAW_INFO( "UNMANAGED ANT CASE= 0x%04X\n", p_ant_evt->event );
				break;
		}
	}

	else {
		NRF_LOG_RAW_INFO( "UNMANAGED CHANNEL= %u\n", p_profile->channel_number );
	}
}

Please can you help me?

Thanks!

Related