1.cc3000用tcp/ip通过ap连接到server端,40秒左右socket会自动断开连接!该如何解决?
cc3000代码如下
while ((ulCC3000DHCP == 0) || (ulCC3000Connected == 0))
{
__delay_cycles(1000);
}
long theSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
Socket=&theSocket;
firstTimeConnected=NotFirstTimeConnect ;
SocketConnected=-1;
// the family is always AF_INET
tSocketAddr.sa_family = AF_INET;
// the destination port
tSocketAddr.sa_data[0] = (ClientPort)>>8;
tSocketAddr.sa_data[1] = (unsigned char)(ClientPort);
// the destination IP address
tSocketAddr.sa_data[2] = ServerIPaddress[0];
tSocketAddr.sa_data[3] = ServerIPaddress[1];
tSocketAddr.sa_data[4] = ServerIPaddress[2];
tSocketAddr.sa_data[5] = ServerIPaddress[3];
while(SocketConnected==-1)
{
SocketConnected=connect(*Socket,&tSocketAddr,sizeof(sockaddr));
if(SocketConnected==0)
{
turnLedOn(6);
}
else
{
turnLedOn(6);
__delay_cycles(600000);
turnLedOff(6);
__delay_cycles(600000);
}
}
2.有没有办法能够获得cc3000 当前的与ap之间的信号强度?
hao chen4:
自己顶一个吧
Yonghua Pan:
1. 你在这40秒之间是不是没有数据的交互,如果是这样,socket会觉得你是inactive, 为了保护socket的资源,会把你断掉。默认时间大致上会是55秒
2. 请参照一下http://www.deyisupport.com/question_answer/wireless_connectivity/wifi/f/105/p/63020/147189.aspx#147189,这里面有读取信号强度的方法。