From 3234f987d6bb58a8424399eea7271e7098e3b372 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 15 Jun 2007 04:20:45 +0000 Subject: [PATCH] wtf git-svn-id: http://svn.openzap.org/svn/openzap/trunk@259 a93c3328-9c30-0410-af19-c9cd2b2d52af --- libs/openzap/src/zap_wanpipe.c | 64 +++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/libs/openzap/src/zap_wanpipe.c b/libs/openzap/src/zap_wanpipe.c index 1ac08b40f6..01a3f469d9 100644 --- a/libs/openzap/src/zap_wanpipe.c +++ b/libs/openzap/src/zap_wanpipe.c @@ -355,17 +355,15 @@ static unsigned wp_open_range(zap_span_t *span, unsigned spanno, unsigned start, wanpipe_tdm_api_t tdm_api; tdm_api.wp_tdm_cmd.cmd = SIOC_WP_TDM_SET_EVENT; - tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type = WP_TDMAPI_EVENT_RXHOOK; + tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type = WP_TDMAPI_EVENT_RING_DETECT; + tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_mode = WP_TDMAPI_EVENT_ENABLE; + wp_tdm_cmd_exec(chan, &tdm_api); +#if 0 + tdm_api.wp_tdm_cmd.cmd=SIOC_WP_TDM_SET_EVENT; + tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type = WP_TDMAPI_EVENT_TXSIG_KEWL; tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_mode = WP_TDMAPI_EVENT_ENABLE; wp_tdm_cmd_exec(chan, &tdm_api); -#if 0 - if (type == ZAP_CHAN_TYPE_FXS) { - tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type = WP_TDMAPI_EVENT_RING; - tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_mode = WP_TDMAPI_EVENT_ENABLE; - wp_tdm_cmd_exec(chan, &tdm_api); - } #endif - tdm_api.wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_HW_CODING; wp_tdm_cmd_exec(chan, &tdm_api); if (tdm_api.wp_tdm_cmd.hw_tdm_coding) { @@ -526,10 +524,58 @@ static ZIO_COMMAND_FUNCTION(wanpipe_command) memset(&tdm_api, 0, sizeof(tdm_api)); switch(command) { + case ZAP_COMMAND_OFFHOOK: + { + tdm_api.wp_tdm_cmd.cmd=SIOC_WP_TDM_SET_EVENT; + tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type = WP_TDMAPI_EVENT_TXSIG_OFFHOOK; + tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_mode = WP_TDMAPI_EVENT_ENABLE; + if ((err = wp_tdm_cmd_exec(zchan, &tdm_api))) { + snprintf(zchan->last_error, sizeof(zchan->last_error), "OFFHOOK Failed"); + return ZAP_FAIL; + } + zap_set_flag_locked(zchan, ZAP_CHANNEL_OFFHOOK); + } + break; + case ZAP_COMMAND_ONHOOK: + { + tdm_api.wp_tdm_cmd.cmd=SIOC_WP_TDM_SET_EVENT; + tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type = WP_TDMAPI_EVENT_TXSIG_OFFHOOK; + tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_mode=WP_TDMAPI_EVENT_DISABLE; + if ((err = wp_tdm_cmd_exec(zchan, &tdm_api))) { + snprintf(zchan->last_error, sizeof(zchan->last_error), "ONHOOK Failed"); + return ZAP_FAIL; + } + zap_clear_flag_locked(zchan, ZAP_CHANNEL_OFFHOOK); + } + break; + case ZAP_COMMAND_GENERATE_RING_ON: + { + tdm_api.wp_tdm_cmd.cmd=SIOC_WP_TDM_SET_EVENT; + tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type = WP_TDMAPI_EVENT_RING; + tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_mode = WP_TDMAPI_EVENT_ENABLE; + if ((err = wp_tdm_cmd_exec(zchan, &tdm_api))) { + snprintf(zchan->last_error, sizeof(zchan->last_error), "Ring Failed"); + return ZAP_FAIL; + } + zap_set_flag_locked(zchan, ZAP_CHANNEL_RINGING); + } + break; + case ZAP_COMMAND_GENERATE_RING_OFF: + { + tdm_api.wp_tdm_cmd.cmd=SIOC_WP_TDM_SET_EVENT; + tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_type = WP_TDMAPI_EVENT_RING; + tdm_api.wp_tdm_cmd.event.wp_tdm_api_event_mode=WP_TDMAPI_EVENT_ENABLE; + if ((err = wp_tdm_cmd_exec(zchan, &tdm_api))) { + snprintf(zchan->last_error, sizeof(zchan->last_error), "Ring-off Failed"); + return ZAP_FAIL; + } + zap_clear_flag_locked(zchan, ZAP_CHANNEL_RINGING); + } + break; case ZAP_COMMAND_GET_INTERVAL: { tdm_api.wp_tdm_cmd.cmd = SIOC_WP_TDM_GET_USR_PERIOD; - + if (!(err = wp_tdm_cmd_exec(zchan, &tdm_api))) { ZAP_COMMAND_OBJ_INT = tdm_api.wp_tdm_cmd.usr_period; }