I'm playing around with the light and switch examples with the Bluetooth mesh SDK on nRF52832 devices. I'm trying to find out what the maximum distance would be given changes in TX output power. However, every time I make a call to the sd_ble_gap_tx_power_set function it returns an error.
I'm guessing this has something to do with the mesh SDK? Does the mesh SDK support changes in TX power?
The mesh stack operates within a SoftDevice timeslot and implements its own advertiser and scanner. To modify the TX output power of the device, I believe you only have to call the void radio_tx_power_set(radio_tx_power_t tx_power) function in mesh/include/core/radio.h. You could also set the default at compile time in mesh/src/core/radio.c in radio_init().
void radio_tx_power_set(radio_tx_power_t tx_power)
In the v0.10.0 a new bearer layer appeared and changed this around a bit. There is a concept of an "advertiser instance": advertiser_t in mesh/bearer/include/advertiser.h. This means that the stack can instantiate and use any number of advertisers concurrently. Each advertiser owns a broadcast_t structure, which owns the lower level radio configurations like which access address, what advertising channels and what radio_config_t to use.
To answer your question directly. To change the TX power of the mesh itself, you would really have to change the values used in the individual advertiser_t instances. However, all advertisers used in the mesh are set up with default parameters by the set_default_broadcast_configuration() in advertiser.c:268. In that function you can change the default TX power among other things.
Thanks, Thomas! That helps me a lot after getting a lot of search results for the function I was trying to use instead...
I'm glad to hear that!
I believe the accepted argument values for sd_ble_gap_tx_power_set() are -40, -20, -16, -12, -8, -4, 0, 4 (dbm). Please verify with the softdevice documentation.
I believe you are correct. I was using 4 as my value. See the answer below for the solution to the problem.