mirror of
https://github.com/markqvist/OpenModem.git
synced 2025-05-20 15:20:29 -04:00
EEPROM configuration
This commit is contained in:
parent
b3b1a9b253
commit
474f3ad4d2
13 changed files with 429 additions and 131 deletions
|
@ -7,6 +7,7 @@
|
|||
#include "util/CRC-CCIT.h"
|
||||
#include "hardware/AFSK.h"
|
||||
#include "protocol/KISS.h"
|
||||
#include "util/Config.h"
|
||||
|
||||
#define countof(a) sizeof(a)/sizeof(a[0])
|
||||
#define MIN(a,b) ({ typeof(a) _a = (a); typeof(b) _b = (b); ((typeof(_a))((_a < _b) ? _a : _b)); })
|
||||
|
@ -32,7 +33,7 @@ void ax25_poll(AX25Ctx *ctx) {
|
|||
while ((c = fgetc(ctx->ch)) != EOF) {
|
||||
if (!ctx->escape && c == HDLC_FLAG) {
|
||||
if (ctx->frame_len >= AX25_MIN_FRAME_LEN) {
|
||||
if (ctx->crc_in == AX25_CRC_CORRECT || CONFIG_PASSALL) {
|
||||
if (ctx->crc_in == AX25_CRC_CORRECT || config_passall) {
|
||||
ax25_decode(ctx);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "hardware/Crypto.h"
|
||||
#include "util/FIFO16.h"
|
||||
#include "util/time.h"
|
||||
#include "util/Config.h"
|
||||
#include "KISS.h"
|
||||
|
||||
uint8_t packet_queue[CONFIG_QUEUE_SIZE];
|
||||
|
@ -31,11 +32,10 @@ bool IN_FRAME;
|
|||
bool ESCAPE;
|
||||
|
||||
uint8_t command = CMD_UNKNOWN;
|
||||
unsigned long custom_preamble = CONFIG_AFSK_PREAMBLE_LEN;
|
||||
unsigned long custom_tail = CONFIG_AFSK_TRAILER_LEN;
|
||||
|
||||
unsigned long slotTime = 200;
|
||||
uint8_t p = CONFIG_CSMA_P;
|
||||
//unsigned long custom_preamble = CONFIG_AFSK_PREAMBLE_LEN;
|
||||
//unsigned long custom_tail = CONFIG_AFSK_TRAILER_LEN;
|
||||
|
||||
|
||||
void kiss_init(AX25Ctx *ax25, Afsk *afsk, Serial *ser) {
|
||||
ax25ctx = ax25;
|
||||
|
@ -89,6 +89,7 @@ void kiss_messageCallback(AX25Ctx *ctx) {
|
|||
for (uint8_t i = 0; i < CRYPTO_HMAC_SIZE; i++) {
|
||||
if (hmac[i] != crypto_work_block[i]) {
|
||||
HMAC_ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,7 +146,7 @@ void kiss_csma(void) {
|
|||
if (!channel->hdlc.dcd) {
|
||||
ticks_t timeout = last_serial_read + ms_to_ticks(CONFIG_SERIAL_TIMEOUT_MS);
|
||||
if (timer_clock() > timeout) {
|
||||
if (p == 255) {
|
||||
if (config_p == 255) {
|
||||
kiss_flushQueue();
|
||||
} else {
|
||||
// TODO: Implement real CSMA
|
||||
|
@ -155,7 +156,7 @@ void kiss_csma(void) {
|
|||
}
|
||||
#else
|
||||
if (!channel->hdlc.dcd) {
|
||||
if (p == 255) {
|
||||
if (config_p == 255) {
|
||||
kiss_flushQueue();
|
||||
} else {
|
||||
// TODO: Implement real CSMA
|
||||
|
@ -302,16 +303,14 @@ void kiss_serialCallback(uint8_t sbyte) {
|
|||
if (queue_cursor == CONFIG_QUEUE_SIZE) queue_cursor = 0;
|
||||
}
|
||||
}
|
||||
} else if (command == CMD_TXDELAY) {
|
||||
custom_preamble = sbyte * 10UL;
|
||||
} else if (command == CMD_PREAMBLE) {
|
||||
config_preamble = sbyte * 10UL;
|
||||
} else if (command == CMD_TXTAIL) {
|
||||
custom_tail = sbyte * 10;
|
||||
config_tail = sbyte * 10UL;
|
||||
} else if (command == CMD_SLOTTIME) {
|
||||
slotTime = sbyte * 10;
|
||||
config_slottime = sbyte * 10UL;
|
||||
} else if (command == CMD_P) {
|
||||
p = sbyte;
|
||||
} else if (command == CMD_FLUSHQUEUE) {
|
||||
kiss_flushQueue();
|
||||
config_p = sbyte;
|
||||
} else if (command == CMD_LED_INTENSITY) {
|
||||
if (sbyte == FESC) {
|
||||
ESCAPE = true;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#define CMD_UNKNOWN 0xFE
|
||||
#define CMD_DATA 0x00
|
||||
#define CMD_TXDELAY 0x01
|
||||
#define CMD_PREAMBLE 0x01
|
||||
#define CMD_P 0x02
|
||||
#define CMD_SLOTTIME 0x03
|
||||
#define CMD_TXTAIL 0x04
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue