esp8266.h.bak 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef __BSP_ESP8266_H
  2. #define __BSP_ESP8266_H
  3. #include "stm32f1xx_hal.h"
  4. //#include "common.h"
  5. #include <stdio.h>
  6. #include <stdbool.h>
  7. #include "sys.h"
  8. #if defined ( __CC_ARM )
  9. #pragma anon_unions
  10. #endif
  11. /******************************* ESP8266 数据类型定义 ***************************/
  12. typedef enum{
  13. STA,
  14. AP,
  15. STA_AP
  16. } ENUM_Net_ModeTypeDef;
  17. typedef enum{
  18. enumTCP,
  19. enumUDP,
  20. } ENUM_NetPro_TypeDef;
  21. typedef enum{
  22. Multiple_ID_0 = 0,
  23. Multiple_ID_1 = 1,
  24. Multiple_ID_2 = 2,
  25. Multiple_ID_3 = 3,
  26. Multiple_ID_4 = 4,
  27. Single_ID_0 = 5,
  28. } ENUM_ID_NO_TypeDef;
  29. typedef enum{
  30. OPEN = 0,
  31. WEP = 1,
  32. WPA_PSK = 2,
  33. WPA2_PSK = 3,
  34. WPA_WPA2_PSK = 4,
  35. } ENUM_AP_PsdMode_TypeDef;
  36. /******************************* ESP8266 外部全局变量声明 ***************************/
  37. #define RX_BUF_MAX_LEN 1024 //最大接收缓存字节数
  38. extern struct STRUCT_USARTx_Fram //串口数据帧的处理结构体
  39. {
  40. char Data_RX_BUF [ RX_BUF_MAX_LEN ];
  41. union {
  42. __IO u16 InfAll;
  43. struct {
  44. __IO u16 FramLength :15; // 14:0
  45. __IO u16 FramFinishFlag :1; // 15
  46. } InfBit;
  47. };
  48. } strEsp8266_Fram_Record;
  49. /******************************** ESP8266 连接引脚定义 ***********************************/
  50. /*********************************************** ESP8266 函数宏定义 *******************************************/
  51. #define macESP8266_Usart( fmt, ... ) USART_printf ( macESP8266_USARTx, fmt, ##__VA_ARGS__ )
  52. #define macPC_Usart( fmt, ... ) printf ( fmt, ##__VA_ARGS__ )
  53. #define ESP8266_IO0 PCin(11) //ESP8266 IO0管脚
  54. #define ESP8266_RST PCout(10) //ESP8266复位管脚 低电平复位有效
  55. /****************************************** ESP8266 函数声明 ***********************************************/
  56. void ESP8266_Init ( void );
  57. void ESP8266_Rst ( void );
  58. bool ESP8266_Cmd ( char * cmd, char * reply1, char * reply2, u32 waittime );
  59. void ESP8266_AT_Test ( void );
  60. bool ESP8266_Net_Mode_Choose ( ENUM_Net_ModeTypeDef enumMode );
  61. bool ESP8266_JoinAP ( char * pSSID, char * pPassWord );
  62. bool ESP8266_BuildAP ( char * pSSID, char * pPassWord, ENUM_AP_PsdMode_TypeDef enunPsdMode );
  63. bool ESP8266_Enable_MultipleId ( FunctionalState enumEnUnvarnishTx );
  64. bool ESP8266_Link_Server ( ENUM_NetPro_TypeDef enumE, char * ip, char * ComNum, ENUM_ID_NO_TypeDef id);
  65. bool ESP8266_StartOrShutServer ( FunctionalState enumMode, char * pPortNum, char * pTimeOver );
  66. uint8_t ESP8266_Get_LinkStatus ( void );
  67. uint8_t ESP8266_Get_IdLinkStatus ( void );
  68. uint8_t ESP8266_Inquire_ApIp ( char * pApIp, uint8_t ucArrayLength );
  69. bool ESP8266_UnvarnishSend ( void );
  70. void ESP8266_ExitUnvarnishSend ( void );
  71. bool ESP8266_SendString ( FunctionalState enumEnUnvarnishTx, char * pStr, u32 ulStrLength, ENUM_ID_NO_TypeDef ucId );
  72. char * ESP8266_ReceiveString ( FunctionalState enumEnUnvarnishTx );
  73. uint8_t ESP8266_CWLIF ( char * pStaIp );
  74. uint8_t ESP8266_CIPAP ( char * pApIp );
  75. #endif