pub struct CoapEndpoint<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize = { crate::DEFAULT_MAX_OPTION_COUNT }, const MAX_OPTION_SIZE: usize = { crate::DEFAULT_MAX_OPTION_SIZE }, const INCOMING_BUFFER_SIZE: usize = { crate::DEFAULT_COAP_MESSAGE_SIZE }, const OUTGOING_BUFFER_SIZE: usize = { crate::DEFAULT_COAP_MESSAGE_SIZE }, const RECEIVE_BUFFER_SIZE: usize = { crate::DEFAULT_COAP_MESSAGE_SIZE }>{ /* private fields */ }Expand description
Endpoint for 1-to-1 connection to another CoAP Endpoint
Implementations§
Source§impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>
impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>
Sourcepub fn connect_with_socket(
&mut self,
socket: UDP::UdpSocket,
addr: SocketAddr,
) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
pub fn connect_with_socket( &mut self, socket: UDP::UdpSocket, addr: SocketAddr, ) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
Stores an already initialized socket inside the CoAP Endpoint.
This socket has to already be connected to a remote endpoint.
Sourcepub fn connect_to_addr<'client>(
&mut self,
client: &'client mut UDP,
addr: SocketAddr,
) -> Result<&'client mut UDP, Error<<UDP as UdpClientStack>::Error>>
pub fn connect_to_addr<'client>( &mut self, client: &'client mut UDP, addr: SocketAddr, ) -> Result<&'client mut UDP, Error<<UDP as UdpClientStack>::Error>>
Connects the CoAP Endpoint to a socket address and stores the socket.
Sourcepub fn close<'client>(
&mut self,
client: &'client mut UDP,
) -> Result<&'client mut UDP, Error<<UDP as UdpClientStack>::Error>>
pub fn close<'client>( &mut self, client: &'client mut UDP, ) -> Result<&'client mut UDP, Error<<UDP as UdpClientStack>::Error>>
Closes the connection specified by the CoAP Endpoints socket.
Source§impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>
impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>
Sourcepub fn connect_to_url(
&mut self,
client: &mut UDP,
url: &str,
) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
pub fn connect_to_url( &mut self, client: &mut UDP, url: &str, ) -> Result<(), Error<<UDP as UdpClientStack>::Error>>
Connect the Endpoint to the specified URL string.
The URL has to have the
format coap://<host>:<port>, although the port is optional.
If you specify a hostname, a DNS lookup will be made.
If you specify an IP Address, no lookup has to be done.
Source§impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>
impl<'a, UDP, RNG, CLOCK, const MAX_OPTION_COUNT: usize, const MAX_OPTION_SIZE: usize, const INCOMING_BUFFER_SIZE: usize, const OUTGOING_BUFFER_SIZE: usize, const RECEIVE_BUFFER_SIZE: usize> CoapEndpoint<'a, UDP, RNG, CLOCK, MAX_OPTION_COUNT, MAX_OPTION_SIZE, INCOMING_BUFFER_SIZE, OUTGOING_BUFFER_SIZE, RECEIVE_BUFFER_SIZE>
Sourcepub fn try_new(
transmission_parameters: TransmissionParameters,
rng: RNG,
clock: &'a CLOCK,
receive_buffer: &'a mut [u8],
) -> Result<Self, Error<<UDP as UdpClientStack>::Error>>
pub fn try_new( transmission_parameters: TransmissionParameters, rng: RNG, clock: &'a CLOCK, receive_buffer: &'a mut [u8], ) -> Result<Self, Error<<UDP as UdpClientStack>::Error>>
Constructs a new CoAP Endpoint.
Initializes the message_id_counter randomly.
Sourcepub fn incoming(
&mut self,
) -> &mut IncomingCommunication<'a, UDP, CLOCK, INCOMING_BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>
pub fn incoming( &mut self, ) -> &mut IncomingCommunication<'a, UDP, CLOCK, INCOMING_BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>
Access the IncomingCommunication
Sourcepub fn outgoing(
&mut self,
) -> &mut OutgoingCommunication<'a, CLOCK, UDP, OUTGOING_BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>
pub fn outgoing( &mut self, ) -> &mut OutgoingCommunication<'a, CLOCK, UDP, OUTGOING_BUFFER_SIZE, MAX_OPTION_COUNT, MAX_OPTION_SIZE>
Access the OutgoingCommunication
Sourcepub fn process(
&mut self,
client_stack: &mut UDP,
) -> Result<(Result<IncomingEvent<'_>, Error<<UDP as UdpClientStack>::Error>>, Result<OutgoingEvent<'_>, Error<<UDP as UdpClientStack>::Error>>, EndpointEvent<'_>), Error<<UDP as UdpClientStack>::Error>>
pub fn process( &mut self, client_stack: &mut UDP, ) -> Result<(Result<IncomingEvent<'_>, Error<<UDP as UdpClientStack>::Error>>, Result<OutgoingEvent<'_>, Error<<UDP as UdpClientStack>::Error>>, EndpointEvent<'_>), Error<<UDP as UdpClientStack>::Error>>
Handles internal state machine.
Has to be called periodically. If any ongoing process is present, this function has to be called at an interval less than CoapEndpoint::transmission_parameter.ack_timeout.
This method receives a possibly pending RX message and offers this received message to
IncomingCommunication and OutgoingCommunication. Incoming pings are automatically
answered with a RST message and a corresponding EndpointEvent::Ping is generated. If
neither the incoming nor the outgoing communication path have consumed the RX message, an
EndpointEvent::Unhandled is generated.
Unhandled requests are silently ignored because we may be able to handle a possible future retransmission. Unhandled NON and CON responses are automatically rejected with a RST message because there is no reason to believe that a response which was not consumed now will be handled in the future. Unhandled ACKs and RSTs are silently ignored because there must never be a response to ACKs and RSTs, see section 4.2. (Messages Transmitted Reliably) from RFC 7252: “More generally, recipients of Acknowledgement and Reset messages MUST NOT respond with either Acknowledgement or Reset messages.”