Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which are the allowed values for txPower? > BLEDevice::setTxPower(int8_t txPower) #30

Closed
joseangeljimenez opened this issue Feb 19, 2015 · 8 comments
Assignees

Comments

@joseangeljimenez
Copy link

Hello,

I am developing with the latest version of the BLE_API. So far, I have successfully created fairly complex Peripheral examples. However, I have been only partially capable of changing the TX power.

I have been trying different values for txPower,
ble_error_t BLEDevice::setTxPower(int8_t txPower)

However, so far I only could make it work for txPower = 0 (0 dBm) and txPower = 4 (dBm). I have tried some negative values with no success.

Is there any documentation on the subject?

Best regards,
Jose Angel

@rgrover
Copy link
Contributor

rgrover commented Feb 19, 2015

ble_error_t BLEDevice::setTxPower(int8_t txPower) resolves to sd_ble_gap_tx_power_set().


/**@brief Set the radio's transmit power.
 *
 * @param[in] tx_power Radio transmit power in dBm (accepted values are -40, -30, -20, -16, -12, -8, -4, 0, and 4 dBm).
 *
 * @note -40 dBm will not actually give -40 dBm, but will instead be remapped to -30 dBm.
 *
 * @return @ref NRF_SUCCESS Successfully changed the transmit power.
 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
 * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry.
 */
SVCALL(SD_BLE_GAP_TX_POWER_SET, uint32_t, sd_ble_gap_tx_power_set(int8_t tx_power));

do you get an error as a return value? If not, then you'll need to take this up with Nordic. devzone.nordicsemi.com

@joseangeljimenez
Copy link
Author

Hello Rohit,

Thanks for your help. I have now finished checking all the accepted values for setTxPower / sd_ble_gap_tx_power_set(), and verified that the underlying Nordic SoftDevice is working as expected.

For all -30, -20, -16, -12, -8, -4, 0, 4 dBm, the RSSI at the Central device follows. For instance, if the RSSI at the Central device is ~-50dBm for a TX power of 4dBm, changing the TX power setting to 0dBm is seen from the Central device as a RSSI of ~-54dBm. And so on...

As a nice to have improvement to the actual BLE API documentation, I suggest to add a the range of valid input values for setTxPower().

Best regards,
Jose Angel

@rgrover
Copy link
Contributor

rgrover commented Feb 24, 2015

Hi Jose,

You commented "I suggest to add a the range of valid input values for setTxPower()."
Are you suggesting that we create a separate API which can return a set of valid TxPower values (using an iterator perhaps)?

@joseangeljimenez
Copy link
Author

Hello Rohit,

As the library currently supports only one backend (nRF51822), you could simply add a little description to the high level documentation of the BLEDevice::setTxPower() method.

However, paving the way for new backends, a simple API like the one below will do,
std::deque<int8_t> getTxPowerPermittedValues(); // C++03

Regards,
Jose Angel


P.S.: For those landing in this page with little C++ experience...

C++ can get tricky really fast, and something apparentrly trivial as returning an array of integer values turns out to be not so trivial,
http://stackoverflow.com/questions/4264304/how-to-return-an-array-from-a-method

My rationale,

@rgrover
Copy link
Contributor

rgrover commented Feb 25, 2015

how about keeping things really simple: return a static array--i.e. pointer
to a const int32_t and a unsigned count?

On Tue, Feb 24, 2015 at 6:08 PM, José Ángel Jiménez <
[email protected]> wrote:

Hello Rohit,

As the library currently supports only one backend (nRF51822), you could
simply add a little description to the high level documentation of the
BLEDevice::setTxPower() method.

However, paving the way for new backends, a simple API like the one below
will do,
std::deque getTxPowerPermittedValues(); // C++

Regards,

Jose Angel

P.S.: For those landing in this page with little C++ experience...

C++ can get tricky really fast, and something apparentrly trivial as
returning an array of integer values turns out to be not so trivial,

http://stackoverflow.com/questions/4264304/how-to-return-an-array-from-a-method

My rationale,


Reply to this email directly or view it on GitHub
#30 (comment).

@joseangeljimenez
Copy link
Author

Absolutely yes to the C style. Simpler for this case. Sorry, I jumped straight to C++ style.

@joseangeljimenez
Copy link
Author

The signature could be,
void getTxPowerPermittedValues(int8_t* const, size_t* const); // C style

@rgrover rgrover self-assigned this Feb 26, 2015
@rgrover
Copy link
Contributor

rgrover commented Feb 26, 2015

fixed in f557237

@rgrover rgrover closed this as completed Feb 26, 2015
jacobrosenthal pushed a commit to jacobrosenthal/ble that referenced this issue Dec 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants