Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize fmt.rs to provide correct logging location when using defmt #3065

Closed
wants to merge 14 commits into from
Closed
5 changes: 3 additions & 2 deletions cyw43/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ repository = "https://github.com/embassy-rs/embassy"
documentation = "https://docs.embassy.dev/cyw43"

[features]
defmt = ["dep:defmt", "heapless/defmt-03", "embassy-time/defmt"]
log = ["dep:log"]
defmt = ["dep:defmt", "embassy-fmt/defmt", "heapless/defmt-03", "embassy-time/defmt"]
log = ["dep:log", "embassy-fmt/log"]

# Fetch console logs from the WiFi firmware and forward them to `log` or `defmt`.
firmware-logs = []

[dependencies]
embassy-fmt = {version = "0.1.0", path = "../embassy-fmt" }
embassy-time = { version = "0.3.1", path = "../embassy-time"}
embassy-sync = { version = "0.6.0", path = "../embassy-sync"}
embassy-futures = { version = "0.1.0", path = "../embassy-futures"}
Expand Down
2 changes: 1 addition & 1 deletion cyw43/src/control.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use core::cmp::{max, min};
use core::iter::zip;

use embassy_fmt::Bytes;
use embassy_net_driver_channel as ch;
use embassy_net_driver_channel::driver::{HardwareAddress, LinkState};
use embassy_time::{Duration, Timer};

use crate::consts::*;
use crate::events::{Event, EventSubscriber, Events};
use crate::fmt::Bytes;
use crate::ioctl::{IoctlState, IoctlType};
use crate::structs::*;
use crate::{countries, events, PowerManagementMode};
Expand Down
257 changes: 0 additions & 257 deletions cyw43/src/fmt.rs

This file was deleted.

3 changes: 1 addition & 2 deletions cyw43/src/ioctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ use core::cell::{Cell, RefCell};
use core::future::poll_fn;
use core::task::{Poll, Waker};

use embassy_fmt::Bytes;
use embassy_sync::waitqueue::WakerRegistration;

use crate::fmt::Bytes;

#[derive(Clone, Copy)]
pub enum IoctlType {
Get = 0,
Expand Down
31 changes: 29 additions & 2 deletions cyw43/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,35 @@
#![doc = include_str!("../README.md")]
#![warn(missing_docs)]

// This mod MUST go first, so that the others see its macros.
pub(crate) mod fmt;
#[allow(unused)]
#[macro_use]
extern crate embassy_fmt;

#[allow(unused)]
#[macro_use(
assert,
assert_eq,
assert_ne,
debug_assert,
debug_assert_eq,
debug_assert_ne,
todo,
unreachable,
panic,
trace,
debug,
info,
warn,
error,
unwrap
)]
#[cfg(feature = "defmt")]
extern crate defmt;

#[allow(unused)]
#[macro_use(trace, debug, info, warn, error)]
#[cfg(feature = "log")]
extern crate log;

mod bus;
mod consts;
Expand Down
2 changes: 1 addition & 1 deletion cyw43/src/runner.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use embassy_fmt::Bytes;
use embassy_futures::select::{select3, Either3};
use embassy_net_driver_channel as ch;
use embassy_time::{block_for, Duration, Timer};
Expand All @@ -7,7 +8,6 @@ use crate::bus::Bus;
pub use crate::bus::SpiBusCyw43;
use crate::consts::*;
use crate::events::{Event, Events, Status};
use crate::fmt::Bytes;
use crate::ioctl::{IoctlState, IoctlType, PendingIoctl};
use crate::nvram::NVRAM;
use crate::structs::*;
Expand Down
3 changes: 2 additions & 1 deletion cyw43/src/structs.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use embassy_fmt::Bytes;

use crate::events::Event;
use crate::fmt::Bytes;

macro_rules! impl_bytes {
($t:ident) => {
Expand Down
3 changes: 3 additions & 0 deletions embassy-boot-nrf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ target = "thumbv7em-none-eabi"
defmt = { version = "0.3", optional = true }
log = { version = "0.4.17", optional = true }

embassy-fmt = {version = "0.1.0", path = "../embassy-fmt" }
embassy-sync = { version = "0.6.0", path = "../embassy-sync" }
embassy-nrf = { version = "0.1.0", path = "../embassy-nrf", default-features = false }
embassy-boot = { version = "0.2.0", path = "../embassy-boot" }
Expand All @@ -39,8 +40,10 @@ nrf-softdevice-mbr = { version = "0.2.0", optional = true }
defmt = [
"dep:defmt",
"embassy-boot/defmt",
"embassy-fmt/defmt",
"embassy-nrf/defmt",
]
log = ["dep:log", "embassy-fmt/log"]
softdevice = [
"nrf-softdevice-mbr",
]
Loading