From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH v2] emulator: add AT+CMEE support for HFP
Date: Tue, 26 Apr 2011 14:18:18 -0500 [thread overview]
Message-ID: <4DB71A7A.608@gmail.com> (raw)
In-Reply-To: <1303299295-4080-1-git-send-email-frederic.danis@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 4433 bytes --]
Hi Frédéric,
On 04/20/2011 06:34 AM, Frédéric Danis wrote:
> ---
> src/emulator.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 73 insertions(+), 1 deletions(-)
>
> diff --git a/src/emulator.c b/src/emulator.c
> index 9b4647b..cffda21 100644
> --- a/src/emulator.c
> +++ b/src/emulator.c
> @@ -51,6 +51,7 @@ struct ofono_emulator {
> int r_features;
> int events_mode;
> gboolean events_ind;
> + unsigned char cme_error_ind;
Please name this cmee_mode;
> GSList *indicators;
> guint callsetup_source;
> gboolean clip;
> @@ -569,6 +570,52 @@ fail:
> };
> }
>
> +static void cmee_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 > 1)
> + goto fail;
> +
> + em->cme_error_ind = val;
> +
> + sprintf(buf, "+CMEE: %d", em->cme_error_ind);
> + g_at_server_send_info(em->server, buf, TRUE);
The CMEE set command should not result in the current mode being
printed, right?
> + g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
> + break;
> +
> + case G_AT_SERVER_REQUEST_TYPE_QUERY:
> + sprintf(buf, "+CMEE: %d", em->cme_error_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:
> + /* HFP only support 0 and 1 */
> + sprintf(buf, "+CMEE: (0,1)");
> + 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 emulator_add_indicator(struct ofono_emulator *em, const char* name,
> int min, int max, int dflt)
> {
> @@ -656,6 +703,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
> g_at_server_register(em->server, "+CMER", cmer_cb, em, NULL);
> g_at_server_register(em->server, "+CLIP", clip_cb, em, NULL);
> g_at_server_register(em->server, "+CCWA", ccwa_cb, em, NULL);
> + g_at_server_register(em->server, "+CMEE", cmee_cb, em, NULL);
> }
>
> __ofono_atom_register(em->atom, emulator_unregister);
> @@ -699,6 +747,7 @@ struct ofono_emulator *ofono_emulator_create(struct ofono_modem *modem,
> /* TODO: Check real local features */
> em->l_features = 32;
> em->events_mode = 3; /* default mode is forwarding events */
> + em->cme_error_ind = 0; /* CME ERROR disabled by default */
>
> em->atom = __ofono_modem_add_atom_offline(modem, atom_t,
> emulator_remove, em);
> @@ -727,7 +776,23 @@ void ofono_emulator_send_final(struct ofono_emulator *em,
> break;
>
> case OFONO_ERROR_TYPE_CME:
> - sprintf(buf, "+CME ERROR: %d", final->error);
> + /* default string */
> + sprintf(buf, "ERROR");
What exactly is this for? The default case goes to failure label anyway
> +
> + switch (em->cme_error_ind) {
> + case 1:
> + sprintf(buf, "+CME ERROR: %d", final->error);
> + break;
> +
> + case 2:
> + sprintf(buf, "+CME ERROR: %s",
> + telephony_error_to_str(final));
> + break;
> +
> + default:
> + goto failure;
> + }
> +
> g_at_server_send_ext_final(em->server, buf);
> break;
>
> @@ -738,6 +803,13 @@ void ofono_emulator_send_final(struct ofono_emulator *em,
> case OFONO_ERROR_TYPE_CEER:
> case OFONO_ERROR_TYPE_SIM:
> case OFONO_ERROR_TYPE_FAILURE:
> +failure:
> + if (final->error == 30) {
> + g_at_server_send_final(em->server,
> + G_AT_SERVER_RESULT_NO_CARRIER);
> + break;
> + }
What is this magic trying to do? If you really want to send a NO
CARRIER, then I suggest using the g_at_server_send_final directly from
the callback. Unless you want to do this for voicecalls...? If so,
then inventing a new ofono error type might be better. Drop this change
for now.
> +
> g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
> break;
> };
Regards,
-Denis
prev parent reply other threads:[~2011-04-26 19:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-20 11:34 [PATCH v2] emulator: add AT+CMEE support for HFP =?unknown-8bit?q?Fr=C3=A9d=C3=A9ric?= Danis
2011-04-26 19:18 ` Denis Kenzior [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=4DB71A7A.608@gmail.com \
--to=denkenz@gmail.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 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.