Updated macro names
This commit is contained in:
parent
e89c02bf56
commit
cd1c799a64
19 changed files with 147 additions and 126 deletions
|
@ -9,7 +9,7 @@ void ISerial::begin(long speed) {
|
|||
}
|
||||
|
||||
bool ISerial::listen() {
|
||||
#ifdef SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
return true;
|
||||
#else
|
||||
return(_mod->ModuleSerial->listen());
|
||||
|
@ -21,7 +21,7 @@ void ISerial::end() {
|
|||
}
|
||||
|
||||
bool ISerial::isListening() {
|
||||
#ifdef SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
return true;
|
||||
#else
|
||||
return(_mod->ModuleSerial->isListening());
|
||||
|
@ -29,7 +29,7 @@ bool ISerial::isListening() {
|
|||
}
|
||||
|
||||
bool ISerial::stopListening() {
|
||||
#ifdef SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
return true;
|
||||
#else
|
||||
return(_mod->ModuleSerial->stopListening());
|
||||
|
@ -37,7 +37,7 @@ bool ISerial::stopListening() {
|
|||
}
|
||||
|
||||
bool ISerial::overflow() {
|
||||
#ifdef SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
return false;
|
||||
#else
|
||||
return(_mod->ModuleSerial->overflow());
|
||||
|
|
|
@ -7,7 +7,7 @@ Module::Module(int rx, int tx, HardwareSerial* useSer) {
|
|||
_int0 = -1;
|
||||
_int1 = -1;
|
||||
|
||||
#ifdef SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
ModuleSerial = useSer;
|
||||
#else
|
||||
ModuleSerial = new SoftwareSerial(_rx, _tx);
|
||||
|
@ -34,7 +34,7 @@ Module::Module(int cs, int int0, int int1, int rx, int tx, SPIClass& spi, SPISet
|
|||
_spi = &spi;
|
||||
_spiSettings = spiSettings;
|
||||
|
||||
#ifdef SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
ModuleSerial = useSer;
|
||||
#else
|
||||
ModuleSerial = new SoftwareSerial(_rx, _tx);
|
||||
|
@ -55,33 +55,33 @@ Module::Module(int cs, int int0, int int1, int int2, SPIClass& spi, SPISettings
|
|||
void Module::init(uint8_t interface, uint8_t gpio) {
|
||||
// select interface
|
||||
switch(interface) {
|
||||
case USE_SPI:
|
||||
case RADIOLIB_USE_SPI:
|
||||
pinMode(_cs, OUTPUT);
|
||||
digitalWrite(_cs, HIGH);
|
||||
_spi->begin();
|
||||
break;
|
||||
case USE_UART:
|
||||
case RADIOLIB_USE_UART:
|
||||
#if defined(ESP32)
|
||||
ModuleSerial->begin(baudrate, SERIAL_8N1, _rx, _tx);
|
||||
#else
|
||||
ModuleSerial->begin(baudrate);
|
||||
#endif
|
||||
break;
|
||||
case USE_I2C:
|
||||
case RADIOLIB_USE_I2C:
|
||||
break;
|
||||
}
|
||||
|
||||
// select GPIO
|
||||
switch(gpio) {
|
||||
case INT_NONE:
|
||||
case RADIOLIB_INT_NONE:
|
||||
break;
|
||||
case INT_0:
|
||||
case RADIOLIB_INT_0:
|
||||
pinMode(_int0, INPUT);
|
||||
break;
|
||||
case INT_1:
|
||||
case RADIOLIB_INT_1:
|
||||
pinMode(_int1, INPUT);
|
||||
break;
|
||||
case INT_BOTH:
|
||||
case RADIOLIB_INT_BOTH:
|
||||
pinMode(_int0, INPUT);
|
||||
pinMode(_int1, INPUT);
|
||||
break;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include <SPI.h>
|
||||
//#include <Wire.h>
|
||||
#ifndef SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#ifndef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#include <SoftwareSerial.h>
|
||||
#endif
|
||||
|
||||
|
@ -27,7 +27,7 @@ class Module {
|
|||
|
||||
\param serial HardwareSerial to be used on ESP32 and SAMD. Defaults to 1
|
||||
*/
|
||||
#ifdef SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
Module(int tx, int rx, HardwareSerial* useSer = &Serial1);
|
||||
#else
|
||||
Module(int tx, int rx, HardwareSerial* useSer = nullptr);
|
||||
|
@ -84,7 +84,7 @@ class Module {
|
|||
|
||||
\param serial HardwareSerial to be used on ESP32 and SAMD. Defaults to 1
|
||||
*/
|
||||
#ifdef SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
Module(int cs, int int0, int int1, int rx, int tx, SPIClass& spi = SPI, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0), HardwareSerial* useSer = &Serial1);
|
||||
#else
|
||||
Module(int cs, int int0, int int1, int rx, int tx, SPIClass& spi = SPI, SPISettings spiSettings = SPISettings(2000000, MSBFIRST, SPI_MODE0), HardwareSerial* useSer = nullptr);
|
||||
|
@ -96,7 +96,7 @@ class Module {
|
|||
/*!
|
||||
\brief Internal SoftwareSerial instance.
|
||||
*/
|
||||
#ifdef SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#ifdef RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
HardwareSerial* ModuleSerial;
|
||||
#else
|
||||
SoftwareSerial* ModuleSerial;
|
||||
|
|
|
@ -1,27 +1,34 @@
|
|||
#ifndef _RADIOLIB_TYPES_H
|
||||
#define _RADIOLIB_TYPES_H
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#error "Unsupported Arduino version (< 1.0.0)"
|
||||
#endif
|
||||
|
||||
// the following platforms do not support SoftwareSerial library
|
||||
#if defined(ESP32) || defined(SAMD_SERIES) || defined(ARDUINO_ARCH_STM32) || defined(__SAM3X8E__)
|
||||
#define SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#endif
|
||||
/*
|
||||
* Uncomment to enable static-only memory management: no dynamic allocation will be performed.
|
||||
* Warning: Large static arrays will be created in some methods. It is not advised to send large packets in this mode.
|
||||
*/
|
||||
|
||||
// uncomment to enable static-only memory management: no dynamic allocation will be performed
|
||||
// Warning: Large static arrays will be created in some methods. It is also not advised to send large packets in this mode.
|
||||
//#define STATIC_ONLY
|
||||
#define STATIC_ARRAY_SIZE 256
|
||||
//#define RADIOLIB_STATIC_ONLY
|
||||
|
||||
#define RADIOLIB_DEBUG_PORT Serial
|
||||
// set the size of static arrays to use
|
||||
#define RADIOLIB_STATIC_ARRAY_SIZE 256
|
||||
|
||||
/*
|
||||
* Uncomment to enable debug output.
|
||||
* Warning: Debug output will slow down the whole system significantly
|
||||
* Levels: debug - only main info
|
||||
* verbose - full transcript of all SPI/UART communication
|
||||
*/
|
||||
|
||||
//#define RADIOLIB_DEBUG
|
||||
//#define RADIOLIB_VERBOSE
|
||||
|
||||
// set which Serial port should be used for debug output
|
||||
#define RADIOLIB_DEBUG_PORT Serial
|
||||
|
||||
#ifdef RADIOLIB_DEBUG
|
||||
#define RADIOLIB_DEBUG_PRINT(...) { RADIOLIB_DEBUG_PORT.print(__VA_ARGS__); }
|
||||
#define RADIOLIB_DEBUG_PRINTLN(...) { RADIOLIB_DEBUG_PORT.println(__VA_ARGS__); }
|
||||
|
@ -38,6 +45,20 @@
|
|||
#define RADIOLIB_VERBOSE_PRINTLN(...) {}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Uncomment to enable god mode - all methods and member variables in all classes will be made public, thus making them accessible from Arduino code.
|
||||
* Warning: Come on, it's called GOD mode - obviously only use this if you know what you're doing.
|
||||
* Failure to heed the above warning may result in bricked module.
|
||||
*/
|
||||
//#define RADIOLIB_GODMODE
|
||||
|
||||
/*
|
||||
* The following platforms do not support SoftwareSerial library.
|
||||
*/
|
||||
#if defined(ESP32) || defined(SAMD_SERIES) || defined(ARDUINO_ARCH_STM32) || defined(__SAM3X8E__)
|
||||
#define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\defgroup shield_config Shield Configuration
|
||||
|
||||
|
@ -47,37 +68,37 @@
|
|||
/*!
|
||||
\brief Use SPI interface.
|
||||
*/
|
||||
#define USE_SPI 0x00
|
||||
#define RADIOLIB_USE_SPI 0x00
|
||||
|
||||
/*!
|
||||
\brief Use UART interface.
|
||||
*/
|
||||
#define USE_UART 0x01
|
||||
#define RADIOLIB_USE_UART 0x01
|
||||
|
||||
/*!
|
||||
\brief Use I2C interface.
|
||||
*/
|
||||
#define USE_I2C 0x02
|
||||
#define RADIOLIB_USE_I2C 0x02
|
||||
|
||||
/*!
|
||||
\brief Do not use any interrupts/GPIOs.
|
||||
*/
|
||||
#define INT_NONE 0x00
|
||||
#define RADIOLIB_INT_NONE 0x00
|
||||
|
||||
/*!
|
||||
\brief Use interrupt/GPIO 0.
|
||||
*/
|
||||
#define INT_0 0x01
|
||||
#define RADIOLIB_INT_0 0x01
|
||||
|
||||
/*!
|
||||
\brief Use interrupt/GPIO 1.
|
||||
*/
|
||||
#define INT_1 0x02
|
||||
#define RADIOLIB_INT_1 0x02
|
||||
|
||||
/*!
|
||||
\brief Use both interrupts/GPIOs.
|
||||
*/
|
||||
#define INT_BOTH 0x03
|
||||
#define RADIOLIB_INT_BOTH 0x03
|
||||
|
||||
/*!
|
||||
\}
|
||||
|
|
|
@ -12,7 +12,7 @@ int16_t CC1101::begin(float freq, float br, float rxBw, float freqDev, int8_t po
|
|||
// set module properties
|
||||
_mod->SPIreadCommand = CC1101_CMD_READ;
|
||||
_mod->SPIwriteCommand = CC1101_CMD_WRITE;
|
||||
_mod->init(USE_SPI, INT_0);
|
||||
_mod->init(RADIOLIB_USE_SPI, RADIOLIB_INT_0);
|
||||
|
||||
// try to find the CC1101 chip
|
||||
uint8_t i = 0;
|
||||
|
|
|
@ -9,7 +9,7 @@ int16_t ESP8266::begin(long speed) {
|
|||
// set module properties
|
||||
_mod->AtLineFeed = "\r\n";
|
||||
_mod->baudrate = speed;
|
||||
_mod->init(USE_UART, INT_NONE);
|
||||
_mod->init(RADIOLIB_USE_UART, RADIOLIB_INT_NONE);
|
||||
|
||||
// empty UART buffer (garbage data)
|
||||
_mod->ATemptyBuffer();
|
||||
|
@ -52,8 +52,8 @@ int16_t ESP8266::join(const char* ssid, const char* password) {
|
|||
|
||||
// build AT command
|
||||
const char* atStr = "AT+CWJAP_CUR=\"";
|
||||
#ifdef STATIC_ONLY
|
||||
char cmd[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char cmd[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
uint8_t cmdLen = strlen(atStr) + strlen(ssid) + strlen(password) + 4;
|
||||
char* cmd = new char[cmdLen + 1];
|
||||
|
@ -66,7 +66,7 @@ int16_t ESP8266::join(const char* ssid, const char* password) {
|
|||
|
||||
// send command
|
||||
bool res = _mod->ATsendCommand(cmd);
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] cmd;
|
||||
#endif
|
||||
if(!res) {
|
||||
|
@ -93,8 +93,8 @@ int16_t ESP8266::openTransportConnection(const char* host, const char* protocol,
|
|||
if((strcmp(protocol, "TCP") == 0) && (tcpKeepAlive > 0)) {
|
||||
cmdLen += strlen(tcpKeepAliveStr) + 1;
|
||||
}
|
||||
#ifdef STATIC_ONLY
|
||||
char cmd[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char cmd[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
char* cmd = new char[cmdLen + 1];
|
||||
#endif
|
||||
|
@ -111,7 +111,7 @@ int16_t ESP8266::openTransportConnection(const char* host, const char* protocol,
|
|||
|
||||
// send command
|
||||
bool res = _mod->ATsendCommand(cmd);
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] cmd;
|
||||
#endif
|
||||
if(!res) {
|
||||
|
@ -134,8 +134,8 @@ int16_t ESP8266::send(const char* data) {
|
|||
char lenStr[8];
|
||||
itoa(strlen(data), lenStr, 10);
|
||||
const char* atStr = "AT+CIPSEND=";
|
||||
#ifdef STATIC_ONLY
|
||||
char cmd[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char cmd[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
char* cmd = new char[strlen(atStr) + strlen(lenStr) + 1];
|
||||
#endif
|
||||
|
@ -144,7 +144,7 @@ int16_t ESP8266::send(const char* data) {
|
|||
|
||||
// send command
|
||||
bool res = _mod->ATsendCommand(cmd);
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] cmd;
|
||||
#endif
|
||||
if(!res) {
|
||||
|
@ -164,8 +164,8 @@ int16_t ESP8266::send(uint8_t* data, uint32_t len) {
|
|||
char lenStr[8];
|
||||
itoa(len, lenStr, 10);
|
||||
const char atStr[] = "AT+CIPSEND=";
|
||||
#ifdef STATIC_ONLY
|
||||
char cmd[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char cmd[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
char* cmd = new char[strlen(atStr) + strlen(lenStr) + 1];
|
||||
#endif
|
||||
|
@ -174,7 +174,7 @@ int16_t ESP8266::send(uint8_t* data, uint32_t len) {
|
|||
|
||||
// send command
|
||||
bool res = _mod->ATsendCommand(cmd);
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] cmd;
|
||||
#endif
|
||||
if(!res) {
|
||||
|
|
|
@ -7,5 +7,5 @@ HC05::HC05(Module* mod) : ISerial(mod) {
|
|||
void HC05::begin(long speed) {
|
||||
// set module properties
|
||||
_mod->baudrate = speed;
|
||||
_mod->init(USE_UART, INT_NONE);
|
||||
_mod->init(RADIOLIB_USE_UART, RADIOLIB_INT_NONE);
|
||||
}
|
||||
|
|
|
@ -8,5 +8,5 @@ void JDY08::begin(long speed) {
|
|||
// set module properties
|
||||
_mod->AtLineFeed = "";
|
||||
_mod->baudrate = speed;
|
||||
_mod->init(USE_UART, INT_NONE);
|
||||
_mod->init(RADIOLIB_USE_UART, RADIOLIB_INT_NONE);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ RF69::RF69(Module* module) : PhysicalLayer(RF69_CRYSTAL_FREQ, RF69_DIV_EXPONENT,
|
|||
|
||||
int16_t RF69::begin(float freq, float br, float rxBw, float freqDev, int8_t power) {
|
||||
// set module properties
|
||||
_mod->init(USE_SPI, INT_0);
|
||||
_mod->init(RADIOLIB_USE_SPI, RADIOLIB_INT_0);
|
||||
|
||||
// try to find the RF69 chip
|
||||
uint8_t i = 0;
|
||||
|
|
|
@ -6,7 +6,7 @@ SX1231::SX1231(Module* mod) : RF69(mod) {
|
|||
|
||||
int16_t SX1231::begin(float freq, float br, float rxBw, float freqDev, int8_t power) {
|
||||
// set module properties
|
||||
_mod->init(USE_SPI, INT_BOTH);
|
||||
_mod->init(RADIOLIB_USE_SPI, RADIOLIB_INT_BOTH);
|
||||
|
||||
// try to find the SX1231 chip
|
||||
uint8_t i = 0;
|
||||
|
|
|
@ -6,7 +6,7 @@ SX126x::SX126x(Module* mod) : PhysicalLayer(SX126X_CRYSTAL_FREQ, SX126X_DIV_EXPO
|
|||
|
||||
int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint16_t syncWord, float currentLimit, uint16_t preambleLength) {
|
||||
// set module properties
|
||||
_mod->init(USE_SPI, INT_BOTH);
|
||||
_mod->init(RADIOLIB_USE_SPI, RADIOLIB_INT_BOTH);
|
||||
pinMode(_mod->getRx(), INPUT);
|
||||
|
||||
// BW in kHz and SF are required in order to calculate LDRO for setModulationParams
|
||||
|
@ -71,7 +71,7 @@ int16_t SX126x::begin(float bw, uint8_t sf, uint8_t cr, uint16_t syncWord, float
|
|||
|
||||
int16_t SX126x::beginFSK(float br, float freqDev, float rxBw, float currentLimit, uint16_t preambleLength, float dataShaping) {
|
||||
// set module properties
|
||||
_mod->init(USE_SPI, INT_BOTH);
|
||||
_mod->init(RADIOLIB_USE_SPI, RADIOLIB_INT_BOTH);
|
||||
pinMode(_mod->getRx(), INPUT);
|
||||
|
||||
// initialize configuration variables (will be overwritten during public settings configuration)
|
||||
|
|
|
@ -7,7 +7,7 @@ SX127x::SX127x(Module* mod) : PhysicalLayer(SX127X_CRYSTAL_FREQ, SX127X_DIV_EXPO
|
|||
|
||||
int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimit, uint16_t preambleLength) {
|
||||
// set module properties
|
||||
_mod->init(USE_SPI, INT_BOTH);
|
||||
_mod->init(RADIOLIB_USE_SPI, RADIOLIB_INT_BOTH);
|
||||
|
||||
// try to find the SX127x chip
|
||||
if(!SX127x::findChip(chipVersion)) {
|
||||
|
@ -51,7 +51,7 @@ int16_t SX127x::begin(uint8_t chipVersion, uint8_t syncWord, uint8_t currentLimi
|
|||
|
||||
int16_t SX127x::beginFSK(uint8_t chipVersion, float br, float freqDev, float rxBw, uint8_t currentLimit, uint16_t preambleLength, bool enableOOK) {
|
||||
// set module properties
|
||||
_mod->init(USE_SPI, INT_BOTH);
|
||||
_mod->init(RADIOLIB_USE_SPI, RADIOLIB_INT_BOTH);
|
||||
|
||||
// try to find the SX127x chip
|
||||
if(!SX127x::findChip(chipVersion)) {
|
||||
|
|
|
@ -10,7 +10,7 @@ XBee::XBee(Module* mod) {
|
|||
int16_t XBee::begin(long speed) {
|
||||
// set module properties
|
||||
_mod->baudrate = speed;
|
||||
_mod->init(USE_UART, INT_1);
|
||||
_mod->init(RADIOLIB_USE_UART, RADIOLIB_INT_1);
|
||||
|
||||
// reset module
|
||||
reset();
|
||||
|
@ -68,8 +68,8 @@ int16_t XBee::transmit(uint8_t* dest, uint8_t* destNetwork, const char* payload,
|
|||
// build the frame
|
||||
size_t payloadLen = strlen(payload);
|
||||
size_t dataLen = 8 + 2 + 1 + 1 + payloadLen;
|
||||
#ifdef STATIC_ONLY
|
||||
uint8_t cmd[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
uint8_t cmd[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
uint8_t* cmd = new uint8_t[dataLen];
|
||||
#endif
|
||||
|
@ -82,7 +82,7 @@ int16_t XBee::transmit(uint8_t* dest, uint8_t* destNetwork, const char* payload,
|
|||
// send frame
|
||||
uint8_t frameID = _frameID++;
|
||||
sendApiFrame(XBEE_API_FRAME_ZIGBEE_TRANSMIT_REQUEST, frameID, cmd, dataLen);
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] cmd;
|
||||
#endif
|
||||
|
||||
|
@ -119,8 +119,8 @@ size_t XBee::available() {
|
|||
return(0);
|
||||
}
|
||||
|
||||
#ifdef STATIC_ONLY
|
||||
char frame[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char frame[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
uint8_t* frame = new uint8_t[_frameLength];
|
||||
#endif
|
||||
|
@ -130,7 +130,7 @@ size_t XBee::available() {
|
|||
|
||||
// save packet source and data
|
||||
size_t payloadLength = _frameLength - 12;
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] _packetData;
|
||||
_packetData = new char[payloadLength];
|
||||
#endif
|
||||
|
@ -138,7 +138,7 @@ size_t XBee::available() {
|
|||
_packetData[payloadLength - 1] = '\0';
|
||||
memcpy(_packetSource, frame + 1, 8);
|
||||
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] frame;
|
||||
#endif
|
||||
_frameLength = 0;
|
||||
|
@ -189,7 +189,7 @@ int16_t XBeeSerial::begin(long speed) {
|
|||
// set module properties
|
||||
_mod->AtLineFeed = "\r";
|
||||
_mod->baudrate = speed;
|
||||
_mod->init(USE_UART, INT_NONE);
|
||||
_mod->init(RADIOLIB_USE_UART, RADIOLIB_INT_NONE);
|
||||
|
||||
// empty UART buffer (garbage data)
|
||||
_mod->ATemptyBuffer();
|
||||
|
@ -232,7 +232,7 @@ int16_t XBeeSerial::setDestinationAddress(const char* destinationAddressHigh, co
|
|||
|
||||
// set higher address bytes
|
||||
RADIOLIB_DEBUG_PRINTLN(F("Setting address (high) ..."));
|
||||
#ifdef STATIC_ONLY
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char addressHigh[13];
|
||||
#else
|
||||
char* addressHigh = new char[strlen(destinationAddressHigh) + 4];
|
||||
|
@ -240,7 +240,7 @@ int16_t XBeeSerial::setDestinationAddress(const char* destinationAddressHigh, co
|
|||
strcpy(addressHigh, "ATDH");
|
||||
strcat(addressHigh, destinationAddressHigh);
|
||||
bool res = _mod->ATsendCommand(addressHigh);
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] addressHigh;
|
||||
#endif
|
||||
if(!res) {
|
||||
|
@ -249,7 +249,7 @@ int16_t XBeeSerial::setDestinationAddress(const char* destinationAddressHigh, co
|
|||
|
||||
// set lower address bytes
|
||||
RADIOLIB_DEBUG_PRINTLN(F("Setting address (low) ..."));
|
||||
#ifdef STATIC_ONLY
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char addressLow[13];
|
||||
#else
|
||||
char* addressLow = new char[strlen(destinationAddressLow) + 4];
|
||||
|
@ -257,7 +257,7 @@ int16_t XBeeSerial::setDestinationAddress(const char* destinationAddressHigh, co
|
|||
strcpy(addressLow, "ATDL");
|
||||
strcat(addressLow, destinationAddressLow);
|
||||
res = _mod->ATsendCommand(addressLow);
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] addressLow;
|
||||
#endif
|
||||
if(!res) {
|
||||
|
@ -282,7 +282,7 @@ int16_t XBeeSerial::setPanId(const char* panId) {
|
|||
|
||||
// set PAN ID
|
||||
RADIOLIB_DEBUG_PRINTLN(F("Setting PAN ID ..."));
|
||||
#ifdef STATIC_ONLY
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char cmd[21];
|
||||
#else
|
||||
char* cmd = new char[strlen(panId) + 4];
|
||||
|
@ -290,7 +290,7 @@ int16_t XBeeSerial::setPanId(const char* panId) {
|
|||
strcpy(cmd, "ATID");
|
||||
strcat(cmd, panId);
|
||||
bool res = _mod->ATsendCommand(cmd);
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] cmd;
|
||||
#endif
|
||||
if(!res) {
|
||||
|
@ -364,8 +364,8 @@ void XBee::sendApiFrame(uint8_t type, uint8_t id, const char* data) {
|
|||
void XBee::sendApiFrame(uint8_t type, uint8_t id, uint8_t* data, uint16_t length) {
|
||||
// build the API frame
|
||||
size_t frameLength = 1 + 2 + length + 1 + 2;
|
||||
#ifdef STATIC_ONLY
|
||||
uint8_t frame[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
uint8_t frame[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
uint8_t* frame = new uint8_t[frameLength];
|
||||
#endif
|
||||
|
@ -390,7 +390,7 @@ void XBee::sendApiFrame(uint8_t type, uint8_t id, uint8_t* data, uint16_t length
|
|||
}
|
||||
|
||||
// deallocate memory
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] frame;
|
||||
#endif
|
||||
}
|
||||
|
@ -418,8 +418,8 @@ int16_t XBee::readApiFrame(uint8_t frameID, uint8_t codePos, uint16_t timeout) {
|
|||
RADIOLIB_DEBUG_PRINTLN(numBytes);
|
||||
|
||||
// read the response
|
||||
#ifdef STATIC_ONLY
|
||||
uint8_t resp[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
uint8_t resp[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
uint8_t* resp = new uint8_t[numBytes];
|
||||
#endif
|
||||
|
@ -451,7 +451,7 @@ int16_t XBee::readApiFrame(uint8_t frameID, uint8_t codePos, uint16_t timeout) {
|
|||
|
||||
// codePos does not include start delimiter and frame ID
|
||||
uint8_t code = resp[codePos];
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] resp;
|
||||
#endif
|
||||
return(code);
|
||||
|
|
|
@ -176,8 +176,8 @@ class XBee {
|
|||
size_t _frameLength;
|
||||
bool _frameHeaderProcessed;
|
||||
|
||||
#ifdef STATIC_ONLY
|
||||
char _packetData[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char _packetData[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
char* _packetData = new char[0];
|
||||
#endif
|
||||
|
|
|
@ -8,7 +8,7 @@ int16_t nRF24::begin(int16_t freq, int16_t dataRate, int8_t power, uint8_t addrW
|
|||
// set module properties
|
||||
_mod->SPIreadCommand = NRF24_CMD_READ;
|
||||
_mod->SPIwriteCommand = NRF24_CMD_WRITE;
|
||||
_mod->init(USE_SPI, INT_BOTH);
|
||||
_mod->init(RADIOLIB_USE_SPI, RADIOLIB_INT_BOTH);
|
||||
|
||||
// override pin mode on INT0 (connected to nRF24 CE pin)
|
||||
pinMode(_mod->getInt0(), OUTPUT);
|
||||
|
|
|
@ -27,7 +27,7 @@ int16_t MQTTClient::connect(const char* host, const char* clientId, const char*
|
|||
size_t encodedBytes = encodeLength(remainingLength, encoded);
|
||||
|
||||
// build the CONNECT packet
|
||||
#ifdef STATIC_ONLY
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
uint8_t packet[256];
|
||||
#else
|
||||
uint8_t* packet = new uint8_t[1 + encodedBytes + remainingLength];
|
||||
|
@ -101,7 +101,7 @@ int16_t MQTTClient::connect(const char* host, const char* clientId, const char*
|
|||
// create TCP connection
|
||||
int16_t state = _tl->openTransportConnection(host, "TCP", _port, keepAlive);
|
||||
if(state != ERR_NONE) {
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] packet;
|
||||
#endif
|
||||
return(state);
|
||||
|
@ -109,7 +109,7 @@ int16_t MQTTClient::connect(const char* host, const char* clientId, const char*
|
|||
|
||||
// send MQTT packet
|
||||
state = _tl->send(packet, 1 + encodedBytes + remainingLength);
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] packet;
|
||||
#endif
|
||||
if(state != ERR_NONE) {
|
||||
|
@ -123,21 +123,21 @@ int16_t MQTTClient::connect(const char* host, const char* clientId, const char*
|
|||
}
|
||||
|
||||
// read the response
|
||||
#ifdef STATIC_ONLY
|
||||
uint8_t response[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
uint8_t response[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
uint8_t* response = new uint8_t[numBytes];
|
||||
#endif
|
||||
_tl->receive(response, numBytes);
|
||||
if((response[0] == MQTT_CONNACK << 4) && (response[1] == 2)) {
|
||||
uint8_t returnCode = response[3];
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] response;
|
||||
#endif
|
||||
return(returnCode);
|
||||
}
|
||||
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] response;
|
||||
#endif
|
||||
return(ERR_RESPONSE_MALFORMED);
|
||||
|
@ -174,8 +174,8 @@ int16_t MQTTClient::publish(const char* topic, const char* message) {
|
|||
size_t encodedBytes = encodeLength(remainingLength, encoded);
|
||||
|
||||
// build the PUBLISH packet
|
||||
#ifdef STATIC_ONLY
|
||||
uint8_t packet[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
uint8_t packet[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
uint8_t* packet = new uint8_t[1 + encodedBytes + remainingLength];
|
||||
#endif
|
||||
|
@ -201,7 +201,7 @@ int16_t MQTTClient::publish(const char* topic, const char* message) {
|
|||
|
||||
// send MQTT packet
|
||||
int16_t state = _tl->send(packet, 1 + encodedBytes + remainingLength);
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] packet;
|
||||
#endif
|
||||
return(state);
|
||||
|
@ -217,8 +217,8 @@ int16_t MQTTClient::subscribe(const char* topicFilter) {
|
|||
size_t encodedBytes = encodeLength(remainingLength, encoded);
|
||||
|
||||
// build the SUBSCRIBE packet
|
||||
#ifdef STATIC_ONLY
|
||||
uint8_t packet[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
uint8_t packet[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
uint8_t* packet = new uint8_t[1 + encodedBytes + remainingLength];
|
||||
#endif
|
||||
|
@ -244,7 +244,7 @@ int16_t MQTTClient::subscribe(const char* topicFilter) {
|
|||
|
||||
// send MQTT packet
|
||||
int16_t state = _tl->send(packet, 1 + encodedBytes + remainingLength);
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] packet;
|
||||
#endif
|
||||
if(state != ERR_NONE) {
|
||||
|
@ -258,8 +258,8 @@ int16_t MQTTClient::subscribe(const char* topicFilter) {
|
|||
}
|
||||
|
||||
// read the response
|
||||
#ifdef STATIC_ONLY
|
||||
uint8_t response[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
uint8_t response[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
uint8_t* response = new uint8_t[numBytes];
|
||||
#endif
|
||||
|
@ -268,7 +268,7 @@ int16_t MQTTClient::subscribe(const char* topicFilter) {
|
|||
// check packet ID
|
||||
uint16_t receivedId = response[3] | response[2] << 8;
|
||||
int16_t returnCode = response[4];
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] response;
|
||||
#endif
|
||||
if(receivedId != packetId) {
|
||||
|
@ -277,7 +277,7 @@ int16_t MQTTClient::subscribe(const char* topicFilter) {
|
|||
return(returnCode);
|
||||
}
|
||||
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] response;
|
||||
#endif
|
||||
return(ERR_RESPONSE_MALFORMED);
|
||||
|
@ -291,8 +291,8 @@ int16_t MQTTClient::unsubscribe(const char* topicFilter) {
|
|||
size_t encodedBytes = encodeLength(remainingLength, encoded);
|
||||
|
||||
// build the UNSUBSCRIBE packet
|
||||
#ifdef STATIC_ONLY
|
||||
uint8_t packet[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
uint8_t packet[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
uint8_t* packet = new uint8_t[1 + encodedBytes + remainingLength];
|
||||
#endif
|
||||
|
@ -317,7 +317,7 @@ int16_t MQTTClient::unsubscribe(const char* topicFilter) {
|
|||
|
||||
// send MQTT packet
|
||||
int16_t state = _tl->send(packet, 1 + encodedBytes + remainingLength);
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] packet;
|
||||
#endif
|
||||
if(state != ERR_NONE) {
|
||||
|
@ -331,8 +331,8 @@ int16_t MQTTClient::unsubscribe(const char* topicFilter) {
|
|||
}
|
||||
|
||||
// read the response
|
||||
#ifdef STATIC_ONLY
|
||||
uint8_t response[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
uint8_t response[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
uint8_t* response = new uint8_t[numBytes];
|
||||
#endif
|
||||
|
@ -340,7 +340,7 @@ int16_t MQTTClient::unsubscribe(const char* topicFilter) {
|
|||
if((response[0] == MQTT_UNSUBACK << 4) && (response[1] == 2)) {
|
||||
// check packet ID
|
||||
uint16_t receivedId = response[3] | response[2] << 8;
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] response;
|
||||
#endif
|
||||
if(receivedId != packetId) {
|
||||
|
@ -349,7 +349,7 @@ int16_t MQTTClient::unsubscribe(const char* topicFilter) {
|
|||
return(ERR_NONE);
|
||||
}
|
||||
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] response;
|
||||
#endif
|
||||
return(ERR_RESPONSE_MALFORMED);
|
||||
|
@ -376,20 +376,20 @@ int16_t MQTTClient::ping() {
|
|||
}
|
||||
|
||||
// read the response
|
||||
#ifdef STATIC_ONLY
|
||||
uint8_t response[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
uint8_t response[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
uint8_t* response = new uint8_t[numBytes];
|
||||
#endif
|
||||
_tl->receive(response, numBytes);
|
||||
if((response[0] == MQTT_PINGRESP << 4) && (response[1] == 0)) {
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] response;
|
||||
#endif
|
||||
return(ERR_NONE);
|
||||
}
|
||||
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] response;
|
||||
#endif
|
||||
return(ERR_RESPONSE_MALFORMED);
|
||||
|
|
|
@ -19,8 +19,8 @@ int16_t PhysicalLayer::transmit(__FlashStringHelper* fstr, uint8_t addr) {
|
|||
}
|
||||
|
||||
// dynamically allocate memory
|
||||
#ifdef STATIC_ONLY
|
||||
char str[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char str[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
char* str = new char[len];
|
||||
#endif
|
||||
|
@ -33,7 +33,7 @@ int16_t PhysicalLayer::transmit(__FlashStringHelper* fstr, uint8_t addr) {
|
|||
|
||||
// transmit string
|
||||
int16_t state = transmit(str, addr);
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] str;
|
||||
#endif
|
||||
return(state);
|
||||
|
@ -68,8 +68,8 @@ int16_t PhysicalLayer::readData(String& str, size_t len) {
|
|||
}
|
||||
|
||||
// build a temporary buffer
|
||||
#ifdef STATIC_ONLY
|
||||
uint8_t data[STATIC_ARRAY_SIZE + 1];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
uint8_t data[RADIOLIB_STATIC_ARRAY_SIZE + 1];
|
||||
#else
|
||||
uint8_t* data = new uint8_t[length + 1];
|
||||
if(!data) {
|
||||
|
@ -89,7 +89,7 @@ int16_t PhysicalLayer::readData(String& str, size_t len) {
|
|||
}
|
||||
|
||||
// deallocate temporary buffer
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] data;
|
||||
#endif
|
||||
|
||||
|
@ -108,8 +108,8 @@ int16_t PhysicalLayer::receive(String& str, size_t len) {
|
|||
}
|
||||
|
||||
// build a temporary buffer
|
||||
#ifdef STATIC_ONLY
|
||||
uint8_t data[STATIC_ARRAY_SIZE + 1];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
uint8_t data[RADIOLIB_STATIC_ARRAY_SIZE + 1];
|
||||
#else
|
||||
uint8_t* data = new uint8_t[length + 1];
|
||||
if(!data) {
|
||||
|
@ -134,7 +134,7 @@ int16_t PhysicalLayer::receive(String& str, size_t len) {
|
|||
}
|
||||
|
||||
// deallocate temporary buffer
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] data;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ ITA2String::ITA2String(const char* str) {
|
|||
}
|
||||
|
||||
ITA2String::~ITA2String() {
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] _str;
|
||||
#endif
|
||||
}
|
||||
|
@ -32,8 +32,8 @@ size_t ITA2String::length() {
|
|||
|
||||
uint8_t* ITA2String::byteArr() {
|
||||
// create temporary array 2x the string length (figures may be 3 bytes)
|
||||
#ifdef STATIC_ONLY
|
||||
uint8_t temp[STATIC_ARRAY_SIZE*2 + 1];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
uint8_t temp[RADIOLIB_STATIC_ARRAY_SIZE*2 + 1];
|
||||
#else
|
||||
uint8_t* temp = new uint8_t[_len*2 + 1];
|
||||
#endif
|
||||
|
@ -79,7 +79,7 @@ uint8_t* ITA2String::byteArr() {
|
|||
|
||||
uint8_t* arr = new uint8_t[arrayLen];
|
||||
memcpy(arr, temp, arrayLen);
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] temp;
|
||||
#endif
|
||||
|
||||
|
@ -208,8 +208,8 @@ size_t RTTYClient::print(__FlashStringHelper* fstr) {
|
|||
}
|
||||
|
||||
// dynamically allocate memory
|
||||
#ifdef STATIC_ONLY
|
||||
char str[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char str[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
char* str = new char[len];
|
||||
#endif
|
||||
|
@ -227,7 +227,7 @@ size_t RTTYClient::print(__FlashStringHelper* fstr) {
|
|||
} else if((_encoding == ASCII) || (_encoding == ASCII_EXTENDED)) {
|
||||
n = RTTYClient::write((uint8_t*)str, len);
|
||||
}
|
||||
#ifndef STATIC_ONLY
|
||||
#ifndef RADIOLIB_STATIC_ONLY
|
||||
delete[] str;
|
||||
#endif
|
||||
return(n);
|
||||
|
|
|
@ -58,8 +58,8 @@ class ITA2String {
|
|||
uint8_t* byteArr();
|
||||
|
||||
private:
|
||||
#ifdef STATIC_ONLY
|
||||
char _str[STATIC_ARRAY_SIZE];
|
||||
#ifdef RADIOLIB_STATIC_ONLY
|
||||
char _str[RADIOLIB_STATIC_ARRAY_SIZE];
|
||||
#else
|
||||
char* _str = new char[1];
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue