From e5afeee672c2a011ffabd2be46614c4214c9c255 Mon Sep 17 00:00:00 2001 From: Mathias Date: Tue, 29 Oct 2024 12:54:11 +0100 Subject: [PATCH] Transition to core::net --- Cargo.toml | 22 ++++++++++------------ examples/rpi-pico/src/bin/embassy-async.rs | 2 +- examples/rpi-pico/src/bin/embassy-perf.rs | 2 +- rust-toolchain.toml | 2 +- src/asynch/control.rs | 2 +- src/asynch/network.rs | 2 +- src/asynch/runner.rs | 8 ++------ src/asynch/ublox_stack/dns.rs | 2 +- src/asynch/ublox_stack/mod.rs | 2 +- src/asynch/ublox_stack/peer_builder.rs | 2 +- src/asynch/ublox_stack/tcp.rs | 4 ++-- src/asynch/ublox_stack/tls.rs | 6 +++--- src/command/edm/types.rs | 2 +- src/command/edm/urc.rs | 2 +- src/command/ethernet/types.rs | 2 +- src/command/ping/urc.rs | 2 +- src/command/wifi/types.rs | 2 +- src/connection.rs | 4 +++- src/options.rs | 2 +- 19 files changed, 34 insertions(+), 38 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e84312f..8ece450 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,6 @@ doctest = false atat = { version = "0.23", features = ["derive", "bytes"] } 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", optional = true } ublox-sockets = { git = "https://github.com/BlackbirdHQ/ublox-sockets", rev = "9f7fe54", optional = true } @@ -32,7 +31,7 @@ embassy-time = "0.3" embassy-sync = "0.6" embassy-futures = "0.1" -embedded-nal-async = { version = "0.7" } +embedded-nal-async = { version = "0.8" } futures-util = { version = "0.3.29", default-features = false } embedded-io-async = "0.6" @@ -83,16 +82,15 @@ exclude = ["examples"] [patch.crates-io] -no-std-net = { git = "https://github.com/rushmorem/no-std-net", branch = "issue-15" } atat = { git = "https://github.com/BlackbirdHQ/atat", rev = "a466836" } # atat = { path = "../atat/atat" } -embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" } -embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" } -embassy-time-driver = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" } -embassy-time-queue-driver = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" } -embassy-net = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" } -embassy-net-driver = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" } -embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" } -embassy-net-ppp = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" } -embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" } \ No newline at end of file +embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" } +embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" } +embassy-time-driver = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" } +embassy-time-queue-driver = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" } +embassy-net = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" } +embassy-net-driver = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" } +embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" } +embassy-net-ppp = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" } +embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" } \ No newline at end of file diff --git a/examples/rpi-pico/src/bin/embassy-async.rs b/examples/rpi-pico/src/bin/embassy-async.rs index 81090c4..181737f 100644 --- a/examples/rpi-pico/src/bin/embassy-async.rs +++ b/examples/rpi-pico/src/bin/embassy-async.rs @@ -6,6 +6,7 @@ #![allow(incomplete_features)] use core::fmt::Write as _; +use core::net::{Ipv4Addr, SocketAddr}; use embassy_executor::Spawner; use embassy_futures::select::{select, Either}; use embassy_rp::gpio::{AnyPin, Input, Level, Output, Pull}; @@ -14,7 +15,6 @@ use embassy_rp::uart::{BufferedInterruptHandler, BufferedUartTx}; use embassy_rp::{bind_interrupts, uart}; use embassy_time::{Duration, Timer}; use embedded_io_async::Write; -use no_std_net::{Ipv4Addr, SocketAddr}; use static_cell::make_static; use ublox_short_range::asynch::runner::Runner; use ublox_short_range::asynch::ublox_stack::dns::DnsSocket; diff --git a/examples/rpi-pico/src/bin/embassy-perf.rs b/examples/rpi-pico/src/bin/embassy-perf.rs index 630415a..af85989 100644 --- a/examples/rpi-pico/src/bin/embassy-perf.rs +++ b/examples/rpi-pico/src/bin/embassy-perf.rs @@ -4,6 +4,7 @@ #![feature(async_fn_in_trait)] #![allow(incomplete_features)] +use core::net::Ipv4Addr; use embassy_executor::Spawner; use embassy_futures::join::join; use embassy_rp::gpio::{Level, Output}; @@ -11,7 +12,6 @@ use embassy_rp::peripherals::{PIN_26, UART1}; use embassy_rp::uart::BufferedInterruptHandler; use embassy_rp::{bind_interrupts, uart}; use embassy_time::{with_timeout, Duration, Timer}; -use no_std_net::Ipv4Addr; use static_cell::make_static; use ublox_short_range::asynch::runner::Runner; use ublox_short_range::asynch::ublox_stack::tcp::TcpSocket; diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 1dca89f..8e39e38 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.79" +channel = "1.80" components = [ "rust-src", "rustfmt", "llvm-tools" ] targets = [ "thumbv6m-none-eabi", diff --git a/src/asynch/control.rs b/src/asynch/control.rs index fda8cb2..0eaba53 100644 --- a/src/asynch/control.rs +++ b/src/asynch/control.rs @@ -1,4 +1,5 @@ use core::cell::Cell; +use core::net::Ipv4Addr; use core::str::FromStr as _; use atat::AtatCmd; @@ -6,7 +7,6 @@ use atat::{asynch::AtatClient, response_slot::ResponseSlotGuard, UrcChannel}; use embassy_sync::{blocking_mutex::raw::NoopRawMutex, channel::Sender}; use embassy_time::{with_timeout, Duration, Timer}; use heapless::Vec; -use no_std_net::Ipv4Addr; use crate::command::general::responses::SoftwareVersionResponse; use crate::command::general::types::FirmwareVersion; diff --git a/src/asynch/network.rs b/src/asynch/network.rs index 6f28b9e..0e2df88 100644 --- a/src/asynch/network.rs +++ b/src/asynch/network.rs @@ -1,8 +1,8 @@ use atat::{asynch::AtatClient, UrcChannel, UrcSubscription}; +use core::net::{Ipv4Addr, Ipv6Addr}; use core::str::FromStr as _; use embassy_time::{with_timeout, Duration, Timer}; use embedded_hal::digital::OutputPin as _; -use no_std_net::{Ipv4Addr, Ipv6Addr}; use crate::{ command::{ diff --git a/src/asynch/runner.rs b/src/asynch/runner.rs index ae19712..dca3f25 100644 --- a/src/asynch/runner.rs +++ b/src/asynch/runner.rs @@ -419,15 +419,11 @@ where }; 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 _ = dns_servers.push(s.clone()); } let config = embassy_net::ConfigV4::Static(embassy_net::StaticConfigV4 { - address: embassy_net::Ipv4Cidr::new( - embassy_net::Ipv4Address::from_bytes(&addr.0), - 0, - ), + address: embassy_net::Ipv4Cidr::new(addr, 0), gateway: None, dns_servers, }); diff --git a/src/asynch/ublox_stack/dns.rs b/src/asynch/ublox_stack/dns.rs index 00550a2..a503be8 100644 --- a/src/asynch/ublox_stack/dns.rs +++ b/src/asynch/ublox_stack/dns.rs @@ -1,8 +1,8 @@ use core::{cell::RefCell, future::poll_fn, task::Poll}; +use core::net::IpAddr; use embassy_sync::waitqueue::WakerRegistration; use embedded_nal_async::AddrType; -use no_std_net::IpAddr; use crate::command::ping::types::PingError; diff --git a/src/asynch/ublox_stack/mod.rs b/src/asynch/ublox_stack/mod.rs index 07247b6..8d5384e 100644 --- a/src/asynch/ublox_stack/mod.rs +++ b/src/asynch/ublox_stack/mod.rs @@ -32,11 +32,11 @@ use self::dns::{DnsSocket, DnsState, DnsTable}; use super::control::ProxyClient; +use core::net::IpAddr; use embassy_futures::select; use embassy_sync::waitqueue::WakerRegistration; use embassy_time::{Duration, Ticker}; use embedded_nal_async::SocketAddr; -use no_std_net::IpAddr; use portable_atomic::{AtomicBool, AtomicU8, Ordering}; use ublox_sockets::{ AnySocket, ChannelId, PeerHandle, Socket, SocketHandle, SocketSet, SocketStorage, diff --git a/src/asynch/ublox_stack/peer_builder.rs b/src/asynch/ublox_stack/peer_builder.rs index 2e65114..82a266e 100644 --- a/src/asynch/ublox_stack/peer_builder.rs +++ b/src/asynch/ublox_stack/peer_builder.rs @@ -1,7 +1,7 @@ use crate::error::Error; use core::fmt::Write; +use core::net::{IpAddr, SocketAddr}; use heapless::String; -use no_std_net::{IpAddr, SocketAddr}; #[derive(Debug, Clone, PartialEq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] diff --git a/src/asynch/ublox_stack/tcp.rs b/src/asynch/ublox_stack/tcp.rs index 8706313..b911ec4 100644 --- a/src/asynch/ublox_stack/tcp.rs +++ b/src/asynch/ublox_stack/tcp.rs @@ -656,13 +656,13 @@ pub mod client { &self, host: &str, addr_type: embedded_nal_async::AddrType, - ) -> Result { + ) -> Result { DnsSocket::new(self.stack).query(host, addr_type).await } async fn get_host_by_address( &self, - _addr: no_std_net::IpAddr, + _addr: core::net::IpAddr, _result: &mut [u8], ) -> Result { unimplemented!() diff --git a/src/asynch/ublox_stack/tls.rs b/src/asynch/ublox_stack/tls.rs index 327f811..a642524 100644 --- a/src/asynch/ublox_stack/tls.rs +++ b/src/asynch/ublox_stack/tls.rs @@ -1,5 +1,5 @@ +use core::net::SocketAddr; use embassy_time::Duration; -use no_std_net::SocketAddr; use ublox_sockets::TcpState as State; use super::peer_builder::SecurityCredentials; @@ -301,13 +301,13 @@ pub mod client { &self, host: &str, addr_type: embedded_nal_async::AddrType, - ) -> Result { + ) -> Result { DnsSocket::new(self.stack).query(host, addr_type).await } async fn get_host_by_address( &self, - _addr: no_std_net::IpAddr, + _addr: core::net::IpAddr, _result: &mut [u8], ) -> Result { unimplemented!() diff --git a/src/command/edm/types.rs b/src/command/edm/types.rs index 08690cf..95635e0 100644 --- a/src/command/edm/types.rs +++ b/src/command/edm/types.rs @@ -1,5 +1,5 @@ +use core::net::{Ipv4Addr, Ipv6Addr}; use heapless::Vec; -use no_std_net::{Ipv4Addr, Ipv6Addr}; use serde::{Deserialize, Serialize}; use ublox_sockets::ChannelId; diff --git a/src/command/edm/urc.rs b/src/command/edm/urc.rs index 1f78606..2bb4e37 100644 --- a/src/command/edm/urc.rs +++ b/src/command/edm/urc.rs @@ -3,8 +3,8 @@ use super::types::*; use super::Urc; use atat::helpers::LossyStr; use atat::AtatUrc; +use core::net::{Ipv4Addr, Ipv6Addr}; use heapless::Vec; -use no_std_net::{Ipv4Addr, Ipv6Addr}; use ublox_sockets::ChannelId; #[allow(clippy::large_enum_variant)] diff --git a/src/command/ethernet/types.rs b/src/command/ethernet/types.rs index 8c15549..c63f544 100644 --- a/src/command/ethernet/types.rs +++ b/src/command/ethernet/types.rs @@ -1,7 +1,7 @@ //! Argument and parameter types used by Ethernet Commands and Responses use atat::atat_derive::AtatEnum; -use no_std_net::Ipv4Addr; +use core::net::Ipv4Addr; use crate::command::OnOff; diff --git a/src/command/ping/urc.rs b/src/command/ping/urc.rs index 0abc5c7..0fd4002 100644 --- a/src/command/ping/urc.rs +++ b/src/command/ping/urc.rs @@ -1,8 +1,8 @@ //! Responses for Ping Commands use super::types::*; use atat::atat_derive::AtatResp; +use core::net::IpAddr; use heapless::String; -use no_std_net::IpAddr; /// 16.1 Ping command +UPING /// /// The ping command is the common method to know if a remote host is reachable on the Internet. diff --git a/src/command/wifi/types.rs b/src/command/wifi/types.rs index 01774bc..1b996ec 100644 --- a/src/command/wifi/types.rs +++ b/src/command/wifi/types.rs @@ -3,8 +3,8 @@ use crate::command::OnOff; use atat::atat_derive::AtatEnum; use atat::heapless_bytes::Bytes; +use core::net::{Ipv4Addr, Ipv6Addr}; use heapless::{String, Vec}; -use no_std_net::{Ipv4Addr, Ipv6Addr}; use serde::Deserialize; #[derive(Clone, PartialEq, AtatEnum)] diff --git a/src/connection.rs b/src/connection.rs index a1b44d0..3371342 100644 --- a/src/connection.rs +++ b/src/connection.rs @@ -1,4 +1,4 @@ -use no_std_net::Ipv4Addr; +use core::net::Ipv4Addr; use crate::network::{WifiMode, WifiNetwork}; @@ -50,6 +50,7 @@ impl WifiConnection { } } + #[allow(dead_code)] pub fn is_station(&self) -> bool { self.network .as_ref() @@ -57,6 +58,7 @@ impl WifiConnection { .unwrap_or_default() } + #[allow(dead_code)] pub fn is_access_point(&self) -> bool { !self.is_station() } diff --git a/src/options.rs b/src/options.rs index c51bdc2..f77850d 100644 --- a/src/options.rs +++ b/src/options.rs @@ -1,5 +1,5 @@ +use core::net::Ipv4Addr; use heapless::Vec; -use no_std_net::Ipv4Addr; #[allow(dead_code)] #[derive(Debug, Clone, Copy)]