更新硬件SDK

This commit is contained in:
kerwincui
2023-03-04 03:44:56 +08:00
parent dcdf6e1b7c
commit e39d3d2f03
1900 changed files with 663153 additions and 0 deletions

View File

@@ -0,0 +1,440 @@
/******************************************************************************
* (C) Copyright 2018 AirM2M International Ltd.
* All Rights Reserved
*******************************************************************************
* Filename: cms_api.h
*
* Description: CMS (Communication Modem Service layer/task) external API & signal definition
*
* History:
*
* Notes:
* 1> This is the API file which should (only) included by other modules, such as APP task
* which need CMS serives.
* 2> Other modules (not runing in CMS task), must not include other CMS header files
******************************************************************************/
#ifndef __CMS_API_H__
#define __CMS_API_H__
#include <stdint.h>
#include "string.h"
#include "commontypedef.h"
#include "osasys.h"
#include "cms_def.h"
/******************************************************************************
*****************************************************************************
* CMS EXTERNAL COMMON MARCO
*****************************************************************************
******************************************************************************/
#define CMS_MAX_DELAY_MS 0xEFFFFFFF //without time out
/******************************************************************************
*****************************************************************************
* CMS EXTERNAL COMMON ENUM
*****************************************************************************
******************************************************************************/
/*
* Signal ID between CMS task and other tasks
*/
typedef enum _SIG_EPAT_cmsSigId_Enum
{
/*
* 0x0900 - 0x09FF, reserved for CMS task signals
*/
SIG_CMS_BASE = 0x0900,
/*
* 0x0900 - 0x090F, used between URAT/USB <-> CMS (AT CMD SRV)
*/
AT_CMD_SIGNAL_BASE = 0x0900,
SIG_AT_CMD_STR_REQ, //AtCmdStrReq
SIG_AT_CMD_CONTINUE_REQ, //AtCmdContinueReq
//SIG_AT_CMD_DATA_MODE_HS_REQ,
SIG_AT_CMD_DATA_MODE_HS_CNF,
AT_CMD_SIGNAL_END = 0x090F,
/*
* 0x0910 - 0x091F, used between APP (LWM2M/COAP/MQTT, etc) <-> CMS(AT CMD SRV) (cms_comm.h)
*/
APP_SIGNAL_BASE = 0x0910,
SIG_CMS_APPL_REQ, //CmsApplReq
SIG_CMS_APPL_CNF, //CmsApplCnf
SIG_CMS_APPL_IND, //CmsApplInd
APP_SIGNAL_END = 0x091F,
/*
* 0x0928 - 0x092F, used between SIMBIP <-> STK PS Proxy (psstk_bip.h)
*/
/*
* 0x0930 - 0x093F, used between CMS task <- IPC -> PHY for PHY/RF AT CMD (acmsgtype.h)
*/
/*
* 0x0940 - 0x095F, used for others CMS signal
*/
SIG_CMS_OTHER_BASE = 0x0940,
SIG_CMS_PHY_WAKEUP_READY_IND, //usless for CAT1, OsaEmptySignal, after PHY wake up ready, send this signal to CMS to schedule PS tasks
SIG_CMS_SYN_API_REQ, //CmsSynApiReq
SIG_CMS_HIGH_PRI_SYN_API_REQ, //CmsSynApiReq, this called with high priority without any block in CMS task
SIG_CMS_BLOCK_API_REQ, //CmsBlockApiReq
SIG_CMS_NON_BLOCK_API_REQ, //CmsNonBlockApiReq
SIG_CMS_APMU_SC_CALIBR_REQ, // C2A_SLOWCLOCK_CALIBR_REQ
SIG_CMS_APMU_SC_CALIBR_CANCEL_REQ,
SIG_CMS_DCXO_NVM_UPDT_REQ, // C2A_DCXO_NVM_UPDT_REQ
SIG_CMS_AUXADC_REQ, // C2A_AUXADC_REQ
SIG_CMS_SEND_UART_STR_REQ, // C2A_SEND_UART_STR_REQ
SIG_CMS_UTC_TIME_REQ, // C2A_UTC_TIME_REQ
SIG_CMS_CP_BTOFFSET_UPD_REQ, // CP indicate ap to update BT offset
SIG_CMS_APMU_COMM_TEST_REQ, // C2A_COMM_TEST_REQ
SIG_CMS_CP_PAGING_EVENT_IND_ISR, //CmsCpPagingEventIndIsr
SIG_CMS_SIM_HOT_SWAP_IND, //CmsSimHotSwapInd--fast signal
//SIG_CMS_PMU_PS_WAKEUP_IND = 0x0950,
SIG_CMS_PMU_PS_MODEM_START_IND, //CmsPmuInd
SIG_CMS_OTHER_END = 0x0960,
/*
* 0x0980 - 0x09FF, reserved for customer, an example
*/
CUSTOMER_SIGNAL_BASE = 0x0980,
SIG_CUSTOMER_MSG_CALLBACK,
SIG_CUSTOMER_REQ,
SIG_CUSTOMER_CNF,
SIG_CUSTOMER_IND,
#ifdef __USER_CODE__
SIG_CUSTOMER_LOG,
#endif
CUSTOMER_SIGNAL_END = 0x09FF
}cmsSigId;
/*
* CMS ERROR CODE, at_api/cms_api common return error code
*/
typedef enum CmsRetId_enum
{
CMS_RET_SUCC = 0,
CMS_FAIL = -1,
CMS_INVALID_PARAM = -2,
CMS_BUSY = -3,
CMS_LIST_FULL = -4,
CMS_LIST_NOT_FOUND = -5,
CMS_SEMP_ERROR = -6, //Semaphore not created/error
CMS_TIME_OUT = -7,
CMS_SIM_NOT_INSERT = -8, //SIM not inserted
CMS_OPER_NOT_SUPPROT = -9, //operation not supported
CMS_SIM_WRONG = -10, //SIM wrong, excute command while returned invalid data
CMS_NOT_POWER_ON = -11, //Not power on, maybe cfun0 state
CMS_SIM_BUSY = -12, //SIM busy, cannot process any instruction
CMS_NO_MEM = -13,
CMS_NO_RESOURCE = -14,
CMS_AT_SENT_FAIL = -15,
CMS_RET_CONTINUE = -127, /* specical ERR ID */
}_CmsRetId;
/*
* refer _CmsRetId
*/
typedef INT32 CmsRetId;
/*
* APP layer ID, value: 0 - 255
* CmsApplCnf->header.appId
*/
typedef enum CmsAppLayerId_Enum
{
APPL_BASE = 1,
APPL_NM = 2,
APPL_SOCKET = 3,
APPL_MQTT = 4,
APPL_CTW = 5,
APPL_LWM2M = 6,
APPL_HTTP = 7,
APPL_SSL = 8,
APPL_DTLS = 9,
APPL_ECSOC = 10,
APPL_ONENET = 11,
APPL_CTLWM2M = 12,
APPL_ADC = 13,
APPL_EXAMPLE = 14,
APPL_ECSRVSOC = 16,
APPL_DM = 17,
APPL_FWUPD = 18,
/*
* new APPL add here
*/
APPL_ALARM = 19,
APPL_FILE = 20,
APPL_REF_SOC = 21,
APPL_END = 0xFF
}CmsAppId;
/*
* ApplRetCode
* value of "ApplRetCnf->header.rc"
* Note:
* 1> If some APP has their own error code, need to defined in their own header file, such as: at_sock_task.h
* 2> But the "0" is reserved for SUCC
*/
typedef enum applRetCode_Enum
{
APPL_RET_SUCC = 0,
APPL_RET_FAIL = 1,
APPL_RET_NETWORK_FAIL = 2,
APPL_RET_END,
}ApplRetCode;
/*
* LWM2M error code
*/
typedef enum AT_LWM2M_ERROR
{
LWM2M_PARAM_ERROR = 1, //parameter error
LWM2M_SEMPH_ERROR = 2, //cannot create semph
LWM2M_CONFIG_ERROR = 3, //config error
LWM2M_NO_FREE_CLIENT = 4, //no free client
LWM2M_NO_FIND_CLIENT = 5, //no find client
LWM2M_OPERATION_NOT_SUPPORT = 6, //operation not support
LWM2M_ADDOBJ_FAILED = 7, //add object failed
LWM2M_NO_FIND_OBJ = 8, //no find object
LWM2M_DELOBJ_FAILED = 9, //delete object failed
LWM2M_NO_NETWORK = 10, //network not ready
LWM2M_INTER_ERROR = 11, //internal error
LWM2M_REG_BAD_REQUEST = 12, //register fail bad request
LWM2M_REG_FORBIDEN = 13, //register fail forbden
LWM2M_REG_PRECONDITION = 14, //register fail parameter error
LWM2M_REG_TIMEOUT = 15, //register fail timeout
LWM2M_SESSION_INVALID = 16, //create session fail
LWM2M_ALREADY_ADD = 17 //already has object
}_AtLwm2mError;
typedef enum AT_CTLWM2M_ERROR
{
CTLWM2M_OTHER_ERROR = 1,
CTLWM2M_PARAM_NUM_ERROR = 2,
CTLWM2M_PARAM_VALUE_ERROR = 3,
CTLWM2M_TERMINAL_NOT_READY = 4,
CTLWM2M_NOT_SUPPORT_SECURITY_MODE = 5,
CTLWM2M_OPERATION_NOT_SUPPORT = 6,
CTLWM2M_ADDOBJ_FAILED = 7,
CTLWM2M_PARAM_NOT_INT = 8,
CTLWM2M_DELOBJ_FAILED = 9,
CTLWM2M_SEMPH_ERROR = 10,
CTLWM2M_PARAM_LEN_OVERFLOW = 14,
CTLWM2M_PLATFORM_NOT_READY = 15,
CTLWM2M_DATALEN_NOT_EVEN = 17,
CTLWM2M_NOT_ALLOWED_CONNECT = 32,
CTLWM2M_NOT_SEND_COMMAND = 33,
CTLWM2M_CREATE_SESSION_FAILED = 34
}_AtCtLwm2mError;
/******************************************************************************
*****************************************************************************
* STRUCT
*****************************************************************************
******************************************************************************/
/*
* SigId: SIG_CMS_APPL_REQ
* Signal send to other APP task
*/
typedef struct CmsApplReq_Tag
{
struct {
UINT8 appId; //CmsAppId
UINT8 primId; //prim ID in each APP group
UINT16 srcHandler;
}header;
UINT8 body[];
}CmsApplReq;
/*
* SigId: SIG_CMS_APPL_CNF
* Signal sent from APP tasks
*/
typedef struct CmsApplCnf_Tag
{
struct {
UINT8 appId; //CmsAppId
UINT8 primId; //prim ID in each APP group
UINT16 srcHandler; //Handler
UINT16 rc;
UINT16 rsvd;
}header;
UINT8 body[];
}CmsApplCnf;
/*
* SigId: SIG_CMS_APPL_IND
* Signal sent from APP tasks
*/
typedef struct CmsApplInd_Tag
{
struct {
UINT8 appId; //CmsAppId
UINT8 primId; //prim ID in each APP group
/*
* As some indication is triggered by some AT request, in such as need to fill this "reqHandler",
* otherwise set to "BROADCAST_IND_HANDLER".
*/
UINT16 reqHandler;
}header;
UINT8 body[];
}CmsApplInd;
/*
* SigIg: SIG_PMU_IND
* Signal: send from pmu module to cms task
*/
typedef struct CmsPmuIndTag
{
UINT16 indId;
UINT16 reserved;
}CmsPmuInd;
/*
* SigIg: SIG_CMS_SIM_HOT_SWAP_IND
* Signal: send from APP tasks or ISR to cms task
*/
typedef struct CmsSimHotSwapIndTag
{
BOOL bSimPlugIn;// indicated whether the SIM card plugged in or out
UINT8 reserved1;
UINT16 reserved2;
}CmsSimHotSwapInd;
/*
* SigId: SIG_CUSTOMER_CNF, used as an example
*/
typedef struct custRetCnfTag
{
struct {
UINT16 cnfId;
UINT16 srcHandler; //Handler from CamCmiReq
UINT16 rc;
UINT16 reserved;
}header;
UINT8 body[];
}custRetCnf;
/*
* SigIg: SIG_CUSTOMER_IND, used as an example
*/
typedef struct custRetIndTag
{
struct {
UINT16 indId;
UINT16 srcHandler;
UINT16 rc;
UINT16 reserved;
}header;
UINT8 body[];
}custRetInd;
/******************************************************************************
*****************************************************************************
* CMS EXTERNAL API
*****************************************************************************
******************************************************************************/
/*
* init and create CMS task
*/
void cmsTaskInit(void);
/*
* APP send the "SIG_CMS_APPL_CNF" to CMS task
*/
CmsRetId applSendCmsCnf(UINT16 reqHandler, UINT16 rcCode, UINT8 appId, UINT8 primId, UINT16 primSize, void *pPrimBody);
/*
* APP send the "SIG_CMS_APPL_IND" to CMS task
*/
CmsRetId applSendCmsInd(UINT16 reqHandler, UINT8 appId, UINT8 primId, UINT16 primSize, void *pPrimBody);
/*
* Pmu Module send the "SIG_CMS_PMU_PS_WAKEUP_IND" to CMS task
*/
CmsRetId apmuWakeupPsNoneBlock(void);
/*
* Pmu Module send the "SIG_CMS_PMU_PS_MODEM_START_IND" to CMS task
*/
CmsRetId apmuSendCmsCpStartSig(void);
/*
* must remove later - TBD
*/
//CmsRetId appCallbackWithNoBlock(app_callback_fn function, void *ctx);;
/**
\fn void cmsStartPs(void)
\brief start protocl stack (tasks), if PS is not ready
\returns void
\Note: a) could only be called in task.
\ b) this is a blocked (sync) API, after PS task started, than return
\ c) if the caller not want to blocked, please call: cmsStartPsNonBlock()
*/
void cmsStartPs(void);
/**
\fn void cmsStartPs(void)
\brief start protocl stack (tasks), if PS is not ready
\returns void
\Note: a) could only be called in task.
\ b) this is a non blocked API, API return, not means PS is already
*/
void cmsStartPsNonBlock(void);
/**
\fn BOOL cmsIsPsReady(void)
\brief Whether protocol stack is ready to send/recv signals
\returns BOOL
*/
BOOL cmsIsPsReady(void);
#endif

View File

@@ -0,0 +1,52 @@
/****************************************************************************
*
* Copy right: 2017-, Copyrigths of AirM2M Ltd.
* File name: cms_comm.h
* Description: Communication Modem Service layer/task common header file
* History: Rev1.0 2018-08-06
* Note: common header which called by CMS task internally
****************************************************************************/
#ifndef __CMS_COMM_H__
#define __CMS_COMM_H__
#include "cms_api.h"
#include "mw_nvm_config.h"
#include "mw_nvm_info.h"
#include "mw_aon_info.h"
/******************************************************************************
*****************************************************************************
* CMS EXTERNAL COMMON MARCO
*****************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* CMS EXTERNAL COMMON ENUM
*****************************************************************************
******************************************************************************/
/******
* extern specification
******/
extern SignalQueue gCmsPendingSigQueue; // 8 bytes
#define pCmsPendingSigQue &gCmsPendingSigQueue
/******************************************************************************
*****************************************************************************
* CMS EXTERNAL API
*****************************************************************************
******************************************************************************/
#endif

View File

