@ray-js/robot-protocol

@ray-js/robot-protocol中提供扫地机中常用的复杂协议的解码和编码的方法,方法命名大部分都是依据协议中的cmd命令号来命名的,可以以此为依据快速索引。

在该文档中不会涉及具体的协议格式,如需了解,请联系您的客户经理或提工单咨询。

虚拟墙

encodeVirtualWall0x12

将虚拟墙数据编码为特定格式的字符串,适用于0x12/0x13,V1.0.0版本

参数

  • params (对象): 包含以下属性的对象
    • walls (Point[][]): 虚拟墙的端点坐标数组,每个虚拟墙由一组点组成。
    • origin (Point): 地图的原点坐标。
    • mapScale (number, 可选): 地图的缩放比例,默认为 1。
    • version ('0' | '1', 可选): 协议版本版本号,默认为 '1'。

返回值

  • string: 编码后的虚拟墙数据字符串。

示例

const walls = [
  [{ x: 1, y: 2 }, { x: 3, y: 4 }],
  [{ x: 5, y: 6 }, { x: 7, y: 8 }]
];
const origin = { x: 0, y: 0 };
const mapScale = 1;
const version = '1';

const encodedString = encodeVirtualWall0x12({ walls, origin, mapScale, version });
console.log(encodedString);

decodeVirtualWall0x13

从指令中解析获取虚拟墙数据 (0x13) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 包含虚拟墙数据的指令字符串。
    • mapScale (number, 可选): 地图的缩放比例,默认为 1。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • Point[][] | null: 解析后的虚拟墙数据,若指令无效则返回 null。

示例

const command = "your_command_string_here";
const mapScale = 1;
const version = '1';

const walls = decodeVirtualWall0x13({ command, mapScale, version });
console.log(walls);

选区清扫

requestRoomClean0x15

向设备请求选区清扫数据 (0x15) | App ➜ Robot

参数

  • params (对象, 可选): 包含以下属性的对象
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 请求选区清扫数据的指令字符串。

示例

const command = requestRoomClean0x15({ version: '1' });
console.log(command);

encodeRoomClean0x14

设置选区清扫的指令 (0x14) | App ➜ Robot

参数

  • params (对象): 包含以下属性的对象
    • cleanTimes (number): 清扫次数。
    • roomHexIds (string[], 可选): 房间的十六进制 ID 数组。
    • roomIds (number[], 可选): 房间的 ID 数组。
    • mapVersion (0 | 1 | 2, 可选): 地图版本,默认为 2。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 设置选区清扫的指令字符串。

示例

const command = encodeRoomClean0x14({
  cleanTimes: 2,
  roomHexIds: ['1A', '2B'],
  mapVersion: 2,
  version: '1'
});
console.log(command);

decodeRoomClean0x15

从指令中解析获取选区清扫信息 (0x15) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 包含选区清扫信息的指令字符串。
    • mapVersion (0 | 1 | 2, 可选): 地图版本,默认为 2。
    • version ('0' | '1', 可选): 协议版本号,默认为 '1'。

返回值

  • object | null: 解析后的选区清扫信息对象,若指令无效则返回 null。 包含以下属性:
    • cleanTimes (number): 清扫次数。
    • roomIds (number[]): 房间的 ID 数组。
    • roomHexIds (string[]): 房间的十六进制 ID 数组。 若指令无效则返回 null。

示例

const command = "your_command_string_here";
const result = decodeRoomClean0x15({ command, mapVersion: 2, version: '1' });
console.log(result);

requestRoomClean0x57

向设备请求选区清扫数据 (0x57) | App ➜ Robot

参数

  • params (对象, 可选): 包含以下属性的对象
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 请求选区清扫数据的指令字符串。

示例

const command = requestRoomClean0x57({ version: '1' });
console.log(command);

encodeRoomClean0x56

设置选区清扫的指令 (0x56) | App ➜ Robot

参数

  • params (对象): 包含以下属性的对象
    • rooms (Room[]): 房间信息数组,每个房间包含以下属性:
      • roomHexId (string, 可选): 房间的十六进制 ID。
      • roomId (number, 可选): 房间的 ID。
      • cleanTimes (number): 清扫次数。
      • yMop (number): 拖地次数。
      • suction (number): 吸力等级。
      • cistern (number): 水箱等级。
    • mapVersion (0 | 1 | 2, 可选): 地图版本,默认为 2。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 设置选区清扫的指令字符串。

