NCS: Softdevice+Mesh+Ext. Advertising -> TX Power Control?

Hello,

I have trouble again with TX Power control. This time using Softdevice Controller and NCS2.6.0.

Previous issue which was solved (this was using Zephyr Controller):  NCS Mesh: TX Power register value does not change when changing TX Power via HCI 

Is there a common solution to control TX Power runtime, when running Mesh + Extended Advertising and Softdevice controller?

Thanks in advance! :)

Parents Reply Children
  • Is there a way to determine which handles are available? With Zephyr controller it worked 0-3 for 4 sets, but with Softdevice looks that it does not work that way. For last 3 sets I get such error: "Set Tx power err: -5 reason 0x00"

    EDIT: Also I tried to print value of NRF_RADIO->TXPOWER each 200ms, it always returns 0, despite that tx power was reconfigured for 8dBm using functions from the sample project.

  • For general legacy and extended advertising, you can use https://github.com/nrfconnect/sdk-zephyr/blob/v3.5.99-ncs1-1/include/zephyr/bluetooth/hci.h#L91-L98.

    But for Mesh, there is no way to get the advertising handle, unfortunately. Sorry that we ended up at this dead end after my suggestions.

    May I ask why you wish to have dynamic TX power control with mesh?

  • Thanks for rapid response.

    1. Can you please explain why Softdevice is altering TX Power on its own, after its configured by the user once?

    2. Dynamic setting would allow user to reconfigure TX Power, this is not a must but nice to have feature. Also dynamic setting allow to have chip dependent configuration, e.g. 52832 does not have 8dbm, therefore its configured for 4dbm in our case.

    3. Static configuration does not work neither. It sets expected value to the register once, and later 0dBm is read back from the register all the time. I tried following conf:

    CONFIG_BT_CTLR_TX_PWR_ANTENNA=8
    CONFIG_BT_CTLR_TX_PWR_PLUS_8=y
    So we are stuck with 0dBm at the moment :(
  • mesh777 said:
    1. Can you please explain why Softdevice is altering TX Power on its own, after its configured by the user once?

    It makes more sense if you think of it as "the user requests the SoftDevice Controller to use this TX Power for that connection/advertising handle; and the SoftDevice then serves that request appropriately by changing TX Power when it's time to serve that handle."

    At no point does the SoftDevice change this requested power. When the radio transmits, the TX Power will be raised to the appropriate value.

    If you configure request different handles to different TX Power, the Controller will also get that done.

    mesh777 said:
    2. Dynamic setting would allow user to reconfigure TX Power, this is not a must but nice to have feature. Also dynamic setting allow to have chip dependent configuration, e.g. 52832 does not have 8dbm, therefore its configured for 4dbm in our case.

    Thank you. This is a very reasonable feature. We have registered it and will look into it. Unfortunately, it is quite tricky to realize this with the way the mesh layers interact, so it might be difficult.

    mesh777 said:

    3. Static configuration does not work neither. It sets expected value to the register once, and later 0dBm is read back from the register all the time. I tried following conf:

    CONFIG_BT_CTLR_TX_PWR_ANTENNA=8
    CONFIG_BT_CTLR_TX_PWR_PLUS_8=y
    So we are stuck with 0dBm at the moment :(

    I just tried with the Mesh Light sample, and it does work. I do see that just printing out TXPOWER rapidly doesn't work nearly as well as I once remember. Perhaps it worked better with BLE applications where the radio time is longer.

    For Mesh, I tweak the logic a little like below and I can observe TXPOWER does get set to 8. You could also use debugging to stop the execution at certain point to confirm the register value.

    int main(void)
    {
    	int err;
    
    	printk("Initializing...\n");
    
    	err = bt_enable(bt_ready);
    	if (err) {
    		printk("Bluetooth init failed (err %d)\n", err);
    	}
    
    	while (1)
    	{
    		int txpower = NRF_RADIO->TXPOWER;
    		if (txpower > 0) printk("TX power: %d\n", txpower);
    		static int cnt;
    		if (cnt > 50000)
    		{
    			static int cnt2;
    			printk("cnt2: %d\n", cnt2++);
    			cnt = 0;
    		}
    		k_sleep(K_MSEC(1));
    	}
    
    	return 0;
    }

    If you want absolute proof that it works, I recommend using a spectrum analyzer and look into the radio output directly.

  • Many thanks for clarification.

    I noticed that most of the time TX Power register is 0dBm, with the static config set which mentioned above.

    Does it mean that TX power setting is applied not to all handles? To which it is applied then?

    In your sample code you do not print value of 0 by the way, otherwise it is 0 most of the time.

Related