[svn-commits] mnicholson: branch mnicholson/chan-mobile-refactor r804 - /team/mnicholson/ch...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Mar 13 11:39:05 CDT 2009


Author: mnicholson
Date: Fri Mar 13 11:38:58 2009
New Revision: 804

URL: http://svn.digium.com/svn-view/asterisk-addons?view=rev&rev=804
Log:
rename hfp_pvt pointers from pvt to hfp

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=804&r1=803&r2=804
==============================================================================
--- team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c (original)
+++ team/mnicholson/chan-mobile-refactor/channels/chan_mobile.c Fri Mar 13 11:38:58 2009
@@ -347,39 +347,39 @@
 };
 
 
-static int hfp_init(struct hfp_pvt *pvt);
-static int hfp_init_sms(struct hfp_pvt *pvt);
-static int hfp_wait(struct hfp_pvt *pvt);
-static int hfp_parse_ciev(struct hfp_pvt *pvt, char *buf, int *value);
-static char *hfp_parse_clip(struct hfp_pvt *pvt, char *buf);
-static int hfp_parse_cmti(struct hfp_pvt *pvt, char *buf);
-static int hfp_parse_cmgr(struct hfp_pvt *pvt, char *buf, char **from_number, char **text);
+static int hfp_init(struct hfp_pvt *hfp);
+static int hfp_init_sms(struct hfp_pvt *hfp);
+static int hfp_wait(struct hfp_pvt *hfp);
+static int hfp_parse_ciev(struct hfp_pvt *hfp, char *buf, int *value);
+static char *hfp_parse_clip(struct hfp_pvt *hfp, char *buf);
+static int hfp_parse_cmti(struct hfp_pvt *hfp, char *buf);
+static int hfp_parse_cmgr(struct hfp_pvt *hfp, char *buf, char **from_number, char **text);
 
 static int hfp_brsf2int(struct hfp_hf *hf);
 static struct hfp_ag *hfp_int2brsf(int brsf, struct hfp_ag *ag);
 
-static int hfp_send_brsf(struct hfp_pvt *pvt, struct hfp_hf *brsf);
-static int hfp_send_cind(struct hfp_pvt *pvt);
-static int hfp_send_cind_test(struct hfp_pvt *pvt);
-static int hfp_send_cmer(struct hfp_pvt *pvt, int status);
-static int hfp_send_clip(struct hfp_pvt *pvt, int status);
-static int hfp_send_vgs(struct hfp_pvt *pvt, int value);
+static int hfp_send_brsf(struct hfp_pvt *hfp, struct hfp_hf *brsf);
+static int hfp_send_cind(struct hfp_pvt *hfp);
+static int hfp_send_cind_test(struct hfp_pvt *hfp);
+static int hfp_send_cmer(struct hfp_pvt *hfp, int status);
+static int hfp_send_clip(struct hfp_pvt *hfp, int status);
+static int hfp_send_vgs(struct hfp_pvt *hfp, int value);
 #if 0
-static int hfp_send_vgm(struct hfp_pvt *pvt, int value);
+static int hfp_send_vgm(struct hfp_pvt *hfp, int value);
 #endif
