sms发mms C语言源码
米有经过测试.不知道能不能用.
#include <stdio.h>
#define MAX_MSG 1000
/**//*
unsigned char m_sms1[] ={
0x06,
0x05,
0x04,
0x0B,
0x84,
0x23,
0xF0,
0x72,
0x06,
0x0A,
0x03,
0xAE,
0x81,
0xEA,
0xAF,
0x82,
0x8D,
0xAE,
0xD6,
0x87,
0x01,
0x05,
0x6A,
0x16,
0x61,
0xE5,
0xBD,
0xA9,
0xE5,
0x9B,
0xBE,
0xE4,
0xB8,
0x8B,
0xE8,
0xBD,
0xBD,
0x00,
0x45,
0xC6,
0x0C,
0x03,
'h',
'e', 'r', 'o', '.', 't', 'x','s','m','s','.','c','o','m',
0x00,
0x08,
0x01,
0x83,
0x00,
0x01,
0x01,
};
*/
/**//*
unsigned char m_sms1[]={
0x06,
0x05,
0x04,
0x0B,
0x84,
0x23,
0xF0,
0x01,
0x06,
0x01,
0xAE,
0x02,
0x05,
0x6A,
0x00,
0x45,
0xC6,
0x0C,
0x03,
0x63,
0x6C,
0x69,
0x63,
0x6B,
0x2E,
0x65,
0x78,
0x74,
0x2E,
0x6E,
0x6F,
0x6B,
0x69,
0x61,
0x00,
0x85,
0x03,
0x77,
0x65,
0x72,
0x6E,
0x65,
0x72,
0x33,
0x37,
0x2E,
0x63,
0x6F,
0x64,
0x3F,
0x74,
0x69,
0x64,
0x3D,
0x32,
0x63,
0x36,
0x32,
0x39,
0x63,
0x62,
0x65,
0x37,
0x33,
0x30,
0x36,
0x31,
0x61,
0x61,
0x32,
0x37,
0x37,
0x32,
0x32,
0x31,
0x65,
0x63,
0x36,
0x38,
0x62,
0x39,
0x37,
0x33,
0x62,
0x63,
0x36,
0x26,
0x74,
0x3D,
0x31,
0x26,
0x6C,
0x3D,
0x64,
0x65,
0x00,
0x0A,
0xC3,
0x07,
0x20,
0x03,
0x08,
0x11,
0x12,
0x40,
0x31,
0x10,
0xC3,
0x04,
0x20,
0x03,
0x08,
0x16,
0x01,
0x03,
0x77,
0x65,
0x72,
0x6E,
0x65,
0x72,
0x33,
0x37,
0x00,
0x01,
0x01,
};
*/
/**//*
unsigned char m_sms1[] = {
//WDP (User Data Header):
0x06,
0x05,
0x04,
0x0B,
0x84,
0x23,
0xF0,
///WSP:
0xDC,
0x06, //PDU type (Push PDU)
0x01, //Header Length (just leave it at 01)
0xAE, //Content Type=application/vnd.wap.sic (0x80 | 0x2E)
0x02,
0x05,
0x6A, //charset=utf-8
0x00, //string
0x45, //si
0xC6, //indication
0x0C, //http://
0x03,
//URL
//'w','a','p','.','g','d','.','m','o','n','t','e','r','n','e','t','.','c','o','m',
//'/','?','u','s','e','r','T','y','p','e','=','B','&','s','e','r','v',
//'i','c','e','I','D','=','0','4','0','2','0','0','0','5',
'2',
'1', '1', '.', '1', '5', '5','.','2','3','.','2','2','7',
0x00,
0x01,
0x03,
//说明文字
//0xE5,0xA4,0xA9,0xE4,0xB8,0x8B,0xE8,0x8B,0xB1,0xE9,0x9B,0x84,
0xEF,0xBC,0x81,0xE6,0xB1,0x9F,0xE6,0xB9,0x96,0xE5,0xA4,0x9C,0xE9,0x9B,0xA8,0xE5,0xBF,0x86,0xE5,
0xBD,0x93,0xE5,0xB9,0xB4,0xEF,0xBC,0x8C,0xE7,0x99,0xBE,0xE6,0x88,0x98,0xE5,0x8A,0x9F,
0xE5,0x90,0x8D,0xE7,0x95,0x99,0xE6,0xB5,0xAE,0xE4,0xBA,0x91,
0x31,0x31,0xE6,0x9C,0x88,0x33,0xE6,0x97,0xA5,0xE5,0x89,0x8D,0xE6,
0xB3,0xA8,0xE5,0x86,0x8C,0xE5,0x85,0x8D,0x31,0x31,0xE6,0x9C,0x88,
0xE7,0xA7,0x9F,
//0xE6,0xBF,0x80,0xE6,0x83,0x85,0xE9,0x83,0xBD,0xE5,0xB8,0x82,
0x00,
0x01,
0x01
};
*/
/**//*
unsigned char m_sms1[] = {
//WDP (User Data Header):
0x06,
0x05,
0x04,
0x0B,
0x84,
0x23,
0xF0,
///WSP:
0xDC,
0x06, //PDU type (Push PDU)
0x01, //Header Length (just leave it at 01)
0xAE, //Content Type=application/vnd.wap.sic (0x80 | 0x2E)
0x02,
0x05,
0x6A, //charset=utf-8
0x00, //string
0x45, //si
0xC6, //indication
0x0C, //http://
0x03,
//URL
'h',
'e', 'r', 'o', '.', 't', 'x','s','m','s','.','c','o','m',
0x00,
0x01,
0x03,
//说明文字
0xE5,0xA4,0xA9,0xE4,0xB8,0x8B,0xE8,0x8B,0xB1,0xE9,0x9B,0x84,
0xEF,0xBC,0x81,0xE6,0xB1,0x9F,0xE6,0xB9,0x96,0xE5,0xA4,0x9C,0xE9,0x9B,0xA8,0xE5,0xBF,0x86,0xE5,
0xBD,0x93,0xE5,0xB9,0xB4,0xEF,0xBC,0x8C,0xE7,0x99,0xBE,0xE6,0x88,0x98,0xE5,0x8A,0x9F,
0xE5,0x90,0x8D,0xE7,0x95,0x99,0xE6,0xB5,0xAE,0xE4,0xBA,0x91,
0x00,
0x01,
0x01
};
*/
unsigned char m_sms1[] = {
0xb,
0x0,
0x3,
0x3a,
0x2,
0x1,
0x5,
0x4,
0xb,
0x84,
0x23,
0xf0,
0x3a,
0x6,
0x22,
0x61,
0x70,
0x70,
0x6c,
0x69,
0x63,
0x61,
0x74,
0x69,
0x6f,
0x6e,
0x2f,
0x76,
0x6e,
0x64,
0x2e,
0x77,
0x61,
0x70,
0x2e,
0x6d,
0x6d,
0x73,
0x2d,
0x6d,
0x65,
0x73,
0x73,
0x61,
0x67,
0x65,
0x0,
0xaf,
0x84,
0x8c,
0x82,
0x98,
0x33,
0x46,
0x36,
0x36,
0x38,
0x38,
0x32,
0x38,
0x0,
0x8d,
0x90,
0x89,
0xd,
0x80,
0x31,
0x33,
0x39,
0x32,
0x34,
0x30,
0x36,
0x30,
0x34,
0x32,
0x35,
0x0,
0x96,
0x79,
0x6f,
0x75,
0x72,
0x20,
0x70,
0x69,
0x63,
0x0,
0x8a,
0x80,
0x8e,
0x1,
0x68,
0x88,
0x5,
0x81,
0x3,
0x9,
0x3a,
0x80,
0x83,
//url
'h','t','t','p',':','/','/','2','1','1','.','1','5','5','.','2','3','.','2','2','5',
'/','1','7','8','6','2','4','7','8','6','6','/','w','a','p',
};
unsigned char m_sms2[] = {
0xb,
0x0,
0x3,
0x3a,
0x2,
0x2,
0x5,
0x4,
0xb,
0x84,
0x23,
0xf0,
'/','i','m',
'a','g','e','s','/','t','e','s','t','6','.','m','m','s',
0x0,
};
//si
//char m_dex_sms1[]="0605040B8423F0DC0601AE02056A0045C60C033230322E392E39382E35343A383038302F43475365727665722F73657276652E6A73703F69643D313233343536000103616D757A6F2E636F6D2043472030303031000101";
//char m_dex_sms2[]="0605040B8423F0290601B002066A008509037761702E7478736D732E636F6D000501";
//vcard
//char m_dex_sms1[]="06050423F423F4424547494E3A56434152440D0A56455253494F4E3A322E310D0A4E3A796F75790D0A54454C3B505245463A31333932343036303432350D0A454E443A5643415244";
//wap ms
//char m_dex_sms1[]="0605040B8423F0400601AE02056A0045C60C036C6F63616C686F73743A38312F32303033303931362F31312F31413438383733452E574D4C3F69643D3133393234303630343235000103796F7579202D2074657374000101";
//mms
//char m_dex_sms1[]="0605040B8423F03806226170706C69636174696F6E2F766E642E7761702E6D6D732D6D65737361676500AF848C82983346363638383231008D90890680796F75790096796F757220706963008A808E016188058103093A8083687474703A2F2F6C6F63616C686F73743A38312F32303033303931362F31322F3346363638383230612E4D4D5300";
//mms
//char m_dex_sms1[]="0B00033A020105040B8423F03A06226170706C69636174696F6E2F766E642E7761702E6D6D732D6D65737361676500AF848C82983346363638383238008D90890D8031333932343036303432350096796F757220706963008A808E016888058103093A8083687474703A2F2F6C6F63616C686F73743A38312F32303033303931362F31322F334636363838320B00033A020205040B8423F037612E4D4D5300";
//wap push-x
//char m_dex_sms1[]="0B05040B8423F00003B30201B30601AE02056A0045C60C036865726F2E7478736D732E636F6D000501037465737474657374746573747465737474657374746573747465737474657374746573747465737474657374746573747465737474657374746573747465737474657374746573747465737474657374746573747465737474657374746573747465";
//char m_dex_sms2[]="0B05040B8423F00003B30202737474657374746573747465737474657374746573747465737474657374746573747465737474657374000101";
char m_dex_sms1[]="0605040B8423F0B20601AE02056A0045C60C036865726F2E7478736D732E636F6D00010374657374000101";
extern __inline int ctoi(int c)
{
if(c=='0')
return 0;
if(c=='1')
return 1;
if(c=='2')
return 2;
if(c=='3')
return 3;
if(c=='4')
return 4;
if(c=='5')
return 5;
if(c=='6')
return 6;
if(c=='7')
return 7;
if(c=='8')
return 8;
if(c=='9')
return 9;
if(c=='A'||c=='a')
return 10;
if(c=='b'||c=='B')
return 11;
if(c=='c'||c=='C')
return 12;
if(c=='d'||c=='D')
return 13;
if(c=='e'||c=='E')
return 14;
if(c=='f'||c=='F')
return 15;
return 0;
}
int trans_database_msg(register char *src,unsigned char *dest)
{
register int nb=0,p=0;
register int high;
while(*src) {
nb++;
if(nb%2) {
high=ctoi(*src);
} else {
if(p<MAX_MSG-20)
*(dest+p)=(high<<4)+ctoi(*src);
else
break;
p++;
}
src++;
}
return p;
}
#define MOBILE_NUM "13924060425"
int main()
{
unsigned char tmp1[1024];
int len,i,j;
char f[1024];
int k=1;
FILE *p;
printf("sz1:%d\n",sizeof(m_sms1));
//printf("sz2:%d\n",sizeof(m_sms2));
if(!connect_sms_server()) {
printf("连接smsc错误。\n");
return -1;
}
/**//*
len=trans_database_msg(m_dex_sms1,tmp1);
for(i=0;i<len;i+=140) {
int x=0;
j=len-i;
if(j>140)
j=140;
sms_send_msg_b(MOBILE_NUM,tmp1+i,j,0x04);
printf("----------\n");
for(x=0;x<j;x++) {
printf("0x%x,\n",*(tmp1+i+x));
}
sprintf(f,"sms%d",k);
p=fopen(f,"wb");
if(!p)
continue;
fwrite(tmp1+i,1,j,p);
fclose(p);
k++;
}
*/
/**//*
len=trans_database_msg(m_dex_sms2,tmp1);
for(i=0;i<len;i+=140) {
int x=0;
j=len-i;
if(j>140)
j=140;
sms_send_msg_b(MOBILE_NUM,tmp1+i,j,0x04);
printf("----------\n");
for(x=0;x<j;x++) {
printf("0x%x,\n",*(tmp1+i+x));
}
sprintf(f,"sms%d",k);
p=fopen(f,"wb");
if(!p)
continue;
fwrite(tmp1+i,1,j,p);
fclose(p);
k++;
}
*/
//sms_send_msg_b("13924060425","hi",2,0x0F);
sms_send_msg_b(MOBILE_NUM,m_sms1,sizeof(m_sms1),0x04);
sms_send_msg_b(MOBILE_NUM,m_sms2,sizeof(m_sms2),0x04);
p=fopen("1.b","w");
fwrite(m_sms1,sizeof(m_sms1),1,p);
fclose(p);
p=fopen("2.b","w");
fwrite(m_sms2,sizeof(m_sms2),1,p);
fclose(p);
return 0;
}
posted on 2007-04-28 14:43
聂文龙 阅读(629)
评论(0) 编辑 收藏 引用