X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fnet%2Fax25.c;h=3d5ac3431f0d82059e0836416da318f69e036647;hb=7ab0db65df07943ccdac8fce7e35c360767033ff;hp=68a6ae56d777066356d1ce66bff0473d1a99f862;hpb=319029b456527124521b6a6a65c21edb321cdcb8;p=bertos.git diff --git a/bertos/net/ax25.c b/bertos/net/ax25.c index 68a6ae56..3d5ac343 100644 --- a/bertos/net/ax25.c +++ b/bertos/net/ax25.c @@ -34,7 +34,6 @@ * For now, only UI frames without any Layer 3 protocol are handled. * This however is enough to send/receive APRS packets. * - * \version $Id$ * \author Francesco Sacchi * */ @@ -54,7 +53,8 @@ #define DECODE_CALL(buf, addr) \ for (unsigned i = 0; i < sizeof((addr)); i++) \ { \ - (addr)[i] = *(buf)++ >> 1; \ + char c = (*(buf)++ >> 1); \ + (addr)[i] = (c == ' ') ? '\x0' : c; \ } static void ax25_decode(AX25Ctx *ctx) @@ -258,6 +258,36 @@ void ax25_sendVia(AX25Ctx *ctx, const AX25Call *path, size_t path_len, const voi kfile_putc(HDLC_FLAG, ctx->ch); } +static void print_call(KFile *ch, const AX25Call *call) +{ + kfile_printf(ch, "%.6s", call->call); + if (call->ssid) + kfile_printf(ch, "-%d", call->ssid); +} + +/** + * Print a AX25 message in TNC-2 packet monitor format. + * \param ch a kfile channel where the message will be printed. + * \param msg the message to be printed. + */ +void ax25_print(KFile *ch, const AX25Msg *msg) +{ + print_call(ch, &msg->src); + kfile_putc('>', ch); + print_call(ch, &msg->dst); + + #if CONFIG_AX25_RPT_LST + for (int i = 0; i < msg->rpt_cnt; i++) + { + kfile_putc(',', ch); + print_call(ch, &msg->rpt_lst[i]); + // TODO: add * to the trasmitting digi + } + #endif + + kfile_printf(ch, ":%.*s\n", msg->len, msg->info); +} + /** * Init the AX25 protocol decoder.