This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
configuration:telephone-on-serial [2017/10/18 12:08] – [The output of a telephone number on the serial interface] gray | configuration:telephone-on-serial [2021/11/15 17:48] (current) – schmitt | ||
---|---|---|---|
Line 7: | Line 7: | ||
===== Router License Generator ===== | ===== 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. If you need a license, you can get it via the support of netModule. | + | 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. |
- | {{: | + | {{: |
Line 22: | Line 22: | ||
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. | 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. | ||
- | {{: | + | {{: |
===== Voice Gateway ===== | ===== Voice Gateway ===== | ||
Line 28: | Line 28: | ||
Under the tab „Administration“, | Under the tab „Administration“, | ||
- | {{: | + | {{: |
Under the „Endpoints“ tab, select „Voice-over-Mobile“ under „Option Type“. Then the button „Apply“ can be pressed again. | Under the „Endpoints“ tab, select „Voice-over-Mobile“ under „Option Type“. Then the button „Apply“ can be pressed again. | ||
- | {{: | + | {{: |
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. | 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. | ||
- | {{: | + | {{: |
===== Create a new SDK job ===== | ===== Create a new SDK job ===== | ||
Line 42: | Line 42: | ||
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. | 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. | ||
- | {{: | + | {{: |
- | 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, „evebt-based“ is selected. The function „system-startuo“ is used as an event. | + | 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. |
- | {{: | + | {{: |
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. | 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. | ||
- | {{: | + | {{: |
Line 71: | Line 71: | ||
===== SDK-Script ===== | ===== SDK-Script ===== | ||
- | The SDK command | + | The SDK script |
- | With a loop and the SDK command, you get when a voice call comes in. | + | <code - serial-write.are > |
- | <code - voice_evenet.ads > | ||
- | while(true) | + | /* DESC: This script can be used to write calling phone numbers |
- | { | + | * CR/LF terminated to the serial port. |
- | dump(nb_voice_event(10)); | + | * |
- | } | + | * Copyright |
+ | */ | ||
+ | DEV = " | ||
+ | |||
+ | /* open serial port */ | ||
+ | fd = nb_serial_open(DEV); | ||
+ | if (fd < 0) { | ||
+ | nb_syslog(" | ||
+ | exit(2); | ||
+ | } | ||
+ | |||
+ | ret = nb_serial_setattr(DEV, | ||
+ | if (ret != 0) { | ||
+ | nb_syslog(" | ||
+ | exit(3); | ||
+ | } | ||
+ | |||
+ | |||
+ | while (true) { | ||
+ | msg = nb_voice_event(1).call.calling; | ||
+ | if (!is_void(msg)) { | ||
+ | msg = left(msg, strlen(msg) - 5); // trim phone number | ||
+ | msg = right(msg, strlen(msg) - 6); | ||
+ | msg = strcat(msg, " | ||
+ | len = strlen(msg); | ||
+ | |||
+ | if (write(fd, msg, len) != len) { | ||
+ | nb_syslog(" | ||
+ | close(fd); | ||
+ | exit(4); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | /* not reached */ | ||
</ | </ | ||
- | This structure | + | The SDK command „nb_voice_event“ makes it possible to query the status |
+ | |||
+ | You can use the test window to see when a voice call comes in. | ||
< | < | ||
+ | dump(nb_voice_event(10)); | ||
+ | </ | ||
- | void | + | This structure of output, with the number, status and type output. |
+ | < | ||
struct(2): { | struct(2): { | ||
.call = struct(4): { | .call = struct(4): { | ||
Line 106: | Line 143: | ||
.state = string[6]: " | .state = string[6]: " | ||
} | } | ||
- | .type = string[6]: " | ||
} | } | ||
Line 112: | Line 148: | ||
</ | </ | ||
- | |||
- | The SDK script „serial-write.are“ us extended for output of the call number on the serial interface. | ||
- | |||
- | <code - phone_number_on_serial_port.ads | ||
- | |||
- | |||
- | /* DESC: This script can be used to write a message to the serial port. | ||
- | * Copyright (C) 2017 NetModule AG, Switzerland | ||
- | */ | ||
- | |||
- | void usage() | ||
- | { | ||
- | printf(" | ||
- | exit(1); | ||
- | } | ||
- | |||
- | if (argc < 1) { | ||
- | usage(); | ||
- | } | ||
- | |||
- | DEV = " | ||
- | |||
- | while(true) | ||
- | { | ||
- | |||
- | MSG = nb_voice_event(1).call.calling; | ||
- | |||
- | if ( !is_void(MSG)) | ||
- | { | ||
- | |||
- | MSG = left(MSG, | ||
- | MSG = right(MSG, | ||
- | |||
- | /* check serial port config */ | ||
- | st = nb_config_get(" | ||
- | if (st != " | ||
- | printf(" | ||
- | exit(1); | ||
- | } | ||
- | |||
- | ret = nb_serial_setattr(DEV, | ||
- | if (ret != 0) { | ||
- | | ||
- | | ||
- | } | ||
- | |||
- | fd = nb_serial_open(DEV); | ||
- | if (fd < 0) { | ||
- | | ||
- | | ||
- | } | ||
- | |||
- | | ||
- | ret = write(fd, message, strlen(message)); | ||
- | if (ret> 0) { | ||
- | | ||
- | } else { | ||
- | | ||
- | } | ||
- | | ||
- | |||
- | } | ||
- | } | ||
- | |||
- | exit(0); | ||
- | |||
- | </ | ||
- | |||