Update embassy

This commit is contained in:
Dario Nieuwenhuis 2021-03-02 21:20:00 +01:00
parent f100383b3c
commit 9bee576fd2
12 changed files with 32 additions and 21 deletions

View File

@ -1,2 +0,0 @@
[unstable]
namespaced-features = true

View File

@ -21,4 +21,4 @@ jobs:
target: thumbv7em-none-eabi
override: true
- name: Build
run: ./test-build.sh
run: ./ci.sh

6
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,6 @@
{
"editor.formatOnSave": true,
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.cargo.loadOutDirsFromCheck": true,
"rust-analyzer.assist.importMergeBehavior": "last",
}

View File

@ -45,4 +45,5 @@ overflow-checks = false
embassy = { git = "https://github.com/akiles/embassy" }
embassy-std = { 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" }

View File

@ -7,7 +7,7 @@ set -euxo pipefail
# build for embedded
(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
(cd embassy-net-examples; cargo build)

View File

@ -1,8 +1,7 @@
#![feature(type_alias_impl_trait)]
use embassy::executor::{Spawner, task};
use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
use embassy::time::{Duration, Timer};
use embassy::executor::{task, Spawner};
use embassy::io::AsyncWriteExt;
use embassy::util::Forever;
use embassy_net::*;
use embassy_std::Executor;

View File

@ -1,11 +1,11 @@
use async_io::Async;
use embassy::util::WakerRegistration;
use libc;
use log::*;
use smoltcp::wire::EthernetFrame;
use std::io;
use std::io::{Read, Write};
use std::os::unix::io::{AsRawFd, RawFd};
use log::*;
pub const SIOCGIFMTU: libc::c_ulong = 0x8921;
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 embassy_net::{DeviceCapabilities, LinkState, Packet, PacketBox, PacketBuf};
impl crate::Device for TunTapDevice {
fn is_transmit_ready(&mut self) -> bool {
@ -197,4 +197,8 @@ impl crate::Device for TunTapDevice {
fn link_state(&mut self) -> LinkState {
LinkState::Up
}
fn ethernet_address(&mut self) -> [u8; 6] {
[0x02, 0x03, 0x04, 0x05, 0x06, 0x07]
}
}

View File

@ -11,11 +11,10 @@ defmt-debug = []
defmt-info = []
defmt-warn = []
defmt-error = []
defmt = [ "dep:defmt", "smoltcp/defmt" ]
[dependencies]
defmt = { version = "0.1.3", optional = true }
defmt = { version = "0.2.0", optional = true }
log = { version = "0.4.11", optional = true }
embassy = { version = "0.1.0" }

View File

@ -1,13 +1,13 @@
use embassy::util::Forever;
use heapless::consts::*;
use heapless::Vec;
use smoltcp::dhcp::Dhcpv4Client;
use smoltcp::socket::{RawPacketMetadata, RawSocketBuffer};
use smoltcp::time::Instant;
use smoltcp::wire::{Ipv4Address, Ipv4Cidr};
use smoltcp::wire::Ipv4Address;
use super::*;
use crate::{device::LinkState, fmt::*};
use crate::device::LinkState;
use crate::fmt::*;
use crate::{Interface, SocketSet};
pub struct DhcpResources {

View File

@ -1,11 +1,11 @@
use core::task::{Poll, Waker};
use core::task::Waker;
use smoltcp::phy::Device as SmolDevice;
use smoltcp::phy::DeviceCapabilities;
use smoltcp::time::Instant as SmolInstant;
use crate::fmt::*;
use crate::{Packet, PacketBox, PacketBuf};
use crate::Result;
use crate::{Packet, PacketBox, PacketBuf};
#[derive(PartialEq, Eq, Clone, Copy)]
pub enum LinkState {
@ -21,7 +21,7 @@ pub trait Device {
fn register_waker(&mut self, waker: &Waker);
fn capabilities(&mut self) -> DeviceCapabilities;
fn link_state(&mut self) -> LinkState;
fn ethernet_address(&mut self) -> [u8;6];
fn ethernet_address(&mut self) -> [u8; 6];
}
pub struct DeviceAdapter {
@ -92,7 +92,7 @@ pub struct 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
F: FnOnce(&mut [u8]) -> Result<R>,
{

View File

@ -1,7 +1,7 @@
use core::cell::RefCell;
use core::future::Future;
use core::task::Context;
use core::task::Poll;
use core::{cell::RefCell, future};
use embassy::time::{Instant, Timer};
use embassy::util::ThreadModeMutex;
use embassy::util::{Forever, WakerRegistration};
@ -110,7 +110,7 @@ impl Stack {
self.waker.register(cx.waker());
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.
cx.waker().wake_by_ref();
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 local_port = LOCAL_PORT_MIN;
/*
let local_port = loop {
let mut res = [0u8; 2];
embassy::rand::rand(&mut res);
@ -182,6 +185,7 @@ pub fn init(device: &'static mut dyn Device, configurator: &'static mut dyn Conf
break port;
}
};
*/
let stack = Stack {
iface,

View File

@ -111,7 +111,7 @@ impl<'a> TcpSocket<'a> {
}
}
fn to_ioerr(e: Error) -> io::Error {
fn to_ioerr(_err: Error) -> io::Error {
// todo
io::Error::Other
}