* [PATCH] emulator: add AT hook_control_cb() CB and register it
@ 2011-03-24 10:25 Guillaume Zajac
2011-03-30 3:49 ` Denis Kenzior
0 siblings, 1 reply; 4+ messages in thread
From: Guillaume Zajac @ 2011-03-24 10:25 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1839 bytes --]
---
src/emulator.c | 44 +++++++++++++++++++++++++++++++++++++++++---
1 files changed, 41 insertions(+), 3 deletions(-)
diff --git a/src/emulator.c b/src/emulator.c
index c84f0a9..586c7ec 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -177,6 +177,41 @@ error:
g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
}
+static void hook_control_cb(GAtServer *server, GAtServerRequestType type,
+ GAtResult *result, gpointer user_data)
+{
+ struct ofono_emulator *em = user_data;
+ GAtResultIter iter;
+ int val;
+
+ DBG("");
+
+ if (type != G_AT_SERVER_REQUEST_TYPE_SET)
+ goto error;
+
+ if (em->ppp == NULL)
+ goto error;
+
+ g_at_result_iter_init(&iter, result);
+ g_at_result_iter_next(&iter, "");
+
+ if (g_at_result_iter_next_number(&iter, &val) == FALSE)
+ goto error;
+
+ if (val != 0)
+ goto error;
+
+ g_at_ppp_unref(em->ppp);
+ em->ppp = NULL;
+
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+
+ return;
+
+error:
+ g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+}
+
static void brsf_cb(GAtServer *server, GAtServerRequestType type,
GAtResult *result, gpointer user_data)
{
@@ -466,10 +501,13 @@ 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);
- else if (em->type == OFONO_EMULATOR_TYPE_HFP)
- g_at_server_set_echo(em->server, FALSE);
+ g_at_server_register(em->server, "H", hook_control_cb, em, NULL);
+ } else {
+ if (em->type == OFONO_EMULATOR_TYPE_HFP)
+ g_at_server_set_echo(em->server, FALSE);
+ }
}
static void emulator_remove(struct ofono_atom *atom)
--
1.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] emulator: add AT hook_control_cb() CB and register it
2011-03-24 10:25 [PATCH] emulator: add AT hook_control_cb() CB and register it Guillaume Zajac
@ 2011-03-30 3:49 ` Denis Kenzior
2011-03-30 8:02 ` Guillaume Zajac
0 siblings, 1 reply; 4+ messages in thread
From: Denis Kenzior @ 2011-03-30 3:49 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2257 bytes --]
Hi Guillaume,
On 03/24/2011 05:25 AM, Guillaume Zajac wrote:
> ---
> src/emulator.c | 44 +++++++++++++++++++++++++++++++++++++++++---
> 1 files changed, 41 insertions(+), 3 deletions(-)
>
> diff --git a/src/emulator.c b/src/emulator.c
> index c84f0a9..586c7ec 100644
> --- a/src/emulator.c
> +++ b/src/emulator.c
> @@ -177,6 +177,41 @@ error:
> g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
> }
>
> +static void hook_control_cb(GAtServer *server, GAtServerRequestType type,
Can you rename this dun_ath_cb, since this is pretty much dun specific
> + GAtResult *result, gpointer user_data)
> +{
> + struct ofono_emulator *em = user_data;
> + GAtResultIter iter;
> + int val;
> +
> + DBG("");
> +
> + if (type != G_AT_SERVER_REQUEST_TYPE_SET)
> + goto error;
Wouldn't we be also getting G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY here?
> +
> + if (em->ppp == NULL)
> + goto error;
> +
> + g_at_result_iter_init(&iter, result);
> + g_at_result_iter_next(&iter, "");
> +
> + if (g_at_result_iter_next_number(&iter, &val) == FALSE)
> + goto error;
> +
> + if (val != 0)
> + goto error;
> +
> + g_at_ppp_unref(em->ppp);
> + em->ppp = NULL;
> +
> + g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
> +
> + return;
> +
> +error:
> + g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
> +}
> +
> static void brsf_cb(GAtServer *server, GAtServerRequestType type,
> GAtResult *result, gpointer user_data)
> {
> @@ -466,10 +501,13 @@ 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);
> - else if (em->type == OFONO_EMULATOR_TYPE_HFP)
> - g_at_server_set_echo(em->server, FALSE);
> + g_at_server_register(em->server, "H", hook_control_cb, em, NULL);
> + } else {
> + if (em->type == OFONO_EMULATOR_TYPE_HFP)
> + g_at_server_set_echo(em->server, FALSE);
I'd really prefer this to use a switch/case statement.
> + }
> }
>
> static void emulator_remove(struct ofono_atom *atom)
Regards,
-Denis
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] emulator: add AT hook_control_cb() CB and register it
2011-03-30 3:49 ` Denis Kenzior
@ 2011-03-30 8:02 ` Guillaume Zajac
2011-03-30 14:39 ` Denis Kenzior
0 siblings, 1 reply; 4+ messages in thread
From: Guillaume Zajac @ 2011-03-30 8:02 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2722 bytes --]
Hi Denis,
On 30/03/2011 05:49, Denis Kenzior wrote:
> Hi Guillaume,
>
> On 03/24/2011 05:25 AM, Guillaume Zajac wrote:
>> ---
>> src/emulator.c | 44 +++++++++++++++++++++++++++++++++++++++++---
>> 1 files changed, 41 insertions(+), 3 deletions(-)
>>
>> diff --git a/src/emulator.c b/src/emulator.c
>> index c84f0a9..586c7ec 100644
>> --- a/src/emulator.c
>> +++ b/src/emulator.c
>> @@ -177,6 +177,41 @@ error:
>> g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
>> }
>>
>> +static void hook_control_cb(GAtServer *server, GAtServerRequestType type,
> Can you rename this dun_ath_cb, since this is pretty much dun specific
Ok I will do it.
>> + GAtResult *result, gpointer user_data)
>> +{
>> + struct ofono_emulator *em = user_data;
>> + GAtResultIter iter;
>> + int val;
>> +
>> + DBG("");
>> +
>> + if (type != G_AT_SERVER_REQUEST_TYPE_SET)
>> + goto error;
> Wouldn't we be also getting G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY here?
Sorry I forgot it. I will add thise case.
>> +
>> + if (em->ppp == NULL)
>> + goto error;
>> +
>> + g_at_result_iter_init(&iter, result);
>> + g_at_result_iter_next(&iter, "");
>> +
>> + if (g_at_result_iter_next_number(&iter,&val) == FALSE)
>> + goto error;
>> +
>> + if (val != 0)
>> + goto error;
>> +
>> + g_at_ppp_unref(em->ppp);
>> + em->ppp = NULL;
>> +
>> + g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
>> +
>> + return;
>> +
>> +error:
>> + g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
>> +}
>> +
>> static void brsf_cb(GAtServer *server, GAtServerRequestType type,
>> GAtResult *result, gpointer user_data)
>> {
>> @@ -466,10 +501,13 @@ 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);
>> - else if (em->type == OFONO_EMULATOR_TYPE_HFP)
>> - g_at_server_set_echo(em->server, FALSE);
>> + g_at_server_register(em->server, "H", hook_control_cb, em, NULL);
>> + } else {
>> + if (em->type == OFONO_EMULATOR_TYPE_HFP)
>> + g_at_server_set_echo(em->server, FALSE);
> I'd really prefer this to use a switch/case statement.
Ok.
>> + }
>> }
>>
>> static void emulator_remove(struct ofono_atom *atom)
This patch is also in the set of patches I have sent for escape sequence
detection because I needed it to complete gsmdial tests.
Should I resend the set of patches with this patch updated ? or I should
wait for your feedback on the complete set of patches?
Kind regards,
Guillaume
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-30 14:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-24 10:25 [PATCH] emulator: add AT hook_control_cb() CB and register it Guillaume Zajac
2011-03-30 3:49 ` Denis Kenzior
2011-03-30 8:02 ` Guillaume Zajac
2011-03-30 14:39 ` 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.