[AX.25] Added option to adjust audio frequencies (#346)

This commit is contained in:
jgromes 2021-09-05 16:04:14 +02:00
parent 8c66edc03e
commit 6460d566cd
4 changed files with 40 additions and 2 deletions

View file

@ -74,6 +74,22 @@ void setup() {
Serial.println(state);
while(true);
}
// Sometimes, it may be required to adjust audio
// frequencies to match the expected 1200/2200 Hz tones.
// The following method will offset mark frequency by
// 100 Hz up and space frequency by 100 Hz down
/*
Serial.print(F("[AX.25] Setting correction ... "));
state = ax25.setCorrection(100, -100);
if(state == ERR_NONE) {
Serial.println(F("success!"));
} else {
Serial.print(F("failed, code "));
Serial.println(state);
while(true);
}
*/
}
void loop() {

View file

@ -230,6 +230,7 @@ setRepeaters KEYWORD2
setRecvSequence KEYWORD2
setSendSequence KEYWORD2
sendFrame KEYWORD2
setCorrection KEYWORD2
# SSTV
sendHeader KEYWORD2

View file

@ -160,6 +160,14 @@ AX25Client::AX25Client(PhysicalLayer* phy) {
AX25Client::AX25Client(AFSKClient* audio) {
_phy = audio->_phy;
_audio = audio;
_afskMark = AX25_AFSK_MARK;
_afskSpace = AX25_AFSK_SPACE;
}
int16_t AX25Client::setCorrection(int16_t mark, int16_t space) {
_afskMark = AX25_AFSK_MARK + mark;
_afskSpace = AX25_AFSK_SPACE + space;
return(ERR_NONE);
}
#endif
@ -393,9 +401,9 @@ int16_t AX25Client::sendFrame(AX25Frame* frame) {
for(uint16_t mask = 0x80; mask >= 0x01; mask >>= 1) {
uint32_t start = Module::micros();
if(stuffedFrameBuff[i] & mask) {
_audio->tone(AX25_AFSK_MARK, false);
_audio->tone(_afskMark, false);
} else {
_audio->tone(AX25_AFSK_SPACE, false);
_audio->tone(_afskSpace, false);
}
while(Module::micros() - start < AX25_AFSK_TONE_DURATION) {
Module::yield();

View file

@ -292,6 +292,17 @@ class AX25Client {
\param audio Pointer to the AFSK instance providing audio.
*/
explicit AX25Client(AFSKClient* audio);
/*!
\brief Set AFSK tone correction offset. On some platforms, this is required to get the audio produced by the setup to match the expected 1200/2200 Hz tones.
\param mark Positive or negative correction offset for mark audio frequency in Hz.
\param space Positive or negative correction offset for space audio frequency in Hz.
\returns \ref status_codes
*/
int16_t setCorrection(int16_t mark, int16_t space);
#endif
// basic methods
@ -337,6 +348,8 @@ class AX25Client {
PhysicalLayer* _phy;
#if !defined(RADIOLIB_EXCLUDE_AFSK)
AFSKClient* _audio;
uint32_t _afskMark;
uint32_t _afskSpace;
#endif
char _srcCallsign[AX25_MAX_CALLSIGN_LEN + 1] = {0, 0, 0, 0, 0, 0, 0};