c語言發簡訊
㈠ 璋佹湁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);