forked from robotastic/trunk-recorder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmartnet_parser.cc
65 lines (50 loc) · 1.33 KB
/
smartnet_parser.cc
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
#include "smartnet_parser.h"
using namespace std;
SmartnetParser::SmartnetParser() {
lastaddress = 0;
lastcmd = 0;
}
double SmartnetParser::getfreq(int cmd) {
float freq;
if (cmd < 0x1b8) {
freq = float(cmd * 0.025 + 851.0125);
} else if (cmd < 0x230) {
freq = float(cmd * 0.025 + 851.0125 - 10.9875);
} else {
freq = 0;
}
return freq*1000000;
}
std::vector<TrunkMessage> SmartnetParser::parse_message(std::string s) {
std::vector<TrunkMessage> messages;
TrunkMessage message;
message.message_type = UNKNOWN;
std::vector<std::string> x;
boost::split(x, s, boost::is_any_of(","), boost::token_compress_on);
long address = atoi( x[0].c_str() ) & 0xFFF0;
//int groupflag = atoi( x[1].c_str() );
int command = atoi( x[2].c_str() );
x.clear();
vector<string>().swap(x);
if (command < 0x2d0) {
if ( (address != 56016) && (address != 8176)) { // remove this later to make it more general
message.talkgroup = address;
message.freq = getfreq(command);
if ( lastcmd == 0x308) {
// Channel Grant
message.message_type = GRANT;
} else {
// Call continuation
message.message_type = UPDATE;
}
}
}
if (command == 0x03c0) {
message.message_type = STATUS;
//parse_status(command, address,groupflag);
}
lastaddress = address;
lastcmd = command;
messages.push_back(message);
return messages;
}