Skip to content

Commit 06a7b5c

Browse files
authored
Transition to core::net (#90)
1 parent 6666302 commit 06a7b5c

File tree

20 files changed

+105
-94
lines changed

20 files changed

+105
-94
lines changed

.github/workflows/ci.yml

+71-56
Original file line numberDiff line numberDiff line change
@@ -10,72 +10,87 @@ defaults:
1010
run:
1111
shell: bash
1212

13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
15+
cancel-in-progress: true
16+
1317
jobs:
14-
rustfmt:
15-
name: rustfmt
18+
build:
19+
name: Build
1620
runs-on: ubuntu-latest
1721
steps:
1822
- name: Checkout source code
19-
uses: actions/checkout@v2
20-
21-
- name: Install Rust
22-
uses: actions-rs/toolchain@v1
23-
with:
24-
profile: minimal
25-
toolchain: nightly
26-
override: true
27-
components: rustfmt
28-
29-
- name: Run rustfmt
30-
uses: actions-rs/cargo@v1
31-
with:
32-
command: fmt
33-
args: --all -- --check --verbose
23+
uses: actions/checkout@v4
3424

35-
clippy:
36-
name: clippy
37-
runs-on: ubuntu-latest
38-
steps:
39-
- name: Checkout source code
40-
uses: actions/checkout@v2
41-
42-
- name: Install Rust
43-
uses: actions-rs/toolchain@v1
44-
with:
45-
profile: minimal
46-
toolchain: stable
47-
override: true
48-
components: clippy
49-
50-
- name: Run clippy
51-
uses: actions-rs/clippy-check@v1
52-
with:
53-
token: ${{ secrets.GITHUB_TOKEN }}
54-
args: --features odin-w2xx,ppp
25+
- uses: dsherret/rust-toolchain-file@v1
26+
27+
- name: Build (library)
28+
run: cargo build --all --target thumbv7em-none-eabihf --features "odin-w2xx,ppp"
29+
30+
# - name: Build (examples)
31+
# run: |
32+
# for EXAMPLE in $(ls examples);
33+
# do
34+
# (cd examples/$EXAMPLE && cargo build)
35+
# done
5536

5637
test:
5738
name: Test
5839
runs-on: ubuntu-latest
5940
steps:
6041
- name: Checkout source code
61-
uses: actions/checkout@v2
62-
63-
- name: Install Rust
64-
uses: actions-rs/toolchain@v1
65-
with:
66-
profile: minimal
67-
toolchain: stable
68-
target: thumbv7m-none-eabi
69-
override: true
70-
71-
- name: Build
72-
uses: actions-rs/cargo@v1
73-
with:
74-
command: build
75-
args: --all --target thumbv7m-none-eabi --features odin-w2xx,ppp
42+
uses: actions/checkout@v4
43+
44+
- uses: dsherret/rust-toolchain-file@v1
7645

7746
- name: Test
78-
uses: actions-rs/cargo@v1
79-
with:
80-
command: test
81-
args: --lib --features odin-w2xx,ppp
47+
run: cargo test --features "odin-w2xx,ppp"
48+
49+
- name: Install Miri
50+
run: |
51+
rustup toolchain install nightly --component miri
52+
rustup override set nightly
53+
cargo miri setup
54+
55+
- name: Test (Miri)
56+
run: cargo miri test --lib --features "odin-w2xx,ppp"
57+
58+
rustfmt:
59+
name: Rustfmt
60+
runs-on: ubuntu-latest
61+
steps:
62+
- name: Checkout source code
63+
64+
uses: actions/checkout@v4
65+
- uses: dsherret/rust-toolchain-file@v1
66+
67+
- name: Run rustfmt (library)
68+
run: cargo fmt --all -- --check --verbose
69+
70+
- name: Run rustfmt (examples)
71+
run: |
72+
for EXAMPLE in $(ls examples);
73+
do
74+
(cd examples/$EXAMPLE && cargo fmt --all -- --check --verbose)
75+
done
76+
77+
clippy:
78+
name: Clippy
79+
runs-on: ubuntu-latest
80+
env:
81+
CLIPPY_PARAMS: -W clippy::all -W clippy::pedantic -W clippy::nursery -W clippy::cargo
82+
steps:
83+
- name: Checkout source code
84+
85+
uses: actions/checkout@v4
86+
- uses: dsherret/rust-toolchain-file@v1
87+
88+
- name: Run clippy (library)
89+
run: cargo clippy --features "odin-w2xx,ppp" -- ${{ env.CLIPPY_PARAMS }}
90+
91+
# - name: Run clippy (examples)
92+
# run: |
93+
# for EXAMPLE in $(ls examples);
94+
# do
95+
# (cd examples/$EXAMPLE && cargo clippy -- ${{ env.CLIPPY_PARAMS }})
96+
# done

Cargo.toml

+10-12
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ doctest = false
1818
atat = { version = "0.23", features = ["derive", "bytes"] }
1919

2020
heapless = { version = "^0.8", features = ["serde"] }
21-
no-std-net = { version = "0.6", features = ["serde"] }
2221
serde = { version = "^1", default-features = false, features = ["derive"] }
2322
# ublox-sockets = { version = "0.5", optional = true }
2423
ublox-sockets = { git = "https://github.com/BlackbirdHQ/ublox-sockets", rev = "9f7fe54", optional = true }
@@ -32,7 +31,7 @@ embassy-time = "0.3"
3231
embassy-sync = "0.6"
3332
embassy-futures = "0.1"
3433

35-
embedded-nal-async = { version = "0.7" }
34+
embedded-nal-async = { version = "0.8" }
3635
futures-util = { version = "0.3.29", default-features = false }
3736

3837
embedded-io-async = "0.6"
@@ -83,16 +82,15 @@ exclude = ["examples"]
8382

8483

8584
[patch.crates-io]
86-
no-std-net = { git = "https://github.com/rushmorem/no-std-net", branch = "issue-15" }
8785
atat = { git = "https://github.com/BlackbirdHQ/atat", rev = "a466836" }
8886
# atat = { path = "../atat/atat" }
8987

90-
embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" }
91-
embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" }
92-
embassy-time-driver = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" }
93-
embassy-time-queue-driver = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" }
94-
embassy-net = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" }
95-
embassy-net-driver = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" }
96-
embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" }
97-
embassy-net-ppp = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" }
98-
embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "0ede847" }
88+
embassy-futures = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" }
89+
embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" }
90+
embassy-time-driver = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" }
91+
embassy-time-queue-driver = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" }
92+
embassy-net = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" }
93+
embassy-net-driver = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" }
94+
embassy-net-driver-channel = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" }
95+
embassy-net-ppp = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" }
96+
embassy-sync = { git = "https://github.com/embassy-rs/embassy", rev = "80cb2bc" }

