# Set required packages
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 tcore db-util libxml-2.0 libtzplatform-config vconf)
+pkg_check_modules(pkgs REQUIRED glib-2.0 tcore tel-headers db-util libxml-2.0 libtzplatform-config vconf)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+++ /dev/null
-<manifest>
- <request>
- <domain name="telephony_framework"/>
- </request>
- <assign>
- <filesystem path="/usr/lib/telephony/plugins/imc-plugin.so" label="telephony_framework"/>
- </assign>
- <request>
- <domain name="telephony_framework"/>
- </request>
-</manifest>
BuildRequires: cmake
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(tcore)
+BuildRequires: pkgconfig(tel-headers)
BuildRequires: pkgconfig(db-util)
BuildRequires: pkgconfig(libxml-2.0)
BuildRequires: pkgconfig(libtzplatform-config)
tcore_strdup("AT+XDNS=1,1"));
/* CMEE */
- __send_request(ps, "AT+CMEE=2",
+ __send_request(ps, "AT+CMEE=1",
__on_response_subscribe_bootup_notification,
- tcore_strdup("AT+CMEE=2"));
+ tcore_strdup("AT+CMEE=1"));
/****** SMS subscriptions ******/
sms = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SMS);
- /* CMEE */
- __send_request(sms, "AT+CMEE=2",
- __on_response_subscribe_bootup_notification,
- tcore_strdup("AT+CMEE=2"));
/* Incoming SMS, Cell Broadcast, Status Report Subscription */
__send_request(sms, "AT+CNMI=1,2,2,1,0",
static TelReturn __call_list_get(CoreObject *co, gboolean flag);
+static void __on_response_imc_call_end_cause(TcorePending *p,
+ guint data_len, const void *data, void *user_data);
+
static TelCallType __call_type(int type)
{
dbg("Entry");
case TEL_CALL_STATE_INCOMING:
case TEL_CALL_STATE_WAITING: {
TelCallIncomingInfo incoming = {0,};
- command = TCORE_NOTIFICATION_CALL_STATUS_INCOMING;
+
incoming.call_id = call_id;
tcore_call_object_get_cli_validity(call_obj, &incoming.cli_validity);
tcore_call_object_get_number(call_obj, incoming.number);
tcore_call_object_get_active_line(call_obj, &incoming.active_line);
/* Send notification */
- tcore_object_send_notification(co, command,
+ tcore_object_send_notification(co,
+ TCORE_NOTIFICATION_CALL_STATUS_INCOMING,
sizeof(TelCallIncomingInfo), &incoming);
return;
}
case TEL_CALL_STATE_IDLE: {
- TelCallStatusIdleNoti idle;
- command = TCORE_NOTIFICATION_CALL_STATUS_IDLE;
- idle.call_id = call_id;
+ /* Send AT+CEER command*/
+ ImcRespCbData *resp_cb_data = NULL;
+ TelReturn ret;
- /* TODO - get proper call end cause. */
- idle.cause = TEL_CALL_END_CAUSE_NONE;
+ /* Response callback data */
+ resp_cb_data = imc_create_resp_cb_data(NULL, NULL, &call_id, sizeof(call_id));
- /* Send notification */
- tcore_object_send_notification(co, command,
- sizeof(TelCallStatusIdleNoti), &idle);
+ /* Send Request to modem */
+ ret = tcore_at_prepare_and_send_request(co,
+ "AT+CEER", "+CEER:",
+ TCORE_AT_COMMAND_TYPE_SINGLELINE,
+ NULL,
+ __on_response_imc_call_end_cause, resp_cb_data,
+ on_send_imc_request, NULL);
+ if (ret != TEL_RETURN_SUCCESS) {
+ warn("Failed to send request");
+ TelCallStatusIdleNoti idle;
+
+ idle.call_id = call_id;
+ idle.cause = TEL_CALL_END_CAUSE_NONE;
+
+ /* Send notification */
+ tcore_object_send_notification(co,
+ TCORE_NOTIFICATION_CALL_STATUS_IDLE,
+ sizeof(TelCallStatusIdleNoti), &idle);
+
+ imc_destroy_resp_cb_data(resp_cb_data);
+ }
/* Free Call object */
tcore_call_object_free(co, call_obj);
case TEL_CALL_STATE_IDLE: {
TelCallStatusIdleNoti idle;
- command = TCORE_NOTIFICATION_VIDEO_CALL_STATUS_IDLE;
- idle.call_id = call_id;
- /* TODO - get proper call end cause. */
+ idle.call_id = call_id;
idle.cause = TEL_CALL_END_CAUSE_NONE;
/* Send notification */
- tcore_object_send_notification(co, command,
+ tcore_object_send_notification(co,
+ TCORE_NOTIFICATION_VIDEO_CALL_STATUS_IDLE,
sizeof(TelCallStatusIdleNoti), &idle);
/* Free Call object */
return;
}
}
- }
- else {
+ } else {
err("Unknown Call type: [%d]", call_type);
}
int call_type;
int state;
int mpty;
- int ton;
+ int ton = -1;
GSList *tokens = NULL;
char *resp = NULL;
char *line;
CoreObject *co = tcore_pending_ref_core_object(p);
ImcRespCbData *resp_cb_data = user_data;
GSList *lines = NULL;
- TelCallResult result = TEL_CALL_RESULT_FAILURE; //TODO - CME error mapping required
+ TelCallResult result = TEL_CALL_RESULT_FAILURE;
gboolean *flag = IMC_GET_DATA_FROM_RESP_CB_DATA(resp_cb_data);
int count;
dbg("entry");
return ret;
}
+static TelCallResult __convert_imc_extended_err_tel_call_result(gint error)
+{
+ /*
+ * CEER error codes
+ * 1 - unassigned (unallocated) number.
+ * 28 - invalid number format (incomplete number).
+ * 96 - invalid mandatory information.
+ * 258 - Invalid parameters.
+ * 371 - Invalid mandatory info.
+ * 257 - Out of memory.
+ * 279 - FDN Failed.
+ * 42 - switching equipment congestion
+ * 287 - MM network failure unspecified.
+ * 380 - Congestion.
+ */
+ dbg("CEER Error: [%d]", error);
+
+ switch (error) {
+ case 1:
+ case 28:
+ case 96:
+ case 258:
+ case 371:
+ return TEL_CALL_RESULT_INVALID_PARAMETER;
+ case 257:
+ return TEL_CALL_RESULT_MEMORY_FAILURE;
+ case 279:
+ return TEL_CALL_RESULT_FDN_RESTRICTED;
+ case 42:
+ case 287:
+ case 380:
+ return TEL_CALL_RESULT_NETWORK_BUSY;
+ default:
+ return TEL_CALL_RESULT_FAILURE;
+ }
+}
+
+static TelCallEndCause __convert_imc_extended_err_call_end_cause(gint error)
+{
+ /*
+ * CEER error codes
+ * 1 - unassigned (unallocated) number.
+ * 3 - No route to destination.
+ * 16 - operator determined barring.
+ * 17 - user busy.
+ * 18 - no user responding.
+ * 19 - user alerting, no answer.
+ * 21 - call rejected.
+ * 22 - number changed
+ * 27 - destination out of order.
+ * 28 - invalid number format (incomplete number).
+ * 29 - facility rejected
+ * 34 - no circuit / channel available.
+ * 38 - network out of order
+ * 41 - temporary failure
+ * 44 - requested circuit / channel not available.
+ * 50 - requested facility not subscribed
+ * 68 - ACM equal to or greater than ACMmax
+ */
+ dbg("Call end-cause: [%d]", error);
+ switch (error) {
+ case 1:
+ return TEL_CALL_END_CAUSE_UNASSIGNED_NUMBER;
+ case 3:
+ return TEL_CALL_END_CAUSE_NO_ROUTE_TO_DEST;
+ case 8:
+ return TEL_CALL_END_CAUSE_OPERATOR_DETERMINED_BARRING;
+ case 16:
+ return TEL_CALL_END_CAUSE_NORMAL_CALL_CLEARING;
+ case 17:
+ return TEL_CALL_END_CAUSE_USER_BUSY;
+ case 18:
+ return TEL_CALL_END_CAUSE_NO_USER_RESPONDING;
+ case 19:
+ return TEL_CALL_END_CAUSE_USER_ALERTING_NO_ANSWER;
+ case 21:
+ return TEL_CALL_END_CAUSE_CALL_REJECTED;
+ case 22:
+ return TEL_CALL_END_CAUSE_NUMBER_CHANGED;
+ case 27:
+ return TEL_CALL_END_CAUSE_DESTINATION_OUT_OF_ORDER;
+ case 28:
+ return TEL_CALL_END_CAUSE_INVALID_NUMBER_FORMAT;
+ case 29:
+ return TEL_CALL_END_CAUSE_FACILITY_REJECTED;
+ case 34:
+ return TEL_CALL_END_CAUSE_NO_CIRCUIT_CHANNEL_AVAILABLE;
+ case 38:
+ return TEL_CALL_END_CAUSE_NETWORK_OUT_OF_ORDER;
+ case 41:
+ return TEL_CALL_END_CAUSE_TEMPORARY_FAILURE;
+ case 42:
+ return TEL_CALL_END_CAUSE_SWITCHING_EQUIPMENT_CONGESTION;
+ case 44:
+ return TEL_CALL_END_CAUSE_REQUESTED_CIRCUIT_CHANNEL_NOT_AVAILABLE;
+ case 50:
+ return TEL_CALL_END_CAUSE_REQUESTED_FACILITY_NOT_SUBSCRIBED;
+ case 68:
+ return TEL_CALL_END_CAUSE_ACM_GEQ_ACMMAX;
+ case 63:
+ case 79:
+ return TEL_CALL_END_CAUSE_SERVICE_OPTION_OUT_OF_ORDER;
+ default:
+ return TEL_CALL_END_CAUSE_FAILED;
+ }
+}
+
+static TelCallResult __convert_imc_xdrv_result_tel_call_result(gint xdrv_err)
+{
+ /*
+ * 0 - Command was executed without any error.
+ * 1 - One of the parameters is out of range.
+ * 2 - The function doesn’t exist for this driver.
+ * 3 - The group is not supported.
+ * 4 - The internal state of the driver is not allowing to process the command.
+ * 5 - The driver interface function for the command is not available.
+ * 6 - The corresponding driver for the command retuns an error.
+ * 7 - Timeout occured when expecting response from the corresponding driver.
+ * 8 - The driver is not supported for this product.
+ * 12 - No of parameteres passed for the command is mismatch with the rquirements.
+ * 13 - The given command to xdrv is invalid.
+ * 14 - Any internal error in xdrv like out of memory.
+ */
+
+ dbg("XDRV result: [%d]", xdrv_err);
+ switch (xdrv_err) {
+ case 1:
+ case 12:
+ case 13:
+ return TEL_CALL_RESULT_INVALID_PARAMETER;
+ case 14:
+ return TEL_CALL_RESULT_MEMORY_FAILURE;
+ default:
+ return TEL_CALL_RESULT_OPERATION_NOT_SUPPORTED;
+ }
+}
+
/* Notification */
/*
-* Operation - call status notification from network.
-* notification message format:
-* +XCALLSTAT: <call_id><stat>
-* where
-* <call_id>
-* indicates the call identification (GSM02.30 4.5.5.1)
-* <stat>
-* 0 active
-* 1 hold
-* 2 dialling (MO call)
-* 3 alerting (MO call; ringing for the remote party)
-* 4 ringing (MT call)
-* 5 waiting (MT call)
-* 6 disconnected
-* 7 connected (indicates the completion of a call setup first time for MT and MO calls
-* this is reported in addition to state active)
-*/
+ * Operation - call status notification from network.
+ * notification message format:
+ * +XCALLSTAT: <call_id><stat>
+ * where
+ * <call_id>
+ * indicates the call identification (GSM02.30 4.5.5.1)
+ * <stat>
+ * 0 active
+ * 1 hold
+ * 2 dialling (MO call)
+ * 3 alerting (MO call; ringing for the remote party)
+ * 4 ringing (MT call)
+ * 5 waiting (MT call)
+ * 6 disconnected
+ * 7 connected (indicates the completion of a call setup first time
+ * for MT and MO calls this is reported in addition to state active)
+ */
static gboolean on_notification_imc_call_status(CoreObject *co, const void *data,
void *user_data)
{
}
/* Response */
+static void __on_response_imc_call_handle_error_report(TcorePending *p,
+ guint data_len, const void *data, void *user_data)
+{
+ const TcoreAtResponse *at_resp = data;
+ CoreObject *co = tcore_pending_ref_core_object(p);
+ ImcRespCbData *resp_cb_data = user_data;
+ TelCallResult result = TEL_CALL_RESULT_FAILURE;
+ GSList *tokens = NULL;
+ dbg("entry");
+
+ tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
+
+ if (at_resp && at_resp->success) {
+ GSList *resp_data = NULL;
+ gchar *resp_str;
+ gint error;
+
+ resp_data = at_resp->lines;
+ if (!resp_data) {
+ err("invalid response data received");
+ goto OUT;
+ }
+
+ tokens = tcore_at_tok_new(resp_data->data);
+ resp_str = g_slist_nth_data(tokens, 0);
+ if (!resp_str) {
+ err("In extended error report - <category> missing");
+ goto OUT;
+ }
+ dbg("category[%s]", resp_str);
+
+ resp_str = g_slist_nth_data(tokens, 1);
+ if (!resp_str) {
+ err("In extended error report - <cause> missing");
+ goto OUT;
+ }
+ error = atoi(resp_str);
+ dbg("Cause: [%d] description: [%s]", error, g_slist_nth_data(tokens, 2));
+
+ result = __convert_imc_extended_err_tel_call_result(error);
+ dbg("result: [%d]", result);
+ } else {
+ err("Response - [NOK]");
+ }
+OUT:
+
+ dbg("%s: [%s]", IMC_GET_DATA_FROM_RESP_CB_DATA(resp_cb_data),
+ (result == TEL_CALL_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
+
+ /* Invoke callback */
+ if (resp_cb_data->cb)
+ resp_cb_data->cb(co, (gint)result, NULL, resp_cb_data->cb_data);
+
+ /* Free callback data */
+ imc_destroy_resp_cb_data(resp_cb_data);
+
+ /* Free tokens*/
+ tcore_at_tok_free(tokens);
+}
+
+static void __on_response_imc_call_end_cause(TcorePending *p,
+ guint data_len, const void *data, void *user_data)
+{
+ const TcoreAtResponse *at_resp = data;
+ CoreObject *co = tcore_pending_ref_core_object(p);
+ ImcRespCbData *resp_cb_data = user_data;
+ TelCallStatusIdleNoti idle;
+ TcoreNotification command;
+ TelCallEndCause cause = TEL_CALL_END_CAUSE_NONE;
+ guint *call_id;
+ GSList *tokens = NULL;
+
+ dbg("entry");
+
+ tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
+ call_id = IMC_GET_DATA_FROM_RESP_CB_DATA(resp_cb_data);
+
+ if (at_resp && at_resp->success) {
+ GSList *resp_data = NULL;
+ gchar *resp_str;
+ gint error;
+
+ resp_data = at_resp->lines;
+ if (!resp_data) {
+ err("invalid response data received");
+ goto OUT;
+ }
+ tokens = tcore_at_tok_new(resp_data->data);
+ resp_str = g_slist_nth_data(tokens, 0);
+ if (!resp_str) {
+ err("In extended error report - <category> missing");
+ goto OUT;
+ }
+ dbg("category[%s]", resp_str);
+ resp_str = g_slist_nth_data(tokens, 1);
+ if (!resp_str) {
+ err("In extended error report - <cause> missing");
+ goto OUT;
+ }
+ error = atoi(resp_str);
+ dbg("cause: [%d] description: [%s]", error, g_slist_nth_data(tokens, 2));
+
+ cause = __convert_imc_extended_err_call_end_cause(error);
+ dbg("cause: [%d]", cause);
+
+ } else {
+ err("RESPONSE - [NOK]");
+ }
+OUT:
+ command = TCORE_NOTIFICATION_CALL_STATUS_IDLE;
+ idle.call_id = *call_id;
+
+ idle.cause = cause;
+
+ /* Send notification */
+ tcore_object_send_notification(co, command,
+ sizeof(TelCallStatusIdleNoti), &idle);
+
+ /* Free callback data */
+ imc_destroy_resp_cb_data(resp_cb_data);
+
+ /* Free tokens*/
+ tcore_at_tok_free(tokens);
+}
static void on_response_imc_call_default(TcorePending *p,
guint data_len, const void *data, void *user_data)
{
if (at_resp && at_resp->success) {
result = TEL_CALL_RESULT_SUCCESS;
} else {
+ TelReturn ret;
if(at_resp){
err("ERROR[%s]", at_resp->final_response);
-
- if(at_resp->lines)
- err("CME error[%s]", at_resp->lines->data);
}
- /*
- * TODO - need to map CME error and final
- * response error to TelCallResult
- */
+
+ /* Send Request to modem to get extended error report*/
+ ret = tcore_at_prepare_and_send_request(co,
+ "AT+CEER", "+CEER:",
+ TCORE_AT_COMMAND_TYPE_SINGLELINE,
+ NULL,
+ __on_response_imc_call_handle_error_report, resp_cb_data,
+ on_send_imc_request, NULL);
+
+
+ if (ret == TEL_RETURN_SUCCESS)
+ return;
}
dbg("%s: [%s]", IMC_GET_DATA_FROM_RESP_CB_DATA(resp_cb_data),
char *resp_str = NULL;
gboolean error;
- /* TODO: XDRV error mapping required */
TelCallResult result = TEL_CALL_RESULT_FAILURE;
dbg("Enter");
error = atoi(resp_str);
if (error) {
err("RESPONSE NOK");
+ result = __convert_imc_xdrv_result_tel_call_result(error);
goto OUT;
}
gboolean error;
gint xdrv_func_id = -1;
- TelCallResult result = TEL_CALL_RESULT_FAILURE; // TODO: XDRV error mapping is required
+ TelCallResult result = TEL_CALL_RESULT_FAILURE;
dbg("Enter");
tcore_check_return_assert(co != NULL);
error = atoi(resp_str);
if (error) {
err("RESPONSE NOK");
+ result = __convert_imc_xdrv_result_tel_call_result(error);
goto OUT;
}
char *resp_str = NULL;
gboolean error;
- TelCallResult result = TEL_CALL_RESULT_FAILURE; // TODO: XDRV error mapping is required
+ TelCallResult result = TEL_CALL_RESULT_FAILURE;
dbg("Enter");
tcore_check_return_assert(co != NULL);
line = (((GSList *)at_resp->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 missing");
goto OUT;
goto OUT;
}
- resp_str = g_slist_nth_data(tokens, 2);
- if (!(resp_str = g_slist_nth_data(tokens, 1))) {
+ if (!(resp_str = g_slist_nth_data(tokens, 2))) {
err("xdrv_result missing");
goto OUT;
}
+
error = atoi(resp_str);
- if (!error) {
+ if (error) {
err(" RESPONSE NOK [%d]", error);
+ result = __convert_imc_xdrv_result_tel_call_result(error);
goto OUT;
}
result = TEL_CALL_RESULT_SUCCESS;
static gboolean on_event_imc_nvm_update(CoreObject *co,
const void *event_info, void *user_data);
+static TelModemResult
+__imc_modem_convert_cme_error_tel_modem_result(const TcoreAtResponse *at_resp)
+{
+ TelModemResult result = TEL_MODEM_RESULT_FAILURE;
+ const gchar *line;
+ GSList *tokens = NULL;
+
+ dbg("Entry");
+
+ if (!at_resp || !at_resp->lines) {
+ err("Invalid response data");
+ return result;
+ }
+
+ line = (const gchar *)at_resp->lines->data;
+ tokens = tcore_at_tok_new(line);
+ if (g_slist_length(tokens) > 0) {
+ gchar *resp_str;
+ gint cme_err;
+
+ resp_str = g_slist_nth_data(tokens, 0);
+ if (!resp_str) {
+ err("Invalid CME Error data");
+ tcore_at_tok_free(tokens);
+ return result;
+ }
+ cme_err = atoi(resp_str);
+ dbg("CME error[%d]", cme_err);
+
+ switch (cme_err) {
+ case 3:
+ result = TEL_MODEM_RESULT_OPERATION_NOT_PERMITTED;
+ break;
+
+ case 4:
+ result = TEL_MODEM_RESULT_OPERATION_NOT_SUPPORTED;
+ break;
+
+ case 20:
+ result = TEL_MODEM_RESULT_MEMORY_FAILURE;
+ break;
+
+ case 50:
+ result = TEL_MODEM_RESULT_INVALID_PARAMETER;
+ break;
+
+ case 100:
+ result = TEL_MODEM_RESULT_UNKNOWN_FAILURE;
+ break;
+
+ default:
+ result = TEL_MODEM_RESULT_FAILURE;
+ }
+ }
+ tcore_at_tok_free(tokens);
+
+ return result;
+}
+
/* NVM Req/Response */
static gboolean __imc_modem_check_nvm_response(const void *data, int command)
{
tcore_check_return_assert(co != NULL);
tcore_check_return_assert(resp_cb_data != NULL);
- if (at_resp && at_resp->success)
+ if (at_resp && at_resp->success){
+ dbg("RESPONSE OK");
result = TEL_MODEM_RESULT_SUCCESS;
+ } else{
+ err("RESPONSE NOK");
+ result = __imc_modem_convert_cme_error_tel_modem_result(at_resp);
+ goto END;
+ }
status = (TelModemPowerStatus *)
IMC_GET_DATA_FROM_RESP_CB_DATA(resp_cb_data);
}
tcore_modem_set_powered(co, powered);
+END:
/* Invoke callback */
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)result, NULL, resp_cb_data->cb_data);
tcore_check_return_assert(co != NULL);
tcore_check_return_assert(resp_cb_data != NULL);
- if (at_resp && at_resp->success)
+ if (at_resp && at_resp->success){
+ dbg("RESPONSE OK");
result = TEL_MODEM_RESULT_SUCCESS;
+ } else{
+ err("RESPONSE NOK");
+ result = __imc_modem_convert_cme_error_tel_modem_result(at_resp);
+ goto END;
+ }
enable = (gboolean *)IMC_GET_DATA_FROM_RESP_CB_DATA(resp_cb_data);
/* Update Core Object */
(void)tcore_modem_set_flight_mode_state(co, *enable);
+END:
/* Invoke callback */
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)result, NULL, resp_cb_data->cb_data);
} else {
err("RESPONSE - [NOK]");
err("[%s]", g_slist_nth_data(tokens, 0));
+ result = __imc_modem_convert_cme_error_tel_modem_result(at_resp);
}
} else {
err("Invalid response message");
(ret == TEL_RETURN_SUCCESS ? "SUCCESS" : "FAIL"));
}
+static TelNetworkResult
+__imc_network_convert_cme_error_tel_network_result(const TcoreAtResponse *at_resp)
+{
+ TelNetworkResult result = TEL_NETWORK_RESULT_FAILURE;
+ const gchar *line;
+ GSList *tokens = NULL;
+
+ dbg("Entry");
+
+ if (!at_resp || !at_resp->lines) {
+ err("Invalid response data");
+ return result;
+ }
+
+ line = (const gchar *)at_resp->lines->data;
+ tokens = tcore_at_tok_new(line);
+ if (g_slist_length(tokens) > 0) {
+ gchar *resp_str;
+ gint cme_err;
+
+ resp_str = g_slist_nth_data(tokens, 0);
+ if (!resp_str) {
+ err("Invalid CME Error data");
+ tcore_at_tok_free(tokens);
+ return result;
+ }
+ cme_err = atoi(resp_str);
+ dbg("CME error[%d]", cme_err);
+
+ switch (cme_err) {
+ case 3:
+ result = TEL_NETWORK_RESULT_OPERATION_NOT_PERMITTED;
+ break;
+
+ case 4:
+ result = TEL_NETWORK_RESULT_OPERATION_NOT_SUPPORTED;
+ break;
+
+ case 20:
+ result = TEL_NETWORK_RESULT_MEMORY_FAILURE;
+ break;
+
+ case 30:
+ case 31:
+ result = TEL_NETWORK_RESULT_FAILURE;
+ break;
+
+ case 50:
+ result = TEL_NETWORK_RESULT_INVALID_PARAMETER;
+ break;
+
+ default:
+ result = TEL_NETWORK_RESULT_FAILURE;
+ }
+ }
+ tcore_at_tok_free(tokens);
+
+ return result;
+}
+
static void __on_response_imc_network_fetch_nw_name_internal(CoreObject *co,
gint result, const void *response, void *user_data)
{
nol = g_slist_length(at_resp->lines);
if (nol > 3) {
err("Invalid response message");
+ imc_destroy_resp_cb_data(resp_cb_data);
return;
}
CustomData *custom_data;
ImcRespCbData *resp_cb_data = user_data;
- TelNetworkResult result = TEL_NETWORK_RESULT_FAILURE; //TODO - CME Error mapping required.
+ TelNetworkResult result = TEL_NETWORK_RESULT_FAILURE;
TelNetworkPlmnList plmn_list = {0, };
guint num_network_avail = 0;
guint count;
result = TEL_NETWORK_RESULT_SUCCESS;
} else {
err("RESPONSE NOK");
- if (at_resp->lines)
- err("CME Error[%s]",(char *)at_resp->lines->data);
+ result = __imc_network_convert_cme_error_tel_network_result(at_resp);
}
END:
TelNetworkSelectionMode selection_mode = -1;
GSList *tokens = NULL;
- TelNetworkResult result = TEL_NETWORK_RESULT_FAILURE; //TODO - CME Error mapping required.
+ TelNetworkResult result = TEL_NETWORK_RESULT_FAILURE;
dbg("Enter");
tcore_check_return_assert(co != NULL);
} else {
err("RESPONSE NOK");
+ result = __imc_network_convert_cme_error_tel_network_result(at_resp);
}
END:
const TcoreAtResponse *at_resp = data;
CoreObject *co = tcore_pending_ref_core_object(p);
ImcRespCbData *resp_cb_data = user_data;
- TelNetworkResult result = TEL_NETWORK_RESULT_FAILURE; //TODO - CME Error mapping required.
+ TelNetworkResult result = TEL_NETWORK_RESULT_FAILURE;
dbg("Enter");
tcore_check_return_assert(co != NULL);
result = TEL_NETWORK_RESULT_SUCCESS;
} else {
err("RESPONSE NOK");
- if (at_resp->lines)
- err("CME Error[%s]",(char *)at_resp->lines->data);
+ result = __imc_network_convert_cme_error_tel_network_result(at_resp);
}
/* Invoke callback */
const TcoreAtResponse *at_resp = data;
CoreObject *co = tcore_pending_ref_core_object(p);
ImcRespCbData *resp_cb_data = user_data;
- TelNetworkResult result = TEL_NETWORK_RESULT_FAILURE; //TODO - CME Error mapping required.
+ TelNetworkResult result = TEL_NETWORK_RESULT_FAILURE;
TelNetworkMode mode = -1;
GSList *tokens = NULL;
net_mode = atoi(tcore_at_tok_nth(tokens, 0));
dbg("mode = %d", net_mode);
- switch(net_mode) {
+ switch (net_mode) {
case 0:
mode = TEL_NETWORK_MODE_2G;
break;
result = TEL_NETWORK_RESULT_SUCCESS;
} else {
err("RESPONSE NOK");
+ result = __imc_network_convert_cme_error_tel_network_result(at_resp);
}
END:
/* Invoke callback */
ImcRespCbData *resp_cb_data = user_data;
TelNetworkPreferredPlmnList plmn_list = {0,};
guint count = 0, total_lines = 0;
- TelNetworkResult result = TEL_NETWORK_RESULT_FAILURE; //TODO - CME Error mapping required.
+ TelNetworkResult result = TEL_NETWORK_RESULT_FAILURE;
dbg("Enter");
tcore_check_return_assert(co != NULL);
plmn_list.count = count;
} else {
err("RESPONSE NOK");
- if (at_resp->lines)
- err("CME Error[%s]",(char *)at_resp->lines->data);
+ result = __imc_network_convert_cme_error_tel_network_result(at_resp);
}
END:
gint act;
dbg("entry");
- switch(sel_manual->act) {
+ switch (sel_manual->act) {
case TEL_NETWORK_ACT_GSM:
case TEL_NETWORK_ACT_GPRS:
case TEL_NETWORK_ACT_EGPRS:
TelReturn ret = TEL_RETURN_INVALID_PARAMETER;
dbg("entry");
- switch(pref_plmn->act) {
+ switch (pref_plmn->act) {
case TEL_NETWORK_ACT_GSM:
case TEL_NETWORK_ACT_GPRS:
case TEL_NETWORK_ACT_EGPRS:
int act;
gchar *at_cmd;
- switch(mode) {
+ switch (mode) {
case TEL_NETWORK_MODE_AUTO:
act = 1;
break;
gboolean used_index_usim_valid;
} PrivateInfo;
+static TelPbResult
+__imc_phonebook_convert_cme_error_tel_phonebook_result(const TcoreAtResponse *at_resp)
+{
+ TelPbResult result = TEL_PB_RESULT_FAILURE;
+ GSList *tokens = NULL;
+ const gchar *line;
+
+ dbg("Entry");
+
+ if (!at_resp || !at_resp->lines) {
+ err("Invalid response data");
+ return result;
+ }
+
+ line = (const gchar *)at_resp->lines->data;
+ tokens = tcore_at_tok_new(line);
+ if (g_slist_length(tokens) > 0) {
+ gchar *resp_str;
+ gint cme_err;
+
+ resp_str = g_slist_nth_data(tokens, 0);
+ if (!resp_str) {
+ err("Invalid CME Error data");
+ tcore_at_tok_free(tokens);
+ return result;
+ }
+ cme_err = atoi(resp_str);
+ dbg("CME Error: [%d]", cme_err);
+
+ switch (cme_err) {
+ case 3:
+ result = TEL_PB_RESULT_OPERATION_NOT_PERMITTED;
+ break;
+
+ case 4:
+ result = TEL_PB_RESULT_OPERATION_NOT_SUPPORTED;
+ break;
+
+ case 17:
+ result = TEL_PB_RESULT_PIN2_REQUIRED;
+ break;
+
+ case 18:
+ result = TEL_PB_RESULT_PUK2_REQUIRED;
+ break;
+
+ case 20:
+ result = TEL_PB_RESULT_MEMORY_FAILURE;
+ break;
+
+ case 21:
+ result = TEL_PB_RESULT_INVALID_INDEX;
+ break;
+
+ case 50:
+ result = TEL_PB_RESULT_INVALID_PARAMETER;
+ break;
+
+ case 100:
+ result = TEL_PB_RESULT_UNKNOWN_FAILURE;
+ break;
+
+ default:
+ result = TEL_PB_RESULT_FAILURE;
+ }
+ }
+ tcore_at_tok_free(tokens);
+
+ return result;
+}
+
static gboolean __imc_phonebook_get_sim_type(CoreObject *co_pb,
TelSimCardType *sim_type)
{
if (at_resp->success != TRUE) {
err("Response NOK");
+ result = __imc_phonebook_convert_cme_error_tel_phonebook_result(at_resp);
goto out;
}
if (at_resp->success != TRUE) {
err("Response NOK");
+ result = __imc_phonebook_convert_cme_error_tel_phonebook_result(at_resp);
goto out;
}
if (at_resp->success != TRUE) {
err("Response NOK");
+ result = __imc_phonebook_convert_cme_error_tel_phonebook_result(at_resp);
goto out;
}
} else {
list = g_slist_insert_sorted(list, (gpointer)req_data->index,
__imc_phonebook_compare_index);
+ dbg("list: [0x%x]", list);
}
out:
if (at_resp->success != TRUE) {
err("Response NOK");
+ result = __imc_phonebook_convert_cme_error_tel_phonebook_result(at_resp);
goto out;
}
err("used_index list is NOT valid");
} else {
list = g_slist_remove(list, (gconstpointer)req_data->index);
- dbg("Remove index: [%u]", req_data->index);
+ dbg("Remove index: [%u], list: [0x%x]", req_data->index, list);
}
out:
#include "imc_sap.h"
#include "imc_common.h"
+static TelSapResult __imc_sap_convert_cme_error_tel_sap_result(const TcoreAtResponse *at_resp)
+{
+ TelSapResult result = TEL_SAP_RESULT_FAILURE_NO_REASON;
+ const gchar *line;
+ GSList *tokens = NULL;
+
+ dbg("Entry");
+
+ if (!at_resp || !at_resp->lines) {
+ err("Invalid response data");
+ return result;
+ }
+
+ line = (const gchar *)at_resp->lines->data;
+ tokens = tcore_at_tok_new(line);
+ if (g_slist_length(tokens) > 0) {
+ gchar *resp_str;
+ gint cme_err;
+
+ resp_str = g_slist_nth_data(tokens, 0);
+ if (!resp_str) {
+ err("Invalid CME Error data");
+ tcore_at_tok_free(tokens);
+ return result;
+ }
+ cme_err = atoi(resp_str);
+ dbg("CME Error: [%d]", cme_err);
+
+ switch (cme_err) {
+ case 3:
+ case 4:
+ result = TEL_SAP_RESULT_OPERATION_NOT_PERMITTED;
+ break;
+
+ case 14:
+ result = TEL_SAP_RESULT_ONGOING_CALL;
+ break;
+
+ default:
+ result = TEL_SAP_RESULT_FAILURE_NO_REASON;
+ }
+ }
+ tcore_at_tok_free(tokens);
+
+ return result;
+}
+
static TelSapResult __map_sap_status_to_result(int sap_status)
{
switch(sap_status){
result = TEL_SAP_RESULT_SUCCESS;
memcpy(&max_msg_size, IMC_GET_DATA_FROM_RESP_CB_DATA(resp_cb_data), sizeof(unsigned int));
} else {
- err("CME error[%s]", at_resp->lines->data);
- /*TODO - need to map CME error to TelSapResult */
+ err("RESPONSE NOK");
+ result = __imc_sap_convert_cme_error_tel_sap_result(at_resp);
}
dbg("Request to sap connection : [%s]",
if (at_resp && at_resp->success) {
result = TEL_SAP_RESULT_SUCCESS;
} else {
- err("CME error[%s]", at_resp->lines->data);
- /*TODO - need to map CME error to TelSapResult */
+ err("RESPONSE NOK");
+ result = __imc_sap_convert_cme_error_tel_sap_result(at_resp);
}
dbg("Request to sap connection : [%s]",
tcore_at_tok_free(tokens);
} else {
err("RESPONSE NOK");
+ result = __imc_sap_convert_cme_error_tel_sap_result(at_resp);
}
END:
tcore_at_tok_free(tokens);
} else {
err("RESPONSE NOK");
+ result = __imc_sap_convert_cme_error_tel_sap_result(at_resp);
}
END:
tcore_at_tok_free(tokens);
} else {
err("RESPONSE NOK");
+ result = __imc_sap_convert_cme_error_tel_sap_result(at_resp);
}
END:
result = __map_sap_status_to_result(atoi(g_slist_nth_data(tokens, 0)));
card_reader_status = (unsigned char)atoi(g_slist_nth_data(tokens, 1));
- card_reader_status = card_reader_status >> 3;
+ card_reader_status = card_reader_status >> 3;
for (count = 8; count > 3; count--) { //check bit 8 to 3
+ /*TODO - Need to map card reader status to TelSapCardStatus.
if ((card_reader_status & 0x80) == TRUE) { //Check most significant bit
- //card_status = //TODO - Need to map card reader status to TelSapCardStatus.
+ //card_status = TEL_SAP_CARD_STATUS_UNKNOWN;
break;
}
+ */
card_reader_status = card_reader_status << 1; //left shift by 1
}
tcore_at_tok_free(tokens);
} else {
err("RESPONSE NOK");
- result = TEL_SAP_RESULT_FAILURE_NO_REASON;
+ result = __imc_sap_convert_cme_error_tel_sap_result(at_resp);
}
END:
#define PROACTV_CMD_LEN 256
+static TelSatResult
+__imc_sim_convert_cme_error_tel_sat_result(const TcoreAtResponse *at_resp)
+{
+ TelSatResult result = TEL_SAT_RESULT_FAILURE;
+ const gchar *line;
+ GSList *tokens = NULL;
+
+ dbg("Entry");
+
+ if (!at_resp || !at_resp->lines) {
+ err("Invalid response data");
+ return result;
+ }
+
+ line = (const gchar *)at_resp->lines->data;
+ tokens = tcore_at_tok_new(line);
+ if (g_slist_length(tokens) > 0) {
+ gchar *resp_str;
+ gint cme_err;
+
+ resp_str = g_slist_nth_data(tokens, 0);
+ if (!resp_str) {
+ err("Invalid CME Error data");
+ tcore_at_tok_free(tokens);
+ return result;
+ }
+
+ cme_err = atoi(resp_str);
+ dbg("CME error[%d]", cme_err);
+ switch (cme_err) {
+ case 3:
+ case 4:
+ result = TEL_SAT_RESULT_OPERATION_NOT_SUPPORTED;
+ break;
+
+ case 20:
+ case 23:
+ result = TEL_SAT_RESULT_MEMORY_FAILURE;
+ break;
+
+ case 50:
+ result = TEL_SAT_RESULT_INVALID_PARAMETER;
+ break;
+
+ case 100:
+ result = TEL_SAT_RESULT_UNKNOWN_FAILURE;
+ break;
+
+ default:
+ result = TEL_SAT_RESULT_FAILURE;
+ }
+ }
+ tcore_at_tok_free(tokens);
+
+ return result;
+}
+
static void on_response_enable_sat(TcorePending *p,
guint data_len, const void *data, void *user_data)
{
*/
dbg("SIM Status: [%d]", *sim_status);
if (*sim_status == TEL_SIM_STATUS_SIM_INIT_COMPLETED) {
+ TelReturn ret;
dbg("SIM Initialized!!! Enable SAT");
/* Enable SAT - Send AT+CFUN=6 */
- tcore_at_prepare_and_send_request(co,
+ ret = tcore_at_prepare_and_send_request(co,
"AT+CFUN=6", NULL,
TCORE_AT_COMMAND_TYPE_NO_RESULT,
NULL,
on_response_enable_sat, NULL,
on_send_imc_request, NULL);
+ IMC_CHECK_REQUEST_RET(ret, NULL, "Enable SAT");
}
return TCORE_HOOK_RETURN_CONTINUE;
TelSatResult result = TEL_SAT_RESULT_FAILURE;
GSList *tokens = NULL;
const gchar *line = NULL;
- const gchar *env_res = NULL;
gint sw2 = -1;
dbg("Entry");
tokens = tcore_at_tok_new(line);
if (g_slist_length(tokens) < 1) {
err("invalid message");
- tcore_at_tok_free(tokens);
- return;
+ goto OUT;
}
- }
- env_res = g_slist_nth_data(tokens, 0);
- envelop_resp = TEL_SAT_ENVELOPE_SUCCESS;
- dbg("RESPONSE tokens present");
- if (NULL != g_slist_nth_data(tokens, 1)) {
- sw2 = atoi(g_slist_nth_data(tokens, 1));
- dbg("status word SW2:[%d]", sw2);
- if (sw2 == 0) {
- dbg("Response is processed completely and sending session end notification");
- /* Send Session End notification */
- tcore_object_send_notification(co,
- TCORE_NOTIFICATION_SAT_SESSION_END, 0, NULL);
+
+ envelop_resp = TEL_SAT_ENVELOPE_SUCCESS;
+ dbg("RESPONSE tokens present");
+ if (NULL != g_slist_nth_data(tokens, 1)) {
+ sw2 = atoi(g_slist_nth_data(tokens, 1));
+ dbg("status word SW2:[%d]", sw2);
+ if (sw2 == 0) {
+ dbg("Response is processed completely " \
+ "and sending session end notification");
+
+ /* Send Session End notification */
+ tcore_object_send_notification(co,
+ TCORE_NOTIFICATION_SAT_SESSION_END,
+ 0, NULL);
+ }
}
}
} else {
- dbg("RESPONSE NOK");
+ err("RESPONSE NOK");
+
envelop_resp = TEL_SAT_ENVELOPE_FAILED;
+ result = __imc_sim_convert_cme_error_tel_sat_result(at_resp);
}
+OUT:
/* Invoke callback */
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)result, &envelop_resp, resp_cb_data->cb_data);
dbg(" at_resp->success = %d", at_resp->success);
/* Send Session End notification */
tcore_object_send_notification(co, TCORE_NOTIFICATION_SAT_SESSION_END, 0, NULL);
+ } else {
+ err("RESPONSE NOK");
+ result = __imc_sim_convert_cme_error_tel_sat_result(at_resp);
}
/* Invoke callback */
if (at_resp && at_resp->success) {
dbg("RESPONSE OK");
result = TEL_SAT_RESULT_SUCCESS;
+ } else {
+ err("RESPONSE NOK");
+ result = __imc_sim_convert_cme_error_tel_sat_result(at_resp);
}
/* Invoke callback */
#define ENABLE_FLAG 1
#define DISABLE_FLAG 2
+#define VAL_MINUS_ONE (-1)
+
#define IMC_SIM_ACCESS_READ_BINARY 176
#define IMC_SIM_ACCESS_READ_RECORD 178
#define IMC_SIM_ACCESS_GET_RESPONSE 192
typedef struct {
guint smsp_count; /**< SMSP record count */
guint smsp_rec_len; /**< SMSP record length */
+ guint mb_rec_len; /**< MBDN record length */
} ImcSimPrivateInfo;
typedef struct {
guint rec_length; /**< Length of one record in file */
guint rec_count; /**< Number of records in file */
guint data_size; /**< File size */
- guint current_index; /**< Current index to read */
- guint mb_count; /**< Current mbdn read index */
+ guint current_index; /**< Current index to read */
+ guint mb_count; /**< Current mbdn read index */
int mb_index[TEL_SIM_MSP_CNT_MAX * TEL_SIM_MAILBOX_TYPE_MAX]; /**< List of mbdn index to read */
+ int mbdn_index; /**< MBDN index to set mb_data */
+ TelSimMailBoxNumber *mb_data; /**< Set MailBox data */
ImcSimFileType file_type; /**< File type and structure */
- ImcSimCurrSecOp sec_op; /**< Current index to read */
- TelSimFileId file_id; /**< Current file id */
+ ImcSimCurrSecOp sec_op; /**< Current index to read */
+ TelSimFileId file_id; /**< Current file id */
TelSimResult file_result; /**< File access result */
- TelSimFileResult files; /**< File read data */
- TcoreCommand req_command; /**< Request command Id */
- TelSimImsiInfo imsi; /**< Stored locally as of now,
- Need to store in secure storage*/
+ TelSimFileResult files; /**< File read data */
+ TcoreCommand req_command; /**< Request command Id */
+ TelSimImsiInfo imsi; /**< Stored locally as of now,
+ Need to store in secure storage */
} ImcSimMetaInfo;
/* Utility Function Declaration */
static void __imc_sim_update_sim_status(CoreObject *co, TelSimCardStatus sim_status);
static void __imc_sim_notify_sms_state(CoreObject *co, gboolean sms_ready);
static TelReturn __imc_sim_start_to_cache(CoreObject *co);
-static gboolean __imc_sim_get_sim_type(CoreObject *co, TcoreObjectResponseCallback cb, void *cb_data);
-static void __imc_sim_next_from_read_binary(CoreObject *co, ImcRespCbData *resp_cb_data, TelSimResult sim_result, gboolean decode_ret);
-static void __imc_sim_next_from_get_response(CoreObject *co, ImcRespCbData *resp_cb_data, TelSimResult sim_result);
-static TelReturn __imc_sim_update_file(CoreObject *co, ImcRespCbData *resp_cb_data, int cmd, TelSimFileId ef,
- int p1, int p2, int p3, char *encoded_data);
+static TelReturn __imc_sim_get_sim_type(CoreObject *co,
+ TcoreObjectResponseCallback cb, void *cb_data);
+static void __imc_sim_next_from_read_binary(CoreObject *co,
+ ImcRespCbData *resp_cb_data, TelSimResult sim_result, gboolean decode_ret);
+static void __imc_sim_next_from_get_response(CoreObject *co,
+ ImcRespCbData *resp_cb_data, TelSimResult sim_result);
+static void __sim_set_mailbox_info(CoreObject *co, ImcRespCbData *resp_cb_data);
+static TelReturn __imc_sim_update_file(CoreObject *co,
+ ImcRespCbData *resp_cb_data, int cmd, TelSimFileId ef,
+ int p1, int p2, int p3, char *encoded_data);
static void __imc_sim_read_record(CoreObject *co, ImcRespCbData *resp_cb_data);
static void __imc_sim_read_binary(CoreObject *co, ImcRespCbData *resp_cb_data);
static TelReturn __imc_sim_get_response (CoreObject *co, ImcRespCbData *resp_cb_data);
static TelReturn __imc_sim_get_retry_count(CoreObject *co, ImcRespCbData *resp_cb_data);
static TelSimLockType __imc_sim_lock_type(int lock_type);
-static char *__imc_sim_get_fac_from_lock_type(TelSimLockType lock_type, ImcSimCurrSecOp *sec_op, int flag);
+static char *__imc_sim_get_fac_from_lock_type(TelSimLockType lock_type,
+ ImcSimCurrSecOp *sec_op, int flag);
static int __imc_sim_get_lock_type(ImcSimCurrSecOp sec_op);
/* Internal Response Functions*/
static void __on_response_imc_sim_get_retry_count(TcorePending *p, guint data_len, const void *data, void *user_data);
static void __on_response_imc_sim_update_file(TcorePending *p, guint data_len, const void *data, void *user_data);
+static TelSimResult
+__imc_sim_convert_cme_error_tel_sim_result(const TcoreAtResponse *at_resp)
+{
+
+ TelSimResult result = TEL_SIM_RESULT_FAILURE;
+ const gchar *line;
+ GSList *tokens = NULL;
+
+ dbg("Entry");
+
+ if (!at_resp || !at_resp->lines) {
+ err("Invalid response data");
+ return result;
+ }
+
+ line = (const gchar *)at_resp->lines->data;
+ tokens = tcore_at_tok_new(line);
+ if (g_slist_length(tokens) > 0) {
+ gchar *resp_str;
+ gint cme_err;
+
+ resp_str = g_slist_nth_data(tokens, 0);
+ if (!resp_str) {
+ err("Invalid CME Error data");
+ tcore_at_tok_free(tokens);
+ return result;
+ }
+ cme_err = atoi(resp_str);
+ dbg("CME error[%d]", cme_err);
+
+ switch (cme_err) {
+ case 3:
+ result = TEL_SIM_RESULT_OPERATION_NOT_PERMITTED;
+ break;
+
+ case 4:
+ result = TEL_SIM_RESULT_OPERATION_NOT_SUPPORTED;
+ break;
+
+ case 10:
+ case 13:
+ case 14:
+ case 15:
+ result = TEL_SIM_RESULT_CARD_ERROR;
+ break;
+
+ case 5:
+ case 6:
+ case 11:
+ case 17:
+ case 46:
+ case 47:
+ result = TEL_SIM_RESULT_PIN_REQUIRED;
+ break;
+
+ case 7:
+ case 12:
+ case 18:
+ case 45:
+ result = TEL_SIM_RESULT_PUK_REQUIRED;
+ break;
+
+ case 16:
+ result = TEL_SIM_RESULT_INCORRECT_PASSWORD;
+ break;
+
+ case 20:
+ case 23:
+ result = TEL_SIM_RESULT_MEMORY_FAILURE;
+ break;
+
+ case 50:
+ result = TEL_SIM_RESULT_INVALID_PARAMETER;
+ break;
+
+ default:
+ result = TEL_SIM_RESULT_FAILURE;
+ }
+ }
+ tcore_at_tok_free(tokens);
+
+ return result;
+}
+
/* GET SMSP info for SMS module */
gboolean imc_sim_get_smsp_info(TcorePlugin *plugin, int *rec_count, int *rec_len)
{
IMC_SIM_READ_FILE(co, NULL, NULL, TEL_SIM_EF_ECC, ret);
IMC_SIM_READ_FILE(co, NULL, NULL, TEL_SIM_EF_MSISDN, ret);
IMC_SIM_READ_FILE(co, NULL, NULL, TEL_SIM_EF_SMSP, ret);
-
+ IMC_SIM_READ_FILE(co, NULL, NULL, TEL_SIM_EF_MBDN, ret);
return ret;
}
* Failure:
* +CME ERROR: <error>
*/
-gboolean __imc_sim_get_sim_type(CoreObject *co,
+TelReturn __imc_sim_get_sim_type(CoreObject *co,
TcoreObjectResponseCallback cb, void *cb_data)
{
ImcRespCbData *resp_cb_data;
/* 2G */
/* The ME requests the Extended Language Preference. The ME only requests the Language Preference (EFLP) if at least one of the following conditions holds:
- EFELP is not available;
- - EFELP does not contain an entry corresponding to a language specified in ISO 639[30];
+ - EFELP does not contain an Entry corresponding to a language specified in ISO 639[30];
- the ME does not support any of the languages in EFELP.
*/
/* 3G */
break;
case TEL_SIM_EF_USIM_MBI:
- if (file_meta->current_index == file_meta->rec_count) {
- /* Init file_meta to read next EF file */
- file_meta->rec_count = 0;
- file_meta->current_index = 0;
- file_meta->file_id = TEL_SIM_EF_MBDN;
- /* Read MBDN record*/
- dbg("Read MBDN record");
- __imc_sim_get_response(co, resp_cb_data);
- return;
+ if (file_meta->current_index == file_meta->rec_count) {
+ if (file_meta->mb_data) {
+ guint i = 0;
+ for (i = 0; i < file_meta->files.data.mb.count; i++) {
+ if (file_meta->files.data.mb.list[i].mb_type
+ == file_meta->mb_data->mb_type)
+ file_meta->mbdn_index = file_meta->mb_index[i];
+ }
- } else {
- file_meta->current_index++;
- __imc_sim_read_record(co, resp_cb_data);
- return;
- }
+ if(!file_meta->mbdn_index)
+ file_meta->mbdn_index = VAL_MINUS_ONE;
+
+ __sim_set_mailbox_info(co, resp_cb_data);
+
+ return;
+ }
+
+ /* Init file_meta to read next EF file */
+ file_meta->rec_count = 0;
+ file_meta->current_index = 0;
+ file_meta->file_id = TEL_SIM_EF_MBDN;
+
+ /* Read MBDN record*/
+ dbg("Read MBDN record");
+ __imc_sim_get_response(co, resp_cb_data);
+
+ return;
+
+ } else {
+ file_meta->current_index++;
+
+ __imc_sim_read_record(co, resp_cb_data);
+
+ return;
+ }
break;
case TEL_SIM_EF_MBDN:
&& (sim_result != TEL_SIM_RESULT_SUCCESS)) {
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)sim_result, &file_meta->files.data, resp_cb_data->cb_data);
+ /* free resp_cb_data */
+ imc_destroy_resp_cb_data(resp_cb_data);
return;
}
dbg(" [SIM DATA]fail to get Language information in USIM(EF-LI(6F05),EF-PL(2F05))");
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)sim_result, &file_meta->files.data, resp_cb_data->cb_data);
+ /* free resp_cb_data */
+ imc_destroy_resp_cb_data(resp_cb_data);
return;
}
}
if (TEL_SIM_CARD_TYPE_GSM == card_type) {
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)sim_result, &file_meta->files.data, resp_cb_data->cb_data);
+ /* free resp_cb_data */
+ imc_destroy_resp_cb_data(resp_cb_data);
+
return;
}
/* if EFLI is not present, then the language selection shall be as defined in EFPL at the MF level */
" [SIM DATA]SIM_EF_USIM_PL(2A05) access fail. Request SIM_EF_ECC(0x6FB7) info");
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)sim_result, &file_meta->files.data, resp_cb_data->cb_data);
+ /* free resp_cb_data */
+ imc_destroy_resp_cb_data(resp_cb_data);
+
return;
}
break;
tcore_sim_set_cphs_status(co, FALSE);
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)sim_result, &file_meta->files.data, resp_cb_data->cb_data);
+
+ /* free resp_cb_data */
+ imc_destroy_resp_cb_data(resp_cb_data);
}
break;
break;
case TEL_SIM_EF_MBDN:
+ {
+ ImcSimPrivateInfo *priv_info = NULL;
+ priv_info = tcore_sim_ref_userdata(co);
+ if(priv_info)
+ priv_info->mb_rec_len = file_meta->rec_length;
file_meta->mb_count = 0;
file_meta->current_index = file_meta->mb_index[file_meta->mb_count];
__imc_sim_read_record(co, resp_cb_data);
+ }
break;
case TEL_SIM_EF_OPL:
}
} else {
err("RESPONSE NOK");
- sim_result = TEL_SIM_RESULT_FAILURE;
+ sim_result = __imc_sim_convert_cme_error_tel_sim_result(resp);
}
OUT:
/* Send Response */
if (resp_cb_data->cb)
resp_cb_data->cb(co_sim, (gint)sim_result, NULL, resp_cb_data->cb_data);
+ /* free resp_cb_data */
+ imc_destroy_resp_cb_data(resp_cb_data);
+
tcore_at_tok_free(tokens);
dbg("Exit");
}
if (g_slist_length(tokens) < 2) {
err("Invalid message");
tcore_at_tok_free(tokens);
+ /* free resp_cb_data */
+ imc_destroy_resp_cb_data(resp_cb_data);
return;
}
}
case TEL_SIM_EF_SPN:
dr = tcore_sim_decode_spn((unsigned char *)res, res_len, &file_meta->files.data.spn);
+ if( dr == FALSE ) {
+ err("SPN decoding failed");
+ } else {
+ tcore_sim_set_disp_condition(co, file_meta->files.data.spn.display_condition);
+ tcore_sim_set_spn(co, file_meta->files.data.spn.spn);
+ }
break;
case TEL_SIM_EF_SPDI:
} else {
err("RESPONSE NOK");
dbg("Error - File ID: [0x%x]", file_meta->file_id);
- sim_result = TEL_SIM_RESULT_FAILURE;
+ sim_result = __imc_sim_convert_cme_error_tel_sim_result(resp);
}
/* Get File data */
if (g_slist_length(tokens) < 2) {
err("Invalid message");
tcore_at_tok_free(tokens);
- return;
+ goto OUT;
}
}
sw1 = atoi(g_slist_nth_data(tokens, 0));
dbg("INVALID FCP received - DEbug!");
tcore_at_tok_free(tokens);
g_free(record_data);
- return;
+ goto OUT;
}
/*File identifier - 0x84,0x85,0x86 etc are currently ignored and not handled */
dbg("INVALID FCP received - DEbug!");
tcore_at_tok_free(tokens);
g_free(record_data);
- return;
+ goto OUT;
}
/* proprietary information */
dbg("INVALID FCP received[0x%x] - DEbug!", *ptr_data);
tcore_at_tok_free(tokens);
g_free(record_data);
- return;
+ goto OUT;
}
dbg("Current ptr_data value is [%x]", *ptr_data);
dbg("INVALID FCP received - DEbug!");
tcore_at_tok_free(tokens);
g_free(record_data);
- return;
+ goto OUT;
}
/* total file size including structural info*/
dbg("INVALID FCP received - DEbug!");
tcore_at_tok_free(tokens);
g_free(record_data);
- return;
+ goto OUT;
}
} else if (TEL_SIM_CARD_TYPE_GSM == card_type) {
unsigned char gsm_specific_file_data_len = 0;
} else {
err("RESPONSE NOK");
err("Failed to get ef[0x%x] (file_meta->file_id) ", file_meta->file_id);
- sim_result = TEL_SIM_RESULT_FAILURE;
+ sim_result = __imc_sim_convert_cme_error_tel_sim_result(resp);
}
+OUT:
dbg("Calling __imc_sim_next_from_get_response");
__imc_sim_next_from_get_response(co, resp_cb_data, sim_result);
dbg("Exit");
static TelSimLockType __imc_sim_lock_type(int lock_type)
{
- switch(lock_type) {
+ switch (lock_type) {
case 1 :
return TEL_SIM_LOCK_SC;
case 2 :
ImcSimCurrSecOp *sec_op, int flag)
{
char *fac = NULL;
- switch(lock_type) {
+ switch (lock_type) {
case TEL_SIM_LOCK_PS :
fac = "PS";
if (flag == ENABLE_FLAG)
static int __imc_sim_get_lock_type(ImcSimCurrSecOp sec_op)
{
- switch(sec_op) {
+ switch (sec_op) {
case IMC_SIM_CURR_SEC_OP_SIM_DISABLE :
case IMC_SIM_CURR_SEC_OP_SIM_ENABLE :
case IMC_SIM_CURR_SEC_OP_SIM_STATUS :
if (NULL == at_resp) {
err("at_resp is NULL");
auth_resp.detailed_result = TEL_SIM_AUTH_CANNOT_PERFORM;
- goto out;
+ goto OUT;
}
auth_resp.auth_type = *auth_type;
} else {
err("at_resp->lines is NULL");
auth_resp.detailed_result = TEL_SIM_AUTH_CANNOT_PERFORM;
- goto out;
+ goto OUT;
}
tokens = tcore_at_tok_new(line);
if (tokens == NULL) {
err("tokens is NULL");
auth_resp.detailed_result = TEL_SIM_AUTH_CANNOT_PERFORM;
- goto out;
+ goto OUT;
}
status = atoi(g_slist_nth_data(tokens, 0));
case 1:
err("Synchronize fail");
auth_resp.detailed_result = TEL_SIM_AUTH_SYNCH_FAILURE;
- goto out;
+ goto OUT;
case 2:
err("MAC wrong");
auth_resp.detailed_result = TEL_SIM_AUTH_MAK_CODE_FAILURE;
- goto out;
+ goto OUT;
case 3:
err("Does not support security context");
auth_resp.detailed_result = TEL_SIM_AUTH_UNSUPPORTED_CONTEXT;
- goto out;
+ goto OUT;
default:
err("Other failure");
auth_resp.detailed_result = TEL_SIM_AUTH_CANNOT_PERFORM;
- goto out;
+ goto OUT;
}
if (auth_resp.auth_type == TEL_SIM_AUTH_GSM) {
} else {
err("Invalid Kc");
auth_resp.detailed_result = TEL_SIM_AUTH_CANNOT_PERFORM;
- goto out;
+ goto OUT;
}
sres = g_slist_nth_data(tokens, 2);
} else {
err("Invalid SRES");
auth_resp.detailed_result = TEL_SIM_AUTH_CANNOT_PERFORM;
- goto out;
+ goto OUT;
}
} else if (auth_resp.auth_type == TEL_SIM_AUTH_3G_CTX) {
char *res, *ck, *ik, *kc;
} else {
err("Invalid RES/AUTS");
auth_resp.detailed_result = TEL_SIM_AUTH_CANNOT_PERFORM;
- goto out;
+ goto OUT;
}
ck = g_slist_nth_data(tokens, 2);
} else {
err("Invalid CK");
auth_resp.detailed_result = TEL_SIM_AUTH_CANNOT_PERFORM;
- goto out;
+ goto OUT;
}
ik = g_slist_nth_data(tokens, 3);
} else {
err("Invalid IK");
auth_resp.detailed_result = TEL_SIM_AUTH_CANNOT_PERFORM;
- goto out;
+ goto OUT;
}
kc = g_slist_nth_data(tokens, 4);
} else {
err("Invalid Kc");
auth_resp.detailed_result = TEL_SIM_AUTH_CANNOT_PERFORM;
- goto out;
+ goto OUT;
}
} else {
err("Not supported");
auth_resp.detailed_result = TEL_SIM_AUTH_CANNOT_PERFORM;
- goto out;
+ goto OUT;
}
sim_result = TEL_SIM_RESULT_SUCCESS;
} else {
auth_resp.detailed_result = TEL_SIM_AUTH_CANNOT_PERFORM;
}
-out:
+OUT:
if(resp_cb_data->cb)
resp_cb_data->cb(co, (gint)sim_result, &auth_resp, resp_cb_data->cb_data);
+ /* free resp_cb_data */
+ imc_destroy_resp_cb_data(resp_cb_data);
+
tcore_at_tok_free(tokens);
}
tcore_at_tok_free(tokens);
} else {
err("Sim Get Facility Response- [NOK]");
+ result = __imc_sim_convert_cme_error_tel_sim_result(at_resp);
+
}
EXIT:
/* Invoke callback */
tcore_at_tok_free(tokens);
} else {
err("Sim Get Lock Info Response- [NOK]");
+ result = __imc_sim_convert_cme_error_tel_sim_result(at_resp);
}
EXIT:
/* Invoke callback */
}
} else {
err("RESPONSE NOK");
+ sim_result = __imc_sim_convert_cme_error_tel_sim_result(resp);
}
OUT:
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)sim_result, &apdu_resp, resp_cb_data->cb_data);
tcore_at_tok_free(tokens);
+ imc_destroy_resp_cb_data(resp_cb_data);
dbg("Exit");
}
}
} else {
err("RESPONSE NOK");
+ sim_result = __imc_sim_convert_cme_error_tel_sim_result(resp);
+
}
OUT:
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)sim_result, &atr_res, resp_cb_data->cb_data);
tcore_at_tok_free(tokens);
+ imc_destroy_resp_cb_data(resp_cb_data);
dbg("Exit");
}
return ret;
}
-static TelReturn imc_sim_set_mailbox_info (CoreObject *co,
- const TelSimMailBoxNumber *request, TcoreObjectResponseCallback cb, void *cb_data)
+static void __sim_set_mailbox_info(CoreObject *co, ImcRespCbData *resp_cb_data)
{
- ImcSimMetaInfo file_meta = {0, };
- ImcRespCbData *resp_cb_data = NULL;
char *tmp = NULL;
- int tmp_len = 0;
char *encoded_data = NULL;
int encoded_data_len = 0;
int p1 = 0;
int p2 = 0;
int p3 = 0;
+ TelSimResult sim_result = TEL_SIM_RESULT_FAILURE;
+ ImcSimMetaInfo *file_meta = (ImcSimMetaInfo *)IMC_GET_DATA_FROM_RESP_CB_DATA(resp_cb_data);
+ ImcSimPrivateInfo *priv_info = tcore_sim_ref_userdata(co);
dbg("Entry");
- file_meta.file_id = TEL_SIM_EF_USIM_MBI;
- file_meta.file_result = TEL_SIM_RESULT_FAILURE;
+ if (!file_meta || !file_meta->mb_data || !priv_info) {
+ err("NULL data : file_meta[%p], file_meta->mb_data[%p], priv_info[%p]",
+ file_meta, file_meta->mb_data, priv_info);
+ goto OUT;
+ }
- /* TBD - Do Encoding.
- if (!tcore_sim_encode_mbi(request, sizeof(request), tmp, &tmp_len)) {
- err("Failed to encode mwis");
- return TEL_RETURN_FAILURE;
- } */
+ if (file_meta->mbdn_index == VAL_MINUS_ONE) {
+ err("Failed to get MBDN Index");
+ goto OUT;
+ }
+
+ dbg("mbdn_index:[%d], mb_rec_len:[%d]",
+ file_meta->mbdn_index, priv_info->mb_rec_len);
- encoded_data_len = tmp_len * 2;
+ if (!tcore_sim_encode_xdn(file_meta->mb_data->alpha_id,
+ file_meta->mb_data->number,
+ priv_info->mb_rec_len, &tmp)) {
+ err("Failed to encode mailbox_info");
+ goto OUT;
+ }
+
+ if (!tmp)
+ goto OUT;
+
+ dbg("Record length: [%d]", priv_info->mb_rec_len);
+
+ encoded_data_len = 2 * priv_info->mb_rec_len;
encoded_data = (char *)tcore_malloc0(encoded_data_len + 1);
- tcore_util_byte_to_hex(tmp, encoded_data, tmp_len);
+ tcore_util_byte_to_hex(tmp, encoded_data, priv_info->mb_rec_len);
if (!encoded_data) {
err("Failed to convert byte to hex");
- tcore_free(encoded_data);
- return TEL_RETURN_FAILURE;
+ goto OUT;
}
- p1 = 1;
+ p1 = file_meta->mbdn_index;
p2 = 0x04;
- p3 = encoded_data_len;
- dbg("encoded_data - [%s], encoded_data_len - %d", encoded_data, encoded_data_len);
+ p3 = priv_info->mb_rec_len;
+ dbg("encoded_data - [%s], encoded_data_len - %d",
+ encoded_data, priv_info->mb_rec_len);
+
+ __imc_sim_update_file(co, resp_cb_data,
+ IMC_SIM_ACCESS_UPDATE_RECORD,
+ TEL_SIM_EF_MBDN, p1, p2, p3, encoded_data);
+
+ tcore_free(tmp);
+ tcore_free(file_meta->mb_data);
+ file_meta->mb_data = NULL;
+
+ dbg("Exit");
+ return;
+
+OUT:
+ /* Send Response */
+ if (resp_cb_data->cb)
+ resp_cb_data->cb(co, (gint)sim_result, NULL, resp_cb_data->cb_data);
+
+ /* Free Memory */
+ tcore_free(tmp);
+ tcore_free(encoded_data);
+ tcore_free(file_meta->mb_data);
+ file_meta->mb_data = NULL;
+ imc_destroy_resp_cb_data(resp_cb_data);
+
+ dbg("Exit");
+}
+
+static TelReturn imc_sim_set_mailbox_info (CoreObject *co,
+ const TelSimMailBoxNumber *request, TcoreObjectResponseCallback cb, void *cb_data)
+{
+ ImcSimMetaInfo file_meta = {0, };
+ ImcRespCbData *resp_cb_data = NULL;
+ TelReturn ret;
+
+ dbg("Entry");
+
+ file_meta.file_id = TEL_SIM_EF_USIM_MBI;
+ file_meta.file_result = TEL_SIM_RESULT_FAILURE;
+
+ file_meta.mb_data = (TelSimMailBoxNumber *)tcore_malloc0(sizeof(TelSimMailBoxNumber));
+ memcpy(file_meta.mb_data, request, sizeof(TelSimMailBoxNumber));
resp_cb_data = imc_create_resp_cb_data(cb, cb_data, &file_meta, sizeof(ImcSimMetaInfo));
+ ret = __imc_sim_get_response(co, resp_cb_data);
- return __imc_sim_update_file(co, resp_cb_data, IMC_SIM_ACCESS_UPDATE_RECORD,
- TEL_SIM_EF_USIM_MBI, p1, p2, p3, encoded_data);
+ return ret;
}
static TelReturn imc_sim_get_msisdn (CoreObject *co,
return TEL_SIM_RESULT_OPERATION_NOT_SUPPORTED;
}
- if (request->rand_data != NULL) {
- convert_rand = tcore_malloc0(request->rand_length*2 + 1);
- tcore_util_byte_to_hex(request->rand_data, convert_rand, request->rand_length);
- dbg("Convert RAND hex to string: [%s]", convert_rand);
- } else {
- err("rand_data is NULL");
- goto EXIT;
- }
+ convert_rand = tcore_malloc0(request->rand_length*2 + 1);
+ tcore_util_byte_to_hex(request->rand_data, convert_rand, request->rand_length);
+ dbg("Convert RAND hex to string: [%s]", convert_rand);
switch (request->auth_type) {
case TEL_SIM_AUTH_GSM:
break;
case TEL_SIM_AUTH_3G_CTX:
context_type = 1;
- if (request->autn_data != NULL) {
- convert_autn = tcore_malloc0(request->autn_length*2 + 1);
- tcore_util_byte_to_hex(request->autn_data, convert_autn, request->autn_length);
- dbg("Convert AUTN hex to string: [%s]", convert_autn);
- } else {
- err("autn_data is NULL");
- goto EXIT;
- }
+ convert_autn = tcore_malloc0(request->autn_length*2 + 1);
+ tcore_util_byte_to_hex(request->autn_data, convert_autn, request->autn_length);
+
+ dbg("Convert AUTN hex to string: [%s]", convert_autn);
+
cmd_str = g_strdup_printf("AT+XAUTH=%d,%d,\"%s\",\"%s\"",
session_id, context_type, convert_rand, convert_autn);
break;
guint index;
TelSmsParamsInfo *params;
} ImcSmsParamsCbData;
+
+static TelSmsResult
+__imc_sms_convert_cms_error_tel_sms_result(const TcoreAtResponse *at_resp)
+{
+ TelSmsResult result = TEL_SMS_RESULT_FAILURE;
+ const gchar *line;
+ GSList *tokens = NULL;
+ dbg("Entry");
+
+ if (!at_resp || !at_resp->lines) {
+ err("Invalid response data");
+ return result;
+ }
+
+ line = (const gchar *)at_resp->lines->data;
+ tokens = tcore_at_tok_new(line);
+ if (g_slist_length(tokens) > 0) {
+ gchar *resp_str;
+ gint cms_err;
+
+ resp_str = g_slist_nth_data(tokens, 0);
+ if (!resp_str) {
+ err("invalid cms error data");
+ tcore_at_tok_free(tokens);
+ return result;
+ }
+ cms_err = atoi(resp_str);
+ dbg("CMS error[%d]", cms_err);
+
+ switch (cms_err) {
+ case 96:
+ result = TEL_SMS_RESULT_INVALID_MANDATORY_INFO;
+ break;
+
+ case 208:
+ case 209:
+ case 211:
+ case 320:
+ case 321:
+ case 322:
+ result = TEL_SMS_RESULT_MEMORY_FAILURE;
+ break;
+
+ case 42:
+ result = TEL_SMS_RESULT_NETWORK_CONGESTION;
+ break;
+
+ case 17:
+ case 38:
+ case 287:
+ case 290:
+ case 331:
+ case 332:
+ case 538:
+ result = TEL_SMS_RESULT_NETWORK_FAILURE;
+ break;
+
+ case 8:
+ case 10:
+ case 302:
+ case 303:
+ result = TEL_SMS_RESULT_OPERATION_NOT_SUPPORTED;
+ break;
+
+ case 255:
+ case 500:
+ case 548:
+ case 547:
+ result = TEL_SMS_RESULT_UNKNOWN_FAILURE;
+ break;
+
+ case 310:
+ case 311:
+ case 312:
+ case 313:
+ case 314:
+ case 315:
+ result = TEL_SMS_RESULT_SIM_FAILURE;
+ break;
+
+ case 84:
+ case 95:
+ case 161:
+ case 176:
+ case 195:
+ case 304:
+ case 305:
+ case 516:
+ case 521:
+ case 524:
+ case 525:
+ case 526:
+ case 527:
+ case 528:
+ case 529:
+ case 530:
+ case 531:
+ case 532:
+ case 533:
+ case 534:
+ case 535:
+ result = TEL_SMS_RESULT_INVALID_PARAMETER;
+ break;
+
+ default:
+ result = TEL_SMS_RESULT_FAILURE;
+ }
+ }
+ tcore_at_tok_free(tokens);
+
+ return result;
+}
+
+static TelSmsResult
+__imc_sms_convert_cme_error_tel_sms_result(const TcoreAtResponse *at_resp)
+{
+ TelSmsResult result = TEL_SMS_RESULT_FAILURE;
+ const gchar *line;
+ GSList *tokens = NULL;
+ dbg("Entry");
+
+ if (!at_resp || !at_resp->lines) {
+ err("Invalid response data");
+ return result;
+ }
+
+ line = (const gchar *)at_resp->lines->data;
+ tokens = tcore_at_tok_new(line);
+ if (g_slist_length(tokens) > 0) {
+ gchar *resp_str;
+ gint cme_err;
+
+ resp_str = g_slist_nth_data(tokens, 0);
+ if (!resp_str) {
+ err("Invalid CME Error data");
+ tcore_at_tok_free(tokens);
+ return result;
+ }
+ cme_err = atoi(resp_str);
+ dbg("CME error[%d]", cme_err);
+
+ switch (cme_err) {
+ case 3:
+ case 4:
+ result = TEL_SMS_RESULT_OPERATION_NOT_SUPPORTED;
+ break;
+
+ case 10:
+ case 11:
+ case 12:
+ case 13:
+ case 14:
+ case 15:
+ case 17:
+ case 18:
+ result = TEL_SMS_RESULT_SIM_FAILURE;
+ break;
+
+ case 20:
+ result = TEL_SMS_RESULT_MEMORY_FAILURE;
+ break;
+
+ case 30:
+ case 31:
+ result = TEL_SMS_RESULT_NETWORK_FAILURE;
+ break;
+
+ case 50:
+ result = TEL_SMS_RESULT_INVALID_PARAMETER;
+ break;
+
+ case 100:
+ result = TEL_SMS_RESULT_UNKNOWN_FAILURE;
+ break;
+
+ default:
+ result = TEL_SMS_RESULT_FAILURE;
+ }
+ }
+ tcore_at_tok_free(tokens);
+
+ return result;
+}
+
/*
* Notification - SMS-DELIVER
* +CMT = [<alpha>],<length><CR><LF><pdu> (PDU mode enabled)
return TRUE;
}
- line = (char *)g_slist_nth_data(lines, 0); /* Fetch Line 1 */
+ /* Fetch Line 1 */
+ line = (char *)g_slist_nth_data(lines, 0);
if (!line) {
err("Line 1 is invalid");
return TRUE;
guint encoded_sca_len;
/*
* byte_pdu[1] - sca_address_type
- * Excluding sca_address_type and copy SCA
+ * Excluding sca_address_type and copy SCA
*/
encoded_sca_len = sca_length - 1;
decoded_sca =
- tcore_util_convert_bcd_to_ascii(&byte_pdu[2], encoded_sca_len, encoded_sca_len*2);
+ tcore_util_convert_bcd_to_ascii(&byte_pdu[2], encoded_sca_len, encoded_sca_len * 2);
dbg("Decoded SCA: [%s]", decoded_sca);
g_strlcpy(incoming_msg.sca.number, decoded_sca, strlen(decoded_sca)+1);
tcore_free(decoded_sca);
dbg("TON: [%d] NPI: [%d] SCA: [%s]",
incoming_msg.sca.ton, incoming_msg.sca.npi,
incoming_msg.sca.number);
- }
- else {
+ } else {
dbg("NO SCA Present");
}
guint byte_pdu_len = 0;
GSList *lines = NULL;
- TelSmsCbMsgInfo cb_noti = { 0, };
+ TelSmsCbMsgInfo cb_noti = {0, };
dbg("Enter");
lines = (GSList *)event_info;
-
- line = (char *)(lines->data);/*Fetch Line 1*/
+ /* Fetch Line 1 */
+ line = (char *)(lines->data);
if (line != NULL) {
- tokens = tcore_at_tok_new(line); /* Split Line 1 into tokens */
+ /* Split Line 1 into tokens */
+ tokens = tcore_at_tok_new(line);
line_token = g_slist_nth_data(tokens, 0);
- if (line_token) {
- cb_noti.length = atoi(line_token);
- } else {
- dbg("token 0 is NULL");
- tcore_at_tok_free(tokens);
- return TRUE;
+ if (!line_token) {
+ err("invalid token");
+ goto OUT;
}
- pdu = g_slist_nth_data(lines, 1);
- if (pdu != NULL) {
- cb_noti.cb_type = TEL_SMS_CB_MSG_GSM;
- dbg("CB Msg LENGTH [%d]", cb_noti.length);
+ cb_noti.length = atoi(line_token);
+ pdu = g_slist_nth_data(lines, 1);
+ if (!pdu) {
+ err("NULL PDU Recieved ");
+ goto OUT;
+ }
- if ((cb_noti.length > 0) && (TEL_SMS_CB_DATA_SIZE_MAX >= cb_noti.length)) {
- tcore_util_hexstring_to_bytes(pdu, (gchar **)&byte_pdu, &byte_pdu_len);
+ cb_noti.cb_type = TEL_SMS_CB_MSG_GSM;
+ dbg("CB Msg LENGTH [%d]", cb_noti.length);
- memcpy(cb_noti.cb_data, (char*)byte_pdu, cb_noti.length);
- } else {
- err("Invalid Message Length");
- tcore_at_tok_free(tokens);
- return TRUE;
- }
+ if ((cb_noti.length > 0) && (cb_noti.length <= TEL_SMS_CB_DATA_SIZE_MAX)) {
+ tcore_util_hexstring_to_bytes(pdu, (gchar **)&byte_pdu, &byte_pdu_len);
+ cb_noti.cb_data = tcore_malloc0(cb_noti.length + 1);
+ memcpy(cb_noti.cb_data, (char*)byte_pdu, cb_noti.length);
} else {
- err("NULL PDU Recieved ");
- tcore_at_tok_free(tokens);
- return TRUE;
+ err("Invalid Message Length");
+ goto OUT;
}
+
tcore_object_send_notification(co,
- TCORE_NOTIFICATION_SMS_CB_INCOM_MSG, sizeof(TelSmsCbMsgInfo), &cb_noti);
+ TCORE_NOTIFICATION_SMS_CB_INCOM_MSG,
+ sizeof(TelSmsCbMsgInfo), &cb_noti);
g_free(byte_pdu);
+ tcore_free(cb_noti.cb_data);
} else {
- err("Response NOK");
+ err("Invalid Message received");
}
-
+OUT:
tcore_at_tok_free(tokens);
return TRUE;
}
/* Send notification */
tcore_object_send_notification(co,
- TCORE_NOTIFICATION_SMS_MEMORY_STATUS,
- sizeof(gboolean), &memory_status);
+ TCORE_NOTIFICATION_SMS_MEMORY_STATUS,
+ sizeof(gboolean), &memory_status);
}
tcore_at_tok_free(tokens);
} else {
- err("Response NOK");
+ err("invalid message received");
}
return TRUE;
{
const TcoreAtResponse *at_resp = data;
CoreObject *co = tcore_pending_ref_core_object(p);
-
- TelSmsDatapackageInfo incoming_msg = { { 0 }, };
-
- GSList *tokens=NULL;
- char *gslist_line = NULL, *line_token = NULL, *byte_pdu = NULL, *hex_pdu = NULL;
+ GSList *tokens = NULL;
+ char *gslist_line = NULL, *line_token = NULL;
+ char *byte_pdu = NULL, *hex_pdu = NULL;
gint sca_length = 0;
guint byte_pdu_len = 0;
+ TelSmsDatapackageInfo incoming_msg = { { 0 }, };
dbg("Enter");
if (at_resp && at_resp->success) {
dbg("RESPONSE OK");
- if (at_resp->lines) {
- /*
- * TCORE_AT_PDU:
- * Multi-line output
- *
- * Fetching First Line
- */
- gslist_line = (char *)at_resp->lines->data;
- dbg("gslist_line: [%s]", gslist_line);
+ if (!at_resp->lines) {
+ err("Invalid Response Received");
+ return;
+ }
+ /*
+ * TCORE_AT_PDU:
+ * Multi-line output
+ *
+ * Fetching First Line
+ */
+ gslist_line = (char *)at_resp->lines->data;
+ dbg("gslist_line: [%s]", gslist_line);
- /*Tokenize*/
- tokens = tcore_at_tok_new(gslist_line);
- dbg("Number of tokens: [%d]", g_slist_length(tokens));
+ /* Tokenize */
+ tokens = tcore_at_tok_new(gslist_line);
+ dbg("Number of tokens: [%d]", g_slist_length(tokens));
- /* First Token : status
- * Second Token: Alpha ID - not needed
- */
- line_token = g_slist_nth_data(tokens, 2); /* Third Token: PDU Length */
- if (line_token != NULL) {
- incoming_msg.tpdu_length = atoi(line_token);
- dbg("Length: [%d]", incoming_msg.tpdu_length);
- }
- else {
- err("Line Token for PDU Length is NULL");
- return;
- }
+ /* First Token : status (ignore)
+ * Second Token: Alpha ID(ignore)
+ * Third Token: PDU Length.
+ */
+ line_token = g_slist_nth_data(tokens, 2);
+ if (line_token != NULL) {
+ incoming_msg.tpdu_length = atoi(line_token);
+ dbg("Length: [%d]", incoming_msg.tpdu_length);
+ } else {
+ err("Line Token for PDU Length is NULL");
+ tcore_at_tok_free(tokens);
+ return;
+ }
- /* Fetching line: Second line is PDU */
- hex_pdu = (char *) at_resp->lines->next->data;
- dbg("EF-SMS PDU: [%s]", hex_pdu);
+ /* Fetching line: Second line is PDU */
+ hex_pdu = (char *) at_resp->lines->next->data;
+ dbg("EF-SMS PDU: [%s]", hex_pdu);
- tcore_at_tok_free(tokens); /* free the consumed token */
- if (NULL != hex_pdu) {
- tcore_util_hexstring_to_bytes(hex_pdu, &byte_pdu, &byte_pdu_len);
+ if (NULL != hex_pdu) {
+ tcore_util_hexstring_to_bytes(hex_pdu, &byte_pdu, &byte_pdu_len);
+ sca_length = (int)byte_pdu[0];
+ dbg("SCA Length [%d], msgLength: [%d]",
+ sca_length, incoming_msg.tpdu_length);
- sca_length = (int)byte_pdu[0];
+ if (ZERO == sca_length) {
+ memcpy(incoming_msg.tpdu, &byte_pdu[1],
+ incoming_msg.tpdu_length);
+ } else {
+ char sca_toa;
- dbg("SCA Length [%d], msgLength: [%d]", sca_length, incoming_msg.tpdu_length);
+ /*
+ * byte_pdu[1] - sca_address_type
+ * Excluding sca_address_type and copy SCA
+ */
+ memcpy(incoming_msg.sca.number, &byte_pdu[2],
+ (sca_length - 1));
- if (ZERO == sca_length) {
- memcpy(incoming_msg.tpdu, &byte_pdu[1], incoming_msg.tpdu_length);
- }
- else {
- char sca_toa;
-
- /*
- * byte_pdu[1] - sca_address_type
- * Excluding sca_address_type and copy SCA
- */
- memcpy(incoming_msg.sca.number, &byte_pdu[2], (sca_length-1));
-
- /*
- * SCA Conversion: Address Type
- * 3GPP TS 23.040 V6.5.0 Section: 9.1.2.5
- */
- sca_toa = byte_pdu[1];
- incoming_msg.sca.npi = IMC_NUM_PLAN_ID(sca_toa);
- incoming_msg.sca.ton = IMC_TYPE_OF_NUM(sca_toa);
-
- memcpy(incoming_msg.tpdu,
- &byte_pdu[sca_length+1],
- incoming_msg.tpdu_length);
- }
- }
+ /*
+ * SCA Conversion: Address Type
+ * 3GPP TS 23.040 V6.5.0 Section: 9.1.2.5
+ */
+ sca_toa = byte_pdu[1];
+ incoming_msg.sca.npi = IMC_NUM_PLAN_ID(sca_toa);
+ incoming_msg.sca.ton = IMC_TYPE_OF_NUM(sca_toa);
- tcore_object_send_notification(co,
- TCORE_NOTIFICATION_SMS_INCOM_MSG,
- sizeof(TelSmsDatapackageInfo), &incoming_msg);
- tcore_at_tok_free(tokens);
- g_free(byte_pdu);
- }
- else {
- err("Invalid Response Received");
+ memcpy(incoming_msg.tpdu,&byte_pdu[sca_length+1],
+ incoming_msg.tpdu_length);
+ }
}
- }
- else {
+
+ tcore_object_send_notification(co,
+ TCORE_NOTIFICATION_SMS_INCOM_MSG,
+ sizeof(TelSmsDatapackageInfo), &incoming_msg);
+ tcore_at_tok_free(tokens);
+ g_free(byte_pdu);
+ } else {
err("RESPONSE NOK");
}
}
* <mem> memory location
* <index> index where msg is stored
*/
-static gboolean on_notification_imc_sms_class2_incoming_msg(CoreObject *co, const void *event_info, void *user_data)
+static gboolean on_notification_imc_sms_class2_incoming_msg(CoreObject *co,
+ const void *event_info, void *user_data)
{
- gchar *at_cmd;
+ gchar *at_cmd = NULL;
TelReturn ret;
-
GSList *tokens = NULL , *lines = NULL;
char *line = NULL;
gint index, mem_type = 0;
dbg("Enter");
lines = (GSList *)event_info;
- line = (char *)g_slist_nth_data(lines, 0); /* Fetch Line 1 */
+ /* Fetch Line 1 */
+ line = (char *)g_slist_nth_data(lines, 0);
if (!line) {
err("Line 1 is invalid");
return TRUE;
}
dbg("Line 1: [%s]", line);
- tokens = tcore_at_tok_new(line); /* Split Line 1 into tokens */
- mem_type = atoi(g_slist_nth_data(tokens, 0));/* Type of Memory stored */
- dbg("mem_type=[%d]", mem_type);
+ /* Split Line 1 into tokens */
+ tokens = tcore_at_tok_new(line);
+ /* Type of Memory stored */
+ mem_type = atoi(g_slist_nth_data(tokens, 0));
+ dbg("mem_type = [%d]", mem_type);
index = atoi((char *) g_slist_nth_data(tokens, 1));
dbg("index: [%d]", index);
+ /* Free resources */
+ tcore_at_tok_free(tokens);
/*
* Operation - read_sms_in_sim
* Failure:
* +CMS ERROR: <error>
*/
- /*AT Command*/
+
+ /* AT Command */
at_cmd = g_strdup_printf("AT+CMGR=%d", index);
/* Send Request to modem */
NULL,
on_response_imc_class2_sms_incom_msg, NULL,
on_send_imc_request, NULL);
+
if (ret != TEL_RETURN_SUCCESS) {
err("Failed to Read Class2 Incomming Message");
}
CoreObject *co = tcore_pending_ref_core_object(p);
ImcRespCbData *resp_cb_data = user_data;
- TelSmsResult result = TEL_SMS_RESULT_FAILURE;/*TODO: CMS error mapping required */
+ TelSmsResult result = TEL_SMS_RESULT_FAILURE;
dbg("Enter");
tcore_check_return_assert(co != NULL);
tokens = tcore_at_tok_new(line);
line_token = g_slist_nth_data(tokens, 0);
if (line_token != NULL) {
- /*Response from MODEM for send SMS: +CMGS: <mr>[,<ackpdu>]*/
- /*Message Reference is not used by MSG_SERVER and application.So Filling only result*/
+ /* Response from MODEM for send SMS: +CMGS:
+ * <mr>[,<ackpdu>].
+ *
+ * Message Reference is not used by MSG_SERVER,
+ * and application. So Filling only result
+ */
msg_ref = atoi(line_token);
-
dbg("Message Reference: [%d]", msg_ref);
-
result = TEL_SMS_RESULT_SUCCESS;
- }
- else {
- dbg("No Message Reference received");
+ } else {
+ err("No Message Reference received");
}
tcore_at_tok_free(tokens);
}
- }
- else {
- err("Response NOK");
+ } else {
+ err("RESPONSE NOK");
+ result = __imc_sms_convert_cms_error_tel_sms_result(at_resp);
}
/* Invoke callback */
ImcRespCbData *resp_cb_data = user_data;
TelSmsResult result = TEL_SMS_RESULT_FAILURE;
-
GSList *tokens = NULL;
char *line = NULL, *line_token = NULL;
- guint index = -1;
-
+ gint index = -1;
dbg("Enter");
+ tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
if (at_resp && at_resp->success) {
dbg("Response OK");
if (at_resp->lines) {
- line = (char *)at_resp->lines->data;
+ line = (char *)at_resp->lines->data;
tokens = tcore_at_tok_new(line);
line_token = g_slist_nth_data(tokens, 0);
if (line_token) {
- index = (atoi(line_token));
+ index = atoi(line_token);
dbg("SMS written to '%d' index", index);
result = TEL_SMS_RESULT_SUCCESS;
+ } else {
+ err("invalid message");
}
- else {
- dbg("No Tokens");
- result = TEL_SMS_RESULT_FAILURE;
- }
- }
- else {
+ } else {
err("Lines NOT present");
}
- }
- else {
- dbg("Response NOK");
+ } else {
+ err("RESPONSE NOK");
+ result = __imc_sms_convert_cms_error_tel_sms_result(at_resp);
}
/* Invoke callback */
const TcoreAtResponse *at_resp = data;
CoreObject *co = tcore_pending_ref_core_object(p);
ImcRespCbData *resp_cb_data = user_data;
- TelSmsSimDataInfo read_resp;
+ TelSmsSimDataInfo read_resp = {0,};
GSList *tokens = NULL;
- TelSmsResult result = TEL_SMS_RESULT_FAILURE;/* CMS error mapping required */
+ TelSmsResult result = TEL_SMS_RESULT_FAILURE;
dbg("Enter");
- memset(&read_resp, 0x0, sizeof(TelSmsSimDataInfo));
+ tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
if (at_resp && at_resp->success) {
dbg("RESPONSE OK");
if (at_resp->lines) {
- char *gslist_line = NULL,*line_token = NULL,*byte_pdu = NULL,*hex_pdu = NULL;
+ gchar *gslist_line = NULL, *line_token = NULL;
+ gchar *byte_pdu = NULL, *hex_pdu = NULL;
gint msg_status = 0, pdu_len = 0, alpha_id = 0;
+ gint sca_length = 0;
+ guint byte_pdu_len = 0;
/*
* TCORE_AT_PDU:
- * Multi-line output
+ * Multi-line output
*
* Fetching First Line
*/
gslist_line = (char *)at_resp->lines->data;
dbg("gslist_line: [%s]", gslist_line);
- /*Tokenize*/
+ /* Tokenize */
tokens = tcore_at_tok_new(gslist_line);
dbg("Number of tokens: [%d]", g_slist_length(tokens));
- /*+CMGR: <stat>,[<alpha>],<length><CR><LF><pdu>*/
- line_token = g_slist_nth_data(tokens, 0); /*First Token: Message status*/
+ /* +CMGR: <stat>,[<alpha>],<length><CR><LF><pdu> */
+ /* First Token: Message status */
+ line_token = g_slist_nth_data(tokens, 0);
if (line_token == NULL) {
err("Invalid stat");
goto OUT;
}
msg_status = atoi(line_token);
- dbg("msg_status is %d",msg_status);
+ dbg("msg_status [%d]", msg_status);
switch (msg_status) {
case AT_MT_UNREAD:
break;
}
- /*Second Token: Alpha ID*/
+ /* Second Token: Alpha ID */
line_token = g_slist_nth_data(tokens, 1);
if (line_token != NULL) {
alpha_id = atoi(line_token);
dbg("alpha_id: [%d]", alpha_id);
}
- /*Third Token: Length*/
+ /* Third Token: Length */
line_token = g_slist_nth_data(tokens, 2);
if (line_token == NULL) {
err("Invalid PDU length");
pdu_len = atoi(line_token);
dbg("PDU length: [%d]", pdu_len);
- /*Fetching line: Second line is PDU*/
+ /* Fetching line: Second line is PDU */
hex_pdu = (char *) at_resp->lines->next->data;
dbg("EF-SMS PDU: [%s]", hex_pdu);
- if (NULL != hex_pdu) {
- gint sca_length = 0;
- guint byte_pdu_len = 0;
-
- tcore_util_hex_dump(" ", sizeof(hex_pdu), (void *)hex_pdu);
-
- tcore_util_hexstring_to_bytes(hex_pdu, &byte_pdu, &byte_pdu_len);
-
- sca_length = byte_pdu[0];
- dbg("SCA length = %d", sca_length);
- if (sca_length) {
- gchar *decoded_sca;
- guint encoded_sca_len;
-
- /*
- * byte_pdu[1] - sca_address_type
- * Excluding sca_address_type and copy SCA
- */
- encoded_sca_len = sca_length - 1;
- decoded_sca =
- tcore_util_convert_bcd_to_ascii(&byte_pdu[2],
- encoded_sca_len, encoded_sca_len*2);
-
- dbg("Decoded SCA: [%s]", decoded_sca);
- memcpy(read_resp.data.sca.number, decoded_sca, TEL_SMS_SCA_LEN_MAX);
- tcore_free(decoded_sca);
-
- /*SCA Conversion for Address type*/
- read_resp.data.sca.ton = IMC_TYPE_OF_NUM(byte_pdu[1]);
- read_resp.data.sca.npi = IMC_NUM_PLAN_ID(byte_pdu[1]);
- dbg("TON: [%d] NPI: [%d] SCA: [%s]",
- read_resp.data.sca.ton, read_resp.data.sca.npi,
- read_resp.data.sca.number);
- } else {
- err("NO SCA Present");
- }
+ if (NULL == hex_pdu) {
+ err("Invalid Response Received");
+ goto OUT;
+ }
- /* TPDU */
- read_resp.data.tpdu_length = pdu_len;
- if ((read_resp.data.tpdu_length > 0)
- && (read_resp.data.tpdu_length <= TEL_SMS_SMDATA_SIZE_MAX)) {
- memcpy(read_resp.data.tpdu, &byte_pdu[sca_length+1],
- read_resp.data.tpdu_length);
- } else {
- warn("Invalid TPDU length: [%d]", read_resp.data.tpdu_length);
- }
+ tcore_util_hex_dump(" ", sizeof(hex_pdu), (void *)hex_pdu);
- result = TEL_SMS_RESULT_SUCCESS;
- g_free(byte_pdu);
+ tcore_util_hexstring_to_bytes(hex_pdu, &byte_pdu, &byte_pdu_len);
+
+ sca_length = byte_pdu[0];
+ dbg("SCA length = %d", sca_length);
+ if (sca_length) {
+ gchar *decoded_sca;
+ guint encoded_sca_len;
+
+ /*
+ * byte_pdu[1] - sca_address_type
+ * Excluding sca_address_type and copy SCA
+ */
+ encoded_sca_len = sca_length - 1;
+ decoded_sca =
+ tcore_util_convert_bcd_to_ascii(&byte_pdu[2],
+ encoded_sca_len, encoded_sca_len * 2);
+
+ dbg("Decoded SCA: [%s]", decoded_sca);
+ memcpy(read_resp.data.sca.number, decoded_sca,
+ TEL_SMS_SCA_LEN_MAX);
+ tcore_free(decoded_sca);
+
+ /* SCA Conversion for Address type */
+ read_resp.data.sca.ton = IMC_TYPE_OF_NUM(byte_pdu[1]);
+ read_resp.data.sca.npi = IMC_NUM_PLAN_ID(byte_pdu[1]);
+ dbg("TON: [%d] NPI: [%d] SCA: [%s]",
+ read_resp.data.sca.ton, read_resp.data.sca.npi,
+ read_resp.data.sca.number);
+ } else {
+ err("NO SCA Present");
}
- } else {
- err("Invalid Response Received");
+
+ /* TPDU */
+ read_resp.data.tpdu_length = pdu_len;
+ if ((read_resp.data.tpdu_length > 0)
+ && (read_resp.data.tpdu_length <= TEL_SMS_SMDATA_SIZE_MAX)) {
+ memcpy(read_resp.data.tpdu, &byte_pdu[sca_length+1],
+ read_resp.data.tpdu_length);
+ } else {
+ warn("Invalid TPDU length: [%d]",
+ read_resp.data.tpdu_length);
+ }
+
+ result = TEL_SMS_RESULT_SUCCESS;
+ g_free(byte_pdu);
}
- }
- else {
+
+ } else {
err("RESPONSE NOK");
+ result = __imc_sms_convert_cms_error_tel_sms_result(at_resp);
}
OUT:
/* Invoke callback */
/* Free callback data */
imc_destroy_resp_cb_data(resp_cb_data);
- /*free the consumed token*/
+ /* free the consumed token */
tcore_at_tok_free(tokens);
}
dbg("Enter");
tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
if (at_resp && at_resp->success) {
dbg("Response OK");
result = TEL_SMS_RESULT_SUCCESS;
- }
- else {
- dbg("Response NOK");
+ } else {
+ err("RESPONSE NOK");
+ result = __imc_sms_convert_cms_error_tel_sms_result(at_resp);
}
/* Invoke callback */
static void on_response_imc_sms_get_msg_indices(TcorePending *p,
guint data_len, const void *data, void *user_data)
{
- TelSmsStoredMsgCountInfo *count_info;/*Response from get_count Request*/
- TelSmsResult result = TEL_SMS_RESULT_FAILURE;/*TODO: CMS error mapping required */
-
+ /* Response from get_count Request */
+ TelSmsStoredMsgCountInfo *count_info;
const TcoreAtResponse *at_resp = data;
CoreObject *co = tcore_pending_ref_core_object(p);
ImcRespCbData *resp_cb_data = user_data;
+ TelSmsResult result = TEL_SMS_RESULT_FAILURE;
dbg("Enter");
+ tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
count_info = (TelSmsStoredMsgCountInfo *)IMC_GET_DATA_FROM_RESP_CB_DATA(resp_cb_data);
if (at_resp && at_resp->success) {
dbg("RESPONSE OK");
if (at_resp->lines) {
- char *gslist_line = NULL;
+ gchar *gslist_line = NULL;
gint gslist_line_count = 0, ctr_loop = 0;
gslist_line_count = g_slist_length(at_resp->lines);
if (NULL != gslist_line) {
GSList *tokens = NULL;
- char *line_token = NULL;
+ gchar *line_token = NULL;
tokens = tcore_at_tok_new(gslist_line);
line_token = g_slist_nth_data(tokens, 0);
if (NULL != line_token) {
- count_info->index_list[ctr_loop] = atoi(line_token);
- }
- else {
- dbg("line_token of gslist_line [%d] is NULL", ctr_loop);
+ count_info->index_list[ctr_loop] =
+ atoi(line_token);
+ } else {
+ dbg("line_token of gslist_line [%d] is NULL",
+ ctr_loop);
}
tcore_at_tok_free(tokens);
- }
- else {
+ } else {
err("gslist_line is NULL");
- goto ERROR;
+ goto OUT;
}
}
result = TEL_SMS_RESULT_SUCCESS;
- }
- else {
- err("Invalid Response received. No Lines present in Response");
-
+ } else {
+ err("Invalid Response received. No Lines present in response");
/* Check if used count is zero*/
if (count_info->used_count == 0)
result = TEL_SMS_RESULT_SUCCESS;
}
- }
- else {
+ } else {
err("RESPONSE NOK");
+ result = __imc_sms_convert_cms_error_tel_sms_result(at_resp);
}
-ERROR:
+OUT:
+ dbg("get msg indices: [%s]",
+ (result == TEL_SMS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
+
/* Invoke callback */
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)result, count_info, resp_cb_data->cb_data);
{
gchar *at_cmd;
TelReturn ret;
-
TelSmsStoredMsgCountInfo count_info = {0, };
- TelSmsResult result = TEL_SMS_RESULT_FAILURE;
int used_count = 0, total_count = 0;
-
const TcoreAtResponse *at_resp = data;
CoreObject *co = tcore_pending_ref_core_object(p);
ImcRespCbData *resp_cb_data = user_data;
ImcRespCbData *getcnt_resp_cb_data;
+ TelSmsResult result = TEL_SMS_RESULT_FAILURE;
dbg("Enter");
+ tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
+
if (at_resp && at_resp->success) {
dbg("RESPONSE OK");
if (at_resp->lines) {
GSList *tokens = NULL;
- char *line = NULL, *line_token = NULL;
+ gchar *line = NULL, *line_token = NULL;
- line = (char *)at_resp->lines->data;
- dbg("line: [%s]",line);
+ line = (gchar *)at_resp->lines->data;
+ dbg("line: [%s]", line);
/*
* Tokenize
*
- * +CPMS: <used1>, <total1>, <used2>, <total2>, <used3>, <total3>
+ * +CPMS: <used1>, <total1>, <used2>, <total2>,
+ * <used3>, <total3>
*/
tokens = tcore_at_tok_new(line);
/* <used1> */
line_token = g_slist_nth_data(tokens, 0);
- if (line_token) {
- used_count =atoi(line_token);
- dbg("used cnt is %d",used_count);
- }
- else {
+ if (!line_token) {
err("Line Token for used count is NULL");
tcore_at_tok_free(tokens);
- goto ERROR;
+ goto OUT;
}
+ used_count = atoi(line_token);
+ dbg("used count [%d]", used_count);
/* <total1> */
line_token = g_slist_nth_data(tokens, 1);
- if (line_token) {
- total_count = atoi(line_token);
+ if (!line_token) {
+ err("Line Token for Total count is NULL");
+ tcore_at_tok_free(tokens);
+ goto OUT;
+ }
+ total_count = atoi(line_token);
+ count_info.total_count = total_count;
+ count_info.used_count = used_count;
+ dbg("Count - used: [%d] total: [%d]", used_count, total_count);
- count_info.total_count = total_count;
- count_info.used_count = used_count;
- dbg("Count - used: [%d] total: [%d]", used_count, total_count);
+ /*
+ * Operation - get_msg_indices_in_sim
+ *
+ * Request -
+ * AT-Command: AT+CMGL
+ * +CPMS=<mem1>[, <mem2>[,<mem3>]]
+ * where
+ * <mem1> memory storage to read.
+ *
+ * Response -
+ * Success: (Multi-line output)
+ * +CMGL=<stat>]
+ *
+ * <stat> status of the message.
+ * Failure:
+ * +CMS ERROR: <error>
+ */
- /*
- * Operation - get_msg_indices_in_sim
- *
- * Request -
- * AT-Command: AT+CMGL
- * +CPMS=<mem1>[, <mem2>[,<mem3>]]
- * where
- * <mem1> memory storage to read.
- *
- * Response -
- * Success: (Multi-line output)
- * +CMGL=<stat>]
- *
- * <stat> status of the message.
- * Failure:
- * +CMS ERROR: <error>
- */
-
- /* Sending the Second AT Request to fetch msg indices */
- at_cmd = g_strdup_printf("AT+CMGL=4");
-
- /* Response callback data */
- getcnt_resp_cb_data = imc_create_resp_cb_data(resp_cb_data->cb,
- resp_cb_data->cb_data,
- &count_info, sizeof(TelSmsStoredMsgCountInfo));
-
- /* Free previous request callback data */
- imc_destroy_resp_cb_data(resp_cb_data);
+ /* Sending the Second AT Request to fetch msg indices */
+ at_cmd = g_strdup_printf("AT+CMGL=4");
- /* Send Request to modem */
- ret = tcore_at_prepare_and_send_request(co,
- at_cmd, "+CMGL",
- TCORE_AT_COMMAND_TYPE_MULTILINE,
- NULL,
- on_response_imc_sms_get_msg_indices, getcnt_resp_cb_data,
- on_send_imc_request, NULL);
+ /* Response callback data */
+ getcnt_resp_cb_data = imc_create_resp_cb_data(resp_cb_data->cb,
+ resp_cb_data->cb_data,
+ &count_info, sizeof(TelSmsStoredMsgCountInfo));
- /* free the consumed token */
- tcore_at_tok_free(tokens);
- g_free(at_cmd);
+ /* Free previous request callback data */
+ imc_destroy_resp_cb_data(resp_cb_data);
+ resp_cb_data = NULL;
+ /* free the consumed token */
+ tcore_at_tok_free(tokens);
- IMC_CHECK_REQUEST_RET(ret, getcnt_resp_cb_data, "Get Indices in SIM");
- if (ret != TEL_RETURN_SUCCESS) {
- err("Failed to Process Get Msg Indices Request");
- goto ERROR;
- }
+ /* Send Request to modem */
+ ret = tcore_at_prepare_and_send_request(co,
+ at_cmd, "+CMGL",
+ TCORE_AT_COMMAND_TYPE_MULTILINE,
+ NULL,
+ on_response_imc_sms_get_msg_indices,
+ getcnt_resp_cb_data,
+ on_send_imc_request, NULL);
- dbg("Exit");
- return;
+ g_free(at_cmd);
+ if (ret != TEL_RETURN_SUCCESS) {
+ err("Failed to Process Get Msg Indices Request");
+ imc_destroy_resp_cb_data(getcnt_resp_cb_data);
+ goto OUT;
}
- else {
- err("Line Token for Total count is NULL");
+ dbg("Exit");
+ return;
- /* free the consumed token */
- tcore_at_tok_free(tokens);
- goto ERROR;
- }
- }
- else {
+ } else {
err("Invalid Response Received: NO Lines Present");
}
- }
- else {
+ } else {
err("RESPONSE NOK");
+ result = __imc_sms_convert_cms_error_tel_sms_result(at_resp);
}
-ERROR:
+OUT:
+ dbg("Get sms count: [%s]",
+ (result == TEL_SMS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
+
/* Invoke callback in case of error*/
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)result, NULL, resp_cb_data->cb_data);
TelSmsResult result = TEL_SMS_RESULT_FAILURE;
dbg("Enter");
+ tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
+
if (at_resp && at_resp->success) {
dbg("Response OK");
result = TEL_SMS_RESULT_SUCCESS;
- }
- else {
+ } else {
err("Response NOK");
}
+ dbg("Set sca: [%s]",
+ (result == TEL_SMS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
+
/* Invoke callback */
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)result, NULL, resp_cb_data->cb_data);
TelSmsResult result = TEL_SMS_RESULT_FAILURE;
dbg("Enter");
+ tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
+
if (at_resp && at_resp->success) {
dbg("Response OK");
if (at_resp->lines) {
GSList *tokens = NULL;
const char *sca_tok_addr;
- gchar *line = NULL, *sca_addr = NULL, *sca_toa = NULL;
+ gchar *line = NULL, *sca_addr = NULL;
gint hexa_toa = 0;
+ gchar *sca_toa = NULL;
- line = (char *)at_resp->lines->data;
+ line = (gchar *)at_resp->lines->data;
tokens = tcore_at_tok_new(line);
sca_tok_addr = g_slist_nth_data(tokens, 0);
sca_toa = g_slist_nth_data(tokens, 1);
sca_resp.npi = hexa_toa & 0x0F;
sca_resp.ton = (hexa_toa & 0x70) >> 4;
result = TEL_SMS_RESULT_SUCCESS;
- }
- else {
+ } else {
err("SCA is NULL");
}
tcore_at_tok_free(tokens);
g_free(sca_addr);
+ } else {
+ err("Invalid RESPONSE. No Lines Received");
}
- else {
- err("Invalid Response.No Lines Received");
- }
- }
- else {
- err("Response NOK");
+ } else {
+ err("RESPONSE NOK");
+ result = __imc_sms_convert_cms_error_tel_sms_result(at_resp);
}
+ dbg("Get sca: [%s]",
+ (result == TEL_SMS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
+
/* Invoke callback */
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)result, &sca_resp, resp_cb_data->cb_data);
CoreObject *co = tcore_pending_ref_core_object(p);
ImcRespCbData *resp_cb_data = user_data;
- TelSmsResult result = TEL_SMS_RESULT_FAILURE;/*TODO: CME error mapping required */
+ TelSmsResult result = TEL_SMS_RESULT_FAILURE;
dbg("Enter");
+ tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
+
if (at_resp && at_resp->success) {
dbg("Response OK");
result = TEL_SMS_RESULT_SUCCESS;
+ } else {
+ err("RESPONSE NOK");
+ result = __imc_sms_convert_cme_error_tel_sms_result(at_resp);
}
- else {
- err("Response NOK");
- }
+
+ dbg("Set cb config: [%s]",
+ (result == TEL_SMS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
/* Invoke callback */
if (resp_cb_data->cb)
CoreObject *co = tcore_pending_ref_core_object(p);
ImcRespCbData *resp_cb_data = user_data;
- GSList *cb_tokens = NULL;
- char *cb_str_token = NULL;
- int num_cb_tokens = 0;
- char *mid_tok = NULL;
- char *first_tok = NULL, *second_tok = NULL;
- gint i = 0, mode = 0;
- char delim[] = "-";
-
TelSmsCbConfigInfo get_cb_conf = {0, };
TelSmsResult result = TEL_SMS_RESULT_FAILURE;
dbg("Enter");
+ tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
+
if (at_resp && at_resp->success) {
dbg("Response OK");
if (at_resp->lines) {
GSList *tokens = NULL;
- char *line_token = NULL, *line = NULL;
- line = (char*)at_resp->lines->data;
- if (line != NULL) {
- tokens = tcore_at_tok_new(line);
- /*
- * Response -
- * +CSCB: <mode>,<mids>,<dcss>
- */
- line_token = g_slist_nth_data(tokens, 0);
- if (line_token) {
- mode = atoi(line_token);
- dbg("mode:[%d]", mode);
- get_cb_conf.cb_enabled = mode;
- }
- else {
- err("Line Token for Mode is NULL");
- tcore_at_tok_free(tokens);
- goto OUT;
- }
- line_token = g_slist_nth_data(tokens, 1);
- if (line_token) {
- cb_str_token = tcore_at_tok_extract(line_token);
- cb_tokens = tcore_at_tok_new((const char *)cb_str_token);
-
- num_cb_tokens = g_slist_length(cb_tokens);
- dbg("num_cb_tokens = %d", num_cb_tokens);
- if (num_cb_tokens == 0) {
- if (mode == 1) { /* All CBS Enabled */
- get_cb_conf.msg_id_range_cnt = 1;
- get_cb_conf.msg_ids[0].from_msg_id = 0x0000;
- get_cb_conf.msg_ids[0].to_msg_id = TEL_SMS_GSM_CBMI_LIST_SIZE_MAX + 1;
- get_cb_conf.msg_ids[0].selected = TRUE;
- }
- else { /* All CBS Disabled */
- get_cb_conf.msg_id_range_cnt = 0;
- get_cb_conf.msg_ids[0].selected = FALSE;
- }
- }
+ gchar *data = NULL, *line = NULL;
+ gchar *msg_ids = NULL;
+ GSList *cb_tokens = NULL;
+ gint num_cb_tokens = 0;
+ gchar *mid_tok = NULL;
+ gint i = 0, mode = 0;
+ gchar *first_tok = NULL, *second_tok = NULL;
+ gchar delim[] = "-";
+
+ line = (gchar*)at_resp->lines->data;
+ if (!line) {
+ err("Line is NULL");
+ goto OUT;
+ }
- for(i = 0; i < num_cb_tokens; i++) {
- get_cb_conf.msg_ids[i].selected = TRUE;
- dbg("msgIdRangeCount:[%d]", get_cb_conf.msg_id_range_cnt);
- get_cb_conf.msg_id_range_cnt++;
- dbg("Incremented msgIdRangeCount:[%d]", get_cb_conf.msg_id_range_cnt);
-
- 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) */
- get_cb_conf.msg_ids[i].from_msg_id = atoi(first_tok);
- get_cb_conf.msg_ids[i].to_msg_id = atoi(second_tok);
- }
- else {/* single mid value (0,1,5, 922)*/
- get_cb_conf.msg_ids[i].from_msg_id = atoi(mid_tok);
- get_cb_conf.msg_ids[i].to_msg_id = atoi(mid_tok);
- }
- }
- }
- else {
- err("Line Token for MID is NULL");
- tcore_at_tok_free(tokens);
- goto OUT;
+ tokens = tcore_at_tok_new(line);
+ /*
+ * Response -
+ * +CSCB: <mode>,<mids>,<dcss>
+ */
+ data = g_slist_nth_data(tokens, 0);
+ if (data) {
+ mode = atoi(data);
+ dbg("mode:[%d]", mode);
+ get_cb_conf.cb_enabled = mode;
+ } else {
+ err("Line Token for Mode is NULL");
+ tcore_at_tok_free(tokens);
+ goto OUT;
+ }
+
+ data = g_slist_nth_data(tokens, 1);
+ if (!data) {
+ err("Line Token for MID is NULL");
+ tcore_at_tok_free(tokens);
+ goto OUT;
+ }
+ msg_ids = tcore_at_tok_extract(data);
+ cb_tokens = tcore_at_tok_new((const char *)msg_ids);
+ num_cb_tokens = g_slist_length(cb_tokens);
+ dbg("num_cb_tokens = %d", num_cb_tokens);
+
+ if (num_cb_tokens == 0) {
+ if (mode == 1) { /* All CBS Enabled */
+ get_cb_conf.msg_id_range_cnt = 1;
+ get_cb_conf.msg_ids[0].from_msg_id = 0x0000;
+ get_cb_conf.msg_ids[0].to_msg_id =
+ TEL_SMS_GSM_CBMI_LIST_SIZE_MAX + 1;
+ get_cb_conf.msg_ids[0].selected = TRUE;
+ } else { /* All CBS Disabled */
+ get_cb_conf.msg_id_range_cnt = 0;
+ get_cb_conf.msg_ids[0].selected = FALSE;
}
}
- else {
- err("Line is NULL");
+
+ for (i = 0; i < num_cb_tokens; i++) {
+ get_cb_conf.msg_ids[i].selected = TRUE;
+ dbg("msgIdRangeCount:[%d]", get_cb_conf.msg_id_range_cnt);
+
+ get_cb_conf.msg_id_range_cnt++;
+ dbg("Incremented msgIdRangeCount:[%d]",
+ get_cb_conf.msg_id_range_cnt);
+
+ mid_tok = tcore_at_tok_nth(cb_tokens, i);
+ first_tok = strtok(mid_tok, delim);
+ second_tok = strtok(NULL, delim);
+
+ /* mids in range (320-478) */
+ if ((first_tok != NULL) && (second_tok != NULL)) {
+ get_cb_conf.msg_ids[i].from_msg_id = atoi(first_tok);
+ get_cb_conf.msg_ids[i].to_msg_id = atoi(second_tok);
+ } else { /* single mid value (0,1,5, 922)*/
+ get_cb_conf.msg_ids[i].from_msg_id = atoi(mid_tok);
+ get_cb_conf.msg_ids[i].to_msg_id = atoi(mid_tok);
+ }
}
+
result = TEL_SMS_RESULT_SUCCESS;
tcore_at_tok_free(tokens);
tcore_at_tok_free(cb_tokens);
- g_free(cb_str_token);
- }
- else {
+ g_free(msg_ids);
+ } else {
err("Invalid Response.No Lines Received");
}
- }
- else {
- err("Response NOK");
+ } else {
+ err("RESPONSE NOK");
+ result = __imc_sms_convert_cme_error_tel_sms_result(at_resp);
}
OUT:
+ dbg("Get cb config: [%s]",
+ (result == TEL_SMS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
+
/* Invoke callback */
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)result, &get_cb_conf, resp_cb_data->cb_data);
TelSmsResult result = TEL_SMS_RESULT_FAILURE;
dbg("Enter");
+ tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
+
if (at_resp && at_resp->success) {
dbg("Response OK");
result = TEL_SMS_RESULT_SUCCESS;
- }
- else {
- err("Response NOK");
+ } else {
+ err("RESPONSE NOK");
+ result = __imc_sms_convert_cme_error_tel_sms_result(at_resp);
}
+ dbg("Set memory status: [%s]",
+ (result == TEL_SMS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
/* Invoke callback */
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)result, NULL, resp_cb_data->cb_data);
ImcRespCbData *resp_cb_data = user_data;
TelSmsResult result = TEL_SMS_RESULT_FAILURE;
- int response = 0, sw1 = 0, sw2 = 0;
- const char *line = NULL;
- char *line_token = NULL;
- GSList *tokens = NULL;
dbg("Enter");
+ tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
+
if (at_resp && at_resp->success) {
dbg("RESPONSE OK");
if (at_resp->lines) {
+ gint response = 0, sw1 = 0, sw2 = 0;
+ const char *line = NULL;
+ gchar *data = NULL;
+ GSList *tokens = NULL;
+
line = (const char *) at_resp->lines->data;
tokens = tcore_at_tok_new(line);
- line_token = g_slist_nth_data(tokens, 0);
- if (line_token != NULL) {
- sw1 = atoi(line_token);
- }
- else {
+ data = g_slist_nth_data(tokens, 0);
+ if (data != NULL) {
+ sw1 = atoi(data);
+ } else {
dbg("sw1 is NULL");
}
- line_token = g_slist_nth_data(tokens, 1);
- if (line_token != NULL) {
- sw2 = atoi(line_token);
+
+ data = g_slist_nth_data(tokens, 1);
+ if (data != NULL) {
+ sw2 = atoi(data);
if ((sw1 == 0x90) && (sw2 == 0)) {
result = TEL_SMS_RESULT_SUCCESS;
}
- }
- else {
+ } else {
dbg("sw2 is NULL");
}
- line_token = g_slist_nth_data(tokens, 3);
- if (line_token != NULL) {
- response = atoi(line_token);
+ data = g_slist_nth_data(tokens, 3);
+ if (data != NULL) {
+ response = atoi(data);
dbg("response is %s", response);
}
tcore_at_tok_free(tokens);
+ } else {
+ err("No lines");
}
- else {
- dbg("No lines");
- }
- }
- else {
- err("RESPONSE NOK");
+ } else {
+ err("RESPONSE NOK");
+ result = __imc_sms_convert_cme_error_tel_sms_result(at_resp);
}
+ dbg("Set message status: [%s]",
+ (result == TEL_SMS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
+
/* Invoke callback */
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)result, NULL, resp_cb_data->cb_data);
TelSmsStatusInfo *status_info;
TelSmsResult result = TEL_SMS_RESULT_FAILURE;
TelReturn ret;
-
- char *encoded_data = NULL;
- int encoded_len = 0;
- char msg_status = 0;
- char *line_token = NULL;
- GSList *tokens=NULL;
- const char *line = NULL;
- int sw1 = 0;
- int sw2 = 0;
dbg("Enter");
+ tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
+
status_info = (TelSmsStatusInfo *)IMC_GET_DATA_FROM_RESP_CB_DATA(resp_cb_data);
if (at_resp && at_resp->success) {
dbg("RESPONSE OK");
if (at_resp->lines) {
- dbg("Entry:lines Ok");
+ char *encoded_data = NULL;
+ int encoded_len = 0;
+ char msg_status = 0;
+ char *line_token = NULL;
+ GSList *tokens = NULL;
+ const char *line = NULL;
+ gint sw1 = 0, sw2 = 0;
+
line = (const char *) at_resp->lines->data;
tokens = tcore_at_tok_new(line);
sw1 = atoi(g_slist_nth_data(tokens, 0));
sw2 = atoi(g_slist_nth_data(tokens, 1));
line_token = g_slist_nth_data(tokens, 2);
+ encoded_len = strlen(line_token);
- dbg("line_token:[%s], Length of line token:[%d]", line_token, strlen(line_token));
+ dbg("line_token:[%s], Length of line token:[%d]",
+ line_token, encoded_len);
+
+ encoded_data = tcore_malloc0(2 * encoded_len + 1);
+ memcpy(encoded_data, line_token, encoded_len);
+ dbg("encoded_data: [%s]", encoded_data);
if ((sw1 == 0x90 && sw2 == 0x00) || sw1 == 0x91) {
switch (status_info->status) {
break;
}
}
- encoded_len = strlen(line_token);
- dbg("Encoded data length:[%d]", encoded_len);
-
- encoded_data = tcore_malloc0(2*encoded_len + 1);
-
- memcpy(encoded_data, line_token, encoded_len);
- dbg("encoded_data: [%s]", encoded_data);
-
/* overwrite Status byte information */
tcore_util_byte_to_hex((const char *)&msg_status, encoded_data, 1);
*
*/
at_cmd = g_strdup_printf("AT+CRSM=220,28476,%d, 4, %d, \"%s\"",
- (status_info->index), IMC_AT_EF_SMS_RECORD_LEN, encoded_data);
+ (status_info->index), IMC_AT_EF_SMS_RECORD_LEN, encoded_data);
/* Send Request to modem */
ret = tcore_at_prepare_and_send_request(co,
at_cmd, "+CRSM:",
TCORE_AT_COMMAND_TYPE_SINGLELINE,
NULL,
- on_response_imc_sms_set_message_status, resp_cb_data,
+ on_response_imc_sms_set_message_status,
+ resp_cb_data,
on_send_imc_request, NULL);
IMC_CHECK_REQUEST_RET(ret, resp_cb_data,
"Set Message Status-Updating status in Record");
g_free(status_info);
tcore_at_tok_free(tokens);
return;
- }
- else {
+ } else {
err("Invalid Response Received");
}
}
else {
- err("Response NOK");
+ err("RESPONSE NOK");
+ result = __imc_sms_convert_cme_error_tel_sms_result(at_resp);
}
+ dbg("get efsms status: [%s]",
+ (result == TEL_SMS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
+
/* Invoke callback */
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)result, NULL, resp_cb_data->cb_data);
err("invalid response received");
goto OUT;
}
- hex_data = tcore_at_tok_extract((const gchar *)hex_data);
+ hex_data = tcore_at_tok_extract((const gchar *)hex_data);
tcore_util_hexstring_to_bytes(hex_data, &record_data, (guint*)&decoding_length);
tcore_free(hex_data);
/*
* Decrementing the Record Count and Filling the ParamsInfo List
- * Final Response will be posted when Record count is ZERO
+ * Final RESPONSE will be posted when Record count is ZERO
*/
params_req_data->params[params_req_data->index].index = params_req_data->index;
tcore_util_decode_sms_parameters((unsigned char *)record_data,
- decoding_length,
- ¶ms_req_data->params[params_req_data->index]);
+ decoding_length,
+ ¶ms_req_data->params[params_req_data->index]);
params_req_data->total_param_count -= 1;
return;
}
} else {
- err("Invalid Response Received");
+ err("Invalid RESPONSE Received");
}
} else {
err("RESPONSE NOK");
+ result = __imc_sms_convert_cme_error_tel_sms_result(at_resp);
}
OUT:
{
TelSmsParamsInfoList param_info_list = {0, };
-
if (result == TEL_SMS_RESULT_SUCCESS) {
param_info_list.params = params_req_data->params;
param_info_list.count = params_req_data->record_count;
const TcoreAtResponse *at_resp = data;
CoreObject *co = tcore_pending_ref_core_object(p);
ImcRespCbData *resp_cb_data = user_data;
-
TelSmsResult result = TEL_SMS_RESULT_FAILURE;
- gint sw1 = 0 , sw2 = 0;
- const char *line = NULL;
- GSList *tokens=NULL;
dbg("Enter");
+ tcore_check_return_assert(co != NULL);
+ tcore_check_return_assert(resp_cb_data != NULL);
+
if (at_resp && at_resp->success) {
dbg("Response OK");
if (at_resp->lines) {
+ gint sw1 = 0 , sw2 = 0;
+ const char *line = NULL;
+ GSList *tokens = NULL;
+
line = (const char *) at_resp->lines->data;
tokens = tcore_at_tok_new(line);
if ((sw1 == 0x90 && sw2 == 0x00) || sw1 == 0x91) {
result = TEL_SMS_RESULT_SUCCESS;
}
- else {
- result = TEL_SMS_RESULT_FAILURE;
- }
+ tcore_at_tok_free(tokens);
}
- tcore_at_tok_free(tokens);
+
} else {
- err("Response NOK");
+ err("RESPONSE NOK");
+ result = __imc_sms_convert_cme_error_tel_sms_result(at_resp);
}
+ dbg("set sms params: [%s]",
+ (result == TEL_SMS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
+
/* Invoke callback */
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)result, NULL, resp_cb_data->cb_data);
*
* Request -
* AT-Command: AT+CMGS
- * For PDU mode (+CMGF=0):
- * +CMGS=<length><CR>
- * PDU is given<ctrl-Z/ESC>
+ * For PDU mode (+CMGF=0):
+ * +CMGS=<length><CR>
+ * PDU is given<ctrl-Z/ESC>
* where,
* <length> Length of the pdu.
* <PDU> PDU to send.
*
* Response -
- *+CMGS: <mr>[,<ackpdu>]
- * OK
+ * +CMGS: <mr>[,<ackpdu>]
+ * OK
* Failure:
- * +CMS ERROR: <error>
+ * +CMS ERROR: <error>
*/
static TelReturn imc_sms_send_sms(CoreObject *co,
const TelSmsSendInfo *send_info, TcoreObjectResponseCallback cb, void *cb_data)
*
* Request -
* AT-Command: AT+CMGW
- * AT+CMGW = <length>[,<stat>]<CR>PDU is given<ctrl-Z/ESC>
+ * AT+CMGW = <length>[,<stat>]<CR>PDU is given<ctrl-Z/ESC>
* where
- * <length> length of the tpdu
- * <stat> status of the message
- * <PDU> PDu of the message
+ * <length> length of the tpdu
+ * <stat> status of the message
+ * <PDU> PDu of the message
*
* Response -
- * +CMGW: <index>
+ * +CMGW: <index>
* Success: (Single line)
* OK
* Failure:
- * +CMS ERROR: <error>
+ * +CMS ERROR: <error>
*/
static TelReturn imc_sms_write_sms_in_sim(CoreObject *co,
const TelSmsSimDataInfo *wdata, TcoreObjectResponseCallback cb, void *cb_data)
*
* Request -
* AT-Command: At+CMGR=<index>
- * where
+ * where
* <index> index of the message to be read.
*
* Response -
* +CMGR: <stat>,[<alpha>],<length><CR><LF><pdu>
*
* Failure:
- * +CMS ERROR: <error>
+ * +CMS ERROR: <error>
*/
static TelReturn imc_sms_read_sms_in_sim(CoreObject *co,
unsigned int index, TcoreObjectResponseCallback cb, void *cb_data)
*
* Request -
* AT-Command: AT+CGMD
- * +CMGD=<index>[,<delflag>]
+ * +CMGD=<index>[,<delflag>]
*
* Response -
* Success: (NO RESULT) -
- * OK
+ * OK
* Failure:
- * +CMS ERROR: <error>
+ * +CMS ERROR: <error>
*/
static TelReturn imc_sms_delete_sms_in_sim(CoreObject *co,
unsigned int index,
*/
/* AT-Command */
- at_cmd = g_strdup_printf("AT+CMGD=%d,0", index); /*Delete specified index*/
+ at_cmd = g_strdup_printf("AT+CMGD=%d,0", index); /* Delete specified index */
/* Send Request to modem */
ret = tcore_at_prepare_and_send_request(co,
*
* Request -
* AT-Command: AT+CPMS
- * +CPMS=<mem1>[, <mem2>[,<mem3>]]
- * where
+ * +CPMS=<mem1>[, <mem2>[,<mem3>]]
+ * where
* <mem1> memory storage to read.
*
* Response -
* OK
*
* Failure:
- * +CMS ERROR: <error>
+ * +CMS ERROR: <error>
*/
static TelReturn imc_sms_get_msg_count_in_sim(CoreObject *co,
TcoreObjectResponseCallback cb, void *cb_data)
*
* Request -
* AT-Command: AT+CSCA
- * AT+CSCA=<sca>[,<tosca>]
+ * AT+CSCA=<sca>[,<tosca>]
* where
* <sca> Service center number
* <tosca> address type of SCA
*
* Response -
* Success: No result
- * OK
+ * OK
*
* Failure:
- * +CMS ERROR: <error>
+ * +CMS ERROR: <error>
*/
static TelReturn imc_sms_set_sca(CoreObject *co,
const TelSmsSca *sca, TcoreObjectResponseCallback cb, void *cb_data)
* AT-Command: AT+CSCA?
*
* Response -
- * Success: Single-Line
- * +CSCA: <sca>,<tosca>
- * OK
+ * Success: Single-Line
+ * +CSCA: <sca>,<tosca>
+ * OK
* where
* <sca> Service center number
* <tosca> address type of SCA
static TelReturn imc_sms_get_sca(CoreObject *co,
TcoreObjectResponseCallback cb, void *cb_data)
{
- gchar *at_cmd;
-
ImcRespCbData *resp_cb_data;
TelReturn ret;
dbg("Enter");
- /* AT Command */
- at_cmd = g_strdup_printf("AT+CSCA?");
-
/* Response callback data */
resp_cb_data = imc_create_resp_cb_data(cb, cb_data, NULL, 0);
/* Send Request to modem */
ret = tcore_at_prepare_and_send_request(co,
- at_cmd, "+CSCA",
+ "AT+CSCA?", "+CSCA",
TCORE_AT_COMMAND_TYPE_SINGLELINE,
NULL,
on_response_imc_sms_get_sca, resp_cb_data,
on_send_imc_request, NULL);
IMC_CHECK_REQUEST_RET(ret, resp_cb_data, "Get SCA");
- /* Free resources */
- g_free(at_cmd);
-
return ret;
}
*
* Request -
* AT-Command: AT+CSCB
- * +CSCB=[<mode>[,<mids>[,<dcss>]]]
+ * +CSCB=[<mode>[,<mids>[,<dcss>]]]
*
* Response -
* Success
* OK
*
* Failure:
- * +CME ERROR: <error>
+ * +CME ERROR: <error>
*/
static TelReturn imc_sms_set_cb_config(CoreObject *co,
const TelSmsCbConfigInfo *cb_conf,
TcoreObjectResponseCallback cb, void *cb_data)
{
gchar *at_cmd;
-
ImcRespCbData *resp_cb_data;
TelReturn ret;
-
unsigned short ctr1 = 0, ctr2 = 0, msg_id_range = 0;
unsigned short append_msg_id = 0;
dbg("Enter");
at_cmd = NULL;
mid_string = g_string_new("AT+CSCB=0,\"");
- for(ctr1 = 0; ctr1 < cb_conf->msg_id_range_cnt; ctr1++) {
+ for (ctr1 = 0; ctr1 < cb_conf->msg_id_range_cnt; ctr1++) {
if (cb_conf->msg_ids[ctr1].selected == FALSE)
continue;
- msg_id_range = ((cb_conf->msg_ids[ctr1].to_msg_id) - (cb_conf->msg_ids[ctr1].from_msg_id));
+ msg_id_range = ((cb_conf->msg_ids[ctr1].to_msg_id) -
+ (cb_conf->msg_ids[ctr1].from_msg_id));
if (TEL_SMS_GSM_CBMI_LIST_SIZE_MAX <= msg_id_range) {
mid_string = g_string_new("AT+CSCB=1"); /* Enable All CBS */
append_msg_id = cb_conf->msg_ids[ctr1].from_msg_id;
dbg( "%x", append_msg_id);
- for(ctr2 = 0; ctr2 <= msg_id_range; ctr2++) {
- mid_string = g_string_append(mid_string, g_strdup_printf("%d", append_msg_id));
+ for (ctr2 = 0; ctr2 <= msg_id_range; ctr2++) {
+ mid_string = g_string_append(mid_string,
+ g_strdup_printf("%d", append_msg_id));
if (ctr2 == msg_id_range) {
- mid_string = g_string_append(mid_string, "\""); /*Mids string termination*/
- }
- else {
+ /* Mids string termination */
+ mid_string = g_string_append(mid_string, "\"");
+ } else {
mid_string = g_string_append(mid_string, ",");
}
append_msg_id++;
mids_str = g_string_free(mid_string, FALSE);
at_cmd = g_strdup_printf("%s", mids_str);
g_free(mids_str);
- }
- else {
- at_cmd = g_strdup_printf("AT+CSCB=%d", cb_conf->cb_enabled); /* Enable or Disable MsgId's */
+ } else {
+ /* Enable or Disable MsgId's */
+ at_cmd = g_strdup_printf("AT+CSCB=%d", cb_conf->cb_enabled);
}
/* Response callback data */
*
* Request -
* AT-Command: AT+CSCB
- * +CSCB?
+ * +CSCB?
*
* Response -
* Success - (Single line)
- * +CSCB : <mode>,<mids>,<dcss>
+ * +CSCB : <mode>,<mids>,<dcss>
* OK
*
*/
static TelReturn imc_sms_get_cb_config(CoreObject *co,
TcoreObjectResponseCallback cb, void *cb_data)
{
- gchar *at_cmd;
-
ImcRespCbData *resp_cb_data;
TelReturn ret;
dbg("Enter");
- /* AT Command */
- at_cmd = g_strdup_printf("AT+CSCB?");
-
/* Response callback data */
resp_cb_data = imc_create_resp_cb_data(cb, cb_data, NULL, 0);
/* Send Request to modem */
ret = tcore_at_prepare_and_send_request(co,
- at_cmd, NULL,
+ "AT+CSCB?", NULL,
TCORE_AT_COMMAND_TYPE_SINGLELINE,
NULL,
on_response_imc_sms_get_cb_config, resp_cb_data,
on_send_imc_request, NULL);
IMC_CHECK_REQUEST_RET(ret, resp_cb_data, "Get Cb Config");
- /* Free resources */
- g_free(at_cmd);
-
return ret;
}
* Operation - send_deliver_report
*
* Request -
- * Modem Takes care of sending the ACK to the network
+ * Modem Takes care of sending the ACK to the network
*
* Response -
* Success: Default response always SUCCESS posted
*
* Request -
* AT-Command: AT+XTESM=<mem_capacity>
- * <mem_capacity> status of the external SMS storage which may be:
+ * <mem_capacity> status of the external SMS storage which may be:
* 0: memory capacity free
* 1: memory capacity full
*
* Response -No Result
- * Success
- * OK
+ * Success
+ * OK
*
* Failure:
- * +CME ERROR: <error>
+ * +CME ERROR: <error>
*/
static TelReturn imc_sms_set_memory_status(CoreObject *co,
gboolean available, TcoreObjectResponseCallback cb, void *cb_data)
*
* Request -
* AT-Command: AT+CRSM= command>[,<fileid>[,<P1>,<P2>,<P3>[,<data>[,<pathid>]]]]
- * p1 Index
- * p3 SMSP record length
+ * p1 Index
+ * p3 SMSP record length
*
*
* Response -Single Line
- * Success
- * OK
+ * Success
+ * OK
*
* Failure:
- * +CME ERROR: <error>
+ * +CME ERROR: <error>
*/
static TelReturn imc_sms_set_message_status(CoreObject *co,
const TelSmsStatusInfo *status_info,
*
* Request -
* AT-Command: AT+CRSM
- * AT+CRSM= command>[,<fileid>[,<P1>,<P2>,<P3>[,<data>[,<pathid>]]]]
+ * AT+CRSM= command>[,<fileid>[,<P1>,<P2>,<P3>[,<data>[,<pathid>]]]]
*
* Response -
* Success: (Single-line output)
- * +CRSM:
- * <sw1>,<sw2>[,<response>]
- * OK
+ * +CRSM:
+ * <sw1>,<sw2>[,<response>]
+ * OK
*
* Failure:
- * +CME ERROR: <error>
+ * +CME ERROR: <error>
*/
static TelReturn imc_sms_get_sms_params(CoreObject *co,
TcoreObjectResponseCallback cb, void *cb_data)
TcorePlugin *plugin;
ImcRespCbData *resp_cb_data;
ImcSmsParamsCbData params_req_data = {0, };
- gint loop_count, record_count = 0, smsp_record_len = 0;
+ gint record_count = 0, smsp_record_len = 0;
gchar *at_cmd;
/* SMSP record length */
params_req_data.record_length = smsp_record_len;
- /* Response callback data */
+ /* RESPONSE callback data */
resp_cb_data = imc_create_resp_cb_data(cb, cb_data,
(void *)¶ms_req_data,
sizeof(ImcSmsParamsCbData));
*
* Request -
* AT-Command: AT+CRSM
- * AT+CRSM= command>[,<fileid>[,<P1>,<P2>,<P3>[,<data>[,<pathid>]]]]
+ * AT+CRSM= command>[,<fileid>[,<P1>,<P2>,<P3>[,<data>[,<pathid>]]]]
*
* Response -
* Success: (Single-line output)
- * +CRSM:
- * <sw1>,<sw2>[,<response>]
- * OK
+ * +CRSM:
+ * <sw1>,<sw2>[,<response>]
+ * OK
*
* Failure:
* +CME ERROR: <error>
tcore_util_byte_to_hex((const char *)set_params_data,
(char *)encoded_data, smsp_record_len);
- /* Response callback data */
+ /* RESPONSE callback data */
resp_cb_data = imc_create_resp_cb_data(cb, cb_data, NULL, 0);
/* AT+ Command*/
return TRUE;
}
+static TelSsResult __imc_ss_convert_cme_error_tel_ss_result(const TcoreAtResponse *at_resp)
+{
+ TelSsResult result = TEL_SS_RESULT_FAILURE;
+ const gchar *line;
+ GSList *tokens = NULL;
+ dbg("Entry");
+
+ if (!at_resp || !at_resp->lines) {
+ err("Invalid response data");
+ return result;
+ }
+
+ line = (const gchar *)at_resp->lines->data;
+ tokens = tcore_at_tok_new(line);
+ if (g_slist_length(tokens) > 0) {
+ gchar *resp_str;
+ gint cme_err;
+
+ resp_str = g_slist_nth_data(tokens, 0);
+ if (!resp_str) {
+ err("invalid cme error data");
+ tcore_at_tok_free(tokens);
+ return result;
+ }
+ cme_err = atoi(resp_str);
+ dbg("CME error[%d]", cme_err);
+
+ switch (cme_err) {
+ case 3:
+ result = TEL_SS_RESULT_OPERATION_NOT_PERMITTED;
+ break;
+
+ case 4:
+ result = TEL_SS_RESULT_OPERATION_NOT_SUPPORTED;
+ break;
+
+ case 16:
+ result = TEL_SS_RESULT_INVALID_PASSWORD;
+ break;
+
+ case 20:
+ result = TEL_SS_RESULT_MEMORY_FAILURE;
+ break;
+
+ case 50:
+ result = TEL_SS_RESULT_INVALID_PARAMETER;
+ break;
+
+ case 132:
+ case 133:
+ case 134:
+ result = TEL_SS_RESULT_SERVICE_NOT_AVAILABLE;
+ break;
+
+ default:
+ result = TEL_SS_RESULT_FAILURE;
+ }
+ }
+ tcore_at_tok_free(tokens);
+
+ return result;
+}
+
static gboolean __imc_ss_convert_modem_class_to_class(gint classx, TelSsClass *class)
{
- switch(classx)
+ switch (classx)
{
case 7:
*class = TEL_SS_CLASS_ALL_TELE;
static guint __imc_ss_convert_class_to_imc_class(TelSsClass class)
{
- switch(class)
+ switch (class)
{
case TEL_SS_CLASS_ALL_TELE:
return 7;
static gboolean __imc_ss_convert_barring_type_to_facility(TelSsBarringType type,
gchar **facility)
{
- switch(type)
+ switch (type)
{
case TEL_SS_CB_TYPE_BAOC:
*facility = "AO";
static gboolean __imc_ss_convert_forwarding_mode_to_modem_mode(TelSsForwardMode mode,
guint *modex)
{
- switch(mode)
+ switch (mode)
{
case TEL_SS_CF_MODE_DISABLE:
*modex = 0;
static gboolean __imc_ss_convert_cli_info_modem_info(const TelSsCliInfo **cli_info,gint *status,
gchar **cmd_prefix)
{
- switch((*cli_info)->type)
+ switch ((*cli_info)->type)
{
case TEL_SS_CLI_CLIR:
if ((*status = __imc_ss_convert_clir_status_modem_status((*cli_info)->status.clir))
return FALSE;
}
} else { //CLIP, COLP,COLR,CNAP.
- switch(dev_status) {
+ switch (dev_status) {
case 0:
*status = TEL_SS_CLI_DISABLE;
break;
if (at_resp && at_resp->success)
result = TEL_SS_RESULT_SUCCESS;
+ else {
+ err("RESPONSE NOK");
+ result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
+ }
dbg("Setting Barring status: [%s]",
(result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
}
else {
err("RESPONSE - [NOK]");
+ result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
}
} else {
err("No response data");
if (!classx_str) {
dbg("Class error. Setting to the requested class: [%d]",
req_info->class);
- barring_resp.records[valid_records].class = req_info->class;
+ barring_resp.records[valid_records].class =
+ req_info->class;
} else {
if (__imc_ss_convert_modem_class_to_class(atoi(classx_str),
&(barring_resp.records[valid_records].class))
const TcoreAtResponse *at_resp = data;
CoreObject *co = tcore_pending_ref_core_object(p);
ImcRespCbData *resp_cb_data = user_data;
- /* TODO: CMEE error mapping is required */
TelSsResult result = TEL_SS_RESULT_FAILURE;
dbg("Enter");
if (at_resp && at_resp->success)
result = TEL_SS_RESULT_SUCCESS;
+ else {
+ err("RESPONSE NOK");
+ result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
+ }
dbg("Change Barring Password: [%s]",
(result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
if (at_resp && at_resp->success)
result = TEL_SS_RESULT_SUCCESS;
+ else {
+ err("RESPONSE NOK");
+ result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
+ }
dbg("Set Forwarding Status: [%s]",
(result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
TelSsForwardGetInfo *req_info;
gint valid_records = 0;
GSList *resp_data = NULL;
- /* TODO: CMEE error mapping is required */
TelSsResult result = TEL_SS_RESULT_FAILURE;
dbg("Enter");
dbg("Total records: [%d]", forwarding_resp.record_num);
} else {
err("RESPONSE - [NOK]");
+ result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
}
} else {
err("No response data");
const TcoreAtResponse *at_resp = data;
CoreObject *co = tcore_pending_ref_core_object(p);
ImcRespCbData *resp_cb_data = user_data;
- /* TODO: CMEE error mapping is required */
TelSsResult result = TEL_SS_RESULT_FAILURE;
dbg("Enter");
if (at_resp && at_resp->success)
result = TEL_SS_RESULT_SUCCESS;
+ else {
+ err("RESPONSE NOK");
+ result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
+ }
dbg("Set Waiting Status: [%s]",
(result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
TelSsClass *class;
gint valid_records = 0;
GSList *resp_data = NULL;
- /* TODO: CMEE error mapping is required */
TelSsResult result = TEL_SS_RESULT_FAILURE;
dbg("Enter");
resp_data = (GSList *) at_resp->lines;
waiting_resp.record_num= g_slist_length(resp_data);
dbg("Total records: [%d]", waiting_resp.record_num);
- }
- else {
+ } else {
err("RESPONSE - [NOK]");
+ result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
}
} else {
err("No response data");
if (at_resp && at_resp->success)
result = TEL_SS_RESULT_SUCCESS;
+ else {
+ err("RESPONSE - [NOK]");
+ result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
+ }
dbg("Set Cli Status: [%s]",
(result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
atoi(status), &net_status))
goto END;
- switch(*cli_type){
+ switch (*cli_type){
case TEL_SS_CLI_CLIR:
cli_resp.status.clir.net_status = net_status;
cli_resp.status.clir.dev_status = dev_status;
result = TEL_SS_RESULT_SUCCESS;
} else{
err("RESPONSE NOK");
+ result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
}
END:
/* Need to initialise ussd response string */
ussd_resp.str = (unsigned char *)g_strdup("Operation success");
} else {
+ err("RESPONSE - [NOK]");
ussd_resp.str = (unsigned char *)g_strdup("Operation failed");
- }
+ result = __imc_ss_convert_cme_error_tel_ss_result(at_resp);
+ }
dbg("Send Ussd Request: [%s]",
(result == TEL_SS_RESULT_SUCCESS ? "SUCCESS" : "FAIL"));
tcore_ss_ussd_destroy_session(ussd_s);
-
/* Invoke callback */
if (resp_cb_data->cb)
resp_cb_data->cb(co, (gint)result, &ussd_resp, resp_cb_data->cb_data);
ImcRespCbData *resp_cb_data = NULL;
TelReturn ret = TEL_RETURN_INVALID_PARAMETER;
- if (barring_pwd_info->old_pwd == NULL || barring_pwd_info->new_pwd == NULL) {
- err("Invalid data");
- return ret;
- }
+ tcore_check_return_value(barring_pwd_info != NULL, ret);
dbg("Old password: [%s], New password: [%s]", barring_pwd_info->old_pwd,
barring_pwd_info->new_pwd);
/* Close 'modem_fd' */
close(modem_fd);
return ret_val;
- } else if (open(NV_FILE_PATH, O_EXCL) > 0) {
- /* NV data file already exists */
- dbg("File exists: [%s]", NV_FILE_PATH);
-
- /* Close 'modem_fd' */
- close(modem_fd);
- return TRUE;
} else {
- dbg("File does't exsits... need to create!!!");
+ gint fd = open(NV_FILE_PATH, O_EXCL);
+ if (fd < 0) {
+ dbg("File does't exsits... need to create!!!");
+ } else {
+ /* NV data file already exists */
+ dbg("File exists: [%s]", NV_FILE_PATH);
+
+ /* Close 'fds' */
+ close(fd);
+ close(modem_fd);
+
+ return TRUE;
+ }
}
}