mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-17 16:36:03 +08:00
compile ok after transfering mqtt protocol
This commit is contained in:
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/wumei-smart.iml" filepath="$PROJECT_DIR$/.idea/wumei-smart.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
9
.idea/wumei-smart.iml
generated
Normal file
9
.idea/wumei-smart.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
@@ -29,14 +29,15 @@
|
|||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
#include "esp8266.h"
|
||||||
|
#include "mqtt.h"
|
||||||
#include "oled.h"
|
#include "oled.h"
|
||||||
#include "dht11.h"
|
#include "dht11.h"
|
||||||
#include "flash.h"
|
#include "flash.h"
|
||||||
#include "esp8266.h"
|
|
||||||
#include "sensor_light.h"
|
#include "sensor_light.h"
|
||||||
#include "rc522.h"
|
#include "rc522.h"
|
||||||
#include "process.h"
|
#include "process.h"
|
||||||
#include "mqtt.h"
|
|
||||||
|
|
||||||
/* USER CODE END Includes */
|
/* USER CODE END Includes */
|
||||||
|
|
||||||
@@ -170,7 +171,7 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ESP8266_Fram_Record_Struct.wifi_data_recv_cb = wifi_data_recv_fun; // <20><><EFBFBD><EFBFBD>ϵͳ<CFB5>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
ESP8266_Fram_Record_Struct.wifi_data_recv_cb = wifi_data_recv_fun; // <20><><EFBFBD><EFBFBD>ϵͳ<CFB5>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
ESP8266_STA_MQTTClient_Init();
|
|
||||||
printf("ready go into while1\r\n");
|
printf("ready go into while1\r\n");
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
2705
firmware/stm32/smart_dormitory/MDK-ARM/Project/Project.map
Normal file
2705
firmware/stm32/smart_dormitory/MDK-ARM/Project/Project.map
Normal file
File diff suppressed because it is too large
Load Diff
15
firmware/stm32/smart_dormitory/MDK-ARM/Project/Project.sct
Normal file
15
firmware/stm32/smart_dormitory/MDK-ARM/Project/Project.sct
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
; *************************************************************
|
||||||
|
; *** Scatter-Loading Description File generated by uVision ***
|
||||||
|
; *************************************************************
|
||||||
|
|
||||||
|
LR_IROM1 0x08000000 0x00010000 { ; load region size_region
|
||||||
|
ER_IROM1 0x08000000 0x00010000 { ; load address = execution address
|
||||||
|
*.o (RESET, +First)
|
||||||
|
*(InRoot$$Sections)
|
||||||
|
.ANY (+RO)
|
||||||
|
}
|
||||||
|
RW_IRAM1 0x20000000 0x00005000 { ; RW data
|
||||||
|
.ANY (+RW +ZI)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/adc.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/adc.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/dht11.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/dht11.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/dma.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/dma.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/esp8266.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/esp8266.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/flash.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/flash.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/gpio.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/gpio.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/i2c.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/i2c.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/main.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/main.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/mqtt.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/mqtt.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/oled.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/oled.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/process.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/process.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/rc522.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/rc522.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/sensor_light.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/sensor_light.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/spi.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/spi.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/stm32f1xx_hal.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/stm32f1xx_hal.crf
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/stm32f1xx_it.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/stm32f1xx_it.crf
Normal file
Binary file not shown.
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/tcp.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/tcp.crf
Normal file
Binary file not shown.
40
firmware/stm32/smart_dormitory/MDK-ARM/Project/tcp.d
Normal file
40
firmware/stm32/smart_dormitory/MDK-ARM/Project/tcp.d
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
project\tcp.o: ..\User\xiaoyi_wifi\tcp.c
|
||||||
|
project\tcp.o: ..\User\xiaoyi_wifi\tcp.h
|
||||||
|
project\tcp.o: ../Core/Inc/main.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h
|
||||||
|
project\tcp.o: ../Core/Inc/stm32f1xx_hal_conf.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_def.h
|
||||||
|
project\tcp.o: ../Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f1xx.h
|
||||||
|
project\tcp.o: ../Drivers/CMSIS/Device/ST/STM32F1xx/Include/stm32f103xb.h
|
||||||
|
project\tcp.o: ../Drivers/CMSIS/Include/core_cm3.h
|
||||||
|
project\tcp.o: C:\Keil_v5\ARM\ARMCC\Bin\..\include\stdint.h
|
||||||
|
project\tcp.o: ../Drivers/CMSIS/Include/cmsis_version.h
|
||||||
|
project\tcp.o: ../Drivers/CMSIS/Include/cmsis_compiler.h
|
||||||
|
project\tcp.o: ../Drivers/CMSIS/Include/cmsis_armcc.h
|
||||||
|
project\tcp.o: ../Drivers/CMSIS/Device/ST/STM32F1xx/Include/system_stm32f1xx.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h
|
||||||
|
project\tcp.o: C:\Keil_v5\ARM\ARMCC\Bin\..\include\stddef.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_rcc_ex.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_gpio_ex.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_exti.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_dma_ex.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_cortex.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc_ex.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_flash_ex.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_i2c.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_pwr.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_spi.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_tim_ex.h
|
||||||
|
project\tcp.o: ../Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_uart.h
|
||||||
|
project\tcp.o: C:\Keil_v5\ARM\ARMCC\Bin\..\include\stdarg.h
|
||||||
|
project\tcp.o: C:\Keil_v5\ARM\ARMCC\Bin\..\include\stdio.h
|
||||||
|
project\tcp.o: C:\Keil_v5\ARM\ARMCC\Bin\..\include\string.h
|
||||||
|
project\tcp.o: ..\User\xiaoyi_wifi\esp8266.h
|
||||||
|
project\tcp.o: C:\Keil_v5\ARM\ARMCC\Bin\..\include\stdbool.h
|
||||||
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/tcp.o
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/tcp.o
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/tim.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/tim.crf
Normal file
Binary file not shown.
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/usart.crf
Normal file
BIN
firmware/stm32/smart_dormitory/MDK-ARM/Project/usart.crf
Normal file
Binary file not shown.
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Auto generated Run-Time-Environment Component Configuration File
|
||||||
|
* *** Do not modify ! ***
|
||||||
|
*
|
||||||
|
* Project: 'Project'
|
||||||
|
* Target: 'Project'
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RTE_COMPONENTS_H
|
||||||
|
#define RTE_COMPONENTS_H
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define the Device Header File:
|
||||||
|
*/
|
||||||
|
#define CMSIS_device_header "stm32f10x.h"
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* RTE_COMPONENTS_H */
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,9 @@
|
|||||||
#include "esp8266.h"
|
#include "esp8266.h"
|
||||||
#include "usart.h"
|
|
||||||
|
|
||||||
|
extern UART_HandleTypeDef huart3;
|
||||||
|
|
||||||
|
STRUCT_USART_Fram_t ESP8266_Fram_Record_Struct;
|
||||||
|
|
||||||
struct STRUCT_USART_Fram ESP8266_Fram_Record_Struct= { 0 }; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡<EFBFBD>ṹ<EFBFBD><E1B9B9>
|
|
||||||
void ESP8266_Init(uint32_t bound)
|
void ESP8266_Init(uint32_t bound)
|
||||||
{
|
{
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
@@ -17,7 +18,7 @@ void ESP8266_Init(uint32_t bound)
|
|||||||
// GPIO_InitStructure.Pin = ESP8266_CH_PD_Pin;
|
// GPIO_InitStructure.Pin = ESP8266_CH_PD_Pin;
|
||||||
// HAL_GPIO_Init(ESP8266_CH_PD_Pin_Port, &GPIO_InitStructure);
|
// HAL_GPIO_Init(ESP8266_CH_PD_Pin_Port, &GPIO_InitStructure);
|
||||||
//
|
//
|
||||||
ESP8266_Rst();
|
// ESP8266_Rst();
|
||||||
}
|
}
|
||||||
|
|
||||||
//<2F><>ESP8266ģ<36>鷢<EFBFBD><E9B7A2>ATָ<54><D6B8>
|
//<2F><>ESP8266ģ<36>鷢<EFBFBD><E9B7A2>ATָ<54><D6B8>
|
||||||
@@ -27,8 +28,11 @@ void ESP8266_Init(uint32_t bound)
|
|||||||
//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD>ͳɹ<CDB3><C9B9><EFBFBD> 0ʧ<30><CAA7>
|
//<2F><><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD>ͳɹ<CDB3><C9B9><EFBFBD> 0ʧ<30><CAA7>
|
||||||
bool ESP8266_Send_AT_Cmd(char *cmd,char *ack1,char *ack2,uint32_t time)
|
bool ESP8266_Send_AT_Cmd(char *cmd,char *ack1,char *ack2,uint32_t time)
|
||||||
{
|
{
|
||||||
ESP8266_Fram_Record_Struct.InfBit .FramLength = 0; //<2F><><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
ESP8266_Fram_Record_Struct.InfBit.FramLength = 0; //<2F><><EFBFBD>½<EFBFBD><C2BD><EFBFBD><EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD>ݰ<EFBFBD>
|
||||||
ESP8266_USART("%s\r\n", cmd);
|
ESP8266_Fram_Record_Struct.InfBit.FramFinishFlag = 0;
|
||||||
|
memset(ESP8266_Fram_Record_Struct.Data_RX_BUF, 0x00, sizeof(ESP8266_Fram_Record_Struct.Data_RX_BUF));
|
||||||
|
|
||||||
|
hal_AT_printf("%s\r\n", cmd);
|
||||||
if(ack1==0&&ack2==0) //<2F><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
if(ack1==0&&ack2==0) //<2F><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -51,17 +55,17 @@ bool ESP8266_Send_AT_Cmd(char *cmd,char *ack1,char *ack2,uint32_t time)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------*/
|
||||||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WiFi<46><69>λ */
|
||||||
|
/*<2A><> <20><><EFBFBD><EFBFBD>timeout<75><74><EFBFBD><EFBFBD>ʱʱ<CAB1>䣨100ms<6D>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
/*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>0<EFBFBD><30><EFBFBD><EFBFBD>ȷ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
/*-------------------------------------------------*/
|
||||||
|
|
||||||
//<2F><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>
|
char ESP8266_Rst(void)
|
||||||
void ESP8266_Rst(void)
|
|
||||||
{
|
{
|
||||||
// ESP8266_RST_Pin_SetL;
|
return ESP8266_Send_AT_Cmd ( "AT+RST\r\n", "OK", 0, 5000 );
|
||||||
// delay_ms(500);
|
|
||||||
// ESP8266_RST_Pin_SetH;
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//<2F><><EFBFBD>ͻָ<CDBB><D6B8><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>ģ<EEBDAB><C4A3><EFBFBD>ָ<EFBFBD><D6B8>ɳ<EFBFBD><C9B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//<2F><><EFBFBD>ͻָ<CDBB><D6B8><EFBFBD><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>ģ<EEBDAB><C4A3><EFBFBD>ָ<EFBFBD><D6B8>ɳ<EFBFBD><C9B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
void ESP8266_AT_Test(void)
|
void ESP8266_AT_Test(void)
|
||||||
{
|
{
|
||||||
@@ -85,16 +89,15 @@ void ESP8266_ATE0(void)
|
|||||||
delay_ms(1000);
|
delay_ms(1000);
|
||||||
while(count < 10)
|
while(count < 10)
|
||||||
{
|
{
|
||||||
if(ESP8266_Send_AT_Cmd("ATE0","OK",NULL,500))
|
if(ESP8266_Send_AT_Cmd("ATE0","OK",NULL,1000))
|
||||||
{
|
{
|
||||||
printf("OK\r\n");
|
printf("ATE0 OK\r\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
++ count;
|
++ count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//ѡ<><D1A1>ESP8266<36>Ĺ<EFBFBD><C4B9><EFBFBD>ģʽ
|
//ѡ<><D1A1>ESP8266<36>Ĺ<EFBFBD><C4B9><EFBFBD>ģʽ
|
||||||
// enumMode ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
// enumMode ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
|
||||||
//<2F>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>true<75><65>ʧ<EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD>false
|
//<2F>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>true<75><65>ʧ<EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD>false
|
||||||
@@ -116,7 +119,6 @@ bool ESP8266_Net_Mode_Choose(ENUM_Net_ModeTypeDef enumMode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//ESP8266<36><36><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><E2B2BF>WIFI
|
//ESP8266<36><36><EFBFBD><EFBFBD><EFBFBD>ⲿ<EFBFBD><E2B2BF>WIFI
|
||||||
//pSSID WiFi<46>ʺ<EFBFBD>
|
//pSSID WiFi<46>ʺ<EFBFBD>
|
||||||
//pPassWord WiFi<46><69><EFBFBD><EFBFBD>
|
//pPassWord WiFi<46><69><EFBFBD><EFBFBD>
|
||||||
@@ -126,7 +128,7 @@ bool ESP8266_JoinAP( char * pSSID, char * pPassWord)
|
|||||||
char cCmd [120];
|
char cCmd [120];
|
||||||
|
|
||||||
sprintf ( cCmd, "AT+CWJAP=\"%s\",\"%s\"", pSSID, pPassWord );
|
sprintf ( cCmd, "AT+CWJAP=\"%s\",\"%s\"", pSSID, pPassWord );
|
||||||
return ESP8266_Send_AT_Cmd( cCmd, "OK", NULL, 5000 );
|
return ESP8266_Send_AT_Cmd( cCmd, "OK", "WIFI CONNECTED", 5000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
//ESP8266 <><CDB8>ʹ<EFBFBD><CAB9>
|
//ESP8266 <><CDB8>ʹ<EFBFBD><CAB9>
|
||||||
@@ -142,6 +144,18 @@ bool ESP8266_Enable_MultipleId (FunctionalState enumEnUnvarnishTx )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//ESP8266 ʹ<><CAB9><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
//enumEnUnvarnishTx <20>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD>bool<6F><6C><EFBFBD><EFBFBD>
|
||||||
|
//<2F><><EFBFBD>óɹ<C3B3><C9B9><EFBFBD><EFBFBD><EFBFBD>true<75><65><EFBFBD><EFBFBD>֮false
|
||||||
|
bool ESP8266_Enable_AutoConnect (int enable )
|
||||||
|
{
|
||||||
|
char cStr [20];
|
||||||
|
|
||||||
|
sprintf ( cStr, "AT+CWAUTOCONN=%d", enable );
|
||||||
|
|
||||||
|
return ESP8266_Send_AT_Cmd ( cStr, "OK", 0, 500 );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//ESP8266 <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD>
|
//ESP8266 <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD>
|
||||||
//enumE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
//enumE <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
@@ -187,7 +201,6 @@ bool ESP8266_UnvarnishSend ( void )
|
|||||||
|
|
||||||
return
|
return
|
||||||
ESP8266_Send_AT_Cmd( "AT+CIPSEND", "OK", ">", 500 );
|
ESP8266_Send_AT_Cmd( "AT+CIPSEND", "OK", ">", 500 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -202,15 +215,12 @@ bool ESP8266_SendString(FunctionalState enumEnUnvarnishTx, char * pStr, uint32_t
|
|||||||
char cStr [20];
|
char cStr [20];
|
||||||
bool bRet = false;
|
bool bRet = false;
|
||||||
|
|
||||||
|
|
||||||
if ( enumEnUnvarnishTx )
|
if ( enumEnUnvarnishTx )
|
||||||
{
|
{
|
||||||
ESP8266_USART ( "%s", pStr );
|
hal_AT_printf ( "%s", pStr );
|
||||||
|
|
||||||
bRet = true;
|
bRet = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( ucId < 5 )
|
if ( ucId < 5 )
|
||||||
@@ -222,10 +232,8 @@ bool ESP8266_SendString(FunctionalState enumEnUnvarnishTx, char * pStr, uint32_t
|
|||||||
ESP8266_Send_AT_Cmd ( cStr, "> ", 0, 1000 );
|
ESP8266_Send_AT_Cmd ( cStr, "> ", 0, 1000 );
|
||||||
|
|
||||||
bRet = ESP8266_Send_AT_Cmd ( pStr, "SEND OK", 0, 1000 );
|
bRet = ESP8266_Send_AT_Cmd ( pStr, "SEND OK", 0, 1000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
return bRet;
|
return bRet;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -233,7 +241,7 @@ bool ESP8266_SendString(FunctionalState enumEnUnvarnishTx, char * pStr, uint32_t
|
|||||||
void ESP8266_ExitUnvarnishSend ( void )
|
void ESP8266_ExitUnvarnishSend ( void )
|
||||||
{
|
{
|
||||||
delay_ms(1000);
|
delay_ms(1000);
|
||||||
ESP8266_USART( "+++" );
|
hal_AT_printf( "+++" );
|
||||||
delay_ms( 500 );
|
delay_ms( 500 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,18 +257,87 @@ uint8_t ESP8266_Get_LinkStatus ( void )
|
|||||||
{
|
{
|
||||||
if ( strstr ( (char *)ESP8266_Fram_Record_Struct.Data_RX_BUF, "STATUS:2\r\n" ) )
|
if ( strstr ( (char *)ESP8266_Fram_Record_Struct.Data_RX_BUF, "STATUS:2\r\n" ) )
|
||||||
return 2;
|
return 2;
|
||||||
|
|
||||||
else if ( strstr ( (char *)ESP8266_Fram_Record_Struct.Data_RX_BUF, "STATUS:3\r\n" ) )
|
else if ( strstr ( (char *)ESP8266_Fram_Record_Struct.Data_RX_BUF, "STATUS:3\r\n" ) )
|
||||||
return 3;
|
return 3;
|
||||||
|
|
||||||
else if ( strstr ( (char *)ESP8266_Fram_Record_Struct.Data_RX_BUF, "STATUS:4\r\n" ) )
|
else if ( strstr ( (char *)ESP8266_Fram_Record_Struct.Data_RX_BUF, "STATUS:4\r\n" ) )
|
||||||
return 4;
|
return 4;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern char mqtt_tcp_connect(int timeout);
|
||||||
|
|
||||||
|
/*-------------------------------------------------*/
|
||||||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>WiFi<46><69><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
/*<2A><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
/*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>0<EFBFBD><30><EFBFBD><EFBFBD>ȷ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
/*-------------------------------------------------*/
|
||||||
|
char WiFi_Connect_IoTServer(void)
|
||||||
|
{
|
||||||
|
// printf("<><D7BC><EFBFBD><EFBFBD>λģ<CEBB><C4A3>\r\n"); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||||
|
// ESP8266_Rst();
|
||||||
|
|
||||||
|
// ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
ESP8266_ATE0();
|
||||||
|
|
||||||
|
printf("ready to set STA mode\r\n");
|
||||||
|
// <20><><EFBFBD><EFBFBD>STAģʽ
|
||||||
|
if (ESP8266_Net_Mode_Choose(STA))
|
||||||
|
{
|
||||||
|
printf("Set STA mode\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// <><D7BC><EFBFBD>رն<D8B1>·<EFBFBD><C2B7><EFBFBD><EFBFBD>
|
||||||
|
if (ESP8266_Enable_MultipleId(DISABLE))
|
||||||
|
{
|
||||||
|
printf("close multipled ID success\r\n");
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
printf("close multipled ID error\r\n");
|
||||||
|
}
|
||||||
|
// ȡ<><C8A1><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if(ESP8266_Enable_AutoConnect(0)) //ȡ<><C8A1><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD>ӣ<EFBFBD>100ms<6D><73>ʱ<EFBFBD><CAB1>λ<EFBFBD><CEBB><EFBFBD>ܼ<EFBFBD>5s<35><73>ʱʱ<CAB1><CAB1>
|
||||||
|
{
|
||||||
|
printf("ȡ<EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD>\r\n"); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
printf("ȡ<EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n"); //<2F><><EFBFBD>ط<EFBFBD>0ֵ<30><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>if<69><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD>·<EFBFBD><C2B7><EFBFBD><EFBFBD>
|
||||||
|
if(ESP8266_JoinAP(User_SSID, User_PWD))
|
||||||
|
{
|
||||||
|
printf("connect to router success\r\n");
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
printf("connect to router failed\r\n");
|
||||||
|
return 9;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
if(mqtt_tcp_connect(500)) //<2F><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>100ms<6D><73>ʱ<EFBFBD><CAB1>λ<EFBFBD><CEBB><EFBFBD>ܼ<EFBFBD>10s<30><73>ʱʱ<CAB1><CAB1>
|
||||||
|
{
|
||||||
|
printf("connect to server success\r\n"); //<2F><><EFBFBD>ط<EFBFBD>0ֵ<30><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>if<69><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||||
|
//<2F><><EFBFBD><EFBFBD>10
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
printf("connect to server failed\r\n"); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><CDB8>ģʽ
|
||||||
|
if (ESP8266_UnvarnishSend() )
|
||||||
|
{
|
||||||
|
printf("go into unvarnishSend mode\r\n");
|
||||||
|
}
|
||||||
|
return 0; //<2F><>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static char *itoa( int value, char *string, int radix )
|
static char *itoa( int value, char *string, int radix )
|
||||||
{
|
{
|
||||||
int i, d;
|
int i, d;
|
||||||
@@ -311,7 +388,7 @@ static char *itoa( int value, char *string, int radix )
|
|||||||
} /* NCL_Itoa */
|
} /* NCL_Itoa */
|
||||||
|
|
||||||
|
|
||||||
void USART_printf ( char * Data, ... )
|
void hal_AT_printf ( char * Data, ... )
|
||||||
{
|
{
|
||||||
const char *s;
|
const char *s;
|
||||||
int d;
|
int d;
|
||||||
@@ -382,7 +459,6 @@ void USART_printf ( char * Data, ... )
|
|||||||
Data++;
|
Data++;
|
||||||
while( __HAL_UART_GET_FLAG(&huart3, UART_FLAG_TXE) == false);
|
while( __HAL_UART_GET_FLAG(&huart3, UART_FLAG_TXE) == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#ifndef __ESP8266_H
|
#ifndef __ESP8266_H__
|
||||||
#define __ESP8266_H
|
#define __ESP8266_H__
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
@@ -7,9 +7,30 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#if defined ( __CC_ARM )
|
#define ESP8266_RST_Pin GPIO_PIN_4 //<2F><>λ<EFBFBD>ܽ<EFBFBD>
|
||||||
#pragma anon_unions
|
#define ESP8266_RST_Pin_Port GPIOA //<2F><>λ
|
||||||
#endif
|
|
||||||
|
#define ESP8266_CH_PD_Pin GPIO_PIN_5 //ʹ<>ܹܽ<DCB9>
|
||||||
|
#define ESP8266_CH_PD_Pin_Port GPIOA //ʹ<>ܶ˿<DCB6>
|
||||||
|
|
||||||
|
|
||||||
|
#define ESP8266_RST_Pin_SetH HAL_GPIO_WritePin(ESP8266_RST_Pin_Port, ESP8266_RST_Pin, GPIO_PIN_SET)
|
||||||
|
#define ESP8266_RST_Pin_SetL HAL_GPIO_WritePin(ESP8266_RST_Pin_Port, ESP8266_RST_Pin, GPIO_PIN_RESET)
|
||||||
|
|
||||||
|
|
||||||
|
#define ESP8266_CH_PD_Pin_SetH HAL_GPIO_WritePin(ESP8266_CH_PD_Pin_Port,ESP8266_CH_PD_Pin, GPIO_PIN_SET)
|
||||||
|
#define ESP8266_CH_PD_Pin_SetL HAL_GPIO_WritePin(ESP8266_CH_PD_Pin_Port,ESP8266_CH_PD_Pin, GPIO_PIN_RESET)
|
||||||
|
|
||||||
|
|
||||||
|
#define ESP8266_USART(fmt, ...) USART_printf (fmt, ##__VA_ARGS__)
|
||||||
|
#define PC_USART(fmt, ...) printf(fmt, ##__VA_ARGS__) //<2F><><EFBFBD>Ǵ<EFBFBD><C7B4>ڴ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31>ִ<EFBFBD><D6B4>printf<74><66><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>ִ<EFBFBD><D6B4>fput<75><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>printf<74><66>
|
||||||
|
|
||||||
|
|
||||||
|
#define RX_BUF_MAX_LEN 1024 //<2F><><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
|
||||||
|
|
||||||
|
#define User_SSID "brown1" //wifi<66><69>
|
||||||
|
#define User_PWD "123456789a" //wifi<66><69><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
|
||||||
//ESP8266ģʽѡ<CABD><D1A1>
|
//ESP8266ģʽѡ<CABD><D1A1>
|
||||||
typedef enum
|
typedef enum
|
||||||
@@ -55,32 +76,10 @@ typedef enum{
|
|||||||
TYPE_RECV_NONE,
|
TYPE_RECV_NONE,
|
||||||
}type_recv_e;
|
}type_recv_e;
|
||||||
|
|
||||||
#define ESP8266_RST_Pin GPIO_PIN_4 //<2F><>λ<EFBFBD>ܽ<EFBFBD>
|
|
||||||
#define ESP8266_RST_Pin_Port GPIOA //<2F><>λ
|
|
||||||
|
|
||||||
#define ESP8266_CH_PD_Pin GPIO_PIN_5 //ʹ<>ܹܽ<DCB9>
|
|
||||||
#define ESP8266_CH_PD_Pin_Port GPIOA //ʹ<>ܶ˿<DCB6>
|
|
||||||
|
|
||||||
|
|
||||||
#define ESP8266_RST_Pin_SetH HAL_GPIO_WritePin(ESP8266_RST_Pin_Port, ESP8266_RST_Pin, GPIO_PIN_SET)
|
|
||||||
#define ESP8266_RST_Pin_SetL HAL_GPIO_WritePin(ESP8266_RST_Pin_Port, ESP8266_RST_Pin, GPIO_PIN_RESET)
|
|
||||||
|
|
||||||
|
|
||||||
#define ESP8266_CH_PD_Pin_SetH HAL_GPIO_WritePin(ESP8266_CH_PD_Pin_Port,ESP8266_CH_PD_Pin, GPIO_PIN_SET)
|
|
||||||
#define ESP8266_CH_PD_Pin_SetL HAL_GPIO_WritePin(ESP8266_CH_PD_Pin_Port,ESP8266_CH_PD_Pin, GPIO_PIN_RESET)
|
|
||||||
|
|
||||||
|
|
||||||
#define ESP8266_USART(fmt, ...) USART_printf (fmt, ##__VA_ARGS__)
|
|
||||||
#define PC_USART(fmt, ...) printf(fmt, ##__VA_ARGS__) //<2F><><EFBFBD>Ǵ<EFBFBD><C7B4>ڴ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31>ִ<EFBFBD><D6B4>printf<74><66><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD>ִ<EFBFBD><D6B4>fput<75><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><D8B6><EFBFBD><EFBFBD><EFBFBD>printf<74><66>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define RX_BUF_MAX_LEN 1024 //<2F><><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>
|
|
||||||
|
|
||||||
typedef int (*wifi_data_arrvied)(type_recv_e type, uint8_t *data, int len); // <20><><EFBFBD><EFBFBD>ָ<EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD>WIFI<46><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
typedef int (*wifi_data_arrvied)(type_recv_e type, uint8_t *data, int len); // <20><><EFBFBD><EFBFBD>ָ<EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD>WIFI<46><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
|
#pragma anon_unions
|
||||||
extern struct STRUCT_USART_Fram //<2F><><EFBFBD><EFBFBD>֡<EFBFBD>ṹ<EFBFBD><E1B9B9>
|
typedef struct STRUCT_USART_Fram //<2F><><EFBFBD><EFBFBD>֡<EFBFBD>ṹ<EFBFBD><E1B9B9>
|
||||||
{
|
{
|
||||||
uint8_t Data_RX_BUF[RX_BUF_MAX_LEN];
|
uint8_t Data_RX_BUF[RX_BUF_MAX_LEN];
|
||||||
union
|
union
|
||||||
@@ -92,18 +91,17 @@ extern struct STRUCT_USART_Fram //
|
|||||||
__IO uint16_t FramFinishFlag :1; // 15
|
__IO uint16_t FramFinishFlag :1; // 15
|
||||||
}InfBit;
|
}InfBit;
|
||||||
};
|
};
|
||||||
wifi_data_arrvied wifi_data_recv_cb;
|
wifi_data_arrvied wifi_data_recv_cb;
|
||||||
|
|
||||||
}ESP8266_Fram_Record_Struct;
|
}STRUCT_USART_Fram_t;
|
||||||
|
extern STRUCT_USART_Fram_t ESP8266_Fram_Record_Struct;
|
||||||
|
|
||||||
|
|
||||||
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>TCP<43><50><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
|
//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>TCP<43><50><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
|
||||||
void ESP8266_Init(uint32_t bound);
|
void ESP8266_Init(uint32_t bound);
|
||||||
void ESP8266_AT_Test(void);
|
void ESP8266_AT_Test(void);
|
||||||
void ESP8266_ATE0(void);
|
void ESP8266_ATE0(void);
|
||||||
bool ESP8266_Send_AT_Cmd(char *cmd,char *ack1,char *ack2,uint32_t time);
|
bool ESP8266_Send_AT_Cmd(char *cmd,char *ack1,char *ack2,uint32_t time);
|
||||||
void ESP8266_Rst(void);
|
char ESP8266_Rst(void);
|
||||||
bool ESP8266_Net_Mode_Choose(ENUM_Net_ModeTypeDef enumMode);
|
bool ESP8266_Net_Mode_Choose(ENUM_Net_ModeTypeDef enumMode);
|
||||||
bool ESP8266_JoinAP( char * pSSID, char * pPassWord );
|
bool ESP8266_JoinAP( char * pSSID, char * pPassWord );
|
||||||
bool ESP8266_Enable_MultipleId ( FunctionalState enumEnUnvarnishTx );
|
bool ESP8266_Enable_MultipleId ( FunctionalState enumEnUnvarnishTx );
|
||||||
@@ -112,15 +110,8 @@ bool ESP8266_SendString(FunctionalState enumEnUnvarnishTx, char * pStr, uint32_t
|
|||||||
bool ESP8266_UnvarnishSend ( void );
|
bool ESP8266_UnvarnishSend ( void );
|
||||||
void ESP8266_ExitUnvarnishSend ( void );
|
void ESP8266_ExitUnvarnishSend ( void );
|
||||||
uint8_t ESP8266_Get_LinkStatus ( void );
|
uint8_t ESP8266_Get_LinkStatus ( void );
|
||||||
void USART_printf( char * Data, ... );
|
void hal_AT_printf( char * Data, ... );
|
||||||
|
char WiFi_Connect_IoTServer(void);
|
||||||
//MQTT<54><54><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD>
|
|
||||||
bool ESP8266_MQTTUSERCFG( char * pClient_Id, char * pUserName,char * PassWord);
|
|
||||||
bool ESP8266_MQTTCONN( char * Ip, int Num);
|
|
||||||
bool ESP8266_MQTTSUB(char * Topic);
|
|
||||||
bool ESP8266_MQTTPUB( char * Topic,char *temp);
|
|
||||||
bool ESP8266_MQTTCLEAN(void);
|
|
||||||
bool MQTT_SendString(char * pTopic,char *temp2);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
#include "mqtt.h"
|
#include "mqtt.h"
|
||||||
|
#include "usart.h"
|
||||||
#define MQTT_NAME "n87ieud/my_board2"
|
|
||||||
#define MQTT_PW "k4e9trh5qjwjhc2q"
|
|
||||||
#define MQTT_CLIENT_ID "my_board2"
|
|
||||||
|
|
||||||
#define MQTT_TOPIC_UPDATE "$baidu/iot/shadow/my_board2/update"
|
|
||||||
#define MQTT_TOPIC_DELTA "$baidu/iot/shadow/my_board2/delta"
|
|
||||||
#define MQTT_TOPIC_SNAPSHOT "$baidu/iot/shadow/my_board2/update/snapshot"
|
|
||||||
|
|
||||||
|
|
||||||
char str[] = "{\"deviceNum\": \"E8DB84933089\",\"relayStatus\": 0,\"lightStatus\": 0,\"isOnline\": 1,\"rssi\": -54,\"deviceTemperature\": 38}";
|
char str[] = "{\"deviceNum\": \"E8DB84933089\",\"relayStatus\": 0,\"lightStatus\": 0,\"isOnline\": 1,\"rssi\": -54,\"deviceTemperature\": 38}";
|
||||||
|
|
||||||
@@ -16,7 +8,7 @@ static int mqtt_send(uint8_t head, uint32_t vlen, uint8_t *vhead,
|
|||||||
{
|
{
|
||||||
int32_t tmp_encode, tmp_x;
|
int32_t tmp_encode, tmp_x;
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
uint8_t msg[RX_BUFF_LEN];
|
uint8_t msg[RX_BUF_MAX_LEN];
|
||||||
msg[i++] = head;
|
msg[i++] = head;
|
||||||
|
|
||||||
tmp_x = vlen + pay_len;
|
tmp_x = vlen + pay_len;
|
||||||
@@ -37,10 +29,13 @@ static int mqtt_send(uint8_t head, uint32_t vlen, uint8_t *vhead,
|
|||||||
memcpy(&msg[i], payload, pay_len);
|
memcpy(&msg[i], payload, pay_len);
|
||||||
i = i + pay_len;
|
i = i + pay_len;
|
||||||
}
|
}
|
||||||
esp8266_send(msg, i);
|
ESP8266_Fram_Record_Struct.InfBit.FramFinishFlag = 0;
|
||||||
|
ESP8266_Fram_Record_Struct.InfBit.FramLength = 0;
|
||||||
|
HAL_UART_Transmit(&huart3, msg, i, 0xFFFF);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mqtt_str_fill(uint8_t *outbuff, char *instr)
|
static int mqtt_str_fill(uint8_t *outbuff, char *instr)
|
||||||
{
|
{
|
||||||
uint8_t *p_tmp;
|
uint8_t *p_tmp;
|
||||||
@@ -53,17 +48,20 @@ static int mqtt_str_fill(uint8_t *outbuff, char *instr)
|
|||||||
|
|
||||||
static int mqtt_recv(uint8_t *ackbuff, uint16_t *ack_len, int timeout)
|
static int mqtt_recv(uint8_t *ackbuff, uint16_t *ack_len, int timeout)
|
||||||
{
|
{
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (esp8266_recv(ackbuff, &ack_len) == 0) {
|
if(1 == ESP8266_Fram_Record_Struct.InfBit.FramFinishFlag)
|
||||||
|
{
|
||||||
|
memcpy(ackbuff, ESP8266_Fram_Record_Struct.Data_RX_BUF, ESP8266_Fram_Record_Struct.InfBit.FramLength);
|
||||||
|
*ack_len = ESP8266_Fram_Record_Struct.InfBit.FramLength;
|
||||||
|
ESP8266_Fram_Record_Struct.InfBit.FramFinishFlag = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeout > 0) {
|
if (timeout > 0) {
|
||||||
HAL_Delay(100);
|
HAL_Delay(100);
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (timeout--);
|
} while (timeout--);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -71,7 +69,7 @@ static int mqtt_recv(uint8_t *ackbuff, uint16_t *ack_len, int timeout)
|
|||||||
static int mqtt_ack_check(uint8_t head, int timeout, uint16_t msg_id)
|
static int mqtt_ack_check(uint8_t head, int timeout, uint16_t msg_id)
|
||||||
{
|
{
|
||||||
uint8_t recv_head;
|
uint8_t recv_head;
|
||||||
uint8_t recv_buff[RX_BUFF_LEN];
|
uint8_t recv_buff[RX_BUF_MAX_LEN];
|
||||||
uint16_t recv_len;
|
uint16_t recv_len;
|
||||||
|
|
||||||
if (mqtt_recv(recv_buff, &recv_len, timeout) != 0) {
|
if (mqtt_recv(recv_buff, &recv_len, timeout) != 0) {
|
||||||
@@ -97,6 +95,20 @@ static int mqtt_ack_check(uint8_t head, int timeout, uint16_t msg_id)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------*/
|
||||||
|
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>TCP<43><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
/*<2A><> <20><><EFBFBD><EFBFBD>timeout<75><74> <20><>ʱʱ<CAB1>䣨100ms<6D>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
/*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>True<75><65><EFBFBD><EFBFBD>ȷ False<73><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
||||||
|
/*-------------------------------------------------*/
|
||||||
|
char mqtt_tcp_connect(int timeout)
|
||||||
|
{
|
||||||
|
char cCmd [120];
|
||||||
|
|
||||||
|
sprintf (cCmd, "AT+CIPSTART=\"TCP\",\"%s\",%d\r\n", User_MQTTServer_IP, User_MQTTServer_PORT);
|
||||||
|
|
||||||
|
return ESP8266_Send_AT_Cmd ( cCmd, "OK", "WIFI GOT IP", timeout);
|
||||||
|
}
|
||||||
|
|
||||||
static int mqtt_connect(char *name, char *pwd, char *client_id)
|
static int mqtt_connect(char *name, char *pwd, char *client_id)
|
||||||
{
|
{
|
||||||
uint32_t i, j;
|
uint32_t i, j;
|
||||||
@@ -251,8 +263,9 @@ static int mqtt_publish_from_cloud(uint8_t *ackbuff, uint16_t ack_len)
|
|||||||
payload_len = remain_len - vhead_len - 4;
|
payload_len = remain_len - vhead_len - 4;
|
||||||
|
|
||||||
memcpy(payload, &ackbuff[i], payload_len);
|
memcpy(payload, &ackbuff[i], payload_len);
|
||||||
if (strcmp((char*) topic, MQTT_TOPIC_DELTA) == 0) {
|
if (strcmp((char*) topic, User_MQTTServer_Topic_SUB) == 0) {
|
||||||
sensor_data_set(payload);
|
// sensor_data_set(payload);
|
||||||
|
;
|
||||||
}
|
}
|
||||||
mqtt_publish_ack(msg_id);
|
mqtt_publish_ack(msg_id);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -268,7 +281,7 @@ int mqtt_beat(void)
|
|||||||
uint32_t i = 0, j = 0;
|
uint32_t i = 0, j = 0;
|
||||||
mqtt_send(head, i, vhead, j, payload);
|
mqtt_send(head, i, vhead, j, payload);
|
||||||
if (mqtt_ack_check(MQTT_PINGRESP, 100, 0) != 0) {
|
if (mqtt_ack_check(MQTT_PINGRESP, 100, 0) != 0) {
|
||||||
if (mqtt_connect(MQTT_NAME, MQTT_PW, MQTT_CLIENT_ID) != 0) {
|
if (mqtt_connect(User_Username, User_Password, User_Client_ID) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}else{
|
}else{
|
||||||
return 0;
|
return 0;
|
||||||
@@ -280,7 +293,7 @@ int mqtt_beat(void)
|
|||||||
int mqtt_handle(void)
|
int mqtt_handle(void)
|
||||||
{
|
{
|
||||||
uint8_t recv_head;
|
uint8_t recv_head;
|
||||||
uint8_t recv_buff[RX_BUFF_LEN];
|
uint8_t recv_buff[RX_BUF_MAX_LEN];
|
||||||
uint16_t recv_len;
|
uint16_t recv_len;
|
||||||
|
|
||||||
if (mqtt_recv(recv_buff, &recv_len, 0) != 0) {
|
if (mqtt_recv(recv_buff, &recv_len, 0) != 0) {
|
||||||
@@ -299,7 +312,7 @@ int mqtt_handle(void)
|
|||||||
|
|
||||||
int mqtt_publish_update(uint8_t *msg, uint16_t msg_len)
|
int mqtt_publish_update(uint8_t *msg, uint16_t msg_len)
|
||||||
{
|
{
|
||||||
if (mqtt_publish(MQTT_TOPIC_UPDATE, msg, msg_len, msg_id++) != 0) {
|
if (mqtt_publish(User_MQTTServer_Topic_PUB, msg, msg_len, msg_id++) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -307,17 +320,20 @@ int mqtt_publish_update(uint8_t *msg, uint16_t msg_len)
|
|||||||
|
|
||||||
int mqtt_init(void)
|
int mqtt_init(void)
|
||||||
{
|
{
|
||||||
if (mqtt_connect(MQTT_NAME, MQTT_PW, MQTT_CLIENT_ID) != 0) {
|
if (mqtt_connect(User_Username, User_Password, User_Client_ID) != 0) {
|
||||||
mqtt_disconnect();
|
printf("MQTT handshake error\r\n");
|
||||||
esp8266_init();
|
return -1;
|
||||||
HAL_Delay(100);
|
}else
|
||||||
if (mqtt_connect(MQTT_NAME, MQTT_PW, MQTT_CLIENT_ID) != 0) {
|
{
|
||||||
return -1;
|
printf("MQTT handshake success\r\n");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mqtt_subscriber(MQTT_TOPIC_DELTA, msg_id++) != 0) {
|
if (mqtt_subscriber(User_MQTTServer_Topic_SUB, msg_id++) != 0) {
|
||||||
|
printf("subscribe error\r\n");
|
||||||
return -1;
|
return -1;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
printf("subscribe success\r\n");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +1,18 @@
|
|||||||
#ifndef __MQTT_H
|
#ifndef __MQTT_H__
|
||||||
#define __MQTT_H
|
#define __MQTT_H __
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "esp8266.h"
|
#include "esp8266.h"
|
||||||
|
|
||||||
|
#define User_Client_ID "50fccfefb50a48b98a93ce27bb04592f" //MQTTclientID <20><><EFBFBD>ڱ<EFBFBD>־client<6E><74><EFBFBD><EFBFBD> <20>256<35>ֽ<EFBFBD>
|
||||||
|
#define User_Username "admin" //<2F><><EFBFBD>ڵ<EFBFBD>¼ MQTT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> username, <20> 64 <20>ֽ<EFBFBD>
|
||||||
|
#define User_Password "admin123" //<2F><><EFBFBD>ڵ<EFBFBD>¼ MQTT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> password, <20> 64 <20>ֽ<EFBFBD>
|
||||||
|
#define User_MQTTServer_IP "106.12.9.213" //MQTT<54><54><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>IP
|
||||||
|
#define User_MQTTServer_PORT 1883 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿ں<CBBF>
|
||||||
|
#define User_MQTTServer_Topic_PUB "status" //<2F><><EFBFBD><EFBFBD>MQTT<54><54><EFBFBD><EFBFBD>
|
||||||
|
#define User_MQTTServer_Topic_SUB "status/set/E8DB84933088" //<2F><><EFBFBD><EFBFBD>MQTT<54><54><EFBFBD><EFBFBD>
|
||||||
|
|
||||||
#define User_ESP8266_SSID "brown" //wifi<66><69>
|
typedef enum {
|
||||||
#define User_ESP8266_PWD "123456789a" //wifi<66><69><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
#define User_ESP8266_client_id "50fccfefb50a48b98a93ce27bb04591f" //MQTTclientID <20><><EFBFBD>ڱ<EFBFBD>־client<6E><74><EFBFBD><EFBFBD> <20>256<35>ֽ<EFBFBD>
|
|
||||||
#define User_ESP8266_username "admin" //<2F><><EFBFBD>ڵ<EFBFBD>¼ MQTT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> username, <20> 64 <20>ֽ<EFBFBD>
|
|
||||||
#define User_ESP8266_password "admin123" //<2F><><EFBFBD>ڵ<EFBFBD>¼ MQTT <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> password, <20> 64 <20>ֽ<EFBFBD>
|
|
||||||
#define User_ESP8266_MQTTServer_IP "106.12.9.213" //MQTT<54><54><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD>IP
|
|
||||||
#define User_ESP8266_MQTTServer_PORT 1883 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿ں<CBBF>
|
|
||||||
#define User_ESP8266_MQTTServer_Topic_PUB "status" //<2F><><EFBFBD><EFBFBD>MQTT<54><54><EFBFBD><EFBFBD>
|
|
||||||
#define User_ESP8266_MQTTServer_Topic_SUB "status/set/E8DB84933089" //<2F><><EFBFBD><EFBFBD>MQTT<54><54><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
enum{
|
|
||||||
MQTT_NULL = 0,
|
MQTT_NULL = 0,
|
||||||
MQTT_CONNECT = 1 << 4,
|
MQTT_CONNECT = 1 << 4,
|
||||||
MQTT_CONNACK = 2 << 4,
|
MQTT_CONNACK = 2 << 4,
|
||||||
@@ -38,7 +30,7 @@ enum{
|
|||||||
MQTT_DISCONNECT = 14 << 4,
|
MQTT_DISCONNECT = 14 << 4,
|
||||||
}MQTT_HEAD_T;
|
}MQTT_HEAD_T;
|
||||||
|
|
||||||
enum{
|
typedef enum{
|
||||||
CONNECT_FLAG = 0,
|
CONNECT_FLAG = 0,
|
||||||
CONNECT_FLAG_NAME = 1 << 7,
|
CONNECT_FLAG_NAME = 1 << 7,
|
||||||
CONNECT_FLAG_PWD = 1 << 6,
|
CONNECT_FLAG_PWD = 1 << 6,
|
||||||
@@ -48,7 +40,7 @@ enum{
|
|||||||
CONNECT_FLAG_CLS = 1 << 1,
|
CONNECT_FLAG_CLS = 1 << 1,
|
||||||
}CONNECT_T;
|
}CONNECT_T;
|
||||||
|
|
||||||
enum{
|
typedef enum{
|
||||||
PUBLISH_FLAG_RETN = 1,
|
PUBLISH_FLAG_RETN = 1,
|
||||||
PUBLISH_FLAG_QOS0 = 0,
|
PUBLISH_FLAG_QOS0 = 0,
|
||||||
PUBLISH_FLAG_QOS1 = 1 << 1,
|
PUBLISH_FLAG_QOS1 = 1 << 1,
|
||||||
@@ -61,10 +53,5 @@ int mqtt_handle(void);
|
|||||||
int mqtt_beat(void);
|
int mqtt_beat(void);
|
||||||
int mqtt_publish_update(uint8_t *msg, uint16_t msg_len);
|
int mqtt_publish_update(uint8_t *msg, uint16_t msg_len);
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __MQTT_H */
|
#endif /* __MQTT_H */
|
||||||
|
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
#include "tcp.h"
|
|
||||||
|
|
||||||
volatile uint8_t TcpClosedFlag = 0;
|
|
||||||
|
|
||||||
void ESP8266_STA_TCPClient_Test(void)
|
|
||||||
{
|
|
||||||
uint8_t res;
|
|
||||||
|
|
||||||
char str[100]={0};
|
|
||||||
ESP8266_AT_Test();
|
|
||||||
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ESP8266\r\n");
|
|
||||||
ESP8266_Net_Mode_Choose(STA);
|
|
||||||
while(!ESP8266_JoinAP(User_ESP8266_SSID, User_ESP8266_PWD));
|
|
||||||
ESP8266_Enable_MultipleId ( DISABLE );
|
|
||||||
while(!ESP8266_Link_Server(enumTCP, User_ESP8266_TCPServer_IP, User_ESP8266_TCPServer_PORT, Single_ID_0));
|
|
||||||
while(!ESP8266_UnvarnishSend());
|
|
||||||
printf("\r\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
||||||
while ( 1 )
|
|
||||||
{
|
|
||||||
sprintf (str,"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD><EFBFBD>ſɿƼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˾" );//<2F><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>TCP<43><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
ESP8266_SendString ( ENABLE, str, 0, Single_ID_0 );
|
|
||||||
delay_ms(1000);
|
|
||||||
if(TcpClosedFlag) //<2F>ж<EFBFBD><D0B6>Ƿ<EFBFBD>ʧȥ<CAA7><C8A5><EFBFBD><EFBFBD>
|
|
||||||
{
|
|
||||||
ESP8266_ExitUnvarnishSend(); //<2F>˳<EFBFBD><EFBFBD><CDB8>ģʽ
|
|
||||||
do
|
|
||||||
{
|
|
||||||
res = ESP8266_Get_LinkStatus(); //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>״̬
|
|
||||||
}
|
|
||||||
while(!res);
|
|
||||||
|
|
||||||
if(res == 4) //ȷ<><C8B7>ʧȥ<CAA7><C8A5><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
while (!ESP8266_JoinAP(User_ESP8266_SSID, User_ESP8266_PWD ) );
|
|
||||||
while (!ESP8266_Link_Server(enumTCP, User_ESP8266_TCPServer_IP, User_ESP8266_TCPServer_PORT, Single_ID_0 ) );
|
|
||||||
}
|
|
||||||
while(!ESP8266_UnvarnishSend());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#ifndef __TCP_H
|
|
||||||
#define __TCP_H
|
|
||||||
|
|
||||||
#include "main.h"
|
|
||||||
#include "esp8266.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
*<2A><><EFBFBD>²<EFBFBD><C2B2><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<DEB8><C4B2>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD>ù<EFBFBD>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define User_ESP8266_SSID "miot_default" //wifi<66><69>
|
|
||||||
#define User_ESP8266_PWD "123456789x" //wifi<66><69><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
#define User_ESP8266_TCPServer_IP "192.168.31.16" //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IP
|
|
||||||
#define User_ESP8266_TCPServer_PORT "8888" //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˿ں<CBBF>
|
|
||||||
|
|
||||||
|
|
||||||
extern volatile uint8_t TcpClosedFlag; //<2F><><EFBFBD><EFBFBD>״̬<D7B4><CCAC>־
|
|
||||||
|
|
||||||
void ESP8266_STA_TCPClient_Test(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user