-
Notifications
You must be signed in to change notification settings - Fork 1
/
IRCDDB.h
139 lines (106 loc) · 6.87 KB
/
IRCDDB.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
CIRCDDB - ircDDB client library in C++
Copyright (C) 2010-2011 Michael Dirska, DL1BFF ([email protected])
Copyright (C) 2011,2012 Jonathan Naylor, G4KLX
Copyright (c) 2017 by Thomas A Early N7TAE
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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <string>
#include <vector>
enum IRCDDB_RESPONSE_TYPE {
IDRT_NONE,
IDRT_USER,
IDRT_GATEWAY,
IDRT_REPEATER
};
class CIRCDDB
{
public:
CIRCDDB();
virtual ~CIRCDDB();
// A false return implies a network error, or unable to log in
virtual bool open() = 0;
// rptrQTH can be called multiple times if necessary
// callsign The callsign of the repeater
// latitude WGS84 position of antenna in degrees, positive value -> NORTH
// longitude WGS84 position of antenna in degrees, positive value -> EAST
// desc1, desc2 20-character description of QTH
// infoURL URL of a web page with information about the repeater
virtual void rptrQTH(const std::string& callsign, double latitude, double longitude, const std::string& desc1, const std::string& desc2, const std::string& infoURL) = 0;
// rptrQRG can be called multiple times if necessary
// callsign callsign of the repeater
// txFrequency repeater TX frequency in MHz
// duplexShift duplex shift in MHz (positive or negative value): RX_freq = txFrequency + duplexShift
// range range of the repeater in meters (meters = miles * 1609.344)
// agl height of the antenna above ground in meters (meters = feet * 0.3048)
virtual void rptrQRG(const std::string& callsign, double txFrequency, double duplexShift, double range, double agl) = 0;
// If you call this method once, watchdog messages will be sent to the
// to the ircDDB network every 15 minutes. Invoke this method every 1-2 minutes to indicate
// that the gateway is working properly. After activating the watchdog, a red LED will be displayed
// on the ircDDB web page if this method is not called within a period of about 30 minutes.
// The string wdInfo should contain information about the source of the alive messages, e.g.,
// version of the RF decoding software. For example, the ircDDB java software sets this
// to "rpm_ircddbmhd-x.z-z". The string wdInfo must contain at least one non-space character.
virtual void kickWatchdog(const std::string& callsign, const std::string& wdInfo) = 0;
// get internal network status
virtual int getConnectionState() = 0;
// one of these values is returned:
// 0 = not (yet) connected to the IRC server
// 1-6 = a new connection was established, download of repeater info etc. is
// in progress
// 7 = the ircDDB connection is fully operational
// 10 = some network error occured, next state is "0" (new connection attempt)
// Send heard data, a false return implies a network error
virtual bool sendHeard(const std::string& myCall, const std::string& myCallExt, const std::string& yourCall, const std::string& rpt1, const std::string& rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3) = 0;
// same as sendHeard with two new fields:
// network_destination: empty string or 8-char call sign of the repeater
// or reflector, where this transmission is relayed to.
// tx_message: 20-char TX message or empty string, if the user did not
// send a TX message
virtual bool sendHeardWithTXMsg(const std::string& myCall, const std::string& myCallExt, const std::string& yourCall, const std::string& rpt1, const std::string& rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3, const std::string& network_destination, const std::string& tx_message) = 0;
// this method should be called at the end of a transmission
// num_dv_frames: number of DV frames sent out (96 bit frames, 20ms)
// num_dv_silent_frames: number of DV silence frames sent out in the
// last transmission, or -1 if the information is not available
// num_bit_errors: number of bit errors of the received data. This should
// be the derived from the first Golay block of the voice data. This
// error correction code only looks at 24 bits of the 96 bit frame.
// So, the overall bit error rate is calculated like this:
// BER = num_bit_errors / (num_dv_frames * 24)
// Set num_bit_errors = -1, if the error information is not available.
virtual bool sendHeardWithTXStats(const std::string& myCall, const std::string& myCallExt, const std::string& yourCall, const std::string& rpt1, const std::string& rpt2, unsigned char flag1, unsigned char flag2, unsigned char flag3, int num_dv_frames, int num_dv_silent_frames, int num_bit_errors) = 0;
// The following three functions don't block waiting for a reply, they just send the data
// Send query for a gateway/reflector, a false return implies a network error
virtual bool findGateway(const std::string& gatewayCallsign) = 0;
// Send query for a repeater module, a false return implies a network error
virtual bool findRepeater(const std::string& repeaterCallsign) = 0;
// Send query for a user, a false return implies a network error
virtual bool findUser(const std::string& userCallsign) = 0;
// Support for the Smart Group Server
virtual void sendSGSInfo(const std::string subcommand, const std::vector<std::string> parms) = 0;
// The following functions are for processing received messages
// Get the waiting message type
virtual IRCDDB_RESPONSE_TYPE getMessageType() = 0;
// Get a gateway message, as a result of IDRT_REPEATER returned from getMessageType()
// A false return implies a network error
virtual bool receiveRepeater(std::string& repeaterCallsign, std::string& gatewayCallsign, std::string& address) = 0;
// Get a gateway message, as a result of IDRT_GATEWAY returned from getMessageType()
// A false return implies a network error
virtual bool receiveGateway(std::string& gatewayCallsign, std::string& address) = 0;
// Get a user message, as a result of IDRT_USER returned from getMessageType()
// A false return implies a network error
virtual bool receiveUser(std::string& userCallsign, std::string& repeaterCallsign, std::string& gatewayCallsign, std::string& address) = 0;
virtual bool receiveUser(std::string& userCallsign, std::string& repeaterCallsign, std::string& gatewayCallsign, std::string& address, std::string& timeStamp) = 0;
virtual void close() = 0; // Implictely kills any threads in the IRC code
};
typedef std::vector<CIRCDDB*> CIRCDDB_Array;