====== The output of a telephone number on the serial interface ======
An incoming call is to be recorded using a SDK script on then output on the serial interface.
To capture the call, we can use the SDK command „nb_voice_event“ and output the result via the SDK script „serial-write.are“ on the serial interface.
===== Router License Generator =====
The voice gateway function must have a license in order to use it. Unter the „SYSTEM“ sub-item „Licensing“ you can see your existing licenses.
{{:configuration:license_ueberblick.png?direct&900|}}
===== Integrate into the router =====
The voice key can now be integrated into the router. This can be done again under the tab „SYSTEM“ under „Licensing“.
{{:configuration:voicekey_5.png?direct&900|}}
The „Upload license file“ option allows you to select the created key. Important is the name of the filekey is equal to the serial of the router. With the button „install“ the license is integrated into the router. Now the sub-point „Voice Gateway“ must be present in the „SERVICES“ tab.
{{:configuration:sdk_administration.png?direct&900|}}
===== Voice Gateway =====
Under the tab „Administration“, the admin is released and the SDK is selected under the option „Call Routing“. Now the button „Apply““ can be pressed.
{{:configuration:voicegateway_administration.png?direct&900|}}
Under the „Endpoints“ tab, select „Voice-over-Mobile“ under „Option Type“. Then the button „Apply“ can be pressed again.
{{:configuration:voice_gateway_endpunkt.png?direct&900|}}
The SDK option must be selected under the „INTERFACES“ tab to ensure that the output generated by the SDK can be output on the serial.
{{:configuration:seriell_admin.png?direct&900|}}
===== Create a new SDK job =====
For this, we create a new job under the „SERVICES“ tab in the SDK sub-section of the „Job Management“. Under the „Scripts“ option , we must first assign a name. Under the option „Action“ we can insert the script file via the „upload“. We can confirm this with the „Apply“ button.
{{:configuration:jobmanagement_skripts.png?direct&900|}}
Next, we need to set the trigger for the script under the „Triggers“ option. Here again a name must be assigned for the function. Under the Type option, „event-based“ is selected. The function „system-startup“ is used as an event.
{{:configuration:jobmanagement_triggers.png?direct&900|}}
As a now option, the job can now be set up. Again, we needed a name. The name for „Trigger“ and „Script“ are the ones we have set up before.
{{:configuration:jobmanagement_jobs.png?direct&900|}}
Press the „Apply“ button to confirm the setting.
If one now the rout calls one gets on the serial interface the telephone number of the caller output.
Willkommen zu minicom 2.7
Optionen: I18n
Übersetzt am Apr 22 2017, 09:14:19.
Port /dev/ttyUSB0, 18:40:05
Drücken Sie CTRL-A Z für Hilfe zu speziellen Tasten
+4917012345678
===== SDK-Script =====
The SDK script „serial-write.are“ us extended for output of the call number on the serial interface.
/* DESC: This script can be used to write calling phone numbers
* CR/LF terminated to the serial port.
*
* Copyright (C) 2017 NetModule AG, Switzerland (arg)
*/
DEV = "SERIAL1";
/* open serial port */
fd = nb_serial_open(DEV);
if (fd < 0) {
nb_syslog("Unable to open %s", DEV);
exit(2);
}
ret = nb_serial_setattr(DEV, 115200, 8, 1, 0, 0);
if (ret != 0) {
nb_syslog("Could not set serial attributes on %s return code %i", DEV, ret);
exit(3);
}
while (true) {
msg = nb_voice_event(1).call.calling; // check event with 1sec timeout
if (!is_void(msg)) {
msg = left(msg, strlen(msg) - 5); // trim phone number
msg = right(msg, strlen(msg) - 6);
msg = strcat(msg, "\r\n");
len = strlen(msg);
if (write(fd, msg, len) != len) {
nb_syslog("Error on writing %d bytes to %s", len, DEV);
close(fd);
exit(4);
}
}
}
/* not reached */
The SDK command „nb_voice_event“ makes it possible to query the status of the voice call. For more information about the SDK-API, see please to the Weblink http://wiki.netmodule.com/documentation/start under the item Products under one of the router's model you have.
You can use the test window to see when a voice call comes in.
dump(nb_voice_event(10)); // wait 10secs for call
This structure of output, with the number, status and type output.
struct(2): {
.call = struct(4): {
.id = int: 577568803
.called = string[0]: ""
.calling = string[25]: "vom://+4917012345678@Vom1"
.state = string[7]: "routing"
}
.type = string[8]: "incoming"
}
struct(2): {
.call = struct(4): {
.id = int: 577568803
.called = string[0]: ""
.calling = string[25]: "vom://+4917012345678@Vom1"
.state = string[6]: "hungup"
}
}
void