RadioLib
Universal wireless communication library for Arduino
Loading...
Searching...
No Matches
Pager.h
1#if !defined(_RADIOLIB_PAGER_H) && !RADIOLIB_EXCLUDE_PAGER
2#define _RADIOLIB_PAGER_H
3
4#include "../../TypeDef.h"
5#include "../PhysicalLayer/PhysicalLayer.h"
6#include "../../utils/FEC.h"
7
8// frequency shift in Hz
9#define RADIOLIB_PAGER_FREQ_SHIFT_HZ (4500)
10
11// supported encoding schemes
12#define RADIOLIB_PAGER_ASCII (0)
13#define RADIOLIB_PAGER_BCD (1)
14
15// preamble length in 32-bit code words
16#define RADIOLIB_PAGER_PREAMBLE_LENGTH (18)
17
18// protocol-specified code words
19#define RADIOLIB_PAGER_PREAMBLE_CODE_WORD (0xAAAAAAAA)
20#define RADIOLIB_PAGER_FRAME_SYNC_CODE_WORD (0x7CD215D8)
21#define RADIOLIB_PAGER_IDLE_CODE_WORD (0x7A89C197)
22
23// code word type identification flags
24#define RADIOLIB_PAGER_ADDRESS_CODE_WORD (0UL)
25#define RADIOLIB_PAGER_MESSAGE_CODE_WORD (1UL)
26
27// length of code word in bits
28#define RADIOLIB_PAGER_CODE_WORD_LEN (32)
29
30// number of message bits in a single code block
31#define RADIOLIB_PAGER_ADDRESS_POS (13)
32#define RADIOLIB_PAGER_FUNC_BITS_POS (11)
33#define RADIOLIB_PAGER_MESSAGE_BITS_LENGTH (20)
34#define RADIOLIB_PAGER_MESSAGE_END_POS (11)
35
36// number of code words in a batch
37#define RADIOLIB_PAGER_BATCH_LEN (16)
38
39// mask for address bits in a single code word
40#define RADIOLIB_PAGER_ADDRESS_BITS_MASK (0x7FFFE000UL)
41
42// mask for function bits in a single code word
43#define RADIOLIB_PAGER_FUNCTION_BITS_MASK (0x00001800UL)
44
45// mask for BCH bits in a single code word
46#define RADIOLIB_PAGER_BCH_BITS_MASK (0x000007FFUL)
47
48// message type functional bits
49#define RADIOLIB_PAGER_FUNC_BITS_NUMERIC (0b00)
50#define RADIOLIB_PAGER_FUNC_BITS_TONE (0b01)
51#define RADIOLIB_PAGER_FUNC_BITS_ACTIVATION (0b10)
52#define RADIOLIB_PAGER_FUNC_BITS_ALPHA (0b11)
53#define RADIOLIB_PAGER_FUNC_AUTO 0xFF
54
55// the maximum allowed address (2^22 - 1)
56#define RADIOLIB_PAGER_ADDRESS_MAX (2097151)
57
63 public:
68 explicit PagerClient(PhysicalLayer* phy);
69
70 // basic methods
71
80 int16_t begin(float base, uint16_t speed, bool invert = false, uint16_t shift = RADIOLIB_PAGER_FREQ_SHIFT_HZ);
81
87 int16_t sendTone(uint32_t addr);
88
89 #if defined(RADIOLIB_BUILD_ARDUINO)
98 int16_t transmit(String& str, uint32_t addr, uint8_t encoding = RADIOLIB_PAGER_BCD, uint8_t function = RADIOLIB_PAGER_FUNC_AUTO);
99 #endif
100
109 int16_t transmit(const char* str, uint32_t addr, uint8_t encoding = RADIOLIB_PAGER_BCD, uint8_t function = RADIOLIB_PAGER_FUNC_AUTO);
110
120 int16_t transmit(const uint8_t* data, size_t len, uint32_t addr, uint8_t encoding = RADIOLIB_PAGER_BCD, uint8_t function = RADIOLIB_PAGER_FUNC_AUTO);
121
122 #if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
131 int16_t startReceive(uint32_t pin, uint32_t addr, uint32_t mask = 0xFFFFF);
132
141 int16_t startReceive(uint32_t pin, uint32_t *addrs, uint32_t *masks, size_t numAddress);
142
147 size_t available();
148
149 #if defined(RADIOLIB_BUILD_ARDUINO)
159 int16_t readData(String& str, size_t len = 0, uint32_t* addr = NULL);
160 #endif
161
172 int16_t readData(uint8_t* data, size_t* len, uint32_t* addr = NULL);
173#endif
174
175#if !RADIOLIB_GODMODE
176 private:
177#endif
178 PhysicalLayer* phyLayer;
179
180 float baseFreq = 0;
181 float dataRate = 0;
182 uint32_t baseFreqRaw = 0;
183 uint16_t shiftFreq = 0;
184 uint16_t shiftFreqHz = 0;
185 RadioLibTime_t bitDuration = 0;
186 uint32_t filterAddr = 0;
187 uint32_t filterMask = 0;
188 uint32_t *filterAddresses = nullptr;
189 uint32_t *filterMasks = nullptr;
190 size_t filterNumAddresses = 0;
191 bool inv = false;
192
193 void write(const uint32_t* data, size_t len);
194 void write(uint32_t codeWord);
195 int16_t startReceiveCommon();
196 bool addressMatched(uint32_t addr);
197
198#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
199 uint32_t read();
200#endif
201
202 uint8_t encodeBCD(char c);
203 char decodeBCD(uint8_t b);
204};
205
206#endif
Client for Pager communication.
Definition Pager.h:62
int16_t begin(float base, uint16_t speed, bool invert=false, uint16_t shift=RADIOLIB_PAGER_FREQ_SHIFT_HZ)
Initialization method.
Definition Pager.cpp:35
int16_t sendTone(uint32_t addr)
Method to send a tone-only alert to a destination pager.
Definition Pager.cpp:59
int16_t startReceive(uint32_t pin, uint32_t addr, uint32_t mask=0xFFFFF)
Start reception of POCSAG packets.
Definition Pager.cpp:245
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
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:69
size_t available()
Get the number of POCSAG batches available in buffer. Limited by the size of direct mode buffer!
Definition Pager.cpp:299
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition PhysicalLayer.h:216
unsigned long RadioLibTime_t
Type used for durations in RadioLib.
Definition TypeDef.h:642