# RadioLib: src/protocols/Pager/Pager.h Source File

Pager.h
#if !defined(_RADIOLIB_PAGER_H) && !RADIOLIB_EXCLUDE_PAGER
#define _RADIOLIB_PAGER_H
#include "../../TypeDef.h"
#include "../PhysicalLayer/PhysicalLayer.h"
#include "../../utils/FEC.h"
// frequency shift in Hz
#define RADIOLIB_PAGER_FREQ_SHIFT_HZ (4500)
// supported encoding schemes
#define RADIOLIB_PAGER_ASCII (0)
#define RADIOLIB_PAGER_BCD (1)
// preamble length in 32-bit code words
#define RADIOLIB_PAGER_PREAMBLE_LENGTH (18)
// protocol-specified code words
#define RADIOLIB_PAGER_PREAMBLE_CODE_WORD (0xAAAAAAAA)
#define RADIOLIB_PAGER_FRAME_SYNC_CODE_WORD (0x7CD215D8)
#define RADIOLIB_PAGER_IDLE_CODE_WORD (0x7A89C197)
// code word type identification flags
#define RADIOLIB_PAGER_ADDRESS_CODE_WORD (0UL)
#define RADIOLIB_PAGER_MESSAGE_CODE_WORD (1UL)
// length of code word in bits
#define RADIOLIB_PAGER_CODE_WORD_LEN (32)
// number of message bits in a single code block
#define RADIOLIB_PAGER_ADDRESS_POS (13)
#define RADIOLIB_PAGER_FUNC_BITS_POS (11)
#define RADIOLIB_PAGER_MESSAGE_BITS_LENGTH (20)
#define RADIOLIB_PAGER_MESSAGE_END_POS (11)
// number of code words in a batch
#define RADIOLIB_PAGER_BATCH_LEN (16)
// mask for address bits in a single code word
#define RADIOLIB_PAGER_ADDRESS_BITS_MASK (0x7FFFE000UL)
// mask for function bits in a single code word
#define RADIOLIB_PAGER_FUNCTION_BITS_MASK (0x00001800UL)
// mask for BCH bits in a single code word
#define RADIOLIB_PAGER_BCH_BITS_MASK (0x000007FFUL)
// message type functional bits
#define RADIOLIB_PAGER_FUNC_BITS_NUMERIC (0b00)
#define RADIOLIB_PAGER_FUNC_BITS_TONE (0b01)
#define RADIOLIB_PAGER_FUNC_BITS_ACTIVATION (0b10)
#define RADIOLIB_PAGER_FUNC_BITS_ALPHA (0b11)
#define RADIOLIB_PAGER_FUNC_AUTO 0xFF
// the maximum allowed address (2^22 - 1)
#define RADIOLIB_PAGER_ADDRESS_MAX (2097151)
class PagerClient {
public:
explicit PagerClient(PhysicalLayer* phy);
// basic methods
int16_t begin(float base, uint16_t speed, bool invert = false, uint16_t shift = RADIOLIB_PAGER_FREQ_SHIFT_HZ);
int16_t sendTone(uint32_t addr);
#if defined(RADIOLIB_BUILD_ARDUINO)
int16_t transmit(String& str, uint32_t addr, uint8_t encoding = RADIOLIB_PAGER_BCD, uint8_t function = RADIOLIB_PAGER_FUNC_AUTO);
#endif
int16_t transmit(const char* str, 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 !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
int16_t startReceive(uint32_t pin, uint32_t addr, uint32_t mask = 0xFFFFF);
int16_t startReceive(uint32_t pin, uint32_t *addrs, uint32_t *masks, size_t numAddress);
size_t available();
#if defined(RADIOLIB_BUILD_ARDUINO)
int16_t readData(String& str, size_t len = 0, uint32_t* addr = NULL);
#endif
int16_t readData(uint8_t* data, size_t* len, uint32_t* addr = NULL);
#endif
#if !RADIOLIB_GODMODE
private:
#endif
PhysicalLayer* phyLayer;
float baseFreq = 0;
float dataRate = 0;
uint32_t baseFreqRaw = 0;
uint16_t shiftFreq = 0;
uint16_t shiftFreqHz = 0;
RadioLibTime_t bitDuration = 0;
uint32_t filterAddr = 0;
uint32_t filterMask = 0;
uint32_t *filterAddresses = nullptr;
uint32_t *filterMasks = nullptr;
size_t filterNumAddresses = 0;
bool inv = false;
void write(uint32_t* data, size_t len);
void write(uint32_t codeWord);
int16_t startReceiveCommon();
bool addressMatched(uint32_t addr);
#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
uint32_t read();
#endif
uint8_t encodeBCD(char c);
char decodeBCD(uint8_t b);
};
#endif
PagerClient
Client for Pager communication.
Definition: Pager.h:62
PagerClient::begin
int16_t begin(float base, uint16_t speed, bool invert=false, uint16_t shift=RADIOLIB_PAGER_FREQ_SHIFT_HZ)
Initialization method.
Definition: Pager.cpp:33
PagerClient::sendTone
int16_t sendTone(uint32_t addr)
Method to send a tone-only alert to a destination pager.
Definition: Pager.cpp:57
PagerClient::PagerClient
PagerClient(PhysicalLayer *phy)
Default constructor.
Definition: Pager.cpp:26
PagerClient::startReceive
int16_t startReceive(uint32_t pin, uint32_t addr, uint32_t mask=0xFFFFF)
Start reception of POCSAG packets.
Definition: Pager.cpp:243
PagerClient::readData
int16_t readData(uint8_t *data, size_t *len, uint32_t *addr=NULL)
Reads data that was received after calling startReceive method.
Definition: Pager.cpp:348
PagerClient::transmit
int16_t transmit(const char *str, uint32_t addr, uint8_t encoding=RADIOLIB_PAGER_BCD, uint8_t function=RADIOLIB_PAGER_FUNC_AUTO)
C-string transmit method.
Definition: Pager.cpp:67
PagerClient::available
size_t available()
Get the number of POCSAG batches available in buffer. Limited by the size of direct mode buffer!
Definition: Pager.cpp:297
PhysicalLayer
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition: PhysicalLayer.h:54
RadioLibTime_t
unsigned long RadioLibTime_t
Type used for durations in RadioLib.
Definition: TypeDef.h:586