[AFSK] Added begin method

This commit is contained in:
jgromes 2021-02-13 15:44:15 +01:00
parent 1a2d66305d
commit 85ba05c1f8
3 changed files with 26 additions and 2 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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.