Loading...
Searching...
No Matches
SLIP network device

SLIP network device over UART. More...

Detailed Description

SLIP network device over UART.

See also
RFC 1055

Topics

 CoAP via SLIP
 Exchange CoAP requests and responses via SLIP.
 
 SLIP Network driver compile configuration
 

Files

file  slipdev.h
 SLIP device definitions.
 
file  slipdev_internal.h
 
file  slipdev_params.h
 Default configuration for the SLIP device driver.
 

Data Structures

struct  slipdev_params_t
 Configuration parameters for a slipdev. More...
 
struct  slipdev_t
 Device descriptor for slipdev. More...
 

Enumerations

enum  slipdev_state_t {
  SLIPDEV_STATE_NONE = 0 , SLIPDEV_STATE_UNKNOWN , SLIPDEV_STATE_NET , SLIPDEV_STATE_NET_ESC ,
  SLIPDEV_STATE_STDIN , SLIPDEV_STATE_STDIN_ESC , SLIPDEV_STATE_CONFIG , SLIPDEV_STATE_CONFIG_ESC ,
  SLIPDEV_STATE_STANDBY , SLIPDEV_STATE_SLEEP
}
 States for the slipdev and its parser. More...
 

Functions

void slipdev_setup (slipdev_t *dev, const slipdev_params_t *params, uint8_t index)
 Setup a slipdev device state.
 
void slipdev_coap_set_event_queue (event_queue_t *q)
 Setup the event queue that will be notified when a config frame arrives.
 
void slipdev_coap_unset_event_queue (void)
 Teardown the event queue.
 
void unicoap_slipdev_recv_handler (event_t *event)
 Callback to inform unicoap that a new configuration frame is available.
 
int slipdev_coap_recv (uint8_t *buf, size_t buf_size, slipdev_t *dev)
 Receive a CoAP packet into the given buffer.
 
void slipdev_coap_send (const iolist_t *iolist, const slipdev_t *dev)
 Send a CoAP message as a configuration frame.
 

Enumeration Type Documentation

◆ slipdev_state_t

States for the slipdev and its parser.

Enumerator
SLIPDEV_STATE_NONE 

Device is in no mode (currently not receiving any frame), this is the idle state.

Waits for any byte, if the byte is a valid frame start byte (diagnostic, configuration, IP packet), it starts a new frame of the respective type and switches to the corresponding state. If the byte is a frame end byte, it is a no-op (we received an empty frame). If the byte has any other value, an unknown frame type is assumed. The state switches to UNKNOWN state.

SLIPDEV_STATE_UNKNOWN 

Device discards incoming data.

It switches back to the NONE (idle) state once the unknown frame is ended via a frame end byte.

SLIPDEV_STATE_NET 

Device writes handles data as network device.

SLIPDEV_STATE_NET_ESC 

Device writes handles data as network device, next byte is escaped.

SLIPDEV_STATE_STDIN 

Device writes received data to stdin.

SLIPDEV_STATE_STDIN_ESC 

Device writes received data to stdin, next byte is escaped.

SLIPDEV_STATE_CONFIG 

Device writes received data as CoAP message.

SLIPDEV_STATE_CONFIG_ESC 

Device writes received data as CoAP message, next byte is escaped.

SLIPDEV_STATE_STANDBY 

Device is in standby, will wake up when sending data.

SLIPDEV_STATE_SLEEP 

Device is in sleep mode.

Definition at line 97 of file slipdev.h.

Function Documentation

◆ slipdev_coap_recv()

int slipdev_coap_recv ( uint8_t * buf,
size_t buf_size,
slipdev_t * dev )

Receive a CoAP packet into the given buffer.

This function handles the unescaping and checks the FCS for correctness.

Parameters
[in]bufbuffer into which the received frame is copied.
[in]buf_sizelength of buf.
[in]devdevice descriptor to identify the slipdev instance.
Return values
>0length of the stored frame in bytes
0No frame available, the buffer was not modified
-1Frame length exceeds buffer size or the frame was too short to be valid
-2The checksum was invalid, the buffer was modified

◆ slipdev_coap_send()

void slipdev_coap_send ( const iolist_t * iolist,
const slipdev_t * dev )

Send a CoAP message as a configuration frame.

This functions handles the calculation of the needed checksum, the escaping of data, the framing and finally sends the result onto the wire.

Parameters
[in]iolistIO vector list to send.
[in]devdevice descriptor to identify the slipdev instance.

◆ slipdev_coap_set_event_queue()

void slipdev_coap_set_event_queue ( event_queue_t * q)

Setup the event queue that will be notified when a config frame arrives.

Parameters
[in]qevent queue

◆ slipdev_setup()

void slipdev_setup ( slipdev_t * dev,
const slipdev_params_t * params,
uint8_t index )

Setup a slipdev device state.

Parameters
[in]devdevice descriptor
[in]paramsparameters for device initialization
[in]indexindex of params in a global parameter struct array. If initialized manually, pass a unique identifier instead.

◆ unicoap_slipdev_recv_handler()

void unicoap_slipdev_recv_handler ( event_t * event)

Callback to inform unicoap that a new configuration frame is available.

Parameters
[in]eventevent of the received frame