# Set required packages
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 tcore dlog db-util)
+pkg_check_modules(pkgs REQUIRED glib-2.0 tcore dlog db-util libxml-2.0)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
+ /usr/include/libxml2
+ )
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align")
src/s_sms.c
src/s_phonebook.c
src/s_sap.c
+ src/s_gps.c
)
+++ /dev/null
-From a748999e2015a9546f84d7169c6480ed8f6aa0ee Mon Sep 17 00:00:00 2001
-From: Philippe Nunes <philippe.nunes@linux.intel.com>
-Date: Tue, 18 Sep 2012 17:35:02 +0200
-Subject: [PATCH 01/23] desc: CP name is imc-pr3 for Intel device
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/desc.c | 12 ++++++++++++
- 1 file changed, 12 insertions(+)
-
-diff --git a/src/desc.c b/src/desc.c
-index d165ca0..7a5ef93 100644
---- a/src/desc.c
-+++ b/src/desc.c
-@@ -123,6 +123,18 @@ static int _get_cp_name(char **name)
- uname(&u);
-
- dbg("u.nodename : [ %s ]", u.nodename);
-+ dbg("u.__domainname : [ %s ]", u.__domainname);
-+ dbg("u.machine : [ %s ]", u.machine);
-+ dbg("u.release : [ %s ]", u.release);
-+ dbg("u.sysname : [ %s ]", u.sysname);S
-+ dbg("u.version : [ %s ]", u.version);
-+
-+ /* By default, SUNRISE IMC modem is returned */
-+ if (!strcmp(u.nodename, "(none)")) {
-+ *name = g_new0(char, 8);
-+ strcpy(*name, "imc-pr3");
-+ return 8;
-+ }
-
- for (i = 0; svnet1_models[i]; i++) {
- if (!strcmp(u.nodename, svnet1_models[i])) {
---
-1.7.10.4
-
+++ /dev/null
-From 389f7a04eefccdec5f2597df0d6c836a0010b268 Mon Sep 17 00:00:00 2001
-From: Philippe Nunes <philippe.nunes@linux.intel.com>
-Date: Tue, 18 Sep 2012 17:47:49 +0200
-Subject: [PATCH 02/23] s_modem: CGMR response parsing is compatible with IMC
- PR3 modem
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/s_modem.c | 21 ++++++++++++---------
- 1 file changed, 12 insertions(+), 9 deletions(-)
-
-diff --git a/src/s_modem.c b/src/s_modem.c
-index 88a06a7..edd1ca9 100644
---- a/src/s_modem.c
-+++ b/src/s_modem.c
-@@ -360,20 +360,23 @@ static void on_response_version(TcorePending *p, int data_len, const void *data,
- if (resp->lines) {
- line = (const char *) resp->lines->data;
- tokens = tcore_at_tok_new(line);
-- if (g_slist_length(tokens) != 5) {
-+ if (g_slist_length(tokens) == 1) {
-+ swver = g_slist_nth_data(tokens, 0);
-+ dbg("version: sw=[%s]", swver);
-+ } else if (g_slist_length(tokens) == 5) {
-+ swver = g_slist_nth_data(tokens, 0);
-+ hwver = g_slist_nth_data(tokens, 1);
-+ caldate = g_slist_nth_data(tokens, 2);
-+ pcode = g_slist_nth_data(tokens, 3);
-+ id = g_slist_nth_data(tokens, 4);
-+
-+ dbg("version: sw=[%s], hw=[%s], rf_cal=[%s], product_code=[%s], model_id=[%s]", swver, hwver, caldate, pcode, id);
-+ } else {
- msg("invalid message");
- goto OUT;
- }
- }
-
-- swver = g_slist_nth_data(tokens, 0);
-- hwver = g_slist_nth_data(tokens, 1);
-- caldate = g_slist_nth_data(tokens, 2);
-- pcode = g_slist_nth_data(tokens, 3);
-- id = g_slist_nth_data(tokens, 4);
--
-- dbg("version: sw=[%s], hw=[%s], rf_cal=[%s], product_code=[%s], model_id=[%s]", swver, hwver, caldate, pcode, id);
--
- vi = calloc(sizeof(TelMiscVersionInformation), 1);
- if (NULL != swver)
- memcpy(vi->szSwVersion, swver, strlen(swver));
---
-1.7.10.4
-
+++ /dev/null
-From 7e83caa59a5a98f169a45b58b9767fc8f65e61bf Mon Sep 17 00:00:00 2001
-From: Philippe Nunes <philippe.nunes@linux.intel.com>
-Date: Tue, 18 Sep 2012 17:45:58 +0200
-Subject: [PATCH 03/23] s-modem: Cleanup
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-Conflicts:
- src/s_modem.c
----
- src/s_modem.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/src/s_modem.c b/src/s_modem.c
-index edd1ca9..dd8899b 100644
---- a/src/s_modem.c
-+++ b/src/s_modem.c
-@@ -250,6 +250,7 @@ static void on_response_set_flight_mode(TcorePending *p, int data_len, const voi
- }
- } else {
- dbg("Sending response for Flight mode operation");
-+ tcore_user_request_send_response(ur, TRESP_MODEM_SET_FLIGHTMODE, sizeof(struct tresp_modem_set_flightmode), &res);
-
- req_data = tcore_user_request_ref_data(ur, NULL);
-
-@@ -787,7 +788,7 @@ static TReturn get_imei(CoreObject *o, UserRequest *ur)
- TcorePending *pending = NULL;
-
- hal = tcore_object_get_hal(o);
-- if(FALSE == tcore_hal_get_power_state(hal)){
-+ if (FALSE == tcore_hal_get_power_state(hal)) {
- dbg("cp not ready/n");
- return TCORE_RETURN_ENOSYS;
- }
---
-1.7.10.4
-
+++ /dev/null
-From 18e1f3c2d0e927ff7ff4d8e6c6dd16ba701e9523 Mon Sep 17 00:00:00 2001
-From: Philippe Nunes <philippe.nunes@linux.intel.com>
-Date: Tue, 18 Sep 2012 17:50:08 +0200
-Subject: [PATCH 04/23] s-modem: Add notification hook for SIM status
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/s_modem.c | 16 ++++++++++++++++
- 1 file changed, 16 insertions(+)
-
-diff --git a/src/s_modem.c b/src/s_modem.c
-index dd8899b..2c71457 100644
---- a/src/s_modem.c
-+++ b/src/s_modem.c
-@@ -465,6 +465,20 @@ OUT:
- }
-
-
-+static enum tcore_hook_return on_hook_sim_status(Server *s, CoreObject *source, enum tcore_notification_command command,
-+ unsigned int data_len, void *data, void *user_data)
-+{
-+ const struct tnoti_sim_status *sim = data;
-+
-+ if (sim->sim_status == SIM_STATUS_INIT_COMPLETED) {
-+ dbg("SIM ready for attach");
-+ dbg("Enable STK and Fetching of proactive Commands");
-+ prepare_and_send_pending_request(tcore_object_ref_plugin(source), "sat", "AT+CFUN=6", NULL, TCORE_AT_NO_RESULT, on_response_enable_proactive_command);
-+ prepare_and_send_pending_request(tcore_object_ref_plugin(source), "umts_network", "AT+COPS=0", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
-+ }
-+
-+ return TCORE_HOOK_RETURN_CONTINUE;
-+}
-
- gboolean on_event_modem_power(TcoreAT *at, const char *line, TcorePlugin *p)
- {
-@@ -917,6 +931,8 @@ gboolean s_modem_init(TcorePlugin *p, TcoreHal *h)
- dbg("Registering for +XSIM event");
- tcore_object_add_callback(o, "+XSIM", on_event_bootup_sim_status, NULL);
-
-+ tcore_server_add_notification_hook(tcore_plugin_ref_server(p), TNOTI_SIM_STATUS, on_hook_sim_status, o);
-+
- return TRUE;
- }
-
---
-1.7.10.4
-
+++ /dev/null
-From 65c222ac5b39065cc7a26b94d2e0ba2b985c7d86 Mon Sep 17 00:00:00 2001
-From: Philippe Nunes <philippe.nunes@linux.intel.com>
-Date: Tue, 18 Sep 2012 17:53:42 +0200
-Subject: [PATCH 05/23] s-sim: Query SIM state when modem is powered up
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-With IMC PR3 modem, the SIM state is not received after enabling XSIM ur codes
-(+XSIMSTATE=1)
-We need to do a +XSIMSTATE query to get the current SIM state.
----
- src/s_sim.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
- 1 file changed, 64 insertions(+), 3 deletions(-)
-
-diff --git a/src/s_sim.c b/src/s_sim.c
-index 77287cf..5ab702a 100644
---- a/src/s_sim.c
-+++ b/src/s_sim.c
-@@ -115,6 +115,33 @@ static void _sim_status_update(CoreObject *o, enum tel_sim_status sim_status);
- static void on_confirmation_sim_message_send(TcorePending *p, gboolean result, void *user_data); // from Kernel
- extern gboolean util_byte_to_hex(const char *byte_pdu, char *hex_pdu, int num_bytes);
-
-+static void sim_prepare_and_send_pending_request(TcorePlugin *plugin, char *co_name, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, TcorePendingResponseCallback callback)
-+{
-+ TcoreATRequest *req = NULL;
-+ TcoreHal *hal = NULL;
-+ CoreObject *o = NULL;
-+ TcorePending *pending = NULL;
-+ TReturn ret;
-+
-+ o = tcore_plugin_ref_core_object(plugin, co_name);
-+ hal = tcore_object_get_hal(o);
-+ dbg("hal: %p", hal);
-+
-+ pending = tcore_pending_new(o, 0);
-+ if (!pending)
-+ dbg("Pending is NULL");
-+ req = tcore_at_request_new(at_cmd, prefix, at_cmd_type);
-+
-+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
-+
-+ tcore_pending_set_request_data(pending, 0, req);
-+ tcore_pending_set_response_callback(pending, callback, NULL);
-+ tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
-+ tcore_pending_link_user_request(pending, NULL); // set user request to NULL - this is internal request
-+ ret = tcore_hal_send_request(hal, pending);
-+ return;
-+}
-+
- static void on_confirmation_sim_message_send(TcorePending *p, gboolean result, void *user_data)
- {
- dbg("on_confirmation_sim_message_send - msg out from queue.\n");
-@@ -1686,7 +1713,7 @@ static TReturn _get_file_info(CoreObject *o, UserRequest *ur, const enum tel_sim
- trt = tcore_user_request_set_metainfo(ur, sizeof(struct s_sim_property), &file_meta);
- dbg("trt[%d]", trt);
- cmd_str = g_strdup_printf("AT+CRSM=192, %d", ef); /*command - 192 : GET RESPONSE*/
-- dbg("cmd_str: %x", cmd_str);
-+ dbg("cmd_str: %s", cmd_str);
-
- pending = tcore_at_pending_new(o, cmd_str, "+CRSM:", TCORE_AT_SINGLELINE, _response_get_file_info, NULL);
- tcore_pending_link_user_request(pending, ur);
-@@ -1914,12 +1941,16 @@ static gboolean on_event_pin_status(CoreObject *o, const void *event_info, void
- line = (char *) (lines->data);
-
- tokens = tcore_at_tok_new(line);
-- if (g_slist_length(tokens) != 1) {
-+
-+ if (g_slist_length(tokens) == 4) {
-+ sim_state = atoi(g_slist_nth_data(tokens, 1));
-+ } else if (g_slist_length(tokens) == 1)
-+ sim_state = atoi(g_slist_nth_data(tokens, 0));
-+ else {
- msg("invalid message");
- tcore_at_tok_free(tokens);
- return TRUE;
- }
-- sim_state = atoi(g_slist_nth_data(tokens, 0));
-
- switch (sim_state) {
- case 0: // sim state = SIM not present
-@@ -2033,6 +2064,34 @@ OUT:
- }
-
-
-+static void on_response_get_sim_status(TcorePending *p, int data_len, const void *data, void *user_data)
-+{
-+ const TcoreATResponse *resp = data;
-+ CoreObject *co_sim = NULL;
-+
-+ dbg(" Function entry ");
-+
-+ co_sim = tcore_pending_ref_core_object(p);
-+
-+ if (resp->success > 0) {
-+ dbg("RESPONSE OK");
-+ if (resp->lines)
-+ on_event_pin_status(co_sim, resp->lines, NULL);
-+ } else {
-+ dbg("RESPONSE NOK");
-+ }
-+
-+ dbg(" Function exit");
-+}
-+
-+static enum tcore_hook_return on_hook_modem_power(Server *s, CoreObject *source, enum tcore_notification_command command,
-+ unsigned int data_len, void *data, void *user_data)
-+{
-+ dbg("Get SIM status");
-+ sim_prepare_and_send_pending_request(tcore_object_ref_plugin(source), "sim", "AT+XSIMSTATE?", "+XSIMSTATE:", TCORE_AT_SINGLELINE, on_response_get_sim_status);
-+
-+ return TCORE_HOOK_RETURN_CONTINUE;
-+}
-
- static void on_response_verify_pins(TcorePending *p, int data_len, const void *data, void *user_data)
- {
-@@ -3279,6 +3338,8 @@ gboolean s_sim_init(TcorePlugin *p, TcoreHal *h)
- tcore_object_add_callback(o, "+XLOCK", on_event_facility_lock_status, NULL);
- tcore_object_add_callback(o, "+XSIM", on_event_pin_status, NULL);
-
-+ tcore_server_add_notification_hook(tcore_plugin_ref_server(p), TNOTI_MODEM_POWER, on_hook_modem_power, o);
-+
- dbg("exit");
- return TRUE;
- }
---
-1.7.10.4
-
+++ /dev/null
-From 86510097b43f9a60f50547511fb176cf6d97e9b2 Mon Sep 17 00:00:00 2001
-From: Philippe Nunes <philippe.nunes@linux.intel.com>
-Date: Thu, 20 Sep 2012 17:28:07 +0200
-Subject: [PATCH 06/23] common: Fix warning errors
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/s_common.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/s_common.c b/src/s_common.c
-index 0c83ac5..9b8c4a3 100644
---- a/src/s_common.c
-+++ b/src/s_common.c
-@@ -226,9 +226,9 @@ char _util_unpackb(const char *src, int pos, int len)
- rshift = MAX(8 - (pos + len), 0);
-
- if (rshift > 0) {
-- result = MASK_AND_SHIFT(len, pos, rshift, *src);
-+ result = MASK_AND_SHIFT(len, pos, rshift, (unsigned char)*src);
- } else {
-- result = MASK(8 - pos, pos, *src);
-+ result = MASK(8 - pos, pos, (unsigned char)*src);
- src++;
- len -= 8 - pos;
-
---
-1.7.10.4
-
+++ /dev/null
-From 3da4bb2f70c4a15d1d61187e89d2f28ab33ca383 Mon Sep 17 00:00:00 2001
-From: Philippe Nunes <philippe.nunes@linux.intel.com>
-Date: Fri, 21 Sep 2012 16:46:54 +0200
-Subject: [PATCH 07/23] s_sim: Get the SIM type when SIM is ready
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/s_sim.c | 33 +++++++++++++++------------------
- 1 file changed, 15 insertions(+), 18 deletions(-)
-
-diff --git a/src/s_sim.c b/src/s_sim.c
-index 5ab702a..1d7e5c6 100644
---- a/src/s_sim.c
-+++ b/src/s_sim.c
-@@ -98,7 +98,6 @@ struct s_sim_property {
- int rec_count; /**< Number of records in file */
- int data_size; /**< File size */
- int current_index; /**< current index to read */
-- enum tel_sim_status first_recv_status;
- enum s_sim_sec_op_e current_sec_op; /**< current index to read */
- struct tel_sim_mbi_list mbi_list;
- struct tel_sim_mb_number mb_list[SIM_MSP_CNT_MAX*5];
-@@ -841,7 +840,13 @@ static void _response_get_sim_type(TcorePending *p, int data_len, const void *da
- }
-
- tcore_sim_set_type(co_sim, sim_type);
-- _sim_status_update(co_sim, sp->first_recv_status);
-+
-+ if (sim_type != SIM_TYPE_UNKNOWN) {
-+ /* set user request for using ur metainfo set/ref functionality */
-+ ur = tcore_user_request_new(NULL, NULL);
-+ _get_file_info(co_sim, ur, SIM_EF_IMSI);
-+ }
-+
- tcore_at_tok_free(tokens);
- dbg(" Function exit");
- }
-@@ -1921,7 +1926,6 @@ OUT:
-
- static gboolean on_event_pin_status(CoreObject *o, const void *event_info, void *user_data)
- {
-- UserRequest *ur = NULL;
- struct s_sim_property *sp = NULL;
- enum tel_sim_status sim_status = SIM_STATUS_INITIALIZING;
- GSList *tokens = NULL;
-@@ -1986,7 +1990,7 @@ static gboolean on_event_pin_status(CoreObject *o, const void *event_info, void
-
- case 7: // sim state = ready for attach (+COPS)
- sim_status = SIM_STATUS_INIT_COMPLETED;
-- dbg("Modem init completed");
-+ dbg("SIM is ready for attach");
- break;
-
- case 8: // sim state = SIM Technical Problem
-@@ -2015,8 +2019,10 @@ static gboolean on_event_pin_status(CoreObject *o, const void *event_info, void
-
- switch (sim_status) {
- case SIM_STATUS_INIT_COMPLETED:
-- ur = tcore_user_request_new(NULL, NULL); // this is for using ur metainfo set/ref functionality.
-- _get_file_info(o, ur, SIM_EF_IMSI);
-+ if (tcore_sim_get_type(o) == SIM_TYPE_UNKNOWN)
-+ _get_sim_type(o);
-+ else
-+ _sim_status_update(o, sim_status);
- break;
-
- case SIM_STATUS_INITIALIZING:
-@@ -2028,17 +2034,7 @@ static gboolean on_event_pin_status(CoreObject *o, const void *event_info, void
- case SIM_STATUS_SPCK_REQUIRED:
- case SIM_STATUS_CCK_REQUIRED:
- case SIM_STATUS_LOCK_REQUIRED:
-- if (sp->first_recv_status == SIM_STATUS_UNKNOWN) {
-- dbg("first received sim status[%d]", sim_status);
-- sp->first_recv_status = sim_status;
-- _get_sim_type(o);
-- } else {
-- dbg("second or later received lock status[%d]", sim_status);
-- if (tcore_sim_get_status(o) != SIM_STATUS_INIT_COMPLETED) {
-- dbg("sim is not init complete in telephony side yet");
-- _sim_status_update(o, sim_status);
-- }
-- }
-+ _sim_status_update(o, sim_status);
- break;
-
- case SIM_STATUS_CARD_REMOVED:
-@@ -2048,6 +2044,8 @@ static gboolean on_event_pin_status(CoreObject *o, const void *event_info, void
- dbg("[SIM]SIM CARD REMOVED!!");
- sim_status = SIM_STATUS_CARD_REMOVED;
- }
-+
-+ tcore_sim_set_type(o, SIM_TYPE_UNKNOWN);
- _sim_status_update(o, sim_status);
- break;
-
-@@ -3332,7 +3330,6 @@ gboolean s_sim_init(TcorePlugin *p, TcoreHal *h)
- work_queue = g_queue_new();
- tcore_object_link_user_data(o, work_queue);
-
-- file_meta->first_recv_status = SIM_STATUS_UNKNOWN;
- tcore_sim_link_userdata(o, file_meta);
-
- tcore_object_add_callback(o, "+XLOCK", on_event_facility_lock_status, NULL);
---
-1.7.10.4
-
+++ /dev/null
-From 5c4fbd80accf435889b6f7b16eae14b47a6cba09 Mon Sep 17 00:00:00 2001
-From: Caiwen Zhang <caiwen.zhang@intel.com>
-Date: Tue, 25 Sep 2012 21:28:07 +0800
-Subject: [PATCH 08/23] Fix SCA(service center address) length checking error
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-For the address field used by SM-RL(short message relay layer),
-the length byte represents octets of the whole field(include itself
-and TOA byte - type of address). Please refer to 3GPP 31.102 4.2.27
-and 3GPP 24.011 8.2.5.2
-
-For the address field used by SM-TP(transfer layer), the length
-represents semi-octets within the address(exclude itself and TOA
-byte). Please refer to 3GPP 23.040 9.1.2.5.
-
-SCA is an address filed of SM-RL. SMS_MAX_SMS_SERVICE_CENTER_ADDR
-should be 12.
-
-But currently in the struct telephony_sms_DataPaclageInfo, SM-TP
-address filed is used to represent the SCA.
-
-As we currently can't access libtcore and msg_service packages,
-temporarily change the SCA length checking here to make SMS sending
-work.
----
- src/s_sms.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/s_sms.c b/src/s_sms.c
-index 874f08e..2b3cd4f 100644
---- a/src/s_sms.c
-+++ b/src/s_sms.c
-@@ -2218,7 +2218,7 @@ static TReturn send_umts_msg(CoreObject *obj, UserRequest *ur)
-
- if ((sendUmtsMsg->msgDataPackage.msgLength > 0)
- && (sendUmtsMsg->msgDataPackage.msgLength <= SMS_SMDATA_SIZE_MAX)
-- && (ScLength <= SMS_SCADDRESS_LEN_MAX)) {
-+ && (ScLength <= (SMS_MAX_SMS_SERVICE_CENTER_ADDR - 2) * 2)) {
- if (ScLength == 0) { // ScAddress not specified
- buf[0] = '0';
- buf[1] = '0';
---
-1.7.10.4
-
+++ /dev/null
-From a2b5d447eb38825e0af9e57dde07b6e941d48389 Mon Sep 17 00:00:00 2001
-From: Philippe Nunes <philippe.nunes@linux.intel.com>
-Date: Wed, 26 Sep 2012 17:26:42 +0200
-Subject: [PATCH 09/23] s_modem: Add XGENDATA query to get firmware
- information
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/s_modem.c | 30 ++++++++++++++++++++++++++++++
- 1 file changed, 30 insertions(+)
-
-diff --git a/src/s_modem.c b/src/s_modem.c
-index 2c71457..22adfa3 100644
---- a/src/s_modem.c
-+++ b/src/s_modem.c
-@@ -275,6 +275,33 @@ static void on_response_set_flight_mode(TcorePending *p, int data_len, const voi
- tcore_at_tok_free(tokens);
- }
-
-+static void on_response_xgendata(TcorePending *p, int data_len, const void *data, void *user_data)
-+{
-+ const TcoreATResponse *resp = data;
-+ GSList *tokens = NULL;
-+ const char *line;
-+
-+ if (resp->success > 0) {
-+ dbg("RESPONSE OK");
-+ if (resp->lines) {
-+ line = (const char *) resp->lines->data;
-+ tokens = tcore_at_tok_new(line);
-+ if (g_slist_length(tokens) != 1) {
-+ msg("invalid message");
-+ goto OUT;
-+ }
-+ }
-+
-+ dbg("XGENDATA = [%s]", g_slist_nth_data(tokens, 0));
-+ }
-+
-+OUT:
-+ if (tokens != NULL)
-+ tcore_at_tok_free(tokens);
-+
-+ return;
-+}
-+
- static void on_response_imei(TcorePending *p, int data_len, const void *data, void *user_data)
- {
- const TcoreATResponse *resp = data;
-@@ -511,6 +538,9 @@ gboolean on_event_modem_power(TcoreAT *at, const char *line, TcorePlugin *p)
- /* Get Version Number */
- prepare_and_send_pending_request(p, "modem", "AT+CGMR", NULL, TCORE_AT_SINGLELINE, on_response_version);
-
-+ /* Get XGENDATA info */
-+ prepare_and_send_pending_request(p, "modem", "AT+XGENDATA", "+XGENDATA:", TCORE_AT_MULTILINE, on_response_xgendata);
-+
- tcore_modem_set_powered(o, TRUE);
-
- modem_power.state = MODEM_STATE_ONLINE;
---
-1.7.10.4
-
+++ /dev/null
-From 0ab2df1acdc37d1ada019d0e4c1ccb81913637ef Mon Sep 17 00:00:00 2001
-From: Philippe Nunes <philippe.nunes@linux.intel.com>
-Date: Wed, 26 Sep 2012 17:30:40 +0200
-Subject: [PATCH 10/23] s_sim: Extend XSIMSTATE parsing to get SMS service
- state
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/s_sim.c | 18 ++++++++++++++++++
- 1 file changed, 18 insertions(+)
-
-diff --git a/src/s_sim.c b/src/s_sim.c
-index 1d7e5c6..7bff6dd 100644
---- a/src/s_sim.c
-+++ b/src/s_sim.c
-@@ -28,12 +28,14 @@
- #include <plugin.h>
- #include <queue.h>
- #include <co_sim.h>
-+#include <co_sms.h>
- #include <storage.h>
- #include <user_request.h>
- #include <server.h>
- #include <at.h>
-
- #include "s_common.h"
-+#include "s_sms.h"
- #include "s_sim.h"
-
- #define ID_RESERVED_AT 0x0229
-@@ -1932,6 +1934,7 @@ static gboolean on_event_pin_status(CoreObject *o, const void *event_info, void
- GSList *lines = NULL;
- const char *line = NULL;
- int sim_state = 0;
-+ int sms_state = 0;
-
- dbg(" Function entry ");
-
-@@ -1948,6 +1951,7 @@ static gboolean on_event_pin_status(CoreObject *o, const void *event_info, void
-
- if (g_slist_length(tokens) == 4) {
- sim_state = atoi(g_slist_nth_data(tokens, 1));
-+ sms_state = atoi(g_slist_nth_data(tokens, 3));
- } else if (g_slist_length(tokens) == 1)
- sim_state = atoi(g_slist_nth_data(tokens, 0));
- else {
-@@ -2023,6 +2027,20 @@ static gboolean on_event_pin_status(CoreObject *o, const void *event_info, void
- _get_sim_type(o);
- else
- _sim_status_update(o, sim_status);
-+
-+ if (sms_state) {
-+ struct tnoti_sms_ready_status readyStatusInfo = {0, };
-+ CoreObject *sms;
-+ TcorePlugin *plugin;
-+
-+ dbg("SMS Ready");
-+ readyStatusInfo.status = TRUE;
-+ plugin = tcore_object_ref_plugin(o);
-+ sms = tcore_plugin_ref_core_object(plugin, "umts_sms");
-+ tcore_sms_set_ready_status(sms, readyStatusInfo.status);
-+
-+ tcore_server_send_notification(tcore_plugin_ref_server(plugin), sms, TNOTI_SMS_DEVICE_READY, sizeof(struct tnoti_sms_ready_status), &readyStatusInfo);
-+ }
- break;
-
- case SIM_STATUS_INITIALIZING:
---
-1.7.10.4
-
+++ /dev/null
-From ee0731a4b1c6cb4727910320d9b8e5f96bad9f4b Mon Sep 17 00:00:00 2001
-From: Caiwen Zhang <caiwen.zhang@intel.com>
-Date: Fri, 28 Sep 2012 18:28:10 +0800
-Subject: [PATCH 11/23] set modem power saving mode
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/s_modem.c | 2 ++
- 1 file changed, 2 insertions(+)
-
-diff --git a/src/s_modem.c b/src/s_modem.c
-index 22adfa3..a0fe4dc 100644
---- a/src/s_modem.c
-+++ b/src/s_modem.c
-@@ -703,6 +703,8 @@ static void on_response_enable_logging(TcorePending *p, int data_len, const void
- dbg("Calling setup_mux");
- setup_mux(tcore_pending_ref_core_object(p));
-
-+ /* sets the powersaving-mode */
-+ prepare_and_send_pending_request(plugin, "modem", "at+xpow=0,0,0", NULL, TCORE_AT_NO_RESULT, NULL);
-
- dbg("Exit");
- return;
---
-1.7.10.4
-
+++ /dev/null
-From 3b7a430088ee269c53bb3d107ad13da23e795a7b Mon Sep 17 00:00:00 2001
-From: Caiwen Zhang <caiwen.zhang@intel.com>
-Date: Fri, 28 Sep 2012 18:31:58 +0800
-Subject: [PATCH 12/23] Fix EFsmsp size error
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-EFsmsp record size 28 + Y (Y is the bytes remained for saving alpha
-id). Y always be (record size - 28), it doesn't depends on the alpha
-string length, if the alpha string is longer than Y, the string should
-be cut short, if it is shorter than Y, should padding with 0xFF.
----
- src/s_sms.c | 15 ++++++++++-----
- 1 file changed, 10 insertions(+), 5 deletions(-)
-
-diff --git a/src/s_sms.c b/src/s_sms.c
-index 2b3cd4f..20067a3 100644
---- a/src/s_sms.c
-+++ b/src/s_sms.c
-@@ -3046,6 +3046,7 @@ static TReturn set_sms_params(CoreObject *obj, UserRequest *ur)
- char *encoded_data = NULL;
- unsigned char *temp_data = NULL;
- int SMSPRecordLen = 0;
-+ int *smsp_record_len;
-
- TcoreHal *hal = NULL;
- TcoreATRequest *atreq = NULL;
-@@ -3067,11 +3068,15 @@ static TReturn set_sms_params(CoreObject *obj, UserRequest *ur)
- return TCORE_RETURN_ENOSYS;
- }
-
-- //EFsmsp file size is 28 +Y bytes (Y is alpha id size)
-- SMSPRecordLen = 28 + setSmsParams->params.alphaIdLen;
-- temp_data = calloc(SMSPRecordLen,1);
-- encoded_data = calloc(SMSPRecordLen*2 + 1,1);
--
-+ // EFsmsp file size is 28 +Y bytes (Y is alpha id size)
-+ smsp_record_len = tcore_plugin_ref_property(tcore_object_ref_plugin(obj), "SMSPRECORDLEN");
-+ SMSPRecordLen = *smsp_record_len;
-+ if (SMSPRecordLen < nDefaultSMSPWithoutAlphaId)
-+ return FALSE;
-+
-+ temp_data = calloc(SMSPRecordLen, 1);
-+ encoded_data = calloc(SMSPRecordLen * 2 + 1, 1);
-+
- _tcore_util_sms_encode_smsParameters(&(setSmsParams->params), temp_data, SMSPRecordLen);
-
- util_byte_to_hex((const char *)temp_data, (char *)encoded_data,SMSPRecordLen);
---
-1.7.10.4
-
+++ /dev/null
-From 2a49ea5039f838a3bad9d08cb80284e66c7cc97d Mon Sep 17 00:00:00 2001
-From: Nicolas Bertrand <nicolas.bertrand@linux.intel.com>
-Date: Wed, 3 Oct 2012 15:07:16 +0200
-Subject: [PATCH 13/23] s_call: use hal set sound path function
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/s_call.c | 339 ++++++++++++++++------------------------------------------
- 1 file changed, 92 insertions(+), 247 deletions(-)
-
-diff --git a/src/s_call.c b/src/s_call.c
-index e48e900..2a2b027 100644
---- a/src/s_call.c
-+++ b/src/s_call.c
-@@ -23,6 +23,8 @@
- #include <stdlib.h>
- #include <string.h>
- #include <glib.h>
-+#include <unistd.h>
-+
-
- #include <tcore.h>
- #include <hal.h>
-@@ -43,9 +45,10 @@
- #define STATUS_CONNECTED 7
- #define COMMA 0X2c
-
--static gboolean setsoundpath = FALSE;
- static gboolean soundvolume = FALSE;
-
-+extern void prepare_and_send_pending_request(TcorePlugin *plugin, char *co_name, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, TcorePendingResponseCallback callback);
-+
- // End Cause field - Call state end cause
-
- typedef enum {
-@@ -372,6 +375,66 @@ static gboolean on_notification_call_clip_info(CoreObject *o, const void *data,
- return TRUE;
- }
-
-+static gboolean on_notification_call_audio_info(CoreObject *o, const void *data, void *user_data)
-+{
-+ GSList *tokens = NULL;
-+ GSList *lines = NULL;
-+ TcoreHal *hal = NULL;
-+ const char *line = NULL;
-+ char *stat;
-+ int status;
-+ TcorePlugin *plugin;
-+
-+ dbg("Entry");
-+
-+ lines = (GSList *) data;
-+ if (1 != g_slist_length(lines)) {
-+ err("Unsolicited message, BUT multiple lines present");
-+ goto OUT;
-+ }
-+
-+ line = (char *) (lines->data);
-+ tokens = tcore_at_tok_new(line);
-+
-+ stat = g_slist_nth_data(tokens, 1);
-+ if (!stat) {
-+ dbg("Stat is missing from +XPROGRESS indiaction");
-+ } else {
-+ status = atoi(stat);
-+ dbg("status = %d", status);
-+
-+ switch (status) {
-+
-+ case 11: /*igonre Connected state. */
-+ dbg("audio disconnected")
-+ plugin = tcore_object_ref_plugin(o);
-+
-+ hal = tcore_object_get_hal(o);
-+ tcore_hal_set_sound_path(hal, 0x0);
-+
-+ // amc disable
-+ usleep(1000); // Time to disable MSIC...
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,3,3", NULL, TCORE_AT_NO_RESULT, NULL); //AMC_I2S1_RX
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,3,4", NULL, TCORE_AT_NO_RESULT, NULL); //AMC_I2S2_RX
-+ // amc route: AMC_RADIO_RX => AMC_PCM_GENERALD
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,6,0,4", NULL, TCORE_AT_NO_RESULT, NULL);
-+ usleep(80000); // Time to Disable modem I2S...
-+ break;
-+
-+ default:
-+ dbg("audio continue");
-+ break;
-+ }
-+ }
-+
-+ /* Free tokens */
-+ tcore_at_tok_free(tokens);
-+
-+OUT:
-+ dbg("Exit");
-+ return TRUE;
-+}
-+
- static gboolean on_notification_call_info(CoreObject *o, const void *data, void *user_data)
- {
- GSList *tokens = NULL;
-@@ -1468,179 +1531,6 @@ static void on_confirmation_call_swap(TcorePending *p, int data_len, const void
- return;
- }
-
--static void on_confirmation_call_set_source_sound_path(TcorePending *p, int data_len, const void *data, void *user_data)
--{
-- UserRequest *ur = NULL;
-- GSList *tokens = NULL;
-- const char *line = NULL;
-- const TcoreATResponse *response = data;
-- char *resp_str = NULL;
-- struct tresp_call_sound_set_path resp;
-- gboolean error;
--
-- dbg("Entry");
-- ur = tcore_pending_ref_user_request(p);
--
-- // +XDRV: <group_id>,<function_id>,<xdrv_result>[,<response_n>]\ 3
-- if (!response) {
-- err("Input data is NULL");
-- return;
-- }
--
-- if (response->success > 0) {
-- dbg("RESPONSE OK");
--
-- line = (const char *) (((GSList *) response->lines)->data);
-- tokens = tcore_at_tok_new(line);
--
-- resp_str = g_slist_nth_data(tokens, 0);
-- if (!g_slist_nth_data(tokens, 0)) {
-- err("group_id is missing");
-- resp.err = TRUE;
-- goto OUT;
-- }
--
-- if (!g_slist_nth_data(tokens, 1)) {
-- err(" function_id is missing");
-- resp.err = TRUE;
-- goto OUT;
-- }
--
-- resp_str = g_slist_nth_data(tokens, 2);
--
-- if (resp_str) {
-- error = atoi(resp_str);
-- if (0 == error) {
-- dbg("Response is Success");
-- resp.err = FALSE;
-- } else {
-- resp.err = TRUE;
-- }
-- }
--OUT:
-- // Free tokens
-- tcore_at_tok_free(tokens);
-- } else {
-- dbg("RESPONSE NOT OK");
--
-- line = (const char *) response->final_response;
-- tokens = tcore_at_tok_new(line);
--
-- if (g_slist_length(tokens) < 1) {
-- err("err cause not specified or string corrupted");
-- resp.err = TRUE;
-- } else {
-- error = atoi(g_slist_nth_data(tokens, 0));
--
-- // TODO: CMEE error mapping is required.
-- resp.err = TRUE;
-- }
--
-- // Free tokens
-- tcore_at_tok_free(tokens);
-- }
--
-- if (ur) {
-- if ( resp.err ) { // Send only failed notification . success notification send when destination device is set.
-- // Send notification to TAPI
-- tcore_user_request_send_response(ur, TRESP_CALL_SET_SOUND_PATH, sizeof(struct tresp_call_sound_set_path), &resp);
-- setsoundpath = TRUE;
-- }
-- } else {
-- err("User Request is NULL");
-- }
--
-- dbg("Exit");
-- return;
--}
--
--static void on_confirmation_call_set_destination_sound_path(TcorePending *p, int data_len, const void *data, void *user_data)
--{
-- UserRequest *ur = NULL;
-- GSList *tokens = NULL;
-- const char *line = NULL;
-- char *resp_str = NULL;
-- struct tresp_call_sound_set_path resp;
-- const TcoreATResponse *response = data;
-- gboolean error;
--
-- dbg("Entry");
--
-- ur = tcore_pending_ref_user_request(p);
-- // +XDRV: <group_id>,<function_id>,<xdrv_result>[,<response_n>]\ 3
--
-- if (!response) {
-- err("Input data is NULL");
-- return;
-- }
--
-- if (ur) {
-- if (response->success > 0) {
-- dbg("RESPONSE OK");
--
-- line = (const char *) (((GSList *) response->lines)->data);
-- tokens = tcore_at_tok_new(line);
--
-- resp_str = g_slist_nth_data(tokens, 0);
-- if (!g_slist_nth_data(tokens, 0)) {
-- dbg("group_id is missing");
-- resp.err = TRUE;
-- goto OUT;
-- }
--
-- if (!g_slist_nth_data(tokens, 1)) {
-- dbg("function_id is missing");
-- resp.err = TRUE;
-- goto OUT;
-- }
--
-- resp_str = g_slist_nth_data(tokens, 2);
-- if (resp_str) {
-- error = atoi(resp_str);
-- if (0 == error) {
-- dbg("Response is Success");
-- resp.err = FALSE;
-- } else {
-- resp.err = TRUE;
-- }
-- }
--
--OUT:
-- // Free tokens
-- tcore_at_tok_free(tokens);
-- } else {
-- dbg("RESPONSE NOT OK");
--
-- line = (const char *) response->final_response;
-- tokens = tcore_at_tok_new(line);
--
-- if (g_slist_length(tokens) < 1) {
-- err("err cause not specified or string corrupted");
-- resp.err = TRUE;
-- } else {
-- error = atoi(g_slist_nth_data(tokens, 0));
-- // TODO: CMEE error mapping is required.
-- resp.err = TRUE;
-- }
--
-- // Free tokens
-- tcore_at_tok_free(tokens);
-- }
--
-- if (setsoundpath == TRUE) {
-- setsoundpath = FALSE;
-- } else {
-- // Send response to TAPI
-- tcore_user_request_send_response(ur, TRESP_CALL_SET_SOUND_PATH, sizeof(struct tresp_call_sound_set_path), &resp);
-- }
-- } else {
-- dbg("User Request is NULL");
-- }
--
-- dbg("Exit");
-- return;
--}
--
- static void on_confirmation_call_set_source_sound_volume_level(TcorePending *p, int data_len, const void *data, void *user_data)
- {
- UserRequest *ur = NULL;
-@@ -2978,90 +2868,44 @@ static TReturn s_call_send_dtmf(CoreObject *o, UserRequest *ur)
-
- static TReturn s_call_set_sound_path(CoreObject *o, UserRequest *ur)
- {
-- UserRequest *ur_dup = NULL;
-- TcorePending *pending = NULL, *pending1 = NULL;
-- TcoreATRequest *req, *req1;
-- char *cmd_str = NULL, *cmd_str1 = NULL;
-- int device_type = -1;
-- struct treq_call_sound_set_path *sound_path = 0;
-- gboolean ret = FALSE;
-+ struct tresp_call_sound_set_path resp;
-+ struct treq_call_sound_set_path *SoundPathP;
-+ TcoreHal *hal = NULL;
-+ TcorePlugin *plugin;
-
- dbg("function entrance");
-
-- if (FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))) {
-- dbg("cp not ready/n");
-- return TCORE_RETURN_ENOSYS;
-- }
-- sound_path = (struct treq_call_sound_set_path *) tcore_user_request_ref_data(ur, 0);
-- if (sound_path == NULL) {
-- dbg("invaling user request");
-- return TCORE_RETURN_FAILURE;
-- }
-- dbg("audio device type - 0x%x", sound_path->path);
-- switch (sound_path->path) {
-- case CALL_SOUND_PATH_HANDSET:
-- device_type = 1;
-- break;
--
-- case CALL_SOUND_PATH_HEADSET:
-- device_type = 2;
-- break;
-+ SoundPathP = (struct treq_call_sound_set_path *) tcore_user_request_ref_data(ur, 0);
-
-- case CALL_SOUND_PATH_HEADSET_3_5PI:
-- device_type = 3;
-- break;
--
-- case CALL_SOUND_PATH_SPEAKER:
-- device_type = 4;
-- break;
-+ dbg("deviceId is %d", SoundPathP->path);
-
-- case CALL_SOUND_PATH_HANDFREE:
-- device_type = 5;
-- break;
--
-- case CALL_SOUND_PATH_HEADSET_HAC:
-- device_type = 6;
-- break;
-+ plugin = tcore_object_ref_plugin(o);
-
-- case CALL_SOUND_PATH_BLUETOOTH:
-- case CALL_SOUND_PATH_STEREO_BLUETOOTH:
-- device_type = 7;
-- break;
-+ // Configure modem I2S1
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,4,3,0,1,0,8,0,1,0,2,0,21", NULL, TCORE_AT_NO_RESULT, NULL);
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,5,2,0,1,0,8,0,1,0,2,0,22", NULL, TCORE_AT_NO_RESULT, NULL);
-
-- case CALL_SOUND_PATH_BT_NSEC_OFF:
-- case CALL_SOUND_PATH_MIC1:
-- case CALL_SOUND_PATH_MIC2:
-- default:
-- dbg("unsupported device type");
-- return TCORE_RETURN_FAILURE;
-- }
-+ // Configure modem I2S2 and do the modem routing
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,4,4,0,0,0,8,0,1,0,2,0,21", NULL, TCORE_AT_NO_RESULT, NULL);
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,5,3,0,0,0,8,0,1,0,2,0,22", NULL, TCORE_AT_NO_RESULT, NULL);
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,6,0,4", NULL, TCORE_AT_NO_RESULT, NULL);
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,6,3,0", NULL, TCORE_AT_NO_RESULT, NULL);
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,6,4,2", NULL, TCORE_AT_NO_RESULT, NULL);
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,6,5,2", NULL, TCORE_AT_NO_RESULT, NULL);
-
-- cmd_str = g_strdup_printf("AT+XDRV=40,4,3,0,0,0,0,0,1,0,1,0,%d",device_type); // source type.
-- pending = tcore_pending_new(o, 0);
-- req = tcore_at_request_new(cmd_str, "+XDRV", TCORE_AT_SINGLELINE);
-- dbg("XDRV req-cmd for source type : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
-- tcore_pending_set_request_data(pending, 0, req);
-- ur_dup = tcore_user_request_ref(ur);
-- ret = _call_request_message(pending, o, ur_dup, on_confirmation_call_set_source_sound_path, NULL);
-- g_free(cmd_str);
-+ // amc enable
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,2,4", NULL, TCORE_AT_NO_RESULT, NULL); //AMC_I2S2_RX
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,2,3", NULL, TCORE_AT_NO_RESULT, NULL); //AMC_I2S1_RX
-+ // amc route: AMC_RADIO_RX => AMC_I2S1_TX
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,6,0,2", NULL, TCORE_AT_NO_RESULT, NULL);
-
-- if (!ret) {
-- dbg("At request(%s) sent failed", req->cmd);
-- return TCORE_RETURN_FAILURE;
-- }
-+ usleep(40000); // Time to Enable modem I2S...
-
-- cmd_str1 = g_strdup_printf("AT+XDRV=40,5,2,0,0,0,0,0,1,0,1,0,%d",device_type); // destination type
-- pending1 = tcore_pending_new(o, 0);
-- req1 = tcore_at_request_new(cmd_str1, "+XDRV", TCORE_AT_SINGLELINE);
-- dbg("XDRV req-cmd for destination type : %s, prefix(if any) :%s, cmd_len : %d", req1->cmd, req1->prefix, strlen(req1->cmd));
-- tcore_pending_set_request_data(pending1, 0, req1);
-- ret = _call_request_message(pending1, o, ur, on_confirmation_call_set_destination_sound_path, NULL);
-- g_free(cmd_str1);
-+ hal = tcore_object_get_hal(o);
-+ tcore_hal_set_sound_path(hal, SoundPathP->path);
-
-- if (!ret) {
-- dbg("AT request %s has failed ", req1->cmd);
-- return TCORE_RETURN_FAILURE;
-- }
-+ resp.err = TCORE_RETURN_SUCCESS;
-+ tcore_user_request_send_response(ur, TRESP_CALL_SET_SOUND_PATH, sizeof(struct tresp_call_sound_set_path), &resp);
-
- return TCORE_RETURN_SUCCESS;
- }
-@@ -4060,6 +3904,7 @@ gboolean s_call_init(TcorePlugin *p, TcoreHal *h)
- // Add Callbacks
- tcore_object_add_callback(o, "+XCALLSTAT", on_notification_call_info, NULL);
- tcore_object_add_callback(o, "+CLIP", on_notification_call_clip_info, NULL);
-+ tcore_object_add_callback(o, "+XPROGRESS", on_notification_call_audio_info, NULL);
-
- // User Data
- data = calloc(sizeof(struct property_call_info *), 1);
---
-1.7.10.4
-
+++ /dev/null
-From 96005a4ba04e16b3ae22db6b6f71ea54c88257c8 Mon Sep 17 00:00:00 2001
-From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
-Date: Mon, 8 Oct 2012 15:41:21 +0200
-Subject: [PATCH 14/23] Add core objects and link them to HAL
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-Conflicts:
- src/s_modem.c
----
- src/s_call.c | 7 +++----
- src/s_modem.c | 8 ++++++--
- src/s_network.c | 4 +++-
- src/s_ps.c | 5 ++++-
- src/s_sat.c | 4 +++-
- src/s_sim.c | 4 +++-
- src/s_sms.c | 4 +++-
- src/s_ss.c | 4 +++-
- 8 files changed, 28 insertions(+), 12 deletions(-)
-
-diff --git a/src/s_call.c b/src/s_call.c
-index 2a2b027..2d2b711 100644
---- a/src/s_call.c
-+++ b/src/s_call.c
-@@ -272,7 +272,6 @@ const call_end_cause_info call_end_cause_table[] = // call end cause table to
- static enum tcore_call_cli_mode _get_clir_status(char *num)
- {
- enum tcore_call_cli_mode clir = CALL_CLI_MODE_DEFAULT;
--
- dbg("Entry");
-
- if (!strncmp(num, "*31#", 4)) {
-@@ -3888,16 +3887,17 @@ gboolean s_call_init(TcorePlugin *p, TcoreHal *h)
- {
- CoreObject *o = NULL;
- struct property_call_info *data = NULL;
--
- dbg("Entry");
-
- // Creating Call COre object
-- o = tcore_call_new(p, "call", &call_ops, h);
-+ o = tcore_call_new(p, "call", &call_ops, NULL);
- if (!o) {
- err("Failed to create Call Core Object");
- return FALSE;
- }
-
-+ tcore_hal_link_object(h, o);
-+
- // Set Call Operations
- tcore_call_information_set_operations(o, &call_information_ops);
-
-@@ -3918,7 +3918,6 @@ void s_call_exit(TcorePlugin *p)
- {
- CoreObject *o = NULL;
- struct property_network_info *data = NULL;
--
- dbg("Entry");
-
- o = tcore_plugin_ref_core_object(p, "call");
-diff --git a/src/s_modem.c b/src/s_modem.c
-index a0fe4dc..6212467 100644
---- a/src/s_modem.c
-+++ b/src/s_modem.c
-@@ -163,7 +163,7 @@ void prepare_and_send_pending_request(TcorePlugin *plugin, char *co_name, const
- tcore_pending_set_request_data(pending, 0, req);
- tcore_pending_set_response_callback(pending, callback, NULL);
- tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL);
-- tcore_pending_link_user_request(pending, NULL); // set user request to NULL - this is intenal request
-+ tcore_pending_link_user_request(pending, NULL); // set user request to NULL - this is internal request
- ret = tcore_hal_send_request(hal, pending);
- return;
- }
-@@ -941,10 +941,14 @@ gboolean s_modem_init(TcorePlugin *p, TcoreHal *h)
- TelMiscSNInformation *imei_property = NULL;
- TelMiscSNInformation *sn_property = NULL;
-
-- o = tcore_modem_new(p, "modem", &modem_ops, h);
-+ dbg("Entry");
-+
-+ o = tcore_modem_new(p, "modem", &modem_ops, NULL);
- if (!o)
- return FALSE;
-
-+ tcore_hal_link_object(h, o);
-+
- work_queue = g_queue_new();
- tcore_object_link_user_data(o, work_queue);
-
-diff --git a/src/s_network.c b/src/s_network.c
-index 7c5e8d9..0cbdc23 100644
---- a/src/s_network.c
-+++ b/src/s_network.c
-@@ -2169,10 +2169,12 @@ gboolean s_network_init(TcorePlugin *p, TcoreHal *h)
- {
- CoreObject *o = NULL;
-
-- o = tcore_network_new(p, "umts_network", &network_ops, h);
-+ o = tcore_network_new(p, "umts_network", &network_ops, NULL);
- if (!o)
- return FALSE;
-
-+ tcore_hal_link_object(h, o);
-+
- tcore_object_add_callback(o, "+CREG", on_event_cs_network_regist, NULL);
- tcore_object_add_callback(o, "+CGREG", on_event_ps_network_regist, NULL);
- tcore_object_add_callback(o, "+XCIEV", on_event_network_icon_info, NULL);
-diff --git a/src/s_ps.c b/src/s_ps.c
-index e87e943..78bb9c7 100644
---- a/src/s_ps.c
-+++ b/src/s_ps.c
-@@ -945,10 +945,13 @@ gboolean s_ps_init(TcorePlugin *p, TcoreHal *hal)
- struct context *context_table = NULL;
-
- dbg("Entered");
-- o = tcore_ps_new(p, "umts_ps", &ps_ops, hal);
-+ o = tcore_ps_new(p, "umts_ps", &ps_ops, NULL);
-
- if (!o)
- return FALSE;
-+
-+ tcore_hal_link_object(hal, o);
-+
- tcore_object_link_user_data(o, (void *) context_table);
-
- tcore_object_add_callback(o, "+CGEV", on_event_cgev_handle, p);
-diff --git a/src/s_sat.c b/src/s_sat.c
-index ebacea0..774388c 100644
---- a/src/s_sat.c
-+++ b/src/s_sat.c
-@@ -451,12 +451,14 @@ gboolean s_sat_init(TcorePlugin *p, TcoreHal *h)
- CoreObject *o = NULL;
-
- dbg("Entry");
-- o = tcore_sat_new(p, "sat", &sat_ops, h);
-+ o = tcore_sat_new(p, "sat", &sat_ops, NULL);
- if (!o) {
- dbg("CoreObject NULL !!");
- return FALSE;
- }
-
-+ tcore_hal_link_object(h, o);
-+
- tcore_object_add_callback(o, "+SATI", on_event_sat_proactive_command, NULL);
- tcore_object_add_callback(o, "+SATN", on_event_sat_proactive_command, NULL);
- tcore_object_add_callback(o, "+SATF", on_response_terminal_response_confirm, NULL);
-diff --git a/src/s_sim.c b/src/s_sim.c
-index 7bff6dd..a74bf7c 100644
---- a/src/s_sim.c
-+++ b/src/s_sim.c
-@@ -3336,11 +3336,13 @@ gboolean s_sim_init(TcorePlugin *p, TcoreHal *h)
-
- dbg("entry");
-
-- o = tcore_sim_new(p, "sim", &sim_ops, h);
-+ o = tcore_sim_new(p, "sim", &sim_ops, NULL);
-
- if (!o)
- return FALSE;
-
-+ tcore_hal_link_object(h, o);
-+
- file_meta = calloc(sizeof(struct s_sim_property), 1);
- if (!file_meta)
- return FALSE;
-diff --git a/src/s_sms.c b/src/s_sms.c
-index 20067a3..06b4dcd 100644
---- a/src/s_sms.c
-+++ b/src/s_sms.c
-@@ -3207,7 +3207,7 @@ gboolean s_sms_init(TcorePlugin *plugin, TcoreHal *hal)
- dbg("plugin: [%p]", plugin);
- dbg("hal: [%p]", hal);
-
-- obj = tcore_sms_new(plugin, "umts_sms", &sms_ops, hal);
-+ obj = tcore_sms_new(plugin, "umts_sms", &sms_ops, NULL);
-
- data = calloc(sizeof(struct property_sms_info), 1);
-
-@@ -3219,6 +3219,8 @@ gboolean s_sms_init(TcorePlugin *plugin, TcoreHal *hal)
- return FALSE;
- }
-
-+ tcore_hal_link_object(hal, obj);
-+
- work_queue = g_queue_new();
- tcore_object_link_user_data(obj, work_queue);
-
-diff --git a/src/s_ss.c b/src/s_ss.c
-index 0781ac7..7a7e050 100644
---- a/src/s_ss.c
-+++ b/src/s_ss.c
-@@ -2756,7 +2756,7 @@ gboolean s_ss_init(TcorePlugin *p, TcoreHal *h)
- CoreObject *so = 0, *co = 0;
- struct property_call_info *data = 0;
-
-- so = tcore_ss_new(p, "ss", &ss_ops, h);
-+ so = tcore_ss_new(p, "ss", &ss_ops, NULL);
- if (!so) {
- dbg("[ error ] ss_new()");
- return FALSE;
-@@ -2768,6 +2768,8 @@ gboolean s_ss_init(TcorePlugin *p, TcoreHal *h)
- return FALSE;
- }
-
-+ tcore_hal_link_object(h, so);
-+
- tcore_call_control_set_operations(co, &call_ops);
-
- tcore_object_add_callback(so, "+CSSU", on_notification_ss_info, 0);
---
-1.7.10.4
-
+++ /dev/null
-From 658e94ca29da1e7fc52b036a4dc231db1500f3ff Mon Sep 17 00:00:00 2001
-From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
-Date: Mon, 8 Oct 2012 15:42:12 +0200
-Subject: [PATCH 15/23] Change the way imc plugin is initialized
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-Conflicts:
- src/desc.c
- src/s_modem.c
----
- src/desc.c | 90 ++++++++++++++++++---------------------------------------
- src/s_modem.c | 69 +------------------------------------------
- 2 files changed, 29 insertions(+), 130 deletions(-)
-
-diff --git a/src/desc.c b/src/desc.c
-index 7a5ef93..0cf4542 100644
---- a/src/desc.c
-+++ b/src/desc.c
-@@ -44,51 +44,6 @@
- #include "s_gps.h"
-
- static char *cp_name;
--static int cp_count = 0;
--
--#define MAX_CP_QUERY_COUNT 60
--
--static gboolean _query_cp_state(gpointer data)
--{
-- gboolean power_state = FALSE;
-- TcorePlugin *p = NULL;
-- CoreObject* obj = NULL;
-- TcoreHal* h = NULL;
--
-- p = (TcorePlugin*)data;
--
-- if(cp_count > MAX_CP_QUERY_COUNT){
-- dbg("cp query counter exceeds MAX_CP_QUERY_COUNT");
-- return FALSE;
-- }
-- obj = tcore_plugin_ref_core_object(p, "modem");
-- h = tcore_object_get_hal(obj);
-- power_state = tcore_hal_get_power_state(h);
--
-- if(TRUE == power_state){
-- dbg("CP READY");
-- s_modem_send_poweron(p);
-- return FALSE;
-- }
-- else{
-- dbg("CP NOT READY, cp_count :%d", cp_count);
-- cp_count++;
-- return TRUE;
-- }
--}
--
--static enum tcore_hook_return on_hal_send(TcoreHal *hal, unsigned int data_len, void *data, void *user_data)
--{
-- hook_hex_dump(TX, data_len, data);
-- return TCORE_HOOK_RETURN_CONTINUE;
--}
--
--static void on_hal_recv(TcoreHal *hal, unsigned int data_len, const void *data, void *user_data)
--{
-- msg("=== RX data DUMP =====");
-- util_hex_dump(" ", data_len, data);
-- msg("=== RX data DUMP =====");
--}
-
- static gboolean on_load()
- {
-@@ -126,7 +81,7 @@ static int _get_cp_name(char **name)
- dbg("u.__domainname : [ %s ]", u.__domainname);
- dbg("u.machine : [ %s ]", u.machine);
- dbg("u.release : [ %s ]", u.release);
-- dbg("u.sysname : [ %s ]", u.sysname);S
-+ dbg("u.sysname : [ %s ]", u.sysname);
- dbg("u.version : [ %s ]", u.version);
-
- /* By default, SUNRISE IMC modem is returned */
-@@ -165,11 +120,35 @@ static int _get_cp_name(char **name)
- return 0;
- }
-
-+static void on_hal_set_power(TcoreHal *hal, void *user_data)
-+{
-+ TcorePlugin *p = user_data;
-+ CoreObject *o;
-+
-+ dbg("Entry");
-+
-+ s_modem_init(p, hal);
-+ s_sim_init(p, hal);
-+ s_sat_init(p, hal);
-+ s_network_init(p, hal);
-+ s_ps_init(p, hal);
-+ s_call_init(p, hal);
-+ s_ss_init(p, hal);
-+ s_sms_init(p, hal);
-+ s_gps_init(p, hal);
-+
-+ o = tcore_plugin_ref_core_object(p, "modem");
-+ tcore_server_send_notification(tcore_plugin_ref_server(p), o, TNOTI_MODEM_ADDED, 0, NULL);
-+
-+ s_modem_send_poweron(p);
-+
-+ dbg("Exit");
-+}
-+
- static gboolean on_init(TcorePlugin *p)
- {
- TcoreHal *h;
- struct global_data *gd;
-- // char *cp_name = 0;
- int len = 0;
-
- if (!p)
-@@ -208,25 +187,12 @@ static gboolean on_init(TcorePlugin *p)
-
- tcore_plugin_link_user_data(p, gd);
-
-- tcore_hal_add_send_hook(h, on_hal_send, p);
-- tcore_hal_add_recv_callback(h, on_hal_recv, p);
-+ g_free(cp_name);
-
-- s_modem_init(p, h);
-- s_sim_init(p, h);
-- s_sat_init(p, h);
-- s_network_init(p, h);
-- s_ps_init(p, h);
-- s_call_init(p, h);
-- s_ss_init(p, h);
-- s_sms_init(p, h);
-- s_phonebook_init(p, h);
-- s_sap_init(p, h);
-+ tcore_hal_set_power(h, TRUE, on_hal_set_power, p);
-
- g_free(cp_name);
-
-- tcore_hal_set_power(h, TRUE);
-- //wait until CP is ready
-- g_timeout_add_full(G_PRIORITY_HIGH,500,_query_cp_state, p, 0 );
- return TRUE;
- }
-
-diff --git a/src/s_modem.c b/src/s_modem.c
-index 6212467..47c6c63 100644
---- a/src/s_modem.c
-+++ b/src/s_modem.c
-@@ -616,69 +616,6 @@ static void _modem_subscribe_events(TcorePlugin *plugin)
- return;
- }
-
--
--static void on_response_setupmux(TcorePending *p, int data_len, const void *data, void *user_data)
--{
-- TcorePlugin *plugin = NULL;
-- TcoreHal *hal = NULL;
-- TReturn ret;
-- dbg("Entry");
--
-- /* IMC Plugin dereferenced from pending request */
-- plugin = tcore_pending_ref_plugin(p);
--
-- /* Actual HAL - like svnet(2) */
-- hal = (TcoreHal *) user_data;
--
-- /* Initialize CMUX */
-- ret = tcore_cmux_init(plugin, hal);
-- if (TCORE_RETURN_SUCCESS == ret) {
-- dbg("Successfully initialized CMUX");
-- } else {
-- err("Failed to initialize CMUX");
-- }
--
-- dbg("Exit");
-- return;
--}
--
--
--
--static void setup_mux(CoreObject *o)
--{
-- TcoreHal *hal = NULL;
-- TcorePending *pending = NULL;
-- dbg("Entered");
--
-- /* HAL has type itself,
-- * e.g.) TCORE_HAL_MODE_AT
-- */
-- hal = tcore_object_get_hal(o);
--
-- pending = tcore_at_pending_new(o, "AT+CMUX=0,0,,1509,10,3,30,,", "+CMUX", TCORE_AT_NO_RESULT, on_response_setupmux, hal);
--
-- tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL);
--
-- /* Send callback */
-- tcore_hal_send_request(hal, pending);
--
-- dbg("Exit");
-- return;
--}
--
--
--static gboolean on_event_mux_channel_up(CoreObject *o, const void *event_info, void *user_data)
--{
-- TcorePlugin *plugin = NULL;
-- dbg("Entry");
--
-- plugin = (TcorePlugin *) user_data;
-- _modem_subscribe_events(plugin);
-- dbg("Exit");
-- return TRUE;
--}
--
--
- static void on_response_enable_logging(TcorePending *p, int data_len, const void *data, void *user_data)
- {
- const TcoreATResponse *resp = data;
-@@ -700,8 +637,7 @@ static void on_response_enable_logging(TcorePending *p, int data_len, const void
- dbg("Enabling CP logging is failed !!!\n");
- }
-
-- dbg("Calling setup_mux");
-- setup_mux(tcore_pending_ref_core_object(p));
-+ _modem_subscribe_events(plugin);
-
- /* sets the powersaving-mode */
- prepare_and_send_pending_request(plugin, "modem", "at+xpow=0,0,0", NULL, TCORE_AT_NO_RESULT, NULL);
-@@ -961,9 +897,6 @@ gboolean s_modem_init(TcorePlugin *p, TcoreHal *h)
- sn_property = calloc(sizeof(TelMiscSNInformation), 1);
- tcore_plugin_link_property(p, "SN", sn_property);
-
-- dbg("Registerind for CMUX-UP event");
-- tcore_object_add_callback(o, "CMUX-UP", on_event_mux_channel_up, p);
--
- dbg("Registering for +XSIM event");
- tcore_object_add_callback(o, "+XSIM", on_event_bootup_sim_status, NULL);
-
---
-1.7.10.4
-
+++ /dev/null
-From 18cd0f7d5a979252b30a35537fa3bbaea60fdc5f Mon Sep 17 00:00:00 2001
-From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
-Date: Wed, 10 Oct 2012 11:32:22 +0200
-Subject: [PATCH 16/23] s_ps: Remove plateform dependencies to setup pdp
- context
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/s_ps.c | 130 +++++++++++++++++++++++++++++-------------------------------
- 1 file changed, 62 insertions(+), 68 deletions(-)
-
-diff --git a/src/s_ps.c b/src/s_ps.c
-index 78bb9c7..107d672 100644
---- a/src/s_ps.c
-+++ b/src/s_ps.c
-@@ -43,11 +43,6 @@
- #include "s_common.h"
- #include "s_ps.h"
-
--
--
--#define VNET_CH_PATH_BOOT0 "/dev/umts_boot0"
--#define IOCTL_CG_DATA_SEND _IO('o', 0x37)
--
- /*Invalid Session ID*/
- #define PS_INVALID_CID 999 /*Need to check */
-
-@@ -61,6 +56,7 @@
- #define AT_XDNS_ENABLE 1
- #define AT_XDNS_DISABLE 0
- #define AT_SESSION_DOWN 0
-+
- static void _ps_free(void *ptr)
- {
- dbg("Entered");
-@@ -83,33 +79,6 @@ static void _unable_to_get_pending(CoreObject *co_ps, CoreObject *ps_context)
- (void) tcore_context_set_state(ps_context, CONTEXT_STATE_DEACTIVATED);
- dbg("Exit");
- }
--static TReturn _pdp_device_control(unsigned int cid)
--{
-- int fd = -1;
-- int ret = -1;
-- fd = open(VNET_CH_PATH_BOOT0, O_RDWR);
-- if (fd < 0) {
-- dbg("error : open [ %s ] [ %s ]", VNET_CH_PATH_BOOT0, strerror(errno));
-- return -1;
-- }
-- /*To Do for different Cids*/
-- dbg("Send IOCTL: arg 0x05 (0101) HSIC1, cid=%d \n", cid);
-- if (cid == 1) {
-- ret = ioctl(fd, IOCTL_CG_DATA_SEND, 0x05);
-- } else if (cid == 2) {
-- ret = ioctl(fd, IOCTL_CG_DATA_SEND, 0xA);
-- } else {
-- dbg("More Than 2 context are not supported right Now");
-- }
-- close(fd);
-- if (ret < 0) {
-- dbg("[ error ] send IOCTL_CG_DATA_SEND (0x%x) fail!! \n", IOCTL_CG_DATA_SEND);
-- return TCORE_RETURN_FAILURE;
-- } else {
-- dbg("[ ok ] send IOCTL_CG_DATA_SEND (0x%x) success!! \n", IOCTL_CG_DATA_SEND);
-- return TCORE_RETURN_SUCCESS;
-- }
--}
-
- static gboolean on_event_cgev_handle(CoreObject *co_ps, const void *data, void *user_data)
- {
-@@ -445,10 +414,15 @@ static void on_response_deactivate_ps_context(TcorePending *p, int data_len, con
-
- cid = tcore_context_get_id(ps_context);
- if (resp->success) {
-+ char *devname = tcore_context_get_ipv4_devname(ps_context);
-+
- dbg("Response OK");
- /*get the data usage and report it application*/
- (void) send_data_counter_command(co_ps, ps_context);
- /*get the HSDPA status and report it to server*/
-+ dbg("Removing interface %s", devname);
-+ if (tcore_util_netif_down(devname) != TCORE_RETURN_SUCCESS)
-+ dbg("util_netif_down() failed.");
- } else {
- dbg("Response NOK");
- send_undefine_context_cmd(co_ps, ps_context);
-@@ -489,11 +463,38 @@ static TReturn deactivate_ps_context(CoreObject *co_ps, CoreObject *ps_context,
- return TCORE_RETURN_FAILURE;
- }
-
--static void on_response_get_dns_cmnd(TcorePending *p, int data_len, const void *data, void *user_data)
-+static void on_setup_pdp(CoreObject *co_ps, const char *iname, void *user_data)
- {
-- struct tnoti_ps_pdp_ipconfiguration noti = {0};
-+ struct tnoti_ps_pdp_ipconfiguration *noti = user_data;
- struct tnoti_ps_call_status data_status = {0};
-- char devname[10] = {0, };
-+
-+ dbg("entry");
-+
-+ memcpy(¬i->devname, iname, strlen(iname));
-+ dbg("devname = [%s]", iname);
-+ if (tcore_util_netif_up(iname) != TCORE_RETURN_SUCCESS) {
-+ dbg("util_netif_up() failed.");
-+ }
-+
-+ dbg("Send Notification upwards of IP address");
-+ tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_ps)), co_ps, TNOTI_PS_PDP_IPCONFIGURATION,
-+ sizeof(struct tnoti_ps_pdp_ipconfiguration), noti);
-+
-+ data_status.context_id = noti->context_id;
-+ data_status.state = 1;
-+ data_status.result = 0;
-+
-+ tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_ps)), co_ps,
-+ TNOTI_PS_CALL_STATUS, sizeof(struct tnoti_ps_call_status), &data_status);
-+
-+ g_free(noti);
-+
-+ dbg("exit");
-+}
-+
-+static void on_response_get_dns_cmnd(TcorePending *p, int data_len, const void *data, void *user_data)
-+{
-+ struct tnoti_ps_pdp_ipconfiguration *noti;
- char *dns_prim = NULL;
- char *dns_sec = NULL;
- char *pdp_address = NULL;
-@@ -512,6 +513,14 @@ static void on_response_get_dns_cmnd(TcorePending *p, int data_len, const void *
- const TcoreATResponse *resp = data;
- CoreObject *co_ps = tcore_pending_ref_core_object(p);
- int cid = tcore_context_get_id(ps_context);
-+ TcorePlugin *plugin = tcore_object_ref_plugin(co_ps);
-+ TcoreHal *h;
-+ struct global_data *gd;
-+
-+ noti = g_new0(struct tnoti_ps_pdp_ipconfiguration, 1);
-+
-+ gd = tcore_plugin_ref_user_data(plugin);
-+ h = gd->hal;
-
- dbg("Entered");
-
-@@ -548,7 +557,7 @@ static void on_response_get_dns_cmnd(TcorePending *p, int data_len, const void *
- index = 0;
- token_add = strtok(dns_prim, ".");
- while (token_add != NULL) {
-- noti.primary_dns[index++] = atoi(token_add);
-+ noti->primary_dns[index++] = atoi(token_add);
- token_add = strtok(NULL, ".");
- }
- _ps_free(dns_prim);
-@@ -563,7 +572,7 @@ static void on_response_get_dns_cmnd(TcorePending *p, int data_len, const void *
- index = 0;
- token_add = strtok(dns_sec, ".");
- while (token_add != NULL) {
-- noti.secondary_dns[index++] = atoi(token_add);
-+ noti->secondary_dns[index++] = atoi(token_add);
- token_add = strtok(NULL, ".");
- }
- _ps_free(dns_sec);
-@@ -580,15 +589,15 @@ exit_fail:
- {
- dbg("Adding default DNS");
- dbg("Adding the Primary DNS");
-- noti.primary_dns[0] = 8;
-- noti.primary_dns[1] = 8;
-- noti.primary_dns[2] = 8;
-- noti.primary_dns[3] = 8;
-+ noti->primary_dns[0] = 8;
-+ noti->primary_dns[1] = 8;
-+ noti->primary_dns[2] = 8;
-+ noti->primary_dns[3] = 8;
- dbg("Adding Secondary DNS");
-- noti.secondary_dns[0] = 8;
-- noti.secondary_dns[1] = 8;
-- noti.secondary_dns[2] = 4;
-- noti.secondary_dns[3] = 4;
-+ noti->secondary_dns[0] = 8;
-+ noti->secondary_dns[1] = 8;
-+ noti->secondary_dns[2] = 4;
-+ noti->secondary_dns[3] = 4;
- }
- exit_success:
- {
-@@ -606,32 +615,17 @@ exit_success:
- }
- _ps_free(pdp_address);
- _ps_free((void *) token_pdp_address);
-- noti.field_flag = (0x0001 & 0x0002 & 0x0004);
-- noti.err = 0;
-- noti.context_id = cid;
-- memcpy(¬i.ip_address, &addr, 4);
-- if (_pdp_device_control(cid) != TCORE_RETURN_SUCCESS) {
-- dbg("_pdp_device_control() failed. errno=%d", errno);
-- }
-- snprintf(devname, 10, "pdp%d", cid - 1);
-- memcpy(noti.devname, devname, 10);
-- dbg("devname = [%s]", devname);
-- if (tcore_util_netif_up(devname) != TCORE_RETURN_SUCCESS) {
-- dbg("util_netif_up() failed. errno=%d", errno);
-- }
--
-- dbg("Send Notification upwards of IP address");
-- tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_ps)), co_ps, TNOTI_PS_PDP_IPCONFIGURATION,
-- sizeof(struct tnoti_ps_pdp_ipconfiguration), ¬i);
-+ noti->field_flag = (0x0001 & 0x0002 & 0x0004);
-+ noti->err = 0;
-+ noti->context_id = cid;
-+ memcpy(¬i->ip_address, &addr, 4);
-
-- data_status.context_id = cid;
-- data_status.state = 1;
-- data_status.result = 0;
-+ if (tcore_hal_setup_pdp(h, co_ps, on_setup_pdp, noti, cid) != TCORE_RETURN_SUCCESS) {
-+ err("setup PDP context failed");
-+ return;
-+ }
-
-- tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(co_ps)), co_ps,
-- TNOTI_PS_CALL_STATUS, sizeof(struct tnoti_ps_call_status), &data_status);
- dbg("EXIT : Without error");
-- return;
- }
- }
-
---
-1.7.10.4
-
+++ /dev/null
-From ddcdf41b670a51aee4f30bd3dc2574836e6e324b Mon Sep 17 00:00:00 2001
-From: Caiwen Zhang <caiwen.zhang@intel.com>
-Date: Fri, 19 Oct 2012 23:16:45 +0800
-Subject: [PATCH 17/23] Fix the issue that system is waken up by modem
- frequently
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-Disable modem unsolicited message when screen is off, enable modem
-unsolicted message when screen is on.
-
-Conflicts:
- CMakeLists.txt
- packaging/tel-plugin-imc.spec
----
- CMakeLists.txt | 6 ++++--
- src/s_network.c | 24 ++++++++++++++++++++++++
- 2 files changed, 28 insertions(+), 2 deletions(-)
-
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 9bbaec3..101137c 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -10,13 +10,15 @@ SET(INCLUDEDIR "\${prefix}/include")
-
- # Set required packages
- INCLUDE(FindPkgConfig)
--pkg_check_modules(pkgs REQUIRED glib-2.0 tcore dlog db-util)
-+pkg_check_modules(pkgs REQUIRED glib-2.0 tcore dlog db-util libxml-2.0 vconf)
-
- FOREACH(flag ${pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
- ENDFOREACH(flag)
-
--INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/)
-+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
-+ /usr/include/libxml2
-+ )
-
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align")
-
-diff --git a/src/s_network.c b/src/s_network.c
-index 0cbdc23..ce1ce34 100644
---- a/src/s_network.c
-+++ b/src/s_network.c
-@@ -23,6 +23,8 @@
- #include <string.h>
-
- #include <glib.h>
-+#include <vconf.h>
-+#include <glib-object.h>
-
- #include <tcore.h>
- #include <hal.h>
-@@ -103,6 +105,7 @@ static unsigned int lookup_tbl_access_technology[] = {
- [AT_COPS_ACT_E_UTRAN] = NETWORK_ACT_GSM_UTRAN,
- };
-
-+extern void prepare_and_send_pending_request(TcorePlugin *plugin, char *co_name, const char *at_cmd, const char *prefix, enum tcore_at_command_type at_cmd_type, TcorePendingResponseCallback callback);
- static gboolean get_serving_network(CoreObject *o, UserRequest *ur);
-
-
-@@ -2165,6 +2168,23 @@ static struct tcore_network_operations network_ops = {
- .get_serving_network = get_serving_network,
- };
-
-+static void on_screen_status_changed(keynode_t *key, void* data)
-+{
-+ TcorePlugin *plugin = NULL;
-+ int state;
-+ dbg("Entry");
-+
-+ plugin = (TcorePlugin *) data;
-+ if( vconf_keynode_get_type(key) == VCONF_TYPE_INT) {
-+ state = vconf_keynode_get_int(key);
-+
-+ if (state == VCONFKEY_PM_STATE_NORMAL) //screen on
-+ prepare_and_send_pending_request(plugin, "umts_network", "AT+CREG=2;+XREG=2;+XCSQ=1;+XMER=1;+XFDOR=3", NULL, TCORE_AT_NO_RESULT, NULL);
-+ else if (state == VCONFKEY_PM_STATE_LCDOFF) //screen off
-+ prepare_and_send_pending_request(plugin, "umts_network", "AT+CREG=0;+XREG=0;+XCSQ=0;+XMER=0;+XFDOR=2", NULL, TCORE_AT_NO_RESULT, NULL);
-+ }
-+}
-+
- gboolean s_network_init(TcorePlugin *p, TcoreHal *h)
- {
- CoreObject *o = NULL;
-@@ -2184,6 +2204,8 @@ gboolean s_network_init(TcorePlugin *p, TcoreHal *h)
-
- tcore_server_add_notification_hook(tcore_plugin_ref_server(p), TNOTI_SIM_STATUS, on_hook_sim_init, o);
-
-+ vconf_notify_key_changed(VCONFKEY_PM_STATE, on_screen_status_changed, p);
-+
- _insert_mcc_mnc_oper_list(p, o);
-
- return TRUE;
-@@ -2193,6 +2215,8 @@ void s_network_exit(TcorePlugin *p)
- {
- CoreObject *o;
-
-+ vconf_ignore_key_changed(VCONFKEY_PM_STATE, on_screen_status_changed);
-+
- o = tcore_plugin_ref_core_object(p, "umts_network");
-
- tcore_network_free(o);
---
-1.7.10.4
-
+++ /dev/null
-From 759e70d4743828cb902f093a3cee8a7af76f2440 Mon Sep 17 00:00:00 2001
-From: "Zhang,Vivian" <vivian.zhang@intel.com>
-Date: Wed, 28 Nov 2012 21:55:54 +0800
-Subject: [PATCH 18/23] Configure modem I2s1 to 8khz,mono if routing to
- bluetooth, fixed TZSP-3943: modem configuration to
- support HFP
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/s_call.c | 18 ++++++++++++------
- 1 file changed, 12 insertions(+), 6 deletions(-)
-
-diff --git a/src/s_call.c b/src/s_call.c
-index 2d2b711..762fb24 100644
---- a/src/s_call.c
-+++ b/src/s_call.c
-@@ -2880,11 +2880,17 @@ static TReturn s_call_set_sound_path(CoreObject *o, UserRequest *ur)
-
- plugin = tcore_object_ref_plugin(o);
-
-- // Configure modem I2S1
-- prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,4,3,0,1,0,8,0,1,0,2,0,21", NULL, TCORE_AT_NO_RESULT, NULL);
-- prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,5,2,0,1,0,8,0,1,0,2,0,22", NULL, TCORE_AT_NO_RESULT, NULL);
-+ /* Configure modem I2S1 to 8khz, mono, PCM if routing to bluetooth */
-+ if (SoundPathP->path == CALL_SOUND_PATH_BLUETOOTH) {
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,4,3,0,1,0,0,0,0,0,0,0,21", NULL, TCORE_AT_NO_RESULT, NULL);
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,5,2,0,1,0,0,0,0,0,0,0,22", NULL, TCORE_AT_NO_RESULT, NULL);
-+ }
-+ else {
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,4,3,0,1,0,8,0,1,0,2,0,21", NULL, TCORE_AT_NO_RESULT, NULL);
-+ prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,5,2,0,1,0,8,0,1,0,2,0,22", NULL, TCORE_AT_NO_RESULT, NULL);
-+ }
-
-- // Configure modem I2S2 and do the modem routing
-+ /* Configure modem I2S2 and do the modem routing */
- prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,4,4,0,0,0,8,0,1,0,2,0,21", NULL, TCORE_AT_NO_RESULT, NULL);
- prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,5,3,0,0,0,8,0,1,0,2,0,22", NULL, TCORE_AT_NO_RESULT, NULL);
- prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,6,0,4", NULL, TCORE_AT_NO_RESULT, NULL);
-@@ -2892,10 +2898,10 @@ static TReturn s_call_set_sound_path(CoreObject *o, UserRequest *ur)
- prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,6,4,2", NULL, TCORE_AT_NO_RESULT, NULL);
- prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,6,5,2", NULL, TCORE_AT_NO_RESULT, NULL);
-
-- // amc enable
-+ /* amc enable */
- prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,2,4", NULL, TCORE_AT_NO_RESULT, NULL); //AMC_I2S2_RX
- prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,2,3", NULL, TCORE_AT_NO_RESULT, NULL); //AMC_I2S1_RX
-- // amc route: AMC_RADIO_RX => AMC_I2S1_TX
-+ /* amc route: AMC_RADIO_RX => AMC_I2S1_TX */
- prepare_and_send_pending_request(plugin, "call", "AT+XDRV=40,6,0,2", NULL, TCORE_AT_NO_RESULT, NULL);
-
- usleep(40000); // Time to Enable modem I2S...
---
-1.7.10.4
-
+++ /dev/null
-From b8f8e626877bc32412c18294a72c4e3c60f733bc Mon Sep 17 00:00:00 2001
-From: Philippe Nunes <philippe.nunes@linux.intel.com>
-Date: Thu, 22 Nov 2012 17:34:28 +0100
-Subject: [PATCH 19/23] s_sat.c: Fix envelope cmd and enable Setup Event List
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-The format specifier used to build the envelope command is now x86 compatible
-If the Setup Event List proactive command is not supported, it prevents to
-initiate a SAT session. So, I enabled the proactive command even though
-events are not monitored.
----
- src/s_sat.c | 7 ++++---
- 1 file changed, 4 insertions(+), 3 deletions(-)
-
-diff --git a/src/s_sat.c b/src/s_sat.c
-index 774388c..4a18518 100644
---- a/src/s_sat.c
-+++ b/src/s_sat.c
-@@ -221,7 +221,7 @@ static gboolean on_event_sat_proactive_command(CoreObject *o, const void *event_
- dbg("wrong input");
- break;
- }
-- if ((decoded_data.cmd_type == SAT_PROATV_CMD_REFRESH) || (decoded_data.cmd_type == SAT_PROATV_CMD_SETUP_EVENT_LIST)) {
-+ if (decoded_data.cmd_type == SAT_PROATV_CMD_REFRESH) {
- /*Not supported*/
- dbg("Not suported Proactive command");
- return FALSE;
-@@ -355,10 +355,11 @@ static TReturn s_envelope(CoreObject *o, UserRequest *ur)
- return TCORE_RETURN_EINVAL;
- }
- for (count = 0; count < envelope_cmd_len; count++) {
-- dbg("envelope_cmd %02x", envelope_cmd[count]);
-- sprintf(pbuffer, "%02x", envelope_cmd[count]);
-+ dbg("envelope_cmd %02hhX", envelope_cmd[count]);
-+ sprintf(pbuffer, "%02hhX", envelope_cmd[count]);
- pbuffer += 2;
- }
-+
- dbg("pbuffer %s", envelope_cmdhex);
- cmd_str = g_strdup_printf("AT+SATE=\"%s\"", envelope_cmdhex);
- req = tcore_at_request_new(cmd_str, "+SATE:", TCORE_AT_SINGLELINE);
---
-1.7.10.4
-
+++ /dev/null
-From 6c206b12570762126bf0a35f6c0054edc14aa14b Mon Sep 17 00:00:00 2001
-From: Philippe Nunes <philippe.nunes@linux.intel.com>
-Date: Fri, 11 Jan 2013 17:20:31 +0100
-Subject: [PATCH 20/23] s_sim.c: Fix get lock info
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
-The "lock_type" parameter used by the AT command AT+XPINCNT[=lock_type]
-shall be an integer type when used with our PR3 modem whereas this is
-a string for the Lunchbox modem.
----
- src/s_sim.c | 18 +++++++++---------
- 1 file changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/src/s_sim.c b/src/s_sim.c
-index a74bf7c..a96594b 100644
---- a/src/s_sim.c
-+++ b/src/s_sim.c
-@@ -2961,7 +2961,7 @@ static TReturn s_get_lock_info(CoreObject *o, UserRequest *ur)
- TcoreATRequest *req = NULL;
- TcorePending *pending = NULL;
- char *cmd_str = NULL;
-- char *lock_type = NULL;
-+ int lock_type = 0;
- const struct treq_sim_get_lock_info *req_data;
- struct s_sim_property *sp = NULL;
-
-@@ -2981,37 +2981,37 @@ static TReturn s_get_lock_info(CoreObject *o, UserRequest *ur)
-
- switch (req_data->type) {
- case SIM_FACILITY_PS:
-- lock_type = "PS";
-+ lock_type = 9; // IMSI lock
- break;
-
- case SIM_FACILITY_SC:
-- lock_type = "SC";
-+ lock_type = 1;
- break;
-
- case SIM_FACILITY_FD:
-- lock_type = "FD";
-+ lock_type = 2;
- break;
-
- case SIM_FACILITY_PN:
-- lock_type = "PN";
-+ lock_type = 5;
- break;
-
- case SIM_FACILITY_PU:
-- lock_type = "PU";
-+ lock_type = 6;
- break;
-
- case SIM_FACILITY_PP:
-- lock_type = "PP";
-+ lock_type = 7;
- break;
-
- case SIM_FACILITY_PC:
-- lock_type = "PC";
-+ lock_type = 8;
- break;
-
- default:
- break;
- }
-- cmd_str = g_strdup_printf("AT+XPINCNT =\"%s\"", lock_type);
-+ cmd_str = g_strdup_printf("AT+XPINCNT =%d", lock_type);
- req = tcore_at_request_new(cmd_str, "+XPINCNT:", TCORE_AT_SINGLELINE);
-
- dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
---
-1.7.10.4
-
+++ /dev/null
-From ea2ee872e3b4177da0665e4c1daff61ba1644599 Mon Sep 17 00:00:00 2001
-From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
-Date: Wed, 16 Jan 2013 11:55:33 +0100
-Subject: [PATCH 21/23] s_sim: Fix multiple sim facility status query
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/s_sim.c | 28 +++++++++++++---------------
- 1 file changed, 13 insertions(+), 15 deletions(-)
-
-diff --git a/src/s_sim.c b/src/s_sim.c
-index a96594b..0720bb1 100644
---- a/src/s_sim.c
-+++ b/src/s_sim.c
-@@ -2249,22 +2249,15 @@ static void on_response_get_facility_status(TcorePending *p, int data_len, const
- {
- const TcoreATResponse *resp = data;
- UserRequest *ur = NULL;
-- CoreObject *co_sim = NULL;
-- struct s_sim_property *sp = NULL;
- GSList *tokens = NULL;
-- struct tresp_sim_get_facility_status res;
-+ struct tresp_sim_get_facility_status *res = user_data;
- const char *line;
-
- dbg(" Function entry ");
-
-- co_sim = tcore_pending_ref_core_object(p);
-- sp = tcore_sim_ref_userdata(co_sim);
- ur = tcore_pending_ref_user_request(p);
-
-- memset(&res, 0, sizeof(struct tresp_sim_get_facility_status));
--
-- res.result = SIM_PIN_OPERATION_SUCCESS;
-- res.type = _sim_get_current_pin_facility(sp->current_sec_op);
-+ res->result = SIM_PIN_OPERATION_SUCCESS;
-
- if (resp->success > 0) {
- dbg("RESPONSE OK");
-@@ -2277,17 +2270,18 @@ static void on_response_get_facility_status(TcorePending *p, int data_len, const
- return;
- }
- }
-- res.b_enable = atoi(g_slist_nth_data(tokens, 0));
-+ res->b_enable = atoi(g_slist_nth_data(tokens, 0));
- } else {
- dbg("RESPONSE NOK");
-- res.result = SIM_INCOMPATIBLE_PIN_OPERATION;
-+ res->result = SIM_INCOMPATIBLE_PIN_OPERATION;
- }
-
- if (ur) {
- tcore_user_request_send_response(ur, TRESP_SIM_GET_FACILITY_STATUS,
-- sizeof(struct tresp_sim_get_facility_status), &res);
-+ sizeof(struct tresp_sim_get_facility_status), res);
- }
- tcore_at_tok_free(tokens);
-+ g_free(res);
- dbg(" Function exit");
- }
-
-@@ -2771,6 +2765,7 @@ static TReturn s_get_facility_status(CoreObject *o, UserRequest *ur)
- TcorePending *pending = NULL;
- char *cmd_str = NULL;
- const struct treq_sim_get_facility_status *req_data;
-+ struct tresp_sim_get_facility_status *res;
- struct s_sim_property *sp = NULL;
- char *fac = "SC";
- int mode = 2; /* 0:unlock, 1:lock, 2:query*/
-@@ -2787,8 +2782,11 @@ static TReturn s_get_facility_status(CoreObject *o, UserRequest *ur)
- pending = tcore_pending_new(o, 0);
- req_data = tcore_user_request_ref_data(ur, NULL);
-
-- if (!o || !ur)
-- return TCORE_RETURN_EINVAL;
-+ res = g_try_new0(struct tresp_sim_get_facility_status, 1);
-+ if (!res)
-+ return TCORE_RETURN_ENOMEM;
-+
-+ res->type = req_data->type;
-
- if (req_data->type == SIM_FACILITY_PS) {
- fac = "PS"; /*PH-SIM, Lock PHone to SIM/UICC card*/
-@@ -2813,7 +2811,7 @@ static TReturn s_get_facility_status(CoreObject *o, UserRequest *ur)
- dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
-
- tcore_pending_set_request_data(pending, 0, req);
-- tcore_pending_set_response_callback(pending, on_response_get_facility_status, hal);
-+ tcore_pending_set_response_callback(pending, on_response_get_facility_status, res);
- tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
- tcore_hal_send_request(hal, pending);
---
-1.7.10.4
-
+++ /dev/null
-From 733bcfef07745bc6b8b8861bcbdee8639f2f4aef Mon Sep 17 00:00:00 2001
-From: Philippe Nunes <philippe.nunes@linux.intel.com>
-Date: Wed, 16 Jan 2013 16:23:46 +0100
-Subject: [PATCH 23/23] s_network.c: By default, display the plmn in case SPN
- name is void
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/s_network.c | 4 ++++
- 1 file changed, 4 insertions(+)
-
-diff --git a/src/s_network.c b/src/s_network.c
-index ce1ce34..2965022 100644
---- a/src/s_network.c
-+++ b/src/s_network.c
-@@ -1669,6 +1669,10 @@ static void on_sim_resp_hook_get_netname(UserRequest *ur, enum tcore_response_co
- if ((resp->data.spn.display_condition & 0x03) == 0x01) {
- tcore_network_set_network_name_priority(o, TCORE_NETWORK_NAME_PRIORITY_ANY);
- }
-+
-+ // fallback in case no SPN name is provided
-+ if (resp->data.spn.spn[0] == '\0')
-+ tcore_network_set_network_name_priority(o, TCORE_NETWORK_NAME_PRIORITY_NETWORK);
- }
- }
-
---
-1.7.10.4
-
+++ /dev/null
-From e8ae3b0057dad62602dd539c7e8ea5839d527e8a Mon Sep 17 00:00:00 2001
-From: Nicolas Bertrand <nicolas.bertrand@linux.intel.com>
-Date: Fri, 8 Feb 2013 11:21:45 +0100
-Subject: [PATCH] Use plugin mfld-blackbay
-Content-Type: text/plain; charset="utf-8"
-Content-Transfer-Encoding: 8bit
-
----
- src/desc.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/src/desc.c b/src/desc.c
-index 61833f9..01385a2 100644
---- a/src/desc.c
-+++ b/src/desc.c
-@@ -86,8 +86,8 @@ static int _get_cp_name(char **name)
-
- /* By default, SUNRISE IMC modem is returned */
- if (!strcmp(u.nodename, "(none)")) {
-- *name = g_new0(char, 8);
-- strcpy(*name, "imc-pr3");
-+ *name = g_new0(char, 14);
-+ strcpy(*name, "mfld-blackbay");
- return 8;
- }
-
---
-1.7.10.4
-
#sbs-git:slp/pkgs/t/tel-plugin-imc
Name: tel-plugin-imc
Summary: imc plugin for telephony
-Version: 0.1.36
+ExclusiveArch: %{arm}
+Version: 0.1.38
Release: 1
Group: Development/Libraries
License: Apache
BuildRequires: pkgconfig(tcore)
BuildRequires: pkgconfig(db-util)
BuildRequires: pkgconfig(libxml-2.0)
-BuildRequires: pkgconfig(vconf)
-%ifarch %ix86
-%if "%{simulator}" != "1"
-patch0: 0001-desc-CP-name-is-imc-pr3-for-Intel-device.patch
-patch1: 0002-s_modem-CGMR-response-parsing-is-compatible-with-IMC.patch
-patch2: 0003-s-modem-Cleanup.patch
-patch3: 0004-s-modem-Add-notification-hook-for-SIM-status.patch
-patch4: 0005-s-sim-Query-SIM-state-when-modem-is-powered-up.patch
-patch5: 0006-common-Fix-warning-errors.patch
-patch6: 0007-s_sim-Get-the-SIM-type-when-SIM-is-ready.patch
-patch7: 0008-Fix-SCA-service-center-address-length-checking-error.patch
-patch8: 0009-s_modem-Add-XGENDATA-query-to-get-firmware-informati.patch
-patch9: 0010-s_sim-Extend-XSIMSTATE-parsing-to-get-SMS-service-st.patch
-patch10: 0011-set-modem-power-saving-mode.patch
-patch11: 0012-Fix-EFsmsp-size-error.patch
-patch12: 0013-s_call-use-hal-set-sound-path-function.patch
-patch13: 0014-Add-core-objects-and-link-them-to-HAL.patch
-patch14: 0015-Change-the-way-imc-plugin-is-initialized.patch
-patch15: 0016-s_ps-Remove-plateform-dependencies-to-setup-pdp-cont.patch
-patch16: 0017-Fix-the-issue-that-system-is-waken-up-by-modem-frequ.patch
-patch17: 0018-Configure-modem-I2s1-to-8khz-mono-if-routing-to-blue.patch
-patch18: 0019-s_sat.c-Fix-envelope-cmd-and-enable-Setup-Event-List.patch
-patch19: 0020-s_sim.c-Fix-get-lock-info.patch
-patch20: 0021-s_sim-Fix-multiple-sim-facility-status-query.patch
-patch21: 0023-s_network.c-By-default-display-the-plmn-in-case-SPN-.patch
-patch22: 0024-Use-plugin-mfld-blackbay.patch
-%endif
-%endif
%description
IMC plugin for telephony
%prep
%setup -q
-%ifarch %ix86
-%if "%{simulator}" != "1"
-%patch0 -p1
-%patch1 -p1
-%patch2 -p1
-%patch3 -p1
-%patch4 -p1
-%patch5 -p1
-%patch6 -p1
-%patch7 -p1
-%patch8 -p1
-%patch9 -p1
-%patch10 -p1
-%patch11 -p1
-%patch12 -p1
-%patch13 -p1
-%patch14 -p1
-%patch15 -p1
-%patch16 -p1
-%patch17 -p1
-%patch18 -p1
-%patch19 -p1
-%patch20 -p1
-%patch21 -p1
-%patch22 -p1
-%endif
-%endif
%build
cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
CoreObject* obj = NULL;
TcoreHal* h = NULL;
- p = (TcorePlugin*)data;
+ p = (TcorePlugin *) data;
- if(cp_count > MAX_CP_QUERY_COUNT){
+ if (cp_count > MAX_CP_QUERY_COUNT) {
dbg("cp query counter exceeds MAX_CP_QUERY_COUNT");
return FALSE;
}
h = tcore_object_get_hal(obj);
power_state = tcore_hal_get_power_state(h);
- if(TRUE == power_state){
+ if (TRUE == power_state) {
dbg("CP READY");
s_modem_send_poweron(p);
return FALSE;
- }
- else{
+ } else {
dbg("CP NOT READY, cp_count :%d", cp_count);
cp_count++;
return TRUE;
s_sms_init(p, h);
s_phonebook_init(p, h);
s_sap_init(p, h);
+ s_gps_init(p, h);
g_free(cp_name);
--- /dev/null
+/*
+ * tel-plugin-imc
+ *
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: sharanayya mathapati <sharan.m@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <glib.h>
+
+#include <tcore.h>
+#include <hal.h>
+#include <core_object.h>
+#include <plugin.h>
+#include <queue.h>
+#include <co_gps.h>
+#include <user_request.h>
+#include <util.h>
+#include <server.h>
+#include <at.h>
+#include <libxml/xmlreader.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+
+#include "s_common.h"
+#include "s_gps.h"
+
+
+#define FILE_NAME "/opt/home/root/sample.xml"
+#define POSITION_NODE "pos"
+#define POSITION_NODE_ATTR_XSI "xsi:noNamespaceSchemaLocation"
+#define POSITION_NODE_ATTR_VAL_XSI "pos.xsd"
+#define POSITION_NODE_ATTR_XMLNS "xmlns:xsi"
+#define POSITION_NODE_ATTR_VAL_XMLNS "http://www.w3.org/2001/XMLSchema-instance"
+
+#define MAX_NUM_OF_GPS_REF_TIME_ELEMENT 12 // max number of gps satalite
+#define MAX_NUM_OF_GPS_NAV_ELEMENT 16 // max num of navigation gps element.
+#define MAX_NUM_OF_GPS_ALMANC_ELEMENTS 64 // Max num of almanc elements.
+
+#define NUM_OF_ELEMENTS(array) (sizeof(array) / sizeof(*(array)))
+
+static char node_name[128]; // max len of xml node
+static char node_value[128]; // max len of xml node value.
+
+// node type of gps assist data
+enum gps_assist_element_type {
+ REF_TIME = 1,
+ LOCATION_PARM,
+ DGPS_CORRECTION,
+ NAV_MODEL_ELEM,
+ IONOSPHERIC_MODEL,
+ UTC_MODEL,
+ ALMANAC,
+ ACQU_ASSIST,
+};
+
+// Ref_time
+typedef struct {
+ unsigned char valid;
+ unsigned short bcchCarrier;
+ unsigned short bsic;
+ unsigned long int frameNumber;
+ unsigned short timeSlot;
+ unsigned short bitNumber;
+} __attribute__((packed)) gps_gsm_time_t;
+
+typedef struct {
+ unsigned char valid;
+ unsigned long int gpsTimeUncertainty;
+} __attribute__((packed)) gps_utran_gps_unc_t;
+
+typedef struct {
+ unsigned char valid;
+ signed long int driftRate;
+} __attribute__((packed)) gps_drift_rate_t;
+
+typedef struct {
+ unsigned char valid;
+ unsigned long int cellFrames;
+ unsigned char choice_mode;
+ unsigned long int UtranFdd; // FDD Primary Scrambling Code
+ unsigned long int UtranTdd; // TDD Cell Parameter ID
+ unsigned long int sfn; // SFN
+} __attribute__((packed)) gps_utran_gps_ref_time_t;
+
+typedef struct {
+ gps_utran_gps_ref_time_t UtranGpsRefTime;
+ gps_utran_gps_unc_t UtranGpsUncertainty;
+ unsigned char UtranSfnUncertainty;
+ gps_drift_rate_t UtranDriftRate;
+} __attribute__((packed)) gps_utran_time_t;
+
+typedef struct {
+ unsigned short satID;
+ unsigned short tlmWord;
+ unsigned char antiSpoofFlag;
+ unsigned char alertFlag;
+ unsigned char tmlReservedBits;
+} __attribute__((packed)) gps_gps_tow_assist_t;
+
+typedef struct {
+ unsigned long int gpsTow;
+ unsigned long int gpsWeek;
+ unsigned char nrOfSats;
+ union { // Not supported.
+ gps_gsm_time_t gsm_time;
+ gps_utran_time_t UtranTime;
+ } networkTimeInfo;
+ gps_gps_tow_assist_t GpsTowAssist[12];
+} __attribute__((packed)) gps_ref_time_t;
+
+
+// Ref - Location.
+typedef struct {
+ unsigned char shapeType;
+ unsigned char hemisphere;
+ unsigned short altitude;
+ unsigned long int latitude;
+ signed long int longitude;
+ unsigned char directionOfAlt;
+ unsigned char semiMajorUncert;
+ unsigned char semiMinorUncert;
+ unsigned char majorAxis;
+ unsigned char altUncert;
+ unsigned char confidence;
+} __attribute__((packed)) gps_ref_loc_t;
+
+// DGPS corrections
+typedef enum {
+ GPS_DGPS_INVALID,
+ GPS_DGPS_UDRE_SCALE_1_0,
+ GPS_DGPS_UDRE_SCALE_0_75,
+ GPS_DGPS_UDRE_SCALE_0_5,
+ GPS_DGPS_UDRE_SCALE_0_3,
+ GPS_DGPS_UDRE_SCALE_0_2,
+ GPS_DGPS_UDRE_SCALE_0_1,
+ GPS_DGPS_NO_DATA
+} __attribute__((packed)) gps_dgps_status_e_type;
+
+typedef struct {
+ unsigned char satId; // Satellite ID
+ unsigned short iode;
+ unsigned char udre;
+ signed short pseudoRangeCor;
+ signed short rangeRateCor;
+} gps_dgps_sat_list_t;
+
+typedef struct {
+ unsigned long int gpsTow;
+ gps_dgps_status_e_type status;
+ unsigned long int numberOfSat;
+ gps_dgps_sat_list_t seqOfSatElement[16];
+} __attribute__((packed)) gps_dgps_correction_t;
+
+// Navi model
+typedef struct {
+ unsigned long int rsv1; // 0~838860
+ unsigned long int rsv2; // 0~16777215
+ unsigned long int rsv3; // 0~16777215
+ unsigned long int rsv4; // 0~65535
+} __attribute__((packed)) gps_navi_subframe_rsv_t;
+
+typedef struct {
+ unsigned char ephemCodeOnL2; // 0~3
+ unsigned char ephemUra; // 0~15
+ unsigned char ephemSvHealth; // 0~63
+ unsigned short ephemIodc; // 0~1023
+ unsigned char ephemL2PFlag; // 0~1
+ gps_navi_subframe_rsv_t NavigationSubFrameRsv;
+ signed char ephemTgd; // -128~127
+ unsigned short ephemToc; // 0~37799
+ signed char ephemAf2; // -128~12
+ signed short ephemAf1; // -32768~32767
+ signed long int ephemAf0; // -2097152~2097151
+ signed short ephemCrs; // -32768~32767
+ signed short ephemDeltaN; // -32768~32767
+ signed long int ephemM0; // -2147483648~2147483647
+ signed short ephemCuc; // -32768~32767
+ unsigned long int ephemE; // 0~4294967295
+ signed short ephemCus; // -32768~32767
+ unsigned long int ephemAPowrHalf; // 0~4294967295
+ unsigned short ephemToe; // 0~37799
+ signed char ephemFitFlag; // 0~1
+ unsigned char ephemAoda; // 0~31
+ signed short ephemCic; // -32768~32767
+ signed long int ephemOmegaA0; // -2147483648~2147483647
+ signed short ephemCis; // -32768~32767
+ signed long int ephemI0; // -2147483648~2147483647
+ signed short ephemCrc; // -32768~32767
+ signed long int ephemW; // -2147483648~2147483647
+ signed long int ephemOmegaADot; // -8388608~8388607
+ signed short ephemIDot; // -8192~8191
+} __attribute__((packed)) gps_navi_ephe_t;
+
+typedef enum {
+ GPS_NAVIGATION_MODEL_NEW_SATELLITE_NEW_NAVIGATION,
+ GPS_NAVIGATION_MODEL_EXIST_SATELLITE_EXIST_NAVIGATION,
+ GPS_NAVIGATION_MODEL_EXIST_SATELLITE_NEW_NAVIGATION,
+ GPS_NAVIGATION_MODEL_RESERVED
+} gps_navigation_sat_status_e_type;
+
+typedef struct {
+ unsigned char satId;
+ gps_navigation_sat_status_e_type NavigationSatStatus;
+ gps_navi_ephe_t NavigationEphemeris;
+} __attribute__((packed)) gps_navi_sat_info_t;
+
+typedef struct {
+ unsigned long int numberOfSat;
+ gps_navi_sat_info_t NavigationSatInfo[16];
+} __attribute__((packed)) gps_navi_model_t;
+
+// Iono_model
+typedef struct {
+ signed char alfa0; // -128~127
+ signed char alfa1; // -128~127
+ signed char alfa2; // -128~127
+ signed char alfa3; // -128~127
+ signed char beta0; // -128~127
+ signed char beta1; // -128~127
+ signed char beta2; // -128~127
+ signed char beta3; // -128~127
+} __attribute__((packed)) gps_iono_model_t;
+
+// UTC_model
+typedef struct {
+ signed long int utcA1; // -8388608~8388607
+ signed long int utcA0; // -2147483648~2147483647
+ unsigned char utcTot; // 0~255
+ unsigned char utcWNt; // 0~255
+ signed char utcDeltaTls; // -128~127
+ unsigned char utcWNlsf; // 0~255
+ signed char utcDN; // -128~127
+ signed char utcDeltaTlsf; // -128~127
+} __attribute__((packed)) gps_utc_model_t;
+
+// Almanac-model
+typedef struct {
+ signed char dataId; // only for 3G, 0~3, if this value is -1, it means this value is invalid
+ unsigned char satId;
+ unsigned short almanacE; // 0~65536
+ unsigned char almanacToa; // 0~255
+ signed short almanacKsii; // -32768~3276
+ signed short almanacOmegaDot; // -32768~3276
+ unsigned char almanacSvHealth; // 0~255
+ unsigned long int almanacAPowerHalf; // 0~16777215
+ signed long int almanacOmega0; // -8388608~8388607
+ signed long int almanacW; // -8388608~8388607
+ signed long int almanacM0; // -8388608~8388607
+ signed short almanacAf0; // -1024~1023
+ signed short almanacAf1; // -1024~1023
+} __attribute__((packed)) gps_almanac_sat_info_t;
+
+typedef struct {
+ unsigned char almanacWNa; // 0~255
+ unsigned long int numberOfSat;
+ gps_almanac_sat_info_t AlmanacSatInfo[64];
+} __attribute__((packed)) gps_almanac_model_t;
+
+// acq_assist
+typedef struct {
+ unsigned char satId;
+ signed short doppler0; // -2048~2047 (real value is from -5120 to 5117.5 by step of 2.5)
+ unsigned char doppler1; // 0~63 (real value is from -0.966 to 0.483 by step of 0.023)
+ unsigned char dopplerUncertainty; // 0~7 (12.5, 25, 50, 100, 200)
+ unsigned short codePhase; // 0~1022
+ unsigned char intCodePhase; // 0~19
+ unsigned char gpsBitNumber; // 0~3
+ unsigned char codePhaseSearchWindow; // 0~15 (1023, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192)
+ unsigned char azimuth; // 0~31, 11.25 degree resolution
+ unsigned char elevation; // 0~7, 11.25 degree resolution
+} __attribute__((packed)) gps_acq_sat_info_t;
+
+typedef struct {
+ gps_utran_gps_ref_time_t AcqUtranGpsRefTime;
+ gps_utran_gps_unc_t AcqUtranGpsUncertainty;
+} __attribute__((packed)) gps_acq_utran_time_t;
+
+typedef struct {
+ unsigned long int gpsTow;
+ union {
+ gps_gsm_time_t gsm_time;
+ gps_acq_utran_time_t AcqUtranTime;
+ } acquisitionTimeInfo; // --- not supported.
+ unsigned long int numberOfSat;
+ gps_acq_sat_info_t lcsAcquisitionSatInfo[16];
+} __attribute__((packed)) gps_acq_assist_t;
+
+typedef struct {
+ unsigned char satId[16];
+ unsigned char numOfSat;
+} __attribute__((packed)) gps_r_time_int_t;
+
+
+// Assist-data
+typedef struct {
+ unsigned long int flag;
+ gps_ref_time_t ref_time;
+ gps_ref_loc_t ref_loc;
+ gps_dgps_correction_t dgps_corrections;
+ gps_navi_model_t navi_model;
+ gps_iono_model_t iono_model;
+ gps_utc_model_t utc_model;
+ gps_almanac_model_t almanac;
+ gps_acq_assist_t acq_assist;
+ gps_r_time_int_t r_time_int; // not supported
+} __attribute__((packed)) gps_assist_data_noti_t; // APGPS - GPS Assist Data Message - Notification
+
+typedef struct {
+ char *psat_status;
+ int stat_status;
+} __attribute__((packed)) sat_status_info_t;
+
+const sat_status_info_t sat_status_info_table[] = {
+ { "NS_NN-U", 0}, {"NS_NN", 0}, {"ES_NN-U", 1}, {"ES_SN", 2},
+ { "REVD", 3},
+};
+
+typedef struct {
+ char *pdoppler_status;
+ int doppler_status;
+} __attribute__((packed)) doppler_status_info_t;
+
+const doppler_status_info_t doppler_status_info_table[] = {
+ { "hz12-5", 12.5}, {"hz25", 25}, {"hz50", 50}, {"hz100", 100},
+ {"hz200", 200},
+};
+
+// postion measurement data structure.
+// gps_method_e_type
+typedef enum {
+ GPS_METHODTYPE_INVALID,
+ GPS_METHODTYPE_MS_ASSISTED,
+ GPS_METHODTYPE_MS_BASED,
+ GPS_METHODTYPE_MS_BASED_PREF,
+ GPS_METHODTYPE_MS_ASSISTED_PREF
+} gps_method_e_type;
+
+// gps_accuracy_t
+typedef struct {
+ unsigned int flag;
+ unsigned char horizontalAccuracy;
+ unsigned char vertcalAccuracy;
+} __attribute__((packed)) gps_accuracy_t;
+
+// gps_use_multi_sets_e_type
+typedef enum {
+ GPS_MULTIPLESETS_INVALID,
+ GPS_MULTIPLESETS_MULTIPLESETS,
+ GPS_MULTIPLESETS_ONESET
+} gps_use_multi_sets_e_type;
+
+// gps_env_char_e_type
+typedef enum {
+ GPS_ENVIRONMENT_INVALID,
+ GPS_ENVIRONMENT_BAD_AREA,
+ GPS_ENVIRONMENT_NOT_BAD_AREA,
+ GPS_ENVIRONMENT_MIXED_AREA
+} gps_env_char_e_type;
+
+// gps_cell_timing_wnt_e_type
+typedef enum {
+ GPS_CELLTIMING_INVALID,
+ GPS_CELLTIMING_WANTED,
+ GPS_CELLTIMING_NOT_WANTED
+} gps_cell_timing_wnt_e_type;
+
+// gps_add_assit_req_e_type
+typedef enum {
+ GPS_ADDITIONAL_ASSISREQ_INVALID,
+ GPS_ADDITIONAL_ASSISREQ_REQ,
+ GPS_ADDITIONAL_ASSISREQ_NOT_REQ
+} gps_add_assit_req_e_type;
+
+// gps measure position.
+typedef struct {
+ gps_method_e_type method_type;
+ gps_accuracy_t accuracy;
+ unsigned char rsp_time;
+ gps_use_multi_sets_e_type use_multi_sets;
+ gps_env_char_e_type environment_char;
+ gps_cell_timing_wnt_e_type cell_timing_wnt;
+ gps_add_assit_req_e_type add_assist_req;
+} __attribute__((packed)) gps_measure_position_indi_t;
+
+
+// APGPS - Measure Position message - confirm
+typedef enum {
+ GPS_MSR_POS_RES_LOCATION,
+ GPS_MSR_POS_RES_GPS_MEASUREMENTS,
+ GPS_MSR_POS_RES_AID_REQ,
+ GPS_MSR_POS_RES_ERROR
+} gps_msr_pos_res_e_type;
+
+typedef struct {
+ unsigned char sat_id;
+ unsigned char iode;
+} __attribute__((packed)) gps_sat_info_t;
+
+typedef struct {
+ unsigned char beginWeek;
+ unsigned char endWeek;
+ unsigned char beginTow;
+ unsigned char endTow;
+} __attribute__((packed)) gps_ext_ephe_chk_t;
+
+typedef struct {
+ unsigned long int assistanceFlag;
+ unsigned short gpsWeek;
+ unsigned char gpsToe;
+ unsigned char nSat;
+ unsigned char toeLimit;
+ gps_sat_info_t satInfo[15];
+ unsigned char gpsExtendedEphemeris;
+ gps_ext_ephe_chk_t extEphemerisChk;
+} __attribute__((packed)) gps_assistance_data_t;
+
+// Measure Position message
+typedef struct {
+ unsigned char satId; // Satellite ID
+ unsigned char cno; // 0~63, unit of dB-Hz
+ signed short doppler; // -32768~32767, Hz and scale factor 0.2
+ unsigned short wholeChips; // 0~1022
+ unsigned short fracChips; // 0~1024
+ unsigned char lcsMultiPath;
+ unsigned char pseuRangeRmsErr; // 0~63
+} __attribute__((packed)) gps_measuremet_element_t;
+
+typedef struct {
+ unsigned long int gpsTow; // /< GPS time of week [msec]
+ unsigned short gpsWeek; // /< GPS week [0 .. 1023]
+ unsigned char nrOfSats; // /< number of satellites [1 .. 16]
+ gps_measuremet_element_t GpsMeasure[16];
+} __attribute__((packed)) gps_measure_t;
+
+typedef struct {
+ signed long int latitude;
+ signed long int longitude;
+} __attribute__((packed)) gps_ellipsoid_po_t;
+
+typedef struct {
+ gps_ellipsoid_po_t point;
+ unsigned char uncertainRadius;
+} __attribute__((packed)) gps_po_unc_circle_t;
+
+typedef struct {
+ gps_ellipsoid_po_t point;
+ unsigned char semiMajorAxis;
+ unsigned char semiMinorAxis;
+ unsigned char orientationAngle;
+ unsigned char confidence;
+} __attribute__((packed)) gps_po_unc_ellipse_t;
+
+typedef struct {
+ gps_ellipsoid_po_t point;
+ signed short altitude;
+ unsigned char semiMajorAxis;
+ unsigned char semiMinorAxis;
+ unsigned char orientationAngle;
+ unsigned char uncertainAltitude;
+ unsigned char confidence;
+} __attribute__((packed)) gps_po_alt_unc_ellipse_t;
+
+typedef struct {
+ gps_ellipsoid_po_t point;
+ unsigned short innerRadius;
+ unsigned char uncertainRadius;
+ unsigned char offsetAngle;
+ unsigned char includedAngle;
+ unsigned char confidence;
+} __attribute__((packed)) gps_ellipsoid_arc_t;
+
+typedef struct {
+ gps_ellipsoid_po_t point;
+ signed short altitude;
+} __attribute__((packed)) gps_ellipsoid_alt_t;
+
+typedef struct {
+ unsigned char noOfPoints;
+ gps_ellipsoid_po_t points[15];
+} __attribute__((packed)) gps_polygon_t;
+
+
+typedef struct {
+ unsigned char shape_type;
+ gps_po_unc_circle_t p_unc_clrcle;
+ gps_po_unc_ellipse_t p_unc_ellipse;
+ gps_po_alt_unc_ellipse_t p_alt_unc_ellipse;
+ gps_ellipsoid_arc_t ellipsoid_arc;
+ gps_ellipsoid_po_t ellipsoid_po;
+ gps_ellipsoid_alt_t ellipsoid_alt;
+ gps_polygon_t polygon;
+} __attribute__((packed)) gps_loc_info_t;
+
+
+typedef struct {
+ unsigned long int gpsTow; // /< GPS time of week [msec]
+ unsigned short gpsWeek; // /< GPS week [0 .. 1023]
+ unsigned char fixType; // /< Fix type. 2D(0x01) or 3D(0x02)
+ gps_loc_info_t measured_loc_info;
+} __attribute__((packed)) gps_measure_loc_info_t;
+
+typedef struct {
+ unsigned char valid;
+ unsigned long int cellFrames;
+ unsigned char choice_mode;
+ unsigned long int UtranFdd; // FDD Primary Scrambling Code
+ unsigned long int UtranTdd; // TDD Cell Parameter ID
+ unsigned long int sfn; // SFN
+} __attribute__((packed)) gps_utrangps_ref_time_t;
+
+typedef struct {
+ unsigned char result; // 0x00 : SUCCESS, 0x01 : Fail
+ gps_msr_pos_res_e_type response_type; // should be 4 byte
+ gps_measure_t gps_measure;
+ gps_measure_loc_info_t loc_info;
+ gps_assistance_data_t measured_assit_data;
+ gps_utrangps_ref_time_t UtranGpsRefTime; // only for 3G
+} __attribute__((packed)) gps_measure_position_confirm_t; // APGPS - Measure Position message - confirm
+
+typedef struct {
+ char *name;
+ int type;
+} t_element;
+
+static t_element elements[] = {
+ {"ref_time", REF_TIME},
+ {"location_parameters", LOCATION_PARM},
+ {"DGPS_corrections", DGPS_CORRECTION},
+ {"nav_model_elem", NAV_MODEL_ELEM},
+ {"ionospheric_model", IONOSPHERIC_MODEL},
+ {"UTC_model", UTC_MODEL},
+ {"almanac", ALMANAC},
+ {"acqu_assist", ACQU_ASSIST},
+};
+
+
+/**************************************************************************
+* Local Function Prototypes
+**************************************************************************/
+
+static inline int _modem_sat_status_info_2_tel_sat_info(char *sat_info);
+
+static inline int _modem_acqa_assit_doppler_2_tel_doppler(char *doppler_info);
+
+static int _gps_element_compare(char *element[], char *element_str, int nelem);
+
+static enum gps_assist_element_type _get_element_type(char *element_str);
+
+static void _parse_ref_time_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist, gboolean GPS_TOW_assist, int count);
+
+static void _parse_location_parameters(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist);
+
+static void _parse_dgps_correction_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist);
+
+static void _parse_ionospheric_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist);
+
+static void _parse_utc_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist);
+
+static void _parse_almanc_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist, gboolean alm_elem, int count);
+
+static void _parse_acqu_assist_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist);
+
+static void _parse_nav_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist, gboolean ephem_and_clock, int element_count);
+
+static void _set_coordinate(xmlNodePtr node, gps_ellipsoid_po_t *point, int isalt, int altitude);
+
+static void _set_loc_info_ellipse_elements(xmlNodePtr node, void *elliplse, int is_unc_ellipse);
+
+static xmlChar* _generate_confirm_measure_pos_xml_text(gps_measure_position_confirm_t *gps_measure_position_confirm);
+
+static gboolean on_notification_gps_measure_position_from_modem(CoreObject *o, char *file_name, void *user_data);
+
+/**************************************************************************
+* Local Function Definitions
+ **************************************************************************/
+
+static inline int _modem_sat_status_info_2_tel_sat_info(char *sat_info)
+{
+ int count;
+
+ for (count = 0; count < (int) (sizeof(sat_status_info_table) / sizeof(sat_status_info_t)); count++) {
+ if (strcmp(sat_status_info_table[count].psat_status, sat_info) == 0)
+ return (sat_status_info_table[count].stat_status);
+ }
+ return (-1);
+}
+
+static inline int _modem_acqa_assit_doppler_2_tel_doppler(char *doppler_info)
+{
+ int count;
+
+ for (count = 0; count < (int) (sizeof(doppler_status_info_table) / sizeof(doppler_status_info_t)); count++) {
+ if (strcmp(doppler_status_info_table[count].pdoppler_status, doppler_info) == 0)
+ return (doppler_status_info_table[count].doppler_status);
+ }
+ return (-1);
+}
+
+static int _gps_element_compare(char *element[], char *element_str, int nelem)
+{
+ int count;
+
+ for (count = 0; count < nelem; count++) {
+ if (strcmp(element[count], element_str) == 0)
+ return count;
+ }
+
+ return -1;
+}
+
+
+static enum gps_assist_element_type _get_element_type(char *element_str)
+{
+ unsigned int index;
+
+ for (index = 0; index < sizeof(elements) / sizeof(t_element); index++) {
+ if (strcmp(elements[index].name, element_str) == 0)
+ return elements[index].type;
+ }
+ return -1;
+}
+
+static void _parse_ref_time_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist, gboolean GPS_TOW_assist, int count)
+{
+ int node_count;
+ int nelem;
+ static char *element[] = {"GPS_TOW_msec", "GPS_week", "sat_id", "tlm_word", "anti_sp", "alert", "tlm_res"};
+
+ dbg("Enter")
+ if (count < 0 || count >= MAX_NUM_OF_GPS_REF_TIME_ELEMENT) {
+ dbg("invalid count");
+ return;
+ }
+ nelem = (int) NUM_OF_ELEMENTS(element);
+ node_count = _gps_element_compare(element, element_str, nelem);
+
+ if (node_count == 0) {
+ gpsdata_assist->ref_time.gpsTow = atoi(element_value);
+ dbg("gpsTow - %d\n", gpsdata_assist->ref_time.gpsTow);
+ gpsdata_assist->dgps_corrections.gpsTow = gpsdata_assist->ref_time.gpsTow;
+ return;
+ } else if (node_count == 1) {
+ gpsdata_assist->ref_time.gpsWeek = atoi(element_value);
+ dbg("gpsWeek - %d\n", gpsdata_assist->ref_time.gpsWeek);
+ return;
+ }
+
+ if (GPS_TOW_assist) {
+ switch (node_count) {
+ case 2:
+ {
+ gpsdata_assist->ref_time.GpsTowAssist[count].satID = atoi(element_value);
+ dbg("GpsTowAssist[%d].satID = %d\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].satID);
+ gpsdata_assist->ref_time.nrOfSats = count + 1;
+ }
+ break;
+
+ case 3:
+ {
+ gpsdata_assist->ref_time.GpsTowAssist[count].tlmWord = atoi(element_value);
+ dbg("GpsTowAssist[%d]-tlmWord = %d\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].tlmWord);
+ gpsdata_assist->ref_time.nrOfSats = count + 1;
+ }
+ break;
+
+ case 4:
+ {
+ gpsdata_assist->ref_time.GpsTowAssist[count].antiSpoofFlag = *element_value;
+ dbg("GpsTowAssist[%d]-antiSpoofFlag = 0x%X\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].antiSpoofFlag);
+ gpsdata_assist->ref_time.nrOfSats = count + 1;
+ }
+ break;
+
+ case 5:
+ {
+ gpsdata_assist->ref_time.GpsTowAssist[count].alertFlag = *element_value;
+ dbg("GpsTowAssist[%d]-alertFlag = 0x%X\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].alertFlag);
+ gpsdata_assist->ref_time.nrOfSats = count + 1;
+ }
+ break;
+
+ case 6:
+ {
+ gpsdata_assist->ref_time.GpsTowAssist[count].tmlReservedBits = *element_value;
+ dbg("GpsTowAssist[%d]-tmlReservedBits = 0x%X\n", count, gpsdata_assist->ref_time.GpsTowAssist[count].tmlReservedBits);
+ gpsdata_assist->ref_time.nrOfSats = count + 1;
+ }
+ break;
+
+ default:
+ dbg("Invalid gps element");
+ }
+ }
+}
+
+static void _parse_location_parameters(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
+{
+ // unsigned char shapeType; and unsigned char hemisphere not supported.
+
+ static char *element[] = {
+ "north", "degrees", "height_above_surface", "height", "longitude", "uncert_semi_major", "uncert_semi_minor",
+ "orient_major", "confidence", "uncert_alt"
+ };
+
+ int nelem = (int) NUM_OF_ELEMENTS(element);
+ int count;
+
+ count = _gps_element_compare(element, element_str, nelem);
+
+ dbg("Enter")
+
+ switch (count) {
+ case 0:
+ {
+ // gpsdata_assist.ref_loc.latitude_data.north = atoi(element_str_text);
+ // dbg("gpsdata_assist.ref_loc.latitude_data.north - %d\n",gpsdata_assist.ref_loc.latitude_data.north);
+ }
+ break;
+
+ case 1:
+ {
+ gpsdata_assist->ref_loc.latitude = atoi(element_value);
+ dbg("latitude_data.degrees - %d\n", gpsdata_assist->ref_loc.latitude);
+ }
+ break;
+
+ case 2:
+ {
+ // gpsdata_assist.ref_loc.altitude_data.height_above_surface = atoi(element_str_text);
+ // dbg("altitude_data.height_above_surface - %d\n",gpsdata_assist.ref_loc.altitude_data.height_above_surface);
+ }
+ break;
+
+ case 3:
+ {
+ gpsdata_assist->ref_loc.altitude = atoi(element_value); // todo- need to confirm
+ dbg("altitude_data.height - %d\n", gpsdata_assist->ref_loc.altitude);
+ }
+ break;
+
+ case 4:
+ {
+ gpsdata_assist->ref_loc.longitude = atoi(element_value);
+ dbg("longitude - %d\n", gpsdata_assist->ref_loc.longitude);
+ }
+ break;
+
+ case 5:
+ {
+ gpsdata_assist->ref_loc.semiMajorUncert = *element_value;
+ dbg("semiMajorUncert - 0x%X\n", gpsdata_assist->ref_loc.semiMajorUncert);
+ }
+ break;
+
+ case 6:
+ {
+ gpsdata_assist->ref_loc.semiMinorUncert = *element_value;
+ dbg("uncert_semi_minor - 0x%X\n", gpsdata_assist->ref_loc.semiMinorUncert);
+ }
+ break;
+
+ case 7:
+ {
+ gpsdata_assist->ref_loc.majorAxis = *element_value;
+ dbg("orient_major - 0x%X\n", gpsdata_assist->ref_loc.majorAxis);
+ }
+ break;
+
+ case 8:
+ {
+ gpsdata_assist->ref_loc.confidence = *element_value;
+ dbg("confidence - 0x%X\n", gpsdata_assist->ref_loc.confidence);
+ }
+ break;
+
+ case 9:
+ {
+ gpsdata_assist->ref_loc.altUncert = *element_value;
+ dbg("altUncert - 0x%X\n", gpsdata_assist->ref_loc.altUncert);
+ }
+ break;
+
+ default:
+ dbg("invalid element");
+ }
+}
+
+static void _parse_dgps_correction_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
+{
+ dbg("Enter");
+
+ if (strcmp(element_str, "sat_id") == 0) {
+ gpsdata_assist->dgps_corrections.seqOfSatElement[0].satId = *element_value;
+ dbg("seqOfSatElement[0].satId - %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].satId);
+ } else if (strcmp(element_str, "IODE") == 0) {
+ gpsdata_assist->dgps_corrections.seqOfSatElement[0].iode = atoi(element_value);
+ dbg("seqOfSatElement[0].iode - %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].iode);
+ } else if (strcmp(element_str, "UDRE") == 0) {
+ gpsdata_assist->dgps_corrections.seqOfSatElement[0].udre = *element_value;
+ dbg("seqOfSatElement[0].udre- %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].udre);
+ } else if (strcmp(element_str, "PRC") == 0) {
+ gpsdata_assist->dgps_corrections.seqOfSatElement[0].pseudoRangeCor = atoi(element_value);
+ dbg("seqOfSatElement[0].pseudoRangeCor - %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].pseudoRangeCor);
+ } else if (strcmp(element_str, "RRC") == 0) {
+ gpsdata_assist->dgps_corrections.seqOfSatElement[0].rangeRateCor = atoi(element_value);
+ dbg("seqOfSatElement[0].rangeRateCor - %d\n", gpsdata_assist->dgps_corrections.seqOfSatElement[0].rangeRateCor);
+ }
+}
+
+static void _parse_ionospheric_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
+{
+ static char *element[] = {"alfa0", "alfa1", "alfa2", "alfa3", "beta0", "beta1", "beta2", "beta3" };
+ int nelem = (int) NUM_OF_ELEMENTS(element);
+ int count;
+
+ count = _gps_element_compare(element, element_str, nelem);
+ dbg("enter");
+ switch (count) {
+ case 0:
+ {
+ gpsdata_assist->iono_model.alfa0 = *element_value;
+ dbg("alfa0 - 0x%X\n", gpsdata_assist->iono_model.alfa0);
+ }
+ break;
+
+ case 1:
+ {
+ gpsdata_assist->iono_model.alfa1 = *element_value;
+ dbg("alfa1 - 0x%X\n", gpsdata_assist->iono_model.alfa1);
+ }
+ break;
+
+ case 2:
+ {
+ gpsdata_assist->iono_model.alfa2 = *element_value;
+ dbg("alfa2 - 0x%X\n", gpsdata_assist->iono_model.alfa2);
+ }
+ break;
+
+ case 3:
+ {
+ gpsdata_assist->iono_model.alfa3 = *element_value;
+ dbg("alfa3 - 0x%X\n", gpsdata_assist->iono_model.alfa3);
+ }
+ break;
+
+ case 4:
+ {
+ gpsdata_assist->iono_model.beta0 = *element_value;
+ dbg("beta0 - 0x%X\n", gpsdata_assist->iono_model.beta0);
+ }
+ break;
+
+ case 5:
+ {
+ gpsdata_assist->iono_model.beta1 = *element_value;
+ dbg("beta1 -0x%X\n", gpsdata_assist->iono_model.beta1);
+ }
+ break;
+
+ case 6:
+ {
+ gpsdata_assist->iono_model.beta2 = *element_value;
+ dbg("beta2 - 0x%X\n", gpsdata_assist->iono_model.beta2);
+ }
+ break;
+
+ case 7:
+ {
+ gpsdata_assist->iono_model.beta3 = *element_value;
+ dbg("beta3 - 0x%X\n", gpsdata_assist->iono_model.beta3);
+ }
+ break;
+
+ default:
+ dbg("invalid gps element");
+ }
+}
+
+void _parse_utc_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
+{
+ static char *element[] = {"a1", "a0", "tot", "wnt", "dtls", "wnlsf", "dn", "dtlsf"};
+ int nelem = (int) NUM_OF_ELEMENTS(element);
+ int count;
+
+ count = _gps_element_compare(element, element_str, nelem);
+ dbg("Enter");
+
+ switch (count) {
+ case 0:
+ {
+ gpsdata_assist->utc_model.utcA1 = atoi(element_value);
+ dbg("utcA1 - %d\n", gpsdata_assist->utc_model.utcA1);
+ }
+ break;
+
+ case 1:
+ {
+ gpsdata_assist->utc_model.utcA0 = atoi(element_value);
+ dbg("utcA0 - %d\n", gpsdata_assist->utc_model.utcA0);
+ }
+ break;
+
+ case 2:
+ {
+ gpsdata_assist->utc_model.utcTot = *element_value;
+ dbg("utcTot - 0x%X\n", gpsdata_assist->utc_model.utcTot);
+ }
+ break;
+
+ case 3:
+ {
+ gpsdata_assist->utc_model.utcWNt = *element_value;
+ dbg("utcWNt - 0x%X\n", gpsdata_assist->utc_model.utcWNt);
+ }
+ break;
+
+ case 4:
+ {
+ gpsdata_assist->utc_model.utcDeltaTls = *element_value;
+ dbg("utcDeltaTls -0x%X\n", gpsdata_assist->utc_model.utcDeltaTls);
+ }
+ break;
+
+ case 5:
+ {
+ gpsdata_assist->utc_model.utcWNlsf = *element_value;
+ dbg("utcWNlsf - 0x%X\n", gpsdata_assist->utc_model.utcWNlsf);
+ }
+ break;
+
+ case 6:
+ {
+ gpsdata_assist->utc_model.utcDN = *element_value;
+ dbg("utcDN - 0x%X\n", gpsdata_assist->utc_model.utcDN);
+ }
+ break;
+
+ case 7:
+ {
+ gpsdata_assist->utc_model.utcDeltaTlsf = *element_value;
+ dbg("utcDeltaTlsf - 0x%X\n", gpsdata_assist->utc_model.utcDeltaTlsf);
+ }
+ break;
+
+ default:
+ dbg("invalid gps element");
+ }
+}
+
+static void _parse_almanc_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist,
+ gboolean alm_elem, int count)
+{
+ int nelem;
+ int node_count;
+ static char *element[] = {
+ "wna", "data_id", "sat_id", "alm_ecc", "alm_toa", "alm_ksii", "alm_omega_dot", "alm_sv_health", "alm_power_half",
+ "alm_omega0", "alm_omega", "alm_m0", "alm_af0", "alm_af1"
+ };
+
+ dbg("Enter");
+ if (count < 0 || count >= MAX_NUM_OF_GPS_ALMANC_ELEMENTS) {
+ dbg("invalid count");
+ return;
+ }
+ nelem = (int) NUM_OF_ELEMENTS(element);
+
+ node_count = _gps_element_compare(element, element_str, nelem);
+ if (node_count == 0) {
+ gpsdata_assist->almanac.almanacWNa = *element_value;
+ dbg("almanacWNa - %d\n", gpsdata_assist->almanac.almanacWNa);
+ return;
+ }
+
+ if (alm_elem) {
+ switch (node_count) {
+ case 1:
+ {
+ gpsdata_assist->almanac.AlmanacSatInfo[count].dataId = *element_value;
+ dbg("AlmanacSatInfo[%d].data_id - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].dataId);
+ }
+ break;
+
+ case 2:
+ {
+ gpsdata_assist->almanac.AlmanacSatInfo[count].satId = *element_value;
+ dbg("AlmanacSatInfo[%d].sat_id - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].satId);
+ }
+ break;
+
+ case 3:
+ {
+ gpsdata_assist->almanac.AlmanacSatInfo[count].almanacE = atoi(element_value);
+ dbg("AlmanacSatInfo[%d].almanacE - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacE);
+ }
+ break;
+
+ case 4:
+ {
+ gpsdata_assist->almanac.AlmanacSatInfo[count].almanacToa = *element_value;
+ dbg("AlmanacSatInfo[%d].almanacToa - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacToa);
+ }
+ break;
+
+ case 5:
+ {
+ gpsdata_assist->almanac.AlmanacSatInfo[count].almanacKsii = *element_value;
+ dbg("AlmanacSatInfo[%d].almanacKsii - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacKsii);
+ }
+ break;
+
+ case 6:
+ {
+ gpsdata_assist->almanac.AlmanacSatInfo[count].almanacOmegaDot = *element_value;
+ dbg("AlmanacSatInfo[%d].almanacOmegaDot - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacOmegaDot);
+ }
+ break;
+
+ case 7:
+ {
+ gpsdata_assist->almanac.AlmanacSatInfo[count].almanacSvHealth = *element_value;
+ dbg("AlmanacSatInfo[%d].almanacSvHealth - 0x%X\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacSvHealth);
+ }
+ break;
+
+ case 8:
+ {
+ gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAPowerHalf = atoi(element_value);
+ dbg("AlmanacSatInfo[%d].almanacAPowerHalf - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAPowerHalf);
+ }
+ break;
+
+ case 9:
+ {
+ gpsdata_assist->almanac.AlmanacSatInfo[count].almanacOmega0 = atoi(element_value);
+ dbg("AlmanacSatInfo[%d].almanacOmega0 - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacOmega0);
+ }
+ break;
+
+ case 10:
+ {
+ gpsdata_assist->almanac.AlmanacSatInfo[count].almanacW = atoi(element_value);
+ dbg("AlmanacSatInfo[%d].almanacW - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacW);
+ }
+ break;
+
+ case 11:
+ {
+ gpsdata_assist->almanac.AlmanacSatInfo[count].almanacM0 = atoi(element_value);
+ dbg("AlmanacSatInfo[%d].almanacM0 - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacM0);
+ }
+ break;
+
+ case 12:
+ {
+ gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAf0 = atoi(element_value);
+ dbg("AlmanacSatInfo[%d].almanacAf0 - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAf0);
+ }
+ break;
+
+ case 13:
+ {
+ gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAf1 = atoi(element_value);
+ dbg("AlmanacSatInfo[%d].almanacAf1 - %d\n", count, gpsdata_assist->almanac.AlmanacSatInfo[count].almanacAf1);
+ }
+ break;
+
+ default:
+ dbg("invalid gps element");
+ }
+ }
+ return;
+}
+
+static void _parse_acqu_assist_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t *gpsdata_assist)
+{
+ static char *element[] = {"tow_msec", "sat_id", "dopl0", "dopl1", "code_ph", "code_ph_int", "GPS_bitno", "srch_w", "az", "elev"};
+ int nelem = (int) NUM_OF_ELEMENTS(element);
+ int count;
+
+ count = _gps_element_compare(element, element_str, nelem);
+ dbg("Enter");
+
+ switch (count) {
+ case 0:
+ gpsdata_assist->acq_assist.gpsTow = atoi(element_value);
+ dbg("acq_assist.gpsTow - %d\n", gpsdata_assist->acq_assist.gpsTow);
+ break;
+
+ case 1:
+ gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].satId = *element_value;
+ dbg("lcsAcquisitionSatInfo[0].satId - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].satId);
+ break;
+
+ case 2:
+ gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].doppler0 = atoi(element_value);
+ dbg("lcsAcquisitionSatInfo[0].dopl0 - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].doppler0);
+ break;
+
+ case 3:
+ gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].doppler1 = *element_value;
+ dbg("lcsAcquisitionSatInfo[0].doppler1 - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].doppler1);
+ break;
+
+ case 4:
+ gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].codePhase = atoi(element_value);
+ dbg("lcsAcquisitionSatInfo[0].codePhase - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].codePhase);
+ break;
+
+ case 5:
+ gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].intCodePhase = *element_value;
+ dbg("lcsAcquisitionSatInfo[0].intCodePhase - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].intCodePhase);
+ break;
+
+ case 6:
+ gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].gpsBitNumber = *element_value;
+ dbg("lcsAcquisitionSatInfo[0].GPS_bitno - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].gpsBitNumber);
+ break;
+
+ case 7:
+ gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].codePhaseSearchWindow = *element_value;
+ dbg("lcsAcquisitionSatInfo[0].codePhaseSearchWindow - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].codePhaseSearchWindow);
+ break;
+
+ case 8:
+ gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].azimuth = *element_value;
+ dbg("lcsAcquisitionSatInfo[0].azimuth - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].azimuth);
+ break;
+
+ case 9:
+ gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].elevation = *element_value;
+ dbg("lcsAcquisitionSatInfo[0].elevation - 0x%X\n", gpsdata_assist->acq_assist.lcsAcquisitionSatInfo[0].elevation);
+ break;
+
+ default:
+ dbg("invalid gps element");
+ }
+}
+
+static void _parse_nav_model_gps_elements(char *element_str, char *element_value, gps_assist_data_noti_t
+ *gpsdata_assist, gboolean ephem_and_clock, int element_count)
+{
+ static char *element[] = {
+ "sat_id", "l2_code", "ura", "sv_health", "iodc", "l2p_flag", "esr1", "esr2", "esr3", "esr4", "tgd", "toc", "af2", "af0",
+ "crs", "delta_n", "m0", "cuc", "ecc", "cus", "power_half", "toe", "fit_flag", "aoda", "cic", "omega0", "cis", "i0", "crc", "omega", "idot", "omega_dot"
+ };
+
+ int nelem = (int) NUM_OF_ELEMENTS(element);
+ int count;
+
+ if (element_count < 0 || element_count >= MAX_NUM_OF_GPS_NAV_ELEMENT) {
+ dbg("invalid count");
+ return;
+ }
+ count = _gps_element_compare(element, element_str, nelem);
+
+ dbg("Enter");
+ if (count == 0) {
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].satId = *element_value;
+ dbg("NavigationSatInfo[%d].satId - 0x%X\n", element_count, gpsdata_assist->navi_model.NavigationSatInfo[element_count].satId);
+ return;
+ }
+
+ if (ephem_and_clock) {
+ switch (count) {
+ case 1:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCodeOnL2 = *element_value;
+ break;
+
+ case 2:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemUra = *element_value;
+ break;
+
+ case 3:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemSvHealth = *element_value;
+ break;
+
+ case 4:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemIodc = atoi(element_value);
+ break;
+
+ case 5:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemL2PFlag = *element_value;
+ break;
+
+ case 6:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.NavigationSubFrameRsv.rsv1 = atoi(element_value);
+ break;
+
+ case 7:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.NavigationSubFrameRsv.rsv2 = atoi(element_value);
+ break;
+
+ case 8:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.NavigationSubFrameRsv.rsv3 = atoi(element_value);
+ break;
+
+ case 9:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.NavigationSubFrameRsv.rsv4 = atoi(element_value);
+ break;
+
+ case 10:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemTgd = *element_value;
+ break;
+
+ case 11:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemToc = atoi(element_value);
+ break;
+
+ case 12:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAf2 = *element_value;
+ break;
+
+ case 13:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAf1 = atoi(element_value);
+ break;
+
+ case 14:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAf0 = atoi(element_value);
+ break;
+
+ case 15:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCrs = atoi(element_value);
+ break;
+
+ case 16:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemDeltaN = atoi(element_value);
+ break;
+
+ case 17:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemM0 = atoi(element_value);
+ break;
+
+ case 18:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCuc = atoi(element_value);
+ break;
+
+ case 19:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemE = atoi(element_value);
+ break;
+
+ case 20:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCus = atoi(element_value);
+ break;
+
+ case 21:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAPowrHalf = atoi(element_value);
+ break;
+
+ case 22:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemToe = atoi(element_value);
+ break;
+
+ case 23:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemFitFlag = *element_value;
+ break;
+
+ case 24:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemAoda = *element_value;
+ break;
+
+ case 25:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCic = atoi(element_value);
+ break;
+
+ case 26:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemI0 = atoi(element_value);
+ break;
+
+ case 27:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemCrc = atoi(element_value);
+ break;
+
+ case 28:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemW = atoi(element_value);
+ break;
+
+ case 29:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemIDot = atoi(element_value);
+ break;
+
+ case 30:
+ gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemOmegaADot = atoi(element_value);
+ dbg("NavigationSatInfo[%d].NavigationEphemeris.ephemOmegaADot - 0x%X\n", element_count, gpsdata_assist->navi_model.NavigationSatInfo[element_count].NavigationEphemeris.ephemOmegaADot);
+ break;
+
+ default:
+ dbg("invalid gps element");
+ }
+ }
+}
+
+
+// Set coordinate elements : <latitude> <longitude> <altitude>
+static void _set_coordinate(xmlNodePtr node, gps_ellipsoid_po_t *point, int isalt, int altitude)
+{
+ // <parent_node> .. .. (xmlNodePtr node)
+ // <coordinate> <latitude> <north>0</north> <degrees>0</degrees> </latitude> <longitude>0</longitude> </coordinate>
+ // <altitude> <height_above_surface>0</height_above_surface> <height>0</height> </altitude>
+ // .. .. <\parent_node>
+
+ xmlNodePtr coordinate_node = NULL, temp_node = NULL;
+
+ memset(node_name, 0x00, sizeof(node_name));
+ memset(node_value, 0x00, sizeof(node_value));
+
+ sprintf(node_name, "%s", "coordinate");
+ coordinate_node = xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
+
+ sprintf(node_name, "%s", "latitude");
+ temp_node = xmlNewChild(coordinate_node, NULL, BAD_CAST node_name, NULL);
+
+ sprintf(node_name, "%s", "north");
+ sprintf(node_value, "%d", 0);
+ xmlNewChild(temp_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", "degrees");
+ sprintf(node_value, "%d", (int) point->latitude);
+ xmlNewChild(temp_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", "longitude");
+ sprintf(node_value, "%d", (int) point->longitude);
+ xmlNewChild(coordinate_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ if (isalt) {
+ sprintf(node_name, "%s", "altitude");
+ temp_node = xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
+ sprintf(node_name, "%s", "height_above_surface");
+ sprintf(node_value, "%d", 0);
+ xmlNewChild(temp_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+ sprintf(node_name, "%s", "height");
+ sprintf(node_value, "%d", altitude);
+ xmlNewChild(temp_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+ }
+ return;
+}
+
+static void _set_loc_info_ellipse_elements(xmlNodePtr node, void *elliplse, int is_unc_ellipse)
+{
+ gps_po_unc_ellipse_t *p_unc_ellipse;
+ gps_po_alt_unc_ellipse_t *p_alt_unc_ellipse;
+ unsigned char semiMajorAxis, semiMinorAxis, orientationAngle, confidence;
+
+ memset(node_name, 0x00, sizeof(node_name));
+ memset(node_value, 0x00, sizeof(node_value));
+
+ if (is_unc_ellipse) {
+ p_unc_ellipse = (gps_po_unc_ellipse_t *) elliplse;
+ semiMajorAxis = p_unc_ellipse->semiMajorAxis;
+ semiMinorAxis = p_unc_ellipse->semiMinorAxis;
+ orientationAngle = p_unc_ellipse->orientationAngle;
+ confidence = p_unc_ellipse->confidence;
+ } else {
+ p_alt_unc_ellipse = (gps_po_alt_unc_ellipse_t *) elliplse;
+ semiMajorAxis = p_alt_unc_ellipse->semiMajorAxis;
+ semiMinorAxis = p_alt_unc_ellipse->semiMinorAxis;
+ orientationAngle = p_alt_unc_ellipse->orientationAngle;
+ confidence = p_alt_unc_ellipse->confidence;
+ }
+
+ sprintf(node_name, "%s", "uncert_semi_major");
+ sprintf(node_value, "%d", semiMajorAxis);
+ xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", "uncert_semi_minor");
+ sprintf(node_value, "%d", semiMinorAxis);
+ xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", "orient_major");
+ sprintf(node_value, "%d", orientationAngle);
+ xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", "confidence");
+ sprintf(node_value, "%d", confidence);
+ xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+}
+
+static xmlChar* _generate_confirm_measure_pos_xml_text(gps_measure_position_confirm_t *gps_measure_position_confirm)
+{
+ xmlDocPtr doc = NULL;
+ xmlNodePtr root_node = NULL, node = NULL;
+ xmlNodePtr gps_msr_node = NULL, shape_data_node = NULL, loc_child_node = NULL;
+ xmlChar *xml = NULL;
+ int count = 0, altitude, size;
+
+/*
+ Creates a new XML document
+================================================================================================================================
+
+
+ <?xml version="1.0"?>
+ <pos xsi:noNamespaceSchemaLocation="pos.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <GPS_meas>
+ <ref_time_only>
+ <tow_msec></tow_msec>
+ </ref_time_only>
+ <meas_params>
+ <sat_id></sat_id><carr2_noise></carr2_noise><dopl></dopl><whole_chips></whole_chips><fract_chips></fract_chips>
+ <multi_path literal="xx"></multi_path> <psr_rms_err></psr_rms_err>
+ </meas_params>
+ </GPS_meas>
+ <location>
+ <time_of_fix></time_of_fix><
+ <location_parameters>
+ <shape_data>
+ <ellipsoid_point>
+ <coordinate>
+ <latitude><north></north><degrees></degrees></latitude><longitude></longitude>
+ </coordinate>
+ </ellipsoid_point>
+ <ellipsoid_point_uncert_circle>
+ <uncert_circle></uncert_circle>
+ <coordinate>
+ <latitude> <> <\> ...</latitude> <longitude></longitude>
+ </coordinate>
+ </ellipsoid_point_uncert_circle>
+ <ellipsoid_point_uncert_ellipse>
+ <coordinate>
+ <latitude><> <\>..<longitude></longitude>
+ </coordinate>
+ <uncert_ellipse><uncert_semi_major></uncert_semi_major><uncert_semi_minor></uncert_semi_minor>
+ <orient_major></orient_major><confidence></confidence></uncert_ellipse>
+ </ellipsoid_point_uncert_ellipse>
+ <polygon>
+ <coordinate*>
+ <latitude><> <\>...</latitude><longitude></longitude>
+ </coordinate>
+ </polygon>
+ <ellipsoid_point_alt>
+ <coordinate>
+ <latitude><> <\>..</latitude><longitude></longitude>
+ </coordinate>
+ <altitude>
+ <height_above_surface></height_above_surface><height></height>
+ </altitude>
+ </ellipsoid_point_alt>
+ <ellipsoid_point_alt_uncertellipse>
+ <coordinate>
+ <latitude> <> <\>.. ..</latitude><longitude></longitude>
+ </coordinate>
+ <altitude>
+ <height_above_surface></height_above_surface><height></height>
+ </altitude>
+ <uncert_semi_major></uncert_semi_major><uncert_semi_minor></uncert_semi_minor><orient_major></orient_major>
+ <confidence></confidence><uncert_alt></uncert_alt>
+ </ellipsoid_point_alt_uncertellipse>
+ <ellips_arc>
+ <coordinate>
+ <latitude><> <\> .. </latitude><longitude></longitude>
+ </coordinate><
+ <inner_rad></inner_rad>
+ <uncert_rad></uncert_rad><offset_angle></offset_angle><included_angle></included_angle>
+ <confidence></confidence>
+ </ellips_arc>
+ </shape_data>
+ </location_parameters>
+ </location>
+ <assist_data>
+ <msr_assist_data/>
+ </assist_data>
+ </pos>
+ ================================================================================================================================
+ */
+
+ doc = xmlNewDoc(BAD_CAST "1.0");
+ dbg("Enter");
+
+ memset(node_name, 0x00, sizeof(node_name));
+ memset(node_value, 0x00, sizeof(node_value));
+ // root element
+ sprintf(node_name, "%s", POSITION_NODE);
+ // Creation of a new node element
+ root_node = xmlNewNode(NULL, BAD_CAST node_name);
+ // Set the root element of the document
+ xmlDocSetRootElement(doc, root_node);
+ sprintf(node_name, "%s", POSITION_NODE_ATTR_XSI);
+ sprintf(node_value, "%s", POSITION_NODE_ATTR_VAL_XSI);
+ // Create a new property carried by a node
+ xmlNewProp(root_node, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", POSITION_NODE_ATTR_XMLNS);
+ sprintf(node_value, "%s", POSITION_NODE_ATTR_VAL_XMLNS);
+ xmlNewProp(root_node, BAD_CAST node_name, BAD_CAST node_value);
+
+ // 1.GPS measure.
+ // Creation of a new child element, added at the end of @parent children list
+ sprintf(node_name, "%s", "GPS_meas");
+ gps_msr_node = xmlNewChild(root_node, NULL, BAD_CAST node_name, NULL);
+
+ sprintf(node_name, "%s", "ref_time_only");
+ node = xmlNewChild(gps_msr_node, NULL, BAD_CAST node_name, NULL);
+
+ sprintf(node_name, "%s", "tow_msec");
+ sprintf(node_value, "%d", (int) gps_measure_position_confirm->gps_measure.gpsTow);
+ xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ // creatation of <meas_params> elements.
+ for (count = 0; count < gps_measure_position_confirm->gps_measure.nrOfSats; count++) {
+ xmlNodePtr multipath_node = NULL;
+ sprintf(node_name, "%s", "meas_params");
+ node = xmlNewChild(gps_msr_node, NULL, BAD_CAST node_name, NULL);
+
+ sprintf(node_name, "%s", "sat_id");
+ sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].satId);
+ xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", "carr2_noise");
+ sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].cno);
+ xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", "dopl");
+ sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].doppler);
+ xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", "whole_chips");
+ sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].wholeChips);
+ xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", "fract_chips");
+ sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].fracChips);
+ xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", "multi_path");
+ sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].lcsMultiPath);
+ multipath_node = xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+ xmlNewProp(multipath_node, BAD_CAST "literal", BAD_CAST "not_measured");
+
+ sprintf(node_name, "%s", "psr_rms_err");
+ sprintf(node_value, "%d", gps_measure_position_confirm->gps_measure.GpsMeasure[count].pseuRangeRmsErr);
+ xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+ }
+
+ // 2.Location.
+ sprintf(node_name, "%s", "location");
+ node = xmlNewChild(root_node, NULL, BAD_CAST node_name, NULL);
+
+ sprintf(node_name, "%s", "time_of_fix");
+ sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.fixType);
+ xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ // location_parameters
+ sprintf(node_name, "%s", "location_parameters");
+ node = xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
+
+ // shape_data
+ sprintf(node_name, "%s", "shape_data");
+ shape_data_node = xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
+
+ // ellipsoid_point
+ sprintf(node_name, "%s", "ellipsoid_point");
+ node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
+ // set coordinate.
+ _set_coordinate(node, &(gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_po), 0, 0);
+
+ // ellipsoid_point_uncert_circle
+ sprintf(node_name, "%s", "ellipsoid_point_uncert_circle");
+ node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
+ sprintf(node_name, "%s", "uncert_circle");
+ sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.p_unc_clrcle.uncertainRadius);
+ xmlNewChild(node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+ // set coordinate parameters.
+ _set_coordinate(node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_unc_clrcle.point), 0, 0);
+
+ // ellipsoid_point_uncert_ellipse
+ sprintf(node_name, "%s", "ellipsoid_point_uncert_ellipse");
+ loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
+ // set coordinate parameters.
+ _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_unc_clrcle.point), 0, 0);
+
+ sprintf(node_name, "%s", "uncert_ellipse");
+ node = xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, NULL);
+ // set location ellipse parametes.
+ _set_loc_info_ellipse_elements(node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_unc_ellipse), 1);
+
+ sprintf(node_name, "%s", "polygon");
+ loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
+ for (count = 0; count < gps_measure_position_confirm->loc_info.measured_loc_info.polygon.noOfPoints; count++) {
+ // set coordinate parameters.
+ _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.polygon.points[count]), 0, 0);
+ }
+
+ // ellipsoid_point_alt
+ sprintf(node_name, "%s", "ellipsoid_point_alt");
+ loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
+ altitude = gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_alt.altitude;
+ // set coordinate parameters.
+ _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_alt.point), 1, altitude);
+
+ // ellipsoid_point_alt_uncertellipse
+ sprintf(node_name, "%s", "ellipsoid_point_alt_uncertellipse");
+ loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
+ altitude = gps_measure_position_confirm->loc_info.measured_loc_info.p_alt_unc_ellipse.altitude;
+ // set coordinate parameters.
+ _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_alt_unc_ellipse.point), 1, altitude);
+ // set location ellipse parametes.
+ _set_loc_info_ellipse_elements(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.p_alt_unc_ellipse), 0);
+
+ sprintf(node_name, "%s", "uncert_alt");
+ sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.p_alt_unc_ellipse.uncertainAltitude);
+ xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ // ellipsoid_point_alt_uncertellipse
+ sprintf(node_name, "%s", "ellips_arc");
+ loc_child_node = xmlNewChild(shape_data_node, NULL, BAD_CAST node_name, NULL);
+ _set_coordinate(loc_child_node, &(gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.point), 0, 0);
+
+ sprintf(node_name, "%s", "inner_rad");
+ sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.innerRadius);
+ xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", "uncert_rad");
+ sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.uncertainRadius);
+ xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", "offset_angle");
+ sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.offsetAngle);
+ xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", "included_angle");
+ sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.includedAngle);
+ xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ sprintf(node_name, "%s", "confidence");
+ sprintf(node_value, "%d", gps_measure_position_confirm->loc_info.measured_loc_info.ellipsoid_arc.confidence);
+ xmlNewChild(loc_child_node, NULL, BAD_CAST node_name, BAD_CAST node_value);
+
+ // 3. assist data /msr_assist_data
+ sprintf(node_name, "%s", "assist_data");
+ node = xmlNewChild(root_node, NULL, BAD_CAST node_name, NULL);
+ sprintf(node_name, "%s", "msr_assist_data");
+ xmlNewChild(node, NULL, BAD_CAST node_name, NULL);
+
+ // Dump an XML document in memory and return the #xmlChar * and it's size in bytes
+ xmlDocDumpMemory(doc, &xml, &size);
+ dbg("xmlcontetnt:\n");
+ dbg("%s", (char *) xml);
+ // Free up all the structures used by a document, tree included.
+ xmlFreeDoc(doc);
+ xmlCleanupParser();
+ return xml;
+}
+
+static gboolean on_notification_gps_assist_data(CoreObject *o, const void *event_info, void *user_data)
+{
+ int fd;
+ gps_assist_data_noti_t gps_data_assist;
+ char *node = NULL, *node_value = NULL;
+ char *attribute = NULL, *attr_value = NULL;
+ enum gps_assist_element_type node_type = -1, set_element_type = -1;
+ int nav_model_node_count = -1;
+ int alm_node_count = -1;
+ int gps_tow_assist_count = -1;
+ char *line = NULL, *pos = NULL;
+ char *xml_line = NULL;
+ gboolean ret;
+ xmlTextReaderPtr reader;
+ gboolean _gps_assist_data = FALSE, gps_tow_assist = FALSE;
+ gboolean ephem_and_clock = FALSE, alm_elem = FALSE;
+
+ dbg("enter");
+
+/*
+ Example:GPS assist XML data will be in below format.
+================================================================================================================================
+ +CPOSR:<?xml version="1.0" encoding="UTF-8"?>
+ <pos xsi:noNamespaceSchemaLocation="pos.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <assist_data>
+ <GPS_assist>
+ <ref_time>
+ <GPS_time> <> <\>..<\GPS_time> <GPS_TOW_assist*> <> <\> ..<\GPS_TOW_assist>
+ </ref_time>
+
+ <location_parameters>
+ <shape_data> <ellipsoid_point_alt_uncertellipse> </coordinate> <> <\>...</coordinate> <altitude> <\altitude>
+ <uncert_semi_major> </uncert_semi_major> <uncert_semi_minor> </uncert_semi_minor> <orient_major> </orient_major> <confidence> </confidence>
+ <uncert_alt> </uncert_alt> </ellipsoid_point_alt_uncertellipse> </shape_data>
+ </location_parameters>
+
+ <DGPS_corrections>
+ <sat_id> </sat_id> <IODE> </IODE> <UDRE></UDRE> <PRC></PRC> <RRC></RRC>
+ </DGPS_corrections>
+
+ <nav_model_elem*>
+ <sat_id> </sat_id> <sat_status literal="xx"></sat_status>
+ <ephem_and_clock?> <l2_code></l2_code> <> <\> .. .. <\ephem_and_clock>
+ </nav_model_elem>
+
+ <ionospheric_model> <alfa0> </alfa0> <alfa1> </alfa1> <alfa2> </alfa2> <alfa3></alfa3>
+ <beta0></beta0> <beta1></beta1> <beta2></beta2> <beta3> </beta3>
+ </ionospheric_model>
+
+ <UTC_model>
+ <a1></a1><a0></a0><tot></tot><wnt></wnt> <dtls></dtls> <wnlsf></wnlsf> <dn></dn><dtlsf></dtlsf>
+ </UTC_model>
+ <almanac>
+ <wna>0</wna> <alm_elem*> <> <\> ...<\alm_elem>
+ </almanac>
+
+ <acqu_assist>
+ <tow_msec></tow_msec> <sat_info> <> <\> ... <\sat_info>
+ </acqu_assist>
+
+ </GPS_assist>
+ </assist_data>
+ </pos>
+================================================================================================================================
+*/
+
+ memset((void *) &gps_data_assist, 0x00, sizeof(gps_data_assist));
+ xml_line = (char *) ((GSList *) event_info)->data;
+
+ if (g_str_has_prefix((char *) xml_line, "+CPOSR:")) {
+ dbg("notification line with prefix");
+ pos = (char *) xml_line + strlen("+CPOSR:");
+ } else {
+ pos = (char *) xml_line;
+ }
+ line = g_strdup((char *) pos);
+ // open file.
+ if ((fd = open(FILE_NAME, O_WRONLY | O_CREAT | O_TRUNC | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, S_IRWXU)) == -1) {
+ dbg("Cannot open file\n");
+ g_free(line);
+ return FALSE;
+ }
+ // write gps xml data into file.
+ if (write(fd, (const void *) line, strlen(line)) == -1) {
+ dbg("Cannot write into file\n");
+ close(fd);
+ g_free(line);
+ return FALSE;
+ }
+ // free the memory pointed to by line.
+ g_free(line);
+
+ dbg("read xml file");
+ reader = xmlReaderForFile(FILE_NAME, NULL, 0);
+
+ while (xmlTextReaderRead(reader)) {
+ // Get the node type of the current node
+ switch (xmlTextReaderNodeType(reader)) {
+ case XML_READER_TYPE_ELEMENT:
+ {
+ // Read the qualified name of the node.
+ node = (char *) xmlTextReaderConstName(reader);
+ dbg("Element: %s\n ", node);
+ if (node != NULL) {
+ // check type of sub element of <GPS_assist>
+ set_element_type = _get_element_type(node);
+ if ((int) set_element_type != -1) // ignore negative value as excepted element type not set.
+ node_type = set_element_type;
+
+ dbg("xml node type : %d", node_type);
+
+ // Check for position measurement data.
+ if (strcmp(node, "pos_meas") == 0) {
+ // Deallocate all the resources associated to the reader
+ xmlFreeTextReader(reader);
+ xmlCleanupParser();
+ dbg("gps postion measurement notification ");
+ // GPS position measurement notification.
+ ret = on_notification_gps_measure_position_from_modem(o, FILE_NAME, user_data);
+ // remove file.
+ close(fd);
+ if (access(FILE_NAME, F_OK) == 0) {
+ if (remove(FILE_NAME))
+ dbg("file removed");
+ }
+ return ret;
+ }
+
+ // Moves the position of the current instance to the next attribute associated with the current node.
+ while (xmlTextReaderMoveToNextAttribute(reader)) {
+ // Read the qualified name of the node
+ attribute = (char *) xmlTextReaderConstName(reader);
+ dbg("attribute value - %s\n", attribute);
+
+ // Provides the text value of the node if present.
+ attr_value = (char *) xmlTextReaderConstValue(reader);
+ dbg("=\"%s\"\n", attr_value);
+
+ // Read attribute value of <nav_model_elem>
+ if (node_type == NAV_MODEL_ELEM) {
+ if (strcmp(node, "sat_status") == 0 && strcmp(attribute, "literal") == 0) {
+ gps_data_assist.navi_model.NavigationSatInfo[nav_model_node_count].NavigationSatStatus = _modem_sat_status_info_2_tel_sat_info(attr_value);
+ dbg("navigation sat status of nav model element - %d\n", gps_data_assist.navi_model.NavigationSatInfo[nav_model_node_count].NavigationSatStatus);
+ }
+ }
+ // Read attribute value of <acqu_assist>
+ else if (node_type == ACQU_ASSIST) {
+ if (strcmp(node, "dopl1_uncert") == 0 && strcmp(attribute, "literal") == 0) {
+ gps_data_assist.acq_assist.lcsAcquisitionSatInfo[0].dopplerUncertainty = _modem_acqa_assit_doppler_2_tel_doppler(attr_value);
+ dbg("doppler uncertainty of acqu assist data- %d", gps_data_assist.acq_assist.lcsAcquisitionSatInfo[0].dopplerUncertainty);
+ }
+ }
+ } // end of attribute check.
+
+ // check GPS data is having GPS_assist data.
+ if (strcmp(node, "GPS_assist") == 0) {
+ _gps_assist_data = TRUE;
+ }
+
+ if (_gps_assist_data == TRUE) {
+ // number of GPS_TOW_assist elements.
+ if (strcmp(node, "GPS_TOW_assist") == 0) {
+ gps_tow_assist_count++;
+ gps_tow_assist = TRUE;
+ } else if (strcmp(node, "nav_model_elem") == 0) {
+ // number of nav_model_elem.
+ nav_model_node_count++;
+ } else if (strcmp(node, "alm_elem") == 0) {
+ // number of alm_elem elements.
+ alm_node_count++;
+ dbg("alm_elem_count - %d", alm_node_count);
+ if (node_type == ALMANAC)
+ alm_elem = TRUE;
+ } else if (strcmp(node, "ephem_and_clock") == 0 && node_type == NAV_MODEL_ELEM) {
+ ephem_and_clock = TRUE;
+ }
+ }
+ }
+ xmlTextReaderMoveToElement(reader);
+ } // end of reading node type.
+ break;
+
+ case XML_READER_TYPE_TEXT:
+ {
+ // Provides the text value of the node if present
+ node_value = (char *) xmlTextReaderConstValue(reader);
+ dbg("node_value: %s\n", node_value);
+
+ if (node_value != NULL) {
+ switch (node_type) {
+ case REF_TIME:
+ _parse_ref_time_gps_elements(node, node_value, &gps_data_assist, gps_tow_assist, gps_tow_assist_count);
+ break;
+
+ case LOCATION_PARM:
+ _parse_location_parameters(node, node_value, &gps_data_assist);
+ break;
+
+ case DGPS_CORRECTION:
+ _parse_dgps_correction_gps_elements(node, node_value, &gps_data_assist);
+ break;
+
+ case NAV_MODEL_ELEM:
+ _parse_nav_model_gps_elements(node, node_value, &gps_data_assist, ephem_and_clock, nav_model_node_count);
+ break;
+
+ case IONOSPHERIC_MODEL:
+ _parse_ionospheric_model_gps_elements(node, node_value, &gps_data_assist);
+ break;
+
+ case UTC_MODEL:
+ _parse_utc_model_gps_elements(node, node_value, &gps_data_assist);
+ break;
+
+ case ALMANAC:
+ _parse_almanc_model_gps_elements(node, node_value, &gps_data_assist, alm_elem, alm_node_count);
+ break;
+
+ case ACQU_ASSIST:
+ _parse_acqu_assist_gps_elements(node, node_value, &gps_data_assist);
+ break;
+
+ default:
+ dbg("invalid element");
+ }
+ }
+ } // end of reading node value.
+ break;
+ }
+ } // end of parsing.
+
+ // Deallocate all the resources associated to the reader
+ xmlFreeTextReader(reader);
+ xmlCleanupParser();
+
+ // remove xml file.
+ close(fd);
+ if (access(FILE_NAME, F_OK) == 0) {
+ if (remove(FILE_NAME))
+ dbg("file removed");
+ }
+
+ tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)),
+ o, TNOTI_GPS_ASSIST_DATA, sizeof(gps_data_assist), &gps_data_assist);
+ return TRUE;
+}
+
+static gboolean on_notification_gps_measure_position_from_modem(CoreObject *o, char *file_name, void *user_data)
+{
+ char *node = NULL, *node_value = NULL;
+ char *attribute = NULL;
+ char *attr_value = NULL;
+ gps_measure_position_indi_t gps_measure_position_indi;
+ gboolean rep_quant = FALSE;
+ xmlTextReaderPtr reader;
+
+ memset(&gps_measure_position_indi, 0x00, sizeof(gps_measure_position_indi));
+ reader = xmlReaderForFile(file_name, NULL, 0);
+
+ while (xmlTextReaderRead(reader)) {
+ switch (xmlTextReaderNodeType(reader)) {
+ case XML_READER_TYPE_ELEMENT:
+ {
+ node = (char *) xmlTextReaderConstName(reader);
+ dbg("Element: %s", node);
+ if (node != NULL) {
+ // Read attribute value.
+ while (xmlTextReaderMoveToNextAttribute(reader)) {
+ attribute = (char *) xmlTextReaderConstName(reader);
+ dbg("Attribute value - %s\n", attribute);
+ attr_value = (char *) xmlTextReaderConstValue(reader);
+ dbg("=\"%s\"\n", attr_value);
+
+ if (strcmp(node, "mult_sets") == 0) {
+ if (strcmp(attribute, "literal") == 0) {
+ if (strcmp(attr_value, "one") == 0)
+ gps_measure_position_indi.use_multi_sets = GPS_MULTIPLESETS_ONESET;
+ else if (strcmp(attr_value, "multiple") == 0)
+ gps_measure_position_indi.use_multi_sets = GPS_MULTIPLESETS_MULTIPLESETS;
+ }
+ dbg("gps_measure_position_indi.use_multi_sets - 0x%x\n", gps_measure_position_indi.use_multi_sets);
+ } else if (strcmp(node, "rep_quant") == 0) {
+ rep_quant = TRUE;
+ if (strcmp(attribute, "addl_assist_data_req") == 0) {
+ if (strcmp(attr_value, "true") == 0)
+ gps_measure_position_indi.add_assist_req = GPS_ADDITIONAL_ASSISREQ_REQ;
+ else
+ gps_measure_position_indi.add_assist_req = GPS_ADDITIONAL_ASSISREQ_NOT_REQ;
+ } else if (strcmp(attribute, "gps_timing_of_cell_wanted") == 0) {
+ if (strcmp(attr_value, "true") == 0)
+ gps_measure_position_indi.cell_timing_wnt = GPS_CELLTIMING_WANTED;
+ else
+ gps_measure_position_indi.cell_timing_wnt = GPS_CELLTIMING_NOT_WANTED;
+ }
+ }
+ } // end of attribute check
+
+ if (strcmp(node, "ms_assisted") == 0) {
+ gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_ASSISTED;
+ } else if (strcmp(node, "ms_assisted_no_accuracy") == 0) {
+ gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_ASSISTED;
+ } else if (strcmp(node, "ms_based") == 0) {
+ gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_BASED;
+ } else if (strcmp(node, "ms_based_pref") == 0) {
+ gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_BASED_PREF;
+ } else if (strcmp(node, "ms_assisted_pref") == 0) {
+ gps_measure_position_indi.method_type = GPS_METHODTYPE_MS_ASSISTED_PREF;
+ }
+ }
+ xmlTextReaderMoveToElement(reader);
+ }
+ break;
+
+ case XML_READER_TYPE_TEXT:
+ {
+ node_value = (char *) xmlTextReaderConstValue(reader);
+ dbg("element-value: %s", node_value);
+ if (node_value != NULL) {
+ if (strcmp(node, "resp_time_seconds") == 0) {
+ gps_measure_position_indi.rsp_time = *node_value;
+ dbg("gps_measure_position_indi.rsp_time - 0x%x", gps_measure_position_indi.rsp_time);
+ }
+ if (rep_quant == TRUE) {
+ if (strcmp(node, "hor_acc") == 0)
+ gps_measure_position_indi.accuracy.horizontalAccuracy = *node_value;
+ else if (strcmp(node, "vert_acc") == 0)
+ gps_measure_position_indi.accuracy.vertcalAccuracy = *node_value;
+ }
+ }
+ }
+ break;
+ }
+ }
+ xmlFreeTextReader(reader);
+ xmlCleanupParser();
+
+ tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)),
+ o, TNOTI_GPS_MEASURE_POSITION, sizeof(gps_measure_position_indi), &gps_measure_position_indi);
+ return TRUE;
+}
+
+
+// CONFIRMATION
+static void on_confirmation_gps_message_send(TcorePending *p, gboolean result, void *user_data)
+{
+ dbg("Entry");
+
+ if (result == FALSE) { // Fail
+ dbg("SEND FAIL");
+ } else {
+ dbg("SEND OK");
+ }
+
+ dbg("Exit");
+ return;
+}
+
+static gboolean on_notification_reset_assist_data(CoreObject *o, const void *event_info, void *user_data)
+{
+ dbg("enter!\n");
+ tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)),
+ o, TNOTI_GPS_RESET_ASSIST_DATA, 0, NULL);
+
+ return TRUE;
+}
+static void on_confirmation_gps_measure_position(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ //GPS server does not except confirmation for GPS measure position request.
+ dbg("enter");
+
+ dbg("exit");
+}
+
+static TReturn gps_confirm_measure_pos(CoreObject *o, UserRequest *ur)
+{
+ char *raw_str = NULL;
+ char *cmd_str = NULL;
+ TcorePending *pending = NULL;
+ TcoreATRequest *req = NULL;
+ TcoreHal *hal = NULL;
+ gboolean ret = FALSE;
+ xmlChar *xml = NULL;
+ unsigned char *data = NULL;
+ unsigned int data_len;
+ gps_measure_position_confirm_t gps_measure_pos_confirm;
+
+ dbg("enter!");
+ if (!o || !ur)
+ return TCORE_RETURN_EINVAL;
+
+ data = (unsigned char *) tcore_user_request_ref_data(ur, &data_len);
+ memcpy(&gps_measure_pos_confirm, data, data_len);
+
+ // make confirm measure postion request in xml format.
+ xml = _generate_confirm_measure_pos_xml_text(&gps_measure_pos_confirm);
+ if (!xml) {
+ err("xml text generation failed");
+ return TCORE_RETURN_EINVAL;
+ }
+
+ // AT+CPOS<cr>text is entered<ctrl-z/esc>
+ raw_str = g_strdup_printf("AT+CPOS%s", "\r");
+ cmd_str = g_strdup_printf("%s%s\x1A", raw_str, xml);
+
+ dbg("command string : %s", cmd_str);
+ pending = tcore_pending_new(o, 0);
+ req = tcore_at_request_new(cmd_str, NULL, TCORE_AT_NO_RESULT);
+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+ tcore_pending_set_request_data(pending, strlen(cmd_str), req);
+ tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
+ tcore_pending_set_send_callback(pending, on_confirmation_gps_message_send, NULL);
+ tcore_pending_set_response_callback(pending, on_confirmation_gps_measure_position, NULL);
+ tcore_pending_link_user_request(pending, ur);
+
+ // HAL
+ hal = tcore_object_get_hal(o);
+ // Send request to HAL
+ ret = tcore_hal_send_request(hal, pending);
+ if (TCORE_RETURN_SUCCESS != ret) {
+ err("Request send failed");
+ ret = FALSE;
+ }
+
+ dbg("exit");
+ g_free(raw_str);
+ g_free(cmd_str);
+ xmlFree(xml);
+ return ret;
+}
+
+static struct tcore_gps_operations gps_ops = {
+ .confirm_measure_pos = gps_confirm_measure_pos,
+};
+
+gboolean s_gps_init(TcorePlugin *p, TcoreHal *h)
+{
+ CoreObject *o = NULL;
+ GQueue *work_queue = NULL;
+
+ dbg("enter");
+
+ o = tcore_gps_new(p, "gps", &gps_ops, h);
+ if (!o)
+ return FALSE;
+
+ work_queue = g_queue_new();
+ tcore_object_link_user_data(o, work_queue);
+
+ tcore_object_add_callback(o, "+CPOSR", on_notification_gps_assist_data, NULL);
+ tcore_object_add_callback(o, "+XCPOSR", on_notification_reset_assist_data, NULL);
+ dbg("exit");
+ return TRUE;
+}
+
+void s_gps_exit(TcorePlugin *p)
+{
+ CoreObject *o;
+ GQueue *work_queue;
+
+ o = tcore_plugin_ref_core_object(p, "gps");
+ if (!o)
+ return;
+
+ work_queue = tcore_object_ref_user_data(o);
+ if (work_queue)
+ g_queue_free(work_queue);
+
+ tcore_gps_free(o);
+}
{
unsigned int data_len = 0;
char data[] = "AT+CPAS";
+
dbg("TIMEOUT for 1st AT Command !!!!! NO Response for initial AT command. Resending it");
data_len = sizeof(data);
void on_response_bootup_subscription(TcorePending *p, int data_len, const void *data, void *user_data)
{
const TcoreATResponse *resp = data;
+
dbg("entry of on_response_bootup_subscription() - response comes\n");
if (resp->success) {
void on_response_last_bootup_subscription(TcorePending *p, int data_len, const void *data, void *user_data)
{
const TcoreATResponse *resp = data;
+
dbg("enry of on_response_last_bootup_subscription() - final response comes\n");
if (resp->success) {
dbg("SEND OK");
{
CoreObject *o = 0;
TcoreHal *h = 0;
+
o = tcore_pending_ref_core_object(p);
h = tcore_object_get_hal(o);
/* XBCSTAT subscription */
prepare_and_send_pending_request(plugin, "sap", "at+xbcstat=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
+ /* AGPS- assist data and reset assist data subscription */
+ prepare_and_send_pending_request(plugin, "gps", "at+cposr=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
+
+ prepare_and_send_pending_request(plugin, "gps", "at+xcposr=1", NULL, TCORE_AT_NO_RESULT, on_response_bootup_subscription);
/* text/pdu mode subscription*/
prepare_and_send_pending_request(plugin, "umts_sms", "at+cmgf=0", NULL, TCORE_AT_NO_RESULT, on_response_last_bootup_subscription);
TcorePlugin *plugin = NULL;
TcoreHal *hal = NULL;
TReturn ret;
+
dbg("Entry");
/* IMC Plugin dereferenced from pending request */
{
TcoreHal *hal = NULL;
TcorePending *pending = NULL;
+
dbg("Entered");
/* HAL has type itself,
static gboolean on_event_mux_channel_up(CoreObject *o, const void *event_info, void *user_data)
{
TcorePlugin *plugin = NULL;
+
dbg("Entry");
plugin = (TcorePlugin *) user_data;
TcorePending *pending = NULL;
hal = tcore_object_get_hal(o);
- if(FALSE == tcore_hal_get_power_state(hal)){
+ if (FALSE == tcore_hal_get_power_state(hal)) {
dbg("cp not ready/n");
return TCORE_RETURN_ENOSYS;
}
TcorePending *pending = NULL;
hal = tcore_object_get_hal(o);
- if(FALSE == tcore_hal_get_power_state(hal)){
+ if (FALSE == tcore_hal_get_power_state(hal)) {
dbg("cp not ready/n");
return TCORE_RETURN_ENOSYS;
}
char *cmd_str = NULL;
hal = tcore_object_get_hal(o);
- if(FALSE == tcore_hal_get_power_state(hal)){
+ if (FALSE == tcore_hal_get_power_state(hal)) {
dbg("cp not ready/n");
return TCORE_RETURN_ENOSYS;
}
#define NUM_PLAN_INTERNATIONAL 0x0070
#define NUM_PLAN_UNKNOWN 0x0060
+struct valid_pb_index{
+ int used_count;
+ int total_count;
+ int indexlist_populated;
+ int *indexlist;
+ int current_index;
+};
+static struct valid_pb_index __pbindex;
+
enum pb_usim_file_type {
PB_USIM_NAME = 0x01, /**< Name */
PB_USIM_NUMBER, /**< Number */
static TReturn s_update_record(CoreObject *o, UserRequest *ur);
static TReturn s_delete_record(CoreObject *o, UserRequest *ur);
+
+static void pbindex_reset()
+{
+ if(__pbindex.indexlist){
+ free(__pbindex.indexlist);
+ }
+ memset(&__pbindex, 0x00, sizeof(struct valid_pb_index));
+}
+
static enum tcore_response_command _find_resp_command(UserRequest *ur)
{
switch(tcore_user_request_get_command(ur))
return result;
}
-static void on_confirmation_phonebook_message_send(TcorePending *p, gboolean result, void *user_data)
-{
- dbg("msg out from queue");
-
- if (result == FALSE) { /* Fail */
- dbg("SEND FAIL");
- }
- else {
- dbg("SEND OK");
- }
-}
-
static char* _get_phonebook_type(enum tel_phonebook_type pb_type)
{
char *phonebook_type = NULL;
err("Memory allcoation failed");
return phonebook_type;
}
-
+
switch(pb_type)
{
case PB_TYPE_FDN:
enum tel_phonebook_type phonebook_type = PB_TYPE_UNKNOWNN;
dbg(" Function entry ");
dbg("pb_type = %s", pb_type);
-
+
if(strcmp("FD", pb_type) == VAL_ZERO) {
phonebook_type = PB_TYPE_FDN;
}
else if(strcmp("AP", pb_type) == VAL_ZERO) {
phonebook_type = PB_TYPE_USIM;
}
-
+
dbg(" Function exit");
return phonebook_type;
}
static gboolean on_event_phonebook_status(CoreObject *o, const void *event_info, void *user_data)
{
dbg("Phonebook init received from modem");
-
+
_get_support_list(o);
-
+
return TRUE;
}
{
const TcoreATResponse *resp = data;
UserRequest *ur = NULL;
- CoreObject *o = NULL;
enum tcore_request_command req_cmd = TREQ_UNKNOWN;
int *selected_pb = user_data;
- GQueue *queue = NULL;
+
dbg(" Function entry ");
- o = tcore_pending_ref_core_object(p);
ur = tcore_pending_ref_user_request(p);
if (!ur){
dbg("error - current ur is NULL");
return;
}
- queue = tcore_object_ref_user_data(o);
- if(queue) {
- ur = tcore_user_request_ref(ur);
- }
-
req_cmd = tcore_user_request_get_command(ur);
dbg("origin treq command [%x]", req_cmd);
if(resp->success > VAL_ZERO) {
+ CoreObject *o = NULL;
+ o = tcore_pending_ref_core_object(p);
+
dbg("RESPONSE OK");
tcore_phonebook_set_selected_type(o, *selected_pb);
switch (req_cmd)
dbg("error TREQ_PHONEBOOK_GETCOUNT");
memset(&resp_getcount, 0x00, sizeof(struct tresp_phonebook_get_count));
resp_getcount.result = PB_FAIL;
- tcore_user_request_send_response(ur, TRESP_PHONEBOOK_GETCOUNT, sizeof(struct tresp_phonebook_get_count), &resp_getcount);
+ tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_phonebook_get_count), &resp_getcount);
}
break;
case TREQ_PHONEBOOK_GETMETAINFO:
{
struct tresp_phonebook_read_record resp_readrecord;
dbg("error TREQ_PHONEBOOK_READRECORD");
+ pbindex_reset();
memset(&resp_readrecord, 0x00, sizeof(struct tresp_phonebook_read_record));
resp_readrecord.result = PB_FAIL;
resp_readrecord.phonebook_type = *selected_pb;
- tcore_user_request_send_response(ur, TRESP_PHONEBOOK_READRECORD, sizeof(struct tresp_phonebook_read_record), &resp_readrecord);
+ tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_phonebook_read_record), &resp_readrecord);
}
break;
case TREQ_PHONEBOOK_UPDATERECORD:
}
}
+
+ free(selected_pb);
+ selected_pb = NULL;
+ dbg(" Function exit");
+}
+
+static void _on_response_getindexlist(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ const TcoreATResponse *resp = data;
+ UserRequest *ur = NULL;
+ struct tresp_phonebook_read_record resp_readrecord;
+ int *selected_pb = user_data;
+ int total_lines = 0;
+ int count = 0;
+ GSList *tokens=NULL;
+ const char *line;
+
+ dbg(" Function entry ");
+
+ ur = tcore_pending_ref_user_request(p);
+ if (!ur){
+ dbg("error - current ur is NULL");
+ return;
+ }
+ memset(&resp_readrecord, 0x00, sizeof(struct tresp_phonebook_read_record));
+ resp_readrecord.result = PB_FAIL;
+ resp_readrecord.phonebook_type = *selected_pb;
+ if(resp->success > 0)
+ {
+ CoreObject *o = NULL;
+ o = tcore_pending_ref_core_object(p);
+
+ dbg("RESPONSE OK");
+ tcore_phonebook_set_selected_type(o, *selected_pb);
+ if (resp->lines) {
+ total_lines = g_slist_length(resp->lines);
+ dbg("Total number of PB entry %d\n", total_lines);
+ if (total_lines < 1) {
+ msg("invalid message");
+ pbindex_reset();
+ goto EXIT;
+ }
+ __pbindex.indexlist = (int*)malloc(__pbindex.used_count * sizeof(int));
+ if(__pbindex.indexlist == NULL){
+ dbg("Failed to allocate memory");
+ pbindex_reset();
+ goto EXIT;
+ }
+ resp_readrecord.result = PB_SUCCESS;
+ for (count = 0; count < total_lines; count++) {
+ /* Take each line response at a time & parse it */
+ line = tcore_at_tok_nth(resp->lines, count);
+ tokens = tcore_at_tok_new(line);
+ __pbindex.indexlist[count] = atoi(g_slist_nth_data(tokens, 0));
+ dbg("__pbindex.indexlist[%d] = %d", count, __pbindex.indexlist[count]);
+ tcore_at_tok_free(tokens);
+ }
+ }
+ __pbindex.indexlist_populated = 1;
+ s_read_record(o, ur);
+ free(selected_pb);
+ selected_pb = NULL;
+ return;
+ }
+ else{
+ dbg("RESPONSE NOK");
+ }
+EXIT:
+ tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_phonebook_read_record), &resp_readrecord);
+
free(selected_pb);
selected_pb = NULL;
dbg(" Function exit");
}
memset(&res, 0x00, sizeof(struct tresp_phonebook_get_count));
+ res.result = PB_FAIL;
+
if(resp->success > VAL_ZERO) {
dbg("RESPONSE OK");
if(resp->lines) {
temp = (const char*)resp->lines->data;
tokens = tcore_at_tok_new(temp);
- if (g_slist_length(tokens) < VAL_ONE) {
+ if (g_slist_length(tokens) < VAL_THREE) {
+ //No of tokens must be three. We cannot proceed without used and total count.
msg("invalid message");
- tcore_at_tok_free(tokens);
- return;
+ goto EXIT;
}
}
res.result = PB_SUCCESS;
-
+
temp = (const char*)g_slist_nth_data(tokens, VAL_ZERO);
pbtype = util_removeQuotes((void*)temp);
res.type = _get_phonebook_enum(pbtype);
-
+
if(NULL != g_slist_nth_data(tokens, VAL_ONE)){
res.used_count = atoi(g_slist_nth_data(tokens, VAL_ONE));
+ __pbindex.used_count = res.used_count;
+ dbg("used_count %d", __pbindex.used_count);
}
-
+
if(NULL != g_slist_nth_data(tokens, VAL_TWO)){
res.total_count = atoi(g_slist_nth_data(tokens, VAL_TWO));
+ __pbindex.total_count = res.total_count;
}
dbg("used count = %d, total count= %d", res.used_count, res.total_count);
free(pbtype);
}
else{
dbg("RESPONSE NOK");
- res.result = PB_FAIL;
}
-
- tcore_user_request_send_response(ur, TRESP_PHONEBOOK_GETCOUNT, sizeof(struct tresp_phonebook_get_count), &res);
-
+EXIT:
tcore_at_tok_free(tokens);
+ tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_phonebook_get_count), &res);
dbg(" Function exit");
}
int *selected_pb = (int*)user_data;
dbg(" Function entry ");
-
+
ur = tcore_pending_ref_user_request(p);
if (!ur){
dbg("error - current ur is NULL");
}
memset(&res, 0x00, sizeof(struct tresp_phonebook_get_info));
+ res.result = PB_FAIL;
res.type = *selected_pb;
+
if(resp->success > VAL_ZERO) {
dbg("RESPONSE OK");
if(resp->lines) {
tokens = tcore_at_tok_new(line);
if (g_slist_length(tokens) < VAL_ONE) {
msg("invalid message");
- tcore_at_tok_free(tokens);
- return;
+ goto EXIT;
}
}
res.result = PB_SUCCESS;
-
+
res.number_length_max = atoi(g_slist_nth_data(tokens, VAL_ZERO));
res.text_length_max = atoi(g_slist_nth_data(tokens, VAL_ONE));
dbg("number_length_max %d text_length_max %d",res.number_length_max,res.text_length_max);
}
else{
dbg("RESPONSE NOK");
- res.result = PB_FAIL;
}
-
+EXIT:
tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_phonebook_get_info), &res);
-
- tcore_at_tok_free(tokens);
free(selected_pb);
selected_pb = NULL;
+ tcore_at_tok_free(tokens);
dbg(" Function exit");
+
}
static void on_response_read_record(TcorePending *p, int data_len, const void *data, void *user_data)
int *selected_pb = (int*)user_data;
dbg(" Function entry ");
-
+
ur = tcore_pending_ref_user_request(p);
if (!ur){
dbg("error - current ur is NULL");
}
memset(&res, 0x00, sizeof(struct tresp_phonebook_read_record));
+ res.result = PB_FAIL;
res.phonebook_type = *selected_pb;
-
+
if(resp->success > VAL_ZERO) {
dbg("RESPONSE OK");
if(resp->lines) {
tokens = tcore_at_tok_new(line);
if (g_slist_length(tokens) < VAL_ONE) {
msg("invalid message");
- tcore_at_tok_free(tokens);
- return;
+ pbindex_reset();
+ goto EXIT;
}
}
res.result = PB_SUCCESS;
-
- res.index = atoi(g_slist_nth_data(tokens, VAL_ZERO));
- res.next_index = (res.index + VAL_ONE);
- num_plan = atoi(g_slist_nth_data(tokens, VAL_TWO));
+ res.index = atoi(g_slist_nth_data(tokens, 0));
+ __pbindex.current_index++;
+ if(__pbindex.current_index >= __pbindex.used_count){
+ dbg("RESET");
+ res.next_index = 0;
+ pbindex_reset();
+ }else{
+ dbg("__pbindex.current_index %d", __pbindex.current_index);
+ res.next_index = __pbindex.indexlist[__pbindex.current_index];
+ }
+ num_plan = atoi(g_slist_nth_data(tokens, 2));
res.ton = _find_num_plan(num_plan);
- temp = g_slist_nth_data(tokens, VAL_ONE);
+ /*Remove the quotes("") from the number string*/
+ temp = g_slist_nth_data(tokens, 1);
member = util_removeQuotes((void*)temp);
- dbg("number %s - %d", member, (num_len-VAL_TWO));
memcpy(res.number, member, strlen(member));
+ dbg("number %s - %d", res.number, strlen((const char*)res.number));
free(member);
member = NULL;
- temp = g_slist_nth_data(tokens, VAL_THREE);
+ /*Remove the quotes("") from the name string*/
+ temp = g_slist_nth_data(tokens, 3);
member = util_removeQuotes((void*)temp);
- dbg("name %s - %d", member, strlen(member));
memcpy(res.name, member, strlen(member));
+ dbg("name %s - %d", res.name, strlen((const char*)res.name));
free(member);
member = NULL;
-
+ res.dcs = PB_TEXT_ASCII;
+ res.name_len = strlen((const char*)res.name);
if(NULL != g_slist_nth_data(tokens, VAL_FOUR)) {
if(atoi(g_slist_nth_data(tokens, VAL_FOUR)) == VAL_ZERO) {
dbg("phonebook entry not hidden");
num_len = strlen(g_slist_nth_data(tokens, VAL_SIX));
snprintf((char *)res.anr1, num_len+1, "%s", (char*)g_slist_nth_data(tokens, VAL_SIX));
}
-
+
if(NULL != g_slist_nth_data(tokens, VAL_SEVEN)){
num_plan = atoi(g_slist_nth_data(tokens, VAL_SEVEN));
res.anr1_ton = _find_num_plan(num_plan);
}
-
+
if(NULL != g_slist_nth_data(tokens, VAL_NINE)){
name_len = strlen(g_slist_nth_data(tokens, VAL_NINE));
memcpy(res.email1, g_slist_nth_data(tokens, VAL_NINE), name_len);
}
else{
dbg("RESPONSE NOK");
- res.result = PB_FAIL;
+ pbindex_reset();
}
-
- tcore_user_request_send_response(ur, TRESP_PHONEBOOK_READRECORD, sizeof(struct tresp_phonebook_read_record), &res);
-
- tcore_at_tok_free(tokens);
+EXIT:
+ tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_phonebook_read_record), &res);
free(selected_pb);
selected_pb = NULL;
+ tcore_at_tok_free(tokens);
dbg(" Function exit");
+
}
static void on_response_update_record(TcorePending *p, int data_len, const void *data, void *user_data)
else{
dbg("error - current ur is NULL");
}
-
+ dbg(" Function exit");
}
static void on_response_delete_record(TcorePending *p, int data_len, const void *data, void *user_data)
UserRequest *ur = NULL;
struct tresp_phonebook_delete_record res;
+ dbg(" Function entry ");
+
if(resp->success > VAL_ZERO) {
dbg("RESPONSE OK");
res.result = PB_SUCCESS;
else{
dbg("error - current ur is NULL");
}
+ dbg(" Function exit");
}
static void _response_get_support_list(TcorePending *p, int data_len, const void *data, void *user_data)
return;
}
+ noti_data.b_init = FALSE;
+
if(resp->success > VAL_ZERO) {
dbg("RESPONSE OK");
if(resp->lines) {
tokens = tcore_at_tok_new(line);
if (g_slist_length(tokens) < VAL_ONE) {
msg("invalid message");
- tcore_at_tok_free(tokens);
- return;
+ goto EXIT;
}
}
dbg("SIM barred-dialling-number");
}
pbtype = strtok (NULL, "(,)");
- g_free(temp);
+ free(temp);
}
-
+
noti_data.b_init = TRUE;
tcore_phonebook_set_support_list(o, ¬i_data.support_list);
tcore_phonebook_set_status(o, noti_data.b_init);
- tcore_at_tok_free(tokens);
}
else{
dbg("RESPONSE NOK");
- noti_data.b_init = FALSE;
tcore_phonebook_set_status(o, noti_data.b_init);
}
-
+EXIT:
tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_PHONEBOOK_STATUS,
sizeof(struct tnoti_phonebook_status), ¬i_data);
+ tcore_at_tok_free(tokens);
+ dbg(" Function exit");
}
static TReturn _get_support_list(CoreObject *o)
tcore_pending_set_request_data(pending, VAL_ZERO, req);
tcore_pending_set_response_callback(pending, _response_get_support_list, NULL);
- tcore_pending_set_send_callback(pending, on_confirmation_phonebook_message_send, NULL);
-
+
tcore_hal_send_request(hal, pending);
g_free(cmd_str);
const struct treq_phonebook_get_count *req_data;
int *pb_type = NULL;
char *phonebook_type = NULL;
+ UserRequest *ur_dup = NULL;
dbg(" Function entry ");
if (!o || !ur)
return TCORE_RETURN_EINVAL;
-
+
req_data = tcore_user_request_ref_data(ur, NULL);
+ ur_dup = tcore_user_request_ref(ur);
phonebook_type = (char*)_get_phonebook_type(req_data->phonebook_type);
if(NULL == phonebook_type){
err("phonebook_type is NULL");
return TCORE_RETURN_FAILURE;
}
-
+
pb_type = calloc(sizeof(enum tel_phonebook_type),VAL_ONE);
if(pb_type == NULL) {
err("Failed to allocate memory");
pending = tcore_pending_new(o, VAL_ZERO);
tcore_pending_set_request_data(pending, VAL_ZERO, req);
tcore_pending_set_response_callback(pending, _on_response_select, (void*)pb_type);
- tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_phonebook_message_send, NULL);
-
+ tcore_pending_link_user_request(pending, ur_dup);
+
tcore_hal_send_request(hal, pending);
free(phonebook_type);
return TCORE_RETURN_SUCCESS;
}
+static TReturn _getindexlist(CoreObject *o, UserRequest *ur, enum tel_phonebook_type pbt)
+{
+ TcoreHal *hal = NULL;
+ TcoreATRequest *req = NULL;
+ TcorePending *pending = NULL;
+ char *cmd_str = NULL;
+ const struct treq_phonebook_get_count *req_data;
+ int start_index = 1;
+ int *pb_type = NULL;
+ UserRequest *ur_dup = NULL;
+
+ dbg(" Function entry ");
+
+ if (!o || !ur)
+ return TCORE_RETURN_EINVAL;
+
+ pb_type = calloc(sizeof(enum tel_phonebook_type),1);
+ if(pb_type == NULL) {
+ err("Failed to allocate memory");
+ return TCORE_RETURN_FAILURE;
+ }
+ *pb_type = pbt;
+
+ req_data = tcore_user_request_ref_data(ur, NULL);
+ ur_dup = tcore_user_request_ref(ur);
+
+ cmd_str = g_strdup_printf("AT+CPBR=%d,%d", start_index, __pbindex.total_count);
+ req = tcore_at_request_new(cmd_str, "+CPBR:", TCORE_AT_MULTILINE);
+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+
+ hal = tcore_object_get_hal(o);
+ pending = tcore_pending_new(o, 0);
+
+ tcore_pending_set_request_data(pending, 0, req);
+ tcore_pending_set_response_callback(pending, _on_response_getindexlist, (void*)pb_type);
+ tcore_pending_link_user_request(pending, ur_dup);
+ tcore_hal_send_request(hal, pending);
+
+ free(cmd_str);
+ dbg(" Function exit");
+ return TCORE_RETURN_SUCCESS;
+}
+
static TReturn s_get_count(CoreObject *o, UserRequest *ur)
{
TcoreHal *hal = NULL;
pbt = tcore_phonebook_get_selected_type(o);
if (req_data->phonebook_type != pbt) {
dbg("req pb[%d] is different with tcore pb[%d]", req_data->phonebook_type, pbt);
- _select(o, ur, req_data->phonebook_type);
- return TCORE_RETURN_SUCCESS;
+ return _select(o, ur, req_data->phonebook_type);
}
cmd_str = g_strdup_printf("AT+CPBS?");
hal = tcore_object_get_hal(o);
pending = tcore_pending_new(o, VAL_ZERO);
-
+
tcore_pending_set_request_data(pending, VAL_ZERO, req);
tcore_pending_set_response_callback(pending, on_response_get_count, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_phonebook_message_send, NULL);
-
+
tcore_hal_send_request(hal, pending);
g_free(cmd_str);
pbt = tcore_phonebook_get_selected_type(o);
if (req_data->phonebook_type != pbt) {
dbg("req pb[%d] is different with tcore pb[%d]", req_data->phonebook_type, pbt);
- _select(o, ur, req_data->phonebook_type);
- return TCORE_RETURN_SUCCESS;
+ return _select(o, ur, req_data->phonebook_type);
}
pb_type = calloc(sizeof(enum tel_phonebook_type),VAL_ONE);
tcore_pending_set_request_data(pending, VAL_ZERO, req);
tcore_pending_set_response_callback(pending, on_response_get_info, (void*)pb_type);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_phonebook_message_send, NULL);
tcore_hal_send_request(hal, pending);
pbt = tcore_phonebook_get_selected_type(o);
if (req_data->phonebook_type != pbt) {
dbg("req pb[%d] is different with tcore pb[%d]", req_data->phonebook_type, pbt);
- _select(o, ur, req_data->phonebook_type);
- return TCORE_RETURN_SUCCESS;
+ return _select(o, ur, req_data->phonebook_type);
+ }
+ if(!__pbindex.indexlist_populated){
+ return _getindexlist(o, ur, req_data->phonebook_type);
}
-
pb_type = calloc(sizeof(enum tel_phonebook_type),VAL_ONE);
if(pb_type == NULL) {
err("Failed to allocate memory");
}
*pb_type = pbt;
dbg("pb_type %d", *pb_type);
-
- cmd_str = g_strdup_printf("AT+CPBR=%d,%d", req_data->index, req_data->index);
- req = tcore_at_request_new(cmd_str, NULL, TCORE_AT_SINGLELINE);
+ cmd_str = g_strdup_printf("AT+CPBR=%d", __pbindex.indexlist[__pbindex.current_index]);
+ req = tcore_at_request_new(cmd_str, "+CPBR", TCORE_AT_MULTILINE);
dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
hal = tcore_object_get_hal(o);
tcore_pending_set_request_data(pending, VAL_ZERO, req);
tcore_pending_set_response_callback(pending, on_response_read_record, (void*)pb_type);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_phonebook_message_send, NULL);
tcore_hal_send_request(hal, pending);
pbt = tcore_phonebook_get_selected_type(o);
if (req_data->phonebook_type != pbt) {
dbg("req pb[%d] is different with tcore pb[%d]", req_data->phonebook_type, pbt);
- _select(o, ur, req_data->phonebook_type);
- return TCORE_RETURN_SUCCESS;
+ return _select(o, ur, req_data->phonebook_type);
}
cmd_str = g_strdup_printf("AT+CPBW=,\"%s\",%d,\"%s\"", req_data->number, ((PB_TON_INTERNATIONAL == req_data->ton) ? TON_INTERNATIONAL: TON_UNKNOWN), req_data->name);
hal = tcore_object_get_hal(o);
pending = tcore_pending_new(o, VAL_ZERO);
-
+
tcore_pending_set_request_data(pending, VAL_ZERO, req);
tcore_pending_set_response_callback(pending, on_response_update_record, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_phonebook_message_send, NULL);
tcore_hal_send_request(hal, pending);
pbt = tcore_phonebook_get_selected_type(o);
if (req_data->phonebook_type != pbt) {
dbg("req pb[%d] is different with tcore pb[%d]", req_data->phonebook_type, pbt);
- _select(o, ur, req_data->phonebook_type);
- return TCORE_RETURN_SUCCESS;
+ return _select(o, ur, req_data->phonebook_type);
}
cmd_str = g_strdup_printf("AT+CPBW=%d", req_data->index);
tcore_pending_set_request_data(pending, VAL_ZERO, req);
tcore_pending_set_response_callback(pending, on_response_delete_record, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_phonebook_message_send, NULL);
tcore_hal_send_request(hal, pending);
static gboolean _get_file_data(CoreObject *o, UserRequest *ur, const enum tel_sim_file_id ef, const int offset, const int length);
static gboolean _get_file_record(CoreObject *o, UserRequest *ur, const enum tel_sim_file_id ef, const int index, const int length);
static void _sim_status_update(CoreObject *o, enum tel_sim_status sim_status);
-static void on_confirmation_sim_message_send(TcorePending *p, gboolean result, void *user_data); // from Kernel
extern gboolean util_byte_to_hex(const char *byte_pdu, char *hex_pdu, int num_bytes);
-static void on_confirmation_sim_message_send(TcorePending *p, gboolean result, void *user_data)
-{
- dbg("on_confirmation_sim_message_send - msg out from queue.\n");
-
- if (result == FALSE) {
- /* Fail */
- dbg("SEND FAIL");
- } else {
- dbg("SEND OK");
- }
-}
-
static enum tcore_response_command _find_resp_command(UserRequest *ur)
{
enum tcore_request_command command;
int ret_type = 0;
dbg("current sec_op[%d]", op);
-
+
switch (op) {
case SEC_PIN1_VERIFY:
case SEC_PIN1_CHANGE:
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, _response_get_sim_type, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
tcore_hal_send_request(hal, pending);
free(cmd_str);
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, _response_get_file_data, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
-
tcore_hal_send_request(hal, pending);
free(cmd_str);
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, _response_get_file_data, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
-
tcore_hal_send_request(hal, pending);
free(cmd_str);
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, _on_response_get_retry_count, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
tcore_hal_send_request(hal, pending);
free(cmd_str);
return TRUE;
}
-
-
static void on_response_verify_pins(TcorePending *p, int data_len, const void *data, void *user_data)
{
const TcoreATResponse *resp = data;
if (tcore_sim_get_status(co_sim) != SIM_STATUS_INIT_COMPLETED)
_sim_status_update(co_sim, SIM_STATUS_INITIALIZING);
}
- tcore_user_request_send_response(ur, TRESP_SIM_VERIFY_PINS, sizeof(struct tresp_sim_verify_pins), &res);
+ tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_sim_verify_pins), &res);
} else {
dbg("RESPONSE NOK");
line = (const char *) resp->final_response;
if (g_slist_length(tokens) < 1) {
dbg("err cause not specified or string corrupted");
res.result = TCORE_RETURN_3GPP_ERROR;
+ tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_sim_verify_pins), &res);
} else {
err = atoi(g_slist_nth_data(tokens, 0));
dbg("on_response_verify_pins: err = %d", err);
dbg("RESPONSE OK");
res.result = SIM_PIN_OPERATION_SUCCESS;
res.pin_type = _sim_get_current_pin_facility(sp->current_sec_op);
- tcore_user_request_send_response(ur, TRESP_SIM_VERIFY_PUKS, sizeof(struct tresp_sim_verify_pins), &res);
+ tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_sim_verify_pins), &res);
} else {
dbg("RESPONSE NOK");
line = (const char *) resp->final_response;
if (g_slist_length(tokens) < 1) {
dbg("err cause not specified or string corrupted");
res.result = TCORE_RETURN_3GPP_ERROR;
+ tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_sim_verify_pins), &res);
} else {
err = atoi(g_slist_nth_data(tokens, 0));
queue = tcore_object_ref_user_data(co_sim);
dbg("RESPONSE OK");
res.result = SIM_PIN_OPERATION_SUCCESS;
res.pin_type = _sim_get_current_pin_facility(sp->current_sec_op);
- tcore_user_request_send_response(ur, TRESP_SIM_CHANGE_PINS, sizeof(struct tresp_sim_change_pins), &res);
+ tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_sim_change_pins), &res);
} else {
dbg("RESPONSE NOK");
line = (const char *) resp->final_response;
if (g_slist_length(tokens) < 1) {
dbg("err cause not specified or string corrupted");
res.result = TCORE_RETURN_3GPP_ERROR;
+ tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_sim_change_pins), &res);
} else {
err = atoi(g_slist_nth_data(tokens, 0));
queue = tcore_object_ref_user_data(co_sim);
memset(&res, 0, sizeof(struct tresp_sim_get_facility_status));
- res.result = SIM_PIN_OPERATION_SUCCESS;
+ res.result = SIM_INCOMPATIBLE_PIN_OPERATION;
res.type = _sim_get_current_pin_facility(sp->current_sec_op);
if (resp->success > 0) {
tokens = tcore_at_tok_new(line);
if (g_slist_length(tokens) != 1) {
msg("invalid message");
- tcore_at_tok_free(tokens);
- return;
+ goto OUT;
}
}
res.b_enable = atoi(g_slist_nth_data(tokens, 0));
} else {
dbg("RESPONSE NOK");
- res.result = SIM_INCOMPATIBLE_PIN_OPERATION;
}
-
+OUT:
if (ur) {
- tcore_user_request_send_response(ur, TRESP_SIM_GET_FACILITY_STATUS,
+ tcore_user_request_send_response(ur, _find_resp_command(ur),
sizeof(struct tresp_sim_get_facility_status), &res);
}
tcore_at_tok_free(tokens);
memset(&res, 0, sizeof(struct tresp_sim_enable_facility));
- res.result = SIM_PIN_OPERATION_SUCCESS;
+ res.result = SIM_CARD_ERROR;
res.type = _sim_get_current_pin_facility(sp->current_sec_op);
if (resp->success > 0) {
tokens = tcore_at_tok_new(line);
if (g_slist_length(tokens) != 1) {
msg("invalid message");
+ tcore_user_request_send_response(ur, _find_resp_command(ur),
+ sizeof(struct tresp_sim_enable_facility), &res);
tcore_at_tok_free(tokens);
return;
}
}
res.result = SIM_PIN_OPERATION_SUCCESS;
if (ur) {
- tcore_user_request_send_response(ur, TRESP_SIM_ENABLE_FACILITY,
+ tcore_user_request_send_response(ur, _find_resp_command(ur),
sizeof(struct tresp_sim_enable_facility), &res);
}
tcore_at_tok_free(tokens);
memset(&res, 0, sizeof(struct tresp_sim_disable_facility));
- res.result = SIM_PIN_OPERATION_SUCCESS;
+ res.result = SIM_CARD_ERROR;
res.type = _sim_get_current_pin_facility(sp->current_sec_op);
if (resp->success > 0) {
tokens = tcore_at_tok_new(line);
if (g_slist_length(tokens) != 1) {
msg("invalid message");
+ tcore_user_request_send_response(ur, _find_resp_command(ur),
+ sizeof(struct tresp_sim_disable_facility), &res);
tcore_at_tok_free(tokens);
return;
}
}
res.result = SIM_PIN_OPERATION_SUCCESS;
if (ur) {
- tcore_user_request_send_response(ur, TRESP_SIM_DISABLE_FACILITY,
+ tcore_user_request_send_response(ur, _find_resp_command(ur),
sizeof(struct tresp_sim_disable_facility), &res);
}
tcore_at_tok_free(tokens);
struct tresp_sim_set_data resp_language = {0, };
struct s_sim_property *sp = NULL;
GSList *tokens = NULL;
- enum tel_sim_access_result result;
+ enum tel_sim_access_result result = SIM_CARD_ERROR;
const char *line;
int sw1 = 0;
int sw2 = 0;
tokens = tcore_at_tok_new(line);
if (g_slist_length(tokens) != 2) {
msg("invalid message");
- tcore_at_tok_free(tokens);
- return;
+ goto OUT;
}
}
sw1 = atoi(g_slist_nth_data(tokens, 0));
dbg("RESPONSE NOK");
result = SIM_ACCESS_FAILED;
}
-
+OUT:
switch (sp->file_id) {
case SIM_EF_CPHS_CALL_FORWARD_FLAGS:
case SIM_EF_USIM_CFIS:
+ resp_cf.result = result;
tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_sim_set_data), &resp_cf);
break;
case SIM_EF_LP:
case SIM_EF_USIM_LI:
case SIM_EF_USIM_PL:
+ resp_language.result = result;
tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_sim_set_data), &resp_language);
break;
const TcoreATResponse *resp = data;
UserRequest *ur = NULL;
CoreObject *co_sim = NULL;
- struct s_sim_property *sp = NULL;
GSList *tokens = NULL;
struct tresp_sim_transmit_apdu res;
const char *line;
dbg(" Function entry ");
co_sim = tcore_pending_ref_core_object(p);
- sp = tcore_sim_ref_userdata(co_sim);
ur = tcore_pending_ref_user_request(p);
memset(&res, 0, sizeof(struct tresp_sim_transmit_apdu));
+ res.result = SIM_ACCESS_FAILED;
if (resp->success > 0) {
dbg("RESPONSE OK");
- res.result = SIM_ACCESS_SUCCESS;
if (resp->lines) {
char *tmp = NULL;
char *decoded_data = NULL;
tokens = tcore_at_tok_new(line);
if (g_slist_length(tokens) != 2) {
msg("invalid message");
- tcore_at_tok_free(tokens);
- return;
+ goto OUT;
}
res.apdu_resp_length = atoi(g_slist_nth_data(tokens, 0)) / 2;
memcpy((char *) res.apdu_resp, decoded_data, res.apdu_resp_length);
free(tmp);
free(decoded_data);
+ res.result = SIM_ACCESS_SUCCESS;
}
} else {
dbg("RESPONSE NOK");
- res.result = SIM_ACCESS_FAILED;
}
- ur = tcore_pending_ref_user_request(p);
+OUT:
if (ur) {
tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_sim_transmit_apdu), &res);
}
dbg(" Function exit");
}
+static void on_response_get_atr(TcorePending *p, int data_len, const void *data, void *user_data)
+{
+ const TcoreATResponse *resp = data;
+ UserRequest *ur = NULL;
+ GSList *tokens = NULL;
+ struct tresp_sim_get_atr res;
+ const char *line;
+
+ dbg(" Function entry ");
+
+ memset(&res, 0, sizeof(struct tresp_sim_get_atr));
+ ur = tcore_pending_ref_user_request(p);
+
+ res.result = SIM_ACCESS_FAILED;
+ if (resp->success > 0) {
+ dbg("RESPONSE OK");
+ if (resp->lines) {
+ char *tmp = NULL;
+ char *decoded_data = NULL;
+ line = (const char *) resp->lines->data;
+ tokens = tcore_at_tok_new(line);
+ if (g_slist_length(tokens) < 1) {
+ msg("invalid message");
+ goto OUT;
+ }
+
+ tmp = util_removeQuotes(g_slist_nth_data(tokens, 0));
+ decoded_data = util_hexStringToBytes(tmp);
+
+ res.atr_length = strlen(decoded_data);
+ memcpy((char *) res.atr, decoded_data, res.atr_length);
+ free(tmp);
+ free(decoded_data);
+ res.result = SIM_ACCESS_SUCCESS;
+ }
+ } else {
+ dbg("RESPONSE NOK");
+ }
+
+OUT:
+ if (ur) {
+ tcore_user_request_send_response(ur, _find_resp_command(ur), sizeof(struct tresp_sim_get_atr), &res);
+ }
+ tcore_at_tok_free(tokens);
+ dbg(" Function exit");
+}
+
static TReturn s_verify_pins(CoreObject *o, UserRequest *ur)
{
TcoreHal *hal = NULL;
char *cmd_str = NULL;
const struct treq_sim_verify_pins *req_data = NULL;
struct s_sim_property *sp = NULL;
+ TReturn ret = TCORE_RETURN_FAILURE;
dbg(" Function entry ");
+ if (!o || !ur)
+ return TCORE_RETURN_EINVAL;
+
hal = tcore_object_get_hal(o);
if(FALSE == tcore_hal_get_power_state(hal)){
dbg("cp not ready/n");
pending = tcore_pending_new(o, 0);
req_data = tcore_user_request_ref_data(ur, NULL);
- if (!o || !ur)
- return TCORE_RETURN_EINVAL;
-
if (req_data->pin_type == SIM_PTYPE_PIN1) {
sp->current_sec_op = SEC_PIN1_VERIFY;
cmd_str = g_strdup_printf("AT+CPIN=\"%s\"", req_data->pin);
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, on_response_verify_pins, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
- tcore_hal_send_request(hal, pending);
+ ret = tcore_hal_send_request(hal, pending);
free(cmd_str);
dbg(" Function exit");
- return TCORE_RETURN_SUCCESS;
+ return ret;
}
static TReturn s_verify_puks(CoreObject *o, UserRequest *ur)
char *cmd_str = NULL;
const struct treq_sim_verify_puks *req_data;
struct s_sim_property *sp = NULL;
+ TReturn ret = TCORE_RETURN_FAILURE;
dbg(" Function entry ");
+ if (!o || !ur)
+ return TCORE_RETURN_EINVAL;
+
hal = tcore_object_get_hal(o);
if(FALSE == tcore_hal_get_power_state(hal)){
dbg("cp not ready/n");
pending = tcore_pending_new(o, 0);
req_data = tcore_user_request_ref_data(ur, NULL);
- if (!o || !ur)
- return TCORE_RETURN_EINVAL;
-
if (req_data->puk_type == SIM_PTYPE_PUK1) {
sp->current_sec_op = SEC_PUK1_VERIFY;
cmd_str = g_strdup_printf("AT+CPIN=\"%s\", \"%s\"", req_data->puk, req_data->pin);
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, on_response_verify_puks, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
- tcore_hal_send_request(hal, pending);
+ ret = tcore_hal_send_request(hal, pending);
free(cmd_str);
dbg(" Function exit");
- return TCORE_RETURN_SUCCESS;
+ return ret;
}
static TReturn s_change_pins(CoreObject *o, UserRequest *ur)
struct s_sim_property *sp = NULL;
char *pin1 = "SC";
char *pin2 = "P2";
+ TReturn ret = TCORE_RETURN_FAILURE;
dbg(" Function entry ");
+ if (!o || !ur)
+ return TCORE_RETURN_EINVAL;
+
hal = tcore_object_get_hal(o);
if(FALSE == tcore_hal_get_power_state(hal)){
dbg("cp not ready/n");
pending = tcore_pending_new(o, 0);
req_data = tcore_user_request_ref_data(ur, NULL);
- if (!o || !ur)
- return TCORE_RETURN_EINVAL;
-
if (req_data->type == SIM_PTYPE_PIN1) {
sp->current_sec_op = SEC_PIN1_CHANGE;
cmd_str = g_strdup_printf("AT+CPWD=\"%s\",\"%s\",\"%s\"", pin1, req_data->old_pin, req_data->new_pin);
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, on_response_change_pins, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
- tcore_hal_send_request(hal, pending);
+ ret = tcore_hal_send_request(hal, pending);
free(cmd_str);
dbg(" Function exit");
- return TCORE_RETURN_SUCCESS;
+ return ret;
}
static TReturn s_get_facility_status(CoreObject *o, UserRequest *ur)
TcorePending *pending = NULL;
char *cmd_str = NULL;
const struct treq_sim_get_facility_status *req_data;
- struct s_sim_property *sp = NULL;
char *fac = "SC";
int mode = 2; /* 0:unlock, 1:lock, 2:query*/
+ TReturn ret = TCORE_RETURN_FAILURE;
dbg(" Function entry ");
+ if (!o || !ur)
+ return TCORE_RETURN_EINVAL;
+
hal = tcore_object_get_hal(o);
if(FALSE == tcore_hal_get_power_state(hal)){
dbg("cp not ready/n");
return TCORE_RETURN_ENOSYS;
}
- sp = tcore_sim_ref_userdata(o);
pending = tcore_pending_new(o, 0);
req_data = tcore_user_request_ref_data(ur, NULL);
- if (!o || !ur)
- return TCORE_RETURN_EINVAL;
-
if (req_data->type == SIM_FACILITY_PS) {
fac = "PS"; /*PH-SIM, Lock PHone to SIM/UICC card*/
} else if (req_data->type == SIM_FACILITY_SC) {
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, on_response_get_facility_status, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
- tcore_hal_send_request(hal, pending);
+ ret = tcore_hal_send_request(hal, pending);
free(cmd_str);
dbg(" Function exit");
- return TCORE_RETURN_SUCCESS;
+ return ret;
}
static TReturn s_enable_facility(CoreObject *o, UserRequest *ur)
struct s_sim_property *sp = NULL;
char *fac = "SC";
int mode = 1; /* 0:unlock, 1:lock, 2:query*/
+ TReturn ret = TCORE_RETURN_FAILURE;
dbg(" Function entry ");
+ if (!o || !ur)
+ return TCORE_RETURN_EINVAL;
+
hal = tcore_object_get_hal(o);
if(FALSE == tcore_hal_get_power_state(hal)){
dbg("cp not ready/n");
pending = tcore_pending_new(o, 0);
req_data = tcore_user_request_ref_data(ur, NULL);
- if (!o || !ur)
- return TCORE_RETURN_EINVAL;
-
if (req_data->type == SIM_FACILITY_PS) {
fac = "PS"; /*PH-SIM, Lock PHone to SIM/UICC card*/
sp->current_sec_op = SEC_SIM_ENABLE;
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, on_response_enable_facility, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
- tcore_hal_send_request(hal, pending);
+ ret = tcore_hal_send_request(hal, pending);
free(cmd_str);
dbg(" Function exit");
- return TCORE_RETURN_SUCCESS;
+ return ret;
}
static TReturn s_disable_facility(CoreObject *o, UserRequest *ur)
struct s_sim_property *sp = NULL;
char *fac = "SC";
int mode = 0; /* 0:unlock, 1:lock, 2:query*/
+ TReturn ret = TCORE_RETURN_FAILURE;
dbg(" Function entry ");
+ if (!o || !ur)
+ return TCORE_RETURN_EINVAL;
+
hal = tcore_object_get_hal(o);
if(FALSE == tcore_hal_get_power_state(hal)){
dbg("cp not ready/n");
pending = tcore_pending_new(o, 0);
req_data = tcore_user_request_ref_data(ur, NULL);
- if (!o || !ur)
- return TCORE_RETURN_EINVAL;
-
if (req_data->type == SIM_FACILITY_PS) {
fac = "PS"; /*PH-SIM, Lock PHone to SIM/UICC card*/
sp->current_sec_op = SEC_SIM_DISABLE;
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, on_response_disable_facility, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
- tcore_hal_send_request(hal, pending);
+ ret = tcore_hal_send_request(hal, pending);
free(cmd_str);
dbg(" Function exit");
- return TCORE_RETURN_SUCCESS;
+ return ret;
}
static TReturn s_get_lock_info(CoreObject *o, UserRequest *ur)
char *cmd_str = NULL;
char *lock_type = NULL;
const struct treq_sim_get_lock_info *req_data;
- struct s_sim_property *sp = NULL;
+ TReturn ret = TCORE_RETURN_FAILURE;
dbg(" Function entry ");
+ if (!o || !ur)
+ return TCORE_RETURN_EINVAL;
+
hal = tcore_object_get_hal(o);
if(FALSE == tcore_hal_get_power_state(hal)){
dbg("cp not ready/n");
return TCORE_RETURN_ENOSYS;
}
- sp = tcore_sim_ref_userdata(o);
pending = tcore_pending_new(o, 0);
req_data = tcore_user_request_ref_data(ur, NULL);
- if (!o || !ur)
- return TCORE_RETURN_EINVAL;
-
switch (req_data->type) {
case SIM_FACILITY_PS:
lock_type = "PS";
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, on_response_get_lock_info, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
- tcore_hal_send_request(hal, pending);
+ ret = tcore_hal_send_request(hal, pending);
free(cmd_str);
dbg(" Function exit");
- return TCORE_RETURN_SUCCESS;
+ return ret;
}
static TReturn s_read_file(CoreObject *o, UserRequest *ur)
TReturn api_ret = TCORE_RETURN_SUCCESS;
enum tcore_request_command command;
- command = tcore_user_request_get_command(ur);
-
dbg(" Function entry ");
if (!o || !ur)
return TCORE_RETURN_EINVAL;
+ command = tcore_user_request_get_command(ur);
if(FALSE == tcore_hal_get_power_state(tcore_object_get_hal(o))){
dbg("cp not ready/n");
return TCORE_RETURN_ENOSYS;
TcoreATRequest *req;
TcorePending *pending = NULL;
char *cmd_str = NULL;
- TReturn api_ret = TCORE_RETURN_SUCCESS;
+ TReturn ret = TCORE_RETURN_SUCCESS;
char *encoded_data = NULL;
int encoded_len = 0;
enum tcore_request_command command;
dbg(" Function entry ");
+ if (!o || !ur) {
+ return TCORE_RETURN_EINVAL;
+ }
+
hal = tcore_object_get_hal(o);
if(FALSE == tcore_hal_get_power_state(hal)){
dbg("cp not ready/n");
pending = tcore_pending_new(o, 0);
- if (!o || !ur) {
- return TCORE_RETURN_EINVAL;
- }
-
switch (command) {
case TREQ_SIM_SET_LANGUAGE:
cl = tcore_user_request_ref_data(ur, NULL);
dbg("encoded_data - %s ---", encoded_data);
dbg("out_length - %d ---", out_length);
} else {
- api_ret = TCORE_RETURN_ENOSYS;
+ ret = TCORE_RETURN_ENOSYS;
}
break;
default:
dbg("error - not handled update treq command[%d]", command);
- api_ret = TCORE_RETURN_EINVAL;
+ ret = TCORE_RETURN_EINVAL;
break;
}
file_meta.file_id = ef;
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, on_response_update_file, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
+ ret = tcore_hal_send_request(hal, pending);
- tcore_hal_send_request(hal, pending);
if (NULL != encoded_data) {
g_free(encoded_data);
}
}
dbg(" Function exit");
- return TCORE_RETURN_SUCCESS;
+ return ret;
}
static TReturn s_transmit_apdu(CoreObject *o, UserRequest *ur)
int apdu_len = 0;
int result = 0;
const struct treq_sim_transmit_apdu *req_data;
+ TReturn ret = TCORE_RETURN_FAILURE;
dbg(" Function entry ");
+ if (!o || !ur)
+ return TCORE_RETURN_EINVAL;
+
hal = tcore_object_get_hal(o);
if(FALSE == tcore_hal_get_power_state(hal)){
dbg("cp not ready/n");
pending = tcore_pending_new(o, 0);
req_data = tcore_user_request_ref_data(ur, NULL);
- if (!o || !ur)
- return TCORE_RETURN_EINVAL;
-
apdu = (char *) malloc((2 * req_data->apdu_length) + 1);
memset(apdu, 0x00, (2 * req_data->apdu_length) + 1);
result = util_byte_to_hex((const char *) req_data->apdu, apdu, req_data->apdu_length);
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, on_response_transmit_apdu, hal);
tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sim_message_send, NULL);
- tcore_hal_send_request(hal, pending);
+ ret = tcore_hal_send_request(hal, pending);
free(cmd_str);
free(apdu);
dbg(" Function exit");
- return TCORE_RETURN_SUCCESS;
+ return ret;
+}
+
+static TReturn s_get_atr(CoreObject *o, UserRequest *ur)
+{
+ TcoreHal *hal = NULL;
+ TcoreATRequest *req = NULL;
+ TcorePending *pending = NULL;
+ char *cmd_str = NULL;
+ TReturn ret = TCORE_RETURN_FAILURE;
+
+ dbg(" Function entry ");
+
+ if (!o || !ur)
+ return TCORE_RETURN_EINVAL;
+
+ hal = tcore_object_get_hal(o);
+ if(FALSE == tcore_hal_get_power_state(hal)) {
+ dbg("cp not ready/n");
+ return TCORE_RETURN_ENOSYS;
+ }
+ pending = tcore_pending_new(o, 0);
+
+ cmd_str = g_strdup_printf("AT+XGATR");
+ req = tcore_at_request_new(cmd_str, "+XGATR:", TCORE_AT_SINGLELINE);
+ dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+
+ tcore_pending_set_request_data(pending, 0, req);
+ tcore_pending_set_response_callback(pending, on_response_get_atr, hal);
+ tcore_pending_link_user_request(pending, ur);
+ ret = tcore_hal_send_request(hal, pending);
+
+ free(cmd_str);
+ dbg(" Function exit");
+ return ret;
}
static struct tcore_sim_operations sim_ops = {
.read_file = s_read_file,
.update_file = s_update_file,
.transmit_apdu = s_transmit_apdu,
- .get_atr = NULL,
+ .get_atr = s_get_atr,
.req_authentication = NULL,
};