ANT example ant_continuous_scanning_controller(SDK 17.0.2) problem

Dear Members,

The project I'm working on now requires searching for nearby ANT+ devices and then using a table to choose which device to pair with.

These ANT+ devices include: BPWR,BSC,HRM devices. 

So,I first practice with example ant_continuous_scanning_controller(SDK 17.0.2, SoftDevice S212 ). Test with SimulANT+ (Version 2.3.0.0). Open 2 BPWR devices at the same time, But it can't find any device normally.

bpwr  device:

I press button ,It always shows up p_ant_evt->event: 0x00000007(EVENT_CHANNEL_CLOSED).

I try to change the setting of sdk_config.h, But it still doesn't work.

 

//==========================================================
// <o> ANT_NETWORK_NUM - Network number. 
#ifndef ANT_NETWORK_NUM
#define ANT_NETWORK_NUM 0
#endif

// <o> ANT_RESPONSE_CHANNEL_NUMBER - ANT response channel number. 
#ifndef ANT_RESPONSE_CHANNEL_NUMBER
#define ANT_RESPONSE_CHANNEL_NUMBER 1
#endif

// <o> ANT_SCAN_CHANNEL_NUMBER - ANT scan channel number. 
#ifndef ANT_SCAN_CHANNEL_NUMBER
#define ANT_SCAN_CHANNEL_NUMBER 0
#endif

// <o> CHAN_ID_DEV_TYPE - Channel ID: Device Type. 
#ifndef CHAN_ID_DEV_TYPE
#define CHAN_ID_DEV_TYPE 11	// 1
#endif

// <o> CHAN_ID_TRANS_TYPE - Channel ID: Transmission type. 
#ifndef CHAN_ID_TRANS_TYPE
#define CHAN_ID_TRANS_TYPE 5	// 5	// 21
#endif

// <o> HOME_ID - Unique ID for the entire network. 
#ifndef HOME_ID
#define HOME_ID 4660
#endif

// <o> RF_FREQ - RF Frequency. 
#ifndef RF_FREQ
#define RF_FREQ 57	//0x39u	// 25
#endif

Also add ant_search_init(); to code,then change "search_priority" to highest , But it still doesn't work.

/**@brief initialize ant search // joe
 */
static void AntSearchInit(void)	// joe
{
	uint32_t err_code;
	ant_search_config_t init;
	init.channel_number = ANT_SCAN_CHANNEL_NUMBER;
	init.high_priority_timeout = ANT_DEFAULT_HIGH_PRIORITY_TIMEOUT;
	init.low_priority_timeout = ANT_DEFAULT_LOW_PRIORITY_TIMEOUT;
	init.search_priority = ANT_SEARCH_PRIORITY_HIGHEST;
	init.search_sharing_cycles = ANT_SEARCH_SHARING_CYCLES_DISABLE;
	init.waveform = ANT_WAVEFORM_FAST;
	
	err_code = ant_search_init(&init);
	APP_ERROR_CHECK(err_code);
}
/**@brief initialize application
 */
static void continuous_scan_init()
{
    uint32_t err_code;
	
	AntSearchInit();

    // Set library config to report RSSI and Device ID
    err_code = sd_ant_lib_config_set(
        ANT_LIB_CONFIG_MESG_OUT_INC_RSSI | ANT_LIB_CONFIG_MESG_OUT_INC_DEVICE_ID);
    APP_ERROR_CHECK(err_code);

    // Configure channel 0 for scanning mode, but do not open it.
    // The scanning channel will be opened in scan mode for a short amount of time on a button press.
    ant_channel_config_t channel_config =
    {
        .channel_number    = ANT_SCAN_CHANNEL_NUMBER,
        .channel_type      = CHANNEL_TYPE_SLAVE,
        .ext_assign        = 0x00,
        .rf_freq           = RF_FREQ,
        .transmission_type = CHAN_ID_TRANS_TYPE,
        .device_type       = CHAN_ID_DEV_TYPE,
        .device_number     = 0x00,          // Wildcard
        .channel_period    = 0x00,          // Not used, since this is going to be scanning
        .network_number    = ANT_NETWORK_NUM,
    };

    err_code = ant_channel_init(&channel_config);
    APP_ERROR_CHECK(err_code);
		
    // Assign a second channel for sending messages on the reverse direction
    // There is no need to configure any other parameters, this channel is never opened;
    // its resources are used by ANT to send messages in the reverse direction while in
    // continuous scanning mode.
    err_code = sd_ant_channel_assign(ANT_RESPONSE_CHANNEL_NUMBER,
                                     CHANNEL_TYPE_SLAVE,
                                     ANT_NETWORK_NUM,
                                     0x00);
    APP_ERROR_CHECK(err_code);
		
		
		
}

Please,how can I solve this problem?

Best regards,

Thanks!

Joe

Related