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.

CC2540: How to read Tx power level using SimpleBLEBroadcaster

Part Number: CC2540

Hi,

I would like to use SimpleBLEBroadcaster project and read Tx power level.

I have found some post that we can use "HCI_LE_ReadAdvChanTxPowerCmd" to achieve it.

However, I could not find any function of "HCI_LE_ReadAdvChanTxPowerCmd" except from header file declaration below.

My questions are :

Q1. What function can i use, to read Tx power level in SimpleBLEBroadcaster or SimpleBLEPeripheral project? Can anyone give any example?

Q2. Let say, now I am able to read Tx power level. That Tx power level is the value of my last transmission only or is it something like average consumption over certain period of time?

Thank you.

Regards,

LB

  • Hello,
    1.
    The output power is set to 0 dBm by default after init and will remain the same until you change it with HCI_EXT_SetTxPowerCmd.

    HCI_LE_ReadAdvChanTxPowerCmd will send an command complete event (HCI_LE_READ_ADV_CHANNEL_TX_POWER) with the output power given as the second argument in the returned message. You can handle this in SimpleBLEBroadcaster_ProcessEvent.

    2.
    The TX power level is based on the setting in the TXPOWER register and remains the same until you either change the power level or reset your device.
  • Hi Eirik V,

    Thanks a lot for your reply.

    As for below part, I am sorry, i don't quite get it. May i know if you can kindly give me example code for it. Really appreciate it.

    Eirik V said:


    HCI_LE_ReadAdvChanTxPowerCmd will send an command complete event (HCI_LE_READ_ADV_CHANNEL_TX_POWER) with the output power given as the second argument in the returned message. You can handle this in SimpleBLEBroadcaster_ProcessEvent.

    Do you mean this?

    Regards,

    LB

  • Hello,

    No,

    basically you should not have to worry about this as the programmed output power should remain the same.

    The HCI_LE_ReadAdvChanTxPowerCmd will send an command complete event  to the host. This message is received in the profile implementation GAPRole_ProcessEvent() in broadcaster.c and handled in gapRole_ProcessOSALMsg(). This is currently not implemented for the HCI_LE_READ_ADV_CHANNEL_TX_POWER, but as a reference it is implemented for HCI_READ_RSSI in the peripheral example. If you like you can add handling for the HCI_LE_READ_ADV_CHANNEL_TX_POWER and add a callback function in pGapRoles_AppCGs (type gapRolesCBs_t) to get a callback in your application.

    static void gapRole_ProcessOSALMsg( osal_event_hdr_t *pMsg )
    {
      switch ( pMsg->event )
      {
        case HCI_GAP_EVENT_EVENT:
    ... you would need to add a case for HCI_LE_READ_ADV_CHANNEL_TX_POWER here......

    The second byte in the return value ( pPkt->pReturnParam[1]) then correspond to the output power in the format seen below.

    // TX Output Power Related

    #define LL_TX_POWER_MINUS_23_DBM                 -23

    #define LL_TX_POWER_MINUS_6_DBM                  -6

    #define LL_TX_POWER_0_DBM                        0

    #define LL_TX_POWER_4_DBM                        4

    #define LL_TX_POWER_INVALID                      -128