Patch consists of the following changes - 1. Removal of +XSIMSTATE subscription for...
authorSuresh Kumar Narasimhaiah <suresh.n@samsung.com>
Sat, 16 Mar 2013 14:49:15 +0000 (20:19 +0530)
committerwootak.jung <wootak.jung@samsung.com>
Sun, 24 Mar 2013 07:46:41 +0000 (16:46 +0900)
Change-Id: I0dd42ed4b3f7f13d6b5e1e4477c116a1f7bb5618

CMakeLists.txt
src/desc.c
src/s_modem.c
src/s_network.c
src/s_sim.c
src/s_sms.c

index c7cf7b8..ab3cfa2 100644 (file)
@@ -23,7 +23,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
 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")
 
 ADD_DEFINITIONS("-DFEATURE_DLOG_DEBUG")
-ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"TEL_PLUGIN_IMC\"")
+ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"IMC\"")
 
 MESSAGE(${CMAKE_C_FLAGS})
 MESSAGE(${CMAKE_EXE_LINKER_FLAGS})
index 0cccb95..62b4065 100644 (file)
@@ -69,6 +69,7 @@ static void on_response_last_bootup_subscription(TcorePending *p,
                                                        int data_len, const void *data, void *user_data)
 {
        const TcoreATResponse *resp = data;
+       gboolean ret;
        dbg("Last Subscription - COMPLETED");
 
        if (resp->success) {
@@ -79,7 +80,8 @@ static void on_response_last_bootup_subscription(TcorePending *p,
 
        dbg("Boot-up configration completed for IMC modem. %s",
                                "Bring CP to ONLINE state based on Flightmode status");
-       modem_power_on(tcore_pending_ref_plugin(p));
+       ret = modem_power_on(tcore_pending_ref_plugin(p));
+       dbg("Modem Power ON: [%s]", (ret == TRUE ? "SUCCESS" : "FAIL"));
 }
 
 static void _modem_subscribe_events(TcorePlugin *plugin)
@@ -87,7 +89,6 @@ static void _modem_subscribe_events(TcorePlugin *plugin)
        CoreObject *co_call = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_CALL);
        CoreObject *co_sim = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SIM);
        CoreObject *co_sms = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SMS);
-       CoreObject *co_modem = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_MODEM);
        CoreObject *co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK);
        CoreObject *co_ps = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_PS);
        CoreObject *co_sap = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SAP);
@@ -95,98 +96,101 @@ static void _modem_subscribe_events(TcorePlugin *plugin)
 
        dbg("Entry");
 
