[PATCH] Add Direction property to voice call

2011-08-30 Thread Antti Paila
---
 doc/voicecall-api.txt |6 ++
 src/voicecall.c   |9 +
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/doc/voicecall-api.txt b/doc/voicecall-api.txt
index 7eb41aa..6870905 100644
--- a/doc/voicecall-api.txt
+++ b/doc/voicecall-api.txt
@@ -110,6 +110,12 @@ Properties string LineIdentification [readonly]
service with their network provider and would like
to know what line the call is coming in on.
 
+string Direction [readonly]
+Indicates whether the call is mobile-originated or
+mobile-terminated.
+
+Possible values: "mo", "mt"
+
string Name [readonly]
 
Contains the Name Identification information returned
diff --git a/src/voicecall.c b/src/voicecall.c
index 2b4c209..833fe09 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -415,6 +415,7 @@ static void append_voicecall_properties(struct voicecall *v,
const char *callerid;
const char *timestr;
const char *name;
+const char *direction;
ofono_bool_t mpty;
dbus_bool_t emergency_call;
 
@@ -444,6 +445,14 @@ static void append_voicecall_properties(struct voicecall 
*v,
 
ofono_dbus_dict_append(dict, "Name", DBUS_TYPE_STRING, &name);
 
+if (call->direction == CALL_DIRECTION_MOBILE_ORIGINATED)
+direction = "mo";
+else
+direction = "mt";
+
+ofono_dbus_dict_append(dict, "Direction", DBUS_TYPE_STRING,
+&direction);
+
if (call->status == CALL_STATUS_ACTIVE ||
call->status == CALL_STATUS_HELD ||
(call->status == CALL_STATUS_DISCONNECTED &&
-- 
1.7.4.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH] atmodem: Enable network time for AT modem

2011-03-11 Thread Antti Paila
Hi Marcel,

On Tue, 2011-03-08 at 09:12 -0800, ext Marcel Holtmann wrote:
> Hi Antti,
> 
> >  drivers/atmodem/network-registration.c |2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/atmodem/network-registration.c 
> > b/drivers/atmodem/network-registration.c
> > index 4913611..2d589f0 100644
> > --- a/drivers/atmodem/network-registration.c
> > +++ b/drivers/atmodem/network-registration.c
> > @@ -722,6 +722,8 @@ static void ifx_ctzv_notify(GAtResult *result, gpointer 
> > user_data)
> > nd->time.mday = mday;
> > nd->time.mon = mon;
> > nd->time.year = 2000 + year;
> > +
> > +   ofono_netreg_time_notify(netreg, &nd->time);
> >  }
> >  
> >  static void ifx_ctzdst_notify(GAtResult *result, gpointer user_data)
> 
> actually this time notification is a bad idea since you will notify
> twice now. With the firmware that I tested this with, it is guaranteed
> to always get CTZV and CTZDST and in that order.

Of course there will be two notifications since there are two distinct
event CTZV and CTDST. My ifx modem documentation doesn't say that these
are always bound together so we should not make any implicit assumption.
Anyway I believe that it is the next level i.e. time plug-in whose job
it is to check whether it has all the bits and pieces needed to inform
the Timed or some other client.

BR,
  Antti 

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RE: [PATCH] atmodem: Enable network time for AT modem

2011-03-08 Thread Antti Paila
Hi Jeevaka,

On Tue, 2011-03-08 at 10:59 +0200, ext jeevaka.badrap...@elektrobit.com
wrote:
> Hi Antti,
> 
> ofono-boun...@ofono.org wrote:
> > ---
> >  drivers/atmodem/network-registration.c |2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/atmodem/network-registration.c
> > b/drivers/atmodem/network-registration.c
> > index 4913611..2d589f0 100644
> > --- a/drivers/atmodem/network-registration.c
> > +++ b/drivers/atmodem/network-registration.c
> > @@ -722,6 +722,8 @@ static void ifx_ctzv_notify(GAtResult *result,
> > gpointer user_data) nd->time.mday = mday;
> > nd->time.mon = mon;
> > nd->time.year = 2000 + year;
> > +
> > +   ofono_netreg_time_notify(netreg, &nd->time);
> >  }
> > 
> >  static void ifx_ctzdst_notify(GAtResult *result, gpointer user_data)
> 
> Since the fix is more to do with the ifx modem, it would be nice if we
> have the
> commit message changed to reflect that.

I suppose the person applying the patch can do the modifications to the commit 
message if needed. 

> Whenever there is a timezone change, CTZV, CTZDST and XNITZINFO URCs
> will be reported. That is the main
> reason behind calling the ofono_netreg_time_notify from CTZDST. Are you
> pretty sure
> this is not the case?

I don't know the details of ifx modem internals. If the time changes, is
it always guaranteed that CTZDST is sent and that CTZDST comes after the
CTZV? All I know that when testing NITZ with ifx modem, the time
notification is not emitted without my fix.

BR,
  Antti

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] atmodem: Enable network time for AT modem

2011-03-08 Thread Antti Paila
---
 drivers/atmodem/network-registration.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/atmodem/network-registration.c 
b/drivers/atmodem/network-registration.c
index 4913611..2d589f0 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -722,6 +722,8 @@ static void ifx_ctzv_notify(GAtResult *result, gpointer 
user_data)
nd->time.mday = mday;
nd->time.mon = mon;
nd->time.year = 2000 + year;
+
+   ofono_netreg_time_notify(netreg, &nd->time);
 }
 
 static void ifx_ctzdst_notify(GAtResult *result, gpointer user_data)
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 5/5] isimodem: Makefile modifications

2011-03-07 Thread Antti Paila
---
 Makefile.am |   13 -
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 3f20717..0f9f201 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,7 +15,8 @@ pkginclude_HEADERS = include/log.h include/plugin.h 
include/history.h \
include/ctm.h include/cdma-voicecall.h \
include/cdma-sms.h include/sim-auth.h \
include/gprs-provision.h include/emulator.h \
-   include/location-reporting.h
+   include/location-reporting.h \
+   include/cell-info.h
 
 nodist_pkginclude_HEADERS = include/version.h
 
@@ -139,8 +140,8 @@ builtin_sources += $(gisi_sources) \
drivers/isimodem/gprs-context.c \
drivers/isimodem/gpds.h \
drivers/isimodem/audio-settings.c \
-   drivers/isimodem/uicc.h
-
+   drivers/isimodem/uicc.h \
+   drivers/isimodem/cell-info.c
 
 builtin_modules += isiusb
 builtin_sources += plugins/isiusb.c
@@ -383,7 +384,8 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) 
src/ofono.ver \
src/smsagent.c src/smsagent.h src/ctm.c \
src/cdma-voicecall.c src/sim-auth.c \
src/message.h src/message.c src/gprs-provision.c \
-   src/emulator.c src/location-reporting.c
+   src/emulator.c src/location-reporting.c \
+   src/cell-info.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
@@ -426,7 +428,8 @@ doc_files = doc/overview.txt doc/ofono-paper.txt 
doc/release-faq.txt \
doc/sim-api.txt doc/stk-api.txt \
doc/audio-settings-api.txt doc/text-telephony-api.txt \
doc/calypso-modem.txt doc/message-api.txt \
-   doc/location-reporting-api.txt
+   doc/location-reporting-api.txt \
+   doc/cell-info.txt
 
 
 test_scripts = test/backtrace \
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/5] isimodem: Driver implementation

2011-03-07 Thread Antti Paila
---
 drivers/isimodem/cell-info.c |  375 ++
 1 files changed, 375 insertions(+), 0 deletions(-)
 create mode 100644 drivers/isimodem/cell-info.c

diff --git a/drivers/isimodem/cell-info.c b/drivers/isimodem/cell-info.c
new file mode 100644
index 000..0420327
--- /dev/null
+++ b/drivers/isimodem/cell-info.c
@@ -0,0 +1,375 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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 
+#endif
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "util.h"
+
+#include "isimodem.h"
+#include "isiutil.h"
+#include "sim.h"
+#include "debug.h"
+
+struct ci_data {
+   GIsiClient *client;
+};
+
+struct ci_container {
+   GIsiClient *client;
+   struct ofono_cell_info *ci;
+};
+
+static void mnc_to_string(uint16_t s, char *t)
+{
+   int i;
+
+   for (i = OFONO_MAX_MNC_LENGTH-1; i >= 0; i--) {
+   t[i] = '0' + (char) (s % 10);
+   s /= 10;
+   }
+
+   t[OFONO_MAX_MNC_LENGTH] = '\0';
+}
+
+static void mcc_to_string(uint16_t s, char *t)
+{
+   int i;
+
+   for (i = OFONO_MAX_MCC_LENGTH-1; i >= 0; i--) {
+   t[i] = '0' + (char) (s % 10);
+   s /= 10;
+   }
+
+   t[OFONO_MAX_MCC_LENGTH] = '\0';
+}
+
+static gboolean check_response_status(const GIsiMessage *msg, uint8_t msgid)
+{
+   DBG("");
+
+   if (g_isi_msg_error(msg) < 0) {
+   DBG("Error: %s", strerror(-g_isi_msg_error(msg)));
+   return FALSE;
+   }
+
+   if (g_isi_msg_id(msg) != msgid) {
+   DBG("Unexpected msg: %s",
+   ss_message_id_name(g_isi_msg_id(msg)));
+   return FALSE;
+   }
+   return TRUE;
+
+}
+
+static gboolean decode_geran_info(GIsiSubBlockIter *iter,
+   struct ofono_cell_info_results *cir)
+{
+   int i;
+   uint16_t mcc, mnc;
+
+   DBG("");
+
+   if (!g_isi_sb_iter_eat_word(iter, &mcc) ||
+   !g_isi_sb_iter_eat_word(iter, &mnc) ||
+   !g_isi_sb_iter_eat_word(iter, &cir->geran.lac) ||
+   !g_isi_sb_iter_eat_word(iter, &cir->geran.ci) ||
+   !g_isi_sb_iter_eat_byte(iter, &cir->geran.ta) ||
+   !g_isi_sb_iter_eat_byte(iter, &cir->geran.no_cells))
+   return FALSE;
+
+   mcc_to_string(mcc, cir->mcc);
+   mnc_to_string(mnc, cir->mnc);
+
+   DBG("geran.no_cells %d", cir->geran.no_cells);
+
+   for (i = 0; i < cir->geran.no_cells; ++i) {
+
+   if (!g_isi_sb_iter_eat_word(iter, &cir->geran.nmr[i].arfcn) ||
+   !g_isi_sb_iter_eat_byte(iter,
+   &cir->geran.nmr[i].bsic) ||
+   !g_isi_sb_iter_eat_byte(iter,
+   &cir->geran.nmr[i].rxlev))
+   return FALSE;
+   }
+
+   return TRUE;
+}
+
+static gboolean decode_utra_info(GIsiSubBlockIter *iter,
+   struct ofono_cell_info_results *cir)
+{
+   int i, j;
+   uint16_t mcc, mnc;
+   struct measured_results_list *l;
+
+   DBG("");
+
+   if (!g_isi_sb_iter_eat_dword(iter, &cir->utran.ucid) ||
+   !g_isi_sb_iter_eat_word(iter, &mcc) ||
+   !g_isi_sb_iter_eat_word(iter, &mnc) ||
+   !g_isi_sb_iter_eat_word(iter, &cir->utran.sc) ||
+   !g_isi_sb_iter_eat_word(iter, &cir->utran.dl_freq) ||
+   !g_isi_sb_iter_eat_byte(iter, &cir->utran.no_freq))
+   return FALSE;
+
+   mcc_to_string(mcc, cir->mcc);
+   mnc_to_string(mnc, cir->mnc);
+
+   DBG("utran.no_freq: %d", cir->utran.no_freq);
+
+   cir->utran.ul_freq = OFONO_CI_FIELD_FREQ_UNDEFINED;
+   iter->cursor += 3;
+
+   for (i = 0; i < cir->utran.no_freq; ++i) {
+   l = cir->utran.mrl + i;
+
+   if (!g_isi_sb_iter_eat_word(iter, &l->dl_freq) ||
+   !g_isi_sb_iter_eat_byte(iter, &l->rssi) ||
+   !g_isi_sb_iter_eat_byte(iter, &l->no_cells))
+  

[PATCH 4/5] isimodem: cell info creation to post_online

2011-03-07 Thread Antti Paila
---
 plugins/isiusb.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/plugins/isiusb.c b/plugins/isiusb.c
index 2d17b43..1356f8f 100644
--- a/plugins/isiusb.c
+++ b/plugins/isiusb.c
@@ -55,6 +55,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "drivers/isimodem/isimodem.h"
 #include "drivers/isimodem/isiutil.h"
@@ -441,6 +442,8 @@ static void isiusb_post_online(struct ofono_modem *modem)
mw = ofono_message_waiting_create(modem);
if (mw)
ofono_message_waiting_register(mw);
+
+   ofono_cell_info_create(modem, 0, "isimodem", isi->modem);
 }
 
 static int isiusb_enable(struct ofono_modem *modem)
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 3/5] isimodem: cell info init and exit functions

2011-03-07 Thread Antti Paila
---
 drivers/isimodem/isimodem.c |2 ++
 drivers/isimodem/isimodem.h |3 +++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/isimodem/isimodem.c b/drivers/isimodem/isimodem.c
index ba5cd54..0b69ff9 100644
--- a/drivers/isimodem/isimodem.c
+++ b/drivers/isimodem/isimodem.c
@@ -54,6 +54,7 @@ static int isimodem_init(void)
isi_gprs_init();
isi_gprs_context_init();
isi_audio_settings_init();
+   isi_cell_info_init();
 
return 0;
 }
@@ -77,6 +78,7 @@ static void isimodem_exit(void)
isi_gprs_exit();
isi_gprs_context_exit();
isi_audio_settings_exit();
+   isi_cell_info_exit();
 }
 
 OFONO_PLUGIN_DEFINE(isimodem, "PhoNet / ISI modem driver", VERSION,
diff --git a/drivers/isimodem/isimodem.h b/drivers/isimodem/isimodem.h
index ed64f9d..c8d1a90 100644
--- a/drivers/isimodem/isimodem.h
+++ b/drivers/isimodem/isimodem.h
@@ -69,3 +69,6 @@ extern void isi_gprs_context_exit(void);
 
 extern void isi_audio_settings_init(void);
 extern void isi_audio_settings_exit(void);
+
+extern void isi_cell_info_init();
+extern void isi_cell_info_exit();
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/5] Cell info for ISI modem

2011-03-07 Thread Antti Paila
 This series of patches brings the neighbor
 cell info support for ISI modems.

Antti Paila (5):
  isimodem: new enums declared for cell info
  isimodem: Driver implementation
  isimodem: cell info init and exit functions
  isimodem: cell info creation to post_online
  isimodem: Makefile modifications

 Makefile.am  |   13 +-
 drivers/isimodem/cell-info.c |  375 ++
 drivers/isimodem/debug.c |5 +
 drivers/isimodem/isimodem.c  |2 +
 drivers/isimodem/isimodem.h  |3 +
 drivers/isimodem/network.h   |8 +
 plugins/isiusb.c |3 +
 7 files changed, 404 insertions(+), 5 deletions(-)
 create mode 100644 drivers/isimodem/cell-info.c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/5] isimodem: new enums declared for cell info

2011-03-07 Thread Antti Paila
---
 drivers/isimodem/debug.c   |5 +
 drivers/isimodem/network.h |8 
 2 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/drivers/isimodem/debug.c b/drivers/isimodem/debug.c
index 38f97f9..b6d6f75 100644
--- a/drivers/isimodem/debug.c
+++ b/drivers/isimodem/debug.c
@@ -979,6 +979,9 @@ const char *net_message_id_name(enum net_message_id value)
_(NET_OPER_NAME_READ_REQ);
_(NET_OPER_NAME_READ_RESP);
_(NET_COMMON_MESSAGE);
+   _(NET_NEIGHBOUR_CELLS_REQ);
+   _(NET_NEIGHBOUR_CELLS_RESP);
+
}
return "NET_";
 }
@@ -1002,6 +1005,8 @@ const char *net_subblock_name(enum net_subblock value)
_(NET_SHORT_NITZ_NAME);
_(NET_AVAIL_NETWORK_INFO_COMMON);
_(NET_OPER_NAME_INFO);
+   _(NET_ECID_GERAN_INFO);
+   _(NET_ECID_UTRAN_FDD_INFO);
}
return "NET_";
 }
diff --git a/drivers/isimodem/network.h b/drivers/isimodem/network.h
index ee1fbf2..9f7d5e8 100644
--- a/drivers/isimodem/network.h
+++ b/drivers/isimodem/network.h
@@ -61,6 +61,8 @@ enum net_message_id {
NET_OPER_NAME_READ_REQ =0xE5,
NET_OPER_NAME_READ_RESP =   0xE6,
NET_COMMON_MESSAGE =0xF0,
+   NET_NEIGHBOUR_CELLS_REQ =   0x1A,
+   NET_NEIGHBOUR_CELLS_RESP =  0x1B
 };
 
 enum net_subblock {
@@ -81,6 +83,8 @@ enum net_subblock {
NET_SHORT_NITZ_NAME =   0x49,
NET_AVAIL_NETWORK_INFO_COMMON = 0xE1,
NET_OPER_NAME_INFO =0xE7,
+   NET_ECID_GERAN_INFO =   0x3E,
+   NET_ECID_UTRAN_FDD_INFO =   0x3F,
 };
 
 enum net_reg_status {
@@ -222,6 +226,10 @@ enum net_isi_cause {
NET_CAUSE_NOT_SUPPORTED_IN_TECH =   0x17,
 };
 
+enum net_neighbour_cell_info_type {
+   NET_ECID_INFORMATION =  0x05,
+};
+
 #ifdef __cplusplus
 };
 #endif
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] gisi: M6 coding style violation corrections

