当前位置:首页 » 编程语言 » c语言发短信

c语言发短信

发布时间: 2024-05-18 13:23:08

㈠ 璋佹湁89C51鍗旷墖链猴纸鐗瑰埆鏄疉T89S52锛夋带鍒禛SM妯″潡TC35鏀跺彂鐭淇$殑绋嫔簭锛圕璇瑷镄勶级锛熸ョ敤锛岄潪甯告劅璋锛

杩欎釜绋嫔簭鏄宸茬粡璋冨畬镄勶纴骞朵笖鎴愬姛镄勶纴锷熻兘鏄瀹氢箟浜嗕竴涓狟UTTON1鎸夐敭,锛屾寜涓嫔悗灏辫嚜锷ㄥ彂鐭鎭锛岀煭淇″唴瀹逛负nihao锛孏SM_ATCMGS()鍑芥暟涓链変釜鏁扮粍銆傚瓨鍏ヤ简鎸囦护锷犳坠链哄彿锷0d銆傛妸镓嬫満濂界殑asc鎹㈡垚浣犵殑灏辫兘鐢ㄤ简銆备笉鑳界敤灏県i鎴戯细
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
void gsm_uart();
unsigned int uart_delay(unsigned int z);
void GSM_init();
void GSM_CMGF();
void GSM_ATCMGS();
void TELNUM();
void GSM_TEXT();
void GSM_test();
void BUTTON();
unsigned int d;
unsigned char code ATEnter[]={0x41,0x54,0x0d};
unsigned char code ATCMGFEnter[]={0x41,0x54,0x2b,0x43,0x4d,0x47,0x46,0x3d,0x31,0x0d};
unsigned char code ATCMGS[]={0x41,0x54,0x2b,0x43,0x4d,0x47,0x53,0x3d};
unsigned char code TEL_NUM[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39};
unsigned char code TEXT[]={0x4b,0x4f};
unsigned char code Enter[]={0x0d};
unsigned char code oneA[]={0x31,0x41};
unsigned char idata buf[20];

int flag;
int bufnum=0;

uchar str1[]={"AT"};
uchar str2[]={"ATD"};
uchar str3[]= {"ATH"};
uchar str5[]={"AT+CMGS="};

sbit bell=P1^6;
sbit betton1_1=P3^3;
sbit betton1=P3^4;
void gsm_uart()
{ EA=1;
ES=1;
SCON=0x50; //UART鏂瑰纺1:8浣峌ART; REN=1:鍏佽告帴鏀
PCON=0x00; //SMOD=0:娉㈢壒鐜囦笉锷犲
TMOD=0x20; //T1鏂瑰纺2,鐢ㄤ簬UART娉㈢壒鐜
TH1=0xFD;
TL1=0xFD; //UART娉㈢壒鐜囱剧疆:9600
TI = 0;
RI = 0;
EA = 1;
TR1=1;
}
unsigned int uart_delay(unsigned int z)
{ unsigned int a,b;
for(a=z;a>0;a--)
{for(b=1000;b>0;b--);}
return z;
}
void ddd() interrupt 4 using 3
{
if(RI) //澶勭悊鎺ユ敹涓鏂
{ buf[bufnum]=SBUF; //鎺ユ敹涓插彛鏁版嵁
RI=0;
bufnum++; //娓呴櫎涓鏂镙囧织浣

}

}
void GSM_init()
{
uint i;
uchar code test[]= {0x41,0x54,0X0D};
ES = 0;

for (i=0;i<3;i++)
{
SBUF = test[i];
while (TI == 0);
TI = 0;

}

ES = 1;
}
void GSM_CMGF()
{
uchar code sel[10]= {0x41,0x54,0x2B,0x43,0x4D,0x47,0x46,0x3D,0x31,0x0D}; //AT+CMGF=1锲炶溅
uint i;
for(i=0;i<10;i++)
{
SBUF=sel[i];
while(TI==0);
TI=0;

}

}
void GSM_ATCMGS()
{ uint i;
uchar code tel[20]= {0x41,0x54,0x2B,0x43,0x4D,0x47,0x53,0x3D,0x31,0x33,0x38,0x33,
0x36,0x30,0x32,0x33,0x33,0x37,0x39,0x0D};
for(i=0;i<20;i++)
{
SBUF=tel[i];
while(TI==0);
TI=0;

}

}

void GSM_TEXT()
{
uchar code neirong[10]={0x48,0x69,0x21,0x6E,0x69,0x68,0x61,0x6F,0x2E,0x1a}; //hi!nihao.
uint i;
ES =0;
for(i=0;i<10;i++)
{
SBUF=neirong[i];
while(TI==0);
TI=0;

}
ES = 1;

}
void send()
{
SBUF=oneA[0];while(TI==0);TI=0;

SBUF=oneA[1];while(TI==0);TI=0;
}
void GSM_test()
{
gsm_uart();
uart_delay(400);
GSM_init();
uart_delay(1000);
ES =0;

bufnum = 0;
if(buf[5]=='O' && buf[6] =='K')

{
P0=0xfe;uart_delay(1000);P0=0xff;

}
else
{
P0=0x00;uart_delay(4000);P0=0xff;
}

}

void BUTTON()
{ betton1=1;
betton1_1=0;
if(betton1==0)
{
GSM_test();

uart_delay(1200);
GSM_CMGF();
uart_delay(1200);
GSM_ATCMGS();
uart_delay(1200);
GSM_TEXT();
uart_delay(800);
uart_delay(500);
betton1=1;
}
}
main()
{
BUTTON();
uart_delay(10);

}

㈡ C语言要团购类短信接口,求回答!石家庄的!

C语言可以直接调用webservice接口 当然http也行

团购中验证码和团购券的短信要求很高

速达移动还行,稳定 速度快 主要是服务有保障 其实他们技术人员会帮你实施

还有实例

㈢ C语言Socket服务器怎么给客户端发消息

你的文件中的问题
// 会阻塞进程,直到有客户端连接上来为止
// 既然是直到有客户端连接上,那么就要弄明白哪个是与客户端连接的套接字
// sockClient就是与客户端连接的套接字
sockClient = accept(sockServer, (SOCKADDR*)&addrClient, &len);
//接收并打印客户端数据
recv(sockClient, recvBuf, 100, 0);
printf("%s\n", recvBuf);
// 所以此处,应该把sockServer改为sockClient
send(/*sockServer*/sockClient, sendBuf, 100, 0);

PS:服务器客户端通信,是要保持服务器与客户端的连接。
而不能这样立即关闭,如果设置不对,立即关闭,缓冲区的数据是会丢失的。那客户端也就不会再收到数据了。
你可以加Sleep(10000);来测是通信过程
//关闭socket
closesocket(sockClient);

热点内容
大宋脚本下载 发布:2024-11-27 16:21:01 浏览:89
sql认证培训 发布:2024-11-27 15:53:54 浏览:635
php的异常处理 发布:2024-11-27 15:53:54 浏览:417
电脑设置邮件服务器 发布:2024-11-27 15:53:07 浏览:4
安卓平板叫什么名字 发布:2024-11-27 15:48:12 浏览:172
税盘密码忘了去改需要带什么 发布:2024-11-27 15:41:10 浏览:277
拉筋要加密 发布:2024-11-27 15:38:51 浏览:324
电脑当服务器怎么降低功耗 发布:2024-11-27 15:30:45 浏览:642
苹果手机夸克缓存的视频怎么转为本地视频 发布:2024-11-27 15:24:05 浏览:811
linuxm4 发布:2024-11-27 15:15:12 浏览:322