2016-08-23 02:45:33 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
* Copyright (C) 2016 Furrtek
|
|
|
|
*
|
|
|
|
* This file is part of PortaPack.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __POCSAG_PACKET_H__
|
|
|
|
#define __POCSAG_PACKET_H__
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstddef>
|
2023-06-09 15:50:42 -04:00
|
|
|
#include <array>
|
2016-08-23 02:45:33 -04:00
|
|
|
|
|
|
|
#include "baseband.hpp"
|
|
|
|
|
|
|
|
namespace pocsag {
|
|
|
|
|
2016-08-25 10:20:19 -04:00
|
|
|
enum BitRate : uint32_t {
|
2023-05-18 16:16:05 -04:00
|
|
|
UNKNOWN,
|
|
|
|
FSK512 = 512,
|
|
|
|
FSK1200 = 1200,
|
|
|
|
FSK2400 = 2400,
|
|
|
|
FSK3200 = 3200
|
2016-08-25 10:20:19 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
enum PacketFlag : uint32_t {
|
2023-05-18 16:16:05 -04:00
|
|
|
NORMAL,
|
|
|
|
TIMED_OUT,
|
|
|
|
TOO_LONG
|
2016-08-23 02:45:33 -04:00
|
|
|
};
|
|
|
|
|
2023-09-08 13:41:09 -04:00
|
|
|
/* Number of codewords in a batch. */
|
|
|
|
constexpr uint8_t batch_size = 16;
|
|
|
|
using batch_t = std::array<uint32_t, batch_size>;
|
|
|
|
|
2016-08-23 02:45:33 -04:00
|
|
|
class POCSAGPacket {
|
2023-05-18 16:16:05 -04:00
|
|
|
public:
|
|
|
|
void set_timestamp(const Timestamp& value) {
|
|
|
|
timestamp_ = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
Timestamp timestamp() const {
|
|
|
|
return timestamp_;
|
|
|
|
}
|
|
|
|
|
2023-09-08 13:41:09 -04:00
|
|
|
void set(size_t index, uint32_t data) {
|
|
|
|
if (index < batch_size)
|
2023-05-18 16:16:05 -04:00
|
|
|
codewords[index] = data;
|
|
|
|
}
|
|
|
|
|
2023-09-08 13:41:09 -04:00
|
|
|
void set(const batch_t& batch) {
|
|
|
|
codewords = batch;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t operator[](size_t index) const {
|
|
|
|
return (index < batch_size) ? codewords[index] : 0;
|
2023-05-18 16:16:05 -04:00
|
|
|
}
|
|
|
|
|
2023-09-08 13:41:09 -04:00
|
|
|
void set_bitrate(uint16_t bitrate) {
|
2023-05-18 16:16:05 -04:00
|
|
|
bitrate_ = bitrate;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t bitrate() const {
|
|
|
|
return bitrate_;
|
|
|
|
}
|
|
|
|
|
2023-09-08 13:41:09 -04:00
|
|
|
void set_flag(PacketFlag flag) {
|
2023-05-18 16:16:05 -04:00
|
|
|
flag_ = flag;
|
|
|
|
}
|
|
|
|
|
|
|
|
PacketFlag flag() const {
|
|
|
|
return flag_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void clear() {
|
|
|
|
codewords.fill(0);
|
|
|
|
bitrate_ = 0u;
|
|
|
|
flag_ = NORMAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint16_t bitrate_{0};
|
|
|
|
PacketFlag flag_{NORMAL};
|
2023-09-08 13:41:09 -04:00
|
|
|
batch_t codewords{};
|
2023-05-18 16:16:05 -04:00
|
|
|
Timestamp timestamp_{};
|
2016-08-23 02:45:33 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace pocsag */
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
#endif /*__POCSAG_PACKET_H__*/
|