Skip to content

Commit

Permalink
Merge pull request #661 from rosecitytransit/v4master
Browse files Browse the repository at this point in the history
Log data channel grants, unit answer requests, Location Reg Responses
  • Loading branch information
robotastic authored Apr 6, 2022
2 parents 7cbaaa6 + 7aafe3e commit 4af616b
Show file tree
Hide file tree
Showing 10 changed files with 151 additions and 338 deletions.
14 changes: 7 additions & 7 deletions docs/CONFIGURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Here is a map of the different sections of the *config.json* file:
| broadcastifySystemId | | | number | [*if broadcastifyCallsServer is set*] System ID for Broadcastify Calls <br />(this is an integer, and different from the RadioReference system ID) |
| uploadScript | | | string | This is the filename of a script that is called after each recording has finished. Checkout *encode-upload.sh.sample* as an example. The script should be located in the same directory as the trunk-recorder executable. |
| compressWav | | true | bool | Convert the recorded .wav file to an .m4a file. **This is required for both OpenMHz and Broadcastify!** The `sox` and `fdkaac` packages need to be installed for this command to work. |
| unitScript | | | string | This is the filename of a script that runs when a radio (unit) registers (is turned on), affiliates (joins a talk group), deregisters (is turned off), sends an acknowledgment response or transmits. Passed as parameters: `shortName radioID on\|join\|off\|ackresp\|call`. On joins and transmissions, `talkgroup` is passed as a fourth parameter. On joins and transmissions, `patchedTalkgroups` (comma separated list of talkgroup IDs) is passed as a fifth parameter if the talkgroup is part of a patch on the system. See *examples/unit-script.sh* for a logging example. Note that for paths relative to recorder, this should start with `./`( or `../`). |
| unitScript | | | string | This is the filename of a script that runs when a radio (unit) registers (is turned on), affiliates (joins a talk group), deregisters (is turned off), sends an acknowledgment response or transmits. Passed as parameters: `shortName radioID on\|join\|off\|ackresp\|call\|data\|ans_req\|location`. On joins and transmissions, `talkgroup` is passed as a fourth parameter. On joins and transmissions, `patchedTalkgroups` (comma separated list of talkgroup IDs) is passed as a fifth parameter if the talkgroup is part of a patch on the system. See *examples/unit-script.sh* for a logging example. Note that for paths relative to recorder, this should start with `./`( or `../`). |
| audioArchive | | true | **true** / **false** | Should the recorded audio files be kept after successfully uploading them? |
| transmissionArchive | | false | **true** / **false** | Should each of the individual transmission be kept? These transmission are combined together with other recent ones to form a single call. |
| callLog | | false | **true** / **false** | Should a json file with the call details be kept after successful uploads? |
Expand Down Expand Up @@ -281,7 +281,7 @@ This example will stream audio from talkgroup 58914 on system "CountyTrunked" to
"address":"127.0.0.1",
"port":9123,
"sendTGID":false,
"shortName":"CountyTrunked"}
"shortName":"CountyTrunked"}
}
```

Expand All @@ -296,12 +296,12 @@ This example will stream audio from talkgroup 58914 from System CountyTrunked to
"address":"127.0.0.1",
"port":9123,
"sendTGID":false,
"shortName":"CountyTrunked"},
"shortName":"CountyTrunked"},
{"TGID":58916,
"address":"127.0.0.1",
"port":9124,
"sendTGID":false,
"shortName":"StateTrunked"}
"shortName":"StateTrunked"}
]}
}
```
Expand Down Expand Up @@ -335,7 +335,7 @@ This example will stream audio from all talkgroups being recorded on System Coun
"address":"127.0.0.1",
"port":9123,
"sendTGID":true,
"shortName":"CountyTrunked"}
"shortName":"CountyTrunked"}
}
```
##### Example - Sending Audio to pulseaudio
Expand All @@ -359,8 +359,8 @@ The matching simplestream config to send audio from talkgroup 58918 to TCP port
"address":"127.0.0.1",
"port":9125,
"sendTGID":true,
"shortName":"CountyTrunked",
"useTCP":true}
"shortName":"CountyTrunked",
"useTCP":true}
}
```

