4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
\r
6 * Contact: Madhavi Akella <madhavi.a@samsung.com>
\r
8 * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * you may not use this file except in compliance with the License.
\r
10 * You may obtain a copy of the License at
\r
12 * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * Unless required by applicable law or agreed to in writing, software
\r
15 * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * See the License for the specific language governing permissions and
\r
18 * limitations under the License.
\r
30 #include <core_object.h>
\r
35 #include <user_request.h>
\r
36 #include <storage.h>
\r
41 #include "common/TelErr.h"
\r
42 #include "s_common.h"
\r
45 /*=============================================================
\r
47 ==============================================================*/
\r
48 #define MAX_GSM_SMS_TPDU_SIZE 244
\r
49 #define MAX_GSM_SMS_MSG_NUM 255
\r
50 #define MAX_GSM_SMS_SERVICE_CENTER_ADDR 12 /* Maximum number of bytes of service center address */
\r
51 #define MAX_GSM_SMS_CBMI_LIST_SIZE 100 /* Maximum number of CBMI list size for CBS 30*2=60 */
\r
52 #define MAX_GSM_SMS_PARAM_RECORD_SIZE 156 /* Maximum number of bytes SMSP Record size (Y + 28), y : 0 ~ 128 */
\r
53 #define MAX_GSM_SMS_STATUS_FILE_SIZE 2 /* Last Used TP-MR + SMS "Memory Cap. Exceeded" Noti Flag */
\r
54 #define TAPI_SIM_SMSP_ADDRESS_LEN 20
\r
56 /*=============================================================
\r
58 ==============================================================*/
\r
59 #define AT_SMS_DEVICE_READY 12 /* AT device ready */
\r
60 #define SMS_DEVICE_READY 1 /* Telephony device ready */
\r
61 #define SMS_DEVICE_NOT_READY 0 /* Telephony device not ready */
\r
63 /*=============================================================
\r
65 ==============================================================*/
\r
66 #define SMS_CBMI_SELECTED_SOME 0x02 /* Some CBMIs are selected */
\r
67 #define SMS_CBMI_SELECTED_ALL 0x01 /* All CBMIs are selected */
\r
69 /*=============================================================
\r
71 ==============================================================*/
\r
72 #define AT_REC_UNREAD 0 /* Received and Unread */
\r
73 #define AT_REC_READ 1 /* Received and Read */
\r
74 #define AT_STO_UNSENT 2 /* Unsent */
\r
75 #define AT_STO_SENT 3 /* Sent */
\r
76 #define AT_ALL 4 /* Unknown */
\r
78 /*=============================================================
\r
80 ==============================================================*/
\r
81 #define AT_MEMORY_AVAILABLE 0 /* Memory Available */
\r
82 #define AT_MEMORY_FULL 1 /* Memory Full */
\r
84 /*=============================================================
\r
85 SIM CRSM SW1 and Sw2 Error definitions */
\r
87 #define AT_SW1_SUCCESS 0x90
\r
88 #define AT_SW2_SUCCESS 0
\r
89 #define AT_SW1_LEN_RESP 0x9F
\r
91 #define AT_MAX_RECORD_LEN 256
\r
92 #define AT_EF_SMS_RECORD_LEN 176
\r
94 /*=============================================================*/
\r
97 /*=========================================================
\r
99 ==============================================================*/
\r
100 #define MAX_SEC_PIN_LEN 8
\r
101 #define MAX_SEC_PUK_LEN 8
\r
102 #define MAX_SEC_PHONE_LOCK_PW_LEN 39 /* Maximum Phone Locking Password Length */
\r
103 #define MAX_SEC_SIM_DATA_STRING 256 /* Maximum Length of the DATA or RESPONSE. Restricted SIM Access, Generic SIM Access Message */
\r
104 #define MAX_SEC_NUM_LOCK_TYPE 8 /* Maximum number of Lock Type used in Lock Information Message */
\r
105 #define MAX_SEC_IMS_AUTH_LEN 512 /* Maximum Length of IMS Authentication Message */
\r
107 /*=============================================================
\r
108 String Preprocessor
\r
109 ==============================================================*/
\r
110 #define CR '\r' /* Carriage Return */
\r
112 /*=============================================================
\r
114 ==============================================================*/
\r
115 #define SMS_SWAPBYTES16(x) (((x) & 0xffff0000) | (((x) & 0x0000ff00) >> 8) | (((x) & 0x000000ff) << 8))
\r
117 void print_glib_list_elem(gpointer data, gpointer user_data);
\r
119 static void on_response_class2_read_msg(TcorePending *pending, int data_len, const void *data, void *user_data);
\r
122 gboolean util_byte_to_hex(const char *byte_pdu, char *hex_pdu, int num_bytes);
\r
124 /* gaurav.kalra: For test */
\r
125 void print_glib_list_elem(gpointer data, gpointer user_data)
\r
127 char *item = (char *)data;
\r
128 dbg("item: [%s]", item);
\r
131 /*=============================================================
\r
133 ==============================================================*/
\r
134 static void on_confirmation_sms_message_send(TcorePending *p, gboolean result, void *user_data)
\r
136 dbg("Entered Function. Request message out from queue");
\r
138 dbg("TcorePending: [%p]", p);
\r
139 dbg("result: [%02x]", result);
\r
140 dbg("user_data: [%p]", user_data);
\r
142 if (result == TRUE) {
\r
144 } else { /* Failed */
\r
148 dbg("Exiting Function. Nothing to return");
\r
151 /*=============================================================
\r
153 ==============================================================*/
\r
154 static void util_sms_free_memory(void *sms_ptr)
\r
158 if (NULL != sms_ptr) {
\r
159 dbg("Freeing memory location: [%p]", sms_ptr);
\r
163 err("Invalid memory location. Nothing to do.");
\r
170 static int util_sms_decode_smsParameters(unsigned char *incoming, unsigned int length, struct telephony_sms_Params *params)
\r
172 int alpha_id_len = 0;
\r
176 dbg(" RecordLen = %d", length);
\r
178 if(incoming == NULL || params == NULL)
\r
181 alpha_id_len = length -SMS_SMSP_PARAMS_MAX_LEN;
\r
183 if (alpha_id_len > 0) {
\r
184 if (alpha_id_len > SMS_SMSP_ALPHA_ID_LEN_MAX) {
\r
185 alpha_id_len = SMS_SMSP_ALPHA_ID_LEN_MAX;
\r
188 for (i = 0; i < alpha_id_len; i++) {
\r
189 if (0xff == incoming[i]) {
\r
195 memcpy(params->szAlphaId, incoming, i);
\r
197 params->alphaIdLen = i;
\r
199 dbg(" Alpha id length = %d", i);
\r
201 params->alphaIdLen = 0;
\r
202 dbg(" Alpha id length is zero");
\r
205 //dongil01.park - start parse from here.
\r
206 params->paramIndicator = incoming[alpha_id_len];
\r
208 dbg(" Param Indicator = %02x", params->paramIndicator);
\r
210 //dongil01.park(2008/12/26) - DestAddr
\r
211 if ((params->paramIndicator & SMSPValidDestAddr) == 0) {
\r
212 nOffset = nDestAddrOffset;
\r
214 if (0x00 == incoming[alpha_id_len + nOffset] || 0xff == incoming[alpha_id_len + nOffset]) {
\r
215 params->tpDestAddr.dialNumLen = 0;
\r
217 dbg("DestAddr Length is 0");
\r
219 if (0 < (int) incoming[alpha_id_len + nOffset]) {
\r
220 params->tpDestAddr.dialNumLen = (int) (incoming[alpha_id_len + nOffset] - 1);
\r
222 if (params->tpDestAddr.dialNumLen > SMS_SMSP_ADDRESS_LEN)
\r
223 params->tpDestAddr.dialNumLen = SMS_SMSP_ADDRESS_LEN;
\r
225 params->tpDestAddr.dialNumLen = 0;
\r
228 params->tpDestAddr.numPlanId = incoming[alpha_id_len + (++nOffset)] & 0x0f;
\r
229 params->tpDestAddr.typeOfNum = (incoming[alpha_id_len + nOffset] & 0x70) >> 4;
\r
231 memcpy(params->tpDestAddr.diallingNum, &incoming[alpha_id_len + (++nOffset)], (params->tpDestAddr.dialNumLen));
\r
233 dbg("Dest TON is %d", params->tpDestAddr.typeOfNum);
\r
234 dbg("Dest NPI is %d", params->tpDestAddr.numPlanId);
\r
235 dbg("Dest Length = %d", params->tpDestAddr.dialNumLen);
\r
236 dbg("Dest Addr = %s", params->tpDestAddr.diallingNum);
\r
240 params->tpDestAddr.dialNumLen = 0;
\r
243 // dongil01.park(2008/12/26) - SvcAddr
\r
244 if ((params->paramIndicator & SMSPValidSvcAddr) == 0) {
\r
245 nOffset = nSCAAddrOffset;
\r
247 if (0x00 == (int) incoming[alpha_id_len + nOffset] || 0xff == (int) incoming[alpha_id_len + nOffset]) {
\r
248 params->tpSvcCntrAddr.dialNumLen = 0;
\r
250 dbg(" SCAddr Length is 0");
\r
252 if (0 < (int) incoming[alpha_id_len + nOffset]) {
\r
253 params->tpSvcCntrAddr.dialNumLen = (int) (incoming[alpha_id_len + nOffset] - 1);
\r
255 if (params->tpSvcCntrAddr.dialNumLen > SMS_SMSP_ADDRESS_LEN)
\r
256 params->tpSvcCntrAddr.dialNumLen = SMS_SMSP_ADDRESS_LEN;
\r
258 params->tpSvcCntrAddr.numPlanId = incoming[alpha_id_len + (++nOffset)] & 0x0f;
\r
259 params->tpSvcCntrAddr.typeOfNum = (incoming[alpha_id_len + nOffset] & 0x70) >> 4;
\r
261 memcpy(params->tpSvcCntrAddr.diallingNum, &incoming[alpha_id_len + (++nOffset)], (params->tpSvcCntrAddr.dialNumLen));
\r
263 dbg("SCAddr Length = %d ", params->tpSvcCntrAddr.dialNumLen);
\r
264 dbg("SCAddr TON is %d", params->tpSvcCntrAddr.typeOfNum);
\r
265 dbg("SCAddr NPI is %d", params->tpSvcCntrAddr.numPlanId);
\r
267 for (i = 0; i < (int) params->tpSvcCntrAddr.dialNumLen; i++)
\r
268 dbg("SCAddr = %d [%02x]", i, params->tpSvcCntrAddr.diallingNum[i]);
\r
270 params->tpSvcCntrAddr.dialNumLen = 0;
\r
273 } else if ((0x00 < (int) incoming[alpha_id_len + nSCAAddrOffset] && (int) incoming[alpha_id_len + nSCAAddrOffset] <= 12)
\r
274 || 0xff != (int) incoming[alpha_id_len + nSCAAddrOffset]) {
\r
275 nOffset = nSCAAddrOffset;
\r
277 if (0x00 == (int) incoming[alpha_id_len + nOffset] || 0xff == (int) incoming[alpha_id_len + nOffset]) {
\r
278 params->tpSvcCntrAddr.dialNumLen = 0;
\r
279 dbg("SCAddr Length is 0");
\r
281 if (0 < (int) incoming[alpha_id_len + nOffset]) {
\r
282 params->tpSvcCntrAddr.dialNumLen = (int) (incoming[alpha_id_len + nOffset] - 1);
\r
284 params->tpSvcCntrAddr.dialNumLen = incoming[alpha_id_len + nOffset] - 1;
\r
286 if (params->tpSvcCntrAddr.dialNumLen > SMS_SMSP_ADDRESS_LEN)
\r
287 params->tpSvcCntrAddr.dialNumLen = SMS_SMSP_ADDRESS_LEN;
\r
289 params->tpSvcCntrAddr.numPlanId = incoming[alpha_id_len + (++nOffset)] & 0x0f;
\r
290 params->tpSvcCntrAddr.typeOfNum = (incoming[alpha_id_len + nOffset] & 0x70) >> 4;
\r
292 memcpy(params->tpSvcCntrAddr.diallingNum, &incoming[alpha_id_len + (++nOffset)],
\r
293 (params->tpSvcCntrAddr.dialNumLen));
\r
295 dbg("SCAddr Length = %d ", params->tpSvcCntrAddr.dialNumLen);
\r
296 dbg("SCAddr TON is %d", params->tpSvcCntrAddr.typeOfNum);
\r
297 dbg("SCAddr NPI is %d", params->tpSvcCntrAddr.numPlanId);
\r
299 for (i = 0; i < (int) params->tpSvcCntrAddr.dialNumLen; i++)
\r
300 dbg("SCAddr = %d [%02x]", i, params->tpSvcCntrAddr.diallingNum[i]);
\r
302 params->tpSvcCntrAddr.dialNumLen = 0;
\r
307 params->tpSvcCntrAddr.dialNumLen = 0;
\r
310 if ((params->paramIndicator & SMSPValidPID) == 0 && (alpha_id_len + nPIDOffset) < MAX_GSM_SMS_PARAM_RECORD_SIZE) {
\r
311 params->tpProtocolId = incoming[alpha_id_len + nPIDOffset];
\r
313 if ((params->paramIndicator & SMSPValidDCS) == 0 && (alpha_id_len + nDCSOffset) < MAX_GSM_SMS_PARAM_RECORD_SIZE) {
\r
314 params->tpDataCodingScheme = incoming[alpha_id_len + nDCSOffset];
\r
316 if ((params->paramIndicator & SMSPValidVP) == 0 && (alpha_id_len + nVPOffset) < MAX_GSM_SMS_PARAM_RECORD_SIZE) {
\r
317 params->tpValidityPeriod = incoming[alpha_id_len + nVPOffset];
\r
320 dbg(" Alpha Id(Len) = %d", (int) params->alphaIdLen);
\r
322 for (i = 0; i < (int) params->alphaIdLen; i++) {
\r
323 dbg(" Alpha Id = [%d] [%c]", i, params->szAlphaId[i]);
\r
325 dbg(" PID = %d",params->tpProtocolId);
\r
326 dbg(" DCS = %d",params->tpDataCodingScheme);
\r
327 dbg(" VP = %d",params->tpValidityPeriod);
\r
333 /*=============================================================
\r
335 ==============================================================*/
\r
336 static gboolean on_event_sms_ready_status(CoreObject *o, const void *event_info, void *user_data)
\r
338 struct tnoti_sms_ready_status readyStatusInfo = {0,};
\r
340 GSList *tokens = NULL;
\r
341 GSList *lines = NULL;
\r
342 char *pResp = NULL;
\r
343 //CoreObject *o = NULL;
\r
345 int rtn = -1 , status = 0;
\r
347 dbg(" Func Entrance");
\r
349 lines = (GSList *)event_info;
\r
350 if (1 != g_slist_length(lines)) {
\r
351 dbg("unsolicited msg but multiple line");
\r
354 line = (char *) (lines->data);
\r
356 dbg(" Func Entrance");
\r
358 if (line != NULL) {
\r
359 dbg("Response OK");
\r
360 dbg("noti line is %s", line);
\r
361 tokens = tcore_at_tok_new(line);
\r
362 pResp = g_slist_nth_data(tokens, 0);
\r
364 status = atoi(pResp);
\r
366 dbg("Response NOK");
\r
369 if (status == AT_SMS_DEVICE_READY) {
\r
370 readyStatusInfo.status = SMS_DEVICE_READY;
\r
371 tcore_sms_set_ready_status(o, readyStatusInfo.status);
\r
372 dbg("SMS Ready status = [%s]", readyStatusInfo.status ? "TRUE" : "FALSE");
\r
373 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);
\r
374 dbg(" Return value [%d]", rtn);
\r
376 readyStatusInfo.status = SMS_DEVICE_NOT_READY;
\r
381 tcore_at_tok_free(tokens);
\r
385 static gboolean on_event_class2_sms_incom_msg(CoreObject *obj, const void *event_info, void *user_data)
\r
387 //+CMTI: <mem>,<index>
\r
389 GSList *tokens = NULL , *lines = NULL;
\r
390 char *line = NULL, *cmd_str = NULL;
\r
391 int index = 0, mem_type = 0;
\r
392 TcoreHal *hal = NULL;
\r
393 TcoreATRequest *atreq = NULL;
\r
394 TcorePending *pending = NULL;
\r
396 dbg("Entered Function");
\r
398 lines = (GSList *)event_info;
\r
399 line = (char *)g_slist_nth_data(lines, 0); /* Fetch Line 1 */
\r
401 dbg("Line 1: [%s]", line);
\r
404 err("Line 1 is invalid");
\r
408 tokens = tcore_at_tok_new(line); /* Split Line 1 into tokens */
\r
409 mem_type = atoi(g_slist_nth_data(tokens, 0)); // Type of Memory stored
\r
410 index = atoi((char *) g_slist_nth_data(tokens, 1));
\r
412 hal = tcore_object_get_hal(obj);
\r
414 err("NULL input. Unable to proceed");
\r
415 dbg("readMsg: hal: [%p]", hal);
\r
418 return TCORE_RETURN_EINVAL;
\r
421 dbg("index: [%d]", index);
\r
423 cmd_str = g_strdup_printf("AT+CMGR=%d", index);
\r
424 atreq = tcore_at_request_new((const char *)cmd_str, "+CMGR", TCORE_AT_PDU);
\r
425 pending = tcore_pending_new(obj, 0);
\r
427 if (NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
428 err("Out of memory. Unable to proceed");
\r
429 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
431 //free memory we own
\r
433 util_sms_free_memory(atreq);
\r
434 util_sms_free_memory(pending);
\r
437 return TCORE_RETURN_ENOMEM;
\r
440 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
442 tcore_pending_set_request_data(pending, 0, atreq);
\r
443 tcore_pending_set_response_callback(pending, on_response_class2_read_msg, (void *)(uintptr_t)index); //storing index as user data for response
\r
444 tcore_pending_link_user_request(pending, NULL);
\r
445 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
446 tcore_hal_send_request(hal, pending);
\r
450 tcore_at_tok_free(tokens);
\r
455 static gboolean on_event_sms_incom_msg(CoreObject *o, const void *event_info, void *user_data)
\r
457 //+CMT: [<alpha>],<length><CR><LF><pdu> (PDU mode enabled);
\r
460 GSList *tokens = NULL;
\r
461 GSList *lines = NULL;
\r
463 int pdu_len = 0, no_of_tokens = 0;
\r
464 unsigned char *bytePDU = NULL;
\r
465 struct tnoti_sms_umts_msg gsmMsgInfo;
\r
466 int sca_length = 0;
\r
468 dbg("Entered Function");
\r
470 lines = (GSList *)event_info;
\r
471 memset(&gsmMsgInfo, 0x00, sizeof(struct tnoti_sms_umts_msg));
\r
473 if (2 != g_slist_length(lines)) {
\r
474 err("Invalid number of lines for +CMT. Must be 2");
\r
478 line = (char *)g_slist_nth_data(lines, 0); /* Fetch Line 1 */
\r
480 dbg("Line 1: [%s]", line);
\r
483 err("Line 1 is invalid");
\r
487 tokens = tcore_at_tok_new(line); /* Split Line 1 into tokens */
\r
489 no_of_tokens = g_slist_length(tokens);
\r
491 if (no_of_tokens == 2) { // in case of incoming SMS +CMT
\r
492 dbg("Alpha ID: [%02x]", g_slist_nth_data(tokens, 0)); /* 0: Alpha ID */
\r
493 pdu_len = atoi((char *)g_slist_nth_data(tokens, 1));
\r
494 dbg("pdu_len: [%d]", pdu_len); /* 1: PDU Length */
\r
495 } else if (no_of_tokens == 1) { // in case of incoming status report +CDS
\r
496 pdu_len = atoi((char *)g_slist_nth_data(tokens, 0));
\r
497 dbg("pdu_len: [%d]", pdu_len); /* 1: PDU Length */
\r
500 line = (char *)g_slist_nth_data(lines, 1); /* Fetch Line 2 */
\r
502 dbg("Line 2: [%s]", line);
\r
505 err("Line 2 is invalid");
\r
509 /* Convert to Bytes */
\r
510 bytePDU = (unsigned char *)util_hexStringToBytes(line);
\r
512 sca_length = bytePDU[0];
\r
514 dbg("SCA length = %d", sca_length);
\r
516 gsmMsgInfo.msgInfo.msgLength = pdu_len-(sca_length+1);
\r
518 if (sca_length == 0) {
\r
519 memcpy(gsmMsgInfo.msgInfo.tpduData, &bytePDU[1], gsmMsgInfo.msgInfo.msgLength);
\r
522 memcpy(gsmMsgInfo.msgInfo.sca, &bytePDU[1], sca_length);
\r
523 memcpy(gsmMsgInfo.msgInfo.tpduData, &bytePDU[sca_length+1], gsmMsgInfo.msgInfo.msgLength);
\r
526 util_hex_dump(" ", strlen(line)/2, bytePDU);
\r
527 util_hex_dump(" ", sca_length, gsmMsgInfo.msgInfo.sca);
\r
528 util_hex_dump(" ", gsmMsgInfo.msgInfo.msgLength,gsmMsgInfo.msgInfo.tpduData);
\r
530 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);
\r
533 tcore_at_tok_free(tokens);
\r
542 static gboolean on_event_sms_memory_status(CoreObject *o, const void *event_info, void *user_data)
\r
544 struct tnoti_sms_memory_status memStatusInfo = {0,};
\r
546 int rtn = -1 ,memoryStatus = -1;
\r
547 GSList *tokens=NULL;
\r
548 GSList *lines=NULL;
\r
549 char *line = NULL , *pResp = NULL;
\r
553 lines = (GSList *)event_info;
\r
554 if (1 != g_slist_length(lines)) {
\r
555 dbg("unsolicited msg but multiple line");
\r
558 line = (char*)(lines->data);
\r
561 dbg("Response OK");
\r
562 tokens = tcore_at_tok_new(line);
\r
563 pResp = g_slist_nth_data(tokens, 0);
\r
566 memoryStatus = atoi(pResp);
\r
567 dbg("memoryStatus is %d",memoryStatus);
\r
568 if (memoryStatus == 0) {//SIM Full condition
\r
569 memStatusInfo.status = SMS_PHONE_MEMORY_STATUS_FULL;
\r
571 rtn = tcore_server_send_notification(tcore_plugin_ref_server(tcore_object_ref_plugin(o)), o, TNOTI_SMS_MEMORY_STATUS, sizeof(struct tnoti_sms_memory_status), &memStatusInfo);
\r
573 tcore_at_tok_free(tokens);
\r
575 dbg("Response NOK");
\r
582 static gboolean on_event_sms_cb_incom_msg(CoreObject *o, const void *event_info, void *user_data)
\r
584 //+CBM: <length><CR><LF><pdu>
\r
586 struct tnoti_sms_cellBroadcast_msg cbMsgInfo;
\r
588 int rtn = -1 , length = 0;
\r
589 char * line = NULL, *pdu = NULL, *pResp = NULL;
\r
590 GSList *tokens = NULL;
\r
591 GSList *lines = NULL;
\r
593 dbg(" Func Entrance");
\r
595 lines = (GSList *)event_info;
\r
597 memset(&cbMsgInfo, 0, sizeof(struct tnoti_sms_cellBroadcast_msg));
\r
599 line = (char *)(lines->data);
\r
601 if (line != NULL) {
\r
602 dbg("Response OK");
\r
603 dbg("Noti line is %s",line);
\r
604 tokens = tcore_at_tok_new(line); /* Split Line 1 into tokens */
\r
606 pResp = g_slist_nth_data(tokens, 0);
\r
608 length = atoi(pResp);
\r
610 dbg("token 0 is null");
\r
613 pdu = g_slist_nth_data(lines, 1);
\r
615 cbMsgInfo.cbMsg.length = length;
\r
616 cbMsgInfo.cbMsg.cbMsgType = SMS_CB_MSG_CBS;
\r
618 dbg("CB Msg LENGTH [%2x]", length);
\r
620 if ((cbMsgInfo.cbMsg.length >0) && (SMS_CB_SIZE_MAX >= cbMsgInfo.cbMsg.length)) {
\r
621 unsigned char *byte_pdu = NULL;
\r
623 byte_pdu = (unsigned char *)util_hexStringToBytes(pdu);
\r
625 memcpy(cbMsgInfo.cbMsg.msgData, (char*)byte_pdu, cbMsgInfo.cbMsg.length);
\r
626 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);
\r
629 dbg("Invalid Message Length");
\r
632 dbg("Recieved NULL pdu");
\r
635 dbg("Response NOK");
\r
638 dbg(" Return value [%d]",rtn);
\r
641 tcore_at_tok_free(tokens);
\r
647 /*=============================================================
\r
649 ==============================================================*/
\r
650 static void on_response_sms_delete_msg(TcorePending *p, int data_len, const void *data, void *user_data)
\r
652 struct tresp_sms_delete_msg delMsgInfo = {0,};
\r
653 UserRequest *ur = NULL;
\r
654 const TcoreATResponse *atResp = data;
\r
657 int *index = (int *)user_data;
\r
659 dbg(" Func Entrance");
\r
661 ur = tcore_pending_ref_user_request(p);
\r
662 if (atResp->success) {
\r
663 dbg("Response OK");
\r
664 delMsgInfo.index = *index;
\r
665 delMsgInfo.result = SMS_SENDSMS_SUCCESS;
\r
667 dbg("Response NOK");
\r
668 delMsgInfo.index = *index;
\r
669 delMsgInfo.result = SMS_DEVICE_FAILURE;
\r
672 rtn = tcore_user_request_send_response(ur, TRESP_SMS_DELETE_MSG, sizeof(struct tresp_sms_delete_msg), &delMsgInfo);
\r
677 static void on_response_sms_save_msg(TcorePending *p, int data_len, const void *data, void *user_data)
\r
679 struct tresp_sms_save_msg saveMsgInfo = {0,};
\r
680 UserRequest *ur = NULL;
\r
681 const TcoreATResponse *atResp = data;
\r
682 GSList *tokens = NULL;
\r
684 char *pResp = NULL;
\r
687 ur = tcore_pending_ref_user_request(p);
\r
688 if (atResp->success) {
\r
689 dbg("Response OK");
\r
690 if (atResp->lines) {
\r
691 line = (char *)atResp->lines->data;
\r
692 tokens = tcore_at_tok_new(line);
\r
693 pResp = g_slist_nth_data(tokens, 0);
\r
695 dbg("0: %s", pResp);
\r
696 saveMsgInfo.index = (atoi(pResp) - 1); /* IMC index starts from 1 */
\r
697 saveMsgInfo.result = SMS_SENDSMS_SUCCESS;
\r
700 saveMsgInfo.index = -1;
\r
701 saveMsgInfo.result = SMS_DEVICE_FAILURE;
\r
703 tcore_at_tok_free(tokens);
\r
706 dbg("Response NOK");
\r
707 saveMsgInfo.index = -1;
\r
708 saveMsgInfo.result = SMS_DEVICE_FAILURE;
\r
711 rtn = tcore_user_request_send_response(ur, TRESP_SMS_SAVE_MSG, sizeof(struct tresp_sms_save_msg), &saveMsgInfo);
\r
712 dbg("Return value [%d]", rtn);
\r
716 static void on_response_send_umts_msg(TcorePending *pending, int data_len, const void *data, void *user_data)
\r
718 const TcoreATResponse *at_response = data;
\r
719 struct tresp_sms_send_umts_msg resp_umts;
\r
720 UserRequest *user_req = NULL;
\r
723 GSList *tokens = NULL;
\r
724 char *gslist_line = NULL, *line_token = NULL;
\r
728 user_req = tcore_pending_ref_user_request(pending);
\r
730 if (NULL == user_req) {
\r
731 err("No user request");
\r
737 memset(&resp_umts, 0x00, sizeof(resp_umts));
\r
738 resp_umts.result = SMS_DEVICE_FAILURE;
\r
740 if (at_response->success > 0) { // success
\r
741 dbg("Response OK");
\r
742 if (at_response->lines) { // lines present in at_response
\r
743 gslist_line = (char *)at_response->lines->data;
\r
744 dbg("gslist_line: [%s]", gslist_line);
\r
746 tokens = tcore_at_tok_new(gslist_line); //extract tokens
\r
748 line_token = g_slist_nth_data(tokens, 0);
\r
749 if (line_token != NULL) {
\r
750 msg_ref = atoi(line_token);
\r
751 dbg("Message Reference: [%d]", msg_ref);
\r
753 resp_umts.result = SMS_SENDSMS_SUCCESS;
\r
755 dbg("No Message Reference received");
\r
757 tcore_at_tok_free(tokens);
\r
758 } else { // no lines in at_response
\r
761 } else { // failure
\r
762 dbg("Response NOK");
\r
765 tcore_user_request_send_response(user_req, TRESP_SMS_SEND_UMTS_MSG, sizeof(resp_umts), &resp_umts);
\r
771 static void on_response_class2_read_msg(TcorePending *pending, int data_len, const void *data, void *user_data)
\r
773 const TcoreATResponse *at_response = data;
\r
774 GSList *tokens=NULL;
\r
775 char *gslist_line = NULL, *line_token = NULL, *hex_pdu = NULL;
\r
776 int pdu_len = 0, rtn = 0;
\r
777 unsigned char *bytePDU = NULL;
\r
778 struct tnoti_sms_umts_msg gsmMsgInfo;
\r
782 dbg("lines: [%p]", at_response->lines);
\r
783 g_slist_foreach(at_response->lines, print_glib_list_elem, NULL); //for debug log
\r
785 if (at_response->success > 0) {
\r
786 dbg("Response OK");
\r
787 if (at_response->lines) {
\r
789 gslist_line = (char *)at_response->lines->data;
\r
791 dbg("gslist_line: [%s]", gslist_line);
\r
793 tokens = tcore_at_tok_new(gslist_line);
\r
794 dbg("Number of tokens: [%d]", g_slist_length(tokens));
\r
795 g_slist_foreach(tokens, print_glib_list_elem, NULL); //for debug log
\r
797 line_token = g_slist_nth_data(tokens, 2); //Third Token: Length
\r
798 if (line_token != NULL) {
\r
799 pdu_len = atoi(line_token);
\r
800 dbg("Length: [%d]", pdu_len);
\r
803 //fetch second line
\r
804 gslist_line = (char *)at_response->lines->next->data;
\r
806 dbg("gslist_line: [%s]", gslist_line);
\r
808 //free the consumed token
\r
809 tcore_at_tok_free(tokens);
\r
811 tokens = tcore_at_tok_new(gslist_line);
\r
812 dbg("Number of tokens: [%d]", g_slist_length(tokens));
\r
813 g_slist_foreach(tokens, print_glib_list_elem, NULL); //for debug log
\r
815 hex_pdu = g_slist_nth_data(tokens, 0); //Fetch SMS PDU
\r
817 //free the consumed token
\r
818 tcore_at_tok_free(tokens);
\r
823 err("Response NOK");
\r
826 /* Convert to Bytes */
\r
827 bytePDU = (unsigned char *)util_hexStringToBytes(hex_pdu);
\r
829 sca_length = bytePDU[0];
\r
831 dbg("SCA length = %d", sca_length);
\r
833 gsmMsgInfo.msgInfo.msgLength = pdu_len-(sca_length+1);
\r
835 if (sca_length == 0) {
\r
836 memcpy(gsmMsgInfo.msgInfo.tpduData, &bytePDU[1], gsmMsgInfo.msgInfo.msgLength);
\r
839 memcpy(gsmMsgInfo.msgInfo.sca, bytePDU, sca_length);
\r
840 memcpy(gsmMsgInfo.msgInfo.tpduData, &bytePDU[sca_length+1], gsmMsgInfo.msgInfo.msgLength);
\r
843 util_hex_dump(" ", strlen(hex_pdu)/2, bytePDU);
\r
844 util_hex_dump(" ", sca_length, gsmMsgInfo.msgInfo.sca);
\r
845 util_hex_dump(" ", gsmMsgInfo.msgInfo.msgLength,gsmMsgInfo.msgInfo.tpduData);
\r
847 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);
\r
855 static void on_response_read_msg(TcorePending *pending, int data_len, const void *data, void *user_data)
\r
857 const TcoreATResponse *at_response = data;
\r
858 struct tresp_sms_read_msg resp_read_msg;
\r
859 UserRequest *user_req = NULL;
\r
861 GSList *tokens=NULL;
\r
862 char *gslist_line = NULL, *line_token = NULL, *byte_pdu = NULL, *hex_pdu = NULL;
\r
863 int sca_length = 0;
\r
864 int msg_status = 0, alpha_id = 0, pdu_len = 0;
\r
865 int index = (int)(uintptr_t)user_data;
\r
868 dbg("index: [%d]", index);
\r
869 dbg("lines: [%p]", at_response->lines);
\r
870 g_slist_foreach(at_response->lines, print_glib_list_elem, NULL); //for debug log
\r
872 user_req = tcore_pending_ref_user_request(pending);
\r
873 if (NULL == user_req) {
\r
874 err("No user request");
\r
880 memset(&resp_read_msg, 0x00, sizeof(resp_read_msg));
\r
881 resp_read_msg.result = SMS_PHONE_FAILURE;
\r
883 if (at_response->success > 0) {
\r
884 dbg("Response OK");
\r
885 if (at_response->lines) {
\r
887 gslist_line = (char *)at_response->lines->data;
\r
889 dbg("gslist_line: [%s]", gslist_line);
\r
891 tokens = tcore_at_tok_new(gslist_line);
\r
892 dbg("Number of tokens: [%d]", g_slist_length(tokens));
\r
893 g_slist_foreach(tokens, print_glib_list_elem, NULL); //for debug log
\r
895 line_token = g_slist_nth_data(tokens, 0); //First Token: Message Status
\r
896 if (line_token != NULL) {
\r
897 msg_status = atoi(line_token);
\r
898 dbg("msg_status is %d",msg_status);
\r
899 switch (msg_status) {
\r
900 case AT_REC_UNREAD:
\r
901 resp_read_msg.dataInfo.msgStatus = SMS_STATUS_UNREAD;
\r
905 resp_read_msg.dataInfo.msgStatus = SMS_STATUS_READ;
\r
908 case AT_STO_UNSENT:
\r
909 resp_read_msg.dataInfo.msgStatus = SMS_STATUS_UNSENT;
\r
913 resp_read_msg.dataInfo.msgStatus = SMS_STATUS_SENT;
\r
916 case AT_ALL: //Fall Through
\r
917 default: //Fall Through
\r
918 resp_read_msg.dataInfo.msgStatus = SMS_STATUS_RESERVED;
\r
923 line_token = g_slist_nth_data(tokens, 1); //Second Token: AlphaID
\r
924 if (line_token != NULL) {
\r
925 alpha_id = atoi(line_token);
\r
926 dbg("AlphaID: [%d]", alpha_id);
\r
929 line_token = g_slist_nth_data(tokens, 2); //Third Token: Length
\r
930 if (line_token != NULL) {
\r
931 pdu_len = atoi(line_token);
\r
932 dbg("Length: [%d]", pdu_len);
\r
935 //fetch second line
\r
936 gslist_line = (char *)at_response->lines->next->data;
\r
938 dbg("gslist_line: [%s]", gslist_line);
\r
940 //free the consumed token
\r
941 tcore_at_tok_free(tokens);
\r
943 tokens = tcore_at_tok_new(gslist_line);
\r
945 dbg("Number of tokens: [%d]", g_slist_length(tokens));
\r
946 g_slist_foreach(tokens, print_glib_list_elem, NULL); //for debug log
\r
948 hex_pdu = g_slist_nth_data(tokens, 0); //Fetch SMS PDU
\r
950 //free the consumed token
\r
951 tcore_at_tok_free(tokens);
\r
953 if (NULL != hex_pdu) {
\r
954 util_hex_dump(" ", sizeof(hex_pdu), (void *)hex_pdu);
\r
956 byte_pdu = util_hexStringToBytes(hex_pdu);
\r
958 sca_length = (int)byte_pdu[0];
\r
960 resp_read_msg.dataInfo.simIndex = index; //Retrieving index stored as user_data
\r
962 dbg("SCA Length : %d", sca_length);
\r
964 resp_read_msg.dataInfo.smsData.msgLength = (pdu_len - (sca_length+1));
\r
965 dbg("msgLength: [%d]", resp_read_msg.dataInfo.smsData.msgLength);
\r
967 if(0 == sca_length) {
\r
968 if ((resp_read_msg.dataInfo.smsData.msgLength > 0)
\r
969 && (resp_read_msg.dataInfo.smsData.msgLength <= SMS_SMDATA_SIZE_MAX)) {
\r
970 memset(resp_read_msg.dataInfo.smsData.sca, 0, TAPI_SIM_SMSP_ADDRESS_LEN);
\r
971 memcpy(resp_read_msg.dataInfo.smsData.tpduData, &byte_pdu[1], resp_read_msg.dataInfo.smsData.msgLength);
\r
973 resp_read_msg.result = SMS_SUCCESS;
\r
975 dbg("Invalid Message Length");
\r
976 resp_read_msg.result = SMS_INVALID_PARAMETER_FORMAT;
\r
979 if ((resp_read_msg.dataInfo.smsData.msgLength > 0)
\r
980 && (resp_read_msg.dataInfo.smsData.msgLength <= SMS_SMDATA_SIZE_MAX)) {
\r
981 memcpy(resp_read_msg.dataInfo.smsData.sca, (char *)byte_pdu, (sca_length+1));
\r
982 memcpy(resp_read_msg.dataInfo.smsData.tpduData, &byte_pdu[sca_length+1], resp_read_msg.dataInfo.smsData.msgLength);
\r
984 util_hex_dump(" ", SMS_SMSP_ADDRESS_LEN, (void *)resp_read_msg.dataInfo.smsData.sca);
\r
985 util_hex_dump(" ", (SMS_SMDATA_SIZE_MAX + 1), (void *)resp_read_msg.dataInfo.smsData.tpduData);
\r
986 util_hex_dump(" ", sizeof(byte_pdu), (void *)byte_pdu);
\r
988 resp_read_msg.result = SMS_SUCCESS;
\r
990 dbg("Invalid Message Length");
\r
991 resp_read_msg.result = SMS_INVALID_PARAMETER_FORMAT;
\r
1002 err("Response NOK");
\r
1005 tcore_user_request_send_response(user_req, TRESP_SMS_READ_MSG, sizeof(resp_read_msg), &resp_read_msg);
\r
1011 static void on_response_get_msg_indices(TcorePending *pending, int data_len, const void *data, void *user_data)
\r
1013 const TcoreATResponse *at_response = data;
\r
1014 struct tresp_sms_get_storedMsgCnt resp_stored_msg_cnt;
\r
1015 UserRequest *user_req = NULL;
\r
1016 struct tresp_sms_get_storedMsgCnt *resp_stored_msg_cnt_prev = NULL;
\r
1018 GSList *tokens = NULL;
\r
1019 char *gslist_line = NULL, *line_token = NULL;
\r
1020 int gslist_line_count = 0, ctr_loop = 0;
\r
1024 resp_stored_msg_cnt_prev = (struct tresp_sms_get_storedMsgCnt *)user_data;
\r
1025 user_req = tcore_pending_ref_user_request(pending);
\r
1027 memset(&resp_stored_msg_cnt, 0x00, sizeof(resp_stored_msg_cnt));
\r
1028 resp_stored_msg_cnt.result = SMS_DEVICE_FAILURE;
\r
1030 if (at_response->success) {
\r
1031 dbg("Response OK");
\r
1032 if (at_response->lines) {
\r
1033 gslist_line_count = g_slist_length(at_response->lines);
\r
1035 if (gslist_line_count > SMS_GSM_SMS_MSG_NUM_MAX)
\r
1036 gslist_line_count = SMS_GSM_SMS_MSG_NUM_MAX;
\r
1038 dbg("Number of lines: [%d]", gslist_line_count);
\r
1039 g_slist_foreach(at_response->lines, print_glib_list_elem, NULL); //for debug log
\r
1041 for (ctr_loop = 0; ctr_loop < gslist_line_count; ctr_loop++) {
\r
1042 gslist_line = (char *)g_slist_nth_data(at_response->lines, ctr_loop); /* Fetch Line i */
\r
1044 dbg("gslist_line [%d] is [%s]", ctr_loop, gslist_line);
\r
1046 if (NULL != gslist_line)
\r
1048 tokens = tcore_at_tok_new(gslist_line);
\r
1050 g_slist_foreach(tokens, print_glib_list_elem, NULL); //for debug log
\r
1052 line_token = g_slist_nth_data(tokens, 0);
\r
1053 if (NULL != line_token) {
\r
1054 resp_stored_msg_cnt.storedMsgCnt.indexList[ctr_loop] = atoi(line_token);
\r
1055 resp_stored_msg_cnt.result = SMS_SENDSMS_SUCCESS;
\r
1057 dbg("line_token of gslist_line [%d] is NULL", ctr_loop);
\r
1060 tcore_at_tok_free(tokens);
\r
1062 dbg("gslist_line [%d] is NULL", ctr_loop);
\r
1068 if (resp_stored_msg_cnt_prev->storedMsgCnt.usedCount == 0) { // Check if used count is zero
\r
1069 resp_stored_msg_cnt.result = SMS_SENDSMS_SUCCESS;
\r
1073 dbg("Respnose NOK");
\r
1076 resp_stored_msg_cnt.storedMsgCnt.totalCount = resp_stored_msg_cnt_prev->storedMsgCnt.totalCount;
\r
1077 resp_stored_msg_cnt.storedMsgCnt.usedCount = resp_stored_msg_cnt_prev->storedMsgCnt.usedCount;
\r
1079 util_sms_free_memory(resp_stored_msg_cnt_prev);
\r
1081 dbg("total: [%d], used: [%d], result: [%d]", resp_stored_msg_cnt.storedMsgCnt.totalCount, resp_stored_msg_cnt.storedMsgCnt.usedCount, resp_stored_msg_cnt.result);
\r
1082 for (ctr_loop = 0; ctr_loop < gslist_line_count; ctr_loop++) {
\r
1083 dbg("index: [%d]", resp_stored_msg_cnt.storedMsgCnt.indexList[ctr_loop]);
\r
1086 tcore_user_request_send_response(user_req, TRESP_SMS_GET_STORED_MSG_COUNT, sizeof(resp_stored_msg_cnt), &resp_stored_msg_cnt);
\r
1092 static void on_response_get_stored_msg_cnt(TcorePending *pending, int data_len, const void *data, void *user_data)
\r
1094 UserRequest *ur = NULL, *ur_dup = NULL;
\r
1095 struct tresp_sms_get_storedMsgCnt *respStoredMsgCnt = NULL;
\r
1096 const TcoreATResponse *atResp = data;
\r
1097 GSList *tokens=NULL;
\r
1098 char *line = NULL , *pResp = NULL , *cmd_str = NULL;
\r
1099 TcoreATRequest *atReq = NULL;
\r
1100 int usedCnt = 0, totalCnt = 0, result = 0;
\r
1102 TcorePending *pending_new = NULL;
\r
1103 CoreObject *o = NULL;
\r
1107 respStoredMsgCnt = malloc(sizeof(struct tresp_sms_get_storedMsgCnt));
\r
1109 ur = tcore_pending_ref_user_request(pending);
\r
1110 ur_dup = tcore_user_request_ref(ur);
\r
1111 o = tcore_pending_ref_core_object(pending);
\r
1113 if (atResp->success > 0) {
\r
1114 dbg("Response OK");
\r
1115 if (NULL != atResp->lines) {
\r
1116 line = (char *)atResp->lines->data;
\r
1117 dbg("line is %s",line);
\r
1119 tokens = tcore_at_tok_new(line);
\r
1120 pResp = g_slist_nth_data(tokens, 0);
\r
1123 usedCnt =atoi(pResp);
\r
1124 dbg("used cnt is %d",usedCnt);
\r
1127 pResp = g_slist_nth_data(tokens, 1);
\r
1129 totalCnt =atoi(pResp);
\r
1130 result = SMS_SENDSMS_SUCCESS;
\r
1132 respStoredMsgCnt->storedMsgCnt.usedCount = usedCnt;
\r
1133 respStoredMsgCnt->storedMsgCnt.totalCount = totalCnt;
\r
1134 respStoredMsgCnt->result = result;
\r
1136 dbg("used %d, total %d, result %d",usedCnt, totalCnt,result);
\r
1138 pending_new = tcore_pending_new(o, 0);
\r
1139 //Get all messages information
\r
1140 cmd_str = g_strdup_printf("AT+CMGL=4");
\r
1141 atReq = tcore_at_request_new((const char *)cmd_str, "+CMGL", TCORE_AT_MULTILINE);
\r
1143 dbg("cmd str is %s",cmd_str);
\r
1145 tcore_pending_set_request_data(pending_new, 0,atReq);
\r
1146 tcore_pending_set_response_callback(pending_new, on_response_get_msg_indices, (void *)respStoredMsgCnt);
\r
1147 tcore_pending_link_user_request(pending_new, ur_dup);
\r
1148 tcore_pending_set_send_callback(pending_new, on_confirmation_sms_message_send, NULL);
\r
1149 tcore_hal_send_request(tcore_object_get_hal(o), pending_new);
\r
1151 //free the consumed token
\r
1152 tcore_at_tok_free(tokens);
\r
1160 //free the consumed token
\r
1161 tcore_at_tok_free(tokens);
\r
1164 result = SMS_DEVICE_FAILURE;
\r
1168 err("Response NOK");
\r
1174 static void on_response_get_sca(TcorePending *pending, int data_len, const void *data, void *user_data)
\r
1176 const TcoreATResponse *at_response = data;
\r
1177 struct tresp_sms_get_sca respGetSca;
\r
1178 UserRequest *user_req = NULL;
\r
1180 GSList *tokens = NULL;
\r
1181 char *gslist_line = NULL, *sca_addr = NULL, *sca_toa = NULL;
\r
1185 memset(&respGetSca, 0, sizeof(respGetSca));
\r
1186 respGetSca.result = SMS_DEVICE_FAILURE;
\r
1188 user_req = tcore_pending_ref_user_request(pending);
\r
1190 if (at_response->success) {
\r
1191 dbg("Response OK");
\r
1192 if (at_response->lines) {
\r
1193 gslist_line = (char *)at_response->lines->data;
\r
1195 tokens = tcore_at_tok_new(gslist_line);
\r
1196 sca_addr = g_slist_nth_data(tokens, 0);
\r
1197 sca_toa = g_slist_nth_data(tokens, 1);
\r
1199 if ((NULL != sca_addr)
\r
1200 && (NULL != sca_toa)) {
\r
1201 dbg("sca_addr: [%s]. sca_toa: [%s]", sca_addr, sca_toa);
\r
1203 respGetSca.scaAddress.dialNumLen = strlen(sca_addr);
\r
1205 if (145 == atoi(sca_toa)) {
\r
1206 respGetSca.scaAddress.typeOfNum = SIM_TON_INTERNATIONAL;
\r
1208 respGetSca.scaAddress.typeOfNum = SIM_TON_NATIONAL;
\r
1211 respGetSca.scaAddress.numPlanId = 0;
\r
1213 memcpy(respGetSca.scaAddress.diallingNum, sca_addr, strlen(sca_addr));
\r
1215 dbg("len [%d], sca_addr [%s], TON [%d], NPI [%d]", respGetSca.scaAddress.dialNumLen, respGetSca.scaAddress.diallingNum, respGetSca.scaAddress.typeOfNum, respGetSca.scaAddress.numPlanId);
\r
1217 respGetSca.result = SMS_SENDSMS_SUCCESS;
\r
1219 err("sca_addr OR sca_toa NULL");
\r
1225 dbg("Response NOK");
\r
1228 tcore_user_request_send_response(user_req, TRESP_SMS_GET_SCA, sizeof(respGetSca), &respGetSca);
\r
1231 tcore_at_tok_free(tokens);
\r
1237 static void on_response_set_sca(TcorePending *pending, int data_len, const void *data, void *user_data)
\r
1240 Response is expected in this format
\r
1246 //CoreObject *obj = user_data;
\r
1248 //copies the AT response data to resp
\r
1249 const TcoreATResponse *atResp = data;
\r
1250 struct tresp_sms_set_sca respSetSca;
\r
1252 memset(&respSetSca, 0, sizeof(struct tresp_sms_set_sca));
\r
1254 ur = tcore_pending_ref_user_request(pending);
\r
1256 dbg("no user_request");
\r
1260 if (atResp->success > 0) {
\r
1261 dbg("RESPONSE OK");
\r
1262 respSetSca.result = SMS_SUCCESS;
\r
1264 dbg("RESPONSE NOK");
\r
1265 respSetSca.result = SMS_DEVICE_FAILURE;
\r
1268 tcore_user_request_send_response(ur, TRESP_SMS_SET_SCA, sizeof(struct tresp_sms_set_sca), &respSetSca);
\r
1273 static void on_response_get_cb_config(TcorePending *p, int data_len, const void *data, void *user_data)
\r
1276 struct tresp_sms_get_cb_config respGetCbConfig;
\r
1277 const TcoreATResponse *atResp = data;
\r
1278 GSList *tokens=NULL;
\r
1279 int i = 0, mode =0;
\r
1280 char *mid = NULL, *pResp = NULL, *line = NULL, *res = NULL;
\r
1281 char delim[] = ",";
\r
1283 memset(&respGetCbConfig, 0, sizeof(struct tresp_sms_get_cb_config));
\r
1284 respGetCbConfig.result = SMS_DEVICE_FAILURE;
\r
1286 ur = tcore_pending_ref_user_request(p);
\r
1288 dbg("no user_request");
\r
1292 respGetCbConfig.cbConfig.net3gppType = SMS_NETTYPE_3GPP;
\r
1294 if (atResp->success) {
\r
1295 dbg("Response OK");
\r
1296 if (atResp->lines) {
\r
1297 line = (char*)atResp->lines->data;
\r
1298 if (line != NULL) {
\r
1299 dbg("line is %s",line);
\r
1300 tokens = tcore_at_tok_new(line);
\r
1301 pResp = g_slist_nth_data(tokens, 0);
\r
1303 mode = atoi(pResp);
\r
1304 respGetCbConfig.cbConfig.cbEnabled = mode;
\r
1306 pResp = g_slist_nth_data(tokens, 1);
\r
1308 mid = strtok(pResp, delim);
\r
1310 while ( res != NULL ) {
\r
1311 res = strtok( NULL, delim );
\r
1312 dbg("mid is %s%s\n", mid,res);
\r
1313 if (res != NULL) {
\r
1314 if (strlen(res) >0) {
\r
1315 respGetCbConfig.cbConfig.msgIDs[i].net3gpp.fromMsgId = atoi(res);
\r
1316 respGetCbConfig.cbConfig.msgIDs[i].net3gpp.toMsgId = atoi(res);
\r
1317 respGetCbConfig.cbConfig.msgIDs[i].net3gpp.selected = TRUE;
\r
1319 respGetCbConfig.result = SMS_SENDSMS_SUCCESS;
\r
1324 respGetCbConfig.cbConfig.msgIdRangeCount = i;
\r
1328 respGetCbConfig.cbConfig.msgIdRangeCount = 1;
\r
1329 respGetCbConfig.cbConfig.msgIDs[0].net3gpp.fromMsgId = 0x0000;
\r
1330 respGetCbConfig.cbConfig.msgIDs[0].net3gpp.toMsgId = 0xFFFF;
\r
1331 respGetCbConfig.cbConfig.msgIDs[0].net3gpp.selected = TRUE;
\r
1332 respGetCbConfig.result = SMS_SENDSMS_SUCCESS;
\r
1334 respGetCbConfig.cbConfig.msgIdRangeCount = 0;
\r
1335 respGetCbConfig.cbConfig.msgIDs[0].net3gpp.selected = FALSE;
\r
1336 respGetCbConfig.result = SMS_SENDSMS_SUCCESS;
\r
1341 dbg("line is NULL");
\r
1344 dbg("atresp->lines is NULL");
\r
1347 dbg("RESPONSE NOK");
\r
1350 tcore_user_request_send_response(ur, TRESP_SMS_GET_CB_CONFIG, sizeof(struct tresp_sms_get_cb_config), &respGetCbConfig);
\r
1353 tcore_at_tok_free(tokens);
\r
1358 static void on_response_set_cb_config(TcorePending *pending, int data_len, const void *data, void *user_data)
\r
1361 Response is expected in this format
\r
1368 const TcoreATResponse *resp = data;
\r
1370 const char *line = NULL;
\r
1371 GSList *tokens=NULL;
\r
1373 struct tresp_sms_set_cb_config respSetCbConfig = {0,};
\r
1375 memset(&respSetCbConfig, 0, sizeof(struct tresp_sms_set_cb_config));
\r
1377 ur = tcore_pending_ref_user_request(pending);
\r
1378 respSetCbConfig.result = SMS_SENDSMS_SUCCESS;
\r
1380 if (resp->success > 0) {
\r
1381 dbg("RESPONSE OK");
\r
1383 dbg("RESPONSE NOK");
\r
1384 line = (const char*)resp->final_response;
\r
1385 tokens = tcore_at_tok_new(line);
\r
1387 if (g_slist_length(tokens) < 1) {
\r
1388 dbg("err cause not specified or string corrupted");
\r
1389 respSetCbConfig.result = SMS_DEVICE_FAILURE;
\r
1391 response = atoi(g_slist_nth_data(tokens, 0));
\r
1392 /* TODO: CMEE error mapping is required. */
\r
1393 respSetCbConfig.result = SMS_DEVICE_FAILURE;
\r
1397 dbg("no user_request");
\r
1401 tcore_user_request_send_response(ur, TRESP_SMS_SET_CB_CONFIG, sizeof(struct tresp_sms_set_cb_config), &respSetCbConfig);
\r
1404 tcore_at_tok_free(tokens);
\r
1409 static void on_response_set_mem_status(TcorePending *p, int data_len, const void *data, void *user_data)
\r
1412 struct tresp_sms_set_mem_status respSetMemStatus = {0,};
\r
1413 const TcoreATResponse *resp = data;
\r
1415 memset(&respSetMemStatus, 0, sizeof(struct tresp_sms_set_mem_status));
\r
1417 if (resp->success > 0) {
\r
1418 dbg("RESPONSE OK");
\r
1419 respSetMemStatus.result = SMS_SENDSMS_SUCCESS;
\r
1421 dbg("RESPONSE NOK");
\r
1422 respSetMemStatus.result = SMS_DEVICE_FAILURE;
\r
1425 ur = tcore_pending_ref_user_request(p);
\r
1427 dbg("no user_request");
\r
1431 tcore_user_request_send_response(ur, TRESP_SMS_SET_MEM_STATUS, sizeof(struct tresp_sms_set_mem_status), &respSetMemStatus);
\r
1436 static void on_response_set_msg_status(TcorePending *pending, int data_len, const void *data, void *user_data)
\r
1439 struct tresp_sms_set_msg_status respMsgStatus = {0, };
\r
1440 const TcoreATResponse *atResp = data;
\r
1441 int response = 0, sw1 = 0, sw2 = 0;
\r
1442 const char *line = NULL;
\r
1443 char *pResp = NULL;
\r
1444 GSList *tokens = NULL;
\r
1448 memset(&respMsgStatus, 0, sizeof(struct tresp_sms_set_msg_status));
\r
1449 respMsgStatus.result = SMS_DEVICE_FAILURE;
\r
1451 ur = tcore_pending_ref_user_request(pending);
\r
1453 if (atResp->success > 0) {
\r
1454 dbg("RESPONSE OK");
\r
1456 if (atResp->lines) {
\r
1457 line = (const char *) atResp->lines->data;
\r
1458 tokens = tcore_at_tok_new(line);
\r
1459 pResp = g_slist_nth_data(tokens, 0);
\r
1460 if (pResp != NULL) {
\r
1461 sw1 = atoi(pResp);
\r
1463 dbg("sw1 is NULL");
\r
1465 pResp = g_slist_nth_data(tokens, 1);
\r
1466 if (pResp != NULL) {
\r
1467 sw2 = atoi(pResp);
\r
1468 if ((sw1 == AT_SW1_SUCCESS) && (sw2 == 0)) {
\r
1469 respMsgStatus.result = SMS_SENDSMS_SUCCESS;
\r
1472 dbg("sw2 is NULL");
\r
1474 pResp = g_slist_nth_data(tokens, 3);
\r
1476 if (pResp != NULL) {
\r
1477 response = atoi(pResp);
\r
1478 dbg("response is %s", response);
\r
1484 dbg("RESPONSE NOK");
\r
1487 tcore_user_request_send_response(ur, TRESP_SMS_SET_MSG_STATUS , sizeof(struct tresp_sms_set_msg_status), &respMsgStatus);
\r
1490 tcore_at_tok_free(tokens);
\r
1496 static void on_response_get_sms_params(TcorePending *pending, int data_len, const void *data, void *user_data)
\r
1499 struct tresp_sms_get_params respGetParams ;
\r
1500 const TcoreATResponse *atResp = data;
\r
1501 int sw1 = 0, sw2 = 0;
\r
1502 const char *line = NULL;
\r
1503 char *pResp = NULL;
\r
1504 GSList *tokens=NULL;
\r
1505 char *hexData = NULL;
\r
1506 char *recordData = NULL;
\r
1509 memset(&respGetParams, 0, sizeof(struct tresp_sms_get_params));
\r
1510 respGetParams.result = SMS_DEVICE_FAILURE;
\r
1512 ur = tcore_pending_ref_user_request(pending);
\r
1514 if (atResp->success > 0) {
\r
1515 dbg("RESPONSE OK");
\r
1517 if (atResp->lines) {
\r
1518 line = (const char *) atResp->lines->data;
\r
1519 tokens = tcore_at_tok_new(line);
\r
1520 pResp = g_slist_nth_data(tokens, 0);
\r
1521 if (pResp != NULL) {
\r
1522 sw1 = atoi(pResp);
\r
1523 dbg("sw1 is %d", sw1);
\r
1525 dbg("sw1 is NULL");
\r
1527 pResp = g_slist_nth_data(tokens, 1);
\r
1528 if (pResp != NULL) {
\r
1529 sw2 = atoi(pResp);
\r
1530 dbg("sw2 is %d", sw2);
\r
1531 if ((sw1 == 0x90 && sw2 == 0x00) || sw1 == 0x91) {
\r
1532 respGetParams.result = SMS_SENDSMS_SUCCESS;
\r
1535 dbg("sw2 is NULL");
\r
1537 pResp = g_slist_nth_data(tokens, 2);
\r
1538 if (pResp != NULL) {
\r
1539 hexData = util_removeQuotes(pResp);
\r
1541 recordData = util_hexStringToBytes(hexData);
\r
1542 util_hex_dump(" ", strlen(hexData) / 2, recordData);
\r
1544 respGetParams.paramsInfo.recordLen = strlen(hexData) / 2;
\r
1546 util_sms_decode_smsParameters((unsigned char *) recordData, strlen(hexData) / 2, &(respGetParams.paramsInfo));
\r
1547 respGetParams.result = SMS_SENDSMS_SUCCESS;
\r
1549 for (i = 0; i < (int) respGetParams.paramsInfo.tpSvcCntrAddr.dialNumLen; i++)
\r
1550 dbg("SCAddr = %d [%02x]", i, respGetParams.paramsInfo.tpSvcCntrAddr.diallingNum[i]);
\r
1555 dbg("No response");
\r
1557 tcore_at_tok_free(tokens);
\r
1560 dbg("RESPONSE NOK");
\r
1563 tcore_user_request_send_response(ur, TRESP_SMS_GET_PARAMS, sizeof(struct tresp_sms_get_params), &respGetParams);
\r
1569 static void on_response_set_sms_params(TcorePending *pending, int data_len, const void *data, void *user_data)
\r
1572 struct tresp_sms_set_params respSetParams = {0, };
\r
1573 const TcoreATResponse *atResp = data;
\r
1574 int sw1 =0 , sw2 = 0;
\r
1575 const char *line = NULL;
\r
1576 char *pResp = NULL;
\r
1577 GSList *tokens=NULL;
\r
1580 memset(&respSetParams, 0, sizeof(struct tresp_sms_set_params));
\r
1581 ur = tcore_pending_ref_user_request(pending);
\r
1583 respSetParams.result = SMS_DEVICE_FAILURE;
\r
1585 if (atResp->success > 0) {
\r
1586 dbg("RESPONSE OK");
\r
1588 if (atResp->lines) {
\r
1589 line = (const char *) atResp->lines->data;
\r
1590 tokens = tcore_at_tok_new(line);
\r
1591 pResp = g_slist_nth_data(tokens, 0);
\r
1592 if (pResp != NULL) {
\r
1593 sw1 = atoi(pResp);
\r
1595 dbg("sw1 is NULL");
\r
1598 pResp = g_slist_nth_data(tokens, 1);
\r
1599 if (pResp != NULL) {
\r
1600 sw2 = atoi(pResp);
\r
1601 if (((sw1 == AT_SW1_SUCCESS) && (sw2 == AT_SW2_SUCCESS)) || (sw1 == 0x91)) {
\r
1602 respSetParams.result = SMS_SENDSMS_SUCCESS;
\r
1605 dbg("sw2 is NULL");
\r
1611 dbg("RESPONSE NOK");
\r
1614 tcore_user_request_send_response(ur, TRESP_SMS_SET_PARAMS , sizeof(struct tresp_sms_set_params), &respSetParams);
\r
1617 tcore_at_tok_free(tokens);
\r
1623 static void on_response_get_paramcnt(TcorePending *p, int data_len, const void *data, void *user_data)
\r
1625 UserRequest *ur = NULL;
\r
1626 struct tresp_sms_get_paramcnt respGetParamCnt = {0, };
\r
1627 const TcoreATResponse *atResp = data;
\r
1628 char *line = NULL , *pResp = NULL;
\r
1629 int sw1 = 0 , sw2 = 0, *smsp_record_len = NULL;
\r
1631 GSList *tokens=NULL;
\r
1632 CoreObject *co_sim = NULL; //need this to get the sim type GSM/USIM
\r
1633 TcorePlugin *plugin = NULL;
\r
1637 ur = tcore_pending_ref_user_request(p);
\r
1638 respGetParamCnt.result = SMS_DEVICE_FAILURE;
\r
1640 if (atResp->success > 0) {
\r
1641 dbg("RESPONSE OK");
\r
1643 if (atResp->lines) {
\r
1644 line = (char *) atResp->lines->data;
\r
1646 dbg("line is %s", line);
\r
1648 tokens = tcore_at_tok_new(line);
\r
1649 pResp = g_slist_nth_data(tokens, 0);
\r
1650 if (pResp != NULL) {
\r
1651 sw1 = atoi(pResp);
\r
1653 dbg("sw1 is NULL");
\r
1655 pResp = g_slist_nth_data(tokens, 1);
\r
1656 if (pResp != NULL) {
\r
1657 sw2 = atoi(pResp);
\r
1658 if ((sw1 == 144) && (sw2 == 0)) {
\r
1659 respGetParamCnt.result = SMS_SENDSMS_SUCCESS;
\r
1662 dbg("sw2 is NULL");
\r
1664 pResp = g_slist_nth_data(tokens, 2);
\r
1665 if (pResp != NULL) {
\r
1666 char *hexData = NULL;
\r
1667 char *recordData = NULL;
\r
1668 hexData = util_removeQuotes(pResp);
\r
1670 /*1. SIM access success case*/
\r
1671 if ((sw1 == 0x90 && sw2 == 0x00) || sw1 == 0x91) {
\r
1672 unsigned char tag_len = 0; /* 1 or 2 bytes ??? */
\r
1673 int record_len = 0;
\r
1674 char num_of_records = 0;
\r
1675 unsigned char file_id_len = 0;
\r
1676 unsigned short file_id = 0;
\r
1677 unsigned short file_size = 0;
\r
1678 unsigned short file_type = 0;
\r
1679 unsigned short arr_file_id = 0;
\r
1680 int arr_file_id_rec_num = 0;
\r
1682 /* handling only last 3 bits */
\r
1683 unsigned char file_type_tag = 0x07;
\r
1684 unsigned char *ptr_data;
\r
1686 recordData = util_hexStringToBytes(hexData);
\r
1687 util_hex_dump(" ", strlen(hexData)/2, recordData);
\r
1689 ptr_data = (unsigned char *)recordData;
\r
1691 co_sim = tcore_plugin_ref_core_object(tcore_pending_ref_plugin(p), "sim");
\r
1692 sim_type = tcore_sim_get_type(co_sim);
\r
1693 dbg("sim type is %d",sim_type);
\r
1695 if (sim_type == SIM_TYPE_USIM) {
\r
1697 ETSI TS 102 221 v7.9.0
\r
1699 '62' FCP template tag
\r
1700 - Response for an EF
\r
1701 '82' M File Descriptor
\r
1702 '83' M File Identifier
\r
1703 'A5' O Proprietary information
\r
1704 '8A' M Life Cycle Status Integer
\r
1705 '8B', '8C' or 'AB' C1 Security attributes
\r
1707 '81' O Total file size
\r
1708 '88' O Short File Identifier (SFI)
\r
1711 /* rsim.res_len has complete data length received */
\r
1713 /* FCP template tag - File Control Parameters tag*/
\r
1714 if (*ptr_data == 0x62) {
\r
1715 /* parse complete FCP tag*/
\r
1716 /* increment to next byte */
\r
1718 tag_len = *ptr_data++;
\r
1719 /* FCP file descriptor - file type, accessibility, DF, ADF etc*/
\r
1720 if (*ptr_data == 0x82) {
\r
1721 /* increment to next byte */
\r
1725 /* unsigned char file_desc_len = *ptr_data++;*/
\r
1726 /* dbg("file descriptor length: [%d]", file_desc_len);*/
\r
1727 /* TBD: currently capture only file type : ignore sharable, non sharable, working, internal etc*/
\r
1728 /* consider only last 3 bits*/
\r
1729 file_type_tag = file_type_tag & (*ptr_data);
\r
1731 switch (file_type_tag) {
\r
1732 /* increment to next byte */
\r
1736 dbg("Getting FileType: [Transparent file type]");
\r
1737 /* increment to next byte */
\r
1739 file_type = 0x01; //SIM_FTYPE_TRANSPARENT
\r
1740 /* data coding byte - value 21 */
\r
1745 dbg("Getting FileType: [Linear fixed file type]");
\r
1746 /* increment to next byte */
\r
1748 /* data coding byte - value 21 */
\r
1751 memcpy(&record_len, ptr_data, 2);
\r
1753 record_len = SMS_SWAPBYTES16(record_len);
\r
1754 ptr_data = ptr_data + 2;
\r
1755 num_of_records = *ptr_data++;
\r
1756 /* Data lossy conversation from enum (int) to unsigned char */
\r
1757 file_type = 0x02; // SIM_FTYPE_LINEAR_FIXED
\r
1761 dbg(" Cyclic fixed file type");
\r
1762 /* increment to next byte */
\r
1764 /* data coding byte - value 21 */
\r
1767 memcpy(&record_len, ptr_data, 2);
\r
1769 record_len = SMS_SWAPBYTES16(record_len);
\r
1770 ptr_data = ptr_data + 2;
\r
1771 num_of_records = *ptr_data++;
\r
1772 file_type = 0x04; //SIM_FTYPE_CYCLIC
\r
1776 dbg("not handled file type [0x%x]", *ptr_data);
\r
1780 dbg("INVALID FCP received - DEbug!");
\r
1781 tcore_at_tok_free(tokens);
\r
1785 /*File identifier - file id?? */ // 0x84,0x85,0x86 etc are currently ignored and not handled
\r
1786 if (*ptr_data == 0x83) {
\r
1787 /* increment to next byte */
\r
1789 file_id_len = *ptr_data++;
\r
1790 memcpy(&file_id, ptr_data, file_id_len);
\r
1792 file_id = SMS_SWAPBYTES16(file_id);
\r
1793 ptr_data = ptr_data + 2;
\r
1794 dbg("Getting FileID=[0x%x]", file_id);
\r
1796 dbg("INVALID FCP received - DEbug!");
\r
1799 tcore_at_tok_free(tokens);
\r
1803 /* proprietary information */
\r
1804 if (*ptr_data == 0xA5) {
\r
1805 unsigned short prop_len;
\r
1806 /* increment to next byte */
\r
1809 prop_len = *ptr_data;
\r
1811 ptr_data = ptr_data + prop_len + 1;
\r
1813 dbg("INVALID FCP received - DEbug!");
\r
1816 /* life cycle status integer [8A][length:0x01][status]*/
\r
1819 00000000 : No information given
\r
1820 00000001 : creation state
\r
1821 00000011 : initialization state
\r
1822 000001-1 : operation state -activated
\r
1823 000001-0 : operation state -deactivated
\r
1824 000011-- : Termination state
\r
1825 b8~b5 !=0, b4~b1=X : Proprietary
\r
1826 Any other value : RFU
\r
1828 if (*ptr_data == 0x8A) {
\r
1829 /* increment to next byte */
\r
1831 /* length - value 1 */
\r
1834 switch (*ptr_data) {
\r
1837 dbg("<IPC_RX> operation state -deactivated");
\r
1843 dbg("<IPC_RX> operation state -activated");
\r
1848 dbg("<IPC_RX> DEBUG! LIFE CYCLE STATUS =[0x%x]",*ptr_data);
\r
1854 /* related to security attributes : currently not handled*/
\r
1855 if (*ptr_data == 0x86 || *ptr_data == 0x8B || *ptr_data == 0x8C || *ptr_data == 0xAB) {
\r
1856 /* increment to next byte */
\r
1858 /* if tag length is 3 */
\r
1859 if (*ptr_data == 0x03) {
\r
1860 /* increment to next byte */
\r
1862 /* EFARR file id */
\r
1863 memcpy(&arr_file_id, ptr_data, 2);
\r
1865 arr_file_id = SMS_SWAPBYTES16(arr_file_id);
\r
1866 ptr_data = ptr_data + 2;
\r
1867 arr_file_id_rec_num = *ptr_data++;
\r
1869 /* if tag length is not 3 */
\r
1870 /* ignoring bytes */
\r
1871 // ptr_data = ptr_data + 4;
\r
1872 dbg("Useless security attributes, so jump to next tag");
\r
1873 ptr_data = ptr_data + (*ptr_data + 1);
\r
1876 dbg("INVALID FCP received[0x%x] - DEbug!", *ptr_data);
\r
1879 tcore_at_tok_free(tokens);
\r
1883 dbg("Current ptr_data value is [%x]", *ptr_data);
\r
1885 /* file size excluding structural info*/
\r
1886 if (*ptr_data == 0x80) {
\r
1887 /* for EF file size is body of file and for Linear or cyclic it is
\r
1888 * number of recXsizeof(one record)
\r
1890 /* increment to next byte */
\r
1892 /* length is 1 byte - value is 2 bytes or more */
\r
1894 memcpy(&file_size, ptr_data, 2);
\r
1896 file_size = SMS_SWAPBYTES16(file_size);
\r
1897 ptr_data = ptr_data + 2;
\r
1899 dbg("INVALID FCP received - DEbug!");
\r
1902 tcore_at_tok_free(tokens);
\r
1906 /* total file size including structural info*/
\r
1907 if (*ptr_data == 0x81) {
\r
1909 /* increment to next byte */
\r
1913 /* ignored bytes */
\r
1914 ptr_data = ptr_data + 3;
\r
1916 dbg("INVALID FCP received - DEbug!");
\r
1917 /* 0x81 is optional tag?? check out! so do not return -1 from here! */
\r
1920 /*short file identifier ignored*/
\r
1921 if (*ptr_data == 0x88) {
\r
1922 dbg("0x88: Do Nothing");
\r
1926 dbg("INVALID FCP received - DEbug!");
\r
1929 tcore_at_tok_free(tokens);
\r
1932 } else if (sim_type == SIM_TYPE_GSM) {
\r
1933 unsigned char gsm_specific_file_data_len = 0;
\r
1934 /* ignore RFU byte1 and byte2 */
\r
1938 //file_size = p_info->response_len;
\r
1939 memcpy(&file_size, ptr_data, 2);
\r
1941 file_size = SMS_SWAPBYTES16(file_size);
\r
1942 /* parsed file size */
\r
1943 ptr_data = ptr_data + 2;
\r
1945 memcpy(&file_id, ptr_data, 2);
\r
1946 file_id = SMS_SWAPBYTES16(file_id);
\r
1947 dbg(" FILE id --> [%x]", file_id);
\r
1948 ptr_data = ptr_data + 2;
\r
1949 /* save file type - transparent, linear fixed or cyclic */
\r
1950 file_type_tag = (*(ptr_data + 7));
\r
1952 switch (*ptr_data) {
\r
1954 /* RFU file type */
\r
1955 dbg(" RFU file type- not handled - Debug!");
\r
1959 /* MF file type */
\r
1960 dbg(" MF file type - not handled - Debug!");
\r
1964 /* DF file type */
\r
1965 dbg(" DF file type - not handled - Debug!");
\r
1969 /* EF file type */
\r
1970 dbg(" EF file type [%d] ", file_type_tag);
\r
1971 /* increment to next byte */
\r
1974 if (file_type_tag == 0x00 || file_type_tag == 0x01) {
\r
1975 /* increament to next byte as this byte is RFU */
\r
1978 (file_type_tag == 0x00) ? 0x01 : 0x02; // SIM_FTYPE_TRANSPARENT:SIM_FTYPE_LINEAR_FIXED;
\r
1980 /* increment to next byte */
\r
1982 /* For a cyclic EF all bits except bit 7 are RFU; b7=1 indicates that */
\r
1983 /* the INCREASE command is allowed on the selected cyclic file. */
\r
1984 file_type = 0x04; // SIM_FTYPE_CYCLIC;
\r
1986 /* bytes 9 to 11 give SIM file access conditions */
\r
1988 /* byte 10 has one nibble that is RF U and another for INCREASE which is not used currently */
\r
1990 /* byte 11 is invalidate and rehabilate nibbles */
\r
1992 /* byte 12 - file status */
\r
1994 /* byte 13 - GSM specific data */
\r
1995 gsm_specific_file_data_len = *ptr_data;
\r
1997 /* byte 14 - structure of EF - transparent or linear or cyclic , already saved above */
\r
1999 /* byte 15 - length of record for linear and cyclic , for transparent it is set to 0x00. */
\r
2000 record_len = *ptr_data;
\r
2001 dbg("record length[%d], file size[%d]", record_len, file_size);
\r
2003 if (record_len != 0)
\r
2004 num_of_records = (file_size / record_len);
\r
2006 dbg("Number of records [%d]", num_of_records);
\r
2010 dbg(" not handled file type");
\r
2014 dbg(" Card Type - UNKNOWN [%d]", sim_type);
\r
2017 dbg("EF[0x%x] size[%ld] Type[0x%x] NumOfRecords[%ld] RecordLen[%ld]", file_id, file_size, file_type, num_of_records, record_len);
\r
2019 respGetParamCnt.recordCount = num_of_records;
\r
2020 respGetParamCnt.result = SMS_SUCCESS;
\r
2022 //TO Store smsp record length in the property
\r
2023 plugin = tcore_pending_ref_plugin(p);
\r
2024 smsp_record_len = tcore_plugin_ref_property(plugin, "SMSPRECORDLEN");
\r
2025 memcpy(smsp_record_len, &record_len, sizeof(int));
\r
2030 /*2. SIM access fail case*/
\r
2031 dbg("SIM access fail");
\r
2032 respGetParamCnt.result = SMS_UNKNOWN;
\r
2035 dbg("presp is NULL");
\r
2038 dbg("line is blank");
\r
2041 dbg("RESPONSE NOK");
\r
2044 tcore_user_request_send_response(ur, TRESP_SMS_GET_PARAMCNT, sizeof(struct tresp_sms_get_paramcnt), &respGetParamCnt);
\r
2047 tcore_at_tok_free(tokens);
\r
2053 static void _response_get_efsms_data(TcorePending *p, int data_len, const void *data, void *user_data)
\r
2055 UserRequest *ur = NULL;
\r
2056 UserRequest *dup_ur = NULL;
\r
2057 struct tresp_sms_set_msg_status resp_msg_status = {0,};
\r
2058 const struct treq_sms_set_msg_status *req_msg_status = NULL ;
\r
2060 const TcoreATResponse *resp = data;
\r
2061 char *encoded_data = NULL;
\r
2062 char msg_status = 0;
\r
2063 char *pResp = NULL;
\r
2064 GSList *tokens=NULL;
\r
2065 const char *line = NULL;
\r
2069 TcoreHal *hal = NULL;
\r
2070 TcoreATRequest *atreq = NULL;
\r
2071 TcorePending *pending = NULL;
\r
2072 gchar *cmd_str = NULL;
\r
2074 ur = tcore_pending_ref_user_request(p);
\r
2076 req_msg_status = tcore_user_request_ref_data(ur, NULL);
\r
2078 resp_msg_status.result = SMS_DEVICE_FAILURE;
\r
2080 hal = tcore_object_get_hal(tcore_pending_ref_core_object(pending));
\r
2081 dbg("msgStatus: [%x], index [%x]", req_msg_status->msgStatus, req_msg_status->index);
\r
2083 if (resp->success <= 0) {
\r
2088 dbg("RESPONSE OK");
\r
2089 if (resp->lines) {
\r
2090 line = (const char *) resp->lines->data;
\r
2091 tokens = tcore_at_tok_new(line);
\r
2092 if (g_slist_length(tokens) != 3) {
\r
2093 msg("invalid message");
\r
2097 sw1 = atoi(g_slist_nth_data(tokens, 0));
\r
2098 sw2 = atoi(g_slist_nth_data(tokens, 1));
\r
2099 pResp = g_slist_nth_data(tokens, 2);
\r
2101 if ((sw1 == 0x90 && sw2 == 0x00) || sw1 == 0x91) {
\r
2102 switch (req_msg_status->msgStatus) {
\r
2103 case SMS_STATUS_READ:
\r
2104 msg_status = 0x01;
\r
2107 case SMS_STATUS_UNREAD:
\r
2108 msg_status = 0x03;
\r
2111 case SMS_STATUS_UNSENT:
\r
2112 msg_status = 0x07;
\r
2115 case SMS_STATUS_SENT:
\r
2116 msg_status = 0x05;
\r
2119 case SMS_STATUS_DELIVERED:
\r
2120 msg_status = 0x1D;
\r
2123 case SMS_STATUS_DELIVERY_UNCONFIRMED:
\r
2127 case SMS_STATUS_MESSAGE_REPLACED:
\r
2128 case SMS_STATUS_RESERVED:
\r
2130 msg_status = 0x03;
\r
2134 encoded_data = util_removeQuotes(pResp);
\r
2136 //overwrite Status byte information
\r
2137 util_byte_to_hex((const char *)&msg_status, (char *)encoded_data, 1);
\r
2139 //Update EF-SMS with just status byte overwritten, rest 175 bytes are same as received in read information
\r
2140 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);
\r
2141 atreq = tcore_at_request_new((const char *)cmd_str, "+CRSM", TCORE_AT_SINGLELINE);
\r
2142 pending = tcore_pending_new(tcore_pending_ref_core_object(pending), 0);
\r
2143 if (NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
2144 err("Out of memory. Unable to proceed");
\r
2145 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
2147 //free memory we own
\r
2149 free(encoded_data);
\r
2150 util_sms_free_memory(atreq);
\r
2151 util_sms_free_memory(pending);
\r
2156 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
2158 dup_ur = tcore_user_request_ref(ur);
\r
2160 tcore_pending_set_request_data(pending, 0, atreq);
\r
2161 tcore_pending_set_response_callback(pending, on_response_set_msg_status, NULL);
\r
2162 tcore_pending_link_user_request(pending, dup_ur);
\r
2163 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
2164 tcore_hal_send_request(hal, pending);
\r
2167 free(encoded_data);
\r
2173 tcore_at_tok_free(tokens);
\r
2175 tcore_user_request_send_response(ur, TRESP_SMS_SET_MSG_STATUS , sizeof(struct tresp_sms_set_msg_status), &msg_status);
\r
2182 /*=============================================================
\r
2184 ==============================================================*/
\r
2185 static TReturn send_umts_msg(CoreObject *obj, UserRequest *ur)
\r
2187 gchar *cmd_str = NULL;
\r
2188 TcoreHal *hal = NULL;
\r
2189 TcoreATRequest *atreq = NULL;
\r
2190 TcorePending *pending = NULL;
\r
2191 const struct treq_sms_send_umts_msg *sendUmtsMsg = NULL;
\r
2192 char buf[2*(SMS_SMSP_ADDRESS_LEN+SMS_SMDATA_SIZE_MAX)+1] = {0};
\r
2198 sendUmtsMsg = tcore_user_request_ref_data(ur, NULL);
\r
2199 hal = tcore_object_get_hal(obj);
\r
2200 if (NULL == sendUmtsMsg || NULL == hal) {
\r
2201 err("NULL input. Unable to proceed");
\r
2202 dbg("sendUmtsMsg: [%p], hal: [%p]", sendUmtsMsg, hal);
\r
2205 return TCORE_RETURN_EINVAL;
\r
2208 dbg("msgLength: [%d]", sendUmtsMsg->msgDataPackage.msgLength);
\r
2209 util_hex_dump(" ", (SMS_SMDATA_SIZE_MAX+1), (void *)sendUmtsMsg->msgDataPackage.tpduData);
\r
2210 util_hex_dump(" ", SMS_SMSP_ADDRESS_LEN, (void *)sendUmtsMsg->msgDataPackage.sca);
\r
2212 ScLength = (int)sendUmtsMsg->msgDataPackage.sca[0];
\r
2214 dbg("ScLength: [%d]", ScLength);
\r
2216 if ((sendUmtsMsg->msgDataPackage.msgLength > 0)
\r
2217 && (sendUmtsMsg->msgDataPackage.msgLength <= SMS_SMDATA_SIZE_MAX)
\r
2218 && (ScLength <= SMS_MAX_SMS_SERVICE_CENTER_ADDR)) {
\r
2219 if (ScLength == 0) { // ScAddress not specified
\r
2224 dbg("Specifying SCA in TPDU is currently not supported");
\r
2231 util_byte_to_hex((const char *)sendUmtsMsg->msgDataPackage.tpduData, (char *)&buf[pdu_len], sendUmtsMsg->msgDataPackage.msgLength);
\r
2233 pdu_len = pdu_len + 2*sendUmtsMsg->msgDataPackage.msgLength;
\r
2235 buf[pdu_len] = '\0'; //Ensure termination
\r
2237 dbg("pdu_len: [%d]", pdu_len);
\r
2238 util_hex_dump(" ", sizeof(buf), (void *)buf);
\r
2240 //AT+CMGS=<length><CR>PDU is given<ctrl-Z/ESC>
\r
2241 cmd_str = g_strdup_printf("AT+CMGS=%d%s%s\x1A", sendUmtsMsg->msgDataPackage.msgLength,"\r",buf);
\r
2242 atreq = tcore_at_request_new((const char *)cmd_str, "+CMGS", TCORE_AT_SINGLELINE);
\r
2243 pending = tcore_pending_new(obj, 0);
\r
2245 if (NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
2246 err("Out of memory. Unable to proceed");
\r
2247 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
2249 //free memory we own
\r
2251 util_sms_free_memory(atreq);
\r
2252 util_sms_free_memory(pending);
\r
2255 return TCORE_RETURN_ENOMEM;
\r
2258 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
2260 tcore_pending_set_request_data(pending, 0, atreq);
\r
2261 tcore_pending_set_response_callback(pending, on_response_send_umts_msg, NULL);
\r
2262 tcore_pending_link_user_request(pending, ur);
\r
2263 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
2264 tcore_hal_send_request(hal, pending);
\r
2269 return TCORE_RETURN_SUCCESS;
\r
2272 err("Invalid Data len");
\r
2274 return TCORE_RETURN_SMS_INVALID_DATA_LEN;
\r
2277 static TReturn read_msg(CoreObject *obj, UserRequest *ur)
\r
2279 gchar *cmd_str = NULL;
\r
2280 TcoreHal *hal = NULL;
\r
2281 TcoreATRequest *atreq = NULL;
\r
2282 TcorePending *pending = NULL;
\r
2283 const struct treq_sms_read_msg *readMsg = NULL;
\r
2287 readMsg = tcore_user_request_ref_data(ur, NULL);
\r
2288 hal = tcore_object_get_hal(obj);
\r
2289 if (NULL == readMsg || NULL == hal) {
\r
2290 err("NULL input. Unable to proceed");
\r
2291 dbg("readMsg: [%p], hal: [%p]", readMsg, hal);
\r
2294 return TCORE_RETURN_EINVAL;
\r
2297 dbg("index: [%d]", readMsg->index);
\r
2299 cmd_str = g_strdup_printf("AT+CMGR=%d", (readMsg->index + 1)); //IMC index is one ahead of TAPI
\r
2300 atreq = tcore_at_request_new((const char *)cmd_str, "+CMGR", TCORE_AT_PDU);
\r
2301 pending = tcore_pending_new(obj, 0);
\r
2303 if (NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
2304 err("Out of memory. Unable to proceed");
\r
2305 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
2307 //free memory we own
\r
2309 util_sms_free_memory(atreq);
\r
2310 util_sms_free_memory(pending);
\r
2313 return TCORE_RETURN_ENOMEM;
\r
2316 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
2318 tcore_pending_set_request_data(pending, 0, atreq);
\r
2319 tcore_pending_set_response_callback(pending, on_response_read_msg, (void *)(uintptr_t)(readMsg->index)); //storing index as user data for response
\r
2320 tcore_pending_link_user_request(pending, ur);
\r
2321 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
2322 tcore_hal_send_request(hal, pending);
\r
2327 return TCORE_RETURN_SUCCESS;
\r
2330 static TReturn save_msg(CoreObject *obj, UserRequest *ur)
\r
2332 gchar *cmd_str = NULL;
\r
2333 TcoreHal *hal = NULL;
\r
2334 TcoreATRequest *atreq = NULL;
\r
2335 TcorePending *pending = NULL;
\r
2336 const struct treq_sms_save_msg *saveMsg = NULL;
\r
2337 int ScLength = 0, pdu_len = 0, stat = 0;
\r
2338 char buf[2*(SMS_SMSP_ADDRESS_LEN+SMS_SMDATA_SIZE_MAX)+1] = {0};
\r
2339 char *hex_pdu = NULL;
\r
2343 saveMsg = tcore_user_request_ref_data(ur, NULL);
\r
2344 hal = tcore_object_get_hal(obj);
\r
2345 if (NULL == saveMsg || NULL == hal) {
\r
2346 err("NULL input. Unable to proceed");
\r
2347 dbg("saveMsg: [%p], hal: [%p]", saveMsg, hal);
\r
2350 return TCORE_RETURN_EINVAL;
\r
2353 dbg("msgStatus: %x, msgLength: [%d]", saveMsg->msgStatus, saveMsg->msgDataPackage.msgLength);
\r
2354 util_hex_dump(" ", (SMS_SMDATA_SIZE_MAX+1), (void *)saveMsg->msgDataPackage.tpduData);
\r
2355 util_hex_dump(" ", SMS_SMSP_ADDRESS_LEN, (void *)saveMsg->msgDataPackage.sca);
\r
2357 switch (saveMsg->msgStatus) {
\r
2358 case SMS_STATUS_READ:
\r
2359 stat = AT_REC_READ;
\r
2362 case SMS_STATUS_UNREAD:
\r
2363 stat = AT_REC_UNREAD;
\r
2366 case SMS_STATUS_SENT:
\r
2367 stat = AT_STO_SENT;
\r
2370 case SMS_STATUS_UNSENT:
\r
2371 stat = AT_STO_UNSENT;
\r
2375 err("Invalid msgStatus");
\r
2377 return TCORE_RETURN_EINVAL;
\r
2380 if ((saveMsg->msgDataPackage.msgLength > 0)
\r
2381 && (saveMsg->msgDataPackage.msgLength <= SMS_SMDATA_SIZE_MAX)) {
\r
2382 ScLength = (int)saveMsg->msgDataPackage.sca[0];
\r
2384 buf[0] = ScLength;
\r
2385 dbg("ScLength = %d", ScLength);
\r
2387 if(ScLength == 0) {
\r
2390 memcpy(&buf[1], saveMsg->msgDataPackage.sca, ScLength);
\r
2393 memcpy(&buf[ScLength+1], saveMsg->msgDataPackage.tpduData, saveMsg->msgDataPackage.msgLength);
\r
2395 pdu_len= saveMsg->msgDataPackage.msgLength + ScLength + 1;
\r
2396 dbg("pdu_len: [%d]", pdu_len);
\r
2398 hex_pdu = malloc(pdu_len * 2 + 1);
\r
2399 util_hex_dump(" ", sizeof(buf), (void *)buf);
\r
2401 memset (hex_pdu, 0x00, pdu_len * 2 + 1);
\r
2403 util_byte_to_hex((const char *)buf, (char *)hex_pdu, pdu_len);
\r
2405 //AT+CMGW=<length>[,<stat>]<CR>PDU is given<ctrl-Z/ESC>
\r
2406 cmd_str = g_strdup_printf("AT+CMGW=%d,%d%s%s\x1A", saveMsg->msgDataPackage.msgLength, stat, "\r", hex_pdu);
\r
2407 pending = tcore_pending_new(obj, 0);
\r
2408 atreq = tcore_at_request_new((const char *)cmd_str, "+CMGW", TCORE_AT_SINGLELINE);
\r
2410 if(NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
2411 err("Out of memory. Unable to proceed");
\r
2412 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
2414 //free memory we own
\r
2416 util_sms_free_memory(atreq);
\r
2417 util_sms_free_memory(pending);
\r
2418 util_sms_free_memory(hex_pdu);
\r
2421 return TCORE_RETURN_ENOMEM;
\r
2424 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
2426 tcore_pending_set_request_data(pending, 0, atreq);
\r
2427 tcore_pending_set_response_callback(pending, on_response_sms_save_msg, NULL);
\r
2428 tcore_pending_link_user_request(pending, ur);
\r
2429 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
2430 tcore_hal_send_request(hal, pending);
\r
2436 return TCORE_RETURN_SUCCESS;
\r
2439 err("Invalid Data len");
\r
2441 return TCORE_RETURN_SMS_INVALID_DATA_LEN;
\r
2444 static TReturn delete_msg(CoreObject *obj, UserRequest *ur)
\r
2446 gchar *cmd_str = NULL;
\r
2447 TcoreHal *hal = NULL;
\r
2448 TcoreATRequest *atreq = NULL;
\r
2449 TcorePending *pending = NULL;
\r
2450 const struct treq_sms_delete_msg *deleteMsg = NULL;
\r
2454 deleteMsg = tcore_user_request_ref_data(ur, NULL);
\r
2455 hal = tcore_object_get_hal(obj);
\r
2456 if (NULL == deleteMsg || NULL == hal) {
\r
2457 err("NULL input. Unable to proceed");
\r
2458 dbg("deleteMsg: [%p], hal: [%p]", deleteMsg, hal);
\r
2461 return TCORE_RETURN_EINVAL;
\r
2464 dbg("index: %d", deleteMsg->index);
\r
2466 cmd_str =g_strdup_printf("AT+CMGD=%d,0", deleteMsg->index+1);
\r
2467 pending = tcore_pending_new(obj, 0);
\r
2468 atreq = tcore_at_request_new((const char *)cmd_str, NULL, TCORE_AT_NO_RESULT);
\r
2469 if (NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
2470 err("Out of memory. Unable to proceed");
\r
2471 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
2473 //free memory we own
\r
2475 util_sms_free_memory(atreq);
\r
2476 util_sms_free_memory(pending);
\r
2479 return TCORE_RETURN_ENOMEM;
\r
2482 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
2484 tcore_pending_set_request_data(pending, 0, atreq);
\r
2485 tcore_pending_set_response_callback(pending, on_response_sms_delete_msg, (void *)(uintptr_t)(deleteMsg->index)); //storing index as user data for response
\r
2486 tcore_pending_link_user_request(pending, ur);
\r
2487 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
2488 tcore_hal_send_request(hal, pending);
\r
2493 return TCORE_RETURN_SUCCESS;
\r
2496 static TReturn get_storedMsgCnt(CoreObject *obj, UserRequest *ur)
\r
2498 gchar *cmd_str = NULL;
\r
2499 TcoreHal *hal = NULL;
\r
2500 TcoreATRequest *atreq = NULL;
\r
2501 TcorePending *pending = NULL;
\r
2505 hal = tcore_object_get_hal(obj);
\r
2506 if (NULL == hal) {
\r
2507 err("NULL HAL. Unable to proceed");
\r
2510 return TCORE_RETURN_EINVAL;
\r
2513 cmd_str = g_strdup_printf("AT+CPMS=\"SM\"");
\r
2514 pending = tcore_pending_new(obj, 0);
\r
2515 atreq = tcore_at_request_new((const char *)cmd_str, "+CPMS", TCORE_AT_SINGLELINE);
\r
2517 if (NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
2518 err("Out of memory. Unable to proceed");
\r
2519 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
2521 //free memory we own
\r
2523 util_sms_free_memory(atreq);
\r
2524 util_sms_free_memory(pending);
\r
2527 return TCORE_RETURN_ENOMEM;
\r
2530 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
2532 tcore_pending_set_request_data(pending, 0, atreq);
\r
2533 tcore_pending_set_response_callback(pending, on_response_get_stored_msg_cnt, NULL);
\r
2534 tcore_pending_link_user_request(pending, ur);
\r
2535 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
2536 tcore_hal_send_request(hal, pending);
\r
2541 return TCORE_RETURN_SUCCESS;
\r
2544 static TReturn get_sca(CoreObject *obj, UserRequest *ur)
\r
2546 gchar * cmd_str = NULL;
\r
2547 TcoreHal *hal = NULL;
\r
2548 TcoreATRequest *atreq = NULL;
\r
2549 TcorePending *pending = NULL;
\r
2553 hal = tcore_object_get_hal(obj);
\r
2554 if (NULL == hal) {
\r
2555 err("HAL NULL. Unable to proceed");
\r
2558 return TCORE_RETURN_EINVAL;
\r
2561 cmd_str = g_strdup_printf("AT+CSCA?");
\r
2562 pending = tcore_pending_new(obj, 0);
\r
2563 atreq = tcore_at_request_new((const char *)cmd_str, "+CSCA", TCORE_AT_SINGLELINE);
\r
2565 if (NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
2566 err("Out of memory. Unable to proceed");
\r
2567 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
2569 //free memory we own
\r
2570 g_free(cmd_str);
\r\r
2571 util_sms_free_memory(atreq);
\r
2572 util_sms_free_memory(pending);
\r
2575 return TCORE_RETURN_ENOMEM;
\r
2578 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
2580 tcore_pending_set_request_data(pending, 0, atreq);
\r
2581 tcore_pending_set_response_callback(pending, on_response_get_sca, NULL);
\r
2582 tcore_pending_link_user_request(pending, ur);
\r
2583 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
2584 tcore_hal_send_request(hal, pending);
\r
2589 return TCORE_RETURN_SUCCESS;
\r
2592 static TReturn set_sca(CoreObject *obj, UserRequest *ur)
\r
2594 gchar *cmd_str = NULL;
\r
2595 TcoreHal *hal = NULL;
\r
2596 TcoreATRequest *atreq = NULL;
\r
2597 TcorePending *pending = NULL;
\r
2598 const struct treq_sms_set_sca *setSca = NULL;
\r
2603 setSca = tcore_user_request_ref_data(ur, NULL);
\r
2604 hal = tcore_object_get_hal(obj);
\r
2605 if (NULL == setSca || NULL == hal) {
\r
2606 err("NULL input. Unable to proceed");
\r
2607 dbg("setSca: [%p], hal: [%p]", setSca, hal);
\r
2610 return TCORE_RETURN_EINVAL;
\r
2613 dbg("dialNumLen: %u, typeOfNum: %d, numPlanId: %d, ", setSca->scaInfo.dialNumLen, setSca->scaInfo.typeOfNum, setSca->scaInfo.numPlanId);
\r
2615 util_hex_dump(" ", (SMS_SMSP_ADDRESS_LEN+1), (void *)setSca->scaInfo.diallingNum);
\r
2617 addrType = ((setSca->scaInfo.typeOfNum << 4) | setSca->scaInfo.numPlanId) | 0x80;
\r
2619 cmd_str = g_strdup_printf("AT+CSCA=\"%s\",%d", setSca->scaInfo.diallingNum, addrType);
\r
2620 pending = tcore_pending_new(obj, 0);
\r
2621 atreq = tcore_at_request_new((const char *)cmd_str, NULL, TCORE_AT_NO_RESULT);
\r
2623 if (NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
2624 err("Out of memory. Unable to proceed");
\r
2625 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
2627 //free memory we own
\r
2629 util_sms_free_memory(atreq);
\r
2630 util_sms_free_memory(pending);
\r
2633 return TCORE_RETURN_ENOMEM;
\r
2636 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
2638 tcore_pending_set_request_data(pending, 0, atreq);
\r
2639 tcore_pending_set_response_callback(pending, on_response_set_sca, NULL);
\r
2640 tcore_pending_link_user_request(pending, ur);
\r
2641 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
2642 tcore_hal_send_request(hal, pending);
\r
2647 return TCORE_RETURN_SUCCESS;
\r
2650 static TReturn get_cb_config(CoreObject *obj, UserRequest *ur)
\r
2652 gchar *cmd_str = NULL;
\r
2653 TcoreHal *hal = NULL;
\r
2654 TcoreATRequest *atreq = NULL;
\r
2655 TcorePending *pending = NULL;
\r
2659 hal = tcore_object_get_hal(obj);
\r
2660 if (NULL == hal) {
\r
2661 err("NULL HAL. Unable to proceed");
\r
2664 return TCORE_RETURN_EINVAL;
\r
2667 cmd_str = g_strdup_printf("AT+CSCB?");
\r
2668 pending = tcore_pending_new(obj, 0);
\r
2669 atreq = tcore_at_request_new((const char *)cmd_str, "+CSCB", TCORE_AT_SINGLELINE);
\r
2670 if (NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
2671 err("Out of memory. Unable to proceed");
\r
2672 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
2674 //free memory we own
\r
2676 util_sms_free_memory(atreq);
\r
2677 util_sms_free_memory(pending);
\r
2680 return TCORE_RETURN_ENOMEM;
\r
2683 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
2685 tcore_pending_set_request_data(pending, 0, atreq);
\r
2686 tcore_pending_set_response_callback(pending, on_response_get_cb_config, NULL);
\r
2687 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
2688 tcore_pending_link_user_request(pending, ur);
\r
2689 tcore_hal_send_request(hal, pending);
\r
2694 return TCORE_RETURN_SUCCESS;
\r
2697 static TReturn set_cb_config(CoreObject *obj, UserRequest *ur)
\r
2699 gchar *cmd_str = NULL;
\r
2700 gchar *mids_str = NULL;
\r
2701 GString *mids_GString = NULL;
\r
2703 TcoreHal *hal = NULL;
\r
2704 TcoreATRequest *atreq = NULL;
\r
2705 TcorePending *pending = NULL;
\r
2706 const struct treq_sms_set_cb_config *setCbConfig = NULL;
\r
2707 int ctr1= 0, ctr2 =0;
\r
2708 unsigned short appendMsgId = 0;
\r
2712 setCbConfig = tcore_user_request_ref_data(ur, NULL);
\r
2713 hal = tcore_object_get_hal(obj);
\r
2714 if (NULL == setCbConfig || NULL == hal) {
\r
2715 err("NULL input. Unable to proceed");
\r
2716 dbg("setCbConfig: [%p], hal: [%p]", setCbConfig, hal);
\r
2719 return TCORE_RETURN_EINVAL;
\r
2722 dbg("bCBEnabled: %d, msgIdMaxCount: %x, msgIdCount: %d", setCbConfig->cbEnabled, setCbConfig->msgIdMaxCount, setCbConfig->msgIdRangeCount);
\r
2723 //util_hex_dump(" ", SMS_GSM_SMS_CBMI_LIST_SIZE_MAX, (void *)setCbConfig->msgIDs);
\r
2725 if (setCbConfig->cbEnabled == 2) { //Enable all CBS
\r
2726 cmd_str = g_strdup_printf("AT+CSCB=1");
\r
2727 } else if (setCbConfig->cbEnabled == 0) {//AT+CSCB=0: Disable CBS
\r
2728 cmd_str = g_strdup_printf("AT+CSCB=0");
\r
2730 mids_GString = g_string_new("AT+CSCB=0,\"");
\r
2732 for(ctr1 = 0; ctr1 < setCbConfig->msgIdRangeCount; ctr1++ ) {
\r
2733 if( setCbConfig->msgIDs[ctr1].net3gpp.selected == FALSE )
\r
2736 if( SMS_GSM_SMS_CBMI_LIST_SIZE_MAX <= (setCbConfig->msgIDs[ctr1].net3gpp.toMsgId - setCbConfig->msgIDs[ctr1].net3gpp.fromMsgId) ) {
\r
2737 mids_GString = g_string_new("AT+CSCB=1");
\r
2741 appendMsgId = setCbConfig->msgIDs[ctr1].net3gpp.fromMsgId;
\r
2743 for( ctr2 = 0; (ctr2 <= ((setCbConfig->msgIDs[ctr1].net3gpp.toMsgId) - (setCbConfig->msgIDs[ctr1].net3gpp.fromMsgId))); ctr2++ ) {
\r
2744 dbg( "%x", appendMsgId);
\r
2745 mids_GString = g_string_append(mids_GString, g_strdup_printf("%d", appendMsgId));
\r
2747 if (ctr2 == ((setCbConfig->msgIDs[ctr1].net3gpp.toMsgId) - (setCbConfig->msgIDs[ctr1].net3gpp.fromMsgId))) {
\r
2748 mids_GString = g_string_append(mids_GString, "\""); //Mids string termination
\r
2750 mids_GString = g_string_append(mids_GString, ",");
\r
2756 mids_str = g_string_free(mids_GString, FALSE);
\r
2757 cmd_str = g_strdup_printf("%s", mids_str);
\r
2761 pending = tcore_pending_new(obj, 0);
\r
2762 atreq = tcore_at_request_new((const char *)cmd_str, NULL, TCORE_AT_NO_RESULT);
\r
2763 if(NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
2764 err("Out of memory. Unable to proceed");
\r
2765 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
2767 //free memory we own
\r
2769 util_sms_free_memory(atreq);
\r
2770 util_sms_free_memory(pending);
\r
2773 return TCORE_RETURN_ENOMEM;
\r
2776 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
2778 tcore_pending_set_request_data(pending, 0, atreq);
\r
2779 tcore_pending_set_response_callback(pending, on_response_set_cb_config, NULL);
\r
2780 tcore_pending_link_user_request(pending, ur);
\r
2781 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
2782 tcore_hal_send_request(hal, pending);
\r
2787 return TCORE_RETURN_SUCCESS;
\r
2790 static TReturn set_mem_status(CoreObject *obj, UserRequest *ur)
\r
2792 gchar *cmd_str = NULL;
\r
2793 TcoreHal *hal = NULL;
\r
2794 TcoreATRequest *atreq = NULL;
\r
2795 TcorePending *pending = NULL;
\r
2796 const struct treq_sms_set_mem_status *setMemStatus = NULL;
\r
2797 int memoryStatus = 0;
\r
2801 setMemStatus = tcore_user_request_ref_data(ur, NULL);
\r
2802 hal = tcore_object_get_hal(obj);
\r
2803 if (NULL == setMemStatus || NULL == hal) {
\r
2804 err("NULL input. Unable to proceed");
\r
2805 dbg("setMemStatus: [%p], hal: [%p]", setMemStatus, hal);
\r
2808 return TCORE_RETURN_EINVAL;
\r
2811 dbg("memory_status: %d", setMemStatus->memory_status);
\r
2813 if(setMemStatus->memory_status < SMS_PDA_MEMORY_STATUS_AVAILABLE
\r
2814 || setMemStatus->memory_status > SMS_PDA_MEMORY_STATUS_FULL) {
\r
2815 err("Invalid memory_status");
\r
2818 return TCORE_RETURN_EINVAL;
\r
2821 switch (setMemStatus->memory_status) {
\r
2822 case SMS_PDA_MEMORY_STATUS_AVAILABLE:
\r
2823 memoryStatus = AT_MEMORY_AVAILABLE;
\r
2826 case SMS_PDA_MEMORY_STATUS_FULL:
\r
2827 memoryStatus = AT_MEMORY_FULL;
\r
2831 err("Invalid memory_status");
\r
2833 return TCORE_RETURN_EINVAL;
\r
2836 cmd_str = g_strdup_printf("AT+XTESM=%d", memoryStatus);
\r
2837 pending = tcore_pending_new(obj, 0);
\r
2838 atreq = tcore_at_request_new((const char *)cmd_str, NULL, TCORE_AT_NO_RESULT);
\r
2840 if (NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
2841 err("Out of memory. Unable to proceed");
\r
2842 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
2844 //free memory we own
\r
2846 util_sms_free_memory(atreq);
\r
2847 util_sms_free_memory(pending);
\r
2850 return TCORE_RETURN_ENOMEM;
\r
2853 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
2855 tcore_pending_set_request_data(pending, 0, atreq);
\r
2856 tcore_pending_set_response_callback(pending, on_response_set_mem_status, NULL);
\r
2857 tcore_pending_link_user_request(pending, ur);
\r
2858 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
2859 tcore_hal_send_request(hal, pending);
\r
2864 return TCORE_RETURN_SUCCESS;
\r
2867 static TReturn set_delivery_report(CoreObject *obj, UserRequest *ur)
\r
2869 struct tresp_sms_set_delivery_report respSetDeliveryReport = {0,};
\r
2871 respSetDeliveryReport.result = SMS_SUCCESS;
\r
2875 dbg("CP takes care of sending SMS ack to network for all classes of SMS. Sending default success.");
\r
2877 tcore_user_request_send_response(ur, TRESP_SMS_SET_DELIVERY_REPORT, sizeof(struct tresp_sms_set_delivery_report), &respSetDeliveryReport);
\r
2880 return TCORE_RETURN_SUCCESS;
\r
2883 static TReturn set_msg_status(CoreObject *obj, UserRequest *ur)
\r
2885 gchar *cmd_str = NULL;
\r
2886 TcoreHal *hal = NULL;
\r
2887 TcoreATRequest *atreq = NULL;
\r
2888 TcorePending *pending = NULL;
\r
2889 const struct treq_sms_set_msg_status *msg_status = NULL;
\r
2893 msg_status = tcore_user_request_ref_data(ur, NULL);
\r
2895 cmd_str = g_strdup_printf("AT+CRSM=178,28476,%d,4,%d", (msg_status->index+1), AT_EF_SMS_RECORD_LEN);
\r
2896 atreq = tcore_at_request_new((const char *)cmd_str, "+CRSM", TCORE_AT_SINGLELINE);
\r
2897 pending = tcore_pending_new(obj, 0);
\r
2898 if (NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
2899 err("Out of memory. Unable to proceed");
\r
2900 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
2902 //free memory we own
\r
2904 util_sms_free_memory(atreq);
\r
2905 util_sms_free_memory(pending);
\r
2908 return TCORE_RETURN_ENOMEM;
\r
2911 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
2913 tcore_pending_set_request_data(pending, 0, atreq);
\r
2914 tcore_pending_set_response_callback(pending, _response_get_efsms_data, NULL);
\r
2915 tcore_pending_link_user_request(pending, ur);
\r
2916 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
2917 tcore_hal_send_request(hal, pending);
\r
2922 return TCORE_RETURN_SUCCESS;
\r
2925 static TReturn get_sms_params(CoreObject *obj, UserRequest *ur)
\r
2927 gchar *cmd_str = NULL;
\r
2928 TcoreHal *hal = NULL;
\r
2929 TcoreATRequest *atreq = NULL;
\r
2930 TcorePending *pending = NULL;
\r
2931 const struct treq_sms_get_params *getSmsParams = NULL;
\r
2932 int record_len = 0 , *smsp_record_len = NULL;
\r
2936 getSmsParams = tcore_user_request_ref_data(ur, NULL);
\r
2937 hal = tcore_object_get_hal(obj);
\r
2938 if (NULL == getSmsParams || NULL == hal) {
\r
2939 err("NULL input. Unable to proceed");
\r
2940 dbg("getSmsParams: [%p], hal: [%p]", getSmsParams, hal);
\r
2943 return TCORE_RETURN_EINVAL;
\r
2946 smsp_record_len = tcore_plugin_ref_property(tcore_object_ref_plugin(obj), "SMSPRECORDLEN");
\r
2947 record_len = *smsp_record_len;
\r
2948 dbg("record len from property %d", record_len);
\r
2950 //AT+CRSM=command>[,<fileid>[,<P1>,<P2>,<P3>[,<data>[,<pathid>]]]]
\r
2951 cmd_str = g_strdup_printf("AT+CRSM=178,28482,%d,4,%d", (getSmsParams->index + 1), record_len);
\r
2953 dbg("cmd_str is %s",cmd_str);
\r
2955 atreq = tcore_at_request_new((const char *)cmd_str, "+CRSM", TCORE_AT_SINGLELINE);
\r
2956 pending = tcore_pending_new(obj, 0);
\r
2957 if (NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
2958 err("Out of memory. Unable to proceed");
\r
2959 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
2961 //free memory we own
\r
2963 util_sms_free_memory(atreq);
\r
2964 util_sms_free_memory(pending);
\r
2967 return TCORE_RETURN_ENOMEM;
\r
2970 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
2972 tcore_pending_set_request_data(pending, 0, atreq);
\r
2973 tcore_pending_set_response_callback(pending, on_response_get_sms_params, NULL);
\r
2974 tcore_pending_link_user_request(pending, ur);
\r
2975 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
2976 tcore_hal_send_request(hal, pending);
\r
2981 return TCORE_RETURN_SUCCESS;
\r
2984 static TReturn set_sms_params(CoreObject *obj, UserRequest *ur)
\r
2986 gchar *cmd_str = NULL;
\r
2987 char *encoded_data = NULL;
\r
2988 unsigned char *temp_data = NULL;
\r
2989 int SMSPRecordLen = 0;
\r
2991 TcoreHal *hal = NULL;
\r
2992 TcoreATRequest *atreq = NULL;
\r
2993 TcorePending *pending = NULL;
\r
2994 const struct treq_sms_set_params *setSmsParams = NULL;
\r
2995 int encoded_data_len = 0;
\r
2999 setSmsParams = tcore_user_request_ref_data(ur, NULL);
\r
3000 hal = tcore_object_get_hal(obj);
\r
3001 if (NULL == setSmsParams || NULL == hal) {
\r
3002 err("NULL input. Unable to proceed");
\r
3003 dbg("setSmsParams: [%p], hal: [%p]", setSmsParams, hal);
\r
3007 //EFsmsp file size is 28 +Y bytes (Y is alpha id size)
\r
3008 SMSPRecordLen = 28 + setSmsParams->params.alphaIdLen;
\r
3009 temp_data = calloc(SMSPRecordLen,1);
\r
3010 encoded_data = calloc(SMSPRecordLen*2 + 1,1);
\r
3012 _tcore_util_sms_encode_smsParameters(&(setSmsParams->params), temp_data, SMSPRecordLen);
\r
3014 util_byte_to_hex((const char *)temp_data, (char *)encoded_data,SMSPRecordLen);
\r
3016 encoded_data_len = ((SMSPRecordLen) * 2);
\r
3018 hal = tcore_object_get_hal(obj);
\r
3019 pending = tcore_pending_new(obj, 0);
\r
3021 dbg("alpha id len %d encoded data %s. Encoded data len %d",setSmsParams->params.alphaIdLen,encoded_data, encoded_data_len);
\r
3022 cmd_str = g_strdup_printf("AT+CRSM=220,28482,%d,4,%d,\"%s\"",(setSmsParams->params.recordIndex+1),SMSPRecordLen,encoded_data);
\r
3024 dbg("cmd str is %s",cmd_str);
\r
3025 atreq = tcore_at_request_new(cmd_str, "+CRSM:", TCORE_AT_SINGLELINE);
\r
3027 if (NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
3028 err("Out of memory. Unable to proceed");
\r
3029 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
3031 //free memory we own
\r
3033 util_sms_free_memory(atreq);
\r
3034 util_sms_free_memory(pending);
\r
3036 util_sms_free_memory(temp_data);
\r
3037 util_sms_free_memory(encoded_data);
\r
3040 return TCORE_RETURN_ENOMEM;
\r
3043 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
3045 tcore_pending_set_request_data(pending, 0,atreq);
\r
3046 tcore_pending_set_response_callback(pending, on_response_set_sms_params, NULL);
\r
3047 tcore_pending_link_user_request(pending, ur);
\r
3048 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
3049 tcore_hal_send_request(hal, pending);
\r
3052 util_sms_free_memory(temp_data);
\r
3053 util_sms_free_memory(encoded_data);
\r
3058 static TReturn get_paramcnt(CoreObject *obj, UserRequest *ur)
\r
3060 gchar *cmd_str = NULL;
\r
3061 TcoreHal *hal = NULL;
\r
3062 TcoreATRequest *atreq = NULL;
\r
3063 TcorePending *pending = NULL;
\r
3067 hal = tcore_object_get_hal(obj);
\r
3068 if (NULL == hal) {
\r
3069 err("NULL HAL. Unable to proceed");
\r
3072 return TCORE_RETURN_EINVAL;
\r
3075 //AT+CRSM=command>[,<fileid>[,<P1>,<P2>,<P3>[,<data>[,<pathid>]]]]
\r
3076 cmd_str = g_strdup_printf("AT+CRSM=192,28482");
\r
3077 atreq = tcore_at_request_new((const char *)cmd_str, "+CRSM", TCORE_AT_SINGLELINE);
\r
3078 pending = tcore_pending_new(obj, 0);
\r
3080 if (NULL == cmd_str || NULL == atreq || NULL == pending) {
\r
3081 err("NULL pointer. Unable to proceed");
\r
3082 dbg("cmd_str: [%p], atreq: [%p], pending: [%p]", cmd_str, atreq, pending);
\r
3084 //free memory we own
\r
3086 util_sms_free_memory(atreq);
\r
3087 util_sms_free_memory(pending);
\r
3090 return TCORE_RETURN_FAILURE;
\r
3093 util_hex_dump(" ", strlen(cmd_str), (void *)cmd_str);
\r
3095 tcore_pending_set_request_data(pending, 0, atreq);
\r
3096 tcore_pending_set_response_callback(pending, on_response_get_paramcnt, NULL);
\r
3097 tcore_pending_link_user_request(pending, ur);
\r
3098 tcore_pending_set_send_callback(pending, on_confirmation_sms_message_send, NULL);
\r
3099 tcore_hal_send_request(hal, pending);
\r
3104 return TCORE_RETURN_SUCCESS;
\r
3107 static struct tcore_sms_operations sms_ops = {
\r
3108 .send_umts_msg = send_umts_msg,
\r
3109 .read_msg = read_msg,
\r
3110 .save_msg = save_msg,
\r
3111 .delete_msg = delete_msg,
\r
3112 .get_storedMsgCnt = get_storedMsgCnt,
\r
3113 .get_sca = get_sca,
\r
3114 .set_sca = set_sca,
\r
3115 .get_cb_config = get_cb_config,
\r
3116 .set_cb_config = set_cb_config,
\r
3117 .set_mem_status = set_mem_status,
\r
3118 .get_pref_brearer = NULL,
\r
3119 .set_pref_brearer = NULL,
\r
3120 .set_delivery_report = set_delivery_report,
\r
3121 .set_msg_status = set_msg_status,
\r
3122 .get_sms_params = get_sms_params,
\r
3123 .set_sms_params = set_sms_params,
\r
3124 .get_paramcnt = get_paramcnt,
\r
3127 gboolean s_sms_init(TcorePlugin *plugin, TcoreHal *hal)
\r
3129 CoreObject *obj = NULL;
\r
3130 struct property_sms_info *data = NULL;
\r
3131 GQueue *work_queue = NULL;
\r
3132 int *smsp_record_len = NULL;
\r
3135 dbg("plugin: [%p]", plugin);
\r
3136 dbg("hal: [%p]", hal);
\r
3138 obj = tcore_sms_new(plugin, "umts_sms", &sms_ops, hal);
\r
3140 data = calloc(sizeof(struct property_sms_info), 1);
\r
3142 if (NULL == obj || NULL == data) {
\r
3143 err("Unable to initialize. Exiting");
\r
3144 s_sms_exit(plugin);
\r
3150 work_queue = g_queue_new();
\r
3151 tcore_object_link_user_data(obj, work_queue);
\r
3153 //Registering for SMS notifications
\r
3154 tcore_object_add_callback(obj, "\e+CMTI", on_event_class2_sms_incom_msg, NULL);
\r
3155 tcore_object_add_callback(obj, "\e+CMT", on_event_sms_incom_msg, NULL);
\r
3157 tcore_object_add_callback(obj, "\e+CDS", on_event_sms_incom_msg, NULL);
\r
3158 tcore_object_add_callback(obj, "+XSMSMMSTAT", on_event_sms_memory_status, NULL);
\r
3159 tcore_object_add_callback(obj, "+CMS", on_event_sms_memory_status, NULL);
\r
3161 tcore_object_add_callback(obj, "\e+CBMI", on_event_sms_cb_incom_msg, NULL);
\r
3162 tcore_object_add_callback(obj, "\e+CBM", on_event_sms_cb_incom_msg, NULL);
\r
3163 tcore_object_add_callback(obj, "+XSIM", on_event_sms_ready_status, NULL);
\r
3165 tcore_plugin_link_property(plugin, "SMS", data);
\r
3167 //storing smsp record length
\r
3168 smsp_record_len = calloc(sizeof(int), 1);
\r
3169 tcore_plugin_link_property(plugin, "SMSPRECORDLEN", smsp_record_len);
\r
3175 void s_sms_exit(TcorePlugin *plugin)
\r
3177 CoreObject *obj = NULL;
\r
3178 struct property_sms_info *data = NULL;
\r
3181 dbg("plugin: [%p]", plugin);
\r
3183 obj = tcore_plugin_ref_core_object(plugin, "umts_sms");
\r
3184 if (NULL == obj) {
\r
3185 err("NULL core object. Nothing to do.");
\r
3188 tcore_sms_free(obj);
\r
3190 data = tcore_plugin_ref_property(plugin, "SMS");
\r
3191 util_sms_free_memory(data);
\r