X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fnet%2Fax25.c;h=d2c2639b105805a79385722277cdf4081cf6618e;hb=0638e6c0ca69a05d5d023186abebe63645210b1b;hp=889136595f52997830d310eb5cf342bce1d6f12e;hpb=63a35af8aab90ed049447a2837666a52f13b9598;p=bertos.git diff --git a/bertos/net/ax25.c b/bertos/net/ax25.c index 88913659..d2c2639b 100644 --- a/bertos/net/ax25.c +++ b/bertos/net/ax25.c @@ -63,7 +63,6 @@ static void ax25_decode(AX25Ctx *ctx) uint8_t *buf = ctx->buf; DECODE_CALL(buf, msg.dst.call); - ASSERT(!(*buf & 0x01)); msg.dst.ssid = (*buf++ >> 1) & 0x0F; DECODE_CALL(buf, msg.src.call); @@ -112,6 +111,17 @@ static void ax25_decode(AX25Ctx *ctx) ctx->hook(&msg); } + +/** + * Check if there are any AX25 messages to be processed. + * This function read available characters from the medium and search for + * any AX25 messages. + * If a message is found it is decoded and the linked callback executed. + * This function may be blocking if there are no available chars and the KFile + * used in \a ctx to access the medium is configured in blocking mode. + * + * \param ctx AX25 context to operate on. + */ void ax25_poll(AX25Ctx *ctx) { int c; @@ -201,6 +211,16 @@ static void ax25_sendCall(AX25Ctx *ctx, const AX25Call *addr) ax25_putchar(ctx, ' ' << 1); } +/** + * Send an AX25 frame on the channel. + * \param ctx AX25 context to operate on. + * \param dst the destination callsign for the frame, \see AX25_CALL + * for a handy way to create a callsign on the fly. + * \param src the source callsign for the frame, \see AX25_CALL + * for a handy way to create a callsign on the fly. + * \param _buf payload buffer. + * \param len length of the payload. + */ void ax25_send(AX25Ctx *ctx, const AX25Call *dst, const AX25Call *src, const void *_buf, size_t len) { const uint8_t *buf = (const uint8_t *)_buf; @@ -233,6 +253,14 @@ void ax25_send(AX25Ctx *ctx, const AX25Call *dst, const AX25Call *src, const voi kfile_putc(HDLC_FLAG, ctx->ch); } + +/** + * Init the AX25 protocol decoder. + * + * \param ctx AX25 context to init. + * \param channel Used to gain access to the physical medium + * \param hook Callback function called when a message is received + */ void ax25_init(AX25Ctx *ctx, KFile *channel, ax25_callback_t hook) { ASSERT(ctx);