3
Fork 0

Added support of Talker Alias

This commit is contained in:
Artem Prilutskiy 2016-12-29 11:47:21 +03:00
parent 1c8eaa89e7
commit 262463046e
4 changed files with 38 additions and 20 deletions

View file

@ -11,6 +11,8 @@
#define DEFAULT_USER_NUMBER 1
#define DEFAULT_LINK_NUMBER 10
#define EMPTY_STRING ""
int main(int argc, const char* argv[])
{
printf("\n");
@ -81,13 +83,16 @@ int main(int argc, const char* argv[])
(file == NULL))
{
printf(
"Usage: %s"
" --expression <regular expression>"
" --connection <path to configuration file>"
" [--unknown <ID for unknown call-signs>]"
" --network <network number>"
" --link <link number>"
" [--identity <identity>]"
"Usage: %s\n"
" --expression <regular expression>\n"
" --connection <path to configuration file>\n"
" [--unknown <ID for unknown call-signs>]\n"
" --network <network number>\n"
" --link <link number>\n"
" [--identity <identity>]\n"
"\n"
"Expression example:\n"
" (?<alias>(?<call>[RU][A-Z]?[0-9][A-Z]{1,4})[^;])\n"
"\n",
argv[0]);
return EXIT_FAILURE;
@ -110,15 +115,21 @@ int main(int argc, const char* argv[])
int count = pcre_exec(expression, NULL, line, length, 0, 0, vectors, VECTORS_COUNT);
if (count > 0)
{
const char* call;
pcre_get_substring(line, vectors, count, 1, &call);
const char* call = EMPTY_STRING;
const char* alias = EMPTY_STRING;
pcre_get_named_substring(expression, line, vectors, count, "call", &call);
pcre_get_named_substring(expression, line, vectors, count, "alias", &alias);
uint32_t number = store.getPrivateIDForCall(call);
if (number == 0)
number = unknown;
proxy.setTalkerID(number);
proxy.setTalkerAlias(call);
syslog(LOG_INFO, "*** Found call-sign: %s (ID: %d)", call, number);
proxy.setTalkerAlias(alias);
syslog(LOG_INFO, "*** Found call-sign: %s (ID: %d, Alias: \"%s\")", call, number, alias);
pcre_free_substring(call);
}

View file

@ -48,19 +48,17 @@ uint32_t PatchCordProxy::getTalkerID()
void PatchCordProxy::setTalkerAlias(const char* value)
{
size_t length = strlen(value);
const uint32_t* data = (const uint32_t*)value;
int length = strlen(value);
size_t index = VALUE_CORD_TALKER_ALIAS;
size_t count =
(length / sizeof(uint32_t)) +
((length % sizeof(uint32_t)) > 0);
uint32_t* data = (uint32_t*)alloca(length + sizeof(uint32_t));
memcpy(data, value, length);
getContextBanner();
while (count > 0)
while (length > 0)
{
setSpecificValue(index, *data);
count --;
length -= sizeof(uint32_t);
index ++;
data ++;
}

View file

@ -412,6 +412,10 @@ bool ModuleEchoLink::initialize(void)
return false;
}
if (cfg().getValue(cfgName(), "BRIDGE_DEFAULT", value))
{
bridge.setDefaultConfiguration(value.c_str());
}
if (cfg().getValue(cfgName(), "BRIDGE_PROXY", value))
{
bridge.setProxyConfiguration(value.c_str());

View file

@ -1,2 +1,7 @@
#!/bin/bash
./FRNClientConsole | ./callcapture --identity AlterFRN --expression "RX is started: ([A-Z0-9]{3,7})[-,]" --connection Registry.cnf --network 2502 --link 11
./FRNClientConsole | ./callcapture \
--identity AlterFRN \
--expression "RX is started: (?<alias>(?<call>[A-Z0-9]{2,7})[-,][^;]+)" \
--connection Registry.cnf \
--network 2502 \
--link 11