更新时间:2024-06-25 05:50:57下载pdf
事件报警是一个将设备产生的移动侦测、人形、宠物、门铃呼叫等智能事件发送到云端,并最终在 App 上展示的功能模块。它支持普通的图片消息,也支持视频消息,还能够支持门铃呼叫的 App 弹窗消息。
svc_api_ipc
使用 DP 212 消息上报一个报警信息。若报警类型包含在 NOTIFICATION_NAME_E
(位于tuya_ipc_notify.h
)的枚举中,可以直接使用下面接口上报。
/**
* @brief send a editable alarm to tuya cloud and APP
*
* @param[in] snap_buffer: address of current snapshot
* @param[in] snap_size: size fo snapshot, in Byte
* @param[in] name: editable event type, NOTIFICATION_NAME_E
* @param[in] is_notify: send to message center if TRUE
*
* @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
*/
OPERATE_RET tuya_ipc_notify_alarm(IN CONST CHAR_T *snap_buffer, IN CONST UINT_T snap_size, IN CONST NOTIFICATION_NAME_E name, IN BOOL_T is_notify);
若 NOTIFICATION_NAME_E
中未列举出的事件类型,请查看是否在 TUYA_ALARM_TYPE_E
(位于tuya_ipc_event.h
)中列出,如果包含,可以使用下面接口进行上报。
/**
* @brief notify an alarm not base on event
*
* @param alarm: TUYA_ALARM_T
*
* @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
*/
OPERATE_RET tuya_ipc_trigger_alarm_without_event(IN TUYA_ALARM_T *alarm);
表示报警详情的数据结构体:
typedef struct {
INT_T type; ///< alarm type
TUYA_ALARM_BITMAP_T wait_for; ///< depends on other alarms
INT_T is_notify; ///< notify to cloud
TIME_T trigger_time;
TIME_T upload_time; ///< 0 means immediately and -1 means wait until event end
BOOL_T valid; ///< 1 means needs to handle and 0 means had handled. user should set to 1
BOOL_T force; ///< force upload or not, independent with event like E_ALARM_COVER
INT_T resource_type; ///< refer to macro RESOURCE_XXX
CHAR_T *extra_data; ///< extra data append to upload info, json format: "aaa":3. NULL if not need
CHAR_T *pic_buf;
INT_T pic_size;
TUYA_ALARM_TEXT_T *context; ///< text alarm info, can be NULL
INT_T context_cnt; ///< TUYA_ALARM_TEXT_T count, can be 0
NOTIFICATION_UNIT_T *media; ///< media info, can be NULL
INT_T media_cnt; ///< NOTIFICATION_UNIT_T count, can be 0
CHAR_T dev_id[DEV_ID_LEN+1]; ///< deive id
INT_T dev_chan_index; ///< device channle
} TUYA_ALARM_T;
若仅上报一个图片事件,参考以下初始化的值:
TUYA_ALARM_T alarm_info = {0};
alarm_info.type = ; //报警类型
alarm_info.is_notify = ; //消息中心开关状态
alarm_info.trigger_time = tal_time_get_posix(); //当前时间
alarm_info.upload_time = 0;
alarm_info.valid = 1;
alarm_info.force = 1;
alarm_info.resource_type = RESOURCE_PIC;
alarm_info.pic_buf = ; //图片 buffer 地址
alarm_info.pic_size = ; //图片 buffer 长度
alarm_info.extra_data = NULL;
alarm_info.context = NULL;
alarm_info.context_cnt = 0;
alarm_info.media = NULL;
alarm_info.media_cnt = 0;
tuya_ipc_notify_alarm
接口,将参数 is_notify
设置为 FALSE
。tuya_ipc_trigger_alarm_without_event
接口,将参数 TUYA_ALARM_T
中 is_notify
设置为 FALSE
。NOTIFICATION_NAME_E
已经列出的事件。TUYA_ALARM_TYPE_E
已经列出的事件。JPEG 格式。
要求小于 307120 Byte。
请 提交工单 联系涂鸦技术支持,确认设备的 PID 上 DP 212 消息上是否配置了该报警类型。
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