SLIP network device over UART.
More...
SLIP network device over UART.
- See also
- RFC 1055
◆ 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.
◆ 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] | buf | buffer into which the received frame is copied. |
| [in] | buf_size | length of buf. |
| [in] | dev | device descriptor to identify the slipdev instance. |
- Return values
-
| >0 | length of the stored frame in bytes |
| 0 | No frame available, the buffer was not modified |
| -1 | Frame length exceeds buffer size or the frame was too short to be valid |
| -2 | The checksum was invalid, the buffer was modified |
◆ slipdev_coap_send()
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] | iolist | IO vector list to send. |
| [in] | dev | device descriptor to identify the slipdev instance. |
◆ slipdev_coap_set_event_queue()
Setup the event queue that will be notified when a config frame arrives.
- Parameters
-
◆ slipdev_setup()
Setup a slipdev device state.
- Parameters
-
| [in] | dev | device descriptor |
| [in] | params | parameters for device initialization |
| [in] | index | index 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] | event | event of the received frame |