Skip to content

Commit fee4175

Browse files
Feature: Add signal strength function (#93)
* add function to get signal strength * handle error case in ublox and return i8
1 parent 5b07720 commit fee4175

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/asynch/control.rs

+16
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,22 @@ impl<'a, const INGRESS_BUF_SIZE: usize, const URC_CAPACITY: usize>
195195
}
196196
}
197197

198+
pub async fn get_signal_strength(&self) -> Result<i8, Error> {
199+
match (&self.at_client)
200+
.send_retry(&GetWifiStatus {
201+
status_id: StatusId::Rssi,
202+
})
203+
.await?
204+
.status_id
205+
{
206+
WifiStatus::Rssi(-32768) => Err(Error::NotConnected),
207+
WifiStatus::Rssi(s) => s
208+
.try_into()
209+
.map_err(|_| Error::AT(atat::Error::InvalidResponse)),
210+
_ => Err(Error::AT(atat::Error::InvalidResponse)),
211+
}
212+
}
213+
198214
pub async fn wait_for_link_state(&self, link_state: LinkState) {
199215
self.state_ch.wait_for_link_state(link_state).await
200216
}

src/command/wifi/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ pub enum WifiStatus {
499499
/// The <status_val> is the RSSI value of the current connection; will
500500
/// return-32768, if not connected.
501501
#[at_arg(value = 6)]
502-
Rssi(u32),
502+
Rssi(i16),
503503
/// The <status_val> is the mobility domain of the last or current
504504
/// connection This tag is supported by ODIN-W2 from software version 6.0.0
505505
/// onwards only.

src/error.rs

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub enum Error {
3434
Timeout,
3535
ShadowStoreBug,
3636
AlreadyConnected,
37+
NotConnected,
3738
_Unknown,
3839
}
3940

0 commit comments

Comments
 (0)