示例

const command = encodeRoomClean0x56({
  rooms: [
    { roomHexId: '1A', cleanTimes: 2, yMop: 1, suction: 3, cistern: 2 },
    { roomId: 2, cleanTimes: 1, yMop: 1, suction: 2, cistern: 1 }
  ],
  mapVersion: 2,
  version: '1'
});
console.log(command);

decodeRoomClean0x57

从指令中解析获取选区清扫信息 (0x57) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 包含选区清扫信息的指令字符串。
    • mapVersion (0 | 1 | 2, 可选): 地图版本,默认为 2。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • Room[] | null: 解析后的选区清扫信息数组,每个房间包含以下属性:
    • roomHexId (string): 房间的十六进制 ID。
    • roomId (number): 房间的 ID。
    • suction (number): 吸力等级。
    • cistern (number): 水箱等级。
    • yMop (number): 拖地次数。
    • cleanTimes (number): 清扫次数。 若指令无效则返回 null。

示例

const command = "your_command_string_here";
const rooms = decodeRoomClean0x57({ command, mapVersion: 2, version: '1' });
console.log(rooms);

划区清扫

requestZoneClean0x3b

向设备请求划区清扫数据 (0x3b) | App ➜ Robot

参数

  • params (对象, 可选): 包含以下属性的对象
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 请求划区清扫数据的指令字符串。

示例

const command = requestZoneClean0x3b({ version: '1' });
console.log(command);

encodeZoneClean0x3a

划区清扫的指令 (0x3a) | App ➜ Robot

参数

  • params (对象): 包含以下属性的对象
    • protocolVersion (1 | 2 | 3): 协议版本。
    • zones (Zone[]): 划区清扫的区域信息数组,每个区域包含以下属性:
      • points (Point[]): 区域的顶点坐标数组。
      • name (string, 可选): 区域名称。
      • advanced (对象, 可选): 高级设置,包含以下属性:
        • id (number): 区域 ID。
        • localSave (number): 本地保存标志。
        • order (number): 清扫顺序。
        • cleanMode (number): 清扫模式。
        • cleanTimes (number): 清扫次数。
        • suction (number): 吸力等级。
        • cistern (number): 水箱等级。
    • origin (Point): 地图的原点坐标。
    • cleanMode (CleanMode, 可选): 清扫模式,默认为 0。
    • suction (Suction, 可选): 吸力等级,默认为 0。
    • cistern (Cistern, 可选): 水箱等级,默认为 0。
    • cleanTimes (number, 可选): 清扫次数,默认为 1。
    • mapScale (number, 可选): 地图的缩放比例,默认为 1。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 划区清扫的指令字符串。

示例

const command = encodeZoneClean0x3a({
  protocolVersion: 3,
  zones: [
    {
      points: [{ x: 10, y: 20 }, { x: 30, y: 40 }, { x: 50, y: 60 }, { x: 70, y: 80 }],
      name: '区域1',
      advanced: {
        id: 1,
        localSave: 1,
        order: 1,
        cleanMode: 1,
        cleanTimes: 2,
        suction: 3,
        cistern: 2
      }
    }
  ],
  origin: { x: 0, y: 0 },
  mapScale: 1,
  version: '1'
});
console.log(command);

decodeZoneClean0x3b

从指令中解析获取划区清扫数据 (0x3b) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 包含划区清扫数据的指令字符串。
    • mapScale (number, 可选): 地图的缩放比例,默认为 1。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • object | null: 解析后的划区清扫数据对象,包含以下属性:
    • protocolVersion (1 | 2 | 3): 协议版本。
    • zones (Zone[]): 划区清扫的区域信息数组,每个区域包含以下属性:
      • points (Point[]): 区域的顶点坐标数组。
      • name (string): 区域名称。
      • advanced (对象, 可选): 高级设置,包含以下属性(仅在协议版本 3 时返回):
        • id (number): 区域 ID。
        • localSave (number): 本地保存标志。
        • order (number): 清扫顺序。
        • cleanMode (number): 清扫模式。
        • cleanTimes (number): 清扫次数。
        • suction (number): 吸力等级。
        • cistern (number): 水箱等级。
    • cleanMode (CleanMode, 可选): 清扫模式(仅在协议版本 2 时返回)。
    • suction (Suction, 可选): 吸力等级(仅在协议版本 2 时返回)。
    • cistern (Cistern, 可选): 水箱等级(仅在协议版本 2 时返回)。
    • cleanTimes (number, 可选): 清扫次数(仅在协议版本 2 时返回)。 若指令无效则返回 null。

