All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] bluetooth: add CMER and BRSF support in HFP AG
@ 2011-02-23 19:00 =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-02-23 19:00 ` [PATCH 1/2] emulator: add CMER support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-02-23 19:00 ` [PATCH 2/2] emulator: add BRSF support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  0 siblings, 2 replies; 6+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-02-23 19:00 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 312 bytes --]

Add CMER and simple BRSF support for HFP AG allowing to setup Service
Level Connection

Frédéric Danis (2):
  emulator: add CMER support
  emulator: add BRSF support

 src/emulator.c |  150 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 148 insertions(+), 2 deletions(-)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] emulator: add CMER support
  2011-02-23 19:00 [PATCH 0/2] bluetooth: add CMER and BRSF support in HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-02-23 19:00 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-02-23 20:13   ` Denis Kenzior
  2011-02-23 19:00 ` [PATCH 2/2] emulator: add BRSF support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  1 sibling, 1 reply; 6+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-02-23 19:00 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 3876 bytes --]

---
 src/emulator.c |  107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 105 insertions(+), 2 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index f0ca8c8..ca36c0e 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -43,6 +43,8 @@ struct ofono_emulator {
 	GAtServer *server;
 	GAtPPP *ppp;
 	guint source;
+	int events_mode;
+	gboolean events_ind;
 	GSList *indicators;
 };
 
@@ -251,6 +253,103 @@ fail:
 	}
 }
 
+static void cmer_cb(GAtServer *server, GAtServerRequestType type,
+			GAtResult *result, gpointer user_data)
+{
+	struct ofono_emulator *em = user_data;
+	char buf[32];
+
+	switch (type) {
+	case G_AT_SERVER_REQUEST_TYPE_QUERY:
+		sprintf(buf, "+CMER: %d,0,0,%d,0", em->events_mode,
+						em->events_ind);
+		g_at_server_send_info(em->server, buf, TRUE);
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+		break;
+
+	case G_AT_SERVER_REQUEST_TYPE_SUPPORT:
+		sprintf(buf, "+CMER: (0,3),(0),(0),(0,1),(0)");
+		g_at_server_send_info(em->server, buf, TRUE);
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+		break;
+
+	case G_AT_SERVER_REQUEST_TYPE_SET:
+	{
+		GAtResultIter iter;
+		int mode;
+		int ind = em->events_ind;
+		int val;
+
+		g_at_result_iter_init(&iter, result);
+		g_at_result_iter_next(&iter, "");
+
+		/* mode */
+		if (g_at_result_iter_next_number(&iter, &mode) == FALSE)
+			goto fail;
+
+		if ((mode != 0) && (mode != 3))
+			goto fail;
+
+		/* keyp */
+		if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
+			if (g_at_result_iter_skip_next(&iter) == FALSE)
+				goto done;
+			goto fail;
+		}
+
+		if (val != 0)
+			goto fail;
+
+		/* disp */
+		if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
+			if (g_at_result_iter_skip_next(&iter) == FALSE)
+				goto done;
+			goto fail;
+		}
+
+		if (val != 0)
+			goto fail;
+
+		/* ind */
+		if (g_at_result_iter_next_number(&iter, &ind) == FALSE) {
+			if (g_at_result_iter_skip_next(&iter) == FALSE)
+				goto done;
+			goto fail;
+		}
+
+		if ((ind != 0) && (ind != 1))
+			goto fail;
+
+		/* bfr */
+		if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
+			if (g_at_result_iter_skip_next(&iter) == FALSE)
+				goto done;
+			goto fail;
+		}
+
+		if (val != 0)
+			goto fail;
+
+		/* check that bfr is last parameter */
+		if (g_at_result_iter_skip_next(&iter) == TRUE)
+			goto fail;
+
+done:
+		em->events_mode = mode;
+		em->events_ind = ind;
+
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+
+		break;
+	}
+
+	default:
+fail:
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+		break;
+	}
+}
+
 static void emulator_add_indicator(struct ofono_emulator *em, const char* name,
 					int min, int max, int dflt)
 {
@@ -324,6 +423,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 		emulator_add_indicator(em, OFONO_EMULATOR_IND_BATTERY, 0, 5, 5);
 
 		g_at_server_register(em->server, "+CIND", cind_cb, em, NULL);
+		g_at_server_register(em->server, "+CMER", cmer_cb, em, NULL);
 	}
 
 	__ofono_atom_register(em->atom, emulator_unregister);
@@ -364,6 +464,7 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
 		return NULL;
 
 	em->type = type;
+	em->events_mode = 3;	/* default mode is forwarding events */
 
 	em->atom = __ofono_modem_add_atom_offline(modem, atom_t,
 							emulator_remove, em);
@@ -546,8 +647,10 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
 
 		ind->value = value;
 
