12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- /*
- * tnc_kiss.h
- *
- * Created on: Jun 12, 2019
- * Author: curiousmuch
- */
- #ifndef MAIN_KISS_H_
- #define MAIN_KISS_H_
- // Logging Tag
- #define TNC_TAG "kiss"
- // Frame Buffer
- #define FRAME_BUFFER_SIZE 1024
- // KISS Specific Characters
- #define KISS_FEND 0xC0
- #define KISS_FESC 0xDB
- #define KISS_TFEND 0xDC
- #define KISS_TFESC 0xDD
- // KISS Commands
- // command Structure: [ 4 bits ][ 4 bits ]
- // [ TNC # ][ cmd ]
- #define KISS_DATAFRAME 0x00 // data to be send on HDLC channel
- #define KISS_CMD_TXDELAY 0x01 // keyup delay in 10ms units. default is 50ms.
- #define KISS_CMD_P 0x02
- #define KISS_CMD_SLOTTIME 0x03
- #define KISS_CMD_TXTAIL 0x04
- #define KISS_CMD_FULLDUPLEX 0x05
- #define KISS_CMD_SETHARDWARE 0x06
- #define KISS_CMD_RETURN 0xFF
- // TXDELAY: TX keyup delay in 10 ms units. Default = 50 (500ms)
- // P: Persistence scaled 0 - 255. P = p *256 -1. Default = 63 (p = 0.25)
- // SlotTime: Slot interval in 10ms units. Default = 10 (100ms)
- // TXTail: Time to hold TX after FCS has been sent in 10ms units. Default = 0
- // FullDuplex: 0 = Half Duplex. >0 = Full Duplex. Default = 0
- // SetHardware: Custom
- // Return: Exit Kiss
- typedef void (*kiss_cb_t)(uint8_t *, uint32_t);
- typedef struct {
- uint8_t tnc_number;
- kiss_cb_t rx_callback;
- kiss_cb_t tx_callback;
- } kiss_settings_t;
- typedef enum {
- ESC_MODE = 0,
- FRAME_ASS,
- FRAME_END,
- } KISS_STATE_t;
- typedef enum {
- FRAME_INVALID = 0,
- FRAME_INCOMPLETE,
- FRAME_COMPLETE,
- } FRAME_STATUS_t;
- typedef struct {
- uint8_t buf[FRAME_BUFFER_SIZE];
- uint32_t max_len;
- uint32_t index;
- FRAME_STATUS_t status;
- } kiss_buffer_t;
- typedef struct {
- uint8_t *data;
- uint16_t len;
- } raw_kiss_frame_t;
- typedef struct {
- uint8_t *data;
- uint16_t len;
- } raw_ax25_frame_t;
- /* Public Functions */
- void kiss_receive(uint8_t *data, uint16_t len);
- void kiss_init(uint8_t tnc_number, kiss_cb_t tx_cb, kiss_cb_t rx_cb);
- void kiss_transmit(uint8_t type, uint8_t *data, uint32_t len);
- #endif /* MAIN_TNC_KISS_H_ */
|