Last Updated on : 2024-11-20 08:51:44download
Tuya IPC SDK provides embedded software development and mobile application interaction capabilities for IP cameras (IPCs). After the IPC SDK is integrated into the IPCs, these devices can be networked with a few simple steps and support multiple functions. For example, these functions can be implemented: real-time end-to-end streaming media transmission, local storage and playback of video, cloud storage, Amazon Echo Show streaming, Google Chromecast streaming, and cloud AI.
For more information about the IPC SDK in GitHub, see IPC SDK.
After you get and extract the IPC SDK, you can see the following directory structure.
|- tuya_ipc_sdk
|- build_app.sh
|- demo_tuya_ipc
| |- include
| |- resource
| |- user
| |- zlib
|- docs
| |- cn
| |- en
|- include
|- libs
| |- libmbedtls.a
| |- libtuya_ipc.a
|- Makefile
|- output
|- readme.txt
// Video bitrate enumeration values supported by the device
typedef enum
{
TUYA_VIDEO_BITRATE_64K = 64,
TUYA_VIDEO_BITRATE_128K = 128,
TUYA_VIDEO_BITRATE_256K = 256,
TUYA_VIDEO_BITRATE_512K = 512,
TUYA_VIDEO_BITRATE_768K = 768,
TUYA_VIDEO_BITRATE_1M = 1024,
TUYA_VIDEO_BITRATE_1_5M = 1536,
TUYA_VIDEO_BITRATE_2M = 2048 // Maximum 2 Mbit/s stream is supported, as consideration of cloud storage order price
}TUYA_VIDEO_BITRATE_E; // Kbit/s
// Enumeration for the codec, sync with Tuya Cloud and app. It should NOT be changed.
typedef enum
{
TUYA_CODEC_VIDEO_MPEG4 = 0,
TUYA_CODEC_VIDEO_H263,
TUYA_CODEC_VIDEO_H264,
TUYA_CODEC_VIDEO_MJPEG,
TUYA_CODEC_VIDEO_H265,
TUYA_CODEC_VIDEO_MAX = 99,
TUYA_CODEC_AUDIO_ADPCM,
TUYA_CODEC_AUDIO_PCM,
TUYA_CODEC_AUDIO_AAC_RAW,
TUYA_CODEC_AUDIO_AAC_ADTS,
TUYA_CODEC_AUDIO_AAC_LATM,
TUYA_CODEC_AUDIO_G711U,
TUYA_CODEC_AUDIO_G711A,
TUYA_CODEC_AUDIO_G726,
TUYA_CODEC_AUDIO_SPEEX,
TUYA_CODEC_AUDIO_MP3,
TUYA_CODEC_AUDIO_MAX = 199,
TUYA_CODEC_INVALID
}TUYA_CODEC_ID;
typedef enum
{
TUYA_AUDIO_SAMPLE_8K = 8000,
TUYA_AUDIO_SAMPLE_11K = 11000,
TUYA_AUDIO_SAMPLE_12K = 12000,
TUYA_AUDIO_SAMPLE_16K = 16000,
TUYA_AUDIO_SAMPLE_22K = 22000,
TUYA_AUDIO_SAMPLE_24K = 24000,
TUYA_AUDIO_SAMPLE_32K = 32000,
TUYA_AUDIO_SAMPLE_44K = 44000,
TUYA_AUDIO_SAMPLE_48K = 48000,
TUYA_AUDIO_SAMPLE_MAX = 0xFFFFFFFF
}TUYA_AUDIO_SAMPLE_E;
typedef enum
{
TUYA_AUDIO_DATABITS_8 = 8,
TUYA_AUDIO_DATABITS_16 = 16,
TUYA_AUDIO_DATABITS_MAX = 0xFF
}TUYA_AUDIO_DATABITS_E;
typedef enum
{
TUYA_AUDIO_CHANNEL_MONO,
TUYA_AUDIO_CHANNEL_STERO,
}TUYA_AUDIO_CHANNEL_E;
// Audio and video struct. The struct name indicates the definition of the struct.
typedef struct
{
BOOL_T channel_enable[E_CHANNEL_MAX]; // Enable the channel
UINT_T video_fps[E_CHANNEL_VIDEO_MAX]; // Video FPS
UINT_T video_gop[E_CHANNEL_VIDEO_MAX]; // Video GoP
TUYA_VIDEO_BITRATE_E video_bitrate[E_CHANNEL_VIDEO_MAX]; // Video bitrate
UINT_T video_width[E_CHANNEL_VIDEO_MAX];
UINT_T video_height[E_CHANNEL_VIDEO_MAX];
UINT_T video_freq[E_CHANNEL_VIDEO_MAX];
TUYA_CODEC_ID video_codec[E_CHANNEL_VIDEO_MAX];
TUYA_CODEC_ID audio_codec[E_CHANNEL_MAX];
UINT_T audio_fps[E_CHANNEL_MAX];
TUYA_AUDIO_SAMPLE_E audio_sample[E_CHANNEL_MAX];
TUYA_AUDIO_DATABITS_E audio_databits[E_CHANNEL_MAX];
TUYA_AUDIO_CHANNEL_E audio_channel[E_CHANNEL_MAX];
}IPC_MEDIA_INFO_S;
typedef enum {
WIFI_INIT_AUTO,
WIFI_INIT_AP,
WIFI_INIT_DEBUG,
WIFI_INIT_NULL
}WIFI_INIT_MODE_E;
typedef VOID (*TUYA_CMD_DISPATCH)(IN INT_T cmd,IN VOID *param);
typedef VOID (*TUYA_QUERY_DISPATCH)(IN INT_T cmd,IN VOID *param);
typedef VOID (*TUYA_RST_INFORM_CB)(GW_RESET_TYPE_E from);
typedef VOID (*TUYA_RESTART_INFORM_CB)(VOID);
#define IPC_STORAGE_PATH_LEN 64
#define IPC_PRODUCT_KEY_LEN 16
#define IPC_UUID_LEN 25
#define IPC_AUTH_KEY_LEN 32
#define IPC_SW_VER_LEN 20
#define IPC_SERIAL_NUM_LEN 32
#define IPC_FACTORY_ID_LEN 4
#define IPC_P2P_ID_LEN 25
#define IPC_AES_ENCRYPT_KEY_LEN 16
#define IPC_NOTIFY_INFO_LEN 16
#define NOTIFICATION_MOTION_DETECTION 115
#define NOTIFICATION_CONTENT_SIZE_MAX (150*1024)
/**
* \brief notification type of the event, currently only JPEG and PNG are supported
* \enum NOTIFICATION_CONTENT_TYPE_E
*/
typedef enum{
NOTIFICATION_CONTENT_MP4 = 0, /* mp4 for video, NOT supported now */
NOTIFICATION_CONTENT_JPEG, /* jpeg for snapshot */
NOTIFICATION_CONTENT_PNG, /* png for snapshot */
NOTIFICATION_CONTENT_MAX,
} NOTIFICATION_CONTENT_TYPE_E;
typedef struct
{
CHAR_T *data;
INT_T len;
CHAR_T secret_key[IPC_AES_ENCRYPT_KEY_LEN + 1];
NOTIFICATION_CONTENT_TYPE_E type;
}NOTIFICATION_UNIT_T;
typedef enum
{
NOTIFICATION_NAME_MOTION, /* Motion detection */
NOTIFICATION_NAME_DOORBELL, /* Press the doorbell */
NOTIFICATION_NAME_DEV_LINK, /* Trigger linkage to smart devices */
NOTIFICATION_NAME_PASSBY, /* Normal passing-by events */
NOTIFICATION_NAME_LINGER, /* Suspicious lingering */
NOTIFICATION_NAME_MESSAGE, /* Message */
NOTIFICATION_NAME_CALL_ACCEPT, /* The doorbell is answered */
NOTIFICATION_NAME_CALL_NOT_ACCEPT, /* The doorbell is not answered */
NOTIFICATION_NAME_HUMAN, /* Human shape detection */
NOTIFICATION_NAME_FACE, /* Detection */
NOTIFICATION_NAME_PCD, /* Pet detection */
NOTIFICATION_NAME_BABY_CRY, /* Baby cry */
NOTIFICATION_NAME_ABNORMAL_SOUND, /* Exceptional sound */
NOTIFICATION_NAME_IO_ALARM, /* Alert from an external I/O device */
NOTIFY_TYPE_MAX
}NOTIFICATION_NAME_E;
typedef enum
{
DOORBELL_NORMAL, /* Normal doorbell that pushes pictures */
DOORBELL_AC, /* AC doorbell that pushes P2P streams */
DOORBELL_TYPE_MAX,
}DOORBELL_TYPE_E;
typedef struct
{
INT_T unit_count;
NOTIFICATION_NAME_E name;
CHAR_T *extra_data; // default: NULL
CHAR_T type[IPC_NOTIFY_INFO_LEN]; // jpg:"image",video:""
CHAR_T with[IPC_NOTIFY_INFO_LEN]; // default "resources"
NOTIFICATION_UNIT_T unit[0];
}NOTIFICATION_DATA_GENERIC_T;
typedef enum
{
E_IPC_UNREGISTERED = 0,
E_IPC_REGISTERED = 1,
E_IPC_ACTIVEATED = 2 // After successful register and activation process, the device is in this status
}IPC_REGISTER_STATUS;
/**
* \brief Status for IPC
* \enum IPC_GW_STATUS_E
*/
typedef enum
{
IPC_GW_UNREGISTERED = 0,
IPC_GW_REGISTERED,
IPC_GW_ACTIVED,
IPC_GW_MQTT_ONLINE,
IPC_GW_MQTT_OFFLINE,
}IPC_GW_STATUS_E;
/**
* \brief IPC environment variable struct
* \struct TUYA_IPC_ENV_VAR_S
*/
typedef struct
{
CHAR_T storage_path[IPC_STORAGE_PATH_LEN + 1];/* Path to store Tuya database files, readable and writable */
CHAR_T product_key[IPC_PRODUCT_KEY_LEN + 1]; /* One product ID (PID) for one product */
CHAR_T uuid[IPC_UUID_LEN + 1]; /* One UUID-Authkey pair for one device, to register on Tuya Cloud */
CHAR_T auth_key[IPC_AUTH_KEY_LEN + 1];
CHAR_T p2p_id[IPC_P2P_ID_LEN + 1]; /* This param is not in use now */
CHAR_T dev_sw_version[IPC_SW_VER_LEN + 1]; /* Software version in the format of x1.x2.x3.x4.x5.x6, with zero to five dots */
CHAR_T dev_serial_num[IPC_SERIAL_NUM_LEN + 1]; /* This param is not used in IPCs */
DEV_OBJ_DP_CMD_CB dev_obj_dp_cb;/* DP cmd callback function, which handles cmd from Tuya Cloud and app */
DEV_DP_QUERY_CB dev_dp_query_cb;/* DP query callback function */
GW_STATUS_CHANGED_CB status_changed_cb; /* Status change callback function for developer, which can be NULL if not required */
GW_UG_INFORM_CB gw_ug_cb; /* OTA callback function, triggered by updates from app and Tuya Cloud */
TUYA_RST_INFORM_CB gw_rst_cb;/* Reset callback fucntion, triggered when the user unbinds a device from an account */
TUYA_RESTART_INFORM_CB gw_restart_cb;/* Restart callback function */
BOOL_T mem_save_mode;/* Woking in low memory mode */
VOID *p_reserved;
}TUYA_IPC_ENV_VAR_S;
#define NOTIFICATION_MOTION_DETECTION 115
/**
* \brief Direct connect mode, compared to Wi-Fi EZ mode, get SSID/password via QR code.
* \enum TUYA_IPC_DIRECT_CONNECT_TYPE_E
*/
typedef enum{
TUYA_IPC_DIRECT_CONNECT_QRCODE = 0,
TUYA_IPC_DIRECT_CONNECT_MAX,
} TUYA_IPC_DIRECT_CONNECT_TYPE_E;
typedef enum TUYA_STREAM_TYPE_ {
TUYA_STREAM_TYPE_AUDIO,
TUYA_STREAM_TYPE_VIDEO,
} TUYA_STREAM_TYPE_E;
typedef struct TUYA_STREAM_FRAME_ {
uint64_t utcms; ///< UTC time is in ms
uint64_t pts; ///< PTS time
uint32_t seq; ///< Sequence number of the frame
TUYA_STREAM_TYPE_E type; ///< Frame type
TUYA_CODEC_ID codec;
int32_t length; ///< Frame length
void* pbuff; ///< Frame data buffer
} TUYA_STREAM_FRAME_S;
typedef INT_T (*TUYA_CHROMECAST_START)(PVOID_T context, PVOID_T priv_data);
typedef INT_T (*TUYA_CHROMECAST_STOP)(PVOID_T context, PVOID_T priv_data);
typedef INT_T (*TUYA_CHROMECAST_GET_FRAME)(PVOID_T context, TUYA_STREAM_TYPE_E type, TUYA_STREAM_FRAME_S* pframe);
typedef INT_T (*TUYA_CHROMECAST_GET_FRAME_RELEASE)(PVOID_T context, TUYA_STREAM_TYPE_E type, TUYA_STREAM_FRAME_S* pframe);
typedef struct {
PVOID_T pcontext;
TUYA_CHROMECAST_START start;
TUYA_CHROMECAST_STOP stop;
TUYA_CHROMECAST_GET_FRAME get_frame;
TUYA_CHROMECAST_GET_FRAME_RELEASE get_frame_release;
} TUYA_CHROMECAST_CALLBACK;
typedef enum TUYA_STREAM_SOURCE_ {
TUYA_STREAM_SOURCE_RINGBUFFER,
TUYA_STREAM_SOURCE_CUSTOMER,
} TUYA_STREAM_SOURCE_E;
typedef enum TUYA_STREAM_TRANSMIT_MODE_ {
TUYA_STREAM_TRANSMIT_MODE_ASYNC,
TUYA_STREAM_TRANSMIT_MODE_SYNC,
} TUYA_STREAM_TRANSMIT_MODE_E;
typedef struct {
CHANNEL_E audio_channel;
CHANNEL_E video_channel;
TUYA_STREAM_SOURCE_E src;
TUYA_STREAM_TRANSMIT_MODE_E mode;
IPC_MEDIA_INFO_S* pminfo;
TUYA_CHROMECAST_CALLBACK cbk;
} TUYA_CHROMECAST_PARAM_S;
#define MAX_SNAPSHOT_BUFFER_SIZE (100*1024) // In bytes
#define INVALID_EVENT_ID 0xFFFFFFFF
#define MAX_CLOUD_EVENT_DURATION 300 // In seconds
typedef UINT_T EVENT_ID;
typedef enum
{
EVENT_NONE,
EVENT_ONGOING,
EVENT_READY,
EVENT_INVALID
}EVENT_STATUS_E;
typedef enum
{
EVENT_TYPE_MOTION_DETECT = 0, /* ipc_event_motion,"ipc_motion"*/
EVENT_TYPE_DOOR_BELL = 1, /* ipc_event_doorbell,"ipc_doorbell"*/
EVENT_TYPE_DEV_LINK = 2, /* Event triggered by other Tuya Cloud devices */
EVENT_TYPE_PASSBY = 3, /* For a doorbell, detect passers-by */
EVENT_TYPE_LINGER = 4, /* For a doorbell, detect someone who lingers */
EVENT_TYPE_LEAVE_MESSAGE = 5, /* For a doorbell, a video message is left */
EVENT_TYPE_CALL_ACCEPT = 6, /* For a doorbell, a call is accepted */
EVENT_TYPE_CALL_NOT_ACCEPT = 7, /* For a doorbell, a call is not accepted */
EVENT_TYPE_CALL_REFUSE = 8, /* ipc_event_call_refuse*/
EVENT_TYPE_HUMAN_DETECT = 9, /* ipc_event_human,"ipc_human"*/
EVENT_TYPE_CAT_DETECT = 10, /* ipc_event_cat,"ipc_cat"*/
EVENT_TYPE_CAR_DETECT = 11, /* ipc_event_car,"ipc_car"*/
EVENT_TYPE_BABY_CRY = 12, /* ipc_event_baby_cry,"ipc_baby_cry"*/
EVENT_TYPE_BANG = 13, /* ipc_event_bang,"ipc_bang"*/
EVENT_TYPE_FACE = 14, /* ipc_event_face,"ipc_face"*/
EVENT_TYPE_ANTIBREAK = 15, /* ipc_event_antibreak,"ipc_antibreak"*/
EVENT_TYPE_RECORD_ONLY = 16, /* Only start event record, and no event is reported or will be reported later */
EVENT_TYPE_IO_ALARM = 17, /* Event triggered by local I/O devices */
EVENT_TYPE_INVALID
}ClOUD_STORAGE_EVENT_TYPE_E;
/* Cloud storage order type */
typedef enum
{
ClOUD_STORAGE_TYPE_CONTINUE, /* Continous record type */
ClOUD_STORAGE_TYPE_EVENT, /* Event-based type. Only record and store audio/video when an event happens */
ClOUD_STORAGE_TYPE_INVALID /* No cloud storage order */
}ClOUD_STORAGE_TYPE_E;
typedef INT_T (*TUYA_ECHOSHOW_START)(PVOID_T context, PVOID_T priv_data);
typedef INT_T (*TUYA_ECHOSHOW_STOP)(PVOID_T context, PVOID_T priv_data);
typedef struct {
PVOID_T pcontext;
TUYA_ECHOSHOW_START start;
TUYA_ECHOSHOW_STOP stop;
} TUYA_ECHOSHOW_CALLBACK;
typedef enum TUYA_ECHOSHOW_MODE_ {
TUYA_ECHOSHOW_MODE_ECHOSHOW,
TUYA_ECHOSHOW_MODE_RTSP,
} TUYA_ECHOSHOW_MODE_E;
typedef struct {
int vchannel;
TUYA_ECHOSHOW_MODE_E mode;
IPC_MEDIA_INFO_S* pminfo;
TUYA_ECHOSHOW_CALLBACK cbk;
} TUYA_ECHOSHOW_PARAM_S;
/*********************************************************************************
* Image type
* Y
* YUV
* BGR
**********************************************************************************/
typedef enum
{
Y,
YUV,
}IMG_TYPE;
/*********************************************************************************
* Coordinate of pixels
**********************************************************************************/
typedef struct _TUYA_POINT
{
INT_T x;
INT_T y;
}TUYA_POINT;
/*********************************************************************************
* ROI of Motion Detect
* x y Percent of pixels' coordinate
* width Percent of width
* height Percent of height
**********************************************************************************/
typedef struct _TUYA_RPERCENT_ECT
{
INT_T x_percent;
INT_T y_percent;
INT_T width_percent;
INT_T height_percent;
}TUYA_RPERCENT_ECT;
/*********************************************************************************
* rect of TUYA AI
**********************************************************************************/
typedef struct _TUYA_RECT
{
INT_T left;
INT_T top;
INT_T right;
INT_T bottom;
}TUYA_AI_RECT;
/*********************************************************************************
* Image resize enum
* lINEAR Faster but low quality
* CUBIC Slower but high quality
**********************************************************************************/
typedef enum
{
LINEAR,
CUBIC,
}IMG_RESIZE_TYPE;
/*********************************************************************************
* Image resize struct, please scale the width and height equally
* srcWidth Input width
* srcHeight Input height
* dstWidth Output width
* dstHeight Output height
* type Scale type
**********************************************************************************/
typedef struct _TUYA_IMG_RESIZE_PARA
{
INT_T srcWidth;
INT_T srcHeight;
INT_T dstWidth;
INT_T dstHeight;
IMG_TYPE img_type;
IMG_RESIZE_TYPE resize_type;
}TUYA_IMG_RESIZE_PARA;
#define MAX_MEDIA_FRAME_SIZE (300*1024)
#define AES_ENCRYPT_KEY_LEN 16
typedef enum
{
E_CHANNEL_VIDEO_MAIN = 0,
E_CHANNEL_VIDEO_SUB,
E_CHANNEL_VIDEO_3RD,
E_CHANNEL_VIDEO_4TH,
E_CHANNEL_VIDEO_MAX = 8, // Max video streams
E_CHANNEL_AUDIO,
E_CHANNEL_AUDIO_2RD,
E_CHANNEL_AUDIO_3RD,
E_CHANNEL_AUDIO_4TH,
E_CHANNEL_MAX = 16
}CHANNEL_E;
typedef enum
{
E_VIDEO_PB_FRAME = 0,
E_VIDEO_I_FRAME,
E_VIDEO_TS_FRAME,
E_AUDIO_FRAME,
E_CMD_FRAME,
E_MEDIA_FRAME_TYPE_MAX
}MEDIA_FRAME_TYPE_E;
// Enumeration for the codec, sync with Tuya Cloud and app. It should NOT be changed.
typedef enum
{
TUYA_CODEC_VIDEO_MPEG4 = 0,
TUYA_CODEC_VIDEO_H263,
TUYA_CODEC_VIDEO_H264,
TUYA_CODEC_VIDEO_MJPEG,
TUYA_CODEC_VIDEO_H265,
TUYA_CODEC_VIDEO_MAX = 99,
TUYA_CODEC_AUDIO_ADPCM,
TUYA_CODEC_AUDIO_PCM,
TUYA_CODEC_AUDIO_AAC_RAW,
TUYA_CODEC_AUDIO_AAC_ADTS,
TUYA_CODEC_AUDIO_AAC_LATM,
TUYA_CODEC_AUDIO_G711U,
TUYA_CODEC_AUDIO_G711A,
TUYA_CODEC_AUDIO_G726,
TUYA_CODEC_AUDIO_SPEEX,
TUYA_CODEC_AUDIO_MP3,
TUYA_CODEC_AUDIO_MAX = 199,
TUYA_CODEC_INVALID
}TUYA_CODEC_ID;
typedef enum
{
TUYA_AUDIO_SAMPLE_8K = 8000,
TUYA_AUDIO_SAMPLE_11K = 11000,
TUYA_AUDIO_SAMPLE_12K = 12000,
TUYA_AUDIO_SAMPLE_16K = 16000,
TUYA_AUDIO_SAMPLE_22K = 22000,
TUYA_AUDIO_SAMPLE_24K = 24000,
TUYA_AUDIO_SAMPLE_32K = 32000,
TUYA_AUDIO_SAMPLE_44K = 44000,
TUYA_AUDIO_SAMPLE_48K = 48000,
TUYA_AUDIO_SAMPLE_MAX = 0xFFFFFFFF
}TUYA_AUDIO_SAMPLE_E;
typedef enum
{
TUYA_VIDEO_BITRATE_64K = 64,
TUYA_VIDEO_BITRATE_128K = 128,
TUYA_VIDEO_BITRATE_256K = 256,
TUYA_VIDEO_BITRATE_512K = 512,
TUYA_VIDEO_BITRATE_768K = 768,
TUYA_VIDEO_BITRATE_1M = 1024,
TUYA_VIDEO_BITRATE_1_5M = 1536,
TUYA_VIDEO_BITRATE_2M = 2048 // Maximum 2 Mbit/s stream is supported, as consideration of cloud storage order price
}TUYA_VIDEO_BITRATE_E; // Kbit/s
typedef enum
{
TUYA_AUDIO_DATABITS_8 = 8,
TUYA_AUDIO_DATABITS_16 = 16,
TUYA_AUDIO_DATABITS_MAX = 0xFF
}TUYA_AUDIO_DATABITS_E;
typedef enum
{
TUYA_AUDIO_CHANNEL_MONO,
TUYA_AUDIO_CHANNEL_STERO,
}TUYA_AUDIO_CHANNEL_E;
typedef struct
{
BOOL_T channel_enable[E_CHANNEL_MAX];
UINT_T video_fps[E_CHANNEL_VIDEO_MAX];
UINT_T video_gop[E_CHANNEL_VIDEO_MAX];
TUYA_VIDEO_BITRATE_E video_bitrate[E_CHANNEL_VIDEO_MAX];
UINT_T video_width[E_CHANNEL_VIDEO_MAX];
UINT_T video_height[E_CHANNEL_VIDEO_MAX];
UINT_T video_freq[E_CHANNEL_VIDEO_MAX];
TUYA_CODEC_ID video_codec[E_CHANNEL_VIDEO_MAX];
TUYA_CODEC_ID audio_codec[E_CHANNEL_MAX];
UINT_T audio_fps[E_CHANNEL_MAX];
TUYA_AUDIO_SAMPLE_E audio_sample[E_CHANNEL_MAX];
TUYA_AUDIO_DATABITS_E audio_databits[E_CHANNEL_MAX];
TUYA_AUDIO_CHANNEL_E audio_channel[E_CHANNEL_MAX];
}IPC_MEDIA_INFO_S;
typedef struct
{
UINT_T type;
UINT_T size;
UINT64_T timestamp;
UINT64_T pts;
}STORAGE_FRAME_HEAD_S;
typedef struct
{
MEDIA_FRAME_TYPE_E type;
BYTE_T *p_buf;
UINT_T size;
UINT64_T pts;
UINT64_T timestamp;
}MEDIA_FRAME_S;
typedef INT_T (*Tuya_CBC_AES128_Init)(VOID);
typedef INT_T (*Tuya_CBC_AES128_Encrypt)(IN BYTE_T *pdata_in, // Data to be encrypted. It should NOT be changed.
IN UINT_T data_len, // Data length to be encrypted
IN BYTE_T *pdata_out, // Data after encryption, memory is MALLOC inside tuya SDK already
OUT UINT_T *pdata_out_len, // Data length after encrytion
IN BYTE_T *pkey, // AES key
IN BYTE_T *piv); // AES IV for CBC mode
typedef INT_T (*Tuya_CBC_AES128_Decrypt)(IN BYTE_T *pdata_in, // Data to be decrypted. It should NOT be changed.
IN UINT_T data_len, // Data length after decryption
IN BYTE_T *pdata_out, // Data after decryption, memory is MALLOC inside tuya SDK already
OUT UINT_T *pdata_out_len, // Data length after decrytion
IN BYTE_T *pkey, // AES key
IN BYTE_T *piv); // AES IV for CBC mode
typedef INT_T (*Tuya_CBC_AES128_Destroy)(VOID);
typedef struct
{
Tuya_CBC_AES128_Init init;
Tuya_CBC_AES128_Encrypt encrypt;
Tuya_CBC_AES128_Decrypt decrypt;
Tuya_CBC_AES128_Destroy destory;
}AES_HW_CBC_FUNC;
/**
* \brief p2p callback message enums
* \struct TRANSFER_EVENT_E
*/
typedef enum
{
TRANS_LIVE_VIDEO_START,
TRANS_LIVE_VIDEO_STOP,
TRANS_LIVE_AUDIO_START,
TRANS_LIVE_AUDIO_STOP,
TRANS_LIVE_VIDEO_CLARITY_SET, /* Set clarity from the app */
TRANS_LIVE_VIDEO_CLARITY_QUERY, /* Query clarity information */
TRANS_LIVE_LOAD_ADJUST,
TRANS_PLAYBACK_LOAD_ADJUST,
TRANS_PLAYBACK_QUERY_MONTH_SIMPLIFY, /* Query storage info of the month */
TRANS_PLAYBACK_QUERY_DAY_TS, /* Query storage info of the day */
TRANS_PLAYBACK_START_TS, /* Start playback */
TRANS_PLAYBACK_PAUSE, /* Pause playback */
TRANS_PLAYBACK_RESUME, /* Resume playback */
TRANS_PLAYBACK_MUTE, /* Mute playback */
TRANS_PLAYBACK_UNMUTE, /* Unmute playback */
TRANS_PLAYBACK_STOP, /* Stop playback */
TRANS_SPEAKER_START, /* Start app-to-IPC speak */
TRANS_SPEAKER_STOP, /* Stop app-to-IPC speak */
TRANS_ABILITY_QUERY,/* Query the ability of audio and video streaming */
TRANS_DOWNLOAD_START, /* Start to download */
TRANS_DOWNLOAD_STOP,
TRANS_DOWNLOAD_PAUSE,
TRANS_DOWNLOAD_RESUME,
TRANS_DOWNLOAD_CANCLE,
}TRANSFER_EVENT_E;
typedef enum
{
TRANSFER_SOURCE_TYPE_P2P = 1,
TRANSFER_SOURCE_TYPE_WEBRTC = 2,
TRANSFER_SOURCE_TYPE_STREAMER = 3,
} TRANSFER_SOURCE_TYPE_E;
/**
* \brief P2P online status
* \enum TRANSFER_ONLINE_E
*/
typedef enum
{
TY_DEVICE_OFFLINE,
TY_DEVICE_ONLINE,
}TRANSFER_ONLINE_E;
typedef enum{
TY_CMD_QUERY_IPC_FIXED_ABILITY_TYPE_VIDEO = 0x1, // If video is supported
TY_CMD_QUERY_IPC_FIXED_ABILITY_TYPE_SPEAKER = 0x2, // If speaker is supported
TY_CMD_QUERY_IPC_FIXED_ABILITY_TYPE_MIC = 0x4, // If MIC is supported
}TY_CMD_QUERY_IPC_FIXED_ABILITY_TYPE;
// Request and response
typedef struct tagC2CCmdQueryFixedAbility{
unsigned int channel;
unsigned int ability_mask;// Ability is assigned by bit
}C2C_TRANS_QUERY_FIXED_ABI_REQ, C2C_TRANS_QUERY_FIXED_ABI_RESP;
typedef enum
{
TY_VIDEO_CLARITY_STANDARD = 0,
TY_VIDEO_CLARITY_HIGH,
}TRANSFER_VIDEO_CLARITY_TYPE_E;
typedef struct
{
TRANSFER_VIDEO_CLARITY_TYPE_E clarity;
VOID *pReserved;
}C2C_TRANS_LIVE_CLARITY_PARAM_S;
typedef struct tagC2C_TRANS_CTRL_LIVE_VIDEO{
unsigned int channel;
}C2C_TRANS_CTRL_VIDEO_START,C2C_TRANS_CTRL_VIDEO_STOP;
typedef struct tagC2C_TRANS_CTRL_LIVE_AUDIO{
unsigned int channel;
}C2C_TRANS_CTRL_AUDIO_START,C2C_TRANS_CTRL_AUDIO_STOP;
typedef struct
{
UINT_T start_timestamp; /* Start timestamp in second of playback */
UINT_T end_timestamp; /* End timestamp in second of playback */
} PLAYBACK_TIME_S;
typedef struct tagPLAY_BACK_ALARM_FRAGMENT{
unsigned int type;// Not used now
PLAYBACK_TIME_S time_sect;
}PLAY_BACK_ALARM_FRAGMENT;
typedef struct{
unsigned int file_count; // File count of the day
PLAY_BACK_ALARM_FRAGMENT file_arr[0]; // Playback file array
}PLAY_BACK_ALARM_INFO_ARR;
typedef struct{
unsigned int channel;
unsigned int year;
unsigned int month;
unsigned int day;
}C2C_TRANS_QUERY_PB_DAY_REQ;
typedef struct{
unsigned int channel;
unsigned int year;
unsigned int month;
unsigned int day;
PLAY_BACK_ALARM_INFO_ARR * alarm_arr;
}C2C_TRANS_QUERY_PB_DAY_RESP;
// query playback data by month
typedef struct tagC2CCmdQueryPlaybackInfoByMonth{
unsigned int channel;
unsigned int year;
unsigned int month;
unsigned int day; // List the days that have playback data. Use each bit for one day. For example, day=26496=0110 0111 1000 0000 means days 7/8/9/19/13/14 have playback data.
}C2C_TRANS_QUERY_PB_MONTH_REQ, C2C_TRANS_QUERY_PB_MONTH_RESP;
typedef struct tagC2C_TRANS_CTRL_PB_START{
unsigned int channel;
PLAYBACK_TIME_S time_sect;
UINT_T playTime; /* The actual playback time, in second */
}C2C_TRANS_CTRL_PB_START;
typedef struct tagC2C_TRANS_CTRL_PB_STOP{
unsigned int channel;
}C2C_TRANS_CTRL_PB_STOP;
typedef struct tagC2C_TRANS_CTRL_PB_PAUSE{
unsigned int channel;
}C2C_TRANS_CTRL_PB_PAUSE,C2C_TRANS_CTRL_PB_RESUME;
typedef struct tagC2C_TRANS_CTRL_PB_MUTE{
unsigned int channel;
}C2C_TRANS_CTRL_PB_MUTE,C2C_TRANS_CTRL_PB_UNMUTE;
/**
* \brief network load change callback struct
* \note NOT supported now
*/
typedef struct
{
INT_T client_index;
INT_T curr_load_level; /**< 0: best, 5: worst */
INT_T new_load_level; /**< 0: best, 5: worst */
VOID *pReserved;
}C2C_TRANS_PB_LOAD_PARAM_S;
typedef struct
{
INT_T client_index;
INT_T curr_load_level; /**< 0: best, 5: worst */
INT_T new_load_level; /**< 0: best, 5: worst */
VOID *pReserved;
}C2C_TRANS_LIVE_LOAD_PARAM_S;
typedef struct
{
UINT_T start_timestamp; /* Download start time, in seconds */
UINT_T end_timestamp; /* Download end time, in seconds */
} DOWNLOAD_TIME_S;
typedef struct tagC2C_TRANS_CTRL_DL_START{
unsigned int channel;
PLAYBACK_TIME_S time_sect;
}C2C_TRANS_CTRL_DL_START;
typedef struct tagC2C_TRANS_CTRL_DL_STOP{
unsigned int channel;
}C2C_TRANS_CTRL_DL_STOP,C2C_TRANS_CTRL_DL_PAUSE,C2C_TRANS_CTRL_DL_RESUME,C2C_TRANS_CTRL_DL_CANCLE;
//END
/**
* \brief audio frame struct for P2P
* \struct TRANSFER_AUDIO_FRAME_S
*/
typedef struct
{
TUYA_CODEC_ID audio_codec;
TUYA_AUDIO_SAMPLE_E audio_sample;
TUYA_AUDIO_DATABITS_E audio_databits;
TUYA_AUDIO_CHANNEL_E audio_channel;
BYTE_T *p_audio_buf;
UINT_T buf_len;
UINT64_T pts;
UINT64_T timestamp;//in milliseconds
VOID *p_reserved;
}TRANSFER_AUDIO_FRAME_S;
/**
* \brief video frame type for P2P
* \enum TRANSFER_VIDEO_FRAME_TYPE_E
*/
typedef enum
{
TY_VIDEO_FRAME_PBFRAME, /**< P/B frame */
TY_VIDEO_FRAME_IFRAME, /**< I frame */
}TRANSFER_VIDEO_FRAME_TYPE_E;
/**
* \brief video frame struct for P2P
* \struct TRANSFER_VIDEO_FRAME_S
*/
typedef struct
{
TUYA_CODEC_ID video_codec;
TRANSFER_VIDEO_FRAME_TYPE_E video_frame_type;
BYTE_T *p_video_buf;
UINT_T buf_len;
UINT64_T pts;
UINT64_T timestamp; // In milliseconds
VOID *p_reserved;
}TRANSFER_VIDEO_FRAME_S;
/**
* \typedef TRANSFER_EVENT_CB
* \brief P2P transfer events callback function
* \param[in] event: event type
* \param[in] args: event info required
*/
typedef VOID (*TRANSFER_EVENT_CB)(IN CONST TRANSFER_EVENT_E event, IN CONST PVOID_T args);
/**
* \typedef TRANSFER_REV_AUDIO_CB
* \brief audio receiving (APP->IPC) callback function
* \param [in] p_audio_frame: one frame received from APP via P2P
* \param [in] frame_no: frame sequence number
*/
typedef VOID (*TRANSFER_REV_AUDIO_CB)(IN CONST TRANSFER_AUDIO_FRAME_S *p_audio_frame, IN CONST UINT_T frame_no);
/**
* \typedef TRANSFER_ONLINE_CB
* \brief callback function when P2P status changes
*/
typedef VOID (*TRANSFER_ONLINE_CB)(IN TRANSFER_ONLINE_E status);
/**
* \brief quality for live P2P transferring
* \enum TRANS_LIVE_QUALITY_E
*/
typedef enum
{
TRANS_LIVE_QUALITY_MAX = 0, /**< ex. 640*480, 15 fps, 320 kbit/s (or 1280x720, 5 fps, 320 kbit/s) */
TRANS_LIVE_QUALITY_HIGH, /**< ex. 640*480, 10 fps, 256 kbit/s */
TRANS_LIVE_QUALITY_MIDDLE, /**< ex. 320*240, 15 fps, 256 kbit/s */
TRANS_LIVE_QUALITY_LOW, /**< ex. 320*240, 10 fps, 128 kbit/s */
TRANS_LIVE_QUALITY_MIN, /**< ex. 160*120, 10 fps, 64 kbit/s */
}TRANS_LIVE_QUALITY_E;
/**
* \brief default quality for live P2P transferring
* \enum TRANS_DEFAULT_QUALITY_E
*/
typedef enum
{
TRANS_DEFAULT_STANDARD = 0, /* ex. 640*480, 15 fps */
TRANS_DEFAULT_HIGH, /* ex. 1920*1080, 20 fps */
}TRANS_DEFAULT_QUALITY_E;
/**
* \brief P2P settings
* \struct TUYA_IPC_TRANSFER_VAR_S
*/
typedef struct
{
TRANSFER_ONLINE_CB online_cb; /* Callback function when P2P status changes */
TRANSFER_REV_AUDIO_CB on_rev_audio_cb; /* Audio receiving (app->IPC) callback function */
TUYA_CODEC_ID rev_audio_codec; /* Supported audio codec type for data from the app to the IPC */
TUYA_AUDIO_SAMPLE_E audio_sample;/* Supported audio sampling for data from the app to the IPC */
TUYA_AUDIO_DATABITS_E audio_databits;/* Supported audio databits for data from the app to the IPC */
TUYA_AUDIO_CHANNEL_E audio_channel;/* Supported audio channel type for data from the app to the IPC */
TRANSFER_EVENT_CB on_event_cb; /* P2P event callback function */
TRANS_LIVE_QUALITY_E live_quality;
INT_T max_client_num;
IPC_MEDIA_INFO_S AVInfo;
TRANS_DEFAULT_QUALITY_E defLiveMode; /* For multi-streaming ipc, the default quality for live preview */
VOID *p_reserved;
}TUYA_IPC_TRANSFER_VAR_S;
#define MAX_PRESET_NUM 6
typedef struct {
INT_T pan;
INT_T tilt;
INT_T zoom;
}S_PRESET_PTZ;
typedef struct {
CHAR_T id[32]; // ID in the server
CHAR_T name[32]; // Preset point name
INT_T mpId; // Index ID
S_PRESET_PTZ ptz; // PTZ for preset position
} S_PRESET_POSITION;
typedef struct {
INT_T num;
S_PRESET_POSITION position[MAX_PRESET_NUM];
} S_PRESET_CFG;
#define SS_BASE_PATH_LEN 128
#define DISK_CAPACITY_LOW_THRESH_KB 20*1024 // Threshold to trigger a low disk space warning to the app
#define DISK_CLEAN_THRESH_KB 100*1024 // Threshold to trigger auto-deletion of the earliest data
#define CAPACITY_REPORT_CLEAN_THRESH_KB 100*1024 // Threshold to trigger a disk-space-change notification to the app
typedef enum
{
SD_STATUS_UNKNOWN = 0,
SD_STATUS_NORMAL,
SD_STATUS_ABNORMAL,
SD_STATUS_LACK_SPACE,
SD_STATUS_FORMATING,
SD_STATUS_NOT_EXIST,
SD_STATUS_MAX
}E_SD_STATUS;
typedef enum
{
E_DELETE_NONE,
E_DELETE_YEAR,
E_DELETE_MONTH,
E_DELETE_DAY,
E_DELETE_EVENT,
E_DELETE_INVALID,
E_DELETE_FS_ERROR
}DELETE_LEVEL_E;
typedef enum
{
E_STORAGE_STOP,
E_STORAGE_START,
// The following internal status should NOT be used by developers
E_STORAGE_ONGOING,
E_STORAGE_READY_TO_STOP,
E_STORAGE_RESTART,
E_STORAGE_UNWRITEABLE,
E_STORAGE_INVALID
}STORAGE_STATUS_E;
/**
* \brief storage settings
* \struct STREAM_STORAGE_INFO_S
*/
typedef struct
{
CHAR_T base_path[SS_BASE_PATH_LEN]; /* Base path of storage, /mnt/sdcard/ e.g. */
TUYA_CODEC_ID video_codec; /* Codec type of video stream */
TUYA_CODEC_ID audio_codec; /* Codec type of audio stream */
VOID *p_reserved;
}STREAM_STORAGE_INFO_S;
/**
* \brief storage write mode
* \enum STREAM_STORAGE_WRITE_MODE_E
*/
typedef enum {
SS_WRITE_MODE_NONE, /* Do NOT write AV data */
SS_WRITE_MODE_EVENT,/* Write AV data only when an event happens */
SS_WRITE_MODE_ALL, /* Write AV data all the time */
SS_WRITE_MODE_MAX
}STREAM_STORAGE_WRITE_MODE_E;
typedef enum
{
SD_MODE_NONE = 0,
SD_MODE_EVENT = 1,
SD_MODE_ALL_TIME =2,
SD_MODE_MAX
}E_SD_MODE;
typedef enum
{
SS_EVENT_TYPE_NONE = 0,
SS_EVENT_TYPE_MD,
SS_EVENT_TYPE_FACE,
SS_EVENT_TYPE_BODY,
SS_EVENT_TYPE_MAX
}E_STORAGE_EVENT_TYPE;
/*********************************************************************************
* frame_w Input width
* frame_h Input height
* y_thd The threshold value of motion detection. It is 30 by default and recommended values are 5 to 30. Set 5 in case of low light.
* sensitivity The sensitivity of motion detection ranging from 1 to 7. The larger the number, the higher the sensitivity.
* roi ROI of motion detection
* tracking_enable Switch of motion tracking. `0` indicates the disabled function and `1` indicates the enabled function.
**********************************************************************************/
typedef struct _TUYA_MOTION_TRACKING_CFG
{
INT_T frame_w;
INT_T frame_h;
INT_T y_thd;
INT_T sensitivity; // 1–7
TUYA_RPERCENT_ECT roi;
INT_T tracking_enable; // 1 indicates enable and 0 indicates disable.
}TUYA_MOTION_TRACKING_CFG;
/**
* \brief WebRTC mode
*
*/
typedef enum TUYA_WEBRTC_MODE_ {
TUYA_WEBRTC_ECHOSHOW,
TUYA_WEBRTC_CHROMECAST,
TUYA_WEBRTC_WEB,
} TUYA_WEBRTC_MODE_E;
/**
* \fn callback
* \brief Indicate that WebRTC stream starts
* \param context: user data
* \ mode: stream mode
* \ priv_data: reserve
* \return INT_T 0: success, other: failure
*/
typedef INT_T (*TUYA_WEBRTC_START)(PVOID_T context, TUYA_WEBRTC_MODE_E mode, PVOID_T priv_data);
/**
* \fn callback
* \brief Indicate that WebRTC stream stops
* \param context: user data
* \ mode: stream mode
* \ priv_data: reserve
* \return INT_T 0: success, other: failure
*/
typedef INT_T (*TUYA_WEBRTC_STOP)(PVOID_T context, TUYA_WEBRTC_MODE_E mode, PVOID_T priv_data);
typedef struct {
PVOID_T pcontext; /* Context, user data */
TUYA_WEBRTC_START start; /* Indicate that WebRTC stream starts */
TUYA_WEBRTC_STOP stop; /* Indicate that WebRTC stream stops */
} TUYA_WEBRTC_CALLBACK;
/**
* \brief webrtc params
*
*/
typedef struct TUYA_WEBRTC_PARAM_ {
TUYA_WEBRTC_CALLBACK cbk;
} TUYA_WEBRTC_PARAM_S;
typedef VOID (*FUNC_REQUEST_I_FRAME)(INT_T channel);
typedef enum
{
E_USER_STREAM_STORAGE = 0,
E_USER_COULD_STORAGE = 1,
E_USER_ECHO_SHOW = 2,
E_USER_CHROMECAST = 3,
E_USER_DOORBELL = 4,
E_USER_P2P_USER = 5, // For multiple P2P users, it can be in format of E_USER_P2P_USER+p2p_index
E_USER_RTSP = 10,
E_USER_TSTREAMER = 15,
E_USER_NUM_MAX = 16
}USER_INDEX_E;
typedef struct
{
UINT_T index;
MEDIA_FRAME_TYPE_E type;
UCHAR_T *rawData;
UINT_T size;
UINT64_T pts;
UINT64_T timestamp;
UINT_T seqNo;
UCHAR_T *extraData;
UINT_T extraSize;
}Ring_Buffer_Node_S;
/* Tuya SDK definition of 127.0.0.1 */
#define TY_IPADDR_LOOPBACK ((UINT_T)0x7f000001UL)
/* Tuya SDK definition of 0.0.0.0 */
#define TY_IPADDR_ANY ((UINT_T)0x00000000UL)
/* Tuya SDK definition of 255.255.255.255 */
#define TY_IPADDR_BROADCAST ((UINT_T)0xffffffffUL)
/* Tuya SDK definition of socket protocol */
typedef enum {
PROTOCOL_TCP = 0,
PROTOCOL_UDP = 1,
}UNW_PROTOCOL_TYPE;
/* Tuya SDK definition of transfer type */
typedef enum {
TRANS_RECV = 0,
TRANS_SEND = 1,
}UNW_TRANS_TYPE_E;
/* Tuya SDK definition of socket errno */
typedef INT_T 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
/* Tuya SDK definition of fd operations */
typedef fd_set UNW_FD_SET;
#define UNW_FD_SET(n,p) FD_SET(n, p)
#define UNW_FD_CLR(n, p) FD_CLR(n, p)
#define UNW_FD_ISSET(n,p) FD_ISSET(n,p)
#define UNW_FD_ZERO(p) FD_ZERO(p)
/* Tuya SDK definition of IP info */
typedef struct
{
CHAR_T ip[16]; /* IP address: xxx.xxx.xxx.xxx */
CHAR_T mask[16]; /* Net mask: xxx.xxx.xxx.xxx */
CHAR_T gw[16]; /* Gateway: xxx.xxx.xxx.xxx */
}NW_IP_S;
/* Tuya SDK definition of MAC info */
typedef struct
{
BYTE_T mac[6]; /* MAC address */
}NW_MAC_S;
/* Tuya SDK definition of IP address */
typedef UINT_T UNW_IP_ADDR_T;
/* Tuya SDK definition of IP format change */
#define UNW_INET_ADDR(x) inet_addr(x)
/* Tuya SDK definition of addrinfo */
typedef struct addrinfo ADDRINFO;
/* Tuya SDK definition of Wi-Fi AP info */
#define WIFI_SSID_LEN 32 // Tuya SDK definition of WIFI SSID MAX LEN
#define WIFI_PASSWD_LEN 64 // Tuya SDK definition WIFI PASSWD MAX LEN
typedef struct
{
BYTE_T channel; // AP channel
SCHAR_T rssi; // AP RSSI
BYTE_T bssid[6]; // AP BSSID
BYTE_T ssid[WIFI_SSID_LEN+1]; // AP SSID array
BYTE_T s_len; // AP SSID len
}AP_IF_S;
/***********************************************************
* callback function: SNIFFER_CALLBACK
* Desc: When Wi-Fi sniffers package from the air, notify tuya-sdk with this callback. The package should include 802.11 protocol header.
* Input: buf: the buffer Wi-Fi recv
* Input: len: the length of buffer
***********************************************************/
typedef VOID (*SNIFFER_CALLBACK)(IN CONST BYTE_T *buf,IN CONST USHORT_T len);
/* Tuya SDK definition of Wi-Fi function type */
typedef enum
{
WF_STATION = 0, // Station type
WF_AP, // AP type
}WF_IF_E;
/* Tuya SDK definition of Wi-Fi working mode */
typedef enum
{
WWM_LOWPOWER = 0, // Wi-Fi works in low power mode
WWM_SNIFFER, // Wi-Fi works in sniffer mode
WWM_STATION, // Wi-Fi works in station mode
WWM_SOFTAP, // Wi-Fi works in AP mode
WWM_STATIONAP, // Wi-Fi works in station+AP mode
}WF_WK_MD_E;
/* Tuya SDK definition of Wi-Fi encryption type */
typedef enum
{
WAAM_OPEN = 0, // open
WAAM_WEP, // WEP
WAAM_WPA_PSK, // WPA-PSK
WAAM_WPA2_PSK, // WPA2-PSK
WAAM_WPA_WPA2_PSK, // WPA/WPA2
}WF_AP_AUTH_MODE_E;
/* Tuya SDK definition of AP config info */
typedef struct {
BYTE_T ssid[WIFI_SSID_LEN+1]; // SSID
BYTE_T s_len; // Length of SSID
BYTE_T passwd[WIFI_PASSWD_LEN+1]; // Password
BYTE_T p_len; // Length of password
BYTE_T chan; // Channel. Default: 0.
WF_AP_AUTH_MODE_E md; // Encryption type
BYTE_T ssid_hidden; // The SSID is hidden. Default: 0.
BYTE_T max_conn; // Max number of station connections. Default: 0.
USHORT_T ms_interval; // Broadcast interval. Default: 0.
}WF_AP_CFG_IF_S;
/* Tuya SDK definition of Wi-Fi station working status */
typedef enum {
WSS_IDLE = 0, // Not connected
WSS_CONNECTING, // Connecting Wi-Fi
WSS_PASSWD_WRONG, // Password does not match
WSS_NO_AP_FOUND, // AP is not found
WSS_CONN_FAIL, // Failed to connect
WSS_CONN_SUCCESS, // Connected to Wi-Fi
WSS_GOT_IP, // The IP address is retrieved
}WF_STATION_STAT_E;
Operation | Description |
---|---|
hwl_bnw_get_ip | Get the IP address |
hwl_bnw_station_conn | Connect to a station |
hwl_bnw_set_station_connect | Set station connection |
hwl_bnw_get_mac | Get the MAC address |
hwl_bnw_set_mac | Set the MAC address |
The preceding interfaces are described in the wired pairing section of the demo.
The cloud smart detection service supports multiple functions in the cloud, such as human shape detection. The devices in this service do not require many development tasks. You only need to activate required smart service functions from the app and initialize the smart service functions. If this API is required, the tuya_ipc_ai_detect_storage.h
file must be included. The following API operations are supported:
Operation | Description |
---|---|
tuya_ipc_ai_detect_storage_init | Initialize the smart functions in the cloud |
tuya_ipc_ai_detect_storage_exit | Release smart resources in the cloud |
tuya_ipc_ai_detect_storage_start | Start smart detection in the cloud |
tuya_ipc_ai_detect_storage_stop | Stop smart detection in the cloud |
tuya_ipc_ai_detect_storage_pause | Pause smart detection in the cloud |
tuya_ipc_ai_detect_storage_resume | Resume smart detection in the cloud |
You only need to set request parameters in tuya_ipc_ai_detect_storage_init
. Other API operations for this service do not require request parameters.
The following sample code shows the function prototype:
OPERATE_RET tuya_ipc_ai_detect_storage_init(IPC_MEDIA_INFO_S *media_setting);
For more information about the parameters, see the struct definition section.
Most API operations of the Tuya IPC SDK are included in tuya_ipc_api.h
. The following API operations are supported.
Operation | Description |
---|---|
tuya_ipc_get_sdk_info | Get the SDK version information |
tuya_ipc_init_sdk | Initialize the SDK |
tuya_ipc_start_sdk | Enable the SDK |
tuya_ipc_upgrade_sdk | Upgrade the device |
tuya_ipc_get_register_status | Get the device registration status |
tuya_ipc_get_service_time | Get server time |
tuya_ipc_get_service_time_force | Get server time, which is forcibly synchronized once |
tuya_ipc_check_in_dls | Check if it is daylight saving time (DST) |
tuya_ipc_get_local_time | Get local time fromf the device |
tuya_ipc_get_utc_tm | Get year, month, day, hour, minute, and second |
tuya_ipc_get_utc_time | Get UTC time |
tuya_ipc_get_tm_with_timezone_dls | Get the time with time zone |
tuya_ipc_dp_report_sync | Synchronize DP reporting |
tuya_ipc_get_wakeup_data | Get wake-up data |
tuya_ipc_get_heartbeat_data | Get heartbeat data |
tuya_ipc_direct_connect | Connect to the MQTT service |
tuya_ipc_get_mqtt_status | Get device MQTT status |
tuya_ipc_book_wakeup_topic | Get low power wake-up message |
tuya_ipc_get_mqtt_socket_fd | Get FD of MQTT connection |
tuya_ipc_set_log_attr | Set directional log parameters |
tuya_ipc_send_custom_mqtt_msg | Send MQTT messages |
tuya_ipc_set_service_time | Set server time |
tuya_ipc_notify_motion_detect | Push motion detection pictures |
tuya_ipc_notify_door_bell_press | Push ordinary doorbell pictures |
tuya_ipc_door_bell_press | Push ordinary and AC doorbell pictures |
tuya_ipc_notify_with_event | Push pictures to the Tuya Developer Platform and app message center |
tuya_ipc_upload_skills | Report device capability |
tuya_ipc_fill_skills | Add functions to the device |
tuya_ipc_upgrade_progress_report | Report the device update progress |
/**
* \fn OPERATE_RET tuya_ipc_init_sdk(IN CONST TUYA_IPC_ENV_VAR_S *p_var)
* \brief initialize tuya sdk for embeded devices
* \return OPERATE_RET
*/
OPERATE_RET tuya_ipc_init_sdk(IN CONST TUYA_IPC_ENV_VAR_S *p_var);
Description
Initialize the Tuya SDK.
Parameters
Parameter | Description |
---|---|
p_var | For more information about variable struct, see the struct section. |
Return value
Return value | Description |
---|---|
0 | OK |
Things to note
Implement all parameters or callback functions according to the struct description.
/**
* \fn OPERATE_RET tuya_ipc_start_sdk(IN CONST TUYA_WIFI_DEV_INFO_S *p_wifi_info)
* \brief Start IPC as WIFI_DEVICE
* \return OPERATE_RET
*/
OPERATE_RET tuya_ipc_start_sdk(IN CONST WIFI_INIT_MODE_E wifi_mode,
IN CONST char *pToken);
Description
Enable the SDK.
Parameters
Parameter | Description |
---|---|
wifi_mode | Pairing mode parameter |
pToken | Authorization code required for pairing |
Return value
Return value | Description |
---|---|
0 | OK |
/**
* \fn OPERATE_RET tuya_ipc_upgrade_sdk( IN CONST FW_UG_S *fw,\
* IN CONST GET_FILE_DATA_CB get_file_cb,\
* IN CONST UPGRADE_NOTIFY_CB upgrd_nofity_cb,\
* IN PVOID pri_data)
* \brief OTA, upgrade via TUYA SDK
* \param[in] fw firmware: infomation
* \param[in] get_file_cb: callback function during downloading fw
* \param[in] upgrd_nofity_cb: callback function when fw downloading is finished
* \param[in] pri_data: data transferred between callback functions
* \return OPERATE_RET
*/
OPERATE_RET tuya_ipc_upgrade_sdk( IN CONST FW_UG_S *fw,\
IN CONST GET_FILE_DATA_CB get_file_cb,\
IN CONST UPGRADE_NOTIFY_CB upgrd_nofity_cb,\
IN PVOID_T pri_data);
Description
Upgrade the device. After the device upgrade is configured in the background, the device can be upgraded by means of the API callback. This API operation must be encapsulated in the device and registered in the SDK in the form of a registered interface.
Parameters
Parameter | Description |
---|---|
fw | For more information about the struct definition, including URL, MD5, version, and firmware sizes, see tuya_cloud_com_def.h . |
get_file_cb | The update file obtained |
upgrd_nofity_cb | Upgrade progress callback interface |
pri_data | Context |
Return value
Return value | Description |
---|---|
0 | OK |
Things to note
The device needs to implement the callback of the corresponding upgrade interface registration.
To integrate with the Google Chromecast function, the tuya_ipc_chromecast.h
file is required. The following API operations are supported.
Operation | Description |
---|---|
tuya_ipc_chromecast_init | Initialization interface |
tuya_ipc_chromecast_deinit | Deinitialization interface |
tuya_ipc_chromecast_stop | Stop Chromecast streaming |
The header file of cloud storage services is in tuya_ipc_cloud_storage.h
, mainly including the following interfaces.
Operation | Description |
---|---|
tuya_ipc_cloud_storage_init | Initialization interface of cloud storage |
tuya_ipc_cloud_storage_uninit | Deinitialization interface of cloud storage |
tuya_ipc_cloud_storage_get_store_mode | Get cloud storage mode |
tuya_ipc_cloud_storage_get_event_status | Get cloud storage status |
tuya_ipc_cloud_storage_get_event_status_by_id | Query cloud storage status by ID |
tuya_ipc_cloud_storage_pause | Pause cloud storage |
tuya_ipc_cloud_storage_resume | Resume cloud storage |
tuya_ipc_cloud_storage_event_add | Add a cloud storage event |
tuya_ipc_cloud_storage_event_delete | Delete a cloud storage event |
tuya_ipc_cloud_storage_event_notify | Report a cloud storage event type |
tuya_ipc_cloud_storage_set_event_type | Modify a cloud storage event type |
tuya_ipc_cloud_storage_set_pre_record_time | Pre-recorded cloud storage time setting |
To integrate with the Echo Show function, the tuya_ipc_echo_show.h
file is required. The following API operations are supported.
Operation | Description |
---|---|
tuya_ipc_echoshow_init | Echo Show initialization interface |
tuya_ipc_echoshow_deinit | Echo Show deinitialization interface |
tuya_ipc_echoshow_stop | Stop the Echo Show function |
Tuya SDK provides common image processing function interfaces, and the tuya_ipc_img_proc.h
file is required, mainly including the following interfaces.
Operation | Description |
---|---|
Tuya_Ipc_Img_Resize | Image zoom interface |
Tuya_Ipc_ImgConvert_yuv4202bgr888 | Convert yuv4202 format to bgr888 format |
Tuya_Ipc_Img_DrawRect_YUV | Draw a frame on the YUV image |
Tuya_Ipc_Img_Get_Rect_YUV | Image matting interface |
Tuya_Ipc_Img_OSD_ARGB1555 | Format conversion interface |
Tuya P2P streaming operation needs to include the tuya_ipc_p2p.h
file. The following API operations are supported.
Operation | Description |
---|---|
tuya_ipc_tranfser_init | Initialize P2P transmission |
tuya_ipc_tranfser_close | Close the transmission |
tuya_ipc_tranfser_quit | Exit the transmission |
tuya_ipc_playback_send_video_frame | Playback video frame transmission |
tuya_ipc_playback_send_audio_frame | Playback audio frame transmission |
tuya_ipc_playback_send_fragment_end | End of playback frame. Send end frame |
tuya_ipc_playback_send_finish | End of playback |
tuya_ipc_get_client_conn_info | Get connection information |
tuya_ipc_free_client_conn_info | Release connection information |
tuya_ipc_4_app_download_data | Download preview data in the app |
tuya_ipc_4_app_download_status | Data downloading progress in the app |
tuya_ipc_tranfser_secret_mode | Set transmission encryption method |
The tuya_ipc_ptz.h
file must be included for the related operations of the Tuya motor movement preset point, which provides the following interfaces:
Operation | Description |
---|---|
tuya_ipc_preset_add | Add a preset point |
tuya_ipc_preset_del | Delete a preset point |
tuya_ipc_preset_get | Get a preset point |
tuya_ipc_preset_add_pic | Add a preset point |
The header files of the local storage service are in tuya_ipc_stream_storage.h
, mainly including the following interfaces.
Operation | Description |
---|---|
tuya_ipc_ss_init | Local storage initialization interface |
tuya_ipc_ss_uninit | Local storage deinitialization interface |
tuya_ipc_ss_set_write_mode | Set local storage mode |
tuya_ipc_ss_get_write_mode | Get local storage mode |
tuya_ipc_ss_trigger_event | Trigger local event storage |
tuya_ipc_ss_start_event | Start local storage |
tuya_ipc_ss_stop_event | Stop local storage |
tuya_ipc_ss_start_event_by_type | Start local storage by type |
tuya_ipc_ss_stop_event_by_type | Stop local storage by type |
tuya_ipc_ss_set_pre_record_time | Set local storage pre-recording time |
tuya_ipc_ss_set_max_event_duration | Set the maximum duration of local storage |
tuya_ipc_ss_delete_oldest_event | Delete the earliest event fragment |
tuya_ipc_ss_delete_all_files | Delete all local storage video files |
tuya_ipc_ss_get_status | Get local recording status value |
tuya_ipc_pb_query_by_month | Query local storage playback by month |
tuya_ipc_pb_query_by_day | Query local storage playback by day |
tuya_ipc_pb_query_free_ts_arr | Release the video according to TS |
tuya_ipc_ss_pb_set_status | Set local playback status |
tuya_ipc_ss_pb_stop | Stop local playback |
tuya_ipc_ss_pb_seek | Drag the video by the event during playback |
tuya_ipc_ss_pb_stop_all | Stop all playback |
tuya_ipc_ss_donwload_pre | Pre-process before downloading local storage |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback