Live Map and Route Transmission

Last Updated on : 2024-09-13 07:09:39download

This topic describes how the live map and route transmission feature works on laser robot vacuums and the related APIs.

Overview

The live map and route transmission feature supports two file actions:

  • Download the map.
  • Cancel map download.

The map for laser robot vacuums is available in two standard types:

  • Full map
  • Cleaning route

The map for laser robot vacuums also supports custom files, such as ai.bin.stream for AI-powered recognition.

Custom files are typically used in custom panels, and their naming conventions should match those on the panel.

How it works

General process

DeviceTuyaOS SDKSTUN ServerTuya-Enabled AppCheck if the numberof sessions reachesthe limit. If it does,close a session.Send authentication information.If authenticationfails, the session willbe closed.Query the map files supported by the device.The query callback.Return the result.Return the result.Download the map file.The download informationcallback.Return the result.Return the result.Invoke data transmission.Send the map and route file.Cancel downloading the map file.The download cancelationcallback.Return file transmissiontermination.Return the download cancelation result.DeviceTuyaOS SDKSTUN ServerTuya-Enabled App

Download map

Tuya-Enabled AppTuyaOS SDKDeviceDownload the map file.The download event callback.Read the local map file and sendtuya_sweeper_send_map_data_w-ith_buff.Send data.Read the local route file andsendtuya_sweeper_send_cleanpath_d-ata_with_buff.Send data.Read the local custom file andsendtuya_sweeper_send_custom-ize_data_with_buff.Send data.Tuya-Enabled AppTuyaOS SDKDevice

Cancel map download

Tuya-Enabled AppTuyaOS SDKDeviceCancel downloading the mapfile.Acknowledge the receipt ofthe command.The download event callback.Calltuya_sweeper_stop_send_data_t-o_app to notify the app of filetransmission termination.Send a message to the app.Acknowledge the receipt ofthe command.Tuya-Enabled AppTuyaOS SDKDevice

APIs

tuya_sweeper_send_map_data_with_buff

/**
 * \fn tuya_sweeper_send_map_data_with_buff
 * \brief send file to app by P2P
 * \param[in] client: client handle
 * \param[in] fileLen: file len
 * \param[in] fileBuff: file buff
 * \param[in] timeout_ms: timeout, in ms
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */
OPERATE_RET tuya_sweeper_send_map_data_with_buff(IN INT_T client, IN INT_T fileLen, IN CHAR_T* fileBuff, IN INT_T timeout_ms);

Send the live map data to the mobile app.

Parameter Description
client The session handle for the data transmission channel, obtained from the callback during map downloading.
fileLen The length of the live map file.
fileBuff The content of the live map file.
timeout_ms The timeout for live map file transmission.

tuya_sweeper_send_cleanpath_data_with_buff

/**
 * \fn tuya_sweeper_send_cleanpath_data_with_buff
 * \brief send file to app by P2P
 * \param[in] client: client handle
 * \param[in] fileLen: file len
 * \param[in] fileBuff: file buff
 * \param[in] timeout_ms: timeout, in ms
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */
OPERATE_RET tuya_sweeper_send_cleanpath_data_with_buff(IN INT_T client, IN INT_T fileLen, IN CHAR_T* fileBuff, IN INT_T timeout_ms);

Send the live route data to the mobile app.

Parameter Description
client The session handle for the data transmission channel, obtained from the callback during map downloading.
fileLen The length of the live route file.
fileBuff The content of the live route file.
timeout_ms The timeout for live route file transmission.

tuya_sweeper_send_customize_data_with_buff

/**
 * \fn tuya_sweeper_send_customize_data_with_buff
 * \brief send file to app by P2P
 * \param[in] client: client handle
 * \param[in] name: file name
 * \param[in] fileLen: file len
 * \param[in] fileBuff: file buff
 * \param[in] timeout_ms: timeout, in ms
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */
OPERATE_RET tuya_sweeper_send_customize_data_with_buff(IN INT_T client, IN CHAR_T* name , IN INT_T fileLen, IN CHAR_T* fileBuff,IN INT_T timeout_ms);

Send the custom file data to the mobile app.

Parameter Description
client The session handle for the data transmission channel, obtained from the callback during map downloading.
name The name of the custom file.
fileLen The length of the custom file.
fileBuff The content of the custom file.
timeout_ms The timeout for custom file transmission.

tuya_sweeper_set_customize_name

/**
 * \fn tuya_sweeper_set_customize_name
 * \brief send file to app by P2P
 * \param[in] name_info: file name
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */
OPERATE_RET tuya_sweeper_set_customize_name(IN TUYA_SWEEPER_CUSTOMIZE_FILEINFO* name_info);

Send the custom file to the TuyaOS SDK, which must be called after TuyaOS SDK initialization. See the description of TUYA_SWEEPER_CUSTOMIZE_FILEINFO for the request parameters.

tuya_sweeper_stop_send_data_to_app

/**
 * \fn tuya_sweeper_stop_send_data_to_app
 * \brief send file to app by P2P
 * \param[in] client: client handle
 * \return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */
OPERATE_RET tuya_sweeper_stop_send_data_to_app(IN INT_T client);

The device notifies the app of the end of file transmission.

Parameter Description
client The session handle for the data transmission channel, obtained from the callback during map downloading.

tuya_sweeper_p2p_alone_stream_close

/**
 * \fn tuya_sweeper_p2p_alone_stream_close
 * \brief One link is closed on the device
 * \param[in] client: client handle
 * @return OPRT_OK on success. Others on error, please refer to tuya_error_code.h
 */
OPERATE_RET tuya_sweeper_p2p_alone_stream_close(IN INT_T client);

The device proactively disconnects the transmission channel.

Parameter Description
client The session handle for the data transmission channel, obtained from the callback during map downloading.