2011-03-04 Thread Antti Paila
---
 gisi/iter.c |   16 
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gisi/iter.c b/gisi/iter.c
index f3f6f5a..8308c00 100644
--- a/gisi/iter.c
+++ b/gisi/iter.c
@@ -56,7 +56,7 @@ void g_isi_sb_iter_init_full(GIsiSubBlockIter *iter, const 
GIsiMessage *msg,
len = used = 0;
 
iter->cursor = longhdr ? 4 : 2;
-   iter->start = (uint8_t *)data + used;
+   iter->start = (uint8_t *) data + used;
iter->end = iter->start + len;
iter->longhdr = longhdr;
iter->sub_blocks = len > used ? sub_blocks : 0;
@@ -72,7 +72,7 @@ void g_isi_sb_iter_init(GIsiSubBlockIter *iter, const 
GIsiMessage *msg,
len = used = 0;
 
iter->cursor = 2;
-   iter->start = (uint8_t *)data + used;
+   iter->start = (uint8_t *) data + used;
iter->end = iter->start + len;
iter->longhdr = FALSE;
iter->sub_blocks = len > used ? iter->start[-1] : 0;
@@ -147,18 +147,18 @@ size_t g_isi_sb_iter_get_len(const GIsiSubBlockIter *iter)
 gboolean g_isi_sb_iter_get_data(const GIsiSubBlockIter *restrict iter,
void **data, unsigned pos)
 {
-   if ((size_t)pos > g_isi_sb_iter_get_len(iter)
+   if ((size_t) pos > g_isi_sb_iter_get_len(iter)
|| iter->start + pos > iter->end)
return FALSE;
 
-   *data = (void *)iter->start + pos;
+   *data = (void *) iter->start + pos;
return TRUE;
 }
 
 gboolean g_isi_sb_iter_get_byte(const GIsiSubBlockIter *restrict iter,
uint8_t *byte, unsigned pos)
 {
-   if ((size_t)pos > g_isi_sb_iter_get_len(iter)
+   if ((size_t) pos > g_isi_sb_iter_get_len(iter)
|| iter->start + pos > iter->end)
return FALSE;
 
@@ -257,8 +257,8 @@ gboolean g_isi_sb_iter_get_alpha_tag(const GIsiSubBlockIter 
*restrict iter,
if (ucs2 + len > iter->end)
return FALSE;
 
-   *utf8 = g_convert((const char *)ucs2, len, "UTF-8//TRANSLIT", "UCS-2BE",
-   NULL, NULL, NULL);
+   *utf8 = g_convert((const char *) ucs2, len, "UTF-8//TRANSLIT",
+   "UCS-2BE", NULL, NULL, NULL);
return *utf8 != NULL;
 }
 
@@ -290,7 +290,7 @@ gboolean g_isi_sb_iter_get_latin_tag(const GIsiSubBlockIter 
*restrict iter,
if (str + len > iter->end)
return FALSE;
 
-   *latin = g_strndup((char *)str, len);
+   *latin = g_strndup((char *) str, len);
 
return *latin != NULL;
 }
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] gisi: Consumer functions for ISI message iterator

2011-03-02 Thread Antti Paila
---
 gisi/iter.c |   63 +++
 gisi/iter.h |   13 
 2 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/gisi/iter.c b/gisi/iter.c
index a925b15..f3f6f5a 100644
--- a/gisi/iter.c
+++ b/gisi/iter.c
@@ -55,6 +55,7 @@ void g_isi_sb_iter_init_full(GIsiSubBlockIter *iter, const 
GIsiMessage *msg,
if (data == NULL)
len = used = 0;
 
+   iter->cursor = longhdr ? 4 : 2;
iter->start = (uint8_t *)data + used;
iter->end = iter->start + len;
iter->longhdr = longhdr;
@@ -70,6 +71,7 @@ void g_isi_sb_iter_init(GIsiSubBlockIter *iter, const 
GIsiMessage *msg,
if (data == NULL)
len = used = 0;
 
+   iter->cursor = 2;
iter->start = (uint8_t *)data + used;
iter->end = iter->start + len;
iter->longhdr = FALSE;
@@ -85,6 +87,7 @@ void g_isi_sb_subiter_init(GIsiSubBlockIter *outer, 
GIsiSubBlockIter *inner,
outer->start + used > outer->end)
len = used = 0;
 
+   inner->cursor = 2;
inner->start = outer->start + used;
inner->end = inner->start + len;
inner->longhdr = FALSE;
@@ -101,6 +104,7 @@ void g_isi_sb_subiter_init_full(GIsiSubBlockIter *outer,
outer->start + used > outer->end)
len = used = 0;
 
+   inner->cursor = longhdr ? 4 : 2;
inner->start = outer->start + used;
inner->end = inner->start + len;
inner->longhdr = longhdr;
@@ -188,6 +192,35 @@ gboolean g_isi_sb_iter_get_dword(const GIsiSubBlockIter 
*restrict iter,
return TRUE;
 }
 
+gboolean g_isi_sb_iter_eat_byte(GIsiSubBlockIter *restrict iter,
+   uint8_t *byte)
+{
+   if (!g_isi_sb_iter_get_byte(iter, byte, iter->cursor))
+   return FALSE;
+
+   iter->cursor += 1;
+   return TRUE;
+}
+gboolean g_isi_sb_iter_eat_word(GIsiSubBlockIter *restrict iter,
+   uint16_t *word)
+{
+   if (!g_isi_sb_iter_get_word(iter, word, iter->cursor))
+   return FALSE;
+
+   iter->cursor += 2;
+   return TRUE;
+}
+
+gboolean g_isi_sb_iter_eat_dword(GIsiSubBlockIter *restrict iter,
+   uint32_t *dword)
+{
+   if (!g_isi_sb_iter_get_dword(iter, dword, iter->cursor))
+   return FALSE;
+
+   iter->cursor += 4;
+   return TRUE;
+}
+
 gboolean g_isi_sb_iter_get_oper_code(const GIsiSubBlockIter *restrict iter,
char *mcc, char *mnc, unsigned pos)
 {
@@ -198,6 +231,16 @@ gboolean g_isi_sb_iter_get_oper_code(const 
GIsiSubBlockIter *restrict iter,
return TRUE;
 }
 
+gboolean g_isi_sb_iter_eat_oper_code(GIsiSubBlockIter *restrict iter,
+   char *mcc, char *mnc)
+{
+   if (!g_isi_sb_iter_get_oper_code(iter, mcc, mnc, iter->cursor))
+   return FALSE;
+
+   iter->cursor += 3;
+   return TRUE;
+}
+
 gboolean g_isi_sb_iter_get_alpha_tag(const GIsiSubBlockIter *restrict iter,
char **utf8, size_t len, unsigned pos)
 {
@@ -219,6 +262,15 @@ gboolean g_isi_sb_iter_get_alpha_tag(const 
GIsiSubBlockIter *restrict iter,
return *utf8 != NULL;
 }
 
+gboolean g_isi_sb_iter_eat_alpha_tag(GIsiSubBlockIter *restrict iter,
+   char **utf8, size_t len)
+{
+   if (!g_isi_sb_iter_get_alpha_tag(iter, utf8, len, iter->cursor))
+   return FALSE;
+
+   iter->cursor += len;
+   return TRUE;
+}
 gboolean g_isi_sb_iter_get_latin_tag(const GIsiSubBlockIter *restrict iter,
char **latin, size_t len, unsigned pos)
 {
@@ -243,6 +295,15 @@ gboolean g_isi_sb_iter_get_latin_tag(const 
GIsiSubBlockIter *restrict iter,
return *latin != NULL;
 }
 
+gboolean g_isi_sb_iter_eat_latin_tag(GIsiSubBlockIter *restrict iter,
+   char **latin, size_t len)
+{
+   if (!g_isi_sb_iter_get_latin_tag(iter, latin, len, iter->cursor))
+   return FALSE;
+
+   iter->cursor += len;
+   return TRUE;
+}
 gboolean g_isi_sb_iter_next(GIsiSubBlockIter *iter)
 {
uint8_t len = g_isi_sb_iter_get_len(iter);
@@ -256,6 +317,8 @@ gboolean g_isi_sb_iter_next(GIsiSubBlockIter *iter)
if (iter->start + len > iter->end)
return FALSE;
 
+
+   iter->cursor = iter->longhdr ? 4 : 2;
iter->start += len;
iter->sub_blocks--;
 
diff --git a/gisi/iter.h b/gisi/iter.h
index 1dfcfa9..2fe4ec5 100644
--- a/gisi/iter.h
+++ b/gisi/iter.h
@@ -31,6 +31,7 @@ extern "C" {
 #include "message.h"
 
 struct _GIsiSubBlockIter {
+   uint8_t cursor;
uint8_t *start;
uint8_t *end;
gboolean longhdr;
@@ -63,12 +64,24 @@ gboolean g_isi_sb_iter_get_word(const GIsiSubBlockIter 
*restrict iter,
uint16_t *word, un

[PATCH 5/5] cell-info: Documentation

2011-02-14 Thread Antti Paila
---
 doc/cell-info.txt |  122 +
 1 files changed, 122 insertions(+), 0 deletions(-)
 create mode 100644 doc/cell-info.txt

diff --git a/doc/cell-info.txt b/doc/cell-info.txt
new file mode 100644
index 000..b8a4136
--- /dev/null
+++ b/doc/cell-info.txt
@@ -0,0 +1,122 @@
+Cell Info hierarchy
+===
+
+Serviceorg.ofono
+Interface  org.ofono.NeighborCellInfo
+Object path[variable prefix]/{modem0,modem1,...}
+
+Methodsaa{sv} AquireMeasurement()
+
+   Calling this procedure returns properties of serving
+   and neighbouring cells in GSM, WCDMA and LTE networks.
+   This information can be used to determine current
+   location using triangulation over neighbouring cell
+   tower locations and estimated distances.
+
+   This method returns an array that consists of two
+   types of cells: 1) first type contains a dictionary of
+   common information about network and serving cell for
+   a certain radio access type 2) following entries
+   contain the measurement results of neighboring cells of
+   the same RAT. The contents of the dictionaries
+   follow the specification OMA-TS-ULP-V2_0-20100816-C
+   for user plane Location and is described in properties
+   section.
+
+   Possible errors: org.ofono.Error.Failed
+
+Properties
+
+Serving cell
+   string Type
+   Radio access network type of neighbor cell information.
+   The possible values are:
+   "geran" Measurement results are for the GSM EDGE Radio
+   Access Network.
+   "utran" Measurement results are for UMTS Radio Access
+   Network.
+
+   uint16 MobileCountryCode
+   Mobile Country Code of serving cell. Possible values:
+   Values: 0...999"
+
+   uint16 MobileNetworkCode
+   Mobile Network Code of serving cell.
+   Values: 0...999"
+
+   uint16 LocationAreaCode [GERAN]
+   Location area code of serving cell.
+   Values: 0...65535
+
+   uint16 CellId [GERAN]
+   Cell Id of serving cell.
+   Values: 0...65535
+
+   byte TimingAdvance [GERAN, optional]
+   Timing advance.
+   Values: 0...63
+
+   uint32 UniqueCellId [UTRA-FDD]
+   Serving WCDMA unique cell ID.
+   Values: 0...268435455
+
+   uint16 ScramblingCode [UTRA-FDD]
+   Primary scrambling code.
+   Values: 0...511
+
+   uint16 UARFCN-DL [UTRA-FDD]
+   Downlink UTRA Absolute Radio Frequency Channel Number
+   of serving cell.
+   Values: 0...16383
+
+   uint16 UARFCN-UL [UTRA-FDD, optional]
+   Uplink UTRA Absolute Radio Frequency Channel Number.
+   Values: 0...16383
+
+
+Neighbor cell measurement results
+
+   uint16 AbsoluteRadioFrequencyChannelNumber [GERAN]
+   Absolute radio frequency channel number.
+   Values: 0...1023
+
+   byte BaseStationIdentityCode [GERAN]
+   Base station identity code.
+   Values: 0...63.
+
+   byte RXLEV [GERAN]
+   Measured power of the channel.
+   Values: 0...63
+
+   byte ReceivedSignalStrengthIndicator [UTRA-FDD]
+   RX power level.
+   Values: 0...127
+
+   uint16 UARFCN-DL [UTRA-FDD]
+   Downlink UARFCN.
+   Values: 0...16383
+
+   uint16 UARFCN-UL [UTRA-FDD, optional]
+   Uplink UARFCN.
+   Values: 0...16383
+
+   uint16 ScramblingCode [UTRA-FDD]
+   Primary scrambling code.
+   Values: 0...511
+
+   uint32 UniqueCellId [UTRA-FDD, optional]
+   Unique cell ID.
+   Values: 0...268435455
+
+   byte CPICH-ECN0 [UTRA-FDD, optional]
+Common pilot channel RX energy per chip over noise
+density in dB.
+Values: 0...63
+
+   int16 CPICH-RSCP [UTRA-FDD, optional]
+   Common pilot channel RX carrier power in dBm
+   

[PATCH 4/5] cell-info: New files included in compilation

2011-02-14 Thread Antti Paila
---
 Makefile.am |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 42ad86f..785640b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,7 +14,8 @@ pkginclude_HEADERS = include/log.h include/plugin.h 
include/history.h \
include/audio-settings.h include/nettime.h \
include/ctm.h include/cdma-voicecall.h \
include/cdma-sms.h include/sim-auth.h \
-   include/gprs-provision.h include/emulator.h
+   include/gprs-provision.h include/emulator.h \
+   include/cell-info.h
 
 nodist_pkginclude_HEADERS = include/version.h
 
@@ -367,7 +368,8 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) 
src/ofono.ver \
src/smsagent.c src/smsagent.h src/ctm.c \
src/cdma-voicecall.c src/sim-auth.c \
src/message.h src/message.c src/gprs-provision.c \
-   src/emulator.c
+   src/emulator.c \
+   src/cell-info.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
@@ -409,7 +411,8 @@ doc_files = doc/overview.txt doc/ofono-paper.txt 
doc/release-faq.txt \
doc/phonebook-api.txt doc/radio-settings-api.txt \
doc/sim-api.txt doc/stk-api.txt \
doc/audio-settings-api.txt doc/text-telephony-api.txt \
-   doc/calypso-modem.txt doc/message-api.txt
+   doc/calypso-modem.txt doc/message-api.txt \
+   doc/cell-info.txt
 
 
 test_scripts = test/backtrace \
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/5] cell-info: Header files for neighbor cell info

2011-02-14 Thread Antti Paila
---
 include/cell-info.h |  126 +++
 src/ofono.h |1 +
 2 files changed, 127 insertions(+), 0 deletions(-)
 create mode 100644 include/cell-info.h

diff --git a/include/cell-info.h b/include/cell-info.h
new file mode 100644
index 000..fed5cbd
--- /dev/null
+++ b/include/cell-info.h
@@ -0,0 +1,126 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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
+ *
+ */
+#ifndef __OFONO_CELL_INFO_H
+#define __OFONO_CELL_INFO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+#include 
+
+struct ofono_cell_info;
+
+
+#define OFONO_CI_FIELD_TA_UNDEFINED 0xFF
+#define OFONO_CI_FIELD_UCID_UNDEFINED 0x
+#define OFONO_CI_FIELD_ECN0_UNDEFINED 0xFF
+#define OFONO_CI_FIELD_RSCP_UNDEFINED -127
+#define OFONO_CI_FIELD_PATHLOSS_UNDEFINED 0xFF
+#define OFONO_CI_FIELD_FREQ_UNDEFINED 0x
+
+#define OFONO_MAX_NMR_COUNT 15
+#define OFONO_MAX_MEASURED_CELL_COUNT 32
+#define OFONO_MAX_MEAS_RES_LIST_COUNT 8
+
+struct geran {
+   uint16_t lac;
+   uint16_t ci;
+   uint8_t ta;
+   uint8_t no_cells;
+   struct geran_neigh_cell {
+   uint16_t arfcn;
+   uint8_t bsic;
+   uint8_t rxlev;
+   } nmr[OFONO_MAX_NMR_COUNT];
+};
+
+struct cell_measured_results {
+   uint32_t ucid;
+   uint16_t sc;
+   uint8_t ecn0;
+   int16_t rscp;
+   uint8_t pathloss;
+};
+
+struct measured_results_list {
+   uint16_t dl_freq;
+   uint16_t ul_freq;
+   uint8_t rssi;
+   uint8_t no_cells;
+   struct cell_measured_results cmr[OFONO_MAX_MEASURED_CELL_COUNT];
+};
+
+struct utran {
+   uint32_t ucid;
+   uint16_t dl_freq;
+   uint16_t ul_freq;
+   uint16_t sc;
+   uint8_t no_freq;
+   struct measured_results_list mrl[OFONO_MAX_MEAS_RES_LIST_COUNT];
+};
+
+struct ofono_cell_info_results {
+
+   char mcc[OFONO_MAX_MCC_LENGTH + 1];
+   char mnc[OFONO_MAX_MNC_LENGTH + 1];
+
+   gboolean has_geran_cells;
+   gboolean has_utran_cells;
+
+   struct geran geran;
+   struct utran utran;
+
+};
+
+
+typedef void (*ofono_cell_info_query_cb_t)(const struct ofono_error *error,
+   struct ofono_cell_info_results *results, void *data);
+
+struct ofono_cell_info_driver {
+   const char *name;
+   int (*probe)(struct ofono_cell_info *ci,
+   unsigned int vendor,
+   void *data);
+   void (*remove)(struct ofono_cell_info *ci);
+   void (*query)(struct ofono_cell_info *ci,
+   ofono_cell_info_query_cb_t cb,
+   void *data);
+};
+
+struct ofono_cell_info *ofono_cell_info_create(struct ofono_modem *modem,
+   unsigned int vendor,
+   const char *driver,
+   void *data);
+
+void ofono_cell_info_register(struct ofono_cell_info *ci);
+void ofono_cell_info_remove(struct ofono_cell_info *ci);
+int ofono_cell_info_driver_register(struct ofono_cell_info_driver *driver);
+void ofono_cell_info_driver_unregister(struct ofono_cell_info_driver *driver);
+void *ofono_cell_info_get_data(struct ofono_cell_info *ci);
+void ofono_cell_info_set_data(struct ofono_cell_info *ci, void *cid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_CELL_INFO_H */
diff --git a/src/ofono.h b/src/ofono.h
index dbe1862..cb33b82 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -129,6 +129,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_CDMA_VOICECALL_MANAGER,
OFONO_ATOM_TYPE_SIM_AUTH,
OFONO_ATOM_TYPE_EMULATOR_DUN,
+   OFONO_ATOM_TYPE_CELL_INFO,
 };
 
 enum ofono_atom_watch_condition {
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 3/5] cell-info: Atom for neighbor cell info

2011-02-14 Thread Antti Paila
---
 src/cell-info.c |  475 +++
 1 files changed, 475 insertions(+), 0 deletions(-)
 create mode 100644 src/cell-info.c

diff --git a/src/cell-info.c b/src/cell-info.c
new file mode 100644
index 000..6e70202
--- /dev/null
+++ b/src/cell-info.c
@@ -0,0 +1,475 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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 
+#endif
+
+#include 
+
+#include 
+#include 
+
+#include "ofono.h"
+
+#include "common.h"
+#include "ofono/cell-info.h"
+
+
+struct ofono_cell_info {
+   DBusMessage *pending;
+   struct ofono_atom *atom;
+   const struct ofono_cell_info_driver *driver;
+   void *driver_data;
+};
+
+
+static DBusMessage *ci_get_cells(DBusConnection *, DBusMessage *, void *);
+
+static GSList *g_drivers = NULL;
+
+static GDBusMethodTable ci_methods[] = {
+   { "AquireMeasurement",  "", "aa{sv}",   ci_get_cells,
+   G_DBUS_METHOD_FLAG_ASYNC },
+   { }
+};
+
+static GDBusSignalTable ci_signals[] = {
+   { }
+};
+
+int ofono_cell_info_driver_register(struct ofono_cell_info_driver *driver)
+{
+   DBG("driver: %p, name: %s", driver, driver->name);
+
+   if (driver->probe == NULL)
+   return -EINVAL;
+
+   g_drivers = g_slist_prepend(g_drivers, (void *) driver);
+
+   return 0;
+}
+
+void ofono_cell_info_driver_unregister(struct ofono_cell_info_driver *driver)
+{
+   DBG("driver: %p, name: %s", driver, driver->name);
+
+   g_drivers = g_slist_remove(g_drivers, (void *) driver);
+}
+
+void ofono_cell_info_remove(struct ofono_cell_info *ci)
+{
+   __ofono_atom_free(ci->atom);
+}
+
+static void cell_info_unregister(struct ofono_atom *atom)
+{
+   struct ofono_cell_info *ci = __ofono_atom_get_data(atom);
+   const char *path = __ofono_atom_get_path(ci->atom);
+   DBusConnection *conn = ofono_dbus_get_connection();
+   struct ofono_modem *modem = __ofono_atom_get_modem(ci->atom);
+
+   ofono_modem_remove_interface(modem, OFONO_CELL_INFO_INTERFACE);
+
+   if (!g_dbus_unregister_interface(conn, path, OFONO_CELL_INFO_INTERFACE))
+   ofono_error("Failed to unregister interface %s",
+   OFONO_CELL_INFO_INTERFACE);
+}
+
+static void cell_info_remove(struct ofono_atom *atom)
+{
+   struct ofono_cell_info *ci = __ofono_atom_get_data(atom);
+   DBG("atom: %p", atom);
+
+   if (ci == NULL)
+   return;
+
+   if (ci->driver && ci->driver->remove)
+   ci->driver->remove(ci);
+
+   g_free(ci);
+}
+
+void ofono_cell_info_register(struct ofono_cell_info *ci)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   struct ofono_modem *modem = __ofono_atom_get_modem(ci->atom);
+   const char *path = __ofono_atom_get_path(ci->atom);
+
+   DBG("Modem: %p", modem);
+
+   if (!g_dbus_register_interface(conn, path,
+   OFONO_CELL_INFO_INTERFACE,
+   ci_methods, ci_signals, NULL,
+   ci, NULL)) {
+   ofono_error("Could not create %s interface",
+   OFONO_CELL_INFO_INTERFACE);
+
+   return;
+   }
+
+   ofono_modem_add_interface(modem, OFONO_CELL_INFO_INTERFACE);
+
+   __ofono_atom_register(ci->atom, cell_info_unregister);
+}
+
+struct ofono_cell_info *ofono_cell_info_create(struct ofono_modem *modem,
+   unsigned int vendor,
+   const char *driver,
+   void *data)
+{
+   struct ofono_cell_info *ci;
+   GSList *l;
+
+   if (driver == NULL)
+   return NULL;
+
+   ci = g_try_new0(struct ofono_cell_info, 1);
+   if (ci == NULL)
+   return NULL;
+
+   ci->atom = __ofono_modem_add_atom(modem,
+   OFONO_ATOM_TYPE_CELL_INFO,
+   cell_info_remove, ci);
+
+   for (l = g_drivers; l; l = l->next) {
+   const struct ofono_cell_info_driver *drv = l->data;
+
+   if (g

[PATCH 0/5 v4] Neighbor Cell Info Atom

2011-02-14 Thread Antti Paila
 This series of patches implements an interface for client
 applications to fetch the ECID information of neighboring
 cells using DBUS. Since the 1st version the DBUS api has
 been refactored to use new naming for method and to use
 flat data format for the cell information. Also, the
 internal datatypes have been optimized. Since the 2nd
 version MNC and MCC are converted to strings and CPICH-RSCP
 re-typed. Since 3rd version multiradio support is added and
 interfaces are renamed.

Antti Paila (5):
  cell-info: CellInfo DBUS interface definition
  cell-info: Header files for neighbor cell info
  cell-info: Atom for neighbor cell info
  cell-info: New files included in compilation
  cell-info: Documentation

 Makefile.am |9 +-
 doc/cell-info.txt   |  122 +
 include/cell-info.h |  126 ++
 include/dbus.h  |1 +
 src/cell-info.c |  475 +++
 src/ofono.h |1 +
 6 files changed, 731 insertions(+), 3 deletions(-)
 create mode 100644 doc/cell-info.txt
 create mode 100644 include/cell-info.h
 create mode 100644 src/cell-info.c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/5] cell-info: CellInfo DBUS interface definition

2011-02-14 Thread Antti Paila
---
 include/dbus.h |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/dbus.h b/include/dbus.h
index 19a138a..52514bb 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -46,6 +46,7 @@ extern "C" {
 #define OFONO_SUPPLEMENTARY_SERVICES_INTERFACE 
"org.ofono.SupplementaryServices"
 #define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration"
 #define OFONO_NETWORK_OPERATOR_INTERFACE "org.ofono.NetworkOperator"
+#define OFONO_CELL_INFO_INTERFACE "org.ofono.NeighborCellInfo"
 #define OFONO_PHONEBOOK_INTERFACE "org.ofono.Phonebook"
 #define OFONO_RADIO_SETTINGS_INTERFACE "org.ofono.RadioSettings"
 #define OFONO_AUDIO_SETTINGS_INTERFACE "org.ofono.AudioSettings"
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 3/3] nettime: Mock Timed for testing

2011-02-09 Thread Antti Paila
---
 test/test-nettime |   35 +++
 1 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100755 test/test-nettime

diff --git a/test/test-nettime b/test/test-nettime
new file mode 100755
index 000..acdd167
--- /dev/null
+++ b/test/test-nettime
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+
+import gobject
+import dbus
+import sys
+import time
+import dbus.service
+import dbus.mainloop.glib
+
+
+class NetworkTime(dbus.service.Object):
+   def __init__(self):
+   busName = dbus.service.BusName('com.meego.timed',
+   bus = dbus.SystemBus())
+   dbus.service.Object.__init__(self, busName, '/com/meego/timed')
+   @dbus.service.method(dbus_interface="com.meego.NetworkTime",
+   in_signature="a{sv}", out_signature="")
+   def Notify(self, arg):
+   print arg
+   print
+   print "Time from mobile: %d" % arg["UTC"]
+   print "DST: %d" % arg["DST"]
+   print "Timezone: %d" % arg["Timezone"]
+   print "MNC: %s" % arg["MobileNetworkCode"]
+   print "MCC: %s" % arg["MobileCountryCode"]
+
+if __name__ == '__main__':
+   dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+   agent = NetworkTime()
+
+   mainloop = gobject.MainLoop()
+   mainloop.run()
+
+
+
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/3] nettime: Makefile.am modification

2011-02-09 Thread Antti Paila
---
 Makefile.am |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index e402de4..b043f9e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -338,6 +338,9 @@ builtin_modules += example_provision
 builtin_sources += examples/provision.c
 endif
 
+builtin_modules += meego_nettime
+builtin_sources += plugins/meego-nettime.c
+
 builtin_modules += smart_messaging
 builtin_sources += plugins/smart-messaging.c
 
@@ -480,7 +483,8 @@ test_scripts = test/backtrace \
test/cdma-hangup \
test/disable-call-forwarding \
test/list-messages \
-   test/test-sms
+   test/test-sms \
+   test/test-nettime
 
 if TEST
 testdir = $(pkglibdir)/test
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/3] nettime: Network time plugin implementation

2011-02-09 Thread Antti Paila
---
 plugins/meego-nettime.c |  321 +++
 1 files changed, 321 insertions(+), 0 deletions(-)
 create mode 100644 plugins/meego-nettime.c

diff --git a/plugins/meego-nettime.c b/plugins/meego-nettime.c
new file mode 100644
index 000..442925c
--- /dev/null
+++ b/plugins/meego-nettime.c
@@ -0,0 +1,321 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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 
+#endif
+
+#include 
+#include 
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "ofono.h"
+#include "common.h"
+
+#define TIMED_PATH "/com/meego/timed"
+#define TIMED_SERVICE "com.meego.timed"
+
+struct nt_data {
+   gboolean time_available;
+   gboolean time_pending;
+   time_t nw_time_utc;
+   time_t received;
+   int dst;
+   int time_zone;
+   char mcc[OFONO_MAX_MCC_LENGTH + 1];
+   char mnc[OFONO_MAX_MNC_LENGTH + 1];
+   unsigned int timed_watch;
+   gboolean timed_present;
+   struct ofono_netreg *netreg;
+   unsigned int netreg_status_watch;
+   unsigned int netreg_watch;
+};
+
+static gboolean encode_time_format(struct ofono_network_time *time,
+struct tm *tm)
+{
+
+   if (time->year < 0)
+   return FALSE;
+
+   tm->tm_year = time->year - 1900;
+   tm->tm_mon = time->mon - 1;
+   tm->tm_mday = time->mday;
+   tm->tm_hour = time->hour;
+   tm->tm_min = time->min;
+   tm->tm_sec = time->sec;
+
+   return TRUE;
+}
+
+static time_t get_monotonic_time()
+{
+   struct timespec ts;
+   clock_gettime(CLOCK_MONOTONIC, &ts);
+
+   return ts.tv_sec;
+}
+
+static int fill_time_notification(DBusMessage *msg,
+   struct nt_data *ntd)
+{
+   DBusMessageIter iter, iter_array;
+   int64_t utc;
+
+   const char *mcc = ntd->mcc;
+   const char *mnc = ntd->mnc;
+
+   dbus_message_iter_init_append(msg, &iter);
+   dbus_message_iter_open_container(&iter,
+   DBUS_TYPE_ARRAY,
+   "{sv}",
+   &iter_array);
+
+   if (ntd->time_pending) {
+   if (ntd->time_available) {
+   utc = ntd->nw_time_utc - ntd->received;
+   ofono_dbus_dict_append(&iter_array,
+   "UTC",
+   DBUS_TYPE_INT64,
+   &utc);
+   }
+
+   ofono_dbus_dict_append(&iter_array,
+   "DST",
+   DBUS_TYPE_INT32,
+   &ntd->dst);
+   ofono_dbus_dict_append(&iter_array,
+   "Timezone",
+   DBUS_TYPE_INT32,
+   &ntd->time_zone);
+   }
+
+   ofono_dbus_dict_append(&iter_array,
+   "MobileCountryCode",
+   DBUS_TYPE_STRING,
+   &mcc);
+   ofono_dbus_dict_append(&iter_array,
+   "MobileNetworkCode",
+   DBUS_TYPE_STRING,
+   &mnc);
+
+   dbus_message_iter_close_container(&iter, &iter_array);
+   return 0;
+}
+
+static DBusMessage *create_time_notification(
+   struct ofono_nettime_context *context)
+{
+   DBusMessage *message;
+   struct nt_data *ntd = context->data;
+   const char *path = ofono_modem_get_path(context->modem);
+
+   if (path == NULL) {
+   ofono_error("Fetching path for modem failed");
+   return NULL;
+   }
+
+   message = dbus_message_new_method_call(TIMED_SERVICE, TIMED_PATH,
+   "com.meego.NetworkTime", "Notify");
+
+   if (message == NULL)
+   return NULL;
+
+   dbus_message_set_no_reply(message, TRUE);
+   fill_time_notification(message, ntd);
+
+   return message;
+}
+
+static void nettime_remove(struct ofono_nettime_context *context)

[PATCH 0/3 v5] Network Time Plugin

2011-02-09 Thread Antti Paila
 This series of patches introduces the network time part of
 the NITZ feature as outlined in 3GPP spec 22.042.
 The plugin is for delivering network indicated time information
 to timed process which is responsible for maintaining the system
 time. The delivery is achieved by timed implementing an interface
 with a method that is called by the nettime plugin with time related
 info as a parameter of the method.

Antti Paila (3):
  nettime: Network time plugin implementation
  nettime: Makefile.am modification
  nettime: Mock Timed for testing

 Makefile.am |6 +-
 plugins/meego-nettime.c |  321 +++
 test/test-nettime   |   35 +
 3 files changed, 361 insertions(+), 1 deletions(-)
 create mode 100644 plugins/meego-nettime.c
 create mode 100755 test/test-nettime

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 5/5 v3] Cell-info: Documentation

2011-02-08 Thread Antti Paila
Hi Marcel,

On Mon, 2011-02-07 at 11:24 -0800, ext Marcel Holtmann wrote:
> Hi Antti,
> 
> >  doc/cell-info.txt |  121 
> > +
> >  1 files changed, 121 insertions(+), 0 deletions(-)
> >  create mode 100644 doc/cell-info.txt
> > 
> > diff --git a/doc/cell-info.txt b/doc/cell-info.txt
> > new file mode 100644
> > index 000..64d9db6
> > --- /dev/null
> > +++ b/doc/cell-info.txt
> > @@ -0,0 +1,121 @@
> > +Cell Info hierarchy
> > +===
> > +
> > +Serviceorg.ofono
> > +Interface  org.ofono.CellInfo
> > +Object path[variable prefix]/{modem0,modem1,...}
> > +
> > +Methodsaa{sv} GetNeighbors()
> > +
> > +   Calling this procedure returns properties of serving
> > +   and neighboring cells in GSM or WCDMA networks. This
> > +   information can be used to determine current location
> > +   using triangulation over neighboring cell tower
> > +   locations and estimated distances.
> > +
> > +   The returned array consists of two parts: 1) first
> > +   element of the array contains a dictionary of
> > +   common information about network and serving cell 2)
> > +   rest of the array comprises dictionaries containing
> > +   measurement results of neighboring cells. The contents
> > +   of the dictionaries follow the specification
> > +   OMA-TS-ULP-V2_0-20100816-C for user plane Location and
> > +   is described in properties section.
> 
> I am having a little bit of a problem calling this GetNeighbors and then
> also retrieving the serving cell at the same time.
> 
> I am just spinning some idea here, but maybe calling the interface
> org.ofono.NeighborCellInfo and the method AquireMeasurment() would be
> better.

Sounds better to me also.

> > +   Possible errors: org.ofono.Error.Failed
> > +
> > +Properties
> > +
> > +Serving cell
> > +   string Type
> > +   Radio access network type of neighbor cell information.
> > +   The possible values are:
> > +   "geran" Measurement results are for the GSM EDGE Radio
> > +   Access Network.
> > +   "utran" Measurement results are for UMTS Radio Access
> > +   Network.
> > +
> > +   string MobileCountryCode
> > +   Mobile Country Code of serving cell. Possible values:
> > +   Values: 0...999
> > +
> > +   string MobileNetworkCode
> > +   Mobile Network Code of serving cell.
> > +   Values: 0...999
> > +
> > +   uint16 LocationAreaCode [GERAN]
> > +   Location area code of serving cell.
> > +   Values: 0...65535
> > +
> > +   uint16 CellId [GERAN]
> > +   Cell Id of serving cell.
> > +   Values: 0...65535
> > +
> > +   byte TimingAdvance [GERAN, optional]
> > +   Timing advance.
> > +   Values: 0...63
> > +
> > +   uint32 UniqueCellId [UTRA-FDD]
> > +   Serving WCDMA unique cell ID.
> > +   Values: 0...268435455
> > +
> > +   uint16 ScramblingCode [UTRA-FDD]
> > +   Primary scrambling code.
> > +   Values: 0...511
> > +
> > +   uint16 UARFCN-DL [UTRA-FDD]
> > +   Downlink UTRA Absolute Radio Frequency Channel Number
> > +   of serving cell.
> > +   Values: 0...16383
> 
> Do we wanna keep the UARFCN acronym?
> 
> > +   uint16 UARFCN-UL [UTRA-FDD, optional]
> > +   Uplink UTRA Absolute Radio Frequency Channel Number.
> > +   Values: 0...16383
> 
> I am still going forth and back if it is a good idea to make cell[0]
> special as the serving cell. There are common fields, but also other
> fields that are totally different.
> 
> So one question that came to my mind is how this mixes when the serving
> cell is UMTS, can the neighbors cells also report GSM? Do we have a mix
> of values in the dictionary anyway?

At the moment the dictionary can contain only geran or utran cells but
not both at the same time. Having thought this over, it might be
reasonable to allow the dictionary contain also mixed entries. I don't
know if it is technically possible at the moment to measure different
radio technologies but we might not want to limit this possibility on
the API level.

> > +Neighbor cell measurement results
> > +
> > +   uint16 AbsoluteRadioFrequencyChannelNumber [GERAN]
> > +   Absolute radio frequency channel number.
> > +   Values: 0...1023
> > +
> > +   byte BaseStationIdentityCode [GERAN]
> > +   Base station identity 

Re: [PATCH 2/5 v3] Cell-info: Header file for Neighbor cell info

2011-02-08 Thread Antti Paila
Hi Marcel,

On Mon, 2011-02-07 at 11:30 -0800, ext Marcel Holtmann wrote:
> Hi Antti,
> 
> > +#define OFONO_CI_FIELD_TA_UNDEFINED 0xFF
> > +#define OFONO_CI_FIELD_UCID_UNDEFINED 0x
> > +#define OFONO_CI_FIELD_ECN0_UNDEFINED 0xFF
> > +#define OFONO_CI_FIELD_RSCP_UNDEFINED -127
> > +#define OFONO_CI_FIELD_PATHLOSS_UNDEFINED 0xFF
> > +#define OFONO_CI_FIELD_FREQ_UNDEFINED 0x
> > +
> > +#define OFONO_MAX_NMR_COUNT 15
> > +#define OFONO_MAX_MEASURED_CELL_COUNT 32
> > +#define OFONO_MAX_MEAS_RES_LIST_COUNT 8
> > +
> > +enum ofono_cell_type {
> > +   OFONO_CELL_TYPE_GERAN,
> > +   OFONO_CELL_TYPE_UTRAN_FDD
> > +};
> 
> anything we have to keep in mind for LTE here? Or does LTE not matter
> for neighbor cell info?

Neighbor cell info does matter for LTE. I quickly browsed through the
OMA spec and it seems that eutra follows the same format as geran and
utran. Have not had time to get the details yet.

Best Regards,
  Antti

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 1/4] nettime: Network time plugin implementation

2011-02-08 Thread Antti Paila
Hi Marcel,

On Mon, 2011-02-07 at 10:58 -0800, ext Marcel Holtmann wrote:
> Hi Antti,
> 
> >  plugins/nettime.c |  326 
> > +
> >  1 files changed, 326 insertions(+), 0 deletions(-)
> >  create mode 100644 plugins/nettime.c
> 
> I would prefer if we call this nokia-timed.c or in case this actually
> becomes default part of MeeGo, them maybe meego-timed.c. I would be also
> fine with {nokia,meego}-nettime.c.
> 
> Just calling it nettime.c is too generic. It needs to be clear what this
> is for.
> 
> > +#define TIMED_PATH "/com/meego/time"
> > +#define TIMED_SERVICE "com.meego.time"
> 
> So the intention is to convert the Nokia timed into a MeeGo specific
> daemon? I would have expected to see com.nokia.timed here.

My understanding is that this will be Meego specific plugin since timed
is part of Meego. Hence, the service 'com.meego.timed'.  

> > +struct nt_data {
> > +   gboolean time_available;
> > +   gboolean time_pending;
> > +   time_t nw_time_utc;
> > +   time_t received;
> > +   int dst;
> > +   int time_zone;
> > +   const char *mcc;
> > +   const char *mnc;
> 
> Why do you bother with these here. You might better just reference the
> netreg atom. The memory is only valid if netreg atom is present.

Timed expects to receive the mcc and mnc in the time notification.
However, if the mcc and mnc don't change we don't resend the
information. These fields contain the mnc and mcc that oFono sent
in the previous time notification.

Best Regards,
  Antti

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 0/5 v3] Neighbor Cell Info Atom

2011-02-02 Thread Antti Paila
Hi,

What is the status of this set of patches? Do we still need more time
for review or can neighbor cell info atom be integrated to oFono?
Original patch set was submitted on 12/01/2011.

Best Regards,
  Antti

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/4] nettime: Makefile.am modification

2011-02-01 Thread Antti Paila
---
 Makefile.am |9 +++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index a38fcb9..2d54025 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -337,6 +337,9 @@ builtin_modules += example_provision
 builtin_sources += examples/provision.c
 endif
 
+builtin_modules += nettime
+builtin_sources += plugins/nettime.c
+
 builtin_modules += smart_messaging
 builtin_sources += plugins/smart-messaging.c
 
@@ -404,7 +407,8 @@ doc_files = doc/overview.txt doc/ofono-paper.txt 
doc/release-faq.txt \
doc/phonebook-api.txt doc/radio-settings-api.txt \
doc/sim-api.txt doc/stk-api.txt \
doc/audio-settings-api.txt doc/text-telephony-api.txt \
-   doc/calypso-modem.txt doc/message-api.txt
+   doc/calypso-modem.txt doc/message-api.txt \
+   doc/network-time-api.txt
 
 
 test_scripts = test/backtrace \
@@ -478,7 +482,8 @@ test_scripts = test/backtrace \
test/cdma-dial-number \
test/cdma-hangup \
test/disable-call-forwarding \
-   test/list-messages
+   test/list-messages \
+   test/test-nettime
 
 if TEST
 testdir = $(pkglibdir)/test
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 4/4] nettime: Mock Timed for testing

2011-02-01 Thread Antti Paila
---
 test/test-nettime |   35 +++
 1 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100755 test/test-nettime

diff --git a/test/test-nettime b/test/test-nettime
new file mode 100755
index 000..908a5db
--- /dev/null
+++ b/test/test-nettime
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+
+import gobject
+import dbus
+import sys
+import time
+import dbus.service
+import dbus.mainloop.glib
+
+
+class NetworkTime(dbus.service.Object):
+   def __init__(self):
+   busName = dbus.service.BusName('com.meego.time',
+   bus = dbus.SystemBus())
+   dbus.service.Object.__init__(self, busName, '/com/meego/time')
+   @dbus.service.method(dbus_interface="com.meego.NetworkTime",
+   in_signature="a{sv}", out_signature="")
+   def Notify(self, arg):
+   print arg
+   print
+   print "Time from mobile: %d" % arg["UTC"]
+   print "DST: %d" % arg["DST"]
+   print "Timezone: %d" % arg["Timezone"]
+   print "MNC: %s" % arg["MobileNetworkCode"]
+   print "MCC: %s" % arg["MobileCountryCode"]
+
+if __name__ == '__main__':
+   dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+   agent = NetworkTime()
+
+   mainloop = gobject.MainLoop()
+   mainloop.run()
+
+
+
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 3/4] nettime: Documentation

2011-02-01 Thread Antti Paila
---
 doc/network-time-api.txt |   36 
 1 files changed, 36 insertions(+), 0 deletions(-)
 create mode 100644 doc/network-time-api.txt

diff --git a/doc/network-time-api.txt b/doc/network-time-api.txt
new file mode 100644
index 000..9133a73
--- /dev/null
+++ b/doc/network-time-api.txt
@@ -0,0 +1,36 @@
+Network time hierarchy
+==
+
+Interface  com.meego.NetworkTime
+Object path[variable]
+
+Methodsvoid Notify(dict info)
+
+   Notifies the service of current time and date
+   as notified by the cellular network.  The info
+   argument contains a dictionary with the
+   following possible keys:
+
+   int64 UTC [optional]
+   Network time in seconds from epoch
+   normalized to device boot time.
+   Reveicing entity obtains current real
+   time by adding the value from monotonic
+   clock e.g.
+   clock_gettime(CLOCK_MONOTONIC,...).
+
+   int32 Timezone [optional]
+   Current timezone offset in seconds from
+   UTC.
+
+   int32 DST [optional]
+   Current daylight saving setting in
+   hours.
+
+   string MobileCountryCode
+   The Mobile country code of the
+   current network operator.
+
+   string MobileNetworkCode
+   The Mobile network code of the
+   current network operator.
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/4] nettime: Network time plugin implementation

2011-02-01 Thread Antti Paila
---
 plugins/nettime.c |  326 +
 1 files changed, 326 insertions(+), 0 deletions(-)
 create mode 100644 plugins/nettime.c

diff --git a/plugins/nettime.c b/plugins/nettime.c
new file mode 100644
index 000..894dce7
--- /dev/null
+++ b/plugins/nettime.c
@@ -0,0 +1,326 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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 
+#endif
+
+#include 
+#include 
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "ofono.h"
+
+#include "common.h"
+
+#define TIMED_PATH "/com/meego/time"
+#define TIMED_SERVICE "com.meego.time"
+
+struct nt_data {
+   gboolean time_available;
+   gboolean time_pending;
+   time_t nw_time_utc;
+   time_t received;
+   int dst;
+   int time_zone;
+   const char *mcc;
+   const char *mnc;
+   unsigned int timed_watch;
+   gboolean timed_present;
+   struct ofono_netreg *netreg;
+   unsigned int netreg_st_watch;
+
+};
+
+static void nettime_register(struct ofono_nettime_context *);
+
+static gboolean encode_time_format(struct ofono_network_time *time,
+struct tm *tm)
+{
+
+   tm->tm_gmtoff = time->utcoff;
+   tm->tm_isdst = time->dst;
+
+   if (time->year < 0)
+   return FALSE;
+
+   tm->tm_year = time->year - 1900;
+   tm->tm_mon = time->mon - 1;
+   tm->tm_mday = time->mday;
+   tm->tm_hour = time->hour;
+   tm->tm_min = time->min;
+   tm->tm_sec = time->sec;
+
+   return TRUE;
+}
+
+static time_t get_monotonic_time()
+{
+   struct timespec ts;
+   clock_gettime(CLOCK_MONOTONIC, &ts);
+   return ts.tv_sec;
+}
+
+static int fill_time_notification(DBusMessage *msg,
+   struct nt_data *ntd)
+{
+   DBusMessageIter iter, iter_array;
+   int64_t utc;
+
+   dbus_message_iter_init_append(msg, &iter);
+   dbus_message_iter_open_container(&iter,
+   DBUS_TYPE_ARRAY,
+   "{sv}",
+   &iter_array);
+
+   if (ntd->time_pending) {
+   if (ntd->time_available) {
+   utc = ntd->nw_time_utc - ntd->received;
+   ofono_dbus_dict_append(&iter_array,
+   "UTC",
+   DBUS_TYPE_INT64,
+   &utc);
+   }
+
+   ofono_dbus_dict_append(&iter_array,
+   "DST",
+   DBUS_TYPE_INT32,
+   &ntd->dst);
+   ofono_dbus_dict_append(&iter_array,
+   "Timezone",
+   DBUS_TYPE_INT32,
+   &ntd->time_zone);
+   }
+
+   ofono_dbus_dict_append(&iter_array,
+   "MobileCountryCode",
+   DBUS_TYPE_STRING,
+   &ntd->mcc);
+   ofono_dbus_dict_append(&iter_array,
+   "MobileNetworkCode",
+   DBUS_TYPE_STRING,
+   &ntd->mnc);
+
+   dbus_message_iter_close_container(&iter, &iter_array);
+   return 0;
+}
+
+static DBusMessage *create_time_notification(
+   struct ofono_nettime_context *context)
+{
+   DBusMessage *message;
+   struct nt_data *ntd = context->data;
+   const char *path = ofono_modem_get_path(context->modem);
+
+   if (path == NULL) {
+   ofono_error("Fetching path for modem failed");
+   return NULL;
+   }
+
+   message = dbus_message_new_method_call(TIMED_SERVICE, TIMED_PATH,
+   "com.meego.NetworkTime", "Notify");
+   if (message == NULL)
+   return NULL;
+
+   dbus_message_set_no_reply(message, TRUE);
+   fill_time_notification(message, ntd);
+
+   return message;
+}
+
+static void init_time(struct ofono_nettime_context *context)
+{
+   struct nt_data *nt_data = g_new0(

[PATCH 0/4 v4] Network Time Plugin

2011-02-01 Thread Antti Paila
 This series of patches introduces the network time part of
 the NITZ feature as outlined in 3GPP spec 22.042.
 The plugin is for delivering network indicated time information
 to timed process which is responsible for maintaining the system
 time. The delivery is achieved by timed implementing an interface
 with a method that is called by the nettime plugin with time related
 info as a parameter of the method.

Antti Paila (4):
  nettime: Network time plugin implementation
  nettime: Makefile.am modification
  nettime: Documentation
  nettime: Mock Timed for testing

 Makefile.am  |9 +-
 doc/network-time-api.txt |   36 +
 plugins/nettime.c|  326 ++
 test/test-nettime|   35 +
 4 files changed, 404 insertions(+), 2 deletions(-)
 create mode 100644 doc/network-time-api.txt
 create mode 100644 plugins/nettime.c
 create mode 100755 test/test-nettime

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 3/5 v3] nettime: DBUS and compilation configuration

2011-01-21 Thread Antti Paila
Hi,

On Thu, 2011-01-20 at 12:19 +0100, ext Marcel Holtmann wrote:
> Hi Aki,
> 
> > > please don't implement org.ofono interface in timed. Just implement a
> > > timed specific (com.nokia.time) interface and punch the whole for that
> > > in the timed D-Bus policy.
> > 
> > I think there is some disconnect here. The intention is to implement a
> > similar agent interface as PushNotification and SmartMessaging already
> > do, with the exception that the one and only agent is known beforehand
> > and "hard-coded" to the plugin.
> 
> that is not what I said and that is clearly not the intent here.
> 
> > This is a generic interface that some other time information sink
> > could also implement, so it makes sense to have it in the org.ofono
> > namespace. Regardless of which namespace we use, though, it is oFono
> > that will be calling methods on this interface, and thus it needs to
> > have this interface opened in its D-Bus config.
> 
> They will be always specific to the target daemon and that is fine. This
> is not up to oFono to define and that is point here.
> 
> > > The plugin is timed specific since it monitors com.nokia.time and thus
> > > should also target a timed specific API. Not a generic oFono API
> > > description.
> > 
> > This is really just another agent API in oFono, just one with a
> > build-time registration mechanism for agents.
> 
> It is not. This is timed exposing an API to get notifications from a
> cellular stack and then a timed specific plugin inside oFono. It has
> nothing to do with an oFono defined D-Bus API.

As I see, the question at the moment is where to punch the hole in D-Bus
configuration; alternatives being either in ofono or in timed side. I
can see the rationale and reasoning behind both approaches, but in order
to make some progress with this matter we need a decision. So, should we
take a vote or what? After all isn't this a non-functional,
matter-of-taste type of question?

Best Regards,
  Antti

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 3/5 v3] nettime: DBUS and compilation configuration

2011-01-17 Thread Antti Paila
Hi Marcel,

On Fri, 2011-01-14 at 01:22 +0100, ext Marcel Holtmann wrote:
> Hi Antti,
> 
> >  Makefile.am|9 +++--
> >  src/ofono.conf |2 ++
> >  2 files changed, 9 insertions(+), 2 deletions(-)
> 
> 
>  
> >
> >  
> > +
> >  
> >  
> >  
> >  
> > +
> >
> >  
> >
> 
> I am now lost in what you are trying to achieve here. I thought we
> agreed that we send a D-Bus method to timed. For that you neither have
> to have a well known name nor have a D-Bus interface present.

Are you referring to line
''?
This is the interface timed is supposed to implement in order for oFono
to call its Notify method. How else would you do it? 


> And surely ofonod will not claim com.meego as service name.

Yes, sure. That was just left behind from testing, since the mock timed
script needed this for D-Bus access. I'll remove it.

Best Regards,
  Antti

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 4/5 v3] nettime: Documentation

2011-01-13 Thread Antti Paila
---
 doc/network-time-api.txt |   36 
 1 files changed, 36 insertions(+), 0 deletions(-)
 create mode 100644 doc/network-time-api.txt

diff --git a/doc/network-time-api.txt b/doc/network-time-api.txt
new file mode 100644
index 000..bdefed7
--- /dev/null
+++ b/doc/network-time-api.txt
@@ -0,0 +1,36 @@
+Network time hierarchy
+==
+
+Interface  org.ofono.NetworkTime
+Object path[variable]
+
+Methodsvoid Notify(dict info)
+
+   Notifies the service of current time and date
+   as notified by the cellular network.  The info
+   argument contains a dictionary with the
+   following possible keys:
+
+   int64 UTC [optional]
+   Network time in seconds from epoch
+   normalized to device boot time.
+   Reveicing entity obtains current real
+   time by adding the value from monotonic
+   clock e.g.
+   clock_gettime(CLOCK_MONOTONIC,...).
+
+   int32 Timezone [optional]
+   Current timezone offset in seconds from
+   UTC.
+
+   uint32 DST [optional]
+   Current daylight saving setting in
+   hours.
+
+   string MobileCountryCode
+   The Mobile country code of the
+   current network operator.
+
+   string MobileNetworkCode
+   The Mobile network code of the
+   current network operator.
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/5 v3] nettime: Network time plugin implementation

2011-01-13 Thread Antti Paila
---
 plugins/nettime.c |  317 +
 1 files changed, 317 insertions(+), 0 deletions(-)
 create mode 100644 plugins/nettime.c

diff --git a/plugins/nettime.c b/plugins/nettime.c
new file mode 100644
index 000..ee24320
--- /dev/null
+++ b/plugins/nettime.c
@@ -0,0 +1,317 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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 
+#endif
+
+#include 
+#include 
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "ofono.h"
+
+#include "common.h"
+
+#define TIMED_PATH "/com/meego/time"
+#define TIMED_SERVICE "com.meego.time"
+
+struct nt_data {
+   gboolean time_available;
+   gboolean time_pending;
+
+   time_t nw_time_utc;
+   time_t received;
+
+   int dst;
+   int time_zone;
+
+   const char *mcc;
+   const char *mnc;
+};
+
+static void nettime_register(struct ofono_nettime_context *);
+
+static gboolean encode_time_format(struct ofono_network_time *time,
+struct tm *tm)
+{
+   if (time->year < 0)
+   return FALSE;
+
+   tm->tm_year = time->year - 1900;
+   tm->tm_mon = time->mon - 1;
+   tm->tm_mday = time->mday;
+   tm->tm_hour = time->hour;
+   tm->tm_min = time->min;
+   tm->tm_sec = time->sec;
+   tm->tm_gmtoff = time->utcoff;
+   tm->tm_isdst = time->dst;
+
+   return TRUE;
+}
+
+static time_t get_monotonic_time()
+{
+   struct timespec ts;
+   clock_gettime(CLOCK_MONOTONIC, &ts);
+   return ts.tv_sec;
+}
+
+static int fill_time_notification(DBusMessage *msg,
+   struct nt_data *ntd)
+{
+   DBusMessageIter iter, iter_array;
+   time_t utc;
+
+   dbus_message_iter_init_append(msg, &iter);
+   dbus_message_iter_open_container(&iter,
+   DBUS_TYPE_ARRAY,
+   "{sv}",
+   &iter_array);
+
+   if (ntd->time_pending) {
+   if (ntd->time_available) {
+   utc = ntd->nw_time_utc - ntd->received;
+
+   ofono_dbus_dict_append(&iter_array,
+   "UTC",
+   DBUS_TYPE_INT64,
+   &utc);
+   ofono_dbus_dict_append(&iter_array,
+   "DST",
+   DBUS_TYPE_UINT32,
+   &ntd->dst);
+   }
+
+   ofono_dbus_dict_append(&iter_array,
+   "Timezone",
+   DBUS_TYPE_INT32,
+   &ntd->time_zone);
+   }
+
+   ofono_dbus_dict_append(&iter_array,
+   "MobileCountryCode",
+   DBUS_TYPE_STRING,
+   &ntd->mcc);
+   ofono_dbus_dict_append(&iter_array,
+   "MobileNetworkCode",
+   DBUS_TYPE_STRING,
+   &ntd->mnc);
+
+   dbus_message_iter_close_container(&iter, &iter_array);
+   return 0;
+}
+
+static DBusMessage *create_time_notification(
+   struct ofono_nettime_context *context)
+{
+   DBusMessage *message;
+   struct nt_data *ntd = context->data;
+   const char *path = ofono_modem_get_path(context->modem);
+
+   if (path == NULL) {
+   ofono_error("Fetching path for modem failed");
+   return NULL;
+   }
+
+   message = dbus_message_new_method_call(TIMED_SERVICE, TIMED_PATH,
+   "org.ofono.NetworkTime", "Notify");
+   if (message == NULL)
+   return NULL;
+
+   dbus_message_set_no_reply(message, TRUE);
+   fill_time_notification(message, ntd);
+
+   return message;
+}
+
+static void init_time(struct ofono_nettime_context *context)
+{
+   struct nt_data *nt_data = g_new0(struct nt_data, 1);
+
+   nt_data->time_available = FALSE;
+   nt_data->time_pending = FALSE;
+

[PATCH 3/5 v3] nettime: DBUS and compilation configuration

2011-01-13 Thread Antti Paila
---
 Makefile.am|9 +++--
 src/ofono.conf |2 ++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index a68fc36..4e30cc9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -321,6 +321,9 @@ builtin_modules += example_nettime
 builtin_sources += examples/nettime.c
 endif
 
+builtin_modules += nettime
+builtin_sources += plugins/nettime.c
+
 builtin_modules += smart_messaging
 builtin_sources += plugins/smart-messaging.c
 
@@ -386,7 +389,8 @@ doc_files = doc/overview.txt doc/ofono-paper.txt 
doc/release-faq.txt \
doc/phonebook-api.txt doc/radio-settings-api.txt \
doc/sim-api.txt doc/stk-api.txt \
doc/audio-settings-api.txt doc/text-telephony-api.txt \
-   doc/calypso-modem.txt
+   doc/calypso-modem.txt \
+   doc/network-time-api.txt
 
 
 test_scripts = test/backtrace \
@@ -455,7 +459,8 @@ test_scripts = test/backtrace \
test/set-gsm-band \
test/set-umts-band \
test/lockdown-modem \
-   test/set-call-forwarding
+   test/set-call-forwarding \
+   test/test-nettime
 
 if TEST
 testdir = $(pkglibdir)/test
diff --git a/src/ofono.conf b/src/ofono.conf
index 0dfa038..c7b2e79 100644
--- a/src/ofono.conf
+++ b/src/ofono.conf
@@ -9,10 +9,12 @@
 
   
 
+
 
 
 
 
+
   
 
   
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 5/5 v3] nettime: Mock Timed for testing

