-
-
Notifications
You must be signed in to change notification settings - Fork 83
NimBLEDevice::get/setPower support full power range. #229
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
Conversation
|
This is nice but I was trying to remove as much espressif specific functions/types as I could so it's seamless with other devices/oses. |
|
I see. What about just making the functions do nothing for ESP and emit a warning for the application to use |
|
That's also a possibility but I think the controller command might work with the newer esp32 chips, need to test. |
|
Closing due to excessive platform specific handling. |
|
Too soon, I will do something with this :) |
|
I think this could work, the only request I would make is to have the values specified in dbm, which is what NimBLE natively works with. Just need to remove the It's unfortunate that Bluetooth never specified a standard for this. Unfortunately espressif decided on a quite stage way to go about it as well. |
|
@thekurtovic I have added a commit and rebased to master, please take a look when you can. |
|
Edit: Wait I think I misunderstood what the code was doing. The 20 vs 21 problem should be avoided since it would cast into the same value. Also the ESP32-H2 enums get mapped into a shared values so they should be okay too. |
| return -127; // CONFIG_IDF_TARGET_ESP32P4 does not support esp_ble_tx_power_get | ||
| # endif | ||
|
|
||
| int pwr = esp_ble_tx_power_get(ESP_BLE_PWR_TYPE_DEFAULT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should check if power is invalid here, otherwise a large value like 741 will be returned when equal to ESP_PWR_LVL_INVALID.
Would it make sense to return -127 in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory the current power level should never be invalid I though think, also ESP_PWR_LVL_INVALID isn't defined for all chips/idf versions.
We could add a check for this, 20dbm is actually the max allowed by BLE specs so that's safe 😄 |
|
Okay spent a bit more time looking at the changes, I didn't notice you added methods for setting power level for esp32. This isn't related to the PR but are you able to get a valid reading on an esp32's power level? I get 0xFF anytime the value is read, so I can't properly test the |
I'm curious if you have any examples? I know there are a couple settings out there that were not multiples of 3 but they are deprecated. Just tested this on an esp32 with And the output: |
|
Some interesting results: |
|
And on the C6: Seems like all the devices start at 9dbm, |
|
I've added the |
Looks like the is a bug with the esp32s3, seems to work well with other versions. |
* Add powerType parameter to getPowerLevel and setPowerLevel.
|
Aaaand just like that I found the problem with the esp32s3 right after merging this lol. @thekurtovic if we call |
20 dbm was the main concern, but I see you've addressed it. Other than that I think only esp32-h2 could get an incorrect value if on IDF 5.1.0-5.1.1 and trying to use 16,17, or 19; though the values are now deprecated and round up to 18 and 20 now. CONFIG_BT_CTRL_DFT_TX_POWER_LEVEL defaults to P9 so that makes sense regarding the start value.
Interesting, good find. |
Sadly not but I also found that the same result is achieved by calling |
|
Looks like this was fixed upstream for v5.4. espressif/esp-idf@4108a5c |
|
@thekurtovic What idf version are you on? Looks like the only version with this issue that has been release is 5.2.3. 5.2.2 and 5.3 don't have the "enchanced" function that broke this. |
|
Thanks for looking into it. |
|
Interesting, I had a look and that commit you're using is not released, the actual 5.1.4 release does not contain the offending code. If you update the commit to fddbca1 it contains the fix. |
|
I'll give it a try, though planning on migrating over to 5.3 sometime soon. I forgot to mention this earlier but |
|
@thekurtovic I have updated the PR to check for this as well. |
Uh oh!
There was an error while loading. Please reload this page.