Skip to content

Commit

Permalink
Feature: Add signal strength function (#93)
Browse files Browse the repository at this point in the history
* add function to get signal strength

* handle error case in ublox and return i8
  • Loading branch information
KennethKnudsen97 authored Jan 23, 2025
1 parent 5b07720 commit fee4175
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/asynch/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,22 @@ impl<'a, const INGRESS_BUF_SIZE: usize, const URC_CAPACITY: usize>
}
}

pub async fn get_signal_strength(&self) -> Result<i8, Error> {
match (&self.at_client)
.send_retry(&GetWifiStatus {
status_id: StatusId::Rssi,
})
.await?
.status_id
{
WifiStatus::Rssi(-32768) => Err(Error::NotConnected),
WifiStatus::Rssi(s) => s
.try_into()
.map_err(|_| Error::AT(atat::Error::InvalidResponse)),
_ => Err(Error::AT(atat::Error::InvalidResponse)),
}
}

pub async fn wait_for_link_state(&self, link_state: LinkState) {
self.state_ch.wait_for_link_state(link_state).await
}
Expand Down
2 changes: 1 addition & 1 deletion src/command/wifi/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ pub enum WifiStatus {
/// The <status_val> is the RSSI value of the current connection; will
/// return-32768, if not connected.
#[at_arg(value = 6)]
Rssi(u32),
Rssi(i16),
/// The <status_val> is the mobility domain of the last or current
/// connection This tag is supported by ODIN-W2 from software version 6.0.0
/// onwards only.
Expand Down
1 change: 1 addition & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub enum Error {
Timeout,
ShadowStoreBug,
AlreadyConnected,
NotConnected,
_Unknown,
}

Expand Down

0 comments on commit fee4175

Please sign in to comment.