@ray-js/robot-data-stream 0.0.10-beta-14 → 0.0.10-beta-15
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/constant.d.ts +3 -0
- package/lib/constant.js +29 -0
- package/lib/mqtt/mqttProvider.d.ts +18 -3
- package/lib/mqtt/mqttProvider.js +14 -4
- package/lib/mqtt/promise.js +1 -0
- package/lib/mqtt/useDevInfo.d.ts +5 -5
- package/lib/mqtt/useDevInfo.js +22 -9
- package/lib/mqtt/useHistoryMap.d.ts +1 -1
- package/lib/mqtt/useHistoryMap.js +61 -34
- package/lib/mqtt/usePartDivision.d.ts +1 -1
- package/lib/mqtt/usePartDivision.js +29 -10
- package/lib/mqtt/usePartMerge.d.ts +1 -1
- package/lib/mqtt/usePartMerge.js +24 -8
- package/lib/mqtt/usePassword.js +7 -0
- package/lib/mqtt/useQuiteHours.d.ts +3 -1
- package/lib/mqtt/useQuiteHours.js +42 -21
- package/lib/mqtt/useResetMap.d.ts +1 -1
- package/lib/mqtt/useResetMap.js +20 -6
- package/lib/mqtt/useRoomProperty.js +7 -0
- package/lib/mqtt/useSchedule.d.ts +1 -1
- package/lib/mqtt/useSchedule.js +53 -9
- package/lib/mqtt/useSelectRoomClean.d.ts +8 -8
- package/lib/mqtt/useSelectRoomClean.js +62 -53
- package/lib/mqtt/useSpotClean.d.ts +4 -3
- package/lib/mqtt/useSpotClean.js +68 -48
- package/lib/mqtt/useVirtualArea.d.ts +4 -5
- package/lib/mqtt/useVirtualArea.js +60 -49
- package/lib/mqtt/useVirtualWall.d.ts +5 -5
- package/lib/mqtt/useVirtualWall.js +45 -40
- package/lib/mqtt/useVoice.js +23 -9
- package/lib/mqtt/useZoneClean.d.ts +4 -3
- package/lib/mqtt/useZoneClean.js +89 -55
- package/package.json +6 -4
package/lib/mqtt/useVoice.js
CHANGED
|
@@ -3,6 +3,9 @@ import { getVoiceList } from '@ray-js/ray';
|
|
|
3
3
|
import { createSetCommonParams } from './createCommonOptions';
|
|
4
4
|
import { normalResolve } from './promise';
|
|
5
5
|
import { VoiceLanguageEnum } from './type';
|
|
6
|
+
import { useContext } from 'react';
|
|
7
|
+
import { SingletonContext } from './mqttProvider';
|
|
8
|
+
import { encodeVoice0x34 } from '@ray-js/robot-protocol';
|
|
6
9
|
|
|
7
10
|
// 设置语音语言函数类型定义
|
|
8
11
|
|
|
@@ -14,6 +17,10 @@ import { VoiceLanguageEnum } from './type';
|
|
|
14
17
|
* @returns 包含 requestAllVoices, requestVoiceInUse 和 setVoice 函数的对象
|
|
15
18
|
*/
|
|
16
19
|
export const useVoice = devId => {
|
|
20
|
+
const {
|
|
21
|
+
useStructuredMode,
|
|
22
|
+
devices
|
|
23
|
+
} = useContext(SingletonContext);
|
|
17
24
|
/**
|
|
18
25
|
* 请求所有语音语言
|
|
19
26
|
* @returns Promise<any> 响应结果
|
|
@@ -51,16 +58,23 @@ export const useVoice = devId => {
|
|
|
51
58
|
return normalResolve(VoiceLanguageEnum.query, taskId);
|
|
52
59
|
},
|
|
53
60
|
setVoice: message => {
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
if (useStructuredMode) {
|
|
62
|
+
const sendData = _objectSpread(_objectSpread({}, message), {}, {
|
|
63
|
+
urlLen: message.url.length
|
|
64
|
+
});
|
|
65
|
+
const params = createSetCommonParams({
|
|
66
|
+
deviceId: devId,
|
|
67
|
+
reqType: VoiceLanguageEnum.set,
|
|
68
|
+
message: sendData
|
|
69
|
+
});
|
|
70
|
+
ty.device.sendMqttMessage(params);
|
|
71
|
+
return normalResolve(VoiceLanguageEnum.query, params.message.taskId);
|
|
72
|
+
}
|
|
73
|
+
const command = encodeVoice0x34(message);
|
|
74
|
+
devices.common.model.actions.voice_data.set(command);
|
|
75
|
+
return Promise.resolve({
|
|
76
|
+
success: true
|
|
56
77
|
});
|
|
57
|
-
const params = createSetCommonParams({
|
|
58
|
-
deviceId: devId,
|
|
59
|
-
reqType: VoiceLanguageEnum.set,
|
|
60
|
-
message: sendData
|
|
61
|
-
});
|
|
62
|
-
ty.device.sendMqttMessage(params);
|
|
63
|
-
return normalResolve(VoiceLanguageEnum.query, params.message.taskId);
|
|
64
78
|
}
|
|
65
79
|
};
|
|
66
80
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RoomPreference } from './type';
|
|
2
|
+
import { Point, Zone } from '@ray-js/robot-protocol';
|
|
2
3
|
type Response = {
|
|
3
4
|
reqType: string;
|
|
4
5
|
version: string;
|
|
@@ -13,9 +14,9 @@ type Response = {
|
|
|
13
14
|
sweepMopModes?: string[];
|
|
14
15
|
};
|
|
15
16
|
type TSetZoneClean = (message: Partial<Pick<RoomPreference, 'suctions' | 'cisterns' | 'cleanCounts' | 'yMops' | 'sweepMopModes'>> & {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}) => Promise<Response>;
|
|
17
|
+
zones: Zone[];
|
|
18
|
+
origin: Point;
|
|
19
|
+
}) => Promise<Response | void>;
|
|
19
20
|
/**
|
|
20
21
|
* 划区清扫
|
|
21
22
|
* @returns
|
package/lib/mqtt/useZoneClean.js
CHANGED
|
@@ -1,81 +1,115 @@
|
|
|
1
|
+
import "core-js/modules/esnext.iterator.constructor.js";
|
|
2
|
+
import "core-js/modules/esnext.iterator.for-each.js";
|
|
1
3
|
// 划区清扫
|
|
2
4
|
|
|
3
5
|
import { isArray } from 'lodash-es';
|
|
4
6
|
import { createSetCommonParams } from './createCommonOptions';
|
|
5
7
|
import { normalResolve } from './promise';
|
|
6
8
|
import { ZoneCleanEnum } from './type';
|
|
9
|
+
import { useContext } from 'react';
|
|
10
|
+
import { SingletonContext } from './mqttProvider';
|
|
11
|
+
import { encodeZoneClean0x3a, requestZoneClean0x3b } from '@ray-js/robot-protocol';
|
|
12
|
+
import { pointsToString } from 'src/utils';
|
|
7
13
|
/**
|
|
8
14
|
* 划区清扫
|
|
9
15
|
* @returns
|
|
10
16
|
*/
|
|
11
17
|
export const useZoneClean = devId => {
|
|
18
|
+
const {
|
|
19
|
+
useStructuredMode,
|
|
20
|
+
commandVersion,
|
|
21
|
+
devices
|
|
22
|
+
} = useContext(SingletonContext);
|
|
23
|
+
|
|
12
24
|
// 请求划区清扫信息
|
|
13
25
|
|
|
14
26
|
// 设置划区清扫
|
|
15
27
|
|
|
16
28
|
return {
|
|
17
29
|
requestZoneClean: () => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
30
|
+
if (useStructuredMode) {
|
|
31
|
+
const params = createSetCommonParams({
|
|
32
|
+
deviceId: devId,
|
|
33
|
+
reqType: ZoneCleanEnum.query
|
|
34
|
+
});
|
|
35
|
+
ty.device.sendMqttMessage(params);
|
|
36
|
+
return normalResolve(ZoneCleanEnum.query, params.message.taskId);
|
|
37
|
+
}
|
|
38
|
+
return devices.common.model.actions.command_trans.set(requestZoneClean0x3b({
|
|
39
|
+
version: commandVersion
|
|
40
|
+
}));
|
|
24
41
|
},
|
|
25
42
|
setZoneClean: message => {
|
|
26
43
|
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (!isArray(polygons) || isArray(polygons) && polygons.length === 0) {
|
|
30
|
-
return Promise.reject(new Error('message is required'));
|
|
31
|
-
}
|
|
32
|
-
const num = polygons.length;
|
|
33
|
-
const {
|
|
34
|
-
suctions = new Array(num).fill(''),
|
|
35
|
-
cisterns = new Array(num).fill(''),
|
|
36
|
-
cleanCounts = new Array(num).fill(1),
|
|
37
|
-
yMops = new Array(num).fill(-1),
|
|
38
|
-
sweepMopModes = new Array(num).fill('only_sweep'),
|
|
39
|
-
names = new Array(num).fill('')
|
|
44
|
+
zones,
|
|
45
|
+
origin
|
|
40
46
|
} = message;
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
if (num !== suctions.length || num !== cisterns.length || num !== cleanCounts.length || num !== yMops.length || num !== sweepMopModes.length || num !== names.length) {
|
|
60
|
-
return Promise.reject(new Error('The length of the parameters is inconsistent'));
|
|
61
|
-
}
|
|
62
|
-
const params = createSetCommonParams({
|
|
63
|
-
deviceId: devId,
|
|
64
|
-
reqType: ZoneCleanEnum.set,
|
|
65
|
-
message: {
|
|
66
|
-
num: polygons.length,
|
|
67
|
-
switchGo: true,
|
|
68
|
-
polygons,
|
|
69
|
-
suctions,
|
|
70
|
-
cisterns,
|
|
71
|
-
cleanCounts,
|
|
72
|
-
yMops,
|
|
73
|
-
sweepMopModes,
|
|
74
|
-
names
|
|
47
|
+
if (useStructuredMode) {
|
|
48
|
+
if (!isArray(zones) || isArray(zones) && zones.length === 0) {
|
|
49
|
+
return Promise.reject(new Error('message is required'));
|
|
50
|
+
}
|
|
51
|
+
const num = zones.length;
|
|
52
|
+
const {
|
|
53
|
+
suctions = new Array(num).fill(''),
|
|
54
|
+
cisterns = new Array(num).fill(''),
|
|
55
|
+
cleanCounts = new Array(num).fill(1),
|
|
56
|
+
yMops = new Array(num).fill(-1),
|
|
57
|
+
sweepMopModes = new Array(num).fill('only_sweep')
|
|
58
|
+
} = message;
|
|
59
|
+
if (suctions && !isArray(suctions)) {
|
|
60
|
+
return Promise.reject(new Error('suctions is illegal'));
|
|
61
|
+
}
|
|
62
|
+
if (cisterns && !isArray(cisterns)) {
|
|
63
|
+
return Promise.reject(new Error('cisterns is illegal'));
|
|
75
64
|
}
|
|
65
|
+
if (cleanCounts && !isArray(cleanCounts)) {
|
|
66
|
+
return Promise.reject(new Error('cleanCounts is illegal'));
|
|
67
|
+
}
|
|
68
|
+
if (yMops && !isArray(yMops)) {
|
|
69
|
+
return Promise.reject(new Error('yMops is illegal'));
|
|
70
|
+
}
|
|
71
|
+
if (sweepMopModes && !isArray(sweepMopModes)) {
|
|
72
|
+
return Promise.reject(new Error('sweepMopModes is illegal'));
|
|
73
|
+
}
|
|
74
|
+
if (num !== suctions.length || num !== cisterns.length || num !== cleanCounts.length || num !== yMops.length || num !== sweepMopModes.length) {
|
|
75
|
+
return Promise.reject(new Error('The length of the parameters is inconsistent'));
|
|
76
|
+
}
|
|
77
|
+
const polygons = [];
|
|
78
|
+
const names = [];
|
|
79
|
+
zones.forEach(_ref => {
|
|
80
|
+
let {
|
|
81
|
+
points,
|
|
82
|
+
name
|
|
83
|
+
} = _ref;
|
|
84
|
+
polygons.push(pointsToString(points, origin));
|
|
85
|
+
names.push(name);
|
|
86
|
+
});
|
|
87
|
+
const params = createSetCommonParams({
|
|
88
|
+
deviceId: devId,
|
|
89
|
+
reqType: ZoneCleanEnum.set,
|
|
90
|
+
message: {
|
|
91
|
+
num: zones.length,
|
|
92
|
+
switchGo: true,
|
|
93
|
+
polygons,
|
|
94
|
+
suctions,
|
|
95
|
+
cisterns,
|
|
96
|
+
cleanCounts,
|
|
97
|
+
yMops,
|
|
98
|
+
sweepMopModes,
|
|
99
|
+
names
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
ty.device.sendMqttMessage(params);
|
|
103
|
+
return normalResolve(ZoneCleanEnum.query, params.message.taskId);
|
|
104
|
+
}
|
|
105
|
+
const command = encodeZoneClean0x3a({
|
|
106
|
+
protocolVersion: 1,
|
|
107
|
+
version: commandVersion,
|
|
108
|
+
origin,
|
|
109
|
+
zones
|
|
76
110
|
});
|
|
77
|
-
|
|
78
|
-
return
|
|
111
|
+
devices.common.model.actions.command_trans.set(command);
|
|
112
|
+
return Promise.resolve();
|
|
79
113
|
}
|
|
80
114
|
};
|
|
81
115
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/robot-data-stream",
|
|
3
|
-
"version": "0.0.10-beta-
|
|
3
|
+
"version": "0.0.10-beta-15",
|
|
4
4
|
"description": "扫地机P2P数据流标准化组件",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"files": [
|
|
@@ -31,17 +31,18 @@
|
|
|
31
31
|
"release-it": "standard-version"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
+
"@ray-js/log4js": "^0.0.4",
|
|
34
35
|
"@ray-js/ray": "^1.5.0",
|
|
35
|
-
"@ray-js/
|
|
36
|
+
"@ray-js/robot-protocol": "^0.10.0"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
39
|
"clsx": "^1.2.1",
|
|
40
|
+
"crypto-js": "^4.2.0",
|
|
39
41
|
"lodash-es": "^4.17.21",
|
|
40
42
|
"mitt": "^3.0.1",
|
|
41
43
|
"moment": "^2.30.1",
|
|
42
44
|
"react": "^17.0.2",
|
|
43
|
-
"react-dom": "^17.0.2"
|
|
44
|
-
"crypto-js": "^4.2.0"
|
|
45
|
+
"react-dom": "^17.0.2"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
48
|
"@commitlint/cli": "^7.2.1",
|
|
@@ -49,6 +50,7 @@
|
|
|
49
50
|
"@ray-js/cli": "^1.5.20",
|
|
50
51
|
"@ray-js/log4js": "^0.0.4",
|
|
51
52
|
"@ray-js/ray": "^1.5.0",
|
|
53
|
+
"@ray-js/robot-protocol": "^0.10.0",
|
|
52
54
|
"core-js": "^3.19.1",
|
|
53
55
|
"eslint-config-tuya-panel": "^0.4.2",
|
|
54
56
|
"husky": "^1.2.0",
|