fix RSSI calculations

This commit is contained in:
bunnie 2022-12-12 15:31:06 +08:00
parent edf24d9fc2
commit 80ce119c95
3 changed files with 13 additions and 2 deletions

View file

@ -601,7 +601,10 @@ impl Com {
log::error!("got an error code in fetching the RSSI data: 0x{:x}", rssi_usize);
Err(xous::Error::UnknownError)
} else {
Ok((rssi_usize & 0xFF) as u8)
// must convert raw code to signal strength here
let rssi = 110u8 - (rssi_usize & 0xFF) as u8;
log::debug!("RSSI (lib): -{}dBm", rssi);
Ok(rssi)
}
} else {
Err(xous::Error::InternalError)

View file

@ -997,7 +997,13 @@ fn main() -> ! {
let rssi = if (maybe_rssi >> 8) & 0xff != 0 {
None
} else {
Some(maybe_rssi & 0xff)
// rssi as reported is a number from 0-110, where 110 is 0 dbm.
// a perhaps dubious decision was made to shift the reported value over by one before
// returning to the host, so we lost a 0.5dBm step. But...not a big deal, and not worth
// putting every user through an EC update to gain some resolution they never see.
// note there is also a function in lib.rs/wlan_get_rssi() that has to be patched if
// this is fixed.
Some((110 - maybe_rssi) & 0xff)
};
let link_state = com.wait_txrx(ComState::LINK_READ.verb, Some(STD_TIMEOUT));
let mut ipv4_raw = Ipv4Conf::default().encode_u16();
@ -1015,6 +1021,7 @@ fn main() -> ! {
let ssid_str = core::str::from_utf8(&ssid_buf[2..2+ssid_checked_len]).unwrap_or("Disconnected");
let status = WlanStatusIpc {
ssid: if let Some(rssi) = rssi {
log::debug!("RSSI: -{}dBm", rssi);
Some(SsidRecord {
rssi: rssi as u8,
name: xous_ipc::String::<32>::from_str(ssid_str)

View file

@ -833,6 +833,7 @@ fn wrapped_main() -> ! {
stats.soc).unwrap();
} else {
if let Some(ssid) = wifi_status.ssid {
log::debug!("RSSI: -{}dBm", ssid.rssi);
compute_bars(&mut wifi_bars, ssid.rssi);
bars(&gam, status_gid, &wifi_bars, Point {x: 310, y: 13}, (3 ,2), 3, 2);
write!(