打印

ESP8266连接web服务器不定时下载的问题

[复制链接]
239|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
roucun|  楼主 | 2019-11-27 14:22 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
利用提供的网页抓取例程,希望实现从web服务器不定时下载的功能,大体思路是先将wifi模块设置为STA模式,单连接,透传模式。然后与外部服务器建立TCP连接。紧接着发送http请求。第一次下载很顺利,但调用我写的ESP_To_Web()函数就没反应了,希望得到指导,不知道具体哪里配置错了,谢谢(下面只贴了部分代码)
void ESP8266_fresh ( void )
{
char cStrInput [100] = { 0 }, * pStrDelimiter [2], * pBuf, * pStr;
u8 uc = 0;
ESP8266_Choose ( ENABLE );

ESP8266_AT_Test ();

ESP8266_Net_Mode_Choose ( STA );
  
ESP8266_Cmd ( "AT+CWLAP", "OK", 0, 5000 );

  do
{
  PC_Usart ( "\r\n请输入能连接到Internet的WiFi名称和密钥,输入格式为:名称字符+英文逗号+密钥字符+空格,点击发送\r\n" );
  scanf ( "%s", cStrInput );
  PC_Usart ( "\r\n稍等片刻 ……\r\n" );
  pBuf = cStrInput;
  uc = 0;
  while ( ( pStr = strtok ( pBuf, "," ) ) != NULL )
  {
   pStrDelimiter [ uc ++ ] = pStr;
   pBuf = NULL;
  }
  
  } while ( ! ESP8266_JoinAP ( pStrDelimiter [0], pStrDelimiter [1] ) );

while ( ! ESP8266_Link_Server ( enumTCP, "eat.weixincore.com", "80", Single_ID ) );
ESP8266_UnvarnishSend ();                                       //设为透传
ESP8266_SendString ( ENABLE, "GET /index.php?s=/Mobile/PrinterTest/index HTTP/1.1\r\n", NULL, Single_ID );
ESP8266_SendString ( ENABLE, "Host: eat.weixincore.com\r\n",                            NULL, Single_ID );
ESP8266_SendString ( ENABLE, "User-Agent: abc\r\n",                                     NULL, Single_ID );
ESP8266_SendString ( ENABLE, "Connection: close\r\n",                                   NULL, Single_ID );//Keep-Alive
ESP8266_SendString ( ENABLE, "\r\n",                                                    NULL, Single_ID );
USART_DMACmd(USART2, USART_DMAReq_Rx, ENABLE);
DMA_Cmd(DMA1_Channel6,ENABLE);   /*使能DMA*/
while(1)
{
  if(DMA_GetFlagStatus(DMA1_FLAG_TC6)!=RESET) //判断通道6传输完成
  {
   DMA_ClearFlag(DMA1_FLAG_TC6);//清除通道6传输完成标志
   break;
  }
}
while( ! ESP8266_UnLink_Server ());
}
void Web_To_ESP(void)
{
while ( ! ESP8266_Link_Server ( enumTCP, "eat.weixincore.com", "80", Single_ID ) );
// ESP8266_UnvarnishSend ();  
ESP8266_SendString ( ENABLE, "GET /index.php?s=/Mobile/PrinterTest/index HTTP/1.1\r\n", NULL, Single_ID );
ESP8266_SendString ( ENABLE, "Host: eat.weixincore.com\r\n",                            NULL, Single_ID );
ESP8266_SendString ( ENABLE, "User-Agent: abc\r\n",                                     NULL, Single_ID );
ESP8266_SendString ( ENABLE, "Connection: close\r\n",                                   NULL, Single_ID );
ESP8266_SendString ( ENABLE, "\r\n",                                                    NULL, Single_ID );
USART_DMACmd(USART2, USART_DMAReq_Rx, ENABLE);
DMA_Cmd(DMA1_Channel6,ENABLE);   /*使能DMA*/
while(1)
{
  if(DMA_GetFlagStatus(DMA1_FLAG_TC6)!=RESET) //判断通道6传输完成
  {
   DMA_ClearFlag(DMA1_FLAG_TC6);//清除通道6传输完成标志
   break;
  }
}
while( ! ESP8266_UnLink_Server ());

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

421

主题

446

帖子

0

粉丝