12.ESP8266模块连接外部服务器
bool esp8266_link_Server(u8 tcp_ip_mode,char *ip,char *comNum,char *LocalcomNum,u8 ucid)
{
char cStr[100],cCmd[120];
switch(tcp_ip_mode)
{
case MODE_TCP:
sprintf(cStr,"\"%s\",\"%s\",%s","TCP",ip,comNum); //端口号字符串
break;
case MODE_UDP:
sprintf(cStr,"\"%s\",\"%s\",%s,%s,0","UDP",ip,comNum,LocalcomNum);
break;
default:
break;
}
if(ucid<5) //多连接模式
{
sprintf(cCmd,"AT+CIPSTART=%d,%s",ucid,cStr);
}
else //单链接模式
{
sprintf(cCmd,"AT+CIPSTART=%s",cStr);
}
return esp8266_send_cmd(cCmd,"OK",0,300);
}
|