/*
 * hy40r204.h
 *
 *  Created on: 2022年4月11日
 *      Author: dell
 */

#ifndef ESP32_WROOM_32D_H_
#define ESP32_WROOM_32D_H_
#include <stdio.h>
#include <string.h>
#include "onechip_include_header.h"

/* USER CODE BEGIN Private defines */
#define MAX_RESEND_TIME 5

//WIFI模块状态
enum WIFI_State
{
  WIFI_POWEROFF = -1,   //重启
  WIFI_POWERON = 0,   //上电
  WIFI_INIT,      //初始化
  WIFI_STATION,   //设置Station模式
  WIFI_CWLAP,      //禁止自动连接
  WIFI_DISAUTO,      //禁止自动连接
  WIFI_LINK_AP,   //连接AP
  WIFI_GET_IP,    //查询IP
  WIFI_SETMUX,      //打开多链接
  WIFI_LISTEN,    //监听广播
  WIFI_TRANS,    //数据传输
  WIFI_CLOSE,    //关闭链接
  WIFI_ERROR,    //错误状态
};


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 User_ESP32_SSID     "Onechip"
#define User_ESP32_PWD      "onechip1003"

#define User_ESP32_TCPServer_IP     "192.168.3.182"
#define User_ESP32_TCPServer_PORT   "8002"
#define User_ESP32_UDPServer_IP     "255.255.255.255"
#define User_ESP32_UDPServer_PORT   "9090"

char* find_str(void *src, int size,char *str);
void WIFI_set_ssid(void);
void WIFI_process(void);
void WIFI_set_CloseConnect(void);
int WIFI_Send_Data(uint8_t *data, uint16_t len, uint8_t flag);
int WIFI_Send_MSG(uint8_t*msgHead,uint8_t *data, uint8_t * crc, uint16_t len);
int WIFI_ReSend(void);
int WIFI_SendIlde(void);

int my_sprintf(char *pdes,unsigned int len, const char* str, ...);


#endif /* ESP32_WROOM_32D_H_ */