-		sprintf(buf, "+CIEV: %d,%d", i, ind->value);
-		g_at_server_send_info(em->server, buf, TRUE);
+		if (em->events_mode == 3 && em->events_ind) {
+			sprintf(buf, "+CIEV: %d,%d", i, ind->value);
+			g_at_server_send_info(em->server, buf, TRUE);
+		}
 
 		return;
 	}
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] emulator: add BRSF support
  2011-02-23 19:00 [PATCH 0/2] bluetooth: add CMER and BRSF support in HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-02-23 19:00 ` [PATCH 1/2] emulator: add CMER support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-02-23 19:00 ` =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
  2011-02-23 20:13   ` Denis Kenzior
  1 sibling, 1 reply; 6+ messages in thread
From: =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis @ 2011-02-23 19:00 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 3137 bytes --]

---
 src/emulator.c |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 44 insertions(+), 1 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index ca36c0e..f024468 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -43,6 +43,9 @@ struct ofono_emulator {
 	GAtServer *server;
 	GAtPPP *ppp;
 	guint source;
+	gboolean slc;
+	int l_features;
+	int r_features;
 	int events_mode;
 	gboolean events_ind;
 	GSList *indicators;
@@ -174,6 +177,39 @@ error:
        g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
 }
 
+static void brsf_cb(GAtServer *server, GAtServerRequestType type,
+			GAtResult *result, gpointer user_data)
+{
+	struct ofono_emulator *em = user_data;
+	GAtResultIter iter;
+	int val;
+	char buf[16];
+
+	switch (type) {
+	case G_AT_SERVER_REQUEST_TYPE_SET:
+		g_at_result_iter_init(&iter, result);
+		g_at_result_iter_next(&iter, "");
+
+		if (g_at_result_iter_next_number(&iter, &val) == FALSE)
+			goto fail;
+
+		if ((val < 0) && (val > 127))
+			goto fail;
+
+		em->r_features = val;
+
+		sprintf(buf, "+BRSF: %d", em->l_features);
+		g_at_server_send_info(em->server, buf, TRUE);
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+		break;
+
+	default:
+fail:
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+		break;
+	}
+}
+
 static void cind_cb(GAtServer *server, GAtServerRequestType type,
 			GAtResult *result, gpointer user_data)
 {
@@ -340,6 +376,7 @@ done:
 
 		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
 
+		em->slc = TRUE;
 		break;
 	}
 
@@ -422,6 +459,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 		emulator_add_indicator(em, OFONO_EMULATOR_IND_ROAMING, 0, 1, 0);
 		emulator_add_indicator(em, OFONO_EMULATOR_IND_BATTERY, 0, 5, 5);
 
+		g_at_server_register(em->server, "+BRSF", brsf_cb, em, NULL);
 		g_at_server_register(em->server, "+CIND", cind_cb, em, NULL);
 		g_at_server_register(em->server, "+CMER", cmer_cb, em, NULL);
 	}
@@ -464,6 +502,8 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
 		return NULL;
 
 	em->type = type;
+	/* TODO: Check real local features */
+	em->l_features = 32;
 	em->events_mode = 3;	/* default mode is forwarding events */
 
 	em->atom = __ofono_modem_add_atom_offline(modem, atom_t,
@@ -545,6 +585,9 @@ static void handler_proxy(GAtServer *server, GAtServerRequestType type,
 	struct handler *h = userdata;
 	struct ofono_emulator_request req;
 
+	if ((h->em->type == OFONO_EMULATOR_TYPE_HFP) && !h->em->slc)
+		g_at_server_send_final(h->em->server, G_AT_SERVER_RESULT_ERROR);
+
 	switch (type) {
 	case G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY:
 		req.type = OFONO_EMULATOR_REQUEST_TYPE_COMMAND_ONLY;
@@ -647,7 +690,7 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
 
 		ind->value = value;
 
-		if (em->events_mode == 3 && em->events_ind) {
+		if (em->events_mode == 3 && em->events_ind && em->slc) {
 			sprintf(buf, "+CIEV: %d,%d", i, ind->value);
 			g_at_server_send_info(em->server, buf, TRUE);
 		}
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] emulator: add CMER support
  2011-02-23 19:00 ` [PATCH 1/2] emulator: add CMER support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-02-23 20:13   ` Denis Kenzior
  2011-02-24 10:56     ` Frederic Danis
  0 siblings, 1 reply; 6+ messages in thread
From: Denis Kenzior @ 2011-02-23 20:13 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 4631 bytes --]

Hi Frédéric,

On 02/23/2011 01:00 PM, Frédéric Danis wrote:
> ---
>  src/emulator.c |  107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 105 insertions(+), 2 deletions(-)

I applied this patch, but one comment below:

