[RTTY] Use compact Doxygen and stop using reserved format
This commit is contained in:
parent
47e759f322
commit
5ab24e05dd
2 changed files with 89 additions and 102 deletions
|
@ -4,39 +4,39 @@
|
||||||
#if !defined(RADIOLIB_EXCLUDE_RTTY)
|
#if !defined(RADIOLIB_EXCLUDE_RTTY)
|
||||||
|
|
||||||
ITA2String::ITA2String(char c) {
|
ITA2String::ITA2String(char c) {
|
||||||
_len = 1;
|
asciiLen = 1;
|
||||||
#if !defined(RADIOLIB_STATIC_ONLY)
|
#if !defined(RADIOLIB_STATIC_ONLY)
|
||||||
_str = new char[1];
|
strAscii = new char[1];
|
||||||
#endif
|
#endif
|
||||||
_str[0] = c;
|
strAscii[0] = c;
|
||||||
_ita2Len = 0;
|
ita2Len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ITA2String::ITA2String(const char* str) {
|
ITA2String::ITA2String(const char* str) {
|
||||||
_len = strlen(str);
|
asciiLen = strlen(str);
|
||||||
#if !defined(RADIOLIB_STATIC_ONLY)
|
#if !defined(RADIOLIB_STATIC_ONLY)
|
||||||
_str = new char[_len + 1];
|
strAscii = new char[asciiLen + 1];
|
||||||
#endif
|
#endif
|
||||||
strcpy(_str, str);
|
strcpy(strAscii, str);
|
||||||
_ita2Len = 0;
|
ita2Len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ITA2String::~ITA2String() {
|
ITA2String::~ITA2String() {
|
||||||
#if !defined(RADIOLIB_STATIC_ONLY)
|
#if !defined(RADIOLIB_STATIC_ONLY)
|
||||||
delete[] _str;
|
delete[] strAscii;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ITA2String::length() {
|
size_t ITA2String::length() {
|
||||||
// length returned by this method is different than the length of ASCII-encoded _str
|
// length returned by this method is different than the length of ASCII-encoded strAscii
|
||||||
// ITA2-encoded string length varies based on how many number and characters the string contains
|
// ITA2-encoded string length varies based on how many number and characters the string contains
|
||||||
|
|
||||||
if(_ita2Len == 0) {
|
if(ita2Len == 0) {
|
||||||
// ITA2 length wasn't calculated yet, call byteArr() to calculate it
|
// ITA2 length wasn't calculated yet, call byteArr() to calculate it
|
||||||
byteArr();
|
byteArr();
|
||||||
}
|
}
|
||||||
|
|
||||||
return(_ita2Len);
|
return(ita2Len);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* ITA2String::byteArr() {
|
uint8_t* ITA2String::byteArr() {
|
||||||
|
@ -44,13 +44,13 @@ uint8_t* ITA2String::byteArr() {
|
||||||
#if defined(RADIOLIB_STATIC_ONLY)
|
#if defined(RADIOLIB_STATIC_ONLY)
|
||||||
uint8_t temp[RADIOLIB_STATIC_ARRAY_SIZE*2 + 1];
|
uint8_t temp[RADIOLIB_STATIC_ARRAY_SIZE*2 + 1];
|
||||||
#else
|
#else
|
||||||
uint8_t* temp = new uint8_t[_len*2 + 1];
|
uint8_t* temp = new uint8_t[asciiLen*2 + 1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_t arrayLen = 0;
|
size_t arrayLen = 0;
|
||||||
bool flagFigure = false;
|
bool flagFigure = false;
|
||||||
for(size_t i = 0; i < _len; i++) {
|
for(size_t i = 0; i < asciiLen; i++) {
|
||||||
uint16_t code = getBits(_str[i]);
|
uint16_t code = getBits(strAscii[i]);
|
||||||
uint8_t shift = (code >> 5) & 0b11111;
|
uint8_t shift = (code >> 5) & 0b11111;
|
||||||
uint8_t character = code & 0b11111;
|
uint8_t character = code & 0b11111;
|
||||||
// check if the code is letter or figure
|
// check if the code is letter or figure
|
||||||
|
@ -65,8 +65,8 @@ uint8_t* ITA2String::byteArr() {
|
||||||
temp[arrayLen++] = character & 0b11111;
|
temp[arrayLen++] = character & 0b11111;
|
||||||
|
|
||||||
// check the following character (skip for message end)
|
// check the following character (skip for message end)
|
||||||
if(i < (_len - 1)) {
|
if(i < (asciiLen - 1)) {
|
||||||
uint16_t nextCode = getBits(_str[i+1]);
|
uint16_t nextCode = getBits(strAscii[i+1]);
|
||||||
uint8_t nextShift = (nextCode >> 5) & 0b11111;
|
uint8_t nextShift = (nextCode >> 5) & 0b11111;
|
||||||
if(nextShift == RADIOLIB_ITA2_LTRS) {
|
if(nextShift == RADIOLIB_ITA2_LTRS) {
|
||||||
// next character is a letter, terminate figure shift
|
// next character is a letter, terminate figure shift
|
||||||
|
@ -84,7 +84,7 @@ uint8_t* ITA2String::byteArr() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// save ITA2 string length
|
// save ITA2 string length
|
||||||
_ita2Len = arrayLen;
|
ita2Len = arrayLen;
|
||||||
|
|
||||||
uint8_t* arr = new uint8_t[arrayLen];
|
uint8_t* arr = new uint8_t[arrayLen];
|
||||||
memcpy(arr, temp, arrayLen);
|
memcpy(arr, temp, arrayLen);
|
||||||
|
@ -114,45 +114,45 @@ uint16_t ITA2String::getBits(char c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
RTTYClient::RTTYClient(PhysicalLayer* phy) {
|
RTTYClient::RTTYClient(PhysicalLayer* phy) {
|
||||||
_phy = phy;
|
phyLayer = phy;
|
||||||
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
||||||
_audio = nullptr;
|
audioClient = nullptr;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
||||||
RTTYClient::RTTYClient(AFSKClient* audio) {
|
RTTYClient::RTTYClient(AFSKClient* audio) {
|
||||||
_phy = audio->_phy;
|
phyLayer = audio->phyLayer;
|
||||||
_audio = audio;
|
audioClient = audio;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int16_t RTTYClient::begin(float base, uint32_t shift, uint16_t rate, uint8_t encoding, uint8_t stopBits) {
|
int16_t RTTYClient::begin(float base, uint32_t shift, uint16_t rate, uint8_t enc, uint8_t stopBits) {
|
||||||
// save configuration
|
// save configuration
|
||||||
_encoding = encoding;
|
encoding = enc;
|
||||||
_stopBits = stopBits;
|
stopBitsNum = stopBits;
|
||||||
_baseHz = base;
|
baseFreqHz = base;
|
||||||
_shiftHz = shift;
|
shiftFreqHz = shift;
|
||||||
|
|
||||||
switch(encoding) {
|
switch(encoding) {
|
||||||
case RADIOLIB_ASCII:
|
case RADIOLIB_ASCII:
|
||||||
_dataBits = 7;
|
dataBitsNum = 7;
|
||||||
break;
|
break;
|
||||||
case RADIOLIB_ASCII_EXTENDED:
|
case RADIOLIB_ASCII_EXTENDED:
|
||||||
_dataBits = 8;
|
dataBitsNum = 8;
|
||||||
break;
|
break;
|
||||||
case RADIOLIB_ITA2:
|
case RADIOLIB_ITA2:
|
||||||
_dataBits = 5;
|
dataBitsNum = 5;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return(RADIOLIB_ERR_UNSUPPORTED_ENCODING);
|
return(RADIOLIB_ERR_UNSUPPORTED_ENCODING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate duration of 1 bit
|
// calculate duration of 1 bit
|
||||||
_bitDuration = (uint32_t)1000000/rate;
|
bitDuration = (uint32_t)1000000/rate;
|
||||||
|
|
||||||
// calculate module carrier frequency resolution
|
// calculate module carrier frequency resolution
|
||||||
uint32_t step = round(_phy->getFreqStep());
|
uint32_t step = round(phyLayer->getFreqStep());
|
||||||
|
|
||||||
// check minimum shift value
|
// check minimum shift value
|
||||||
if(shift < step / 2) {
|
if(shift < step / 2) {
|
||||||
|
@ -161,16 +161,16 @@ int16_t RTTYClient::begin(float base, uint32_t shift, uint16_t rate, uint8_t enc
|
||||||
|
|
||||||
// round shift to multiples of frequency step size
|
// round shift to multiples of frequency step size
|
||||||
if(shift % step < (step / 2)) {
|
if(shift % step < (step / 2)) {
|
||||||
_shift = shift / step;
|
shiftFreq = shift / step;
|
||||||
} else {
|
} else {
|
||||||
_shift = (shift / step) + 1;
|
shiftFreq = (shift / step) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// calculate 24-bit frequency
|
// calculate 24-bit frequency
|
||||||
_base = (base * 1000000.0) / _phy->getFreqStep();
|
baseFreq = (base * 1000000.0) / phyLayer->getFreqStep();
|
||||||
|
|
||||||
// configure for direct mode
|
// configure for direct mode
|
||||||
return(_phy->startDirect());
|
return(phyLayer->startDirect());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTTYClient::idle() {
|
void RTTYClient::idle() {
|
||||||
|
@ -195,7 +195,7 @@ size_t RTTYClient::write(uint8_t* buff, size_t len) {
|
||||||
size_t RTTYClient::write(uint8_t b) {
|
size_t RTTYClient::write(uint8_t b) {
|
||||||
space();
|
space();
|
||||||
|
|
||||||
uint16_t maxDataMask = 0x01 << (_dataBits - 1);
|
uint16_t maxDataMask = 0x01 << (dataBitsNum - 1);
|
||||||
for(uint16_t mask = 0x01; mask <= maxDataMask; mask <<= 1) {
|
for(uint16_t mask = 0x01; mask <= maxDataMask; mask <<= 1) {
|
||||||
if(b & mask) {
|
if(b & mask) {
|
||||||
mark();
|
mark();
|
||||||
|
@ -204,7 +204,7 @@ size_t RTTYClient::write(uint8_t b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint8_t i = 0; i < _stopBits; i++) {
|
for(uint8_t i = 0; i < stopBitsNum; i++) {
|
||||||
mark();
|
mark();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,10 +238,10 @@ size_t RTTYClient::print(__FlashStringHelper* fstr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
if(_encoding == RADIOLIB_ITA2) {
|
if(encoding == RADIOLIB_ITA2) {
|
||||||
ITA2String ita2 = ITA2String(str);
|
ITA2String ita2 = ITA2String(str);
|
||||||
n = RTTYClient::print(ita2);
|
n = RTTYClient::print(ita2);
|
||||||
} else if((_encoding == RADIOLIB_ASCII) || (_encoding == RADIOLIB_ASCII_EXTENDED)) {
|
} else if((encoding == RADIOLIB_ASCII) || (encoding == RADIOLIB_ASCII_EXTENDED)) {
|
||||||
n = RTTYClient::write((uint8_t*)str, len);
|
n = RTTYClient::write((uint8_t*)str, len);
|
||||||
}
|
}
|
||||||
#if !defined(RADIOLIB_STATIC_ONLY)
|
#if !defined(RADIOLIB_STATIC_ONLY)
|
||||||
|
@ -252,10 +252,10 @@ size_t RTTYClient::print(__FlashStringHelper* fstr) {
|
||||||
|
|
||||||
size_t RTTYClient::print(const String& str) {
|
size_t RTTYClient::print(const String& str) {
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
if(_encoding == RADIOLIB_ITA2) {
|
if(encoding == RADIOLIB_ITA2) {
|
||||||
ITA2String ita2 = ITA2String(str.c_str());
|
ITA2String ita2 = ITA2String(str.c_str());
|
||||||
n = RTTYClient::print(ita2);
|
n = RTTYClient::print(ita2);
|
||||||
} else if((_encoding == RADIOLIB_ASCII) || (_encoding == RADIOLIB_ASCII_EXTENDED)) {
|
} else if((encoding == RADIOLIB_ASCII) || (encoding == RADIOLIB_ASCII_EXTENDED)) {
|
||||||
n = RTTYClient::write((uint8_t*)str.c_str(), str.length());
|
n = RTTYClient::write((uint8_t*)str.c_str(), str.length());
|
||||||
}
|
}
|
||||||
return(n);
|
return(n);
|
||||||
|
@ -271,10 +271,10 @@ size_t RTTYClient::print(ITA2String& ita2) {
|
||||||
|
|
||||||
size_t RTTYClient::print(const char str[]) {
|
size_t RTTYClient::print(const char str[]) {
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
if(_encoding == RADIOLIB_ITA2) {
|
if(encoding == RADIOLIB_ITA2) {
|
||||||
ITA2String ita2 = ITA2String(str);
|
ITA2String ita2 = ITA2String(str);
|
||||||
n = RTTYClient::print(ita2);
|
n = RTTYClient::print(ita2);
|
||||||
} else if((_encoding == RADIOLIB_ASCII) || (_encoding == RADIOLIB_ASCII_EXTENDED)) {
|
} else if((encoding == RADIOLIB_ASCII) || (encoding == RADIOLIB_ASCII_EXTENDED)) {
|
||||||
n = RTTYClient::write((uint8_t*)str, strlen(str));
|
n = RTTYClient::write((uint8_t*)str, strlen(str));
|
||||||
}
|
}
|
||||||
return(n);
|
return(n);
|
||||||
|
@ -282,10 +282,10 @@ size_t RTTYClient::print(const char str[]) {
|
||||||
|
|
||||||
size_t RTTYClient::print(char c) {
|
size_t RTTYClient::print(char c) {
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
if(_encoding == RADIOLIB_ITA2) {
|
if(encoding == RADIOLIB_ITA2) {
|
||||||
ITA2String ita2 = ITA2String(c);
|
ITA2String ita2 = ITA2String(c);
|
||||||
n = RTTYClient::print(ita2);
|
n = RTTYClient::print(ita2);
|
||||||
} else if((_encoding == RADIOLIB_ASCII) || (_encoding == RADIOLIB_ASCII_EXTENDED)) {
|
} else if((encoding == RADIOLIB_ASCII) || (encoding == RADIOLIB_ASCII_EXTENDED)) {
|
||||||
n = RTTYClient::write(c);
|
n = RTTYClient::write(c);
|
||||||
}
|
}
|
||||||
return(n);
|
return(n);
|
||||||
|
@ -332,10 +332,10 @@ size_t RTTYClient::print(double n, int digits) {
|
||||||
|
|
||||||
size_t RTTYClient::println(void) {
|
size_t RTTYClient::println(void) {
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
if(_encoding == RADIOLIB_ITA2) {
|
if(encoding == RADIOLIB_ITA2) {
|
||||||
ITA2String lf = ITA2String("\r\n");
|
ITA2String lf = ITA2String("\r\n");
|
||||||
n = RTTYClient::print(lf);
|
n = RTTYClient::print(lf);
|
||||||
} else if((_encoding == RADIOLIB_ASCII) || (_encoding == RADIOLIB_ASCII_EXTENDED)) {
|
} else if((encoding == RADIOLIB_ASCII) || (encoding == RADIOLIB_ASCII_EXTENDED)) {
|
||||||
n = RTTYClient::write("\r\n");
|
n = RTTYClient::write("\r\n");
|
||||||
}
|
}
|
||||||
return(n);
|
return(n);
|
||||||
|
@ -410,17 +410,17 @@ size_t RTTYClient::println(double d, int digits) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTTYClient::mark() {
|
void RTTYClient::mark() {
|
||||||
Module* mod = _phy->getMod();
|
Module* mod = phyLayer->getMod();
|
||||||
uint32_t start = mod->hal->micros();
|
uint32_t start = mod->hal->micros();
|
||||||
transmitDirect(_base + _shift, _baseHz + _shiftHz);
|
transmitDirect(baseFreq + shiftFreq, baseFreqHz + shiftFreqHz);
|
||||||
mod->waitForMicroseconds(start, _bitDuration);
|
mod->waitForMicroseconds(start, bitDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RTTYClient::space() {
|
void RTTYClient::space() {
|
||||||
Module* mod = _phy->getMod();
|
Module* mod = phyLayer->getMod();
|
||||||
uint32_t start = mod->hal->micros();
|
uint32_t start = mod->hal->micros();
|
||||||
transmitDirect(_base, _baseHz);
|
transmitDirect(baseFreq, baseFreqHz);
|
||||||
mod->waitForMicroseconds(start, _bitDuration);
|
mod->waitForMicroseconds(start, bitDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t RTTYClient::printNumber(unsigned long n, uint8_t base) {
|
size_t RTTYClient::printNumber(unsigned long n, uint8_t base) {
|
||||||
|
@ -441,12 +441,12 @@ size_t RTTYClient::printNumber(unsigned long n, uint8_t base) {
|
||||||
} while(n);
|
} while(n);
|
||||||
|
|
||||||
size_t l = 0;
|
size_t l = 0;
|
||||||
if(_encoding == RADIOLIB_ITA2) {
|
if(encoding == RADIOLIB_ITA2) {
|
||||||
ITA2String ita2 = ITA2String(str);
|
ITA2String ita2 = ITA2String(str);
|
||||||
uint8_t* arr = ita2.byteArr();
|
uint8_t* arr = ita2.byteArr();
|
||||||
l = RTTYClient::write(arr, ita2.length());
|
l = RTTYClient::write(arr, ita2.length());
|
||||||
delete[] arr;
|
delete[] arr;
|
||||||
} else if((_encoding == RADIOLIB_ASCII) || (_encoding == RADIOLIB_ASCII_EXTENDED)) {
|
} else if((encoding == RADIOLIB_ASCII) || (encoding == RADIOLIB_ASCII_EXTENDED)) {
|
||||||
l = RTTYClient::write(str);
|
l = RTTYClient::write(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,25 +464,25 @@ size_t RTTYClient::printFloat(double number, uint8_t digits) {
|
||||||
if (number <-4294967040.0) strcpy(code, "ovf"); // constant determined empirically
|
if (number <-4294967040.0) strcpy(code, "ovf"); // constant determined empirically
|
||||||
|
|
||||||
if(code[0] != 0x00) {
|
if(code[0] != 0x00) {
|
||||||
if(_encoding == RADIOLIB_ITA2) {
|
if(encoding == RADIOLIB_ITA2) {
|
||||||
ITA2String ita2 = ITA2String(code);
|
ITA2String ita2 = ITA2String(code);
|
||||||
uint8_t* arr = ita2.byteArr();
|
uint8_t* arr = ita2.byteArr();
|
||||||
n = RTTYClient::write(arr, ita2.length());
|
n = RTTYClient::write(arr, ita2.length());
|
||||||
delete[] arr;
|
delete[] arr;
|
||||||
return(n);
|
return(n);
|
||||||
} else if((_encoding == RADIOLIB_ASCII) || (_encoding == RADIOLIB_ASCII_EXTENDED)) {
|
} else if((encoding == RADIOLIB_ASCII) || (encoding == RADIOLIB_ASCII_EXTENDED)) {
|
||||||
return(RTTYClient::write(code));
|
return(RTTYClient::write(code));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle negative numbers
|
// Handle negative numbers
|
||||||
if (number < 0.0) {
|
if (number < 0.0) {
|
||||||
if(_encoding == RADIOLIB_ITA2) {
|
if(encoding == RADIOLIB_ITA2) {
|
||||||
ITA2String ita2 = ITA2String("-");
|
ITA2String ita2 = ITA2String("-");
|
||||||
uint8_t* arr = ita2.byteArr();
|
uint8_t* arr = ita2.byteArr();
|
||||||
n += RTTYClient::write(arr, ita2.length());
|
n += RTTYClient::write(arr, ita2.length());
|
||||||
delete[] arr;
|
delete[] arr;
|
||||||
} else if((_encoding == RADIOLIB_ASCII) || (_encoding == RADIOLIB_ASCII_EXTENDED)) {
|
} else if((encoding == RADIOLIB_ASCII) || (encoding == RADIOLIB_ASCII_EXTENDED)) {
|
||||||
n += RTTYClient::print('-');
|
n += RTTYClient::print('-');
|
||||||
}
|
}
|
||||||
number = -number;
|
number = -number;
|
||||||
|
@ -502,12 +502,12 @@ size_t RTTYClient::printFloat(double number, uint8_t digits) {
|
||||||
|
|
||||||
// Print the decimal point, but only if there are digits beyond
|
// Print the decimal point, but only if there are digits beyond
|
||||||
if(digits > 0) {
|
if(digits > 0) {
|
||||||
if(_encoding == RADIOLIB_ITA2) {
|
if(encoding == RADIOLIB_ITA2) {
|
||||||
ITA2String ita2 = ITA2String(".");
|
ITA2String ita2 = ITA2String(".");
|
||||||
uint8_t* arr = ita2.byteArr();
|
uint8_t* arr = ita2.byteArr();
|
||||||
n += RTTYClient::write(arr, ita2.length());
|
n += RTTYClient::write(arr, ita2.length());
|
||||||
delete[] arr;
|
delete[] arr;
|
||||||
} else if((_encoding == RADIOLIB_ASCII) || (_encoding == RADIOLIB_ASCII_EXTENDED)) {
|
} else if((encoding == RADIOLIB_ASCII) || (encoding == RADIOLIB_ASCII_EXTENDED)) {
|
||||||
n += RTTYClient::print('.');
|
n += RTTYClient::print('.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -525,23 +525,23 @@ size_t RTTYClient::printFloat(double number, uint8_t digits) {
|
||||||
|
|
||||||
int16_t RTTYClient::transmitDirect(uint32_t freq, uint32_t freqHz) {
|
int16_t RTTYClient::transmitDirect(uint32_t freq, uint32_t freqHz) {
|
||||||
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
||||||
if(_audio != nullptr) {
|
if(audioClient != nullptr) {
|
||||||
return(_audio->tone(freqHz));
|
return(audioClient->tone(freqHz));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return(_phy->transmitDirect(freq));
|
return(phyLayer->transmitDirect(freq));
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t RTTYClient::standby() {
|
int16_t RTTYClient::standby() {
|
||||||
// ensure everything is stopped in interrupt timing mode
|
// ensure everything is stopped in interrupt timing mode
|
||||||
Module* mod = _phy->getMod();
|
Module* mod = phyLayer->getMod();
|
||||||
mod->waitForMicroseconds(0, 0);
|
mod->waitForMicroseconds(0, 0);
|
||||||
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
||||||
if(_audio != nullptr) {
|
if(audioClient != nullptr) {
|
||||||
return(_audio->noTone());
|
return(audioClient->noTone());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return(_phy->standby());
|
return(phyLayer->standby());
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,28 +15,27 @@
|
||||||
// ITA2 character table: - position in array corresponds to 5-bit ITA2 code
|
// ITA2 character table: - position in array corresponds to 5-bit ITA2 code
|
||||||
// - characters to the left are in letters shift, characters to the right in figures shift
|
// - characters to the left are in letters shift, characters to the right in figures shift
|
||||||
// - characters marked 0x7F do not have ASCII equivalent
|
// - characters marked 0x7F do not have ASCII equivalent
|
||||||
static const char ITA2Table[RADIOLIB_ITA2_LENGTH][2] RADIOLIB_NONVOLATILE = {{'\0', '\0'}, {'E', '3'}, {'\n', '\n'}, {'A', '-'}, {' ', ' '}, {'S', '\''}, {'I', '8'}, {'U', '7'},
|
static const char ITA2Table[RADIOLIB_ITA2_LENGTH][2] RADIOLIB_NONVOLATILE = {
|
||||||
|
{'\0', '\0'}, {'E', '3'}, {'\n', '\n'}, {'A', '-'}, {' ', ' '}, {'S', '\''}, {'I', '8'}, {'U', '7'},
|
||||||
{'\r', '\r'}, {'D', 0x05}, {'R', '4'}, {'J', '\a'}, {'N', ','}, {'F', '!'}, {'C', ':'}, {'K', '('},
|
{'\r', '\r'}, {'D', 0x05}, {'R', '4'}, {'J', '\a'}, {'N', ','}, {'F', '!'}, {'C', ':'}, {'K', '('},
|
||||||
{'T', '5'}, {'Z', '+'}, {'L', ')'}, {'W', '2'}, {'H', 0x7F}, {'Y', '6'}, {'P', '0'}, {'Q', '1'},
|
{'T', '5'}, {'Z', '+'}, {'L', ')'}, {'W', '2'}, {'H', 0x7F}, {'Y', '6'}, {'P', '0'}, {'Q', '1'},
|
||||||
{'O', '9'}, {'B', '?'}, {'G', '&'}, {0x7F, 0x7F}, {'M', '.'}, {'X', '/'}, {'V', ';'}, {0x7F, 0x7F}};
|
{'O', '9'}, {'B', '?'}, {'G', '&'}, {0x7F, 0x7F}, {'M', '.'}, {'X', '/'}, {'V', ';'}, {0x7F, 0x7F}
|
||||||
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class ITA2String
|
\class ITA2String
|
||||||
|
|
||||||
\brief ITA2-encoded string.
|
\brief ITA2-encoded string.
|
||||||
*/
|
*/
|
||||||
class ITA2String {
|
class ITA2String {
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
\brief Default single-character constructor.
|
\brief Default single-character constructor.
|
||||||
|
|
||||||
\param c ASCII-encoded character to encode as ITA2.
|
\param c ASCII-encoded character to encode as ITA2.
|
||||||
*/
|
*/
|
||||||
explicit ITA2String(char c);
|
explicit ITA2String(char c);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Default string constructor.
|
\brief Default string constructor.
|
||||||
|
|
||||||
\param str ASCII-encoded string to encode as ITA2.
|
\param str ASCII-encoded string to encode as ITA2.
|
||||||
*/
|
*/
|
||||||
explicit ITA2String(const char* str);
|
explicit ITA2String(const char* str);
|
||||||
|
@ -48,14 +47,12 @@ class ITA2String {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Gets the length of the ITA2 string. This number is not the same as the length of ASCII-encoded string!
|
\brief Gets the length of the ITA2 string. This number is not the same as the length of ASCII-encoded string!
|
||||||
|
|
||||||
\returns Length of ITA2-encoded string.
|
\returns Length of ITA2-encoded string.
|
||||||
*/
|
*/
|
||||||
size_t length();
|
size_t length();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Gets the ITA2 representation of the ASCII string set in constructor.
|
\brief Gets the ITA2 representation of the ASCII string set in constructor.
|
||||||
|
|
||||||
\returns Pointer to dynamically allocated array, which contains ITA2-encoded bytes.
|
\returns Pointer to dynamically allocated array, which contains ITA2-encoded bytes.
|
||||||
It is the caller's responsibility to deallocate this memory!
|
It is the caller's responsibility to deallocate this memory!
|
||||||
*/
|
*/
|
||||||
|
@ -65,12 +62,12 @@ class ITA2String {
|
||||||
private:
|
private:
|
||||||
#endif
|
#endif
|
||||||
#if defined(RADIOLIB_STATIC_ONLY)
|
#if defined(RADIOLIB_STATIC_ONLY)
|
||||||
char _str[RADIOLIB_STATIC_ARRAY_SIZE];
|
char strAscii[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||||
#else
|
#else
|
||||||
char* _str;
|
char* strAscii;
|
||||||
#endif
|
#endif
|
||||||
size_t _len;
|
size_t asciiLen;
|
||||||
size_t _ita2Len;
|
size_t ita2Len;
|
||||||
|
|
||||||
static uint16_t getBits(char c);
|
static uint16_t getBits(char c);
|
||||||
};
|
};
|
||||||
|
@ -82,14 +79,12 @@ class ITA2String {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class RTTYClient
|
\class RTTYClient
|
||||||
|
|
||||||
\brief Client for RTTY communication. The public interface is the same as Arduino Serial.
|
\brief Client for RTTY communication. The public interface is the same as Arduino Serial.
|
||||||
*/
|
*/
|
||||||
class RTTYClient {
|
class RTTYClient {
|
||||||
public:
|
public:
|
||||||
/*!
|
/*!
|
||||||
\brief Constructor for 2-FSK mode.
|
\brief Constructor for 2-FSK mode.
|
||||||
|
|
||||||
\param phy Pointer to the wireless module providing PhysicalLayer communication.
|
\param phy Pointer to the wireless module providing PhysicalLayer communication.
|
||||||
*/
|
*/
|
||||||
explicit RTTYClient(PhysicalLayer* phy);
|
explicit RTTYClient(PhysicalLayer* phy);
|
||||||
|
@ -97,7 +92,6 @@ class RTTYClient {
|
||||||
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
||||||
/*!
|
/*!
|
||||||
\brief Constructor for AFSK mode.
|
\brief Constructor for AFSK mode.
|
||||||
|
|
||||||
\param audio Pointer to the AFSK instance providing audio.
|
\param audio Pointer to the AFSK instance providing audio.
|
||||||
*/
|
*/
|
||||||
explicit RTTYClient(AFSKClient* audio);
|
explicit RTTYClient(AFSKClient* audio);
|
||||||
|
@ -107,20 +101,14 @@ class RTTYClient {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Initialization method.
|
\brief Initialization method.
|
||||||
|
|
||||||
\param base Base (space) frequency to be used in MHz (in 2-FSK mode), or the space tone frequency in Hz (in AFSK mode)
|
\param base Base (space) frequency to be used in MHz (in 2-FSK mode), or the space tone frequency in Hz (in AFSK mode)
|
||||||
|
|
||||||
\param shift Frequency shift between mark and space in Hz.
|
\param shift Frequency shift between mark and space in Hz.
|
||||||
|
|
||||||
\param rate Baud rate to be used during transmission.
|
\param rate Baud rate to be used during transmission.
|
||||||
|
\param enc Encoding to be used. Defaults to ASCII.
|
||||||
\param encoding Encoding to be used. Defaults to ASCII.
|
|
||||||
|
|
||||||
\param stopBits Number of stop bits to be used.
|
\param stopBits Number of stop bits to be used.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t begin(float base, uint32_t shift, uint16_t rate, uint8_t encoding = RADIOLIB_ASCII, uint8_t stopBits = 1);
|
int16_t begin(float base, uint32_t shift, uint16_t rate, uint8_t enc = RADIOLIB_ASCII, uint8_t stopBits = 1);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Send out idle condition (RF tone at mark frequency).
|
\brief Send out idle condition (RF tone at mark frequency).
|
||||||
|
@ -129,7 +117,6 @@ class RTTYClient {
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Stops transmitting.
|
\brief Stops transmitting.
|
||||||
|
|
||||||
\returns \ref status_codes
|
\returns \ref status_codes
|
||||||
*/
|
*/
|
||||||
int16_t standby();
|
int16_t standby();
|
||||||
|
@ -170,17 +157,17 @@ class RTTYClient {
|
||||||
#if !defined(RADIOLIB_GODMODE)
|
#if !defined(RADIOLIB_GODMODE)
|
||||||
private:
|
private:
|
||||||
#endif
|
#endif
|
||||||
PhysicalLayer* _phy;
|
PhysicalLayer* phyLayer;
|
||||||
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
#if !defined(RADIOLIB_EXCLUDE_AFSK)
|
||||||
AFSKClient* _audio;
|
AFSKClient* audioClient;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t _encoding = RADIOLIB_ASCII;
|
uint8_t encoding = RADIOLIB_ASCII;
|
||||||
uint32_t _base = 0, _baseHz = 0;
|
uint32_t baseFreq = 0, baseFreqHz = 0;
|
||||||
uint32_t _shift = 0, _shiftHz = 0;
|
uint32_t shiftFreq = 0, shiftFreqHz = 0;
|
||||||
uint32_t _bitDuration = 0;
|
uint32_t bitDuration = 0;
|
||||||
uint8_t _dataBits = 0;
|
uint8_t dataBitsNum = 0;
|
||||||
uint8_t _stopBits = 0;
|
uint8_t stopBitsNum = 0;
|
||||||
|
|
||||||
void mark();
|
void mark();
|
||||||
void space();
|
void space();
|
||||||
|
|
Loading…
Add table
Reference in a new issue