开发板是用的探索者F4,现在想用 ESP8266连接电脑的WIFI热点
初始化以及连接的部分代码如下:
- /* init wifi model */
- while(atk_8266_send_cmd("AT","OK",20))
- {
- LCD_ShowString(30,LCD_CUR++ * LCD_MARGIN,200,16,16,"no wifi model");
- delay_ms(800);
- LCD_ShowString(30,LCD_CUR++ * LCD_MARGIN,200,16,16,"try to connect wifi model");
- }
- LCD_ShowString(30,LCD_CUR++ * LCD_MARGIN,400,16,16,"connect to wifi model successful");
-
- atk_8266_send_cmd("AT+CWAUTOCONN=0","OK",50);
-
- while(atk_8266_send_cmd("ATE0","OK",20));
-
- status = atk_8266_send_cmd("AT+CWMODE=1","OK",50);
-
- if (status)
- LCD_ShowString(30,LCD_CUR++ * LCD_MARGIN,400,16,16,"config wifi failed");
- else
- LCD_ShowString(30,LCD_CUR++ * LCD_MARGIN,400,16,16,"config wifi success");
-
- atk_8266_send_cmd("AT+RST","OK",20);
- LCD_ShowString(30,LCD_CUR++ * LCD_MARGIN,400,16,16,"wait for 4s to restart wifi model");
- delay_ms(1000);
- delay_ms(1000);
- delay_ms(1000);
- delay_ms(1000);
- atk_8266_send_cmd("AT+CIPMUX=0","OK",20);
- LCD_ShowString(30,LCD_CUR++ * LCD_MARGIN,400,16,16,"connect to wifi host...");
- while(atk_8266_send_cmd(cmd_connect_wifi,"WIFI GOT IP",300)){
- atk_8266_send_cmd("AT+CIPSTATUS","",100);
- }
- LCD_ShowString(30,LCD_CUR++ * LCD_MARGIN,400,16,16,"connect wifi host success");
-
- LCD_ShowString(30,LCD_CUR++ * LCD_MARGIN,400,16,16,"connect to tcp server...");
- status = atk_8266_send_cmd(cmd_start_tcp,"OK",1000);
- if (status)
- LCD_ShowString(30,LCD_CUR++ * LCD_MARGIN,400,16,16,"connect to tcp server failed");
- else
- LCD_ShowString(30,LCD_CUR++ * LCD_MARGIN,400,16,16,"connect to tcp server success");
- atk_8266_send_cmd("AT+CIPMODE=1","OK",200);
复制代码 昨天弄了一下午都没连上,然后一样的代码,今天下午一打开就连上了....
大概过了一小时后又是怎么都连不上了...
求解,或者有哪些可能的原因
|