This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

need to configure ble_adv_modes_config_t for Fast advertising not requiring connection

I am advertising a service and providing scan response data. It is not clear to me whether I should be bothering setting up the values of the ble_adv_modes_config_t structure. Please clarify. As presented everything is working.

static void advertising_init(void)
{
    ret_code_t             err_code;
    ble_advdata_t          advdata;
    ble_adv_modes_config_t options;

    // Build advertising data struct to pass into @ref ble_advertising_init.
    memset(&advdata, 0, sizeof(advdata));

    advdata.name_type               = BLE_ADVDATA_FULL_NAME;
    //advdata.include_appearance      = true;
    advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    advdata.uuids_complete.p_uuids  = m_adv_uuids;

    memset(&options, 0, sizeof(options));
    options.ble_adv_whitelist_enabled		= false;	/**< Enable or disable use of the whitelist. */
    options.ble_adv_directed_enabled		= false;	/**< Enable or disable direct advertising mode. */
    options.ble_adv_directed_slow_enabled	= false;	/**< Enable or disable direct advertising mode. */
    options.ble_adv_fast_enabled  			= true;		/**< Enable or disable fast advertising mode. */
    options.ble_adv_slow_enabled			= false;	/**< Enable or disable slow advertising mode. */


    options.ble_adv_fast_interval = APP_ADV_INTERVAL;
    options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;

    err_code = ble_advertising_init(&advdata, NULL, &options, on_adv_evt, NULL);
    APP_ERROR_CHECK(err_code);
}

#define APP_CFG_NON_CONN_ADV_TIMEOUT    0                                 /**< Time for which the device must be advertising in non-connectable mode (in seconds). 0 disables timeout. */
#define NON_CONNECTABLE_ADV_INTERVAL    MSEC_TO_UNITS(100, UNIT_0_625_MS) /**< The advertising interval for non-connectable advertisement (100 ms). This value can vary between 100ms to 10.24s). */

/**@brief Function for starting advertising.
 */
static void advertising_start(void)
{
    // Initialize advertising parameters (used when starting advertising).
	ble_gap_adv_params_t m_adv_params;
    memset(&m_adv_params, 0, sizeof(m_adv_params));

    m_adv_params.type			= BLE_GAP_ADV_TYPE_ADV_SCAN_IND; 	//BLE_GAP_ADV_TYPE_ADV_NONCONN_IND;
    m_adv_params.p_peer_addr 	= NULL;								// Undirected advertisement.
    m_adv_params.fp				= BLE_GAP_ADV_FP_ANY; 				/**< Allow scan requests and connect requests from any device. */
    m_adv_params.interval		= NON_CONNECTABLE_ADV_INTERVAL; 	// setting the advertising interval to 100ms.
    m_adv_params.timeout		= APP_CFG_NON_CONN_ADV_TIMEOUT; 	// this define is 0, meaning that advertising will never timeout.

    ret_code_t err_code = sd_ble_gap_adv_start(&m_adv_params, BLE_CONN_CFG_TAG_DEFAULT);
    APP_ERROR_CHECK(err_code);

Related