Skip to content

Commit

Permalink
fix sara-r5 (#89)
Browse files Browse the repository at this point in the history
* fix imports and Features Enum for sara-r5

* update ublox-sockets

* implement defmt::format

* enable defmt for nb and bump embedded-io,ublox-sockets,atat

* rustfmt
  • Loading branch information
tarfu authored Oct 14, 2023
1 parent 461461e commit 5299a76
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 18 deletions.
8 changes: 4 additions & 4 deletions ublox-cellular/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ doctest = false

[dependencies]
# atat = { version = "0.18", features = ["derive", "bytes"] }
atat = { git = "https://github.com/BlackbirdHQ/atat", rev = "c5caaf7", features = [
atat = { git = "https://github.com/BlackbirdHQ/atat", rev = "31a45fc", features = [
"derive",
"defmt",
"bytes",
] }
embedded-hal = "=1.0.0-rc.1"
Expand All @@ -29,9 +28,9 @@ heapless = { version = "^0.7", features = ["serde"] }
nb = "^1"
serde = { version = "^1", default-features = false, features = ["derive"] }
# ublox-sockets = "0.5.0"
ublox-sockets = { git = "https://github.com/BlackbirdHQ/ublox-sockets", rev = "b1ff942" }
ublox-sockets = { git = "https://github.com/BlackbirdHQ/ublox-sockets", rev = "0bc0dc1" }
embassy-time = "0.1"
embedded-io = "0.5"
embedded-io = "0.6.0"

# Enable `serde` feature of `no-std-net`
no-std-net = { version = "^0.5", features = ["serde"] }
Expand All @@ -50,6 +49,7 @@ defmt-impl = [
"ublox-sockets/defmt",
"atat/defmt",
"heapless/defmt-impl",
"nb/defmt-0-3"
]
# Use `log-impl` to enable log based logging
log-impl = ["log", "ublox-sockets/log", "atat/log"]
Expand Down
36 changes: 25 additions & 11 deletions ublox-cellular/src/command/mobile_control/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ pub enum Functionality {
feature = "toby-l4",
feature = "leon-g1",
feature = "sara-g3",
feature = "sara-g4"
feature = "sara-g4",
feature = "sara-r5",
))]
Minimum = 0,

Expand All @@ -35,7 +36,8 @@ pub enum Functionality {
feature = "toby-l4",
feature = "leon-g1",
feature = "sara-g3",
feature = "sara-g4"
feature = "sara-g4",
feature = "sara-r5",
))]
Full = 1,

Expand All @@ -51,7 +53,8 @@ pub enum Functionality {
feature = "toby-r2",
feature = "lara-r2",
feature = "lara-r6",
feature = "toby-l4"
feature = "toby-l4",
feature = "sara-r5",
))]
AirplaneMode = 4,

Expand All @@ -69,7 +72,8 @@ pub enum Functionality {
feature = "toby-l4",
feature = "leon-g1",
feature = "sara-g3",
feature = "sara-g4"
feature = "sara-g4",
feature = "sara-r5",
))]
DedicatedMode = 6,

Expand All @@ -84,7 +88,8 @@ pub enum Functionality {
feature = "toby-l4",
feature = "leon-g1",
feature = "sara-g3",
feature = "sara-g4"
feature = "sara-g4",
feature = "sara-r5",
))]
DisableSimToolkit = 7,
#[cfg(any(
Expand All @@ -96,7 +101,8 @@ pub enum Functionality {
feature = "toby-l4",
feature = "leon-g1",
feature = "sara-g3",
feature = "sara-g4"
feature = "sara-g4",
feature = "sara-r5",
))]
DisableSimToolkit_ = 8,

Expand All @@ -107,7 +113,8 @@ pub enum Functionality {
feature = "lisa-u2",
feature = "sara-u2",
feature = "toby-r2",
feature = "lara-r2"
feature = "lara-r2",
feature = "sara-r5",
))]
RawMode = 9,

Expand All @@ -125,7 +132,8 @@ pub enum Functionality {
feature = "toby-l4",
feature = "leon-g1",
feature = "sara-g3",
feature = "sara-g4"
feature = "sara-g4",
feature = "sara-r5",
))]
SilentReset = 15,

