2014-12-02 19:10:06 -05:00
|
|
|
#ifndef PROTOCOL_AX25_H
|
|
|
|
#define PROTOCOL_AX25_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
2014-12-18 17:45:36 -05:00
|
|
|
#include "device.h"
|
2018-04-24 11:34:59 -04:00
|
|
|
#include "hardware/AFSK.h"
|
2014-12-02 19:10:06 -05:00
|
|
|
|
|
|
|
#define AX25_CRC_CORRECT 0xF0B8
|
|
|
|
|
|
|
|
#define AX25_CTRL_UI 0x03
|
|
|
|
#define AX25_PID_NOLAYER3 0xF0
|
|
|
|
|
2014-12-18 18:50:14 -05:00
|
|
|
struct AX25Ctx; // Forward declarations
|
2014-12-18 17:45:36 -05:00
|
|
|
struct AX25Msg;
|
2014-12-02 19:10:06 -05:00
|
|
|
|
2018-12-27 14:24:21 -05:00
|
|
|
typedef void (*ax25_callback_t)(struct AX25Ctx *ctx);
|
2014-12-18 17:45:36 -05:00
|
|
|
|
|
|
|
typedef struct AX25Ctx {
|
2014-12-02 19:10:06 -05:00
|
|
|
uint8_t buf[AX25_MAX_FRAME_LEN];
|
2018-04-24 11:34:59 -04:00
|
|
|
Afsk *modem;
|
2014-12-02 19:10:06 -05:00
|
|
|
FILE *ch;
|
|
|
|
size_t frame_len;
|
|
|
|
uint16_t crc_in;
|
|
|
|
uint16_t crc_out;
|
|
|
|
ax25_callback_t hook;
|
|
|
|
bool sync;
|
|
|
|
bool escape;
|
2018-04-24 11:34:59 -04:00
|
|
|
bool ready_for_data;
|
2014-12-02 19:10:06 -05:00
|
|
|
} AX25Ctx;
|
|
|
|
|
|
|
|
void ax25_poll(AX25Ctx *ctx);
|
|
|
|
void ax25_sendRaw(AX25Ctx *ctx, void *_buf, size_t len);
|
2018-04-24 11:34:59 -04:00
|
|
|
void ax25_init(AX25Ctx *ctx, Afsk *modem, FILE *channel, ax25_callback_t hook);
|
2014-12-02 19:10:06 -05:00
|
|
|
|
|
|
|
#endif
|