示例

const command = "your_command_string_here";
const result = decodeZoneClean0x3b({ command, mapScale: 1, version: '1' });
console.log(result);

定点清扫

requestSpotClean0x17

向设备请求定点清扫数据 (0x17) | App ➜ Robot

参数

  • params (对象, 可选): 包含以下属性的对象
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 请求定点清扫数据的指令字符串。

示例

const command = requestSpotClean0x17({ version: '1' });
console.log(command);

encodeSpotClean0x16

设置定点清扫的指令 (0x16) | App ➜ Robot

参数

  • params (对象): 包含以下属性的对象
    • point (Point): 定点清扫的目标点坐标。
    • origin (Point): 地图的原点坐标。
    • mapScale (number, 可选): 地图的缩放比例,默认为 1。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 设置定点清扫的指令字符串。

示例

const command = encodeSpotClean0x16({
  point: { x: 10, y: 20 },
  origin: { x: 0, y: 0 },
  mapScale: 1,
  version: '1'
});
console.log(command);

decodeSpotClean0x17

从指令中解析获取定点清扫数据 (0x17) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 包含定点清扫数据的指令字符串。
    • mapScale (number, 可选): 地图的缩放比例,默认为 1。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • object | null: 解析后的定点清扫信息对象,包含以下属性:
    • point (Point): 定点清扫的目标点坐标。 若指令无效则返回 null。

示例

const command = "your_command_string_here";
const result = decodeSpotClean0x17({ command, mapScale: 1, version: '1' });
console.log(result)

requestSpotClean0x3f

向设备请求定点清扫数据 (0x3f) | App ➜ Robot

参数

  • params (对象, 可选): 包含以下属性的对象
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 请求定点清扫数据的指令字符串。

示例

const command = requestSpotClean0x3f({ version: '1' });
console.log(command);

encodeSpotClean0x3e

设置定点清扫的指令 (0x3e) | App ➜ Robot

参数

  • params (对象): 包含以下属性的对象
    • protocolVersion (1 | 2): 协议版本。
    • points (Point[]): 定点清扫的目标点坐标数组。
    • origin (Point): 地图的原点坐标。
    • cleanMode (CleanMode, 可选): 清扫模式。
    • suction (Suction, 可选): 吸力等级。
    • cistern (Cistern, 可选): 水箱等级。
    • cleanTimes (number, 可选): 清扫次数。
    • mapScale (number, 可选): 地图的缩放比例,默认为 1。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 设置定点清扫的指令字符串。

示例

const command = encodeSpotClean0x3e({
  protocolVersion: 2,
  points: [{ x: 10, y: 20 }, { x: 30, y: 40 }],
  origin: { x: 0, y: 0 },
  mapScale: 1,
  version: '1'
});
console.log(command);

decodeSpotClean0x3f

从指令中解析获取定点清扫数据 (0x3f) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 包含定点清扫数据的指令字符串。
    • mapScale (number, 可选): 地图的缩放比例,默认为 1。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • object | null: 解析后的定点清扫信息对象,包含以下属性:
    • protocolVersion (1 | 2): 协议版本。
    • points (Point[]): 定点清扫的目标点坐标数组。
    • cleanMode (CleanMode, 可选): 清扫模式(仅在协议版本 1 时返回)。
    • suction (Suction, 可选): 吸力等级(仅在协议版本 1 时返回)。
    • cistern (Cistern, 可选): 水箱等级(仅在协议版本 1 时返回)。
    • cleanTimes (number, 可选): 清扫次数(仅在协议版本 1 时返回)。 若指令无效则返回 null。

示例