examples/rpi-pico/src/bin/embassy-async.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![allow(incomplete_features)]
77

88
use core::fmt::Write as _;
9+
use core::net::{Ipv4Addr, SocketAddr};
910
use embassy_executor::Spawner;
1011
use embassy_futures::select::{select, Either};
1112
use embassy_rp::gpio::{AnyPin, Input, Level, Output, Pull};
@@ -14,7 +15,6 @@ use embassy_rp::uart::{BufferedInterruptHandler, BufferedUartTx};
1415
use embassy_rp::{bind_interrupts, uart};
1516
use embassy_time::{Duration, Timer};
1617
use embedded_io_async::Write;
17-
use no_std_net::{Ipv4Addr, SocketAddr};
1818
use static_cell::make_static;
1919
use ublox_short_range::asynch::runner::Runner;
2020
use ublox_short_range::asynch::ublox_stack::dns::DnsSocket;

examples/rpi-pico/src/bin/embassy-perf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
#![feature(async_fn_in_trait)]
55
#![allow(incomplete_features)]
66

7+
use core::net::Ipv4Addr;
78
use embassy_executor::Spawner;
89
use embassy_futures::join::join;
910
use embassy_rp::gpio::{Level, Output};
1011
use embassy_rp::peripherals::{PIN_26, UART1};
1112
use embassy_rp::uart::BufferedInterruptHandler;
1213
use embassy_rp::{bind_interrupts, uart};
1314
use embassy_time::{with_timeout, Duration, Timer};
14-
use no_std_net::Ipv4Addr;
1515
use static_cell::make_static;
1616
use ublox_short_range::asynch::runner::Runner;
1717
use ublox_short_range::asynch::ublox_stack::tcp::TcpSocket;