@@ -0,0 +1,256 @@
/******************************************************************************
* (C) Copyright 2018 AirM2M International Ltd.
* All Rights Reserved
*******************************************************************************
* Filename: cms_def.h
*
* Description: Communication Modem Service layer/task MARCO/COMMON definition
*
* History:
*
* Notes:
*
******************************************************************************/
#ifndef __CMS_DEF_H__
#define __CMS_DEF_H__
#include "commontypedef.h"
#include "osasys.h"
/******************************************************************************
*****************************************************************************
* CMS COMMON MARCO
*****************************************************************************
******************************************************************************/
/*
* CMS task stack size & queue size
*/
#define CMS_TASK_STACK_SIZE 3072
#define CMS_TASK_QUEUE_SIZE 30 /* Enlarge from 20 to 30,
* Bug #3978: as some PS AT CMD maybe trigger several (reach to 15) CMI CNF signal to
* CMS task, (e.g., AT+CGPADDR, if 15 bearer defined by tester), in the case,
* 20 (several CMI IND at same time) queue size maybe not enough, so enlarge to 30
*/
/******************************************************************************
* SRC HANDLER
* 15 12 11 8 7 5 4 0
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
* | R | channel ID | SUB AT ID | TID |
* +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
* Note:
* 1> Channel ID:
* Channel ID 0, is reserved for internal.
* Channel ID 1, used for AT CMD from UART (default).
* 2> SUB AT ID
* If several AT CMD correlated with same CMI REQ ID, this "AT ID" is used to distinguish
* which AT CMD when CMI CNF comes; so MAX 8 AT CMD could use one same CMI REQ ID
* 3> TID: AT Asynchronous Timer index
* Used to index AT CMD guard timer
******************************************************************************/
/*
* Internal handler, channel ID set to 0.
* Internal valid value: 0x01 ~ 0xFF
*/
#define BROADCAST_IND_HANDLER 0x0001
#define CMS_REQ_HANDLER 0x0060
#define PS_DIAL_REQ_HANDLER 0x0061
#define PS_STK_REQ_RSP_HANDLER 0x0062
//#define APP_SYNC_REQ_HANDLER 0x0063
#define PS_LPP_REQ_RSP_HANDLER 0x0064
#define PS_DIAL_PPP_REQ_HANDLER 0x0065
/*
* used in ps_syn_cnf.c, AppPsBlockReq
* Handler from: [0x0020 ~ 0x0030)
*/
#define APP_PS_BLOCK_REQ_NUM 16
#define APP_PS_BLOCK_REQ_START_HANDLER 0x0020
#define APP_PS_BLOCK_REQ_END_HANDLER (APP_PS_BLOCK_REQ_START_HANDLER + APP_PS_BLOCK_REQ_NUM - 1)
/*
* used in CAM, this reserved for CAM SYNC API
*/
#define CAM_CMI_SYNC_REQ_NUM 16
#define CAM_CMI_SYNC_REQ_START_HANDLER 0x0030
#define CAM_CMI_SYNC_REQ_END_HANDLER (CAM_CMI_SYNC_REQ_START_HANDLER + CAM_CMI_SYNC_REQ_NUM - 1)
#define CMS_SET_SRC_HANDLER(TID, subAtId, chanId) ((UINT16)(((TID)&0x1F) | (((subAtId)<<5)&0xE0) | (((chanId)<<8)&0xF00)))
#define CMS_GET_HANDLER_TID(srcHandler) ((srcHandler) & 0x1F)
#define CMS_GET_HANDLER_SUB_ATID(srcHandler) (((srcHandler) & 0xE0) >> 5)
#define CMS_GET_HANDLER_CHAN_ID(srcHandler) (((srcHandler) & 0xF00) >> 8)
#define CMS_GET_UINT16_HANDLER(srcHandler) ((srcHandler) & 0xFFFF)
/******************************************************************************
* 3 bits SUB AT ID, value: 0 - 7
* 1> 0 is default value
* 2> 0 - 4, used for EC
* 3> 5,6,7, used for REF
******************************************************************************/
/*
* CMS default SUB AT ID
* CMS_GET_HANDLER_SUB_ATID()
*/
#define CMS_DEFAULT_SUB_AT_ID 0
#define CMS_EC_MAX_SUB_AT_ID 4
/*
* SUB AT ID, used for REF AT CMD
*/
#define CMS_REF_SUB_AT_1_ID 5
#define CMS_REF_SUB_AT_2_ID 6
#define CMS_REF_SUB_AT_3_ID 7
/*
* ECBCINFO called by ECBCINFO/QENG/CESQ/CSQ/QCELL, so need use different sub Id to diff it.
* the default sub Id is used in ECBCINFO
* CSQ/CESQ all mapped: CMI_MM_GET_EXTENDED_SIGNAL_QUALITY_REQ, so need this "sub Id" to diff it
*/
typedef enum AtcSignalQualitySubAtId_enum
{
ATEC_SIGNAL_ECBCINFO_SUB_AT = CMS_DEFAULT_SUB_AT_ID,
ATEC_SIGNAL_QUALITY_CSQ_SUB_AT = 1,
ATEC_SIGNAL_QUALITY_CESQ_SUB_AT = 2,
ATEC_SIGNAL_QCELL_SUB_AT = CMS_REF_SUB_AT_1_ID,
ATEC_SIGNAL_QENG_SUB_AT = CMS_REF_SUB_AT_2_ID,
}AtcSignalQualitySubAtId;
/******************************************************************************
* CMI REQ/CNF/IND ID:
* 15 11 0
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
* | SG ID | PRIM ID |
* +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
*
* CMI: CIOT Modem Interface
******************************************************************************/
#define CMS_GET_CMI_SG_ID(reqId) (((reqId)>>12)&0x000F)
#define CMS_GET_CMI_PRIM_ID(reqId) ((reqId)&0x0FFF)
#define CMS_SET_CMI_REQ_CNF_ID(sgId, primId) ((UINT16)(((sgId)<<12)|((primId)&0x0FFF)))
/*
* STR end byte: '\0'
*/
#define CMS_NULL_CHAR_LEN 1
/******************************************************************************
*****************************************************************************
* CMS COMMON ENUM
*****************************************************************************
******************************************************************************/
/*
* CMS channel ID, MAX: 15, now only enabled 5 ID
* 1> 1st: 0, is reserved for: AT indication, and internal using
* 2> 2nd: 1, default AT channel, used for AT CMD send from USB.
* 3> 3rd: 2, reserved for AT SDK API (RIL API).
* 4> 4th, 3, AT channel, used for AT CMD send from UART
*/
typedef enum
{
CMS_CHAN_RSVD = 0,
CMS_CHAN_IND = CMS_CHAN_RSVD,
CMS_CHAN_1 = 1,
CMS_CHAN_DEFAULT = 1,
CMS_CHAN_USB = 1, //default is used for ATCMD from USB
AT_CHAN_DEFAULT = 1,
CMS_CHAN_2 = 2,
CMS_RIL_API_CHAN = 2, //channel reserved for SDK API (RIL API)
AT_RIL_API_CHAN = 2,
CMS_CHAN_3 = 3,
CMS_CHAN_UART = 3, //used for ATCMD from UART
/*
* still/only channel 4 are used for other purposes.
*/
CMS_CHAN_4 = 4,
CMS_CHAN_NUM = 5,
CMS_CHAN_MAX = 15
}cmsChanId;
#define MID_WARE_USED_AT_CHAN_NUM 4 //(CMS_CHAN_NUM-1)
/*
* CMS task OSA timer ID defination:
*
* 16 bits timerID
* 15 12 0
* +-------+---------------------+
* | modId | timerId in modId |
* +-------+---------------------+
* MSB 4 bits: use to distinguish which sub-module in CMS task, so MAX 16 sub-modes
*/
typedef enum CmsOsaTimerSubModId_enum
{
CMS_TIMER_AT_SUB_MOD_ID = 0,
CMS_TIMER_PS_LPP_SUB_MOD_ID = 1,
CMS_TIMER_APP_PS_BLOCK_REQ_SUB_MOD_ID = 2,
//...
CMS_TIMER_SUB_MOD_ID_MAX = 15
}CmsOsaTimerSubModId;
#define CMS_SET_OSA_TIMER_ID(subMid, subTid) (UINT16)((((subMid)<<12)&0xF000) | ((subTid)&0xFFF))
#define CMS_GET_OSA_TIMER_SUB_MOD_ID(timerId) (((timerId)>>12)&0x0F)
/******************************************************************************
* cmsDeepPmuCtrlBitmap
* Whether CMS task allow the PMU enter the hibernate/sleep2 state (only AON memory)
* Each sub-module has a bit to indicate whether allow it:
* 0 - allow, 1 - not allow;
* So when all bits is set to 0 (cmsDeepPmuCtrlBitmap == 0) just means CMS task
* is in IDLE state, and allow to enter hibernate state
******************************************************************************/
extern UINT32 cmsDeepPmuCtrlBitmap;
/*
*/
typedef enum CmsDeepPmuVoteSubMod_Enum
{
CMS_AT_UART_CHAN_PMU_MOD,
//...
CMS_PMU_MOD_MAX = 32
}CmsDeepPmuVoteSubMod;
#define CMS_SUB_MOD_ALLOW_DEEP_PMU(subMod) \
do { \
if ((subMod)<32 && (subMod)>=0) \
(cmsDeepPmuCtrlBitmap &= (~(1<<(subMod)))); \
else \
OsaCheck(FALSE, subMod, cmsDeepPmuCtrlBitmap, 0); \
}while(FALSE)
#define CMS_SUB_MOD_NOT_ALLOW_DEEP_PMU(subMod) \
do { \
if ((subMod)<32 && (subMod)>=0) \
(cmsDeepPmuCtrlBitmap |= (1<<(subMod))); \
else \
OsaCheck(FALSE, subMod, cmsDeepPmuCtrlBitmap, 0); \
}while(FALSE)
#endif

View File

@@ -0,0 +1,189 @@
/******************************************************************************
* (C) Copyright 2018 AirM2M International Ltd.
* All Rights Reserved
*******************************************************************************
* Filename: cms_util.h
*
* Description: CMS (Communication Modem Service) utility header file
*
* History:
*
* Notes:
*
******************************************************************************/
#ifndef __CMS_UTIL_H__
#define __CMS_UTIL_H__
#include "cms_api.h"
/******************************************************************************
*****************************************************************************
* MARCO
*****************************************************************************
******************************************************************************/
/*
* 4 bytes MAGIC words
*/
#define CMS_MAGIC_WORDS 0xA4B6C9D2
#define CMS_MAGIC_WORDS_SIZE 4
#define CMS_SYN_API_BODY_MAX 1024
typedef CmsRetId (*CmsSynCallback)(UINT16 inputSize, void *pInput, UINT16 outputSize, void *pOutput);
//typedef void (*CmsBlockCallback)(CmsBlockApiInfo *pApiInfo);
typedef void (*CmsBlockCallback)(void *pArg);
typedef void (*CmsNonBlockCallback)(UINT16 paramSize, void *pParam);
/******************************************************************************
*****************************************************************************
* ENUM
*****************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* STRUCT
*****************************************************************************
******************************************************************************/
/*
* SIG: SIG_CMS_SYN_API_REQ
* API called in CMS task, and without timeout
*/
typedef struct CmsSynApiInfo_Tag
{
osSemaphoreId_t sem;
CmsRetId retCode; //CmsRetId
CmsSynCallback cmsSynFunc;
UINT16 inputSize;
UINT16 outputSize;
UINT32 hdrMagic;
/*
* +----------------------+--------------+---------+--------------+-------+
* | CmsSynApiInfo | input PARAM | MAGIC | output PARAM | MAGIC |
* +----------------------+--------------+---------+--------------+-------+
* ^ ^ ^ ^ ^
* pApiInfo param pInMagic pOutAddr pOutMagic
*/
UINT8 param[]; /*input + output parameters, and should 4 bytes aligned*/
}CmsSynApiInfo; //20 bytes
typedef struct CmsSynApiReq_Tag
{
CmsSynApiInfo *pApiInfo;
}CmsSynApiReq;
/*
* SIG: SIG_CMS_BLOCK_API_REQ
* API called in CMS task, and timeout setting
*/
typedef struct CmsBlockApiInfo_Tag
{
osSemaphoreId_t sem;
CmsRetId retCode; //CmsRetId
CmsBlockCallback cmsBlockFunc;
UINT32 timeOutMs; //timeOut in MILLISECONDS
UINT16 inputSize;
UINT16 outputSize;
void *pInput;
void *pOutput;
}CmsBlockApiInfo; //28 bytes
typedef struct CmsBlockApiReq_Tag
{
CmsBlockApiInfo *pApiInfo;
}CmsBlockApiReq;
/*
* SIG: SIG_CMS_NON_BLOCK_API_REQ
* API called in CMS task
*/
typedef struct CmsNonBlockApiReq_Tag
{
CmsNonBlockCallback cmsNonBlockFunc;
UINT16 paramSize;
UINT16 rsvd;
UINT8 param[];
}CmsNonBlockApiReq;
/******************************************************************************
*****************************************************************************
* API
*****************************************************************************
******************************************************************************/
INT8 cmsDigitCharToNum(UINT8 ch);
BOOL cmsHexStrToUInt(UINT32 *pOutput, const UINT8 *pHexStr, UINT32 strMaxLen);
BOOL cmsDecStrToUInt(UINT32 *pOutput, const UINT8 *pDecStr, UINT32 strMaxLen);
BOOL cmsBinStrToUInt(UINT32 *pOutput, const UINT8 *pBinStr, UINT32 strMaxLen);
BOOL cmsHexStrToInt(INT32 *pOutput, const UINT8 *pHexStr, UINT32 strMaxLen);
BOOL cmsDecStrToInt(INT32 *pOutput, const UINT8 *pDecStr, UINT32 strMaxLen);
BOOL cmsBinStrToInt(INT32 *pOutput, const UINT8 *pBinStr, UINT32 strMaxLen);
BOOL cmsBePureIntStr(CHAR * str);
/*
* "1234" -> {0x12, 0x34}
*/
INT32 cmsHexStrToHex(UINT8 *pOutput, UINT32 outBufSize, const CHAR *pHexStr, UINT32 strMaxLen);
/*
* {0x12, 0x34} -> "1234"
*/
INT32 cmsHexToHexStr(CHAR *pOutStr, UINT32 outBufSize, const UINT8 *pHexData, UINT32 hexLen);
INT32 cmsHexToLowHexStr(CHAR *pOutStr, UINT32 outBufSize, const UINT8 *pHexData, UINT32 hexLen);
/*
* "AbcDef" -> "ABCDEF"
*/
BOOL cmsStrToUpper(CHAR* pStr);
/*
* 3 -> '3'
*/
INT8 cmsNumToChar(UINT8 num);
/*
* CMS API CALL, API called in CMS task
*/
CmsRetId cmsSynApiCall(CmsSynCallback synFunc, UINT16 inputSize, void *pInput, UINT16 outputSize, void *pOutPut);
CmsRetId cmsHighPriSynApiCall(CmsSynCallback synFunc, UINT16 inputSize, void *pInput, UINT16 outputSize, void *pOutPut);
CmsRetId cmsBlockApiCall(CmsBlockCallback blockFunc, UINT16 inputSize, void *pInput, UINT16 outputSize, void *pOutPut, UINT32 timeOutMs);
CmsRetId cmsNonBlockApiCall(CmsNonBlockCallback nonBlockFunc, UINT16 inputSize, void *pInput);
/*
*/
void cmsProcHighPriSynApiReqSig(CmsSynApiReq *pSynApiReq);
/******************************************************************************
* psCamCmiReq
* Description: PS CAM CMI request, reques/access PS service
* input: UINT16 srcHdr;
* UINT8 sgId; // CamSgIdEnum
* UINT16 primId; // prim ID
* UINT16 primSize; //prim body size
* void *primBody; //prim body
* output: void
* Comment:
* 1> Before send the signal, need to check whether PS task is ready, if not, need to
* start PS firstly
* 2> This API could only be called in CMS task
******************************************************************************/
void psCamCmiReq(UINT16 srcHdr, UINT8 sgId, UINT16 primId, UINT16 primSize, void *primBody);
#endif

View File

@@ -0,0 +1,66 @@
#ifndef __CMS_NET_LIGHT_H__
#define __CMS_NET_LIGHT_H__
/******************************************************************************
******************************************************************************
Copyright: - 2017- Copyrights of AirM2M Ltd.
File name: - cmsnetlight.h
Description: - the head file for cmsnetlight.c
History: - 03/30/2020, Originated by xlhu
******************************************************************************
******************************************************************************/
#include "cms_util.h"
#include "osasys.h"
/******************************************************************************
*****************************************************************************
* MARCO
*****************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* STRUCT
*****************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* ENUM
*****************************************************************************
******************************************************************************/
typedef enum CmsNetlightMode_Tag
{
NET_LIGHT_DISABLE = 0,
NET_LIGHT_ENABLE = 1
}
CmsNetlightMode;
typedef enum NetlightFlickerMode_Tag
{
NETLIGHT_FLICKER_NONE = 0,
NETLIGHT_FLICKER_FAST = 1,
NETLIGHT_FLICKER_SLOW = 2,
}
NetlightFlickerMode;
/******************************************************************************
******************************************************************************
* External global variable
******************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* Functions
*****************************************************************************
******************************************************************************/
CmsRetId cmsNetlightMonitorCmiInd(const SignalBuf *indSignalPtr);
CmsRetId cmsNetlightMonitorCmiCnf(const SignalBuf *cnfSignalPtr);
#endif

View File

@@ -0,0 +1,226 @@
#ifndef __PS_DIAL_H__
#define __PS_DIAL_H__
/******************************************************************************
******************************************************************************
Copyright: - 2017- Copyrights of AirM2M Ltd.
File name: - psdial.h
Description: - DIAL functions
History: - 04/12/2018
******************************************************************************
******************************************************************************/
#include "cms_api.h"
#include "osasys.h"
#include "cmicomm.h"
#include "lwip/ip_addr.h"
/******************************************************************************
*****************************************************************************
* MARCO
*****************************************************************************
******************************************************************************/
/*
* whether auto dial after power on
*/
#ifndef AT_POWER_ON_AUTO_DIAL
#define AT_POWER_ON_AUTO_DIAL 1
#endif
/*
* DNS config parameter
*/
#define PS_DAIL_DEFAULT_DNS_NUM 2
#define PS_DAIL_IPV4_ADDR_LEN 4
#define PS_DAIL_IPV6_ADDR_LEN 16
/******************************************************************************
*****************************************************************************
* STRUCT
*****************************************************************************
******************************************************************************/
/*
* PS DAIL context
*/
typedef struct PsDialContext_Tag
{
UINT32 psTaskCreated : 1; /* Whether PS tasks (CCM/NAS/RRC/AS/UICC) created.
* 1> As PS tasks is not created when power on/wake up from deep sleep by default.
* Here, involved a flag to record it.
* 2> When APP/AT need PS service, need to check this flag firstly, and if PS task
* is not created, need let/trigger PSDAIL to create PS tasks.
*/
UINT32 psTaskReady : 1; /* Whether PS tasks is ready to be accessed.
* 1> If first power on, after PS task created, then set it to TRUE
* 2> If wake up from deep sleep. after PS task created and PS wake up procedure done, then set it
* to TRUE.
*/
UINT32 psNeedWakeup : 1; /* Whether PS task need wake up before set to "Ready"
* 1> Set to TRUE, when AP wake up from deep sleep, and PS task has created before.
* 2> Set to TRUE, when AP OS (IDLE task) called enter deep sleep callback to cover the case:
* enter deep sleep failed, if a interrupt comes during enter deep sleep procedure.
* 3> Set to TRUE, after PS task woken up.
* Note:
* 1> "psTaskReady" & "psNeedWakeup" can not both set to TRUE, just
* a) if "psNeedWakeup" = TRUE, "psTaskReady" must be FALSE
* b) if "psTaskReady" = TRUE, "psNeedWakeup" must be FALSE
* c) if "psNeedWakeup" = FALSE, "psTaskReady" could be TRUE or FALSE
*/
//UINT32 bNetifActed : 1; //netif/PDP state, in fact this flag should set in LWIP net-manager side
UINT32 bActIfDuringWakeup : 1; /* whether active bearer/netif during sleep2/hib wake up, proc:
* 1> CGCONTRDP, to read all default bearers, linkup netmgr/lwip
* 2> CGSCONTRDP, to read all dedicated bearers, linkup netmgr/lwip
* 3> CGTFTRDP, to read all TFT config, config to netmgr/lwip
* Set this value to FALSE, after all these done
*/
UINT32 bSilentReset : 1;
UINT32 rsvd0 : 3;
UINT32 actingCid : 8; /* current activating CID */
UINT32 actingCidCgevReason: 4; /* CmiPsPdnTypeReason, 1> psdail need it decide whether need to init another PDP, 2> netif also need it */
UINT32 psConnStatus : 1; /* 0 - RRC IDLE, 1- RRC connected */
UINT32 bTrafficIdleTriggerTau:1; /* When Pdcp monitor traffic idle after a <idle_time> (set by AT+ECSCLKEX), notify psDial, then do as follows:
* 1> Trigger UE to force to go idle
* 2> After UE go idle, trigger a TAU to sync with NW.
* 3> False: no need to trigger TAU after go idle as above.
* True : need to trigger TAU after go idle as above.
*/
UINT32 rsvd1 : 10;
CmiSimImsiStr ueImsi; //20 bytes
}PsDialContext; //24 bytes
/*
* PS DIAL AON info, save to flash, when enter HIB
*/
typedef struct PsDialAonInfo_Tag
{
UINT32 cfunState : 8; /* CFUN state, CmiFuncValueEnum */
UINT32 ceregState : 4; /* CEREG, CmiCeregStateEnum */
UINT32 psTaskCreatedBefore : 1; /* Whether PS task has been created before.
* 1> Set to TRUE, once PS task created.
* 2> No way to set FALSE.
* Note: need it to decide whether need PS wakeup prcedure when PS task created
*/
UINT32 bSmsReady : 1; /* Whether SMS init ready or not */
UINT32 rsvd0 : 2;
UINT32 rsvd1 : 16;
}PsDialAonInfo;
/*
* PS DAIL DNS CONFIG
* DNS order:
* 1> NW configed DNS;
* 2> DNS configed in NVM by AT CMD: AT+ECDNSCFG
* 3> default configed DNS indexed by UE IMSI
*/
typedef struct PsDialDnsCfg_Tag
{
UINT8 ipv4DnsNum ; //ipv4 valid dns num
UINT8 ipv6DnsNum ; //ipv6 valid dns num
UINT16 rsvd;
ip4_addr_t ipv4Dns[PS_DAIL_DEFAULT_DNS_NUM];
ip6_addr_t ipv6Dns[PS_DAIL_DEFAULT_DNS_NUM];
}PsDialDnsCfg; //44 bytes
typedef enum {
PS_DIAL_NET_TYPE_IPV4 = 0,
PS_DIAL_NET_TYPE_IPV6 = 1,
PS_DIAL_NET_TYPE_IPV4V6 = 2,
PS_DIAL_NET_TYPE_INVALID = 3,
}PsDialNetType;
/******************************************************************************
******************************************************************************
* External global variable
******************************************************************************
******************************************************************************/
/*
* This context save in AON memory
*/
extern PsDialAonInfo *pDialAonInfo;
/*
* PS dial static context
*/
extern PsDialContext psDialCtx;
/******************************************************************************
*****************************************************************************
* Functions
*****************************************************************************
******************************************************************************/
CmsRetId psDialProcCmiInd(const SignalBuf *indSignalPtr);
CmsRetId psDialProcCmiCnf(const SignalBuf *cnfSignalPtr);
void psDailGetCfgDnsByUeImsi(PsDialDnsCfg *pDnsCfg);
/*
* check whether netif is acted
*/
//BOOL psDialLwipNetIfIsAct(void);
BOOL psDailBeCfun1State(void);
BOOL psDialBeActNetifDoneDuringWakeup(void);
/******************************************************************************
* psDialSetAdptDnsServerInfo
* Description: Set DNS server address
* input: UINT8 cid, PsDialDnsCfg *pPcoDns, PsDialDnsCfg *pAdptDns, BOOL bWakeUp
* output: BOOL
* Comment:
******************************************************************************/
BOOL psDialSetAdptDnsServerInfo(UINT8 cid, UINT8 type, PsDialDnsCfg *pPcoDns, PsDialDnsCfg *pAdptDns, BOOL bWakeUp);
/*
* return current CFUN state: CMI_DEV_MIN_FUNC/CMI_DEV_FULL_FUNC/CMI_DEV_TURN_OFF_RF_FUNC
*/
UINT8 psDialGetCfunState(void);
/*
* return current RRC connection state: 0 - IDLE state, 1 - connected state
*/
UINT8 psDialGetPsConnStatus(void);
/*
* return CEREG state: CmiCeregStateEnum
* CMI_PS_NOT_REG = 0,
* CMI_PS_REG_HOME = 1,
* CMI_PS_NOT_REG_SEARCHING = 2,
* CMI_PS_REG_DENIED = 3,
* CMI_PS_REG_UNKNOWN = 4,
* CMI_PS_REG_ROAMING = 5,
* CMI_PS_REG_SMS_ONLY_HOME = 6, // not applicable
* CMI_PS_REG_SMS_ONLY_ROAMING = 7, // not applicable
* CMI_PS_REG_EMERGENCY = 8,
* CMI_PS_REG_CSFB_NOT_PREFER_HOME = 9, // not applicable
* CMI_PS_REG_CSFB_NOT_PREFER_ROAMING = 10 //not applicable
*/
UINT8 psDialGetCeregState(void);
/*
* PS dial init, called when CMS task started
*/
void psDialInit(void);
/*
* Request CMI/PS service, all CMS sub-modules must call it to request PS service
*/
void psCamCmiReq(UINT16 srcHdr, UINT8 sgId, UINT16 primId, UINT16 primSize, void *primBody);
/*
* return PS SMS init ready or not
*/
BOOL psDialBeSmsReady(void);
#endif

