@ray-js/robot-data-stream 0.0.13-beta-7 → 0.0.13-beta-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/index.d.ts +2 -12
- package/lib/api/index.js +1 -172
- package/lib/api/p2pApi.d.ts +8 -27
- package/lib/api/p2pApi.js +271 -169
- package/lib/api/sweeperP2p.d.ts +55 -21
- package/lib/api/sweeperP2p.js +376 -246
- package/lib/constant.d.ts +0 -52
- package/lib/constant.js +0 -54
- package/lib/index.d.ts +12 -1
- package/lib/index.js +187 -2
- package/lib/mqtt/createCommonOptions.d.ts +15 -56
- package/lib/mqtt/createCommonOptions.js +8 -44
- package/lib/mqtt/mqttProvider.d.ts +15 -23
- package/lib/mqtt/mqttProvider.js +26 -63
- package/lib/mqtt/myError.d.ts +4 -0
- package/lib/mqtt/myError.js +6 -0
- package/lib/mqtt/promise.js +3 -8
- package/lib/mqtt/type/index.d.ts +0 -9
- package/lib/mqtt/type/index.js +0 -8
- package/lib/mqtt/type/requestType.d.ts +0 -3
- package/lib/mqtt/type/requestType.js +0 -4
- package/lib/mqtt/useDevInfo.d.ts +7 -2
- package/lib/mqtt/useDevInfo.js +9 -25
- package/lib/mqtt/useHistoryMap.d.ts +21 -13
- package/lib/mqtt/useHistoryMap.js +32 -82
- package/lib/mqtt/usePartDivision.d.ts +7 -5
- package/lib/mqtt/usePartDivision.js +16 -41
- package/lib/mqtt/usePartMerge.d.ts +7 -5
- package/lib/mqtt/usePartMerge.js +18 -36
- package/lib/mqtt/usePassword.js +28 -59
- package/lib/mqtt/useQuiteHours.d.ts +24 -9
- package/lib/mqtt/useQuiteHours.js +52 -95
- package/lib/mqtt/useResetMap.d.ts +7 -10
- package/lib/mqtt/useResetMap.js +11 -40
- package/lib/mqtt/useRoomProperty.js +16 -23
- package/lib/mqtt/useSchedule.d.ts +4 -17
- package/lib/mqtt/useSchedule.js +49 -101
- package/lib/mqtt/useSelectRoomClean.d.ts +16 -20
- package/lib/mqtt/useSelectRoomClean.js +49 -145
- package/lib/mqtt/useSpotClean.d.ts +3 -3
- package/lib/mqtt/useSpotClean.js +51 -71
- package/lib/mqtt/useVirtualArea.d.ts +9 -6
- package/lib/mqtt/useVirtualArea.js +42 -112
- package/lib/mqtt/useVirtualWall.d.ts +10 -13
- package/lib/mqtt/useVirtualWall.js +34 -97
- package/lib/mqtt/useVoice.d.ts +6 -3
- package/lib/mqtt/useVoice.js +33 -73
- package/lib/mqtt/useWifiMap.js +18 -34
- package/lib/mqtt/useZoneClean.d.ts +13 -13
- package/lib/mqtt/useZoneClean.js +76 -149
- package/lib/utils/index.d.ts +7 -18
- package/lib/utils/index.js +13 -15
- package/package.json +1 -1
- package/lib/ttt/index.d.ts +0 -153
- package/lib/ttt/index.js +0 -458
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
2
|
import "core-js/modules/esnext.iterator.for-each.js";
|
|
3
|
-
import "core-js/modules/esnext.iterator.map.js";
|
|
4
3
|
// 添加禁区
|
|
5
4
|
import { useContext } from 'react';
|
|
6
5
|
import { createSetCommonParams } from './createCommonOptions';
|
|
@@ -9,9 +8,6 @@ import { VirtualAreaEnum } from './type';
|
|
|
9
8
|
import { SingletonContext } from './mqttProvider';
|
|
10
9
|
import { encodeVirtualArea0x1a, requestVirtualArea0x1b } from '@ray-js/robot-protocol';
|
|
11
10
|
import { pointsToString } from '../utils';
|
|
12
|
-
|
|
13
|
-
// 虚拟区域响应类型
|
|
14
|
-
|
|
15
11
|
// 禁区
|
|
16
12
|
|
|
17
13
|
export const useVirtualArea = devId => {
|
|
@@ -29,132 +25,66 @@ export const useVirtualArea = devId => {
|
|
|
29
25
|
/**
|
|
30
26
|
* 设置虚拟区域数据
|
|
31
27
|
* @param message 包含虚拟区域设置参数的对象
|
|
32
|
-
* @param message.
|
|
33
|
-
* @param message.
|
|
28
|
+
* @param message.polygons 多边形数组,每个元素为一个多边形的坐标字符串
|
|
29
|
+
* @param message.names 名称数组,每个元素为一个区域的名称
|
|
30
|
+
* @param message.modes 模式数组,每个元素为一个区域的模式,0:全禁,1:禁扫,2:禁拖
|
|
31
|
+
* @param message.num 虚拟区域的数量
|
|
34
32
|
* @returns Promise<VirtualAreaResponse> 响应结果
|
|
35
33
|
*/
|
|
36
34
|
|
|
37
35
|
return {
|
|
38
36
|
requestVirtualArea: () => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
reqType: VirtualAreaEnum.query
|
|
44
|
-
});
|
|
45
|
-
ty.device.sendMqttMessage(params);
|
|
46
|
-
const {
|
|
47
|
-
taskId
|
|
48
|
-
} = params.message;
|
|
49
|
-
return normalResolve(VirtualAreaEnum.query, taskId);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// 非 MQTT 模式:使用命令传输
|
|
53
|
-
devices.common.model.actions.command_trans.set(requestVirtualArea0x1b({
|
|
54
|
-
version: commandVersion
|
|
55
|
-
}));
|
|
56
|
-
|
|
57
|
-
// 非 MQTT 模式下无法立即获取响应数据,返回默认响应
|
|
58
|
-
return Promise.resolve({
|
|
59
|
-
success: true,
|
|
60
|
-
errCode: 0,
|
|
61
|
-
reqType: VirtualAreaEnum.query,
|
|
62
|
-
version: commandVersion,
|
|
63
|
-
taskId: `${Date.now()}`,
|
|
64
|
-
num: 0,
|
|
65
|
-
modes: [],
|
|
66
|
-
polygons: [],
|
|
67
|
-
names: [],
|
|
68
|
-
mapId: 0
|
|
37
|
+
if (useMqtt) {
|
|
38
|
+
const params = createSetCommonParams({
|
|
39
|
+
deviceId: devId,
|
|
40
|
+
reqType: VirtualAreaEnum.query
|
|
69
41
|
});
|
|
70
|
-
|
|
71
|
-
return
|
|
42
|
+
ty.device.sendMqttMessage(params);
|
|
43
|
+
return normalResolve(VirtualAreaEnum.query, params.message.taskId);
|
|
72
44
|
}
|
|
45
|
+
return devices.common.model.actions.command_trans.set(requestVirtualArea0x1b({
|
|
46
|
+
version: commandVersion
|
|
47
|
+
}));
|
|
73
48
|
},
|
|
74
49
|
setVirtualArea: _ref => {
|
|
75
50
|
let {
|
|
76
51
|
data,
|
|
77
52
|
origin
|
|
78
53
|
} = _ref;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
throw new Error('origin is required and must be a valid Point object with x and y properties');
|
|
85
|
-
}
|
|
86
|
-
try {
|
|
87
|
-
if (useMqtt) {
|
|
88
|
-
const names = [];
|
|
89
|
-
const modes = [];
|
|
90
|
-
const polygons = [];
|
|
91
|
-
data.forEach(_ref2 => {
|
|
92
|
-
let {
|
|
93
|
-
points,
|
|
94
|
-
name,
|
|
95
|
-
mode
|
|
96
|
-
} = _ref2;
|
|
97
|
-
names.push(name);
|
|
98
|
-
modes.push(mode);
|
|
99
|
-
polygons.push(pointsToString(points, origin));
|
|
100
|
-
});
|
|
101
|
-
const params = createSetCommonParams({
|
|
102
|
-
deviceId: devId,
|
|
103
|
-
reqType: VirtualAreaEnum.set,
|
|
104
|
-
message: {
|
|
105
|
-
polygons,
|
|
106
|
-
num: data.length,
|
|
107
|
-
modes: modes,
|
|
108
|
-
names: names
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
ty.device.sendMqttMessage(params);
|
|
112
|
-
const {
|
|
113
|
-
taskId
|
|
114
|
-
} = params.message;
|
|
115
|
-
return normalResolve(VirtualAreaEnum.query, taskId);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// 非 MQTT 模式:使用命令传输
|
|
119
|
-
const command = encodeVirtualArea0x1a({
|
|
120
|
-
version: commandVersion,
|
|
121
|
-
origin,
|
|
122
|
-
virtualAreas: data
|
|
123
|
-
});
|
|
124
|
-
devices.common.model.actions.command_trans.set(command);
|
|
125
|
-
const names = data.map(_ref3 => {
|
|
126
|
-
let {
|
|
127
|
-
name
|
|
128
|
-
} = _ref3;
|
|
129
|
-
return name;
|
|
130
|
-
});
|
|
131
|
-
const modes = data.map(_ref4 => {
|
|
54
|
+
if (useMqtt) {
|
|
55
|
+
const names = [];
|
|
56
|
+
const modes = [];
|
|
57
|
+
const polygons = [];
|
|
58
|
+
data.forEach(_ref2 => {
|
|
132
59
|
let {
|
|
60
|
+
points,
|
|
61
|
+
name,
|
|
133
62
|
mode
|
|
134
|
-
} =
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
let {
|
|
139
|
-
points
|
|
140
|
-
} = _ref5;
|
|
141
|
-
return pointsToString(points, origin);
|
|
63
|
+
} = _ref2;
|
|
64
|
+
names.push(name);
|
|
65
|
+
modes.push(mode);
|
|
66
|
+
polygons.push(pointsToString(points, origin));
|
|
142
67
|
});
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
names,
|
|
153
|
-
mapId: 0
|
|
68
|
+
const params = createSetCommonParams({
|
|
69
|
+
deviceId: devId,
|
|
70
|
+
reqType: VirtualAreaEnum.set,
|
|
71
|
+
message: {
|
|
72
|
+
polygons,
|
|
73
|
+
num: data.length,
|
|
74
|
+
modes: modes,
|
|
75
|
+
names: names
|
|
76
|
+
}
|
|
154
77
|
});
|
|
155
|
-
|
|
156
|
-
|
|
78
|
+
ty.device.sendMqttMessage(params);
|
|
79
|
+
return normalResolve(VirtualAreaEnum.query, params.message.taskId);
|
|
157
80
|
}
|
|
81
|
+
const command = encodeVirtualArea0x1a({
|
|
82
|
+
version: commandVersion,
|
|
83
|
+
origin,
|
|
84
|
+
virtualAreas: data
|
|
85
|
+
});
|
|
86
|
+
devices.common.model.actions.command_trans.set(command);
|
|
87
|
+
return Promise.resolve();
|
|
158
88
|
}
|
|
159
89
|
};
|
|
160
90
|
};
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import { BaseResponse, VirtualWallEnum } from './type';
|
|
2
1
|
import { Point } from '@ray-js/robot-protocol';
|
|
3
|
-
|
|
4
|
-
reqType: VirtualWallEnum.query;
|
|
2
|
+
type Response = {
|
|
5
3
|
modes: number[];
|
|
4
|
+
success: boolean;
|
|
5
|
+
errCode: number;
|
|
6
6
|
num: number;
|
|
7
|
+
reqType: 'virtualWallQry';
|
|
7
8
|
mapId: number;
|
|
9
|
+
version: string;
|
|
10
|
+
taskId: string;
|
|
8
11
|
points: string[];
|
|
9
|
-
}
|
|
10
|
-
|
|
12
|
+
};
|
|
13
|
+
type TRequestVirtualWall = () => Promise<Response>;
|
|
14
|
+
type TSetVirtualWall = (params: {
|
|
11
15
|
data: Point[][];
|
|
12
16
|
origin: Point;
|
|
13
|
-
}
|
|
14
|
-
type TRequestVirtualWall = () => Promise<VirtualWallResponse>;
|
|
15
|
-
type TSetVirtualWall = (params: SetVirtualWallParams) => Promise<VirtualWallResponse>;
|
|
16
|
-
/**
|
|
17
|
-
* 自定义 Hook,用于虚拟墙管理
|
|
18
|
-
* @param devId 设备ID
|
|
19
|
-
* @returns 包含 requestVirtualWall 和 setVirtualWall 函数的对象
|
|
20
|
-
*/
|
|
17
|
+
}) => Promise<Response> | Promise<void>;
|
|
21
18
|
export declare const useVirtualWall: (devId: string) => {
|
|
22
19
|
requestVirtualWall: TRequestVirtualWall;
|
|
23
20
|
setVirtualWall: TSetVirtualWall;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "core-js/modules/esnext.iterator.map.js";
|
|
2
2
|
// 虚拟墙数据
|
|
3
|
+
|
|
3
4
|
import { useContext } from 'react';
|
|
4
5
|
import { createSetCommonParams } from './createCommonOptions';
|
|
5
6
|
import { normalResolve } from './promise';
|
|
@@ -7,20 +8,6 @@ import { VirtualWallEnum } from './type';
|
|
|
7
8
|
import { SingletonContext } from './mqttProvider';
|
|
8
9
|
import { encodeVirtualWall0x12, requestVirtualWall0x13 } from '@ray-js/robot-protocol';
|
|
9
10
|
import { pointsToString } from '../utils';
|
|
10
|
-
|
|
11
|
-
// 虚拟墙响应类型
|
|
12
|
-
|
|
13
|
-
// 设置虚拟墙参数类型
|
|
14
|
-
|
|
15
|
-
// 请求虚拟墙函数类型定义
|
|
16
|
-
|
|
17
|
-
// 设置虚拟墙函数类型定义
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 自定义 Hook,用于虚拟墙管理
|
|
21
|
-
* @param devId 设备ID
|
|
22
|
-
* @returns 包含 requestVirtualWall 和 setVirtualWall 函数的对象
|
|
23
|
-
*/
|
|
24
11
|
export const useVirtualWall = devId => {
|
|
25
12
|
const {
|
|
26
13
|
useMqtt,
|
|
@@ -28,106 +15,56 @@ export const useVirtualWall = devId => {
|
|
|
28
15
|
devices
|
|
29
16
|
} = useContext(SingletonContext);
|
|
30
17
|
|
|
31
|
-
|
|
32
|
-
* 请求虚拟墙数据
|
|
33
|
-
* @returns Promise<VirtualWallResponse> 响应结果
|
|
34
|
-
*/
|
|
18
|
+
// 请求虚拟墙数据
|
|
35
19
|
|
|
36
20
|
/**
|
|
37
21
|
* 设置虚拟墙数据
|
|
38
|
-
* @param
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
41
|
-
* @
|
|
22
|
+
* @param message 包含虚拟墙设置参数的对象
|
|
23
|
+
* @param message.points 虚拟墙的点数组
|
|
24
|
+
* @param message.num 虚拟墙的数量(可选)
|
|
25
|
+
* @param message.mode 虚拟墙的模式数组(可选)
|
|
26
|
+
* @returns Promise<Response> 响应结果
|
|
42
27
|
*/
|
|
43
28
|
|
|
44
29
|
return {
|
|
45
30
|
requestVirtualWall: () => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
reqType: VirtualWallEnum.query
|
|
51
|
-
});
|
|
52
|
-
ty.device.sendMqttMessage(params);
|
|
53
|
-
const {
|
|
54
|
-
taskId
|
|
55
|
-
} = params.message;
|
|
56
|
-
return normalResolve(VirtualWallEnum.query, taskId);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// 非 MQTT 模式:使用命令传输
|
|
60
|
-
devices.common.model.actions.command_trans.set(requestVirtualWall0x13({
|
|
61
|
-
version: commandVersion
|
|
62
|
-
}));
|
|
63
|
-
|
|
64
|
-
// 非 MQTT 模式下无法立即获取响应数据,返回默认响应
|
|
65
|
-
return Promise.resolve({
|
|
66
|
-
success: true,
|
|
67
|
-
errCode: 0,
|
|
68
|
-
reqType: VirtualWallEnum.query,
|
|
69
|
-
version: commandVersion,
|
|
70
|
-
taskId: `${Date.now()}`,
|
|
71
|
-
num: 0,
|
|
72
|
-
modes: [],
|
|
73
|
-
points: [],
|
|
74
|
-
mapId: 0
|
|
31
|
+
if (useMqtt) {
|
|
32
|
+
const params = createSetCommonParams({
|
|
33
|
+
deviceId: devId,
|
|
34
|
+
reqType: VirtualWallEnum.query
|
|
75
35
|
});
|
|
76
|
-
|
|
77
|
-
return
|
|
36
|
+
ty.device.sendMqttMessage(params);
|
|
37
|
+
return normalResolve(VirtualWallEnum.query, params.message.taskId);
|
|
78
38
|
}
|
|
39
|
+
return devices.common.model.actions.command_trans.set(requestVirtualWall0x13({
|
|
40
|
+
version: commandVersion
|
|
41
|
+
}));
|
|
79
42
|
},
|
|
80
43
|
setVirtualWall: _ref => {
|
|
81
44
|
let {
|
|
82
45
|
data,
|
|
83
46
|
origin
|
|
84
47
|
} = _ref;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const params = createSetCommonParams({
|
|
95
|
-
deviceId: devId,
|
|
96
|
-
reqType: VirtualWallEnum.set,
|
|
97
|
-
message: {
|
|
98
|
-
points: data.map(points => pointsToString(points, origin)),
|
|
99
|
-
num: data.length,
|
|
100
|
-
mode: new Array(data.length).fill('0')
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
ty.device.sendMqttMessage(params);
|
|
104
|
-
const {
|
|
105
|
-
taskId
|
|
106
|
-
} = params.message;
|
|
107
|
-
return normalResolve(VirtualWallEnum.query, taskId);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
// 非 MQTT 模式:使用命令传输
|
|
111
|
-
const command = encodeVirtualWall0x12({
|
|
112
|
-
version: commandVersion,
|
|
113
|
-
origin,
|
|
114
|
-
walls: data
|
|
115
|
-
});
|
|
116
|
-
devices.common.model.actions.command_trans.set(command);
|
|
117
|
-
return Promise.resolve({
|
|
118
|
-
success: true,
|
|
119
|
-
errCode: 0,
|
|
120
|
-
reqType: VirtualWallEnum.query,
|
|
121
|
-
version: commandVersion,
|
|
122
|
-
taskId: `${Date.now()}`,
|
|
123
|
-
num: data.length,
|
|
124
|
-
modes: new Array(data.length).fill(0),
|
|
125
|
-
points: data.map(points => pointsToString(points, origin)),
|
|
126
|
-
mapId: 0
|
|
48
|
+
if (useMqtt) {
|
|
49
|
+
const params = createSetCommonParams({
|
|
50
|
+
deviceId: devId,
|
|
51
|
+
reqType: VirtualWallEnum.set,
|
|
52
|
+
message: {
|
|
53
|
+
points: data.map(points => pointsToString(points, origin)),
|
|
54
|
+
num: data.length,
|
|
55
|
+
mode: new Array(data.length).fill('0')
|
|
56
|
+
}
|
|
127
57
|
});
|
|
128
|
-
|
|
129
|
-
|
|
58
|
+
ty.device.sendMqttMessage(params);
|
|
59
|
+
return normalResolve(VirtualWallEnum.query, params.message.taskId);
|
|
130
60
|
}
|
|
61
|
+
const command = encodeVirtualWall0x12({
|
|
62
|
+
version: commandVersion,
|
|
63
|
+
origin,
|
|
64
|
+
walls: data
|
|
65
|
+
});
|
|
66
|
+
devices.common.model.actions.command_trans.set(command);
|
|
67
|
+
return Promise.resolve();
|
|
131
68
|
}
|
|
132
69
|
};
|
|
133
70
|
};
|
package/lib/mqtt/useVoice.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
interface VoiceLanguageResponse {
|
|
2
|
+
reqType: string;
|
|
3
|
+
version: string;
|
|
4
4
|
id: number;
|
|
5
5
|
schedule: number;
|
|
6
6
|
status: number;
|
|
7
|
+
success: boolean;
|
|
8
|
+
errCode: number;
|
|
9
|
+
taskId: string;
|
|
7
10
|
}
|
|
8
11
|
type TSetVoice = (message: {
|
|
9
12
|
id: number;
|
package/lib/mqtt/useVoice.js
CHANGED
|
@@ -7,8 +7,6 @@ import { useContext } from 'react';
|
|
|
7
7
|
import { SingletonContext } from './mqttProvider';
|
|
8
8
|
import { encodeVoice0x34 } from '@ray-js/robot-protocol';
|
|
9
9
|
|
|
10
|
-
// 语音语言响应类型
|
|
11
|
-
|
|
12
10
|
// 设置语音语言函数类型定义
|
|
13
11
|
|
|
14
12
|
// 请求当前使用的机器语音
|
|
@@ -21,100 +19,62 @@ import { encodeVoice0x34 } from '@ray-js/robot-protocol';
|
|
|
21
19
|
export const useVoice = devId => {
|
|
22
20
|
const {
|
|
23
21
|
useMqtt,
|
|
24
|
-
devices
|
|
25
|
-
commandVersion
|
|
22
|
+
devices
|
|
26
23
|
} = useContext(SingletonContext);
|
|
27
24
|
/**
|
|
28
25
|
* 请求所有语音语言
|
|
29
|
-
* @returns Promise<
|
|
26
|
+
* @returns Promise<any> 响应结果
|
|
30
27
|
*/
|
|
31
28
|
|
|
32
29
|
/**
|
|
33
30
|
* 请求当前使用的语音语言
|
|
34
|
-
* @returns Promise<
|
|
31
|
+
* @returns Promise<any> 响应结果
|
|
35
32
|
*/
|
|
36
33
|
|
|
37
34
|
/**
|
|
38
35
|
* 设置语音语言
|
|
39
36
|
* @param message 包含语音语言设置参数的对象
|
|
40
|
-
* @returns Promise<
|
|
37
|
+
* @returns Promise<Response> 响应结果
|
|
41
38
|
*/
|
|
42
39
|
|
|
43
40
|
return {
|
|
44
41
|
requestAllVoices: async () => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return res;
|
|
52
|
-
} catch (error) {
|
|
53
|
-
throw error instanceof Error ? error : new Error('Failed to request all voices');
|
|
54
|
-
}
|
|
42
|
+
const res = await getVoiceList({
|
|
43
|
+
devId: devId,
|
|
44
|
+
offset: 0,
|
|
45
|
+
limit: 100
|
|
46
|
+
});
|
|
47
|
+
return res;
|
|
55
48
|
},
|
|
56
49
|
requestVoiceInUse: () => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
const params = createSetCommonParams({
|
|
51
|
+
deviceId: devId,
|
|
52
|
+
reqType: VoiceLanguageEnum.query
|
|
53
|
+
});
|
|
54
|
+
const {
|
|
55
|
+
taskId
|
|
56
|
+
} = params.message;
|
|
57
|
+
ty.device.sendMqttMessage(params);
|
|
58
|
+
return normalResolve(VoiceLanguageEnum.query, taskId);
|
|
59
|
+
},
|
|
60
|
+
setVoice: message => {
|
|
61
|
+
if (useMqtt) {
|
|
62
|
+
const sendData = _objectSpread(_objectSpread({}, message), {}, {
|
|
63
|
+
urlLen: message.url.length
|
|
64
|
+
});
|
|
61
65
|
const params = createSetCommonParams({
|
|
62
66
|
deviceId: devId,
|
|
63
|
-
reqType: VoiceLanguageEnum.
|
|
67
|
+
reqType: VoiceLanguageEnum.set,
|
|
68
|
+
message: sendData
|
|
64
69
|
});
|
|
65
|
-
const {
|
|
66
|
-
taskId
|
|
67
|
-
} = params.message;
|
|
68
70
|
ty.device.sendMqttMessage(params);
|
|
69
|
-
return normalResolve(VoiceLanguageEnum.query, taskId);
|
|
70
|
-
} catch (error) {
|
|
71
|
-
return Promise.reject(error instanceof Error ? error : new Error('Failed to request voice in use'));
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
setVoice: message => {
|
|
75
|
-
// 参数验证
|
|
76
|
-
if (!message || typeof message.id !== 'number') {
|
|
77
|
-
throw new Error('message.id is required and must be a number');
|
|
78
|
-
}
|
|
79
|
-
if (!message.url || typeof message.url !== 'string') {
|
|
80
|
-
throw new Error('message.url is required and must be a string');
|
|
81
|
-
}
|
|
82
|
-
if (!message.md5 || typeof message.md5 !== 'string') {
|
|
83
|
-
throw new Error('message.md5 is required and must be a string');
|
|
84
|
-
}
|
|
85
|
-
try {
|
|
86
|
-
if (useMqtt) {
|
|
87
|
-
const sendData = _objectSpread(_objectSpread({}, message), {}, {
|
|
88
|
-
urlLen: message.url.length
|
|
89
|
-
});
|
|
90
|
-
const params = createSetCommonParams({
|
|
91
|
-
deviceId: devId,
|
|
92
|
-
reqType: VoiceLanguageEnum.set,
|
|
93
|
-
message: sendData
|
|
94
|
-
});
|
|
95
|
-
ty.device.sendMqttMessage(params);
|
|
96
|
-
const {
|
|
97
|
-
taskId
|
|
98
|
-
} = params.message;
|
|
99
|
-
return normalResolve(VoiceLanguageEnum.query, taskId);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// 非 MQTT 模式:使用命令传输
|
|
103
|
-
const command = encodeVoice0x34(message);
|
|
104
|
-
devices.common.model.actions.voice_data.set(command);
|
|
105
|
-
return Promise.resolve({
|
|
106
|
-
success: true,
|
|
107
|
-
errCode: 0,
|
|
108
|
-
reqType: VoiceLanguageEnum.query,
|
|
109
|
-
version: commandVersion,
|
|
110
|
-
taskId: `${Date.now()}`,
|
|
111
|
-
id: message.id,
|
|
112
|
-
schedule: 0,
|
|
113
|
-
status: 0
|
|
114
|
-
});
|
|
115
|
-
} catch (error) {
|
|
116
|
-
throw error instanceof Error ? error : new Error('Failed to set voice');
|
|
71
|
+
return normalResolve(VoiceLanguageEnum.query, params.message.taskId);
|
|
117
72
|
}
|
|
73
|
+
const command = encodeVoice0x34(message);
|
|
74
|
+
devices.common.model.actions.voice_data.set(command);
|
|
75
|
+
return Promise.resolve({
|
|
76
|
+
success: true
|
|
77
|
+
});
|
|
118
78
|
}
|
|
119
79
|
};
|
|
120
80
|
};
|
package/lib/mqtt/useWifiMap.js
CHANGED
|
@@ -8,46 +8,30 @@ export const useWifiMap = devId => {
|
|
|
8
8
|
useMqtt
|
|
9
9
|
} = useContext(SingletonContext);
|
|
10
10
|
|
|
11
|
-
//
|
|
11
|
+
// 请求密码状态
|
|
12
12
|
|
|
13
|
-
//
|
|
13
|
+
// 设置密码
|
|
14
14
|
|
|
15
15
|
return {
|
|
16
16
|
requestWifiMap: () => {
|
|
17
|
-
if (!useMqtt)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
ty.device.sendMqttMessage(params);
|
|
26
|
-
const {
|
|
27
|
-
taskId
|
|
28
|
-
} = params.message;
|
|
29
|
-
return normalResolve(WifiMapEnum.query, taskId);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
return Promise.reject(error instanceof Error ? error : new Error('Failed to request WiFi map'));
|
|
32
|
-
}
|
|
17
|
+
if (!useMqtt) return Promise.reject(new Error('useMqtt is not used'));
|
|
18
|
+
const params = createSetCommonParams({
|
|
19
|
+
deviceId: devId,
|
|
20
|
+
reqType: WifiMapEnum.query
|
|
21
|
+
});
|
|
22
|
+
ty.device.sendMqttMessage(params);
|
|
23
|
+
return normalResolve(WifiMapEnum.query, params.message.taskId);
|
|
33
24
|
},
|
|
34
25
|
setWifiMap: () => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const {
|
|
45
|
-
taskId
|
|
46
|
-
} = params.message;
|
|
47
|
-
return normalResolve(WifiMapEnum.rst, taskId);
|
|
48
|
-
} catch (error) {
|
|
49
|
-
throw error instanceof Error ? error : new Error('Failed to set WiFi map');
|
|
50
|
-
}
|
|
26
|
+
const params = createSetCommonParams({
|
|
27
|
+
deviceId: devId,
|
|
28
|
+
reqType: WifiMapEnum.set,
|
|
29
|
+
message: {
|
|
30
|
+
taskId: String(Date.now())
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
ty.device.sendMqttMessage(params);
|
|
34
|
+
return normalResolve(WifiMapEnum.rst, params.message.taskId);
|
|
51
35
|
}
|
|
52
36
|
};
|
|
53
37
|
};
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RoomPreference } from './type';
|
|
2
2
|
import { Point, Zone } from '@ray-js/robot-protocol';
|
|
3
|
-
|
|
4
|
-
reqType:
|
|
3
|
+
type Response = {
|
|
4
|
+
reqType: string;
|
|
5
|
+
version: string;
|
|
6
|
+
success: boolean;
|
|
7
|
+
errCode: number;
|
|
8
|
+
taskId: string;
|
|
5
9
|
polygons: string[];
|
|
6
|
-
names?: string[];
|
|
7
10
|
suctions?: string[];
|
|
8
11
|
cisterns?: string[];
|
|
9
12
|
cleanCounts?: number[];
|
|
10
13
|
yMops?: number[];
|
|
11
14
|
sweepMopModes?: string[];
|
|
12
|
-
}
|
|
13
|
-
|
|
15
|
+
};
|
|
16
|
+
type TSetZoneClean = (message: Partial<Pick<RoomPreference, 'suctions' | 'cisterns' | 'cleanCounts' | 'yMops' | 'sweepMopModes'>> & {
|
|
14
17
|
zones: Zone[];
|
|
15
18
|
origin: Point;
|
|
16
|
-
}
|
|
17
|
-
type TRequestZoneClean = () => Promise<ZoneCleanResponse>;
|
|
18
|
-
type TSetZoneClean = (params: SetZoneCleanParams) => Promise<ZoneCleanResponse>;
|
|
19
|
+
}) => Promise<Response | void>;
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @
|
|
22
|
-
* @returns 包含 requestZoneClean 和 setZoneClean 函数的对象
|
|
21
|
+
* 划区清扫
|
|
22
|
+
* @returns
|
|
23
23
|
*/
|
|
24
24
|
export declare const useZoneClean: (devId: string) => {
|
|
25
|
-
requestZoneClean:
|
|
25
|
+
requestZoneClean: () => Promise<Response>;
|
|
26
26
|
setZoneClean: TSetZoneClean;
|
|
27
27
|
};
|
|
28
28
|
export {};
|