GPRS support for Ofono
by Ismo Puustinen
Hello List,
I started working on Ofono GPRS support.
The patch set contains:
1) Documentation describing how an Ofono GPRS D-Bus API would look like.
2) Common Ofono GPRS support.
3) Ofono GPRS ISI driver.
4) Test script for trying out the GPRS functionality.
Note that the GPRS support is in no way completed -- many things are
still TODO or have rough edges. However, I thought that it would be a
good idea to send the patches to the mailing list to gather comments
and improvement suggestions before finalizing the work.
PS. A disclaimer: I'm a Nokia engineer, even though I'm sending this
email from my personal email account (due to incompatibilities with
Nokia email servers). If you need to contact me off-the-list, please
use the email address ismo.h.puustinen(a)nokia.com .
--
Ismo Puustinen <ismo(a)iki.fi>
12 years, 6 months
light test report for ofono v0.3
by Fu, Elva
Test Environment
-------------------------------
general PC (pre-installed FC11)
- ofono v0.3
- phonesim package
mobile phone (use it as modem)
-------------------------------
Test Scope
-------------------------------
- we mainly focus on checking basic functionality of ofono v0.3 (voice call, sms, phonebook etc.)
- voice call, multiparty call, phonebook, SIM and modem are tested in real network env. For others, we test them through simulator.
- bug verification: verify issues we found in v0.2
-------------------------------
Test Summary
-------------------------------
there are small changes between ofono v0.2 and v0.3. so good test result is expected. :-)
Total 63 test cases were executed during this round of testing.
Pass: 63
Fail: 0
issues we found in v0.2 were fixed already, many thanks!
-------------------------------
Details
-------------------------------
to make it readable, we summarized by feature list. :-)
features checkpoints test results comments
SMS Send/receive pass
Set service center address pass
More recipients pass
More segment pass
Voice call Dial pass
Accept pass
Reject pass
Hold pass
Receive pass
Release pass
Multiparty call Create pass
Hang up pass
Private chat pass
Hold pass
Sim Phonebook Read pass
SS CF pass
CB pass
CW pass
CLIR/CLIP pass
Setting AOC pass
CF/CB pass
GSM string pass
Modem pass
Networking pass
Sim Read IMSI pass
Read MSISDN pass
-------------------------------
Elva
12 years, 8 months
[PATCH] G1: move chat handling into enable callback
by Andres Salomon
This updates the g1 code to create the GAtChat object in the enable() callback,
and to unref it in the disable() callback. This is more in line with what
the other plugins do, and as a bonus fixes a segfault when powering down
the G1 modem..
Signed-off-by: Andres Salomon <dilinger(a)collabora.co.uk>
---
plugins/g1.c | 48 ++++++++++++++++++++++--------------------------
1 files changed, 22 insertions(+), 26 deletions(-)
diff --git a/plugins/g1.c b/plugins/g1.c
index 5c53a12..0414f49 100644
--- a/plugins/g1.c
+++ b/plugins/g1.c
@@ -57,39 +57,14 @@ static void g1_debug(const char *str, void *data)
/* Detect hardware, and initialize if found */
static int g1_probe(struct ofono_modem *modem)
{
- GAtSyntax *syntax;
- GAtChat *chat;
- const char *device;
-
DBG("");
- device = ofono_modem_get_string(modem, "Device");
- if (device == NULL)
- return -EINVAL;
-
- syntax = g_at_syntax_new_gsm_permissive();
- chat = g_at_chat_new_from_tty(device, syntax);
- g_at_syntax_unref(syntax);
-
- if (chat == NULL)
- return -EIO;
-
- if (getenv("OFONO_AT_DEBUG") != NULL)
- g_at_chat_set_debug(chat, g1_debug, NULL);
-
- ofono_modem_set_data(modem, chat);
-
return 0;
}
static void g1_remove(struct ofono_modem *modem)
{
- GAtChat *chat = ofono_modem_get_data(modem);
-
DBG("");
-
- ofono_modem_set_data(modem, NULL);
- g_at_chat_unref(chat);
}
static void cfun_set_on_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -105,10 +80,28 @@ static void cfun_set_on_cb(gboolean ok, GAtResult *result, gpointer user_data)
/* power up hardware */
static int g1_enable(struct ofono_modem *modem)
{
- GAtChat *chat = ofono_modem_get_data(modem);
+ GAtSyntax *syntax;
+ GAtChat *chat;
+ const char *device;
DBG("");
+ device = ofono_modem_get_string(modem, "Device");
+ if (device == NULL)
+ return -EINVAL;
+
+ syntax = g_at_syntax_new_gsm_permissive();
+ chat = g_at_chat_new_from_tty(device, syntax);
+ g_at_syntax_unref(syntax);
+
+ if (chat == NULL)
+ return -EIO;
+
+ if (getenv("OFONO_AT_DEBUG") != NULL)
+ g_at_chat_set_debug(chat, g1_debug, NULL);
+
+ ofono_modem_set_data(modem, chat);
+
/* ensure modem is in a known state; verbose on, echo/quiet off */
g_at_chat_send(chat, "ATE0Q0V1", NULL, NULL, NULL, NULL);
@@ -137,6 +130,9 @@ static int g1_disable(struct ofono_modem *modem)
/* power down modem */
g_at_chat_send(chat, "AT+CFUN=0", NULL, cfun_set_off_cb, modem, NULL);
+ g_at_chat_unref(chat);
+ ofono_modem_set_data(modem, NULL);
+
return 0;
}
--
1.6.4.3
12 years, 9 months
[PATCH] Add call-volume interface to allow user adjust speaker and mic volume
by Zhang, Zhenhua
Hi,
Attached is the patch to add call-volume interface for Ofono. It exposes two
properties: 'SpeakerVolume' and 'MicrophoneVolume' to allow user could control
phone volume through lower level driver. The ofono_call_volume_notify() is
used to report call volume property change notification to the upper
application.
The default volume could be stored in the modem.conf or query from remote.
Each driver could report value in percentage to call-volume through
ofono_call_volume_notify(). And then the call-volume will sync volume with remote
side right after probe().
Please review it.
Regards,
Zhenhua
12 years, 9 months
[PATCH] Present list of preferred languages on SimManager interface.
by Andrzej Zaborowski
It does not look like the list can be used directly for filtering CBs
because for that, the ME should choose one language, if there is one
that is supported by the UI (aka MMI).
Patch made on top of [PATCH] Do the PIN check in SIMManager.
---
src/sim.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/simutil.h | 2 +
2 files changed, 130 insertions(+), 0 deletions(-)
diff --git a/src/sim.c b/src/sim.c
index 3886485..3ebb9e8 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -80,10 +80,13 @@ struct ofono_sim {
gboolean ready;
gboolean pin_ready;
int pin_type;
+ char **language_prefs;
GQueue *simop_q;
gint simop_source;
unsigned char efmsisdn_length;
unsigned char efmsisdn_records;
+ unsigned char *efli;
+ unsigned char efli_length;
unsigned int next_ready_watch_id;
GSList *ready_watches;
const struct ofono_sim_driver *driver;
@@ -224,6 +227,11 @@ static DBusMessage *sim_get_properties(DBusConnection *conn,
(void *) &pin_name);
}
+ if (sim->language_prefs)
+ ofono_dbus_dict_append_array(&dict, "PreferredLanguages",
+ DBUS_TYPE_STRING,
+ &sim->language_prefs);
+
dbus_message_iter_close_container(&iter, &dict);
return reply;
@@ -746,6 +754,120 @@ static void sim_pin_check(struct ofono_sim *sim)
sim->driver->query_passwd_state(sim, sim_pin_query_cb, sim);
}
+static void sim_efli_read_cb(int ok,
+ enum ofono_sim_file_structure structure,
+ int length, int record,
+ const unsigned char *data,
+ int record_length, void *userdata)
+{
+ struct ofono_sim *sim = userdata;
+
+ if (!ok || structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
+ return;
+
+ if (length < 2)
+ return;
+
+ sim->efli = g_memdup(data, length);
+ sim->efli_length = length;
+}
+
+static int parse_language_list(char **out_list, const unsigned char *sim_list,
+ int length)
+{
+ unsigned char code[3];
+ int count, i;
+ long written;
+
+ count = 0;
+ length--;
+
+ for (i = 0; i < length; i += 2) {
+ code[0] = sim_list[i + 0];
+ code[1] = sim_list[i + 1];
+ code[2] = 0;
+
+ if (code[0] == 0xff || code[1] == 0xff)
+ continue;
+
+ out_list[count] = convert_gsm_to_utf8(code, 2,
+ NULL, &written, 0);
+ if (out_list[count] && written == 2)
+ count++;
+ }
+
+ return count;
+}
+
+static void sim_efpl_read_cb(int ok,
+ enum ofono_sim_file_structure structure,
+ int length, int record,
+ const unsigned char *data,
+ int record_length, void *userdata)
+{
+ struct ofono_sim *sim = userdata;
+ unsigned char *efli = sim->efli;
+ const unsigned char *efpl = data;
+ int efli_length = sim->efli_length;
+ int efpl_length = length;
+ int count;
+ const char *path = __ofono_atom_get_path(sim->atom);
+ DBusConnection *conn = ofono_dbus_get_connection();
+
+ if (!ok || structure != OFONO_SIM_FILE_STRUCTURE_TRANSPARENT)
+ efpl = NULL;
+
+ if (length < 2)
+ efpl = NULL;
+
+ sim->language_prefs = g_malloc(((efli_length + efpl_length) / 2 + 1) *
+ sizeof(char *));
+
+ count = 0;
+
+ /* Make a list of languages in both files in order of preferences
+ * following 31.102.
+ */
+
+ if (efli && efpl && efli[0] == 0xff && efli[1] == 0xff) {
+ count += parse_language_list(sim->language_prefs + count,
+ efpl, efpl_length);
+ efpl = NULL;
+ }
+
+ if (efli) {
+ count += parse_language_list(sim->language_prefs + count,
+ efli, efli_length);
+ g_free(efli);
+ sim->efli = NULL;
+ }
+
+ if (efpl)
+ count += parse_language_list(sim->language_prefs + count,
+ efpl, efpl_length);
+
+ sim->language_prefs[count] = NULL;
+
+ ofono_dbus_signal_array_property_changed(conn, path,
+ SIM_MANAGER_INTERFACE,
+ "PreferredLanguages",
+ DBUS_TYPE_STRING,
+ &sim->language_prefs);
+}
+
+static void sim_retrieve_efli(struct ofono_sim *sim)
+{
+ /* According to 31.102 the EFli is read first and EFpl is then
+ * only read if none of the EFli languages are supported by user
+ * interface. 51.011 mandates the exact opposite, making EFpl/EFelp
+ * preferred over EFlp (same ID as EFli, different format).
+ * However we don't depend on the user interface and so
+ * need to read both files now.
+ */
+ ofono_sim_read(sim, SIM_EFLI_FILEID, sim_efli_read_cb, sim);
+ ofono_sim_read(sim, SIM_EFPL_FILEID, sim_efpl_read_cb, sim);
+}
+
static void sim_op_error(struct ofono_sim *sim)
{
struct sim_file_op *op = g_queue_pop_head(sim->simop_q);
@@ -1357,6 +1479,11 @@ static void sim_remove(struct ofono_atom *atom)
sim->service_numbers = NULL;
}
+ if (sim->language_prefs) {
+ g_strfreev(sim->language_prefs);
+ sim->language_prefs = NULL;
+ }
+
if (sim->simop_source) {
g_source_remove(sim->simop_source);
sim->simop_source = 0;
@@ -1446,6 +1573,7 @@ void ofono_sim_register(struct ofono_sim *sim)
* arbitrary files to be written or read, assuming their presence
* in the EFust
*/
+ sim_retrieve_efli(sim);
sim_pin_check(sim);
}
diff --git a/src/simutil.h b/src/simutil.h
index fc4f063..d1517ed 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -20,6 +20,8 @@
*/
enum sim_fileid {
+ SIM_EFPL_FILEID = 0x2f05,
+ SIM_EFLI_FILEID = 0x6f05,
SIM_EFMSISDN_FILEID = 0x6f40,
SIM_EFSPN_FILEID = 0x6f46,
SIM_EFSDN_FILEID = 0x6f49,
--
1.6.1
12 years, 9 months
[Patch]Unref GIOChannel in g_at_chat_new_from_tty
by Zhang, Zhenhua
Hi,
Attached is the patch to unref GIOChannel in g_at_chat_new_from_tty. If the
GAtChat is created from g_at_chat_new, the reference count of channel is
increased by g_io_add_watch_full(channel), so we need to unref it.
If GAtChat is failed to create, we also need to unref channel to free it.
Please review it.
Regards,
Zhenhua
12 years, 9 months
Re: failed to start ofonod....
by Zhao, Lihan
I also face the problem when I install ofono on a new machine.
Unable to hop onto D-Bus
I run as root, but the same error as WuYongbo and no configure directory "ofono" under /etc
By the way, I manually installed dbus-1-dev and dbus-glib-1-dev, unless ./bootstrap-configure reminds that DBUS>=1.0 is required.
Os: ubuntu 9.04.
Thank you
Best Regards,
Lihan
12 years, 9 months
[PATCH] [RFC] Do the PIN check in SIMManager
by Andrzej Zaborowski
This adds checking whether PIN is required during SIM initialisation and
delaying the sim ready notifications until after correct PIN is given.
According to 31.102 the IMSI should be retrieved after the PIN check
however on the SIMs I've tried it can be retrieved before authentication
and I think it would make sense to provide the imsi to the clients so
they know which card they're authenticating to if they're swapping cards.
---
drivers/atmodem/sim.c | 171 +++++++++++++++++++++++++++++++++++++++++++++++++
include/sim.h | 13 ++++
include/types.h | 20 ++++++
src/sim.c | 136 ++++++++++++++++++++++++++++++++++++++-
src/simutil.c | 24 +++++++
src/simutil.h | 2 +
6 files changed, 365 insertions(+), 1 deletions(-)
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index 8333670..fdb972a 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -431,6 +431,174 @@ error:
}
}
+static struct {
+ enum ofono_sim_passwd_type type;
+ const char *name;
+} const at_sim_name[] = {
+ { OFONO_PASSWD_SIM_PIN, "SIM PIN" },
+ { OFONO_PASSWD_SIM_PUK, "SIM PUK" },
+ { OFONO_PASSWD_PHSIM_PIN, "PH-SIM PIN" },
+ { OFONO_PASSWD_PHFSIM_PIN, "PH-FSIM PIN" },
+ { OFONO_PASSWD_PHFSIM_PUK, "PH-FSIM PUK" },
+ { OFONO_PASSWD_SIM_PIN2, "SIM PIN2" },
+ { OFONO_PASSWD_SIM_PUK2, "SIM PUK2" },
+ { OFONO_PASSWD_PHNET_PIN, "PH-NET PIN" },
+ { OFONO_PASSWD_PHNET_PUK, "PH-NET PUK" },
+ { OFONO_PASSWD_PHNETSUB_PIN, "PH-NETSUB PIN" },
+ { OFONO_PASSWD_PHNETSUB_PUK, "PH-NETSUB PUK" },
+ { OFONO_PASSWD_PHSP_PIN, "PH-SP PIN" },
+ { OFONO_PASSWD_PHSP_PUK, "PH-SP PUK" },
+ { OFONO_PASSWD_PHCORP_PIN, "PH-CORP PIN" },
+ { OFONO_PASSWD_PHCORP_PUK, "PH-CORP PUK" },
+};
+
+static void at_cpin_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ GAtResultIter iter;
+ ofono_sim_passwd_cb_t cb = cbd->cb;
+ struct ofono_error error;
+ const char *pin_required;
+ int pin_type;
+ int i;
+ int len = sizeof(at_sim_name) / sizeof(*at_sim_name);
+
+ dump_response("at_cpin_cb", ok, result);
+ decode_at_error(&error, g_at_result_final_response(result));
+
+ if (!ok) {
+ cb(&error, -1, cbd->data);
+ return;
+ }
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "+CPIN:")) {
+ DECLARE_FAILURE(e);
+
+ cb(&e, -1, cbd->data);
+ return;
+ }
+
+ pin_required = g_at_result_iter_raw_line(&iter);
+
+ pin_type = -1;
+ if (!strcmp(pin_required, "READY"))
+ pin_type = OFONO_PASSWD_NONE;
+ else
+ for (i = 0; i < len; i++)
+ if (!g_str_has_suffix(pin_required,
+ at_sim_name[i].name))
+ pin_type = at_sim_name[i].type;
+
+ if (pin_type == -1) {
+ DECLARE_FAILURE(e);
+
+ cb(&e, -1, cbd->data);
+ return;
+ }
+
+ ofono_debug("crsm_pin_cb: %s", pin_required);
+
+ cb(&error, pin_type, cbd->data);
+}
+
+static void at_pin_query(struct ofono_sim *sim, ofono_sim_passwd_cb_t cb,
+ void *data)
+{
+ GAtChat *chat = ofono_sim_get_data(sim);
+ struct cb_data *cbd = cb_data_new(cb, data);
+
+ if (!cbd)
+ goto error;
+
+ if (g_at_chat_send(chat, "AT+CPIN?", NULL,
+ at_cpin_cb, cbd, g_free) > 0)
+ return;
+
+error:
+ if (cbd)
+ g_free(cbd);
+
+ {
+ DECLARE_FAILURE(error);
+ cb(&error, -1, data);
+ }
+}
+
+static void at_cpin_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ ofono_sim_passwd_send_cb_t cb = cbd->cb;
+ struct ofono_error error;
+
+ dump_response("at_cpin_set_cb", ok, result);
+ decode_at_error(&error, g_at_result_final_response(result));
+
+ cb(&error, cbd->data);
+}
+
+static void at_pin_send(struct ofono_sim *sim, const char *passwd,
+ ofono_sim_passwd_send_cb_t cb, void *data)
+{
+ GAtChat *chat = ofono_sim_get_data(sim);
+ struct cb_data *cbd = cb_data_new(cb, data);
+ char buf[64];
+ int ret;
+
+ if (!cbd)
+ goto error;
+
+ snprintf(buf, sizeof(buf), "AT+CPIN=\"%s\"", passwd);
+
+ ret = g_at_chat_send(chat, buf, NULL, at_cpin_set_cb, cbd, g_free);
+
+ memset(buf, 0, sizeof(buf));
+
+ if (ret > 0)
+ return;
+
+error:
+ if (cbd)
+ g_free(cbd);
+
+ {
+ DECLARE_FAILURE(error);
+ cb(&error, data);
+ }
+}
+
+static void at_pin_send_puk(struct ofono_sim *sim, const char *puk,
+ const char *passwd,
+ ofono_sim_passwd_send_cb_t cb, void *data)
+{
+ GAtChat *chat = ofono_sim_get_data(sim);
+ struct cb_data *cbd = cb_data_new(cb, data);
+ char buf[64];
+ int ret;
+
+ if (!cbd)
+ goto error;
+
+ snprintf(buf, sizeof(buf), "AT+CPIN=\"%s\",\"%s\"", puk, passwd);
+
+ ret = g_at_chat_send(chat, buf, NULL, at_cpin_set_cb, cbd, g_free);
+
+ memset(buf, 0, sizeof(buf));
+
+ if (ret > 0)
+ return;
+
+error:
+ if (cbd)
+ g_free(cbd);
+
+ {
+ DECLARE_FAILURE(error);
+ cb(&error, data);
+ }
+}
+
static gboolean at_sim_register(gpointer user)
{
struct ofono_sim *sim = user;
@@ -467,6 +635,9 @@ static struct ofono_sim_driver driver = {
.write_file_linear = at_sim_update_record,
.write_file_cyclic = at_sim_update_cyclic,
.read_imsi = at_read_imsi,
+ .query_passwd_state = at_pin_query,
+ .send_passwd = at_pin_send,
+ .send_new_passwd = at_pin_send_puk,
};
void at_sim_init()
diff --git a/include/sim.h b/include/sim.h
index 1da486c..90bedae 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -64,6 +64,12 @@ typedef void (*ofono_sim_file_read_cb_t)(int ok,
typedef void (*ofono_sim_file_write_cb_t)(int ok, void *userdata);
+typedef void (*ofono_sim_passwd_cb_t)(const struct ofono_error *error,
+ int passwd_type, void *data);
+
+typedef void (*ofono_sim_passwd_send_cb_t)(const struct ofono_error *error,
+ void *data);
+
struct ofono_sim_driver {
const char *name;
int (*probe)(struct ofono_sim *sim, unsigned int vendor, void *data);
@@ -90,6 +96,13 @@ struct ofono_sim_driver {
ofono_sim_write_cb_t cb, void *data);
void (*read_imsi)(struct ofono_sim *sim,
ofono_sim_imsi_cb_t cb, void *data);
+ void (*query_passwd_state)(struct ofono_sim *sim,
+ ofono_sim_passwd_cb_t cb, void *data);
+ void (*send_passwd)(struct ofono_sim *sim, const char *passwd,
+ ofono_sim_passwd_send_cb_t cb, void *data);
+ void (*send_new_passwd)(struct ofono_sim *sim, const char *puk,
+ const char *passwd,
+ ofono_sim_passwd_send_cb_t cb, void *data);
};
int ofono_sim_driver_register(const struct ofono_sim_driver *d);
diff --git a/include/types.h b/include/types.h
index 6a9681d..99e2ca5 100644
--- a/include/types.h
+++ b/include/types.h
@@ -91,6 +91,26 @@ struct ofono_call {
int clip_validity;
};
+enum ofono_sim_passwd_type {
+ OFONO_PASSWD_NONE = 0,
+
+ OFONO_PASSWD_SIM_PIN,
+ OFONO_PASSWD_SIM_PUK,
+ OFONO_PASSWD_PHSIM_PIN,
+ OFONO_PASSWD_PHFSIM_PIN,
+ OFONO_PASSWD_PHFSIM_PUK,
+ OFONO_PASSWD_SIM_PIN2,
+ OFONO_PASSWD_SIM_PUK2,
+ OFONO_PASSWD_PHNET_PIN,
+ OFONO_PASSWD_PHNET_PUK,
+ OFONO_PASSWD_PHNETSUB_PIN,
+ OFONO_PASSWD_PHNETSUB_PUK,
+ OFONO_PASSWD_PHSP_PIN,
+ OFONO_PASSWD_PHSP_PUK,
+ OFONO_PASSWD_PHCORP_PIN,
+ OFONO_PASSWD_PHCORP_PUK,
+};
+
#ifdef __cplusplus
}
#endif
diff --git a/src/sim.c b/src/sim.c
index a072c8c..44f0a3b 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -55,6 +55,7 @@ static GSList *g_drivers = NULL;
static gboolean sim_op_next(gpointer user_data);
static gboolean sim_op_retrieve_next(gpointer user);
static void sim_own_numbers_update(struct ofono_sim *sim);
+static void sim_pin_check(struct ofono_sim *sim);
struct sim_file_op {
int id;
@@ -77,6 +78,8 @@ struct ofono_sim {
GSList *service_numbers;
gboolean sdn_ready;
gboolean ready;
+ gboolean pin_ready;
+ int pin_type;
GQueue *simop_q;
gint simop_source;
unsigned char efmsisdn_length;
@@ -86,6 +89,7 @@ struct ofono_sim {
const struct ofono_sim_driver *driver;
void *driver_data;
struct ofono_atom *atom;
+ DBusMessage *pending;
};
struct msisdn_set_request {
@@ -95,6 +99,7 @@ struct msisdn_set_request {
DBusMessage *msg;
};
+
struct sim_ready_watch {
unsigned int id;
ofono_sim_ready_notify_cb_t notify;
@@ -171,6 +176,8 @@ static DBusMessage *sim_get_properties(DBusConnection *conn,
DBusMessageIter dict;
char **own_numbers;
char **service_numbers;
+ dbus_bool_t pin_needed;
+ const char *pin_name;
reply = dbus_message_new_method_return(msg);
if (!reply)
@@ -205,6 +212,18 @@ static DBusMessage *sim_get_properties(DBusConnection *conn,
g_strfreev(service_numbers);
}
+ pin_needed = !sim->pin_ready;
+ ofono_dbus_dict_append(&dict, "WaitingForPIN",
+ DBUS_TYPE_BOOLEAN, &pin_needed);
+
+ if (sim->pin_type != OFONO_PASSWD_NONE) {
+ pin_name = sim_passwd_name(sim->pin_type);
+
+ ofono_dbus_dict_append(&dict, "PINTypeRequired",
+ DBUS_TYPE_STRING,
+ (void *) &pin_name);
+ }
+
dbus_message_iter_close_container(&iter, &dict);
return reply;
@@ -353,10 +372,64 @@ error:
return __ofono_error_invalid_args(msg);
}
+static void sim_send_pin_cb(const struct ofono_error *error, void *data)
+{
+ struct ofono_sim *sim = data;
+ DBusMessage *reply;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR)
+ reply = __ofono_error_failed(sim->pending);
+ else
+ reply = dbus_message_new_method_return(sim->pending);
+
+
+ __ofono_dbus_pending_reply(&sim->pending, reply);
+
+ /* Re-check the authentication status and update DBus properties
+ * as needed. We need to do this regardless of whether the password
+ * given was correct: if it was incorrect, the number of retries
+ * may have expired and a different password is being requested now.
+ * If it was correct, possibly proceed with SIM initialisation.
+ */
+ sim_pin_check(sim);
+}
+
+static DBusMessage *sim_send_pin(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ struct ofono_sim *sim = data;
+ DBusMessageIter iter;
+ const char *pin;
+
+ if (!sim->driver->send_passwd)
+ return __ofono_error_not_implemented(msg);
+
+ if (sim->pending)
+ return __ofono_error_busy(msg);
+
+ if (!dbus_message_iter_init(msg, &iter))
+ return __ofono_error_invalid_args(msg);
+
+ if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+ return __ofono_error_invalid_args(msg);
+
+ dbus_message_iter_get_basic(&iter, &pin);
+
+ if (!is_valid_pin(pin))
+ return __ofono_error_invalid_format(msg);
+
+ sim->pending = dbus_message_ref(msg);
+ sim->driver->send_passwd(sim, pin, sim_send_pin_cb, sim);
+
+ return NULL;
+}
+
static GDBusMethodTable sim_methods[] = {
{ "GetProperties", "", "a{sv}", sim_get_properties },
{ "SetProperty", "sv", "", sim_set_property,
G_DBUS_METHOD_FLAG_ASYNC },
+ { "SendPIN", "s", "", sim_send_pin,
+ G_DBUS_METHOD_FLAG_ASYNC },
{ }
};
@@ -612,6 +685,67 @@ static void sim_retrieve_imsi(struct ofono_sim *sim)
sim->driver->read_imsi(sim, sim_imsi_cb, sim);
}
+static void sim_pin_check_done(struct ofono_sim *sim)
+{
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(sim->atom);
+ dbus_bool_t value = FALSE;
+
+ if (sim->pin_ready == FALSE) {
+ sim->pin_ready = TRUE;
+
+ ofono_dbus_signal_property_changed(conn, path,
+ SIM_MANAGER_INTERFACE,
+ "WaitingForPIN",
+ DBUS_TYPE_BOOLEAN,
+ &value);
+ }
+
+ sim_retrieve_imsi(sim);
+}
+
+static void sim_pin_query_cb(const struct ofono_error *error, int pin_type,
+ void *data)
+{
+ struct ofono_sim *sim = data;
+ DBusConnection *conn = ofono_dbus_get_connection();
+ const char *path = __ofono_atom_get_path(sim->atom);
+ const char *pin_name;
+
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ ofono_error("Querrying PIN authentication state failed");
+
+ sim_pin_check_done(sim);
+ return;
+ }
+
+ if (sim->pin_type != pin_type) {
+ sim->pin_type = pin_type;
+ pin_name = sim_passwd_name(pin_type);
+
+ ofono_dbus_signal_property_changed(conn, path,
+ SIM_MANAGER_INTERFACE,
+ "PINTypeRequired",
+ DBUS_TYPE_STRING,
+ &pin_name);
+ }
+
+ if (pin_type == OFONO_PASSWD_NONE)
+ sim_pin_check_done(sim);
+}
+
+static void sim_pin_check(struct ofono_sim *sim)
+{
+ if (!sim->driver->query_passwd_state) {
+ sim_pin_check_done(sim);
+ return;
+ }
+
+ sim->pin_ready = FALSE;
+
+ sim->driver->query_passwd_state(sim, sim_pin_query_cb, sim);
+}
+
static void sim_op_error(struct ofono_sim *sim)
{
struct sim_file_op *op = g_queue_pop_head(sim->simop_q);
@@ -1312,7 +1446,7 @@ void ofono_sim_register(struct ofono_sim *sim)
* arbitrary files to be written or read, assuming their presence
* in the EFust
*/
- sim_retrieve_imsi(sim);
+ sim_pin_check(sim);
}
void ofono_sim_remove(struct ofono_sim *sim)
diff --git a/src/simutil.c b/src/simutil.c
index b80e014..2b26700 100644
--- a/src/simutil.c
+++ b/src/simutil.c
@@ -488,3 +488,27 @@ void sim_adn_build(unsigned char *data, int length,
/* Ext1 unused */
*data++ = 0xff;
}
+
+static const char *const passwd_name[] = {
+ [OFONO_PASSWD_NONE] = "None",
+ [OFONO_PASSWD_SIM_PIN] = "SIM PIN",
+ [OFONO_PASSWD_SIM_PUK] = "SIM PUK",
+ [OFONO_PASSWD_PHSIM_PIN] = "PH-SIM PIN",
+ [OFONO_PASSWD_PHFSIM_PIN] = "PH-FSIM PIN",
+ [OFONO_PASSWD_PHFSIM_PUK] = "PH-FSIM PUK",
+ [OFONO_PASSWD_SIM_PIN2] = "SIM PIN2",
+ [OFONO_PASSWD_SIM_PUK2] = "SIM PUK2",
+ [OFONO_PASSWD_PHNET_PIN] = "PH-NET PIN",
+ [OFONO_PASSWD_PHNET_PUK] = "PH-NET PUK",
+ [OFONO_PASSWD_PHNETSUB_PIN] = "PH-NETSUB PIN",
+ [OFONO_PASSWD_PHNETSUB_PUK] = "PH-NETSUB PUK",
+ [OFONO_PASSWD_PHSP_PIN] = "PH-SP PIN",
+ [OFONO_PASSWD_PHSP_PUK] = "PH-SP PUK",
+ [OFONO_PASSWD_PHCORP_PIN] = "PH-CORP PIN",
+ [OFONO_PASSWD_PHCORP_PUK] = "PH-CORP PUK",
+};
+
+const char *sim_passwd_name(enum ofono_sim_passwd_type type)
+{
+ return passwd_name[type];
+}
diff --git a/src/simutil.h b/src/simutil.h
index de3e55e..fc4f063 100644
--- a/src/simutil.h
+++ b/src/simutil.h
@@ -88,3 +88,5 @@ gboolean sim_adn_parse(const unsigned char *data, int length,
void sim_adn_build(unsigned char *data, int length,
const struct ofono_phone_number *ph,
const char *identifier);
+
+const char *sim_passwd_name(enum ofono_sim_passwd_type type);
--
1.6.1
12 years, 9 months
how ofono runs with simulator
by Zhao, Lihan
Hi,
I have got the source code through git, and I build it as the HACKING guides.
But now I do not have a modem, and cannot run ofono on the true environment.
I have one simulator, can anyone know how to run ofono with simulator?
Thank you!
Best Regards,
Lihan
12 years, 9 months
netlink.c:97: error: cast increases required alignment of target type
by Timo Juhani Lindfors
Hi,
git clone git://git.kernel.org/pub/scm/network/ofono/ofono.git
cd ofono
./bootstrap
./configure --enable-debug --prefix=/home/lindi/install --enable-maintainer-mode --mandir=/home/lindi/install/usr/share/man --sysconfdir=/home/lindi/install/etc --localstatedir=/home/lindi/install/var --disable-datafiles
make
fails with
> CC gdbus/watch.o
> CC gisi/netlink.o
> cc1: warnings being treated as errors
> gisi/netlink.c: In function 'g_pn_nl_process':
> gisi/netlink.c:97: error: cast increases required alignment of target type
> gisi/netlink.c:129: error: cast increases required alignment of target type
> gisi/netlink.c:130: error: cast increases required alignment of target type
on armel (openmoko gta02) debian unstable system with gcc 4:4.3.3-9
apparently since in mainstainer mode -Wcast-align complains about
#define NLMSG_NEXT(nlh,len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \
(struct nlmsghdr*)(((char*)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len)))
which is defined in /usr/include/linux/netlink. I don't know how to
best fix this. The options that I see are
1) Add
pragma GCC diagnostic warning "-Wcast-align"
to ignore the issue in the four affected files: gisi/client.c gisi/iter.c gisi/netlink.c gisi/socket.c
2) Disable -Wcast-alignt checks completely even in maintainer mode (not very nice)
3) Include a fixed version of NLMSG_ALIGN (and also send it usptream of course).
best regards,
Timo Lindfors
12 years, 9 months