Open Source Telephony
 help / color / mirror / Atom feed
From: Frederic Danis <frederic.danis@linux.intel.com>
To: ofono@ofono.org
Subject: Re: [PATCH 4/4] emulator: add +COPS support
Date: Fri, 18 Mar 2011 10:13:52 +0100	[thread overview]
Message-ID: <4D832250.3080106@linux.intel.com> (raw)
In-Reply-To: <4D827AA4.4080306@gmail.com>

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

Hello Denis,

Le 17/03/2011 22:18, Denis Kenzior a écrit :
> Hi Frédéric,
>
> On 03/17/2011 11:50 AM, Frédéric Danis wrote:
>> This needs to be in emulator as HFP plugin should answer AT+COPS requests
>> even when oFono is not registered on network.
>> ---
>>   src/emulator.c |   72 ++++++++++++++++++++++++++++++++++++++++++++
>>   src/network.c  |   90 +++++++++++++++++++++++++++++++++++++++++++++++++++----
>>   2 files changed, 155 insertions(+), 7 deletions(-)
>>
>> diff --git a/src/emulator.c b/src/emulator.c
>> index 864e50b..eb4f49e 100644
>> --- a/src/emulator.c
>> +++ b/src/emulator.c
>> @@ -49,6 +49,8 @@ struct ofono_emulator {
>>   	int events_mode;
>>   	gboolean events_ind;
>>   	GSList *indicators;
>> +	char op_name[17];
>> +	int net_mode;
>>   };
>>
>>   struct indicator {
>> @@ -387,6 +389,59 @@ fail:
>>   	}
>>   }
>>
>> +static void cops_cb(GAtServer *server, GAtServerRequestType type,
>> +			GAtResult *result, gpointer user_data)
>> +{
>> +	struct ofono_emulator *em = user_data;
>> +	char buf[32];
>> +
>> +	if (em->type == OFONO_EMULATOR_TYPE_HFP&&  em->slc == FALSE) {
>> +		g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
>> +		return;
>> +	}
>> +
>
> There's no need for this if you use ofono_emulator_add_handler since the
> handler_proxy will take care of this detail.
>
>> +	switch (type) {
>> +	case G_AT_SERVER_REQUEST_TYPE_QUERY:
>> +		sprintf(buf, "+COPS: %d,0,\"%s\"", em->net_mode, em->op_name);
>> +		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 val;
>> +
>> +		g_at_result_iter_init(&iter, result);
>> +		g_at_result_iter_next(&iter, "");
>> +
>> +		if (!g_at_result_iter_next_number(&iter,&val))
>> +			goto fail;
>> +
>> +		if (val != 3)
>> +			goto fail;
>> +
>> +		if (!g_at_result_iter_next_number(&iter,&val))
>> +			goto fail;
>> +
>> +		if (val != 0)
>> +			goto fail;
>> +
>> +		/* check there is no more parameter */
>> +		if (g_at_result_iter_skip_next(&iter))
>> +			goto fail;
>> +
>> +		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;
>> +	}
>> +}
>> +
>
> Please move this function to netreg.c.  This should make this patch
> quite a bit simpler.
>
> <snip>
>
> Regards,
> -Denis

If this is moved to netreg.c, AT+COPS requests will not be handled when 
oFono modem is not online.
I understand that there is no problem to reply ERROR to AT+COPS?, but I 
think this is wrong for AT+COPS=3,0.
This is why I do this in emulator.c.

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


      reply	other threads:[~2011-03-18  9:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-17 16:50 [PATCH 0/4] HFP: add call, callsetup indicators and +COPS support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-03-17 16:50 ` [PATCH 1/4] emulator: add defines for call and callsetup indicators =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-03-17 16:50 ` [PATCH 2/4] emulator: add " =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-03-17 21:14   ` Denis Kenzior
2011-03-17 16:50 ` [PATCH 3/4] emulator: add API to set network mode and name =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-03-17 21:15   ` Denis Kenzior
2011-03-17 16:50 ` [PATCH 4/4] emulator: add +COPS support =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-03-17 21:18   ` Denis Kenzior
2011-03-18  9:13     ` Frederic Danis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D832250.3080106@linux.intel.com \
    --to=frederic.danis@linux.intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox