This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
configuration:telephone-on-serial [2017/10/18 12:10] – [SDK-Script] gray | configuration:telephone-on-serial [2017/10/23 16:02] – fachet | ||
---|---|---|---|
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 44: | Line 44: | ||
{{: | {{: | ||
- | 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. |
{{: | {{: | ||
Line 73: | Line 73: | ||
The SDK script „serial-write.are“ us extended for output of the call number on the serial interface. | The SDK script „serial-write.are“ us extended for output of the call number on the serial interface. | ||
- | + | <code - serial-write.are > | |
- | <code - phone_number_on_serial_port.ads > | + | |
Line 80: | Line 79: | ||
* Copyright (C) 2017 NetModule AG, Switzerland | * Copyright (C) 2017 NetModule AG, Switzerland | ||
*/ | */ | ||
+ | |||
+ | DEV = " | ||
+ | |||
void usage() | void usage() | ||
{ | { | ||
- | | + | |
- | exit(1); | + | exit(1); |
} | } | ||
- | if (argc < 1) { | + | if (argc < 1) |
- | usage(); | + | usage(); |
+ | |||
+ | |||
+ | /* open serial port */ | ||
+ | ret = nb_serial_setattr(DEV, | ||
+ | if (ret != 0) { | ||
+ | nb_syslog(" | ||
+ | exit(3); | ||
+ | } | ||
+ | fd = nb_serial_open(DEV); | ||
+ | if (fd < 0) { | ||
+ | nb_syslog(" | ||
+ | exit(4); | ||
} | } | ||
- | DEV = "SERIAL1"; | + | 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, | ||
- | while(true) | + | if (write(fd, |
- | { | + | nb_syslog("Error on writing |
- | + | close(fd); | |
- | MSG = nb_voice_event(1).call.calling; | + | exit(5); |
- | + | } | |
- | 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, | + | |
- | if (ret> 0) { | + | |
- | | + | |
- | } else { | + | |
- | | + | |
- | } | + | |
- | close(fd); | + | |
- | + | ||
- | } | + | |
} | } | ||
- | + | /* not reached */ | |
- | exit(0); | + | |
</ | </ | ||
- | The SDK command „nb_voice_event“ makes it possible to query the status of the voice call. At the address of the router | + | 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 |
With a loop and the SDK command, you get when a voice call comes in. | With a loop and the SDK command, you get when a voice call comes in. | ||
- | <code - voice_evenet.ads > | + | <code - voice_evenet.are > |
while(true) | while(true) |