Skip to content

Commit 391c833

Browse files
committed
Remove the impls for no longer existing traits
1 parent 822a3a0 commit 391c833

File tree

3 files changed

+51
-122
lines changed

3 files changed

+51
-122
lines changed

src/ping.rs

+51-20
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,62 @@ use core::{ffi, mem, ptr, time::Duration};
33

44
use ::log::*;
55

6-
use embedded_svc::ping::Ping;
7-
86
use crate::ipv4;
97
use crate::private::common::*;
108
use crate::private::waitable::*;
119
use crate::sys::*;
1210

13-
pub use embedded_svc::ping::{Configuration, Info, Reply, Summary};
11+
#[derive(Clone, Debug, PartialEq, Eq)]
12+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
13+
#[cfg_attr(feature = "use_serde", derive(Serialize, Deserialize))]
14+
pub struct Configuration {
15+
pub count: u32,
16+
pub interval: Duration,
17+
pub timeout: Duration,
18+
pub data_size: u32,
19+
pub tos: u8,
20+
}
21+
22+
impl Default for Configuration {
23+
fn default() -> Self {
24+
Configuration {
25+
count: 5,
26+
interval: Duration::from_secs(1),
27+
timeout: Duration::from_secs(1),
28+
data_size: 56,
29+
tos: 0,
30+
}
31+
}
32+
}
33+
34+
#[derive(Clone, Debug, PartialEq, Eq)]
35+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
36+
#[cfg_attr(feature = "use_serde", derive(Serialize, Deserialize))]
37+
pub struct Info {
38+
#[cfg_attr(feature = "defmt", defmt(Debug2Format))]
39+
pub addr: ipv4::Ipv4Addr,
40+
pub seqno: u32,
41+
pub ttl: u8,
42+
pub elapsed_time: Duration,
43+
pub recv_len: u32,
44+
}
45+
46+
#[derive(Clone, Debug, PartialEq, Eq)]
47+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
48+
#[cfg_attr(feature = "use_serde", derive(Serialize, Deserialize))]
49+
pub enum Reply {
50+
Timeout,
51+
Success(Info),
52+
}
53+
54+
#[derive(Clone, Debug, PartialEq, Eq, Default)]
55+
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
56+
#[cfg_attr(feature = "use_serde", derive(Serialize, Deserialize))]
57+
pub struct Summary {
58+
pub transmitted: u32,
59+
pub received: u32,
60+
pub time: Duration,
61+
}
1462

1563
#[derive(Debug, Default)]
1664
pub struct EspPing(u32);
@@ -289,23 +337,6 @@ impl EspPing {
289337
}
290338
}
291339

292-
impl Ping for EspPing {
293-
type Error = EspError;
294-
295-
fn ping(&mut self, ip: ipv4::Ipv4Addr, conf: &Configuration) -> Result<Summary, Self::Error> {
296-
EspPing::ping(self, ip, conf)
297-
}
298-
299-
fn ping_details<F: FnMut(&Summary, &Reply) + Send>(
300-
&mut self,
301-
ip: ipv4::Ipv4Addr,
302-
conf: &Configuration,
303-
reply_callback: F,
304-
) -> Result<Summary, Self::Error> {
305-
EspPing::ping_details(self, ip, conf, reply_callback)
306-
}
307-
}
308-
309340
struct Tracker<F: FnMut(&Summary, &Reply) + Send> {
310341
summary: Summary,
311342
waitable: Waitable<bool>,

src/systime.rs

-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//! System time
22
use core::time::Duration;
33

4-
use embedded_svc::sys_time::SystemTime;
5-
64
use crate::sys::*;
75

86
/// Client for the ESP system time
@@ -20,9 +18,3 @@ impl EspSystemTime {
2018
Duration::from_micros(tv_now.tv_sec as u64 * 1000000_u64 + tv_now.tv_usec as u64)
2119
}
2220
}
23-
24-
impl SystemTime for EspSystemTime {
25-
fn now(&self) -> Duration {
26-
EspSystemTime::now(self)
27-
}
28-
}

src/timer.rs

-94
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ extern crate alloc;
1818
use alloc::boxed::Box;
1919
use alloc::sync::Arc;
2020

