解释下面代码static UINT8 libTXT2PDU( UINT8* msgData, UINT16 msgLen, UINT8* pTpdu, AtciMsgInfo *pAtSmsMessage, AtciCharacterSet chset_type ) { UINT8 offset = 0; UINT16 len=0; //CPUartLogPrintf("%s: enter", __FUNCTION__); //int i; //for(i=0;i<msgLen;i++) //CPUartLogPrintf("%s: msgData[%d] %d 0x%x", __FUNCTION__, i, msgData[i], msgData[i]); /* Copy the first octet */ /*SIMCom xiaokai.yang sync sms code @2023-02-06 begin*/ #ifdef FEATURE_SIMCOM_SMS char headbuf[PDU_HEAD_SIZE] = {0x05,0x00,0x03}; scCmssexInfoT* p_CmgsexInfo = (scCmssexInfoT*)getCmgsexInfoInd(); if(pAtSmsMessage->udhPresent) { pTpdu[ offset++ ] = (pAtSmsMessage->fo)|(0x1<<6); } else #endif /*SIMCom xiaokai.yang sync sms code @2023-02-06 end*/ pTpdu[ offset++ ] = pAtSmsMessage->fo; /* Message Reference */ pTpdu[ offset++ ] = pAtSmsMessage->msgRef; /* Originating Address (TP-OA) */ { UINT8 idx; UINT8 *data; data = pTpdu + offset; /* Set the Address Length octet */ *data++ = strlen( (char *)pAtSmsMessage->destAddr ); #ifdef FEATURE_SIMCOM_SMS PAL_LogIo(SC_MODULE_SMS,PAL_DBG_LEVEL_INFO,"destAddr [%s]",( (char *)pAtSmsMessage->destAddr )); #endif /* Format the TON/NPI octet */ *data++ = (UINT8)((pAtSmsMessage->addrType << 4) | pAtSmsMessage->addrPlan | 0x80); /* Format the BCD digits */ for ( idx = 0; idx < strlen( (char *)pAtSmsMessage->destAddr ); idx++ ) { libPutPackedBcd( data, idx, pAtSmsMessage->destAddr[ idx ], TRUE ); } /* check if we need to tack on a filler */ if( idx & 0x01 ) { /* Yup -- do it! , reversed nibbles */ libPutPackedBcd( data, idx, ATCI_BCD_FILLER, TRUE ); ++idx; } /* We're done -- update the PDU byte index */ offset += idx/2 + ATCI_SMS_BCD_POS; } /* Protocol Identifier (TP-PID) */ pTpdu[ offset++ ] = pAtSmsMessage->pid; /* Data Coding Scheme (TP-DCS) */ pTpdu[ offset++ ] = pAtSmsMessage->dcs; if(((pAtSmsMessage->fo&ATCI_TP_MTI_MASK)==ATCI_SMS_SUBMIT_MTI)&&((pAtSmsMessage->fo&ATCI_SMS_TP_VPF)==0x10)) { pTpdu[ offset++ ] = pAtSmsMessage->vp; } /*SIMCom xiaokai.yang sync sms code @2023-02-06 begin*/ #ifdef FEATURE_SIMCOM_SMS if(pAtSmsMessage->udhPresent) { headbuf[3] = p_CmgsexInfo->mr; headbuf[4] = p_CmgsexInfo->msg_total; headbuf[5] = p_CmgsexInfo->msg_seg; memmove(msgData+PDU_HEAD_SIZE,msgData,msgLen); memcpy(msgData, headbuf, PDU_HEAD_SIZE); msgLen+=PDU_HEAD_SIZE; } PAL_LogIo(SC_MODULE_SMS,PAL_DBG_LEVEL_INFO,"offset1 [%d],msgLen=%d",offset,msgLen);//274 #endif /*SIMCom xiaokai.yang sync sms code @2023-02-06 end*/ /* Now for the Message Data (TP-UDL + TP-UD) */ //ScShowDataByHex((char *)pTpdu, offset); //CPUartLogPrintf("[sms]msgLen=%d",msgLen); libMsgEncodeUserData( pAtSmsMessage->udhPresent, pAtSmsMessage->dcs, pTpdu, msgData, msgLen, offset, &len,chset_type); return len; }