2011-01-13 Thread Antti Paila
---
 test/test-nettime |   35 +++
 1 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100755 test/test-nettime

diff --git a/test/test-nettime b/test/test-nettime
new file mode 100755
index 000..c215902
--- /dev/null
+++ b/test/test-nettime
@@ -0,0 +1,35 @@
+#!/usr/bin/python
+
+import gobject
+import dbus
+import sys
+import time
+import dbus.service
+import dbus.mainloop.glib
+
+
+class NetworkTime(dbus.service.Object):
+   def __init__(self):
+   busName = dbus.service.BusName('com.meego.time',
+   bus = dbus.SystemBus())
+   dbus.service.Object.__init__(self, busName, '/com/meego/time')
+   @dbus.service.method(dbus_interface="org.ofono.NetworkTime",
+   in_signature="a{sv}", out_signature="")
+   def Notify(self, arg):
+   print arg
+   print
+   print "Time from mobile: %d" % arg["UTC"]
+   print "DST: %d" % arg["DST"]
+   print "Timezone: %d" % arg["Timezone"]
+   print "MNC: %s" % arg["MobileNetworkCode"]
+   print "MCC: %s" % arg["MobileCountryCode"]
+
+if __name__ == '__main__':
+   dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+   agent = NetworkTime()
+
+   mainloop = gobject.MainLoop()
+   mainloop.run()
+
+
+
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/5 v3] Network Time plugin

2011-01-13 Thread Antti Paila
 This series of patches introduces the network time part of
 the NITZ feature as outlined in 3GPP spec 22.042.
 The plugin is for delivering network indicated time information
 to timed process which is responsible for maintaining the system
 time. The delivery is achieved by timed implementing an interface
 with a method that is called by the nettime plugin with time related
 info as a parameter of the method.

Antti Paila (5):
  nettime: Header file for nettime plugins
  nettime: Network time plugin implementation
  nettime: DBUS and compilation configuration
  nettime: Documentation
  nettime: Mock Timed for testing

 Makefile.am  |9 +-
 doc/network-time-api.txt |   36 +
 include/nettime.h|4 +
 plugins/nettime.c|  317 ++
 src/ofono.conf   |2 +
 test/test-nettime|   35 +
 6 files changed, 401 insertions(+), 2 deletions(-)
 create mode 100644 doc/network-time-api.txt
 create mode 100644 plugins/nettime.c
 create mode 100755 test/test-nettime

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/5 v3] nettime: Header file for nettime plugins

2011-01-13 Thread Antti Paila
---
 include/nettime.h |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/nettime.h b/include/nettime.h
index 0f23cc7..2f73e1a 100644
--- a/include/nettime.h
+++ b/include/nettime.h
@@ -31,6 +31,10 @@ struct ofono_network_time;
 struct ofono_nettime_context {
struct ofono_nettime_driver *driver;
struct ofono_modem *modem;
+   unsigned int timed_watch;
+   gboolean timed_present;
+   struct ofono_netreg *netreg;
+   unsigned int netreg_st_watch;
void *data;
 };
 
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/5 v3] Neighbor Cell Info Atom

2011-01-12 Thread Antti Paila
 This series of patches implements an interface for client
 applications to fetch the ECID information of neighboring
 cells using DBUS. Since the 1st version the DBUS api has
 been refactored to use new naming for method and to use
 flat data format for the cell information. Also, the
 internal datatypes have been optimized. Since the 2nd
 version MNC and MCC are converted to strings and CPICH-RSCP
 re-typed.

Antti Paila (5):
  Cell-info: CellInfo DBUS interface definition
  Cell-info: Header file for Neighbor cell info
  Cell-info: Atom for obtaining ECID info of cells
  Cell-info: New files included in compilation
  Cell-info: Documentation

 Makefile.am |8 +-
 doc/cell-info.txt   |  121 +
 include/cell-info.h |  128 ++
 include/dbus.h  |1 +
 src/cell-info.c |  485 +++
 src/ofono.h |1 +
 6 files changed, 741 insertions(+), 3 deletions(-)
 create mode 100644 doc/cell-info.txt
 create mode 100644 include/cell-info.h
 create mode 100644 src/cell-info.c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 4/5 v3] Cell-info: New files included in compilation

2011-01-12 Thread Antti Paila
---
 Makefile.am |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 4dec90a..096450f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,7 +15,8 @@ include_HEADERS = include/log.h include/plugin.h 
include/history.h \
include/radio-settings.h include/stk.h \
include/audio-settings.h include/nettime.h \
include/ctm.h include/cdma-voicecall.h \
-   include/cdma-sms.h
+   include/cdma-sms.h \
+   include/cell-info.h
 
 nodist_include_HEADERS = include/version.h
 
@@ -340,7 +341,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) 
src/ofono.ver \
src/nettime.c src/stkagent.c src/stkagent.h \
src/simfs.c src/simfs.h src/audio-settings.c \
src/smsagent.c src/smsagent.h src/ctm.c \
-   src/cdma-voicecall.c
+   src/cdma-voicecall.c src/cell-info.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
@@ -381,7 +382,8 @@ doc_files = doc/overview.txt doc/ofono-paper.txt 
doc/release-faq.txt \
doc/phonebook-api.txt doc/radio-settings-api.txt \
doc/sim-api.txt doc/stk-api.txt \
doc/audio-settings-api.txt doc/text-telephony-api.txt \
-   doc/calypso-modem.txt
+   doc/calypso-modem.txt \
+   doc/cell-info.txt
 
 
 test_scripts = test/backtrace \
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/5 v3] Cell-info: CellInfo DBUS interface definition

2011-01-12 Thread Antti Paila
---
 include/dbus.h |1 +
 src/ofono.h|1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/dbus.h b/include/dbus.h
index 12768f6..f2e18bf 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -45,6 +45,7 @@ extern "C" {
 #define OFONO_MESSAGE_WAITING_INTERFACE "org.ofono.MessageWaiting"
 #define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration"
 #define OFONO_NETWORK_OPERATOR_INTERFACE "org.ofono.NetworkOperator"
+#define OFONO_CELL_INFO_INTERFACE "org.ofono.CellInfo"
 #define OFONO_PHONEBOOK_INTERFACE "org.ofono.Phonebook"
 #define OFONO_RADIO_SETTINGS_INTERFACE "org.ofono.RadioSettings"
 #define OFONO_AUDIO_SETTINGS_INTERFACE "org.ofono.AudioSettings"
diff --git a/src/ofono.h b/src/ofono.h
index cab70cd..820e3a3 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -127,6 +127,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_NETTIME = 21,
OFONO_ATOM_TYPE_CTM = 22,
OFONO_ATOM_TYPE_CDMA_VOICECALL_MANAGER = 23,
+   OFONO_ATOM_TYPE_CELL_INFO = 24,
 };
 
 enum ofono_atom_watch_condition {
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/5 v3] Cell-info: Header file for Neighbor cell info

2011-01-12 Thread Antti Paila
---
 include/cell-info.h |  128 +++
 1 files changed, 128 insertions(+), 0 deletions(-)
 create mode 100644 include/cell-info.h

diff --git a/include/cell-info.h b/include/cell-info.h
new file mode 100644
index 000..36d7fca
--- /dev/null
+++ b/include/cell-info.h
@@ -0,0 +1,128 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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
+ *
+ */
+#ifndef __OFONO_CELL_INFO_H
+#define __OFONO_CELL_INFO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+#include 
+
+struct ofono_cell_info;
+
+
+#define OFONO_CI_FIELD_TA_UNDEFINED 0xFF
+#define OFONO_CI_FIELD_UCID_UNDEFINED 0x
+#define OFONO_CI_FIELD_ECN0_UNDEFINED 0xFF
+#define OFONO_CI_FIELD_RSCP_UNDEFINED -127
+#define OFONO_CI_FIELD_PATHLOSS_UNDEFINED 0xFF
+#define OFONO_CI_FIELD_FREQ_UNDEFINED 0x
+
+#define OFONO_MAX_NMR_COUNT 15
+#define OFONO_MAX_MEASURED_CELL_COUNT 32
+#define OFONO_MAX_MEAS_RES_LIST_COUNT 8
+
+enum ofono_cell_type {
+   OFONO_CELL_TYPE_GERAN,
+   OFONO_CELL_TYPE_UTRAN_FDD
+};
+
+struct geran {
+   uint16_t lac;
+   uint16_t ci;
+   uint8_t ta;
+   uint8_t no_cells;
+   struct geran_neigh_cell {
+   uint16_t arfcn;
+   uint8_t bsic;
+   uint8_t rxlev;
+   } nmr[OFONO_MAX_NMR_COUNT];
+};
+
+struct cell_measured_results {
+   uint32_t ucid;
+   uint16_t sc;
+   uint8_t ecn0;
+   int16_t rscp;
+   uint8_t pathloss;
+};
+
+struct measured_results_list {
+   uint16_t dl_freq;
+   uint16_t ul_freq;
+   uint8_t rssi;
+   uint8_t no_cells;
+   struct cell_measured_results cmr[OFONO_MAX_MEASURED_CELL_COUNT];
+};
+
+struct utran {
+   uint32_t ucid;
+   uint16_t dl_freq;
+   uint16_t ul_freq;
+   uint16_t sc;
+   uint8_t no_freq;
+   struct measured_results_list mrl[OFONO_MAX_MEAS_RES_LIST_COUNT];
+};
+
+struct ofono_cell_info_results {
+   enum ofono_cell_type rat;
+   char mcc[OFONO_MAX_MCC_LENGTH + 1];
+   char mnc[OFONO_MAX_MNC_LENGTH + 1];
+   union {
+   struct geran geran;
+   struct utran utran;
+   };
+};
+
+
+typedef void (*ofono_cell_info_query_cb_t)(const struct ofono_error *error,
+   struct ofono_cell_info_results *results, void *data);
+
+struct ofono_cell_info_driver {
+   const char *name;
+   int (*probe)(struct ofono_cell_info *ci,
+   unsigned int vendor,
+   void *data);
+   void (*remove)(struct ofono_cell_info *ci);
+   void (*query)(struct ofono_cell_info *ci,
+   ofono_cell_info_query_cb_t cb,
+   void *data);
+};
+
+struct ofono_cell_info *ofono_cell_info_create(struct ofono_modem *modem,
+   unsigned int vendor,
+   const char *driver,
+   void *data);
+
+void ofono_cell_info_register(struct ofono_cell_info *ci);
+void ofono_cell_info_remove(struct ofono_cell_info *ci);
+int ofono_cell_info_driver_register(struct ofono_cell_info_driver *driver);
+void ofono_cell_info_driver_unregister(struct ofono_cell_info_driver *driver);
+void *ofono_cell_info_get_data(struct ofono_cell_info *ci);
+void ofono_cell_info_set_data(struct ofono_cell_info *ci, void *cid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_CELL_INFO_H */
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 5/5 v3] Cell-info: Documentation

2011-01-12 Thread Antti Paila
---
 doc/cell-info.txt |  121 +
 1 files changed, 121 insertions(+), 0 deletions(-)
 create mode 100644 doc/cell-info.txt

diff --git a/doc/cell-info.txt b/doc/cell-info.txt
new file mode 100644
index 000..64d9db6
--- /dev/null
+++ b/doc/cell-info.txt
@@ -0,0 +1,121 @@
+Cell Info hierarchy
+===
+
+Serviceorg.ofono
+Interface  org.ofono.CellInfo
+Object path[variable prefix]/{modem0,modem1,...}
+
+Methodsaa{sv} GetNeighbors()
+
+   Calling this procedure returns properties of serving
+   and neighboring cells in GSM or WCDMA networks. This
+   information can be used to determine current location
+   using triangulation over neighboring cell tower
+   locations and estimated distances.
+
+   The returned array consists of two parts: 1) first
+   element of the array contains a dictionary of
+   common information about network and serving cell 2)
+   rest of the array comprises dictionaries containing
+   measurement results of neighboring cells. The contents
+   of the dictionaries follow the specification
+   OMA-TS-ULP-V2_0-20100816-C for user plane Location and
+   is described in properties section.
+
+   Possible errors: org.ofono.Error.Failed
+
+Properties
+
+Serving cell
+   string Type
+   Radio access network type of neighbor cell information.
+   The possible values are:
+   "geran" Measurement results are for the GSM EDGE Radio
+   Access Network.
+   "utran" Measurement results are for UMTS Radio Access
+   Network.
+
+   string MobileCountryCode
+   Mobile Country Code of serving cell. Possible values:
+   Values: 0...999
+
+   string MobileNetworkCode
+   Mobile Network Code of serving cell.
+   Values: 0...999
+
+   uint16 LocationAreaCode [GERAN]
+   Location area code of serving cell.
+   Values: 0...65535
+
+   uint16 CellId [GERAN]
+   Cell Id of serving cell.
+   Values: 0...65535
+
+   byte TimingAdvance [GERAN, optional]
+   Timing advance.
+   Values: 0...63
+
+   uint32 UniqueCellId [UTRA-FDD]
+   Serving WCDMA unique cell ID.
+   Values: 0...268435455
+
+   uint16 ScramblingCode [UTRA-FDD]
+   Primary scrambling code.
+   Values: 0...511
+
+   uint16 UARFCN-DL [UTRA-FDD]
+   Downlink UTRA Absolute Radio Frequency Channel Number
+   of serving cell.
+   Values: 0...16383
+
+   uint16 UARFCN-UL [UTRA-FDD, optional]
+   Uplink UTRA Absolute Radio Frequency Channel Number.
+   Values: 0...16383
+
+
+Neighbor cell measurement results
+
+   uint16 AbsoluteRadioFrequencyChannelNumber [GERAN]
+   Absolute radio frequency channel number.
+   Values: 0...1023
+
+   byte BaseStationIdentityCode [GERAN]
+   Base station identity code.
+   Values: 0...63.
+
+   byte RXLEV [GERAN]
+   Measured power of the channel.
+   Values: 0...63
+
+   byte ReceivedSignalStrengthIndicator [UTRA-FDD]
+   RX power level.
+   Values: 0...127
+
+   uint16 UARFCN-DL [UTRA-FDD]
+   Downlink UARFCN.
+   Values: 0...16383
+
+   uint16 UARFCN-UL [UTRA-FDD, optional]
+   Uplink UARFCN.
+   Values: 0...16383
+
+   uint16 ScramblingCode [UTRA-FDD]
+   Primary scrambling code.
+   Values: 0...511
+
+   uint32 UniqueCellId [UTRA-FDD, optional]
+   Unique cell ID.
+   Values: 0...268435455
+
+   byte CPICH-ECN0 [UTRA-FDD, optional]
+Common pilot channel RX energy per chip over noise
+density in dB.
+Values: 0...63
+
+   int16 CPICH-RSCP [UTRA-FDD, optional]
+   Common pilot channel RX carrier power in dBm
+   Values: -4...127
+
+   byte Pathloss [UTRA-FDD, optional]
+  

[PATCH 3/5 v3] Cell-info: Atom for obtaining ECID info of cells

2011-01-12 Thread Antti Paila
---
 src/cell-info.c |  485 +++
 1 files changed, 485 insertions(+), 0 deletions(-)
 create mode 100644 src/cell-info.c

