Skip to content

Commit

Permalink
Update dependencies and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MathiasKoch committed Dec 29, 2023
1 parent 0e92703 commit 8d14964
Show file tree
Hide file tree
Showing 30 changed files with 559 additions and 343 deletions.
55 changes: 34 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,31 @@ name = "ublox_short_range"
doctest = false

[dependencies]
atat = { version = "0.19.0", features = ["derive", "defmt", "bytes"] }
atat = { version = "0.20.0", features = ["derive", "bytes"] }
# atat = { git = "https://github.com/BlackbirdHQ/atat", rev = "70283be", features = ["derive", "defmt", "bytes"] }
heapless = { version = "^0.7", features = ["serde", "defmt-impl"] }
heapless = { version = "^0.8", features = ["serde"] }
no-std-net = { version = "0.6", features = ["serde"] }
serde = { version = "^1", default-features = false, features = ["derive"] }
ublox-sockets = { version = "0.5", features = [
"defmt",
"edm",
], optional = true }
ublox-sockets = { version = "0.5", features = ["edm"], optional = true }
postcard = "1.0.4"
smoltcp = { version = "0.9.1", default-features = false, optional = true }
atomic-polyfill = "1.0.2"

defmt = { version = "0.3" }
embedded-hal = "=1.0.0-rc.1"
# embedded-nal = "0.6.0"
embassy-time = "0.1"
embassy-sync = "0.2"
portable-atomic = "1.5"

defmt = { version = "0.3", optional = true }
log = { version = "0.4.14", optional = true }

embedded-hal = "=1.0.0-rc.3"
embassy-time = "0.2"
embassy-sync = "0.5"
embassy-futures = "0.1"
embassy-net-driver = "0.1"
embassy-net-driver = "0.2"

embedded-nal-async = { version = "0.5", optional = true }
embedded-nal-async = { version = "0.7", optional = true }
futures = { version = "0.3.17", default-features = false, features = [
"async-await",
] }

embedded-io = "0.5"
embedded-io-async = "0.5"
embedded-io = "0.6"
embedded-io-async = "0.6"

[features]
default = ["async", "odin_w2xx", "ublox-sockets", "socket-tcp"]
Expand All @@ -51,7 +48,13 @@ async = ["dep:embedded-nal-async", "atat/async", "ublox-sockets?/async"]

std = []

defmt = ["postcard/use-defmt"]
defmt = [
"dep:defmt",
"postcard/use-defmt",
"heapless/defmt-03",
"atat/defmt",
"ublox-sockets/defmt",
]

odin_w2xx = []
nina_w1xx = []
Expand All @@ -60,8 +63,14 @@ anna_b1xx = []
nina_b2xx = []
nina_b3xx = []

socket-tcp = ["ublox-sockets?/socket-tcp", "smoltcp?/socket-tcp"]
socket-udp = ["ublox-sockets?/socket-udp", "smoltcp?/socket-udp"]
socket-tcp = [
"ublox-sockets?/socket-tcp",
# "smoltcp?/socket-tcp"
]
socket-udp = [
"ublox-sockets?/socket-udp",
# "smoltcp?/socket-udp"
]

[workspace]
members = []
Expand All @@ -73,4 +82,8 @@ exclude = ["examples"]
atat = { path = "../atat/atat" }
ublox-sockets = { path = "../ublox-sockets" }
no-std-net = { path = "../no-std-net" }

embassy-time = { path = "../embassy/embassy-time" }
embassy-sync = { path = "../embassy/embassy-sync" }
embassy-futures = { path = "../embassy/embassy-futures" }
embassy-net-driver = { path = "../embassy/embassy-net-driver" }
17 changes: 8 additions & 9 deletions examples/rpi-pico/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ edition = "2021"


[dependencies]
ublox-short-range-rs = { path = "../../", features = ["async", "defmt", "odin_w2xx", "ublox-sockets", "socket-tcp"] }
embassy-executor = { version = "0.1.0", features = ["defmt", "integrated-timers", "nightly"] }
embassy-time = { version = "0.1.0", features = ["defmt", "defmt-timestamp-uptime"] }
embassy-rp = { version = "0.1.0", features = ["defmt", "unstable-traits", "nightly", "unstable-pac", "time-driver"] }
ublox-short-range-rs = { path = "../../", features = ["async", "odin_w2xx", "ublox-sockets", "socket-tcp"] }
embassy-executor = { version = "0.4", features = ["defmt", "integrated-timers", "nightly"] }
embassy-time = { version = "0.2", features = ["defmt", "defmt-timestamp-uptime"] }
embassy-rp = { version = "0.1.0", features = ["defmt", "unstable-pac", "time-driver"] }
embassy-futures = { version = "0.1.0" }
atomic-polyfill = "1.0.2"
no-std-net = { version = "0.6", features = ["serde"] }

static_cell = { version = "1.1", features = ["nightly"] }
static_cell = { version = "2", features = ["nightly"] }
defmt = "0.3.4"
defmt-rtt = "0.3"
defmt-rtt = "0.4"
panic-probe = { version = "0.3", features = ["print-defmt"] }

cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0"
futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] }

embedded-io-async = { version = "0.5.0" }
heapless = "0.7.15"
embedded-io-async = { version = "0.6" }
heapless = "0.8"


[patch.crates-io]
Expand Down
61 changes: 25 additions & 36 deletions examples/rpi-pico/src/bin/embassy-async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,22 @@ async fn echo_task(
let ip_addr = match DnsSocket::new(stack).query(hostname, AddrType::IPv4).await {
Ok(ip) => ip,
Err(_) => {
defmt::error!("[{}] Failed to resolve IP addr", hostname);
error!("[{}] Failed to resolve IP addr", hostname);
return;
}
};

let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer);