rust-toolchain.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[toolchain]
2-
channel = "1.79"
2+
channel = "1.80"
33
components = [ "rust-src", "rustfmt", "llvm-tools" ]
44
targets = [
55
"thumbv6m-none-eabi",

src/asynch/control.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
use core::cell::Cell;
2+
use core::net::Ipv4Addr;
23
use core::str::FromStr as _;
34

45
use atat::AtatCmd;
56
use atat::{asynch::AtatClient, response_slot::ResponseSlotGuard, UrcChannel};
67
use embassy_sync::{blocking_mutex::raw::NoopRawMutex, channel::Sender};
78
use embassy_time::{with_timeout, Duration, Timer};
89
use heapless::Vec;
9-
use no_std_net::Ipv4Addr;
1010

1111
use crate::command::general::responses::SoftwareVersionResponse;
1212
use crate::command::general::types::FirmwareVersion;

src/asynch/network.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use atat::{asynch::AtatClient, UrcChannel, UrcSubscription};
2+
use core::net::{Ipv4Addr, Ipv6Addr};
23
use core::str::FromStr as _;
34
use embassy_time::{with_timeout, Duration, Timer};
45
use embedded_hal::digital::OutputPin as _;
5-
use no_std_net::{Ipv4Addr, Ipv6Addr};
66

77
use crate::{
88
command::{

src/asynch/runner.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -419,15 +419,11 @@ where
419419
};
420420
let mut dns_servers = heapless::Vec::new();
421421
for s in ipv4.dns_servers.iter().flatten() {
422-
let _ =
423-
dns_servers.push(embassy_net::Ipv4Address::from_bytes(&s.0));
422+
let _ = dns_servers.push(s.clone());
424423
}
425424
let config =
426425
embassy_net::ConfigV4::Static(embassy_net::StaticConfigV4 {
427-
address: embassy_net::Ipv4Cidr::new(
428-
embassy_net::Ipv4Address::from_bytes(&addr.0),
429-
0,
430-
),
426+
address: embassy_net::Ipv4Cidr::new(addr, 0),
431427
gateway: None,
432428
dns_servers,
433429
});

src/asynch/ublox_stack/dns.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use core::{cell::RefCell, future::poll_fn, task::Poll};
22

3+
use core::net::IpAddr;
34
use embassy_sync::waitqueue::WakerRegistration;
45
use embedded_nal_async::AddrType;
5-
use no_std_net::IpAddr;
66

77
use crate::command::ping::types::PingError;
88

src/asynch/ublox_stack/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ use self::dns::{DnsSocket, DnsState, DnsTable};
3232

3333
use super::control::ProxyClient;
3434

35+
use core::net::IpAddr;
3536
use embassy_futures::select;
3637
use embassy_sync::waitqueue::WakerRegistration;
3738
use embassy_time::{Duration, Ticker};
3839
use embedded_nal_async::SocketAddr;
39-
use no_std_net::IpAddr;
4040
use portable_atomic::{AtomicBool, AtomicU8, Ordering};
4141
use ublox_sockets::{
4242
AnySocket, ChannelId, PeerHandle, Socket, SocketHandle, SocketSet, SocketStorage,

src/asynch/ublox_stack/peer_builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::error::Error;
22
use core::fmt::Write;
3+
use core::net::{IpAddr, SocketAddr};
34
use heapless::String;
4-
use no_std_net::{IpAddr, SocketAddr};
55

66
#[derive(Debug, Clone, PartialEq)]
77
#[cfg_attr(feature = "defmt", derive(defmt::Format))]

src/asynch/ublox_stack/tcp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -656,13 +656,13 @@ pub mod client {
656656
&self,
657657
host: &str,
658658
addr_type: embedded_nal_async::AddrType,
659-
) -> Result<no_std_net::IpAddr, Self::Error> {
659+
) -> Result<core::net::IpAddr, Self::Error> {
660660
DnsSocket::new(self.stack).query(host, addr_type).await
661661
}
662662

663663
async fn get_host_by_address(
664664
&self,
665-
_addr: no_std_net::IpAddr,
665+
_addr: core::net::IpAddr,
666666
_result: &mut [u8],
667667
) -> Result<usize, Self::Error> {
668668
unimplemented!()

src/asynch/ublox_stack/tls.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use core::net::SocketAddr;
12
use embassy_time::Duration;
2-
use no_std_net::SocketAddr;
33
use ublox_sockets::TcpState as State;
44

55
use super::peer_builder::SecurityCredentials;
@@ -301,13 +301,13 @@ pub mod client {
301301
&self,
302302
host: &str,
303303
addr_type: embedded_nal_async::AddrType,
304-
) -> Result<no_std_net::IpAddr, Self::Error> {
304+
) -> Result<core::net::IpAddr, Self::Error> {
305305
DnsSocket::new(self.stack).query(host, addr_type).await
306306
}
307307

308308
async fn get_host_by_address(
309309
&self,
310-
_addr: no_std_net::IpAddr,
310+
_addr: core::net::IpAddr,
311311
_result: &mut [u8],
312312
) -> Result<usize, Self::Error> {
313313
unimplemented!()

src/command/edm/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use core::net::{Ipv4Addr, Ipv6Addr};
12
use heapless::Vec;
2-
use no_std_net::{Ipv4Addr, Ipv6Addr};
33
use serde::{Deserialize, Serialize};
44
use ublox_sockets::ChannelId;
55

src/command/edm/urc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use super::types::*;
33
use super::Urc;
44
use atat::helpers::LossyStr;
55
use atat::AtatUrc;
6+
use core::net::{Ipv4Addr, Ipv6Addr};
67
use heapless::Vec;
7-
use no_std_net::{Ipv4Addr, Ipv6Addr};
88
use ublox_sockets::ChannelId;
99

1010
#[allow(clippy::large_enum_variant)]

src/command/ethernet/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Argument and parameter types used by Ethernet Commands and Responses
22
33
use atat::atat_derive::AtatEnum;
4-
use no_std_net::Ipv4Addr;
4+
use core::net::Ipv4Addr;
55

66
use crate::command::OnOff;
77

src/command/ping/urc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Responses for Ping Commands
22
use super::types::*;
33
use atat::atat_derive::AtatResp;
4+
use core::net::IpAddr;
45
use heapless::String;
5-
use no_std_net::IpAddr;
66
/// 16.1 Ping command +UPING
77
///
88
/// The ping command is the common method to know if a remote host is reachable on the Internet.

src/command/wifi/types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
use crate::command::OnOff;
44
use atat::atat_derive::AtatEnum;
55
use atat::heapless_bytes::Bytes;
6+
use core::net::{Ipv4Addr, Ipv6Addr};
67
use heapless::{String, Vec};
7-
use no_std_net::{Ipv4Addr, Ipv6Addr};
88
use serde::Deserialize;
99

1010
#[derive(Clone, PartialEq, AtatEnum)]

0 commit comments

Comments
 (0)