📄 smi_sms.c
字号:
/*
+-----------------------------------------------------------------------------
| Project : GSM-F&D (8411)
| Modul : SMI_SMS
+-----------------------------------------------------------------------------
| Copyright 2002 Texas Instruments Berlin, AG
| All rights reserved.
|
| This file is confidential and a trade secret of Texas
| Instruments Berlin, AG
| The receipt of or possession of this file does not convey
| any rights to reproduce or disclose its contents or to
| manufacture, use, or sell anything it may describe, in
| whole, or in part, without the specific written consent of
| Texas Instruments Berlin, AG.
+-----------------------------------------------------------------------------
| Purpose : This Modul defines the short message service functions
| for the Man Machine Interface.
+-----------------------------------------------------------------------------
*/
#ifndef SMI_SMS_C
#define SMI_SMS_C
#endif
#define ENTITY_SMI
/*==== INCLUDES ===================================================*/
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "typedefs.h"
#include "vsi.h"
#include "custom.h"
#include "gsm.h"
#include "prim.h"
#include "tok.h"
#include "message.h"
#include "aci_cmh.h"
#include "ksd.h"
#include "aca.h"
#include "smi.h"
/*==== CONSTANTS ==================================================*/
/*==== TYPES ======================================================*/
typedef enum
{
SMS_RSLT_FAIL = 0, /* SMS request failed with unspecific error */
SMS_RSLT_DELETE = 1 /* SMS is deleted from memory */
}
T_SMS_ACA_RSLT;
/*==== EXPORT =====================================================*/
/*==== VARIABLES ==================================================*/
LOCAL T_ACI_AT_CMD currSmsCmd = AT_CMD_NONE;
LOCAL T_ACA_NUMBER sca; /* service center address */
LOCAL T_ACA_NUMBER da; /* destination address */
LOCAL T_ACI_SM_DATA msg; /* short message */
LOCAL SHORT vp; /* validity period */
LOCAL UBYTE curIdx; /* current index of SMS list */
/* held by ACI */
/* t.b.d.: smLst and cbmLst used for call to function +CMGL */
/* t.b.d.: lastIdx and startIdx for call to function +CMGL */
/*==== PROTOTYPES==================================================*/
LOCAL void sms_CmgdRej (T_ACI_CMS_ERR err);
LOCAL void sms_CmgwRej (T_ACI_CMS_ERR err);
LOCAL void sms_CmgsRej (T_ACI_CMS_ERR err);
LOCAL void sms_CmssRej (T_ACI_CMS_ERR err);
/*==== FUNCTIONS ==================================================*/
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_SMS |
| STATE : code ROUTINE : sms_initialize |
+--------------------------------------------------------------------+
PURPOSE : This function is used to initialize this modul.
*/
GLOBAL void sms_initialize (BOOL isStartup)
{
currSmsCmd = AT_CMD_NONE;
sca.number[0] = NULL_TERM;
sca.type.ton = TON_Unknown;
sca.type.npi = NPI_IsdnTelephony;
da.number [0] = NULL_TERM;
da.type.ton = TON_Unknown;
da.type.npi = NPI_IsdnTelephony;
msg.len = 0;
vp = ACI_NumParmNotPresent;
curIdx = -1;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_SMS |
| STATE : code ROUTINE : rAT_sms_ready |
+--------------------------------------------------------------------+
PURPOSE : Indication by phonebook that sms is ready
*/
GLOBAL void rAT_sms_ready (void)
{
TRACE_FUNCTION ("rAT_sms_ready ()");
/* t.b.d.: initializing of smLst and cbmLst used for call to */
/* function +CMGL */
/* t.b.d.: initializing lastIdx, startIdx, curIdx for call */
/* to function +CMGL */
/* Does not work properly and disturbes testing
sAT_PlusCSMS (CMD_SRC_LCL, CSMS_SERV_GsmPh2);
sAT_PlusCPMS (CMD_SRC_LCL, SMS_STOR_Sm, SMS_STOR_Sm, SMS_STOR_Sm);
sAT_PlusCMGF (CMD_SRC_LCL, CMGF_MOD_Txt);
sAT_PlusCNMI (CMD_SRC_LCL,
CNMI_MT_NoSmsDeliverInd,
CNMI_BM_NoCbmInd,
CNMI_DS_NoSmsStatRpt);
*/
/*
sAT_PlusCNMI (CMD_SRC_LCL,
CNMI_MT_SmsDeliverInd,
CNMI_BM_Cbm,
CNMI_DS_NoSmsStatRpt);
*/
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_SMS |
| STATE : code ROUTINE : sms_CmgrRej |
+--------------------------------------------------------------------+
PURPOSE : This function is called to indicate that a message is not
read successfully from the preferred message storage.
<err>: error code
*/
LOCAL void sms_CmgrRej (T_ACI_CMS_ERR err)
{
TRACE_FUNCTION ("sms_CmgrRej ()");
ui_signal (UI_SIG_UNHND_CMS_ERR, err);
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_SMS |
| STATE : code ROUTINE : sms_startInputProc |
+--------------------------------------------------------------------+
PURPOSE : This function is called to start an input procedure
leading in execution of a short message transaction.
<proc>: specifies the transaction
returns: status information concerning the input
procedure progress
*/
GLOBAL T_ACI_RETURN sms_startInputProc (T_ACA_SMS_PROC proc)
{
UBYTE signal;
T_ACI_RETURN ret = AT_FAIL;
TRACE_FUNCTION ("sms_startInputProc ()");
if (mmi_data->serviceType EQ SRV_NORMAL)
{
switch (proc)
{
case (SMS_PROC_SEND):
signal = UI_SIG_SMS_PROC_SUBMIT;
break;
case (SMS_PROC_SEND_FROM_MEM):
signal = UI_SIG_SMS_PROC_SUBMIT_FROM_MEM;
break;
case (SMS_PROC_WRITE):
signal = UI_SIG_SMS_PROC_WRITE;
break;
case (SMS_PROC_READ):
signal = UI_SIG_SMS_PROC_READ;
break;
case (SMS_PROC_DELETE):
signal = UI_SIG_SMS_PROC_DELETE;
break;
case (SMS_PROC_LIST):
signal = UI_SIG_SMS_PROC_LIST;
break;
case (SMS_PROC_READ_SINGLE):
signal = UI_SIG_SMS_PROC_READ_SINGLE;
break;
}
ui_sms_signal (signal);
ret = AT_EXCT;
}
return ret;
}
/*
+--------------------------------------------------------------------+
| PROJECT : GSM-PS (6147) MODULE : SMI_SMS |
| STATE : code ROUTINE : sms_signal |
+--------------------------------------------------------------------+
PURPOSE : This function processs the SMS_SIG_XXX signals that are
send by the MMI_UI logic.
*/
static USHORT sms_siglevel = 0; /* used to indicate a recursion */
GLOBAL void sms_signal (UBYTE sigCode, ...)
{
va_list varpars;
CHAR buf[30];
sprintf (buf, "[%d], SMS-Signal: %d", sms_siglevel++, sigCode);
TRACE_EVENT (buf);
switch (sigCode)
{
/*
*---------------------------------------------------------------
* process the signal SMS_SIG_START_LIST_VIEW
*---------------------------------------------------------------
*/
case (SMS_SIG_START_LIST_VIEW):
{
curIdx = -1;
ui_sms_signal (UI_SIG_SMS_SHOW_LIST, 0, 1, "1234567890",
"First short message used for testing purposes");
}
break;
/*
*---------------------------------------------------------------
* process the signal SMS_SIG_NEXT_LIST_VIEW
*---------------------------------------------------------------
*/
case (SMS_SIG_NEXT_LIST_VIEW):
{
ui_sms_signal (UI_SIG_SMS_SHOW_LIST, 0, 2, "2345678901",
"Second short message used for testing purposes");
}
break;
/*
*---------------------------------------------------------------
* process the signal SMS_SIG_PREV_LIST_VIEW
*---------------------------------------------------------------
*/
case (SMS_SIG_PREV_LIST_VIEW):
{
ui_sms_signal (UI_SIG_SMS_SHOW_LIST, 1, 3,
"First cell broadcast message used for testing purposes");
}
break;
/*
*---------------------------------------------------------------
* process the signal SMS_SIG_START_MSG_VIEW
*---------------------------------------------------------------
*/
case (SMS_SIG_START_MSG_VIEW):
{
curIdx = -1;
ui_sms_signal (UI_SIG_SMS_SHOW_MSG,
"This is a testing short message which will be deleted unless the SMS functionalities are supported by ACI. \nThe quick brown fox jumps over the lazy dog. \nEnd");
}
break;
/*
*---------------------------------------------------------------
* process the signal SMS_SIG_DELETE
*---------------------------------------------------------------
*/
case (SMS_SIG_DELETE):
{
if (curIdx > -1)
{
/*
*-----------------------------------------------------------
* call to ACI function when no answer on a further ACI
* function call is expected
*-----------------------------------------------------------
*/
if (currSmsCmd EQ AT_CMD_NONE)
{
T_ACI_RETURN ret;
ret = sAT_PlusCMGD (CMD_SRC_LCL, curIdx);
currSmsCmd = AT_CMD_CMGD;
/*
*---------------------------------------------------------
* process result code of ACI function call
*---------------------------------------------------------
*/
switch (ret)
{
case (AT_CMPL):
rAT_OK (currSmsCmd);
break;
case (AT_EXCT):
break;
default:
rAT_PlusCMS (currSmsCmd, CMS_ERR_UnknownErr, NULL);
break;
}
}
else
/*
*---------------------------------------------------------
* error handling while waiting for answer on further ACI
* function call
*---------------------------------------------------------
*/
sms_CmgdRej (CMS_ERR_UnknownErr);
}
}
break;
/*
*---------------------------------------------------------------
* process the signal SMS_SIG_READ_SINGLE
*---------------------------------------------------------------
*/
case (SMS_SIG_READ_SINGLE):
{
/*
*-------------------------------------------------------------
* call to ACI function when no answer on a further ACI
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -