[Pager] Reworked macro configuration system

This commit is contained in:
jgromes 2023-11-27 21:17:45 +01:00
parent 8f5cff0cd4
commit 074b707924
2 changed files with 13 additions and 13 deletions

View file

@ -1,9 +1,9 @@
#include "Pager.h" #include "Pager.h"
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
#if !defined(RADIOLIB_EXCLUDE_PAGER) #if !RADIOLIB_EXCLUDE_PAGER
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
// this is a massive hack, but we need a global-scope ISR to manage the bit reading // this is a massive hack, but we need a global-scope ISR to manage the bit reading
// let's hope nobody ever tries running two POCSAG receivers at the same time // let's hope nobody ever tries running two POCSAG receivers at the same time
static PhysicalLayer* readBitInstance = NULL; static PhysicalLayer* readBitInstance = NULL;
@ -21,7 +21,7 @@ static void PagerClientReadBit(void) {
PagerClient::PagerClient(PhysicalLayer* phy) { PagerClient::PagerClient(PhysicalLayer* phy) {
phyLayer = phy; phyLayer = phy;
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
readBitInstance = phyLayer; readBitInstance = phyLayer;
#endif #endif
} }
@ -127,7 +127,7 @@ int16_t PagerClient::transmit(uint8_t* data, size_t len, uint32_t addr, uint8_t
// calculate message length in 32-bit code words // calculate message length in 32-bit code words
size_t msgLen = RADIOLIB_PAGER_PREAMBLE_LENGTH + (1 + RADIOLIB_PAGER_BATCH_LEN) * numBatches; size_t msgLen = RADIOLIB_PAGER_PREAMBLE_LENGTH + (1 + RADIOLIB_PAGER_BATCH_LEN) * numBatches;
#if defined(RADIOLIB_STATIC_ONLY) #if RADIOLIB_STATIC_ONLY
uint32_t msg[RADIOLIB_STATIC_ARRAY_SIZE]; uint32_t msg[RADIOLIB_STATIC_ARRAY_SIZE];
#else #else
uint32_t* msg = new uint32_t[msgLen]; uint32_t* msg = new uint32_t[msgLen];
@ -225,7 +225,7 @@ int16_t PagerClient::transmit(uint8_t* data, size_t len, uint32_t addr, uint8_t
// transmit the message // transmit the message
PagerClient::write(msg, msgLen); PagerClient::write(msg, msgLen);
#if !defined(RADIOLIB_STATIC_ONLY) #if !RADIOLIB_STATIC_ONLY
delete[] msg; delete[] msg;
#endif #endif
@ -235,7 +235,7 @@ int16_t PagerClient::transmit(uint8_t* data, size_t len, uint32_t addr, uint8_t
return(RADIOLIB_ERR_NONE); return(RADIOLIB_ERR_NONE);
} }
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
int16_t PagerClient::startReceive(uint32_t pin, uint32_t addr, uint32_t mask) { int16_t PagerClient::startReceive(uint32_t pin, uint32_t addr, uint32_t mask) {
// save the variables // save the variables
readBitPin = pin; readBitPin = pin;
@ -289,7 +289,7 @@ int16_t PagerClient::readData(String& str, size_t len, uint32_t* addr) {
} }
// build a temporary buffer // build a temporary buffer
#if defined(RADIOLIB_STATIC_ONLY) #if RADIOLIB_STATIC_ONLY
uint8_t data[RADIOLIB_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];
@ -316,7 +316,7 @@ int16_t PagerClient::readData(String& str, size_t len, uint32_t* addr) {
} }
// deallocate temporary buffer // deallocate temporary buffer
#if !defined(RADIOLIB_STATIC_ONLY) #if !RADIOLIB_STATIC_ONLY
delete[] data; delete[] data;
#endif #endif
@ -496,7 +496,7 @@ void PagerClient::write(uint32_t codeWord) {
} }
} }
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
uint32_t PagerClient::read() { uint32_t PagerClient::read() {
uint32_t codeWord = 0; uint32_t codeWord = 0;
codeWord |= (uint32_t)phyLayer->read() << 24; codeWord |= (uint32_t)phyLayer->read() << 24;

View file

@ -1,4 +1,4 @@
#if !defined(_RADIOLIB_PAGER_H) && !defined(RADIOLIB_EXCLUDE_PAGER) #if !defined(_RADIOLIB_PAGER_H) && !RADIOLIB_EXCLUDE_PAGER
#define _RADIOLIB_PAGER_H #define _RADIOLIB_PAGER_H
#include "../../TypeDef.h" #include "../../TypeDef.h"
@ -119,7 +119,7 @@ class PagerClient {
*/ */
int16_t transmit(uint8_t* data, size_t len, uint32_t addr, uint8_t encoding = RADIOLIB_PAGER_BCD, uint8_t function = RADIOLIB_PAGER_FUNC_AUTO); int16_t transmit(uint8_t* data, size_t len, uint32_t addr, uint8_t encoding = RADIOLIB_PAGER_BCD, uint8_t function = RADIOLIB_PAGER_FUNC_AUTO);
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
/*! /*!
\brief Start reception of POCSAG packets. \brief Start reception of POCSAG packets.
\param pin Pin to receive digital data on (e.g., DIO2 for SX127x). \param pin Pin to receive digital data on (e.g., DIO2 for SX127x).
@ -162,7 +162,7 @@ class PagerClient {
int16_t readData(uint8_t* data, size_t* len, uint32_t* addr = NULL); int16_t readData(uint8_t* data, size_t* len, uint32_t* addr = NULL);
#endif #endif
#if !defined(RADIOLIB_GODMODE) #if !RADIOLIB_GODMODE
private: private:
#endif #endif
PhysicalLayer* phyLayer; PhysicalLayer* phyLayer;
@ -180,7 +180,7 @@ class PagerClient {
void write(uint32_t* data, size_t len); void write(uint32_t* data, size_t len);
void write(uint32_t codeWord); void write(uint32_t codeWord);
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE) #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
uint32_t read(); uint32_t read();
#endif #endif