[asterisk-addons-commits] mnicholson: branch mnicholson/chan-mobile-refactor r771 - /team/mnicholson/ch...

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Wed Feb 11 11:44:07 CST 2009


Author: mnicholson
Date: Wed Feb 11 11:44:07 2009
New Revision: 771

URL: http://svn.digium.com/svn-view/asterisk-addons?view=rev&rev=771
Log:
simplify do_monitor_phone() loop by removing monitor variable

Modified:
    team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c

Modified: team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c
URL: http://svn.digium.com/svn-view/asterisk-addons/team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c?view=diff&rev=771&r1=770&r2=771
==============================================================================
--- team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c (original)
+++ team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c Wed Feb 11 11:44:07 2009
@@ -2194,7 +2194,6 @@
 	struct mbl_pvt *pvt = (struct mbl_pvt *)data;
 	struct hfp_pvt *hfp = pvt->hfp;
 	struct ast_channel *chn;
-	char monitor = 1;
 	char buf[256];
 	char cid_num[AST_MAX_EXTENSION], *pcids, *pcide;
 	int t, i, smsi;
@@ -2209,12 +2208,12 @@
 
 	if (hfp_init(hfp)) {
 		ast_verb(3, "Error initializing Bluetooth device %s.\n", pvt->id);
-		monitor = 0;
+		goto e_cleanup;
 	} else {
 		pvt->state = MBL_STATE_PREIDLE;
 	}
 
-	while (monitor) {
+	for (;;) {
 
 		if (pvt->state == MBL_STATE_DIAL1)
 			t = pvt->dial_timeout * 1000;
@@ -2234,8 +2233,7 @@
 				else
 					ast_debug(1, "[%s] error reading from device: %s (%d)\n", pvt->id, buf, errno); 
 
-				monitor = 0;
-				continue;
+				break;
 			}
 			ast_debug(1, "[%s] %s\n", pvt->id, buf);
 
@@ -2296,7 +2294,7 @@
 					p += 5;
 					if (*(p+(callp*2)) == '1') {
 						ast_verb(3, "Bluetooth Device %s has a call in progress - delaying connection.\n", pvt->id);
-						monitor = 0;
+						break;
 					}
 				} else if (strstr(buf, "OK")) {
 					if (pvt->blackberry) {
@@ -2361,8 +2359,8 @@
 					 * handset we disconnect now, as he is
 					 * probably leaving BT range...
 					 */
-					monitor = 0;	
 					ast_verb(3, "Disconnecting bluetooth device %s, user has initated a call from the handset.\n", pvt->id); 
+					break;
 				}
 				break;
 			case MBL_STATE_DIAL: /* Nothing handled here, we need to wait for a timeout */
@@ -2560,7 +2558,7 @@
 				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;
+						break;
 					}
 					rfcomm_write(pvt->rfcomm_socket, "AT+CHUP\r");
 					pvt->hangup_count++;
@@ -2586,6 +2584,8 @@
 		}
 	}
 
+e_cleanup:
+
 	if (pvt->rfcomm_socket > -1)
 		close(pvt->rfcomm_socket);
 	if (pvt->sco_socket > -1)




More information about the asterisk-addons-commits mailing list