@ray-js/robot-data-stream 0.0.10-beta-20 → 0.0.10-beta-21
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/sweeperP2p.js +4 -1
- package/lib/mqtt/mqttProvider.d.ts +4 -4
- package/lib/mqtt/mqttProvider.js +3 -3
- package/lib/mqtt/useDevInfo.js +2 -2
- package/lib/mqtt/useHistoryMap.js +4 -4
- package/lib/mqtt/usePartDivision.js +2 -2
- package/lib/mqtt/usePartMerge.js +2 -2
- package/lib/mqtt/usePassword.js +2 -2
- package/lib/mqtt/useQuiteHours.js +2 -2
- package/lib/mqtt/useResetMap.js +2 -2
- package/lib/mqtt/useRoomProperty.js +2 -2
- package/lib/mqtt/useSchedule.js +2 -2
- package/lib/mqtt/useSelectRoomClean.js +3 -3
- package/lib/mqtt/useSpotClean.js +2 -2
- package/lib/mqtt/useVirtualArea.js +3 -3
- package/lib/mqtt/useVirtualWall.js +3 -3
- package/lib/mqtt/useVoice.js +2 -2
- package/lib/mqtt/useZoneClean.js +3 -3
- package/package.json +1 -1
package/lib/api/sweeperP2p.js
CHANGED
|
@@ -410,6 +410,10 @@ export class SweeperP2p extends P2pApi {
|
|
|
410
410
|
let {
|
|
411
411
|
fileName
|
|
412
412
|
} = data;
|
|
413
|
+
if (fileName.startsWith('map')) {
|
|
414
|
+
var _FILE_NAME_MAP$fileNa;
|
|
415
|
+
this.initStructuredMode(((_FILE_NAME_MAP$fileNa = FILE_NAME_MAP[fileName]) === null || _FILE_NAME_MAP$fileNa === void 0 ? void 0 : _FILE_NAME_MAP$fileNa.type) === 6);
|
|
416
|
+
}
|
|
413
417
|
|
|
414
418
|
// 因为XXXX_YYYYY会被替换为坐标值,所以这里需要替换一下
|
|
415
419
|
|
|
@@ -471,7 +475,6 @@ export class SweeperP2p extends P2pApi {
|
|
|
471
475
|
if (type === 0 || type === 6) {
|
|
472
476
|
this.onReceiveMapData(hexValue);
|
|
473
477
|
this.mapUpdateCount += 1;
|
|
474
|
-
this.initStructuredMode(type === 6);
|
|
475
478
|
}
|
|
476
479
|
if (type === 1) {
|
|
477
480
|
this.onReceivePathData(hexValue);
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare const SingletonContext: React.Context<{
|
|
3
|
-
|
|
3
|
+
useMqtt: boolean;
|
|
4
4
|
commandVersion: '0' | '1';
|
|
5
5
|
devices: {
|
|
6
6
|
common: any;
|
|
7
7
|
};
|
|
8
8
|
}>;
|
|
9
9
|
export declare function useMqtt(): {
|
|
10
|
-
|
|
10
|
+
useMqtt: boolean;
|
|
11
11
|
commandVersion: "0" | "1";
|
|
12
12
|
devices: {
|
|
13
13
|
common: any;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
|
-
export declare function MqttProvider({ children,
|
|
16
|
+
export declare function MqttProvider({ children, useMqtt, commandVersion, devices }: {
|
|
17
17
|
children: any;
|
|
18
|
-
|
|
18
|
+
useMqtt: any;
|
|
19
19
|
commandVersion: any;
|
|
20
20
|
devices: any;
|
|
21
21
|
}): React.JSX.Element;
|
package/lib/mqtt/mqttProvider.js
CHANGED
|
@@ -17,7 +17,7 @@ export function useMqtt() {
|
|
|
17
17
|
export function MqttProvider(_ref) {
|
|
18
18
|
let {
|
|
19
19
|
children,
|
|
20
|
-
|
|
20
|
+
useMqtt,
|
|
21
21
|
commandVersion,
|
|
22
22
|
devices
|
|
23
23
|
} = _ref;
|
|
@@ -54,8 +54,8 @@ export function MqttProvider(_ref) {
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
instanceRef.current = {
|
|
57
|
-
//
|
|
58
|
-
|
|
57
|
+
// 是否走mqtt64/65通道
|
|
58
|
+
useMqtt,
|
|
59
59
|
// 指令协议版本(1byte or 4bytes)
|
|
60
60
|
commandVersion,
|
|
61
61
|
// sdm
|
package/lib/mqtt/useDevInfo.js
CHANGED
|
@@ -10,12 +10,12 @@ var DevInfoEnum = /*#__PURE__*/function (DevInfoEnum) {
|
|
|
10
10
|
// 请求设备信息
|
|
11
11
|
export const useDevInfo = devId => {
|
|
12
12
|
const {
|
|
13
|
-
|
|
13
|
+
useMqtt,
|
|
14
14
|
devices
|
|
15
15
|
} = useContext(SingletonContext);
|
|
16
16
|
return {
|
|
17
17
|
requestDevInfo: () => {
|
|
18
|
-
if (
|
|
18
|
+
if (useMqtt) {
|
|
19
19
|
const params = createSetCommonParams({
|
|
20
20
|
deviceId: devId,
|
|
21
21
|
reqType: DevInfoEnum.query,
|
|
@@ -17,7 +17,7 @@ import { encodeDeleteMap0x2c, encodeSaveMap0x2a, encodeUseMap0x2e } from '@ray-j
|
|
|
17
17
|
*/
|
|
18
18
|
export const useHistoryMap = devId => {
|
|
19
19
|
const {
|
|
20
|
-
|
|
20
|
+
useMqtt,
|
|
21
21
|
devices
|
|
22
22
|
} = useContext(SingletonContext);
|
|
23
23
|
/**
|
|
@@ -45,7 +45,7 @@ export const useHistoryMap = devId => {
|
|
|
45
45
|
return Promise.reject(new Error('mapId is required'));
|
|
46
46
|
}
|
|
47
47
|
await deleteMultipleMapFile(mapId, devId);
|
|
48
|
-
if (
|
|
48
|
+
if (useMqtt) {
|
|
49
49
|
const params = createSetCommonParams({
|
|
50
50
|
deviceId: devId,
|
|
51
51
|
reqType: DeleteMapEnum.set,
|
|
@@ -70,7 +70,7 @@ export const useHistoryMap = devId => {
|
|
|
70
70
|
},
|
|
71
71
|
changeCurrentMap: async (mapId, url) => {
|
|
72
72
|
try {
|
|
73
|
-
if (
|
|
73
|
+
if (useMqtt) {
|
|
74
74
|
const sendData = {
|
|
75
75
|
reqType: UseMapEnum.set,
|
|
76
76
|
mapId,
|
|
@@ -99,7 +99,7 @@ export const useHistoryMap = devId => {
|
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
saveMap: () => {
|
|
102
|
-
if (
|
|
102
|
+
if (useMqtt) {
|
|
103
103
|
const params = createSetCommonParams({
|
|
104
104
|
deviceId: devId,
|
|
105
105
|
reqType: SaveCurrentMapEnum.set,
|
|
@@ -16,7 +16,7 @@ import { encodePartitionDivision0x1c } from '@ray-js/robot-protocol';
|
|
|
16
16
|
*/
|
|
17
17
|
export const usePartDivision = devId => {
|
|
18
18
|
const {
|
|
19
|
-
|
|
19
|
+
useMqtt,
|
|
20
20
|
devices,
|
|
21
21
|
commandVersion
|
|
22
22
|
} = useContext(SingletonContext);
|
|
@@ -31,7 +31,7 @@ export const usePartDivision = devId => {
|
|
|
31
31
|
|
|
32
32
|
return {
|
|
33
33
|
setPartDivision: (points, roomId, origin) => {
|
|
34
|
-
if (
|
|
34
|
+
if (useMqtt) {
|
|
35
35
|
const pointStr = pointsToString(points, origin);
|
|
36
36
|
const params = createSetCommonParams({
|
|
37
37
|
deviceId: devId,
|
package/lib/mqtt/usePartMerge.js
CHANGED
|
@@ -17,7 +17,7 @@ import { encodePartitionMerge0x1e } from '@ray-js/robot-protocol';
|
|
|
17
17
|
*/
|
|
18
18
|
export const usePartMerge = devId => {
|
|
19
19
|
const {
|
|
20
|
-
|
|
20
|
+
useMqtt,
|
|
21
21
|
devices,
|
|
22
22
|
commandVersion
|
|
23
23
|
} = useContext(SingletonContext);
|
|
@@ -35,7 +35,7 @@ export const usePartMerge = devId => {
|
|
|
35
35
|
if (ids.some(id => typeof id !== 'number')) {
|
|
36
36
|
return Promise.reject(new Error('ids must be an array of numbers'));
|
|
37
37
|
}
|
|
38
|
-
if (
|
|
38
|
+
if (useMqtt) {
|
|
39
39
|
const params = createSetCommonParams({
|
|
40
40
|
deviceId: devId,
|
|
41
41
|
reqType: PartMergeEnum.set,
|
package/lib/mqtt/usePassword.js
CHANGED
|
@@ -6,7 +6,7 @@ import { useContext } from 'react';
|
|
|
6
6
|
import { SingletonContext } from './mqttProvider';
|
|
7
7
|
export const usePassword = devId => {
|
|
8
8
|
const {
|
|
9
|
-
|
|
9
|
+
useMqtt
|
|
10
10
|
} = useContext(SingletonContext);
|
|
11
11
|
|
|
12
12
|
// 请求密码状态
|
|
@@ -17,7 +17,7 @@ export const usePassword = devId => {
|
|
|
17
17
|
|
|
18
18
|
return {
|
|
19
19
|
requestPassword: () => {
|
|
20
|
-
if (!
|
|
20
|
+
if (!useMqtt) return null;
|
|
21
21
|
const params = createSetCommonParams({
|
|
22
22
|
deviceId: devId,
|
|
23
23
|
reqType: PasswordEnum.query
|
|
@@ -18,7 +18,7 @@ import { encodeDoNotDisturb0x32 } from '@ray-js/robot-protocol';
|
|
|
18
18
|
*/
|
|
19
19
|
export const useQuiteHours = devId => {
|
|
20
20
|
const {
|
|
21
|
-
|
|
21
|
+
useMqtt,
|
|
22
22
|
devices,
|
|
23
23
|
commandVersion
|
|
24
24
|
} = useContext(SingletonContext);
|
|
@@ -40,7 +40,7 @@ export const useQuiteHours = devId => {
|
|
|
40
40
|
endTime
|
|
41
41
|
} = message,
|
|
42
42
|
others = _objectWithoutProperties(message, _excluded);
|
|
43
|
-
if (
|
|
43
|
+
if (useMqtt) {
|
|
44
44
|
if (!startTime || !endTime) {
|
|
45
45
|
throw new Error('Invalid time');
|
|
46
46
|
}
|
package/lib/mqtt/useResetMap.js
CHANGED
|
@@ -6,7 +6,7 @@ import { SingletonContext } from './mqttProvider';
|
|
|
6
6
|
import { encodeResetMap0x42 } from '@ray-js/robot-protocol';
|
|
7
7
|
export const useResetMap = devId => {
|
|
8
8
|
const {
|
|
9
|
-
|
|
9
|
+
useMqtt,
|
|
10
10
|
devices,
|
|
11
11
|
commandVersion
|
|
12
12
|
} = useContext(SingletonContext);
|
|
@@ -14,7 +14,7 @@ export const useResetMap = devId => {
|
|
|
14
14
|
|
|
15
15
|
return {
|
|
16
16
|
setResetMap: () => {
|
|
17
|
-
if (
|
|
17
|
+
if (useMqtt) {
|
|
18
18
|
const params = createSetCommonParams({
|
|
19
19
|
deviceId: devId,
|
|
20
20
|
reqType: ResetCurrMapEnum.set
|
|
@@ -6,7 +6,7 @@ import { useContext } from 'react';
|
|
|
6
6
|
import { SingletonContext } from './mqttProvider';
|
|
7
7
|
export const useRoomProperty = devId => {
|
|
8
8
|
const {
|
|
9
|
-
|
|
9
|
+
useMqtt
|
|
10
10
|
} = useContext(SingletonContext);
|
|
11
11
|
|
|
12
12
|
// 请求房间属性
|
|
@@ -15,7 +15,7 @@ export const useRoomProperty = devId => {
|
|
|
15
15
|
|
|
16
16
|
return {
|
|
17
17
|
requestRoomProperty: () => {
|
|
18
|
-
if (!
|
|
18
|
+
if (!useMqtt) return null;
|
|
19
19
|
const params = createSetCommonParams({
|
|
20
20
|
deviceId: devId,
|
|
21
21
|
reqType: RoomPropertyEnum.query
|
package/lib/mqtt/useSchedule.js
CHANGED
|
@@ -12,7 +12,7 @@ import { CISTERN_MAP, CLEAN_MODE_MAP, SUCTION_MAP } from '../constant';
|
|
|
12
12
|
|
|
13
13
|
export const useSchedule = devId => {
|
|
14
14
|
const {
|
|
15
|
-
|
|
15
|
+
useMqtt,
|
|
16
16
|
devices,
|
|
17
17
|
commandVersion
|
|
18
18
|
} = useContext(SingletonContext);
|
|
@@ -33,7 +33,7 @@ export const useSchedule = devId => {
|
|
|
33
33
|
return normalResolve(ScheduleEnum.query, taskId);
|
|
34
34
|
},
|
|
35
35
|
setSchedule: message => {
|
|
36
|
-
if (
|
|
36
|
+
if (useMqtt) {
|
|
37
37
|
const params = createSetCommonParams({
|
|
38
38
|
deviceId: devId,
|
|
39
39
|
reqType: ScheduleEnum.set,
|
|
@@ -10,7 +10,7 @@ import { SingletonContext } from './mqttProvider';
|
|
|
10
10
|
import { encodeRoomClean0x14, requestRoomClean0x15 } from '@ray-js/robot-protocol';
|
|
11
11
|
export const useSelectRoomClean = devId => {
|
|
12
12
|
const {
|
|
13
|
-
|
|
13
|
+
useMqtt,
|
|
14
14
|
commandVersion,
|
|
15
15
|
devices
|
|
16
16
|
} = useContext(SingletonContext);
|
|
@@ -22,7 +22,7 @@ export const useSelectRoomClean = devId => {
|
|
|
22
22
|
|
|
23
23
|
return {
|
|
24
24
|
requestSelectRoomClean: () => {
|
|
25
|
-
if (
|
|
25
|
+
if (useMqtt) {
|
|
26
26
|
const params = createSetCommonParams({
|
|
27
27
|
deviceId: devId,
|
|
28
28
|
reqType: RoomCleanSetEnum.query
|
|
@@ -36,7 +36,7 @@ export const useSelectRoomClean = devId => {
|
|
|
36
36
|
},
|
|
37
37
|
setRoomClean: rooms => {
|
|
38
38
|
var _rooms$0$cleanTimes, _rooms$;
|
|
39
|
-
if (
|
|
39
|
+
if (useMqtt) {
|
|
40
40
|
const ids = [];
|
|
41
41
|
const suctions = [];
|
|
42
42
|
const cisterns = [];
|
package/lib/mqtt/useSpotClean.js
CHANGED
|
@@ -14,7 +14,7 @@ import { pointsToString } from '../utils';
|
|
|
14
14
|
*/
|
|
15
15
|
export const useSpotClean = devId => {
|
|
16
16
|
const {
|
|
17
|
-
|
|
17
|
+
useMqtt,
|
|
18
18
|
commandVersion,
|
|
19
19
|
devices
|
|
20
20
|
} = useContext(SingletonContext);
|
|
@@ -38,7 +38,7 @@ export const useSpotClean = devId => {
|
|
|
38
38
|
spots,
|
|
39
39
|
origin
|
|
40
40
|
} = message;
|
|
41
|
-
if (
|
|
41
|
+
if (useMqtt) {
|
|
42
42
|
if (!isArray(spots) || isArray(spots) && spots.length === 0) {
|
|
43
43
|
return Promise.reject(new Error('message is required'));
|
|
44
44
|
}
|
|
@@ -12,7 +12,7 @@ import { pointsToString } from '../utils';
|
|
|
12
12
|
|
|
13
13
|
export const useVirtualArea = devId => {
|
|
14
14
|
const {
|
|
15
|
-
|
|
15
|
+
useMqtt,
|
|
16
16
|
commandVersion,
|
|
17
17
|
devices
|
|
18
18
|
} = useContext(SingletonContext);
|
|
@@ -34,7 +34,7 @@ export const useVirtualArea = devId => {
|
|
|
34
34
|
|
|
35
35
|
return {
|
|
36
36
|
requestVirtualArea: () => {
|
|
37
|
-
if (
|
|
37
|
+
if (useMqtt) {
|
|
38
38
|
const params = createSetCommonParams({
|
|
39
39
|
deviceId: devId,
|
|
40
40
|
reqType: VirtualAreaEnum.query
|
|
@@ -51,7 +51,7 @@ export const useVirtualArea = devId => {
|
|
|
51
51
|
data,
|
|
52
52
|
origin
|
|
53
53
|
} = _ref;
|
|
54
|
-
if (
|
|
54
|
+
if (useMqtt) {
|
|
55
55
|
const names = [];
|
|
56
56
|
const modes = [];
|
|
57
57
|
const polygons = [];
|
|
@@ -10,7 +10,7 @@ import { encodeVirtualWall0x12, requestVirtualWall0x13 } from '@ray-js/robot-pro
|
|
|
10
10
|
import { pointsToString } from '../utils';
|
|
11
11
|
export const useVirtualWall = devId => {
|
|
12
12
|
const {
|
|
13
|
-
|
|
13
|
+
useMqtt,
|
|
14
14
|
commandVersion,
|
|
15
15
|
devices
|
|
16
16
|
} = useContext(SingletonContext);
|
|
@@ -28,7 +28,7 @@ export const useVirtualWall = devId => {
|
|
|
28
28
|
|
|
29
29
|
return {
|
|
30
30
|
requestVirtualWall: () => {
|
|
31
|
-
if (
|
|
31
|
+
if (useMqtt) {
|
|
32
32
|
const params = createSetCommonParams({
|
|
33
33
|
deviceId: devId,
|
|
34
34
|
reqType: VirtualWallEnum.query
|
|
@@ -45,7 +45,7 @@ export const useVirtualWall = devId => {
|
|
|
45
45
|
data,
|
|
46
46
|
origin
|
|
47
47
|
} = _ref;
|
|
48
|
-
if (
|
|
48
|
+
if (useMqtt) {
|
|
49
49
|
const params = createSetCommonParams({
|
|
50
50
|
deviceId: devId,
|
|
51
51
|
reqType: VirtualWallEnum.set,
|
package/lib/mqtt/useVoice.js
CHANGED
|
@@ -18,7 +18,7 @@ import { encodeVoice0x34 } from '@ray-js/robot-protocol';
|
|
|
18
18
|
*/
|
|
19
19
|
export const useVoice = devId => {
|
|
20
20
|
const {
|
|
21
|
-
|
|
21
|
+
useMqtt,
|
|
22
22
|
devices
|
|
23
23
|
} = useContext(SingletonContext);
|
|
24
24
|
/**
|
|
@@ -58,7 +58,7 @@ export const useVoice = devId => {
|
|
|
58
58
|
return normalResolve(VoiceLanguageEnum.query, taskId);
|
|
59
59
|
},
|
|
60
60
|
setVoice: message => {
|
|
61
|
-
if (
|
|
61
|
+
if (useMqtt) {
|
|
62
62
|
const sendData = _objectSpread(_objectSpread({}, message), {}, {
|
|
63
63
|
urlLen: message.url.length
|
|
64
64
|
});
|
package/lib/mqtt/useZoneClean.js
CHANGED
|
@@ -16,7 +16,7 @@ import { pointsToString } from '../utils';
|
|
|
16
16
|
*/
|
|
17
17
|
export const useZoneClean = devId => {
|
|
18
18
|
const {
|
|
19
|
-
|
|
19
|
+
useMqtt,
|
|
20
20
|
commandVersion,
|
|
21
21
|
devices
|
|
22
22
|
} = useContext(SingletonContext);
|
|
@@ -27,7 +27,7 @@ export const useZoneClean = devId => {
|
|
|
27
27
|
|
|
28
28
|
return {
|
|
29
29
|
requestZoneClean: () => {
|
|
30
|
-
if (
|
|
30
|
+
if (useMqtt) {
|
|
31
31
|
const params = createSetCommonParams({
|
|
32
32
|
deviceId: devId,
|
|
33
33
|
reqType: ZoneCleanEnum.query
|
|
@@ -44,7 +44,7 @@ export const useZoneClean = devId => {
|
|
|
44
44
|
zones,
|
|
45
45
|
origin
|
|
46
46
|
} = message;
|
|
47
|
-
if (
|
|
47
|
+
if (useMqtt) {
|
|
48
48
|
if (!isArray(zones) || isArray(zones) && zones.length === 0) {
|
|
49
49
|
return Promise.reject(new Error('message is required'));
|
|
50
50
|
}
|