6 Replies Latest reply on Jun 27, 2016 2:53 PM by okhwaja

    blecm_setTxPowerInADV

    okhwaja

      Is blecm_setTxPowerInADV() still supported in SDK v2.2.2?

      I can't seem to find it in any header file or documentation, though my application builds if I include a call to it.

       

      That said, I would like to be able to vary the Tx power of the advertising packets. Is this the correct API to use?

      If so, what range of values can I specify?

      I read somewhere that it is -10 dBm to 4 dBm in 2dBm steps.

      Is my understanding correct?

       

      I have read through all (I think) issues in this forum regarding Tx power but do not see a clear answer.

        • 1. Re: blecm_setTxPowerInADV
          ShawnA_01
          1 of 1 people found this helpful
          • 2. Re: blecm_setTxPowerInADV
            okhwaja

            Thanks for the prompt response.

            Yes I have read Power level granularity in blecm_setTxPowerInConnection() and blecm_setTxPowerInADV()  many times but cannot see how what is said there explains how to use blecm_setTxPowerInADV().

            I see what I understand is the PA Tx power table: { 3, -1, -5, -9, -13, -17, -21, -25 }

            So that would mean that I can set Tx Power levels between -25 and 3 dBm in 4 dB increments.

             

            But how do I specify the power level?

            If I want the advertisements to be at -1 dBm, do I call blecm_setTxPowerInADV(-1) ?

            Somehow I do not think that is correct!

             

            What about all the sample apps that call  blecm_setTxPowerInADV(4) ?

            How does that work? I thought that was setting Tx Power to 4 dBm? But there is no 4 in that table!

            Other sample apps call blecm_setTxPowerInADV(0)?

            Again, what power is being set here? 0 dBm? Again, no entry in the table.

             

            I hope you see my confusion and can provide some concrete examples on how to use blecm_setTxPowerInADV() and how that relates to the PA Tx power table.

             

            Thanks in advance

             

            P.S. I am using the BCM20736

            • 3. Re: blecm_setTxPowerInADV
              ShawnA_01

              <<<So that would mean that I can set Tx Power levels between -25 and 3 dBm in 4 dB increments.

              Correct.   Using blecm_setTxPowerInADV(4) sets the transmitter to the highest output power, which cannot exceed +4dBm per the spec. Not sure if your antenna has any gain stages in it, or if like other designs (such as in the module) there is some attenuation present.  Bottom line:  Don't expect to get exact RF measurements on the spectrum analyzer based on the parameter sent to blecm_setTxPowerInADV().

               

              <<<If I want the advertisements to be at -1 dBm, do I call blecm_setTxPowerInADV(-1)

              Transmitter will not exceed +1dBm... but again attenuation is present so you might measure less than -1dBm.

               

              <<<Somehow I do not think that is correct!

              Why do you question this usage/result?

               

              <<<But there is no 4 in that table!

              Using 4 as the parameter sets the transmitter to the highest level it can go.

               

              <<<Other sample apps call blecm_setTxPowerInADV(0)?

              <<<Again, what power is being set here? 0 dBm? Again, no entry in the table.

              When using values not shown in the table, the algorithm rounds down.

               

              Use the functions to lower the TX power to extend battery life and/or lower the connection range.

              • 4. Re: blecm_setTxPowerInADV
                okhwaja

                ShawnA_01

                Thanks for your answers... but I am still not totally clear on the mapping.

                 

                You say "When using values not shown in the table, the algorithm rounds down."

                So with the PA table being { 3, -1, -5, -9, -13, -17, -21, -25 }

                 

                If I specify 4 or 3, I should get 3 dBm

                If I specify 2,1,0, or -1, I should get -1 dBm

                ...

                If I specify -22,-23, -24 or -25, I should get -25 dBm

                 

                Is my understanding correct?

                • 5. Re: blecm_setTxPowerInADV
                  ShawnA_01

                  Sorry for the delay, it's been a while since this issue came up, and I had to go look at the source code.  The other posting was psuedo-code, whereas the stuff below is the real-deal. 

                   

                  There is an "if, else-if, else" sequence in the code:

                   

                  // If the power level > element 0 in the table, return (element) 0, else-if

                  // If the power level < last element in the table, return (element) tableLen-1, else

                          for (i=1; i < tableLen; i++)

                          {

                              if ((tPtr[i].AttndB * -1) <= powerLevel_dB)

                              {

                                  INT8 n_1_diff = (tPtr[i-1].AttndB * -1) - powerLevel_dB;

                                  INT8 n_diff   = powerLevel_dB - (tPtr[i].AttndB * -1);

                                  if (n_diff <= n_1_diff)

                                  {

                                      tableIndx = i;

                                  }

                                  else

                                  {

                                      tableIndx = i-1;

                                  }

                                  break;

                              }

                          }

                   

                  Where the Class 2 power table (stored in dB and shown as tPtr[].AttndB) looks like:   0, 4, 8, 12, 16, 20, 24, 28

                   

                  To reiterate: Function calls to these routines round to the nearest value in the table and the middle value rounds "up".

                   

                  1 of 1 people found this helpful
                  • 6. Re: blecm_setTxPowerInADV
                    okhwaja

                    Now I see how this Tx Power Level is really the power level attenuation below the maximum value.

                     

                    I factored that code into a standalone program and for Tx Power values between 4 dBm and -30 dBm here's what I get:

                    Power Level     : Attenuation

                    4,3,2,1,0,-1      :   0

                    -2,-3,-4,-5        :   4

                    -6,-7,-8,-9        :   8

                    -10,-11,-12,-13 : 12

                    -14,-15,-16,-17 : 16

                    -18,-19,-20,-21 : 20

                    -22,-23,-24,-25 : 24

                    -26,-27,-28,-29 : 28

                     

                    Thanks again for the prompt and detailed response!

                    1 of 1 people found this helpful