View File

@@ -0,0 +1,123 @@
#ifndef __PS_DIAL_NET_H__
#define __PS_DIAL_NET_H__
/******************************************************************************
******************************************************************************
Copyright: - 2017- Copyrights of AirM2M Ltd.
File name: - psdial_net.h
Description: - psdial net header
History: - 2021/11/17, Originated by xlhu
******************************************************************************
******************************************************************************/
#include "commontypedef.h"
#include "cms_api.h"
#include "networkmgr.h"
/******************************************************************************
*****************************************************************************
* MARCO
*****************************************************************************
******************************************************************************/
#define PSDIAL_NET_OPT
/******************************************************************************
*****************************************************************************
* STRUCT
*****************************************************************************
******************************************************************************/
#ifdef PSDIAL_NET_OPT
/*
* PS dial static context in MSMB
*/
typedef struct PsDialNetStaticContext_Tag
{
#if 0
UINT32 ignoreUrc :1; /* Whether need ignore URC: +ECNETDEVSTATUS: %d
* 1> During the NET CID re-bind (AT+ECNETDEVCTL change the CID) procedure,
* should not report the first unbind URC for old CID.
* 2> During the PDP re-act procedure, also should not report all URC
*/
UINT32 needRebindAfterUnbindInd :1; /* Whether need to re-bind (NetMgrLanCtrl()) the CID, after recv: NmAtiLanInfo
* which indicated the OLD cid unbind. used in case:
* 1> the bind CID changed by AT+ECNETDEVCTL, before bind new, need waiting for
* old unbind
* 2> PDP re-act, should wait for old CID LAN unbind, before bind new CID, in fact
* here "old CID" = "new CID"
* 3> the new bind CID in: "MWAonNetParamCfg.cid"
* In fact, not need it, always need to check whether need to bind after recv: NmAtiLanInfo
*/
#endif
UINT32 bBindOnceProc :1; /* whether current procedure is tigger by AT+ECNETDEVCTL, which OPT is:
* MW_AON_NET_DEV_CTL_OP_BIND_CID_ONCE
*/
UINT32 rsvd :31;
}PsDialNetStaticContext;
#endif
/******************************************************************************
******************************************************************************
* External global variable
******************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* Functions
*****************************************************************************
******************************************************************************/
/*
* psdial net unbind cid for lwip
*/
//void psDialNetDevCtrlUnBindCid(UINT8 cid);
/*
* psdial net bind cid for lwip
*/
//void psDialNetDevCtrlBindCid(UINT8 newCid);
/*
* psdial net process device control
*/
void psDialNetDevCtl(UINT8 op, UINT8 cid, BOOL bUrcEn);
/*
* psdial net proc appl Ind (NM_ATI_LAN_INFO_IND)
*/
void psDialNetProcApplInd(CmsApplInd *pAppInd);
/*
* psdial net proc Act Pdn Ctx Failure by sending appl Ind (NM_ATI_LAN_INFO_IND)
*/
void psDialNetProcActPdnCtxFailure(void);
/*
* psdial net WAN link up and lan bind
*/
void psDialNetLinkupCtrl(UINT8 cid, NmIfConfiguration *pIfCfg);
/*
* psdial net auto dial mode check
*/
void psDialNetAutoDialCheck(void);
/*
* psdial net link down
*/
void psDialNetLinkDown(UINT8 cid);
/*
* psdial net init and lanconfig for lwip
*/
void psDialNetInit(void);
#endif

View File

@@ -0,0 +1,96 @@
#ifndef __PS_DIAL_PAGING_BOOT_H__
#define __PS_DIAL_PAGING_BOOT_H__
/******************************************************************************
******************************************************************************
Copyright: - 2017- Copyrights of AirM2M Ltd.
File name: - psdial_paging_boot.h
Description: - PS paging boot header, control paging/measurement wake up procedure
History: - 2021/06/02, Originated by Jason
******************************************************************************
******************************************************************************/
#include "commontypedef.h"
#include "osasig.h"
/******************************************************************************
*****************************************************************************
* MACRO/ENUM
*****************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* STRUCT
*****************************************************************************
******************************************************************************/
/*
* SIG_CMS_CP_PAGING_EVENT_IND_ISR
*/
typedef struct CmsCpPagingEventIndIsr
{
UINT8 eventId; //CpPagingImgEventId
UINT8 rsvd;
UINT16 eventSize; //event body/buffer size
void *pEvent; /* event body/buffer, !!! not need to free, as using global memory !!! */
}CmsCpPagingEventIndIsr; // 8 bytes
/******************************************************************************
*****************************************************************************
* CMS EXTERNAL API
*****************************************************************************
******************************************************************************/
/**
\fn void psDialPagingImgInfoInit(void)
\brief init "pagingImgInfo" context
\returns void
\Note: a) called in ec_main() before AP start paging image,
\ b) can not be to re-called when boot from AP paging image to AP full image
*/
void psDialPagingImgInfoInit(void);
/**
\fn BOOL psDialPagingImgProcCpEventIsr(UINT8 eventId, void *pEvent, UINT16 eventSize)
\brief API called by AP paging image, to process CP/PHY paging event
\param[in] eventID CpPagingImgEventId
\param[in] pEvent event buffer/body, using AP/CP share global memory, !!! NOT need to free !!!
\param[in] eventSize event buffer/body size in bytes
\returns BOOL
\Note: a) return TRUE, caller must wake up to AP big image
\ b) should only be called in ISR (IPC0)
*/
CpPagingImgEventRet psDialPagingImgProcCpEventIsr(UINT8 eventId, void *pEvent, UINT16 eventSize);
/**
\fn void psDialWakeupCheckPagingEvent(void)
\brief check whether any paging event is set in AP paging image
\returns void
\Note: a) called when CMS task start/init.
\ b) if CP paging event need to wake up AP big image, when AP big image wake up
\ (CMS task created), check any paging event
*/
void psDialWakeupCheckPagingEvent(void);
/**
\fn void psDialProcCpPagingEventIndIsrSig(CmsCpPagingEventIndIsr *pCpEventIsr)
\brief proc "SIG_CMS_CP_PAGING_EVENT_IND_ISR" signal
\returns void
\Note: a) if CMS task already created, CP paging event don't processed in ISR, just forward
\ this signal to CMS task
*/
void psDialProcCpPagingEventIndIsrSig(CmsCpPagingEventIndIsr *pCpEventIsr);
#endif

View File

@@ -0,0 +1,72 @@
#ifndef __PS_DIAL_PLMN_CFG_H__
#define __PS_DIAL_PLMN_CFG_H__
/******************************************************************************
******************************************************************************
Copyright: - 2017- Copyrights of AirM2M Ltd.
File name: - psdial_plmn_cfg.h
Description: - PLMN static configuation functions
History: - 06/26/2018, Originated by Jason
******************************************************************************
******************************************************************************/
#include "commontypedef.h"
/******************************************************************************
*****************************************************************************
* MARCO
*****************************************************************************
******************************************************************************/
#define DIAL_CFG_IPV4 0
#define DIAL_CFG_IPV6 1
#define DIAL_CFG_IPV4V6 2
#define DIAL_CFG_PRFER_BAND_NUM 8
/******************************************************************************
*****************************************************************************
* STRUCT
*****************************************************************************
******************************************************************************/
typedef struct DialPlmnCfgInfoTag
{
struct {
UINT16 mcc;
UINT16 mnc;
} plmn;
BOOL eitf; /*ESM information transfer flag*/
UINT8 ipType;
CHAR *pApn;
CHAR *pShortName;
CHAR *pLongName;
UINT8 preBand[DIAL_CFG_PRFER_BAND_NUM]; /*prefer band*/
CHAR *pDefIp4Dns1;
CHAR *pDefIp4Dns2;
CHAR *pDefIp6Dns1;
CHAR *pDefIp6Dns2;
}DialPlmnCfgInfo;
/******************************************************************************
******************************************************************************
* External global variable
******************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* Functions
*****************************************************************************
******************************************************************************/
const DialPlmnCfgInfo* psDialGetPlmnCfgByPlmn(UINT16 mcc, UINT16 mnc);
BOOL psDialIsValidPlmnName(UINT8 plmnFormat, CHAR *plmnName);
#endif

View File

@@ -0,0 +1,108 @@
#ifndef __PS_DIAL_PPP_H__
#define __PS_DIAL_PPP_H__
/******************************************************************************
******************************************************************************
Copyright: - 2017- Copyrights of AirM2M Ltd.
File name: - psdial_pp.h
Description: - psdial pp header
History: - 2021/12/15, Originated by fwang
******************************************************************************
******************************************************************************/
#include "commontypedef.h"
#include "cms_api.h"
#include "networkmgr.h"
/******************************************************************************
*****************************************************************************
* MARCO
*****************************************************************************
******************************************************************************/
#define PS_DIAL_PPP_AUTH_INFO_LEN 64
/******************************************************************************
*****************************************************************************
* STRUCT
*****************************************************************************
******************************************************************************/
/*
* PS Dial Ppp Disconnect non block api struct info
*/
typedef struct PsDialPppDisconnect_Tag
{
UINT8 atChanId;
UINT8 ipv4Cid;
UINT8 ipv6Cid;
UINT8 resv;
}PsDialPppDisconnect;
/*
* AUTH info during PPP LCP AUTH procedure
*/
typedef struct PsDialPppAuthInfo_Tag
{
UINT8 cid;
UINT8 authType; /* 0 - invalid, 1 - PAP,; 2 - CHAP*/
UINT8 idChallLen; /* len of "papIdChapChall" */
UINT8 pwdRespLen; /* len of "papPwdChapResp" */
/*
* 1> If PAP type, "papIdChapChall" is the PAP username/userId, "papPwdChapResp" is PAP password, all in string format.
* 2> If CHAP type, "papIdChapChall" is the CHAP challenge which sent from PPP server (UE) to PPP client (host),
* "papPwdChapResp" is the CHAP response which sent from PPP client (host) to PPP server (UE),
* Format (RFC 1994, 4.1):
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Code | Identifier | Length |
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Value-Size | Value ...
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* | Name ...
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
* Code: 1 - Challenge
* 2 - Response
* Length: length of: 4 bytes (code + ID + length) + length of "Value-size + Value + name"
*/
UINT8 papIdChapChall[PS_DIAL_PPP_AUTH_INFO_LEN];
UINT8 papPwdChapResp[PS_DIAL_PPP_AUTH_INFO_LEN];
}PsDialPppAuthInfo;
/******************************************************************************
******************************************************************************
* External global variable
******************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* Functions
*****************************************************************************
******************************************************************************/
CmsRetId psDialPppProcCmiCnf(const SignalBuf *cnfSignalPtr);
BOOL psDialIsPppChan(UINT16 atHandle);
CmsRetId psDialPppConnect(UINT16 atHandle, BOOL bCidPresent, UINT8 cid);
void psDialPppDisconnect(UINT8 atChanId, UINT8 ipv4Cid, UINT8 ipv6Cid);
void psDialPppHoldOn(UINT8 atChanId);
void psDialPppHangUp(UINT16 atHandle);
void psDialPppLanLinkUp(UINT8 wanLinkupCid, NmIfConfiguration *pIfCfg);
/*
* PPP LCP AUTH info
*/
void psDialPppSetAuth(PsDialPppAuthInfo *pAuthInfo);
/*
* PPP LCP ACT BEARER
*/
void psDialPppActBearer(UINT8 cid);
#endif

View File

@@ -0,0 +1,99 @@
#ifndef __PS_DIAL_PS_CTRL_H__
#define __PS_DIAL_PS_CTRL_H__
/******************************************************************************
******************************************************************************
Copyright: - 2017- Copyrights of AirM2M Ltd.
File name: - psdial_ps_ctrl.h
Description: - PS control header
History: - 2021/04/19, Originated by Jason
******************************************************************************
******************************************************************************/
#include "commontypedef.h"
#include "cms_api.h"
#include "apmu_external.h"
/******************************************************************************
*****************************************************************************
* MARCO
*****************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* STRUCT
*****************************************************************************
******************************************************************************/
/******************************************************************************
******************************************************************************
* External global variable
******************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* Functions
*****************************************************************************
******************************************************************************/
/*
* CMS task callback, before UE enter HIB/Sleep2 state
* This API should be called in IDLE task, before PMU decide to enter HIB/Sleep2 state, and task schedule already closed
*/
void psDialDeepSlpEnterCallBack(APSleepState lowPowerState);
/*
* PS dial first power on, not wake up, called when CMS task started,
*/
void psDialFirstPowerOn(void);
/*
* whether PS task is ready (created) to access
*/
BOOL psDialPsIsReady(void);
/*
* start PS and wake up PS, after this API, PS will be ready to access
* this API, could only be called in CMS task
*/
void psDialStartPs(void);
/*
* start PS, sync callback, called in API: void cmsStartPs(void)
*/
CmsRetId psDialStartPsSynCallback(UINT16 inputSize, void *pInput, UINT16 outputSize, void *pOutput);
/*
* start PS, non-blocked callback, called in API: void cmsStartPsNonBlock(void)
*/
void psDialStartPsNonBlockCallback(UINT16 paramSize, void *pParam);
/*
* AT+CGCONTRDP to get all default bearer context during wakeup procedure
*/
CmsRetId psDialGetAllCGCONTRDPParamDuringWakeup(UINT16 atHandle);
/*
* AT+CEREG to get PS REG state
*/
CmsRetId psDialGetCEREGDuringWakeup(UINT16 atHandle);
/*
* AT+CGSCONTRDP to get all dedicated bearer context during wakeup procedure
*/
CmsRetId psDialGetAllCGSCONTRDPDuringWakeup(UINT16 atHandle);
/*
* AT+CGTFTRDP to get all activated TFT during wakeup procedure
*/
CmsRetId psDialGetAllCGTFTRDPDuringWakeup(UINT16 atHandle);
#endif

View File

