* [PATCH] dun: Add ATX command in emulator (X0 only)
@ 2011-03-24 15:29 Olivier Guiter
2011-03-25 17:36 ` Denis Kenzior
0 siblings, 1 reply; 4+ messages in thread
From: Olivier Guiter @ 2011-03-24 15:29 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2290 bytes --]
---
src/emulator.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 56 insertions(+), 1 deletions(-)
diff --git a/src/emulator.c b/src/emulator.c
index c84f0a9..101d6b8 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -177,6 +177,59 @@ error:
g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
}
+static gboolean get_result_value(GAtServer *server, GAtResult *result,
+ int min, int max, int *value)
+{
+ GAtResultIter iter;
+ int val;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, ""))
+ return FALSE;
+
+ if (!g_at_result_iter_next_number(&iter, &val))
+ return FALSE;
+
+ if (val < min || val > max)
+ return FALSE;
+
+ if (value != NULL)
+ *value = val;
+
+ return TRUE;
+}
+
+static void at_x_cb(GAtServer *server, GAtServerRequestType type,
+ GAtResult *result, gpointer user_data)
+{
+ switch (type) {
+ case G_AT_SERVER_REQUEST_TYPE_SET:
+ if (!get_result_value(server, result, 0, 0, NULL)) {
+ g_at_server_send_final(server,
+ G_AT_SERVER_RESULT_ERROR);
+ return;
+ }
+ /* the value is not stored, as there's only one choice */
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+ break;
+
+ case G_AT_SERVER_REQUEST_TYPE_QUERY:
+ g_at_server_send_info(server, "000", TRUE);
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+ break;
+
+ case G_AT_SERVER_REQUEST_TYPE_SUPPORT:
+ g_at_server_send_info(server, "X: (0-0)", TRUE);
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+ break;
+
+ default:
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+ break;
+ }
+}
+
static void brsf_cb(GAtServer *server, GAtServerRequestType type,
GAtResult *result, gpointer user_data)
{
@@ -466,8 +519,10 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
__ofono_atom_register(em->atom, emulator_unregister);
- if (em->type == OFONO_EMULATOR_TYPE_DUN)
+ if (em->type == OFONO_EMULATOR_TYPE_DUN) {
g_at_server_register(em->server, "D", dial_cb, em, NULL);
+ g_at_server_register(em->server, "X", at_x_cb, em, NULL);
+ }
else if (em->type == OFONO_EMULATOR_TYPE_HFP)
g_at_server_set_echo(em->server, FALSE);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] dun: Add ATX command in emulator (X0 only)
2011-03-24 15:29 [PATCH] dun: Add ATX command in emulator (X0 only) Olivier Guiter
@ 2011-03-25 17:36 ` Denis Kenzior
2011-03-28 7:49 ` Olivier Guiter
0 siblings, 1 reply; 4+ messages in thread
From: Denis Kenzior @ 2011-03-25 17:36 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 508 bytes --]
Hi Olivier,
On 03/24/2011 10:29 AM, Olivier Guiter wrote:
> ---
> src/emulator.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 56 insertions(+), 1 deletions(-)
>
I applied this patch, however...
<snip>
> + case G_AT_SERVER_REQUEST_TYPE_QUERY:
> + g_at_server_send_info(server, "000", TRUE);
This seems fishy to me. Shouldn't this be X: 0?
> + g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
> + break;
<snip>
Regards,
-Denis
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] dun: Add ATX command in emulator (X0 only)
2011-03-25 17:36 ` Denis Kenzior
@ 2011-03-28 7:49 ` Olivier Guiter
2011-03-28 16:20 ` Denis Kenzior
0 siblings, 1 reply; 4+ messages in thread
From: Olivier Guiter @ 2011-03-28 7:49 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 710 bytes --]
On 03/25/2011 06:36 PM, Denis Kenzior wrote:
> Hi Olivier,
>
> On 03/24/2011 10:29 AM, Olivier Guiter wrote:
>> ---
>> src/emulator.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>> 1 files changed, 56 insertions(+), 1 deletions(-)
>>
> I applied this patch, however...
>
> <snip>
>
>> + case G_AT_SERVER_REQUEST_TYPE_QUERY:
>> + g_at_server_send_info(server, "000", TRUE);
> This seems fishy to me. Shouldn't this be X: 0?
>
>> + g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
>> + break;
> <snip>
>
> Regards,
> -Denis
It should be ;) but i tried to keep the answer format consistent with
other AT command answers... Maybe i m wrong ?
Olivier
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] dun: Add ATX command in emulator (X0 only)
2011-03-28 7:49 ` Olivier Guiter
@ 2011-03-28 16:20 ` Denis Kenzior
0 siblings, 0 replies; 4+ messages in thread
From: Denis Kenzior @ 2011-03-28 16:20 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 974 bytes --]
Hi Olivier,
On 03/28/2011 02:49 AM, Olivier Guiter wrote:
> On 03/25/2011 06:36 PM, Denis Kenzior wrote:
>> Hi Olivier,
>>
>> On 03/24/2011 10:29 AM, Olivier Guiter wrote:
>>> ---
>>> src/emulator.c | 57
>>> +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>>> 1 files changed, 56 insertions(+), 1 deletions(-)
>>>
>> I applied this patch, however...
>>
>> <snip>
>>
>>> + case G_AT_SERVER_REQUEST_TYPE_QUERY:
>>> + g_at_server_send_info(server, "000", TRUE);
>> This seems fishy to me. Shouldn't this be X: 0?
>>
>>> + g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
>>> + break;
>> <snip>
>>
>> Regards,
>> -Denis
> It should be ;) but i tried to keep the answer format consistent with
> other AT command answers... Maybe i m wrong ?
What other AT command answers?
Anyhow, I've reverted this patch for now since I realized that ATX is
already implemented in gatserver.c
Regards,
-Denis
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-28 16:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-24 15:29 [PATCH] dun: Add ATX command in emulator (X0 only) Olivier Guiter
2011-03-25 17:36 ` Denis Kenzior
2011-03-28 7:49 ` Olivier Guiter
2011-03-28 16:20 ` 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.