个人记录之8266数据处理
个人记录,只想赚C币
#include “stm32f10x.h”
#include “bsp_usart1.h”
#include “bsp_SysTick.h”
#include “bsp_esp8266.h”
#include “test.h”
#include “bsp_dht11.h”
#include “bsp_led.h”
#include “bsp_beep.h”
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
int main ( void )
{
uint8_t ucId, ucLen,z;
char cStr1 [ 100 ] = { 0 }, cCh;
char cStr2 [ 100 ] = { 0 },cStr3 [ 100 ] = { 0 }, cStr4 [ 100 ] = { 0 };
char buf1[]={0},buf2[50]={0},buf3[50]={0};
char * pCh, * pCh1;
USARTx_Config (); //初始化串口1
SysTick_Init (); //配置 SysTick 为 1ms 中断一次
ESP8266_Init (); //初始化WiFi模块使用的接口和外设
LED_Init ();
ESP8266_StaTcpClient_UnvarnishTest ();
while(1)
{
if ( strEsp8266_Fram_Record .InfBit .FramFinishFlag )
{
USART_ITConfig ( macESP8266_USARTx, USART_IT_RXNE, DISABLE );
strEsp8266_Fram_Record .Data_RX_BUF [ strEsp8266_Fram_Record .InfBit .FramLength ] = ‘\0’;
if ( ( ( pCh = strstr ( strEsp8266_Fram_Record .Data_RX_BUF, “<” ) ) != 0 ) &&
( ( pCh1 = strstr ( strEsp8266_Fram_Record .Data_RX_BUF, “>” ) ) != 0 ) )
{
if ( pCh < pCh1)
{
ucLen = pCh1-pCh+1;
memcpy ( cStr1, pCh, ucLen );
cStr1 [ ucLen ] = ‘\0’;
Usart_SendArray(macUSARTx,cStr1,strlen(cStr1)); //发送接收到的数据
sscanf(cStr1, "%*[^/]/%[^@]", buf1); //buf1,cStr2为地址加参数
memcpy ( cStr2,buf1,strlen(buf1));
cStr2[strlen(buf1)] = '\0';
Usart_SendArray(macUSARTx,cStr2,strlen(cStr2)); //发送cStr2的数据 地址加参数
sscanf(buf1, "%*s%s",buf3); //buf3为参数
memcpy ( cStr3,buf3,strlen(buf3));
cStr3[strlen(buf3)] = '\0';
Usart_SendArray(macUSARTx,cStr3,strlen(cStr3)); //发送参数
sscanf(buf1,"%[^, ]", buf2); //buf2为地址
memcpy ( cStr4,buf2,strlen(buf2));
cStr4[strlen(buf2)] = '\0';
Usart_SendArray(macUSARTx,cStr4,strlen(cStr4)); //发送地址
macLED2_ON();
Delay_ms(500);
macLED2_OFF();
}
}
strEsp8266_Fram_Record .InfBit .FramLength = 0;
strEsp8266_Fram_Record .InfBit .FramFinishFlag = 0;
USART_ITConfig ( macESP8266_USARTx, USART_IT_RXNE, ENABLE ); //使能串口接收中断
}
}
}
上一篇: AsyncTask
下一篇: Python入门(3)