-static int hfp_send_dtmf(struct hfp_pvt *pvt, char digit);
-static int hfp_send_cmgf(struct hfp_pvt *pvt, int mode);
-static int hfp_send_cnmi(struct hfp_pvt *pvt);
-static int hfp_send_cmgr(struct hfp_pvt *pvt, int index);
-static int hfp_send_cmgs(struct hfp_pvt *pvt, const char *number);
-static int hfp_send_sms_text(struct hfp_pvt *pvt, const char *message);
-static int hfp_send_chup(struct hfp_pvt *pvt);
-static int hfp_send_atd(struct hfp_pvt *pvt, const char *number);
-static int hfp_send_ata(struct hfp_pvt *pvt);
-
-static int hfp_read_brsf(struct hfp_pvt *pvt);
-static int hfp_read_cind(struct hfp_pvt *pvt);
-static int hfp_read_cind_test(struct hfp_pvt *pvt);
+static int hfp_send_dtmf(struct hfp_pvt *hfp, char digit);
+static int hfp_send_cmgf(struct hfp_pvt *hfp, int mode);
+static int hfp_send_cnmi(struct hfp_pvt *hfp);
+static int hfp_send_cmgr(struct hfp_pvt *hfp, int index);
+static int hfp_send_cmgs(struct hfp_pvt *hfp, const char *number);
+static int hfp_send_sms_text(struct hfp_pvt *hfp, const char *message);
+static int hfp_send_chup(struct hfp_pvt *hfp);
+static int hfp_send_atd(struct hfp_pvt *hfp, const char *number);
+static int hfp_send_ata(struct hfp_pvt *hfp);
+
+static int hfp_read_brsf(struct hfp_pvt *hfp);
+static int hfp_read_cind(struct hfp_pvt *hfp);
+static int hfp_read_cind_test(struct hfp_pvt *hfp);
 
 /*
  * bluetooth headset profile helpers
@@ -1847,93 +1847,93 @@
 
 /*!
  * \brief Initilize an HFP service level connection.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  *
  * This function brings up an HFP service level connection.
  *
  * \note This function expects a connected rfcomm socket and it expects the pvt
  * structure to be initilized with zeroes.
  */
