riot_coap_handler_demos::ping

Struct PingPool

Source
pub struct PingPool {
    jobs: [TryLock<Option<PingJob>>; 4],
    next_id: TryLock<u16>,
}
Available on crate feature ping only.
Expand description

Container for a number of ping jobs

To make this run, the pool’s tick method needs to be called at regular intervals (at least while its any_active_now returns true), and any incoming ICMP responses need to be turned over to its .received method.

Instead of calling [.tick()] and [.received()] manually, the [.run_on_async()] infinite async function can be run.

In parallel to that, the PingPool needs to be registered with a CoAP handler (see ping_tree).

Fields§

§jobs: [TryLock<Option<PingJob>>; 4]§next_id: TryLock<u16>

Implementations§

Source§

impl PingPool

Source

pub const fn new() -> Self

Source

pub fn register( self: &'static PingPool, callback_slot: &'static mut Slot<PingCallback>, )

Set up a hook for receiving ICMP messages.

It requires a ’static pool to ease GNRC registrations, and GNRC callback slot that contains the memory needed for handling the registration. Note that the slot can be crated through a static_cell::StaticCell initialized with SLOT.init(Default::default()), and by its own construction is previously unused. (The static mutable reference is consumed in this function).

Source

pub async fn tick_on_async(self: &PingPool, delay: impl DelayNs)

Periodically send a tick to self, keeping all the sending and expiration activities active.

§Caveats

Currently, this has no means of pausing the tick timer while no pings are pending. This makes it not really a suitable replacement for the deprecated [.any_active_now()] function, but it can gain that capability once it is added.

Source

pub fn tick(&self)

Source

pub fn received(&self, packet: Pktsnip<Shared>)

Source

pub fn any_active_now(&self) -> bool

👎Deprecated: Use tick_on_async: any_active_now only allows you to retire the timer if you can get an ask-again signal from the network stack at any time something happens around the CoAP handler. (Otherwise, how would you know when to resume ticking?)

Trait Implementations§

Source§

impl Debug for PingPool

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PingPool

Source§

fn default() -> PingPool

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoSwitch for T

Source§

fn into_switch<ActiveLevel>(self) -> Switch<T, ActiveLevel>

Consumes the IoPin returning a Switch of the appropriate ActiveLevel. Read more
Source§

fn into_active_low_switch(self) -> Switch<Self, ActiveLow>
where Self: Sized,

Consumes the IoPin returning a Switch<IoPin, ActiveLow>. Read more
Source§

fn into_active_high_switch(self) -> Switch<Self, ActiveHigh>
where Self: Sized,

Consumes the IoPin returning a Switch<IoPin, ActiveHigh>. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 148 bytes