diff --git a/src/cell-info.c b/src/cell-info.c
new file mode 100644
index 000..0ba6658
--- /dev/null
+++ b/src/cell-info.c
@@ -0,0 +1,485 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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 
+#endif
+
+#include 
+
+#include 
+#include 
+
+#include "ofono.h"
+
+#include "common.h"
+#include "ofono/cell-info.h"
+
+
+struct ofono_cell_info {
+   DBusMessage *pending;
+   struct ofono_atom *atom;
+   const struct ofono_cell_info_driver *driver;
+   void *driver_data;
+};
+
+
+static DBusMessage *ci_get_cells(DBusConnection *, DBusMessage *, void *);
+
+static GSList *g_drivers = NULL;
+
+static GDBusMethodTable ci_methods[] = {
+   { "GetNeighbors",   "", "aa{sv}",   ci_get_cells,
+   G_DBUS_METHOD_FLAG_ASYNC },
+   { }
+};
+
+static GDBusSignalTable ci_signals[] = {
+   { }
+};
+
+int ofono_cell_info_driver_register(struct ofono_cell_info_driver *driver)
+{
+   DBG("driver: %p, name: %s", driver, driver->name);
+
+   if (driver->probe == NULL)
+   return -EINVAL;
+
+   g_drivers = g_slist_prepend(g_drivers, (void *) driver);
+
+   return 0;
+}
+
+void ofono_cell_info_driver_unregister(struct ofono_cell_info_driver *driver)
+{
+   DBG("driver: %p, name: %s", driver, driver->name);
+
+   g_drivers = g_slist_remove(g_drivers, (void *) driver);
+}
+
+void ofono_cell_info_remove(struct ofono_cell_info *ci)
+{
+   __ofono_atom_free(ci->atom);
+}
+
+static void cell_info_unregister(struct ofono_atom *atom)
+{
+   struct ofono_cell_info *ci = __ofono_atom_get_data(atom);
+   const char *path = __ofono_atom_get_path(ci->atom);
+   DBusConnection *conn = ofono_dbus_get_connection();
+   struct ofono_modem *modem = __ofono_atom_get_modem(ci->atom);
+
+   ofono_modem_remove_interface(modem, OFONO_CELL_INFO_INTERFACE);
+
+   if (!g_dbus_unregister_interface(conn, path, OFONO_CELL_INFO_INTERFACE))
+   ofono_error("Failed to unregister interface %s",
+   OFONO_CELL_INFO_INTERFACE);
+}
+
+static void cell_info_remove(struct ofono_atom *atom)
+{
+   struct ofono_cell_info *ci = __ofono_atom_get_data(atom);
+   DBG("atom: %p", atom);
+
+   if (ci == NULL)
+   return;
+
+   if (ci->driver && ci->driver->remove)
+   ci->driver->remove(ci);
+
+   g_free(ci);
+}
+
+void ofono_cell_info_register(struct ofono_cell_info *ci)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   struct ofono_modem *modem = __ofono_atom_get_modem(ci->atom);
+   const char *path = __ofono_atom_get_path(ci->atom);
+
+   DBG("Modem: %p", modem);
+
+   if (!g_dbus_register_interface(conn, path,
+   OFONO_CELL_INFO_INTERFACE,
+   ci_methods, ci_signals, NULL,
+   ci, NULL)) {
+   ofono_error("Could not create %s interface",
+   OFONO_CELL_INFO_INTERFACE);
+
+   return;
+   }
+
+   ofono_modem_add_interface(modem, OFONO_CELL_INFO_INTERFACE);
+
+   __ofono_atom_register(ci->atom, cell_info_unregister);
+}
+
+struct ofono_cell_info *ofono_cell_info_create(struct ofono_modem *modem,
+   unsigned int vendor,
+   const char *driver,
+   void *data)
+{
+   struct ofono_cell_info *ci;
+   GSList *l;
+
+   if (driver == NULL)
+   return NULL;
+
+   ci = g_try_new0(struct ofono_cell_info, 1);
+   if (ci == NULL)
+   return NULL;
+
+   ci->atom = __ofono_modem_add_atom(modem,
+   OFONO_ATOM_TYPE_CELL_INFO,
+   cell_info_remove, ci);
+
+   for (l = g_drivers; l; l = l->next) {
+   const struct ofono_cell_info_driver *drv = l->data;
+
+   if (g

Re: [PATCH 0/4 v2] Network Time plugin

2011-01-07 Thread Antti Paila
Hi Marcel,

On Tue, 2011-01-04 at 13:49 -0800, ext Marcel Holtmann wrote:
> Hi Aki,
> 
> > > > But then it is far simpler to have a D-Bus getter and a D-Bus signal by 
> > > > any 
> > > > sane measure of complexity.
> > > 
> > > So you did consider the complexity on both sides, ofonod and timed? And
> > > not just looked at one side of picture?
> > 
> > Timed also needs to follow the registration status, namely the MNC/MCC
> > of the registered network.  This information it needs to be able to find
> > the correct timezone, as the UTC offset alone only indicates the
> > geographic longitude for the timezone.
> > 
> > Factor that in to the equation, and timed already needs to enumerate
> > available modems, call GetProperties, and listen to the
> > NetworkRegistration interface's PropertyChanged signals.
> > 
> > However, if we refactor the time plugin to also send the MNC/MCC pair --
> > or better yet, the ISO country code based on MCC or even the actual
> > timezone from matching zone.tab entry -- then following netreg is no
> > longer needed.
> > 
> > *Then* I agree a method call is actually a lot simpler from timed point
> > of view; all it needs to do is implement a single method on some
> > org.ofono.NetworkTimeConsumer interface and not worry about enumerating
> > modems via ModemManager or listening on any signals.
> 
> we are doing the country alpha2 matching to MCC already in ConnMan for
> the WiFi regulatory enforcement update. I am not sure that I wanna copy
> these tables around all the time.
> 
> So the struct ofono_nettime_context has already a reference to struct
> ofono_modem, so why not add a reference to the struct ofono_netreg and
> then you have the MCC/MNC details available inside the plugin.

If I would like to do conversion from mcc to alpha2 in ofono, what would
be your suggestion for doing this. I noticed that in connman you have
mcc.h that contains the mapping array, but in ofono we don't have such
an array. As a temporary solution, would it be feasible to just import
the mcc.h to ofono until a more generic solution is implemented?

Best Regards,
 Antti

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RE: [PATCH 3/5 v2] Cell-info: Atom for obtaining ECID info of cells

2011-01-06 Thread Antti Paila
Hi Jun,

On Thu, 2011-01-06 at 20:35 +0800, ext Wei, Jun wrote:
> Hi Antti, 
> 
> >-Original Message-
> >Subject: [PATCH 3/5 v2] Cell-info: Atom for obtaining ECID info of cells
> >
> >+static int append_utra_neigh_cell_data(DBusMessageIter *iter,
> >+struct cell_measured_results *cmr)
> >+{
> >
> >
> >+
> >+if (cmr->rscp != OFONO_CI_FIELD_RSCP_UNDEFINED)
> >+ofono_dbus_dict_append(iter,
> >+"CPICH-RSCP",
> >+DBUS_TYPE_INT16,
> >+&cmr->rscp);
> >+
> 
> The type for RSCP should be "DBUS_TYPE_BYTE"


RSCP may obtain negative values whereas DBUS_TYPE_BYTE is a
type code marking an 8-bit _unsigned_ integer.

-Antti

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 5/5 v2] Cell-info: Documentation

2011-01-04 Thread Antti Paila
---
 doc/cell-info.txt |  121 +
 1 files changed, 121 insertions(+), 0 deletions(-)
 create mode 100644 doc/cell-info.txt

diff --git a/doc/cell-info.txt b/doc/cell-info.txt
new file mode 100644
index 000..9d39e38
--- /dev/null
+++ b/doc/cell-info.txt
@@ -0,0 +1,121 @@
+Cell Info hierarchy
+===
+
+Serviceorg.ofono
+Interface  org.ofono.CellInfo
+Object path[variable prefix]/{modem0,modem1,...}
+
+Methodsaa{sv} GetNeighbors()
+
+   Calling this procedure returns properties of serving
+   and neighbouring cells in GSM or WCDMA networks. This
+   information can be used to determine current location
+   using triangulation over neighbouring cell tower
+   locations and estimated distances.
+
+   The returned array consists of two parts: 1) first
+   element of the array contains a dictionary of
+   common information about network and serving cell 2)
+   rest of the array comprises dictionaries containing
+   measurement results of neighboring cells. The contents
+   of the dictionaries follow the specification
+   OMA-TS-ULP-V2_0-20100816-C for user plane Location and
+   is described in properties section.
+
+   Possible errors: org.ofono.Error.Failed
+
+Properties
+
+Serving cell
+   string Type
+   Radio access network type of neighbor cell information.
+   The possible values are:
+   "geran" Measurement results are for the GSM EDGE Radio
+   Access Network.
+   "utran" Measurement results are for UMTS Radio Access
+   Network.
+
+   uint16 MobileCountryCode
+   Mobile Country Code of serving cell. Possible values:
+   Values: 0...999"
+
+   uint16 MobileNetworkCode
+   Mobile Network Code of serving cell.
+   Values: 0...999"
+
+   uint16 LocationAreaCode [GERAN]
+   Location area code of serving cell.
+   Values: 0...65535
+
+   uint16 CellId [GERAN]
+   Cell Id of serving cell.
+   Values: 0...65535
+
+   byte TimingAdvance [GERAN, optional]
+   Timing advance.
+   Values: 0...63
+
+   uint32 UniqueCellId [UTRA-FDD]
+   Serving WCDMA unique cell ID.
+   Values: 0...268435455
+
+   uint16 ScramblingCode [UTRA-FDD]
+   Primary scrambling code.
+   Values: 0...511
+
+   uint16 UARFCN-DL [UTRA-FDD]
+   Downlink UTRA Absolute Radio Frequency Channel Number
+   of serving cell.
+   Values: 0...16383
+
+   uint16 UARFCN-UL [UTRA-FDD, optional]
+   Uplink UTRA Absolute Radio Frequency Channel Number.
+   Values: 0...16383
+
+
+Neighbor cell measurement results
+
+   uint16 AbsoluteRadioFrequencyChannelNumber [GERAN]
+   Absolute radio frequency channel number.
+   Values: 0...1023
+
+   byte BaseStationIdentityCode [GERAN]
+   Base station identity code.
+   Values: 0...63.
+
+   byte RXLEV [GERAN]
+   Measured power of the channel.
+   Values: 0...63
+
+   byte ReceivedSignalStrengthIndicator [UTRA-FDD]
+   RX power level.
+   Values: 0...127
+
+   uint16 UARFCN-DL [UTRA-FDD]
+   Downlink UARFCN.
+   Values: 0...16383
+
+   uint16 UARFCN-UL [UTRA-FDD, optional]
+   Uplink UARFCN.
+   Values: 0...16383
+
+   uint16 ScramblingCode [UTRA-FDD]
+   Primary scrambling code.
+   Values: 0...511
+
+   uint32 UniqueCellId [UTRA-FDD, optional]
+   Unique cell ID.
+   Values: 0...268435455
+
+   byte CPICH-ECN0 [UTRA-FDD, optional]
+Common pilot channel RX energy per chip over noise
+density in dB.
+Values: 0...63
+
+   int16 CPICH-RSCP [UTRA-FDD, optional]
+   Common pilot channel RX carrier power in dBm
+   Values: -4...127
+
+   byte Pathloss [UTRA-FDD, optional]

[PATCH 3/5 v2] Cell-info: Atom for obtaining ECID info of cells

2011-01-04 Thread Antti Paila
---
 src/cell-info.c |  482 +++
 1 files changed, 482 insertions(+), 0 deletions(-)
 create mode 100644 src/cell-info.c

diff --git a/src/cell-info.c b/src/cell-info.c
new file mode 100644
index 000..e509b9e
--- /dev/null
+++ b/src/cell-info.c
@@ -0,0 +1,482 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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 
+#endif
+
+#include 
+
+#include 
+#include 
+
+#include "ofono.h"
+
+#include "common.h"
+#include "ofono/cell-info.h"
+
+
+struct ofono_cell_info {
+   DBusMessage *pending;
+   struct ofono_atom *atom;
+   const struct ofono_cell_info_driver *driver;
+   void *driver_data;
+};
+
+
+static DBusMessage *ci_get_cells(DBusConnection *, DBusMessage *, void *);
+
+static GSList *g_drivers = NULL;
+
+static GDBusMethodTable ci_methods[] = {
+   { "GetNeighbors",   "", "aa{sv}",   ci_get_cells,
+   G_DBUS_METHOD_FLAG_ASYNC },
+   { }
+};
+
+static GDBusSignalTable ci_signals[] = {
+   { }
+};
+
+int ofono_cell_info_driver_register(struct ofono_cell_info_driver *driver)
+{
+   DBG("driver: %p, name: %s", driver, driver->name);
+
+   if (driver->probe == NULL)
+   return -EINVAL;
+
+   g_drivers = g_slist_prepend(g_drivers, (void *) driver);
+
+   return 0;
+}
+
+void ofono_cell_info_driver_unregister(struct ofono_cell_info_driver *driver)
+{
+   DBG("driver: %p, name: %s", driver, driver->name);
+
+   g_drivers = g_slist_remove(g_drivers, (void *) driver);
+}
+
+void ofono_cell_info_remove(struct ofono_cell_info *ci)
+{
+   __ofono_atom_free(ci->atom);
+}
+
+static void cell_info_unregister(struct ofono_atom *atom)
+{
+   struct ofono_cell_info *ci = __ofono_atom_get_data(atom);
+   const char *path = __ofono_atom_get_path(ci->atom);
+   DBusConnection *conn = ofono_dbus_get_connection();
+   struct ofono_modem *modem = __ofono_atom_get_modem(ci->atom);
+
+   ofono_modem_remove_interface(modem, OFONO_CELL_INFO_INTERFACE);
+
+   if (!g_dbus_unregister_interface(conn, path, OFONO_CELL_INFO_INTERFACE))
+   ofono_error("Failed to unregister interface %s",
+   OFONO_CELL_INFO_INTERFACE);
+}
+
+static void cell_info_remove(struct ofono_atom *atom)
+{
+   struct ofono_cell_info *ci = __ofono_atom_get_data(atom);
+   DBG("atom: %p", atom);
+
+   if (ci == NULL)
+   return;
+
+   if (ci->driver && ci->driver->remove)
+   ci->driver->remove(ci);
+
+   g_free(ci);
+}
+
+void ofono_cell_info_register(struct ofono_cell_info *ci)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   struct ofono_modem *modem = __ofono_atom_get_modem(ci->atom);
+   const char *path = __ofono_atom_get_path(ci->atom);
+
+   DBG("Modem: %p", modem);
+
+   if (!g_dbus_register_interface(conn, path,
+   OFONO_CELL_INFO_INTERFACE,
+   ci_methods, ci_signals, NULL,
+   ci, NULL)) {
+   ofono_error("Could not create %s interface",
+   OFONO_CELL_INFO_INTERFACE);
+
+   return;
+   }
+
+   ofono_modem_add_interface(modem, OFONO_CELL_INFO_INTERFACE);
+
+   __ofono_atom_register(ci->atom, cell_info_unregister);
+}
+
+struct ofono_cell_info *ofono_cell_info_create(struct ofono_modem *modem,
+   unsigned int vendor,
+   const char *driver,
+   void *data)
+{
+   struct ofono_cell_info *ci;
+   GSList *l;
+
+   if (driver == NULL)
+   return NULL;
+
+   ci = g_try_new0(struct ofono_cell_info, 1);
+   if (ci == NULL)
+   return NULL;
+
+   ci->atom = __ofono_modem_add_atom(modem,
+   OFONO_ATOM_TYPE_CELL_INFO,
+   cell_info_remove, ci);
+
+   for (l = g_drivers; l; l = l->next) {
+   const struct ofono_cell_info_driver *drv = l->data;
+
+   if (g

[PATCH 2/5 v2] Cell-info: Header file for Neighbor cell info

2011-01-04 Thread Antti Paila
---
 include/cell-info.h |  128 +++
 1 files changed, 128 insertions(+), 0 deletions(-)
 create mode 100644 include/cell-info.h

diff --git a/include/cell-info.h b/include/cell-info.h
new file mode 100644
index 000..e08944c
--- /dev/null
+++ b/include/cell-info.h
@@ -0,0 +1,128 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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
+ *
+ */
+#ifndef __OFONO_CELL_INFO_H
+#define __OFONO_CELL_INFO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+#include 
+
+struct ofono_cell_info;
+
+
+#define OFONO_CI_FIELD_TA_UNDEFINED 0xFF
+#define OFONO_CI_FIELD_UCID_UNDEFINED 0x
+#define OFONO_CI_FIELD_ECN0_UNDEFINED 0xFF
+#define OFONO_CI_FIELD_RSCP_UNDEFINED -127
+#define OFONO_CI_FIELD_PATHLOSS_UNDEFINED 0xFF
+#define OFONO_CI_FIELD_FREQ_UNDEFINED 0x
+
+#define OFONO_MAX_NMR_COUNT 15
+#define OFONO_MAX_MEASURED_CELL_COUNT 32
+#define OFONO_MAX_MEAS_RES_LIST_COUNT 8
+
+enum ofono_cell_type {
+   OFONO_CELL_TYPE_GERAN,
+   OFONO_CELL_TYPE_UTRAN_FDD
+};
+
+struct geran {
+   uint16_t lac;
+   uint16_t ci;
+   uint8_t ta;
+   uint8_t no_cells;
+   struct geran_neigh_cell {
+   uint16_t arfcn;
+   uint8_t bsic;
+   uint8_t rxlev;
+   } nmr[OFONO_MAX_NMR_COUNT];
+};
+
+struct cell_measured_results {
+   uint32_t ucid;
+   uint16_t sc;
+   uint8_t ecn0;
+   int8_t rscp;
+   uint8_t pathloss;
+};
+
+struct measured_results_list {
+   uint16_t dl_freq;
+   uint16_t ul_freq;
+   uint8_t rssi;
+   uint8_t no_cells;
+   struct cell_measured_results cmr[OFONO_MAX_MEASURED_CELL_COUNT];
+};
+
+struct utran {
+   uint32_t ucid;
+   uint16_t dl_freq;
+   uint16_t ul_freq;
+   uint16_t sc;
+   uint8_t no_freq;
+   struct measured_results_list mrl[OFONO_MAX_MEAS_RES_LIST_COUNT];
+};
+
+struct ofono_cell_info_results {
+   enum ofono_cell_type rat;
+   uint16_t mcc;
+   uint16_t mnc;
+   union {
+   struct geran geran;
+   struct utran utran;
+   };
+};
+
+
+typedef void (*ofono_cell_info_query_cb_t)(const struct ofono_error *error,
+   struct ofono_cell_info_results *results, void *data);
+
+struct ofono_cell_info_driver {
+   const char *name;
+   int (*probe)(struct ofono_cell_info *ci,
+   unsigned int vendor,
+   void *data);
+   void (*remove)(struct ofono_cell_info *ci);
+   void (*query)(struct ofono_cell_info *ci,
+   ofono_cell_info_query_cb_t cb,
+   void *data);
+};
+
+struct ofono_cell_info *ofono_cell_info_create(struct ofono_modem *modem,
+   unsigned int vendor,
+   const char *driver,
+   void *data);
+
+void ofono_cell_info_register(struct ofono_cell_info *ci);
+void ofono_cell_info_remove(struct ofono_cell_info *ci);
+int ofono_cell_info_driver_register(struct ofono_cell_info_driver *driver);
+void ofono_cell_info_driver_unregister(struct ofono_cell_info_driver *driver);
+void *ofono_cell_info_get_data(struct ofono_cell_info *ci);
+void ofono_cell_info_set_data(struct ofono_cell_info *ci, void *cid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_CELL_INFO_H */
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 4/5 v2] Cell-info: New files included in compilation

2011-01-04 Thread Antti Paila
---
 Makefile.am |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 8a8555d..1ede3e7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,7 +14,8 @@ include_HEADERS = include/log.h include/plugin.h 
include/history.h \
include/gprs.h include/gprs-context.h \
include/radio-settings.h include/stk.h \
include/audio-settings.h include/nettime.h \
-   include/ctm.h include/cdma-voicecall.h
+   include/ctm.h include/cdma-voicecall.h \
+   include/cell-info.h
 
 nodist_include_HEADERS = include/version.h
 
@@ -328,7 +329,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) 
src/ofono.ver \
src/nettime.c src/stkagent.c src/stkagent.h \
src/simfs.c src/simfs.h src/audio-settings.c \
src/smsagent.c src/smsagent.h src/ctm.c \
-   src/cdma-voicecall.c
+   src/cdma-voicecall.c src/cell-info.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
@@ -368,7 +369,8 @@ doc_files = doc/overview.txt doc/ofono-paper.txt 
doc/release-faq.txt \
doc/phonebook-api.txt doc/radio-settings-api.txt \
doc/sim-api.txt doc/stk-api.txt \
doc/audio-settings-api.txt doc/text-telephony-api.txt \
-   doc/calypso-modem.txt
+   doc/calypso-modem.txt \
+   doc/cell-info.txt
 
 
 test_scripts = test/backtrace \
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/5 v2] Neighbor cell info Atom

2011-01-04 Thread Antti Paila
 This series of patches implements an interface for client
 applications to fetch the ECID information of neighboring
 cells using DBUS. Since the 1st version the DBUS api has
 been refactored to use new naming for method and to use
 flat data format for the cell information. Also, the 
 internal datatypes have been optimized. 

Antti Paila (5):
  Cell-info: CellInfo DBUS interface definition
  Cell-info: Header file for Neighbor cell info
  Cell-info: Atom for obtaining ECID info of cells
  Cell-info: New files included in compilation
  Cell-info: Documentation

 Makefile.am |8 +-
 doc/cell-info.txt   |  121 +
 include/cell-info.h |  128 ++
 include/dbus.h  |1 +
 src/cell-info.c |  482 +++
 src/ofono.h |1 +
 6 files changed, 738 insertions(+), 3 deletions(-)
 create mode 100644 doc/cell-info.txt
 create mode 100644 include/cell-info.h
 create mode 100644 src/cell-info.c

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/5 v2] Cell-info: CellInfo DBUS interface definition

2011-01-04 Thread Antti Paila
---
 include/dbus.h |1 +
 src/ofono.h|1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/dbus.h b/include/dbus.h
index c527515..98839cc 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -45,6 +45,7 @@ extern "C" {
 #define OFONO_MESSAGE_WAITING_INTERFACE "org.ofono.MessageWaiting"
 #define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration"
 #define OFONO_NETWORK_OPERATOR_INTERFACE "org.ofono.NetworkOperator"
+#define OFONO_CELL_INFO_INTERFACE "org.ofono.CellInfo"
 #define OFONO_PHONEBOOK_INTERFACE "org.ofono.Phonebook"
 #define OFONO_RADIO_SETTINGS_INTERFACE "org.ofono.RadioSettings"
 #define OFONO_AUDIO_SETTINGS_INTERFACE "org.ofono.AudioSettings"
diff --git a/src/ofono.h b/src/ofono.h
index cab70cd..820e3a3 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -127,6 +127,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_NETTIME = 21,
OFONO_ATOM_TYPE_CTM = 22,
OFONO_ATOM_TYPE_CDMA_VOICECALL_MANAGER = 23,
+   OFONO_ATOM_TYPE_CELL_INFO = 24,
 };
 
 enum ofono_atom_watch_condition {
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 5/5] cell-info: Documentation

2010-12-28 Thread Antti Paila
Hi Marcel,

On Tue, 2010-12-28 at 09:13 -0800, ext Marcel Holtmann wrote:
> Hi Antti,
> 
> >  doc/cell-info.txt |  124 
> > +
> >  1 files changed, 124 insertions(+), 0 deletions(-)
> >  create mode 100644 doc/cell-info.txt
> > 
> > diff --git a/doc/cell-info.txt b/doc/cell-info.txt
> > new file mode 100644
> > index 000..b288e69
> > --- /dev/null
> > +++ b/doc/cell-info.txt
> > @@ -0,0 +1,124 @@
> > +Cell Info hierarchy
> > +===
> > +
> > +Serviceorg.ofono
> > +Interface  org.ofono.CellInfo
> > +Object path[variable prefix]/{modem0,modem1,...}
> > +
> > +Methodsa{sv}aa{sv} GetNeighborCellInfo()
> > +
> > +   Calling this procedure returns properties of serving
> > +   and neighbouring cells in GSM or WCDMA networks. This
> > +   information can be used to determine current location
> > +   using triangulation over neighbouring cell tower
> > +   locations and estimated distances.
> > +
> > +   The return value consists of two parts: 1) dictionary
> > +   of common information about network and serving cell 2)
> > +   array of dictionaries containing measurement results
> > +   of neighbouring cells. The contents of the dictionaries
> > +   follow the specification OMA-TS-ULP-V2_0-20100816-C for
> > +   user plane Location and is described in properties
> > +   section.
> > +
> > +   a{sv} GetProperties
> > +
> > +   Calling this procedure returns properties of serving
> > +   cell in GSM or WCDMA networks. Effectively the data
> > +   returned is the part 1 of the data returned by
> > +   GetNeighborCellInfo.
> 
> why do we bother here with two methods calls. What is the use of getting
> only half of the information. You are making the same call to the
> hardware, so why not return the same information.

The GetProperties was kind of last minute glue-on but it was not without
a reason. This atom is about cell info and hence I implicitly assumed
that when you want to query the properties of a cell you would mean the
cell that is your current serving cell. Since nearly all atoms have
GetProperties method, this would be in line with oFono conventions and
services that assume that interface has GetProperties -method could
utilize the cell info. As an example, 'list-modems'-script would nicely
print the serving cell info for a modem.

If the client wants the measurement result of neighboring cells, it
needs to call the GetNeighbors method explicitly. Even if internally
these two methods lead to same hardware call, I don't believe this
should effect the design of DBUS interface, that is visible to client
applications.

That was the reasoning behind the decision to include GetProperties
-method. If you still believe it is not right I can remove the method. 

> The method name org.ofono.CellInfo.GetNeighborCellInfo is also not
> really good. I duplicates the CellInfo information. So I would just have
> called this GetNeighbors.

I agree about the naming. GetNeighbors is better.

> What is the reason behind a{sv}aa{sv} here? Wouldn't it be simpler to
> just go with aa{sv} and declare that the first dict is always the
> current serving cell? Are the information from the current cell really
> that different than from the neighbors?

The rationale is that this is the format OMA-TS-ULP-V2_0-20100816-C and
3GPP RRC define for user plane location. Also, all modems don't provide
the same information for serving and neighbor cells; e.g. isimodem
follows the above mentioned specs. I believe that for location purposes
the information included in the a{sv} part is not needed for neighbors.
Hence making the structure flat would not really make things simpler. 


> One other think that I don't really like with the GetProperties part is
> that we could expect a PropertiesChanged signal. However that is not
> really going to happen since the query should only be done on demand. So
> I would prefer if we then don't have properties at all in this case.

Agreed. Yet again, this is about interface design and what services we
want to provide for clients. I am not religiously trying to defend my
approach, but merely opening the reasons behind the implementation.

Thanks for the comments.

Best Regards,
  Antti 

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 5/5] cell-info: Documentation

2010-12-28 Thread Antti Paila
---
 doc/cell-info.txt |  124 +
 1 files changed, 124 insertions(+), 0 deletions(-)
 create mode 100644 doc/cell-info.txt

diff --git a/doc/cell-info.txt b/doc/cell-info.txt
new file mode 100644
index 000..b288e69
--- /dev/null
+++ b/doc/cell-info.txt
@@ -0,0 +1,124 @@
+Cell Info hierarchy
+===
+
+Serviceorg.ofono
+Interface  org.ofono.CellInfo
+Object path[variable prefix]/{modem0,modem1,...}
+
+Methodsa{sv}aa{sv} GetNeighborCellInfo()
+
+   Calling this procedure returns properties of serving
+   and neighbouring cells in GSM or WCDMA networks. This
+   information can be used to determine current location
+   using triangulation over neighbouring cell tower
+   locations and estimated distances.
+
+   The return value consists of two parts: 1) dictionary
+   of common information about network and serving cell 2)
+   array of dictionaries containing measurement results
+   of neighbouring cells. The contents of the dictionaries
+   follow the specification OMA-TS-ULP-V2_0-20100816-C for
+   user plane Location and is described in properties
+   section.
+
+   a{sv} GetProperties
+
+   Calling this procedure returns properties of serving
+   cell in GSM or WCDMA networks. Effectively the data
+   returned is the part 1 of the data returned by
+   GetNeighborCellInfo.
+
+Properties
+
+a{sv]  string Type
+
+   Radio access network type of neighbor cell information.
+
+   The possible values are:
+   "geran" Measurement results are for the GSM EDGE Radio
+   Access Network.
+   "utran" Measurement results are for UMTS Radio Access
+   Network.
+
+   uint16 MobileCountryCode
+   Mobile Country Code of serving cell. Possible values:
+   Values: 0...999"
+
+   uint16 MobileNetworkCode
+   Mobile Network Code of serving cell.
+   Values: 0...999"
+
+   uint16 LocationAreaCode [GERAN]
+   Location area code of serving cell.
+   Values: 0...65535
+
+   uint16 CellId [GERAN]
+   Cell Id of serving cell.
+   Values: 0...65535
+
+   byte TimingAdvance [GERAN, optional]
+   Timing advance.
+   Values: 0...63
+
+   uint32 UniqueCellId [UTRA-FDD]
+   Serving WCDMA unique cell ID.
+   Values: 0...268435455
+
+   uint16 ScramblingCode [UTRA-FDD]
+   Primary scrambling code.
+   Values: 0...511
+
+   uint16 UARFCN-DL [UTRA-FDD]
+   Downlink UTRA Absolute Radio Frequency Channel Number
+   of serving cell.
+   Values: 0...16383
+
+   uint16 UARFCN-UL [UTRA-FDD, optional]
+   Uplink UTRA Absolute Radio Frequency Channel Number.
+   Values: 0...16383
+
+
+aa{sv} uint16 AbsoluteRadioFrequencyChannelNumber [GERAN]
+   Absolute radio frequency channel number.
+Values: 0...1023
+
+   byte BaseStationIdentityCode [GERAN]
+   Base station identity code.
+   Values: 0...63.
+
+   byte RXLEV [GERAN]
+   Measured power of the channel.
+   Values: 0...63
+
+   byte ReceivedSignalStrengthIndicator [UTRA-FDD]
+   RX power level.
+   Values: 0...127
+
+   uint16 UARFCN-DL [UTRA-FDD]
+   Downlink UARFCN.
+   Values: 0...16383
+
+   uint16 UARFCN-UL [UTRA-FDD, optional]
+   Uplink UARFCN.
+   Values: 0...16383
+
+   uint16 ScramblingCode [UTRA-FDD]
+   Primary scrambling code.
+   Values: 0...511
+
+   uint32 UniqueCellId [UTRA-FDD, optional]
+   Unique cell ID.
+   Values: 0...268435455
+
+   byte CPICH-ECN0 [UTRA-FDD, optional]
+Common pilot channel RX energy per chip over noise
+density in dB.
+Values: 0...63
+
+   int16 CPICH-RSCP [UTRA-FDD, optional]
+   Common pilot channel RX car

[PATCH 1/5] cell-info: Header file for cell info atom

2010-12-28 Thread Antti Paila
---
 include/cell-info.h |  128 +++
 1 files changed, 128 insertions(+), 0 deletions(-)
 create mode 100644 include/cell-info.h

