# SVXLink patch to bridge with BrandMeister

Copyright 2015-2019 by Artem Prilutskiy

The main purpose for this patch is to pass a callsign and talker alias between echolink and DMR.

## How to install:

Put PatchCord.* and BrandMeisterBridge.* into src/modules/echolink

Add following lines to CMakeLists.txt after "set(MODSRC QsoImpl.cpp)":
```
pkg_check_modules(DBUS dbus-1)
include_directories(${DBUS_INCLUDE_DIRS})
set(LIBS ${LIBS} ${DBUS_LIBRARIES})
set(MODSRC ${MODSRC} PatchCord.cpp BrandMeisterBridge.cpp)
```

### Add following lines to ModuleEchoLink.h:

Find this:
```
#include "version/SVXLINK.h"
```
and add this ***AFTER***:
```
include "BrandMeisterBridge.h"
```

Find this:
```
private:
```
and add this ***AFTER***:
```
BrandMeisterBridge bridge;
```

### Add following lines to ModuleEchoLink.cpp:

Find this (*bool ModuleEchoLink::initialize(void)*):
```
  IpAddress bind_addr;
  if (cfg().getValue(cfgName(), "BIND_ADDR", bind_addr) && bind_addr.isEmpty())
  {
    cerr << "*** ERROR: Invalid configuration value for " << cfgName()
         << "/BIND_ADDR specified.\n";
    moduleCleanup();
    return false;
  }
```
And then put next lines:
```
  if (cfg().getValue(cfgName(), "BRIDGE_DEFAULT", value))
  {
    bridge.setDefaultConfiguration(value.c_str());
  }
  if (cfg().getValue(cfgName(), "BRIDGE_ENCODING", value))
  {
    bridge.setEncodingConfiguration(value.c_str());
  }
  if (cfg().getValue(cfgName(), "BRIDGE_PROXY", value))
  {
    bridge.setProxyConfiguration(value.c_str());
  }

  bridge.setCallConfiguration(mycall);
```

Find this (*void ModuleEchoLink::onChatMsgReceived(QsoImpl *qso, const string& msg)*):
```
processEvent(ss.str());
```
And add this ***BEFORE***:
```
bridge.handleChatMessage(escaped.c_str());
```
This code responds to pass a chat message emitted by conference server to the bridge, required to find a talker of transmission in case of conference call.


Find this line (*void ModuleEchoLink::broadcastTalkerStatus(void)*):
```
msg << "> " << mycall << "         " << sysop_name << "\n\n";
```
And add this ***BEFORE***:
```
const char* sysop_name = bridge.getTalker();
```
This code responds to pass a talker of transmisson to the bridge in case of call on direct link.


Find this text (*void ModuleEchoLink::broadcastTalkerStatus(void)*):
```
msg << "> " << talker->remoteCallsign() << "         " << talker->remoteName() << "\n\n";
```
And add this ***AFTER***:
```
bridge.setTalker(talker->remoteCallsign().c_str(), talker->remoteName().c_str());
```
This code responds to pass a talker of transmisson from the bridge to echolink.


## How to configure:

Add folowing lines to your *ModuleEchoLink.conf*

```
BRIDGE_DEFAULT=9504
BRIDGE_PROXY=2501:10
BRIDGE_ENCODING=cp1251
```

Where:
* *BRIDGE_DEFAULT* is a default ID of callee that will be passed when ID cannot be resolved by callsign (most possible this callsign has not been registred in DMR database)
* *BRIDGE_PROXY* should correspond to Network ID of BrandMeister Server and Cord ID connected to
* *BRIDGE_ENCODING* should contain national encoding name used for text messages and descriptions at EchoLink (please google iconv for available encoding names)