[asterisk-addons-commits] murf: trunk r412 - /trunk/chan_mobile.c

SVN commits to the Asterisk addons project asterisk-addons-commits at lists.digium.com
Mon Jul 16 12:54:58 CDT 2007


Author: murf
Date: Mon Jul 16 12:54:58 2007
New Revision: 412

URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=412
Log:
Added some informational messages, esp. about SMS, so you can tell WHY sms is not working.

Modified:
    trunk/chan_mobile.c

Modified: trunk/chan_mobile.c
URL: http://svn.digium.com/view/asterisk-addons/trunk/chan_mobile.c?view=diff&rev=412&r1=411&r2=412
==============================================================================
--- trunk/chan_mobile.c (original)
+++ trunk/chan_mobile.c Mon Jul 16 12:54:58 2007
@@ -365,27 +365,46 @@
 		dest = strsep(&args, "|");
 		if (dest && (dest[0] != 0x00)) {
 			message = args;
-			if (!message || (message[0] == 0x00))
+			if (!message || (message[0] == 0x00)) {
+				ast_log(LOG_ERROR,"NULL Message to be sent-- SMS will not be sent.\n");
 				return -1;
-		} else
+			}
+		} else {
+			ast_log(LOG_ERROR,"NULL destination for message -- SMS will not be sent.\n");
 			return -1;
-	} else
+		}
+		
+	} else {
+		ast_log(LOG_ERROR,"NULL device for message -- SMS will not be sent.\n");
 		return -1;
+	}
+	
 
 	AST_LIST_TRAVERSE(&devices, pvt, entry) {
 		if (!strcmp(pvt->id, device))
 			break;
 	}
 
-	if (!pvt)
+	if (!pvt) {
+		ast_log(LOG_ERROR,"Bluetooth device %s wasn't found in the list -- SMS will not be sent.\n",device);
 		return -1;
-	if (!pvt->connected)
+	}
+	
+	if (!pvt->connected) {
+		ast_log(LOG_ERROR,"bluetooth device %s wasn't connected -- SMS will not be sent.\n",device);
 		return -1;
-	if (!pvt->has_sms)
+	}
+	
+	if (!pvt->has_sms) {
+		ast_log(LOG_ERROR,"bluetooth device %s doesn't handle SMS -- SMS will not be sent.\n",device);
 		return -1;
-	if (pvt->state != MBL_STATE_IDLE)
+	}
+	
+	if (pvt->state != MBL_STATE_IDLE) {
+		ast_log(LOG_ERROR,"bluetooth device %s isn't IDLE -- SMS will not be sent.\n",device);
 		return -1;
-
+	}
+	
 	strcpy(pvt->dial_number, dest);
 	memset(pvt->sms_txt, 0x0, sizeof(pvt->sms_txt));
 	strncpy(pvt->sms_txt, message, 160);
@@ -612,14 +631,17 @@
 	int r;
 	struct ast_frame *f;
 
-	if (!pvt->owner)
+	if (!pvt->owner) {
 		return &ast_null_frame;
-
-	if (pvt->state == MBL_STATE_HANGUP)
+	}
+
+	if (pvt->state == MBL_STATE_HANGUP) {
 		return &ast_null_frame;
-
-	if (pvt->sco_socket == -1)
+	}
+
+	if (pvt->sco_socket == -1) {
 		return &ast_null_frame;
+	}
 
 	pvt->fr.frametype = AST_FRAME_VOICE;
 	pvt->fr.subclass = AST_FORMAT_SLINEAR;
@@ -632,11 +654,11 @@
 				pvt->fr.frametype = AST_FRAME_DTMF_END;
 				pvt->fr.subclass = f->subclass;
 				pvt->skip_frames = pvt->dtmf_skip;
-				ast_debug(1, "DTMF digit %c detected.\n", pvt->fr.subclass);
 			}
 			return &pvt->fr;
