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

Advertising packets power

I am interested in setting the tx power level the advertising packets in a nRF52832 are transmitted with. I saw there is the TXPOWER register in the RADIO section (address 0x40001000 + 0x50C) that sets the "Output power". My questions are:

  1. Is there any specific mechanism in the nRF5 SDK (v11.0.0) to set the tx power and, more specifically, the tx power of the advertising data?

  2. Otherwise, is it safe to manually change the value of the TXPOWER register, dinamically and as needed? For example, advertise at -20 dBm and switch to 4 dBM after a connection request is received. Will that actually change the TX power or do I need to initialize the BLE library again or stuff?

Parents
  • Hi,

    Since you're enabling and using the SoftDevice, the RADIO peripheral is blocked seen from the application point-of-view. You can change the output power by calling this softdevice GAP function:

    err_code = sd_ble_gap_tx_power_set(tx_power);

    To ensure that a connection has a given TX_POWER you can do something like this in the main ble-event handler:

    static void on_ble_evt(ble_evt_t * p_ble_evt)
    {
        uint32_t                         err_code;
        
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_CONNECTED:
                ....
                err_code = sd_ble_gap_tx_power_set(connection_tx_power);
                break;
            case BLE_GAP_EVT_DISCONNECTED:
                ....
                err_code = sd_ble_gap_tx_power_set(adv_tx_power);
                break;
        /* Rest of events and handling */
        }
    }
    

    Cheers, Håkon

Reply
  • Hi,

    Since you're enabling and using the SoftDevice, the RADIO peripheral is blocked seen from the application point-of-view. You can change the output power by calling this softdevice GAP function:

    err_code = sd_ble_gap_tx_power_set(tx_power);

    To ensure that a connection has a given TX_POWER you can do something like this in the main ble-event handler:

    static void on_ble_evt(ble_evt_t * p_ble_evt)
    {
        uint32_t                         err_code;
        
        switch (p_ble_evt->header.evt_id)
        {
            case BLE_GAP_EVT_CONNECTED:
                ....
                err_code = sd_ble_gap_tx_power_set(connection_tx_power);
                break;
            case BLE_GAP_EVT_DISCONNECTED:
                ....
                err_code = sd_ble_gap_tx_power_set(adv_tx_power);
                break;
        /* Rest of events and handling */
        }
    }
    

    Cheers, Håkon

Children
Related