Skip to content

Commit

Permalink
Fix logging when using log
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasKoch committed Aug 9, 2024
1 parent ad09bea commit 944d089
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 11 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ embedded-hal = "1.0.0"
embedded-nal = "0.8"
embedded-nal-async = { version = "0.7" }

embassy-at-cmux = { git = "https://github.com/MathiasKoch/embassy", rev = "e9ce1e2", optional = true }
embassy-at-cmux = { git = "https://github.com/MathiasKoch/embassy", rev = "e2f4365", optional = true }
# embassy-at-cmux = { path = "../embassy/embassy-at-cmux" }

embassy-net-ppp = { version = "0.1", optional = true }
embassy-net = { version = "0.4", features = [
"proto-ipv4",
Expand Down
5 changes: 4 additions & 1 deletion src/asynch/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@ where
let current_state = self.ch.operation_state(None);
let desired_state = self.ch.desired_state(None);

info!("State transition: {} -> {}", current_state, desired_state);
info!(
"State transition: {:?} -> {:?}",
current_state, desired_state
);

match (current_state, desired_state.cmp(&current_state)) {
(_, Ordering::Equal) => break,
Expand Down
6 changes: 1 addition & 5 deletions src/asynch/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,7 @@ where
self.ch.set_module(Module::from_model_id(&model_id));

let FirmwareVersion { version } = at_client.send_retry(&GetFirmwareVersion).await?;
info!(
"Found module to be: {=[u8]:a}, {}",
model_id.model.as_slice(),
version
);
info!("Found module to be: {:?}, {:?}", self.ch.module(), version);

at_client
.send_retry(&SetEmbeddedPortFiltering {
Expand Down
12 changes: 8 additions & 4 deletions src/asynch/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,15 @@ impl<'d> Runner<'d> {
pub fn update_registration_with(&self, f: impl FnOnce(&mut RegistrationState)) {
self.shared.lock(|s| {
let s = &mut *s.borrow_mut();
let prev = s.registration_state.is_registered();
f(&mut s.registration_state);
info!(
"Registration status changed! Registered: {:?}",
s.registration_state.is_registered()
);
if prev != s.registration_state.is_registered() {
info!(
"Cellular registration status changed! Registered: {:?} -> {:?}",
prev,
s.registration_state.is_registered()
);
}
s.registration_waker.wake();
})
}
Expand Down
1 change: 1 addition & 0 deletions src/modules/lara_r6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use super::ModuleParams;
use embassy_time::Duration;

#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct LaraR6;

impl ModuleParams for LaraR6 {
Expand Down
1 change: 1 addition & 0 deletions src/modules/lena_r8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::command::mobile_control::types::Functionality;
use embassy_time::Duration;

#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct LenaR8;

impl ModuleParams for LenaR8 {
Expand Down
5 changes: 5 additions & 0 deletions src/modules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ pub trait ModuleParams: Copy {
}

#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub(crate) enum Module {
#[cfg(any(feature = "any-module", feature = "lara-r6"))]
LaraR6(lara_r6::LaraR6),
Expand All @@ -100,6 +101,9 @@ impl Module {
match model_id.model.as_slice() {
b"LARA-R6001D" => Self::LaraR6(lara_r6::LaraR6),
id => {
#[cfg(feature = "defmt")]
warn!("Attempting to run {=[u8]:a} using generic module parameters! This may or may not work.", id);
#[cfg(feature = "log")]
warn!("Attempting to run {:?} using generic module parameters! This may or may not work.", id);
Self::Generic(Generic)
}
Expand Down Expand Up @@ -174,6 +178,7 @@ impl ModuleParams for Module {
}

#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct Generic;

impl ModuleParams for Generic {}
1 change: 1 addition & 0 deletions src/modules/sara_r410m.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::command::mobile_control::types::Functionality;
use embassy_time::Duration;

#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct SaraR410m;

impl ModuleParams for SaraR410m {
Expand Down
1 change: 1 addition & 0 deletions src/modules/sara_r412m.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::command::mobile_control::types::Functionality;
use embassy_time::Duration;

#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct SaraR412m;

impl ModuleParams for SaraR412m {
Expand Down
1 change: 1 addition & 0 deletions src/modules/sara_r422.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::command::mobile_control::types::Functionality;
use embassy_time::Duration;

#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct SaraR422;

impl ModuleParams for SaraR422 {
Expand Down
1 change: 1 addition & 0 deletions src/modules/sara_r5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::command::mobile_control::types::Functionality;
use embassy_time::Duration;

#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct SaraR5;

impl ModuleParams for SaraR5 {
Expand Down
1 change: 1 addition & 0 deletions src/modules/sara_u201.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::command::mobile_control::types::Functionality;
use embassy_time::Duration;

#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct SaraU201;

impl ModuleParams for SaraU201 {
Expand Down
1 change: 1 addition & 0 deletions src/modules/toby_r2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::command::mobile_control::types::Functionality;
use embassy_time::Duration;

#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct TobyR2;

impl ModuleParams for TobyR2 {
Expand Down

0 comments on commit 944d089

Please sign in to comment.