/*
tuya_cloud_wifi_defs.h
Copyright(C),2018-2020, 涂鸦科技 www.tuya.comm
*/

#ifndef TUYA_CLOUD_WIFI_DEFS_H
#define TUYA_CLOUD_WIFI_DEFS_H

#include "tuya_cloud_types.h"

#ifdef __cplusplus
extern "C" {
#endif

/* tuya sdk definition of wifi work mode */
typedef BYTE_T GW_WF_CFG_MTHD_SEL;  // wifi config method select
#define GWCM_OLD                0   // do not have low power mode
#define GWCM_LOW_POWER          1   // with low power mode
#define GWCM_SPCL_MODE          2   // special with low power mode
#define GWCM_OLD_PROD           3   // GWCM_OLD mode with product
#define GWCM_LOW_POWER_AUTOCFG  4   // with low power mode && auto cfg
#define GWCM_SPCL_AUTOCFG       5   // special with low power mode && auto cfg



/* tuya sdk definition of wifi start mode */
typedef BYTE_T GW_WF_START_MODE;
#define WF_START_AP_ONLY        0   // only have ap-cfg mode
#define WF_START_SMART_ONLY     1   // only have smart-cfg mode
#define WF_START_AP_FIRST       2   // have both ap-cfg and smart-cfg. default is ap-cfg mode
#define WF_START_SMART_FIRST    3   // have both ap-cfg and smart-cfg. default is smart-cfg mode
#define WF_START_SMART_AP_CONCURRENT    4   //  ap-cfg and smart-cfg is concurrent

/* tuya sdk definition of wifi-config status */
typedef BYTE_T GW_WF_NWC_STAT_T;
#define GWNS_LOWPOWER           0   // current in low power mode
#define GWNS_UNCFG_SMC          1   // current in smart-cfg mode
#define GWNS_UNCFG_AP           2   // current in ap-cfg mode
#define GWNS_TY_SMARTCFG        3   // already get ssid && passwd from smart-cfg mode
#define GWNS_TY_AP              4   // already get ssid && passwd from ap-cfg mode
#define GWNS_WECHAT_AK          5   // already get ssid && passwd from wechat mode
#define GWNS_OTHER_CFG          6   // already get ssid && passwd from other mode.for example:uart、bluetooth、qrcode and so on
#define GWNS_NO_NEED_CFG        7   // no need config wifi
#define GWNS_TY_SMART_AP_CFG	9	//already get ssid && passwd from smart-cfg and ap-cfg concurrent mode
#define GWNS_UNCFG_SMC_AP		10 	//current in smart-cfg and ap-cfg concurrent mode

/* tuya sdk definition of wifi-config fast status */
typedef BYTE_T GW_WF_NWC_FAST_STAT_T;
#define GWNS_FAST_LOWPOWER           0   // current in low power mode
#define GWNS_FAST_UNCFG_SMC          1   // current in smart-cfg mode
#define GWNS_FAST_UNCFG_AP           2   // current in ap-cfg mode
#define GWNS_FAST_UNCFG_NORMAL       3   // current in normal mode


/* tuya sdk definition of wifi-net status */
typedef BYTE_T GW_WIFI_NW_STAT_E;
#define STAT_LOW_POWER          0   // idle status,use to external config network
#define STAT_UNPROVISION        1   // smart config status
#define STAT_AP_STA_UNCFG       2   // ap WIFI config status
#define STAT_AP_STA_DISC        3   // ap WIFI already config,station disconnect
#define STAT_AP_STA_CONN        4   // ap station mode,station connect
#define STAT_STA_DISC           5   // only station mode,disconnect
#define STAT_STA_CONN           6   // station mode connect
#define STAT_CLOUD_CONN         7   // cloud connect
#define STAT_AP_CLOUD_CONN      8   // cloud connect and ap start
#define STAT_REG_FAIL           9   // register fail
#define STAT_OFFLINE            10   // offline
#define STAT_MQTT_ONLINE        11
#define STAT_MQTT_OFFLINE       12
#define STAT_UNPROVISION_AP_STA_UNCFG		13 //smart-cfg and ap-cfg concurrent config status

typedef BYTE_T NW_CFG_ERR_CODE_E;
/*初始状态*/
#define NW_CFG_INIT  				0
/*激活失败*/
#define NW_CFG_ACTIVE_FAILED 		1
/*ap找不到*/
#define NW_CFG_AP_NOT_FOUND 		2
/*密码错误*/
#define NW_CFG_ERR_PASSWD 			3
/*ap连接不上*/
#define NW_CFG_CANT_CONN_AP 		4
/*dhcp错误*/
#define NW_CFG_DHCP_FAILED 			5
/*路由器连接成功*/
#define NW_CFG_SUCC  				100

/* tuya sdk definition of wifi-reset type */
typedef BYTE_T WF_RESET_TP_T;
#define WRT_SMT_CFG             0
#define WRT_AP                  1
#define WRT_AUTO                2
#define WRT_SMT_AP_CFG			3

/* tuya-sdk product info (wifi version) */
typedef struct {
    CHAR_T *uuid;       // strlen(uuid) <= 16,must not be null
    CHAR_T *auth_key;   // strlen(auth_key) <= 32,must not be null
    CHAR_T *ap_ssid;    // strlen(ap_ssid) <= 16,if ap_ssid is null ,then the default ssid is Smartlife_xxxx
    CHAR_T *ap_passwd;  // strlen(ap_passwd) <= 16,default null
}WF_GW_PROD_INFO_S;

typedef struct {
    BOOL_T has_auth; 	// authFlag
    CHAR_T *ap_ssid; 	// strlen(ap_ssid) <= 16,if ap_ssid is null ,then the default ssid is Smartlife_xxxx
    CHAR_T *ap_passwd; 	// strlen(ap_passwd) <= 16,default null
}DEBUG_GW_PROD_INFO_S;

/***********************************************************
*  callback function: GET_WF_NW_STAT_CB
*  Desc:    tuya-sdk network check callback (wifi version)
*  Input:   stat: curr network status
***********************************************************/
typedef VOID (*GET_WF_NW_STAT_CB)(IN CONST GW_WIFI_NW_STAT_E stat);

/***********************************************************
*  callback function: WF_NW_CFG_ERR_CODE_CB
*  Desc:	tuya-sdk network config error code callback (wifi version)
*  Input:	stat: curr network error code
***********************************************************/
typedef VOID (*WF_NW_CFG_ERR_CODE_CB)(IN CONST NW_CFG_ERR_CODE_E err_code);

#ifdef __cplusplus
}
#endif

#endif // TUYA_CLOUD_WIFI_DEFS_H