> 
> diff --git a/src/emulator.c b/src/emulator.c
> index f0ca8c8..ca36c0e 100644
> --- a/src/emulator.c
> +++ b/src/emulator.c
> @@ -43,6 +43,8 @@ struct ofono_emulator {
>  	GAtServer *server;
>  	GAtPPP *ppp;
>  	guint source;
> +	int events_mode;
> +	gboolean events_ind;
>  	GSList *indicators;
>  };
>  
> @@ -251,6 +253,103 @@ fail:
>  	}
>  }
>  
> +static void cmer_cb(GAtServer *server, GAtServerRequestType type,
> +			GAtResult *result, gpointer user_data)
> +{
> +	struct ofono_emulator *em = user_data;
> +	char buf[32];
> +
> +	switch (type) {
> +	case G_AT_SERVER_REQUEST_TYPE_QUERY:
> +		sprintf(buf, "+CMER: %d,0,0,%d,0", em->events_mode,
> +						em->events_ind);
> +		g_at_server_send_info(em->server, buf, TRUE);
> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
> +		break;
> +
> +	case G_AT_SERVER_REQUEST_TYPE_SUPPORT:
> +		sprintf(buf, "+CMER: (0,3),(0),(0),(0,1),(0)");
> +		g_at_server_send_info(em->server, buf, TRUE);
> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
> +		break;
> +
> +	case G_AT_SERVER_REQUEST_TYPE_SET:
> +	{
> +		GAtResultIter iter;
> +		int mode;
> +		int ind = em->events_ind;
> +		int val;
> +
> +		g_at_result_iter_init(&iter, result);
> +		g_at_result_iter_next(&iter, "");
> +
> +		/* mode */
> +		if (g_at_result_iter_next_number(&iter, &mode) == FALSE)
> +			goto fail;
> +
> +		if ((mode != 0) && (mode != 3))
> +			goto fail;
> +
> +		/* keyp */
> +		if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
> +			if (g_at_result_iter_skip_next(&iter) == FALSE)
> +				goto done;
> +			goto fail;
> +		}

From what I understand you're trying to enable something like:

+CMER=3,,1 right?

So this code does accomplish this, but it also allows silliness like this:

+CMER=3,"foobar",,1

You might want to make a special version of next_number that would
actually check that either the number is given, or the field is empty.

> +
> +		if (val != 0)
> +			goto fail;
> +
> +		/* disp */
> +		if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
> +			if (g_at_result_iter_skip_next(&iter) == FALSE)
> +				goto done;
> +			goto fail;
> +		}
> +
> +		if (val != 0)
> +			goto fail;
> +
> +		/* ind */
> +		if (g_at_result_iter_next_number(&iter, &ind) == FALSE) {
> +			if (g_at_result_iter_skip_next(&iter) == FALSE)
> +				goto done;
> +			goto fail;
> +		}
> +
> +		if ((ind != 0) && (ind != 1))
> +			goto fail;
> +
> +		/* bfr */
> +		if (g_at_result_iter_next_number(&iter, &val) == FALSE) {
> +			if (g_at_result_iter_skip_next(&iter) == FALSE)
> +				goto done;
> +			goto fail;
> +		}
> +
> +		if (val != 0)
> +			goto fail;
> +
> +		/* check that bfr is last parameter */
> +		if (g_at_result_iter_skip_next(&iter) == TRUE)
> +			goto fail;
> +
> +done:
> +		em->events_mode = mode;
> +		em->events_ind = ind;
> +
> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
> +
> +		break;
> +	}
> +
> +	default:
> +fail:
> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
> +		break;
> +	}
> +}
> +
>  static void emulator_add_indicator(struct ofono_emulator *em, const char* name,
>  					int min, int max, int dflt)
>  {
> @@ -324,6 +423,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
>  		emulator_add_indicator(em, OFONO_EMULATOR_IND_BATTERY, 0, 5, 5);
>  
>  		g_at_server_register(em->server, "+CIND", cind_cb, em, NULL);
> +		g_at_server_register(em->server, "+CMER", cmer_cb, em, NULL);
>  	}
>  
>  	__ofono_atom_register(em->atom, emulator_unregister);
> @@ -364,6 +464,7 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
>  		return NULL;
>  
>  	em->type = type;
> +	em->events_mode = 3;	/* default mode is forwarding events */
>  
>  	em->atom = __ofono_modem_add_atom_offline(modem, atom_t,
>  							emulator_remove, em);
> @@ -546,8 +647,10 @@ void ofono_emulator_set_indicator(struct ofono_emulator *em,
>  
>  		ind->value = value;
>  
> -		sprintf(buf, "+CIEV: %d,%d", i, ind->value);
> -		g_at_server_send_info(em->server, buf, TRUE);
> +		if (em->events_mode == 3 && em->events_ind) {
> +			sprintf(buf, "+CIEV: %d,%d", i, ind->value);
> +			g_at_server_send_info(em->server, buf, TRUE);
> +		}
>  
>  		return;
>  	}

