-
-
Notifications
You must be signed in to change notification settings - Fork 159
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
Fixes a bug where incorrect Tx power level would be advertised. #832
Conversation
Tx Power level would be transmitted into the advertisement package.
If you are only setting the TX power for advertising, you could change the line to omit specifying the power type instead.
|
Hi @thekurtovic, I am not only setting the Tx power for advertising but also in the device itself. So that's how I found the issue in the first place. The retrieval of the power in the addTxPower is not correct without the fix. I could do the 2nd solution you proposed, although I find it kind of redundant since the device should "know" with which power it currently transmits. Let me know what change you prefer and I'll update the PR. Alternatively I could use NimbleDevice::getPowerLevel() and put that into the add TxPower or even build the advertisement packet myself but I guess that's not so user friendly. |
Just to rule out any confusion, I agree it should know which power type to use, your solution makes sense in a vacuum. |
Thanks @sanastasiou, this makes sense, but as @thekurtovic has mentioned it would break the API when building for non-esp devices. I have a couple ideas:
|
Hi @h2zero so if I understand correctly, the AddTxPower should also call NimbleDevice::setPowerLevel for Advertising and also set the power in dbM in the advertising package right ? |
What I meant was inside |
@h2zero Do we even need this of extAdv class?
|
Yes, it is an advertisable data in extended advertising, however the data used is stored in |
@h2zero @thekurtovic thanks but I think I'll create an issue instead and you guys can fix this. I am pretty sure that whatever I implemented wouldn't be quite right. ExtAdvertising already has a member to store dbM, simple advertising doesn't and needs one setPowerLevel doesn't pass the dbM rather |
Thank you for your efforts here @sanastasiou, your solution is perfectly acceptable and I greatly appreciate you bringing this to attention. This isn't the easiest library to maintain, that is for sure, this issue in particular is tricky because each chip manufacturer can implement tx power in their own way, no specification for it. I will definitely ensure you are credited with the final fix and hope you will approve the solution presented. |
@h2zero hey no worries happy to help and thanks for the only sane ble library out there 🥇 |
C3 and S3 have a workaround where different power levels could be set for e.g. advertising or scanning. The workaround does not take into account advertisement data, which keeps sending "default" channel with incorrect dbM value to the advertisement packet.
The fix should be backwards compatible since it only adds an optional parameter when Tx level is added into the advertisement packet.
Tested and verified that I now see -3 dbM when previously setting the Tx Level like this:
NimBLEDevice::setPowerLevel(ESP_PWR_LVL_N3, ESP_BLE_PWR_TYPE_ADV);
Without the fix some default value is transmitted.