Update embassy
This commit is contained in:
parent
f100383b3c
commit
9bee576fd2
@ -1,2 +0,0 @@
|
|||||||
[unstable]
|
|
||||||
namespaced-features = true
|
|
2
.github/workflows/rust.yml
vendored
2
.github/workflows/rust.yml
vendored
@ -21,4 +21,4 @@ jobs:
|
|||||||
target: thumbv7em-none-eabi
|
target: thumbv7em-none-eabi
|
||||||
override: true
|
override: true
|
||||||
- name: Build
|
- name: Build
|
||||||
run: ./test-build.sh
|
run: ./ci.sh
|
||||||
|
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"rust-analyzer.procMacro.enable": true,
|
||||||
|
"rust-analyzer.cargo.loadOutDirsFromCheck": true,
|
||||||
|
"rust-analyzer.assist.importMergeBehavior": "last",
|
||||||
|
}
|
@ -45,4 +45,5 @@ overflow-checks = false
|
|||||||
embassy = { git = "https://github.com/akiles/embassy" }
|
embassy = { git = "https://github.com/akiles/embassy" }
|
||||||
embassy-std = { git = "https://github.com/akiles/embassy" }
|
embassy-std = { git = "https://github.com/akiles/embassy" }
|
||||||
embassy-macros = { git = "https://github.com/akiles/embassy" }
|
embassy-macros = { git = "https://github.com/akiles/embassy" }
|
||||||
|
embassy-traits = { git = "https://github.com/akiles/embassy" }
|
||||||
smoltcp = { git = "https://github.com/akiles/smoltcp" }
|
smoltcp = { git = "https://github.com/akiles/smoltcp" }
|
@ -7,7 +7,7 @@ set -euxo pipefail
|
|||||||
|
|
||||||
# build for embedded
|
# build for embedded
|
||||||
(cd embassy-net; cargo build --target thumbv7em-none-eabi --features log)
|
(cd embassy-net; cargo build --target thumbv7em-none-eabi --features log)
|
||||||
(cd embassy-net; cargo build --target thumbv7em-none-eabi --features defmt)
|
(cd embassy-net; cargo build --target thumbv7em-none-eabi --features defmt,smoltcp/defmt)
|
||||||
|
|
||||||
# build examples
|
# build examples
|
||||||
(cd embassy-net-examples; cargo build)
|
(cd embassy-net-examples; cargo build)
|
@ -1,8 +1,7 @@
|
|||||||
#![feature(type_alias_impl_trait)]
|
#![feature(type_alias_impl_trait)]
|
||||||
|
|
||||||
use embassy::executor::{Spawner, task};
|
use embassy::executor::{task, Spawner};
|
||||||
use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
|
use embassy::io::AsyncWriteExt;
|
||||||
use embassy::time::{Duration, Timer};
|
|
||||||
use embassy::util::Forever;
|
use embassy::util::Forever;
|
||||||
use embassy_net::*;
|
use embassy_net::*;
|
||||||
use embassy_std::Executor;
|
use embassy_std::Executor;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use async_io::Async;
|
use async_io::Async;
|
||||||
use embassy::util::WakerRegistration;
|
use embassy::util::WakerRegistration;
|
||||||
use libc;
|
use libc;
|
||||||
|
use log::*;
|
||||||
use smoltcp::wire::EthernetFrame;
|
use smoltcp::wire::EthernetFrame;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::{Read, Write};
|
use std::io::{Read, Write};
|
||||||
use std::os::unix::io::{AsRawFd, RawFd};
|
use std::os::unix::io::{AsRawFd, RawFd};
|
||||||
use log::*;
|
|
||||||
|
|
||||||
pub const SIOCGIFMTU: libc::c_ulong = 0x8921;
|
pub const SIOCGIFMTU: libc::c_ulong = 0x8921;
|
||||||
pub const SIOCGIFINDEX: libc::c_ulong = 0x8933;
|
pub const SIOCGIFINDEX: libc::c_ulong = 0x8933;
|
||||||
@ -142,8 +142,8 @@ impl TunTapDevice {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use embassy_net::{LinkState, DeviceCapabilities, Packet, PacketBox, PacketBuf};
|
|
||||||
use core::task::Waker;
|
use core::task::Waker;
|
||||||
|
use embassy_net::{DeviceCapabilities, LinkState, Packet, PacketBox, PacketBuf};
|
||||||
|
|
||||||
impl crate::Device for TunTapDevice {
|
impl crate::Device for TunTapDevice {
|
||||||
fn is_transmit_ready(&mut self) -> bool {
|
fn is_transmit_ready(&mut self) -> bool {
|
||||||
@ -197,4 +197,8 @@ impl crate::Device for TunTapDevice {
|
|||||||
fn link_state(&mut self) -> LinkState {
|
fn link_state(&mut self) -> LinkState {
|
||||||
LinkState::Up
|
LinkState::Up
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn ethernet_address(&mut self) -> [u8; 6] {
|
||||||
|
[0x02, 0x03, 0x04, 0x05, 0x06, 0x07]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,10 @@ defmt-debug = []
|
|||||||
defmt-info = []
|
defmt-info = []
|
||||||
defmt-warn = []
|
defmt-warn = []
|
||||||
defmt-error = []
|
defmt-error = []
|
||||||
defmt = [ "dep:defmt", "smoltcp/defmt" ]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
defmt = { version = "0.1.3", optional = true }
|
defmt = { version = "0.2.0", optional = true }
|
||||||
log = { version = "0.4.11", optional = true }
|
log = { version = "0.4.11", optional = true }
|
||||||
|
|
||||||
embassy = { version = "0.1.0" }
|
embassy = { version = "0.1.0" }
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
use embassy::util::Forever;
|
use embassy::util::Forever;
|
||||||
use heapless::consts::*;
|
|
||||||
use heapless::Vec;
|
use heapless::Vec;
|
||||||
use smoltcp::dhcp::Dhcpv4Client;
|
use smoltcp::dhcp::Dhcpv4Client;
|
||||||
use smoltcp::socket::{RawPacketMetadata, RawSocketBuffer};
|
use smoltcp::socket::{RawPacketMetadata, RawSocketBuffer};
|
||||||
use smoltcp::time::Instant;
|
use smoltcp::time::Instant;
|
||||||
use smoltcp::wire::{Ipv4Address, Ipv4Cidr};
|
use smoltcp::wire::Ipv4Address;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{device::LinkState, fmt::*};
|
use crate::device::LinkState;
|
||||||
|
use crate::fmt::*;
|
||||||
use crate::{Interface, SocketSet};
|
use crate::{Interface, SocketSet};
|
||||||
|
|
||||||
pub struct DhcpResources {
|
pub struct DhcpResources {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
use core::task::{Poll, Waker};
|
use core::task::Waker;
|
||||||
use smoltcp::phy::Device as SmolDevice;
|
use smoltcp::phy::Device as SmolDevice;
|
||||||
use smoltcp::phy::DeviceCapabilities;
|
use smoltcp::phy::DeviceCapabilities;
|
||||||
use smoltcp::time::Instant as SmolInstant;
|
use smoltcp::time::Instant as SmolInstant;
|
||||||
|
|
||||||
use crate::fmt::*;
|
use crate::fmt::*;
|
||||||
use crate::{Packet, PacketBox, PacketBuf};
|
|
||||||
use crate::Result;
|
use crate::Result;
|
||||||
|
use crate::{Packet, PacketBox, PacketBuf};
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Clone, Copy)]
|
#[derive(PartialEq, Eq, Clone, Copy)]
|
||||||
pub enum LinkState {
|
pub enum LinkState {
|
||||||
@ -21,7 +21,7 @@ pub trait Device {
|
|||||||
fn register_waker(&mut self, waker: &Waker);
|
fn register_waker(&mut self, waker: &Waker);
|
||||||
fn capabilities(&mut self) -> DeviceCapabilities;
|
fn capabilities(&mut self) -> DeviceCapabilities;
|
||||||
fn link_state(&mut self) -> LinkState;
|
fn link_state(&mut self) -> LinkState;
|
||||||
fn ethernet_address(&mut self) -> [u8;6];
|
fn ethernet_address(&mut self) -> [u8; 6];
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DeviceAdapter {
|
pub struct DeviceAdapter {
|
||||||
@ -92,7 +92,7 @@ pub struct TxToken<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> smoltcp::phy::TxToken for TxToken<'a> {
|
impl<'a> smoltcp::phy::TxToken for TxToken<'a> {
|
||||||
fn consume<R, F>(mut self, _timestamp: SmolInstant, len: usize, f: F) -> Result<R>
|
fn consume<R, F>(self, _timestamp: SmolInstant, len: usize, f: F) -> Result<R>
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut [u8]) -> Result<R>,
|
F: FnOnce(&mut [u8]) -> Result<R>,
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
use core::cell::RefCell;
|
||||||
use core::future::Future;
|
use core::future::Future;
|
||||||
use core::task::Context;
|
use core::task::Context;
|
||||||
use core::task::Poll;
|
use core::task::Poll;
|
||||||
use core::{cell::RefCell, future};
|
|
||||||
use embassy::time::{Instant, Timer};
|
use embassy::time::{Instant, Timer};
|
||||||
use embassy::util::ThreadModeMutex;
|
use embassy::util::ThreadModeMutex;
|
||||||
use embassy::util::{Forever, WakerRegistration};
|
use embassy::util::{Forever, WakerRegistration};
|
||||||
@ -110,7 +110,7 @@ impl Stack {
|
|||||||
self.waker.register(cx.waker());
|
self.waker.register(cx.waker());
|
||||||
|
|
||||||
let timestamp = instant_to_smoltcp(Instant::now());
|
let timestamp = instant_to_smoltcp(Instant::now());
|
||||||
if let Err(e) = self.iface.poll(&mut self.sockets, timestamp) {
|
if let Err(_) = self.iface.poll(&mut self.sockets, timestamp) {
|
||||||
// If poll() returns error, it may not be done yet, so poll again later.
|
// If poll() returns error, it may not be done yet, so poll again later.
|
||||||
cx.waker().wake_by_ref();
|
cx.waker().wake_by_ref();
|
||||||
return;
|
return;
|
||||||
@ -174,6 +174,9 @@ pub fn init(device: &'static mut dyn Device, configurator: &'static mut dyn Conf
|
|||||||
|
|
||||||
let sockets = SocketSet::new(&mut res.sockets[..]);
|
let sockets = SocketSet::new(&mut res.sockets[..]);
|
||||||
|
|
||||||
|
let local_port = LOCAL_PORT_MIN;
|
||||||
|
|
||||||
|
/*
|
||||||
let local_port = loop {
|
let local_port = loop {
|
||||||
let mut res = [0u8; 2];
|
let mut res = [0u8; 2];
|
||||||
embassy::rand::rand(&mut res);
|
embassy::rand::rand(&mut res);
|
||||||
@ -182,6 +185,7 @@ pub fn init(device: &'static mut dyn Device, configurator: &'static mut dyn Conf
|
|||||||
break port;
|
break port;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
let stack = Stack {
|
let stack = Stack {
|
||||||
iface,
|
iface,
|
||||||
|
@ -111,7 +111,7 @@ impl<'a> TcpSocket<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_ioerr(e: Error) -> io::Error {
|
fn to_ioerr(_err: Error) -> io::Error {
|
||||||
// todo
|
// todo
|
||||||
io::Error::Other
|
io::Error::Other
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user