21-
use embedded_svc::sys_time::SystemTime;
22-
use embedded_svc::timer::{self, asynch, ErrorType, OnceTimer, PeriodicTimer, Timer, TimerService};
23-
2421
use esp_idf_hal::task::asynch::Notification;
2522

2623
use crate::sys::*;
@@ -135,32 +132,6 @@ impl<'a> RawHandle for EspTimer<'a> {
135132
}
136133
}
137134

138-
impl<'a> ErrorType for EspTimer<'a> {
139-
type Error = EspError;
140-
}
141-
142-
impl<'a> timer::Timer for EspTimer<'a> {
143-
fn is_scheduled(&self) -> Result<bool, Self::Error> {
144-
EspTimer::is_scheduled(self)
145-
}
146-
147-
fn cancel(&mut self) -> Result<bool, Self::Error> {
148-
EspTimer::cancel(self)
149-
}
150-
}
151-
152-
impl<'a> OnceTimer for EspTimer<'a> {
153-
fn after(&mut self, duration: Duration) -> Result<(), Self::Error> {
154-
EspTimer::after(self, duration)
155-
}
156-
}
157-
158-
impl<'a> PeriodicTimer for EspTimer<'a> {
159-
fn every(&mut self, duration: Duration) -> Result<(), Self::Error> {
160-
EspTimer::every(self, duration)
161-
}
162-
}
163-
164135
pub struct EspAsyncTimer {
165136
timer: EspTimer<'static>,
166137
notification: Arc<Notification>,
@@ -192,30 +163,6 @@ impl EspAsyncTimer {
192163
}
193164
}
194165

195-
impl ErrorType for EspAsyncTimer {
196-
type Error = EspError;
197-
}
198-
199-
impl asynch::OnceTimer for EspAsyncTimer {
200-
async fn after(&mut self, duration: Duration) -> Result<(), Self::Error> {
201-
EspAsyncTimer::after(self, duration).await
202-
}
203-
}
204-
205-
impl asynch::PeriodicTimer for EspAsyncTimer {
206-
type Clock<'a> = &'a mut Self where Self: 'a;
207-
208-
fn every(&mut self, duration: Duration) -> Result<Self::Clock<'_>, Self::Error> {
209-
EspAsyncTimer::every(self, duration)
210-
}
211-
}
212-
213-
impl<'a> asynch::Clock for &'a mut EspAsyncTimer {
214-
async fn tick(&mut self) {
215-
EspAsyncTimer::tick(self).await
216-
}
217-
}
218-
219166
impl embedded_hal_async::delay::DelayNs for EspAsyncTimer {
220167
async fn delay_ns(&mut self, ns: u32) {
221168
EspAsyncTimer::after(self, Duration::from_micros(ns as _))
@@ -369,47 +316,6 @@ where
369316
}
370317
}
371318

372-
impl<T> ErrorType for EspTimerService<T>
373-
where
374-
T: EspTimerServiceType,
375-
{
376-
type Error = EspError;
377-
}
378-
379-
impl<T> TimerService for EspTimerService<T>
380-
where
381-
T: EspTimerServiceType,
382-
{
383-
type Timer<'a> = EspTimer<'static> where Self: 'a;
384-
385-
fn timer<F>(&self, callback: F) -> Result<Self::Timer<'_>, Self::Error>
386-
where
387-
F: FnMut() + Send + 'static,
388-
{
389-
EspTimerService::timer(self, callback)
390-
}
391-
}
392-
393-
impl<T> SystemTime for EspTimerService<T>
394-
where
395-
T: EspTimerServiceType,
396-
{
397-
fn now(&self) -> Duration {
398-
EspTimerService::now(self)
399-
}
400-
}
401-
402-
impl<T> asynch::TimerService for EspTimerService<T>
403-
where
404-
T: EspTimerServiceType,
405-
{
406-
type Timer<'a> = EspAsyncTimer where Self: 'a;
407-
408-
async fn timer(&self) -> Result<Self::Timer<'_>, Self::Error> {
409-
EspTimerService::timer_async(self)
410-
}
411-
}
412-
413319
#[cfg(esp_idf_esp_timer_supports_isr_dispatch_method)]
414320
mod isr {
415321
use crate::sys::EspError;

0 commit comments

Comments
 (0)