-		} else
+		} else {
 			pvt->skip_frames--;
+		}
 	} else if (r == -1) {
 		ast_debug(1, "mbl_read() read error %d.\n", errno);
 		close(pvt->sco_socket);
@@ -666,14 +688,16 @@
 	int num_frames, i, r;
 	char *pfr;
 
-	if (frame->frametype != AST_FRAME_VOICE)
+	if (frame->frametype != AST_FRAME_VOICE) {
 		return 0;
-
-	if (pvt->sco_socket == -1)
+	}
+	if (pvt->sco_socket == -1) {
 		return 0;
-
-	if (pvt->state == MBL_STATE_HANGUP)
+	}
+
+	if (pvt->state == MBL_STATE_HANGUP) {
 		return 0;
+	}
 
 	if (frame->datalen > sizeof(pvt->sco_out_buf) - pvt->sco_out_len) {
 		frame->datalen = sizeof(pvt->sco_out_buf) - pvt->sco_out_len;
@@ -696,7 +720,7 @@
 	pvt->sco_out_len = pvt->sco_out_len - (num_frames * 48);
 	memmove(pvt->sco_out_buf, pfr, pvt->sco_out_len);
 	pvt->sco_out_ptr = pvt->sco_out_buf + pvt->sco_out_len; 
-
+	
 	return 0;
 
 }
@@ -1185,6 +1209,7 @@
 					pvt->state = MBL_STATE_PREIDLE;
 				} else if (strstr(buf, "ERROR")) {
 					pvt->has_sms = 0;
+					ast_log(LOG_NOTICE,"Device %s has no bluetooth SMS capability.\n", pvt->id);
 					pvt->state = MBL_STATE_PREIDLE;
 				}
 				break;
@@ -1273,6 +1298,7 @@
 							pvt->state = MBL_STATE_INCOMING;
 						} else {		/* User answered on handset!, disconnect */
 							pvt->state = MBL_STATE_IDLE;
+							ast_log(LOG_NOTICE,"Closing the sco_socket in RING3 with CIEV\n");
 							if (pvt->sco_socket > -1)
 								close(pvt->sco_socket);
 							ast_queue_control(pvt->owner, AST_CONTROL_HANGUP);
@@ -1449,6 +1475,7 @@
 				if (strstr(buf, "AT+CKPD=")) {
 					ast_channel_lock(pvt->owner);
 					pvt->owner->fds[0] = pvt->sco_socket;
+					ast_log(LOG_NOTICE,"pvt-sco_socket used for fds in headphone code\n");
 					ast_channel_unlock(pvt->owner);
 					ast_queue_control(pvt->owner, AST_CONTROL_ANSWER);
 					pvt->state = MBL_STATE_INCOMING;
@@ -1477,6 +1504,7 @@
 			} else if (pvt->state == MBL_STATE_RING) {
 				pvt->sco_socket = sco_connect(pvt->bdaddr);
 				if (pvt->sco_socket > -1) {
+					ast_log(LOG_NOTICE,"sco_connect returned -1 in state RING\n");
 					ast_setstate(pvt->owner, AST_STATE_RINGING);
 					ast_queue_control(pvt->owner, AST_CONTROL_RINGING);
 					pvt->state = MBL_STATE_RING2;
@@ -1603,7 +1631,9 @@
 	}
 	while (1) {
 		addrlen = sizeof(struct sockaddr);
+		ast_log(LOG_NOTICE, "About to accept the sco_socket...\n");
 		if ((ns = accept(sco_socket, (struct sockaddr *)&addr, &addrlen)) > -1) {
+			ast_log(LOG_NOTICE, "sco_socket returns %d...\n",ns);
 			ba2str(&addr.sco_bdaddr, saddr);
 
 			len = sizeof(so);
@@ -1617,6 +1647,7 @@
 					break;
 			}
 			if (pvt) {
+				ast_log(LOG_NOTICE,"about to close the pvt-sco_socket and set it ns\n");
 				if (pvt->sco_socket != -1)
 					close(pvt->sco_socket);
 				pvt->sco_socket = ns;
@@ -1628,6 +1659,7 @@
 			} else
 				ast_debug(1, "Could not find device for incoming Audio Connection.\n");
 		}
+		else ast_log(LOG_NOTICE, "Accept got a -1....");
 	}
 
 	return NULL;
@@ -1659,6 +1691,7 @@
 			address = ast_variable_retrieve(cfg, cat, "address");
 			port = ast_variable_retrieve(cfg, cat, "port");
 			context = ast_variable_retrieve(cfg, cat, "context");
+			ast_log(LOG_NOTICE, "context for non-general category %s was %s\n", cat, context);
 			type = ast_variable_retrieve(cfg, cat, "type");
 			skip = ast_variable_retrieve(cfg, cat, "dtmfskip");
 			if (address && port) {




More information about the asterisk-addons-commits mailing list