YSFClients/YSFGateway/WiresX.h

119 lines
3.6 KiB
C
Raw Normal View History

2016-05-27 18:55:44 +02:00
/*
2019-02-02 13:05:41 +01:00
* Copyright (C) 2016,2017,2018,2019 by Jonathan Naylor G4KLX
2016-05-27 18:55:44 +02: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.
*/
#if !defined(WIRESX_H)
#define WIRESX_H
2018-02-21 19:41:24 +01:00
#include "YSFReflectors.h"
#include "YSFNetwork.h"
2016-06-06 23:16:22 +02:00
#include "Timer.h"
#include "StopWatch.h"
#include "RingBuffer.h"
2016-05-27 18:55:44 +02:00
#include <string>
enum WX_STATUS {
WXS_NONE,
WXS_CONNECT_YSF,
WXS_CONNECT_FCS,
2016-05-27 18:55:44 +02:00
WXS_DISCONNECT
};
enum WXSI_STATUS {
WXSI_NONE,
WXSI_DX,
WXSI_CONNECT,
WXSI_DISCONNECT,
WXSI_ALL,
2018-08-06 00:04:35 +02:00
WXSI_SEARCH,
WXSI_CATEGORY
};
2016-05-27 18:55:44 +02:00
class CWiresX {
public:
2018-03-05 21:00:29 +01:00
CWiresX(const std::string& callsign, const std::string& suffix, CYSFNetwork* network, CYSFReflectors& reflectors);
2016-05-27 18:55:44 +02:00
~CWiresX();
2016-06-07 22:19:33 +02:00
void setInfo(const std::string& name, unsigned int txFrequency, unsigned int rxFrequency);
void setParrot(const std::string& address, unsigned int port);
2018-01-29 03:05:25 +01:00
void setYSF2DMR(const std::string& address, unsigned int port);
void setYSF2NXDN(const std::string& address, unsigned int port);
void setYSF2P25(const std::string& address, unsigned int port);
2018-05-09 21:04:09 +02:00
void addFCSRoom(const std::string& id, const std::string& name);
bool start();
2019-02-02 13:05:41 +01:00
bool isBusy() const;
WX_STATUS process(const unsigned char* data, const unsigned char* source, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft, bool wiresXCommandPassthrough);
2016-05-27 18:55:44 +02:00
CYSFReflector* getReflector() const;
2018-03-05 21:00:29 +01:00
void setReflector(CYSFReflector* reflector);
2016-05-27 18:55:44 +02:00
2017-05-01 15:37:14 +02:00
void processConnect(CYSFReflector* reflector);
void processDisconnect(const unsigned char* source = NULL);
2019-01-29 15:02:56 +01:00
void sendConnect(CYSFNetwork* network);
2016-05-27 18:55:44 +02:00
void clock(unsigned int ms);
private:
2018-03-05 21:00:29 +01:00
std::string m_callsign;
std::string m_node;
CYSFNetwork* m_network;
CYSFReflectors& m_reflectors;
CYSFReflector* m_reflector;
std::string m_id;
std::string m_name;
unsigned char* m_command;
unsigned int m_txFrequency;
unsigned int m_rxFrequency;
CTimer m_timer;
unsigned char m_seqNo;
unsigned char* m_header;
unsigned char* m_csd1;
unsigned char* m_csd2;
unsigned char* m_csd3;
WXSI_STATUS m_status;
unsigned int m_start;
std::string m_search;
2018-08-06 00:04:35 +02:00
std::vector<CYSFReflector*> m_category;
bool m_busy;
CTimer m_busyTimer;
CStopWatch m_txWatch;
CRingBuffer<unsigned char> m_bufferTX;
WX_STATUS processConnect(const unsigned char* source, const unsigned char* data);
void processDX(const unsigned char* source);
void processAll(const unsigned char* source, const unsigned char* data);
2018-08-06 00:04:35 +02:00
void processCategory(const unsigned char* source, const unsigned char* data);
2016-06-06 23:16:22 +02:00
void sendDXReply();
void sendConnectReply();
void sendDisconnectReply();
void sendAllReply();
2016-06-16 19:45:00 +02:00
void sendSearchReply();
void sendSearchNotFoundReply();
2018-08-06 00:04:35 +02:00
void sendCategoryReply();
2019-01-29 15:02:56 +01:00
void createReply(const unsigned char* data, unsigned int length, CYSFNetwork* network = NULL);
void writeData(const unsigned char* data, CYSFNetwork* network, bool isYSF2XX);
unsigned char calculateFT(unsigned int length, unsigned int offset) const;
2016-05-27 18:55:44 +02:00
};
#endif