const command = "your_command_string_here";
const result = decodeSpotClean0x3f({ command, mapScale: 1, version: '1' });
console.log(result);

禁区设置

requestVirtualArea0x39

向设备请求禁区数据 (0x39) | App ➜ Robot

参数

  • params (对象, 可选): 包含以下属性的对象
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 请求禁区数据的指令字符串。

示例

const command = requestVirtualArea0x39({ version: '1' });
console.log(command);

encodeVirtualArea0x38

设置禁区的指令 (0x38) | App ➜ Robot

参数

  • params (对象): 包含以下属性的对象
    • protocolVersion (1 | 2): 协议版本。
    • virtualAreas (VirtualArea[]): 禁区信息数组,每个禁区包含以下属性:
      • points (Point[]): 禁区的顶点坐标数组。
      • mode (number): 禁区模式。
      • name (string, 可选): 禁区名称。
    • origin (Point): 地图的原点坐标。
    • mapScale (number, 可选): 地图的缩放比例,默认为 1。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 设置禁区的指令字符串。

示例

const command = encodeVirtualArea0x38({
  protocolVersion: 2,
  virtualAreas: [
    {
      points: [{ x: 10, y: 20 }, { x: 30, y: 40 }, { x: 50, y: 60 }, { x: 70, y: 80 }],
      mode: 1,
      name: '禁区1'
    }
  ],
  origin: { x: 0, y: 0 },
  mapScale: 1,
  version: '1'
});
console.log(command);

decodeVirtualArea0x39

从指令中解析获取禁区数据 (0x39) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 包含禁区数据的指令字符串。
    • mapScale (number, 可选): 地图的缩放比例,默认为 1。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • object | null: 解析后的禁区数据对象,包含以下属性:
    • protocolVersion (1 | 2): 协议版本。
    • virtualAreas (VirtualArea[]): 禁区信息数组,每个禁区包含以下属性:
      • mode (number): 禁区模式。
      • points (Point[]): 禁区的顶点坐标数组。
      • name (string): 禁区名称。 若指令无效则返回 null。

示例

const command = "your_command_string_here";
const result = decodeVirtualArea0x39({ command, mapScale: 1, version: '1' });
console.log(result);

分区分隔

decodeVirtualArea0x39

从指令中解析获取禁区数据 (0x39) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 包含禁区数据的指令字符串。
    • mapScale (number, 可选): 地图的缩放比例,默认为 1。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • object | null: 解析后的禁区数据对象,包含以下属性:
    • protocolVersion (1 | 2): 协议版本。
    • virtualAreas (VirtualArea[]): 禁区信息数组,每个禁区包含以下属性:
      • mode (number): 禁区模式。
      • points (Point[]): 禁区的顶点坐标数组。
      • name (string): 禁区名称。 若指令无效则返回 null。

示例

const command = "your_command_string_here";
const result = decodeVirtualArea0x39({ command, mapScale: 1, version: '1' });
console.log(result);

decodePartitionDivision0x1d

解析设备响应的分区分割结果 (0x1d) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 包含分区分割结果的指令字符串。
    • mapScale (number, 可选): 地图的缩放比例,默认为 1。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • object | null: 解析后的分区分割结果对象,包含以下属性:
    • ret (number): 返回码。
    • success (boolean): 是否成功。
    • roomId (number): 房间的 ID。
    • points (Point[]): 分区分割的顶点坐标数组。 若指令无效则返回 null。

示例

const command = "your_command_string_here";
const result = decodePartitionDivision0x1d({ command, mapScale: 1, version: '1' });
console.log(result);

设置清扫顺序

requestRoomOrder0x26

向设备请求房间清扫顺序数据 (0x26) | App ➜ Robot

参数

  • params (对象, 可选): 包含以下属性的对象
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 请求房间清扫顺序数据的指令字符串。

示例

const command = requestRoomOrder0x26({ version: '1' });
console.log(command);

encodeRoomOrder0x26

编码房间顺序信息 (0x26 / 0x27) | App ➜ Robot

参数

  • params (对象): 包含以下属性的对象
    • roomIdHexs (string[]): 房间ID的数组,每个房间ID是一个字符串。
    • mapVersion (0 | 1 | 2): 地图版本。
    • version ('0' | '1', 可选): 编码版本号,默认为 '1'。

