set gap parameters 2M Phy

i am working on current consumption in nrf52832 sdk 17.2. 

i have found 2M phy reduces the energy consumption as compared to 1M phy.

i want to set 2M phy GAP aparameter for advertising mode na dalso for connection gatt mode. how to do this pls assist.

 */
static void advertising_init(){
    ret_code_t             err_code;
    ble_advertising_init_t init;

    memset(&init, 0, sizeof(init));

    init.advdata.name_type                = BLE_ADVDATA_FULL_NAME;
    init.advdata.include_appearance       = true;
    init.advdata.flags                    = BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
   
		init.srdata.uuids_more_available.uuid_cnt=sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
		init.srdata.uuids_more_available.p_uuids =m_adv_uuids;
    init.config.ble_adv_whitelist_enabled = false;
    init.config.ble_adv_fast_enabled      = true;
    init.config.ble_adv_fast_interval     = APP_ADV_INTERVAL;
    init.config.ble_adv_fast_timeout      = APP_ADV_DURATION;
    
    init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&m_advertising, &init);
    APP_ERROR_CHECK(err_code);
    uint32_t err_code = sd_ble_gap_tx_power_set(BLE_GAP_TX_POWER_ROLE_ADV, m_advertising.adv_handle, 4); 
    APP_ERROR_CHECK(err_code);
    ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
		
		
		
		
		
}

Parents Reply
  • Hi,

    Call it in the BLE_GAP_EVT_CONNECTED event, in the ble_evt_handler() function.

    Snippet:

            case BLE_GAP_EVT_CONNECTED:
                NRF_LOG_INFO("Connected.");
                err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
                APP_ERROR_CHECK(err_code);
                m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
                err_code = nrf_ble_qwr_conn_handle_assign(&m_qwr, m_conn_handle);
                APP_ERROR_CHECK(err_code);
    
                NRF_LOG_INFO("PHY update requested.");
                ble_gap_phys_t const phys =
                {
                    .rx_phys = BLE_GAP_PHY_2MBPS,
                    .tx_phys = BLE_GAP_PHY_2MBPS,
                };
                err_code = sd_ble_gap_phy_update(p_ble_evt->evt.gap_evt.conn_handle, &phys);
                APP_ERROR_CHECK(err_code);
    
                break;

Children
Related