@@ -0,0 +1,79 @@
/****************************************************************************
*
* Copy right: 2017-, Copyrigths of AirM2M Ltd.
* File name: ps_dev_if.h
* Description: API interface implementation header file for dev service
* History: Rev1.0 2018-10-12
*
****************************************************************************/
#ifndef __PS_DEV_IF_H__
#define __PS_DEV_IF_H__
#include "cms_util.h"
#include "cmidev.h"
CmsRetId devGetFunc(UINT32 atHandle);
CmsRetId devSetFunc(UINT32 atHandle, INT32 funcVal, INT32 resetVal);
CmsRetId devGetDevStatus(UINT32 atHandle);
CmsRetId devGetSupportedCiotBandModeReq(UINT32 atHandle);
CmsRetId devGetCiotBandModeReq(UINT32 atHandle);
CmsRetId devSetCiotBandModeReq(UINT32 atHandle, CmiDevSetCiotBandReq *pCmiSetBandReq);
CmsRetId devGetCiotFreqReq(UINT32 atHandle);
CmsRetId devSetCiotFreqReq(UINT32 atHandle, UINT8 mode, const INT32 *pFreqList, UINT8 freqNum, INT32 phyCellId, BOOL bRefAT);
CmsRetId devSetPowerState(UINT32 atHandle, UINT8 powerState);
CmsRetId devGetExtCfg(UINT32 atHandle);
CmsRetId devSetExtCfg(UINT32 atHandle, CmiDevSetExtCfgReq *pSetExtCfgReq);
CmsRetId devRmFPLMN(UINT32 atHandle, INT32 type);
#ifdef CMS_ENABLE_CAT_LPP_FEATURE
CmsRetId devGetCMOLRCapa(UINT32 atHandle);
CmsRetId devGetCMOLR(UINT32 atHandle);
CmsRetId devSetCMOLR(UINT32 atHandle, UINT32 enable, UINT32 method, UINT32 horAccSet, UINT32 horAcc, UINT32 verReq, UINT32 verAccSet,
UINT32 verAcc, UINT32 velReq, UINT32 reqMode, UINT32 timeOut, UINT32 interval, UINT32 shapeReq, UINT32 plane,
UINT8* NMEAReq, UINT8* thirdPartyAddr, UINT32 paramNmb);
CmsRetId devGetCMTLRCapa(UINT32 atHandle);
CmsRetId devGetCMTLR(UINT32 atHandle);
CmsRetId devSetCMTLR(UINT32 atHandle,INT32 subscribe);
CmsRetId devGetCMTLRACapa(UINT32 atHandle);
CmsRetId devGetCMTLRA(UINT32 atHandle);
CmsRetId devSetCMTLRA(UINT32 atHandle,INT32 allow, INT32 handleId);
#endif
CmsRetId devGetESTATUS(UINT32 atHandle, UINT8 statusType);
CmsRetId devSetESTATIS(UINT32 atHandle, UINT16 periodS);
CmsRetId devGetECBCINFO(UINT32 atHandle, CmiDevGetBasicCellListInfoReq *pGetBcInfoReq);
CmsRetId devGetECPSTEST(UINT32 atHandle);
CmsRetId devSetECPSTEST(UINT32 atHandle,UINT8 subscribe);
CmsRetId devGetSupportedBandPowerClassReq(UINT32 atHandle);
CmsRetId devGetECPOWERCLASS(UINT32 atHandle);
CmsRetId devSetECPOWERCLASS(UINT32 atHandle, CmiDevSetPowerClassReq *pPowerClass);
CmsRetId devGetECNBR14(UINT32 atHandle);
CmsRetId devGetEVENTSTATIS(UINT32 atHandle);
CmsRetId devSetEVENTSTATIS(UINT32 atHandle, CmiDevSetEventStatisReq *pMode);
CmsRetId devGetWIFISCAN(UINT32 atHandle);
CmsRetId devSetWIFISCAN(UINT32 atHandle, CmiDevSetWifiSacnReq *wifiScanReq);
CmiRcCode devSetExCfgParaSync(CmiDevSetExtCfgReq *pSetExCfgReq);
CmiRcCode devGetExCfgParaSync(CmiDevGetExtCfgCnf *pGetExCfgCnf);
/**
\fn CmiRcCode devGetNasTimerParaReqSync
\brief get HighPriPlmnTimer/ESM3482/ESM3492 timer config info by syn Api
\param[in/out] CmiDevGetTimerParaCnf *pGetTimerPareCnf
\returns CmsRetId
*/
CmiRcCode devGetNasTimerParaReqSync(CmiDevGetNasTimerParaCnf *pGetTimerPareCnf);
/**
\fn CmiRcCode psDevSetTimerParaReqSync
\brief Set HighPriPlmnTimer/ESM3482/ESM3492 timer config info by syn Api
\param[in/out]CmiDevSetTimerParaReq *pSetParaReq
\returns CmsRetId
*/
CmiRcCode devSetNasTimerParaReqSync(CmiDevSetNasTimerParaReq *pSetParaReq);
#endif

View File

@@ -0,0 +1,47 @@
/****************************************************************************
*
* Copy right: 2017-, Copyrigths of AirM2M Ltd.
* File name: ps_mm_if.h
* Description: API interface implementation header file for mm service
* History: Rev1.0 2018-10-12
*
****************************************************************************/
#ifndef __PS_MM_IF_H__
#define __PS_MM_IF_H__
#include "cms_util.h"
CmsRetId mmGetCregCapaReq(UINT32 atHandle);
CmsRetId mmGetCregReq(UINT32 atHandle);
CmsRetId mmManualPlmnSearch(UINT32 atHandle, UINT32 gardTimerSec);
CmsRetId mmGetCurOperInfo(UINT32 atHandle);
CmsRetId mmSetAutoPlmnRegister(UINT32 atHandle);
CmsRetId mmSetManualPlmnRegister(UINT32 atHandle, BOOL bFailToAuto, INT32 operFormat, UINT8 *pOperStr, INT32 accTchVal);
CmsRetId mmSetDeregister(UINT32 atHandle);
CmsRetId mmSetOperFormat(UINT32 atHandle, INT32 operFormat);
CmsRetId mmSetOperFormatSync(INT32 operFormat);
CmsRetId mmGetCpsms(UINT32 atHandle);
CmsRetId mmSetCpsms(UINT32 atHandle, UINT8 modeVal, const UINT8 *pRauT, const UINT8 *pGprsT, const UINT8 *pTauT, const UINT8 *pActT);
CmsRetId mmGetEdrx(UINT32 atHandle);
CmsRetId mmSetEdrx(UINT32 atHandle, UINT8 modeVal, UINT8 actType, UINT8* edrxVal);
CmsRetId mmReadEdrxDyn(UINT32 atHandle);
CmsRetId mmGetCiotoptCapa(UINT32 atHandle);
CmsRetId mmSetCiotoptCfg(UINT32 atHandle, CmiMmSetCiotOptCfgReq *pSetCiotOptCfgReq);
CmsRetId mmGetCiotoptCfg(UINT32 atHandle);
CmsRetId mmGetCoverEnhancStatus(UINT32 atHandle);
CmsRetId mmGetEcplmns(UINT32 atHandle);
CmsRetId mmExecEcplmns(UINT32 atHandle);
CmsRetId mmGetCESQ(UINT32 atHandle);
CmsRetId mmGetECPSMR(UINT32 atHandle);
UINT8 mmGetCsqRssiFromCesq(INT8 rsrp, INT8 rsrq, UINT16 rssiComp);
CmsRetId mmSetPtwEdrx(UINT32 atHandle, UINT8 modeVal, UINT8 actType, UINT8* ptw, UINT8* edrxVal);
CmsRetId mmGetPtwEdrx(UINT32 atHandle);
CmsRetId mmGetECEMMTIME(UINT32 atHandle);
CmsRetId mmSetECPLMNRESELECT(UINT32 atHandle);
CmsRetId mmGetCurrOperatorName(UINT32 atHandle);
CmsRetId mmSetTriggerRrcRelease(UINT32 atHandle);
CmsRetId mmSetTriggerTau(UINT32 atHandle, UINT8 epsUpdateType);
BOOL OperatorStringToNumericPlmn(const UINT8 *pPlmnStr, CmiNumericPlmn *pOutPlmn);
#endif

View File

@@ -0,0 +1,37 @@
/****************************************************************************
*
* Copy right: 2017-, Copyrigths of AirM2M Ltd.
* File name: ps_nm_if.h
* Description: API interface implementation header file for PHY service
* History: Rev1.0 2018-10-12
*
****************************************************************************/
#ifndef __PS_NM_IF_H__
#define __PS_NM_IF_H__
#include "cms_util.h"
#include "appmgr.h"
#include "networkmgr.h"
//#define ATEC_PING_IND_STR_LEN 160
//#define ATEC_ECGADDR_STR_LEN 160
CmsRetId psGetDNS(UINT32 atHandle, UINT8* url, UINT8 cid);
CmsRetId psGetDNSWithoutCache(UINT32 atHandle, UINT8* url, UINT8 cid);
CmsRetId psStopPing(UINT32 atHandle );
CmsRetId psStartPing(UINT32 atHandle, UINT8* addr, INT16 addr_len, INT32 count, INT32 size, INT32 timeout, BOOL raiFlag, UINT8 cid);
CmsRetId psStartPingWithOutUrl(UINT32 atHandle, UINT8 *pAddr, INT16 addr_len, INT32 count, INT32 size, INT32 timeout, BOOL raiFlag, UINT8 cid);
CmsRetId psIperfReq(UINT32 atHandle, NmIperfReq *pIperfReq);
CmsRetId psSntpReq(UINT32 atHandle, char *sntpServer, UINT16 port, BOOL autoSync, UINT8 cid);
CmsRetId psClearDnsCache(BOOL bClearAll, UINT8* url );
CmsRetId psGetDnsServer(UINT8 cid, NmNetIfDnsCfg *dnsServer);
CmsRetId psSetDnsServer(UINT8 cid, NmNetIfDnsCfg *dnsServer);
#endif

View File

@@ -0,0 +1,111 @@
/****************************************************************************
*
* Copy right: 2017-, Copyrigths of AirM2M Ltd.
* File name: ps_phy_if.h
* Description: API interface implementation header file for PHY service
* History: Rev1.0 2018-10-12
*
****************************************************************************/
#ifndef __PS_PHY_IF_H__
#define __PS_PHY_IF_H__
#include "commontypedef.h"
/******************************************************************************
* If no parameters carried in signal, just pass a reserved UINT32
******************************************************************************/
typedef UINT32 PhyCmiEmptySig;
/*
* defined fast signal Id between CMS task<- IPC -> PHY for PHY/RF AT CMD
* Id: 0x0930 - 0x093F
*/
typedef enum _EPAT_SIG_PHYCMISIGID_Tag
{
SIG_FAST_PHY_CMI_BASE = 0x0930,
SIG_FAST_PHY_CMI_REQ, // PhyCmiReq
SIG_FAST_PHY_CMI_CNF, // PhyCmiCnf
SIG_FAST_PHY_CMI_IND, // PhyCmiInd
SIG_FAST_PHY_CMI_END = 0x093F
}PHYCMISIGID;
typedef enum CMI_PHY_PRIM_ID_TAG /* PRIM Id*/
{
CMI_PHY_PRIM_BASE,
CMI_PHY_SET_CFG_PARAM_REQ, //CmiPhySetCfgParamReq, AT+ECPHYCFG=<>
CMI_PHY_SET_CFG_PARAM_CNF,
CMI_PHY_SET_RF_TEST_CMD_REQ,
CMI_PHY_SET_RF_TEST_CMD_CNF,
CMI_PHY_SET_RF_NST_RST_REQ,
CMI_PHY_SET_RF_NST_RST_CNF,
CMI_PHY_SET_RF_NST_RST_IND,
CMI_PHY_SET_RF_NST_RST_DEBUG,
CMI_PHY_SET_RF_CFG_REQ,
CMI_PHY_SET_RF_CFG_CNF,
CMI_PHY_PRIM_END
}CMI_PHY_PRIM_ID;
/******************************************************************************
* PhyCmiReq - SIG_FAST_PHY_CMI_REQ
* CMI interface request for PHY/RF AT CMD
* Int16 reqId; 4 MSB bits SG ID | 12 bits PRIM ID;
* Int16 srcHandler; ID use to identify which module send this request
* Int8 body[0]; request PRIM entity
******************************************************************************/
typedef struct PhyCmiReqTag
{
struct {
UINT16 reqId;
UINT16 srcHandler;
}header;
UINT8 body[];
}PhyCmiReq;
/******************************************************************************
* PhyCmiCnf - SIG_FAST_PHY_CMI_CNF
******************************************************************************/
typedef struct PhyCmiCnfTag
{
struct {
UINT16 cnfId; //4 MSB bits SG ID | 12 bits PRIM ID
UINT16 srcHandler; //Handler from PhyCmiReq
UINT16 rc;
UINT16 reserved;
}header;
UINT8 body[];
}PhyCmiCnf;
typedef struct PhyCmiIndTag
{
struct {
UINT16 indId; //4 MSB bits SG ID | 12 bits PRIM ID
/*
* As some indication is triggered by some AT request, in such as need to fill this "reqHandler",
* otherwise set to "BROADCAST_IND_HANDLER".
*/
UINT16 reqHandler;
}header;
UINT8 body[];
}PhyCmiInd;
BOOL phyGetDebugModule(CHAR *strName, UINT8 *phyModule);
INT32 phySetDebugCfgInfo(UINT16 atHandle, UINT32 phyModId, INT32 *pCfgParams, UINT8 paramNum);
void phyGetPhyDebugAtCmdInfo(CHAR *pAtRspBuf, UINT16 bufLen);
void phyRestorePhyDebugAtCmdInfo(void);
void phySavePhyDebugAtCmdInfo(void);
#endif

View File

@@ -0,0 +1,236 @@
/******************************************************************************
* (C) Copyright 2018 AirM2M International Ltd.
* All Rights Reserved
*******************************************************************************
* Filename: ps_ps_if.h
*
* Description: API interface for PS service
*
* History:
*
* Notes:
*
******************************************************************************/
#ifndef __PS_PS_IF_H__
#define __PS_PS_IF_H__
#include "networkmgr.h"
#include "cmicomm.h"
#include "cmips.h"
#include "cms_util.h"
/******************************************************************************
*****************************************************************************
* MARCO
*****************************************************************************
******************************************************************************/
#define PSIL_PS_PDP_IP_V6_SIZE 128
#define PSIL_PS_PDP_IPV4_SIZE 16
#define PSIL_IPV4_SUBNETMUX_MAX_LEN 32
/******************************************************************************
*****************************************************************************
* ENUM
*****************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* STRUCT
*****************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* API
*****************************************************************************
******************************************************************************/
CmsRetId psDeleteCGDCONTContext(UINT32 atHandle, UINT32 dwContextID);
CmsRetId psSetAttachState(UINT32 atHandle, BOOL fAttached);
CmsRetId psGetAttachState(UINT32 atHandle);
CmsRetId psSetCGACT(UINT32 atHandle, INT32 cid, INT32 state);
CmsRetId psEnterDataState(UINT32 atHandle, UINT8 cid);
CmsRetId psSetCdgcont (UINT32 atHandle, CmiPsDefPdpDefinition* ctxInfo);
CmsRetId psGetCGCONTRDPParam(UINT32 atHandle, UINT32 cid);
CmsRetId psGetAllCGCONTRDPParam(UINT32 atHandle);
CmsRetId psQueryERegOption(UINT32 atHandle);
CmsRetId psGetERegStatus(UINT32 atHandle);
CmsRetId psGetCGTFT(UINT32 atHandle);
CmsRetId psDeleteTft(UINT32 atHandle, INT32 cid);
CmsRetId psSetTftFilter(UINT32 atHandle, const CmiPsPacketFilter *tftFilter);
CmsRetId psSendUserData(UINT32 atHandle, INT32 cid, INT32 dataStrLen, UINT8 *pStrdata, INT32 rai, INT32 typeOfUserData, BOOL isCSODCP);
CmsRetId psSetAttBear(UINT32 atHandle, AttachedBearCtxPreSetParam * param);
CmsRetId psGetATTBEAR(UINT32 atHandle);
CmsRetId psModBearerCtxReq (UINT32 atHandle, UINT32 cid);
CmsRetId psGetCGDCONTCid (UINT32 atHandle);
CmsRetId psSetCGEQOSQualityService (UINT32 atHandle, const CmiPsEpsQosParams* params);
CmsRetId psDeleteCGEQOSQualityService (UINT32 atHandle, UINT32 cid);
CmsRetId psGetCGEQOSQualityService (UINT32 atHandle);
CmsRetId psSetCGEQOSRDPQualityService(UINT32 atHandle, UINT32 cid, BOOL bGetAll);
CmsRetId psSetRTDCP(UINT32 atHandle, INT32 reporting);
CmsRetId psGetCurRTDCP(UINT32 atHandle);
CmsRetId psSetCGAUTH( UINT32 atHandle,CmiPsSetDefineAuthCtxReq *pSetDefinedAuthReq);
CmsRetId psGetCGAUTH(UINT32 atHandle);
CmsRetId psSetCIPCA(UINT32 atHandle,INT32 n,INT32 attach);
CmsRetId psGetCIPCA(UINT32 atHandle);
CmsRetId psGetCGAPNRC(UINT32 atHandle, INT32 cid, BOOL bGetAll);
CmsRetId psSetECCIOTPLANE(UINT32 atHandle,INT32 plane);
CmsRetId psGetPDPAddr(UINT32 atHandle, INT32 cid, BOOL bGetAll);
CmsRetId psGetCSCON(UINT32 atHandle);
CmsRetId psSendNoMorePsDataReq(UINT32 atHandle);
CmsRetId psGetCEER(UINT32 atHandle);
CmsRetId psSetCemode(UINT32 atHandle, UINT8 ceMode);
CmsRetId psGetCemode(UINT32 atHandle);
CmsRetId psGetAllBrsCidsInfo(UINT32 atHandle, CmiPsGetAllCidsInfoCmd reqCmd);
void psSetNetMaskStr(UINT8 addrType, int subnetMaskLen, char *maskStr);
void psUint8IpAddrToStr(UINT8 addrType, UINT8 *valData, CHAR *ippStr);
void psUint8Ipv4AddrToStr(UINT8 *addrData, CHAR *ippStr);
void psUint8Ipv6AddrToStr(UINT8 addrType, UINT8 *ipUint8Addr, CHAR *ippStr);
void psPdpTypeToStr(UINT8 pdpType, char *typeStr);
CmsRetId psParseIpAddrAndMaskFromStr(CmiIpAddr *pCmiIp, const UINT8 *pIpStr);
CmsRetId psParsePfPortInfoFromStr(CmiPsPfPortInfo *pPfPortInfo, const UINT8 *pIpStr);
CmsRetId psParseTosMaskFromStr(CmiPsTosMask *pTosMask, const UINT8 *pStr);
BOOL psBeAllZero(const UINT8 *ArrayName, UINT8 Length);
CmsRetId psGetCGDSCONTCid (UINT32 atHandle);
CmsRetId psDeleteCGDedDCONTContext (UINT32 atHandle, UINT32 delCid);
CmsRetId psSetDedCdgCont (UINT32 atHandle, DefineDedBearerCtxInfo* ctxInfo);
CmsRetId psGetCGTFTRDPParam(UINT32 atHandle, UINT32 cid);
CmsRetId psGetAllCGTFTRDPParam(UINT32 atHandle) ;
CmsRetId psGetCPSDO(UINT32 atHandle);
CmsRetId psSetCPSDO(UINT32 atHandle, UINT8 status);
CmsRetId psSetModDedHandSkResultReq(UINT32 atHandle, UINT8 cid,UINT8 result);
CmsRetId psSetActDedHandSkResultReq(UINT32 atHandle, UINT8 cid,UINT8 result);
BOOL psParseDisplayApnName(const UINT8 *srcApn,UINT8 *destApn,UINT16 destMaxSize, UINT16 len, UINT8 *outlen);
CmsRetId psGetCGSCONTRDPParam(UINT32 atHandle, UINT32 cid);
CmsRetId psGetAllCGSCONTRDPParam(UINT32 atHandle);
CmsRetId psGetDefinedCidContext (UINT32 atHandle,UINT8 cid);
CmsRetId psSetGDCNT(UINT32 atHandle, UINT8 dataCounterOption);
CmsRetId psGetGDCNT(UINT32 atHandle);
CmsRetId psSetAUGDCNT(UINT32 atHandle, UINT16 autoSavePeriodS);
CmsRetId psGetAUGDCNT(UINT32 atHandle);
/******************************************************************************
******************************************************************************
PS SYNC API, which could return info directly
******************************************************************************
******************************************************************************/
/**
\fn CmiRcCode psGetCGATTSync(UINT8 *pPsState)
\brief AT+CGATT? get PS attach state
\param[out] pPsState CMI_PS_DETACHED(0)/CMI_PS_DETACHED(1)
\returns CmiRcCode MtErrorResultCode
*/
CmiRcCode psGetCGATTSync(UINT8 *pPsState);
/**
\fn CmiRcCode psGetAllBearersCidsBasicInfoSync(CmiPsGetAllBearersCidsInfoCnf *pCmiAllBrCidBasicInfo)
\brief Get all bearers and cids basic info
\param[out] pCmiAllBrCidBasicInfo CmiPsGetAllBearersCidsInfoCnf
\returns CmiRcCode MtErrorResultCode
*/
CmiRcCode psGetAllBearersCidsBasicInfoSync(CmiPsGetAllBearersCidsInfoCnf *pCmiAllBrCidBasicInfo);
/**
\fn CmiRcCode psSetCGAUTHSync(const CmiPsSetDefineAuthCtxReq *pCmiSetAuthInfo)
\brief Set CGAUTH info
\param[in] pCmiSetAuthInfo CmiPsSetDefineAuthCtxReq
\returns CmiRcCode MtErrorResultCode
*/
CmiRcCode psSetCGAUTHSync(const CmiPsSetDefineAuthCtxReq *pCmiSetAuthInfo);
/**
\fn CmiRcCode psGetOneCGAUTHSync(UINT8 cid, CmiPsGetDefineAuthCtxCnf *pCmiGetAuthCnf)
\brief get one PDP AUTH config info
\param[in] cid PDP CID
\param[out] pCmiGetAuthCnf CmiPsGetDefineAuthCtxCnf
\returns CmiRcCode MtErrorResultCode
*/
CmiRcCode psGetOneCGAUTHSync(UINT8 cid, CmiPsGetDefineAuthCtxCnf *pCmiGetAuthCnf);
/**
\fn CmiRcCode psSetCGDCONTSync(CmiPsDefineBearerCtxReq *pCmiDefinePdpCtxReq)
\brief Set CGDCONT info, define a default PDP
\param[in] pCmiDefinePdpCtxReq CmiPsDefineBearerCtxReq
\returns CmiRcCode MtErrorResultCode
*/
CmiRcCode psSetCGDCONTSync(const CmiPsDefineBearerCtxReq *pCmiDefinePdpCtxReq);
/**
\fn CmiRcCode psGetOneCGDCONTSync(UINT8 cid, CmiPsGetDefinedBearerCtxCnf *pCmiGetdefinedPdpCnf)
\brief get one default PDP CGDCONT info
\param[in] cid default PDP CID
\param[out] pCmiGetdefinedPdpCnf CmiPsGetDefinedBearerCtxCnf
\returns CmiRcCode MtErrorResultCode
*/
CmiRcCode psGetOneCGDCONTSync(UINT8 cid, CmiPsGetDefinedBearerCtxCnf *pCmiGetdefinedPdpCnf);
/**
\fn CmiRcCode psDelCGDCONTSync(UINT8 cid)
\brief delete CGDCONT info, delete a default PDP context, refer: AT+CGDCONT=<cid>
\param[in] cid PDP CID
\returns CmiRcCode MtErrorResultCode
*/
CmiRcCode psDelCGDCONTSync(UINT8 cid);
/**
\fn CmiRcCode psGetCGCONTRDPSync(UINT8 cid, CmiPsReadBearerDynCtxParamCnf *pDynBearerCtxParamCnf)
\brief get one default PDP CGDCONT dyn param
\param[in] cid default PDP CID
\param[out] pDynBearerCtxParamCnf CmiPsReadBearerDynCtxParamCnf
\returns CmiRcCode MtErrorResultCode
*/
CmiRcCode psGetCGCONTRDPSync(UINT8 cid, CmiPsReadBearerDynCtxParamCnf *pDynBearerCtxParamCnf);
#if 0 //duplicated
/**
\fn CmiRcCode psGetOneCGCONTRDPSync(UINT8 cid, CmiPsReadBearerDynCtxParamCnf *pCmiGetdefinedPdpCnf)
\brief get one PDP dynamic info
\param[in] cid default PDP CID
\param[out] CmiPsReadBearerDynCtxParamCnf pCmiGetRdpPdpCnf
\returns CmiRcCode
*/
CmiRcCode psGetOneCGCONTRDPSync(UINT8 cid, CmiPsReadBearerDynCtxParamCnf *pCmiGetRdpPdpCnf);
#endif
/**
\fn CmiRcCode psGetCGTFTRDPSync(UINT8 cid, CmiPsReadTFTDynCtxParamCnf *pDynTftCnf)
\brief get actived TFT parameters of one bearer
\param[in] cid PDP CID
\param[out] pDynBearerCtxParamCnf CmiPsReadTFTDynCtxParamCnf
\returns CmiRcCode MtErrorResultCode
*/
CmiRcCode psGetCGTFTRDPSync(UINT8 cid, CmiPsReadTFTDynCtxParamCnf *pDynTftCnf);
/**
\fn CmiRcCode psGetSCLKEXSync(CmiPsGetTrafficIdleMonitorCnf *pGetTrafficIdleMonitorCnf)
\brief Get Traffic Idle Monitor Cnf
\param[in] void
\param[out] CmiPsGetTrafficIdleMonitorCnf *pGetTrafficIdleMonitorCnf
\returns CmiRcCode MtErrorResultCode
*/
CmiRcCode psGetSCLKEXSync(CmiPsGetTrafficIdleMonitorCnf *pGetTrafficIdleMonitorCnf);
/**
\fn CmiRcCode psGetSCLKEXSync(CmiPsSetTrafficIdleMonitorReq *pSetTrafficIdleMonitorReq)
\brief Set Traffic Idle Monitor Cnf
\param[in] CmiPsSetTrafficIdleMonitorReq *pSetTrafficIdleMonitorReq
\param[out] void
\returns CmiRcCode MtErrorResultCode
*/
CmiRcCode psSetSCLKEXSync(const CmiPsSetTrafficIdleMonitorReq *pSetTrafficIdleMonitorReq);
#endif

