From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH] emulator: add AT+CMEE support for HFP
Date: Tue, 05 Apr 2011 00:40:47 -0500 [thread overview]
Message-ID: <4D9AAB5F.4050909@gmail.com> (raw)
In-Reply-To: <1301667693-7781-1-git-send-email-olivier.guiter@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 3965 bytes --]
Hi Olivier,
On 04/01/2011 09:21 AM, Olivier Guiter wrote:
> ---
> src/emulator.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> 1 files changed, 58 insertions(+), 1 deletions(-)
>
> diff --git a/src/emulator.c b/src/emulator.c
> index c84f0a9..24897b4 100644
> --- a/src/emulator.c
> +++ b/src/emulator.c
> @@ -29,6 +29,7 @@
> #include <glib.h>
>
> #include "ofono.h"
> +#include "common.h"
> #include "gatserver.h"
> #include "gatppp.h"
>
> @@ -48,6 +49,7 @@ struct ofono_emulator {
> int r_features;
> int events_mode;
> gboolean events_ind;
> + char cme_error_ind;
You probably want unsigned char here, since the value is never negative.
> GSList *indicators;
> };
>
> @@ -387,6 +389,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))
Please avoid unneeded parentheses whenever possible.
> + goto fail;
> +
> + em->cme_error_ind = (char)val;
Do you really need this cast?
> +
> + 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_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)
> {
> @@ -462,6 +510,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
> 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);
> + g_at_server_register(em->server, "+CMEE", cmee_cb, em, NULL);
> }
>
> __ofono_atom_register(em->atom, emulator_unregister);
> @@ -505,6 +554,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; /* numeric only */
The comment does not match the initializer? Do you really mean numeric
only here (e.g. CMEE=1) or something like disable cme-error? What
default does BT-HFP spec suggests?
>
> em->atom = __ofono_modem_add_atom_offline(modem, atom_t,
> emulator_remove, em);
> @@ -533,7 +583,14 @@ 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");
> +
> + if (em->cme_error_ind == 1)
> + sprintf(buf, "+CME ERROR: %d", final->error);
> + else if (em->cme_error_ind == 2)
> + sprintf(buf, "+CME ERROR: %s", telephony_error_to_str(final));
> +
I suspect that a switch/case would be more readable and slightly more
efficient here.
> g_at_server_send_ext_final(em->server, buf);
> break;
>
Regards,
-Denis
prev parent reply other threads:[~2011-04-05 5:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-01 14:21 [PATCH] emulator: add AT+CMEE support for HFP Olivier Guiter
2011-04-05 5:40 ` 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=4D9AAB5F.4050909@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox