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,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
}