Files
SM-1000M/RTX5_20220316/Driver/esp8266/esp8266.h
2026-04-23 10:50:18 +08:00

90 lines
2.5 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __ESP8266_H
#define __ESP8266_H
#include "stm32l1xx.h"
#include "pbdata.h"
#include "bsp.h"
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#if defined ( __CC_ARM )
#pragma anon_unions
#endif
//ESP8266模式选择
typedef enum
{
STA,
AP,
STA_AP
}ENUM_Net_ModeTypeDef;
//网络传输层协议,枚举类型
typedef enum{
enumTCP,
enumUDP,
} ENUM_NetPro_TypeDef;
//连接号,指定为该连接号可以防止其他计算机访问同一端口而发生错误
typedef enum{
Multiple_ID_0 = 0,
Multiple_ID_1 = 1,
Multiple_ID_2 = 2,
Multiple_ID_3 = 3,
Multiple_ID_4 = 4,
Single_ID_0 = 5,
} ENUM_ID_NO_TypeDef;
#define ESP8266_USART(fmt, ...) USART_printf (UART4, fmt, ##__VA_ARGS__)
#define PC_USART(fmt, ...) printf(fmt, ##__VA_ARGS__) //这是串口打印函数串口1执行printf后会自动执行fput函数重定向了printf。
#define RX_BUF_MAX_LEN 200 //最大字节数
extern struct STRUCT_USART_Fram //数据帧结构体
{
char Data_RX_BUF[RX_BUF_MAX_LEN];
union
{
__IO u16 InfAll;
struct
{
__IO u16 FramLength :15; // 14:0
__IO u16 FramFinishFlag :1; // 15
}InfBit;
};
}ESP8266_Fram_Record_Struct;
//初始化和TCP功能函数
void ESP8266_Init(u32 bound);
void ESP8266_AT_Test(void);
bool ESP8266_Send_AT_Cmd(char *cmd,char *ack1,char *ack2,u32 time);
//void ESP8266_Rst(void);
bool ESP8266_Net_Mode_Choose(ENUM_Net_ModeTypeDef enumMode);
bool ESP8266_JoinAP( char * pSSID, char * pPassWord );
bool ESP8266_Enable_MultipleId ( FunctionalState enumEnUnvarnishTx );
bool ESP8266_Link_Server(ENUM_NetPro_TypeDef enumE, char * ip, char * ComNum);
bool ESP8266_SendString(FunctionalState enumEnUnvarnishTx, char * pStr, u32 ulStrLength, char ucId );
bool ESP8266_UnvarnishSend ( void );
void ESP8266_ExitUnvarnishSend ( void );
void ESP8266_Fram_Record_Struct_Clear(void);//清除缓存
u8 ESP8266_Get_LinkStatus ( void );
void USART_printf( USART_TypeDef * USARTx, char * Data, ... );
bool ESP8266_CWSAP_Set ( char * SSID, char * PWD,char CHL, char ECN );
bool ESP8266_Server_Create ( char * Port, FunctionalState Dis_En );
//MQTT功能函数
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