[EXT] Added support for external radios (646)

ax5x43
jgromes 2023-01-08 15:12:49 +01:00
rodzic 02de83f941
commit 139a68dfd4
5 zmienionych plików z 117 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,89 @@
/*
RadioLib AFSK External Radio example
This example shows how to use your Arduino
as modulator for an external analogue FM radio.
The example sends APRS position reports with
audio modulated as AFSK at 1200 baud using
Bell 202 tones. However, any other AFSK
protocol (RTTY, SSTV, etc.) may be used as well.
DO NOT transmit in APRS bands unless
you have a ham radio license!
For full API reference, see the GitHub Pages
https://jgromes.github.io/RadioLib/
*/
// include the library
#include <RadioLib.h>
// create a dummy radio module
ExternalRadio radio;
// create AFSK client instance using the external radio
// pin 5 is connected to the radio sound input
AFSKClient audio(&radio, 5);
// create AX.25 client instance using the AFSK instance
AX25Client ax25(&audio);
// create APRS client instance using the AX.25 client
APRSClient aprs(&ax25);
void setup() {
Serial.begin(9600);
// initialize AX.25 client
Serial.print(F("[AX.25] Initializing ... "));
// source station callsign: "N7LEM"
// source station SSID: 0
// preamble length: 8 bytes
int16_t state = ax25.begin("N7LEM");
if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while(true);
}
// initialize APRS client
Serial.print(F("[APRS] Initializing ... "));
// symbol: '>' (car)
state = aprs.begin('>');
if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while(true);
}
}
void loop() {
Serial.print(F("[APRS] Sending position ... "));
// send a location without message or timestamp
int state = aprs.sendPosition("N0CALL", 0, "4911.67N", "01635.96E");
delay(500);
// send a location with message and without timestamp
state |= aprs.sendPosition("N0CALL", 0, "4911.67N", "01635.96E", "I'm here!");
delay(500);
// send a location with message and timestamp
state |= aprs.sendPosition("N0CALL", 0, "4911.67N", "01635.96E", "I'm here!", "093045z");
delay(500);
if(state == RADIOLIB_ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
}
// wait one minute before transmitting again
delay(60000);
}

Wyświetl plik

@ -50,6 +50,7 @@ AFSKClient KEYWORD1
FSK4Client KEYWORD1
APRSClient KEYWORD1
PagerClient KEYWORD1
ExternalRadio KEYWORD1
# SSTV modes
Scottie1 KEYWORD1

Wyświetl plik

@ -99,6 +99,7 @@
#include "protocols/SSTV/SSTV.h"
#include "protocols/FSK4/FSK4.h"
#include "protocols/APRS/APRS.h"
#include "protocols/ExternalRadio/ExternalRadio.h"
// only create Radio class when using RadioShield
#if defined(RADIOLIB_RADIOSHIELD)

Wyświetl plik

@ -0,0 +1,9 @@
#include "ExternalRadio.h"
ExternalRadio::ExternalRadio() : PhysicalLayer(1, 0) {
mod = new Module(RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC);
}
Module* ExternalRadio::getMod() {
return(mod);
}

Wyświetl plik

@ -0,0 +1,17 @@
#if !defined(_RADIOLIB_EXTERNAL_RADIO_H)
#define _RADIOLIB_EXTERNAL_RADIO_H
#include "../../TypeDef.h"
#include "../../Module.h"
#include "../PhysicalLayer/PhysicalLayer.h"
class ExternalRadio: public PhysicalLayer {
public:
ExternalRadio();
Module* getMod();
private:
Module* mod;
};
#endif