Open Source Telephony
 help / color / mirror / Atom feed
From: Gustavo F. Padovan <padovan@profusion.mobi>
To: ofono@ofono.org
Subject: Re: [PATCH 1/1] hfp: Add faked sim driver to support SIM ready
Date: Mon, 30 Aug 2010 16:33:49 -0300	[thread overview]
Message-ID: <20100830193349.GB11191@vigoh> (raw)
In-Reply-To: <1283161817-22935-2-git-send-email-zhenhua.zhang@intel.com>

[-- Attachment #1: Type: text/plain, Size: 5268 bytes --]

Hi Zhenhua,

* Zhenhua Zhang <zhenhua.zhang@intel.com> [2010-08-30 17:50:17 +0800]:

> HFP modem doesn't have IMSI at all. In order to notify SIM ready to the
> core, we create a special sim driver with a faked IMSI number.
> ---
>  Makefile.am                 |    3 +-
>  drivers/hfpmodem/hfpmodem.c |    2 +
>  drivers/hfpmodem/hfpmodem.h |    3 +
>  drivers/hfpmodem/sim.c      |  114 +++++++++++++++++++++++++++++++++++++++++++
>  plugins/hfp.c               |    6 ++
>  5 files changed, 127 insertions(+), 1 deletions(-)
>  create mode 100644 drivers/hfpmodem/sim.c
> 
> diff --git a/Makefile.am b/Makefile.am
> index f31180e..a1ec0e7 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -187,7 +187,8 @@ builtin_sources += drivers/atmodem/atutil.h \
>  			drivers/hfpmodem/hfpmodem.c \
>  			drivers/hfpmodem/voicecall.c \
>  			drivers/hfpmodem/network-registration.c \
> -			drivers/hfpmodem/call-volume.c
> +			drivers/hfpmodem/call-volume.c \
> +			drivers/hfpmodem/sim.c
>  
>  builtin_modules += mbmmodem
>  builtin_sources += drivers/atmodem/atutil.h \
> diff --git a/drivers/hfpmodem/hfpmodem.c b/drivers/hfpmodem/hfpmodem.c
> index 4471a7b..ecbabe3 100644
> --- a/drivers/hfpmodem/hfpmodem.c
> +++ b/drivers/hfpmodem/hfpmodem.c
> @@ -44,6 +44,7 @@ static int hfpmodem_init(void)
>  	hfp_voicecall_init();
>  	hfp_netreg_init();
>  	hfp_call_volume_init();
> +	hfp_sim_init();
>  
>  	return 0;
>  }
> @@ -53,6 +54,7 @@ static void hfpmodem_exit(void)
>  	hfp_voicecall_exit();
>  	hfp_netreg_exit();
>  	hfp_call_volume_exit();
> +	hfp_sim_exit();
>  }
>  
>  OFONO_PLUGIN_DEFINE(hfpmodem, "Hands-Free Profile Driver", VERSION,
> diff --git a/drivers/hfpmodem/hfpmodem.h b/drivers/hfpmodem/hfpmodem.h
> index bf5d563..631f773 100644
> --- a/drivers/hfpmodem/hfpmodem.h
> +++ b/drivers/hfpmodem/hfpmodem.h
> @@ -80,3 +80,6 @@ extern void hfp_call_volume_exit();
>  
>  extern void hfp_voicecall_init();
>  extern void hfp_voicecall_exit();
> +
> +extern void hfp_sim_init();
> +extern void hfp_sim_exit();
> diff --git a/drivers/hfpmodem/sim.c b/drivers/hfpmodem/sim.c
> new file mode 100644
> index 0000000..e42cfb9
> --- /dev/null
> +++ b/drivers/hfpmodem/sim.c
> @@ -0,0 +1,114 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2008-2010  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 <stdlib.h>
> +#include <stdio.h>
> +
> +#include <glib.h>
> +
> +#include <ofono/log.h>
> +#include <ofono/modem.h>
> +#include <ofono/sim.h>
> +
> +#include "gatchat.h"
> +#include "gatresult.h"
> +#include "hfpmodem.h"
> +
> +static void hfp_read_imsi(struct ofono_sim *sim, ofono_sim_imsi_cb_t cb,
> +			void *data)
> +{
> +	struct ofono_error error;
> +	const char *imsi = "1234567890123456";
> +
> +	DBG("%s", imsi);
> +
> +	/*
> +	 * Return the faked IMSI since HFP doesn't have IMSI.
> +	 */
> +	error.type = OFONO_ERROR_TYPE_NO_ERROR;
> +	cb(&error, imsi, data);
> +}
> +
> +static void hfp_sim_read_binary(struct ofono_sim *sim, int fileid,
> +					int start, int length,
> +					ofono_sim_read_cb_t cb, void *data)
> +{
> +	DBG("");
> +
> +	CALLBACK_WITH_FAILURE(cb, NULL, 0, data);
> +}
> +
> +static void hfp_sim_read_info(struct ofono_sim *sim, int fileid,
> +					ofono_sim_file_info_cb_t cb,
> +					void *data)
> +{
> +	DBG("");
> +
> +	CALLBACK_WITH_FAILURE(cb, -1, -1, -1, NULL, data);
> +}
> +
> +static int hfp_sim_probe(struct ofono_sim *sim, unsigned int vendor,
> +				void *data)
> +{
> +	ofono_sim_register(sim);
> +
> +	return 0;
> +}
> +
> +static void hfp_sim_remove(struct ofono_sim *sim)
> +{
> +}
> +
> +static struct ofono_sim_driver driver = {
> +	.name			= "hfpmodem",
> +	.probe			= hfp_sim_probe,
> +	.remove			= hfp_sim_remove,
> +	.read_file_info		= hfp_sim_read_info,
> +	.read_file_transparent	= hfp_sim_read_binary,
> +	.read_file_linear	= NULL,
> +	.read_file_cyclic	= NULL,
> +	.write_file_transparent	= NULL,
> +	.write_file_linear	= NULL,
> +	.write_file_cyclic	= NULL,
> +	.read_imsi		= hfp_read_imsi,
> +	.query_passwd_state	= NULL,
> +	.send_passwd		= NULL,
> +	.reset_passwd		= NULL,
> +	.lock			= NULL,
> +	.change_passwd		= NULL,
> +	.query_locked		= NULL,

You don't need to add the NULL funcions here.

-- 
Gustavo F. Padovan
ProFUSION embedded systems - http://profusion.mobi

  reply	other threads:[~2010-08-30 19:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-30  9:50 [PATCH 0/1] Add faked sim driver for hfp modem Zhenhua Zhang
2010-08-30  9:50 ` [PATCH 1/1] hfp: Add faked sim driver to support SIM ready Zhenhua Zhang
2010-08-30 19:33   ` Gustavo F. Padovan [this message]
2010-08-30 19:50   ` Denis Kenzior
2010-08-30 23:54     ` Marcel Holtmann
2010-08-31  0:58     ` Zhang, Zhenhua

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=20100830193349.GB11191@vigoh \
    --to=padovan@profusion.mobi \
    --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