This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2340R5: TX POWER UPDATION DYNAMICALLY

Part Number: CC2340R5
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hi, 

I am updating the tx power of my peripheral device dynamically .

In the sysconfig, under radio section it is set as default tx power value. In the advertisement parameters it is set as tx power value as 0.

Only based on certain conditions, I will change the tx power to maximum and once that condition is met I will move back to 0 again.

My only concern is I am able to change the advertisement parameter using the below code

        uint8_t txPower = 8;
        GapAdv_setParam(GAP_ADV_PARAM_TX_POWER, &txPower);

 But how will I modify the radio section of sysconfig dynamically through code because by default it is set as 0.

  • Hello Satakshi,

    Thank you for reaching out! Sysconfig runs at compile time, so it sets the initial value, however once you change the value at run time (i.e. through code) you won't need to change the Sysconfig file anymore. So by simply running the GAPADV_setParam function, you'll be able to change the value of TX Power. I hope this helps!

    Best Regards,

    Tarek

  • Hi Tarek,

    Thanks a lot for the clarification. I have few more doubts.

    I have my code as below:

    void connectionEventHandler(uint32 event, BLEAppUtil_msgHdr_t *pMsgData)
    {
    gapCbData_t connEvtData = {0};
    switch (event)
    {
    case BLEAPPUTIL_LINK_ESTABLISHED_EVENT:
    {
    connEvtData.evt = BT_EVT_CONNECT;
    connEvtData.error = ERR_SUCCESS;
    pfnGapCb(connEvtData);
    BLEAppUtil_advStop(peripheralAdvHandle_1);
    uint8_t txPower = 8;
    GapAdv_setParam(GAP_ADV_PARAM_TX_POWER, &txPower);
    break;
    }
    case BLEAPPUTIL_LINK_TERMINATED_EVENT:
    {
    Log_message(LOG_INFO, "device is disconnected");
    BLEAppUtil_advStart(peripheralAdvHandle_1, &advSetStartParamsSet_1);
    break;
    }
    default:
    {
    Log_message(LOG_ERROR,"unhandled peripheral event");
    break;
    }
    }
    }

    When connection is established, I updated the tx power and when disconnection happens, it should take the updated tx power right but its not getting updated. It is still showing 0dBm in nRF connect app when I am checking it. Or tx power is changing but since I have set 0 in adv data section and scan response data section it still shows 0 dbM but actually it is increased?

    In the documentation it is mentioned as

    @warning In order to set this parameter, @ref GAP_ADV_PARAM_PROPS must
    * be set to include @ref GAP_ADV_PROP_TX_POWER

    I am not able to understand how to include tx power in the GAP_ADV_PARAM_PROPS. In the sysconfig, I am not able to do so. Please guide me on this.

    Also, this is advertising TX power setting. After connection, if I want to maintain higher tx power for sometime, which API shall I use and how? Please guide me as I cannot understand.

    In your documentation, I have seen HCI_EXT_SetTxPowerDbmCmd(int8 txPower, uint8 fraction). Please explain which API shall I use that will correctly change the tx power during advertisement and after connection. My usecase is, when I press a given button, the advertising tx power shall increase to maximum and after connection with central, it will transmit data with maximum tx power and after execution of the command, I will move back to default 0 dbM value at connection and advertisement time.

    Also whichever API I use, I need to stop advertisement and restart it right?

    I have the code below

  • Hello Satakshi,

    I believe you are missing an argument in your GapAdv_SetParam function. You are not including the peripheral advertisement handler. The function should look like this: GapAdv_SetParam( uint8 handle, GapAdv_ParamId paramID,  void * pValue) 
    For more information on how to use this function and similar functions, please refer to our BLE5-Stack API documentation.

    Best Regards,

    Tarek

  • Hi Tarek,

    Can you please confirm if HCI_EXT_SetTxPowerDbmCmd(int8 txPower, uint8 fraction) API alone will change the TX power during advertisement and after connection both or I have to use both GapAdv_SetParam for changing tx power during advertisement and HCI_EXT_SetTxPowerDbmCmd(int8 txPower, uint8 fraction) during connection??

  • Hey Satakshi,

    For changing the Tx power when advertising, stop advertisement, using the GapAdv_SetParam function to change the value, then restart advertising. I don't believe you need HCI_EXT_SetTxPowerDbmCmd for the advertisement portion. However, I've included the API documentation for both functions down below, incase you needed more info. I hope this helps!

    https://dev.ti.com/tirex/content/simplelink_lowpower_f3_sdk_8_40_00_61/docs/ble5stack/ble_user_guide/doxygen/ble/html/group___gap_adv.html#ga65020be0895c76efdaf18cb6da791a60
    https://dev.ti.com/tirex/content/simplelink_lowpower_f3_sdk_8_40_00_61/docs/ble5stack/ble_user_guide/doxygen/ble/html/group___h_c_i.html#gaa61487d3db72c8628aa9d529e8de1bed

    Best Regards,

    Tarek

  • Hi Tarek,

    Thanks for the clarification. Changing advertisement parameters is not an issue for me. It's working properly. I just want to confirm if the HCI command is used for changing tx power during an active connection or not as in the API documentation nothing is mentioned exclusively.

    How should I change tx power during active connection?

    Thanks in advance.

  • Hello Satakshi,

    Thank you for the clarification and so sorry for the misunderstanding! Yes, you are correct, you will need to use the HCI_EXT_SetTxPowerDbmCmd function to dynamically change the value of TX power during run time. I've included the documentation link for this below:

    https://software-dl.ti.com/simplelink/esd/simplelink_lowpower_f3_sdk/8.40.00.61/exports/docs/ble5stack/ble_user_guide/html/cc23xx/txpower-cc23xx.html#changing-txpower-at-run-time

    I hope this answers your question!

    Best Regards,

    Tarek

  • Hi Tarek,

    Thanks for the clarification.