Merge pull request #726 from Mesteery/fix-generic-build

Fix generic build
This commit is contained in:
Jan Gromeš 2023-04-10 17:25:40 +02:00 committed by GitHub
commit 9c019a58e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 205 additions and 231 deletions

View file

@ -1040,14 +1040,14 @@
#if defined(RADIOLIB_DEBUG)
#if defined(RADIOLIB_BUILD_ARDUINO)
#define RADIOLIB_DEBUG_PRINT(...) { RADIOLIB_DEBUG_PORT.print(__VA_ARGS__); }
#define RADIOLIB_DEBUG_PRINTLN(...) { RADIOLIB_DEBUG_PORT.println(__VA_ARGS__); }
#define RADIOLIB_DEBUG_PRINT(...) Module::serialPrintf(__VA_ARGS__)
#define RADIOLIB_DEBUG_PRINTLN(M, ...) Module::serialPrintf(M "\n", ##__VA_ARGS__)
#else
#if !defined(RADIOLIB_DEBUG_PRINT)
#define RADIOLIB_DEBUG_PRINT(...) { frintf(RADIOLIB_DEBUG_PORT, __VA_ARGS__); }
#define RADIOLIB_DEBUG_PRINT(...) fprintf(RADIOLIB_DEBUG_PORT, __VA_ARGS__)
#endif
#if !defined(RADIOLIB_DEBUG_PRINTLN)
#define RADIOLIB_DEBUG_PRINTLN(...) { printf(RADIOLIB_DEBUG_PORT, __VA_ARGS__ "\n"); }
#define RADIOLIB_DEBUG_PRINTLN(M, ...) fprintf(RADIOLIB_DEBUG_PORT, M "\n", ##__VA_ARGS__)
#endif
#endif
#else

View file