-       /* XCALLSTAT subscription */
+       /* URC Subscriptions per Module */
+
+       /****** SIM subscriptions ******/
+       /* XSIMSTATE  */
+       tcore_prepare_and_send_at_request(co_sim, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
+                                               on_response_bootup_subscription, NULL,
+                                               on_confirmation_modem_message_send, NULL);
+
+       /****** CALL subscriptions ******/
+       /* XCALLSTAT */
        tcore_prepare_and_send_at_request(co_call, "at+xcallstat=1", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       /* XSIMSTATE subscription */
-       tcore_prepare_and_send_at_request(co_sim, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
+       /* CSSN */
+       tcore_prepare_and_send_at_request(co_call, "at+cssn=1,1", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       tcore_prepare_and_send_at_request(co_sms, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
+       /* CUSD */
+       tcore_prepare_and_send_at_request(co_call, "at+cusd=1", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
-       tcore_prepare_and_send_at_request(co_modem, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
+
+       /* CLIP */
+       tcore_prepare_and_send_at_request(co_call, "at+clip=1", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       /* CREG subscription */
+       /****** NETWORK subscriptions ******/
+       /* CREG */
        tcore_prepare_and_send_at_request(co_network, "at+creg=2", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       /* CGREG subscription */
+       /* CGREG */
        tcore_prepare_and_send_at_request(co_network, "at+cgreg=2", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       /* Allow automatic time Zone updation via NITZ */
+       /* Allow Automatic Time Zone updation via NITZ */
        tcore_prepare_and_send_at_request(co_network, "at+ctzu=1", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       /* TZ, time & daylight changing event reporting subscription */
+       /* TZ, Time & Daylight changing event reporting Subscription */
        tcore_prepare_and_send_at_request(co_network, "at+ctzr=1", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       /* XMER subscription */
+       /* XMER */
        tcore_prepare_and_send_at_request(co_network, "at+xmer=1", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       /* CGEREP subscription */
+       /****** PS subscriptions ******/
+       /* CGEREP */
        tcore_prepare_and_send_at_request(co_ps, "at+cgerep=1", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       /* XDATASTAT subscription */
+       /* XDATASTAT */
        tcore_prepare_and_send_at_request(co_ps, "at+xdatastat=1", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       /* CSSN subscription */
-       tcore_prepare_and_send_at_request(co_call, "at+cssn=1,1", NULL, TCORE_AT_NO_RESULT, NULL,
-                                               on_response_bootup_subscription, NULL,
-                                               on_confirmation_modem_message_send, NULL);
 
-       /* CUSD subscription */
-       tcore_prepare_and_send_at_request(co_call, "at+cusd=1", NULL, TCORE_AT_NO_RESULT, NULL,
-                                               on_response_bootup_subscription, NULL,
-                                               on_confirmation_modem_message_send, NULL);
-
-       /* XDNS subscription */
+       /* XDNS */
        tcore_prepare_and_send_at_request(co_ps, "at+xdns=1,1", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       /* CLIP subscription */
-       tcore_prepare_and_send_at_request(co_call, "at+clip=1", NULL, TCORE_AT_NO_RESULT, NULL,
-                                               on_response_bootup_subscription, NULL,
-                                               on_confirmation_modem_message_send, NULL);
-
-       /*CMEE subscription for ps*/
+       /* CMEE */
        tcore_prepare_and_send_at_request(co_ps, "at+cmee=2", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       /*CMEE subscription for sms*/
+       /****** SMS subscriptions ******/
+       /* CMEE */
        tcore_prepare_and_send_at_request(co_sms, "at+cmee=2", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       /*incoming sms,cb,status report subscription*/
+       /* Incoming SMS, Cell Broadcast, Status Report Subscription */
        tcore_prepare_and_send_at_request(co_sms, "at+cnmi=1,2,2,1,0", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       /* XBCSTAT subscription */
-       tcore_prepare_and_send_at_request(co_sap, "at+xbcstat=1", NULL, TCORE_AT_NO_RESULT, NULL,
+       /* Text/PDU mode Subscription */
+       tcore_prepare_and_send_at_request(co_sms, "at+cmgf=0", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
-       /* AGPS- assist data and reset assist data subscription */
+
+       /****** GPS subscriptions ******/
+       /* AGPS- Assist Data and Reset Assist Data Subscription */
        tcore_prepare_and_send_at_request(co_gps, "at+cposr=1", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
@@ -195,8 +199,9 @@ static void _modem_subscribe_events(TcorePlugin *plugin)
                                                on_response_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
-       /* text/pdu mode subscription*/
-       tcore_prepare_and_send_at_request(co_sms, "at+cmgf=0", NULL, TCORE_AT_NO_RESULT, NULL,
+       /****** SAP subscriptions ******/
+       /* XBCSTAT */
+       tcore_prepare_and_send_at_request(co_sap, "at+xbcstat=1", NULL, TCORE_AT_NO_RESULT, NULL,
                                                on_response_last_bootup_subscription, NULL,
                                                on_confirmation_modem_message_send, NULL);
 
@@ -253,13 +258,10 @@ static gboolean on_init(TcorePlugin *p)
                return FALSE;
        }
 
-       /* Notify addition of Plug-in to Upper Layers */
-       tcore_server_send_notification(tcore_plugin_ref_server(p), NULL,
-                                                               TNOTI_SERVER_ADDED_PLUGIN, 0, p);
-
        /* Subscribe for the Events from CP */
        _modem_subscribe_events(p);
 
+       dbg("Init - Successful");
        return TRUE;
 }
 
index f73b495..4cf657f 100644 (file)
@@ -296,7 +296,8 @@ static void on_response_imei(TcorePending *p, int data_len, const void *data, vo
        }
 
        ur = tcore_pending_ref_user_request(p);
-       tcore_user_request_send_response(ur, TRESP_MODEM_GET_IMEI, sizeof(struct tresp_modem_get_imei), &res);
+       tcore_user_request_send_response(ur, TRESP_MODEM_GET_IMEI,
+                                       sizeof(struct tresp_modem_get_imei), &res);
 
 OUT:
        if (tokens != NULL)
@@ -338,14 +339,15 @@ static void on_response_version(TcorePending *p, int data_len, const void *data,
                                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);
+                               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;
                        }
                }
 
-               vi = calloc(sizeof(TelMiscVersionInformation), 1);
+               vi = g_try_new0(TelMiscVersionInformation, 1);
                if (NULL != swver)
                        memcpy(vi->szSwVersion, swver, strlen(swver));
                if (NULL != hwver)
@@ -359,10 +361,17 @@ static void on_response_version(TcorePending *p, int data_len, const void *data,
 
                memset(&res, 0, sizeof(struct tresp_modem_get_version));
 
-               if (NULL != swver)
-                       snprintf(res.software, (AT_VER_LEN > strlen(swver) ? strlen(swver) : AT_VER_LEN), "%s", swver);
-               if (NULL != hwver)
-                       snprintf(res.hardware, (AT_VER_LEN > strlen(hwver) ? strlen(hwver) : AT_VER_LEN), "%s", hwver);
+               if (NULL != swver) {
+                       snprintf(res.software,
+                               (AT_VER_LEN > strlen(swver) ? strlen(swver) : AT_VER_LEN),
+                               "%s", swver);
+               }
+
+               if (NULL != hwver) {
+                       snprintf(res.hardware,
+                               (AT_VER_LEN > strlen(hwver) ? strlen(hwver) : AT_VER_LEN),
+                               "%s", hwver);
+               }
 
                plugin = tcore_pending_ref_plugin(p);
                vi_property = tcore_plugin_ref_property(plugin, "VERSION");
@@ -389,7 +398,8 @@ static void on_response_version(TcorePending *p, int data_len, const void *data,
        }
 
        ur = tcore_pending_ref_user_request(p);
-       tcore_user_request_send_response(ur, TRESP_MODEM_GET_VERSION, sizeof(struct tresp_modem_get_version), &res);
+       tcore_user_request_send_response(ur, TRESP_MODEM_GET_VERSION,
+                                               sizeof(struct tresp_modem_get_version), &res);
 
 OUT:
        if (tokens != NULL)
@@ -398,22 +408,41 @@ OUT:
        return;
 }
 
-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)
+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;
+       TcorePlugin *plugin;
+       const struct tnoti_sim_status *noti_sim_status;
        CoreObject *co_sat;
        CoreObject *co_network;
-       TcorePlugin *plugin = tcore_object_ref_plugin(source);
 
+       plugin = tcore_object_ref_plugin(source);
        co_sat = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SAT);
-       co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK);
+       if (co_sat == NULL)
+               return TCORE_HOOK_RETURN_CONTINUE;
 
-       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(co_sat, "AT+CFUN=6", NULL, TCORE_AT_NO_RESULT, on_response_enable_proactive_command);
-               prepare_and_send_pending_request(co_network, "AT+COPS=0", NULL, TCORE_AT_NO_RESULT, on_response_network_registration);
+       co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK);
+       if (co_network == NULL)
+               return TCORE_HOOK_RETURN_CONTINUE;
+
+       dbg("Get SIM status");
+       noti_sim_status = data;
+       if (noti_sim_status == NULL)
+               return TCORE_HOOK_RETURN_CONTINUE;
+
+       /* If SIM is initialized, Enable STK and and attach to Network */
+       dbg("SIM Status: [%d]", noti_sim_status->sim_status);
+       if (noti_sim_status->sim_status == SIM_STATUS_INIT_COMPLETED) {
+               dbg("SIM ready for attach!!! Enable STK and attach to Network");
+
+               /* Sending AT+CFUN=6 */
+               prepare_and_send_pending_request(co_sat, "AT+CFUN=6", NULL,
+                                               TCORE_AT_NO_RESULT, on_response_enable_proactive_command);
+
+               /* Sending AT+COPS */
+               prepare_and_send_pending_request(co_network, "AT+COPS=0", NULL,
+                                               TCORE_AT_NO_RESULT, on_response_network_registration);
        }
 
        return TCORE_HOOK_RETURN_CONTINUE;
@@ -424,38 +453,50 @@ gboolean modem_power_on(TcorePlugin *p)
        CoreObject *co_modem = NULL;
        struct treq_modem_set_flightmode flight_mode_set = {0};
        struct tnoti_modem_power modem_power = {0};
-       TcoreHal *h = NULL;
        Storage *strg = NULL;
 
        co_modem = tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_MODEM);
+       if (co_modem == NULL) {
+               err("Modem Core object is NULL");
+               return FALSE;
+       }
 
+       /* Set Modem Power State to 'ON' */
+       tcore_modem_set_powered(co_modem, TRUE);
+
+       /* Get Flight mode from VCONFKEY */
        strg = tcore_server_find_storage(tcore_plugin_ref_server(p), "vconf");
        flight_mode_set.enable = tcore_storage_get_bool(strg, STORAGE_KEY_FLIGHT_MODE_BOOL);
 
-       h = tcore_object_get_hal(co_modem);
-       tcore_hal_set_power_state(h, TRUE);
-
        /* Set Flight mode as per AP settings */
-       if (flight_mode_set.enable) { /* Radio Off */
-               prepare_and_send_pending_request(co_modem, "AT+CFUN=4", NULL, TCORE_AT_NO_RESULT, on_response_set_flight_mode);
+       if (flight_mode_set.enable) {           /* Radio OFF */
+               prepare_and_send_pending_request(co_modem, "AT+CFUN=4", NULL,
+                                                       TCORE_AT_NO_RESULT, on_response_set_flight_mode);
+
+               /* Set Flight mode TRUE */
                tcore_modem_set_flight_mode_state(co_modem, TRUE);
-       } else { /* Radio On */
-               prepare_and_send_pending_request(co_modem, "AT+CFUN=1", NULL, TCORE_AT_NO_RESULT, on_response_set_flight_mode);
+       } else {                                                        /* Radio ON */
+               prepare_and_send_pending_request(co_modem, "AT+CFUN=1", NULL,
+                                                       TCORE_AT_NO_RESULT, on_response_set_flight_mode);
+
+               /* Set Flight mode FALSE */
                tcore_modem_set_flight_mode_state(co_modem, FALSE);
        }
 
        /* Get IMEI */
-       prepare_and_send_pending_request(co_modem, "AT+CGSN", NULL, TCORE_AT_NUMERIC, on_response_imei);
+       prepare_and_send_pending_request(co_modem, "AT+CGSN", NULL,
+                                                       TCORE_AT_NUMERIC, on_response_imei);
 
        /* Get Version Number  */
-       prepare_and_send_pending_request(co_modem, "AT+CGMR", NULL, TCORE_AT_SINGLELINE, on_response_version);
-
-       tcore_modem_set_powered(co_modem, TRUE);
+       prepare_and_send_pending_request(co_modem, "AT+CGMR", NULL,
+                                                       TCORE_AT_SINGLELINE, on_response_version);
 
+       /* Send Notification to TAPI - MODEM_POWER */
        modem_power.state = MODEM_STATE_ONLINE;
 
-       tcore_server_send_notification(tcore_plugin_ref_server(p), co_modem, TNOTI_MODEM_POWER,
-                                                                  sizeof(struct tnoti_modem_power), &modem_power);
+       dbg("Sending notification - Modem Power state: [ONLINE]");
+       tcore_server_send_notification(tcore_plugin_ref_server(p),
+               co_modem, TNOTI_MODEM_POWER, sizeof(modem_power), &modem_power);
 
        return TRUE;
 }
@@ -471,7 +512,8 @@ static TReturn power_off(CoreObject *o, UserRequest *ur)
 
        req = tcore_at_request_new("AT+CFUN=0", NULL, TCORE_AT_NO_RESULT);
 
-       dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+       dbg("Command: [%s], Prefix(if any): [%s], Command Length: [%d]",
+                                               req->cmd, req->prefix, strlen(req->cmd));
 
        tcore_pending_set_request_data(pending, 0, req);
        tcore_pending_set_response_callback(pending, on_response_power_off, hal);
@@ -498,16 +540,15 @@ static TReturn get_imei(CoreObject *o, UserRequest *ur)
 
        req = tcore_at_request_new("AT+CGSN", NULL, TCORE_AT_NUMERIC);
 
-       dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+       dbg("Command: [%s], Prefix(if any): [%s], Command Length: [%d]",
+                                               req->cmd, req->prefix, strlen(req->cmd));
 
        tcore_pending_set_request_data(pending, 0, req);
        tcore_pending_set_response_callback(pending, on_response_imei, hal);
        tcore_pending_link_user_request(pending, ur);
        tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL);
 
-       tcore_hal_send_request(hal, pending);
-
-       return TCORE_RETURN_SUCCESS;
+       return tcore_hal_send_request(hal, pending);
 }
 
 
@@ -526,16 +567,15 @@ static TReturn get_version(CoreObject *o, UserRequest *ur)
 
        req = tcore_at_request_new("AT+CGMR", NULL, TCORE_AT_SINGLELINE);
 
-       dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+       dbg("Command: [%s], Prefix(if any): [%s], Command Length: [%d]",
+                                               req->cmd, req->prefix, strlen(req->cmd));
 
        tcore_pending_set_request_data(pending, 0, req);
        tcore_pending_set_response_callback(pending, on_response_version, hal);
        tcore_pending_link_user_request(pending, ur);
        tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL);
 
-       tcore_hal_send_request(hal, pending);
-
-       return TCORE_RETURN_SUCCESS;
+       return tcore_hal_send_request(hal, pending);
 }
 
 static TReturn set_flight_mode(CoreObject *o, UserRequest *ur)
@@ -563,18 +603,18 @@ static TReturn set_flight_mode(CoreObject *o, UserRequest *ur)
                cmd_str = g_strdup("AT+CFUN=1");
        }
 
-       req = tcore_at_request_new((const char *) cmd_str, NULL, TCORE_AT_NO_RESULT);
+       req = tcore_at_request_new((const char *)cmd_str, NULL, TCORE_AT_NO_RESULT);
+       g_free(cmd_str);
 
-       dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+       dbg("Command: [%s], Prefix(if any): [%s], Command Length: [%d]",
+                                               req->cmd, req->prefix, strlen(req->cmd));
 
        tcore_pending_set_request_data(pending, 0, req);
        tcore_pending_set_response_callback(pending, on_response_set_flight_mode, hal);
        tcore_pending_link_user_request(pending, ur);
        tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL);
 
-       tcore_hal_send_request(hal, pending);
-
-       return TCORE_RETURN_SUCCESS;
+       return tcore_hal_send_request(hal, pending);
 }
 
 
@@ -608,10 +648,10 @@ gboolean s_modem_init(TcorePlugin *cp, CoreObject *co_modem)
        sn_property = g_try_new0(TelMiscSNInformation, 1);
        tcore_plugin_link_property(cp, "SN", sn_property);
 
-       tcore_server_add_notification_hook(tcore_plugin_ref_server(cp), TNOTI_SIM_STATUS, on_hook_sim_status, co_modem);
+       tcore_server_add_notification_hook(tcore_plugin_ref_server(cp),
+                                                       TNOTI_SIM_STATUS, on_hook_sim_status, NULL);
 
        dbg("Exit");
-
        return TRUE;
 }
 
index e4aab10..8da3a76 100644 (file)
@@ -1302,7 +1302,7 @@ Note: <Act> is supporting from R7 and above Protocol Stack.
                regist_status.roaming_status = tcore_network_get_roaming_state(o);
 
                tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o,
-                                                                          TNOTI_NETWORK_REGISTRATION_STATUS, sizeof(struct tnoti_network_registration_status), &regist_status);
+                                                                          TNOTI_NETWORK_REGISTRATION_STATUS, sizeof(regist_status), &regist_status);
 #if 0
                if (service_type == NETWORK_SERVICE_TYPE_HSDPA)
                        noti.status = TELEPHONY_HSDPA_ON;
index 8520c70..567e1cc 100644 (file)
@@ -2023,7 +2023,11 @@ static gboolean on_event_pin_status(CoreObject *o, const void *event_info, void
                        sms = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_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);
+                       /* Send notification - SMS Ready */
+                       tcore_server_send_notification(tcore_plugin_ref_server(plugin),
+                                                                               sms, TNOTI_SMS_DEVICE_READY,
+                                                                               sizeof(struct tnoti_sms_ready_status),
+                                                                               &readyStatusInfo);
                }
                break;
 
@@ -2042,7 +2046,8 @@ static gboolean on_event_pin_status(CoreObject *o, const void *event_info, void
        case SIM_STATUS_CARD_REMOVED:
        case SIM_STATUS_CARD_NOT_PRESENT:
        case SIM_STATUS_CARD_ERROR:
-               if (sim_status == SIM_STATUS_CARD_NOT_PRESENT && tcore_sim_get_status(o) != SIM_STATUS_UNKNOWN) {
+               if (sim_status == SIM_STATUS_CARD_NOT_PRESENT
+                               && tcore_sim_get_status(o) != SIM_STATUS_UNKNOWN) {
                        dbg("[SIM]SIM CARD REMOVED!!");
                        sim_status = SIM_STATUS_CARD_REMOVED;
                }
@@ -2052,7 +2057,7 @@ static gboolean on_event_pin_status(CoreObject *o, const void *event_info, void
                break;
 
        default:
-               dbg("not handled status[%d]", sim_status);
+               dbg("Not handled SIM State: [0x02x]", sim_status);
 
                break;
        }
@@ -3489,10 +3494,13 @@ gboolean s_sim_init(TcorePlugin *cp, CoreObject *co_sim)
 
        tcore_sim_link_userdata(co_sim, file_meta);
 
-       tcore_object_override_callback(co_sim, "+XLOCK", on_event_facility_lock_status, NULL);
-       tcore_object_override_callback(co_sim, "+XSIM", on_event_pin_status, NULL);
+       tcore_object_override_callback(co_sim, "+XLOCK",
+                                                               on_event_facility_lock_status, NULL);
+       tcore_object_override_callback(co_sim, "+XSIM",
+                                                               on_event_pin_status, NULL);
 
-       tcore_server_add_notification_hook(tcore_plugin_ref_server(cp), TNOTI_MODEM_POWER, on_hook_modem_power, co_sim);
+       tcore_server_add_notification_hook(tcore_plugin_ref_server(cp),
+                                                       TNOTI_MODEM_POWER, on_hook_modem_power, co_sim);
 
        dbg("Exit");
 
index 40e0afd..fd21b33 100644 (file)
@@ -58,7 +58,6 @@
 /*=============================================================
                                                        Device Ready
 ==============================================================*/
-#define AT_SMS_DEVICE_READY                    12              /* AT device ready */
 #define SMS_DEVICE_READY                               1               /* Telephony device ready */
 #define SMS_DEVICE_NOT_READY                   0               /* Telephony device not ready */
 
@@ -157,7 +156,7 @@ static void util_sms_free_memory(void *sms_ptr)
        dbg("Exit");
 }
 
+
 static int util_sms_decode_smsParameters(unsigned char *incoming, unsigned int length, struct telephony_sms_Params *params)
 {
        int alpha_id_len = 0;
@@ -225,7 +224,7 @@ static int util_sms_decode_smsParameters(unsigned char *incoming, unsigned int l
                        dbg("Dest Addr = %s", params->tpDestAddr.diallingNum);
                }
        } else {
-               params->tpDestAddr.dialNumLen = 0;                      
+               params->tpDestAddr.dialNumLen = 0;
        }
 
        if ((params->paramIndicator & SMSPValidSvcAddr) == 0) {
@@ -315,63 +314,14 @@ static int util_sms_decode_smsParameters(unsigned char *incoming, unsigned int l
        return TRUE;
 }
 
-
 /*=============================================================
                                                        Notifications
 ==============================================================*/
-static gboolean on_event_sms_ready_status(CoreObject *o, const void *event_info, void *user_data)
-{
-       struct tnoti_sms_ready_status readyStatusInfo = {0,};
-       char *line = NULL;
-       GSList *tokens = NULL;
-       GSList *lines = NULL;
-       char *pResp = NULL;
-       //CoreObject *o = NULL;
-
-       int rtn = -1 , status = 0;
-
-       dbg(" Func Entrance");
-
-       lines = (GSList *)event_info;
-       if (1 != g_slist_length(lines)) {
-               dbg("unsolicited msg but multiple line");
-               goto OUT;
-       }
-       line = (char *) (lines->data);
-
-       dbg(" Func Entrance");
-
-       if (line != NULL) {
-               dbg("Response OK");
-               dbg("noti line is %s", line);
-               tokens = tcore_at_tok_new(line);
-               pResp = g_slist_nth_data(tokens, 0);
-               if (pResp != NULL)
-                       status = atoi(pResp);
-       } else {
-               dbg("Response NOK");
-       }
-
-       if (status == AT_SMS_DEVICE_READY) {
-               readyStatusInfo.status = SMS_DEVICE_READY;
-               tcore_sms_set_ready_status(o, readyStatusInfo.status);
-               dbg("SMS Ready status = [%s]", readyStatusInfo.status ? "TRUE" : "FALSE");
-               rtn = tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_SMS_DEVICE_READY, sizeof(struct tnoti_sms_ready_status), &readyStatusInfo);
-               dbg(" Return value [%d]", rtn);
-       } else {
-               readyStatusInfo.status = SMS_DEVICE_NOT_READY;
-       }
-
-OUT:
-       if(NULL!=tokens)
-               tcore_at_tok_free(tokens);
-       return TRUE;
-}
-
-static gboolean on_event_class2_sms_incom_msg(CoreObject *obj, const void *event_info, void *user_data)
+static gboolean on_event_class2_sms_incom_msg(CoreObject *obj,
+                                                                       const void *event_info, void *user_data)
 {
        //+CMTI: <mem>,<index>
-       
+
        GSList *tokens = NULL , *lines = NULL;
        char *line = NULL, *cmd_str = NULL;
        int index = 0, mem_type = 0;
@@ -406,7 +356,7 @@ static gboolean on_event_class2_sms_incom_msg(CoreObject *obj, const void *event
 
        dbg("index: [%d]", index);
 
-       cmd_str = g_strdup_printf("AT+CMGR=%d", index); 
+       cmd_str = g_strdup_printf("AT+CMGR=%d", index);
        atreq     = tcore_at_request_new((const char *)cmd_str, "+CMGR", TCORE_AT_PDU);
        pending = tcore_pending_new(obj, 0);
 
@@ -431,7 +381,7 @@ static gboolean on_event_class2_sms_incom_msg(CoreObject *obj, const void *event
        tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
        tcore_hal_send_request(hal, pending);
        g_free(cmd_str);
-       
+
        if(tokens)
                tcore_at_tok_free(tokens);
 
@@ -441,7 +391,7 @@ static gboolean on_event_class2_sms_incom_msg(CoreObject *obj, const void *event
 static gboolean on_event_sms_incom_msg(CoreObject *o, const void *event_info, void *user_data)
 {
        //+CMT: [<alpha>],<length><CR><LF><pdu> (PDU mode enabled);
-       
+
        int rtn = -1;
        GSList *tokens = NULL;
        GSList *lines = NULL;
@@ -482,7 +432,7 @@ static gboolean on_event_sms_incom_msg(CoreObject *o, const void *event_info, vo
                pdu_len = atoi((char *)g_slist_nth_data(tokens, 0));
                dbg("pdu_len: [%d]", pdu_len);  /* 1: PDU Length */
        }
-       
+
        line = (char *)g_slist_nth_data(lines, 1); /* Fetch Line 2 */
 
        dbg("Line 2: [%s]", line);
@@ -496,12 +446,12 @@ static gboolean on_event_sms_incom_msg(CoreObject *o, const void *event_info, vo
        bytePDU = (unsigned char *)util_hexStringToBytes(line);
 
        sca_length = bytePDU[0];
-               
+
        dbg("SCA length = %d", sca_length);
-       
+
        gsmMsgInfo.msgInfo.msgLength = pdu_len;
 
-       if (sca_length == 0) { 
+       if (sca_length == 0) {
                memcpy(gsmMsgInfo.msgInfo.tpduData, &bytePDU[1], gsmMsgInfo.msgInfo.msgLength);
        } else {
                memcpy(gsmMsgInfo.msgInfo.sca, &bytePDU[1], sca_length);
@@ -513,7 +463,7 @@ static gboolean on_event_sms_incom_msg(CoreObject *o, const void *event_info, vo
        util_hex_dump("      ", gsmMsgInfo.msgInfo.msgLength,gsmMsgInfo.msgInfo.tpduData);
 
        rtn = tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_SMS_INCOM_MSG, sizeof(struct tnoti_sms_umts_msg), &gsmMsgInfo);
-       
+
        if(tokens)
                tcore_at_tok_free(tokens);
 
@@ -594,7 +544,7 @@ static gboolean on_event_sms_cb_incom_msg(CoreObject *o, const void *event_info,
                } else {
                        dbg("token 0 is null");
                }
-               
+
                pdu = g_slist_nth_data(lines, 1);
                if (pdu != NULL) {
                        cbMsgInfo.cbMsg.length = length;
@@ -604,9 +554,9 @@ static gboolean on_event_sms_cb_incom_msg(CoreObject *o, const void *event_info,
 
                        if ((cbMsgInfo.cbMsg.length >0) && (SMS_CB_SIZE_MAX >= cbMsgInfo.cbMsg.length)) {
                                unsigned char *byte_pdu = NULL;
-                               
+
                                byte_pdu = (unsigned char *)util_hexStringToBytes(pdu);
-                               
+
                                memcpy(cbMsgInfo.cbMsg.msgData, (char*)byte_pdu, cbMsgInfo.cbMsg.length);
                                rtn = tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_SMS_CB_INCOM_MSG, sizeof(struct tnoti_sms_cellBroadcast_msg), &cbMsgInfo);
                                free(byte_pdu);
@@ -812,12 +762,12 @@ static void on_response_class2_read_msg(TcorePending *pending, int data_len, con
        bytePDU = (unsigned char *)util_hexStringToBytes(hex_pdu);
 
        sca_length = bytePDU[0];
-               
+
        dbg("SCA length = %d", sca_length);
 
        gsmMsgInfo.msgInfo.msgLength = pdu_len;
 
-       if (sca_length == 0) { 
+       if (sca_length == 0) {
                memcpy(gsmMsgInfo.msgInfo.tpduData, &bytePDU[1], gsmMsgInfo.msgInfo.msgLength);
        } else {
                memcpy(gsmMsgInfo.msgInfo.sca, bytePDU, sca_length);
@@ -936,7 +886,7 @@ static void on_response_read_msg(TcorePending *pending, int data_len, const void
 
                                resp_read_msg.dataInfo.smsData.msgLength = pdu_len;
                                dbg("msgLength: [%d]", resp_read_msg.dataInfo.smsData.msgLength);
-                               
+
                                if(0 == sca_length) {
                                        if ((resp_read_msg.dataInfo.smsData.msgLength > 0)
                                                && (resp_read_msg.dataInfo.smsData.msgLength <= SMS_SMDATA_SIZE_MAX))   {
@@ -1120,10 +1070,10 @@ static void on_response_get_stored_msg_cnt(TcorePending *pending, int data_len,
                                tcore_pending_link_user_request(pending_new, ur_dup);
                                tcore_pending_set_send_callback(pending_new, on_confirmation_sms_message_send, NULL);
                                tcore_hal_send_request(tcore_object_get_hal(o), pending_new);
-                               
+
                                //free the consumed token
                                tcore_at_tok_free(tokens);
-                       
+
                                g_free(cmd_str);
 
                                dbg("Exit");
@@ -1255,7 +1205,7 @@ static void on_response_get_cb_config(TcorePending *p, int data_len, const void
 
        memset(&respGetCbConfig, 0, sizeof(struct tresp_sms_get_cb_config));
        respGetCbConfig.result = SMS_DEVICE_FAILURE;
-       
+
        ur = tcore_pending_ref_user_request(p);
        if (!ur) {
                dbg("no user_request");
@@ -1304,7 +1254,7 @@ static void on_response_get_cb_config(TcorePending *p, int data_len, const void
                                                                respGetCbConfig.result = SMS_SENDSMS_SUCCESS;
                                                        }
                                                }
-                                               
+
                                                for (i = 0; i < num_cb_tokens; i++) {
                                                        respGetCbConfig.cbConfig.msgIDs[i].net3gpp.selected = TRUE;
                                                        respGetCbConfig.cbConfig.msgIdRangeCount++;
@@ -1312,7 +1262,7 @@ static void on_response_get_cb_config(TcorePending *p, int data_len, const void
                                                        mid_tok = tcore_at_tok_nth(cb_tokens, i);
                                                        first_tok = strtok(mid_tok, delim);
                                                        second_tok = strtok(NULL, delim);
-                                       
+
                                                        if ((first_tok != NULL) && (second_tok != NULL)) { // mids in range (320-478)
                                                                dbg("inside if mid_range");
                                                                respGetCbConfig.cbConfig.msgIDs[i].net3gpp.fromMsgId = atoi(first_tok);
@@ -1336,7 +1286,7 @@ static void on_response_get_cb_config(TcorePending *p, int data_len, const void
                                                respGetCbConfig.cbConfig.msgIDs[0].net3gpp.selected = FALSE;
                                                respGetCbConfig.result = SMS_SENDSMS_SUCCESS;
                                        }
-                               }                       
+                               }
                        } else {
                                        dbg("line is NULL");
                        }
@@ -1351,7 +1301,7 @@ static void on_response_get_cb_config(TcorePending *p, int data_len, const void
 
        if(tokens)
                tcore_at_tok_free(tokens);
-       
+
        return;
 }
 
@@ -1376,7 +1326,7 @@ static void on_response_set_cb_config(TcorePending *pending, int data_len, const
 
        ur = tcore_pending_ref_user_request(pending);
        respSetCbConfig.result = SMS_SENDSMS_SUCCESS;
-       
+
        if (resp->success > 0) {
                dbg("RESPONSE OK");
        } else {
@@ -1488,7 +1438,7 @@ static void on_response_set_msg_status(TcorePending *pending, int data_len, cons
 
        if(tokens)
                tcore_at_tok_free(tokens);
-       
+
        dbg("Exit");
        return;
 }
@@ -1615,7 +1565,7 @@ static void on_response_set_sms_params(TcorePending *pending, int data_len, cons
 
        if(tokens)
                tcore_at_tok_free(tokens);
-               
+
        dbg("Exit");
        return;
 }
@@ -2067,7 +2017,7 @@ static void _response_get_efsms_data(TcorePending *p, int data_len, const void *
        const char *line = NULL;
        int sw1 = 0;
        int sw2 = 0;
-       
+
        TcoreHal *hal = NULL;
        TcoreATRequest *atreq = NULL;
        TcorePending *pending = NULL;
@@ -2078,7 +2028,7 @@ static void _response_get_efsms_data(TcorePending *p, int data_len, const void *
        req_msg_status = tcore_user_request_ref_data(ur, NULL);
 
        resp_msg_status.result = SMS_DEVICE_FAILURE;
-               
+
        hal = tcore_object_get_hal(tcore_pending_ref_core_object(pending));
        dbg("msgStatus: [%x], index [%x]", req_msg_status->msgStatus, req_msg_status->index);
 
@@ -2173,7 +2123,7 @@ static void _response_get_efsms_data(TcorePending *p, int data_len, const void *
 OUT:
        if(tokens)
                tcore_at_tok_free(tokens);
-       
+
        tcore_user_request_send_response(ur, TRESP_SMS_SET_MSG_STATUS , sizeof(struct tresp_sms_set_msg_status), &msg_status);
 
        dbg("Exit");
@@ -2370,7 +2320,7 @@ static TReturn save_msg(CoreObject *obj, UserRequest *ur)
 
                buf[0] = ScLength;
                dbg("ScLength = %d", ScLength);
-               
+
                if(ScLength == 0) {
                        buf[0] = 0;
                } else {
@@ -2386,7 +2336,7 @@ static TReturn save_msg(CoreObject *obj, UserRequest *ur)
                util_hex_dump("    ", sizeof(buf), (void *)buf);
 
                memset (hex_pdu, 0x00, pdu_len * 2 + 1);
-               
+
                util_byte_to_hex((const char *)buf, (char *)hex_pdu, pdu_len);
 
                //AT+CMGW=<length>[,<stat>]<CR>PDU is given<ctrl-Z/ESC>
@@ -2549,7 +2499,7 @@ static TReturn get_sca(CoreObject *obj, UserRequest *ur)
        TcoreHal *hal = NULL;
        TcoreATRequest *atreq = NULL;
        TcorePending *pending = NULL;
-       
+
        dbg("Entry");
 
        hal = tcore_object_get_hal(obj);
@@ -2756,13 +2706,13 @@ static TReturn set_cb_config(CoreObject *obj, UserRequest *ur)
                                mids_GString = g_string_new("AT+CSCB=1");
                                break;
                        }
-                       
+
                        appendMsgId = setCbConfig->msgIDs[ctr1].net3gpp.fromMsgId;
 
                        for( ctr2 = 0; (ctr2 <= ((setCbConfig->msgIDs[ctr1].net3gpp.toMsgId) - (setCbConfig->msgIDs[ctr1].net3gpp.fromMsgId))); ctr2++ ) {
                                dbg( "%x", appendMsgId);
                                mids_GString = g_string_append(mids_GString, g_strdup_printf("%d", appendMsgId));
-                               
+
                                if (ctr2 == ((setCbConfig->msgIDs[ctr1].net3gpp.toMsgId) - (setCbConfig->msgIDs[ctr1].net3gpp.fromMsgId))) {
                                        mids_GString = g_string_append(mids_GString, "\""); //Mids string termination
                                } else {
@@ -2890,7 +2840,7 @@ static TReturn set_mem_status(CoreObject *obj, UserRequest *ur)
 static TReturn set_delivery_report(CoreObject *obj, UserRequest *ur)
 {
        struct tresp_sms_set_delivery_report respSetDeliveryReport = {0,};
-       
+
        respSetDeliveryReport.result = SMS_SUCCESS;
 
        dbg("Entry");
@@ -3047,11 +2997,11 @@ static TReturn set_sms_params(CoreObject *obj, UserRequest *ur)
        SMSPRecordLen = 28 + setSmsParams->params.alphaIdLen;
        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);
-       
+
        encoded_data_len = ((SMSPRecordLen) * 2);
 
        hal = tcore_object_get_hal(obj);
@@ -3170,9 +3120,9 @@ static struct tcore_sms_operations sms_ops = {
 gboolean s_sms_init(TcorePlugin *cp, CoreObject *co_sms)
 {
        int *smsp_record_len;
-
        dbg("Entry");
 
+       /* Override SMS Operations */
        tcore_sms_override_ops(co_sms, &sms_ops);
 
        /* Registering for SMS notifications */
@@ -3185,15 +3135,12 @@ gboolean s_sms_init(TcorePlugin *cp, CoreObject *co_sms)
 
        tcore_object_override_callback(co_sms, "\e+CBMI", on_event_sms_cb_incom_msg, NULL);
        tcore_object_override_callback(co_sms, "\e+CBM", on_event_sms_cb_incom_msg, NULL);
-       tcore_object_override_callback(co_sms, "+XSIM", on_event_sms_ready_status, NULL);
 
-       /* storing smsp record length */
+       /* Storing SMSP record length */
        smsp_record_len = g_new0(int, 1);
-
        tcore_plugin_link_property(cp, "SMSPRECORDLEN", smsp_record_len);
 
        dbg("Exit");
-
        return TRUE;
 }