X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fnet%2Fax25.c;h=3bd3e75ce2376c3d7220ee056daae962e3e21917;hb=56f2c002c50338f23f1b969ba51a43b0eb24f3da;hp=a4059505b9878c195a3367329dff87ebf3d5900b;hpb=e47f203a5648786cd782d921880a77a395570059;p=bertos.git diff --git a/bertos/net/ax25.c b/bertos/net/ax25.c index a4059505..3bd3e75c 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 * */ @@ -51,6 +50,17 @@ #include //memset, memcmp #include //isalnum, toupper +#if CONFIG_AX25_RPT_LST + #define AX25_SET_REPEATED(msg, idx, val) \ + do \ + { \ + if (val) \ + (msg)->rpt_flags |= BV(idx) ; \ + else \ + (msg)->rpt_flags &= ~BV(idx) ; \ + } while(0) +#endif + #define DECODE_CALL(buf, addr) \ for (unsigned i = 0; i < sizeof((addr)); i++) \ { \ @@ -77,7 +87,12 @@ static void ax25_decode(AX25Ctx *ctx) { DECODE_CALL(buf, msg.rpt_lst[msg.rpt_cnt].call); msg.rpt_lst[msg.rpt_cnt].ssid = (*buf >> 1) & 0x0F; - LOG_INFO("RPT%d[%.6s-%d]\n", msg.rpt_cnt, msg.rpt_lst[msg.rpt_cnt].call, msg.rpt_lst[msg.rpt_cnt].ssid); + AX25_SET_REPEATED(&msg, msg.rpt_cnt, (*buf & 0x80)); + + LOG_INFO("RPT%d[%.6s-%d]%c\n", msg.rpt_cnt, + msg.rpt_lst[msg.rpt_cnt].call, + msg.rpt_lst[msg.rpt_cnt].ssid, + (AX25_REPEATED(&msg, msg.rpt_cnt) ? '*' : ' ')); } #else while (!(*buf++ & 0x01)) @@ -211,8 +226,10 @@ static void ax25_sendCall(AX25Ctx *ctx, const AX25Call *addr, bool last) for (unsigned i = 0; i < sizeof(addr->call) - len; i++) ax25_putchar(ctx, ' ' << 1); + /* The bit7 "has-been-repeated" flag is not implemented here */ + /* Bits6:5 should be set to 1 for all SSIDs (0x60) */ /* The bit0 of last call SSID should be set to 1 */ - uint8_t ssid = addr->ssid << 1 | (last ? 0x01 : 0); + uint8_t ssid = 0x60 | (addr->ssid << 1) | (last ? 0x01 : 0); ax25_putchar(ctx, ssid); } @@ -265,7 +282,7 @@ static void print_call(KFile *ch, const AX25Call *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. @@ -275,14 +292,17 @@ void ax25_print(KFile *ch, const AX25Msg *msg) { print_call(ch, &msg->src); kfile_putc('>', ch); - print_call(ch, &msg->dst); - + 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 + /* Print a '*' if packet has already been transmitted + * by this repeater */ + if (AX25_REPEATED(msg, i)) + kfile_putc('*', ch); } #endif