FreeCalypso > hg > themwi-system-sw
changeset 159:c8e9b295e88f
mtctest: add time reporting for DTMF events
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 12 Oct 2022 12:11:06 -0800 |
parents | 51cf5ea7f320 |
children | 4b35a5a400f1 |
files | mtctest/main.c mtctest/sig_handler.c |
diffstat | 2 files changed, 29 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mtctest/main.c Wed Oct 12 08:45:39 2022 -0800 +++ b/mtctest/main.c Wed Oct 12 12:11:06 2022 -0800 @@ -3,6 +3,7 @@ */ #include <sys/types.h> +#include <sys/time.h> #include <sys/errno.h> #include <stdio.h> #include <stdint.h> @@ -13,6 +14,8 @@ extern int mtc_socket; extern int disconnect_mode; +struct timeval cur_event_time; + static void drain_stdin() { @@ -64,6 +67,7 @@ perror("select"); exit(1); } + gettimeofday(&cur_event_time, 0); if (FD_ISSET(mtc_socket, &fds)) mtc_socket_select(); if (!disconnect_mode && FD_ISSET(0, &fds)) {
--- a/mtctest/sig_handler.c Wed Oct 12 08:45:39 2022 -0800 +++ b/mtctest/sig_handler.c Wed Oct 12 12:11:06 2022 -0800 @@ -5,6 +5,7 @@ */ #include <sys/types.h> +#include <sys/time.h> #include <sys/socket.h> #include <stdio.h> #include <stdint.h> @@ -16,6 +17,7 @@ extern int disconnect_mode; extern struct sockaddr_storage dummy_rtp_endp; +extern struct timeval cur_event_time; static void print_bearer_cap(bcap) @@ -180,6 +182,27 @@ } static void +handle_dtmf_time() +{ + static struct timeval last_dtmf_time; + struct timeval delta; + unsigned ms; + + if (timerisset(&last_dtmf_time) && + timercmp(&cur_event_time, &last_dtmf_time, >)) { + timersub(&cur_event_time, &last_dtmf_time, &delta); + if (delta.tv_sec >= 2) + printf("Time since last DTMF event: %u s\n", + (unsigned) delta.tv_sec); + else { + ms = delta.tv_sec * 1000 + delta.tv_usec / 1000; + printf("Time since last DTMF event: %u ms\n", ms); + } + } + bcopy(&cur_event_time, &last_dtmf_time, sizeof(struct timeval)); +} + +static void handle_signaling_msg(msg, msglen) struct gsm_mncc *msg; unsigned msglen; @@ -230,6 +253,7 @@ case MNCC_START_DTMF_IND: printf("MNCC_START_DTMF_IND: MS sending DTMF start\n"); print_fields(msg); + handle_dtmf_time(); if (msg->fields & MNCC_F_KEYPAD && is_valid_dtmf_digit(msg->keypad)) { printf("Responding with ACK\n"); @@ -244,6 +268,7 @@ return; case MNCC_STOP_DTMF_IND: printf("MNCC_STOP_DTMF_IND: MS sending DTMF stop\n"); + handle_dtmf_time(); msg->msg_type = MNCC_STOP_DTMF_RSP; send_mncc_to_gsm(msg, sizeof(struct gsm_mncc)); return;