/*******************************************************************
*  File: tuya_OS_ADAPTER_error_code.h
*  Author: auto generate by tuya code gen system
*  Date: 2019-08-14
*  Description:this file defined the error code of tuya IOT 
*  Device OS module OS_ADAPTER, you can change it manully
*  if needed
*  Copyright(C),2018-2020, tuya inc, www.tuya.comm
*******************************************************************/

#ifndef TUYA_OS_ADAPTER_ERROR_CODE_H
#define TUYA_OS_ADAPTER_ERROR_CODE_H


#ifdef __cplusplus
extern "C" {
#endif

#ifndef IN
#define IN
#endif

#ifndef OUT
#define OUT
#endif

#ifndef INOUT
#define INOUT
#endif

//#define OPRT_OK                             (0)
//#define OPRT_COM_ERROR                      (-1)


/* tuya sdk definition of socket errno */
typedef int UNW_ERRNO_T;
#define UNW_SUCCESS       0
#define UNW_FAIL          -1
#define UNW_EINTR         -2
#define UNW_EBADF         -3
#define UNW_EAGAIN        -4
#define UNW_EFAULT        -5
#define UNW_EBUSY         -6
#define UNW_EINVAL        -7
#define UNW_ENFILE        -8
#define UNW_EMFILE        -9
#define UNW_ENOSPC        -10
#define UNW_EPIPE         -11
#define UNW_EWOULDBLOCK   -12
#define UNW_ENOTSOCK      -13
#define UNW_ENOPROTOOPT   -14
#define UNW_EADDRINUSE    -15
#define UNW_EADDRNOTAVAIL -16
#define UNW_ENETDOWN      -17
#define UNW_ENETUNREACH   -18
#define UNW_ENETRESET     -19
#define UNW_ECONNRESET    -20
#define UNW_ENOBUFS       -21
#define UNW_EISCONN       -22
#define UNW_ENOTCONN      -23
#define UNW_ETIMEDOUT     -24
#define UNW_ECONNREFUSED  -25
#define UNW_EHOSTDOWN     -26
#define UNW_EHOSTUNREACH  -27
#define UNW_ENOMEM        -28
#define UNW_EMSGSIZE      -29

#define OPRT_OS_INTF_INVALID   -200  //组件接口服务无效

/****************************************************************************
            the error code marco define for module OS_ADAPTER 
****************************************************************************/
//common reason
#define OPRT_OS_ADAPTER_OK                      0
#define OPRT_OS_ADAPTER_COM_ERROR               -1
#define OPRT_OS_ADAPTER_INVALID_PARM            -2
#define OPRT_OS_ADAPTER_MALLOC_FAILED           -3
#define OPRT_OS_ADAPTER_NOT_SUPPORTED           -4
#define OPRT_OS_ADAPTER_NETWORK_ERROR           -5


//mutex
#define OPRT_OS_ADAPTER_ERRCODE_MUTEX           10100
#define OPRT_OS_ADAPTER_MUTEX_CREAT_FAILED      -(OPRT_OS_ADAPTER_ERRCODE_MUTEX + 1)
#define OPRT_OS_ADAPTER_MUTEX_LOCK_FAILED       -(OPRT_OS_ADAPTER_ERRCODE_MUTEX + 2)
#define OPRT_OS_ADAPTER_MUTEX_UNLOCK_FAILED     -(OPRT_OS_ADAPTER_ERRCODE_MUTEX + 3)
#define OPRT_OS_ADAPTER_MUTEX_RELEASE_FAILED    -(OPRT_OS_ADAPTER_ERRCODE_MUTEX + 4)


//semaphore
#define OPRT_OS_ADAPTER_ERRCODE_SEM             10110
#define OPRT_OS_ADAPTER_SEM_CREAT_FAILED        -(OPRT_OS_ADAPTER_ERRCODE_SEM + 1)
#define OPRT_OS_ADAPTER_SEM_WAIT_FAILED         -(OPRT_OS_ADAPTER_ERRCODE_SEM + 2)
#define OPRT_OS_ADAPTER_SEM_POST_FAILED         -(OPRT_OS_ADAPTER_ERRCODE_SEM + 3)
#define OPRT_OS_ADAPTER_SEM_RELEASE_FAILED      -(OPRT_OS_ADAPTER_ERRCODE_SEM + 4)


//queue
#define OPRT_OS_ADAPTER_ERRCODE_QUEUE           10120
#define OPRT_OS_ADAPTER_QUEUE_CREAT_FAILED      -(OPRT_OS_ADAPTER_ERRCODE_QUEUE + 1)
#define OPRT_OS_ADAPTER_QUEUE_SEND_FAIL         -(OPRT_OS_ADAPTER_ERRCODE_QUEUE + 2)
#define OPRT_OS_ADAPTER_QUEUE_RECV_FAIL         -(OPRT_OS_ADAPTER_ERRCODE_QUEUE + 3)


//thread
#define OPRT_OS_ADAPTER_ERRCODE_THRD            10130
#define OPRT_OS_ADAPTER_THRD_CREAT_FAILED       -(OPRT_OS_ADAPTER_ERRCODE_THRD + 1)
#define OPRT_OS_ADAPTER_THRD_RELEASE_FAILED     -(OPRT_OS_ADAPTER_ERRCODE_THRD + 2)
#define OPRT_OS_ADAPTER_THRD_JUDGE_SELF_FAILED  -(OPRT_OS_ADAPTER_ERRCODE_THRD + 3)


//system
#define OPRT_OS_ADAPTER_ERRCODE_SYSTEM          10140
#define OPRT_OS_ADAPTER_CPU_LPMODE_SET_FAILED   -(OPRT_OS_ADAPTER_ERRCODE_SYSTEM + 1)


//output
#define OPRT_OS_ADAPTER_ERRCODE_LOG             10150
#define OPRT_OS_ADAPTER_LOG_CLOSE_FAILED        -(OPRT_OS_ADAPTER_ERRCODE_LOG + 1)
#define OPRT_OS_ADAPTER_LOG_OPEN_FAILED         -(OPRT_OS_ADAPTER_ERRCODE_LOG + 2)


//wifi
#define OPRT_OS_ADAPTER_ERRCODE_WIFI            10160
#define OPRT_OS_ADAPTER_AP_NOT_FOUND            -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 1)
#define OPRT_OS_ADAPTER_AP_SCAN_FAILED          -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 2)
#define OPRT_OS_ADAPTER_AP_RELEASE_FAILED       -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 3)
#define OPRT_OS_ADAPTER_CHAN_SET_FAILED         -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 4)
#define OPRT_OS_ADAPTER_CHAN_GET_FAILED         -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 5)
#define OPRT_OS_ADAPTER_IP_GET_FAILED           -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 6)
#define OPRT_OS_ADAPTER_MAC_SET_FAILED          -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 7)
#define OPRT_OS_ADAPTER_MAC_GET_FAILED          -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 8)
#define OPRT_OS_ADAPTER_WORKMODE_SET_FAILED     -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 9)
#define OPRT_OS_ADAPTER_WORKMODE_GET_FAILED     -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 10)
#define OPRT_OS_ADAPTER_SNIFFER_SET_FAILED      -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 11)
#define OPRT_OS_ADAPTER_AP_START_FAILED         -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 12)
#define OPRT_OS_ADAPTER_AP_STOP_FAILED          -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 13)
#define OPRT_OS_ADAPTER_APINFO_GET_FAILED       -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 14)
#define OPRT_OS_ADAPTER_FAST_CONN_FAILED        -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 15)
#define OPRT_OS_ADAPTER_CONN_FAILED             -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 16)
#define OPRT_OS_ADAPTER_DISCONN_FAILED          -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 17)
#define OPRT_OS_ADAPTER_RSSI_GET_FAILED         -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 18)
#define OPRT_OS_ADAPTER_BSSID_GET_FAILED        -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 19)
#define OPRT_OS_ADAPTER_STAT_GET_FAILED         -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 20)
#define OPRT_OS_ADAPTER_CCODE_SET_FAILED        -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 21)
#define OPRT_OS_ADAPTER_MGNT_SEND_FAILED        -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 22)
#define OPRT_OS_ADAPTER_MGNT_REG_FAILED         -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 23)
#define OPRT_OS_ADAPTER_WF_LPMODE_SET_FAILED    -(OPRT_OS_ADAPTER_ERRCODE_WIFI + 24)


//flash
#define OPRT_OS_ADAPTER_ERRCODE_FLASH           10210
#define OPRT_OS_ADAPTER_FLASH_READ_FAILED       -(OPRT_OS_ADAPTER_ERRCODE_FLASH + 1)
#define OPRT_OS_ADAPTER_FLASH_WRITE_FAILED      -(OPRT_OS_ADAPTER_ERRCODE_FLASH + 2)
#define OPRT_OS_ADAPTER_FLASH_ERASE_FAILED      -(OPRT_OS_ADAPTER_ERRCODE_FLASH + 3)


//ota
#define OPRT_OS_ADAPTER_ERRCODE_OTA             10220
#define OPRT_OS_ADAPTER_OTA_START_INFORM_FAILED -(OPRT_OS_ADAPTER_ERRCODE_OTA + 1)
#define OPRT_OS_ADAPTER_OTA_PKT_SIZE_FAILED     -(OPRT_OS_ADAPTER_ERRCODE_OTA + 2)
#define OPRT_OS_ADAPTER_OTA_PROCESS_FAILED      -(OPRT_OS_ADAPTER_ERRCODE_OTA + 3)
#define OPRT_OS_ADAPTER_OTA_VERIFY_FAILED       -(OPRT_OS_ADAPTER_ERRCODE_OTA + 4)
#define OPRT_OS_ADAPTER_OTA_END_INFORM_FAILED   -(OPRT_OS_ADAPTER_ERRCODE_OTA + 5)


//watchdog
#define OPRT_OS_ADAPTER_ERRCODE_WD              10230
#define OPRT_OS_ADAPTER_WD_INIT_FAILED          -(OPRT_OS_ADAPTER_ERRCODE_WD + 1)


//gpio
#define OPRT_OS_ADAPTER_ERRCODE_GPIO            10240
#define OPRT_OS_ADAPTER_GPIO_INOUT_SET_FAILED   -(OPRT_OS_ADAPTER_ERRCODE_GPIO + 1)
#define OPRT_OS_ADAPTER_GPIO_MODE_SET_FAILED    -(OPRT_OS_ADAPTER_ERRCODE_GPIO + 2)
#define OPRT_OS_ADAPTER_GPIO_WRITE_FAILED       -(OPRT_OS_ADAPTER_ERRCODE_GPIO + 3)
#define OPRT_OS_ADAPTER_GPIO_IRQ_INIT_FAILED    -(OPRT_OS_ADAPTER_ERRCODE_GPIO + 4)


//uart
#define OPRT_OS_ADAPTER_ERRCODE_UART            10250
#define OPRT_OS_ADAPTER_UART_INIT_FAILED        -(OPRT_OS_ADAPTER_ERRCODE_UART + 1)
#define OPRT_OS_ADAPTER_UART_DEINIT_FAILED      -(OPRT_OS_ADAPTER_ERRCODE_UART + 2)
#define OPRT_OS_ADAPTER_UART_SEND_FAILED        -(OPRT_OS_ADAPTER_ERRCODE_UART + 3)
#define OPRT_OS_ADAPTER_UART_READ_FAILED        -(OPRT_OS_ADAPTER_ERRCODE_UART + 4)


//i2c
#define OPRT_OS_ADAPTER_ERRCODE_I2C             10260
#define OPRT_OS_ADAPTER_I2C_OPEN_FAILED         -(OPRT_OS_ADAPTER_ERRCODE_I2C + 1)
#define OPRT_OS_ADAPTER_I2C_CLOSE_FAILED        -(OPRT_OS_ADAPTER_ERRCODE_I2C + 2)
#define OPRT_OS_ADAPTER_I2C_READ_FAILED         -(OPRT_OS_ADAPTER_ERRCODE_I2C + 3)
#define OPRT_OS_ADAPTER_I2C_WRITE_FAILED        -(OPRT_OS_ADAPTER_ERRCODE_I2C + 4)


//bt
#define OPRT_OS_ADAPTER_ERRCODE_BT              10270
#define OPRT_OS_ADAPTER_BT_INIT_FAILED          -(OPRT_OS_ADAPTER_ERRCODE_BT + 1)
#define OPRT_OS_ADAPTER_BT_DEINIT_FAILED        -(OPRT_OS_ADAPTER_ERRCODE_BT + 2)
#define OPRT_OS_ADAPTER_BT_DISCONN_FAILED       -(OPRT_OS_ADAPTER_ERRCODE_BT + 3)
#define OPRT_OS_ADAPTER_BT_SEND_FAILED          -(OPRT_OS_ADAPTER_ERRCODE_BT + 4)
#define OPRT_OS_ADAPTER_BT_ADV_RESET_FAILED     -(OPRT_OS_ADAPTER_ERRCODE_BT + 5)
#define OPRT_OS_ADAPTER_BT_RSSI_GET_FAILED      -(OPRT_OS_ADAPTER_ERRCODE_BT + 6)
#define OPRT_OS_ADAPTER_BT_ADV_START_FAILED     -(OPRT_OS_ADAPTER_ERRCODE_BT + 7)
#define OPRT_OS_ADAPTER_BT_ADV_STOP_FAILED      -(OPRT_OS_ADAPTER_ERRCODE_BT + 8)
#define OPRT_OS_ADAPTER_BT_SCAN_FAILED          -(OPRT_OS_ADAPTER_ERRCODE_BT + 9)

//#define OPRT_OS_ADAPTER_ERRCODE_MAX_CNT 26
#ifdef __cplusplus
}
#endif
#endif