View File

@@ -0,0 +1,76 @@
/****************************************************************************
*
* Copy right: 2017-, Copyrigths of AirM2M Ltd.
* File name: ps_sim_if.h
* Description: The header file for API interface for PS SIM module
* History: Rev1.0 2018-10-12
*
****************************************************************************/
#ifndef __PS_SIM_IF_H__
#define __PS_SIM_IF_H__
#include "cms_util.h"
#include "cmisim.h"
CmsRetId simGetImsi(UINT32 atHandle);
CmsRetId simGetPinState(UINT32 atHandle);
CmsRetId simEnterPin(UINT32 atHandle, UINT8* oldPasswd, UINT8* newPasswd);
CmsRetId simSetCRSM(UINT32 atHandle, INT32 cmd, INT32 fileId, INT32 p1, INT32 p2, INT32 p3, CHAR *data, CHAR *pathId);
CmsRetId simSetCSIM(UINT32 atHandle, UINT16 cmdStrLen, UINT8 *cmdStr);
CmsRetId simGetIccid(UINT32 atHandle);
CmsRetId simSetCPWD(UINT32 atHandle, UINT8 no, UINT8 oper, UINT8* oldPasswd, UINT8* newPasswd);
CmsRetId simSetClck(UINT32 atHandle, UINT8 mode, UINT8 fac, UINT8* pinCode);
CmsRetId simSetCcho(UINT32 atHandle, UINT8 *dfName);
CmsRetId simSetCchc(UINT32 atHandle, UINT8 sessionId);
CmsRetId simSetCgla(UINT32 atHandle, UINT8 sessionId, UINT16 len, UINT8* command);
CmsRetId simSetSimSleep(UINT32 atHandle, UINT8 mode);
CmsRetId simGetSimSleepState(UINT32 atHandle);
CmsRetId simSetCpinr(UINT32 atHandle, UINT8 pinCode);
CmsRetId simSetECSWC(UINT32 atHandle, UINT8 mode);
CmsRetId simGetSWCSetting(UINT32 atHandle);
CmsRetId simSetPinOperation(UINT32 atHandle, UINT8 operMode, UINT8* pinStr1, UINT8* pinStr2);
//CmsRetId simSetECSIMPD(UINT32 atHandle, UINT8 mode);
CmsRetId simGetECSIMPDSetting(UINT32 atHandle);
CmsRetId simGetSubscriberNumber(UINT32 atHandle);
CmsRetId simSetTerminalProfile(UINT32 atHandle, UINT16 strLen, UINT8 *profileStr);
CmsRetId simGetTerminalProfile(UINT32 atHandle);
CmsRetId simSetExtCfg(UINT32 atHandle, CmiSimSetExtCfgReq *pSetExtCfgReq);
CmsRetId simGetExtCfg(UINT32 atHandle);
CmsRetId simSetRemoval(UINT32 atHandle);
CmsRetId simGetSmsParams(UINT32 atHandle);
CmsRetId simSetSelectPlmnList(UINT32 atHandle, UINT8 plmnList);
CmsRetId simSetPreferredPlmnList(UINT32 atHandle, UINT16 index, UINT8 format, UINT8 *pOperStr, UINT16 AccessTech);
CmsRetId simGetPreferredPlmnList(UINT32 atHandle);
/******************************************************************************
******************************************************************************
PS SYNC API, which could return info directly
******************************************************************************
******************************************************************************/
/**
\fn CmiRcCode simGetPinStateSync(UINT8 *pPinState)
\brief AT+CPIN? get SIM PIN state
\param[out] pPinState CmiSimPinState
\returns CmiRcCode MtErrorResultCode
*/
CmiRcCode simGetPinStateSync(UINT8 *pPinState);
/**
\fn simSetHotSwapNotifySync(BOOL bSimPlugIn)
\brief called by CMS task processed CmsSimHotSwapInd
\param[out] pPinState CmiSimPinState
\returns CmiRcCode MtErrorResultCode
*/
CmiRcCode simSetHotSwapNotifySync(BOOL bSimPlugIn);
/**
\fn CmiRcCode simGetSelectedPlmnListSync(UINT8 *pPinState)
\brief AT+CPLS? get selected PLMN list
\param[out] pPinState CmiSimPinState
\returns CmiRcCode MtErrorResultCode
*/
CmiRcCode simGetSelectedPlmnListSync(UINT8 *pList);
#endif

View File