@ -160,24 +160,26 @@ int16_t Module::SPIsetRegValue(uint16_t reg, uint8_t value, uint8_t msb, uint8_t
}
}
#if defined(RADIOLIB_DEBUG) && defined(RADIOLIB_BUILD_ARDUINO)
#define RADIOLIB_DEBUG_PRINT_BIN(x) RADIOLIB_DEBUG_PORT.println(x, BIN)
#else // no bin representation, fallback to hex
#define RADIOLIB_DEBUG_PRINT_BIN(x) RADIOLIB_DEBUG_PRINTLN("%X", x)
#endif
// check failed, print debug info
RADIOLIB_DEBUG_PRINTLN();
RADIOLIB_DEBUG_PRINT(F("address:\t0x"));
RADIOLIB_DEBUG_PRINTLN(reg, HEX);
RADIOLIB_DEBUG_PRINT(F("bits:\t\t"));
RADIOLIB_DEBUG_PRINT(msb);
RADIOLIB_DEBUG_PRINT(' ');
RADIOLIB_DEBUG_PRINTLN(lsb);
RADIOLIB_DEBUG_PRINT(F("value:\t\t0b"));
RADIOLIB_DEBUG_PRINTLN(value, BIN);
RADIOLIB_DEBUG_PRINT(F("current:\t0b"));
RADIOLIB_DEBUG_PRINTLN(currentValue, BIN);
RADIOLIB_DEBUG_PRINT(F("mask:\t\t0b"));
RADIOLIB_DEBUG_PRINTLN(mask, BIN);
RADIOLIB_DEBUG_PRINT(F("new:\t\t0b"));
RADIOLIB_DEBUG_PRINTLN(newValue, BIN);
RADIOLIB_DEBUG_PRINT(F("read:\t\t0b"));
RADIOLIB_DEBUG_PRINTLN(readValue, BIN);
RADIOLIB_DEBUG_PRINTLN("address:\t0x%X", reg);
RADIOLIB_DEBUG_PRINTLN("bits:\t\t%d %d", msb, lsb);
RADIOLIB_DEBUG_PRINT("value:\t\t0b");
RADIOLIB_DEBUG_PRINT_BIN(value);
RADIOLIB_DEBUG_PRINT("current:\t0b");
RADIOLIB_DEBUG_PRINT_BIN(currentValue);
RADIOLIB_DEBUG_PRINT("mask:\t\t0b");
RADIOLIB_DEBUG_PRINT_BIN(mask);
RADIOLIB_DEBUG_PRINT("new:\t\t0b");
RADIOLIB_DEBUG_PRINT_BIN(newValue);
RADIOLIB_DEBUG_PRINT("read:\t\t0b");
RADIOLIB_DEBUG_PRINT_BIN(readValue);
RADIOLIB_DEBUG_PRINTLN();
return(RADIOLIB_ERR_SPI_WRITE_FAILED);
@ -241,13 +243,11 @@ void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* d
#if defined(RADIOLIB_VERBOSE)
if(cmd == SPIwriteCommand) {
RADIOLIB_VERBOSE_PRINT('W');
RADIOLIB_VERBOSE_PRINT("W");
} else if(cmd == SPIreadCommand) {
RADIOLIB_VERBOSE_PRINT('R');
RADIOLIB_VERBOSE_PRINT("R");
}
RADIOLIB_VERBOSE_PRINT('\t')
RADIOLIB_VERBOSE_PRINT(reg, HEX);
RADIOLIB_VERBOSE_PRINT('\t');
RADIOLIB_VERBOSE_PRINT("\t%X\t", reg);
#endif
// send data or get response
@ -255,16 +255,14 @@ void Module::SPItransfer(uint8_t cmd, uint16_t reg, uint8_t* dataOut, uint8_t* d
if(dataOut != NULL) {
for(size_t n = 0; n < numBytes; n++) {
this->transfer(dataOut[n]);
RADIOLIB_VERBOSE_PRINT(dataOut[n], HEX);
RADIOLIB_VERBOSE_PRINT('\t');
RADIOLIB_VERBOSE_PRINT("%X\t", dataOut[n]);
}
}
} else if (cmd == SPIreadCommand) {
if(dataIn != NULL) {
for(size_t n = 0; n < numBytes; n++) {
dataIn[n] = this->transfer(0x00);
RADIOLIB_VERBOSE_PRINT(dataIn[n], HEX);
RADIOLIB_VERBOSE_PRINT('\t');
RADIOLIB_VERBOSE_PRINT("%X\t", dataIn[n]);
}
}
}
@ -419,8 +417,7 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
// print command byte(s)
RADIOLIB_VERBOSE_PRINT("CMD\t");
for(uint8_t n = 0; n < cmdLen; n++) {
RADIOLIB_VERBOSE_PRINT(cmd[n], HEX);
RADIOLIB_VERBOSE_PRINT('\t');
RADIOLIB_VERBOSE_PRINT("%X\t", cmd[n]);
}
RADIOLIB_VERBOSE_PRINTLN();
@ -429,25 +426,14 @@ int16_t Module::SPItransferStream(uint8_t* cmd, uint8_t cmdLen, bool write, uint
if(write) {
RADIOLIB_VERBOSE_PRINT("W\t");
for(size_t n = 0; n < numBytes; n++) {
RADIOLIB_VERBOSE_PRINT(dataOut[n], HEX);
RADIOLIB_VERBOSE_PRINT('\t');
RADIOLIB_VERBOSE_PRINT(debugBuff[n], HEX);
RADIOLIB_VERBOSE_PRINT('\t');
RADIOLIB_VERBOSE_PRINT("%X\t%X\t", dataOut[n], debugBuff[n]);
}
RADIOLIB_VERBOSE_PRINTLN();
} else {
RADIOLIB_VERBOSE_PRINT("R\t");
// skip the first byte for read-type commands (status-only)
RADIOLIB_VERBOSE_PRINT(this->SPInopCommand, HEX);
RADIOLIB_VERBOSE_PRINT('\t');
RADIOLIB_VERBOSE_PRINT(debugBuff[0], HEX);
RADIOLIB_VERBOSE_PRINT('\t')
RADIOLIB_VERBOSE_PRINT("R\t%X\t%X\t", this->SPInopCommand, debugBuff[0]);
for(size_t n = 0; n < numBytes; n++) {
RADIOLIB_VERBOSE_PRINT(this->SPInopCommand, HEX);
RADIOLIB_VERBOSE_PRINT('\t');
RADIOLIB_VERBOSE_PRINT(dataIn[n], HEX);
RADIOLIB_VERBOSE_PRINT('\t');
RADIOLIB_VERBOSE_PRINT("%X\t%X\t", this->SPInopCommand, dataIn[n]);
}
RADIOLIB_VERBOSE_PRINTLN();
}
@ -752,7 +738,8 @@ void Module::hexdump(uint8_t* data, size_t len, uint32_t offset, uint8_t width,
for(size_t j = line_len; j < 16; j++) {
sprintf(&str[58 + j], " ");
}
RADIOLIB_DEBUG_PRINTLN(str);
RADIOLIB_DEBUG_PRINT(str);
RADIOLIB_DEBUG_PRINTLN();
rem_len -= 16;
}
}
@ -770,6 +757,32 @@ void Module::regdump(uint16_t start, size_t len) {
#endif
}
#if defined(RADIOLIB_DEBUG) and defined(RADIOLIB_BUILD_ARDUINO)
// https://github.com/esp8266/Arduino/blob/65579d29081cb8501e4d7f786747bf12e7b37da2/cores/esp8266/Print.cpp#L50
size_t Module::serialPrintf(const char* format, ...) {
va_list arg;
va_start(arg, format);
char temp[64];
char* buffer = temp;
size_t len = vsnprintf(temp, sizeof(temp), format, arg);
va_end(arg);
if (len > sizeof(temp) - 1) {
buffer = new char[len + 1];
if (!buffer) {
return 0;
}
va_start(arg, format);
vsnprintf(buffer, len + 1, format, arg);
va_end(arg);
}
len = RADIOLIB_DEBUG_PORT.write((const uint8_t*)buffer, len);
if (buffer != temp) {
delete[] buffer;
}
return len;
}
#endif
void Module::setRfSwitchPins(RADIOLIB_PIN_TYPE rxEn, RADIOLIB_PIN_TYPE txEn) {
// This can be on the stack, setRfSwitchTable copies the contents
const RADIOLIB_PIN_TYPE pins[] = {

View file

@ -704,6 +704,10 @@ class Module {
*/
void regdump(uint16_t start, size_t len);
#if defined(RADIOLIB_DEBUG) and defined(RADIOLIB_BUILD_ARDUINO)
static size_t serialPrintf(const char* format, ...);
#endif
#if !defined(RADIOLIB_GODMODE)
private:
#endif

View file

@ -24,28 +24,18 @@ int16_t CC1101::begin(float freq, float br, float freqDev, float rxBw, int8_t po
if((version == RADIOLIB_CC1101_VERSION_CURRENT) || (version == RADIOLIB_CC1101_VERSION_LEGACY) || (version == RADIOLIB_CC1101_VERSION_CLONE)) {
flagFound = true;
} else {
#if defined(RADIOLIB_DEBUG)
RADIOLIB_DEBUG_PRINT(F("CC1101 not found! ("));
RADIOLIB_DEBUG_PRINT(i + 1);
RADIOLIB_DEBUG_PRINT(F(" of 10 tries) RADIOLIB_CC1101_REG_VERSION == "));
char buffHex[7];
sprintf(buffHex, "0x%04X", version);
RADIOLIB_DEBUG_PRINT(buffHex);
RADIOLIB_DEBUG_PRINT(F(", expected 0x0004/0x0014"));
RADIOLIB_DEBUG_PRINTLN();
#endif
RADIOLIB_DEBUG_PRINTLN("CC1101 not found! (%d of 10 tries) RADIOLIB_CC1101_REG_VERSION == 0x%04X, expected 0x0004/0x0014", i + 1, version);
_mod->delay(10);
i++;
}
}
if(!flagFound) {
RADIOLIB_DEBUG_PRINTLN(F("No CC1101 found!"));
RADIOLIB_DEBUG_PRINTLN("No CC1101 found!");
_mod->term();
return(RADIOLIB_ERR_CHIP_NOT_FOUND);
} else {
RADIOLIB_DEBUG_PRINTLN(F("M\tCC1101"));
RADIOLIB_DEBUG_PRINTLN("M\tCC1101");
}
// configure settings not accessible by API
@ -319,7 +309,7 @@ int16_t CC1101::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
*
* TODO: test this on real hardware
*/
delayMicroseconds(250);
_mod->delayMicroseconds(250);
}
}
@ -388,7 +378,7 @@ int16_t CC1101::readData(uint8_t* data, size_t len) {
if (bytesInFIFO == 0) {
if (millis() - lastPop > 5) {
// readData was required to read a packet longer than the one received.
RADIOLIB_DEBUG_PRINTLN(F("No data for more than 5mS. Stop here."));
RADIOLIB_DEBUG_PRINTLN("No data for more than 5mS. Stop here.");
break;
} else {
delay(1);
@ -919,7 +909,7 @@ void CC1101::setRfSwitchTable(const RADIOLIB_PIN_TYPE (&pins)[Module::RFSWITCH_M
uint8_t CC1101::randomByte() {
// set mode to Rx
SPIsendCommand(RADIOLIB_CC1101_CMD_RX);
RADIOLIB_DEBUG_PRINTLN("random");
RADIOLIB_DEBUG_PRINTLN("CC1101::randomByte");
// wait a bit for the RSSI reading to stabilise
_mod->delay(10);
@ -946,7 +936,7 @@ void CC1101::setDirectAction(void (*func)(void)) {
}
void CC1101::readBit(RADIOLIB_PIN_TYPE pin) {
updateDirectBuffer((uint8_t)digitalRead(pin));
updateDirectBuffer((uint8_t)_mod->digitalRead(pin));
}
#endif

View file

@ -26,28 +26,18 @@ int16_t RF69::begin(float freq, float br, float freqDev, float rxBw, int8_t powe
if(version == RADIOLIB_RF69_CHIP_VERSION) {
flagFound = true;
} else {
#if defined(RADIOLIB_DEBUG)
RADIOLIB_DEBUG_PRINT(F("RF69 not found! ("));
RADIOLIB_DEBUG_PRINT(i + 1);
RADIOLIB_DEBUG_PRINT(F(" of 10 tries) RADIOLIB_RF69_REG_VERSION == "));
char buffHex[7];
sprintf(buffHex, "0x%04X", version);
RADIOLIB_DEBUG_PRINT(buffHex);
RADIOLIB_DEBUG_PRINT(F(", expected 0x0024"));
RADIOLIB_DEBUG_PRINTLN();
#endif
RADIOLIB_DEBUG_PRINTLN("RF69 not found! (%d of 10 tries) RADIOLIB_RF69_REG_VERSION == 0x%04X, expected 0x0024", i + 1, version);
_mod->delay(10);
i++;
}
}
if(!flagFound) {
RADIOLIB_DEBUG_PRINTLN(F("No RF69 found!"));
RADIOLIB_DEBUG_PRINTLN("No RF69 found!");
_mod->term();
return(RADIOLIB_ERR_CHIP_NOT_FOUND);
} else {
RADIOLIB_DEBUG_PRINTLN(F("M\tRF69"));
RADIOLIB_DEBUG_PRINTLN("M\tRF69");
}
// configure settings not accessible by API
@ -959,7 +949,7 @@ void RF69::setDirectAction(void (*func)(void)) {
}
void RF69::readBit(RADIOLIB_PIN_TYPE pin) {
updateDirectBuffer((uint8_t)digitalRead(pin));
updateDirectBuffer((uint8_t)_mod->digitalRead(pin));
}
#endif

View file

@ -16,8 +16,8 @@ int16_t RFM95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncW
// some other error
return(state);
}
RADIOLIB_DEBUG_PRINTLN(F("M\tSX1278"));
RADIOLIB_DEBUG_PRINTLN(F("M\tRFM95"));
RADIOLIB_DEBUG_PRINTLN("M\tSX1278");
RADIOLIB_DEBUG_PRINTLN("M\tRFM95");
// configure publicly accessible settings
state = setBandwidth(bw);
@ -51,8 +51,8 @@ int16_t RFM95::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t
// some other error
return(state);
}
RADIOLIB_DEBUG_PRINTLN(F("M\tSX1278"));
RADIOLIB_DEBUG_PRINTLN(F("M\tRFM95"));
RADIOLIB_DEBUG_PRINTLN("M\tSX1278");
RADIOLIB_DEBUG_PRINTLN("M\tRFM95");
// configure settings not accessible by API
state = configFSK();

View file

@ -16,8 +16,8 @@ int16_t RFM96::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncW
// some other error
return(state);
}
RADIOLIB_DEBUG_PRINTLN(F("M\tSX1278"));
RADIOLIB_DEBUG_PRINTLN(F("M\tRFM96"));
RADIOLIB_DEBUG_PRINTLN("M\tSX1278");
RADIOLIB_DEBUG_PRINTLN("M\tRFM96");
// configure publicly accessible settings
state = setBandwidth(bw);
@ -52,8 +52,8 @@ int16_t RFM96::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t
// some other error
return(state);
}
RADIOLIB_DEBUG_PRINTLN(F("M\tSX1278"));
RADIOLIB_DEBUG_PRINTLN(F("M\tRFM96"));
RADIOLIB_DEBUG_PRINTLN("M\tSX1278");
RADIOLIB_DEBUG_PRINTLN("M\tRFM96");
// configure settings not accessible by API
state = configFSK();

View file

@ -20,33 +20,23 @@ int16_t SX1231::begin(float freq, float br, float freqDev, float rxBw, int8_t po
flagFound = true;
_chipRevision = version;
} else {
#if defined(RADIOLIB_DEBUG)
RADIOLIB_DEBUG_PRINT(F("SX1231 not found! ("));
RADIOLIB_DEBUG_PRINT(i + 1);
RADIOLIB_DEBUG_PRINT(F(" of 10 tries) RF69_REG_VERSION == "));
char buffHex[12];
sprintf(buffHex, "0x%04X", version);
RADIOLIB_DEBUG_PRINT(buffHex);
RADIOLIB_DEBUG_PRINT(F(", expected 0x0021 / 0x0022 / 0x0023"));
RADIOLIB_DEBUG_PRINTLN();
#endif
RADIOLIB_DEBUG_PRINTLN("SX1231 not found! (%d of 10 tries) RF69_REG_VERSION == 0x%04X, expected 0x0021 / 0x0022 / 0x0023", i + 1, version);
_mod->delay(10);
i++;
}
}
if(!flagFound) {
RADIOLIB_DEBUG_PRINTLN(F("No SX1231 found!"));
RADIOLIB_DEBUG_PRINTLN("No SX1231 found!");
_mod->term();
return(RADIOLIB_ERR_CHIP_NOT_FOUND);
}
RADIOLIB_DEBUG_PRINTLN(F("M\tSX1231"));
RADIOLIB_DEBUG_PRINTLN("M\tSX1231");
// configure settings not accessible by API
int16_t state = config();
RADIOLIB_ASSERT(state);
RADIOLIB_DEBUG_PRINTLN(F("M\tRF69"));
RADIOLIB_DEBUG_PRINTLN("M\tRF69");
// configure publicly accessible settings
state = setFrequency(freq);

View file

@ -24,11 +24,11 @@ int16_t SX126x::begin(uint8_t cr, uint8_t syncWord, uint16_t preambleLength, flo
// try to find the SX126x chip
if(!SX126x::findChip(_chipType)) {
RADIOLIB_DEBUG_PRINTLN(F("No SX126x found!"));
RADIOLIB_DEBUG_PRINTLN("No SX126x found!");
_mod->term();
return(RADIOLIB_ERR_CHIP_NOT_FOUND);
}
RADIOLIB_DEBUG_PRINTLN(F("M\tSX126x"));
RADIOLIB_DEBUG_PRINTLN("M\tSX126x");
// BW in kHz and SF are required in order to calculate LDRO for setModulationParams
// set the defaults, this will get overwritten later anyway
@ -106,11 +106,11 @@ int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, uint16_t preambleL
// try to find the SX126x chip
if(!SX126x::findChip(_chipType)) {
RADIOLIB_DEBUG_PRINTLN(F("No SX126x found!"));
RADIOLIB_DEBUG_PRINTLN("No SX126x found!");
_mod->term();
return(RADIOLIB_ERR_CHIP_NOT_FOUND);
}
RADIOLIB_DEBUG_PRINTLN(F("M\tSX126x"));
RADIOLIB_DEBUG_PRINTLN("M\tSX126x");
// initialize configuration variables (will be overwritten during public settings configuration)
_br = 21333; // 48.0 kbps
@ -245,9 +245,7 @@ int16_t SX126x::transmit(uint8_t* data, size_t len, uint8_t addr) {
return(RADIOLIB_ERR_UNKNOWN);
}
RADIOLIB_DEBUG_PRINT(F("Timeout in "));
RADIOLIB_DEBUG_PRINT(timeout);
RADIOLIB_DEBUG_PRINTLN(F(" us"));
RADIOLIB_DEBUG_PRINTLN("Timeout in %d us", timeout);
// start transmission
state = startTransmit(data, len, addr);
@ -296,9 +294,7 @@ int16_t SX126x::receive(uint8_t* data, size_t len) {
return(RADIOLIB_ERR_UNKNOWN);
}
RADIOLIB_DEBUG_PRINT(F("Timeout in "));
RADIOLIB_DEBUG_PRINT(timeout);
RADIOLIB_DEBUG_PRINTLN(F(" us"));
RADIOLIB_DEBUG_PRINTLN("Timeout in %d us", timeout);
// start reception
uint32_t timeoutValue = (uint32_t)((float)timeout / 15.625);
@ -594,8 +590,7 @@ int16_t SX126x::startReceiveDutyCycleAuto(uint16_t senderPreambleLength, uint16_
uint32_t symbolLength = ((uint32_t)(10 * 1000) << _sf) / (10 * _bwKhz);
uint32_t sleepPeriod = symbolLength * sleepSymbols;
RADIOLIB_DEBUG_PRINT(F("Auto sleep period: "));
RADIOLIB_DEBUG_PRINTLN(sleepPeriod);
RADIOLIB_DEBUG_PRINTLN("Auto sleep period: %d", sleepPeriod);
// when the unit detects a preamble, it starts a timer that will timeout if it doesn't receive a header in time.
// the duration is sleepPeriod + 2 * wakePeriod.
@ -606,8 +601,7 @@ int16_t SX126x::startReceiveDutyCycleAuto(uint16_t senderPreambleLength, uint16_
uint32_t wakePeriod = max(
(symbolLength * (senderPreambleLength + 1) - (sleepPeriod - 1000)) / 2, // (A)
symbolLength * (minSymbols + 1)); //(B)
RADIOLIB_DEBUG_PRINT(F("Auto wake period: "));
RADIOLIB_DEBUG_PRINTLN(wakePeriod);
RADIOLIB_DEBUG_PRINTLN("Auto wake period: ", wakePeriod);
// If our sleep period is shorter than our transition time, just use the standard startReceive
if(sleepPeriod < _tcxoDelay + 1016) {
@ -1440,7 +1434,7 @@ void SX126x::setDirectAction(void (*func)(void)) {
}
void SX126x::readBit(RADIOLIB_PIN_TYPE pin) {
updateDirectBuffer((uint8_t)digitalRead(pin));
updateDirectBuffer((uint8_t)_mod->digitalRead(pin));
}
#endif
@ -1453,8 +1447,7 @@ int16_t SX126x::uploadPatch(const uint32_t* patch, size_t len, bool nonvolatile)
#if defined(RADIOLIB_DEBUG)
char ver_pre[16];
_mod->SPIreadRegisterBurst(RADIOLIB_SX126X_REG_VERSION_STRING, 16, (uint8_t*)ver_pre);
RADIOLIB_DEBUG_PRINT(F("Pre-update version string: "));
RADIOLIB_DEBUG_PRINTLN(ver_pre);
RADIOLIB_DEBUG_PRINTLN("Pre-update version string: %d", ver_pre);
#endif
// enable patch update
@ -1486,8 +1479,7 @@ int16_t SX126x::uploadPatch(const uint32_t* patch, size_t len, bool nonvolatile)
#if defined(RADIOLIB_DEBUG)
char ver_post[16];
_mod->SPIreadRegisterBurst(RADIOLIB_SX126X_REG_VERSION_STRING, 16, (uint8_t*)ver_post);
RADIOLIB_DEBUG_PRINT(F("Post-update version string: "));
RADIOLIB_DEBUG_PRINTLN(ver_post);
RADIOLIB_DEBUG_PRINTLN("Post-update version string: %d", ver_post);
#endif
return(state);
@ -1714,8 +1706,7 @@ int16_t SX126x::calibrateImage(uint8_t* data) {
// unless mode is forced to standby, device errors will be 0
standby();
uint16_t errors = getDeviceErrors();
RADIOLIB_DEBUG_PRINT("Calibration failed, device errors: 0x");
RADIOLIB_DEBUG_PRINTLN(errors, HEX);
RADIOLIB_DEBUG_PRINTLN("Calibration failed, device errors: 0x%X", errors);
}
#endif
return(state);
@ -1768,9 +1759,7 @@ int16_t SX126x::setModulationParams(uint8_t sf, uint8_t bw, uint8_t cr, uint8_t
// calculate symbol length and enable low data rate optimization, if auto-configuration is enabled
if(_ldroAuto) {
float symbolLength = (float)(uint32_t(1) << _sf) / (float)_bwKhz;
RADIOLIB_DEBUG_PRINT("Symbol length: ");
RADIOLIB_DEBUG_PRINT(symbolLength);
RADIOLIB_DEBUG_PRINTLN(" ms");
RADIOLIB_DEBUG_PRINTLN("Symbol length: %d ms", symbolLength);
if(symbolLength >= 16.0) {
_ldro = RADIOLIB_SX126X_LORA_LOW_DATA_RATE_OPTIMIZE_ON;
} else {
@ -1978,8 +1967,7 @@ int16_t SX126x::config(uint8_t modem) {
// unless mode is forced to standby, device errors will be 0
standby();
uint16_t errors = getDeviceErrors();
RADIOLIB_DEBUG_PRINT("Calibration failed, device errors: 0x");
RADIOLIB_DEBUG_PRINTLN(errors, HEX);
RADIOLIB_DEBUG_PRINTLN("Calibration failed, device errors: 0x%X", errors);
}
#endif
@ -2012,18 +2000,15 @@ bool SX126x::findChip(const char* verStr) {
// check version register
if(strncmp(verStr, version, 6) == 0) {
RADIOLIB_DEBUG_PRINTLN(F("Found SX126x: RADIOLIB_SX126X_REG_VERSION_STRING:"));
RADIOLIB_DEBUG_PRINTLN("Found SX126x: RADIOLIB_SX126X_REG_VERSION_STRING:");
_mod->hexdump((uint8_t*)version, 16, RADIOLIB_SX126X_REG_VERSION_STRING);
RADIOLIB_DEBUG_PRINTLN();
flagFound = true;
} else {
#if defined(RADIOLIB_DEBUG)
RADIOLIB_DEBUG_PRINT(F("SX126x not found! ("));
RADIOLIB_DEBUG_PRINT(i + 1);
RADIOLIB_DEBUG_PRINTLN(F(" of 10 tries) RADIOLIB_SX126X_REG_VERSION_STRING:"));
RADIOLIB_DEBUG_PRINTLN("SX126x not found! (%d of 10 tries) RADIOLIB_SX126X_REG_VERSION_STRING:", i + 1);
_mod->hexdump((uint8_t*)version, 16, RADIOLIB_SX126X_REG_VERSION_STRING);
RADIOLIB_DEBUG_PRINT(F("Expected string: "));
RADIOLIB_DEBUG_PRINTLN(verStr);
RADIOLIB_DEBUG_PRINTLN("Expected string: %s", verStr);
#endif
_mod->delay(10);
i++;

View file

@ -116,9 +116,7 @@ int16_t SX1272::setBandwidth(float bw) {
// calculate symbol length and set low data rate optimization, if auto-configuration is enabled
if(_ldroAuto) {
float symbolLength = (float)(uint32_t(1) << SX127x::_sf) / (float)SX127x::_bw;
RADIOLIB_DEBUG_PRINT("Symbol length: ");
RADIOLIB_DEBUG_PRINT(symbolLength);
RADIOLIB_DEBUG_PRINTLN(" ms");
RADIOLIB_DEBUG_PRINTLN("Symbol length: %f ms", symbolLength);
if(symbolLength >= 16.0) {
state = _mod->SPIsetRegValue(RADIOLIB_SX127X_REG_MODEM_CONFIG_1, RADIOLIB_SX1272_LOW_DATA_RATE_OPT_ON, 0, 0);
} else {
@ -172,9 +170,7 @@ int16_t SX1272::setSpreadingFactor(uint8_t sf) {
// calculate symbol length and set low data rate optimization, if auto-configuration is enabled
if(_ldroAuto) {
float symbolLength = (float)(uint32_t(1) << SX127x::_sf) / (float)SX127x::_bw;
RADIOLIB_DEBUG_PRINT("Symbol length: ");
RADIOLIB_DEBUG_PRINT(symbolLength);
RADIOLIB_DEBUG_PRINTLN(" ms");
RADIOLIB_DEBUG_PRINTLN("Symbol length: %f ms", symbolLength);
if(symbolLength >= 16.0) {
state = _mod->SPIsetRegValue(RADIOLIB_SX127X_REG_MODEM_CONFIG_1, RADIOLIB_SX1272_LOW_DATA_RATE_OPT_ON, 0, 0);
} else {

View file

@ -130,9 +130,7 @@ int16_t SX1278::setBandwidth(float bw) {
// calculate symbol length and set low data rate optimization, if auto-configuration is enabled
if(_ldroAuto) {
float symbolLength = (float)(uint32_t(1) << SX127x::_sf) / (float)SX127x::_bw;
RADIOLIB_DEBUG_PRINT("Symbol length: ");
RADIOLIB_DEBUG_PRINT(symbolLength);
RADIOLIB_DEBUG_PRINTLN(" ms");
RADIOLIB_DEBUG_PRINTLN("Symbol length: %f ms", symbolLength);
if(symbolLength >= 16.0) {
state = _mod->SPIsetRegValue(RADIOLIB_SX1278_REG_MODEM_CONFIG_3, RADIOLIB_SX1278_LOW_DATA_RATE_OPT_ON, 3, 3);
} else {
@ -186,9 +184,7 @@ int16_t SX1278::setSpreadingFactor(uint8_t sf) {
// calculate symbol length and set low data rate optimization, if auto-configuration is enabled
if(_ldroAuto) {
float symbolLength = (float)(uint32_t(1) << SX127x::_sf) / (float)SX127x::_bw;
RADIOLIB_DEBUG_PRINT("Symbol length: ");
RADIOLIB_DEBUG_PRINT(symbolLength);
RADIOLIB_DEBUG_PRINTLN(" ms");
RADIOLIB_DEBUG_PRINT("Symbol length: %f ms", symbolLength);
if(symbolLength >= 16.0) {
state = _mod->SPIsetRegValue(RADIOLIB_SX1278_REG_MODEM_CONFIG_3, RADIOLIB_SX1278_LOW_DATA_RATE_OPT_ON, 3, 3);
} else {

View file

@ -17,11 +17,11 @@ int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint16_t preambleLe
// try to find the SX127x chip
if(!SX127x::findChip(chipVersion)) {
RADIOLIB_DEBUG_PRINTLN(F("No SX127x found!"));
RADIOLIB_DEBUG_PRINTLN("No SX127x found!");
_mod->term();
return(RADIOLIB_ERR_CHIP_NOT_FOUND);
}
RADIOLIB_DEBUG_PRINTLN(F("M\tSX127x"));
RADIOLIB_DEBUG_PRINTLN("M\tSX127x");
// set mode to standby
int16_t state = standby();
@ -64,11 +64,11 @@ int16_t SX127x::beginFSK(uint8_t chipVersion, float freqDev, float rxBw, uint16_
// try to find the SX127x chip
if(!SX127x::findChip(chipVersion)) {
RADIOLIB_DEBUG_PRINTLN(F("No SX127x found!"));
RADIOLIB_DEBUG_PRINTLN("No SX127x found!");
_mod->term();
return(RADIOLIB_ERR_CHIP_NOT_FOUND);
}
RADIOLIB_DEBUG_PRINTLN(F("M\tSX127x"));
RADIOLIB_DEBUG_PRINTLN("M\tSX127x");
// set mode to standby
int16_t state = standby();
@ -1431,17 +1431,7 @@ bool SX127x::findChip(uint8_t ver) {
if(version == ver) {
flagFound = true;
} else {
#if defined(RADIOLIB_DEBUG)
RADIOLIB_DEBUG_PRINT(F("SX127x not found! ("));
RADIOLIB_DEBUG_PRINT(i + 1);
RADIOLIB_DEBUG_PRINT(F(" of 10 tries) RADIOLIB_SX127X_REG_VERSION == "));
char buffHex[12];
sprintf(buffHex, "0x%04X", version);
RADIOLIB_DEBUG_PRINT(buffHex);
RADIOLIB_DEBUG_PRINT(F(", expected 0x00"));
RADIOLIB_DEBUG_PRINTLN(ver, HEX);
#endif
RADIOLIB_DEBUG_PRINTLN("SX127x not found! (%d of 10 tries) RADIOLIB_SX127X_REG_VERSION == 0x%04X, expected 0x00%X", i + 1, version, ver);
_mod->delay(10);
i++;
}
@ -1518,7 +1508,7 @@ void SX127x::setDirectAction(void (*func)(void)) {
}
void SX127x::readBit(RADIOLIB_PIN_TYPE pin) {
updateDirectBuffer((uint8_t)digitalRead(pin));
updateDirectBuffer((uint8_t)_mod->digitalRead(pin));
}
#endif

View file

@ -20,7 +20,7 @@ int16_t SX128x::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t sync
_mod->SPIstatusCommand = RADIOLIB_SX128X_CMD_GET_STATUS;
_mod->SPIstreamType = true;
_mod->SPIparseStatusCb = SPIparseStatus;
RADIOLIB_DEBUG_PRINTLN(F("M\tSX128x"));
RADIOLIB_DEBUG_PRINTLN("M\tSX128x");
// initialize LoRa modulation variables
_bwKhz = bw;
@ -81,7 +81,7 @@ int16_t SX128x::beginGFSK(float freq, uint16_t br, float freqDev, int8_t power,
_mod->SPIstatusCommand = RADIOLIB_SX128X_CMD_GET_STATUS;
_mod->SPIstreamType = true;
_mod->SPIparseStatusCb = SPIparseStatus;
RADIOLIB_DEBUG_PRINTLN(F("M\tSX128x"));
RADIOLIB_DEBUG_PRINTLN("M\tSX128x");
// initialize GFSK modulation variables
_brKbps = br;
@ -150,7 +150,7 @@ int16_t SX128x::beginBLE(float freq, uint16_t br, float freqDev, int8_t power, u
_mod->SPIstatusCommand = RADIOLIB_SX128X_CMD_GET_STATUS;
_mod->SPIstreamType = true;
_mod->SPIparseStatusCb = SPIparseStatus;
RADIOLIB_DEBUG_PRINTLN(F("M\tSX128x"));
RADIOLIB_DEBUG_PRINTLN("M\tSX128x");
// initialize BLE modulation variables
_brKbps = br;
@ -205,7 +205,7 @@ int16_t SX128x::beginFLRC(float freq, uint16_t br, uint8_t cr, int8_t power, uin
_mod->SPIstatusCommand = RADIOLIB_SX128X_CMD_GET_STATUS;
_mod->SPIstreamType = true;
_mod->SPIparseStatusCb = SPIparseStatus;
RADIOLIB_DEBUG_PRINTLN(F("M\tSX128x"));
RADIOLIB_DEBUG_PRINTLN("M\tSX128x");
// initialize FLRC modulation variables
_brKbps = br;
@ -311,9 +311,7 @@ int16_t SX128x::transmit(uint8_t* data, size_t len, uint8_t addr) {
// calculate timeout (500% of expected time-on-air)
uint32_t timeout = getTimeOnAir(len) * 5;
RADIOLIB_DEBUG_PRINT(F("Timeout in "));
RADIOLIB_DEBUG_PRINT(timeout);
RADIOLIB_DEBUG_PRINTLN(F(" us"));
RADIOLIB_DEBUG_PRINTLN("Timeout in %d us", timeout);
// start transmission
state = startTransmit(data, len, addr);
@ -346,9 +344,7 @@ int16_t SX128x::receive(uint8_t* data, size_t len) {
// calculate timeout (1000% of expected time-on-air)
uint32_t timeout = getTimeOnAir(len) * 10;
RADIOLIB_DEBUG_PRINT(F("Timeout in "));
RADIOLIB_DEBUG_PRINT(timeout);
RADIOLIB_DEBUG_PRINTLN(F(" us"));
RADIOLIB_DEBUG_PRINTLN("Timeout in %d us", timeout);
// start reception
uint32_t timeoutValue = (uint32_t)((float)timeout / 15.625);

View file

@ -9,7 +9,7 @@ int16_t Si4430::begin(float freq, float br, float freqDev, float rxBw, int8_t po
// execute common part
int16_t state = Si443x::begin(br, freqDev, rxBw, preambleLen);
RADIOLIB_ASSERT(state);
RADIOLIB_DEBUG_PRINTLN(F("M\tSi4430"));
RADIOLIB_DEBUG_PRINTLN("M\tSi4430");
// configure publicly accessible settings
state = setFrequency(freq);

View file

@ -9,7 +9,7 @@ int16_t Si4431::begin(float freq, float br, float freqDev, float rxBw, int8_t po
// execute common part
int16_t state = Si443x::begin(br, freqDev, rxBw, preambleLen);
RADIOLIB_ASSERT(state);
RADIOLIB_DEBUG_PRINTLN(F("M\tSi4431"));
RADIOLIB_DEBUG_PRINTLN("M\tSi4431");
// configure publicly accessible settings
state = setFrequency(freq);

View file

@ -9,7 +9,7 @@ int16_t Si4432::begin(float freq, float br, float freqDev, float rxBw, int8_t po
// execute common part
int16_t state = Si443x::begin(br, freqDev, rxBw, preambleLen);
RADIOLIB_ASSERT(state);
RADIOLIB_DEBUG_PRINTLN(F("M\tSi4432"));
RADIOLIB_DEBUG_PRINTLN("M\tSi4432");
// configure publicly accessible settings
state = setFrequency(freq);

View file

@ -18,11 +18,11 @@ int16_t Si443x::begin(float br, float freqDev, float rxBw, uint8_t preambleLen)
// try to find the Si443x chip
if(!Si443x::findChip()) {
RADIOLIB_DEBUG_PRINTLN(F("No Si443x found!"));
RADIOLIB_DEBUG_PRINTLN("No Si443x found!");
_mod->term();
return(RADIOLIB_ERR_CHIP_NOT_FOUND);
} else {
RADIOLIB_DEBUG_PRINTLN(F("M\tSi443x"));
RADIOLIB_DEBUG_PRINTLN("M\tSi443x");
}
// reset the device
@ -612,7 +612,7 @@ void Si443x::setDirectAction(void (*func)(void)) {
}
void Si443x::readBit(RADIOLIB_PIN_TYPE pin) {
updateDirectBuffer((uint8_t)digitalRead(pin));
updateDirectBuffer((uint8_t)_mod->digitalRead(pin));
}
#endif
@ -683,17 +683,7 @@ bool Si443x::findChip() {
if(version == RADIOLIB_SI443X_DEVICE_VERSION) {
flagFound = true;
} else {
#if defined(RADIOLIB_DEBUG)
RADIOLIB_DEBUG_PRINT(F("Si443x not found! ("));
RADIOLIB_DEBUG_PRINT(i + 1);
RADIOLIB_DEBUG_PRINT(F(" of 10 tries) RADIOLIB_SI443X_REG_DEVICE_VERSION == "));
char buffHex[5];
sprintf(buffHex, "0x%02X", version);
RADIOLIB_DEBUG_PRINT(buffHex);
RADIOLIB_DEBUG_PRINT(F(", expected 0x00"));
RADIOLIB_DEBUG_PRINTLN(RADIOLIB_SI443X_DEVICE_VERSION, HEX);
#endif
RADIOLIB_DEBUG_PRINTLN("Si443x not found! (%d of 10 tries) RADIOLIB_SI443X_REG_DEVICE_VERSION == 0x%02X, expected 0x0%X", i + 1, version, RADIOLIB_SI443X_DEVICE_VERSION);
_mod->delay(10);
i++;
}
@ -762,20 +752,8 @@ int16_t Si443x::updateClockRecovery() {
uint16_t rxOsr_fixed = (uint16_t)rxOsr;
// print that whole mess
RADIOLIB_DEBUG_PRINTLN(bypass, HEX);
RADIOLIB_DEBUG_PRINTLN(decRate, HEX);
RADIOLIB_DEBUG_PRINTLN(manch, HEX);
RADIOLIB_DEBUG_PRINT(rxOsr, 3);
RADIOLIB_DEBUG_PRINT('\t');
RADIOLIB_DEBUG_PRINT(rxOsr_fixed);
RADIOLIB_DEBUG_PRINT('\t');
RADIOLIB_DEBUG_PRINTLN(rxOsr_fixed, HEX);
RADIOLIB_DEBUG_PRINT(ncoOff);
RADIOLIB_DEBUG_PRINT('\t');
RADIOLIB_DEBUG_PRINTLN(ncoOff, HEX);
RADIOLIB_DEBUG_PRINT(crGain);
RADIOLIB_DEBUG_PRINT('\t');
RADIOLIB_DEBUG_PRINTLN(crGain, HEX);
RADIOLIB_DEBUG_PRINTLN("%X\n%X\n%X", bypass, decRate, manch);
RADIOLIB_DEBUG_PRINTLN("%f\t%d\t%X\n%d\t%X\n%d\t%X", rxOsr, rxOsr_fixed, rxOsr_fixed, ncoOff, ncoOff, crGain, crGain);
// update oversampling ratio
int16_t state = _mod->SPIsetRegValue(RADIOLIB_SI443X_REG_CLOCK_REC_OFFSET_2, (uint8_t)((rxOsr_fixed & 0x0700) >> 3), 7, 5);

View file

@ -26,11 +26,11 @@ int16_t nRF24::begin(int16_t freq, int16_t dataRate, int8_t power, uint8_t addrW
// check SPI connection
int16_t val = _mod->SPIgetRegValue(RADIOLIB_NRF24_REG_SETUP_AW);
if(!((val >= 0) && (val <= 3))) {
RADIOLIB_DEBUG_PRINTLN(F("No nRF24 found!"));
RADIOLIB_DEBUG_PRINTLN("No nRF24 found!");
_mod->term();
return(RADIOLIB_ERR_CHIP_NOT_FOUND);
}
RADIOLIB_DEBUG_PRINTLN(F("M\tnRF24"));
RADIOLIB_DEBUG_PRINTLN("M\tnRF24");
// configure settings inaccessible by public API
int16_t state = config();

View file

@ -194,9 +194,11 @@ int16_t AX25Client::begin(const char* srcCallsign, uint8_t srcSSID, uint8_t prea
return(_phy->startDirect());
}
#if defined(RADIOLIB_BUILD_ARDUINO)
int16_t AX25Client::transmit(String& str, const char* destCallsign, uint8_t destSSID) {
return(transmit(str.c_str(), destCallsign, destSSID));
}
#endif
int16_t AX25Client::transmit(const char* str, const char* destCallsign, uint8_t destSSID) {
// create control field

View file

@ -322,6 +322,7 @@ class AX25Client {
*/
int16_t begin(const char* srcCallsign, uint8_t srcSSID = 0x00, uint8_t preambleLen = 8);
#if defined(RADIOLIB_BUILD_ARDUINO)
/*!
\brief Transmit unnumbered information (UI) frame.
@ -334,6 +335,7 @@ class AX25Client {
\returns \ref status_codes
*/
int16_t transmit(String& str, const char* destCallsign, uint8_t destSSID = 0x00);
#endif
/*!
\brief Transmit unnumbered information (UI) frame.

View file

@ -94,6 +94,7 @@ size_t HellClient::write(uint8_t b) {
return(printGlyph(buff));
}
#if defined(RADIOLIB_BUILD_ARDUINO)
size_t HellClient::print(__FlashStringHelper* fstr) {
PGM_P p = reinterpret_cast<PGM_P>(fstr);
size_t n = 0;
@ -110,6 +111,7 @@ size_t HellClient::print(__FlashStringHelper* fstr) {
size_t HellClient::print(const String& str) {
return(HellClient::write((uint8_t*)str.c_str(), str.length()));
}
#endif
size_t HellClient::print(const char* str) {
return(HellClient::write((uint8_t*)str, strlen(str)));
@ -163,6 +165,7 @@ size_t HellClient::println(void) {
return(HellClient::print(' '));
}
#if defined(RADIOLIB_BUILD_ARDUINO)
size_t HellClient::println(__FlashStringHelper* fstr) {
size_t n = HellClient::print(fstr);
n += HellClient::println();
@ -174,6 +177,7 @@ size_t HellClient::println(const String& str) {
n += HellClient::println();
return(n);
}
#endif
size_t HellClient::println(const char* str) {
size_t n = HellClient::print(str);

View file

@ -135,8 +135,10 @@ class HellClient {
size_t write(uint8_t* buff, size_t len);
size_t write(uint8_t b);
#if defined(RADIOLIB_BUILD_ARDUINO)
size_t print(__FlashStringHelper*);
size_t print(const String &);
#endif
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
@ -147,8 +149,10 @@ class HellClient {
size_t print(double, int = 2);
size_t println(void);
#if defined(RADIOLIB_BUILD_ARDUINO)
size_t println(__FlashStringHelper*);
size_t println(const String &);
#endif
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);

View file

@ -91,17 +91,15 @@ int MorseClient::read(byte* symbol, byte* len, float low, float high) {
uint32_t signalLen = mod->millis() - signalStart;
if((signalLen >= low*(float)_dotLength) && (signalLen <= high*(float)_dotLength)) {
RADIOLIB_DEBUG_PRINT('.');
RADIOLIB_DEBUG_PRINT(".");
(*symbol) |= (RADIOLIB_MORSE_DOT << (*len));
(*len)++;
} else if((signalLen >= low*(float)_dashLength) && (signalLen <= high*(float)_dashLength)) {
RADIOLIB_DEBUG_PRINT('-');
RADIOLIB_DEBUG_PRINT("-");
(*symbol) |= (RADIOLIB_MORSE_DASH << (*len));
(*len)++;
} else {
RADIOLIB_DEBUG_PRINT("<len=");
RADIOLIB_DEBUG_PRINT(signalLen);
RADIOLIB_DEBUG_PRINTLN("ms>");
RADIOLIB_DEBUG_PRINTLN("<len=%dms>", signalLen);
}
}
@ -135,7 +133,7 @@ size_t MorseClient::write(uint8_t b) {
// inter-word pause (space)
if(b == ' ') {
RADIOLIB_DEBUG_PRINTLN(F("space"));
RADIOLIB_DEBUG_PRINTLN("space");
standby();
mod->waitForMicroseconds(mod->micros(), _wordSpace*1000);
return(1);
@ -154,11 +152,11 @@ size_t MorseClient::write(uint8_t b) {
// send dot or dash
if (code & RADIOLIB_MORSE_DASH) {
RADIOLIB_DEBUG_PRINT('-');
RADIOLIB_DEBUG_PRINT("-");
transmitDirect(_base, _baseHz);
mod->waitForMicroseconds(mod->micros(), _dashLength*1000);
} else {
RADIOLIB_DEBUG_PRINT('.');
RADIOLIB_DEBUG_PRINT(".");
transmitDirect(_base, _baseHz);
mod->waitForMicroseconds(mod->micros(), _dotLength*1000);
}
@ -179,6 +177,7 @@ size_t MorseClient::write(uint8_t b) {
return(1);
}
#if defined(RADIOLIB_BUILD_ARDUINO)
size_t MorseClient::print(__FlashStringHelper* fstr) {
PGM_P p = reinterpret_cast<PGM_P>(fstr);
size_t n = 0;
@ -195,6 +194,7 @@ size_t MorseClient::print(__FlashStringHelper* fstr) {
size_t MorseClient::print(const String& str) {
return(MorseClient::write((uint8_t*)str.c_str(), str.length()));
}
#endif
size_t MorseClient::print(const char* str) {
return(MorseClient::write((uint8_t*)str, strlen(str)));
@ -247,6 +247,7 @@ size_t MorseClient::println(void) {
return(MorseClient::write('^'));
}
#if defined(RADIOLIB_BUILD_ARDUINO)
size_t MorseClient::println(__FlashStringHelper* fstr) {
size_t n = MorseClient::print(fstr);
n += MorseClient::println();
@ -258,6 +259,7 @@ size_t MorseClient::println(const String& str) {
n += MorseClient::println();
return(n);
}
#endif
size_t MorseClient::println(const char* str) {
size_t n = MorseClient::print(str);

View file

@ -160,8 +160,10 @@ class MorseClient {
size_t write(uint8_t* buff, size_t len);
size_t write(uint8_t b);
#if defined(RADIOLIB_BUILD_ARDUINO)
size_t print(__FlashStringHelper*);
size_t print(const String &);
#endif
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
@ -172,8 +174,10 @@ class MorseClient {
size_t print(double, int = 2);
size_t println(void);
#if defined(RADIOLIB_BUILD_ARDUINO)
size_t println(__FlashStringHelper*);
size_t println(const String &);
#endif
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);

View file

@ -52,9 +52,11 @@ int16_t PagerClient::sendTone(uint32_t addr) {
return(PagerClient::transmit(NULL, 0, addr));
}
#if defined(RADIOLIB_BUILD_ARDUINO)
int16_t PagerClient::transmit(String& str, uint32_t addr, uint8_t encoding) {
return(PagerClient::transmit(str.c_str(), addr, encoding));
}
#endif
int16_t PagerClient::transmit(const char* str, uint32_t addr, uint8_t encoding) {
return(PagerClient::transmit((uint8_t*)str, strlen(str), addr, encoding));
@ -260,6 +262,7 @@ size_t PagerClient::available() {
return(_phy->available() + sizeof(uint32_t))/(sizeof(uint32_t) * (RADIOLIB_PAGER_BATCH_LEN + 1));
}
#if defined(RADIOLIB_BUILD_ARDUINO)
int16_t PagerClient::readData(String& str, size_t len, uint32_t* addr) {
int16_t state = RADIOLIB_ERR_NONE;
@ -304,6 +307,7 @@ int16_t PagerClient::readData(String& str, size_t len, uint32_t* addr) {
return(state);
}
#endif
int16_t PagerClient::readData(uint8_t* data, size_t* len, uint32_t* addr) {
// find the correct address
@ -492,9 +496,7 @@ uint32_t PagerClient::read() {
codeWord = ~codeWord;
}
RADIOLIB_VERBOSE_PRINT("R\t");
RADIOLIB_VERBOSE_PRINTLN(codeWord, HEX);
RADIOLIB_VERBOSE_PRINTLN("R\t%X", codeWord);
// TODO BCH error correction here
return(codeWord);
}

View file

@ -101,6 +101,7 @@ class PagerClient {
*/
int16_t sendTone(uint32_t addr);
#if defined(RADIOLIB_BUILD_ARDUINO)
/*!
\brief Arduino String transmit method.
@ -113,6 +114,7 @@ class PagerClient {
\returns \ref status_codes
*/
int16_t transmit(String& str, uint32_t addr, uint8_t encoding = RADIOLIB_PAGER_BCD);
#endif
/*!
\brief C-string transmit method.
@ -164,6 +166,7 @@ class PagerClient {
*/
size_t available();
#if defined(RADIOLIB_BUILD_ARDUINO)
/*!
\brief Reads data that was received after calling startReceive method.
@ -177,6 +180,7 @@ class PagerClient {
\returns \ref status_codes
*/
int16_t readData(String& str, size_t len = 0, uint32_t* addr = NULL);
#endif
/*!
\brief Reads data that was received after calling startReceive method.

View file

@ -9,6 +9,7 @@ PhysicalLayer::PhysicalLayer(float freqStep, size_t maxPacketLength) {
#endif
}
#if defined(RADIOLIB_BUILD_ARDUINO)
int16_t PhysicalLayer::transmit(__FlashStringHelper* fstr, uint8_t addr) {
// read flash string length
size_t len = 0;
@ -45,6 +46,7 @@ int16_t PhysicalLayer::transmit(__FlashStringHelper* fstr, uint8_t addr) {
int16_t PhysicalLayer::transmit(String& str, uint8_t addr) {
return(transmit(str.c_str(), addr));
}
#endif
int16_t PhysicalLayer::transmit(const char* str, uint8_t addr) {
return(transmit((uint8_t*)str, strlen(str), addr));
@ -57,6 +59,7 @@ int16_t PhysicalLayer::transmit(uint8_t* data, size_t len, uint8_t addr) {
return(RADIOLIB_ERR_UNSUPPORTED);
}
#if defined(RADIOLIB_BUILD_ARDUINO)
int16_t PhysicalLayer::receive(String& str, size_t len) {
int16_t state = RADIOLIB_ERR_NONE;
@ -103,6 +106,7 @@ int16_t PhysicalLayer::receive(String& str, size_t len) {
return(state);
}
#endif
int16_t PhysicalLayer::receive(uint8_t* data, size_t len) {
(void)data;
@ -131,9 +135,11 @@ int16_t PhysicalLayer::startReceive(uint32_t timeout, uint16_t irqFlags, uint16_
return(RADIOLIB_ERR_UNSUPPORTED);
}
#if defined(RADIOLIB_BUILD_ARDUINO)
int16_t PhysicalLayer::startTransmit(String& str, uint8_t addr) {
return(startTransmit(str.c_str(), addr));
}
#endif
int16_t PhysicalLayer::startTransmit(const char* str, uint8_t addr) {
return(startTransmit((uint8_t*)str, strlen(str), addr));
@ -150,6 +156,7 @@ int16_t PhysicalLayer::finishTransmit() {
return(RADIOLIB_ERR_UNSUPPORTED);
}
#if defined(RADIOLIB_BUILD_ARDUINO)
int16_t PhysicalLayer::readData(String& str, size_t len) {
int16_t state = RADIOLIB_ERR_NONE;
@ -192,6 +199,7 @@ int16_t PhysicalLayer::readData(String& str, size_t len) {
return(state);
}
#endif
int16_t PhysicalLayer::readData(uint8_t* data, size_t len) {
(void)data;
@ -266,7 +274,7 @@ int32_t PhysicalLayer::random(int32_t max) {
if(randNum < 0) {
randNum *= -1;
}
RADIOLIB_DEBUG_PRINTLN(randNum);
RADIOLIB_DEBUG_PRINTLN("%d", randNum);
return(randNum % max);
}
@ -338,8 +346,7 @@ void PhysicalLayer::updateDirectBuffer(uint8_t bit) {
_syncBuffer <<= 1;
_syncBuffer |= bit;
RADIOLIB_VERBOSE_PRINT("S\t");
RADIOLIB_VERBOSE_PRINTLN(_syncBuffer, HEX);
RADIOLIB_VERBOSE_PRINTLN("S\t%X", _syncBuffer);
if((_syncBuffer & _directSyncWordMask) == _directSyncWord) {
_gotSync = true;
@ -360,8 +367,7 @@ void PhysicalLayer::updateDirectBuffer(uint8_t bit) {
// check complete byte
if(_bufferBitPos == 8) {
_buffer[_bufferWritePos] = Module::flipBits(_buffer[_bufferWritePos]);
RADIOLIB_VERBOSE_PRINT("R\t");
RADIOLIB_VERBOSE_PRINTLN(_buffer[_bufferWritePos], HEX);
RADIOLIB_VERBOSE_PRINTLN("R\t%X", _buffer[_bufferWritePos]);
_bufferWritePos++;
_bufferBitPos = 0;

View file

@ -27,6 +27,7 @@ class PhysicalLayer {
// basic methods
#if defined(RADIOLIB_BUILD_ARDUINO)
/*!
\brief Arduino Flash String transmit method.
@ -48,6 +49,7 @@ class PhysicalLayer {
\returns \ref status_codes
*/
int16_t transmit(String& str, uint8_t addr = 0);
#endif
/*!
\brief C-string transmit method.
@ -73,6 +75,7 @@ class PhysicalLayer {
*/
virtual int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0);
#if defined(RADIOLIB_BUILD_ARDUINO)
/*!
\brief Arduino String receive method.
@ -83,6 +86,7 @@ class PhysicalLayer {
\returns \ref status_codes
*/
int16_t receive(String& str, size_t len = 0);
#endif
/*!
\brief Sets module to sleep.
@ -131,6 +135,7 @@ class PhysicalLayer {
*/
virtual int16_t receive(uint8_t* data, size_t len);
#if defined(RADIOLIB_BUILD_ARDUINO)
/*!
\brief Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking.
Interrupt pin will be activated when transmission finishes.
@ -142,6 +147,7 @@ class PhysicalLayer {
\returns \ref status_codes
*/
int16_t startTransmit(String& str, uint8_t addr = 0);
#endif
/*!
\brief Interrupt-driven Arduino String transmit method. Unlike the standard transmit method, this one is non-blocking.
@ -175,6 +181,7 @@ class PhysicalLayer {
*/
virtual int16_t finishTransmit();
#if defined(RADIOLIB_BUILD_ARDUINO)
/*!
\brief Reads data that was received after calling startReceive method.
@ -186,6 +193,7 @@ class PhysicalLayer {
\returns \ref status_codes
*/
int16_t readData(String& str, size_t len = 0);
#endif
/*!
\brief Reads data that was received after calling startReceive method.

View file

@ -209,6 +209,7 @@ size_t RTTYClient::write(uint8_t b) {
return(1);
}
#if defined(RADIOLIB_BUILD_ARDUINO)
size_t RTTYClient::print(__FlashStringHelper* fstr) {
// read flash string length
size_t len = 0;
@ -247,13 +248,6 @@ size_t RTTYClient::print(__FlashStringHelper* fstr) {
return(n);
}
size_t RTTYClient::print(ITA2String& ita2) {
uint8_t* arr = ita2.byteArr();
size_t n = RTTYClient::write(arr, ita2.length());
delete[] arr;
return(n);
}
size_t RTTYClient::print(const String& str) {
size_t n = 0;
if(_encoding == RADIOLIB_ITA2) {
@ -264,6 +258,14 @@ size_t RTTYClient::print(const String& str) {
}
return(n);
}
#endif
size_t RTTYClient::print(ITA2String& ita2) {
uint8_t* arr = ita2.byteArr();
size_t n = RTTYClient::write(arr, ita2.length());
delete[] arr;
return(n);
}
size_t RTTYClient::print(const char str[]) {
size_t n = 0;
@ -337,20 +339,22 @@ size_t RTTYClient::println(void) {
return(n);
}
#if defined(RADIOLIB_BUILD_ARDUINO)
size_t RTTYClient::println(__FlashStringHelper* fstr) {
size_t n = RTTYClient::print(fstr);
n += RTTYClient::println();
return(n);
}
size_t RTTYClient::println(ITA2String& ita2) {
size_t n = RTTYClient::print(ita2);
size_t RTTYClient::println(const String& str) {
size_t n = RTTYClient::print(str);
n += RTTYClient::println();
return(n);
}
#endif
size_t RTTYClient::println(const String& str) {
size_t n = RTTYClient::print(str);
size_t RTTYClient::println(ITA2String& ita2) {
size_t n = RTTYClient::print(ita2);
n += RTTYClient::println();
return(n);
}

View file

@ -138,9 +138,11 @@ class RTTYClient {
size_t write(uint8_t* buff, size_t len);
size_t write(uint8_t b);
#if defined(RADIOLIB_BUILD_ARDUINO)
size_t print(__FlashStringHelper*);
size_t print(ITA2String &);
size_t print(const String &);
#endif
size_t print(ITA2String &);
size_t print(const char[]);
size_t print(char);
size_t print(unsigned char, int = DEC);
@ -151,9 +153,11 @@ class RTTYClient {
size_t print(double, int = 2);
size_t println(void);
#if defined(RADIOLIB_BUILD_ARDUINO)
size_t println(__FlashStringHelper*);
size_t println(ITA2String &);
size_t println(const String &);
#endif
size_t println(ITA2String &);
size_t println(const char[]);
size_t println(char);
size_t println(unsigned char, int = DEC);