更新时间:2025-01-24 11:51:54下载pdf
为降低客户开发成本,方便扫地机与 App 面板交互,激光扫地机品类 SDK 把虚拟墙、房间属性等复杂控制,封装成不同的 API,应用开发者使用 API 即可完成数据通信。
当前 API 提供了以下方面的功能:
当前 API 支持的命令列表如下:
功能 | 命令类型标识 | 发起方向 | 备注 |
---|---|---|---|
虚拟墙设置 | VIRTUAL_WALL_SET | 面板->设备 | |
虚拟墙查询 | VIRTUAL_WALL_QUERY | 面板->设备 | |
禁区设置 | RESTRICTED_AREA_SET | 面板->设备 | |
禁区查询 | RESTRICTED_AREA_QUERY | 面板->设备 | |
房间属性设置 | ROOM_PROPERTY_SET | 面板->设备 | |
房间属性查询 | ROOM_PROPERTY_QUERY | 面板->设备 | |
选区清扫设置 | ROOM_CLEAN_SET | 面板->设备 | |
选区清扫查询 | ROOM_CLEAN_QUERY | 面板->设备 | |
划区清扫设置 | ZONE_CLEAN_SET | 面板->设备 | |
划区清扫查询 | ZONE_CLEAN_QUERY | 面板->设备 | |
定点清扫设置 | SPOT_CLEAN_SET | 面板->设备 | |
定点清扫查询 | SPOT_CLEAN_QUERY | 面板->设备 | |
预约定时设置 | SCHEDULE_SET | 面板->设备 | |
预约定时查询 | SCHEDULE_QUERY | 面板->设备 | |
勿扰定时设置 | QUIET_HOUR_SET | 面板->设备 | |
勿扰定时查询 | QUIET_HOUR_QUERY | 面板->设备 | |
地图分区分割 | PART_DIVI_SET | 面板->设备 | |
地图分区合并 | PART_MERGE_SET | 面板->设备 | |
地图分区恢复默认 | PART_DEFAULT_SET | 面板->设备 | |
地图重置 | RESET_CURR_MAP_SET | 面板->设备 | |
地图保存 | SAVE_CURR_MAP_SET | 面板->设备 | |
云端地图删除 | DELETE_CLOUD_MAP_SET | 面板->设备 | |
云端地图使用 | USE_CLOUD_MAP_SET | 面板->设备 | |
语音使用 | USE_CLOUD_VOICE_LANGUAGE_SET | 面板->设备 | |
语音查询 | VOICE_LANGUAGE_QUERY | 面板->设备 | |
设备信息查询 | DEV_INFO_QUERY | 面板->设备 | |
缩略图信息设置 | AI_OBJECT_IGNORE_SET | 面板->设备 | |
空地图信息查询 | MAP_EMPTY_QUERY | 面板->设备 | |
密码状态查询 | PASSWORD_STATE_QUERY | 面板->设备 | |
密码验证 | PASSWORD_CHECK | 面板->设备 | |
密码设置 | PASSWORD_SET | 面板->设备 |
FUNC_SET_CB
回调对应的处理命令后,需要异步处理该事件,以保证频繁点击面板进行命令下发时,不对后续命令解析造成阻塞,异步处理时需要将命令参数先进行数据复制,然后使用复制后的数据进行命令事件处理。命令处理回调函数的注册接口。回调函数注册成功后,SDK 在收到云端下发的命令协议并成功解析后会调用注册的回调函数执行业务功能。需要注意的是回调函数中的 param 入参变量会在回调函数被调用后释放掉,如果回调函数有异步操作,需要将该入参的参数数据复制到应用自己申请的变量空间中。
/**
* @brief Sweeper advanced function setting callback function pointer
* @param [ADVANCE_CMD_E] cmd, protocol command, the SDK uses this parameter to notify the application of the current setting command to be processed, see the list for setting commands, all ending with SET
* @param [void *] param, parameters corresponding to the command, the application converts the param parameter into the command corresponding parameter structure based on the cmd command field, the structure correspondence can refer to the accompanying demo
*/
typedef OPERATE_RET (*FUNC_SET_CB)(IN ADVANCE_CMD_E cmd, IN void* param);
/**
* @brief Sweeper advanced function query callback function pointer
* @param [ADVANCE_CMD_E] cmd, protocol command, the SDK uses this parameter to notify the application of the current query command to be processed, see the list for query commands, all ending with QUERY
* @param [void *] param, parameters corresponding to the command, current query command, its parameters are meaningless and do not need to be processed
* @note When the application gets the corresponding command parameters in the query callback function and needs to report, please call the corresponding response reporting function, for example, after processing the VIRTUAL_WALL_QUERY command, when needing to report parameters, use the ty_rvc_virtual_wall_data_response interface to report
*/
typedef OPERATE_RET (*FUNC_QUERY_CB)(IN ADVANCE_CMD_E cmd, IN void* param);
/**
* @brief Register advanced capability setting and query callback functions
* @param[in] sets_handler: Command setting callback function that the application needs to implement
* @param[in] query_handler: Command query callback function that the application needs to implement
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_advance_func_register(IN FUNC_SET_CB sets_handler, IN FUNC_QUERY_CB query_handler);
参数 | 说明 |
---|---|
sets_handler | 入参,设置命令的处理回调函数,由业务应用实现。通过该接口注册到 SDK,回调函数的 param 入参为命令参数,应用应根据命令类型将该参数转换成对应的命令参数结构体,再进行使用 |
query_handler | 入参,查询命令的处理回调函数,由业务应用实现。通过该接口注册到 SDK,回调函数的 param 入参当前未使用,应用无需关心 |
OPERATE_RET | 返回值,OPRT_OK 代表执行成功,其它值代表执行失败,错误码含义参见 TuyaOS_SDK 对应头文件定义 |
设备端数据上报接口,用于完成与涂鸦 App 的数据同步,各接口完成的数据上报功能列表如下:
接口名称 | 接口功能 | 备注 |
---|---|---|
ty_rvc_virtual_wall_data_response | 虚拟墙数据上报 | 设备端有相应数据变化时应主动调用该接口进行数据上报 |
ty_rvc_restricted_area_data_response | 禁区数据上报 | 设备端有相应数据变化时应主动调用该接口进行数据上报 |
ty_rvc_room_property_data_response | 房间属性数据上报 | 设备端有相应数据变化时应主动调用该接口进行数据上报 |
ty_rvc_room_clean_data_response | 选区清扫数据上报 | 设备端有相应数据变化时应主动调用该接口进行数据上报 |
ty_rvc_spot_clean_data_response | 定点清扫数据上报 | 设备端有相应数据变化时应主动调用该接口进行数据上报 |
ty_rvc_zone_clean_data_response | 划区清扫数据上报 | 设备端有相应数据变化时应主动调用该接口进行数据上报 |
ty_rvc_schedule_data_response | 预约定时数据上报 | 设备端有相应数据变化时应主动调用该接口进行数据上报 |
ty_rvc_quiet_hours_data_response | 勿扰定时数据上报 | 设备端有相应数据变化时应主动调用该接口进行数据上报 |
ty_rvc_voice_language_data_response | 语音切换数据上报 | 设备端有相应数据变化时应主动调用该接口进行数据上报 |
ty_rvc_device_info_data_response | 设备信息数据上报 | 设备端有相应数据变化时应主动调用该接口进行数据上报 |
ty_rvc_part_division_data_response | 地图分区分割设置结果上报 | 该功能仅用于设置命令执行后的结果回复,面板无设置命令下发时设备无需调用该接口进行数据同步 |
ty_rvc_part_merge_data_response | 地图分区合并设置结果上报 | 该功能仅用于设置命令执行后的结果回复,面板无设置命令下发时设备无需调用该接口进行数据同步 |
ty_rvc_map_part_default_data_response | 地图分区恢复默认数据上报 | 该功能仅用于设置命令执行后的结果回复,面板无设置命令下发时设备无需调用该接口进行数据同步 |
ty_rvc_map_clear_data_response | 地图重置命令设置结果上报 | 该功能仅用于设置命令执行后的结果回复,面板无设置命令下发时设备无需调用该接口进行数据同步 |
ty_rvc_map_save_data_response | 地图保存命令设置结果上报 | 该功能仅用于设置命令执行后的结果回复,面板无设置命令下发时设备无需调用该接口进行数据同步 |
ty_rvc_map_delete_data_response | 地图删除命令设置结果上报 | 该功能仅用于设置命令执行后的结果回复,面板无设置命令下发时设备无需调用该接口进行数据同步 |
ty_rvc_map_use_data_response | 地图使用命令设置结果上报 | 该功能仅用于设置命令执行后的结果回复,面板无设置命令下发时设备无需调用该接口进行数据同步 |
ty_rvc_map_empty_response | 空地图查询命令结果上报 | 该功能仅用于查询命令执行后的结果回复,面板无设置命令下发时设备无需调用该接口进行数据同步 |
ty_rvc_password_check_response | 密码验证命令结果上报 | 该功能仅用于查询命令执行后的结果回复,面板无设置命令下发时设备无需调用该接口进行数据同步 |
ty_rvc_password_state_response | 密码状态命令结果上报 | 该功能仅用于设置或者查询命令执行后的结果回复,面板无设置命令下发时设备无需调用该接口进行数据同步 |
ty_rvc_password_set_response | 设置密码命令结果上报 | 该功能仅用于设置命令执行后的结果回复,面板无设置命令下发时设备无需调用该接口进行数据同步 |
/**
* @brief Report virtual wall information
* @param[in] p_virtual_wall: Virtual wall data, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Command execution result, 0 for success, other values for failure
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_virtual_wall_data_response(VIRTUAL_WALL_S* p_virtual_wall, int errcode);
/**
* @brief Report restricted area data
* @param[in] p_restricted_area: Restricted area data input parameter, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Execution result corresponding to the parameter setting, 0 for success, other values for failure
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_restricted_area_data_response(RESTRICTED_AREA_S* p_restricted_area, int errcode);
/**
* @brief Report room property data
* @param[in] p_room_clean: Room property data, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Execution result corresponding to the parameter setting, 0 for success, other values for failure
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_room_property_data_response(ROOM_PROPERTY_S* p_room_clean, int errcode);
/**
* @brief Report selected area cleaning parameter values
* @param[in] p_room_clean: Cleaning parameter input parameter, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Execution error code, no error, input parameter is 0
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_room_clean_data_response(ROOM_CLEAN_S* p_room_clean, int errcode);
/**
* @brief Report spot cleaning data
* @param[in] spot_clean_data: Spot cleaning data input parameter, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Execution error code, input 0 when no error
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_spot_clean_data_response(SPOT_CLEAN_S* spot_clean_data, int errcode);
/**
* @brief Report zone cleaning data
* @param[in] p_zone_area: Zone cleaning data input parameter, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Execution error code, input 0 when no error
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_zone_clean_data_response(ZONE_CLEAN_S* p_zone_area, int errcode);
/**
* @brief Partition setting reply
* @param[in] p_part_division: Partition parameters, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Execution error code, input 0 when no error
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_part_division_data_response(PART_DIVI_S* p_part_division, PART_DIV_ST_E errcode);
/**
* @brief Partition merge command reply
* @param[in] p_part_merge: Partition setting reply parameters, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Execution error code, input 0 when no error
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_part_merge_data_response(PART_MERGE_S* p_part_merge, PART_MERGE_ST_E errcode);
/**
* @brief Partition restore default command response
* @param[in] p_part_merge: Structure parameters, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Execution error code
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_map_part_default_data_response(MAP_PART_RESET_S* p_part_merge, PART_RESET_ST_E errcode);
/**
* @brief Clear home map reply
* @param[in] p_map_reset: Map reset structure, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Execution error code
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_map_clear_data_response(CURRENT_MAP_RESET_S* p_map_reset, MAP_RESET_ST_E errcode);
/**
* @brief Map save command reply
* @param[in] p_map_save: Map save reply parameter input, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Error code
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_map_save_data_response(MAP_SAVE_S* p_map_save, MAP_SAVE_ST_E errcode);
/**
* @brief Map delete command reply
* @param[in] p_map_delete: Map delete reply parameters, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Error code
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_map_delete_data_response(DELETE_CLOUD_MAP_S* p_map_delete, MAP_DELETE_ST_E errcode);
/**
* @brief Use map command reply
* @param[in] p_map_use_set: Use map reply parameters, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Error code
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_map_use_data_response(USE_CLOUD_MAP_S* p_map_use_set, MAP_USE_ST_E errcode);
/**
* @brief Scheduled data report
* @param[in] p_schedule: Scheduled data, passed in by the application, parameters are defined in the structure
* @param[in] current_map_id:
* @param[in] errcode:
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_schedule_data_response(SCHEDULE_S* p_schedule, int errcode);
/**
* @brief Do not disturb scheduled data report
* @param[in] p_quiet_hours: Do not disturb scheduled data input, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Error code
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_quiet_hours_data_response(QUIET_HOURS_S* p_quiet_hours, int errcode);
/**
* @brief Voice use parameter report
* @param[in] p_voice_language_set: Voice use parameter report, passed in by the application, parameters are defined in the structure
* @param[in] errcode: Execution error code
* @param[in] download_status: Voice file download status
* @param[in] schedule: File download progress, value range 0~100, representing 0%~100%
* @return OPERATE_RET: 0 success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_voice_language_data_response(USE_VOICE_LANGUAGE_S* p_voice_language_set, VOICE_USE_ST_E errcode, VOICE_DOWNLOAD_ST_E download_status, int schedule);
/**
* @brief Device information report, info field is concatenated by the customer in key:value format in JSON, when the app panel displays device information, it shows each value in the order of the key list
* The panel needs to correctly configure multilingual support for each key value
* This interface is responsible for completing data reporting via the MQTT channel
*
* @param[char*] info: Application's JSON format string
* @param [int] len: String length
* @return OPERATE_RET, OPRT_OK indicates success, other error codes indicate failure
*/
OPERATE_RET ty_rvc_device_info_data_response(char* info, int len);
static OPERATE_RET __sweeper_advance_function_set(OUT ADVANCE_CMD_E cmd, OUT void *param)
{
OPERATE_RET ret = 0;
int i=0,j=0;
switch (cmd) {
case VIRTUAL_WALL_SET: {
VIRTUAL_WALL_S* p_virtual_wall = (VIRTUAL_WALL_S*)param;
PR_DEBUG("virtual wall num:%d", p_virtual_wall->num);
for(i = 0; i < p_virtual_wall->num;i++){
PR_DEBUG("mode:%d", p_virtual_wall->line[i].mode);
PR_DEBUG("line:%d", p_virtual_wall->line[i].points[0].x);
PR_DEBUG("line:%d", p_virtual_wall->line[i].points[0].y);
PR_DEBUG("line:%d", p_virtual_wall->line[i].points[1].x);
PR_DEBUG("line:%d", p_virtual_wall->line[i].points[1].y);
}
........
//此处仅演示接口用法,实际使用时应在异步事件处理函数中获取设备实际数据,并进行数据上报
current_map_id = 8;
errcode = 0;
ty_rvc_virtual_wall_data_response(p_virtual_wall, current_map_id, errcode);
}break;
.......
default:
PR_DEBUG("cmd not support now");
break;
}
}
static OPERATE_RET __sweeper_advance_function_query(OUT ADVANCE_CMD_E cmd, OUT void *param)
{
OPERATE_RET ret = OPRT_OK;
uint16_t cmd_index = 0;
switch(cmd){
case VIRTUAL_WALL_QUERY:{
// 使用测试数据进行数据上报演示
VIRTUAL_WALL_S test_virtual_wall;
VIRTUAL_LINE_S virtual_line[10] = {0};
OPERATE_RET ret = OPRT_OK;
test_virtual_wall.num = 1;
for (int i = 0; i < test_virtual_wall.num; i++) {
virtual_line[i].mode = FORBIT_ALL;
virtual_line[i].points[0].x = 100;
virtual_line[i].points[0].y = 200;
virtual_line[i].points[1].x = 50;
virtual_line[i].points[1].y = 60;
}
test_virtual_wall.line = virtual_line;
int current_map_id = 7;
ty_rvc_virtual_wall_data_response(&test_virtual_wall, current_map_id, errcode);
}break;
default:
PR_DEBUG("cmd not support now");
break;
}
return ret;
}
// 上电主流程
int main(int argc, char* argv[])
{
OPERATE_RET ret = 0;
....
ret = ty_sys_start();
if (ret != OPRT_OK) {
PR_ERR("[%s, %d] sys start failed", __FUNCTION__, __LINE__);
return ret;
}
ty_rvc_advance_func_register(__sweeper_advance_function_set, __sweeper_advance_function_query);
....
}
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