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