diff --git a/examples/AFSK/AFSK_External_Radio/AFSK_External_Radio.ino b/examples/AFSK/AFSK_External_Radio/AFSK_External_Radio.ino new file mode 100644 index 00000000..c933ebcc --- /dev/null +++ b/examples/AFSK/AFSK_External_Radio/AFSK_External_Radio.ino @@ -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 + +// 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); +} diff --git a/keywords.txt b/keywords.txt index edcb4faa..7ad8dbbd 100644 --- a/keywords.txt +++ b/keywords.txt @@ -50,6 +50,7 @@ AFSKClient KEYWORD1 FSK4Client KEYWORD1 APRSClient KEYWORD1 PagerClient KEYWORD1 +ExternalRadio KEYWORD1 # SSTV modes Scottie1 KEYWORD1 diff --git a/src/RadioLib.h b/src/RadioLib.h index 37963d15..be496dd6 100644 --- a/src/RadioLib.h +++ b/src/RadioLib.h @@ -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) diff --git a/src/protocols/ExternalRadio/ExternalRadio.cpp b/src/protocols/ExternalRadio/ExternalRadio.cpp new file mode 100644 index 00000000..9b9358b8 --- /dev/null +++ b/src/protocols/ExternalRadio/ExternalRadio.cpp @@ -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); +} \ No newline at end of file diff --git a/src/protocols/ExternalRadio/ExternalRadio.h b/src/protocols/ExternalRadio/ExternalRadio.h new file mode 100644 index 00000000..52478643 --- /dev/null +++ b/src/protocols/ExternalRadio/ExternalRadio.h @@ -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 \ No newline at end of file