summaryrefslogtreecommitdiffstats
path: root/src/cbs.c
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-09-11 21:38:08 -0500
committerDenis Kenzior <denkenz@gmail.com>2009-09-11 21:38:08 -0500
commit03ce875a7b049c49a07420e779afa42281c8fee9 (patch)
tree1d5e22e3613265102863bb05ab38cb3f013e34b2 /src/cbs.c
parent6f86a8d0a6c7999a1b191b61ce5f7e5d15a80e83 (diff)
downloadofono-03ce875a7b049c49a07420e779afa42281c8fee9.tar.bz2
Support base station name cell broadcasts
If we receive an immediate cell-specific cell broadcast, report it as the base station id up to netreg atom
Diffstat (limited to 'src/cbs.c')
-rw-r--r--src/cbs.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/cbs.c b/src/cbs.c
index 3089379d..10ba5b26 100644
--- a/src/cbs.c
+++ b/src/cbs.c
@@ -59,6 +59,7 @@ struct ofono_cbs {
unsigned int imsi_watch;
unsigned int netreg_watch;
unsigned int location_watch;
+ guint reset_source;
int lac;
int ci;
char mnc[OFONO_MAX_MNC_LENGTH + 1];
@@ -74,6 +75,13 @@ static void cbs_dispatch_base_station_id(struct ofono_cbs *cbs, const char *id)
if (cbs->netreg == NULL)
return;
+
+ if (cbs->reset_source) {
+ g_source_remove(cbs->reset_source);
+ cbs->reset_source = 0;
+ }
+
+ __ofono_netreg_set_base_station_name(cbs->netreg, id);
}
static void cbs_dispatch_emergency(struct ofono_cbs *cbs, const char *message,
@@ -424,6 +432,14 @@ static void cbs_unregister(struct ofono_atom *atom)
cbs->sim = NULL;
}
+ if (cbs->reset_source) {
+ g_source_remove(cbs->reset_source);
+ cbs->reset_source = 0;
+
+ if (cbs->netreg)
+ __ofono_netreg_set_base_station_name(cbs->netreg, NULL);
+ }
+
if (cbs->netreg_watch) {
if (cbs->location_watch) {
__ofono_netreg_remove_status_watch(cbs->netreg,
@@ -518,6 +534,21 @@ static void sim_watch(struct ofono_atom *atom,
cbs_got_imsi(cbs);
}
+static gboolean reset_base_station_name(gpointer user)
+{
+ struct ofono_cbs *cbs = user;
+
+ cbs->reset_source = 0;
+
+ if (cbs->netreg == NULL)
+ goto out;
+
+ __ofono_netreg_set_base_station_name(cbs->netreg, NULL);
+
+out:
+ return FALSE;
+}
+
static void cbs_location_changed(int status, int lac, int ci, int tech,
const struct ofono_network_operator *op,
void *data)
@@ -565,10 +596,18 @@ static void cbs_location_changed(int status, int lac, int ci, int tech,
return;
out:
- /* TODO: reset base station ID */
-
DBG("%d, %d, %d", plmn_changed, lac_changed, ci_changed);
+ /* In order to minimize signal transmissions we wait about X seconds
+ * before reseting the base station id. The hope is that we receive
+ * another cell broadcast with the new base station name within
+ * that time
+ */
+ if (lac_changed || ci_changed) {
+ cbs->reset_source =
+ g_timeout_add_seconds(3, reset_base_station_name, cbs);
+ }
+
cbs_assembly_location_changed(cbs->assembly, plmn_changed,
lac_changed, ci_changed);
}