* [PATCH 2/5] GAD shape tests
2010-06-17 13:42 [PATCH 1/5] 23.032 GAD Shape structs and encoding utility Andrzej Zaborowski
@ 2010-06-17 13:42 ` Andrzej Zaborowski
2010-06-17 13:42 ` [PATCH 3/5] stkutil: Add the Geographical Location Reporting envelope builder Andrzej Zaborowski
` (7 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Andrzej Zaborowski @ 2010-06-17 13:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5407 bytes --]
---
Makefile.am | 6 ++-
unit/test-lcsutil.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 163 insertions(+), 1 deletions(-)
create mode 100644 unit/test-lcsutil.c
diff --git a/Makefile.am b/Makefile.am
index 2b59f01..a661200 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -360,7 +360,7 @@ unit_objects =
noinst_PROGRAMS = unit/test-common unit/test-util unit/test-idmap \
unit/test-sms unit/test-simutil \
unit/test-mux unit/test-caif \
- unit/test-stkutil
+ unit/test-stkutil unit/test-lcsutil
unit_test_common_SOURCES = unit/test-common.c src/common.c
unit_test_common_LDADD = @GLIB_LIBS@
@@ -399,6 +399,10 @@ unit_test_caif_SOURCES = unit/test-caif.c $(gatchat_sources) \
unit_test_caif_LDADD = @GLIB_LIBS@
unit_objects += $(unit_test_caif_OBJECTS)
+unit_test_lcsutil_SOURCES = unit/test-lcsutil.c src/lcsutil.c
+unit_test_lcsutil_LDADD = @GLIB_LIBS@ -lm
+unit_objects += $(unit_test_lcsutil_OBJECTS)
+
noinst_PROGRAMS += gatchat/gsmdial gatchat/test-server gatchat/test-qcdm
gatchat_gsmdial_SOURCES = gatchat/gsmdial.c $(gatchat_sources)
diff --git a/unit/test-lcsutil.c b/unit/test-lcsutil.c
new file mode 100644
index 0000000..ca494d6
--- /dev/null
+++ b/unit/test-lcsutil.c
@@ -0,0 +1,158 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+#include <stdint.h>
+#include <glib.h>
+
+#include <ofono/types.h>
+
+#include "lcsutil.h"
+
+struct gad_shape_test {
+ uint8_t coding[128];
+ int len;
+ struct gad_shape shape;
+};
+
+static const struct gad_shape_test gad_shape_valid[] = {
+ {
+ .coding = { 0x00, 0x49, 0xf4, 0x9f, 0x0e, 0xee, 0xee, },
+ .len = 7,
+ .shape = {
+ .type = GAD_TYPE_ELLIPSOID_POINT,
+ { .ellipsoid_point = { .lat = 52, .lon = 21 } },
+ },
+ }, {
+ .coding = {
+ 0x90, 0x49, 0xf4, 0x9f, 0x0e, 0xee, 0xee,
+ 0x80, 0x64, 0x3c, 0x02, 0x02, 0x3c, 0x5d,
+ },
+ .len = 14,
+ .shape = {
+ .type = GAD_TYPE_ELLIPSOID_WITH_ALTITUDE,
+ { .ellipsoid_with_altitude = {
+ .origin = { .lat = 52, .lon = 21 }, /* deg */
+ .r1 = 3000.0, /* m */
+ .r2 = 2.1, /* m */
+ .r3 = 153.0, /* m */
+ .a = 5.0, /* deg */
+ .altitude = -100.0, /* m undeground */
+ .confidence = 93, /* % */
+ }},
+ },
+ }, {
+ .coding = {
+ 0x55, 0x4a, 0x3d, 0x70, 0x0e, 0xee, 0xee,
+ 0x49, 0x3e, 0x93, 0x00, 0x15, 0xd8, 0x40,
+ 0xb6, 0x0b, 0xa8, 0xbf, 0x26, 0x91, 0x11,
+ 0x11, 0xc9, 0x3e, 0x94, 0xa5, 0x43, 0x20,
+ 0x13, 0xe9, 0x3e,
+ },
+ .len = 31,
+ .shape = {
+ .type = GAD_TYPE_POLYGON,
+ { .polygon = {
+ .count = 5,
+ .point = {
+ { .lat = 52.2, .lon = 21.0 },
+ { .lat = 51.5, .lon = 0.12 },
+ { .lat = 45.5, .lon = -122.7 },
+ { .lat = -12.0, .lon = -77.0 },
+ { .lat = -26.2, .lon = 28.0 },
+ },
+ }},
+ },
+ },
+
+ {},
+};
+
+static void test_gad_shape(void) {
+ const struct gad_shape_test *test;
+ uint8_t buf[128];
+ int len;
+
+ for (test = gad_shape_valid; test->len; test++) {
+ len = sizeof(buf);
+ g_assert(gad_shape_encode(&test->shape, buf, &len));
+ g_assert(len == test->len);
+ g_assert(memcmp(buf, test->coding, len) == 0);
+ }
+}
+
+struct gad_velocity_test {
+ uint8_t coding[128];
+ int len;
+ struct gad_velocity velocity;
+};
+
+static const struct gad_velocity_test gad_velocity_valid[] = {
+ {
+ .coding = { 0x33, 0x0e, 0x00, 0x1e, 0x05, 0x01, 0x01, },
+ .len = 7,
+ .velocity = {
+ .horizontal = 30.0, /* kmh */
+ .bearing = 270.0, /* deg */
+ .has_vertical = TRUE,
+ .vertical = -5, /* kmh */
+ .has_uncertainty = TRUE,
+ .horizontal_uncertainty = 1, /* kmh */
+ .vertical_uncertainty = 1, /* kmh */
+ },
+ }, {
+ .coding = { 0x00, 0x05, 0x00, 0x1e, },
+ .len = 4,
+ .velocity = {
+ .horizontal = 30.0, /* kmh */
+ .bearing = 5.0, /* deg */
+ },
+ },
+
+ {},
+};
+
+static void test_gad_velocity(void) {
+ const struct gad_velocity_test *test;
+ uint8_t buf[128];
+ int len;
+
+ for (test = gad_velocity_valid; test->len; test++) {
+ len = sizeof(buf);
+ g_assert(gad_velocity_encode(&test->velocity, buf, &len));
+ g_assert(len == test->len);
+ g_assert(memcmp(buf, test->coding, len) == 0);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ g_test_init(&argc, &argv, NULL);
+
+ g_test_add_func("/testutil/GAD Shape", test_gad_shape);
+ g_test_add_func("/testutil/GAD Velocity", test_gad_velocity);
+
+ return g_test_run();
+}
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 3/5] stkutil: Add the Geographical Location Reporting envelope builder
2010-06-17 13:42 [PATCH 1/5] 23.032 GAD Shape structs and encoding utility Andrzej Zaborowski
2010-06-17 13:42 ` [PATCH 2/5] GAD shape tests Andrzej Zaborowski
@ 2010-06-17 13:42 ` Andrzej Zaborowski
2010-06-17 13:42 ` [PATCH 4/5] stkutil: Add More Time terminal response builder Andrzej Zaborowski
` (6 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Andrzej Zaborowski @ 2010-06-17 13:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5932 bytes --]
---
Makefile.am | 4 +-
src/stk.c | 1 +
src/stkutil.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
src/stkutil.h | 15 +++++++++++
unit/test-stkutil.c | 1 +
5 files changed, 85 insertions(+), 2 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index a661200..3784627 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -385,8 +385,8 @@ unit_objects += $(unit_test_simutil_OBJECTS)
unit_test_stkutil_SOURCES = unit/test-stkutil.c src/util.c \
src/storage.c src/smsutil.c \
- src/simutil.c src/stkutil.c
-unit_test_stkutil_LDADD = @GLIB_LIBS@
+ src/simutil.c src/stkutil.c src/lcsutil.c
+unit_test_stkutil_LDADD = @GLIB_LIBS@ -lm
unit_objects += $(unit_test_stkutil_OBJECTS)
unit_test_mux_SOURCES = unit/test-mux.c $(gatchat_sources)
diff --git a/src/stk.c b/src/stk.c
index b5c6919..2325326 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -35,6 +35,7 @@
#include "ofono.h"
#include "smsutil.h"
+#include "lcsutil.h"
#include "stkutil.h"
static GSList *g_drivers = NULL;
diff --git a/src/stkutil.c b/src/stkutil.c
index 44a8eff..914ac1f 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -31,6 +31,7 @@
#include <ofono/types.h>
#include "smsutil.h"
+#include "lcsutil.h"
#include "stkutil.h"
#include "simutil.h"
#include "util.h"
@@ -5155,6 +5156,60 @@ static gboolean build_dataobj_rejection_cause_code(struct stk_tlv_builder *tlv,
stk_tlv_builder_close_container(tlv);
}
+/* Described in TS 131.111 Section 8.95 */
+static gboolean build_dataobj_gad_shape(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const struct stk_gad_shapes *shapes = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_GAD_SHAPE;
+ unsigned char shape_buf[128];
+ unsigned char velocity_buf[8];
+ int shape_len = sizeof(shape_buf);
+ int velocity_len = sizeof(velocity_buf);
+
+ if (shapes->has_shape != TRUE)
+ return TRUE;
+
+ if (gad_shape_encode(&shapes->shape, shape_buf, &shape_len) != TRUE)
+ return FALSE;
+
+ if (shapes->has_velocity == TRUE) {
+ if (gad_velocity_encode(&shapes->velocity,
+ velocity_buf, &velocity_len) != TRUE)
+ return FALSE;
+ } else
+ velocity_len = 0;
+
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, shape_len) &&
+ stk_tlv_builder_append_bytes(tlv, shape_buf, shape_len) &&
+ stk_tlv_builder_append_byte(tlv, velocity_len) &&
+ stk_tlv_builder_append_bytes(tlv, velocity_buf, velocity_len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
+/* Described in TS 131.111 Section 8.96 */
+static gboolean build_dataobj_nmea_sentence(struct stk_tlv_builder *tlv,
+ const void *data, gboolean cr)
+{
+ const char *nmea = data;
+ unsigned char tag = STK_DATA_OBJECT_TYPE_NMEA_SENTENCE;
+ int len;
+
+ if (nmea == NULL)
+ return TRUE;
+
+ len = strlen(nmea);
+ if (len > 0x7e)
+ return FALSE;
+
+ /* No need to convert because NMEA only uses basic ASCII, UTF8 subset */
+ return stk_tlv_builder_open_container(tlv, cr, tag, FALSE) &&
+ stk_tlv_builder_append_byte(tlv, len) &&
+ stk_tlv_builder_append_bytes(tlv, (void *) nmea, len) &&
+ stk_tlv_builder_close_container(tlv);
+}
+
/* Described in TS 131.111 Section 8.98, 3GPP 24.301 Section 6.5.1 */
static gboolean build_dataobj_eps_pdn_conn_params(struct stk_tlv_builder *tlv,
const void *data, gboolean cr)
@@ -5883,6 +5938,17 @@ const unsigned char *stk_pdu_from_envelope(const struct stk_envelope *envelope,
case STK_ENVELOPE_TYPE_TERMINAL_APP:
ok = build_envelope_terminal_apps(&builder, envelope);
break;
+ case STK_ENVELOPE_TYPE_GEOLOCATION_REPORT:
+ ok = build_dataobj(&builder,
+ build_envelope_dataobj_device_ids,
+ DATAOBJ_FLAG_CR,
+ envelope,
+ build_dataobj_gad_shape, 0,
+ &envelope->geolocation_report.shape,
+ build_dataobj_nmea_sentence, 0,
+ &envelope->geolocation_report.nmea,
+ NULL);
+ break;
default:
return NULL;
};
diff --git a/src/stkutil.h b/src/stkutil.h
index 471e10f..8141383 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -182,6 +182,7 @@ enum stk_data_object_type {
STK_DATA_OBJECT_TYPE_ROUTING_AREA_INFO = 0x73,
STK_DATA_OBJECT_TYPE_UPDATE_ATTACH_TYPE = 0x74,
STK_DATA_OBJECT_TYPE_REJECTION_CAUSE_CODE = 0x75,
+ STK_DATA_OBJECT_TYPE_GAD_SHAPE = 0x77,
STK_DATA_OBJECT_TYPE_NMEA_SENTENCE = 0x78,
STK_DATA_OBJECT_TYPE_PLMN_LIST = 0x79,
STK_DATA_OBJECT_TYPE_BROADCAST_NETWORK_INFO = 0x7A,
@@ -1031,6 +1032,14 @@ struct stk_routing_area_info {
unsigned char rac;
};
+/* Defined in TS 131.111 Section 8.95 */
+struct stk_gad_shapes {
+ struct gad_shape shape;
+ struct gad_velocity velocity;
+ ofono_bool_t has_shape; /* Whether the struct is valid */
+ ofono_bool_t has_velocity; /* Whether velocity is known */
+};
+
/* Defined in TS 131.111 Section 8.99 */
struct stk_tracking_area_id {
char mnc[OFONO_MAX_MNC_LENGTH + 1];
@@ -1592,6 +1601,11 @@ struct stk_envelope_terminal_apps {
ofono_bool_t last;
};
+struct stk_envelope_geolocation_report {
+ struct stk_gad_shapes shape;
+ const char *nmea;
+};
+
struct stk_envelope {
enum stk_envelope_type type;
enum stk_device_identity_type src;
@@ -1608,6 +1622,7 @@ struct stk_envelope {
struct stk_envelope_mms_transfer_status mms_status;
struct stk_envelope_mms_notification_download mms_notification;
struct stk_envelope_terminal_apps terminal_apps;
+ struct stk_envelope_geolocation_report geolocation_report;
};
};
diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c
index 706dd85..0c38dab 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -34,6 +34,7 @@
#include <ofono/types.h>
#include "smsutil.h"
+#include "lcsutil.h"
#include "stkutil.h"
#include "util.h"
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 4/5] stkutil: Add More Time terminal response builder
2010-06-17 13:42 [PATCH 1/5] 23.032 GAD Shape structs and encoding utility Andrzej Zaborowski
2010-06-17 13:42 ` [PATCH 2/5] GAD shape tests Andrzej Zaborowski
2010-06-17 13:42 ` [PATCH 3/5] stkutil: Add the Geographical Location Reporting envelope builder Andrzej Zaborowski
@ 2010-06-17 13:42 ` Andrzej Zaborowski
2010-06-18 19:05 ` Denis Kenzior
2010-06-17 13:42 ` [PATCH 5/5] test-stkutil: Add a More Time response builder test Andrzej Zaborowski
` (5 subsequent siblings)
8 siblings, 1 reply; 13+ messages in thread
From: Andrzej Zaborowski @ 2010-06-17 13:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1013 bytes --]
---
src/stkutil.c | 1 +
src/stkutil.h | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/stkutil.c b/src/stkutil.c
index 914ac1f..144251a 100644
--- a/src/stkutil.c
+++ b/src/stkutil.c
@@ -5504,6 +5504,7 @@ const unsigned char *stk_pdu_from_response(const struct stk_response *response,
&response->get_input.text,
NULL);
break;
+ case STK_COMMAND_TYPE_MORE_TIME:
case STK_COMMAND_TYPE_SEND_SMS:
case STK_COMMAND_TYPE_PLAY_TONE:
break;
diff --git a/src/stkutil.h b/src/stkutil.h
index 8141383..8f18de8 100644
--- a/src/stkutil.h
+++ b/src/stkutil.h
@@ -1438,6 +1438,7 @@ struct stk_response {
struct stk_response_generic display_text;
struct stk_response_get_inkey get_inkey;
struct stk_response_get_input get_input;
+ struct stk_response_generic more_time;
struct stk_response_generic play_tone;
struct stk_response_poll_interval poll_interval;
struct stk_response_generic refresh;
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 5/5] test-stkutil: Add a More Time response builder test
2010-06-17 13:42 [PATCH 1/5] 23.032 GAD Shape structs and encoding utility Andrzej Zaborowski
` (2 preceding siblings ...)
2010-06-17 13:42 ` [PATCH 4/5] stkutil: Add More Time terminal response builder Andrzej Zaborowski
@ 2010-06-17 13:42 ` Andrzej Zaborowski
2010-06-18 19:06 ` Denis Kenzior
2010-06-17 13:42 ` [PATCH 1/5] mbmmodem: Allow no response data for envelope Andrzej Zaborowski
` (4 subsequent siblings)
8 siblings, 1 reply; 13+ messages in thread
From: Andrzej Zaborowski @ 2010-06-17 13:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1541 bytes --]
---
unit/test-stkutil.c | 24 ++++++++++++++++++++++++
1 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/unit/test-stkutil.c b/unit/test-stkutil.c
index 0c38dab..31dc41e 100644
--- a/unit/test-stkutil.c
+++ b/unit/test-stkutil.c
@@ -16179,6 +16179,26 @@ static const struct terminal_response_test get_input_response_data_1221 = {
},
};
+static const unsigned char more_time_response_111[] = {
+ 0x81, 0x03, 0x01, 0x02, 0x00, 0x82, 0x02, 0x82,
+ 0x81, 0x83, 0x01, 0x00,
+};
+
+static const struct terminal_response_test more_time_response_data_111 = {
+ .pdu = more_time_response_111,
+ .pdu_len = sizeof(more_time_response_111),
+ .response = {
+ .number = 1,
+ .type = STK_COMMAND_TYPE_MORE_TIME,
+ .qualifier = 0x00,
+ .src = STK_DEVICE_IDENTITY_TYPE_TERMINAL,
+ .dst = STK_DEVICE_IDENTITY_TYPE_UICC,
+ .result = {
+ .type = STK_RESULT_TYPE_SUCCESS,
+ },
+ },
+};
+
static const unsigned char send_sms_response_111[] = {
0x81, 0x03, 0x01, 0x13, 0x00, 0x82, 0x02, 0x82,
0x81, 0x83, 0x01, 0x00,
@@ -21027,6 +21047,10 @@ int main(int argc, char **argv)
g_test_add_data_func("/teststk/More Time 1.1.1",
&more_time_data_111, test_more_time);
+ g_test_add_data_func("/teststk/More Time response 1.1.1",
+ &more_time_response_data_111,
+ test_terminal_response_encoding);
+
g_test_add_data_func("/teststk/Play Tone 1.1.1",
&play_tone_data_111, test_play_tone);
g_test_add_data_func("/teststk/Play Tone 1.1.2",
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 1/5] mbmmodem: Allow no response data for envelope.
2010-06-17 13:42 [PATCH 1/5] 23.032 GAD Shape structs and encoding utility Andrzej Zaborowski
` (3 preceding siblings ...)
2010-06-17 13:42 ` [PATCH 5/5] test-stkutil: Add a More Time response builder test Andrzej Zaborowski
@ 2010-06-17 13:42 ` Andrzej Zaborowski
2010-06-18 19:25 ` Denis Kenzior
2010-06-17 13:42 ` [PATCH 2/5] mbm: Register stk driver post sim Andrzej Zaborowski
` (3 subsequent siblings)
8 siblings, 1 reply; 13+ messages in thread
From: Andrzej Zaborowski @ 2010-06-17 13:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1243 bytes --]
Partially reverts
http://git.kernel.org/?p=network/ofono/ofono.git;a=commitdiff;h=f98c6dc91702c0d14c0afa2a4e32102d3105568d
---
drivers/mbmmodem/stk.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/mbmmodem/stk.c b/drivers/mbmmodem/stk.c
index cea902e..77bd7b5 100644
--- a/drivers/mbmmodem/stk.c
+++ b/drivers/mbmmodem/stk.c
@@ -52,8 +52,8 @@ static void mbm_stke_cb(gboolean ok, GAtResult *result, gpointer user_data)
ofono_stk_envelope_cb_t cb = cbd->cb;
GAtResultIter iter;
struct ofono_error error;
- const guint8 *pdu;
- gint len;
+ const guint8 *pdu = NULL;
+ gint len = 0;
decode_at_error(&error, g_at_result_final_response(result));
@@ -64,11 +64,9 @@ static void mbm_stke_cb(gboolean ok, GAtResult *result, gpointer user_data)
g_at_result_iter_init(&iter, result);
- if (g_at_result_iter_next(&iter, "*STKE:") == FALSE)
- goto error;
-
- if (g_at_result_iter_next_hexstring(&iter, &pdu, &len) == FALSE)
- goto error;
+ if (g_at_result_iter_next(&iter, "*STKE:") == TRUE)
+ if (g_at_result_iter_next_hexstring(&iter, &pdu, &len) == FALSE)
+ goto error;
cb(&error, pdu, len, cbd->data);
return;
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 2/5] mbm: Register stk driver post sim.
2010-06-17 13:42 [PATCH 1/5] 23.032 GAD Shape structs and encoding utility Andrzej Zaborowski
` (4 preceding siblings ...)
2010-06-17 13:42 ` [PATCH 1/5] mbmmodem: Allow no response data for envelope Andrzej Zaborowski
@ 2010-06-17 13:42 ` Andrzej Zaborowski
2010-06-17 13:42 ` [PATCH 3/5] atmodem: Add PIN entry quirk for mbm Andrzej Zaborowski
` (2 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: Andrzej Zaborowski @ 2010-06-17 13:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 824 bytes --]
---
plugins/mbm.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/plugins/mbm.c b/plugins/mbm.c
index 00b5550..9d059ef 100644
--- a/plugins/mbm.c
+++ b/plugins/mbm.c
@@ -318,7 +318,6 @@ static void mbm_pre_sim(struct ofono_modem *modem)
ofono_devinfo_create(modem, 0, "atmodem", data->modem_port);
sim = ofono_sim_create(modem, 0, "atmodem", data->modem_port);
- ofono_stk_create(modem, 0, "mbmmodem", data->modem_port);
if (data->have_sim && sim)
ofono_sim_inserted_notify(sim, TRUE);
@@ -332,6 +331,8 @@ static void mbm_post_sim(struct ofono_modem *modem)
DBG("%p", modem);
+ ofono_stk_create(modem, 0, "mbmmodem", data->modem_port);
+
ofono_netreg_create(modem, OFONO_VENDOR_MBM, "atmodem",
data->modem_port);
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 3/5] atmodem: Add PIN entry quirk for mbm.
2010-06-17 13:42 [PATCH 1/5] 23.032 GAD Shape structs and encoding utility Andrzej Zaborowski
` (5 preceding siblings ...)
2010-06-17 13:42 ` [PATCH 2/5] mbm: Register stk driver post sim Andrzej Zaborowski
@ 2010-06-17 13:42 ` Andrzej Zaborowski
2010-06-17 13:42 ` [PATCH 4/5] mbm: Use MBM vendor quirk of the sim driver Andrzej Zaborowski
2010-06-17 13:42 ` [PATCH 5/5] mbm: Move +CFUN=1 to after SIM authentication Andrzej Zaborowski
8 siblings, 0 replies; 13+ messages in thread
From: Andrzej Zaborowski @ 2010-06-17 13:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2638 bytes --]
Wait for *EPEV unsolicited response after PIN entered, otherwise the
next AT+CPIN? query still returns the old value for a fraction of a
second and ofono gets stuck until the next PIN entry attempt.
---
drivers/atmodem/sim.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 45 insertions(+), 1 deletions(-)
diff --git a/drivers/atmodem/sim.c b/drivers/atmodem/sim.c
index e722fbb..8d5a9fa 100644
--- a/drivers/atmodem/sim.c
+++ b/drivers/atmodem/sim.c
@@ -44,6 +44,7 @@
struct sim_data {
GAtChat *chat;
unsigned int vendor;
+ guint epev_id;
};
static const char *crsm_prefix[] = { "+CRSM:", NULL };
@@ -509,6 +510,45 @@ error:
CALLBACK_WITH_FAILURE(cb, -1, data);
}
+static void at_epev_notify(GAtResult *result, gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ struct sim_data *sd = cbd->user;
+ ofono_sim_lock_unlock_cb_t cb = cbd->cb;
+ struct ofono_error error = { .type = OFONO_ERROR_TYPE_NO_ERROR };
+
+ cb(&error, cbd->data);
+
+ g_at_chat_unregister(sd->chat, sd->epev_id);
+ sd->epev_id = 0;
+}
+
+static void at_pin_send_cb(gboolean ok, GAtResult *result,
+ gpointer user_data)
+{
+ struct cb_data *cbd = user_data;
+ struct sim_data *sd = cbd->user;
+ ofono_sim_lock_unlock_cb_t cb = cbd->cb;
+ struct ofono_error error;
+
+ decode_at_error(&error, g_at_result_final_response(result));
+
+ /*
+ * On the MBM modem, AT+CPIN? keeps returning SIM PIN for a moment
+ * after successful AT+CPIN="..", but sends *EPEV when that changes.
+ */
+ if (ok && sd->vendor == OFONO_VENDOR_MBM) {
+ sd->epev_id = g_at_chat_register(sd->chat, "*EPEV",
+ at_epev_notify,
+ FALSE, cbd, g_free);
+ return;
+ }
+
+ cb(&error, cbd->data);
+
+ g_free(cbd);
+}
+
static void at_lock_unlock_cb(gboolean ok, GAtResult *result,
gpointer user_data)
{
@@ -532,10 +572,12 @@ static void at_pin_send(struct ofono_sim *sim, const char *passwd,
if (!cbd)
goto error;
+ cbd->user = sd;
+
snprintf(buf, sizeof(buf), "AT+CPIN=\"%s\"", passwd);
ret = g_at_chat_send(sd->chat, buf, none_prefix,
- at_lock_unlock_cb, cbd, g_free);
+ at_pin_send_cb, cbd, NULL);
memset(buf, 0, sizeof(buf));
@@ -740,6 +782,8 @@ static int at_sim_probe(struct ofono_sim *sim, unsigned int vendor,
if (sd->vendor == OFONO_VENDOR_WAVECOM)
g_at_chat_add_terminator(chat, "+CPIN:", 6, TRUE);
+ if (sd->vendor == OFONO_VENDOR_MBM)
+ g_at_chat_send(chat, "AT*EPEE=1", NULL, NULL, NULL, NULL);
ofono_sim_set_data(sim, sd);
g_idle_add(at_sim_register, sim);
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 4/5] mbm: Use MBM vendor quirk of the sim driver.
2010-06-17 13:42 [PATCH 1/5] 23.032 GAD Shape structs and encoding utility Andrzej Zaborowski
` (6 preceding siblings ...)
2010-06-17 13:42 ` [PATCH 3/5] atmodem: Add PIN entry quirk for mbm Andrzej Zaborowski
@ 2010-06-17 13:42 ` Andrzej Zaborowski
2010-06-17 13:42 ` [PATCH 5/5] mbm: Move +CFUN=1 to after SIM authentication Andrzej Zaborowski
8 siblings, 0 replies; 13+ messages in thread
From: Andrzej Zaborowski @ 2010-06-17 13:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 620 bytes --]
---
plugins/mbm.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/plugins/mbm.c b/plugins/mbm.c
index 9d059ef..9193539 100644
--- a/plugins/mbm.c
+++ b/plugins/mbm.c
@@ -317,7 +317,8 @@ static void mbm_pre_sim(struct ofono_modem *modem)
DBG("%p", modem);
ofono_devinfo_create(modem, 0, "atmodem", data->modem_port);
- sim = ofono_sim_create(modem, 0, "atmodem", data->modem_port);
+ sim = ofono_sim_create(modem, OFONO_VENDOR_MBM, "atmodem",
+ data->modem_port);
if (data->have_sim && sim)
ofono_sim_inserted_notify(sim, TRUE);
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH 5/5] mbm: Move +CFUN=1 to after SIM authentication.
2010-06-17 13:42 [PATCH 1/5] 23.032 GAD Shape structs and encoding utility Andrzej Zaborowski
` (7 preceding siblings ...)
2010-06-17 13:42 ` [PATCH 4/5] mbm: Use MBM vendor quirk of the sim driver Andrzej Zaborowski
@ 2010-06-17 13:42 ` Andrzej Zaborowski
8 siblings, 0 replies; 13+ messages in thread
From: Andrzej Zaborowski @ 2010-06-17 13:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3853 bytes --]
This is mostly a hack, as discussed on IRC we don't know what the
"correct" order is, but this seems to make the SIM toolkit work
more or less reliably on this modem, on SIMs with PIN enabled or
disabled alike. Use this if you want to try out the STK menu.
In particular I'm not sure if the modem will be able to make
emergency calls unauthenticated, without CFUN=1.
I've tried other things, but generally, without this patch, with
PIN disabled in the SIM, the initial proactive command is only
passed through by the modem if the profile download is done before
any of the atom drivers initialise, (before sim driver). With PIN
enabled it won't work at all.
Incidentally it seems that on the calypso we also need to send
+CFUN=1 only after SIM authentication, for things to work.
With this patch, the initial proactive command still only works in
the first ofono session after modem reset. When ofono restarts
without unplugging or resetting (AT*E2RESET) the modem, on the
next session the SIM doesn't get reinitialised and will not send
the Set Up Menu unless it's one of those SIMs that resend it
periodically.
---
plugins/mbm.c | 55 ++++++++++++++++++++-----------------------------------
1 files changed, 20 insertions(+), 35 deletions(-)
diff --git a/plugins/mbm.c b/plugins/mbm.c
index 9193539..7873f54 100644
--- a/plugins/mbm.c
+++ b/plugins/mbm.c
@@ -121,22 +121,6 @@ poweron:
ofono_modem_set_powered(modem, TRUE);
}
-static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- struct mbm_data *data = ofono_modem_get_data(modem);
-
- DBG("");
-
- if (!ok) {
- ofono_modem_set_powered(modem, FALSE);
- return;
- }
-
- g_at_chat_send(data->modem_port, "AT+CRSM=242", crsm_prefix,
- status_check, modem, NULL);
-}
-
static void cfun_query(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
@@ -146,23 +130,13 @@ static void cfun_query(gboolean ok, GAtResult *result, gpointer user_data)
DBG("%d", ok);
- if (!ok)
- return;
-
- g_at_result_iter_init(&iter, result);
-
- if (g_at_result_iter_next(&iter, "+CFUN:") == FALSE)
- return;
-
- g_at_result_iter_next_number(&iter, &status);
-
- if (status == 4) {
- g_at_chat_send(data->modem_port, "AT+CFUN=1", none_prefix,
- cfun_enable, modem, NULL);
+ if (!ok) {
+ ofono_modem_set_powered(modem, FALSE);
return;
}
- cfun_enable(TRUE, NULL, modem);
+ g_at_chat_send(data->modem_port, "AT+CRSM=242", crsm_prefix,
+ status_check, modem, NULL);
}
static void emrdy_notifier(GAtResult *result, gpointer user_data)
@@ -324,16 +298,14 @@ static void mbm_pre_sim(struct ofono_modem *modem)
ofono_sim_inserted_notify(sim, TRUE);
}
-static void mbm_post_sim(struct ofono_modem *modem)
+static void cfun_enable(gboolean ok, GAtResult *result,
+ gpointer user_data)
{
+ struct ofono_modem *modem = user_data;
struct mbm_data *data = ofono_modem_get_data(modem);
struct ofono_gprs *gprs;
struct ofono_gprs_context *gc;
- DBG("%p", modem);
-
- ofono_stk_create(modem, 0, "mbmmodem", data->modem_port);
-
ofono_netreg_create(modem, OFONO_VENDOR_MBM, "atmodem",
data->modem_port);
@@ -348,6 +320,19 @@ static void mbm_post_sim(struct ofono_modem *modem)
ofono_gprs_add_context(gprs, gc);
}
+static void mbm_post_sim(struct ofono_modem *modem)
+{
+ struct mbm_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ ofono_stk_create(modem, 0, "mbmmodem", data->modem_port);
+
+ g_at_chat_send(data->modem_port, "AT+CFUN=1", none_prefix,
+ cfun_enable, modem, NULL);
+
+}
+
static struct ofono_modem_driver mbm_driver = {
.name = "mbm",
.probe = mbm_probe,
--
1.7.1.86.g0e460.dirty
^ permalink raw reply related [flat|nested] 13+ messages in thread