Index: channels/chan_mobile.c
===================================================================
--- channels/chan_mobile.c	(revision 841)
+++ channels/chan_mobile.c	(working copy)
@@ -418,6 +418,8 @@
 	AT_VGM,
 	AT_VGS,
 	AT_VTS,
+	AT_CMGF,
+	AT_CNMI,
 } at_message_t;
 
 static int at_match_prefix(char *buf, char *prefix);
@@ -1912,6 +1914,10 @@
 		return "AT+VGS";
 	case AT_VTS:
 		return "AT+VTS";
+	case AT_CMGF:
+		return "AT+CMGF";
+	case AT_CNMI:
+		return "AT+CNMI";
 	}
 }
 
@@ -1974,40 +1980,22 @@
 		}
 	}
 
-	/* enalbe calling line identification notification */
-	if (hfp_send_clip(hfp, 1) || !hfp_wait(hfp) || at_read(hfp->rsock) != AT_OK) {
-		ast_debug(1, "[%s] error enabling calling line notification\n", hfp->owner->id);
-		return -1;
-	}
-
-	/* send current gain levels */
-	if (hfp_send_vgs(hfp, 15) || !hfp_wait(hfp) || at_read(hfp->rsock) != AT_OK) {
-		ast_debug(1, "[%s] error synchronizing gain settings\n", hfp->owner->id);
-		return -1;
-	}
-
 	/* we now have a service level connection */
 	hfp->connected = 1;
 
-	if (hfp_init_sms(hfp)) {
-		ast_debug(1, "[%s] no SMS support\n", hfp->owner->id);
-	} else {
-		hfp->owner->has_sms = 1;
-	}
-
 	return 0;
 }
 
 static int hfp_init_sms(struct hfp_pvt *hfp)
 {
 	/* set the SMS operating mode to text mode */
-	if (hfp_send_cmgf(hfp, 1) || !hfp_wait(hfp) || at_read(hfp->rsock) != AT_OK) {
+	if (hfp_send_cmgf(hfp, 1) || msg_queue_push(hfp->owner, AT_OK, AT_CMGF)) {
 		ast_debug(1, "[%s] error setting CMGF\n", hfp->owner->id);
 		return -1;
 	}
 
 	/* turn on SMS new message indication */
-	if (hfp_send_cnmi(hfp) || !hfp_wait(hfp) || at_read(hfp->rsock) != AT_OK) {
+	if (hfp_send_cnmi(hfp) || msg_queue_push(hfp->owner, AT_OK, AT_CNMI)) {
 		ast_debug(1, "[%s] error setting CNMI\n", hfp->owner->id);
 		return -1;
 	}
@@ -2959,6 +2947,19 @@
 		case AT_VTS:
 			ast_debug(1, "[%s] digit sent successfully\n", pvt->id);
 			break;
+		case AT_VGS:
+			ast_debug(1, "[%s] volume request sent successfully\n", pvt->id);
+			break;
+		case AT_CLIP:
+			ast_debug(1, "[%s] caling line indication set successfully\n", pvt->id);
+			break;
+		case AT_CMGF:
+			ast_debug(1, "[%s] sms text mode enabled\n", pvt->id);
+			break;
+		case AT_CNMI:
+			ast_debug(1, "[%s] sms new message indication enabled\n", pvt->id);
+			pvt->has_sms = 1;
+			break;
 		case AT_UNKNOWN:
 		default:
 			ast_debug(1, "[%s] recieved OK for unhandled request: %s\n", pvt->id, at_msg2str(entry->response_to));
@@ -3012,6 +3013,21 @@
 		case AT_VTS:
 			ast_debug(1, "[%s] error sending digit\n", pvt->id);
 			break;
+		case AT_VGS:
+			ast_debug(1, "[%s] sending volume request failed\n", pvt->id);
+			break;
+		case AT_CLIP:
+			ast_debug(1, "[%s] error setting calling line indication, disconnecting\n", pvt->id);
+			res = -1;
+			break;
+		case AT_CMGF:
+			ast_debug(1, "[%s] error setting CMGF\n", pvt->id);
+			ast_debug(1, "[%s] no SMS support\n", pvt->id);
+			break;
+		case AT_CNMI:
+			ast_debug(1, "[%s] error setting CNMI\n", pvt->id);
+			ast_debug(1, "[%s] no SMS support\n", pvt->id);
+			break;
 		case AT_UNKNOWN:
 		default:
 			ast_debug(1, "[%s] recieved ERROR for unhandled request: %s\n", pvt->id, at_msg2str(entry->response_to));
@@ -3271,6 +3287,25 @@
 		ast_verb(3, "Error initializing Bluetooth device %s.\n", pvt->id);
 		goto e_cleanup;
 	}
+
+	/* enalbe calling line identification notification */
+	if (hfp_send_clip(hfp, 1) || msg_queue_push(pvt, AT_OK, AT_CLIP)) {
+		ast_debug(1, "[%s] error enabling calling line notification\n", hfp->owner->id);
+		ast_verb(3, "Error initializing Bluetooth device %s.\n", pvt->id);
+		goto e_cleanup;
+	}
+
+	/* send current gain levels */
+	if (hfp_send_vgs(hfp, 15) || msg_queue_push(pvt, AT_OK, AT_VGS)) {
+		ast_debug(1, "[%s] error synchronizing gain settings\n", hfp->owner->id);
+		ast_verb(3, "Error initializing Bluetooth device %s.\n", pvt->id);
+		goto e_cleanup;
+	}
+
+	if (hfp_init_sms(hfp)) {
+		ast_debug(1, "[%s] no SMS support\n", hfp->owner->id);
+	}
+
 	ast_mutex_unlock(&pvt->lock);
 
 	ast_verb(3, "Bluetooth Device %s initialised and ready.\n", pvt->id);