diff --git a/include/cell-info.h b/include/cell-info.h
new file mode 100644
index 000..2b75819
--- /dev/null
+++ b/include/cell-info.h
@@ -0,0 +1,128 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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
+ *
+ */
+#ifndef __OFONO_CELL_INFO_H
+#define __OFONO_CELL_INFO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+#include 
+
+struct ofono_cell_info;
+
+
+#define OFONO_CI_FIELD_TA_UNDEFINED 0xFF
+#define OFONO_CI_FIELD_UCID_UNDEFINED 0x
+#define OFONO_CI_FIELD_ECN0_UNDEFINED 0xFF
+#define OFONO_CI_FIELD_RSCP_UNDEFINED -127
+#define OFONO_CI_FIELD_PATHLOSS_UNDEFINED 0xFF
+#define OFONO_CI_FIELD_FREQ_UNDEFINED 0x
+
+#define OFONO_MAX_NMR_COUNT 15
+#define OFONO_MAX_MEASURED_CELL_COUNT 32
+#define OFONO_MAX_MEAS_RES_LIST_COUNT 8
+
+enum ofono_cell_type {
+   OFONO_CELL_TYPE_GERAN,
+   OFONO_CELL_TYPE_UTRAN_FDD
+};
+
+struct geran {
+   uint16_t lac;
+   uint16_t ci;
+   uint8_t  ta;
+   uint8_t  no_cells;
+   struct geran_neigh_cell {
+   uint16_t arfcn;
+   uint8_t bsic;
+   uint8_t rxlev;
+   } nmr[OFONO_MAX_NMR_COUNT];
+};
+
+struct cell_measured_results {
+   uint32_t ucid;
+   uint16_t sc;
+   uint8_t ecn0;
+   int8_t rscp;
+   uint8_t pathloss;
+};
+
+struct measured_results_list {
+   uint16_t dl_freq;
+   uint16_t ul_freq;
+   uint8_t  rssi;
+   uint8_t  no_cells;
+   struct cell_measured_results cmr[OFONO_MAX_MEASURED_CELL_COUNT];
+};
+
+struct utran {
+   uint32_t ucid;
+   uint16_t dl_freq;
+   uint16_t ul_freq;
+   uint16_t sc;
+   uint8_t  no_freq;
+   struct measured_results_list mrl[OFONO_MAX_MEAS_RES_LIST_COUNT];
+};
+
+struct ofono_cell_info_results {
+   enum ofono_cell_type rat;
+   uint16_t mcc;
+   uint16_t mnc;
+   union {
+   struct geran geran;
+   struct utran utran;
+   };
+};
+
+
+typedef void (*ofono_cell_info_query_cb_t)(const struct ofono_error *error,
+   struct ofono_cell_info_results *results, void *data);
+
+struct ofono_cell_info_driver {
+   const char *name;
+   int (*probe)(struct ofono_cell_info *ci,
+   unsigned int vendor,
+   void *data);
+   void (*remove)(struct ofono_cell_info *ci);
+   void (*query)(struct ofono_cell_info *ci,
+   ofono_cell_info_query_cb_t cb,
+   void *data);
+};
+
+struct ofono_cell_info *ofono_cell_info_create(struct ofono_modem *modem,
+   unsigned int vendor,
+   const char *driver,
+   void *data);
+
+void ofono_cell_info_register(struct ofono_cell_info *ci);
+void ofono_cell_info_remove(struct ofono_cell_info *ci);
+int ofono_cell_info_driver_register(struct ofono_cell_info_driver *driver);
+void ofono_cell_info_driver_unregister(struct ofono_cell_info_driver *driver);
+void *ofono_cell_info_get_data(struct ofono_cell_info *ci);
+void ofono_cell_info_set_data(struct ofono_cell_info *ci, void *cid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_CELL_INFO_H */
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 0/5] Neighboring Cell Info

2010-12-28 Thread Antti Paila
 This series of patches implements an interface for client
 application to fetch the ECID information of neighboring
 cells using DBUS.
 
 include/cell-info.h |  128 +++
 src/cell-info.c |  512 +++
 include/dbus.h |1 +
 src/ofono.h|1 +
 Makefile.am |8 +---
 doc/cell-info.txt |  124 +
 
 
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 3/5] cell-info: Interface declaration for cell info

2010-12-28 Thread Antti Paila
---
 include/dbus.h |1 +
 src/ofono.h|1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/dbus.h b/include/dbus.h
index c527515..98839cc 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -45,6 +45,7 @@ extern "C" {
 #define OFONO_MESSAGE_WAITING_INTERFACE "org.ofono.MessageWaiting"
 #define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration"
 #define OFONO_NETWORK_OPERATOR_INTERFACE "org.ofono.NetworkOperator"
+#define OFONO_CELL_INFO_INTERFACE "org.ofono.CellInfo"
 #define OFONO_PHONEBOOK_INTERFACE "org.ofono.Phonebook"
 #define OFONO_RADIO_SETTINGS_INTERFACE "org.ofono.RadioSettings"
 #define OFONO_AUDIO_SETTINGS_INTERFACE "org.ofono.AudioSettings"
diff --git a/src/ofono.h b/src/ofono.h
index cab70cd..820e3a3 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -127,6 +127,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_NETTIME = 21,
OFONO_ATOM_TYPE_CTM = 22,
OFONO_ATOM_TYPE_CDMA_VOICECALL_MANAGER = 23,
+   OFONO_ATOM_TYPE_CELL_INFO = 24,
 };
 
 enum ofono_atom_watch_condition {
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/5] cell-info: Atom for ECID info of neighb cells

2010-12-28 Thread Antti Paila
---
 src/cell-info.c |  512 +++
 1 files changed, 512 insertions(+), 0 deletions(-)
 create mode 100644 src/cell-info.c

diff --git a/src/cell-info.c b/src/cell-info.c
new file mode 100644
index 000..1a561e4
--- /dev/null
+++ b/src/cell-info.c
@@ -0,0 +1,512 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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 
+#endif
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "ofono.h"
+
+#include "common.h"
+#include "util.h"
+#include "ofono/cell-info.h"
+
+
+struct ofono_cell_info {
+   DBusMessage *pending;
+   struct ofono_atom *atom;
+   const struct ofono_cell_info_driver *driver;
+   void *driver_data;
+   gboolean incl_neigh;
+};
+
+
+static DBusMessage *ci_get_cells(DBusConnection *, DBusMessage *, void *);
+static DBusMessage *ci_get_properties(DBusConnection *, DBusMessage *, void *);
+
+static GSList *g_drivers = NULL;
+
+static GDBusMethodTable ci_methods[] = {
+   { "GetNeighborCellInfo","", "a{sv}aa{sv}",  ci_get_cells,
+   G_DBUS_METHOD_FLAG_ASYNC },
+   { "GetProperties",  "", "a{sv}",ci_get_properties,
+   G_DBUS_METHOD_FLAG_ASYNC },
+
+   { }
+};
+
+static GDBusSignalTable ci_signals[] = {
+   { }
+};
+
+int ofono_cell_info_driver_register(struct ofono_cell_info_driver *driver)
+{
+   DBG("driver: %p, name: %s", driver, driver->name);
+
+   if (driver->probe == NULL)
+   return -EINVAL;
+
+   g_drivers = g_slist_prepend(g_drivers, (void *) driver);
+
+   return 0;
+}
+
+void ofono_cell_info_driver_unregister(struct ofono_cell_info_driver *driver)
+{
+   DBG("driver: %p, name: %s", driver, driver->name);
+
+   g_drivers = g_slist_remove(g_drivers, (void *) driver);
+}
+
+void ofono_cell_info_remove(struct ofono_cell_info *ci)
+{
+   __ofono_atom_free(ci->atom);
+}
+
+static void cell_info_unregister(struct ofono_atom *atom)
+{
+   struct ofono_cell_info *ci = __ofono_atom_get_data(atom);
+   const char *path = __ofono_atom_get_path(ci->atom);
+   DBusConnection *conn = ofono_dbus_get_connection();
+   struct ofono_modem *modem = __ofono_atom_get_modem(ci->atom);
+
+   ofono_modem_remove_interface(modem, OFONO_CELL_INFO_INTERFACE);
+
+   if (!g_dbus_unregister_interface(conn, path, OFONO_CELL_INFO_INTERFACE))
+   ofono_error("Failed to unregister interface %s",
+   OFONO_CELL_INFO_INTERFACE);
+}
+
+static void cell_info_remove(struct ofono_atom *atom)
+{
+   struct ofono_cell_info *ci = __ofono_atom_get_data(atom);
+   DBG("atom: %p", atom);
+
+   if (ci == NULL)
+   return;
+
+   if (ci->driver && ci->driver->remove)
+   ci->driver->remove(ci);
+
+   g_free(ci);
+}
+
+void ofono_cell_info_register(struct ofono_cell_info *ci)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   struct ofono_modem *modem = __ofono_atom_get_modem(ci->atom);
+   const char *path = __ofono_atom_get_path(ci->atom);
+
+   DBG("Modem: %p", modem);
+
+   if (!g_dbus_register_interface(conn, path,
+   OFONO_CELL_INFO_INTERFACE,
+   ci_methods, ci_signals, NULL,
+   ci, NULL)) {
+   ofono_error("Could not create %s interface",
+   OFONO_CELL_INFO_INTERFACE);
+
+   return;
+   }
+
+   ofono_modem_add_interface(modem, OFONO_CELL_INFO_INTERFACE);
+
+   __ofono_atom_register(ci->atom, cell_info_unregister);
+}
+
+struct ofono_cell_info *ofono_cell_info_create(struct ofono_modem *modem,
+   unsigned int vendor,
+   const char *driver,
+   void *data)
+{
+   struct ofono_cell_info *ci;
+   GSList *l;
+
+   if (driver == NULL)
+   return NULL;
+
+   ci = g_try_new0(struct ofono_cell_info, 1);
+   if (ci == NULL)
+   return NULL;
+
+  

[PATCH 4/5] cell-info: New files included for compilation

2010-12-28 Thread Antti Paila
---
 Makefile.am |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index dfdb7bd..d9b0ad3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,7 +14,8 @@ include_HEADERS = include/log.h include/plugin.h 
include/history.h \
include/gprs.h include/gprs-context.h \
include/radio-settings.h include/stk.h \
include/audio-settings.h include/nettime.h \
-   include/ctm.h include/cdma-voicecall.h
+   include/ctm.h include/cdma-voicecall.h \
+   include/cell-info.h
 
 nodist_include_HEADERS = include/version.h
 
@@ -328,7 +329,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) 
src/ofono.ver \
src/nettime.c src/stkagent.c src/stkagent.h \
src/simfs.c src/simfs.h src/audio-settings.c \
src/smsagent.c src/smsagent.h src/ctm.c \
-   src/cdma-voicecall.c
+   src/cdma-voicecall.c src/cell-info.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
@@ -367,7 +368,8 @@ doc_files = doc/overview.txt doc/ofono-paper.txt 
doc/release-faq.txt \
doc/message-api.txt doc/message-waiting-api.txt \
doc/phonebook-api.txt doc/radio-settings-api.txt \
doc/sim-api.txt doc/stk-api.txt \
-   doc/audio-settings-api.txt doc/text-telephony-api.txt
+   doc/audio-settings-api.txt doc/text-telephony-api.txt \
+   doc/cell-info.txt
 
 
 test_scripts = test/backtrace \
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RE: [RFC PATCH 1/5 v2] cell-info: Atom for ECID info of neighb cells

2010-12-28 Thread Antti Paila
Hi Jun,

On Tue, 2010-12-28 at 18:00 +0800, ext Wei, Jun wrote:
> Hi Antti,
> 
> >+static GSList *g_drivers = NULL;
> >+
> >+static GDBusMethodTable ci_methods[] = {
> >+{ "GetProperties",  "", "a{sv}aa{sv}",  ci_get_cells },
> >+{ }
> +};
> +
> 
> Do we need to add 'G_DBUS_METHOD_FLAG_ASYNC' after ci_get_cells? 

Yes, we need. Already noticed it myself while testing :). I'll post the
next version of the patch soon which contains all sort of fixes plus
refactoring. 

> 
> >+static DBusMessage *ci_get_cells(DBusConnection *conn, DBusMessage *msg,
> >+void *data)
> >+{
> >+struct ofono_cell_info *ci = data;
> >+DBG("");
> >+
> >+ci->pending = dbus_message_ref(msg);
> >+ci->driver->query(ci, ofono_cell_info_query_cb, ci->driver_data);
> 
> The 3rd parameter should be 'ci' instead of 'ci->driver_data', right?

Well, the first parameter is already 'ci', so maybe repetition is not
needed. The third parameter is kind of useless here anyway.

Thanks for the comments.

Best Regards,
  Antti

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


n900 not recongnized by ofono?

2010-12-26 Thread Antti Paila
Hi,

It appears that after commit 374dd32812026c3d728f2a14f78357463f12a3f8
ofono is no longer registering n900 properly. At least 'list-modems'
shows empty list even if two commit earlier [isigen0] is there as it
should. Has the functionality changed or is this regression?

Best Regards,
  Antti

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RE: [RFC PATCH 2/5 v2] cell-info: Header file for cell-info atom

2010-12-26 Thread Antti Paila
Hi Waldo,

On Fri, 2010-12-24 at 10:54 -0800, ext Bastian, Waldo wrote:
> > +struct gsm {
> > +   int lac;
> > +   int ci;
> > +   int ta;
> > +   int no_cells;
> > +   struct geran_neigh_cell{
> > +   int arfcn;
> > +   int bsic;
> > +   int rxlev;
> > +
> > +   } nmr[OFONO_MAX_NMR_COUNT];
> > +};
> 
> What about the frequency of the serving cell? I was under the impression that
> there was a need for that one as well.
> 
> Even though the serving cell may be included already in the nmr, do you see a 
> need 
> to explicitly provide the arfcn, bsic and rxlev of the serving cell as well?

Serving cell frequency is, or should be, included in the nmr list in the
arfcn variable. I believe the arfcn, bsic and rxlev are needed for all
cells since this information is used for location determination.

> What about LAC and CI for the neighbouring cells?

As far as I know, the neighbor cell info in the above-mentioned form is
used for location specific purposes. Hence, bsic suffices to identify
base station and rxlev gives the unscaled distance from it.

If there is a reason for including LAC and CI for neighboring cells, we
can add them to the list. In that case we should probably modify the
DBUS method list to include one method for requesting location data and
another method for general identity data.

Best Regards,
  Antti 

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RE: [RFC PATCH 2/5 v2] cell-info: Header file for cell-info atom

2010-12-22 Thread Antti Paila
Hi Jun,

On Thu, 2010-12-23 at 14:31 +0800, ext Wei, Jun wrote:
> Hi Antti,
> 
> On Wed, 2010-12-22 at 11:35 +0200, ext Antti Paila wrote:
> > ---
> >  include/cell-info.h |  133 
> > +++
> >  1 files changed, 133 insertions(+), 0 deletions(-)  create mode 
> > 100644 include/cell-info.h
> > 
> > diff --git a/include/cell-info.h b/include/cell-info.h new file mode 
> > 100644 index 000..3941e69
> > --- /dev/null
> > +++ b/include/cell-info.h
> > @@ -0,0 +1,133 @@
> > +/*
> >  ...
> >  ...
> >  ...
> > +struct ofono_cell_info_driver {
> > +   const char *name;
> > +   int (*probe)(struct ofono_cell_info *ci,
> > +   unsigned int vendor,
> > +   void *data);
> > +   void (*remove)(struct ofono_cell_info *ci);
> > +   void (*query)(struct ofono_cell_info *ci,
> > +   ofono_cell_info_query_cb_t,
> > +   void *data);
> > +};
> > +
> 
> To be aligning with the other header files, do we need to add one 'cb' after 
> 'ofono_cell_info_query_cb_t' here?

This seems to be a matter with no clear convention. In "sms.h" and
"netreg.h" some callbacks have 'cb' and some not. I agree that if within
a function's parameter list some parameters have name declared, so
should all have.

Thanks for the comment.

Best Regards,
  Antti  

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [RFC PATCH 5/5 v2] cell-info: Documentation

2010-12-22 Thread Antti Paila
Hi Aki,

On Wed, 2010-12-22 at 20:46 +0200, ext Aki Niemi wrote:
> Hi Antti,
> 
> On Wed, 2010-12-22 at 11:35 +0200, ext Antti Paila wrote:
> > ---
> >  doc/cell-info.txt |  110 
> > +
> >  1 files changed, 110 insertions(+), 0 deletions(-)
> >  create mode 100644 doc/cell-info.txt
> > 
> > diff --git a/doc/cell-info.txt b/doc/cell-info.txt
> > new file mode 100644
> > index 000..9144eb7
> > --- /dev/null
> > +++ b/doc/cell-info.txt
> > @@ -0,0 +1,110 @@
> > +Cell Info hierarchy
> > +===
> > +
> > +Serviceorg.ofono
> > +Interface  org.ofono.CellInfo
> > +Object path[variable prefix]/{modem0,modem1,...}
> > +
> > +Methodsa{sv}aa{sv} GetProperties()
> > +
> > +   Calling this procedure returns properties of serving
> > +   and neighbouring cells in GSM or WCDMA networks. This
> > +   information can be used to determine current location
> > +   using triangulation over neighbouring cell tower
> > +   locations and estimated distances.
> > +
> > +   The return value consists of two parts: 1) dictionary
> > +   of common information about network and serving cell 2)
> > +   array of dictionaries containing measurement results
> > +   of neighbouring cells. The contents of the dictionaries
> > +   follow the specification OMA-TS-ULP-V2_0-20100816-C for
> > +   user plane Location and is described in properties
> > +   section.
> > +
> > +Properties
> > +
> > +a{sv]  string Type
> > +
> > +   Radio access type.
> > +   Values: "GERAN", "UTRA-FDD
> 
> How about some brief explanation of what these mean? Also, missing end
> quotes on UTRA-FDD, and the naming convention has been to use lower case
> for string values.
> 
> Perhaps along these lines:
> 
> string Type
> 
>   Radio access network type of neighbor cell information.
> 
>   The possible values are:
>   "geran"   Measurement results are for the GSM EDGE Radio
> Access Network
>   "utran"   Measurement results are for UMTS Radio Access
> Network
> 

I'll include this to doc.

> > +   uint32 MCC
> > +   Mobile Country Code of serving cell. Possible values:
> > +   Values: 0...999"
> > +
> > +   uint32 MNC
> > +   Mobile Network Code of serving cell.
> > +   Values: 0...999"
> 
> These need to be MobileCountryCode and MobileNetworkCode, as elsewhere
> in the API. Also, why not string like in the network API?

If convention is to use full names, then so be it. However, MNC and MCC
are so widely used acronyms in 3GPP specifications and generally in
telecommunication that chances for confusing is minimal. The three
letter form is also more compact and more convenient to use.

What is the benefit of representing MNC and MCC as strings? Both codes
consist of digits so to me a natural representation is integer of some
sort.   

> > +   uint32 LAC [GERAN]
> > +   Location area code of serving cell.
> > +   Values: 0...65535
> > +
> > +   uint32 CI [GERAN]
> > +   Cell Id of serving cell.
> > +   Values: 0...65535
> > +
> > +   uint32 TA [GERAN, OPTIONAL]
> > +   Timing advance.
> > +   Values: 0...63
> > +
> > +   uint32 UCID [UTRA-FDD]
> > +   Serving WCDMA unique cell ID.
> > +   Values: 0...268435455
> 
> For the LAC and CI, naming could be borrowed from the network API here
> as well. Though I understand the need to conform to the SUPL specs here.

This is up to discussion. Good argument for the use of acronyms is SUPL
specs and, for example, this doc that explains the content of each
field. Argument against is on the other hand ofono conventions that
should also be respected. Of course, conventions can be changed if seen
necessary.

Thanks for the comments.

Best Regards,
  Antti

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [RFC PATCH 2/5 v2] cell-info: Header file for cell-info atom

2010-12-22 Thread Antti Paila
On Wed, 2010-12-22 at 20:45 +0200, ext Aki Niemi wrote:
> Hi Antti,
> 
> On Wed, 2010-12-22 at 11:35 +0200, ext Antti Paila wrote:
> > ---
> >  include/cell-info.h |  133 
> > +++
> >  1 files changed, 133 insertions(+), 0 deletions(-)
> >  create mode 100644 include/cell-info.h
> > 
> > diff --git a/include/cell-info.h b/include/cell-info.h
> > new file mode 100644
> > index 000..3941e69
> > --- /dev/null
> > +++ b/include/cell-info.h
> > @@ -0,0 +1,133 @@
> > +/*
> > + *
> > + *  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
> > + *
> > + */
> > +
> > +#ifndef __OFONO_CELL_INFO_H
> > +#define __OFONO_CELL_INFO_H
> > +
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
> > +
> > +#include 
> > +
> > +struct ofono_cell_info;
> > +
> > +#define OFONO_CI_FIELD_UNDEFINED -1001
> > +#define OFONO_MAX_NMR_COUNT 15
> > +#define OFONO_MAX_MEASURED_CELL_COUNT 32
> > +#define OFONO_MAX_MEAS_RES_LIST_COUNT 8
> > +
> > +
> > +enum ofono_cell_type {
> > +   OFONO_CELL_TYPE_GERAN,
> > +   OFONO_CELL_TYPE_UTRA_FDD
> > +};
> > +
> > +enum UTRA_MEAS_TYPE {
> > +   UTRA_MEAS_TYPE_INTER_FREQ,
> > +   UTRA_MEAS_TYPE_INTRA_FREQ,
> > +};
> > +
> > +struct gsm {
> > +   int lac;
> > +   int ci;
> > +   int ta;
> > +   int no_cells;
> > +   struct geran_neigh_cell{
> > +   int arfcn;
> > +   int bsic;
> > +   int rxlev;
> > +
> > +   } nmr[OFONO_MAX_NMR_COUNT];
> > +};
> > +
> > +struct cell_measured_results {
> > +   int ucid;
> > +   int sc;
> > +   int ecn0;
> > +   int rscp;
> > +   int pathloss;
> > +};
> > +
> > +struct measured_results_list {
> > +   int dl_freq;
> > +   int ul_freq;
> > +   int rssi;
> > +   int no_cells;
> > +   struct cell_measured_results cmr[OFONO_MAX_MEASURED_CELL_COUNT];
> > +};
> > +
> > +struct wcdma {
> > +   int ucid;
> > +   int dl_freq;
> > +   int ul_freq;
> > +   int sc;
> > +   int no_freq;
> > +   struct measured_results_list mrl[OFONO_MAX_MEAS_RES_LIST_COUNT];
> > +
> > +};
> 
> Since these things are called GERAN and UTRAN over D-Bus, it would make
> sense to use the same naming here instead of struct gsm and struct
> wcdma.
> 
> > +struct ofono_cell_info_results {
> > +   enum ofono_cell_type rat;
> > +   int mcc;
> > +   int mnc;
> > +   union {
> > +   struct gsm gsm;
> > +   struct wcdma wcdma;
> > +   };
> > +
> > +};
> > +
> > +
> > +typedef void (*ofono_cell_info_query_cb_t)(const struct ofono_error *error,
> > +   struct ofono_cell_info_results results, void *data);
> 
> The results is a pointer.

Should be.

> > +struct ofono_cell_info_driver {
> > +   const char *name;
> > +   int (*probe)(struct ofono_cell_info *ci,
> > +   unsigned int vendor,
> > +   void *data);
> > +   void (*remove)(struct ofono_cell_info *ci);
> > +   void (*query)(struct ofono_cell_info *ci,
> > +   ofono_cell_info_query_cb_t,
> > +   void *data);
> > +};
> > +
> > +struct ofono_cell_info *ofono_cell_info_create(struct ofono_modem *modem,
> > +   unsigned int vendor,
> > +   const char *driver,
> > +   void *data);
> > +
> > +void ofono_cell_info_register(struct ofono_cell_info *ci);
> > +void ofono_cell_info_remove(struct ofono_cell_info *ci);
> > +int ofono_cell_info_driver_register(struct ofono_cell_info_driver *driver);
> > +void ofono_cell_info_driver_unregister(struct ofono_cell_info_driver 
> > *driver);
> > +void *ofono_cell_info_get_data(struct ofono_cell_info *ci);
> > +void ofono_cell_info_set_data(struct ofono_cell_info *ci, void *cid);
> > +void ofono_cell_info_query_cb(const struct ofono_error *error,
> > +   struct ofono_cell_info_results results, void *data);
> 
> Why is this last one public?

You are right. It doesn't need to be public. Thanks for the comments.

Best Regards,
 Antti

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 3/5 v2] cell-info: Interface declarations

2010-12-22 Thread Antti Paila
---
 include/dbus.h |1 +
 src/ofono.h|1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/dbus.h b/include/dbus.h
index c527515..98839cc 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -45,6 +45,7 @@ extern "C" {
 #define OFONO_MESSAGE_WAITING_INTERFACE "org.ofono.MessageWaiting"
 #define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration"
 #define OFONO_NETWORK_OPERATOR_INTERFACE "org.ofono.NetworkOperator"
+#define OFONO_CELL_INFO_INTERFACE "org.ofono.CellInfo"
 #define OFONO_PHONEBOOK_INTERFACE "org.ofono.Phonebook"
 #define OFONO_RADIO_SETTINGS_INTERFACE "org.ofono.RadioSettings"
 #define OFONO_AUDIO_SETTINGS_INTERFACE "org.ofono.AudioSettings"
diff --git a/src/ofono.h b/src/ofono.h
index 792134b..cd89a8f 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -126,6 +126,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_STK = 20,
OFONO_ATOM_TYPE_NETTIME = 21,
OFONO_ATOM_TYPE_CTM = 22,
+   OFONO_ATOM_TYPE_CELL_INFO = 23,
 };
 
 enum ofono_atom_watch_condition {
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 5/5 v2] cell-info: Documentation