@@ -0,0 +1,739 @@
/******************************************************************************
* Copy right: 2017-, Copyrigths of AirM2M Ltd.
* All Rights Reserved
*******************************************************************************
* Filename: ps_sms_if.h
*
* Description: API interface for SMS service
*
* History:
*
* Notes:
*
******************************************************************************/
#ifndef __PS_SMS_IF_H__
#define __PS_SMS_IF_H__
#include "cms_util.h"
#include "cmisms.h"
/******************************************************************************
* SMS/CB Parameter Definitions: (27.005)
* ============================================================================
* A) Message storage param
* 1. <index>: integer type
* value in the range of location numbers supported by the associated memory
* 2. <mem1>: string type
* memory from which messages are READ and DELETED; +CMGL/+CMGR/+CMGD
* "BM" - broadcast message storage
* "ME" - ME message storage
* "MT" - any of the storages associated with ME
* "SM" - (U)SIM message storage
* "TA" - TA message storage
* "SR" - status report storage
* 3. <mem2>: memory to which writing and sending operations
* <mem3>: memory to which received SMs are preferred to be stored
* unless forwarded directly to TE: +CNMI
* 4. <stat>: integer type in PDU mode; string type in text mode
* the status of message in memory
* 0 "REC UNREAD" received unread message (i.e. new message)
* 1 "REC READ" received read message
* 2 "STO UNSENT" stored unsent message (only applicable to SMs)
* 3 "STO SENT" stored sent message (only applicable to SMs)
* 4 "ALL" all messages (only applicable to +CMGL command)
*
* ============================================================================
* B) Message data param
* 1. <ackpdu>: string type
RP-ACK PDU
* 2. <alpha>: string type
* alphanumeric representation of <da> or <oa>;
* 3. <cdata>: string type
* TP-Command-Data in text mode responses,
* example: int: 42 (0x2A) => "2A"
* 4. <ct>: integer type
* TP-Command-Type (default: 0)
* 5. <da>: string format
* TP-Destination-Address, type of address given by <toda>
* 6. <data>
* TP-User-Data in text mode response
* 7. <dcs> integer format
* SMS Data Coding Scheme (default 0)
* 8. <dt> time-string format
* TP-Discharge-Time: "yy/MM/dd,hh:mm:ss+zz or-zz"
* 9. <fo> integer format
* first octet of SMS-DELIVER, SMSSUBMIT (default 0x21), SMS-STATUS-REPORT, or SMS-COMMAND (default 2)
* 10.<length> integer format
* the length of the message body <data> in characters, in the text mode (+CMGF=1)
* the length of the actual TP data unit in octets (INT8), in the PDU mode (+CMGF=0)
* 11.<mid> integer format
* CBM Message Identifier
* 12.<mn> integer format
* TP-Message-Number
* 13.<mr> integer format
* TP-Message-Reference
* 14.<oa> string format
* TP-Originating-Address, type of address given by <tooa>
* 15.<page> integer format
* 23.041 CBM Page Parameter bits 4-7
* 16.<pages> integer format
* 23.041 CBM Page Parameter bits 0-3
* 17.<pdu> hexadecimal format
* SMS TPDU in hexadecimal format: ME/TA converts each octet of TP data unit into two IRA character
* example: int: 42 (0x2A) => "2A"
* 18.<pid> integer format
* 23.040 TP-Protocol-Identifier in integer format (default 0)
* 19.<ra> string format
* 23.040 TP-Recipient-Address, type of address given by <tora>
* 20.<sca> string format
* 24.011 RP SC (SMS service centre) address Address, type of address given by <tosca>
* 21.<scts> time-string format
* 23.040 TP-Service-Centre-Time-Stamp
* 22.<sn> integer format
* 23.041 CBM Serial Number
* 23.<st> integer format
* 23.040 TP-Status
* 24.<toda> integer format
* 24.011 TP-Destination-Address Type-of-Address
* when first character of <da> is + (IRA 43) default is 145, otherwise default is 129
* 25.<tooa>/<tora>/<tosca>
* Type-of-Address octet in integer format
* 26.<vp> integer format/time-string format
* depending on SMS-SUBMIT <fo> setting: 3GPP TS 23.040 [3] TP-Validity-Period
* either in integer format (default 167) or in time-string format (refer <dt>)
*
*******************************************************************************
* Memory:
* 1> AT+CSMP, +CSCA and +CSCB settings are stored directly to non-volatile memory of ME
* a) AT+CSMP, param saved in mwconfig.nvm;
* b) +CSCA=<sca>[,<tosca>], param saved in UICC
*
******************************************************************************/
/******************************************************************************
*****************************************************************************
* MARCO
*****************************************************************************
******************************************************************************/
#define PSIL_SMS_ADDR_INTERNATIONAL_PREFIX ((UINT8)'+')
#define PSIL_SMS_MAX_PDU_SIZE CMI_SMS_MAX_PDU_SIZE //180
#define PSIL_SMS_MAX_PDU_SIZE_OF_DELIVER_REPORT 164 /* 23.040 9.2.2.1a MAX length of SMS-DELIVER-REPORT */
/*
* 1> DCS 7bit, max size is 160, max size of CSCS Char Set UCS2 is 160 * 4 = 640
* 2> DCS 8bit, max size is 140
* 3> DCS UCS2, max size is 280, HEX string type, example: "4F60" just means: 0x4F60.
*/
#define PSIL_SMS_MAX_7BIT_TXT_SIZE 160
#define PSIL_SMS_MAX_TXT_SIZE 640
#define PSIL_SMS_MAX_UD_SIZE 140
#define PSIL_SMS_INVALID_MEM_INDEX 255
#define PSIL_BITS_NUMBER_OF_DIGIT 4
/*
* Service Centre address, refer to TS-24.011 8.2.5.1
* +----------------+
* | length | Length of SC Address contents
* +----------------+
* | TOA | Type-of-Address
* +----------------+
* | dig 2 | dig 1 | Address value, 0 - 10 bytes
* +----------------+
* | dig 4 | dig 3 |
* +----------------+
* length: byte length, include: TOA and address.
* TOA:
* 7 0
* +---+---+---+---+---+---+---+---+
* | 1 | type-num | num-plan |
* +---+---+---+---+---+---+---+---+
* type-num: CmiSmsTypeOfNumberEnum
* num-plan: CmiSmsNumberPlanIdEnum
*/
/* The maximum length of the full address field (Address-Length, Type-of-Address and Address-Value) is 12 octets */
#define PSIL_SMS_ADDR_ENCODE_MAX_SIZE 12
/*
* From 27.005:
* 1> <pdu>: In the case of SMS: 3GPP TS 24.011 [6] SC address followed by 3GPP TS 23.040 [3] TPDU in
* hexadecimal format.
* 2> AT input is "HEX" (hexadecimal) string type, example: "2A" just means: 0x2A.
* 3> So the input max string size should be: 2*(180+12)
*/
#define PSIL_SMS_HEX_PDU_STR_MAX_SIZE (2*(PSIL_SMS_MAX_PDU_SIZE+PSIL_SMS_ADDR_ENCODE_MAX_SIZE))
#define PSIL_SMS_VP_OCTET_MAX_LENGTH 7
/* The TP-Validity-Period-Format is a 2-bit field, located within bit no 3 and 4 of the first octet of SMS-SUBMIT */
#define PSIL_SMS_FO_VPF_BIT_MASK 0x18
/*
* FO:
* SMS-SUBMIT first octet, refer to TS-23.040 9.2.2.2
* bit7 bit0
* +----+----+----+----+----+----+----+----+
* | RP |UDHI|SRR | VPF | RD | MTI |
* +----+----+----+----+----+----+----+----+
* RP: Reply Path, 0 - not set
* UDHI:User-Data-Header-Indicator, 0 - The TP-UD field contains only the short message
* SRR: Status-Report-Request , 1 - A status report is requested
* VPF: Validity-Period-Format, 00 - TP-VP field not present
* RD: Reject-Duplicates, 0 - SC not reject the duplicate SMS
* MTI: Message-Type-Indicator, 01 - SMS-SUBMIT
*
* Default FO: 0x21; SMS-SUBMIT PDU, status report required
*/
#define PSIL_MSG_FO_SUBMIT_DEFAULT ((UINT8)0x21)
#define PSIL_MSG_FO_DELIVER_DEFAULT ((UINT8)0)
#define PSIL_MSG_VP_DEFAULT ((UINT8)167) /* 24 hours - refer to TS-23.040 */
#define PSIL_MSG_PID_DEFAULT ((UINT8)0) /* Refer to TS-23.040 9.2.3.9 */
#define PSIL_MSG_REF_DEFAULT ((UINT8)0) /* Reference = 0 */
/*
* SMS-SUBMIT T-PDU format/basic element, refer to TS-23.040 9.2.2.2
* +----------------+
* | FO | First Octet
* +----------------+
* | MR | Message-Reference
* +----------------+
* \ DA \ Destination-Address, length: 2 - 12 bytes
* +----------------+
* | PID | Protocol-Identifier
* +----------------+
* | DCS | Data-Coding-Scheme
* +----------------+
* : VP : Validity-Period, 0/1/7 bytes
* +----------------+
* | UDL | User-Data-Length
* +----------------+
* \ UD \ User-Data, 0 - 140 bytes
* +----------------+
*/
/*
* SM-TL, address field (Destination-Address), refer to TS-23.040 9.1.2.5
* +----------------+
* | AL | Address length
* +----------------+
* | TOA | Type-of-Address
* +----------------+
* \ AV \ Address value, 0 - 10 bytes
* +----------------+
* AL: Number of useful semi-octets within the Address-Value field. !! (1 byte -> 2 length) !!
* TOA:
* 7 0
* +---+---+---+---+---+---+---+---+
* | 1 | type-num | num-plan |
* +---+---+---+---+---+---+---+---+
* type-num: CmiSmsTypeOfNumberEnum
* num-plan: CmiSmsNumberPlanIdEnum
*/
/*
* MSG/SMS ADDRESS LEN, encoded MAX 10 bytes, so for UCS2 MAX 80 length here
*/
#define PSIL_MSG_MAX_ADDR_LEN 80
/* Refer to TS-27.005 case 3.1 Parameter definitions Parameter <Stat> for Text mode */
#define PSIL_SMS_STATUS_STRING_REC_UNREAD "REC UNREAD"
#define PSIL_SMS_STATUS_STRING_REC_READ "REC READ"
#define PSIL_SMS_STATUS_STRING_STO_UNSENT "STO UNSENT"
#define PSIL_SMS_STATUS_STRING_STO_SENT "STO SENT"
#define PSIL_SMS_STATUS_STRING_ALL "ALL"
/*
* A CBS page comprises of 82 octets, which, using the default character set, equates to 93 characters.
*/
#define PSIL_SMS_CBS_MAX_DATA_LENGTH 93
/*
* This code is an escape to an extension of GSM 7 bit Default Alphabet table
* 3GPP TS 23.038, 6.2.1
*/
#define PSIL_SMS_ESCAPE_EXTERN_TBL_CODE 0x1B
#define PSIL_SMS_SEND_RP_ACK_WITHOUT_TPDU 0
#define PSIL_SMS_SEND_RP_ACK 1
#define PSIL_SMS_SEND_RP_ERROR 2
#define PSIL_SMS_TP_CAUSE_NO_SMS_STORAGE_CAPABILITY_IN_SIM 0xD1
#define PSIL_SMS_TP_CAUSE_MEMORY_CAPACITY_EXCEEDED 0xD3
#define PSIL_SMS_TP_CAUSE_UNSPECIFIED_ERR 0xFF
/******************************************************************************
*****************************************************************************
* ENUM
*****************************************************************************
******************************************************************************/
typedef enum PsilSmsDCSType_enum
{
PSIL_SMS_DCS_GENERAL_CODING = 0,
PSIL_SMS_DCS_MESSAGE_WAITING = 1,
PSIL_SMS_DCS_MESSAGE_CLASS = 2
}PsilSmsDCSType;
typedef enum PsilSmsDCSClass_enum
{
PSIL_SMS_DCS_MESSAGE_CLASS_0 = 0,
PSIL_SMS_DCS_MESSAGE_CLASS_1 = 1,
PSIL_SMS_DCS_MESSAGE_CLASS_2 = 2,
PSIL_SMS_DCS_MESSAGE_CLASS_3 =3
}PsilSmsDCSClass;
typedef enum PsilSmsDCSIndicationType_Tag
{
PSIL_SMS_DCS_VOICEMAIL_MESSAGE_WAITING = 0,
PSIL_SMS_DCS_FAX_MESSAGE_WAITING = 1,
PSIL_SMS_DCS_ELECTRONIC_MAIL_MESSAGE_WAITING = 2,
PSIL_SMS_DCS_OTHER_MESSAGE_WAITING = 3
}PsilSmsDCSIndicationType;
/* Refer to TS-23.404 9.2.3.3 TP-VPF:TP-Validity-Period-Format */
typedef enum PsilSmsValidityPeriodFormat_Enum
{
PSIL_SMS_VPF_NOT_PRESENT = 0, /* TP-VP field not present */
PSIL_SMS_VPF_ENHANCE = 1, /* TP-VP field present and enhanced format */
PSIL_SMS_VPF_RELATIVE = 2, /* TP-VP field present and Relative format */
PSIL_SMS_VPF_ABSOLUTE = 3, /* TP-VP field present and Absolute format */
PSIL_SMS_VPF_NUM_OF
}PsilSmsValidityPeriodFormat;
/*
* enum used in encoding/decoding SMS text
*/
typedef enum
{
PSIL_MSG_CODING_DEFAULT_7BIT = 0x00,
PSIL_MSG_CODING_8BIT = 0x01,
PSIL_MSG_CODING_UCS2 = 0x02,
PSIL_MSG_CODING_NUM_OF
}PsilMsgCodingType;
/*
* current SMS input/output format
*/
typedef enum PsilSmsFormatMode_enum
{
PSIL_SMS_FORMAT_PDU_MODE = 0,
PSIL_SMS_FORMAT_TXT_MODE = 1,
PSIL_SMS_FORMAT_NUM_MODE
}PsilSmsFormatMode;
/*
* SMS show format in text mode for command +CSDH
*/
typedef enum PsilSmsShowMode_enum
{
PSIL_SMS_SHOW_DETAIL_INFO_DISABLE = 0,
PSIL_SMS_SHOW_DETAIL_INFO_ENABLE = 1,
PSIL_SMS_SHOW_DETAIL_INFO_END
}PsilSmsShowMode;
/*
* <toda>, type of dest address
* 3GPP TS-24.011 [6] TP-Destination-Address Type-of-Address octet in integer format (when first
* character of <da> is + (IRA 43) default is 145, otherwise default is 129)
* 3GPP TS-23.040, 9.1.2.5
*/
typedef enum PsilSmsTypeOfAddress_enum
{
PSIL_SMS_TOA_NUMBER_RESTRICTED = 0x80, /* 128, Unknown type, unknown number format */
PSIL_SMS_TOA_NUMBER_UNKNOWN = 0x81, /* 129, Unknown type, IDSN format number */
PSIL_SMS_TOA_NUMBER_INTERNATIONAL = 0x91, /* 145, International number type, ISDN format */
PSIL_SMS_TOA_NUMBER_NATIONAL = 0xA1, /* 161, National number type, IDSN format */
PSIL_SMS_TOA_NUMBER_NETWORK_SPECIFIC = 0xB1, /* 177, Network specific number, ISDN format */
PSIL_SMS_TOA_NUMBER_DEDICATED = 0xC1, /* 193, Subscriber number, ISDN format */
PSIL_SMS_TOA_NUMBER_EXTENSION = 0xF1, /* 241, extension, ISDN format */
PSIL_SMS_TOA_NUMBER_INVALID
}PsilSmsTypeOfAddress;
/* Ref to TS-27.005 3.1 Parameter definitions Parameter <mem1>/<mem2>/<mem3> */
typedef enum PsilSmsStoreMemType_Enum
{
PSIL_SMS_STOR_MEM_TYPE_ME = 1, /* ME message storage */
PSIL_SMS_STOR_MEM_TYPE_SM = 2, /* (U)SIM message storage */
PSIL_SMS_STOR_MEM_TYPE_BM = 3, /* broadcast message storage */
PSIL_SMS_STOR_MEM_TYPE_MT = 4, /* Any of the storage associated whit ME */
PSIL_SMS_STOR_MEM_TYPE_TA = 5, /* TA message storage */
PSIL_SMS_STOR_MEM_TYPE_SR = 6, /* status report storage */
PSIL_SMS_STOR_MEM_TYPE_END
}PsilSmsStoreMemType;
typedef enum PsilSmsStoreMemNum_Enum
{
PSIL_SMS_STOR_MEM_1 = 1, /* typedef <mem1> */
PSIL_SMS_STOR_MEM_2 = 2, /* typedef <mem2> */
PSIL_SMS_STOR_MEM_3 = 3, /* typedef <mem3> */
PSIL_SMS_STOR_MEM_END
}PsilSmsStoreMemNum;
/*
* 3GPP TS-23.040 9.2.3.23 Information Element Identifier
* Only UDH_IEI_CONCATENATED_SMS_8_BIT is supported
*/
typedef enum TypeOfUdhIeId_Tag
{
UDH_IEI_CONCATENATED_SMS_8_BIT = 0,
UDH_IEI_SPECIAL_SMS_IND = 1,
UDH_IEI_RESERVED = 2,
UDH_IEI_VALUE_NOT_USED = 3,
UDH_IEI_APPLICATION_PORT_ADDRESSING_SCH_8_BIT = 4,
UDH_IEI_APPLICATION_PORT_ADDRESSING_SCH_16_BIT = 5,
UDH_IEI_SMSC_CTRL_PARAM = 6,
UDH_IEI_UDH_SOURCE_IND = 7,
UDH_IEI_CONCATENATED_SMS_16_BIT = 8,
UDH_IEI_WIRELESS_CONTROL = 9,
UDH_IEI_TEXT_FORMATTING = 0xA
}TypeOfUdhIeId;
typedef enum PsilSmsCharSet_Enum
{
PSIL_SMS_CHAR_SET_GSM = 0,
PSIL_SMS_CHAR_SET_IRA = 1,
PSIL_SMS_CHAR_SET_UCS2 = 2,
PSIL_SMS_CHAR_SET_END
}PsilSmsCharSet;
/******************************************************************************
*****************************************************************************
* STRUCT
*****************************************************************************
******************************************************************************/
/*
* SMS send message/command info, used for AT:
* 1> AT+CMGS
* a) text mode
* AT+CMGS=<da>[,<toda>]<CR>
* text is entered<ctrl-Z/ESC>
* b) PDU mode
* +CMGS=<length><CR>
* PDU is given<ctrl-Z/ESC>
* 2> AT+CMGC
* a) text mode
* AT+CMGC=<fo>,<ct>[,<pid>[,<mn>[,<da>[,<toda>]]]]<CR>
* text is entered<ctrl-Z/ESC>
* b) PDU mode
* +CMGC=<length><CR>
* PDU is given<ctrl-Z/ESC>
*
* SMS write and save draft message info, used for AT
* 2> AT+CMGW
* a) text mode
* +CMGW[=<oa/da>[,<tooa/toda>[,<stat>]]]<CR>
* text is entered<ctrl-Z/ESC>
* b) PDU mode
* +CMGC=<length>[,<stat>]<CR>
* PDU is given<ctrl-Z/ESC>
* =====================================
* Note:
According to 27.005
*
*
*/
typedef struct PsilSmsSendInfo_Tag
{
UINT16 reqHander; /* if set to zero, just means no sending request */
/*
* Used for PDU mode, input of: +CMGS=<length><CR> or +CMGW=<length>[,<stat>]<CR>
* <length> must indicate the number of octets coded in the TP layer data unit to be given
* (i.e. SMSC address octets are excluded)
* If set to 0, just means not set.
*
*/
UINT16 reqPduLen;
/*
* For Text mode,
* +CMGS=<da>[,<toda>]<CR>...
*
* +CMGW[=<oa/da>[,<tooa/toda>[,<stat>]]]<CR>
*
* example:
* DA: "+8613813801380"
* daInfo.len = 13
* daInfo.digits = "8613813801380\0" => string format
*/
CmiSmsAddressInfo daInfo; /* If is MO SMS message, it will be destination address. */
/*
* Concatenated SMS
* +ECCMGS=<da>[,<toda>][,<msg_ref>,<msg_max>,<msg_seq>]<CR>
*
*/
BOOL udhPresent;
UINT8 refNum;
UINT8 maxNum;
UINT8 seqNum;
UINT16 inputOffset;
BOOL bCommand; /* Whether is AT+CMGC command */
UINT8 reserved0;
UINT8 input[PSIL_SMS_MAX_TXT_SIZE + 1];
}PsilSmsSendInfo;
/*
* SMS send RP-ACK/RP-ERROR info, used for AT:
* 1> AT+CNMA
* a) PDU mode
* +CNMA=<n>,<length><CR>
* PDU is given<ctrl-Z/ESC>
* =====================================
* Note:
According to 27.005
*
*
*/
typedef struct PsilSmsSendAckInfo_Tag
{
UINT16 reqHander;
UINT8 reply;
UINT16 ackPduLen;
UINT16 ackPduOffset;
UINT8 ackPdu[PSIL_SMS_MAX_PDU_SIZE_OF_DELIVER_REPORT*2+1];
}PsilSmsSendAckInfo;
/* for +CMGW command */
typedef struct PsilSmsWriteInfo_Tag
{
UINT8 smsMsgType; /* SMS message type defined CmiSmsMessageType */
UINT8 stat; /* defined CmiSmsRecStorStatus */
UINT16 reserved0;
CmiSmsOptAddressInfo scaInfo; /* service centre address */
PsilSmsSendInfo smsSendInfo;
}PsilSmsWriteInfo;
/* for +CMGR/+CMGL/+CMSS */
typedef struct PsilSmsStoreItemInfo_tag
{
UINT8 smsRecStatus; /* SMS record status. Enum CmiSmsRecStorStatus */
UINT8 smsRecMsgType; /* SMS message type, defined type CmiSmsMessageType */
BOOL scAddrPresent; /* SC Address info present or not */
UINT8 memIndex; /* memory index */
CmiSmsAddressInfo scAddrInfo; /* SC address info */
CmiSmsPdu smsPduData; /* SMS PDU contents */
}PsilSmsStoreItemInfo;
typedef struct PsilSmsTimeStampInfo_tag
{
UINT8 year;
UINT8 month;
UINT8 day;
UINT8 hour;
UINT8 minute;
UINT8 second;
UINT8 tz; /* time zone */
UINT8 tzSign; /* '+'/'-' */
}PsilSmsTimeStampInfo;
typedef struct PsilSmsDcsInfo_Tag
{
UINT8 type;
UINT8 msgClass;
UINT8 alphabet;
UINT8 indication;
UINT8 dcs;
}PsilSmsDcsInfo;
typedef union
{
UINT8 vpRelativeFormat; /* Relative Format: 1 octet, TS-23.040 9.23.12.1 */
PsilSmsTimeStampInfo vpAbsoluteFormat; /* Absolute Format: as TP-SCTS, TS-23.040 9.23.12.2 */
UINT8 vpEnhancedFormat[PSIL_SMS_VP_OCTET_MAX_LENGTH + 1]; /* Enhanced Format: TS-23.040 9.23.12.3 */
}PsilSmsValidityPeriodValue;
typedef struct PsilSmsValidityPeriodInfo_tag
{
UINT8 vpfType; /* defined PsilSmsValidityPeriodFormat */
UINT8 reserved0;
UINT16 reserved1;
PsilSmsValidityPeriodValue vpValue;
}PsilSmsValidityPeriodInfo;
/* SMS sumbit message structure info for Text mode
* Refer to TS-23.040 9.2.2.2 */
typedef struct AtecMoSubmitSmsInfo_Tag
{
UINT8 firstOctet; /* first octet */
UINT8 protocolId; /* TP-PD */
UINT8 smsMsgRef; /* message reference */
UINT8 destAddrType; /* type of mumber for dest address */
UINT16 smsLength; /* length of body */
UINT16 reserved0;
UINT8 destAddr[PSIL_MSG_MAX_ADDR_LEN + 1]; /* TP Destination Address */
PsilSmsValidityPeriodInfo validityPreriod; /* TP-VP */
PsilSmsDcsInfo dcsInfo; /* TP-DCS */
UINT8 cnctRefNum; /* Concatenated short message reference number */
UINT8 cnctMaxNum; /* Maximum number of short messages in the concatenated short message */
UINT8 cnctSeqNum; /* Sequence number of the current short message */
UINT8 smsBuffer[PSIL_SMS_MAX_TXT_SIZE + 1]; /* msg body buffer, Hex string format */
}AtecMoSubmitSmsInfo;
typedef struct AtecMtDeliverSmsInfo_Tag
{
UINT8 firstOctet; /* first octet */
UINT8 protocolId; /* TP-PID */
UINT8 srcAddrType; /* type of mumber for originating address */
UINT16 smsLength; /* length of body */
UINT8 srcAddr[PSIL_MSG_MAX_ADDR_LEN + 1]; /* originating address string */
PsilSmsTimeStampInfo timeStamp; /* TP-SCTS */
PsilSmsDcsInfo dcsInfo; /* TP-DCS */
UINT8 cnctRefNum; /* Concatenated short message reference number */
UINT8 cnctMaxNum; /* Maximum number of short messages in the concatenated short message */
UINT8 cnctSeqNum; /* Sequence number of the current short message */
UINT8 smsBuffer[PSIL_SMS_MAX_TXT_SIZE + 1]; /* message body buffer pdu string */
}AtecMtDeliverSmsInfo;
/* SMS status report structure info for Text mode */
typedef struct AtecStatusRptSmsInfo_Tag
{
UINT8 firstOctet; /* <fo> first octet */
UINT8 tpMr; /* <mr> TP-MR */
UINT8 reciptAddr[PSIL_MSG_MAX_ADDR_LEN + 1]; /* <ra> TP-Recipient-Address string */
UINT8 reciptAddrType; /* <tora> type of mumber for TP-Recipient-Address */
PsilSmsTimeStampInfo scTimeStamp; /* <scts> TP-Service-Centre-Time-Stamp */
PsilSmsTimeStampInfo destTime; /* <dt> TP-Discharge-Time */
UINT8 tpStatus; /* <st> TpStatus */
}AtecStatusRptSmsInfo;
/* SMS submit report structure info for Text mode */
typedef struct AtecSubmitRptSmsInfo_Tag
{
UINT8 firstOctet; /* first octet */
UINT8 tpFcs; /* TP-Failure-Cause */
UINT8 tpPi; /* TP-Parameter-Indicator */
PsilSmsTimeStampInfo scTimeStamp; /* <scts> TP-Service-Centre-Time-Stamp */
}AtecSubmitRptSmsInfo;
/* concatnated SMS 8Bit IE data
* Refer to TS-23.040 9.2.3.24.1 */
typedef struct UdhIeConcatenatedSms8Bit_Tag
{
UINT8 refNum; /* Octet 1 Concatenated short message reference number */
UINT8 maxNum; /* Octet 2 Maximum number of short messages in the concatenated short message */
UINT8 seqNum; /* Octet 3 Sequence number of the current short message */
}UdhIeConcatenatedSms8Bit;
typedef struct UdhIe_Tag
{
TypeOfUdhIeId ieId;
union
{
UdhIeConcatenatedSms8Bit concatenatedSms8Bit; /* UDH_IEI_CONCATENATED_SMS_8_BIT */
/* TS-23.040 9.2.3.24 TP-User Data (TP-UD).The support of other Information Element Identifier is not implemented now */
}ieData;
}UdhIe;
/* TS-23.038 5 CBS Data Coding Scheme */
typedef enum PsilCbsLanguage_Tag
{
PSIL_SMS_CBS_LANG_GERMAN = 0x00,
PSIL_SMS_CBS_LANG_ENGLISH = 0x01,
PSIL_SMS_CBS_LANG_ITALIAN = 0x02,
PSIL_SMS_CBS_LANG_FRENCH = 0x03,
PSIL_SMS_CBS_LANG_SPANISH = 0x04,
PSIL_SMS_CBS_LANG_DUTCH = 0x05,
PSIL_SMS_CBS_LANG_SWEDISH = 0x06,
PSIL_SMS_CBS_LANG_DANISH = 0x07,
PSIL_SMS_CBS_LANG_PORTUGUESE = 0x08,
PSIL_SMS_CBS_LANG_FINNISH = 0x09,
PSIL_SMS_CBS_LANG_NORWEGIAN = 0x0A,
PSIL_SMS_CBS_LANG_GREEK = 0x0B,
PSIL_SMS_CBS_LANG_TURKISH = 0x0C,
PSIL_SMS_CBS_LANG_HUNGARIAN = 0x0D,
PSIL_SMS_CBS_LANG_POLISH = 0x0E,
PSIL_SMS_CBS_LANG_UNSPECIFIED = 0x0F,
PSIL_SMS_CBS_LANG_CZECH = 0x20,
PSIL_SMS_CBS_LANG_HEBREW = 0x21,
PSIL_SMS_CBS_LANG_ARABIC = 0x22,
PSIL_SMS_CBS_LANG_RUSSIAN = 0x23,
PSIL_SMS_CBS_LANG_ICELANDIC = 0x24
}PsilCbsLanguage;
typedef struct PsilCbsDcsInfo_Tag
{
BOOL isCompressed;
BOOL isLanguageIncluded;
UINT8 cbLanguage; //PsilCbsLanguage
UINT8 alphabet;
UINT8 cbClass; //CmiSmsMessageClass
}PsilCbsDcsInfo;
/******************************************************************************
*****************************************************************************
* API
*****************************************************************************
******************************************************************************/
CmsRetId smsQuerySmsService(UINT32 atHandle);
CmsRetId smsGetSmsService(UINT32 atHandle);
CmsRetId smsSetSmsService(UINT32 atHandle, const UINT32 service);
BOOL smsGetSCAddrFromNvm(CmiSmsAddressInfo *pSmscAddr);
CmsRetId smsGetSrvCenterAddr(UINT32 atHandle, CmiSmsAddressInfo *pScAddressinfo);
CmsRetId smsSetSrvCenterAddr(UINT32 atHandle, const UINT8 *addressStr, UINT16 addrStrLen, UINT32 toaOctType);
void smsResetSrvCenterAddr(void);
void smsPduDecodeAddress(UINT8 *pduData, UINT8 *pOffset, UINT8 *pAddressType, UINT8 *pAddress, UINT8 addressSize);
void smsPduDecodeDcs(UINT8 *pduData, UINT8 *pOffset, PsilSmsDcsInfo *pDcsInfo);
void smsPduDecodeTimeStamp(UINT8 *pduData, UINT8 *pOffset, PsilSmsTimeStampInfo *pTimeStamp);
void smsPduDecodeUserData(UINT8 *pUserData,
UINT8 pduDataLen,
PsilMsgCodingType codingType,
BOOL hdrPresent,
UINT8 *pOutData,
UINT16 *pSmsLength,
UINT16 dstBufSize,
UdhIe *pUdhIe);
CmsRetId smsSendSms(UINT8 smsFormat, PsilSmsSendInfo *pSendInfo);
CmsRetId smsWriteSms(UINT8 smsFormat, PsilSmsWriteInfo *pWriteInfo, UINT8 smsMemType, UINT8* memIndex);
CmsRetId smsSendStoredSms(UINT32 atHandle, BOOL daPresent, CmiSmsAddressInfo *pDestAddrInfo, PsilSmsStoreItemInfo *pSendInfo);
CmsRetId smsPduReplaceDestAddress(CmiSmsAddressInfo *pNewDestAddrInfo, CmiSmsPdu *pInSmsPdu, CmiSmsPdu *pOutSmsPdu);
CmsRetId smsReadSmsFromNvm(UINT8 memIndex, PsilSmsStoreItemInfo *pReadSmsInfo);
BOOL SmsSubmitPduToText(AtecMoSubmitSmsInfo *pMoSumbitInfo, CmiSmsPdu *pPduData);
BOOL SmsDeliverPduToText(AtecMtDeliverSmsInfo *pMtDeliverInfo, CmiSmsPdu *pPduData);
UINT16 errorCauseofSendSms(UINT16 rc, UINT8 rpCause, UINT8 tpCause, UINT16 errorCode);
void smsSmscToHexStrPdu(CmiSmsAddressInfo *pScaInfo, CHAR *pSmsc, UINT16 *pSmscLen);
CmsRetId smsSetMoreMessageMode(UINT32 atHandle, const UINT8 mode);
CmsRetId smsGetMoreMessageState(UINT32 atHandle);
CmsRetId smsGetCscbSetting(UINT32 atHandle);
CmsRetId smsSetCscbSetting(UINT32 atHandle, BOOL mode, CHAR *pMids, CHAR *pDcss);
CmsRetId smsGetStoredInSimSmsMsg(UINT32 atHandle, UINT8 readIndex, UINT8 readMode);
CmsRetId smsSetStoredInSimSmsMsg(UINT32 atHandle, UINT8 savedMode, UINT8 smsStatus, BOOL scAddrPresent, CmiSmsAddressInfo * pScAddr, CmiSmsPdu * pSavedSmsPdu);
CmsRetId smsDelStoredInSimSmsMsg(UINT32 atHandle, UINT8 delIndex, UINT8 delFlag);
CmsRetId smsGetPrefMemStorageInfoInSim(UINT32 atHandle, UINT8 listMode);
CmsRetId smsListSmsStoredInSimSmsMsg(UINT32 atHandle, UINT8 listStatus);
BOOL smsStateStrToInt(CHAR *statString, UINT8 *pStat);
BOOL smsStateIntToStr(UINT8 stat, CHAR *pStatString);
PsilSmsStoreMemType smsGetSmsPrefMsgStorageType(PsilSmsStoreMemNum memDomain);
CmsRetId smsReadSmsStoreRecord(UINT32 atHandle, UINT8 memIndex, UINT8 smsMemType, UINT8 readCmd, PsilSmsStoreItemInfo * pReadSmsInfo);
CmsRetId smsUpdateSmsToNvm( UINT8 memIndex, PsilSmsStoreItemInfo *pStoreSmsInfo);
CmsRetId smsUpdateSmsStoreRecord(UINT8 memIndex, UINT8 smsMemType, PsilSmsStoreItemInfo * pReadSmsInfo);
CmsRetId smsDeleteSmsStoreRecord(UINT32 atHandle, CmiSmsOperationMode delOperat, UINT8 smsMemType, UINT8 delIndex, CmiSmsDelFlag delFlag);
CmsRetId smsSetSmsp(UINT32 atHandle);
CmsRetId smsSendSMMA(UINT32 atHandle);
BOOL smsSubmitTpduLen(UINT8 *pTpduLen, CmiSmsPdu *pPduData);
BOOL smsDeliverTpduLen(UINT8 *pTpduLen, CmiSmsPdu *pPduData);
BOOL SmsStatusRptPduToText(AtecStatusRptSmsInfo *pStatusRptInfo, CmiSmsPdu *pPduData);
void smsDecodeCbsData(UINT8 *pPdu, UINT8 pduDataLen, PsilMsgCodingType codingType, UINT8 *pOutData, UINT8 *pOutLength, UINT8 dstBufSize);
UINT16 smsAsciiToUcs2(const UINT8 *pAscii, UINT16 iLengh, UINT8 *pUcs2, UINT16 oLengh);
UINT16 smsUcs2ToAscii(const UINT8 *pUcs2, UINT16 iLengh, UINT8 *pAscii, UINT16 oLengh);
CmsRetId smsSetMemCap(UINT32 atHandle, BOOL isMemCapExceed);
BOOL SmsSubmitRptPduToText(AtecSubmitRptSmsInfo *pSubmitRptInfo, CmiSmsPdu *pPduData, BOOL bePositiveAck);
void smsPduDecodeCbsDCS(UINT8 *pduData, UINT8 *pOffset, PsilCbsDcsInfo *pDcsInfo);
void smsSendNewMsgRsp(UINT32 reqHandle, UINT8 smsId, UINT32 reply, UINT8 tpCause, UINT16 ackPduLen, UINT8 *ackPdu);
CmsRetId smsSrvCenterAddrToText(CHAR *smscBuf, UINT8 smscBufLen, CmiSmsAddressInfo *scAddrInfo);

