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