2016-01-14 18:45:04 +00:00
|
|
|
/*
|
2020-08-26 08:29:11 +00:00
|
|
|
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
|
2016-01-14 18:45:04 +00:00
|
|
|
*
|
|
|
|
* 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 of the License, 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; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2016-09-14 06:41:37 +00:00
|
|
|
#if !defined(DMRNetwork_H)
|
|
|
|
#define DMRNetwork_H
|
2016-01-14 18:45:04 +00:00
|
|
|
|
|
|
|
#include "UDPSocket.h"
|
|
|
|
#include "Timer.h"
|
2018-02-08 20:25:03 +00:00
|
|
|
#include "RingBuffer.h"
|
2016-01-14 18:45:04 +00:00
|
|
|
#include "DMRData.h"
|
2016-09-05 16:40:43 +00:00
|
|
|
#include "Defines.h"
|
2016-01-14 18:45:04 +00:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <cstdint>
|
2020-07-01 21:40:26 +00:00
|
|
|
#include <random>
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2016-09-14 06:41:37 +00:00
|
|
|
class CDMRNetwork
|
2016-01-14 18:45:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-08-26 08:29:11 +00:00
|
|
|
CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, bool duplex, const char* version, bool debug, bool slot1, bool slot2, HW_TYPE hwType);
|
2016-09-14 06:41:37 +00:00
|
|
|
~CDMRNetwork();
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2020-08-27 09:13:02 +00:00
|
|
|
void setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode);
|
2016-01-14 18:45:04 +00:00
|
|
|
|
|
|
|
bool open();
|
|
|
|
|
2016-01-25 18:11:44 +00:00
|
|
|
void enable(bool enabled);
|
|
|
|
|
2016-01-14 18:45:04 +00:00
|
|
|
bool read(CDMRData& data);
|
|
|
|
|
|
|
|
bool write(const CDMRData& data);
|
|
|
|
|
2018-10-30 07:53:11 +00:00
|
|
|
bool writeRadioPosition(unsigned int id, const unsigned char* data);
|
2017-05-17 17:16:08 +00:00
|
|
|
|
|
|
|
bool writeTalkerAlias(unsigned int id, unsigned char type, const unsigned char* data);
|
|
|
|
|
2016-01-14 18:45:04 +00:00
|
|
|
bool wantsBeacon();
|
|
|
|
|
|
|
|
void clock(unsigned int ms);
|
|
|
|
|
|
|
|
void close();
|
|
|
|
|
|
|
|
private:
|
2020-09-06 11:54:08 +00:00
|
|
|
std::string m_addressStr;
|
|
|
|
sockaddr_storage m_addr;
|
|
|
|
unsigned int m_addrLen;
|
|
|
|
unsigned int m_port;
|
|
|
|
uint8_t* m_id;
|
|
|
|
bool m_duplex;
|
|
|
|
const char* m_version;
|
|
|
|
bool m_debug;
|
|
|
|
CUDPSocket m_socket;
|
|
|
|
bool m_enabled;
|
|
|
|
bool m_slot1;
|
|
|
|
bool m_slot2;
|
|
|
|
HW_TYPE m_hwType;
|
|
|
|
unsigned char* m_buffer;
|
|
|
|
uint32_t* m_streamId;
|
2018-02-08 20:25:03 +00:00
|
|
|
CRingBuffer<unsigned char> m_rxData;
|
2020-09-06 11:54:08 +00:00
|
|
|
bool m_beacon;
|
|
|
|
std::mt19937 m_random;
|
|
|
|
std::string m_callsign;
|
|
|
|
unsigned int m_rxFrequency;
|
|
|
|
unsigned int m_txFrequency;
|
|
|
|
unsigned int m_power;
|
|
|
|
unsigned int m_colorCode;
|
|
|
|
CTimer m_pingTimer;
|
2018-02-08 20:25:03 +00:00
|
|
|
|
2016-01-14 18:45:04 +00:00
|
|
|
bool writeConfig();
|
|
|
|
|
|
|
|
bool write(const unsigned char* data, unsigned int length);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|