pub struct IncomingCommunication<'a, UDP: UdpClientStack, CLOCK: Clock, const BUFFER_SIZE: usize = { crate::DEFAULT_COAP_MESSAGE_SIZE }, const MAX_OPTION_COUNT: usize = { crate::DEFAULT_MAX_OPTION_COUNT }, const MAX_OPTION_SIZE: usize = { crate::DEFAULT_MAX_OPTION_SIZE }> { /* private fields */ }Expand description
Incoming communication path. This handles incoming requests and pings which will be automatically answered with RST messages.
Implementations§
Source§impl<'a, UDP, CLOCK, const BUFFER_SIZE: usize, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize> IncomingCommunication<'a, UDP, CLOCK, BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>where
UDP: UdpClientStack,
CLOCK: Clock,
impl<'a, UDP, CLOCK, const BUFFER_SIZE: usize, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize> IncomingCommunication<'a, UDP, CLOCK, BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>where
UDP: UdpClientStack,
CLOCK: Clock,
Sourcepub fn new(
clock: &'a CLOCK,
transmission_parameters: TransmissionParameters,
) -> Self
pub fn new( clock: &'a CLOCK, transmission_parameters: TransmissionParameters, ) -> Self
Initializes the incoming communication path in the IncomingState::Idle state so it is
ready to handle incoming requests.
Sourcepub fn state(&self) -> IncomingState
pub fn state(&self) -> IncomingState
Returns the current state of the IncomingCommunication. Depending on the state, the user
must take action to drive the state forward, see the documentation to the states in
IncomingState.
Sourcepub fn request(
&self,
) -> Result<EncodedMessage<'_>, Error<<UDP as UdpClientStack>::Error>>
pub fn request( &self, ) -> Result<EncodedMessage<'_>, Error<<UDP as UdpClientStack>::Error>>
Returns the current request message which is the same that was returned in the Request
event before. Therefore, usage of this method is only required if the decision between
ACK + separate response and a piggybacked response shall be postponed (the message from the
Request event can probably not be stored due to lifetime requirements).
This method is only available in IncomingState::Received, IncomingState::SendingAck
and IncomingState::AwaitingResponse and will return Error::Forbidden otherwise.
Sourcepub fn schedule_response(
&mut self,
code: ResponseCode,
options: Vec<CoapOption<'_>, MAX_OPTION_COUNT>,
payload: Option<&[u8]>,
) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
pub fn schedule_response( &mut self, code: ResponseCode, options: Vec<CoapOption<'_>, MAX_OPTION_COUNT>, payload: Option<&[u8]>, ) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
Schedules an immediate response to be sent.
If a confirmable request was received, a piggy-backed response will be scheduled. In case of a non-confirmable request, the response will be send as non-confirmable as well.
For more control, the user can check if the request was confirmable or non-confirmable
themselves and call IncomingCommunication::schedule_empty_ack,
IncomingCommunication::schedule_piggybacked_response,
IncomingCommunication::schedule_con_response or
IncomingCommunication::schedule_non_response accordingly.
Sourcepub fn schedule_empty_ack(
&mut self,
) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
pub fn schedule_empty_ack( &mut self, ) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
Schedules an Acknowledgement to be sent.
The ACK will fit the message_id for the last received request
Sourcepub fn schedule_rst(
&mut self,
) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
pub fn schedule_rst( &mut self, ) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
Schedules a RST message to be sent.
Sourcepub fn schedule_piggybacked_response(
&mut self,
code: ResponseCode,
options: Vec<CoapOption<'_>, MAX_OPTION_COUNT>,
payload: Option<&[u8]>,
) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
pub fn schedule_piggybacked_response( &mut self, code: ResponseCode, options: Vec<CoapOption<'_>, MAX_OPTION_COUNT>, payload: Option<&[u8]>, ) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
Schedules an Acknowledgement with piggy-backed response
The ACK will fit the message_id for the last received request.
The response is defined by the given details (code, payload and additional_options).
Sourcepub fn schedule_con_response(
&mut self,
code: ResponseCode,
options: Vec<CoapOption<'_>, MAX_OPTION_COUNT>,
payload: Option<&[u8]>,
) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
pub fn schedule_con_response( &mut self, code: ResponseCode, options: Vec<CoapOption<'_>, MAX_OPTION_COUNT>, payload: Option<&[u8]>, ) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
Schedules a message to be sent as a separate CON response
Sourcepub fn schedule_non_response(
&mut self,
code: ResponseCode,
options: Vec<CoapOption<'_>, MAX_OPTION_COUNT>,
payload: Option<&[u8]>,
) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
pub fn schedule_non_response( &mut self, code: ResponseCode, options: Vec<CoapOption<'_>, MAX_OPTION_COUNT>, payload: Option<&[u8]>, ) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
Schedules a message to be sent as a separate NON response