Updating embedded-nal version
This commit is contained in:
parent
270436affa
commit
09db1687dd
4 changed files with 20 additions and 12 deletions
|
|
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- [breaking] The driver now uses the v1.0 of the `embedded-hal` traits.
|
- [breaking] The driver now uses the v1.0 of the `embedded-hal` traits.
|
||||||
- [breaking] The `FourWireRef` bus and `DeviceRefMut` have been removed in favor of using
|
- [breaking] The `FourWireRef` bus and `DeviceRefMut` have been removed in favor of using
|
||||||
`embedded-hal-bus` to facilitate SPI bus sharing.
|
`embedded-hal-bus` to facilitate SPI bus sharing.
|
||||||
|
- [breaking] Updated to `embedded-nal` v0.8
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ no-chip-version-assertion = []
|
||||||
[dependencies]
|
[dependencies]
|
||||||
byteorder = { version = "1.3.4", default-features = false }
|
byteorder = { version = "1.3.4", default-features = false }
|
||||||
embedded-hal = "1"
|
embedded-hal = "1"
|
||||||
embedded-nal = "0.6.0"
|
embedded-nal = "0.8.0"
|
||||||
bit_field = "0.10"
|
bit_field = "0.10"
|
||||||
derive-try-from-primitive = "1"
|
derive-try-from-primitive = "1"
|
||||||
nb = "1.0.0"
|
nb = "1.0.0"
|
||||||
|
|
|
||||||
|
|
@ -24,9 +24,9 @@ impl Default for HostConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
mac: MacAddress::default(),
|
mac: MacAddress::default(),
|
||||||
ip: Ipv4Addr::unspecified(),
|
ip: Ipv4Addr::UNSPECIFIED,
|
||||||
gateway: Ipv4Addr::unspecified(),
|
gateway: Ipv4Addr::UNSPECIFIED,
|
||||||
subnet: Ipv4Addr::unspecified(),
|
subnet: Ipv4Addr::UNSPECIFIED,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
23
src/tcp.rs
23
src/tcp.rs
|
|
@ -5,7 +5,9 @@ use crate::{
|
||||||
socket::Socket,
|
socket::Socket,
|
||||||
};
|
};
|
||||||
|
|
||||||
use embedded_nal::{nb, IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4, TcpClientStack};
|
use embedded_nal::{
|
||||||
|
nb, IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4, TcpClientStack, TcpError, TcpErrorKind,
|
||||||
|
};
|
||||||
|
|
||||||
use core::convert::TryFrom;
|
use core::convert::TryFrom;
|
||||||
|
|
||||||
|
|
@ -13,12 +15,21 @@ use core::convert::TryFrom;
|
||||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
pub enum TcpSocketError<E: core::fmt::Debug> {
|
pub enum TcpSocketError<E: core::fmt::Debug> {
|
||||||
NoMoreSockets,
|
NoMoreSockets,
|
||||||
NotReady,
|
NotConnected,
|
||||||
UnsupportedAddress,
|
UnsupportedAddress,
|
||||||
Other(#[cfg_attr(feature = "defmt", defmt(Debug2Format))] E),
|
Other(#[cfg_attr(feature = "defmt", defmt(Debug2Format))] E),
|
||||||
UnsupportedMode,
|
UnsupportedMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<E: core::fmt::Debug> TcpError for TcpSocketError<E> {
|
||||||
|
fn kind(&self) -> TcpErrorKind {
|
||||||
|
match self {
|
||||||
|
TcpSocketError::NotConnected => TcpErrorKind::PipeClosed,
|
||||||
|
_ => TcpErrorKind::Other,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<E: core::fmt::Debug> From<E> for TcpSocketError<E> {
|
impl<E: core::fmt::Debug> From<E> for TcpSocketError<E> {
|
||||||
fn from(e: E) -> Self {
|
fn from(e: E) -> Self {
|
||||||
TcpSocketError::Other(e)
|
TcpSocketError::Other(e)
|
||||||
|
|
@ -135,7 +146,7 @@ impl TcpSocket {
|
||||||
data: &[u8],
|
data: &[u8],
|
||||||
) -> Result<usize, TcpSocketError<B::Error>> {
|
) -> Result<usize, TcpSocketError<B::Error>> {
|
||||||
if !self.socket_is_connected(bus)? {
|
if !self.socket_is_connected(bus)? {
|
||||||
return Err(TcpSocketError::NotReady);
|
return Err(TcpSocketError::NotConnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
let max_size = self.socket.get_tx_free_size(bus)? as usize;
|
let max_size = self.socket.get_tx_free_size(bus)? as usize;
|
||||||
|
|
@ -171,7 +182,7 @@ impl TcpSocket {
|
||||||
data: &mut [u8],
|
data: &mut [u8],
|
||||||
) -> Result<usize, TcpSocketError<B::Error>> {
|
) -> Result<usize, TcpSocketError<B::Error>> {
|
||||||
if !self.socket_is_connected(bus)? {
|
if !self.socket_is_connected(bus)? {
|
||||||
return Err(TcpSocketError::NotReady);
|
return Err(TcpSocketError::NotConnected);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we've received data.
|
// Check if we've received data.
|
||||||
|
|
@ -231,10 +242,6 @@ impl<SpiBus: Bus, StateImpl: State> TcpClientStack for Device<SpiBus, StateImpl>
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_connected(&mut self, socket: &Self::TcpSocket) -> Result<bool, Self::Error> {
|
|
||||||
socket.socket_is_connected(&mut self.bus)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn send(
|
fn send(
|
||||||
&mut self,
|
&mut self,
|
||||||
socket: &mut Self::TcpSocket,
|
socket: &mut Self::TcpSocket,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue