Skip to content

Commit

Permalink
Bump embassy-sync to 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasKoch committed Jun 17, 2024
1 parent 584bc40 commit 52f9c70
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 11 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ doctest = false
[dependencies]
atat = { version = "0.22", features = ["derive", "bytes"] }
heapless = { version = "^0.8", features = ["serde"] }
nb = "^1"
serde = { version = "^1", default-features = false, features = ["derive"] }
#ublox-sockets = { version = "0.5", optional = true }
ublox-sockets = { git = "https://github.com/BlackbirdHQ/ublox-sockets", branch = "feature/async-borrowed-sockets", optional = true }
embassy-time = "0.3"
embassy-sync = "0.5"
embassy-sync = "0.6"

no-std-net = { version = "^0.6", features = ["serde"] }

Expand Down
2 changes: 1 addition & 1 deletion examples/embassy-rp2040-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ embassy-time = { version = "0.3", features = [
"defmt-timestamp-uptime",
] }
embassy-futures = { version = "0.1", features = ["defmt"] }
embassy-sync = { version = "0.5", features = ["defmt"] }
embassy-sync = { version = "0.6", features = ["defmt"] }

embassy-net = { version = "0.4", features = [
"defmt",
Expand Down
2 changes: 1 addition & 1 deletion examples/tokio-std-example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ tokio-serial = "5.4.1"

embassy-time = { version = "0.3", features = ["std", "generic-queue"] }
embassy-futures = { version = "0.1", features = ["log"] }
embassy-sync = { version = "0.5", features = ["log"] }
embassy-sync = { version = "0.6", features = ["log"] }

embassy-net = { version = "0.4", features = [
"log",
Expand Down
10 changes: 7 additions & 3 deletions src/asynch/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ where
pub async fn factory_reset(&mut self) -> Result<(), Error> {
self.at_client
.send(&crate::command::system_features::SetFactoryConfiguration {
fs_op: crate::command::system_features::types::FSFactoryRestoreType::AllFiles,
fs_op: crate::command::system_features::types::FSFactoryRestoreType::NoRestore,
nvm_op:
crate::command::system_features::types::NVMFactoryRestoreType::NVMFlashSectors,
})
Expand Down Expand Up @@ -439,9 +439,13 @@ where

let model_id = self.at_client.send(&GetModelId).await?;
self.ch.set_module(Module::from_model_id(&model_id));

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

// Echo off
self.at_client.send(&SetEcho { enabled: Echo::Off }).await?;
Expand Down
25 changes: 23 additions & 2 deletions src/asynch/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ where
}
}

pub async fn run(mut self, on_ipv4_up: impl FnMut(embassy_net_ppp::Ipv4Status) + Copy) -> ! {
pub async fn run<D: embassy_net::driver::Driver>(mut self, stack: &embassy_net::Stack<D>) -> ! {
#[cfg(feature = "ppp")]
let mut ppp_runner = self.ppp_runner.take().unwrap();

Expand Down Expand Up @@ -262,7 +262,28 @@ where

info!("RUNNING PPP");
let res = ppp_runner
.run(&mut self.data_channel, C::PPP_CONFIG, on_ipv4_up)
.run(&mut self.data_channel, C::PPP_CONFIG, |ipv4| {
let Some(addr) = ipv4.address else {
warn!("PPP did not provide an IP address.");
return;
};
let mut dns_servers = heapless::Vec::new();
for s in ipv4.dns_servers.iter().flatten() {
let _ =
dns_servers.push(embassy_net::Ipv4Address::from_bytes(&s.0));
}
let config =
embassy_net::ConfigV4::Static(embassy_net::StaticConfigV4 {
address: embassy_net::Ipv4Cidr::new(
embassy_net::Ipv4Address::from_bytes(&addr.0),
0,
),
gateway: None,
dns_servers,
});

stack.set_config_v4(config);
})
.await;

info!("ppp failed: {:?}", res);
Expand Down
2 changes: 0 additions & 2 deletions src/asynch/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ use embassy_sync::blocking_mutex::Mutex;
use embassy_sync::pubsub::PubSubChannel;
use embassy_sync::waitqueue::WakerRegistration;

const MAX_STATE_LISTENERS: usize = 5;

/// The link state of a network device.
#[derive(PartialEq, Eq, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
Expand Down

0 comments on commit 52f9c70

Please sign in to comment.