How to set the transmit gain for the Bluetooth communications?

I am using the nRF52840 and the pair of Nordic BLE UART Demo projects ble_app_uart_c_pca10056_s140 and ble_app_uart_pca10056_s140

Please can you tell me how to change the transmit gain to (+8dB) and specifically where in the demo code this instruction needs to be added?

I suspect that the correct function call is the sd_ble_gap_tx_power_set

However it is unclear what role parameter to apply, whether it needs to be called multiple times (once per role), and where in the demo code to add these instructions.

It is also unclear as to whether the Tx gain change instruction needs to just be added to the central, or also to the peripheral project code.

Thank you.

Parents
  • Hello,

    Please can you tell me how to change the transmit gain to (+8dB) and specifically where in the demo code this instruction needs to be added?

    I suspect that the correct function call is the sd_ble_gap_tx_power_set

    You are correct that this is set by the call to sd_ble_gap_tx_power_set. This should be done as part of your advertising initialization - after you've initialized your advertising, and before advertising starts.

    However it is unclear what role parameter to apply, whether it needs to be called multiple times (once per role), and where in the demo code to add these instructions.

    As mentioned in the API Reference documentation the roles can be either of BLE_GAP_TX_POWER_ROLES, and the power level set for a specific role will be inherited by the the connection.

    It is also unclear as to whether the Tx gain change instruction needs to just be added to the central, or also to the peripheral project code.

    It must be added on both sides separately.

    Best regards,
    Karl

  • Thank you.
    I agree that it seems logical to set the BLE_GAP_TX_POWER_ROLE_ADV power setting after you've initialized your advertising, and before advertising starts, but what to do about the other two roles BLE_GAP_TX_POWER_ROLE_SCAN_INIT  and BLE_GAP_TX_POWER_ROLE_CONN  ?

    Only the Peripheral does advertising, so only that project would contain the call to change the BLE_GAP_TX_POWER_ROLE_ADV setting.
    However, you also said that the Tx gain change needs to be added on both sides separately (i.e. also in the Central project, which does not advertise), so how does that work?

    Should I be setting the BLE_GAP_TX_POWER_ROLE_SCAN_INIT  setting in the Central project? If so, is this done before calling nrf_ble_scan_init, or after that, but before calling nrf_ble_scan_filters_enable ?

    Where do I change the setting for the BLE_GAP_TX_POWER_ROLE_CONN  role? In both projects?

    I note that the documentation says that "When a connection is created it will inherit the transmit power from the initiator or advertiser leading to the connection". This makes it unclear as to what the point of setting the BLE_GAP_TX_POWER_ROLE_SCAN_INIT  power is, if the Central it is just going to listen to the advertiser and then inherit that power setting from it.

    Can the BLE_GAP_TX_POWER_ROLE_CONN  be changed during an active connection to compensate for changes in RSSI?

    Sadly, the documentation just provides a list of enum names, but a list does not convey any clear explanation to the reader or give any instructions regarding what to do with them.

Reply
  • Thank you.
    I agree that it seems logical to set the BLE_GAP_TX_POWER_ROLE_ADV power setting after you've initialized your advertising, and before advertising starts, but what to do about the other two roles BLE_GAP_TX_POWER_ROLE_SCAN_INIT  and BLE_GAP_TX_POWER_ROLE_CONN  ?

    Only the Peripheral does advertising, so only that project would contain the call to change the BLE_GAP_TX_POWER_ROLE_ADV setting.
    However, you also said that the Tx gain change needs to be added on both sides separately (i.e. also in the Central project, which does not advertise), so how does that work?

    Should I be setting the BLE_GAP_TX_POWER_ROLE_SCAN_INIT  setting in the Central project? If so, is this done before calling nrf_ble_scan_init, or after that, but before calling nrf_ble_scan_filters_enable ?

    Where do I change the setting for the BLE_GAP_TX_POWER_ROLE_CONN  role? In both projects?

    I note that the documentation says that "When a connection is created it will inherit the transmit power from the initiator or advertiser leading to the connection". This makes it unclear as to what the point of setting the BLE_GAP_TX_POWER_ROLE_SCAN_INIT  power is, if the Central it is just going to listen to the advertiser and then inherit that power setting from it.

    Can the BLE_GAP_TX_POWER_ROLE_CONN  be changed during an active connection to compensate for changes in RSSI?

    Sadly, the documentation just provides a list of enum names, but a list does not convey any clear explanation to the reader or give any instructions regarding what to do with them.

Children
  • Nicholas Lee said:
    what to do about the other two roles BLE_GAP_TX_POWER_ROLE_SCAN_INIT  and BLE_GAP_TX_POWER_ROLE_CONN  ?
    Nicholas Lee said:
    Only the Peripheral does advertising, so only that project would contain the call to change the BLE_GAP_TX_POWER_ROLE_ADV setting.
    However, you also said that the Tx gain change needs to be added on both sides separately (i.e. also in the Central project, which does not advertise), so how does that work?
    Nicholas Lee said:
    Should I be setting the BLE_GAP_TX_POWER_ROLE_SCAN_INIT  setting in the Central project? If so, is this done before calling nrf_ble_scan_init, or after that, but before calling nrf_ble_scan_filters_enable ?

    Yes, as mentioned in the enumeration documentation the SCAN_INIT role is the role of the scanning and initiator device (central) while the CONN role is for a specific connection. I.e, if you are scanning for a device and intend to connect to it (that will inherit the power level) you use the SCAN_INIT role.
    If you wish to change the TXPOWER of an existing connection, you would use the CONN role.
    You could then set the TX power level at the end of your initialization, before you begin the scan.

    Nicholas Lee said:
    Where do I change the setting for the BLE_GAP_TX_POWER_ROLE_CONN  role? In both projects?

    A connection inherits the power level set for the SCAN_INIT and PERIPHERAL role, so there is no need to set it for the CONN as well.

    Nicholas Lee said:
    This makes it unclear as to what the point of setting the BLE_GAP_TX_POWER_ROLE_SCAN_INIT  power is, if the Central it is just going to listen to the advertiser and then inherit that power setting from it.

    The scanner does not know what power level the peripheral is transmitting with unless it includes it in its advertising info. There is no default option to have the central just follow peripheral's TXPOWER either.

    Nicholas Lee said:
    Can the BLE_GAP_TX_POWER_ROLE_CONN  be changed during an active connection to compensate for changes in RSSI?

    You can change the TX power while in a connection, yes. This is actually coming in BLE 5.2 through the LE Power Control feature. Unfortunately, this feature is not supported by the SoftDevices currently. You may implement this yourself though - changing the power level in case of an RSSI drop, for example, or lowering the power level in case the RSSI is steadily high.

    Nicholas Lee said:
    Sadly, the documentation just provides a list of enum names, but a list does not convey any clear explanation to the reader or give any instructions regarding what to do with them.

    I am sorry to hear that. Please do not hesitate to ask if anything still should be unclear, or if you have any other questions!

    Best regards,
    Karl

Related