-
Notifications
You must be signed in to change notification settings - Fork 7
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
SX128x RSSI Calc Update #4
Conversation
at the time I did that I was thinking about this too, but somehow decided against it you need to be carefull with adding the offset since the result must not exceed the int8_t range. So you either use int16 internally and constrain it then to INT8_MIN, or you check this doesn't happen otherwise. pl do not use camelcase variables inside the function, but lower case with '_', So, e.g. rssi_tmp, snr_tmp, neg_ofs; (temp sound smuch like temperature). One could thus also just use rssi, snr, ofs. |
Assume that you mean this would return 3 pieces of data: Rssi, RssiCorrected and Snr. Could do this but see pieces like this would likely need to be updated as well: maybe one should add a return int8_t* RssiSyncCorrected to the function? So may just be simpler to have two pieces returned.
I added this - feedback here appreciated.
No problem, will update. |
why did this internal int16 calculus go? is there an argument which I'm missing that it can't underflow? |
Was debugging why that version wouldn't compile and didn't realize I had forgot a semicolon on the if statement (whoops) so made it simpler while I was trying to debug. I do agree that it makes sense to do the math here with int16 to protect for overflow. In reality, I think the RSSI values won't be less than -100 and SNR values won't be less than -20 which means int8 would probably be fine. Probably wishful thinking that the chip wouldn't provide values that could overflow but better to be safe. |
the lowets rssi depends on the lora mode ... this is supposed to be a universal driver, so we shouldn't make any assumption on what we only use it for :) |
@jlpoltrack
We then have to ensure in the higher-level drivers in the main mLRS repo that we constrain to -128...127. Does this make sense? |
many thx |
Submitted this as well: olliw42/mLRS#66. 1RSS looks okay on the bench at short range. |
many THX! |
Updates the RSSI calculation to account for when the SNR is negative.
Borrowed logic from Datasheet / ELRS: https://github.com/ExpressLRS/ExpressLRS/blob/master/src/lib/SX1280Driver/SX1280.cpp#L580-L597