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

chore(*): transition to core::net #90

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 71 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,72 +10,87 @@ defaults:
run:
shell: bash

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
rustfmt:
name: rustfmt
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
override: true
components: rustfmt

- name: Run rustfmt
uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check --verbose
uses: actions/checkout@v4

clippy:
name: clippy
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy

- name: Run clippy
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --features odin-w2xx,ppp
- uses: dsherret/rust-toolchain-file@v1

- name: Build (library)
run: cargo build --all --target thumbv7em-none-eabihf --features "odin-w2xx,ppp"

# - name: Build (examples)
# run: |
# for EXAMPLE in $(ls examples);
# do
# (cd examples/$EXAMPLE && cargo build)
# done

test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: thumbv7m-none-eabi
override: true

- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --all --target thumbv7m-none-eabi --features odin-w2xx,ppp
uses: actions/checkout@v4

- uses: dsherret/rust-toolchain-file@v1

- name: Test
uses: actions-rs/cargo@v1
with:
command: test
args: --lib --features odin-w2xx,ppp
run: cargo test --features "odin-w2xx,ppp"

- name: Install Miri
run: |
rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup

- name: Test (Miri)
run: cargo miri test --lib --features "odin-w2xx,ppp"

rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- name: Checkout source code

uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1

- name: Run rustfmt (library)
run: cargo fmt --all -- --check --verbose

- name: Run rustfmt (examples)
run: |
for EXAMPLE in $(ls examples);
do
(cd examples/$EXAMPLE && cargo fmt --all -- --check --verbose)
done

clippy:
name: Clippy
runs-on: ubuntu-latest
env:
CLIPPY_PARAMS: -W clippy::all -W clippy::pedantic -W clippy::nursery -W clippy::cargo
steps:
- name: Checkout source code

uses: actions/checkout@v4
- uses: dsherret/rust-toolchain-file@v1

- name: Run clippy (library)
run: cargo clippy --features "odin-w2xx,ppp" -- ${{ env.CLIPPY_PARAMS }}

# - name: Run clippy (examples)
# run: |
# for EXAMPLE in $(ls examples);
# do
# (cd examples/$EXAMPLE && cargo clippy -- ${{ env.CLIPPY_PARAMS }})
# done
22 changes: 10 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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"
Expand Down Expand Up @@ -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" }
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" }
2 changes: 1 addition & 1 deletion examples/rpi-pico/src/bin/embassy-async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/rpi-pico/src/bin/embassy-perf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#![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};
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;
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[toolchain]
channel = "1.79"
channel = "1.80"
components = [ "rust-src", "rustfmt", "llvm-tools" ]
targets = [
"thumbv6m-none-eabi",
Expand Down
2 changes: 1 addition & 1 deletion src/asynch/control.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use core::cell::Cell;
use core::net::Ipv4Addr;
use core::str::FromStr as _;

use atat::AtatCmd;
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;
Expand Down
2 changes: 1 addition & 1 deletion src/asynch/network.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
8 changes: 2 additions & 6 deletions src/asynch/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
2 changes: 1 addition & 1 deletion src/asynch/ublox_stack/dns.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/asynch/ublox_stack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/asynch/ublox_stack/peer_builder.rs
Original file line number Diff line number Diff line change
@@ -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))]
Expand Down
4 changes: 2 additions & 2 deletions src/asynch/ublox_stack/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,13 +656,13 @@ pub mod client {
&self,
host: &str,
addr_type: embedded_nal_async::AddrType,
) -> Result<no_std_net::IpAddr, Self::Error> {
) -> Result<core::net::IpAddr, Self::Error> {
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<usize, Self::Error> {
unimplemented!()
Expand Down
6 changes: 3 additions & 3 deletions src/asynch/ublox_stack/tls.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -301,13 +301,13 @@ pub mod client {
&self,
host: &str,
addr_type: embedded_nal_async::AddrType,
) -> Result<no_std_net::IpAddr, Self::Error> {
) -> Result<core::net::IpAddr, Self::Error> {
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<usize, Self::Error> {
unimplemented!()
Expand Down
2 changes: 1 addition & 1 deletion src/command/edm/types.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/command/edm/urc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion src/command/ethernet/types.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/command/ping/urc.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/command/wifi/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
Loading