首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Windows Mobile >

如何用at指令发短信

2012-02-20 
怎么用at指令发短信?请给出代码[解决办法]最近在做这方面的课设,刚写的代码,不过因为是要烧进单片机的,片

怎么用at指令发短信?
请给出代码



[解决办法]
最近在做这方面的课设,刚写的代码,不过因为是要烧进单片机的,片子还没回来,所以没有调试过。。。。
大家也帮忙看看有没有问题吧:)

C/C++ code
void sendMessage(){    sendAT();    sendBPS();    setPDUmode();    sendLength();    sendContent();}void sendText(){    while(sendBuffer[sendPointer] != '\0')    {        sendASC(sendBuffer[sendPointer ++]);    }    clearSendBuffer();}void sendAT(){    while(1)    {        sendASC('A');        sendASC('T');        sendASC(0x1A);        ES = 0;        delay(50);        clearReadBuffer();        p = strstr(readBuffer, "OK");        if(p != NULL)            break;    }    }void sendBPS(){    strcpy(sendBuffer, "AT+IPR=19200");    sendText();}void setPDUmode(){    while(1)    {        strcpy(sendBuffer, "AT+CMFG=2");        sendText();        ES = 0;        delay(50);        clearReadBuffer();        p = strstr(readBuffer, "OK");        if(p != NULL)            break;    }}void sendLength(){    while(1)    {        strcpy(sendBuffer, "AT+CMGS=26");        sendText();        ES = 0;        delay(50);        clearReadBuffer();        p = strstr(readBuffer, '>');        if(p != NULL)            break;    }}void sendContent(){    strcpy(sendBuffer, "0891683108705505F011000D91683104176226F00008000A67094EBA76D78F66FF01");//PDU编码内容    sendText();    sendASC(0x1A);}void sendASC(uchar ASC){    SBUF = ASC;}void delay(uchar i){    while(i --){}    }void clearSendBuffer(){    while(sendPointer >= 0)    {        sendBuffer[sendPointer --] = 0;    }    sendPointer = 0;}void clearReadBuffer(){    while(readPointer >= 0)    {        readBuffer[readPointer --] = 0;    }    readPointer = 0;} 

热点排行