From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH] rilmodem/stk: add STK support for rilmodem
Date: Fri, 29 Apr 2016 10:18:39 -0500 [thread overview]
Message-ID: <57237B4F.1080308@gmail.com> (raw)
In-Reply-To: <1461896487-22200-1-git-send-email-caiwen.zhang@intel.com>
[-- Attachment #1: Type: text/plain, Size: 9359 bytes --]
Hi Caiwen,
On 04/28/2016 09:21 PM, caiwen.zhang(a)intel.com wrote:
> From: Caiwen Zhang <caiwen.zhang@intel.com>
>
> ---
> Makefile.am | 1 +
> drivers/rilmodem/rilmodem.c | 2 +
> drivers/rilmodem/rilmodem.h | 3 +
> drivers/rilmodem/stk.c | 237 ++++++++++++++++++++++++++++++++++++++++++++
> plugins/ril.c | 1 +
> 5 files changed, 244 insertions(+)
> create mode 100644 drivers/rilmodem/stk.c
>
Please refer to ofono.git/HACKING 'Submitting Patches' section. The
plugins/ril.c change should be in a separate commit.
> diff --git a/Makefile.am b/Makefile.am
> index 5215b2e..8ab9851 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -151,6 +151,7 @@ builtin_sources += drivers/rilmodem/rilmodem.h \
> drivers/rilmodem/radio-settings.c \
> drivers/rilmodem/call-barring.c \
> drivers/rilmodem/netmon.c \
> + drivers/rilmodem/stk.c \
> drivers/infineonmodem/infineon_constants.h
> endif
>
> diff --git a/drivers/rilmodem/rilmodem.c b/drivers/rilmodem/rilmodem.c
> index e4de3c2..9a063a2 100644
> --- a/drivers/rilmodem/rilmodem.c
> +++ b/drivers/rilmodem/rilmodem.c
> @@ -52,6 +52,7 @@ static int rilmodem_init(void)
> ril_radio_settings_init();
> ril_call_barring_init();
> ril_netmon_init();
> + ril_stk_init();
>
> return 0;
> }
> @@ -74,6 +75,7 @@ static void rilmodem_exit(void)
> ril_radio_settings_exit();
> ril_call_barring_exit();
> ril_netmon_exit();
> + ril_stk_exit();
> }
>
> OFONO_PLUGIN_DEFINE(rilmodem, "RIL modem driver", VERSION,
> diff --git a/drivers/rilmodem/rilmodem.h b/drivers/rilmodem/rilmodem.h
> index f838b6b..7e47573 100644
> --- a/drivers/rilmodem/rilmodem.h
> +++ b/drivers/rilmodem/rilmodem.h
> @@ -72,3 +72,6 @@ extern void ril_phonebook_exit(void);
>
> extern void ril_netmon_init(void);
> extern void ril_netmon_exit(void);
> +
> +extern void ril_stk_init(void);
> +extern void ril_stk_exit(void);
> diff --git a/drivers/rilmodem/stk.c b/drivers/rilmodem/stk.c
> new file mode 100644
> index 0000000..9082683
> --- /dev/null
> +++ b/drivers/rilmodem/stk.c
> @@ -0,0 +1,237 @@
> +/*
> + *
> + * oFono - Open Source Telephony
> + *
> + * Copyright (C) 2008-2016 Intel Corporation. All rights reserved.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
> + *
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include <config.h>
> +#endif
> +
> +#define _GNU_SOURCE
> +#include <string.h>
> +#include <stdio.h>
> +
> +#include <glib.h>
> +
> +#include <ofono/log.h>
> +#include <ofono/modem.h>
> +#include <ofono/stk.h>
> +#include "util.h"
> +
> +#include <gril.h>
> +#include <parcel.h>
> +
> +#include "rilmodem.h"
> +#include "vendor.h"
> +
> +struct stk_data {
> + GRil *ril;
> + unsigned int vendor;
> +};
> +
> +static void ril_stk_terminal_response_cb(struct ril_msg *message,
> + gpointer user_data)
> +{
> + struct cb_data *cbd = user_data;
> + ofono_stk_generic_cb_t cb = cbd->cb;
> + struct stk_data *sd = cbd->user;
> +
> + g_ril_print_response(sd->ril, message);
> +
> + if (message->error == RIL_E_SUCCESS) {
> + CALLBACK_WITH_SUCCESS(cb, cbd->data);
> + } else {
> + ofono_error("%s RILD reply failure: %s",
> + g_ril_request_id_to_string(sd->ril, message->req),
> + ril_error_to_string(message->error));
> + CALLBACK_WITH_FAILURE(cb, cbd->data);
> + }
> +}
> +
> +static void ril_stk_terminal_response(struct ofono_stk *stk, int len,
> + const unsigned char *data,
> + ofono_stk_generic_cb_t cb, void *user_data)
> +{
> + struct stk_data *sd = ofono_stk_get_data(stk);
> + struct cb_data *cbd = cb_data_new(cb, user_data, sd);
> + struct parcel rilp;
> + char *buf = alloca(len * 2 + 1);
> + int size = 0;
> +
> + for (; len; len--)
> + size += sprintf(buf + size, "%02hhX", *data++);
> +
> + parcel_init(&rilp);
> + parcel_w_string(&rilp, buf);
> +
> + if (g_ril_send(sd->ril, RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE, &rilp,
> + ril_stk_terminal_response_cb, cbd, g_free) > 0)
> + return;
> +
> + g_free(cbd);
> + CALLBACK_WITH_FAILURE(cb, user_data);
> +}
> +
> +static void ril_stk_envelope_cb(struct ril_msg *message, gpointer user_data)
> +{
> + struct cb_data *cbd = user_data;
> + ofono_stk_envelope_cb_t cb = cbd->cb;
> + struct stk_data *sd = cbd->user;
> + struct parcel rilp;
> + unsigned char *response = NULL;
> + long len = 0;
> + char *pdu;
> +
> + g_ril_print_response(sd->ril, message);
> +
> + if (message->error == RIL_E_SUCCESS) {
> + g_ril_init_parcel(message, &rilp);
> + pdu = parcel_r_string(&rilp);
Empty line here, doc/coding-style.txt item M1
> + if (pdu)
> + response = decode_hex(pdu, -1, &len, -1);
> +
> + CALLBACK_WITH_SUCCESS(cb, response, len, cbd->data);
> + g_free(response);
> + } else {
> + ofono_error("%s RILD reply failure: %s",
> + g_ril_request_id_to_string(sd->ril, message->req),
> + ril_error_to_string(message->error));
> + CALLBACK_WITH_FAILURE(cb, NULL, 0, cbd->data);
> + }
> +}
> +
> +static void ril_stk_envelope(struct ofono_stk *stk, int len,
> + const unsigned char *cmd,
> + ofono_stk_envelope_cb_t cb, void *user_data)
> +{
> + struct stk_data *sd = ofono_stk_get_data(stk);
> + struct cb_data *cbd = cb_data_new(cb, user_data, sd);
> + struct parcel rilp;
> + char *buf = alloca(len * 2 + 1);
> + int size = 0;
> +
> + for (; len; len--)
> + size += sprintf(buf + size, "%02hhX", *cmd++);
> +
> + parcel_init(&rilp);
> + parcel_w_string(&rilp, buf);
> +
> + if (g_ril_send(sd->ril, RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND, &rilp,
> + ril_stk_envelope_cb, cbd, g_free) > 0)
> + return;
> +
> + g_free(cbd);
> + CALLBACK_WITH_FAILURE(cb, NULL, 0, user_data);
> +}
> +
> +static void ril_stk_proactive_cmd_noti(struct ril_msg *message,
can we name this ril_stk_proactive_cmd_notify?
> + gpointer user_data)
> +{
> + struct ofono_stk *stk = user_data;
> + struct parcel rilp;
> + long pdulen;
> + unsigned char *pdu;
> +
> + DBG("");
> +
> + g_ril_init_parcel(message, &rilp);
> + pdu = decode_hex(parcel_r_string(&rilp), -1, &pdulen, -1);
> +
> + ofono_stk_proactive_command_notify(stk, pdulen, pdu);
> + g_free(pdu);
> +}
> +
> +static void ril_stk_event_noti(struct ril_msg *message, gpointer user_data)
notify here as well
> +{
> + struct ofono_stk *stk = user_data;
> + struct parcel rilp;
> + long pdulen;
> + unsigned char *pdu;
> +
> + DBG("");
> +
> + g_ril_init_parcel(message, &rilp);
> + pdu = decode_hex(parcel_r_string(&rilp), -1, &pdulen, -1);
> +
> + ofono_stk_proactive_command_handled_notify(stk, pdulen, pdu);
> + g_free(pdu);
> +}
> +
> +static void ril_stk_session_end_noti(struct ril_msg *message,
> + gpointer user_data)
notify
> +{
> + struct ofono_stk *stk = user_data;
> +
> + DBG("");
> + ofono_stk_proactive_session_end_notify(stk);
> +}
> +
> +static int ril_stk_probe(struct ofono_stk *stk, unsigned int vendor,
> + void *user)
> +{
> + GRil *ril = user;
> + struct stk_data *data;
> +
> + data = g_new0(struct stk_data, 1);
> + data->ril = g_ril_clone(ril);
> + data->vendor = vendor;
> +
> + ofono_stk_set_data(stk, data);
> +
> + g_ril_register(ril, RIL_UNSOL_STK_PROACTIVE_COMMAND,
> + ril_stk_proactive_cmd_noti, stk);
> +
> + g_ril_register(ril, RIL_UNSOL_STK_SESSION_END,
> + ril_stk_session_end_noti, stk);
> +
> + g_ril_register(ril, RIL_UNSOL_STK_EVENT_NOTIFY,
> + ril_stk_event_noti, stk);
> +
> + ofono_stk_register(stk);
> +
> + return 0;
> +}
> +
> +static void ril_stk_remove(struct ofono_stk *stk)
> +{
> + struct stk_data *data = ofono_stk_get_data(stk);
> +
> + ofono_stk_set_data(stk, NULL);
> +
> + g_ril_unref(data->ril);
> + g_free(data);
> +}
> +
> +static struct ofono_stk_driver driver = {
> + .name = RILMODEM,
> + .probe = ril_stk_probe,
> + .remove = ril_stk_remove,
> + .envelope = ril_stk_envelope,
> + .terminal_response = ril_stk_terminal_response,
> +};
> +
> +void ril_stk_init(void)
> +{
> + ofono_stk_driver_register(&driver);
> +}
> +
> +void ril_stk_exit(void)
> +{
> + ofono_stk_driver_unregister(&driver);
> +}
> diff --git a/plugins/ril.c b/plugins/ril.c
> index b66664a..833fd99 100644
> --- a/plugins/ril.c
> +++ b/plugins/ril.c
> @@ -230,6 +230,7 @@ void ril_post_sim(struct ofono_modem *modem)
>
> ofono_call_forwarding_create(modem, rd->vendor, RILMODEM, rd->ril);
>
> + ofono_stk_create(modem, rd->vendor, RILMODEM, rd->ril);
> ofono_phonebook_create(modem, rd->vendor, RILMODEM, modem);
> }
>
>
Regards,
-Denis
prev parent reply other threads:[~2016-04-29 15:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-29 2:21 [PATCH] rilmodem/stk: add STK support for rilmodem caiwen.zhang
2016-04-29 15: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=57237B4F.1080308@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.