我用原子哥的代码做GPRS实验 因为用了花生壳 所以把映射的域名直接给出了 就做了这方面的修改 测试时显示连接成功 但按key0后过一段时间显示数据发送失败 为什么呢?
u8 sim900a_gprs_test(void)
{
const u8 *port="8086"; //¶Ë¿ú1춨Îa8086,μ±ÄãμÄμçÄÔ8086¶Ë¿ú±»ÆäËû3ìDòÕ¼óÃμÄê±oò,ÇëDT¸ÄÎaÆäËû¿ÕÏD¶Ë¿ú
const u8 *ipaddr="k169t56564.imwork.net:16833";
u8 mode=0; //0,TCPᬽó;1,UDPᬽó
//u8 key;
u8
timex=0;
//u8 ipbuf[16]; //IP»o′æ
//u8 iplen=0; //IP3¤¶è
sim900a_gprs_ui(); //¼óÔØÖ÷½çÃæ
Show_Str(30+72,90,200,16,(u8*)modetbl[mode],16,0); //ÏÔê¾á¬½ó·½ê½
Show_Str(30+40,130,200,16,(u8*)port,16,0); //ÏÔ꾶˿ú
sim900a_send_cmd("AT+CIPCLOSE=1","CLOSE OK",100); //1رÕᬽó
sim900a_send_cmd("AT+CIPSHUT","SHUT OK",100); //1رÕòƶˉ3¡¾°
if(sim900a_send_cmd("AT+CGCLASS="B"","OK",1000))return 1; //éèÖÃGPRSòƶˉì¨àà±eÎaB,Ö§3Ö°ü½»»»oíêy¾Y½»»»
if(sim900a_send_cmd("AT+CGDCONT=1,"IP","CMNET"","OK",1000))return 2;//éèÖÃDPéÏÏÂÎÄ,»¥áaíø½óD-òé,½óèëμãμèDÅÏ¢
if(sim900a_send_cmd("AT+CGATT=1","OK",500))return 3; //¸½×ÅGPRSòμÎñ
if(sim900a_send_cmd("AT+CIPCSGP=1,"CMNET"","OK",500))return 4; //éèÖÃÎaGPRSᬽóÄ£ê½
if(sim900a_send_cmd("AT+CIPHEAD=1","OK",500))return 5; //éèÖýóêÕêy¾YÏÔê¾IPí·(·½±ãÅD¶Ïêy¾Yà′Ô′)
if(sim900a_send_cmd("AT+CLPORT="TCP","2000"","OK",500))return 6;
if(sim900a_send_cmd("AT+CIPSTART="TCP","k169t56564.imwork.net:16833 ","8080"","OK",500))return 7;
sim900a_tcpudp_test(mode,(u8*)ipaddr,(u8*)port);
sim900a_gprs_ui(); //¼óÔØÖ÷½çÃæ
Show_Str(30+72,90,200,16,(u8*)modetbl[mode],16,0); //ÏÔê¾á¬½óÄ£ê½
//Show_Str(30+40,130,200,16,(u8*)port,16,0);//ÏÔ꾶˿ú
USART2_RX_STA=0;
Show_Str(30+56,110,200,16,(u8*)ipaddr,16,0); //ÏÔê¾IPμØÖ·
/*ipbuf[0]=0;
while(1)
{
key=KEY_Scan(0);
if(key==WKUP_PRES)
{
mode=!mode; //ᬽóÄ£ê½ÇD»»
Show_Str(30+72,90,200,16,(u8*)modetbl[mode],16,0); //ÏÔê¾á¬½óÄ£ê½
}
key=sim900a_get_keynum(0,180);
if(key)
{
if(key<12)
{
if(iplen<15)
{
ipbuf[iplen++]=kbd_tbl[key-1][0];
u2_printf("AT+CLDTMF=2,"%c"rn",kbd_tbl[key-1][0]);
}
}else
{
if(key==13)if(iplen)iplen--; //é¾3y
if(key==14&&iplen) //Ö′DDGPRSᬽó
{
sim900a_tcpudp_test(mode,ipbuf,(u8*)port);
sim900a_gprs_ui(); //¼óÔØÖ÷½çÃæ
Show_Str(30+72,90,200,16,(u8*)modetbl[mode],16,0); //ÏÔê¾á¬½óÄ£ê½
Show_Str(30+40,130,200,16,(u8*)port,16,0);//ÏÔ꾶˿ú
USART2_RX_STA=0;
}
if(key==15)break;
}
ipbuf[iplen]=0;
LCD_Fill(30+56,110,239,110+16,WHITE);
Show_Str(30+56,110,200,16,ipbuf,16,0); //ÏÔê¾IPμØÖ·
}
*/
timex++;
if(timex==20)
{
timex=0;
LED0=!LED0;
}
delay_ms(10);
sim_at_response(1);//¼ì2éGSMÄ£¿é·¢Ëí1yà′μÄêy¾Y,¼°ê±éÏ′«¸øμçÄÔ
return 0;
}
0