#include <at.h>
#include <plugin.h>
+#include <util.h>
+
#include "common/TelErr.h"
#include "s_common.h"
#include "s_sms.h"
/*=============================================================
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 */
#define AT_SW1_LEN_RESP 0x9F
#define AT_MAX_RECORD_LEN 256
-#define AT_EF_SMS_RECORD_LEN 176
+ /* SCA 12 bytes long and TDPU is 164 bytes long */
+#define PDU_LEN_MAX 176
+#define HEX_PDU_LEN_MAX ((PDU_LEN_MAX * 2) + 1)
/*=============================================================
String Preprocessor
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);
- free(bytePDU);
+ g_free(bytePDU);
return TRUE;
}
} 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);
+ g_free(byte_pdu);
} else {
dbg("Invalid Message Length");
}
memset(&resp_umts, 0x00, sizeof(resp_umts));
resp_umts.result = SMS_DEVICE_FAILURE;
- if (at_response->success > 0) { // success
+ if (at_response->success > 0) { /* SUCCESS */
dbg("Response OK");
if (at_response->lines) { // lines present in at_response
gslist_line = (char *)at_response->lines->data;
dbg("lines: [%p]", at_response->lines);
g_slist_foreach(at_response->lines, print_glib_list_elem, NULL); //for debug log
- if (at_response->success > 0) {
- dbg("Response OK");
- if (at_response->lines) {
- //fetch first line
- gslist_line = (char *)at_response->lines->data;
+ if (at_response->success <= 0) {
+ err("Response NOK");
+ return;
+ }
- dbg("gslist_line: [%s]", gslist_line);
+ dbg("Response OK");
+ if (at_response->lines == NULL) {
+ err("No lines");
+ return;
+ }
- tokens = tcore_at_tok_new(gslist_line);
- dbg("Number of tokens: [%d]", g_slist_length(tokens));
- g_slist_foreach(tokens, print_glib_list_elem, NULL); //for debug log
+ //fetch first line
+ gslist_line = (char *)at_response->lines->data;
+ if (gslist_line == NULL) {
+ err("Error response data");
+ return;
+ }
- line_token = g_slist_nth_data(tokens, 2); //Third Token: Length
- if (line_token != NULL) {
- pdu_len = atoi(line_token);
- dbg("Length: [%d]", pdu_len);
- }
+ dbg("gslist_line: [%s]", gslist_line);
- //fetch second line
- gslist_line = (char *)at_response->lines->next->data;
+ tokens = tcore_at_tok_new(gslist_line);
+ dbg("Number of tokens: [%d]", g_slist_length(tokens));
+ g_slist_foreach(tokens, print_glib_list_elem, NULL); //for debug log
- dbg("gslist_line: [%s]", gslist_line);
+ line_token = g_slist_nth_data(tokens, 2); //Third Token: Length
+ if (line_token == NULL) {
+ err("Error response data");
+ tcore_at_tok_free(tokens);
+ return;
+ }
- //free the consumed token
- tcore_at_tok_free(tokens);
+ pdu_len = atoi(line_token);
+ dbg("Length: [%d]", pdu_len);
+ tcore_at_tok_free(tokens);
- tokens = tcore_at_tok_new(gslist_line);
- dbg("Number of tokens: [%d]", g_slist_length(tokens));
- g_slist_foreach(tokens, print_glib_list_elem, NULL); //for debug log
+ //fetch second line
+ if (at_response->lines->next == NULL) {
+ err("Error response data");
+ return;
+ }
+ gslist_line = (char *)at_response->lines->next->data;
+ if (gslist_line == NULL) {
+ err("Error response data");
+ return;
+ }
- hex_pdu = g_slist_nth_data(tokens, 0); //Fetch SMS PDU
+ dbg("gslist_line: [%s]", gslist_line);
- //free the consumed token
- tcore_at_tok_free(tokens);
- } else {
- dbg("No lines");
- }
- } else {
- err("Response NOK");
- }
+ tokens = tcore_at_tok_new(gslist_line);
+ dbg("Number of tokens: [%d]", g_slist_length(tokens));
+ g_slist_foreach(tokens, print_glib_list_elem, NULL); //for debug log
+
+ hex_pdu = g_slist_nth_data(tokens, 0); //Fetch SMS PDU
/* Convert to Bytes */
bytePDU = (unsigned char *)util_hexStringToBytes(hex_pdu);
+ if (bytePDU == NULL) {
+ tcore_at_tok_free(tokens);
+ return;
+ }
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);
rtn = tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(tcore_pending_ref_core_object(pending))), tcore_pending_ref_core_object(pending), TNOTI_SMS_INCOM_MSG, sizeof(struct tnoti_sms_umts_msg), &gsmMsgInfo);
- free(bytePDU);
-
- dbg("Exit");
- return;
+ g_free(bytePDU);
+ tcore_at_tok_free(tokens);
}
static void on_response_read_msg(TcorePending *pending, int data_len, const void *data, void *user_data)
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)) {
dbg("Invalid Message Length");
resp_read_msg.result = SMS_INVALID_PARAMETER_FORMAT;
}
+ } else if (sca_length > SMS_ENCODED_SCA_LEN_MAX) {
+ dbg("Invalid Message Length");
+ resp_read_msg.result = SMS_INVALID_PARAMETER_FORMAT;
} else {
if ((resp_read_msg.dataInfo.smsData.msgLength > 0)
&& (resp_read_msg.dataInfo.smsData.msgLength <= SMS_SMDATA_SIZE_MAX)) {
resp_read_msg.result = SMS_INVALID_PARAMETER_FORMAT;
}
}
- free(byte_pdu);
+ g_free(byte_pdu);
}else {
dbg("NULL PDU");
}
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");
UserRequest *user_req = NULL;
GSList *tokens = NULL;
+ const char *sca_tok_addr;
char *gslist_line = NULL, *sca_addr = NULL, *sca_toa = NULL;
dbg("Entry");
gslist_line = (char *)at_response->lines->data;
tokens = tcore_at_tok_new(gslist_line);
- sca_addr = g_slist_nth_data(tokens, 0);
+ sca_tok_addr = g_slist_nth_data(tokens, 0);
sca_toa = g_slist_nth_data(tokens, 1);
+ sca_addr = tcore_at_tok_extract(sca_tok_addr);
if ((NULL != sca_addr)
&& (NULL != sca_toa)) {
dbg("sca_addr: [%s]. sca_toa: [%s]", sca_addr, sca_toa);
tcore_user_request_send_response(user_req, TRESP_SMS_GET_SCA, sizeof(respGetSca), &respGetSca);
- if(tokens)
- tcore_at_tok_free(tokens);
+ tcore_at_tok_free(tokens);
+ g_free(sca_addr);
dbg("Exit");
return;
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");
cb_mid_str = util_removeQuotes(pResp);
cb_tokens = tcore_at_tok_new((const char *) cb_mid_str);
+ g_free(cb_mid_str);
+
num_cb_tokens = g_slist_length(cb_tokens);
dbg("num_cb_tokens = %d", num_cb_tokens);
respGetCbConfig.cbConfig.msgIDs[0].net3gpp.selected = FALSE;
respGetCbConfig.result = SMS_SENDSMS_SUCCESS;
}
+ } else {
+ respGetCbConfig.cbConfig.msgIdRangeCount = 0;
+ respGetCbConfig.cbConfig.msgIDs[0].net3gpp.selected = FALSE;
+ 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;
}
for (i = 0; i < (int) respGetParams.paramsInfo.tpSvcCntrAddr.dialNumLen; i++)
dbg("SCAddr = %d [%02x]", i, respGetParams.paramsInfo.tpSvcCntrAddr.diallingNum[i]);
- free(recordData);
- free(hexData);
+ g_free(recordData);
+ g_free(hexData);
} else {
dbg("No response");
}
if(tokens)
tcore_at_tok_free(tokens);
-
+
dbg("Exit");
return;
}
ptr_data = (unsigned char *)recordData;
- co_sim = tcore_plugin_ref_core_object(tcore_pending_ref_plugin(p), "sim");
+ co_sim = tcore_plugin_ref_core_object(tcore_pending_ref_plugin(p), CORE_OBJECT_TYPE_SIM);
sim_type = tcore_sim_get_type(co_sim);
dbg("sim type is %d",sim_type);
}
} else {
dbg("INVALID FCP received - DEbug!");
- free(hexData);
- free(recordData);
+ g_free(hexData);
+ g_free(recordData);
tcore_at_tok_free(tokens);
return;
}
dbg("Getting FileID=[0x%x]", file_id);
} else {
dbg("INVALID FCP received - DEbug!");
- free(hexData);
- free(recordData);
+ g_free(hexData);
+ g_free(recordData);
tcore_at_tok_free(tokens);
return;
}
switch (*ptr_data) {
case 0x04:
case 0x06:
- dbg("<IPC_RX> operation state -deactivated");
+ dbg("[RX] Operation State: DEACTIVATED");
ptr_data++;
break;
case 0x05:
case 0x07:
- dbg("<IPC_RX> operation state -activated");
+ dbg("[RX] Operation State: ACTIVATED");
ptr_data++;
break;
default:
- dbg("<IPC_RX> DEBUG! LIFE CYCLE STATUS =[0x%x]",*ptr_data);
+ dbg("[RX] DEBUG! LIFE CYCLE STATUS: [0x%x]",*ptr_data);
ptr_data++;
break;
}
}
} else {
dbg("INVALID FCP received[0x%x] - DEbug!", *ptr_data);
- free(hexData);
- free(recordData);
+ g_free(hexData);
+ g_free(recordData);
tcore_at_tok_free(tokens);
return;
}
ptr_data = ptr_data + 2;
} else {
dbg("INVALID FCP received - DEbug!");
- free(hexData);
- free(recordData);
+ g_free(hexData);
+ g_free(recordData);
tcore_at_tok_free(tokens);
return;
}
}
} else {
dbg("INVALID FCP received - DEbug!");
- free(hexData);
- free(recordData);
+ g_free(hexData);
+ g_free(recordData);
tcore_at_tok_free(tokens);
return;
}
smsp_record_len = tcore_plugin_ref_property(plugin, "SMSPRECORDLEN");
memcpy(smsp_record_len, &record_len, sizeof(int));
- free(recordData);
- free(hexData);
+ g_free(recordData);
+ g_free(hexData);
} else {
/*2. SIM access fail case*/
dbg("SIM access fail");
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);
util_byte_to_hex((const char *)&msg_status, (char *)encoded_data, 1);
//Update EF-SMS with just status byte overwritten, rest 175 bytes are same as received in read information
- cmd_str = g_strdup_printf("AT+CRSM=220,28476,%d, 4, %d, \"%s\"", (req_msg_status->index+1), AT_EF_SMS_RECORD_LEN, encoded_data);
+ cmd_str = g_strdup_printf("AT+CRSM=220,28476,%d, 4, %d, \"%s\"", (req_msg_status->index+1), PDU_LEN_MAX, encoded_data);
atreq = tcore_at_request_new((const char *)cmd_str, "+CRSM", TCORE_AT_SINGLELINE);
pending = tcore_pending_new(tcore_pending_ref_core_object(pending), 0);
if (NULL == cmd_str || NULL == atreq || NULL == pending) {
//free memory we own
g_free(cmd_str);
- free(encoded_data);
+ g_free(encoded_data);
util_sms_free_memory(atreq);
util_sms_free_memory(pending);
tcore_hal_send_request(hal, pending);
g_free(cmd_str);
- free(encoded_data);
+ g_free(encoded_data);
}
}
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");
/*=============================================================
Requests
==============================================================*/
-static TReturn send_umts_msg(CoreObject *obj, UserRequest *ur)
+static TReturn send_umts_msg(CoreObject *co_sms, UserRequest *ur)
{
- gchar *cmd_str = NULL;
- TcoreHal *hal = NULL;
- TcoreATRequest *atreq = NULL;
- TcorePending *pending = NULL;
- const struct treq_sms_send_umts_msg *sendUmtsMsg = NULL;
- char buf[2*(SMS_SMSP_ADDRESS_LEN+SMS_SMDATA_SIZE_MAX)+1] = {0};
- int ScLength = 0;
- int pdu_len = 0;
+ const struct treq_sms_send_umts_msg *send_msg;
+ const unsigned char *tpdu_byte_data, *sca_byte_data;
+ int tpdu_byte_len, pdu_byte_len;
+ char buf[HEX_PDU_LEN_MAX];
+ char pdu[PDU_LEN_MAX];
+ char *cmd_str;
+ int pdu_hex_len, mms;
+ TReturn ret;
- dbg("Entry");
+ dbg("Enter");
- sendUmtsMsg = tcore_user_request_ref_data(ur, NULL);
- hal = tcore_object_get_hal(obj);
- if (NULL == sendUmtsMsg || NULL == hal) {
- err("NULL input. Unable to proceed");
- dbg("sendUmtsMsg: [%p], hal: [%p]", sendUmtsMsg, hal);
+ send_msg = tcore_user_request_ref_data(ur, NULL);
- dbg("Exit");
- return TCORE_RETURN_EINVAL;
- }
+ tpdu_byte_data = send_msg->msgDataPackage.tpduData;
+ sca_byte_data = send_msg->msgDataPackage.sca;
- if(FALSE == tcore_hal_get_power_state(hal)){
- dbg("cp not ready/n");
- return TCORE_RETURN_ENOSYS;
- }
- dbg("msgLength: [%d]", sendUmtsMsg->msgDataPackage.msgLength);
- util_hex_dump(" ", (SMS_SMDATA_SIZE_MAX+1), (void *)sendUmtsMsg->msgDataPackage.tpduData);
- util_hex_dump(" ", SMS_SMSP_ADDRESS_LEN, (void *)sendUmtsMsg->msgDataPackage.sca);
+ /* TPDU length is in byte */
+ tpdu_byte_len = send_msg->msgDataPackage.msgLength;
- ScLength = (int)sendUmtsMsg->msgDataPackage.sca[0];
+ /* Use same Radio Resource Channel */
+ mms = send_msg->more;
- dbg("ScLength: [%d]", ScLength);
+ dbg("TDPU length: [%d]", tpdu_byte_len);
+ dbg("SCA semi-octet length: [%d]", sca_byte_data[0]);
- if ((sendUmtsMsg->msgDataPackage.msgLength > 0)
- && (sendUmtsMsg->msgDataPackage.msgLength <= SMS_SMDATA_SIZE_MAX)
- && (ScLength <= SMS_SCADDRESS_LEN_MAX)) {
- if (ScLength == 0) { // ScAddress not specified
- buf[0] = '0';
- buf[1] = '0';
- pdu_len = 2;
- } else {
- dbg("Specifying SCA in TPDU is currently not supported");
+ /* Prepare PDU for hex encoding */
+ pdu_byte_len = tcore_util_pdu_encode(sca_byte_data, tpdu_byte_data,
+ tpdu_byte_len, pdu);
- buf[0] = '0';
- buf[1] = '0';
- pdu_len = 2;
- }
+ pdu_hex_len = (int) tcore_util_encode_hex((unsigned char *) pdu,
+ pdu_byte_len, buf);
- util_byte_to_hex((const char *)sendUmtsMsg->msgDataPackage.tpduData, (char *)&buf[pdu_len], sendUmtsMsg->msgDataPackage.msgLength);
+ dbg("PDU hexadecimal length: [%d]", pdu_hex_len);
- pdu_len = pdu_len + 2*sendUmtsMsg->msgDataPackage.msgLength;
+ if (mms > 0) {
+ cmd_str = g_strdup_printf("AT+CMMS=%d", mms);
- buf[pdu_len] = '\0'; //Ensure termination
-
- dbg("pdu_len: [%d]", pdu_len);
- util_hex_dump(" ", sizeof(buf), (void *)buf);
-
- //AT+CMGS=<length><CR>PDU is given<ctrl-Z/ESC>
- cmd_str = g_strdup_printf("AT+CMGS=%d%s%s\x1A", sendUmtsMsg->msgDataPackage.msgLength,"\r",buf);
- atreq = tcore_at_request_new((const char *)cmd_str, "+CMGS", TCORE_AT_SINGLELINE);
- pending = tcore_pending_new(obj, 0);
-
- if (NULL == cmd_str || NULL == atreq || NULL == pending) {
- err("Out of memory. Unable to proceed");
- dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
-
- //free memory we own
- g_free(cmd_str);
- util_sms_free_memory(atreq);
- util_sms_free_memory(pending);
-
- dbg("Exit");
- return TCORE_RETURN_ENOMEM;
+ ret = tcore_prepare_and_send_at_request(co_sms, cmd_str, NULL,
+ TCORE_AT_NO_RESULT, NULL, NULL, NULL,
+ on_confirmation_sms_message_send,
+ NULL);
+ if (ret != TCORE_RETURN_SUCCESS) {
+ err("Failed to prepare and send AT request");
+ goto error;
}
- util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
+ g_free(cmd_str);
+ }
- tcore_pending_set_request_data(pending, 0, atreq);
- tcore_pending_set_response_callback(pending, on_response_send_umts_msg, NULL);
- tcore_pending_link_user_request(pending, ur);
- tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
- tcore_hal_send_request(hal, pending);
+ cmd_str = g_strdup_printf("AT+CMGS=%d\r%s\x1A", tpdu_byte_len, buf);
- g_free(cmd_str);
+ ret = tcore_prepare_and_send_at_request(co_sms, cmd_str, "+CMGS:",
+ TCORE_AT_SINGLELINE, ur,
+ on_response_send_umts_msg, NULL,
+ on_confirmation_sms_message_send, NULL);
+ if (ret != TCORE_RETURN_SUCCESS)
+ err("Failed to prepare and send AT request");
- dbg("Exit");
- return TCORE_RETURN_SUCCESS;
- }
+error:
+ g_free(cmd_str);
- err("Invalid Data len");
dbg("Exit");
- return TCORE_RETURN_SMS_INVALID_DATA_LEN;
+
+ return ret;
}
static TReturn read_msg(CoreObject *obj, UserRequest *ur)
}
dbg("index: [%d]", readMsg->index);
- cmd_str = g_strdup_printf("AT+CMGR=%d", (readMsg->index + 1)); //IMC index is one ahead of TAPI
+ cmd_str = g_strdup_printf("AT+CMGR=%d", readMsg->index); //IMC index is one ahead of TAPI
atreq = tcore_at_request_new((const char *)cmd_str, "+CMGR", TCORE_AT_PDU);
pending = tcore_pending_new(obj, 0);
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>
return TCORE_RETURN_SUCCESS;
}
-static TReturn get_storedMsgCnt(CoreObject *obj, UserRequest *ur)
+static TReturn get_stored_msg_cnt(CoreObject *obj, UserRequest *ur)
{
gchar *cmd_str = NULL;
TcoreHal *hal = NULL;
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");
}
msg_status = tcore_user_request_ref_data(ur, NULL);
- cmd_str = g_strdup_printf("AT+CRSM=178,28476,%d,4,%d", (msg_status->index+1), AT_EF_SMS_RECORD_LEN);
+ cmd_str = g_strdup_printf("AT+CRSM=178,28476,%d,4,%d", (msg_status->index+1), PDU_LEN_MAX);
atreq = tcore_at_request_new((const char *)cmd_str, "+CRSM", TCORE_AT_SINGLELINE);
pending = tcore_pending_new(obj, 0);
if (NULL == cmd_str || NULL == atreq || NULL == pending) {
char *encoded_data = NULL;
unsigned char *temp_data = NULL;
int SMSPRecordLen = 0;
+ int *smsp_record_len;
TcoreHal *hal = NULL;
TcoreATRequest *atreq = NULL;
}
//EFsmsp file size is 28 +Y bytes (Y is alpha id size)
- SMSPRecordLen = 28 + setSmsParams->params.alphaIdLen;
+ smsp_record_len = tcore_plugin_ref_property(tcore_object_ref_plugin(obj), "SMSPRECORDLEN");
+ SMSPRecordLen = *smsp_record_len;
+ if (SMSPRecordLen < nDefaultSMSPWithoutAlphaId)
+ return FALSE;
+
temp_data = calloc(SMSPRecordLen,1);
encoded_data = calloc(SMSPRecordLen*2 + 1,1);
-
+
_tcore_util_sms_encode_smsParameters(&(setSmsParams->params), temp_data, SMSPRecordLen);
util_byte_to_hex((const char *)temp_data, (char *)encoded_data,SMSPRecordLen);
-
+
encoded_data_len = ((SMSPRecordLen) * 2);
hal = tcore_object_get_hal(obj);
.read_msg = read_msg,
.save_msg = save_msg,
.delete_msg = delete_msg,
- .get_storedMsgCnt = get_storedMsgCnt,
+ .get_stored_msg_cnt = get_stored_msg_cnt,
.get_sca = get_sca,
.set_sca = set_sca,
.get_cb_config = get_cb_config,
.get_paramcnt = get_paramcnt,
};
-gboolean s_sms_init(TcorePlugin *plugin, TcoreHal *hal)
+gboolean s_sms_init(TcorePlugin *cp, CoreObject *co_sms)
{
- CoreObject *obj = NULL;
- struct property_sms_info *data = NULL;
- GQueue *work_queue = NULL;
- int *smsp_record_len = NULL;
-
+ int *smsp_record_len;
dbg("Entry");
- dbg("plugin: [%p]", plugin);
- dbg("hal: [%p]", hal);
- obj = tcore_sms_new(plugin, "umts_sms", &sms_ops, hal);
+ /* Override SMS Operations */
+ tcore_sms_override_ops(co_sms, &sms_ops);
- data = calloc(sizeof(struct property_sms_info), 1);
+ /* Registering for SMS notifications */
+ tcore_object_override_callback(co_sms, "+CMTI:", on_event_class2_sms_incom_msg, NULL);
+ tcore_object_override_callback(co_sms, "\e+CMT:", on_event_sms_incom_msg, NULL);
- if (NULL == obj || NULL == data) {
- err("Unable to initialize. Exiting");
- s_sms_exit(plugin);
+ tcore_object_override_callback(co_sms, "\e+CDS", on_event_sms_incom_msg, NULL);
+ tcore_object_override_callback(co_sms, "+XSMSMMSTAT", on_event_sms_memory_status, NULL);
+ tcore_object_override_callback(co_sms, "+CMS", on_event_sms_memory_status, NULL);
- dbg("Exit");
- return FALSE;
- }
+ tcore_object_override_callback(co_sms, "+CBMI:", on_event_sms_cb_incom_msg, NULL);
+ tcore_object_override_callback(co_sms, "\e+CBM:", on_event_sms_cb_incom_msg, NULL);
- work_queue = g_queue_new();
- tcore_object_link_user_data(obj, work_queue);
-
- //Registering for SMS notifications
- tcore_object_add_callback(obj, "\e+CMTI", on_event_class2_sms_incom_msg, NULL);
- tcore_object_add_callback(obj, "\e+CMT", on_event_sms_incom_msg, NULL);
-
- tcore_object_add_callback(obj, "\e+CDS", on_event_sms_incom_msg, NULL);
- tcore_object_add_callback(obj, "+XSMSMMSTAT", on_event_sms_memory_status, NULL);
- tcore_object_add_callback(obj, "+CMS", on_event_sms_memory_status, NULL);
-
- tcore_object_add_callback(obj, "\e+CBMI", on_event_sms_cb_incom_msg, NULL);
- tcore_object_add_callback(obj, "\e+CBM", on_event_sms_cb_incom_msg, NULL);
- tcore_object_add_callback(obj, "+XSIM", on_event_sms_ready_status, NULL);
-
- tcore_plugin_link_property(plugin, "SMS", data);
-
- //storing smsp record length
- smsp_record_len = calloc(sizeof(int), 1);
- tcore_plugin_link_property(plugin, "SMSPRECORDLEN", smsp_record_len);
+ /* Storing SMSP record length */
+ smsp_record_len = g_new0(int, 1);
+ tcore_plugin_link_property(cp, "SMSPRECORDLEN", smsp_record_len);
dbg("Exit");
return TRUE;
}
-void s_sms_exit(TcorePlugin *plugin)
+void s_sms_exit(TcorePlugin *cp, CoreObject *co_sms)
{
- CoreObject *obj = NULL;
- struct property_sms_info *data = NULL;
+ int *smsp_record_len;
- dbg("Entry");
- dbg("plugin: [%p]", plugin);
-
- obj = tcore_plugin_ref_core_object(plugin, "umts_sms");
- if (NULL == obj) {
- err("NULL core object. Nothing to do.");
- return;
- }
- tcore_sms_free(obj);
-
- data = tcore_plugin_ref_property(plugin, "SMS");
- util_sms_free_memory(data);
+ smsp_record_len = tcore_plugin_ref_property(cp, "SMSPRECORDLEN");
+ g_free(smsp_record_len);
dbg("Exit");
- return;
}