SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Werror -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wdeclaration-after-statement -Wmissing-declarations -Wredundant-decls -Wcast-align")
ADD_DEFINITIONS("-DFEATURE_DLOG_DEBUG")
-ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"TEL_PLUGIN_IMC\"")
+ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"IMC\"")
MESSAGE(${CMAKE_C_FLAGS})
MESSAGE(${CMAKE_EXE_LINKER_FLAGS})
int data_len, const void *data, void *user_data)
{
const TcoreATResponse *resp = data;
+ gboolean ret;
dbg("Last Subscription - COMPLETED");
if (resp->success) {
dbg("Boot-up configration completed for IMC modem. %s",
"Bring CP to ONLINE state based on Flightmode status");
- modem_power_on(tcore_pending_ref_plugin(p));
+ ret = modem_power_on(tcore_pending_ref_plugin(p));
+ dbg("Modem Power ON: [%s]", (ret == TRUE ? "SUCCESS" : "FAIL"));
}
static void _modem_subscribe_events(TcorePlugin *plugin)
CoreObject *co_call = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_CALL);
CoreObject *co_sim = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SIM);
CoreObject *co_sms = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SMS);
- CoreObject *co_modem = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_MODEM);
CoreObject *co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK);
CoreObject *co_ps = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_PS);
CoreObject *co_sap = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SAP);
dbg("Entry");
- /* XCALLSTAT subscription */
+ /* URC Subscriptions per Module */
+
+ /****** SIM subscriptions ******/
+ /* XSIMSTATE */
+ tcore_prepare_and_send_at_request(co_sim, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ on_response_bootup_subscription, NULL,
+ on_confirmation_modem_message_send, NULL);
+
+ /****** CALL subscriptions ******/
+ /* XCALLSTAT */
tcore_prepare_and_send_at_request(co_call, "at+xcallstat=1", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /* XSIMSTATE subscription */
- tcore_prepare_and_send_at_request(co_sim, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ /* CSSN */
+ tcore_prepare_and_send_at_request(co_call, "at+cssn=1,1", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- tcore_prepare_and_send_at_request(co_sms, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ /* CUSD */
+ tcore_prepare_and_send_at_request(co_call, "at+cusd=1", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- tcore_prepare_and_send_at_request(co_modem, "at+xsimstate=1", NULL, TCORE_AT_NO_RESULT, NULL,
+
+ /* CLIP */
+ tcore_prepare_and_send_at_request(co_call, "at+clip=1", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /* CREG subscription */
+ /****** NETWORK subscriptions ******/
+ /* CREG */
tcore_prepare_and_send_at_request(co_network, "at+creg=2", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /* CGREG subscription */
+ /* CGREG */
tcore_prepare_and_send_at_request(co_network, "at+cgreg=2", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /* Allow automatic time Zone updation via NITZ */
+ /* Allow Automatic Time Zone updation via NITZ */
tcore_prepare_and_send_at_request(co_network, "at+ctzu=1", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /* TZ, time & daylight changing event reporting subscription */
+ /* TZ, Time & Daylight changing event reporting Subscription */
tcore_prepare_and_send_at_request(co_network, "at+ctzr=1", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /* XMER subscription */
+ /* XMER */
tcore_prepare_and_send_at_request(co_network, "at+xmer=1", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /* CGEREP subscription */
+ /****** PS subscriptions ******/
+ /* CGEREP */
tcore_prepare_and_send_at_request(co_ps, "at+cgerep=1", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /* XDATASTAT subscription */
+ /* XDATASTAT */
tcore_prepare_and_send_at_request(co_ps, "at+xdatastat=1", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /* CSSN subscription */
- tcore_prepare_and_send_at_request(co_call, "at+cssn=1,1", NULL, TCORE_AT_NO_RESULT, NULL,
- on_response_bootup_subscription, NULL,
- on_confirmation_modem_message_send, NULL);
- /* CUSD subscription */
- tcore_prepare_and_send_at_request(co_call, "at+cusd=1", NULL, TCORE_AT_NO_RESULT, NULL,
- on_response_bootup_subscription, NULL,
- on_confirmation_modem_message_send, NULL);
-
- /* XDNS subscription */
+ /* XDNS */
tcore_prepare_and_send_at_request(co_ps, "at+xdns=1,1", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /* CLIP subscription */
- tcore_prepare_and_send_at_request(co_call, "at+clip=1", NULL, TCORE_AT_NO_RESULT, NULL,
- on_response_bootup_subscription, NULL,
- on_confirmation_modem_message_send, NULL);
-
- /*CMEE subscription for ps*/
+ /* CMEE */
tcore_prepare_and_send_at_request(co_ps, "at+cmee=2", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /*CMEE subscription for sms*/
+ /****** SMS subscriptions ******/
+ /* CMEE */
tcore_prepare_and_send_at_request(co_sms, "at+cmee=2", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /*incoming sms,cb,status report subscription*/
+ /* Incoming SMS, Cell Broadcast, Status Report Subscription */
tcore_prepare_and_send_at_request(co_sms, "at+cnmi=1,2,2,1,0", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /* XBCSTAT subscription */
- tcore_prepare_and_send_at_request(co_sap, "at+xbcstat=1", NULL, TCORE_AT_NO_RESULT, NULL,
+ /* Text/PDU mode Subscription */
+ tcore_prepare_and_send_at_request(co_sms, "at+cmgf=0", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /* AGPS- assist data and reset assist data subscription */
+
+ /****** GPS subscriptions ******/
+ /* AGPS- Assist Data and Reset Assist Data Subscription */
tcore_prepare_and_send_at_request(co_gps, "at+cposr=1", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
on_response_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
- /* text/pdu mode subscription*/
- tcore_prepare_and_send_at_request(co_sms, "at+cmgf=0", NULL, TCORE_AT_NO_RESULT, NULL,
+ /****** SAP subscriptions ******/
+ /* XBCSTAT */
+ tcore_prepare_and_send_at_request(co_sap, "at+xbcstat=1", NULL, TCORE_AT_NO_RESULT, NULL,
on_response_last_bootup_subscription, NULL,
on_confirmation_modem_message_send, NULL);
return FALSE;
}
- /* Notify addition of Plug-in to Upper Layers */
- tcore_server_send_notification(tcore_plugin_ref_server(p), NULL,
- TNOTI_SERVER_ADDED_PLUGIN, 0, p);
-
/* Subscribe for the Events from CP */
_modem_subscribe_events(p);
+ dbg("Init - Successful");
return TRUE;
}
}
ur = tcore_pending_ref_user_request(p);
- tcore_user_request_send_response(ur, TRESP_MODEM_GET_IMEI, sizeof(struct tresp_modem_get_imei), &res);
+ tcore_user_request_send_response(ur, TRESP_MODEM_GET_IMEI,
+ sizeof(struct tresp_modem_get_imei), &res);
OUT:
if (tokens != NULL)
pcode = g_slist_nth_data(tokens, 3);
id = g_slist_nth_data(tokens, 4);
- dbg("version: sw=[%s], hw=[%s], rf_cal=[%s], product_code=[%s], model_id=[%s]", swver, hwver, caldate, pcode, id);
+ dbg("version: sw=[%s], hw=[%s], rf_cal=[%s], product_code=[%s], model_id=[%s]",
+ swver, hwver, caldate, pcode, id);
} else {
msg("invalid message");
goto OUT;
}
}
- vi = calloc(sizeof(TelMiscVersionInformation), 1);
+ vi = g_try_new0(TelMiscVersionInformation, 1);
if (NULL != swver)
memcpy(vi->szSwVersion, swver, strlen(swver));
if (NULL != hwver)
memset(&res, 0, sizeof(struct tresp_modem_get_version));
- if (NULL != swver)
- snprintf(res.software, (AT_VER_LEN > strlen(swver) ? strlen(swver) : AT_VER_LEN), "%s", swver);
- if (NULL != hwver)
- snprintf(res.hardware, (AT_VER_LEN > strlen(hwver) ? strlen(hwver) : AT_VER_LEN), "%s", hwver);
+ if (NULL != swver) {
+ snprintf(res.software,
+ (AT_VER_LEN > strlen(swver) ? strlen(swver) : AT_VER_LEN),
+ "%s", swver);
+ }
+
+ if (NULL != hwver) {
+ snprintf(res.hardware,
+ (AT_VER_LEN > strlen(hwver) ? strlen(hwver) : AT_VER_LEN),
+ "%s", hwver);
+ }
plugin = tcore_pending_ref_plugin(p);
vi_property = tcore_plugin_ref_property(plugin, "VERSION");
}
ur = tcore_pending_ref_user_request(p);
- tcore_user_request_send_response(ur, TRESP_MODEM_GET_VERSION, sizeof(struct tresp_modem_get_version), &res);
+ tcore_user_request_send_response(ur, TRESP_MODEM_GET_VERSION,
+ sizeof(struct tresp_modem_get_version), &res);
OUT:
if (tokens != NULL)
return;
}
-static enum tcore_hook_return on_hook_sim_status(Server *s, CoreObject *source, enum tcore_notification_command command,
- unsigned int data_len, void *data, void *user_data)
+static enum tcore_hook_return on_hook_sim_status(Server *s,
+ CoreObject *source, enum tcore_notification_command command,
+ unsigned int data_len, void *data, void *user_data)
{
- const struct tnoti_sim_status *sim = data;
+ TcorePlugin *plugin;
+ const struct tnoti_sim_status *noti_sim_status;
CoreObject *co_sat;
CoreObject *co_network;
- TcorePlugin *plugin = tcore_object_ref_plugin(source);
+ plugin = tcore_object_ref_plugin(source);
co_sat = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SAT);
- co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK);
+ if (co_sat == NULL)
+ return TCORE_HOOK_RETURN_CONTINUE;
- if (sim->sim_status == SIM_STATUS_INIT_COMPLETED) {
- dbg("SIM ready for attach");
- dbg("Enable STK and Fetching of proactive Commands");
- prepare_and_send_pending_request(co_sat, "AT+CFUN=6", NULL, TCORE_AT_NO_RESULT, on_response_enable_proactive_command);
- prepare_and_send_pending_request(co_network, "AT+COPS=0", NULL, TCORE_AT_NO_RESULT, on_response_network_registration);
+ co_network = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_NETWORK);
+ if (co_network == NULL)
+ return TCORE_HOOK_RETURN_CONTINUE;
+
+ dbg("Get SIM status");
+ noti_sim_status = data;
+ if (noti_sim_status == NULL)
+ return TCORE_HOOK_RETURN_CONTINUE;
+
+ /* If SIM is initialized, Enable STK and and attach to Network */
+ dbg("SIM Status: [%d]", noti_sim_status->sim_status);
+ if (noti_sim_status->sim_status == SIM_STATUS_INIT_COMPLETED) {
+ dbg("SIM ready for attach!!! Enable STK and attach to Network");
+
+ /* Sending AT+CFUN=6 */
+ prepare_and_send_pending_request(co_sat, "AT+CFUN=6", NULL,
+ TCORE_AT_NO_RESULT, on_response_enable_proactive_command);
+
+ /* Sending AT+COPS */
+ prepare_and_send_pending_request(co_network, "AT+COPS=0", NULL,
+ TCORE_AT_NO_RESULT, on_response_network_registration);
}
return TCORE_HOOK_RETURN_CONTINUE;
CoreObject *co_modem = NULL;
struct treq_modem_set_flightmode flight_mode_set = {0};
struct tnoti_modem_power modem_power = {0};
- TcoreHal *h = NULL;
Storage *strg = NULL;
co_modem = tcore_plugin_ref_core_object(p, CORE_OBJECT_TYPE_MODEM);
+ if (co_modem == NULL) {
+ err("Modem Core object is NULL");
+ return FALSE;
+ }
+ /* Set Modem Power State to 'ON' */
+ tcore_modem_set_powered(co_modem, TRUE);
+
+ /* Get Flight mode from VCONFKEY */
strg = tcore_server_find_storage(tcore_plugin_ref_server(p), "vconf");
flight_mode_set.enable = tcore_storage_get_bool(strg, STORAGE_KEY_FLIGHT_MODE_BOOL);
- h = tcore_object_get_hal(co_modem);
- tcore_hal_set_power_state(h, TRUE);
-
/* Set Flight mode as per AP settings */
- if (flight_mode_set.enable) { /* Radio Off */
- prepare_and_send_pending_request(co_modem, "AT+CFUN=4", NULL, TCORE_AT_NO_RESULT, on_response_set_flight_mode);
+ if (flight_mode_set.enable) { /* Radio OFF */
+ prepare_and_send_pending_request(co_modem, "AT+CFUN=4", NULL,
+ TCORE_AT_NO_RESULT, on_response_set_flight_mode);
+
+ /* Set Flight mode TRUE */
tcore_modem_set_flight_mode_state(co_modem, TRUE);
- } else { /* Radio On */
- prepare_and_send_pending_request(co_modem, "AT+CFUN=1", NULL, TCORE_AT_NO_RESULT, on_response_set_flight_mode);
+ } else { /* Radio ON */
+ prepare_and_send_pending_request(co_modem, "AT+CFUN=1", NULL,
+ TCORE_AT_NO_RESULT, on_response_set_flight_mode);
+
+ /* Set Flight mode FALSE */
tcore_modem_set_flight_mode_state(co_modem, FALSE);
}
/* Get IMEI */
- prepare_and_send_pending_request(co_modem, "AT+CGSN", NULL, TCORE_AT_NUMERIC, on_response_imei);
+ prepare_and_send_pending_request(co_modem, "AT+CGSN", NULL,
+ TCORE_AT_NUMERIC, on_response_imei);
/* Get Version Number */
- prepare_and_send_pending_request(co_modem, "AT+CGMR", NULL, TCORE_AT_SINGLELINE, on_response_version);
-
- tcore_modem_set_powered(co_modem, TRUE);
+ prepare_and_send_pending_request(co_modem, "AT+CGMR", NULL,
+ TCORE_AT_SINGLELINE, on_response_version);
+ /* Send Notification to TAPI - MODEM_POWER */
modem_power.state = MODEM_STATE_ONLINE;
- tcore_server_send_notification(tcore_plugin_ref_server(p), co_modem, TNOTI_MODEM_POWER,
- sizeof(struct tnoti_modem_power), &modem_power);
+ dbg("Sending notification - Modem Power state: [ONLINE]");
+ tcore_server_send_notification(tcore_plugin_ref_server(p),
+ co_modem, TNOTI_MODEM_POWER, sizeof(modem_power), &modem_power);
return TRUE;
}
req = tcore_at_request_new("AT+CFUN=0", NULL, TCORE_AT_NO_RESULT);
- dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+ dbg("Command: [%s], Prefix(if any): [%s], Command Length: [%d]",
+ req->cmd, req->prefix, strlen(req->cmd));
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, on_response_power_off, hal);
req = tcore_at_request_new("AT+CGSN", NULL, TCORE_AT_NUMERIC);
- dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+ dbg("Command: [%s], Prefix(if any): [%s], Command Length: [%d]",
+ req->cmd, req->prefix, strlen(req->cmd));
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, on_response_imei, hal);
tcore_pending_link_user_request(pending, ur);
tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL);
- tcore_hal_send_request(hal, pending);
-
- return TCORE_RETURN_SUCCESS;
+ return tcore_hal_send_request(hal, pending);
}
req = tcore_at_request_new("AT+CGMR", NULL, TCORE_AT_SINGLELINE);
- dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+ dbg("Command: [%s], Prefix(if any): [%s], Command Length: [%d]",
+ req->cmd, req->prefix, strlen(req->cmd));
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, on_response_version, hal);
tcore_pending_link_user_request(pending, ur);
tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL);
- tcore_hal_send_request(hal, pending);
-
- return TCORE_RETURN_SUCCESS;
+ return tcore_hal_send_request(hal, pending);
}
static TReturn set_flight_mode(CoreObject *o, UserRequest *ur)
cmd_str = g_strdup("AT+CFUN=1");
}
- req = tcore_at_request_new((const char *) cmd_str, NULL, TCORE_AT_NO_RESULT);
+ req = tcore_at_request_new((const char *)cmd_str, NULL, TCORE_AT_NO_RESULT);
+ g_free(cmd_str);
- dbg("cmd : %s, prefix(if any) :%s, cmd_len : %d", req->cmd, req->prefix, strlen(req->cmd));
+ dbg("Command: [%s], Prefix(if any): [%s], Command Length: [%d]",
+ req->cmd, req->prefix, strlen(req->cmd));
tcore_pending_set_request_data(pending, 0, req);
tcore_pending_set_response_callback(pending, on_response_set_flight_mode, hal);
tcore_pending_link_user_request(pending, ur);
tcore_pending_set_send_callback(pending, on_confirmation_modem_message_send, NULL);
- tcore_hal_send_request(hal, pending);
-
- return TCORE_RETURN_SUCCESS;
+ return tcore_hal_send_request(hal, pending);
}
sn_property = g_try_new0(TelMiscSNInformation, 1);
tcore_plugin_link_property(cp, "SN", sn_property);
- tcore_server_add_notification_hook(tcore_plugin_ref_server(cp), TNOTI_SIM_STATUS, on_hook_sim_status, co_modem);
+ tcore_server_add_notification_hook(tcore_plugin_ref_server(cp),
+ TNOTI_SIM_STATUS, on_hook_sim_status, NULL);
dbg("Exit");
-
return TRUE;
}
regist_status.roaming_status = tcore_network_get_roaming_state(o);
tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o,
- TNOTI_NETWORK_REGISTRATION_STATUS, sizeof(struct tnoti_network_registration_status), ®ist_status);
+ TNOTI_NETWORK_REGISTRATION_STATUS, sizeof(regist_status), ®ist_status);
#if 0
if (service_type == NETWORK_SERVICE_TYPE_HSDPA)
noti.status = TELEPHONY_HSDPA_ON;
sms = tcore_plugin_ref_core_object(plugin, CORE_OBJECT_TYPE_SMS);
tcore_sms_set_ready_status(sms, readyStatusInfo.status);
- tcore_server_send_notification(tcore_plugin_ref_server(plugin), sms, TNOTI_SMS_DEVICE_READY, sizeof(struct tnoti_sms_ready_status), &readyStatusInfo);
+ /* Send notification - SMS Ready */
+ tcore_server_send_notification(tcore_plugin_ref_server(plugin),
+ sms, TNOTI_SMS_DEVICE_READY,
+ sizeof(struct tnoti_sms_ready_status),
+ &readyStatusInfo);
}
break;
case SIM_STATUS_CARD_REMOVED:
case SIM_STATUS_CARD_NOT_PRESENT:
case SIM_STATUS_CARD_ERROR:
- if (sim_status == SIM_STATUS_CARD_NOT_PRESENT && tcore_sim_get_status(o) != SIM_STATUS_UNKNOWN) {
+ if (sim_status == SIM_STATUS_CARD_NOT_PRESENT
+ && tcore_sim_get_status(o) != SIM_STATUS_UNKNOWN) {
dbg("[SIM]SIM CARD REMOVED!!");
sim_status = SIM_STATUS_CARD_REMOVED;
}
break;
default:
- dbg("not handled status[%d]", sim_status);
+ dbg("Not handled SIM State: [0x02x]", sim_status);
break;
}
tcore_sim_link_userdata(co_sim, file_meta);
- tcore_object_override_callback(co_sim, "+XLOCK", on_event_facility_lock_status, NULL);
- tcore_object_override_callback(co_sim, "+XSIM", on_event_pin_status, NULL);
+ tcore_object_override_callback(co_sim, "+XLOCK",
+ on_event_facility_lock_status, NULL);
+ tcore_object_override_callback(co_sim, "+XSIM",
+ on_event_pin_status, NULL);
- tcore_server_add_notification_hook(tcore_plugin_ref_server(cp), TNOTI_MODEM_POWER, on_hook_modem_power, co_sim);
+ tcore_server_add_notification_hook(tcore_plugin_ref_server(cp),
+ TNOTI_MODEM_POWER, on_hook_modem_power, co_sim);
dbg("Exit");
/*=============================================================
Device Ready
==============================================================*/
-#define AT_SMS_DEVICE_READY 12 /* AT device ready */
#define SMS_DEVICE_READY 1 /* Telephony device ready */
#define SMS_DEVICE_NOT_READY 0 /* Telephony device not ready */
dbg("Exit");
}
-
+
static int util_sms_decode_smsParameters(unsigned char *incoming, unsigned int length, struct telephony_sms_Params *params)
{
int alpha_id_len = 0;
dbg("Dest Addr = %s", params->tpDestAddr.diallingNum);
}
} else {
- params->tpDestAddr.dialNumLen = 0;
+ params->tpDestAddr.dialNumLen = 0;
}
if ((params->paramIndicator & SMSPValidSvcAddr) == 0) {
return TRUE;
}
-
/*=============================================================
Notifications
==============================================================*/
-static gboolean on_event_sms_ready_status(CoreObject *o, const void *event_info, void *user_data)
-{
- struct tnoti_sms_ready_status readyStatusInfo = {0,};
- char *line = NULL;
- GSList *tokens = NULL;
- GSList *lines = NULL;
- char *pResp = NULL;
- //CoreObject *o = NULL;
-
- int rtn = -1 , status = 0;
-
- dbg(" Func Entrance");
-
- lines = (GSList *)event_info;
- if (1 != g_slist_length(lines)) {
- dbg("unsolicited msg but multiple line");
- goto OUT;
- }
- line = (char *) (lines->data);
-
- dbg(" Func Entrance");
-
- if (line != NULL) {
- dbg("Response OK");
- dbg("noti line is %s", line);
- tokens = tcore_at_tok_new(line);
- pResp = g_slist_nth_data(tokens, 0);
- if (pResp != NULL)
- status = atoi(pResp);
- } else {
- dbg("Response NOK");
- }
-
- if (status == AT_SMS_DEVICE_READY) {
- readyStatusInfo.status = SMS_DEVICE_READY;
- tcore_sms_set_ready_status(o, readyStatusInfo.status);
- dbg("SMS Ready status = [%s]", readyStatusInfo.status ? "TRUE" : "FALSE");
- rtn = tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_SMS_DEVICE_READY, sizeof(struct tnoti_sms_ready_status), &readyStatusInfo);
- dbg(" Return value [%d]", rtn);
- } else {
- readyStatusInfo.status = SMS_DEVICE_NOT_READY;
- }
-
-OUT:
- if(NULL!=tokens)
- tcore_at_tok_free(tokens);
- return TRUE;
-}
-
-static gboolean on_event_class2_sms_incom_msg(CoreObject *obj, const void *event_info, void *user_data)
+static gboolean on_event_class2_sms_incom_msg(CoreObject *obj,
+ const void *event_info, void *user_data)
{
//+CMTI: <mem>,<index>
-
+
GSList *tokens = NULL , *lines = NULL;
char *line = NULL, *cmd_str = NULL;
int index = 0, mem_type = 0;
dbg("index: [%d]", index);
- cmd_str = g_strdup_printf("AT+CMGR=%d", index);
+ cmd_str = g_strdup_printf("AT+CMGR=%d", index);
atreq = tcore_at_request_new((const char *)cmd_str, "+CMGR", TCORE_AT_PDU);
pending = tcore_pending_new(obj, 0);
tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
tcore_hal_send_request(hal, pending);
g_free(cmd_str);
-
+
if(tokens)
tcore_at_tok_free(tokens);
static gboolean on_event_sms_incom_msg(CoreObject *o, const void *event_info, void *user_data)
{
//+CMT: [<alpha>],<length><CR><LF><pdu> (PDU mode enabled);
-
+
int rtn = -1;
GSList *tokens = NULL;
GSList *lines = NULL;
pdu_len = atoi((char *)g_slist_nth_data(tokens, 0));
dbg("pdu_len: [%d]", pdu_len); /* 1: PDU Length */
}
-
+
line = (char *)g_slist_nth_data(lines, 1); /* Fetch Line 2 */
dbg("Line 2: [%s]", line);
bytePDU = (unsigned char *)util_hexStringToBytes(line);
sca_length = bytePDU[0];
-
+
dbg("SCA length = %d", sca_length);
-
+
gsmMsgInfo.msgInfo.msgLength = pdu_len;
- if (sca_length == 0) {
+ if (sca_length == 0) {
memcpy(gsmMsgInfo.msgInfo.tpduData, &bytePDU[1], gsmMsgInfo.msgInfo.msgLength);
} else {
memcpy(gsmMsgInfo.msgInfo.sca, &bytePDU[1], sca_length);
util_hex_dump(" ", gsmMsgInfo.msgInfo.msgLength,gsmMsgInfo.msgInfo.tpduData);
rtn = tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_SMS_INCOM_MSG, sizeof(struct tnoti_sms_umts_msg), &gsmMsgInfo);
-
+
if(tokens)
tcore_at_tok_free(tokens);
} else {
dbg("token 0 is null");
}
-
+
pdu = g_slist_nth_data(lines, 1);
if (pdu != NULL) {
cbMsgInfo.cbMsg.length = length;
if ((cbMsgInfo.cbMsg.length >0) && (SMS_CB_SIZE_MAX >= cbMsgInfo.cbMsg.length)) {
unsigned char *byte_pdu = NULL;
-
+
byte_pdu = (unsigned char *)util_hexStringToBytes(pdu);
-
+
memcpy(cbMsgInfo.cbMsg.msgData, (char*)byte_pdu, cbMsgInfo.cbMsg.length);
rtn = tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_SMS_CB_INCOM_MSG, sizeof(struct tnoti_sms_cellBroadcast_msg), &cbMsgInfo);
free(byte_pdu);
bytePDU = (unsigned char *)util_hexStringToBytes(hex_pdu);
sca_length = bytePDU[0];
-
+
dbg("SCA length = %d", sca_length);
gsmMsgInfo.msgInfo.msgLength = pdu_len;
- if (sca_length == 0) {
+ if (sca_length == 0) {
memcpy(gsmMsgInfo.msgInfo.tpduData, &bytePDU[1], gsmMsgInfo.msgInfo.msgLength);
} else {
memcpy(gsmMsgInfo.msgInfo.sca, bytePDU, sca_length);
resp_read_msg.dataInfo.smsData.msgLength = pdu_len;
dbg("msgLength: [%d]", resp_read_msg.dataInfo.smsData.msgLength);
-
+
if(0 == sca_length) {
if ((resp_read_msg.dataInfo.smsData.msgLength > 0)
&& (resp_read_msg.dataInfo.smsData.msgLength <= SMS_SMDATA_SIZE_MAX)) {
tcore_pending_link_user_request(pending_new, ur_dup);
tcore_pending_set_send_callback(pending_new, on_confirmation_sms_message_send, NULL);
tcore_hal_send_request(tcore_object_get_hal(o), pending_new);
-
+
//free the consumed token
tcore_at_tok_free(tokens);
-
+
g_free(cmd_str);
dbg("Exit");
memset(&respGetCbConfig, 0, sizeof(struct tresp_sms_get_cb_config));
respGetCbConfig.result = SMS_DEVICE_FAILURE;
-
+
ur = tcore_pending_ref_user_request(p);
if (!ur) {
dbg("no user_request");
respGetCbConfig.result = SMS_SENDSMS_SUCCESS;
}
}
-
+
for (i = 0; i < num_cb_tokens; i++) {
respGetCbConfig.cbConfig.msgIDs[i].net3gpp.selected = TRUE;
respGetCbConfig.cbConfig.msgIdRangeCount++;
mid_tok = tcore_at_tok_nth(cb_tokens, i);
first_tok = strtok(mid_tok, delim);
second_tok = strtok(NULL, delim);
-
+
if ((first_tok != NULL) && (second_tok != NULL)) { // mids in range (320-478)
dbg("inside if mid_range");
respGetCbConfig.cbConfig.msgIDs[i].net3gpp.fromMsgId = atoi(first_tok);
respGetCbConfig.cbConfig.msgIDs[0].net3gpp.selected = FALSE;
respGetCbConfig.result = SMS_SENDSMS_SUCCESS;
}
- }
+ }
} else {
dbg("line is NULL");
}
if(tokens)
tcore_at_tok_free(tokens);
-
+
return;
}
ur = tcore_pending_ref_user_request(pending);
respSetCbConfig.result = SMS_SENDSMS_SUCCESS;
-
+
if (resp->success > 0) {
dbg("RESPONSE OK");
} else {
if(tokens)
tcore_at_tok_free(tokens);
-
+
dbg("Exit");
return;
}
if(tokens)
tcore_at_tok_free(tokens);
-
+
dbg("Exit");
return;
}
const char *line = NULL;
int sw1 = 0;
int sw2 = 0;
-
+
TcoreHal *hal = NULL;
TcoreATRequest *atreq = NULL;
TcorePending *pending = NULL;
req_msg_status = tcore_user_request_ref_data(ur, NULL);
resp_msg_status.result = SMS_DEVICE_FAILURE;
-
+
hal = tcore_object_get_hal(tcore_pending_ref_core_object(pending));
dbg("msgStatus: [%x], index [%x]", req_msg_status->msgStatus, req_msg_status->index);
OUT:
if(tokens)
tcore_at_tok_free(tokens);
-
+
tcore_user_request_send_response(ur, TRESP_SMS_SET_MSG_STATUS , sizeof(struct tresp_sms_set_msg_status), &msg_status);
dbg("Exit");
buf[0] = ScLength;
dbg("ScLength = %d", ScLength);
-
+
if(ScLength == 0) {
buf[0] = 0;
} else {
util_hex_dump(" ", sizeof(buf), (void *)buf);
memset (hex_pdu, 0x00, pdu_len * 2 + 1);
-
+
util_byte_to_hex((const char *)buf, (char *)hex_pdu, pdu_len);
//AT+CMGW=<length>[,<stat>]<CR>PDU is given<ctrl-Z/ESC>
TcoreHal *hal = NULL;
TcoreATRequest *atreq = NULL;
TcorePending *pending = NULL;
-
+
dbg("Entry");
hal = tcore_object_get_hal(obj);
mids_GString = g_string_new("AT+CSCB=1");
break;
}
-
+
appendMsgId = setCbConfig->msgIDs[ctr1].net3gpp.fromMsgId;
for( ctr2 = 0; (ctr2 <= ((setCbConfig->msgIDs[ctr1].net3gpp.toMsgId) - (setCbConfig->msgIDs[ctr1].net3gpp.fromMsgId))); ctr2++ ) {
dbg( "%x", appendMsgId);
mids_GString = g_string_append(mids_GString, g_strdup_printf("%d", appendMsgId));
-
+
if (ctr2 == ((setCbConfig->msgIDs[ctr1].net3gpp.toMsgId) - (setCbConfig->msgIDs[ctr1].net3gpp.fromMsgId))) {
mids_GString = g_string_append(mids_GString, "\""); //Mids string termination
} else {
static TReturn set_delivery_report(CoreObject *obj, UserRequest *ur)
{
struct tresp_sms_set_delivery_report respSetDeliveryReport = {0,};
-
+
respSetDeliveryReport.result = SMS_SUCCESS;
dbg("Entry");
SMSPRecordLen = 28 + setSmsParams->params.alphaIdLen;
temp_data = calloc(SMSPRecordLen,1);
encoded_data = calloc(SMSPRecordLen*2 + 1,1);
-
+
_tcore_util_sms_encode_smsParameters(&(setSmsParams->params), temp_data, SMSPRecordLen);
util_byte_to_hex((const char *)temp_data, (char *)encoded_data,SMSPRecordLen);
-
+
encoded_data_len = ((SMSPRecordLen) * 2);
hal = tcore_object_get_hal(obj);
gboolean s_sms_init(TcorePlugin *cp, CoreObject *co_sms)
{
int *smsp_record_len;
-
dbg("Entry");
+ /* Override SMS Operations */
tcore_sms_override_ops(co_sms, &sms_ops);
/* Registering for SMS notifications */
tcore_object_override_callback(co_sms, "\e+CBMI", on_event_sms_cb_incom_msg, NULL);
tcore_object_override_callback(co_sms, "\e+CBM", on_event_sms_cb_incom_msg, NULL);
- tcore_object_override_callback(co_sms, "+XSIM", on_event_sms_ready_status, NULL);
- /* storing smsp record length */
+ /* Storing SMSP record length */
smsp_record_len = g_new0(int, 1);
-
tcore_plugin_link_property(cp, "SMSPRECORDLEN", smsp_record_len);
dbg("Exit");
-
return TRUE;
}