GSM 程序
第 1 页
GSM 程序
#include "reg51.h"
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "absacc.h"
#define GSM_7BIT 0
#define GSM_8BIT 4
#define GSM_UCS2 8
char AT_TC[]="+CMGL:";
char AT_RN[]="";
typedef struct {
char SCA[16];
char TPA[16];
char TP_PID;
char TP_DCS;
char TP_SCTS[16];
char TP_UD[161];
char index;
} SM_PARAM;
int gsmEncodeUcs2(const char* pSrc, unsigned char* pDst, int nSrcLength)
{
int nDstLength,i;
char *wchar;
nDstLength = strlen(strcpy(pDst,pSrc));
for(i=0; i<nDstLength; i++)
{
*pDst++ =*(wchar+i) >> 8;
*pDst++ =*(wchar+i) & 0xff;
}
return nDstLength * 2;
}
int gsmDecodeUcs2(const unsigned char* pSrc, char* pDst, int nSrcLength)
{
int nDstLength,i;
char *wchar;
for( i=0; i<nSrcLength/2; i++)
{
*(wchar+i)= *pSrc++ << 8;
*(wchar+i)|= *pSrc++;
}
nDstLength = strlen(strcpy(pDst,pSrc));
pDst[nDstLength] = ' ';
return nDstLength;
评论0