This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
configuration:telephone-on-serial [2017/10/23 16:02] – fachet | configuration:telephone-on-serial [2017/10/23 16:35] – [SDK-Script] fachet | ||
---|---|---|---|
Line 76: | Line 76: | ||
- | /* DESC: This script can be used to write a message | + | /* DESC: This script can be used to write calling phone numbers |
- | * Copyright (C) 2017 NetModule AG, Switzerland | + | * CR/LF terminated |
+ | * | ||
+ | * Copyright (C) 2017 NetModule AG, Switzerland | ||
*/ | */ | ||
DEV = " | DEV = " | ||
- | + | /* open serial port */ | |
- | void usage() | + | fd = nb_serial_open(DEV); |
- | { | + | if (fd < 0) { |
- | | + | |
- | exit(1); | + | exit(2); |
} | } | ||
- | if (argc < 1) | ||
- | usage(); | ||
- | |||
- | |||
- | /* open serial port */ | ||
ret = nb_serial_setattr(DEV, | ret = nb_serial_setattr(DEV, | ||
if (ret != 0) { | if (ret != 0) { | ||
Line 99: | Line 96: | ||
exit(3); | exit(3); | ||
} | } | ||
- | fd = nb_serial_open(DEV); | + | |
- | if (fd < 0) { | + | |
- | nb_syslog(" | + | |
- | exit(4); | + | |
- | } | + | |
while (true) { | while (true) { | ||
- | msg = nb_voice_event(1).call.calling; | + | msg = nb_voice_event(1).call.calling; |
if (!is_void(msg)) { | if (!is_void(msg)) { | ||
msg = left(msg, strlen(msg) - 5); // trim phone number | msg = left(msg, strlen(msg) - 5); // trim phone number | ||
msg = right(msg, strlen(msg) - 6); | msg = right(msg, strlen(msg) - 6); | ||
msg = strcat(msg, " | msg = strcat(msg, " | ||
+ | len = strlen(msg); | ||
- | if (write(fd, msg, strlen(msg) < 0 ); | + | if (write(fd, msg, len) != len) { |
- | nb_syslog(" | + | nb_syslog(" |
close(fd); | close(fd); | ||
- | exit(5); | + | exit(4); |
} | } | ||
+ | } | ||
} | } | ||
/* not reached */ | /* not reached */ | ||
Line 123: | Line 118: | ||
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:// | 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:// | ||
- | With a loop and the SDK command, you get when a voice call comes in. | + | You can use the test window to see when a voice call comes in. |
- | + | ||
- | <code - voice_evenet.are > | + | |
- | + | ||
- | while(true) | + | |
- | { | + | |
- | dump(nb_voice_event(10)); | + | |
- | } | + | |
+ | < | ||
+ | dump(nb_voice_event(10)); | ||
</ | </ | ||
Line 137: | Line 127: | ||
< | < | ||
- | |||
- | void | ||
- | |||
struct(2): { | struct(2): { | ||
.call = struct(4): { | .call = struct(4): { | ||
Line 156: | Line 143: | ||
.state = string[6]: " | .state = string[6]: " | ||
} | } | ||
- | .type = string[6]: " | ||
} | } | ||