libsdr  0.1.0
A simple SDR library
pocsag.hh
1 #ifndef __SDR_POSAG_HH__
2 #define __SDR_POSAG_HH__
3 
4 #include "node.hh"
5 
6 namespace sdr {
7 
23 class POCSAG: public Sink<uint8_t>
24 {
25 public:
37  class Message {
38  public:
40  Message();
42  Message(uint32_t addr, uint8_t func);
44  Message(const Message &other);
45 
47  Message &operator=(const Message &other);
48 
50  inline bool isEmpty() const { return _empty; }
52  inline uint32_t address() const { return _address; }
54  inline uint8_t function() const { return _function; }
56  inline uint32_t bits() const { return _bits; }
57 
59  void addPayload(uint32_t word);
60 
62  int estimateText() const;
65  int estimateNumeric() const;
66 
68  std::string asText() const;
70  std::string asNumeric() const;
72  std::string asHex() const;
73 
74  protected:
76  uint32_t _address;
78  uint8_t _function;
80  bool _empty;
82  uint32_t _bits;
84  std::vector<uint8_t> _payload;
85  };
86 
87 protected:
89  typedef enum {
90  WAIT,
93  } State;
94 
95 public:
97  POCSAG();
98 
99  void config(const Config &src_cfg);
100  void process(const Buffer<uint8_t> &buffer, bool allow_overwrite);
101 
104  virtual void handleMessages();
105 
106 protected:
108  void _process_word(uint32_t word);
110  void _reset_message();
112  void _finish_message();
113 
114 protected:
118  uint64_t _bits;
120  uint8_t _bitcount;
122  uint8_t _slot;
126  std::list<Message> _queue;
127 };
128 
129 
133 class POCSAGDump: public POCSAG
134 {
135 public:
138  POCSAGDump(std::ostream &stream);
139 
141  void handleMessages();
142 
143 protected:
145  std::ostream &_stream;
146 };
147 
148 
149 }
150 
151 #endif // __SDR_POSAG_HH__
uint8_t _slot
The current slot.
Definition: pocsag.hh:122
int estimateText() const
Retruns the "likelihood" that the message is a text message (actually a log-likelihood).
Definition: pocsag.cc:344
A collection of configuration information that is send by a source to all connected sinks to properga...
Definition: node.hh:35
std::string asHex() const
Dumps the payload.
Definition: pocsag.cc:334
void _finish_message()
Add the (non-empty) message to the queue.
Definition: pocsag.cc:136
void handleMessages()
Dumps the received messages.
Definition: pocsag.cc:158
uint32_t _address
The address of the message.
Definition: pocsag.hh:76
std::string asText() const
Decodes the message as a text message.
Definition: pocsag.cc:297
Typed sink.
Definition: node.hh:192
Definition: autocast.hh:8
bool _empty
If true the message is empty.
Definition: pocsag.hh:80
std::vector< uint8_t > _payload
The actual payload.
Definition: pocsag.hh:84
uint32_t _bits
The number of payload bits in the message.
Definition: pocsag.hh:82
int estimateNumeric() const
Retruns the "likelihood" that the message is a numeric message (actually a log-likelihood).
Definition: pocsag.cc:360
std::ostream & _stream
The output stream.
Definition: pocsag.hh:145
Wait for the sync word for continuation.
Definition: pocsag.hh:92
void config(const Config &src_cfg)
Needs to be implemented by any sub-type to check and perform the configuration of the node...
Definition: pocsag.cc:22
A pocsag message.
Definition: pocsag.hh:37
uint32_t bits() const
Returns the number of data bits.
Definition: pocsag.hh:56
State
The possible states of the POGSAC receiver.
Definition: pocsag.hh:89
uint8_t _bitcount
The number of received bits.
Definition: pocsag.hh:120
void _process_word(uint32_t word)
Process a POGSAC word.
Definition: pocsag.cc:99
POCSAG()
Constructor.
Definition: pocsag.cc:15
POCSAGDump(std::ostream &stream)
Constructor.
Definition: pocsag.cc:151
void addPayload(uint32_t word)
Adds some payload from the given POGSAC word.
Definition: pocsag.cc:283
virtual void handleMessages()
Can be overwritten by any other implementation to process the received messages stored in _queue...
Definition: pocsag.cc:143
std::string asNumeric() const
Decodes the message as a numeric message.
Definition: pocsag.cc:317
Message & operator=(const Message &other)
Assignment operator.
Definition: pocsag.cc:273
State _state
The current state.
Definition: pocsag.hh:116
void _reset_message()
Clear the message.
Definition: pocsag.cc:131
Wait for a sync word.
Definition: pocsag.hh:90
uint64_t _bits
The last received bits.
Definition: pocsag.hh:118
uint8_t _function
The function of the message.
Definition: pocsag.hh:78
std::list< Message > _queue
The completed messages.
Definition: pocsag.hh:126
bool isEmpty() const
Retruns true if the message is empty (has no address).
Definition: pocsag.hh:50
A simple extention of the POCSAG node that prints the received messages to a std::ostream.
Definition: pocsag.hh:133
Message()
Empty constructor.
Definition: pocsag.cc:253
Message _message
The current message.
Definition: pocsag.hh:124
void process(const Buffer< uint8_t > &buffer, bool allow_overwrite)
Needs to be implemented by any sub-type to process the received data.
Definition: pocsag.cc:41
uint32_t address() const
Returns the address of the message.
Definition: pocsag.hh:52
Receive data.
Definition: pocsag.hh:91
Implements a POCSAG decoder.
Definition: pocsag.hh:23