-static int hfp_init(struct hfp_pvt *pvt)
+static int hfp_init(struct hfp_pvt *hfp)
 {
 	/* send and receive BRSF data */
-	if (hfp_send_brsf(pvt, &hfp_our_brsf) || !hfp_wait(pvt) || hfp_read_brsf(pvt)) {
-		ast_debug(1, "[%s] error sending/receiving BRSF\n", pvt->owner->id);
+	if (hfp_send_brsf(hfp, &hfp_our_brsf) || !hfp_wait(hfp) || hfp_read_brsf(hfp)) {
+		ast_debug(1, "[%s] error sending/receiving BRSF\n", hfp->owner->id);
 		return -1;
 	}
 
 	/* if this is a blackberry, do CMER now */
-	if (pvt->blackberry) {
-		if (hfp_send_cmer(pvt, 1) || !hfp_wait(pvt) || at_read(pvt->rsock) != AT_OK) {
-			ast_debug(1, "[%s] error sending CMER, try setting 'blackberry=no'\n", pvt->owner->id);
+	if (hfp->blackberry) {
+		if (hfp_send_cmer(hfp, 1) || !hfp_wait(hfp) || at_read(hfp->rsock) != AT_OK) {
+			ast_debug(1, "[%s] error sending CMER, try setting 'blackberry=no'\n", hfp->owner->id);
 			return -1;
 		}
 	}
 
 	/* send CIND test */
-	if (hfp_send_cind_test(pvt) || !hfp_wait(pvt) || hfp_read_cind_test(pvt)) {
-		if (!pvt->blackberry)
-			ast_debug(1, "[%s] error performing CIND test, try setting 'blackberry=yes'\n", pvt->owner->id);
+	if (hfp_send_cind_test(hfp) || !hfp_wait(hfp) || hfp_read_cind_test(hfp)) {
+		if (!hfp->blackberry)
+			ast_debug(1, "[%s] error performing CIND test, try setting 'blackberry=yes'\n", hfp->owner->id);
 		else
-			ast_debug(1, "[%s] error performing CIND test\n", pvt->owner->id);
+			ast_debug(1, "[%s] error performing CIND test\n", hfp->owner->id);
 		return -1;
 	}
 	
 	/* read current CIND state */
-	if (hfp_send_cind(pvt) || !hfp_wait(pvt) || hfp_read_cind(pvt)) {
-		ast_debug(1, "[%s] error getting CIND state\n", pvt->owner->id);
+	if (hfp_send_cind(hfp) || !hfp_wait(hfp) || hfp_read_cind(hfp)) {
+		ast_debug(1, "[%s] error getting CIND state\n", hfp->owner->id);
 		return -1;
 	}
 
 	/* check if a call is active */
-	if (pvt->cind_state[pvt->cind_map.call]) {
-		ast_verb(3, "Bluetooth Device %s has a call in progress - delaying connection.\n", pvt->owner->id);
+	if (hfp->cind_state[hfp->cind_map.call]) {
+		ast_verb(3, "Bluetooth Device %s has a call in progress - delaying connection.\n", hfp->owner->id);
 		return -1;
 	}
 
 	/* if this is not a blackberry send CMER now */
-	if (!pvt->blackberry) {
-		if (hfp_send_cmer(pvt, 1) || !hfp_wait(pvt) || at_read(pvt->rsock) != AT_OK) {
-			ast_debug(1, "[%s] error sending CMER\n", pvt->owner->id);
+	if (!hfp->blackberry) {
+		if (hfp_send_cmer(hfp, 1) || !hfp_wait(hfp) || at_read(hfp->rsock) != AT_OK) {
+			ast_debug(1, "[%s] error sending CMER\n", hfp->owner->id);
 			return -1;
 		}
 	}
 	
 	/* enalbe calling line identification notification */
-	if (hfp_send_clip(pvt, 1) || !hfp_wait(pvt) || at_read(pvt->rsock) != AT_OK) {
-		ast_debug(1, "[%s] error enabling calling line notification\n", pvt->owner->id);
+	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(pvt, 15) || !hfp_wait(pvt) || at_read(pvt->rsock) != AT_OK) {
-		ast_debug(1, "[%s] error synchronizing gain settings\n", pvt->owner->id);
+	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 */
-	pvt->connected = 1;
-
-	if (hfp_init_sms(pvt)) {
-		ast_debug(1, "[%s] no SMS support\n", pvt->owner->id);
+	hfp->connected = 1;
+
+	if (hfp_init_sms(hfp)) {
+		ast_debug(1, "[%s] no SMS support\n", hfp->owner->id);
 	} else {
-		pvt->owner->has_sms = 1;
+		hfp->owner->has_sms = 1;
 	}
 
 	return 0;
 }
 
-static int hfp_init_sms(struct hfp_pvt *pvt)
+static int hfp_init_sms(struct hfp_pvt *hfp)
 {
 	/* set the SMS operating mode to text mode */
-	if (hfp_send_cmgf(pvt, 1) || !hfp_wait(pvt) || at_read(pvt->rsock) != AT_OK) {
-		ast_debug(1, "[%s] error setting CMGF\n", pvt->owner->id);
+	if (hfp_send_cmgf(hfp, 1) || !hfp_wait(hfp) || at_read(hfp->rsock) != AT_OK) {
+		ast_debug(1, "[%s] error setting CMGF\n", hfp->owner->id);
 		return -1;
 	}
 
 	/* turn on SMS new message indication */
-	if (hfp_send_cnmi(pvt) || !hfp_wait(pvt) || at_read(pvt->rsock) != AT_OK) {
-		ast_debug(1, "[%s] error setting CNMI\n", pvt->owner->id);
+	if (hfp_send_cnmi(hfp) || !hfp_wait(hfp) || at_read(hfp->rsock) != AT_OK) {
+		ast_debug(1, "[%s] error setting CNMI\n", hfp->owner->id);
 		return -1;
 	}
 
@@ -1945,50 +1945,50 @@
  * \brief Wait a default timeout.
  * \return zero on timeout and non zero on data
  */
-static int hfp_wait(struct hfp_pvt *pvt)
+static int hfp_wait(struct hfp_pvt *hfp)
 {
 	int ms = 10000;
-	return rfcomm_wait(pvt->rsock, &ms);
+	return rfcomm_wait(hfp->rsock, &ms);
 }
 
 /*!
  * \brief Parse a CIEV event.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param buf the buffer to parse (null terminated)
  * \param value a pointer to an int to store the event value in (can be NULL)
  * \return 0 on error (parse error, or unknown event) or a HFP_CIND_* value on
  * success
  */
-static int hfp_parse_ciev(struct hfp_pvt *pvt, char *buf, int *value)
+static int hfp_parse_ciev(struct hfp_pvt *hfp, char *buf, int *value)
 {
 	int i, v;
 	if (!value)
 		value = &v;
 
 	if (!sscanf(buf, "+CIEV: %d,%d", &i, value)) {
-		ast_debug(2, "[%s] error parsing CIEV event '%s'\n", pvt->owner->id, buf);
+		ast_debug(2, "[%s] error parsing CIEV event '%s'\n", hfp->owner->id, buf);
 		return HFP_CIND_NONE;
 	}
 
-	if (i >= sizeof(pvt->cind_state)) {
-		ast_debug(2, "[%s] CIEV event index too high (%s)\n", pvt->owner->id, buf);
+	if (i >= sizeof(hfp->cind_state)) {
+		ast_debug(2, "[%s] CIEV event index too high (%s)\n", hfp->owner->id, buf);
 		return HFP_CIND_NONE;
 	}
 
-	pvt->cind_state[i] = *value;
-	return pvt->cind_index[i];
+	hfp->cind_state[i] = *value;
+	return hfp->cind_index[i];
 }
 
 /*!
  * \brief Parse a CLIP event.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param buf the buffer to parse (null terminated)
  * @note buf will be modified when the CID string is parsed
  * \return NULL on error (parse error) or a pointer to the caller id
  * inforamtion in buf
  * success
  */
-static char *hfp_parse_clip(struct hfp_pvt *pvt, char *buf) {
+static char *hfp_parse_clip(struct hfp_pvt *hfp, char *buf) {
 	int i, state;
 	char *clip;
 	size_t s;
@@ -2027,12 +2027,12 @@
 
 /*!
  * \brief Parse a CMTI notification.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param buf the buffer to parse (null terminated)
  * @note buf will be modified when the CMTI message is parsed
  * \return -1 on error (parse error) or the index of the new sms message
  */
-static int hfp_parse_cmti(struct hfp_pvt *pvt, char *buf) {
+static int hfp_parse_cmti(struct hfp_pvt *hfp, char *buf) {
 	int index;
 	char mem[8];
 
@@ -2040,7 +2040,7 @@
 	 * +CMTI: <mem>,<index> 
 	 */
 	if (!sscanf(buf, "+CMTI: %7s,%d", mem, &index)) {
-		ast_debug(2, "[%s] error parsing CMTI event '%s'\n", pvt->owner->id, buf);
+		ast_debug(2, "[%s] error parsing CMTI event '%s'\n", hfp->owner->id, buf);
 		return -1;
 	}
 
@@ -2049,7 +2049,7 @@
 
 /*!
  * \brief Parse a CMGR message.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param buf the buffer to parse (null terminated)
  * \param from_number a pointer to a char pointer which will store the from
  * number
@@ -2058,7 +2058,7 @@
  * \retval -1 parse error
  * \retval 0 success
  */
-static int hfp_parse_cmgr(struct hfp_pvt *pvt, char *buf, char **from_number, char **text)
+static int hfp_parse_cmgr(struct hfp_pvt *hfp, char *buf, char **from_number, char **text)
 {
 	int i, state;
 	size_t s;
@@ -2158,95 +2158,95 @@
 
 /*!
  * \brief Send a BRSF request.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param brsf an hfp_hf brsf struct
  *
  * \retval 0 on success
  * \retval -1 on error
  */
-static int hfp_send_brsf(struct hfp_pvt *pvt, struct hfp_hf *brsf)
+static int hfp_send_brsf(struct hfp_pvt *hfp, struct hfp_hf *brsf)
 {
 	char cmd[32];
 	snprintf(cmd, sizeof(cmd), "AT+BRSF=%d\r", hfp_brsf2int(brsf));
-	return rfcomm_write(pvt->rsock, cmd);
+	return rfcomm_write(hfp->rsock, cmd);
 }
 
 /*!
  * \brief Send the CIND read command.
- * \param pvt an hfp_pvt struct
- */
-static int hfp_send_cind(struct hfp_pvt *pvt)
-{
-	return rfcomm_write(pvt->rsock, "AT+CIND?\r");
+ * \param hfp an hfp_pvt struct
+ */
+static int hfp_send_cind(struct hfp_pvt *hfp)
+{
+	return rfcomm_write(hfp->rsock, "AT+CIND?\r");
 }
 
 /*!
  * \brief Send the CIND test command.
- * \param pvt an hfp_pvt struct
- */
-static int hfp_send_cind_test(struct hfp_pvt *pvt)
-{
-	return rfcomm_write(pvt->rsock, "AT+CIND=?\r");
+ * \param hfp an hfp_pvt struct
+ */
+static int hfp_send_cind_test(struct hfp_pvt *hfp)
+{
+	return rfcomm_write(hfp->rsock, "AT+CIND=?\r");
 }
 
 /*!
  * \brief Enable or disable indicator events reporting.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param status enable or disable events reporting (should be 1 or 0)
  */
-static int hfp_send_cmer(struct hfp_pvt *pvt, int status)
+static int hfp_send_cmer(struct hfp_pvt *hfp, int status)
 {
 	char cmd[32];
 	snprintf(cmd, sizeof(cmd), "AT+CMER=3,0,0,%d\r", status ? 1 : 0);
-	return rfcomm_write(pvt->rsock, cmd);
+	return rfcomm_write(hfp->rsock, cmd);
 }
 
 /*!
  * \brief Send the current speaker gain level.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param value the value to send (must be between 0 and 15)
  */
-static int hfp_send_vgs(struct hfp_pvt *pvt, int value)
+static int hfp_send_vgs(struct hfp_pvt *hfp, int value)
 {
 	char cmd[32];
 	snprintf(cmd, sizeof(cmd), "AT+VGS=%d\r", value);
-	return rfcomm_write(pvt->rsock, cmd);
+	return rfcomm_write(hfp->rsock, cmd);
 }
 
 #if 0
 /*!
  * \brief Send the current microphone gain level.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param value the value to send (must be between 0 and 15)
  */
-static int hfp_send_vgm(struct hfp_pvt *pvt, int value)
+static int hfp_send_vgm(struct hfp_pvt *hfp, int value)
 {
 	char cmd[32];
 	snprintf(cmd, sizeof(cmd), "AT+VGM=%d\r", value);
-	return rfcomm_write(pvt->rsock, cmd);
+	return rfcomm_write(hfp->rsock, cmd);
 }
 #endif
 
 /*!
  * \brief Enable or disable calling line identification.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param status enable or disable calling line identification (should be 1 or
  * 0)
  */
-static int hfp_send_clip(struct hfp_pvt *pvt, int status)
+static int hfp_send_clip(struct hfp_pvt *hfp, int status)
 {
 	char cmd[32];
 	snprintf(cmd, sizeof(cmd), "AT+CLIP=%d\r", status ? 1 : 0);
-	return rfcomm_write(pvt->rsock, cmd);
+	return rfcomm_write(hfp->rsock, cmd);
 }
 
 /*!
  * \brief Send a DTMF command.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param digit the dtmf digit to send
  * \return the result of rfcomm_write() or -1 on an invalid digit being sent
  */
-static int hfp_send_dtmf(struct hfp_pvt *pvt, char digit)
+static int hfp_send_dtmf(struct hfp_pvt *hfp, char digit)
 {
 	char cmd[10];
 
@@ -2264,7 +2264,7 @@
 	case '*':
 	case '#':
 		snprintf(cmd, sizeof(cmd), "AT+VTS=%c\r", digit);
-		return rfcomm_write(pvt->rsock, cmd);
+		return rfcomm_write(hfp->rsock, cmd);
 	default:
 		return -1;
 	}
@@ -2272,111 +2272,111 @@
 
 /*!
  * \brief Set the SMS mode.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param mode the sms mode (0 = PDU, 1 = Text)
  */
-static int hfp_send_cmgf(struct hfp_pvt *pvt, int mode)
+static int hfp_send_cmgf(struct hfp_pvt *hfp, int mode)
 {
 	char cmd[32];
 	snprintf(cmd, sizeof(cmd), "AT+CMGF=%d\r", mode);
-	return rfcomm_write(pvt->rsock, cmd);
+	return rfcomm_write(hfp->rsock, cmd);
 }
 
 /*!
  * \brief Setup SMS new message indication.
- * \param pvt an hfp_pvt struct
- */
-static int hfp_send_cnmi(struct hfp_pvt *pvt)
-{
-	return rfcomm_write(pvt->rsock, "AT+CNMI=2,1,0,1,0\r");
+ * \param hfp an hfp_pvt struct
+ */
+static int hfp_send_cnmi(struct hfp_pvt *hfp)
+{
+	return rfcomm_write(hfp->rsock, "AT+CNMI=2,1,0,1,0\r");
 }
 
 /*!
  * \brief Read an SMS message.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param index the location of the requested message
  */
-static int hfp_send_cmgr(struct hfp_pvt *pvt, int index)
+static int hfp_send_cmgr(struct hfp_pvt *hfp, int index)
 {
 	char cmd[32];
 	snprintf(cmd, sizeof(cmd), "AT+CMGR=%d\r", index);
-	return rfcomm_write(pvt->rsock, cmd);
+	return rfcomm_write(hfp->rsock, cmd);
 }
 
 /*!
  * \brief Start sending an SMS message.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param number the destination of the message
  */
-static int hfp_send_cmgs(struct hfp_pvt *pvt, const char *number)
+static int hfp_send_cmgs(struct hfp_pvt *hfp, const char *number)
 {
 	char cmd[64];
 	snprintf(cmd, sizeof(cmd), "AT+CMGS=\"%s\"\r", number);
-	return rfcomm_write(pvt->rsock, cmd);
+	return rfcomm_write(hfp->rsock, cmd);
 }
 
 /*!
  * \brief Send the text of an SMS message.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param message the text of the message
  */
-static int hfp_send_sms_text(struct hfp_pvt *pvt, const char *message)
+static int hfp_send_sms_text(struct hfp_pvt *hfp, const char *message)
 {
 	char cmd[162];
 	snprintf(cmd, sizeof(cmd), "%.160s\x1a", message);
-	return rfcomm_write(pvt->rsock, cmd);
+	return rfcomm_write(hfp->rsock, cmd);
 }
 
 /*!
  * \brief Send AT+CHUP.
- * \param pvt an hfp_pvt struct
- */
-static int hfp_send_chup(struct hfp_pvt *pvt)
-{
-	return rfcomm_write(pvt->rsock, "AT+CHUP\r");
+ * \param hfp an hfp_pvt struct
+ */
+static int hfp_send_chup(struct hfp_pvt *hfp)
+{
+	return rfcomm_write(hfp->rsock, "AT+CHUP\r");
 }
 
 /*!
  * \brief Send ATD.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param number the number to send
  */
-static int hfp_send_atd(struct hfp_pvt *pvt, const char *number)
+static int hfp_send_atd(struct hfp_pvt *hfp, const char *number)
 {
 	char cmd[64];
 	snprintf(cmd, sizeof(cmd), "ATD%s;\r", number);
-	return rfcomm_write(pvt->rsock, cmd);
+	return rfcomm_write(hfp->rsock, cmd);
 }
 
 /*!
  * \brief Send ATA.
- * \param pvt an hfp_pvt struct
- */
-static int hfp_send_ata(struct hfp_pvt *pvt)
-{
-	return rfcomm_write(pvt->rsock, "ATA\r");
+ * \param hfp an hfp_pvt struct
+ */
+static int hfp_send_ata(struct hfp_pvt *hfp)
+{
+	return rfcomm_write(hfp->rsock, "ATA\r");
 }
 
 /*!
  * \brief Read BRSF data.
- * \param pvt an hfp_pvt struct
- */
-static int hfp_read_brsf(struct hfp_pvt *pvt)
+ * \param hfp an hfp_pvt struct
+ */
+static int hfp_read_brsf(struct hfp_pvt *hfp)
 {
 	int brsf;
 	char buf[128];
 
 	/* read the BRSF data */
-	if (at_read_full(pvt->rsock, buf, sizeof(buf)) != AT_BRSF)
+	if (at_read_full(hfp->rsock, buf, sizeof(buf)) != AT_BRSF)
 		return -1;
 
 	if (!sscanf(buf, "+BRSF:%d", &brsf))
 		return -1;
 
-	hfp_int2brsf(brsf, &pvt->brsf);
+	hfp_int2brsf(brsf, &hfp->brsf);
 
 	/* read the OK message */
-	if (!hfp_wait(pvt) || at_read(pvt->rsock) != AT_OK)
+	if (!hfp_wait(hfp) || at_read(hfp->rsock) != AT_OK)
 		return -1;
 
 	return 0;
@@ -2384,17 +2384,17 @@
 
 /*!
  * \brief Parse and store the given indicator.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \param group the indicator group
  * \param indicator the indicator to parse
  */
-static int hfp_parse_cind_indicator(struct hfp_pvt *pvt, int group, char *indicator)
+static int hfp_parse_cind_indicator(struct hfp_pvt *hfp, int group, char *indicator)
 {
 	int value;
 
 	/* store the current indicator */
-	if (group >= sizeof(pvt->cind_state)) {
-		ast_debug(1, "ignoring CIND state '%s' for group %d, we only support up to %d indicators\n", indicator, group, (int) sizeof(pvt->cind_state));
+	if (group >= sizeof(hfp->cind_state)) {
+		ast_debug(1, "ignoring CIND state '%s' for group %d, we only support up to %d indicators\n", indicator, group, (int) sizeof(hfp->cind_state));
 		return -1;
 	}
 	
@@ -2403,24 +2403,24 @@
 		return -1;
 	}
 	
-	pvt->cind_state[group] = value;
+	hfp->cind_state[group] = value;
 	return 0;
 }
 
 /*!
  * \brief Read the result of the AT+CIND? command.
- * \param pvt an hfp_pvt struct
+ * \param hfp an hfp_pvt struct
  * \note hfp_send_cind_test() and hfp_read_cind_test() should be called at
  * least once before this function is called.
  */
-static int hfp_read_cind(struct hfp_pvt *pvt)
+static int hfp_read_cind(struct hfp_pvt *hfp)
 {
 	int i, state, group;
 	size_t s;
 	char buf[256];
 	char *indicator;
 
-	if (at_read_full(pvt->rsock, buf, sizeof(buf)) != AT_CIND)
+	if (at_read_full(hfp->rsock, buf, sizeof(buf)) != AT_CIND)
 		return -1;
 
 	/* parse current state of all of our indicators.  The list is in the
@@ -2446,7 +2446,7 @@
 			if (buf[i] == ',') {
 				buf[i] = '\0';
 
-				hfp_parse_cind_indicator(pvt, group, indicator);
+				hfp_parse_cind_indicator(hfp, group, indicator);
 
 				group++;
 				state = 1;
@@ -2457,10 +2457,10 @@
 
 	/* store the last indicator */
 	if (state == 2)
-		hfp_parse_cind_indicator(pvt, group, indicator);
+		hfp_parse_cind_indicator(hfp, group, indicator);
 	
 	/* read the OK message */
-	if (!hfp_wait(pvt) || at_read(pvt->rsock) != AT_OK)
+	if (!hfp_wait(hfp) || at_read(hfp->rsock) != AT_OK)
 		return -1;
 
 	return 0;
@@ -2468,19 +2468,19 @@
 
 /*!
  * \brief Read the result of the AT+CIND=? command.
- * \param pvt an hfp_pvt struct
- */
-static int hfp_read_cind_test(struct hfp_pvt *pvt)
+ * \param hfp an hfp_pvt struct
+ */
+static int hfp_read_cind_test(struct hfp_pvt *hfp)
 {
 	int i, state, group;
 	size_t s;
 	char buf[512];
 	char *indicator, *values;
 
-	if (at_read_full(pvt->rsock, buf, sizeof(buf)) != AT_CIND)
-		return -1;
-
-	pvt->nocallsetup = 1;
+	if (at_read_full(hfp->rsock, buf, sizeof(buf)) != AT_CIND)
+		return -1;
+
+	hfp->nocallsetup = 1;
 
 	/* parse the indications list.  It is in the follwing format:
 	 * +CIND: ("ind1",(0-1)),("ind2",(0-5))
@@ -2527,38 +2527,38 @@
 			}
 			break;
 		case 7: /* process the values we found */
-			if (group < sizeof(pvt->cind_index)) {
+			if (group < sizeof(hfp->cind_index)) {
 				if (!strcmp(indicator, "service")) {
-					pvt->cind_map.service = group;
-					pvt->cind_index[group] = HFP_CIND_SERVICE;
+					hfp->cind_map.service = group;
+					hfp->cind_index[group] = HFP_CIND_SERVICE;
 				} else if (!strcmp(indicator, "call")) {
-					pvt->cind_map.call = group;
-					pvt->cind_index[group] = HFP_CIND_CALL;
+					hfp->cind_map.call = group;
+					hfp->cind_index[group] = HFP_CIND_CALL;
 				} else if (!strcmp(indicator, "callsetup")) {
-					pvt->nocallsetup = 0;
-					pvt->cind_map.callsetup = group;
-					pvt->cind_index[group] = HFP_CIND_CALLSETUP;
+					hfp->nocallsetup = 0;
+					hfp->cind_map.callsetup = group;
+					hfp->cind_index[group] = HFP_CIND_CALLSETUP;
 				} else if (!strcmp(indicator, "call_setup")) { /* non standard call setup identifier */
-					pvt->nocallsetup = 0;
-					pvt->cind_map.callsetup = group;
-					pvt->cind_index[group] = HFP_CIND_CALLSETUP;
+					hfp->nocallsetup = 0;
+					hfp->cind_map.callsetup = group;
+					hfp->cind_index[group] = HFP_CIND_CALLSETUP;
 				} else if (!strcmp(indicator, "callheld")) {
-					pvt->cind_map.callheld = group;
-					pvt->cind_index[group] = HFP_CIND_CALLHELD;
+					hfp->cind_map.callheld = group;
+					hfp->cind_index[group] = HFP_CIND_CALLHELD;
 				} else if (!strcmp(indicator, "signal")) {
-					pvt->cind_map.signal = group;
-					pvt->cind_index[group] = HFP_CIND_SIGNAL;
+					hfp->cind_map.signal = group;
+					hfp->cind_index[group] = HFP_CIND_SIGNAL;
 				} else if (!strcmp(indicator, "roam")) {
-					pvt->cind_map.roam = group;
-					pvt->cind_index[group] = HFP_CIND_ROAM;
+					hfp->cind_map.roam = group;
+					hfp->cind_index[group] = HFP_CIND_ROAM;
 				} else if (!strcmp(indicator, "battchg")) {
-					pvt->cind_map.battchg = group;
-					pvt->cind_index[group] = HFP_CIND_BATTCHG;
+					hfp->cind_map.battchg = group;
+					hfp->cind_index[group] = HFP_CIND_BATTCHG;
 				} else {
 					ast_debug(2, "ignoring unknown CIND indicator '%s'\n", indicator);
 				}
 			} else {
-					ast_debug(1, "can't store indicator %d (%s), we only support up to %d indicators", group, indicator, (int) sizeof(pvt->cind_index));
+					ast_debug(1, "can't store indicator %d (%s), we only support up to %d indicators", group, indicator, (int) sizeof(hfp->cind_index));
 			}
 
 			state = 0;
@@ -2566,10 +2566,10 @@
 		}
 	}
 
-	pvt->owner->no_callsetup = pvt->nocallsetup;
+	hfp->owner->no_callsetup = hfp->nocallsetup;
 	
 	/* read the OK message */
-	if (!hfp_wait(pvt) || at_read(pvt->rsock) != AT_OK)
+	if (!hfp_wait(hfp) || at_read(hfp->rsock) != AT_OK)
 		return -1;
 
 	return 0;




More information about the svn-commits mailing list