Expand All @@ -141,19 +149,25 @@ pub enum Functionality {
feature = "toby-l4",
feature = "leon-g1",
feature = "sara-g3",
feature = "sara-g4"
feature = "sara-g4",
feature = "sara-r5",
))]
SilentResetWithSimReset = 16,

/// 19: Sets the MT to minimum functionality by deactivating CS and PS services and
/// the SIM card
#[cfg(any(feature = "toby-l2", feature = "mpci-l2", feature = "toby-l4"))]
#[cfg(any(
feature = "toby-l2",
feature = "mpci-l2",
feature = "toby-l4",
feature = "sara-r5",
))]
MinimumWithoutSim = 19,

/// 127: Sets the MT in a deep low power state "HALT" (with detach from the network
/// and saving of the NVM parameters); the only way to wake up the module is a power
/// cycle or a module reset
#[cfg(any(feature = "toby-l2", feature = "mpci-l2"))]
#[cfg(any(feature = "toby-l2", feature = "mpci-l2", feature = "sara-r5",))]
Halt = 127,
}

Expand Down
17 changes: 17 additions & 0 deletions ublox-cellular/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ pub enum Error {
_Unknown,
}

#[cfg(feature = "defmt")]
impl defmt::Format for Error {
fn format(&self, f: defmt::Formatter<'_>) {
match self {
Self::BaudDetection => defmt::write!(f, "BaudDetection"),
Self::Busy => defmt::write!(f, "Busy"),
Self::Uninitialized => defmt::write!(f, "Uninitialized"),
Self::StateTimeout => defmt::write!(f, "StateTimeout"),
Self::Network(e) => defmt::write!(f, "Network({:?})", e),
Self::DataService(e) => defmt::write!(f, "DataService({:?})", e),
Self::Generic(e) => defmt::write!(f, "Generic({:?})", e),
Self::_Unknown => defmt::write!(f, "_Unknown"),
_ => defmt::write!(f, "non_exhaustive"),
}
}
}

impl From<DataServiceError> for Error {
fn from(e: DataServiceError) -> Self {
// Unwrap generic and network errors
Expand Down
1 change: 1 addition & 0 deletions ublox-cellular/src/services/data/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::network::Error as NetworkError;
use ublox_sockets::Error as SocketError;

#[derive(Debug, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error {
InvalidApn,
SocketMemory,
Expand Down
14 changes: 11 additions & 3 deletions ublox-cellular/src/services/data/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ pub use error::Error;
use psn::{types::GPRSAttachedState, GetGPRSAttached};
use ublox_sockets::{Error as SocketError, SocketSet, SocketType};

use crate::command::psn::responses::PacketSwitchedNetworkData;
use crate::command::psn::types::{
PacketSwitchedAction, PacketSwitchedNetworkDataParam, PacketSwitchedParam, ProtocolType,
};
use crate::command::psn::{
GetPacketSwitchedNetworkData, SetPacketSwitchedAction, SetPacketSwitchedConfig,
};
#[cfg(feature = "upsd-context-activation")]
use embedded_nal::Ipv4Addr;
use heapless::String;

// NOTE: If these are changed, remember to change the corresponding `Bytes` len
// in commands for now.
Expand Down Expand Up @@ -285,7 +293,7 @@ where
.send_internal(
&SetPacketSwitchedConfig {
profile_id,
param: PacketSwitchedParam::APN(apn),
param: PacketSwitchedParam::APN(String::from(apn)),
},
true,
)
Expand All @@ -298,7 +306,7 @@ where
.send_internal(
&SetPacketSwitchedConfig {
profile_id,
param: PacketSwitchedParam::Username(user_name),
param: PacketSwitchedParam::Username(String::from(user_name)),
},
true,
)
Expand All @@ -311,7 +319,7 @@ where
.send_internal(
&SetPacketSwitchedConfig {
profile_id,
param: PacketSwitchedParam::Password(password),
param: PacketSwitchedParam::Password(String::from(password)),
},
true,
)
Expand Down

0 comments on commit 5299a76

Please sign in to comment.