defmt::info!(
"[{}] Connecting... {}",
hostname,
defmt::Debug2Format(&ip_addr)
);
info!("[{}] Connecting... {}", hostname, debug2Format(&ip_addr));
if let Err(e) = socket.connect((ip_addr, port)).await {
defmt::warn!("[{}] connect error: {:?}", hostname, e);
warn!("[{}] connect error: {:?}", hostname, e);
return;
}
defmt::info!(
info!(
"[{}] Connected to {:?}",
hostname,
defmt::Debug2Format(&socket.remote_endpoint())
debug2Format(&socket.remote_endpoint())
);

loop {
Expand All @@ -96,25 +92,25 @@ async fn echo_task(
write!(msg, "Hello {}! {}\n", ip_addr, cnt).unwrap();
cnt = cnt.wrapping_add(1);
if let Err(e) = socket.write_all(msg.as_bytes()).await {
defmt::warn!("[{}] write error: {:?}", hostname, e);
warn!("[{}] write error: {:?}", hostname, e);
break;
}
defmt::info!("[{}] txd: {}", hostname, msg);
info!("[{}] txd: {}", hostname, msg);
Timer::after(Duration::from_millis(400)).await;
}
Either::Second(res) => {
let n = match res {
Ok(0) => {
defmt::warn!("[{}] read EOF", hostname);
warn!("[{}] read EOF", hostname);
break;
}
Ok(n) => n,
Err(e) => {
defmt::warn!("[{}] {:?}", hostname, e);
warn!("[{}] {:?}", hostname, e);
break;
}
};
defmt::info!(
info!(
"[{}] rxd {}",
hostname,
core::str::from_utf8(&buf[..n]).unwrap()
Expand All @@ -138,7 +134,7 @@ bind_interrupts!(struct Irqs {

#[embassy_executor::main]
async fn main(spawner: Spawner) {
defmt::info!("Hello World!");
info!("Hello World!");

let p = embassy_rp::init(Default::default());

Expand All @@ -164,11 +160,7 @@ async fn main(spawner: Spawner) {
let (rx, tx) = uart.split();

let buffers = &*make_static!(atat::Buffers::new());
let (ingress, client) = buffers.split(
tx,
EdmDigester::default(),
atat::Config::new(),
);
let (ingress, client) = buffers.split(tx, EdmDigester::default(), atat::Config::new());
defmt::unwrap!(spawner.spawn(ingress_task(ingress, rx)));

let state = make_static!(State::new(client));
Expand All @@ -190,7 +182,7 @@ async fn main(spawner: Spawner) {
defmt::unwrap!(spawner.spawn(net_task(stack)));

// And now we can use it!
defmt::info!("Device initialized!");
info!("Device initialized!");

let mut rx_buffer = [0; 256];
let mut tx_buffer = [0; 256];
Expand All @@ -202,7 +194,7 @@ async fn main(spawner: Spawner) {
loop {
match control.join_wpa2("test", "1234abcd").await {
Ok(_) => {
defmt::info!("Network connected!");
info!("Network connected!");
spawner
.spawn(echo_task(
&stack,
Expand All @@ -225,7 +217,7 @@ async fn main(spawner: Spawner) {
break;
}
Err(err) => {
defmt::info!("join failed with error={:?}. Retrying in 1 second", err);
info!("join failed with error={:?}. Retrying in 1 second", err);
Timer::after(Duration::from_secs(1)).await;
}
}
Expand All @@ -237,15 +229,12 @@ async fn main(spawner: Spawner) {
// // socket.set_timeout(Some(Duration::from_secs(10)));

let remote: SocketAddr = (Ipv4Addr::new(192, 168, 1, 183), 4444).into();
defmt::info!("Connecting... {}", defmt::Debug2Format(&remote));
info!("Connecting... {}", debug2Format(&remote));
if let Err(e) = socket.connect(remote).await {
defmt::warn!("connect error: {:?}", e);
warn!("connect error: {:?}", e);
continue;
}
defmt::info!(
"Connected to {:?}",
defmt::Debug2Format(&socket.remote_endpoint())
);
info!("Connected to {:?}", debug2Format(&socket.remote_endpoint()));

'inner: loop {
match select(Timer::after(Duration::from_secs(3)), socket.read(&mut buf)).await {
Expand All @@ -254,25 +243,25 @@ async fn main(spawner: Spawner) {
write!(msg, "Hello world! {}\n", cnt).unwrap();
cnt = cnt.wrapping_add(1);
if let Err(e) = socket.write_all(msg.as_bytes()).await {
defmt::warn!("write error: {:?}", e);
warn!("write error: {:?}", e);
break;
}
defmt::info!("txd: {}", msg);
info!("txd: {}", msg);
Timer::after(Duration::from_millis(400)).await;
}
Either::Second(res) => {
let n = match res {
Ok(0) => {
defmt::warn!("read EOF");
warn!("read EOF");
break;
}
Ok(n) => n,
Err(e) => {
defmt::warn!("{:?}", e);
warn!("{:?}", e);
break;
}
};
defmt::info!("rxd [{}] {}", n, core::str::from_utf8(&buf[..n]).unwrap());
info!("rxd [{}] {}", n, core::str::from_utf8(&buf[..n]).unwrap());

match &buf[..n] {
b"c\n" => {
Expand All @@ -296,11 +285,11 @@ async fn main(spawner: Spawner) {
}
}
}
defmt::info!("Press USER button to reconnect socket!");
info!("Press USER button to reconnect socket!");
btn.wait_for_any_edge().await;
continue;
}
defmt::info!("Press USER button to reconnect to WiFi!");
info!("Press USER button to reconnect to WiFi!");
btn.wait_for_any_edge().await;
}
}
Loading

0 comments on commit 8d14964

Please sign in to comment.