返回值

string: 编码后的房间顺序信息字符串。

示例

const command = encodeRoomOrder0x26({
  roomIdHexs: ['1A', '2B', '3C'],
  mapVersion: 1,
  version: '1'
});
console.log(command);

decodeRoomOrder0x27

解码房间清扫顺序信息 (0x27) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 待解码的命令字符串。
    • version ('0' | '1', 可选): 命令字符串的版本信息,默认为 '1'。

返回值

  • number[] | null: 解码后的房间订单信息数组,如果解码失败则返回 null。

示例

const command = "your_command_string_here";
const result = decodeRoomOrder0x27({ command, version: '1' });
console.log(result);

分区分隔

encodePartitionDivision0x1c

向设备下发的分区分割指令 (0x1c) | App ➜ Robot

参数

  • params (对象): 包含以下属性的对象
    • roomId (number): 房间的 ID。
    • points (Point[]): 分区划分的顶点坐标数组。
    • origin (Point): 地图的原点坐标。
    • mapScale (number, 可选): 地图的缩放比例,默认为 1。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 设置分区划分的指令字符串。

示例

const command = encodePartitionDivision0x1c({
  roomId: 1,
  points: [{ x: 10, y: 20 }, { x: 30, y: 40 }],
  origin: { x: 0, y: 0 },
  mapScale: 1,
  version: '1'
});
console.log(command);

decodePartitionDivision0x1d

解析设备响应的分区分割结果 (0x1d) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 包含分区分割结果的指令字符串。
    • mapScale (number, 可选): 地图的缩放比例,默认为 1。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • object | null: 解析后的分区分割结果对象,包含以下属性:
    • ret (number): 返回码。
    • success (boolean): 是否成功。
    • roomId (number): 房间的 ID。
    • points (Point[]): 分区分割的顶点坐标数组。 若指令无效则返回 null。

示例

const command = "your_command_string_here";
const result = decodePartitionDivision0x1d({ command, mapScale: 1, version: '1' });
console.log(result);

分区合并

encodePartitionMerge0x1e

向设备下发的分区合并指令 (0x1e) | App ➜ Robot

参数

  • params (对象): 包含以下属性的对象
    • roomIds (number[]): 要合并的房间 ID 数组。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 设置分区合并的指令字符串。

示例

const command = encodePartitionMerge0x1e({
  roomIds: [1, 2, 3],
  version: '1'
});
console.log(command);

decodePartitionMerge1f

解析设备响应的分区合并结果 (0x1f) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 包含分区合并结果的指令字符串。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • object | null: 解析后的分区合并结果对象,包含以下属性:
    • ret (number): 返回码。
    • success (boolean): 是否成功。 若指令无效则返回 null。

示例

const command = "your_command_string_here";
const result = decodePartitionMerge1f({ command, version: '1' });
console.log(result);

设置房间名称

encodeSetRoomName0x24

向设备下发的设置房间名称指令 (0x24) | App ➜ Robot

参数

  • params (对象): 包含以下属性的对象
    • rooms (Room[]): 房间信息数组,每个房间包含以下属性:
      • roomHexId (string, 可选): 房间的十六进制 ID。
      • roomId (number, 可选): 房间的 ID。
      • name (string, 可选): 房间名称。
    • mapVersion (0 | 1 | 2, 可选): 地图版本,默认为 2。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 设置房间名称的指令字符串。

示例

const command = encodeSetRoomName0x24({
  rooms: [
    { roomHexId: '1A', name: '客厅' },
    { roomId: 2, name: '卧室' }
  ],
  mapVersion: 2,
  version: '1'
});
console.log(command);

decodeSetRoomName0x25

解析设备响应的设置房间名称结果 (0x25) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 包含设置房间名称结果的指令字符串。
    • mapVersion (0 | 1 | 2, 可选): 地图版本,默认为 2。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • Room[] | null: 解析后的房间信息数组,每个房间包含以下属性:
    • roomHexId (string): 房间的十六进制 ID。
    • roomId (number): 房间的 ID。
    • name (string): 房间名称。 若指令无效则返回 null。

示例