View File

@@ -0,0 +1,47 @@
#ifndef __PS_STK_BIP_API_H__
#define __PS_STK_BIP_API_H__
/******************************************************************************
******************************************************************************
Copyright: - 2017- Copyrights of AirM2M Ltd.
File name: - psstk_bip_api.h
Description: - API called by psproxy task
******************************************************************************
******************************************************************************/
#include <osasys.h>
/******************************************************************************
*****************************************************************************
* MARCO
*****************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* ENUM
*****************************************************************************
******************************************************************************/
/******************************************************************************
******************************************************************************
* External global variable
******************************************************************************
******************************************************************************/
/******************************************************************************
*****************************************************************************
* Functions
*****************************************************************************
******************************************************************************/
void psStkBipProcCmiInd(const SignalBuf *indSignalPtr);
void psStkBipProcCmiCnf(const SignalBuf *cnfSignalPtr);
/*
* processed the signal send to STK CMS, if processed, return TRUE
*/
BOOL psStkBipProcSimBipSig(const SignalBuf *pSig);
#endif

View File

@@ -0,0 +1,634 @@
/******************************************************************************
* (C) Copyright 2018 AirM2M International Ltd.
* All Rights Reserved
*******************************************************************************
* Filename: cms_sock_mgr.h
*
* Description: cms socket manager API header file
*
* History:create by xwang
*
* Notes:
*
******************************************************************************/
#ifndef __CMS_SOCK_MGR_H__
#define __CMS_SOCK_MGR_H__
#include "commontypedef.h"
#include "cmicomm.h"
#include "ip_addr.h"
#include "pssys.h"
#include "lwip/opt.h"
#include "apmu_external.h"
/******************************************************************************
*****************************************************************************
* MARCO
*****************************************************************************
******************************************************************************/
#define CMS_LIMIT_DL_BUFFER_OPT
#define CMS_SOCK_MGR_CONTEXT_NUM_MAX 12
#define CMS_SOCK_MGR_CLIENT_PORT 60002
#define CMS_SOCK_MGR_SERVER_PORT 60003
#define CMS_SOCK_MGR_ASYNC_REQUEST_MAGIC 0x1234
#define CMS_SOCK_MGR_SYNC_REQUEST_MAGIC 0x4321
#define CMS_SOCK_MGR_EVENT_MAGIC 0x1111
#define CMS_SOCK_MGR_RESPONSE_LEN_MAX 256 //bytes
#define CMS_SOCK_MGR_CONNECT_TIMEOUT 31 //seconds
#define CMS_SOCK_MGR_UL_DATA_SEQUENCE_MAX 255
#define CMS_SOCK_MGR_UL_DATA_SEQUENCE_MIN 1
#define CMS_SOCK_MGR_DNS_RESOLVE_RESULT_REQ_ID 200
#define CMS_SOCK_MGR_MESSAGE_MAGIC 0xAABB
#define CMS_SOCK_MGR_MESSAGE_LENGTH_MAX 124
#define CMS_SOCK_MGR_CONTEXT_MAGIC 0xABCD
#define CMS_SOCK_MGR_TCP_CONTEXT_MAGIC 0xBCDA
#define CMS_SOCK_MGR_UDP_CONTEXT_MAGIC 0xCDAB
#define CMS_SOCK_MGR_HIB_PRIVATE_CONTEXT_MAX_LENGTH 32
#define CMS_SOCK_MGR_DATA_HEADER_LENGTH_MAX 64
#define CMS_SOCK_ONE_MGR_DL_LENGTH_MAX 1460
#ifdef CMS_LIMIT_DL_BUFFER_OPT
#define CMS_SOCK_TOTAL_MGR_DL_LENGTH_MAX (12*1024) //max 12K DL PDU buffer
#else
#define CMS_SOCK_TOTAL_MGR_DL_LENGTH_MAX (20*1024) //max 20K DL PDU buffer
#endif
#define CMS_SOCK_MGR_SELECT_WAIT_TIME_MISECONDS (500) //Microseconds
#define CMS_SOCK_RECV_RAWDATA_PADDING_LEN (10)
#define CMS_SOCK_UL_PENDING_TIMEOUT_SECONDS_MAX (10)
#define CMSSOCKMGR_CHECK_SOURCE(source) (((source) > (SOCK_SOURCE_MINI)) && ((source) < (SOCK_SOURCE_MAX)))
#define CMSSOCKMGR_CHECK_TYPE(type) (((type) == (SOCK_CONN_TYPE_UDP)) || ((type) == (SOCK_CONN_TYPE_TCP)))
#define CMSSOCKMGR_EXPECT_CLIENT_SOCKET_ID (MEMP_NUM_NETCONN + LWIP_SOCKET_OFFSET - 2)
#define CMSSOCKMGR_EXPEXT_SERVER_SOCKET_ID (MEMP_NUM_NETCONN + LWIP_SOCKET_OFFSET - 1)
/*this define how long to report close event under connect state*/
#define CMS_SOC_REF_SOCK_TIMEOUT_MAX (30)
/******************************************************************************
*****************************************************************************
* ENUM
*****************************************************************************
******************************************************************************/
typedef enum{
SOCK_MGR_MESSAGE_TYPE_REQUEST = 1,
SOCK_MGR_MESSAGE_TYPE_EVENT = 2,
}CmsSockMgrMessageType;
typedef enum{
SOCK_CONN_TYPE_UDP = 1,
SOCK_CONN_TYPE_TCP = 2,
}CmsSockMgrConnType;
typedef enum{
SOCK_MGR_DATA_TYPE_RAW = 1,
SOCK_MGR_DATA_TYPE_HEX_STRING = 2,
}CmsSockMgrDataType;
typedef enum{
SOCK_SOURCE_MINI = 0,
SOCK_SOURCE_ATSKT ,
SOCK_SOURCE_ECSOC ,
SOCK_SOURCE_ATQIREF ,
SOCK_SOURCE_SDKAPI ,
SOCK_SOURCE_ECSRVSOC ,
SOCK_SOURCE_MAX ,
}CmsSockMgrSource;
typedef enum{
SOCK_EVENT_CONN_STATUS = 0,
SOCK_EVENT_CONN_DL = 1,
SOCK_EVENT_CONN_UL_STATUS = 2,
SOCK_EVENT_CONN_ERROR = 3,
SOCK_EVENT_CONN_TCP_ACCEPT_CLIENT = 4, //for tcp server mode, accept client connection event
SOCK_EVENT_CONN_TCP_REFUSE_CLIENT = 5,
SOCK_EVENT_CONN_UL_TOTAL_STATUS =6,
SOCK_EVENT_PROC_UL_PENDINGLIST =7,
SOCK_EVENT_PROC_CONNECT_TIMEOUT_CLOSE = 8, /* this error is :
1> received the error event under connect state
2> dl data list has pendding data
*/
SOCK_EVENT_CONN_MAX = 255,
}CmsSockMgrEventType;
typedef enum{
SOCK_CONN_STATUS_CLOSED = 0,
SOCK_CONN_STATUS_CREATED = 1,
SOCK_CONN_STATUS_CONNECTING = 2,
SOCK_CONN_STATUS_CONNECTED = 3,
SOCK_CONN_DNS_RESOLVING = 4,
SOCK_CONN_STATUS_CLOSING = 5,
}CmsSockMgrConnStatus;
typedef enum{
SOCK_MGR_IND_UL_STATUS = 1,
SOCK_MGR_IND_UL_TOTAL_LEN_STATUS = 2,
}CmsSockMgrInd;
typedef enum{
SOCK_CONN_UL_STATUS_SUCCESS = 0,
SOCK_CONN_UL_STATUS_FAIL = 1,
}CmsSockMgrConnUlStatus;
typedef enum{
SOCK_MGR_ACTION_OK = 1,
SOCK_MGR_ACTION_TIMEOUT = 2,
SOCK_MGR_ACTION_FAIL = 3,
}CmsSockMgrActionResult;
typedef enum {
SOCK_MGR_UL_SEQUENCE_STATE_DISCARD = 0,
SOCK_MGR_UL_SEQUENCE_STATE_SENT = 1,
}CmsSockMgrUlStatusResult;
typedef enum {
/*
* 401 - 500 are reserved for socket error
*/
CME_SOCK_MGR_ERROR_BASE = 401,
CME_SOCK_MGR_ERROR_PARAM_ERROR, //parameter error
CME_SOCK_MGR_ERROR_TOO_MUCH_INST, //too much socket instance
CME_SOCK_MGR_ERROR_CREATE_SOCK_ERROR, //create socket error
CME_SOCK_MGR_ERROR_OPERATION_NOT_SUPPORT, //operation not support
CME_SOCK_MGR_ERROR_NO_FIND_CLIENT, //operation not support
CME_SOCK_MGR_ERROR_CONNECT_FAIL, //connect failed
CME_SOCK_MGR_ERROR_BIND_FAIL, //bind failed
CME_SOCK_MGR_ERROR_SEND_FAIL, //send failed
CME_SOCK_MGR_ERROR_NO_CONNECTED, //connect failed
CME_SOCK_MGR_ERROR_IS_CONNECTED, //already connected
CME_SOCK_MGR_ERROR_INVALID_STATUS,
CME_SOCK_MGR_ERROR_CONNECT_TIMEOUT,
CME_SOCK_MGR_ERROR_DELETE_FAIL,
CME_SOCK_MGR_ERROR_SOCK_ERROR, //socket error
CME_SOCK_MGR_ERROR_NO_MEMORY,
CME_SOCK_MGR_ERROR_NO_MORE_DL_BUFFER_RESOURCE,
CME_SOCK_MGR_ERROR_CONNECT_IS_ONGOING,
CME_SOCK_MGR_ERROR_UL_SEQUENCE_INVALID,
CME_SOCK_MGR_ERROR_SEND_REQUEST_FAIL,
CME_SOCK_MGR_ERROR_SERVER_HASE_CREATED,
CME_SOCK_MGR_ERROR_SET_DNS_SERVER_FAIL,
CME_SOCK_MGR_ERROR_DNS_RESOLVE_FAIL,
CME_SOCK_MGR_ERROR_LISTERN_FAIL,
CME_SOCK_MGR_ERROR_SET_OPTION_FAIL,
CME_SOCK_MGR_ERROR_PDP_CONTEXT_DEACTIVE,
CME_SOCK_MGR_ERROR_PDP_CONTEXT_BIND_FAIL,
CME_SOCK_MGR_ERROR_CONNECT_ID_USED,
CME_SOCK_MGR_ERROR_UNKNOWN,
CME_SOCK_MGR_ERROR_MAX = 500
}CmsSockMgrErrorCode;
typedef enum {
/*
* 0, 550 - 574 are reserved for ref socket error
*/
CME_REF_SOCK_SUCC = 0, //Operation success
CME_REF_SOCK_UNKNOWN_ERROR = 550, //Unknown error
CME_REF_SOCK_OPERATION_BLOCKED = 551, //Operation blocked
CME_REF_SOCK_INVALID_PARAM = 552, //Invalid parameters
CME_REF_SOCK_MEM_NOT_ENOUGH = 553, //Memory not enough
CME_REF_SOCK_SOCK_CREATE_FAIL = 554, //Socket creation failed
CME_REF_SOCK_OPERATION_NOT_SUPPORT = 555, //Operation not supported
CME_REF_SOCK_SOCK_BIND_FAIL = 556, //Socket bind failed
CME_REF_SOCK_SOCK_LISTEN_FAIL = 557, //Socket listen failed
CME_REF_SOCK_SOCK_WRITE_FAIL = 558, //Socket write failed
CME_REF_SOCK_SOCK_READ_FAIL = 559, //Socket read failed
CME_REF_SOCK_ACCEPT_FAIL = 560, //Socket accept failed
CME_REF_SOCK_PDP_CTX_OPEN_FAIL = 561, //PDP context opening failed
CME_REF_SOCK_PDP_CTX_CLOSE_FAIL = 562, //PDP context closure failed
CME_REF_SOCK_SOCK_ID_HAS_BEEN_USED = 563, //Socket Identity has been used
CME_REF_SOCK_DNS_BUSY = 564, //DNS busy
CME_REF_SOCK_DNS_PARSE_FAIL = 565, //DNS parse failed
CME_REF_SOCK_SOCK_CONNECT_FAIL = 566, //Socket connect failed
CME_REF_SOCK_SOCK_HAS_BEEN_CLOSE = 567, //Socket has been closed
CME_REF_SOCK_OPERATION_BUSY = 568, //Operation busy
CME_REF_SOCK_OPERATION_TIMEOUT = 569, //Operation timeout
CME_REF_SOCK_PDP_CTX_BROKEN_DOWN = 570, //PDP contet broken down
CME_REF_SOCK_CANCEL_SENDING = 571, //Cancel sending
CME_REF_SOCK_OPERATION_NOT_ALLOWED = 572, //Operation not allowed
CME_REF_SOCK_APN_NOT_CONFIGURED = 573, //APN not configured
CME_REF_SOCK_PORT_BUSY = 574, //Port busy
CME_REF_SOCK_SOCK_OPTION_SET_FAIL = 575, //Port busy
/*here is a internal error for showing URC to applayer*/
CME_REF_SOCK_BUFFSIZE_NOT_ENOUGH = 800,
CME_REF_SOCK_MGR_ERROR_PARAM_ERROR = 801,
CME_REF_SOCK_MGR_WRITE_IS_ONGOING = 802, /*in this case the send length is litter than expect length, cms will
continue to send the buffer,and NOT directly response SEND CNF until
all raw data sent out*/
CME_REF_SOCK_ERROR_MAX = 1024,
}CmsRefSockErrorCode;
/******************************************************************************
*****************************************************************************
* structure
*****************************************************************************
******************************************************************************/
typedef struct CmsSockDlBufContext_Tag
{
UINT16 dlLen; //the dl rawdata total len
UINT16 remotePort;
INT32 sockId;
ip_addr_t remoteAddr;
void *pData;
struct CmsSockDlBufContext_Tag *pNext;
}CmsSockDlBufContext;
typedef struct CmsSockUlPendingPriData_Tag
{
UINT8 accMode; /*AcceMode: 0,buffer mode;1.direct transfer mode;3. passthrough mode*/
UINT8 primId; /*requst prim id*/
UINT16 offset; /*this flag marks the actural rawData send position when re-transmit */
UINT32 atHandle; /*at request handle, for response Send CNF*/
UINT8 rawData[]; /*the actual send raw data*/
}CmsSockUlPendingPriData;
typedef struct CmsSockUlPendingList_Tag
{
INT32 sockId; /*the sockId*/
UINT16 leftLen; /*the send raw datalength*/
UINT16 remotePort; /*remote port*/
ip_addr_t remoteAddr; /*remote address*/
UINT32 addTicks; /*record the time that raw data adds into pending list*/
struct CmsSockUlPendingList_Tag *pNext;
UINT8 pData[];
}CmsSockUlPendingList;
typedef struct CmsSockMgrContext_Tag{
INT32 sockId; //the socket connection id
UINT8 source; //CmsSockMgrSource
UINT8 type; //CmsSockMgrConnType
BOOL hibEnable; //whether the socketid enable HIB/SLEEP2 option
UINT8 status; //the socket connection status
UINT8 bServer; //the flag indicate whether the connection is or not server connection
UINT8 hWaterOccur; //the flag that current this socket whether has reach highwater
UINT16 localPort;
UINT8 domain;
UINT8 errorThenCloseFlag:1;
UINT8 resv0: 7 ;
UINT16 dlCacheCalLen; /*Cal the DL buffer has Malloc but Not send out buffer size*/
ip_addr_t localAddr;
UINT32 connectStartTicks;
UINT32 dlMaxLen;
void *eventCallback; //error/dl/ul status event callback
CmsSockDlBufContext *pDlBufContext;
CmsSockUlPendingList *pUlPendingList;
struct CmsSockMgrContext_Tag *next;
UINT8 priContext[]; //the sock mgr private context
}CmsSockMgrContext;
/*
*
*-------------------------------------------------------------------
|CmsSockMgrDataContext | |
*-------------------------------------------------------------------
*--------------^ dlPdu data ^
* DlPduBlock | | | |
*--------------| | | |
*^ pPdu--------| | --------
*| |
*-------------------------|
*/
typedef struct CmsSockMgrDataContext_Tag{
UINT16 type; //data type, CmsSockMgrDataType
UINT16 Length; //rcv data lenghth
UINT16 totalLen; //dlpdu->length
UINT16 offset; // the data point of the pdu,dlPdu->pPdu + offset, init the offset as sizeof(CmsSockMgrDataContext)
DlPduBlock *dlPdu;
struct CmsSockMgrDataContext_Tag *pNext;
CHAR header[CMS_SOCK_MGR_DATA_HEADER_LENGTH_MAX];
CHAR data[];
}CmsSockMgrDataContext;
typedef struct CmsSockMgrMessage_Tag{
UINT16 magic; //CMS_SOCK_MGR_MESSAGE_MAGIC
UINT8 type; //CmsSockMgrMessageType
UINT8 rsvd;
UINT8 body[CMS_SOCK_MGR_MESSAGE_LENGTH_MAX];
}CmsSockMgrMessage;
typedef struct CmsSockMgrRequest_Tag{
UINT16 magic;
UINT16 reqId;
UINT32 reqTicks;
UINT16 timeout;
UINT8 source;
UINT8 rsvd;
void *reqBody; /* heap memory, struct desided by "reqId" */
}CmsSockMgrRequest;
typedef struct CmsSockMgrEvent_Tag{
UINT16 magic; //CMS_SOCK_MGR_EVENT_MAGIC
UINT16 eventId; //CmsSockMgrInd
UINT8 eventBody[CMS_SOCK_MGR_MESSAGE_LENGTH_MAX - 4];
}CmsSockMgrEvent;
typedef struct CmsSockMgrResponse_Tag{
UINT8 source;
UINT8 reqId;
UINT16 bodyLen; // < CMSSOCKMGRRESPONSELEN_MAX
UINT8 body[];
}CmsSockMgrResponse;
typedef struct CmsSockMgrConnStatusArg_Tag{
UINT8 oldStatus; //CmsSockMgrConnStatus
UINT8 newStatus;
UINT16 cause;
}CmsSockMgrConnStatusArg;
typedef struct CmsSockMgrConnDlArg_Tag{
UINT16 fromPort;
UINT16 rsvd;
ip_addr_t fromAddr;
CmsSockMgrDataContext *dataContext;
}CmsSockMgrConnDlArg;
typedef struct CmsSockMgrConnUlStatusArg_Tag{
UINT8 sequence;
UINT8 status; //CmsSockMgrConnUlStatus
UINT16 rsvd;
}CmsSockMgrConnUlStatusArg;
typedef struct CmsSockMgrConnErrArg_Tag{
INT32 errCode;
}CmsSockMgrConnErrArg;
typedef struct CmsSockMgrConnAcceptClientArg_Tag{
INT32 serverSocketId;
INT32 clientSocketId;
UINT16 clientPort;
UINT16 rsvd;
ip_addr_t clientAddr;
}CmsSockMgrConnAcceptClientArg;
typedef struct CmsSockUlPendingListArg_Tag{
UINT8 failCause; /*if failCause is not equal to 0,this is failed*/
UINT8 resv0;
UINT16 resv1;
void *pList;
}CmsSockUlPendingEventArg;
typedef struct CmsSockMgrConnRefuseClientArg_Tag{
INT32 serverSocketId;
INT32 clientSocketId;
UINT16 clientPort;
UINT16 cause;
ip_addr_t clientAddr;
}CmsSockMgrConnRefuseClientArg;
typedef struct CmsSockMgrConnUlTotalStatusArg_Tag{
UINT32 totalLen;
}CmsSockMgrConnUlTotalStatusArg;
enum {
CMS_SOCK_MGR_UL_SEQUENCE_STATE_DISCARD = 0,
CMS_SOCK_MGR_UL_SEQUENCE_STATE_SENT = 1,
};
typedef struct CmsSockMgrUlStatusInd_Tag{
INT32 sockId;
INT32 ulStatus;//0->success, 1->fail/discard
UINT32 sequence_state_bitmap[8];
}CmsSockMgrUlStatusInd;
typedef struct CmsSockMgrUlTotalStatusInd_Tag{
INT32 socketId;
UINT32 hasSentTotalLent;
}CmsSockMgrUlTotalStatusInd;
typedef struct CmsCockMgrDnsResolveResult_tag
{
UINT8 result;
UINT8 rsvd0;
UINT16 rsvd1;
ip_addr_t addrinfo;
CHAR url[DNS_MAX_NAME_LENGTH];
}CmsCockMgrDnsResolveResult;
typedef struct CmsSockMgrConnHibContext_Tag{
UINT16 magic;
UINT8 source;
UINT8 type;
INT32 sockId;
UINT8 status;
UINT8 domain;
UINT16 localPort;
ip_addr_t localAddr;
void *eventCallback;
UINT8 priContext[CMS_SOCK_MGR_HIB_PRIVATE_CONTEXT_MAX_LENGTH];
}CmsSockMgrConnHibContext; //64 bytes
typedef struct CmsSockMgrHibContext_Tag{
UINT16 magic; //CMS_SOCK_MGR_CONTEXT_MAGIC
UINT16 flag;
CmsSockMgrConnHibContext tcpContext; //64 bytes
CmsSockMgrConnHibContext udpContext; //64 bytes
}CmsSockMgrHibContext; // 92 bytes
typedef enum CmsRefSockDataFormat_Tag
{
REF_SOCK_DATA_FORMAT_TEXT = 0,
REF_SOCK_DATA_FORMAT_HEX = 1
}CmsRefSockDataFormat;
typedef enum CmsRefSockViewMode_Tag
{
REF_SOCK_VIEW_MODE_HEADER_NEWLING_DATA = 0,//data header\r\ndata
REF_SOCK_VIEW_MODE_HEADER_COMMA_DATA = 1//data header,data
}CmsRefSockViewMode;
typedef enum CmsRefSockDataTransMode_Tag
{
REF_SOCK_DATA_TRANS_MODE_DISABLE_BLOCK = 0,//disable block mode
REF_SOCK_DATA_TRANS_MODE_ENABLE_STREAM = 1//enable stream mode
}CmsRefSockDataTransMode;
typedef struct CmsRefSockTcpKeepAliveParam_Tag
{
UINT16 idleTime;//cycle time to trigger keepalive, range value: 1-1800 sec
UINT8 intervalTime;//range value:24-100 sec
UINT8 probeCnt;//range value: 3-10
}CmsRefSockTcpKeepAliveParam;
typedef struct CmsRefSockCfgParam_Tag
{
UINT16 transPktSize; //transport paket size, range: 1-1460, def 1024 bytes
UINT8 transWaitTm; //range: 0-20, def: 2 ms
UINT8 rsvd;
CmsRefSockDataFormat sendDataFormat;
CmsRefSockDataFormat recvDataFormat;
CmsRefSockViewMode viewMode;
CmsRefSockDataTransMode udpRdMode;//UPD read mode
CmsRefSockDataTransMode udpSendMode;//UDP send mode
UINT8 bPassiveClose:1;//indicated whether auto disconnect when server close enable or not
UINT8 bRecvInd:1;//indicated whether show length in recv URC on cache mode
UINT8 bTcpServerAutoAccept:1;//indicated whether TCP auto accept enable or not
UINT8 bTcpKeepAlive:1;//indicated whether TCP keep alive enable or not
UINT8 bSendEcho:1;//indicated whether echo sent data by AT+QISDE enable or not
UINT8 bSendInfoFlag:1 ;/*show QISEND/QISENDEX result 0 : not with URC;1: with +QISEND URC */
UINT8 bresv:2;
CmsRefSockTcpKeepAliveParam tcpKeepAliveParam;
}CmsRefSockCfgParam; // 14 bytes
typedef void (*CmsSockMgrReqProcess)(CmsSockMgrRequest *Req, ip_addr_t *sourceAddr, UINT16 sourcePort, INT32 rcvRequestFd);
typedef void (*CmsSockMgrEventCallback)(CmsSockMgrContext *mgrContext, CmsSockMgrEventType eventType, void *eventArg);
typedef BOOL (*CmsSockMgrCheckHibMode)(CmsSockMgrContext *mgrContext);
typedef void (*CmsSockMgrStoreConnContext)(CmsSockMgrContext *sockMgrContext, CmsSockMgrConnHibContext *hibContext);
typedef void (*CmsSockMgrRecoverConnContext)(CmsSockMgrConnHibContext *hibContext);
typedef BOOL (*CmsSockMgrTcpServerProcessAcceptClient)(CmsSockMgrContext* gMgrContext, INT32 clientSocketId, ip_addr_t *clientAddr, UINT16 clientPort);
typedef struct cmsSockMgrHandleDefine_Tag{
UINT32 source;
CmsSockMgrReqProcess reqProcess;
CmsSockMgrCheckHibMode hibCheck;
CmsSockMgrStoreConnContext storeHibContext;
CmsSockMgrRecoverConnContext recoverHibContext;
CmsSockMgrTcpServerProcessAcceptClient tcpServerProcessAcceptClient;
}CmsSockMgrHandleDefine;
typedef struct CmsSockMgrDynamicHandleList_Tag{
CmsSockMgrHandleDefine handle;
struct CmsSockMgrDynamicHandleList_Tag *next;
}CmsSockMgrDynamicHandleList;
/******************************************************************************
*****************************************************************************
* function
*****************************************************************************
******************************************************************************/
//get ticks
UINT32 cmsSockMgrGetCurrHibTicks(void);
UINT32 cmsSockMgrGetCurrentSysTicks(void);
//cms sock mgr context related
CmsSockMgrContext* cmsSockMgrGetContextList(void);
CmsSockMgrContext* cmsSockMgrGetFreeMgrContext(UINT16 priLen);
CmsSockMgrContext* cmsSockMgrFindMgrContextById(INT32 id);
void cmsSockMgrRemoveContextById(INT32 id);
void cmsSockMgrRemoveContext(CmsSockMgrContext *context);
//cms sock related
INT32 cmsSockMgrCreateSocket(INT32 domain, INT32 type, INT32 protocol, INT32 expect_fd);
INT32 cmsSockMgrBindSocket(INT32 fd, UINT8 domain, UINT16 localPort, ip_addr_t *localAddr);
INT32 cmsSockMgrConnectSocket(INT32 fd, UINT8 domain, UINT16 remotePort, ip_addr_t *remoteAddr, BOOL withTimeout);
INT32 cmsSockMgrCloseSocket(INT32 fd);
INT32 cmsSockMgrCreateTcpSrvSocket(INT32 domain, UINT16 listenPort, ip_addr_t *bindAddr, UINT8 listenNum, INT32 expect_fd);
CmsSockMgrConnStatus cmsSockMgrRebuildSocket(INT32 fd, ip_addr_t *localAddr, ip_addr_t *remoteAddr, UINT16 *localPort, UINT16 *remotePort, INT32 type);
CmsSockMgrConnStatus cmsSockMgrReCreateSocket(INT32 fd, INT32 domain, INT32 type);
//cms sock ul sequence status related
BOOL cmsSockMgrGetUlPendingSequenceState(UINT32 bitmap[8], UINT8 sequence);
void cmsSockMgrUpdateUlPendingSequenceBitMapState(UINT32 bitmap[8], UINT8 sequence, BOOL bActive);
//cms sock send request related
CmsSockMgrActionResult cmsSockMgrSendAsyncRequest(UINT16 reqId, void *reqBody, CmsSockMgrSource source);
CmsSockMgrActionResult cmsSockMgrSendsyncRequest(UINT16 reqId, void *reqBody, CmsSockMgrSource source, CmsSockMgrResponse *response, UINT16 timeout);
//event callback related
void csmsSockMgrCallErrorEventCallback(CmsSockMgrContext* gMgrContext, INT32 errorCode);
void cmsSockMgrCallStatusEventCallback(CmsSockMgrContext* gMgrContext, UINT8 oldStatus, UINT8 newStatus, UINT16 cause);
void cmsSockMgrCallDlEventCallback(CmsSockMgrContext* gMgrContext, CmsSockMgrDataContext *dataContext, ip_addr_t *remoteAddr, UINT16 remotePort);
void cmsSockMgrCallUlStatusEventCallback(CmsSockMgrContext* gMgrContext, UINT8 sequence, UINT8 status);
void cmsSockMgrCallProcUlPendingCallBack(CmsSockMgrContext* gMgrContext,CmsSockUlPendingList *pList,UINT8 isTimeOut);
CmsSockUlPendingList *cmsSockMgrInitUlPendingList(UINT16 len);
//cms sock hibernate related
BOOL cmsSockMgrEnableHibMode(CmsSockMgrContext *context);
CmsSockMgrContext* cmsSockMgrGetHibContext(CmsSockMgrConnType type);
void cmsSockMgrRecoverHibCallback(CmsSockMgrHibContext *hibContext);
void cmsSockMgrEnterHibCallback(void *data, APSleepState state);
//cms sock mgr init related
BOOL cmsSockMgrHandleInit(BOOL bWakeup);
//cms sock mgr handle register/unregister
BOOL cmsSockMgrRegisterHandleDefine(CmsSockMgrHandleDefine *handleDefine);
void cmsSockMgrUnregisterHandleDefine(UINT8 source);
void cmsSockMgrSockDlCacheContext(void);
void cmsSockMgrCallErrorEventCallback(CmsSockMgrContext* gMgrContext, UINT8 eventType,INT32 errorCode);
void cmsSockMgrProcessWriteEvent(CmsSockMgrContext *pMgrContext);
void cmsSockMgrProcTimeOutEvent(void);
void cmsSockMgrProcAcceptClientRequest(CmsSockMgrContext* gMgrContext, INT32 clientSocketId, ip_addr_t *clientAddr, UINT16 clientPort);
INT32 cmsSockMgrProcessReadEvent(CmsSockMgrContext *pMgrContext);
INT32 cmsSockMgrProcDlCacheData(CmsSockDlBufContext *pList);
INT32 cmsSockMgrSockRead(CmsSockMgrContext *pMgrContext);
void cmsSockMgrProcessErrorEvent(CmsSockMgrContext *pMgrContext);
void cmsSockMgrSockReCalHwater(void);
BOOL cmsSockMgrProcDlCacheListBuffer(CmsSockMgrContext *pMgrContext);
BOOL cmsSockMgrCheckPendingNodeIsTimeOut(CmsSockUlPendingList *pUlList);
INT32 cmsSockMgrAddUlNodeToPendingList(CmsSockMgrContext *pSockMgrContext,CmsSockUlPendingList *pAddist);
BOOL cmsSockMgrRemvUlPendingNode(CmsSockMgrContext *pSockMgrContext,CmsSockUlPendingList *pRemoveList);
INT32 cmsSockMgrRemvUlAllPendingList(CmsSockMgrContext *pSockMgrContext);
INT32 cmsSockMgrProcUlPendingList(void);
UINT32 cmsSockMgrQueryDlfcDefinedSize(void);
#endif