#![no_std]
#[cfg(feature = "std")]
extern crate std;
#[cfg(feature = "defmt")]
pub(crate) use defmt::{debug, error, info, trace, warn};
#[cfg(not(feature = "defmt"))]
pub(crate) use log::{debug, error, info, trace, warn};
mod client;
mod errors;
mod manager;
mod readwrite;
mod socket;
mod stack;
mod transfer;
pub use errors::Error as CommError;
pub use transfer::Xfer as Transfer;
pub use client::PingResult;
pub use client::StackError;
pub use client::WincClient;
pub use manager::AuthType;
pub use manager::ConnectionInfo;
pub use manager::FirmwareInfo;
pub use manager::{
AccessPoint, Credentials, HostName, S8Password, S8Username, Ssid, WifiChannel, WpaKey,
};
#[cfg(feature = "wep")]
pub use manager::{WepKey, WepKeyIndex};
pub use manager::ScanResult;
pub use client::Handle;
#[cfg(feature = "async")]
mod async_client;
#[cfg(feature = "async")]
pub use async_client::AsyncClient;
#[derive(Debug, PartialEq)]
pub enum StrError {
Utf8Error(core::str::Utf8Error),
CapacityError(arrayvec::CapacityError),
}
impl From<core::str::Utf8Error> for StrError {
fn from(v: core::str::Utf8Error) -> Self {
Self::Utf8Error(v)
}
}
impl From<arrayvec::CapacityError> for StrError {
fn from(v: arrayvec::CapacityError) -> Self {
Self::CapacityError(v)
}
}
#[cfg(feature = "defmt")]
impl defmt::Format for StrError {
fn format(&self, f: defmt::Formatter) {
match self {
Self::Utf8Error(e) => defmt::write!(
f,
"UTF-8 error: invalid sequence at position {}, error length: {:?}",
e.valid_up_to(),
e.error_len()
),
Self::CapacityError(_) => defmt::write!(f, "Capacity error: array full"),
}
}
}
pub(crate) struct HexWrap<'a> {
v: &'a [u8],
}
impl HexWrap<'_> {
pub fn new(v: &[u8]) -> HexWrap {
HexWrap { v }
}
}
impl core::fmt::LowerHex for HexWrap<'_> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> {
for elem in self.v {
write!(f, " {:02x}", elem)?;
}
Ok(())
}
}
#[cfg(feature = "defmt")]
impl<'a> defmt::Format for HexWrap<'a> {
fn format(&self, f: defmt::Formatter) {
defmt::write!(f, " bytes: {=[u8]:#x}", self.v)
}
}
mod nonstd;
use nonstd::Ipv4AddrFormatWrapper;