diff --git a/examples/AFSK/AFSK_Tone/AFSK_Tone.ino b/examples/AFSK/AFSK_Tone/AFSK_Tone.ino index 43286f84..113576b3 100644 --- a/examples/AFSK/AFSK_Tone/AFSK_Tone.ino +++ b/examples/AFSK/AFSK_Tone/AFSK_Tone.ino @@ -46,7 +46,7 @@ void setup() { int state = radio.beginFSK(); // when using one of the non-LoRa modules for AFSK - // (RF69, CC1101,, Si4432 etc.), use the basic begin() method + // (RF69, CC1101, Si4432 etc.), use the basic begin() method // int state = radio.begin(); if(state == ERR_NONE) { @@ -56,17 +56,30 @@ void setup() { Serial.println(state); while(true); } + + // initialize AFSK client + Serial.print(F("[AFSK] Initializing ... ")); + state = audio.begin(); + if(state == ERR_NONE) { + Serial.println(F("success!")); + } else { + Serial.print(F("failed, code ")); + Serial.println(state); + while(true); + } } void loop() { // AFSKClient can be used to transmit tones, // same as Arduino tone() function - + // 400 Hz tone + Serial.print(F("[AFSK] 400 Hz tone ... ")); audio.tone(400); delay(1000); // silence + Serial.println(F("done!")); audio.noTone(); delay(1000); diff --git a/src/protocols/AFSK/AFSK.cpp b/src/protocols/AFSK/AFSK.cpp index 831a278d..ee3c7a0a 100644 --- a/src/protocols/AFSK/AFSK.cpp +++ b/src/protocols/AFSK/AFSK.cpp @@ -5,6 +5,10 @@ AFSKClient::AFSKClient(PhysicalLayer* phy, RADIOLIB_PIN_TYPE pin): _pin(pin) { _phy = phy; } +int16_t AFSKClient::begin() { + return(_phy->startDirect()); +} + int16_t AFSKClient::tone(uint16_t freq, bool autoStart) { if(freq == 0) { return(ERR_INVALID_FREQUENCY); diff --git a/src/protocols/AFSK/AFSK.h b/src/protocols/AFSK/AFSK.h index d92ffe65..a5a2c053 100644 --- a/src/protocols/AFSK/AFSK.h +++ b/src/protocols/AFSK/AFSK.h @@ -25,6 +25,13 @@ class AFSKClient { */ AFSKClient(PhysicalLayer* phy, RADIOLIB_PIN_TYPE pin); + /*! + \brief Initialization method. + + \returns \ref status_codes + */ + int16_t begin(); + /*! \brief Start transmitting audio tone.