From 442186050c45050fd8894ce9911bfe176a11a4fe Mon Sep 17 00:00:00 2001 From: MelwareDE Date: Sat, 20 Oct 2007 08:22:53 +0000 Subject: [PATCH] PR#15: Send DATE/TIME to device on CONNECT when in NT-mode. --- CHANGES | 1 + README | 1 + chan_capi.c | 42 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 272b42d..252ad2c 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,7 @@ CHANGES HEAD ------------------ +- send local DATE/TIME with CONNECT when in NT-mode. - added transfergroup config option to set controllers allowed for transfer. chan_capi-1.0.2 diff --git a/README b/README index 68bb193..9ea395f 100644 --- a/README +++ b/README @@ -69,6 +69,7 @@ This chan_capi version includes: - CCBS (call completion on busy subscriber) - CAPI CHAT (CAPI MeetMe using onboard DSPs) - KEYPAD digits detection +- provide DATE/TIME in NT-mode. The Dial string diff --git a/chan_capi.c b/chan_capi.c index 5f9d45b..306309f 100644 --- a/chan_capi.c +++ b/chan_capi.c @@ -474,6 +474,42 @@ static void capi_channel_task(struct ast_channel *c, int task) c->name, task); } +/* + * Added date/time IE to facility structure + */ +static void capi_facility_add_datetime(unsigned char *facilityarray) +{ + unsigned int idx; + time_t current_time; + struct tm *time_local; + unsigned char year; + + if (!facilityarray) + return; + + current_time = time(NULL); + time_local = localtime(¤t_time); + year = time_local->tm_year; + + while (year > 99) { + year -= 100; + } + + idx = facilityarray[0] + 1; + + facilityarray[idx++] = 0x29; /* date/time IE */ + facilityarray[idx++] = 5; /* length */ + facilityarray[idx++] = year; + facilityarray[idx++] = time_local->tm_mon + 1; + facilityarray[idx++] = time_local->tm_mday; + facilityarray[idx++] = time_local->tm_hour; + facilityarray[idx++] = time_local->tm_min; + + facilityarray[0] = idx - 1; + + return; +} + /* * Echo cancellation is for cards w/ integrated echo cancellation only * (i.e. Eicon active cards support it) @@ -1385,6 +1421,11 @@ static int capi_send_answer(struct ast_channel *c, _cstruct b3conf) facilityarray = alloca(CAPI_MAX_FACILITYDATAARRAY_SIZE); cc_qsig_add_call_answer_data(facilityarray, i, c); + if (i->ntmode) { + /* in NT-mode we send the current local time to device */ + capi_facility_add_datetime(facilityarray); + } + if (capi_sendf(NULL, 0, CAPI_CONNECT_RESP, i->PLCI, i->MessageNumber, "w(wwwssss)s()()(()()()s())", 0, /* accept call */ @@ -2792,7 +2833,6 @@ static void capidev_handle_info_indication(_cmsg *CMSG, unsigned int PLCI, unsig INFO_IND_INFOELEMENT(CMSG)[1], INFO_IND_INFOELEMENT(CMSG)[2], INFO_IND_INFOELEMENT(CMSG)[3], INFO_IND_INFOELEMENT(CMSG)[4], INFO_IND_INFOELEMENT(CMSG)[5]); - capidev_sendback_info(i, CMSG); break; case 0x002c: /* Keypad facility */ cc_verbose(3, 1, VERBOSE_PREFIX_3 "%s: info element KEYPAD FACILITY\n",