kopia lustrzana https://github.com/markqvist/LibAPRS
Fixed library init not adhering to OPEN_SQUELCH and ADC_REFERENCE settings. Added examples on how to get SRC and DST callsign and SSIDs.
rodzic
719ed77653
commit
b87d4d5775
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
extern unsigned long custom_preamble;
|
extern unsigned long custom_preamble;
|
||||||
extern unsigned long custom_tail;
|
extern unsigned long custom_tail;
|
||||||
|
extern int LibAPRS_vref;
|
||||||
|
extern bool LibAPRS_open_squelch;
|
||||||
|
|
||||||
bool hw_afsk_dac_isr = false;
|
bool hw_afsk_dac_isr = false;
|
||||||
bool hw_5v_ref = false;
|
bool hw_5v_ref = false;
|
||||||
|
@ -16,11 +18,11 @@ void afsk_putchar(char c);
|
||||||
|
|
||||||
void AFSK_hw_refDetect(void) {
|
void AFSK_hw_refDetect(void) {
|
||||||
// This is manual for now
|
// This is manual for now
|
||||||
#if ADC_REFERENCE == REF_5V
|
if (LibAPRS_vref == REF_5V) {
|
||||||
hw_5v_ref = true;
|
hw_5v_ref = true;
|
||||||
#else
|
} else {
|
||||||
hw_5v_ref = false;
|
hw_5v_ref = false;
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AFSK_hw_init(void) {
|
void AFSK_hw_init(void) {
|
||||||
|
@ -198,9 +200,9 @@ static bool hdlcParse(Hdlc *hdlc, bool bit, FIFOBuffer *fifo) {
|
||||||
// on the RX LED.
|
// on the RX LED.
|
||||||
fifo_push(fifo, HDLC_FLAG);
|
fifo_push(fifo, HDLC_FLAG);
|
||||||
hdlc->receiving = true;
|
hdlc->receiving = true;
|
||||||
#if OPEN_SQUELCH == false
|
if(!LibAPRS_open_squelch) {
|
||||||
LED_RX_ON();
|
LED_RX_ON();
|
||||||
#endif
|
}
|
||||||
} else {
|
} else {
|
||||||
// If the buffer is full, we have a problem
|
// If the buffer is full, we have a problem
|
||||||
// and abort by setting the return value to
|
// and abort by setting the return value to
|
||||||
|
|
|
@ -10,9 +10,12 @@
|
||||||
|
|
||||||
#define countof(a) sizeof(a)/sizeof(a[0])
|
#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)); })
|
#define MIN(a,b) ({ typeof(a) _a = (a); typeof(b) _b = (b); ((typeof(_a))((_a < _b) ? _a : _b)); })
|
||||||
#define DECODE_CALL(buf, addr) for (unsigned i = 0; i < sizeof((addr)); i++) { char c = (*(buf)++ >> 1); (addr)[i] = (c == ' ') ? '\x0' : c; }
|
#define DECODE_CALL(buf, addr) for (unsigned i = 0; i < sizeof((addr))-1; i++) { char c = (*(buf)++ >> 1); (addr)[i] = (c == ' ') ? '\x0' : c; }
|
||||||
#define AX25_SET_REPEATED(msg, idx, val) do { if (val) { (msg)->rpt_flags |= _BV(idx); } else { (msg)->rpt_flags &= ~_BV(idx) ; } } while(0)
|
#define AX25_SET_REPEATED(msg, idx, val) do { if (val) { (msg)->rpt_flags |= _BV(idx); } else { (msg)->rpt_flags &= ~_BV(idx) ; } } while(0)
|
||||||
|
|
||||||
|
extern int LibAPRS_vref;
|
||||||
|
extern bool LibAPRS_open_squelch;
|
||||||
|
|
||||||
void ax25_init(AX25Ctx *ctx, ax25_callback_t hook) {
|
void ax25_init(AX25Ctx *ctx, ax25_callback_t hook) {
|
||||||
memset(ctx, 0, sizeof(*ctx));
|
memset(ctx, 0, sizeof(*ctx));
|
||||||
ctx->hook = hook;
|
ctx->hook = hook;
|
||||||
|
@ -25,9 +28,11 @@ static void ax25_decode(AX25Ctx *ctx) {
|
||||||
|
|
||||||
DECODE_CALL(buf, msg.dst.call);
|
DECODE_CALL(buf, msg.dst.call);
|
||||||
msg.dst.ssid = (*buf++ >> 1) & 0x0F;
|
msg.dst.ssid = (*buf++ >> 1) & 0x0F;
|
||||||
|
msg.dst.call[6] = 0;
|
||||||
|
|
||||||
DECODE_CALL(buf, msg.src.call);
|
DECODE_CALL(buf, msg.src.call);
|
||||||
msg.src.ssid = (*buf >> 1) & 0x0F;
|
msg.src.ssid = (*buf >> 1) & 0x0F;
|
||||||
|
msg.src.call[6] = 0;
|
||||||
|
|
||||||
for (msg.rpt_count = 0; !(*buf++ & 0x01) && (msg.rpt_count < countof(msg.rpt_list)); msg.rpt_count++) {
|
for (msg.rpt_count = 0; !(*buf++ & 0x01) && (msg.rpt_count < countof(msg.rpt_list)); msg.rpt_count++) {
|
||||||
DECODE_CALL(buf, msg.rpt_list[msg.rpt_count].call);
|
DECODE_CALL(buf, msg.rpt_list[msg.rpt_count].call);
|
||||||
|
@ -55,9 +60,9 @@ void ax25_poll(AX25Ctx *ctx) {
|
||||||
if (!ctx->escape && c == HDLC_FLAG) {
|
if (!ctx->escape && c == HDLC_FLAG) {
|
||||||
if (ctx->frame_len >= AX25_MIN_FRAME_LEN) {
|
if (ctx->frame_len >= AX25_MIN_FRAME_LEN) {
|
||||||
if (ctx->crc_in == AX25_CRC_CORRECT) {
|
if (ctx->crc_in == AX25_CRC_CORRECT) {
|
||||||
#if OPEN_SQUELCH == true
|
if(LibAPRS_open_squelch) {
|
||||||
LED_RX_ON();
|
LED_RX_ON();
|
||||||
#endif
|
}
|
||||||
ax25_decode(ctx);
|
ax25_decode(ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ typedef struct AX25Ctx {
|
||||||
#define AX25_REPEATED(msg, n) ((msg)->rpt_flags & BV(n))
|
#define AX25_REPEATED(msg, n) ((msg)->rpt_flags & BV(n))
|
||||||
|
|
||||||
typedef struct AX25Call {
|
typedef struct AX25Call {
|
||||||
char call[6];
|
char call[7];
|
||||||
uint8_t ssid;
|
uint8_t ssid;
|
||||||
} AX25Call;
|
} AX25Call;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,9 @@ AX25Ctx AX25;
|
||||||
extern void aprs_msg_callback(struct AX25Msg *msg);
|
extern void aprs_msg_callback(struct AX25Msg *msg);
|
||||||
#define countof(a) sizeof(a)/sizeof(a[0])
|
#define countof(a) sizeof(a)/sizeof(a[0])
|
||||||
|
|
||||||
|
int LibAPRS_vref = REF_3V3;
|
||||||
|
bool LibAPRS_open_squelch = false;
|
||||||
|
|
||||||
unsigned long custom_preamble = 350UL;
|
unsigned long custom_preamble = 350UL;
|
||||||
unsigned long custom_tail = 50UL;
|
unsigned long custom_tail = 50UL;
|
||||||
|
|
||||||
|
@ -48,7 +51,10 @@ size_t lastMessageLen;
|
||||||
bool message_autoAck = false;
|
bool message_autoAck = false;
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
|
|
||||||
void APRS_init(void) {
|
void APRS_init(int reference, bool open_squelch) {
|
||||||
|
LibAPRS_vref = reference;
|
||||||
|
LibAPRS_open_squelch = open_squelch;
|
||||||
|
|
||||||
AFSK_init(&modem);
|
AFSK_init(&modem);
|
||||||
ax25_init(&AX25, aprs_msg_callback);
|
ax25_init(&AX25, aprs_msg_callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "AFSK.h"
|
#include "AFSK.h"
|
||||||
#include "AX25.h"
|
#include "AX25.h"
|
||||||
|
|
||||||
void APRS_init(void);
|
void APRS_init(int reference, bool open_squelch);
|
||||||
void APRS_poll(void);
|
void APRS_poll(void);
|
||||||
|
|
||||||
void APRS_setCallsign(char *call, int ssid);
|
void APRS_setCallsign(char *call, int ssid);
|
||||||
|
|
|
@ -16,17 +16,6 @@
|
||||||
#define FREQUENCY_CORRECTION 0
|
#define FREQUENCY_CORRECTION 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ADC settings
|
|
||||||
#ifndef OPEN_SQUELCH
|
|
||||||
#define OPEN_SQUELCH false
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ADC_REFERENCE
|
|
||||||
#define ADC_REFERENCE REF_3V3
|
|
||||||
// OR
|
|
||||||
//#define ADC_REFERENCE REF_5V
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Sampling & timer setup
|
// Sampling & timer setup
|
||||||
#define CONFIG_AFSK_DAC_SAMPLERATE 9600
|
#define CONFIG_AFSK_DAC_SAMPLERATE 9600
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// Include LibAPRS
|
||||||
|
#include <LibAPRS.h>
|
||||||
|
|
||||||
// You must define what reference voltage the ADC
|
// You must define what reference voltage the ADC
|
||||||
// of your device is running at. If you bought a
|
// of your device is running at. If you bought a
|
||||||
// MicroModem from unsigned.io, it will be running
|
// MicroModem from unsigned.io, it will be running
|
||||||
|
@ -12,9 +15,6 @@
|
||||||
// running with an open squelch radio:
|
// running with an open squelch radio:
|
||||||
#define OPEN_SQUELCH false
|
#define OPEN_SQUELCH false
|
||||||
|
|
||||||
// Include LibAPRS
|
|
||||||
#include <LibAPRS.h>
|
|
||||||
|
|
||||||
// You always need to include this function. It will
|
// You always need to include this function. It will
|
||||||
// get called by the library every time a packet is
|
// get called by the library every time a packet is
|
||||||
// received, so you can process incoming packets.
|
// received, so you can process incoming packets.
|
||||||
|
@ -60,7 +60,7 @@ void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
// Initialise APRS library - This starts the modem
|
// Initialise APRS library - This starts the modem
|
||||||
APRS_init();
|
APRS_init(ADC_REFERENCE, OPEN_SQUELCH);
|
||||||
|
|
||||||
// You must at a minimum configure your callsign and SSID
|
// You must at a minimum configure your callsign and SSID
|
||||||
APRS_setCallsign("NOCALL", 1);
|
APRS_setCallsign("NOCALL", 1);
|
||||||
|
@ -132,7 +132,17 @@ void messageExample() {
|
||||||
void processPacket() {
|
void processPacket() {
|
||||||
if (gotPacket) {
|
if (gotPacket) {
|
||||||
gotPacket = false;
|
gotPacket = false;
|
||||||
Serial.print(F("Received APRS packet. Data: "));
|
|
||||||
|
Serial.print(F("Received APRS packet. SRC: "));
|
||||||
|
Serial.print(incomingPacket.src.call);
|
||||||
|
Serial.print(F("-"));
|
||||||
|
Serial.print(incomingPacket.src.ssid);
|
||||||
|
Serial.print(F(". DST: "));
|
||||||
|
Serial.print(incomingPacket.dst.call);
|
||||||
|
Serial.print(F("-"));
|
||||||
|
Serial.print(incomingPacket.dst.ssid);
|
||||||
|
Serial.print(F(". Data: "));
|
||||||
|
|
||||||
for (int i = 0; i < incomingPacket.len; i++) {
|
for (int i = 0; i < incomingPacket.len; i++) {
|
||||||
Serial.write(incomingPacket.info[i]);
|
Serial.write(incomingPacket.info[i]);
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue