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

[SX126x] Add method to support SX126x Rx Boosted Gain mode #663

Merged

Conversation

andrew-moroz
Copy link

This adds a method allowing SX126x radios to be toggled between Rx Boosted Gain and Rx Power Saving Gain (the default setting) as described in section 9.6 of the SX126x datasheets. It also optionally allows the gain mode setting to be persisted across sleep/warm start.

I wasn't sure if perhaps it would be preferable to break the 'retain' argument (whether to persist the selected Rx gain setting) out into its own setter. I stopped short of doing that here, partly because the datasheet does not say anything specific about how to revert to not persisting (though the implication seems to be that if the gain retention registers are set to any values other than those specified, the gain setting will not be retained). But, happy to refactor if needed.

Copy link
Owner

@jgromes jgromes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution! I left some minor comments. In addition, please add setRxBoostedGainMode as keyword to keywords.txt (keep in mind this file has to use true tabs, not spaces).

Regarding restoring non-retention of Rx gain, did you investigate what is the default value of the RADIOLIB_SX126X_REG_RX_GAIN_RETENTION_X registers? And does it change upon power-on reset?

src/modules/SX126x/SX126x.cpp Outdated Show resolved Hide resolved
src/modules/SX126x/SX126x.h Outdated Show resolved Hide resolved

\returns 0
*/
int16_t setRxBoostedGainMode(bool rxbgm = false, bool retain = false);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to remove the first default argument - it doesn't seem to make much sense to call setRxBoostedGainMode(), why is false the default?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yep agreed, defaulting this to false does not make sense – removed.

@andrew-moroz andrew-moroz force-pushed the andrew-moroz/sx126x-rx-boosted-gain branch from 2f15aac to f885d58 Compare January 16, 2023 19:14
@andrew-moroz
Copy link
Author

andrew-moroz commented Jan 16, 2023

Awesome, thanks for the feedback! Made the changes you requested.

Re: retention of Rx gain setting, I was unable to find any other information about the three registers mentioned in the datasheet. I just did some more testing locally, and observed that the value of the first retention register is always 0 on startup, but the values of the other two fluctuate and do not seem to have consistent defaults. But moreover, I was actually not able to get Rx gain retention working at all with my test device (a RAK4631 running Meshtastic 2.0.13). Upon sleep/warm start, the value in the Rx gain setting register is always 0x94, regardless of whether the retention registers were set. (I guess this might be a result of particularities in the way Meshtastic handles sleep, but it is also quite possible I am misunderstanding something in the datasheet or code.)

In light of the above, maybe it would be better to keep things simple and drop the 'retain' argument and functionality for now?

@jgromes
Copy link
Owner

jgromes commented Jan 16, 2023

I was actually not able to get Rx gain retention working at all with my test device

In that case, let's drop it - I would rather not have this functionality, than have something that maybe works, maybe doesn't and might have some unknown side effects.

You could try asking on the LoRa developer forum (https://forum.lora-developers.semtech.com/c/Semtech-Transceivers/SX126x-family/29), maybe somebody from Semtech will be kind enough to help.

@andrew-moroz andrew-moroz force-pushed the andrew-moroz/sx126x-rx-boosted-gain branch from f885d58 to 35ed685 Compare January 16, 2023 21:37
@andrew-moroz
Copy link
Author

Ok sounds good, removed 'retain' arg and functionality.

Copy link
Owner

@jgromes jgromes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, in that case this is good to merge.

@jgromes jgromes merged commit 7a25b27 into jgromes:master Jan 16, 2023
@jgromes
Copy link
Owner

jgromes commented Jan 16, 2023

... and done! Thank you very much for the contribution!

@tckb
Copy link

tckb commented Aug 21, 2024

I know this PR is old and done. @andrew-moroz what is the purpose of this method other whats on the method? in other words, where and how enabling this option (i.e., gain mode) would increase the RX sensitivity? I am currently looking for ways to increase sensitivity (apart from working on LNA and antenna setup) thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants