mirror of
https://github.com/markqvist/OpenModem.git
synced 2024-12-26 07:59:32 -05:00
Slimmed down BertOS AX25
This commit is contained in:
parent
806f1bae56
commit
eb1b4c233e
17
Modem/main.c
17
Modem/main.c
@ -39,13 +39,6 @@ static Serial ser; // Declare a serial interface struct
|
||||
// for the ADC (this is A0 on arduino)
|
||||
|
||||
|
||||
/* Removed for now, use serial to send packets instead
|
||||
static AX25Call path[] = AX25_PATH(AX25_CALL(TO_CALL, 0), AX25_CALL(YOUR_CALLSIGN, 0), AX25_CALL("wide1", 1), AX25_CALL("wide2", 2));
|
||||
#define SEND_TEST_PACKETS false
|
||||
#define TEST_INTERVAL 15000L
|
||||
#define APRS_MSG "Test APRS packet"
|
||||
*/
|
||||
|
||||
static uint8_t serialBuffer[CONFIG_AX25_FRAME_BUF_LEN+1]; // Buffer for holding incoming serial data
|
||||
static int sbyte; // For holding byte read from serial port
|
||||
static size_t serialLen = 0; // Counter for counting length of data from serial
|
||||
@ -178,16 +171,6 @@ int main(void)
|
||||
serialLen = 0;
|
||||
}
|
||||
|
||||
// Removing this for now
|
||||
/*
|
||||
// Use AX.25 to send test data
|
||||
if (SEND_TEST_PACKETS && timer_clock() - start > ms_to_ticks(TEST_INTERVAL))
|
||||
{
|
||||
start = timer_clock();
|
||||
ax25_sendVia(&ax25, path, countof(path), APRS_MSG, sizeof(APRS_MSG));
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -166,7 +166,6 @@ void ss_saveSettings(void) {
|
||||
eeprom_update_byte((void*)&nvSYMBOL, symbol);
|
||||
eeprom_update_byte((void*)&nvAUTOACK, message_autoAck);
|
||||
|
||||
|
||||
eeprom_update_byte((void*)&nvMagicByte, NV_MAGIC_BYTE);
|
||||
|
||||
if (VERBOSE) kprintf("Configuration saved\n");
|
||||
@ -220,7 +219,6 @@ void ss_messageCallback(struct AX25Msg *msg, Serial *ser) {
|
||||
if (msg->info[pos] != CALL[pos-1]) {
|
||||
shouldAck = false;
|
||||
pos = 7;
|
||||
//kfile_printf(&ser->fd, "Not acking, wrong call\n");
|
||||
}
|
||||
pos++;
|
||||
}
|
||||
@ -229,17 +227,14 @@ void ss_messageCallback(struct AX25Msg *msg, Serial *ser) {
|
||||
pos++;
|
||||
}
|
||||
if (ssidPos != 0) {
|
||||
//kfile_printf(&ser->fd, "SSID info [%c %d !%d!]\n", msg->info[ssidPos+1], CALL_SSID, msg->info[ssidPos+1]-48);
|
||||
if (msg->info[ssidPos+2] == ' ') {
|
||||
if (msg->info[ssidPos+1]-48 != CALL_SSID) {
|
||||
shouldAck = false;
|
||||
//kfile_printf(&ser->fd, "Not acking, wrong SSID\n");
|
||||
}
|
||||
} else {
|
||||
int assid = 10+(msg->info[ssidPos+2]-48);
|
||||
if (assid != CALL_SSID) {
|
||||
shouldAck = false;
|
||||
//kfile_printf(&ser->fd, "Not acking, wrong SSID\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -279,7 +274,6 @@ void ss_messageCallback(struct AX25Msg *msg, Serial *ser) {
|
||||
ack[14+ii] = mseq[ii+1];
|
||||
}
|
||||
ss_sendPkt(ack, 14+msl, ax25ctx);
|
||||
//kfile_printf(&ser->fd, "Assembled ACKET %d: (%.*s)\n", msl, 14+msl, ack);
|
||||
|
||||
free(ack);
|
||||
}
|
||||
@ -306,9 +300,13 @@ void ss_serialCallback(void *_buffer, size_t length, Serial *ser, AX25Ctx *ctx)
|
||||
ss_sendMsg(buffer, length, ctx);
|
||||
if (VERBOSE) kprintf("Message sent\n");
|
||||
if (!VERBOSE && !SILENT) kprintf("1\n");
|
||||
} else if (buffer[0] == 'h') {
|
||||
}
|
||||
#if ENABLE_HELP
|
||||
else if (buffer[0] == 'h') {
|
||||
ss_printHelp();
|
||||
} else if (buffer[0] == 'H') {
|
||||
}
|
||||
#endif
|
||||
else if (buffer[0] == 'H') {
|
||||
ss_printSettings();
|
||||
} else if (buffer[0] == 'S') {
|
||||
ss_saveSettings();
|
||||
@ -743,26 +741,6 @@ void ss_msgRetry(AX25Ctx *ax25) {
|
||||
ss_sendMsg(lastMessage, lastMessageLen, ax25);
|
||||
}
|
||||
|
||||
void ss_printSrc(bool val) {
|
||||
PRINT_SRC = val;
|
||||
}
|
||||
|
||||
void ss_printDst(bool val) {
|
||||
PRINT_DST = val;
|
||||
}
|
||||
|
||||
void ss_printPath(bool val) {
|
||||
PRINT_PATH = val;
|
||||
}
|
||||
|
||||
void ss_printData(bool val) {
|
||||
PRINT_DATA = val;
|
||||
}
|
||||
|
||||
void ss_printInfo(bool val) {
|
||||
PRINT_INFO = val;
|
||||
}
|
||||
|
||||
void ss_printSettings(void) {
|
||||
kprintf("Configuration:\n");
|
||||
kprintf("Callsign: %.6s-%d\n", CALL, CALL_SSID);
|
||||
@ -783,50 +761,50 @@ void ss_printSettings(void) {
|
||||
kprintf("Symbol: %c\n", symbol);
|
||||
}
|
||||
|
||||
void ss_printHelp(void) {
|
||||
#if ENABLE_HELP
|
||||
kprintf("----------------------------------\n");
|
||||
kprintf("Serial commands:\n");
|
||||
kprintf("!<data> Send raw packet\n");
|
||||
kprintf("@<cmt> Send location update (cmt = optional comment)\n");
|
||||
kprintf("#<msg> Send APRS message\n\n");
|
||||
#if ENABLE_HELP
|
||||
void ss_printHelp(void) {
|
||||
kprintf("----------------------------------\n");
|
||||
kprintf("Serial commands:\n");
|
||||
kprintf("!<data> Send raw packet\n");
|
||||
kprintf("@<cmt> Send location update (cmt = optional comment)\n");
|
||||
kprintf("#<msg> Send APRS message\n\n");
|
||||
|
||||
kprintf("c<call> Set your callsign\n");
|
||||
kprintf("d<call> Set destination callsign\n");
|
||||
kprintf("1<call> Set PATH1 callsign\n");
|
||||
kprintf("2<call> Set PATH2 callsign\n\n");
|
||||
kprintf("c<call> Set your callsign\n");
|
||||
kprintf("d<call> Set destination callsign\n");
|
||||
kprintf("1<call> Set PATH1 callsign\n");
|
||||
kprintf("2<call> Set PATH2 callsign\n\n");
|
||||
|
||||
kprintf("sc<ssid> Set your SSID\n");
|
||||
kprintf("sd<ssid> Set destination SSID\n");
|
||||
kprintf("s1<ssid> Set PATH1 SSID\n");
|
||||
kprintf("s2<ssid> Set PATH2 SSID\n\n");
|
||||
kprintf("sc<ssid> Set your SSID\n");
|
||||
kprintf("sd<ssid> Set destination SSID\n");
|
||||
kprintf("s1<ssid> Set PATH1 SSID\n");
|
||||
kprintf("s2<ssid> Set PATH2 SSID\n\n");
|
||||
|
||||
kprintf("lla<LAT> Set latitude (NMEA-format, eg 4903.50N)\n");
|
||||
kprintf("llo<LON> Set latitude (NMEA-format, eg 07201.75W)\n");
|
||||
kprintf("lp<0-9> Set TX power info\n");
|
||||
kprintf("lh<0-9> Set antenna height info\n");
|
||||
kprintf("lg<0-9> Set antenna gain info\n");
|
||||
kprintf("ld<0-9> Set antenna directivity info\n");
|
||||
kprintf("ls<sym> Select symbol\n");
|
||||
kprintf("lt<s/a> Select symbol table (standard/alternate)\n\n");
|
||||
kprintf("lla<LAT> Set latitude (NMEA-format, eg 4903.50N)\n");
|
||||
kprintf("llo<LON> Set latitude (NMEA-format, eg 07201.75W)\n");
|
||||
kprintf("lp<0-9> Set TX power info\n");
|
||||
kprintf("lh<0-9> Set antenna height info\n");
|
||||
kprintf("lg<0-9> Set antenna gain info\n");
|
||||
kprintf("ld<0-9> Set antenna directivity info\n");
|
||||
kprintf("ls<sym> Select symbol\n");
|
||||
kprintf("lt<s/a> Select symbol table (standard/alternate)\n\n");
|
||||
|
||||
kprintf("mc<call> Set message recipient callsign\n");
|
||||
kprintf("ms<ssid> Set message recipient SSID\n");
|
||||
kprintf("mr<ssid> Retry last message\n");
|
||||
kprintf("ma<1/0> Automatic message ACK on/off\n\n");
|
||||
kprintf("mc<call> Set message recipient callsign\n");
|
||||
kprintf("ms<ssid> Set message recipient SSID\n");
|
||||
kprintf("mr<ssid> Retry last message\n");
|
||||
kprintf("ma<1/0> Automatic message ACK on/off\n\n");
|
||||
|
||||
kprintf("ps<1/0> Print SRC on/off\n");
|
||||
kprintf("pd<1/0> Print DST on/off\n");
|
||||
kprintf("pp<1/0> Print PATH on/off\n");
|
||||
kprintf("pm<1/0> Print DATA on/off\n");
|
||||
kprintf("pi<1/0> Print INFO on/off\n\n");
|
||||
kprintf("v<1/0> Verbose mode on/off\n");
|
||||
kprintf("V<1/0> Silent mode on/off\n\n");
|
||||
kprintf("ps<1/0> Print SRC on/off\n");
|
||||
kprintf("pd<1/0> Print DST on/off\n");
|
||||
kprintf("pp<1/0> Print PATH on/off\n");
|
||||
kprintf("pm<1/0> Print DATA on/off\n");
|
||||
kprintf("pi<1/0> Print INFO on/off\n\n");
|
||||
kprintf("v<1/0> Verbose mode on/off\n");
|
||||
kprintf("V<1/0> Silent mode on/off\n\n");
|
||||
|
||||
kprintf("S Save configuration\n");
|
||||
kprintf("L Load configuration\n");
|
||||
kprintf("C Clear configuration\n");
|
||||
kprintf("H Print configuration\n");
|
||||
kprintf("----------------------------------\n");
|
||||
#endif
|
||||
}
|
||||
kprintf("S Save configuration\n");
|
||||
kprintf("L Load configuration\n");
|
||||
kprintf("C Clear configuration\n");
|
||||
kprintf("H Print configuration\n");
|
||||
kprintf("----------------------------------\n");
|
||||
}
|
||||
#endif
|
@ -11,11 +11,6 @@ void ss_init(AX25Ctx *ax25);
|
||||
|
||||
void ss_messageCallback(struct AX25Msg *msg, Serial *ser);
|
||||
void ss_serialCallback(void *_buffer, size_t length, Serial *ser, AX25Ctx *ctx);
|
||||
void ss_printSrc(bool val);
|
||||
void ss_printDst(bool val);
|
||||
void ss_printPath(bool val);
|
||||
void ss_printData(bool val);
|
||||
void ss_printInfo(bool val);
|
||||
|
||||
void ss_sendPkt(void *_buffer, size_t length, AX25Ctx *ax25);
|
||||
void ss_sendLoc(void *_buffer, size_t length, AX25Ctx *ax25);
|
||||
|
@ -79,7 +79,6 @@ static void ax25_decode(AX25Ctx *ctx)
|
||||
DECODE_CALL(buf, msg.src.call);
|
||||
msg.src.ssid = (*buf >> 1) & 0x0F;
|
||||
|
||||
LOG_INFO("SRC[%.6s-%d], DST[%.6s-%d]\n", msg.src.call, msg.src.ssid, msg.dst.call, msg.dst.ssid);
|
||||
|
||||
/* Repeater addresses */
|
||||
#if CONFIG_AX25_RPT_LST
|
||||
@ -88,11 +87,6 @@ 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;
|
||||
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))
|
||||
@ -101,27 +95,23 @@ static void ax25_decode(AX25Ctx *ctx)
|
||||
uint8_t ssid;
|
||||
DECODE_CALL(buf, rpt);
|
||||
ssid = (*buf >> 1) & 0x0F;
|
||||
LOG_INFO("RPT[%.6s-%d]\n", rpt, ssid);
|
||||
}
|
||||
#endif
|
||||
|
||||
msg.ctrl = *buf++;
|
||||
if (msg.ctrl != AX25_CTRL_UI)
|
||||
{
|
||||
LOG_WARN("Only UI frames are handled, got [%02X]\n", msg.ctrl);
|
||||
return;
|
||||
}
|
||||
|
||||
msg.pid = *buf++;
|
||||
if (msg.pid != AX25_PID_NOLAYER3)
|
||||
{
|
||||
LOG_WARN("Only frames without layer3 protocol are handled, got [%02X]\n", msg.pid);
|
||||
return;
|
||||
}
|
||||
|
||||
msg.len = ctx->frm_len - 2 - (buf - ctx->buf);
|
||||
msg.info = buf;
|
||||
LOG_INFO("DATA: %.*s\n", msg.len, msg.info);
|
||||
|
||||
if (ctx->hook)
|
||||
ctx->hook(&msg);
|
||||
@ -150,13 +140,8 @@ void ax25_poll(AX25Ctx *ctx)
|
||||
{
|
||||
if (ctx->crc_in == AX25_CRC_CORRECT)
|
||||
{
|
||||
LOG_INFO("Frame found!\n");
|
||||
ax25_decode(ctx);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_INFO("CRC error, computed [%04X]\n", ctx->crc_in);
|
||||
}
|
||||
}
|
||||
ctx->sync = true;
|
||||
ctx->crc_in = CRC_CCITT_INIT_VAL;
|
||||
@ -166,7 +151,6 @@ void ax25_poll(AX25Ctx *ctx)
|
||||
|
||||
if (!ctx->escape && c == HDLC_RESET)
|
||||
{
|
||||
LOG_INFO("HDLC reset\n");
|
||||
ctx->sync = false;
|
||||
continue;
|
||||
}
|
||||
@ -186,7 +170,6 @@ void ax25_poll(AX25Ctx *ctx)
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_INFO("Buffer overrun");
|
||||
ctx->sync = false;
|
||||
}
|
||||
}
|
||||
@ -195,7 +178,6 @@ void ax25_poll(AX25Ctx *ctx)
|
||||
|
||||
if (kfile_error(ctx->ch))
|
||||
{
|
||||
LOG_ERR("Channel error [%04x]\n", kfile_error(ctx->ch));
|
||||
kfile_clearerr(ctx->ch);
|
||||
}
|
||||
}
|
||||
@ -276,40 +258,6 @@ 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]);
|
||||
/* Print a '*' if packet has already been transmitted
|
||||
* by this repeater */
|
||||
if (AX25_REPEATED(msg, i))
|
||||
kfile_putc('*', ch);
|
||||
}
|
||||
#endif
|
||||
|
||||
kfile_printf(ch, ":%.*s\n", msg->len, msg->info);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Init the AX25 protocol decoder.
|
||||
*
|
||||
|
@ -1,2 +1,2 @@
|
||||
#define VERS_BUILD 2178
|
||||
#define VERS_BUILD 2199
|
||||
#define VERS_HOST "shard"
|
||||
|
BIN
images/Modem.elf
BIN
images/Modem.elf
Binary file not shown.
3486
images/Modem.hex
3486
images/Modem.hex
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user