|
63 | 63 | <description>
|
64 | 64 | <para>Line number of SMDR channel as configured on the WHOZZ Calling? device.</para>
|
65 | 65 | <para>Three-way calling is not supported. Please note that WHOZZ Calling? devices do not themselves support pulse dialing.</para>
|
| 66 | + <para>Note that if you wish to log unanswered incoming calls (outgoing calls are always assumed to be answered by the WHOZZ Calling |
| 67 | + unit), you need to set <literal>unanswered = yes</literal> in <literal>cdr.conf</literal>.</para> |
66 | 68 | </description>
|
67 | 69 | </configOption>
|
68 | 70 | <configOption name="device">
|
@@ -133,6 +135,7 @@ struct whozz_line {
|
133 | 135 | int lineno; /*!< Line number on WHOZZ Calling? system */
|
134 | 136 | struct ast_channel *chan; /*!< Dummy channel for CDR */
|
135 | 137 | const char *device; /*!< Asterisk device */
|
| 138 | + unsigned int detect_dialing:1; /*!< Whether to detect dialing in Asterisk, instead of relying on the WHOZZ Calling hardware */ |
136 | 139 | enum line_state state; /*!< Current line state */
|
137 | 140 | enum ast_device_state startstate; /*!< Starting device state of associated FXO device, if applicable */
|
138 | 141 | enum ast_device_state answerstate; /*!< Device state of associated FXO device, if applicable, at time of off-hook on incoming call */
|
@@ -283,25 +286,33 @@ static int serial_sync(struct pollfd *pfd)
|
283 | 286 | return 0;
|
284 | 287 | }
|
285 | 288 |
|
286 |
| -static int set_settings(struct pollfd *pfd) |
| 289 | +static int set_settings(struct pollfd *pfd, int reset) |
287 | 290 | {
|
288 | 291 | struct timeval when;
|
289 | 292 | struct ast_tm tm;
|
290 | 293 | ssize_t bufres;
|
291 | 294 | char buf[64];
|
292 |
| - |
293 |
| - SERIAL_WRITE("V", 1); |
294 |
| - SERIAL_READ_STRING(buf, sizeof(buf), 1); |
| 295 | + char ch; |
295 | 296 |
|
296 | 297 | /* Must wait at least 50 ms between setting each setting to non-volatile memory */
|
297 | 298 | #define SET_SETTING_DELAY 50000
|
298 | 299 |
|
299 | 300 | #define SET_SETTING(c) \
|
300 | 301 | if (!strchr(buf, c)) { \
|
301 | 302 | ast_verb(5, "Setting WHOZZ Calling? register '%c'\n", c); \
|
| 303 | + ch = c; \ |
| 304 | + SERIAL_WRITE(&ch, 1); \ |
302 | 305 | usleep(SET_SETTING_DELAY); \
|
303 | 306 | }
|
304 | 307 |
|
| 308 | + if (reset) { |
| 309 | + buf[0] = '\0'; |
| 310 | + SET_SETTING('R'); |
| 311 | + } |
| 312 | + |
| 313 | + SERIAL_WRITE("V", 1); |
| 314 | + SERIAL_READ_STRING(buf, sizeof(buf), 1); |
| 315 | + |
305 | 316 | SET_SETTING('E'); /* Echo off */
|
306 | 317 | SET_SETTING('c'); /* Remove dashes from phone number, leading $ */
|
307 | 318 | SET_SETTING('X'); /* Duration and checksum */
|
@@ -490,10 +501,12 @@ static int handle_hook(struct whozz_line *w, int outbound, int end, int duration
|
490 | 501 | /* Substitute if needed */
|
491 | 502 | pbx_substitute_variables_helper(w->chan, varval, subbuf, sizeof(subbuf) - 1);
|
492 | 503 | /* Replace or add variable */
|
| 504 | + ast_debug(8, "Setting variable %s=%s\n", varkey, subbuf); |
493 | 505 | pbx_builtin_setvar_helper(w->chan, varkey, subbuf);
|
494 | 506 | }
|
495 | 507 |
|
496 | 508 | ast_channel_hangupcause_set(w->chan, AST_CAUSE_NORMAL);
|
| 509 | + ast_debug(5, "Finalized CDR for channel %s\n", ast_channel_name(w->chan)); |
497 | 510 | ast_hangup(w->chan); /* Kill the channel and force the CDR to be processed, with variable substitution */
|
498 | 511 | w->chan = NULL;
|
499 | 512 | } else {
|
@@ -892,7 +905,7 @@ static int serial_monitor(void *varg)
|
892 | 905 | }
|
893 | 906 | }
|
894 | 907 |
|
895 |
| - if (set_settings(&pfd)) { |
| 908 | + if (set_settings(&pfd, 0)) { |
896 | 909 | ast_log(LOG_ERROR, "Failed to initialize device with SMDR settings\n");
|
897 | 910 | return -1;
|
898 | 911 | }
|
@@ -946,7 +959,7 @@ static struct ast_custom_function acf_whozz = {
|
946 | 959 | .read = whozz_line_state_read,
|
947 | 960 | };
|
948 | 961 |
|
949 |
| -static char *handle_show_whozz(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| 962 | +static char *handle_show_lines(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
950 | 963 | {
|
951 | 964 | struct whozz_line *w;
|
952 | 965 |
|
@@ -975,8 +988,39 @@ static char *handle_show_whozz(struct ast_cli_entry *e, int cmd, struct ast_cli_
|
975 | 988 | return CLI_SUCCESS;
|
976 | 989 | }
|
977 | 990 |
|
| 991 | +static char *handle_reset(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| 992 | +{ |
| 993 | + struct pollfd pfd; |
| 994 | + |
| 995 | + switch (cmd) { |
| 996 | + case CLI_INIT: |
| 997 | + e->command = "whozz reset"; |
| 998 | + e->usage = |
| 999 | + "Usage: whozz reset\n" |
| 1000 | + " Reset and reinitialize the connected unit.\n"; |
| 1001 | + return NULL; |
| 1002 | + case CLI_GENERATE: |
| 1003 | + return NULL; |
| 1004 | + } |
| 1005 | + if (a->argc != 2) { |
| 1006 | + return CLI_SHOWUSAGE; |
| 1007 | + } |
| 1008 | + |
| 1009 | + memset(&pfd, 0, sizeof(pfd)); |
| 1010 | + pfd.fd = serial_fd; |
| 1011 | + pfd.events = POLLIN | POLLERR | POLLNVAL | POLLHUP; |
| 1012 | + |
| 1013 | + if (set_settings(&pfd, 1)) { |
| 1014 | + ast_cli(a->fd, "Failed to reinitialize device with SMDR settings\n"); |
| 1015 | + return CLI_FAILURE; |
| 1016 | + } |
| 1017 | + |
| 1018 | + return CLI_SUCCESS; |
| 1019 | +} |
| 1020 | + |
978 | 1021 | static struct ast_cli_entry whozz_cli[] = {
|
979 |
| - AST_CLI_DEFINE(handle_show_whozz, "List WHOZZ Calling lines"), |
| 1022 | + AST_CLI_DEFINE(handle_show_lines, "List WHOZZ Calling lines"), |
| 1023 | + AST_CLI_DEFINE(handle_reset, "Reset and reinitialize the connected unit"), |
980 | 1024 | };
|
981 | 1025 |
|
982 | 1026 | static int load_config(void)
|
|
0 commit comments