Regards,
-Denis

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] emulator: add BRSF support
  2011-02-23 19:00 ` [PATCH 2/2] emulator: add BRSF support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
@ 2011-02-23 20:13   ` Denis Kenzior
  0 siblings, 0 replies; 6+ messages in thread
From: Denis Kenzior @ 2011-02-23 20:13 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 259 bytes --]

Hi Frédéric,

On 02/23/2011 01:00 PM, Frédéric Danis wrote:
> ---
>  src/emulator.c |   45 ++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 44 insertions(+), 1 deletions(-)
> 

Patch has been applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] emulator: add CMER support
  2011-02-23 20:13   ` Denis Kenzior
@ 2011-02-24 10:56     ` Frederic Danis
  0 siblings, 0 replies; 6+ messages in thread
From: Frederic Danis @ 2011-02-24 10:56 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2841 bytes --]

Hi Denis

Le 23/02/2011 21:13, Denis Kenzior a écrit :
> Hi Frédéric,
>
> On 02/23/2011 01:00 PM, Frédéric Danis wrote:
>> ---
>>   src/emulator.c |  107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>>   1 files changed, 105 insertions(+), 2 deletions(-)
>
> I applied this patch, but one comment below:
>
>>
>> diff --git a/src/emulator.c b/src/emulator.c
>> index f0ca8c8..ca36c0e 100644
>> --- a/src/emulator.c
>> +++ b/src/emulator.c
>> @@ -43,6 +43,8 @@ struct ofono_emulator {
>>   	GAtServer *server;
>>   	GAtPPP *ppp;
>>   	guint source;
>> +	int events_mode;
>> +	gboolean events_ind;
>>   	GSList *indicators;
>>   };
>>
>> @@ -251,6 +253,103 @@ fail:
>>   	}
>>   }
>>
>> +static void cmer_cb(GAtServer *server, GAtServerRequestType type,
>> +			GAtResult *result, gpointer user_data)
>> +{
>> +	struct ofono_emulator *em = user_data;
>> +	char buf[32];
>> +
>> +	switch (type) {
>> +	case G_AT_SERVER_REQUEST_TYPE_QUERY:
>> +		sprintf(buf, "+CMER: %d,0,0,%d,0", em->events_mode,
>> +						em->events_ind);
>> +		g_at_server_send_info(em->server, buf, TRUE);
>> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
>> +		break;
>> +
>> +	case G_AT_SERVER_REQUEST_TYPE_SUPPORT:
>> +		sprintf(buf, "+CMER: (0,3),(0),(0),(0,1),(0)");
>> +		g_at_server_send_info(em->server, buf, TRUE);
>> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
>> +		break;
>> +
>> +	case G_AT_SERVER_REQUEST_TYPE_SET:
>> +	{
>> +		GAtResultIter iter;
>> +		int mode;
>> +		int ind = em->events_ind;
>> +		int val;
>> +
>> +		g_at_result_iter_init(&iter, result);
>> +		g_at_result_iter_next(&iter, "");
>> +
>> +		/* mode */
>> +		if (g_at_result_iter_next_number(&iter,&mode) == FALSE)
>> +			goto fail;
>> +
>> +		if ((mode != 0)&&  (mode != 3))
>> +			goto fail;
>> +
>> +		/* keyp */
>> +		if (g_at_result_iter_next_number(&iter,&val) == FALSE) {
>> +			if (g_at_result_iter_skip_next(&iter) == FALSE)
>> +				goto done;
>> +			goto fail;
>> +		}
>
>> From what I understand you're trying to enable something like:
>
> +CMER=3,,1 right?
>
> So this code does accomplish this, but it also allows silliness like this:
>
> +CMER=3,"foobar",,1
>
> You might want to make a special version of next_number that would
> actually check that either the number is given, or the field is empty.
>

The current version check that the parameter is a number or the end 
(skip_next returns false) :
AT+CMER=3,0,0,1,0 or AT+CMER=3,0 are supported.

Currently void parameter are not supported (AT+CMER=3,,,1).

I will send a patch to support number or void parameter.

Regards

Fred

-- 
Frederic Danis                            Open Source Technology Centre
frederic.danis(a)intel.com                              Intel Corporation


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-02-24 10:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-23 19:00 [PATCH 0/2] bluetooth: add CMER and BRSF support in HFP AG =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-23 19:00 ` [PATCH 1/2] emulator: add CMER support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-23 20:13   ` Denis Kenzior
2011-02-24 10:56     ` Frederic Danis
2011-02-23 19:00 ` [PATCH 2/2] emulator: add BRSF support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-02-23 20:13   ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.