[asterisk-addons-commits] dcb: trunk r477 - in /trunk: chan_mobile.c configure

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Sat Oct 27 01:04:23 CDT 2007


Author: dcb
Date: Sat Oct 27 01:04:23 2007
New Revision: 477

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=477
Log:
Changes to call hangup logic

Modified:
    trunk/chan_mobile.c
    trunk/configure

Modified: trunk/chan_mobile.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/chan_mobile.c?view=diff&rev=477&r1=476&r2=477
==============================================================================
--- trunk/chan_mobile.c (original)
+++ trunk/chan_mobile.c Sat Oct 27 01:04:23 2007
@@ -160,6 +160,7 @@
 	unsigned int sent_answer:1;
 	unsigned int do_alignment_detection:1;
 	unsigned int alignment_detection_triggered:1;
+	unsigned int do_hangup:1;
 	short alignment_samples[4];
 	int alignment_count;
 	char sms_txt[160];
@@ -182,11 +183,6 @@
 	AST_CLI_DEFINE(handle_cli_mobile_show_devices, "Show Bluetooth Cell / Mobile devices"),
 	AST_CLI_DEFINE(handle_cli_mobile_search,       "Search for Bluetooth Cell / Mobile devices"),
 	AST_CLI_DEFINE(handle_cli_mobile_rfcomm,       "Send commands to the rfcomm port for debugging"),
-/*
-	{{"mobile", "show", "devices", NULL}, do_show_devices, "Show Bluetooth Cell / Mobile devices", show_usage},
-	{{"mobile", "search", NULL}, do_search_devices, "Search for Bluetooth Cell / Mobile devices", search_usage},
-	{{"mobile", "rfcomm", NULL}, do_send_rfcomm, "Send commands to the rfcomm port for debugging", rfcomm_usage},
-*/
 };
 
 /* App stuff */
@@ -534,7 +530,7 @@
 		pvt->do_alignment_detection = 1;
 	else
 		pvt->do_alignment_detection = 0;
-		
+	pvt->do_hangup = 1;
 	chn = ast_channel_alloc(1, state, cid_num, pvt->id, 0, 0, pvt->context, 0, "Mobile/%s-%04lx", pvt->id, ast_random() & 0xffff);
 	if (chn) {
 		chn->tech = &mbl_tech;
@@ -670,6 +666,7 @@
 
 	ast_debug(1, "Hanging up device %s.\n", pvt->id);
 
+	ast_channel_set_fd(ast, 0, -1);
 	close(pvt->io_pipe[0]);
 	close(pvt->io_pipe[1]);
 
@@ -679,7 +676,9 @@
 	}
 
 	if ((pvt->state == MBL_STATE_INCOMING || pvt->state == MBL_STATE_OUTGOING || pvt->state == MBL_STATE_DIAL1 || pvt->state == MBL_STATE_RING3) && pvt->type == MBL_TYPE_PHONE) {
-		rfcomm_write(pvt, "AT+CHUP\r");
+		if (pvt->do_hangup) {
+			rfcomm_write(pvt, "AT+CHUP\r");
+		}
 		pvt->state = MBL_STATE_HANGUP;
 		pvt->hangup_count = 0;
 	} else
@@ -762,6 +761,8 @@
 	struct ast_frame *f;
 	int r;
 
+	ast_debug(2, "*** mbl_read()\n");
+
 	if (!pvt->owner) {
 		return &ast_null_frame;
 	}
@@ -804,13 +805,9 @@
 	int i, r, io_need, num_frames;
 	char *pfr, buf[DEVICE_FRAME_SIZE];
 
+	ast_debug(2, "*** mbl_write\n");
+
 	if (frame->frametype != AST_FRAME_VOICE) {
-		return 0;
-	}
-	if (ast->_state != AST_STATE_UP) {
-		return 0;
-	}
-	if (pvt->state == MBL_STATE_HANGUP) {
 		return 0;
 	}
 
@@ -1138,7 +1135,7 @@
 
 	r = write(s, buf, len);
 	if (r == -1) {
-		ast_debug(1, "sco write error %d\n", errno);
+		ast_debug(2, "sco write error %d\n", errno);
 		return 0;
 	}
 		
@@ -1160,7 +1157,7 @@
 
 	r = read(s, buf, len);
 	if (r == -1) {
-		ast_debug(1, "sco_read() error %d\n", errno);
+		ast_debug(2, "sco_read() error %d\n", errno);
 		return 0;
 	}
 
@@ -1442,6 +1439,7 @@
 			case MBL_STATE_OUTGOING:
 				if (strstr(buf, "+CIEV")) {
 					if (strstr(buf, pvt->ciev_call_0)) { 				/* call was hung up */
+						pvt->do_hangup = 0;
 						ast_queue_control(pvt->owner, AST_CONTROL_HANGUP);
 					} else if (strstr(buf, pvt->ciev_callsetup_3)) { 		/* b-party ringing */
 						ast_queue_control(pvt->owner, AST_CONTROL_RINGING);
@@ -1507,6 +1505,7 @@
 			case MBL_STATE_INCOMING:
 				if (strstr(buf, "+CIEV")) {
 					if (strstr(buf, pvt->ciev_call_0)) {
+						pvt->do_hangup = 0;
 						ast_queue_control(pvt->owner, AST_CONTROL_HANGUP);
 					}
 				}
@@ -1595,12 +1594,15 @@
 			} else if (pvt->state == MBL_STATE_RING) { /* No CLIP?, bump it */
 				pvt->state = MBL_STATE_RING2;
 			} else if (pvt->state == MBL_STATE_HANGUP) {
-				if (pvt->hangup_count == 6) {
-					ast_debug(1, "Device %s failed to hangup after 6 tries, disconnecting.\n", pvt->id);
-					monitor = 0;
-				}
-				rfcomm_write(pvt, "AT+CHUP\r");
-				pvt->hangup_count++;
+				if (pvt->do_hangup) {
+					if (pvt->hangup_count == 6) {
+						ast_debug(1, "Device %s failed to hangup after 6 tries, disconnecting.\n", pvt->id);
+						monitor = 0;
+					}
+					rfcomm_write(pvt, "AT+CHUP\r");
+					pvt->hangup_count++;
+				} else
+					pvt->state = MBL_STATE_IDLE;
 			} else if (pvt->state == MBL_STATE_OUTSMS) {
 				sprintf(buf, "AT+CMGS=\"%s\"\r", pvt->dial_number);
 				rfcomm_write(pvt, buf);

Modified: trunk/configure
URL: http://svn.digium.com/view/asterisk-addons/trunk/configure?view=diff&rev=477&r1=476&r2=477
==============================================================================
--- trunk/configure (original)
+++ trunk/configure Sat Oct 27 01:04:23 2007
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 384 .
+# From configure.ac Revision: 455 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61.
 #




More information about the asterisk-addons-commits mailing list