Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rdio scanner auto-populate / Better TG info for plugins #635

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 42 additions & 9 deletions plugins/rdioscanner_uploader/rdioscanner_uploader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ class Rdio_Scanner_Uploader : public Plugin_Api {
int upload(Call_Data_t call_info) {
std::string api_key;
std::string system_id;
std::string tg_group;
std::string tg_tag;
bool compress_wav = false;
Talkgroup *tg;
Rdio_Scanner_System *sys = get_system(call_info.short_name);
Expand All @@ -59,14 +57,43 @@ class Rdio_Scanner_Uploader : public Plugin_Api {
api_key = sys->api_key;
compress_wav = call_info.compress_wav;
system_id = sys->system_id;
tg_group = call_info.talkgroup;
tg_tag = call_info.talkgroup_tag;
}

if (api_key.size() == 0) {
return 0;
}

// Find talkgroup info ahead of the curl request
std::string tg_num;
std::string tg_alphatext;
std::string tg_description;
std::string tg_group;
std::string tg_tag;

if (call_info.tg_info) {
// Lookup TG info if available
tg_num = boost::lexical_cast<std::string>(call_info.tg_info->number);
tg_alphatext = call_info.tg_info->alpha_tag;
tg_description = call_info.tg_info->description;
tg_group = call_info.tg_info->group;
tg_tag = call_info.tg_info->tag;
} else {
// Use default values for TG.
// If "-" is the TG text/description, rdio scanner will use the TG number
// If "" is the TG group/tag, rdio scanner will use Unknown/Untagged
tg_num = boost::lexical_cast<std::string>(call_info.talkgroup);
tg_alphatext = call_info.talkgroup_tag;
tg_description = "";
tg_group = "";
tg_tag = "";
}

BOOST_LOG_TRIVIAL(debug) << "Rdio Scanner TG: " << tg_num;
BOOST_LOG_TRIVIAL(debug) << "Rdio Scanner TG Text: " << tg_alphatext;
BOOST_LOG_TRIVIAL(debug) << "Rdio Scanner TG Desc: " << tg_description;
BOOST_LOG_TRIVIAL(debug) << "Rdio Scanner TG Group: " << tg_group;
BOOST_LOG_TRIVIAL(debug) << "Rdio Scanner TG Tag: " << tg_tag;

std::ostringstream freq;
std::string freq_string;
freq << std::fixed << std::setprecision(0);
Expand Down Expand Up @@ -192,19 +219,25 @@ class Rdio_Scanner_Uploader : public Plugin_Api {
curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "talkgroup",
CURLFORM_COPYCONTENTS, boost::lexical_cast<std::string>(call_info.talkgroup).c_str(),
CURLFORM_COPYCONTENTS, tg_num.c_str(),
CURLFORM_END);

curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "talkgroupGroup",
CURLFORM_COPYCONTENTS, tg_group.c_str(),
CURLFORM_COPYNAME, "talkgroupLabel",
CURLFORM_COPYCONTENTS, tg_alphatext.c_str(),
CURLFORM_END);

curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "talkgroupLabel",
CURLFORM_COPYCONTENTS, boost::lexical_cast<std::string>(call_info.talkgroup_tag).c_str(),
CURLFORM_COPYNAME, "talkgroupName",
CURLFORM_COPYCONTENTS, tg_description.c_str(),
CURLFORM_END);

curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "talkgroupGroup",
CURLFORM_COPYCONTENTS, tg_group.c_str(),
CURLFORM_END);

curl_formadd(&formpost,
Expand Down
4 changes: 3 additions & 1 deletion trunk-recorder/call_concluder/call_concluder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ Call_Data_t Call_Concluder::create_call_data(Call *call, System *sys, Config con

call_info.talkgroup = call->get_talkgroup();
call_info.talkgroup_tag = call->get_talkgroup_tag();
call_info.tg_info = sys->find_talkgroup(call_info.talkgroup);

call_info.freq = call->get_freq();
call_info.encrypted = call->get_encrypted();
call_info.emergency = call->get_emergency();
Expand Down Expand Up @@ -348,4 +350,4 @@ void Call_Concluder::manage_call_data_workers() {
it++;
}
}
}
}
4 changes: 3 additions & 1 deletion trunk-recorder/call_concluder/call_concluder.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ struct Call_Data_t {
std::string upload_script;
std::string audio_type;

Talkgroup *tg_info;

int tdma_slot;
double length;
bool phase2_tdma;
Expand Down Expand Up @@ -74,4 +76,4 @@ static void manage_call_data_workers();



#endif
#endif