2010-12-22 Thread Antti Paila
---
 doc/cell-info.txt |  110 +
 1 files changed, 110 insertions(+), 0 deletions(-)
 create mode 100644 doc/cell-info.txt

diff --git a/doc/cell-info.txt b/doc/cell-info.txt
new file mode 100644
index 000..9144eb7
--- /dev/null
+++ b/doc/cell-info.txt
@@ -0,0 +1,110 @@
+Cell Info hierarchy
+===
+
+Serviceorg.ofono
+Interface  org.ofono.CellInfo
+Object path[variable prefix]/{modem0,modem1,...}
+
+Methodsa{sv}aa{sv} GetProperties()
+
+   Calling this procedure returns properties of serving
+   and neighbouring cells in GSM or WCDMA networks. This
+   information can be used to determine current location
+   using triangulation over neighbouring cell tower
+   locations and estimated distances.
+
+   The return value consists of two parts: 1) dictionary
+   of common information about network and serving cell 2)
+   array of dictionaries containing measurement results
+   of neighbouring cells. The contents of the dictionaries
+   follow the specification OMA-TS-ULP-V2_0-20100816-C for
+   user plane Location and is described in properties
+   section.
+
+Properties
+
+a{sv]  string Type
+
+   Radio access type.
+   Values: "GERAN", "UTRA-FDD
+
+   uint32 MCC
+   Mobile Country Code of serving cell. Possible values:
+   Values: 0...999"
+
+   uint32 MNC
+   Mobile Network Code of serving cell.
+   Values: 0...999"
+
+   uint32 LAC [GERAN]
+   Location area code of serving cell.
+   Values: 0...65535
+
+   uint32 CI [GERAN]
+   Cell Id of serving cell.
+   Values: 0...65535
+
+   uint32 TA [GERAN, OPTIONAL]
+   Timing advance.
+   Values: 0...63
+
+   uint32 UCID [UTRA-FDD]
+   Serving WCDMA unique cell ID.
+   Values: 0...268435455
+
+   uint32 SC [UTRA-FDD]
+   Primary scrambling code.
+   Values: 0...511
+
+   uint32 UARFCN-DL [UTRA-FDD]
+   Downlink UARFCN of serving cell.
+   Values: 0...16383
+
+   uint32 UARFCN-UL [UTRA-FDD, OPTIONAL]
+   Uplink UARFCN.
+   Values: 0...16383
+
+
+aa{sv} uint32 ARFCN [GERAN]
+   Absolute radio frequency channel number.
+Values: 0...1023
+
+   uint32 BSIC [GERAN]
+   Base station identity code.
+   Values: 0...63.
+
+   uint32 RXLEV [GERAN]
+   Measured power of the channel.
+   Values: 0...63
+
+   int32 RSSI [UTRA-FDD]
+   RX power level in dBm.
+   Values: -47...-110
+
+   uint32 UARFCN-DL [UTRA-FDD]
+   Downlink UARFCN.
+   Values: 0...16383
+
+   uint32 UARFCN-UL [UTRA-FDD, OPTIONAL]
+   Uplink UARFCN.
+   Values: 0...16383
+
+   uint32 SC [UTRA-FDD]
+   Primary scrambling code.
+   Values: 0...511
+
+   uint32 UCID [UTRA-FDD, OPTIONAL]
+   Unique cell ID.
+   Values: 0...268435455
+
+   uint32 ECN0 [UTRA-FDD, OPTIONAL]
+CPICH RX energy per chip over noise density in dB.
+Values: 0...63
+
+   int32 RSCP [UTRA-FDD, OPTIONAL]
+   CPICH RX carrier power in dBm
+   Values: -4...127
+
+   uint32 Pathloss [UTRA-FDD, OPTIONAL]
+   Measured path loss in dB.
+   Values: 46...173
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 1/5 v2] cell-info: Atom for ECID info of neighb cells

2010-12-22 Thread Antti Paila
---
 src/cell-info.c |  484 +++
 1 files changed, 484 insertions(+), 0 deletions(-)
 create mode 100644 src/cell-info.c

diff --git a/src/cell-info.c b/src/cell-info.c
new file mode 100644
index 000..2289ce1
--- /dev/null
+++ b/src/cell-info.c
@@ -0,0 +1,484 @@
+/*
+ *
+ *  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 
+#endif
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "ofono.h"
+
+#include "common.h"
+#include "util.h"
+#include "ofono/cell-info.h"
+
+
+struct ofono_cell_info {
+   DBusMessage *pending;
+   struct ofono_atom *atom;
+   const struct ofono_cell_info_driver *driver;
+   void *driver_data;
+};
+
+
+static DBusMessage *ci_get_cells(DBusConnection *, DBusMessage *, void *);
+
+static GSList *g_drivers = NULL;
+
+static GDBusMethodTable ci_methods[] = {
+   { "GetProperties",  "", "a{sv}aa{sv}",  ci_get_cells },
+   { }
+};
+
+static GDBusSignalTable ci_signals[] = {
+   { }
+};
+
+int ofono_cell_info_driver_register(struct ofono_cell_info_driver *driver)
+{
+   DBG("driver: %p, name: %s", driver, driver->name);
+
+   if (driver->probe == NULL)
+   return -EINVAL;
+
+   g_drivers = g_slist_prepend(g_drivers, (void *) driver);
+
+   return 0;
+}
+
+void ofono_cell_info_driver_unregister(struct ofono_cell_info_driver *driver)
+{
+   DBG("driver: %p, name: %s", driver, driver->name);
+
+   g_drivers = g_slist_remove(g_drivers, (void *) driver);
+}
+
+void ofono_cell_info_remove(struct ofono_cell_info *ci)
+{
+   __ofono_atom_free(ci->atom);
+}
+
+static void cell_info_unregister(struct ofono_atom *atom)
+{
+   struct ofono_cell_info *ci = __ofono_atom_get_data(atom);
+   const char *path = __ofono_atom_get_path(ci->atom);
+   DBusConnection *conn = ofono_dbus_get_connection();
+   struct ofono_modem *modem = __ofono_atom_get_modem(ci->atom);
+
+   ofono_modem_remove_interface(modem, OFONO_CELL_INFO_INTERFACE);
+
+   if (!g_dbus_unregister_interface(conn, path, OFONO_CELL_INFO_INTERFACE))
+   ofono_error("Failed to unregister interface %s",
+   OFONO_CELL_INFO_INTERFACE);
+}
+
+static void cell_info_remove(struct ofono_atom *atom)
+{
+   struct ofono_cell_info *ci = __ofono_atom_get_data(atom);
+   DBG("atom: %p", atom);
+
+   if (ci == NULL)
+   return;
+
+   if (ci->driver && ci->driver->remove)
+   ci->driver->remove(ci);
+
+   g_free(ci);
+}
+
+void ofono_cell_info_register(struct ofono_cell_info *ci)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   struct ofono_modem *modem = __ofono_atom_get_modem(ci->atom);
+   const char *path = __ofono_atom_get_path(ci->atom);
+
+   if (!g_dbus_register_interface(conn, path,
+   OFONO_CELL_INFO_INTERFACE,
+   ci_methods, ci_signals, NULL,
+   ci, NULL)) {
+   ofono_error("Could not create %s interface",
+   OFONO_CELL_INFO_INTERFACE);
+
+   return;
+   }
+
+   ofono_modem_add_interface(modem, OFONO_CELL_INFO_INTERFACE);
+
+   __ofono_atom_register(ci->atom, cell_info_unregister);
+}
+
+struct ofono_cell_info *ofono_cell_info_create(struct ofono_modem *modem,
+   unsigned int vendor,
+   const char *driver,
+   void *data)
+{
+   struct ofono_cell_info *ci;
+   GSList *l;
+
+   if (driver == NULL)
+   return NULL;
+
+   ci = g_try_new0(struct ofono_cell_info, 1);
+   if (ci == NULL)
+   return NULL;
+
+   ci->atom = __ofono_modem_add_atom(modem,
+   OFONO_ATOM_TYPE_CELL_INFO,
+   cell_info_remove, ci);
+
+   for (l = g_drivers; l; l = l->next) {
+   const struct ofono_cell_info_driver *drv = l->data;
+
+   if (g_strcmp0(drv->name, driver))
+   co

[RFC PATCH 4/5 v2] cell-info: New files included for compilation

2010-12-22 Thread Antti Paila
---
 Makefile.am |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 4a919ab..e433861 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,7 +14,7 @@ include_HEADERS = include/log.h include/plugin.h 
include/history.h \
include/gprs.h include/gprs-context.h \
include/radio-settings.h include/stk.h \
include/audio-settings.h include/nettime.h \
-   include/ctm.h
+   include/ctm.h include/cell-info.h
 
 nodist_include_HEADERS = include/version.h
 
@@ -320,7 +320,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) 
src/ofono.ver \
src/radio-settings.c src/stkutil.h src/stkutil.c \
src/nettime.c src/stkagent.c src/stkagent.h \
src/simfs.c src/simfs.h src/audio-settings.c \
-   src/smsagent.c src/smsagent.h src/ctm.c
+   src/smsagent.c src/smsagent.h src/ctm.c src/cell-info.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 2/5 v2] cell-info: Header file for cell-info atom

2010-12-22 Thread Antti Paila
---
 include/cell-info.h |  133 +++
 1 files changed, 133 insertions(+), 0 deletions(-)
 create mode 100644 include/cell-info.h

diff --git a/include/cell-info.h b/include/cell-info.h
new file mode 100644
index 000..3941e69
--- /dev/null
+++ b/include/cell-info.h
@@ -0,0 +1,133 @@
+/*
+ *
+ *  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
+ *
+ */
+
+#ifndef __OFONO_CELL_INFO_H
+#define __OFONO_CELL_INFO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+
+struct ofono_cell_info;
+
+#define OFONO_CI_FIELD_UNDEFINED -1001
+#define OFONO_MAX_NMR_COUNT 15
+#define OFONO_MAX_MEASURED_CELL_COUNT 32
+#define OFONO_MAX_MEAS_RES_LIST_COUNT 8
+
+
+enum ofono_cell_type {
+   OFONO_CELL_TYPE_GERAN,
+   OFONO_CELL_TYPE_UTRA_FDD
+};
+
+enum UTRA_MEAS_TYPE {
+   UTRA_MEAS_TYPE_INTER_FREQ,
+   UTRA_MEAS_TYPE_INTRA_FREQ,
+};
+
+struct gsm {
+   int lac;
+   int ci;
+   int ta;
+   int no_cells;
+   struct geran_neigh_cell{
+   int arfcn;
+   int bsic;
+   int rxlev;
+
+   } nmr[OFONO_MAX_NMR_COUNT];
+};
+
+struct cell_measured_results {
+   int ucid;
+   int sc;
+   int ecn0;
+   int rscp;
+   int pathloss;
+};
+
+struct measured_results_list {
+   int dl_freq;
+   int ul_freq;
+   int rssi;
+   int no_cells;
+   struct cell_measured_results cmr[OFONO_MAX_MEASURED_CELL_COUNT];
+};
+
+struct wcdma {
+   int ucid;
+   int dl_freq;
+   int ul_freq;
+   int sc;
+   int no_freq;
+   struct measured_results_list mrl[OFONO_MAX_MEAS_RES_LIST_COUNT];
+
+};
+
+struct ofono_cell_info_results {
+   enum ofono_cell_type rat;
+   int mcc;
+   int mnc;
+   union {
+   struct gsm gsm;
+   struct wcdma wcdma;
+   };
+
+};
+
+
+typedef void (*ofono_cell_info_query_cb_t)(const struct ofono_error *error,
+   struct ofono_cell_info_results results, void *data);
+
+struct ofono_cell_info_driver {
+   const char *name;
+   int (*probe)(struct ofono_cell_info *ci,
+   unsigned int vendor,
+   void *data);
+   void (*remove)(struct ofono_cell_info *ci);
+   void (*query)(struct ofono_cell_info *ci,
+   ofono_cell_info_query_cb_t,
+   void *data);
+};
+
+struct ofono_cell_info *ofono_cell_info_create(struct ofono_modem *modem,
+   unsigned int vendor,
+   const char *driver,
+   void *data);
+
+void ofono_cell_info_register(struct ofono_cell_info *ci);
+void ofono_cell_info_remove(struct ofono_cell_info *ci);
+int ofono_cell_info_driver_register(struct ofono_cell_info_driver *driver);
+void ofono_cell_info_driver_unregister(struct ofono_cell_info_driver *driver);
+void *ofono_cell_info_get_data(struct ofono_cell_info *ci);
+void ofono_cell_info_set_data(struct ofono_cell_info *ci, void *cid);
+void ofono_cell_info_query_cb(const struct ofono_error *error,
+   struct ofono_cell_info_results results, void *data);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_CELL_INFO_H */
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 0/5 v2] Atom for Neighbour Cell Info

2010-12-22 Thread Antti Paila
 This series of patches implements an interface for client
 application to fetch the ECID information of neighbouring
 cells using DBUS.
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 4/4] cell-info: New files included for compilation

2010-12-21 Thread Antti Paila
---
 Makefile.am |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 12b3c33..86f1ab5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -14,7 +14,7 @@ include_HEADERS = include/log.h include/plugin.h 
include/history.h \
include/gprs.h include/gprs-context.h \
include/radio-settings.h include/stk.h \
include/audio-settings.h include/nettime.h \
-   include/ctm.h
+   include/ctm.h include/cell-info.h
 
 nodist_include_HEADERS = include/version.h
 
@@ -319,7 +319,7 @@ src_ofonod_SOURCES = $(gdbus_sources) $(builtin_sources) 
src/ofono.ver \
src/radio-settings.c src/stkutil.h src/stkutil.c \
src/nettime.c src/stkagent.c src/stkagent.h \
src/simfs.c src/simfs.h src/audio-settings.c \
-   src/smsagent.c src/smsagent.h src/ctm.c
+   src/smsagent.c src/smsagent.h src/ctm.c src/cell-info.c
 
 src_ofonod_LDADD = $(builtin_libadd) @GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@ -ldl
 
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 3/4] cell-info: Interface declarations

2010-12-21 Thread Antti Paila
---
 include/dbus.h |1 +
 src/ofono.h|1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/include/dbus.h b/include/dbus.h
index c527515..98839cc 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -45,6 +45,7 @@ extern "C" {
 #define OFONO_MESSAGE_WAITING_INTERFACE "org.ofono.MessageWaiting"
 #define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration"
 #define OFONO_NETWORK_OPERATOR_INTERFACE "org.ofono.NetworkOperator"
+#define OFONO_CELL_INFO_INTERFACE "org.ofono.CellInfo"
 #define OFONO_PHONEBOOK_INTERFACE "org.ofono.Phonebook"
 #define OFONO_RADIO_SETTINGS_INTERFACE "org.ofono.RadioSettings"
 #define OFONO_AUDIO_SETTINGS_INTERFACE "org.ofono.AudioSettings"
diff --git a/src/ofono.h b/src/ofono.h
index 792134b..cd89a8f 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -126,6 +126,7 @@ enum ofono_atom_type {
OFONO_ATOM_TYPE_STK = 20,
OFONO_ATOM_TYPE_NETTIME = 21,
OFONO_ATOM_TYPE_CTM = 22,
+   OFONO_ATOM_TYPE_CELL_INFO = 23,
 };
 
 enum ofono_atom_watch_condition {
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 0/4] Atom for Neighbour Cell Info

2010-12-21 Thread Antti Paila
 This series of patches implements an interface for client
 application to fetch the ECID information of neighbouring
 cells using DBUS.

 src/cell-info.c |  537 +++
 include/cell-info.h |   66 +++
 include/dbus.h |1 +
 src/ofono.h|1 +
 Makefile.am |4 ++--
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[RFC PATCH 1/4] cell-info: Atom for ECID info of neighb cells

2010-12-21 Thread Antti Paila
---
 src/cell-info.c |  537 +++
 1 files changed, 537 insertions(+), 0 deletions(-)
 create mode 100644 src/cell-info.c

diff --git a/src/cell-info.c b/src/cell-info.c
new file mode 100644
index 000..13ae03c
--- /dev/null
+++ b/src/cell-info.c
@@ -0,0 +1,537 @@
+/*
+ *
+ *  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 
+#endif
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include "ofono.h"
+
+#include "common.h"
+#include "util.h"
+#include "ofono/cell-info.h"
+
+#define OFONO_MAX_NMR_COUNT 15
+#define OFONO_MAX_MEASURED_CELL_COUNT 32
+#define OFONO_MAX_MEAS_RES_LIST_COUNT 8
+
+
+enum ofono_cell_type {
+   OFONO_CELL_TYPE_GERAN,
+   OFONO_CELL_TYPE_UTRA_FDD
+};
+
+enum UTRA_MEAS_TYPE {
+   UTRA_MEAS_TYPE_INTER_FREQ,
+   UTRA_MEAS_TYPE_INTRA_FREQ,
+};
+
+struct gsm {
+   int lac;
+   int ci;
+   int ta;
+   int no_cells;
+   struct {
+   int arfcn;
+   int bsic;
+   int rxlev;
+
+   } nmr[OFONO_MAX_NMR_COUNT];
+};
+
+struct cell_measured_results {
+   int ucid;
+   int sc;
+   int ecn0;
+   int rscp;
+   int pathloss;
+};
+
+struct measured_results_list {
+   int dl_freq;
+   int ul_freq;
+   int rssi;
+   int no_cells;
+   struct cell_measured_results cmr[OFONO_MAX_MEASURED_CELL_COUNT];
+};
+
+struct wcdma {
+   int ucid;
+   int dl_freq;
+   int ul_freq;
+   int sc;
+   int no_freq;
+   struct measured_results_list mrl[OFONO_MAX_MEAS_RES_LIST_COUNT];
+
+};
+
+struct ofono_cell_info_results {
+   enum ofono_cell_type rat;
+   int mcc;
+   int mnc;
+   union {
+   struct gsm gsm;
+   struct wcdma wcdma;
+   };
+
+};
+
+struct ofono_cell_info {
+   DBusMessage *pending;
+   struct ofono_atom *atom;
+   const struct ofono_cell_info_driver *driver;
+   struct ofono_cell_info_results cir;
+   void *driver_data;
+};
+
+
+static DBusMessage *ci_get_cells(DBusConnection *, DBusMessage *, void *);
+
+static GSList *g_drivers = NULL;
+
+static GDBusMethodTable ci_methods[] = {
+   { "GetProperties",  "", "a{sv}aa{sv}",  ci_get_cells },
+   { }
+};
+
+static GDBusSignalTable ci_signals[] = {
+   { }
+};
+
+int ofono_cell_info_driver_register(struct ofono_cell_info_driver *driver)
+{
+   DBG("driver: %p, name: %s", driver, driver->name);
+
+   if (driver->probe == NULL)
+   return -EINVAL;
+
+   g_drivers = g_slist_prepend(g_drivers, (void *) driver);
+
+   return 0;
+}
+
+void ofono_cell_info_driver_unregister(struct ofono_cell_info_driver *driver)
+{
+   DBG("driver: %p, name: %s", driver, driver->name);
+
+   g_drivers = g_slist_remove(g_drivers, (void *) driver);
+}
+
+void ofono_cell_info_remove(struct ofono_cell_info *ci)
+{
+   __ofono_atom_free(ci->atom);
+}
+
+static void cell_info_unregister(struct ofono_atom *atom)
+{
+   struct ofono_cell_info *ci = __ofono_atom_get_data(atom);
+   const char *path = __ofono_atom_get_path(ci->atom);
+   DBusConnection *conn = ofono_dbus_get_connection();
+   struct ofono_modem *modem = __ofono_atom_get_modem(ci->atom);
+
+   ofono_modem_remove_interface(modem, OFONO_CELL_INFO_INTERFACE);
+
+   if(!g_dbus_unregister_interface(conn, path, OFONO_CELL_INFO_INTERFACE))
+   ofono_error("Failed to unregister interface %s",
+   OFONO_CELL_INFO_INTERFACE);
+}
+
+static void cell_info_remove(struct ofono_atom *atom)
+{
+   struct ofono_cell_info *ci = __ofono_atom_get_data(atom);
+   DBG("atom: %p", atom);
+
+   if (ci == NULL)
+   return;
+
+   if (ci->driver && ci->driver->remove)
+   ci->driver->remove(ci);
+
+   g_free(ci);
+}
+
+void ofono_cell_info_register(struct ofono_cell_info *ci)
+{
+   DBusConnection *conn = ofono_dbus_get_connection();
+   struct ofono_modem *modem = __ofono_atom_get_modem(ci->atom);
+   const char *path = __ofono_atom_get_path(ci->atom);
+
+   if (!g_dbus_register_interface(conn, path,
+   OF

[RFC PATCH 2/4] cell-info: Header file for cell-info atom

2010-12-21 Thread Antti Paila
---
 include/cell-info.h |   66 +++
 1 files changed, 66 insertions(+), 0 deletions(-)
 create mode 100644 include/cell-info.h

diff --git a/include/cell-info.h b/include/cell-info.h
new file mode 100644
index 000..d9c7810
--- /dev/null
+++ b/include/cell-info.h
@@ -0,0 +1,66 @@
+/*
+ *
+ *  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
+ *
+ */
+
+#ifndef __OFONO_CELL_INFO_H
+#define __OFONO_CELL_INFO_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include 
+
+struct ofono_cell_info;
+
+typedef void (*ofono_cell_info_query_cb_t)(const struct ofono_error *error,
+   void *data);
+
+struct ofono_cell_info_driver {
+   const char *name;
+   int (*probe)(struct ofono_cell_info *ci,
+   unsigned int vendor,
+   void *data);
+   void (*remove)(struct ofono_cell_info *ci);
+   void (*query)(struct ofono_cell_info *ci,
+   ofono_cell_info_query_cb_t,
+   void *data);
+};
+
+struct ofono_cell_info *ofono_cell_info_create(struct ofono_modem *modem,
+   unsigned int vendor,
+   const char *driver,
+   void *data);
+
+void ofono_cell_info_register(struct ofono_cell_info *ci);
+void ofono_cell_info_remove(struct ofono_cell_info *ci);
+int ofono_cell_info_driver_register(struct ofono_cell_info_driver *driver);
+void ofono_cell_info_driver_unregister(struct ofono_cell_info_driver *driver);
+void *ofono_cell_info_get_data(struct ofono_cell_info *ci);
+void ofono_cell_info_set_data(struct ofono_cell_info *ci, void *cid);
+void ofono_cell_info_query_cb(const struct ofono_error *error,
+   void *data);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __OFONO_CELL_INFO_H */
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] udev: Fix warning in compilation

2010-12-21 Thread Antti Paila
---
 plugins/udev.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/plugins/udev.c b/plugins/udev.c
index 837ee9c..3ca6af0 100644
--- a/plugins/udev.c
+++ b/plugins/udev.c
@@ -452,7 +452,6 @@ static void add_isi(struct ofono_modem *modem,
 static void add_calypso(struct ofono_modem *modem,
struct udev_device *udev_device)
 {
-   struct udev_list_entry *entry;
const char *devnode;
 
DBG("modem %p", modem);
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 0/4 v2] Network Time plugin

2010-12-20 Thread Antti Paila
Hi,

Could someone review this patch. It has been waiting for review a while
now. Thanks.

-Antti  

On Fri, 2010-12-10 at 09:53 +0200, Antti Paila wrote:
> This series of patches introduces the network time part of the NITZ feature 
>  as outlined in 3GPP spec 22.042. The Network Time plugin has two DBUS 
>  interfaces for client applications: notification signal and polling method 
>  call. The time information consists of three dictionary entries: 1) time and 
>  date in seconds from epoch (renormalized to time indicatation arrival time);
>  2) daylight saving time; 3) timezone.
>  
>  include/dbus.h |1 +
>  plugins/nettime.c | 285 +
>  Makefile.am |   10 --
>  test/get-nettime |   25 +
>  test/test-nettime |   46 ++
>  doc/network-time-api.txt |   31 +++


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 4/4 v2] plugins: Documentation for nettime plugin

2010-12-09 Thread Antti Paila
---
 doc/network-time-api.txt |   31 +++
 1 files changed, 31 insertions(+), 0 deletions(-)
 create mode 100644 doc/network-time-api.txt

