Hi Andrew,
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index 92ae575..fca6f0f 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
All of this should be a separate patch.
diff --git a/include/sim.h b/include/sim.h
index f76f9d1..8df7ec3 100644
--- a/include/sim.h
+++ b/include/sim.h
@@ -135,6 +135,9 @@ struct ofono_sim_driver {
void (*query_locked)(struct ofono_sim *sim,
enum ofono_sim_password_type type,
ofono_sim_locked_cb_t cb, void *data);
+ void (*envelope)(struct ofono_sim *sim, int length,
+ const guint8 *command,
+ ofono_sim_read_cb_t cb, void *data);
};
This too, separate patch please.
int ofono_sim_driver_register(const struct ofono_sim_driver *d);
@@ -176,6 +179,9 @@ int ofono_sim_write(struct ofono_sim *sim, int id,
ofono_sim_file_write_cb_t cb,
enum ofono_sim_file_structure structure, int record,
const unsigned char *data, int length, void *userdata);
+
+void ofono_cbs_download(struct ofono_sim *sim, const guint8 *pdu, int
pdu_len); +
Lets keep this out of public API, put it in src/ofono.h and rename it into
__ofono_cbs_sim_download.
#ifdef __cplusplus
}
#endif
diff --git a/src/cbs.c b/src/cbs.c
index 42594c7..c378f2a 100644
--- a/src/cbs.c
+++ b/src/cbs.c
@@ -184,6 +184,11 @@ void ofono_cbs_notify(struct ofono_cbs *cbs, const
unsigned char *pdu, return;
}
+ if (cbs_topic_in_range(c.message_identifier, cbs->efcbmid_contents)) {
+ ofono_cbs_download(cbs->sim, pdu, pdu_len);
+ return;
+ }
+
if (!cbs_dcs_decode(c.dcs, &udhi, &cls, &charset, &comp, NULL, NULL))
{
ofono_error("Unknown / Reserved DCS. Ignoring");
return;
Are the contents of EFcbmid ever sent down the modem?
@@ -437,6 +442,13 @@ static void cbs_unregister(struct ofono_atom
*atom)
cbs->new_topics = NULL;
}
+ if (cbs->efcbmid_length) {
+ cbs->efcbmid_length = 0;
+ g_slist_foreach(cbs->efcbmid_contents, (GFunc)g_free, NULL);
+ g_slist_free(cbs->efcbmid_contents);
+ cbs->efcbmid_contents = NULL;
+ }
+
cbs->sim = NULL;
if (cbs->reset_source) {
@@ -627,6 +639,7 @@ static void sim_cbmid_read_cb(int ok, int length, int
record, unsigned short mi;
int i;
char *str;
+ GSList *contents = NULL;
if (!ok)
return;
@@ -648,23 +661,19 @@ static void sim_cbmid_read_cb(int ok, int length, int
record, range->min = mi;
range->max = mi;
- cbs->efcbmid_contents = g_slist_prepend(cbs->efcbmid_contents,
- range);
+ contents = g_slist_prepend(contents, range);
}
- if (cbs->efcbmid_contents == NULL)
+ if (contents == NULL)
return;
- cbs->efcbmid_contents = g_slist_reverse(cbs->efcbmid_contents);
+ cbs->efcbmid_contents = cbs_optimize_ranges(contents);
I really don't think we need to optimize the contents, just send them as is.
See my comment for Patch 1.
+ g_slist_foreach(contents, (GFunc) g_free, NULL);
+ g_slist_free(contents);
str = cbs_topic_ranges_to_string(cbs->efcbmid_contents);
ofono_debug("Got cbmid: %s", str);
g_free(str);
-
- cbs->efcbmid_length = 0;
- g_slist_foreach(cbs->efcbmid_contents, (GFunc)g_free, NULL);
- g_slist_free(cbs->efcbmid_contents);
- cbs->efcbmid_contents = NULL;
}
static void cbs_got_imsi(struct ofono_cbs *cbs)
diff --git a/src/sim.c b/src/sim.c
index 907e4ce..4689886 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -1720,6 +1720,39 @@ void ofono_sim_set_ready(struct ofono_sim *sim)
}
}
+static void sim_cb_download_cb(const struct ofono_error *error,
+ const unsigned char *data, int len, void *user)
+{
+ if (error->type != OFONO_ERROR_TYPE_NO_ERROR) {
+ ofono_error("CellBroadcast download to UICC failed");
+ return;
+ }
+
+ ofono_debug("CellBroadcast download to UICC reported no error");
+}
+
+void ofono_cbs_download(struct ofono_sim *sim, const guint8 *pdu, int
pdu_len) +{
+ guint8 tlv[pdu_len + 8];
+
+ if (sim->ready != TRUE)
+ return;
+ if (!sim->driver->envelope)
+ return;
+
+ tlv[0] = 0xd2; /* Cell Broadcast Download */
+ tlv[1] = 6 + pdu_len;
+ tlv[2] = 0x82; /* Device Identities */
+ tlv[3] = 0x02; /* Device Identities length */
+ tlv[4] = 0x83; /* Network */
+ tlv[5] = 0x81; /* UICC */
+ tlv[6] = 0x8c; /* Cell Broadcast page */
+ tlv[7] = pdu_len;
+ memcpy(tlv + 8, pdu, pdu_len);
+
+ sim->driver->envelope(sim, pdu_len + 8, tlv, sim_cb_download_cb, sim);
+}
+
int ofono_sim_driver_register(const struct ofono_sim_driver *d)
{
DBG("driver: %p, name: %s", d, d->name);
Regards,
-Denis