Expand Down
52 changes: 46 additions & 6 deletions plugins/unit_script/unit_script.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int unit_registration(System *sys, long source_id) {
std::string system_script = get_system_script(sys->get_short_name());
if ((system_script != "") && (source_id != 0)) {
char shell_command[200];
sprintf(shell_command, "./%s %s %li on &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
sprintf(shell_command, "%s %s %li on &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
int rc = system(shell_command);
return 0;
}
Expand All @@ -39,7 +39,7 @@ int unit_deregistration(System *sys, long source_id) {
std::string system_script = get_system_script(sys->get_short_name());
if ((system_script != "") && (source_id != 0)) {
char shell_command[200];
sprintf(shell_command, "./%s %s %li off &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
sprintf(shell_command, "%s %s %li off &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
int rc = system(shell_command);
return 0;
}
Expand All @@ -49,16 +49,56 @@ int unit_acknowledge_response(System *sys, long source_id) {
std::string system_script = get_system_script(sys->get_short_name());
if ((system_script != "") && (source_id != 0)) {
char shell_command[200];
sprintf(shell_command, "./%s %s %li ackresp &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
sprintf(shell_command, "%s %s %li ackresp &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
int rc = system(shell_command);
return 0;
}
return 1;
}

int unit_group_affiliation(System *sys, long source_id, long talkgroup_num) {
unit_affiliations[source_id] = talkgroup_num;
std::string system_script = get_system_script(sys->get_short_name());
if ((system_script != "") && (source_id != 0)) {
char shell_command[200];
std::vector<unsigned long> talkgroup_patches = sys->get_talkgroup_patch(talkgroup_num);
std::string patch_string;
bool first = true;
BOOST_FOREACH (auto& TGID, talkgroup_patches) {
if (!first) { patch_string += ","; }
first = false;
patch_string += std::to_string(TGID);
}
sprintf(shell_command, "%s %s %li join %li %s &", system_script.c_str(), sys->get_short_name().c_str(), source_id, talkgroup_num, patch_string.c_str());
int rc = system(shell_command);
return 0;
}
return 1;
}

int unit_data_grant(System *sys, long source_id) {
std::string system_script = get_system_script(sys->get_short_name());
if ((system_script != "") && (source_id != 0)) {
char shell_command[200];
sprintf(shell_command, "%s %s %li data &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
int rc = system(shell_command);
return 0;
}
return 1;
}

int unit_group_affiliation(System *sys, long source_id, long talkgroup_num) {
int unit_answer_request(System *sys, long source_id) {
std::string system_script = get_system_script(sys->get_short_name());
if ((system_script != "") && (source_id != 0)) {
char shell_command[200];
sprintf(shell_command, "%s %s %li ans_req &", system_script.c_str(), sys->get_short_name().c_str(), source_id);
int rc = system(shell_command);
return 0;
}
return 1;
}

int unit_location(System *sys, long source_id, long talkgroup_num) {
unit_affiliations[source_id] = talkgroup_num;
std::string system_script = get_system_script(sys->get_short_name());
if ((system_script != "") && (source_id != 0)) {
Expand All @@ -71,7 +111,7 @@ int unit_group_affiliation(System *sys, long source_id, long talkgroup_num) {
first = false;
patch_string += std::to_string(TGID);
}
sprintf(shell_command, "./%s %s %li join %li %s &", system_script.c_str(), sys->get_short_name().c_str(), source_id, talkgroup_num, patch_string.c_str());
sprintf(shell_command, "%s %s %li location %li %s &", system_script.c_str(), sys->get_short_name().c_str(), source_id, talkgroup_num, patch_string.c_str());
int rc = system(shell_command);
return 0;
}
Expand All @@ -93,7 +133,7 @@ int call_start(Call *call) {
first = false;
patch_string += std::to_string(TGID);
}
sprintf(shell_command, "./%s %s %li call %li %s &", system_script.c_str(), short_name.c_str(), source_id, talkgroup_num, patch_string.c_str());
sprintf(shell_command, "%s %s %li call %li %s &", system_script.c_str(), short_name.c_str(), source_id, talkgroup_num, patch_string.c_str());
int rc = system(shell_command);
return 0;
}
Expand Down
28 changes: 26 additions & 2 deletions trunk-recorder/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,18 @@ void unit_group_affiliation(System *sys, long source_id, long talkgroup_num) {
plugman_unit_group_affiliation(sys, source_id, talkgroup_num);
}

void unit_data_grant(System *sys, long source_id) {
plugman_unit_data_grant(sys, source_id);
}

void unit_answer_request(System *sys, long source_id) {
plugman_unit_answer_request(sys, source_id);
}

void unit_location(System *sys, long source_id, long talkgroup_num) {
plugman_unit_location(sys, source_id, talkgroup_num);
}

void handle_call(TrunkMessage message, System *sys) {
bool call_found = false;
bool call_retune = false;
Expand Down Expand Up @@ -1016,7 +1028,10 @@ void handle_message(std::vector<TrunkMessage> messages, System *sys) {
current_system_status(message, sys);
break;

case LOCATION: // currently not handling, TODO: expand plugin system to handle this
case LOCATION:
unit_location( sys, message.source, message.talkgroup);
break;

case ACKNOWLEDGE:
unit_acknowledge_response( sys, message.source);
break;
Expand All @@ -1027,6 +1042,15 @@ void handle_message(std::vector<TrunkMessage> messages, System *sys) {
case PATCH_DELETE:
sys->delete_talkgroup_patch(message.patch_data);
break;

case DATA_GRANT:
unit_data_grant(sys, message.source);
break;

case UU_ANS_REQ:
unit_answer_request(sys, message.source);
break;

case UNKNOWN:
break;
}
Expand Down Expand Up @@ -1476,7 +1500,7 @@ int main(int argc, char **argv) {
logging::add_file_log(
keywords::file_name = config.log_dir + "/%m-%d-%Y_%H%M_%2N.log",
keywords::format = "[%TimeStamp%] (%Severity%) %Message%",
keywords::rotation_size = 10 * 1024 * 1024,
keywords::rotation_size = 100 * 1024 * 1024,
keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0),
keywords::auto_flush = true);
}
Expand Down
71 changes: 0 additions & 71 deletions trunk-recorder/plugin_manager/plugin-common.h

This file was deleted.

5 changes: 4 additions & 1 deletion trunk-recorder/plugin_manager/plugin_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ class Plugin_Api {
virtual int unit_deregistration(System *sys, long source_id) { return 0; };
virtual int unit_acknowledge_response(System *sys, long source_id) { return 0; };
virtual int unit_group_affiliation(System *sys, long source_id, long talkgroup_num) { return 0; };
virtual int unit_data_grant(System *sys, long source_id) { return 0; };
virtual int unit_answer_request(System *sys, long source_id) { return 0; };
virtual int unit_location(System *sys, long source_id, long talkgroup_num) { return 0; };
void set_frequency_format(int f) { frequencyFormat = f;}
virtual ~Plugin_Api(){};
};

#endif
#endif
Loading

0 comments on commit 4af616b

Please sign in to comment.