初级会员
- 积分
- 50
- 金钱
- 50
- 注册时间
- 2018-1-20
- 在线时间
- 14 小时
|
1金钱
在原子哥的例程上稍微改动了一下,建立STA TCP client 模式下与电脑的通信。接收数据没有问题,但是发送数据只有第一次成功,之后总是连接不上。不知道什么问题,还请大家赐教。
发送数据部分代码如下:- //WIFI STA ·¢Ëíêy¾Y
- //length :·¢Ëíêy¾Y3¤¶è
- //pointer:Ö¸Ïò·¢Ëíêy¾Y £¡£¡£¡£¡£¡£¡£¡£¡Ö¸ÕëààDí¸ù¾Yêy¾Y2»í¬¿éÄüòa¸Ä£¡£¡£¡
- void atk_8266_wifista_send(u8 length,char *pointer)
- {
- u8 *q;
- u8 j;
- q=mymalloc(32); //éêÇë32×Ö½úÄú′æ
- atk_8266_quit_trans();
- while(atk_8266_send_cmd("AT+CIPSEND","OK",20)); //¿aê¼í¸′«
- {
- if(!atk_8266_send_cmd("AT+CIPSEND","ERROR",20))//èô¶Ï¿a£¬ÔòÖØDÂᬽó
- {
- sprintf((char*)q,"AT+CIPSTART=\"TCP\",\"%s\",%s","192.168.43.186","8080"); //ÅäÖÃÄ¿±êTCP·tÎñÆ÷
- while(atk_8266_send_cmd(q,"OK",200));
- atk_8266_send_cmd("AT+CIPMODE=1","OK",200); //′«êäÄ£ê½Îa£oí¸′«
- USART2_RX_STA=0;
- atk_8266_quit_trans();
- }
- }
- for(j=0;j<length;j++) //Ñ-»··¢Ëíêy¾Y
- {
- while(USART_GetFlagStatus(USART2,USART_FLAG_TC)==RESET); //Ñ-»··¢Ëí,Ö±μ½·¢Ëííê±Ï
- USART_SendData(USART2,*(pointer++));
- }
- myfree(q); //êí·ÅÄú′æ
- }
[color=rgb(51, 102, 153) !important]复制代码
仿真死在这一步:- while(atk_8266_send_cmd("AT+CIPSEND","OK",20)); //¿aê¼í¸′«
- {
- if(!atk_8266_send_cmd("AT+CIPSEND","ERROR",20))//èô¶Ï¿a£¬ÔòÖØDÂᬽó
- {
- sprintf((char*)q,"AT+CIPSTART=\"TCP\",\"%s\",%s","192.168.43.186","8080"); //ÅäÖÃÄ¿±êTCP·tÎñÆ÷
- while(atk_8266_send_cmd(q,"OK",200));
- atk_8266_send_cmd("AT+CIPMODE=1","OK",200); //′«êäÄ£ê½Îa£oí¸′«
- USART2_RX_STA=0;
- atk_8266_quit_trans();
- }
- }
[color=rgb(51, 102, 153) !important]复制代码
电脑接收结果如下:- 【Receive from 192.168.43.254 : 25700】:
- AT+CIPSEND
- L0E+++
- AT
- AT+CIPSEND
- AT+CIPSEND
- AT+CIPSEND
- AT+CIPSEND
- AT+CIPSEND
- AT+CIPSEND
- AT+CIPSEND
- AT+CIPSEND
- AT+CIPSEND
[color=rgb(51, 102, 153) !important]复制代码
|
|