const command = "your_command_string_here";
const rooms = decodeSetRoomName0x25({ command, mapVersion: 2, version: '1' });
console.log(rooms);

设置房间属性

encodeSetRoomProperty0x22

向设备下发的设置房间属性指令 (0x22) | App ➜ Robot

参数

  • params (对象): 包含以下属性的对象
    • rooms (Room[]): 房间信息数组,每个房间包含以下属性:
      • roomHexId (string, 可选): 房间的十六进制 ID。
      • roomId (number, 可选): 房间的 ID。
      • cleanTimes (number): 清扫次数。
      • yMop (number): 拖地次数。
      • suction (number): 吸力等级。
      • cistern (number): 水箱等级。
    • mapVersion (0 | 1 | 2, 可选): 地图版本,默认为 2。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 设置房间属性的指令字符串。

示例

const command = encodeSetRoomProperty0x22({
  rooms: [
    { roomHexId: '1A', cleanTimes: 2, yMop: 1, suction: 3, cistern: 2 },
    { roomId: 2, cleanTimes: 1, yMop: 1, suction: 2, cistern: 1 }
  ],
  mapVersion: 2,
  version: '1'
});
console.log(command);

decodeSetRoomProperty0x23

解析设备响应的设置房间属性结果 (0x23) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 包含设置房间属性结果的指令字符串。
    • mapVersion (0 | 1 | 2, 可选): 地图版本,默认为 2。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • Room[] | null: 解析后的房间信息数组,每个房间包含以下属性:
    • roomHexId (string): 房间的十六进制 ID。
    • roomId (number): 房间的 ID。
    • suction (number): 吸力等级。
    • cistern (number): 水箱等级。
    • yMop (number): 拖地次数。
    • cleanTimes (number): 清扫次数。 若指令无效则返回 null。

示例

const command = "your_command_string_here";
const rooms = decodeSetRoomProperty0x23({ command, mapVersion: 2, version: '1' });
console.log(rooms);

勿扰模式

encodeDoNotDisturb0x40

设置勿扰时间的指令 (0x40) | App ➜ Robot

参数

  • params (对象): 包含以下属性的对象
    • enable (boolean): 是否启用勿扰模式。
    • startHour (number): 勿扰模式开始的小时。
    • startMinute (number): 勿扰模式开始的分钟。
    • endHour (number): 勿扰模式结束的小时。
    • endMinute (number): 勿扰模式结束的分钟。
    • timeZone (number, 可选): 时区,默认为当前时区。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 设置勿扰时间的指令字符串。

示例

const command = encodeDoNotDisturb0x40({
  enable: true,
  startHour: 22,
  startMinute: 0,
  endHour: 6,
  endMinute: 0,
  timeZone: 8,
  version: '1'
});
console.log(command);

decodeDoNotDisturb0x41

从指令中解析获取勿扰时间数据 (0x41) | Robot ➜ App

参数

  • params (对象): 包含以下属性的对象
    • command (string): 包含勿扰时间数据的指令字符串。
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • object | null: 解析后的勿扰时间数据对象,包含以下属性:
    • enable (boolean): 是否启用勿扰模式。
    • timeZone (number): 时区。
    • startHour (number): 勿扰模式开始的小时。
    • startMinute (number): 勿扰模式开始的分钟。
    • endHour (number): 勿扰模式结束的小时。
    • endMinute (number): 勿扰模式结束的分钟。 若指令无效则返回 null。

示例

const command = "your_command_string_here";
const result = decodeDoNotDisturb0x41({ command, version: '1' });
console.log(result);

重置地图

encodeResetMap0x42

向设备下发的快速建图指令 (0x42) | App ➜ Robot

参数

  • params (对象, 可选): 包含以下属性的对象
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 快速建图的指令字符串。

示例

const command = encodeResetMap0x42({ version: '1' });
console.log(command);

快速建图

encodeQuickMap0x3c

向设备下发的快速建图指令 (0x3c) | App ➜ Robot

参数

  • params (对象, 可选): 包含以下属性的对象
    • version ('0' | '1', 可选): 版本号,默认为 '1'。

返回值

  • string: 快速建图的指令字符串。

示例

const command = encodeQuickMap0x3c({ version: '1' });
console.log(command);