Skip to content

Commit

Permalink
Added debug feature
Browse files Browse the repository at this point in the history
  • Loading branch information
taks committed Mar 7, 2024
1 parent 0d6987b commit 9117917
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ default = ["std"]

std = ["esp-idf-svc/std", "esp-idf-hal/std", "once_cell/std", "bstr/std"]
no_std = ["once_cell/critical-section", "esp-idf-hal/critical-section", "bstr/alloc"]
debug = []

[dependencies]
log = { version = "0.4", default-features = false }
Expand Down
11 changes: 11 additions & 0 deletions src/ble_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,21 @@ pub fn return_code_to_string(rc: i32) -> Option<&'static str> {
}
}

#[cfg(not(feature = "debug"))]
macro_rules! ble {
($err:expr) => {{
$crate::BLEError::convert($err as _)
}};
}
#[cfg(feature = "debug")]
macro_rules! ble {
($err:expr) => {{
let rc = $crate::BLEError::convert($err as _);
if let Err(err) = rc {
::log::warn!(target: "esp32_nimble", "{}[{}]: {:?}", file!(), line!(), err);
}
rc
}};
}

pub(crate) use ble;

0 comments on commit 9117917

Please sign in to comment.