diff --git a/doc/network-time-api.txt b/doc/network-time-api.txt
new file mode 100644
index 000..cb2b9d7
--- /dev/null
+++ b/doc/network-time-api.txt
@@ -0,0 +1,31 @@
+Network time hierarchy
+==
+
+Serviceorg.ofono
+Interface  org.ofono.NetworkTime
+Object path[variable prefix]/{modem0,modem1,...}
+
+Methodsdict GetNetworkTime()
+
+   Returns the network indicated time for the modem object.
+   See the properties section for the content of the dict.
+
+SignalsNetworkTimeChanged(dict)
+
+   This signal indicates the reception of network time.
+   See the properties section for the content of the dict.
+
+Properties int64 UTC [readonly, optional]
+
+   Network time in seconds from epoch normalized to 
+   indication arrival timestamp. Reveicing entity obtains 
+   real time by adding the current time from monotonic
+   clock e.g. clock_gettime(CLOCK_MONOTONIC,...).
+
+   int32 Timezone [readonly]
+
+   Current timezone offset in seconds from UTC.
+
+   uint32 DST [readonly]
+
+   Current daylight saving setting in hours.
\ No newline at end of file
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 2/4 v2] plugins: Enabling nettime plugin in Makefile.am

2010-12-09 Thread Antti Paila
---
 Makefile.am |   10 --
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index cdb3166..70162ec 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -296,6 +296,9 @@ builtin_modules += example_nettime
 builtin_sources += examples/nettime.c
 endif
 
+builtin_modules += nettime
+builtin_sources += plugins/nettime.c
+
 builtin_modules += smart_messaging
 builtin_sources += plugins/smart-messaging.c
 
@@ -358,7 +361,8 @@ doc_files = doc/overview.txt doc/ofono-paper.txt \
doc/message-api.txt doc/message-waiting-api.txt \
doc/phonebook-api.txt doc/radio-settings-api.txt \
doc/sim-api.txt doc/stk-api.txt \
-   doc/audio-settings-api.txt doc/text-telephony-api.txt
+   doc/audio-settings-api.txt doc/text-telephony-api.txt \
+   doc/network-time-api.txt
 
 
 test_scripts = test/backtrace \
@@ -423,7 +427,9 @@ test_scripts = test/backtrace \
test/test-push-notification \
test/test-smart-messaging \
test/send-vcard \
-   test/set-tty
+   test/set-tty \
+   test/test-nettime \
+   test/get-nettime
 
 if TEST
 testdir = $(pkglibdir)/test
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 3/4 v2] plugins: Test scripts for nettime plugin

2010-12-09 Thread Antti Paila
---
 test/get-nettime  |   25 +
 test/test-nettime |   46 ++
 2 files changed, 71 insertions(+), 0 deletions(-)
 create mode 100755 test/get-nettime
 create mode 100755 test/test-nettime

diff --git a/test/get-nettime b/test/get-nettime
new file mode 100755
index 000..39aa232
--- /dev/null
+++ b/test/get-nettime
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+
+import gobject
+import dbus
+import sys
+import time
+import dbus.mainloop.glib
+
+def time_changed( arg ) :
+   print "--time_changed callback called"
+   if "UTC" in arg :
+   print "UTC Time from mobile: %d" % arg["UTC"]
+   print "DST: %d" % arg["DST"]
+   print "Timezone: %d" % arg["Timezone"]
+   print "UTC time is: %d"  % time.time()
+
+bus = dbus.SystemBus()
+manager = dbus.Interface(bus.get_object('org.ofono','/'), 'org.ofono.Manager')
+path = manager.GetModems()[0][0]
+
+modem_proxy = bus.get_object('org.ofono', path)
+nettime_iface = dbus.Interface(modem_proxy, 'org.ofono.NetworkTime')
+answer = nettime_iface.GetNetworkTime()
+time_changed(answer)
+
diff --git a/test/test-nettime b/test/test-nettime
new file mode 100755
index 000..c2d533c
--- /dev/null
+++ b/test/test-nettime
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+
+import gobject
+import dbus
+import sys
+import time
+import dbus.mainloop.glib
+
+
+def time_changed( arg ) :
+   print "Time from mobile: %d" % arg["UTC"]
+   print "DST: %d" % arg["DST"]
+   print "Timezone: %d" % arg["Timezone"]
+   print "UTC is: %d"  % time.time()
+
+
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+bus = dbus.SystemBus()
+manager = dbus.Interface(bus.get_object('org.ofono', '/'), 'org.ofono.Manager')
+modems = manager.GetModems()
+path = modems[0][0]
+
+print "Connecting modem %s..." % path
+modem = dbus.Interface(bus.get_object('org.ofono', path),
+   'org.ofono.Modem')
+
+print "Powering up modem %s..." % (path)
+modem.SetProperty("Powered", dbus.Boolean(1))
+
+print "Go Online modem %s..." % (path)
+modem.SetProperty("Online", dbus.Boolean(1))
+print "Go Offline modem %s..." % (path)
+modem.SetProperty("Online", dbus.Boolean(0))
+print "Go Online modem %s..." % (path)
+modem.SetProperty("Online", dbus.Boolean(1))
+
+nettime = dbus.Interface(bus.get_object('org.ofono', path),
+   'org.ofono.NetworkTime')
+nettime.connect_to_signal("NetworkTimeChanged", time_changed)
+
+mainloop = gobject.MainLoop()
+mainloop.run()
+
+
+
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/4 v2] plugins: Implementation of Network Time plugin

2010-12-09 Thread Antti Paila
---
 include/dbus.h|1 +
 plugins/nettime.c |  285 +
 2 files changed, 286 insertions(+), 0 deletions(-)
 create mode 100644 plugins/nettime.c

diff --git a/include/dbus.h b/include/dbus.h
index 9e29afb..0c48f83 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -45,6 +45,7 @@ extern "C" {
 #define OFONO_MESSAGE_WAITING_INTERFACE "org.ofono.MessageWaiting"
 #define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration"
 #define OFONO_NETWORK_OPERATOR_INTERFACE "org.ofono.NetworkOperator"
+#define OFONO_NETWORK_TIME_INTERFACE "org.ofono.NetworkTime"
 #define OFONO_PHONEBOOK_INTERFACE "org.ofono.Phonebook"
 #define OFONO_RADIO_SETTINGS_INTERFACE "org.ofono.RadioSettings"
 #define OFONO_AUDIO_SETTINGS_INTERFACE "org.ofono.AudioSettings"
diff --git a/plugins/nettime.c b/plugins/nettime.c
new file mode 100644
index 000..d080582
--- /dev/null
+++ b/plugins/nettime.c
@@ -0,0 +1,285 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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 
+#endif
+
+#include 
+#include 
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "ofono.h"
+
+#include "common.h"
+
+struct nettime_data {
+
+   gboolean time_available;
+   time_t nw_time_utc;
+   time_t received;
+   int dst;
+   int time_zone;
+};
+
+static void nettime_register(struct ofono_nettime_context *);
+
+static gboolean encode_time_format(struct ofono_network_time *time,
+struct tm *tm)
+{
+   if (time->year < 0)
+   return FALSE;
+
+   tm->tm_year = time->year - 1900;
+   tm->tm_mon = time->mon - 1;
+   tm->tm_mday = time->mday;
+   tm->tm_hour = time->hour;
+   tm->tm_min = time->min;
+   tm->tm_sec = time->sec;
+   tm->tm_gmtoff = time->utcoff;
+   tm->tm_isdst = time->dst;
+
+   return TRUE;
+}
+
+static time_t get_monotonic_time()
+{
+   struct timespec ts;
+   clock_gettime(CLOCK_MONOTONIC, &ts);
+   return ts.tv_sec;
+}
+
+static int fill_time_changed_signal(DBusMessage *signal,
+   struct nettime_data *ntd)
+{
+   DBusMessageIter iter, iter_array;
+   time_t utc;
+
+   dbus_message_iter_init_append(signal, &iter);
+   dbus_message_iter_open_container(&iter,
+   DBUS_TYPE_ARRAY,
+   "{sv}",
+   &iter_array);
+
+   if (ntd->time_available) {
+   utc = ntd->nw_time_utc - ntd->received;
+
+   ofono_dbus_dict_append(&iter_array,
+   "UTC",
+   DBUS_TYPE_INT64,
+   &utc);
+   }
+
+   ofono_dbus_dict_append(&iter_array,
+   "Timezone",
+   DBUS_TYPE_INT32,
+   &ntd->time_zone);
+   ofono_dbus_dict_append(&iter_array,
+   "DST",
+   DBUS_TYPE_UINT32,
+   &ntd->dst);
+   dbus_message_iter_close_container(&iter, &iter_array);
+   return 0;
+}
+
+static DBusMessage *create_time_changed_signal(
+   struct ofono_nettime_context *context)
+{
+   DBusMessage *signal;
+   struct nettime_data *ntd = context->data;
+   const char *path = ofono_modem_get_path(context->modem);
+
+   if (path == NULL) {
+   ofono_error("Fetching path for modem failed");
+   return NULL;
+   }
+
+   signal = dbus_message_new_signal(path, OFONO_NETWORK_TIME_INTERFACE,
+   "NetworkTimeChanged");
+   fill_time_changed_signal(signal, ntd);
+
+   return signal;
+}
+
+static void init_time(struct ofono_nettime_context *context)
+{
+   struct nettime_data *nettime_data = g_new0(struct nettime_data, 1);
+
+   nettime_data->time_available = FALSE;
+   nettime_data->dst = 0;
+   nettime_data->time_zone = 0;
+   context->data = nettime_data;
+
+}
+
+static int nettime_probe(struct ofono_nettime_context *contex

[PATCH 0/4 v2] Network Time plugin

2010-12-09 Thread Antti Paila
 This series of patches introduces the network time part of the NITZ feature 
 as outlined in 3GPP spec 22.042. The Network Time plugin has two DBUS 
 interfaces for client applications: notification signal and polling method 
 call. The time information consists of three dictionary entries: 1) time and 
 date in seconds from epoch (renormalized to time indicatation arrival time);
 2) daylight saving time; 3) timezone.
 
 include/dbus.h |1 +
 plugins/nettime.c | 285 +
 Makefile.am |   10 --
 test/get-nettime |   25 +
 test/test-nettime |   46 ++
 doc/network-time-api.txt |   31 +++
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 1/3] plugins: Implementation of Network Time plugin

2010-12-07 Thread Antti Paila
Hi Marcel,

> I have seen a bunch of devices where we have not a proper clock value to
> begin with. And in that case there is nothing really useful we can do
> with it, except just set the system clock right away.

We are not using any absolute time value from any clock, but instead we
use relative elapsed time from monotonic clock. The reference point is
the monotonic clock time, when the network time indication arrived to
modem. I believe every device that takes ofono into use have a monotonic
time source.

> So the other problem with the timestamp and NITZ and the time daemon not
> running is that we have no idea what happens in between. While this
> might be short time and could potentially work, I still don't see this
> as a good solution at all.

That is why the nettime plugin implements both notification signal and a
polling method call. If timed is running it will receive the DBUS
notification about the network time. Otherwise timed can poll the time
from ofono as it becomes active. One should also notice that the NITZ
feature is optional both from terminal and network point of view, so
anything too fatal should not happen even if timed is not up when
nettime indication is sent. 

> Right now, I still think that either we set the system clock right away
> if no time daemon is running and if time daemon is running, then we send
> a D-Bus method to that time daemon. And we can easily track this D-Bus
> name owner notifications.

Architecturally I prefer that the system time is altered by one entity
alone, being timed. As we can have many modems active simultaneously, I
would not like if they all are allowed to directly alter the system
time. Timed should have a way to decide what is the proper time.

-Antti 


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 1/3] plugins: Implementation of Network Time plugin

2010-12-07 Thread Antti Paila

> Hi Rémi,
> 
> 2010/12/6 Rémi Denis-Courmont :
> >> +static struct tm *refresh_nw_time(struct tm *nw_time,
> >> + time_t received)
> >> +{
> >> + time_t now, new_nw_time;
> >> +
> >> + now = get_monotonic_time();
> >> + new_nw_time = timegm(nw_time) + now - received;
> >> + return gmtime(&new_nw_time);
> >> +}
> >
> > Brrr, the result is somewhere in static data. This can cause quite confusing
> > behaviour if/when the code is changed. I would much rather use gmtime_r().
> 
> I suppose that's a good point.
> 
> > That being said, wouldn't it be far simpler to return a second timestamp
> > instead of a broken-down time structure over D-Bus? Eventually, 
> > timed/whatever
> > will want a timestamp anyway to set the system clock or whatever else it 
> > wants
> > to do with the NITZ.
> >
> >> +static int fill_time_changed_signal(DBusMessage *signal,
> >> + struct nettime_data *ntd)
> >> +{
> >> + DBusMessageIter iter, iter_array;
> >> + int time_available;
> >> + char buf[MAX_TIME_STR_LEN];
> >> + struct tm time_tm, *new_time_tm;
> >> + const char *str = buf;
> >> +
> >> + dbus_message_iter_init_append(signal, &iter);
> >> + dbus_message_iter_open_container(&iter,
> >> + DBUS_TYPE_ARRAY,
> >> + "{sv}",
> >> + &iter_array);
> >> +
> >> + time_available = encode_time_format(&ntd->nw_time, &time_tm);
> >> + if (time_available != 0) {
> >> + new_time_tm = refresh_nw_time(&time_tm, ntd->received);
> >> + strftime(buf, MAX_TIME_STR_LEN, TIME_FORMAT, new_time_tm);
> >> +
> >> + ofono_dbus_dict_append(&iter_array,
> >> + "DateAndTime",
> >> + DBUS_TYPE_STRING,
> >> + &str);
> >> + }
> >> +
> >> + ofono_dbus_dict_append(&iter_array,
> >> + "Timezone",
> >> + DBUS_TYPE_INT32,
> >> + &ntd->nw_time.utcoff);
> >> + ofono_dbus_dict_append(&iter_array,
> >> + "DST",
> >> + DBUS_TYPE_UINT32,
> >> + &ntd->nw_time.dst);
> >> + dbus_message_iter_close_container(&iter, &iter_array);
> >> + return 0;
> >> +}
> >
> > Are the time zone offset and the DST always available, but the current time
> > not? This seems odd.
> 
> Tell me about it, but this is how the spec works. Operators have the
> flexibility to send just the timezone, the timezone and DST, or the
> works.

I suppose Remi means that if the DST and time zone are optional we should at 
least
verify that those fields are part of the MM/GMM message. Specs 24008
states that network may include the following fields to MM information
message: Local time zone, Universal time and local time zone, Network
Daylight Saving Time.

> > Passing the time over D-Bus may cause extra drift/imprecision than we 
> > already
> > have. I wonder if it would make sense to provide not just the current time 
> > but
> > both:
> > - the current time for trivial programs, and
> > - the system boot time (i.e. nw_time - received) for smarter programs;
> >  this value cannot drift.
> 
> I remember we had similar argument in the past with the timed folks,
> which actually resulted in a much more convoluted API... I'm still not
> convinced time drift is a problem, since NITZ itself is accurate to
> the second.
> 
> However, thinking about this, I actually don't see any value in
> providing a human readable time over D-Bus. No application should
> directly ask oFono for time, this is why timed is there to begin with.
> 
> So sending a plain time_t over D-Bus is actually sufficient. This
> leaves us with having to send timestamps over D-Bus, which is ugly.
> Can you explain how you see clock drift a problem here exactly?

I wonder what is drifting since the reception time is updated only when
network indicates new time. While polling time, the correction is
calculated with respect to this reception time. The exactness of the
network time is questionable anyway since the network delivers the time
which may have been when the information was sent. Accuracy is of the
order of minutes rather that seconds.

> 
> >> +static DBusMessage *create_time_changed_signal(
> >> + struct ofono_nettime_context *context)
> >> +{
> >> + DBusMessage *signal;
> >> + struct nettime_data *ntd = context->data;
> >> + const char *path = ofono_modem_get_path(context->modem);
> >> +
> >> + if (path == NULL) {
> >> + ofono_error("Fetching path for modem failed");
> >> + return NULL;
> >> + }
> >> +
> >> + signal = dbus_message_new_signal(path, OFONO_NETWORK_TIME_INTERFACE,
> >> + "NetworkTimeChanged");
> >>

[PATCH 3/3] plugins: Test scripts for nettime plugin

2010-12-03 Thread Antti Paila
---
 test/get-nettime  |   25 +
 test/test-nettime |   46 ++
 2 files changed, 71 insertions(+), 0 deletions(-)
 create mode 100755 test/get-nettime
 create mode 100755 test/test-nettime

diff --git a/test/get-nettime b/test/get-nettime
new file mode 100755
index 000..a0fb1bc
--- /dev/null
+++ b/test/get-nettime
@@ -0,0 +1,25 @@
+#!/usr/bin/python
+
+import gobject
+import dbus
+import sys
+import time
+import dbus.mainloop.glib
+
+def time_changed( arg ) :
+   print "--time_changed callback called"
+   if "DateAndTime" in arg :
+   print "Time from mobile: %s" % arg["DateAndTime"]
+   print "DST: %d" % arg["DST"]
+   print "Timezone: %d" % arg["Timezone"]
+   print "Local time is: %s"  % time.asctime()
+
+bus = dbus.SystemBus()
+manager = dbus.Interface(bus.get_object('org.ofono','/'), 'org.ofono.Manager')
+path = manager.GetModems()[0][0]
+
+modem_proxy = bus.get_object('org.ofono', path)
+nettime_iface = dbus.Interface(modem_proxy, 'org.ofono.NetworkTime')
+answer = nettime_iface.GetNetworkTime()
+time_changed(answer)
+
diff --git a/test/test-nettime b/test/test-nettime
new file mode 100755
index 000..f78c9c6
--- /dev/null
+++ b/test/test-nettime
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+
+import gobject
+import dbus
+import sys
+import time
+import dbus.mainloop.glib
+
+
+def time_changed( arg ) :
+   print "Time from mobile: %s" % arg["DateAndTime"]
+   print "DST: %d" % arg["DST"]
+   print "Timezone: %d" % arg["Timezone"]
+   print "Local time is: %s"  % time.asctime()
+
+
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+bus = dbus.SystemBus()
+manager = dbus.Interface(bus.get_object('org.ofono', '/'), 'org.ofono.Manager')
+modems = manager.GetModems()
+path = modems[0][0]
+
+print "Connecting modem %s..." % path
+modem = dbus.Interface(bus.get_object('org.ofono', path),
+   'org.ofono.Modem')
+
+print "Powering up modem %s..." % (path)
+modem.SetProperty("Powered", dbus.Boolean(1))
+
+print "Go Online modem %s..." % (path)
+modem.SetProperty("Online", dbus.Boolean(1))
+print "Go Offline modem %s..." % (path)
+modem.SetProperty("Online", dbus.Boolean(0))
+print "Go Online modem %s..." % (path)
+modem.SetProperty("Online", dbus.Boolean(1))
+
+nettime = dbus.Interface(bus.get_object('org.ofono', path),
+   'org.ofono.NetworkTime')
+nettime.connect_to_signal("NetworkTimeChanged", time_changed)
+
+mainloop = gobject.MainLoop()
+mainloop.run()
+
+
+
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/3] plugins: Implementation of Network Time plugin

2010-12-03 Thread Antti Paila
---
 include/dbus.h|1 +
 plugins/nettime.c |  293 +
 2 files changed, 294 insertions(+), 0 deletions(-)
 create mode 100644 plugins/nettime.c

diff --git a/include/dbus.h b/include/dbus.h
index 9e29afb..0c48f83 100644
--- a/include/dbus.h
+++ b/include/dbus.h
@@ -45,6 +45,7 @@ extern "C" {
 #define OFONO_MESSAGE_WAITING_INTERFACE "org.ofono.MessageWaiting"
 #define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration"
 #define OFONO_NETWORK_OPERATOR_INTERFACE "org.ofono.NetworkOperator"
+#define OFONO_NETWORK_TIME_INTERFACE "org.ofono.NetworkTime"
 #define OFONO_PHONEBOOK_INTERFACE "org.ofono.Phonebook"
 #define OFONO_RADIO_SETTINGS_INTERFACE "org.ofono.RadioSettings"
 #define OFONO_AUDIO_SETTINGS_INTERFACE "org.ofono.AudioSettings"
diff --git a/plugins/nettime.c b/plugins/nettime.c
new file mode 100644
index 000..0f99bb1
--- /dev/null
+++ b/plugins/nettime.c
@@ -0,0 +1,293 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Nokia Corporation and/or its subsidiary(-ies).
+ *
+ *  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 
+#endif
+
+#include 
+#include 
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "ofono.h"
+
+#include "common.h"
+
+#define MAX_TIME_STR_LEN 128
+#define TIME_FORMAT "%FT%TZ"
+
+
+struct nettime_data {
+   struct ofono_network_time nw_time;
+   time_t received;
+};
+
+static void nettime_register(struct ofono_nettime_context *);
+
+static gboolean encode_time_format(struct ofono_network_time *time,
+struct tm *tm)
+{
+   if (time->year < 0)
+   return FALSE;
+
+   tm->tm_year = time->year - 1900;
+   tm->tm_mon = time->mon - 1;
+   tm->tm_mday = time->mday;
+   tm->tm_hour = time->hour;
+   tm->tm_min = time->min;
+   tm->tm_sec = time->sec;
+   tm->tm_gmtoff = time->utcoff;
+   tm->tm_isdst = time->dst;
+
+   return TRUE;
+}
+
+static time_t get_monotonic_time()
+{
+   struct timespec ts;
+   clock_gettime(CLOCK_MONOTONIC, &ts);
+   return ts.tv_sec;
+}
+
+static struct tm *refresh_nw_time(struct tm *nw_time,
+   time_t received)
+{
+   time_t now, new_nw_time;
+
+   now = get_monotonic_time();
+   new_nw_time = timegm(nw_time) + now - received;
+   return gmtime(&new_nw_time);
+}
+
+static int fill_time_changed_signal(DBusMessage *signal,
+   struct nettime_data *ntd)
+{
+   DBusMessageIter iter, iter_array;
+   int time_available;
+   char buf[MAX_TIME_STR_LEN];
+   struct tm time_tm, *new_time_tm;
+   const char *str = buf;
+
+   dbus_message_iter_init_append(signal, &iter);
+   dbus_message_iter_open_container(&iter,
+   DBUS_TYPE_ARRAY,
+   "{sv}",
+   &iter_array);
+
+   time_available = encode_time_format(&ntd->nw_time, &time_tm);
+   if (time_available != 0) {
+   new_time_tm = refresh_nw_time(&time_tm, ntd->received);
+   strftime(buf, MAX_TIME_STR_LEN, TIME_FORMAT, new_time_tm);
+
+   ofono_dbus_dict_append(&iter_array,
+   "DateAndTime",
+   DBUS_TYPE_STRING,
+   &str);
+   }
+
+   ofono_dbus_dict_append(&iter_array,
+   "Timezone",
+   DBUS_TYPE_INT32,
+   &ntd->nw_time.utcoff);
+   ofono_dbus_dict_append(&iter_array,
+   "DST",
+   DBUS_TYPE_UINT32,
+   &ntd->nw_time.dst);
+   dbus_message_iter_close_container(&iter, &iter_array);
+   return 0;
+}
+
+static DBusMessage *create_time_changed_signal(
+   struct ofono_nettime_context *context)
+{
+   DBusMessage *signal;
+   struct nettime_data *ntd = context->data;
+   const char *path = ofono_modem_get_path(context->modem);
+
+   if (path == NULL) {
+   ofono_error("Fetching path for modem failed");
+   return NULL;
+   }
+
+ 

[PATCH 2/3] plugins: Enabling nettime plugin in Makefile.am

2010-12-03 Thread Antti Paila
---
 Makefile.am |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index a4c47e8..94dbaa1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -296,6 +296,9 @@ builtin_modules += example_nettime
 builtin_sources += examples/nettime.c
 endif
 
+builtin_modules += nettime
+builtin_sources += plugins/nettime.c
+
 builtin_modules += smart_messaging
 builtin_sources += plugins/smart-messaging.c
 
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH] gprs: Fix for gprs context conversion

2010-12-01 Thread Antti Paila
---
 src/gprs.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/gprs.c b/src/gprs.c
index 610f3b2..58166f8 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -175,7 +175,7 @@ static gboolean gprs_context_string_to_type(const char *str,
return TRUE;
} else if (g_str_equal(str, "ims")) {
*out = OFONO_GPRS_CONTEXT_TYPE_IMS;
-   return FALSE;
+   return TRUE;
}
 
return FALSE;
-- 
1.7.1

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono