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

Allowing connections, then switching to connection-less.

I need to allow BLE connections for a period of time after restart, then prevent connections (unless a button is pressed).  Is this functionality as simple as re-configuring the advertising parameters to use (  BLE_GAP_ADV_TYPE_ADV_NONCONN_IND ).

Also, I am using scan responses.  Do I need to use BLE_GAP_ADV_TYPE_ADV_NONCONN_IND instead, and will this prevent connections.  I've seen it mentioned in other forum threads but the documentation is not clear whether this allows connections or not.

Is there anything else I need to do to start preventing connections in the code.

Parents
  • Yes, but what it looks like depends on what SDK you use.

    If you look at the beacon example in SDK 15 for example, it is configured like this:

    static void advertising_init(void)
    {
        ....
    
        // Initialize advertising parameters (used when starting advertising).
        memset(&m_adv_params, 0, sizeof(m_adv_params));
    
        m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
        m_adv_params.p_peer_addr     = NULL;    // Undirected advertisement.
        m_adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
        m_adv_params.interval        = NON_CONNECTABLE_ADV_INTERVAL;
        m_adv_params.duration        = 0;       // Never time out.
    
        err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
    
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
        APP_ERROR_CHECK(err_code);
    }

    You can see that in SDK 15 BLE_GAP_ADV_TYPE_ADV_SCAN_IND has been renamed to BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED. 

     

Reply
  • Yes, but what it looks like depends on what SDK you use.

    If you look at the beacon example in SDK 15 for example, it is configured like this:

    static void advertising_init(void)
    {
        ....
    
        // Initialize advertising parameters (used when starting advertising).
        memset(&m_adv_params, 0, sizeof(m_adv_params));
    
        m_adv_params.properties.type = BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED;
        m_adv_params.p_peer_addr     = NULL;    // Undirected advertisement.
        m_adv_params.filter_policy   = BLE_GAP_ADV_FP_ANY;
        m_adv_params.interval        = NON_CONNECTABLE_ADV_INTERVAL;
        m_adv_params.duration        = 0;       // Never time out.
    
        err_code = ble_advdata_encode(&advdata, m_adv_data.adv_data.p_data, &m_adv_data.adv_data.len);
        APP_ERROR_CHECK(err_code);
    
        err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &m_adv_data, &m_adv_params);
        APP_ERROR_CHECK(err_code);
    }

    You can see that in SDK 15 BLE_GAP_ADV_TYPE_ADV_SCAN_IND has been renamed to BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED. 

     

Children
No Data
Related