@ray-js/robot-data-stream 0.0.13-beta-5 → 0.0.13-beta-6
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.d.ts +8 -1
- package/lib/api/sweeperP2p.js +20 -4
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -2
- package/lib/mqtt/index.d.ts +2 -1
- package/lib/mqtt/index.js +2 -1
- package/lib/mqtt/type/index.d.ts +5 -0
- package/lib/mqtt/type/index.js +6 -0
- package/lib/mqtt/type/requestType.d.ts +5 -0
- package/lib/mqtt/type/requestType.js +6 -0
- package/lib/mqtt/useSpotClean.js +2 -1
- package/lib/mqtt/useWifiMap.d.ts +8 -0
- package/lib/mqtt/useWifiMap.js +37 -0
- package/package.json +1 -1
package/lib/api/sweeperP2p.d.ts
CHANGED
|
@@ -42,6 +42,12 @@ declare const FILE_NAME_MAP: {
|
|
|
42
42
|
readonly 'aiHD_XXXX_YYYY.bin.stream': {
|
|
43
43
|
readonly type: 5;
|
|
44
44
|
};
|
|
45
|
+
readonly 'wifi_map.bin': {
|
|
46
|
+
readonly type: 7;
|
|
47
|
+
};
|
|
48
|
+
readonly 'wifi_map.bin.stream': {
|
|
49
|
+
readonly type: 7;
|
|
50
|
+
};
|
|
45
51
|
};
|
|
46
52
|
export declare class SweeperP2p extends P2pApi {
|
|
47
53
|
file: {
|
|
@@ -69,6 +75,7 @@ export declare class SweeperP2p extends P2pApi {
|
|
|
69
75
|
onReceivePathData: (data: string) => void;
|
|
70
76
|
onReceiveAIPicData: (data: string) => void;
|
|
71
77
|
onReceiveAIPicHDData: (data: string) => void;
|
|
78
|
+
onReceiveWifiMapData: (data: string) => void;
|
|
72
79
|
offFileDownloadComplete: () => void;
|
|
73
80
|
offP2pStreamPacketReceive: () => void;
|
|
74
81
|
offDownLoadProgressUpdate: () => void;
|
|
@@ -125,7 +132,7 @@ export declare class SweeperP2p extends P2pApi {
|
|
|
125
132
|
* @param downloadType
|
|
126
133
|
* 0: 下载断开 1: 持续下载
|
|
127
134
|
*/
|
|
128
|
-
startObserverSweeperDataByP2P: (downloadType: number, devId: string, onReceiveMapData: (data: string) => void, onReceivePathData: (data: string) => void, onReceiveAIPicData?: ((data: string) => void) | undefined, onReceiveAIPicHDData?: ((data: string) => void) | undefined, onDefineStructuredMode?: ((isStructured: boolean) => void) | undefined) => Promise<void>;
|
|
135
|
+
startObserverSweeperDataByP2P: (downloadType: number, devId: string, onReceiveMapData: (data: string) => void, onReceivePathData: (data: string) => void, onReceiveAIPicData?: ((data: string) => void) | undefined, onReceiveAIPicHDData?: ((data: string) => void) | undefined, onReceiveWifiMapData?: ((data: string) => void) | undefined, onDefineStructuredMode?: ((isStructured: boolean) => void) | undefined) => Promise<void>;
|
|
129
136
|
/**
|
|
130
137
|
* 在下载过程中继续添加下载文件
|
|
131
138
|
* @param files
|
package/lib/api/sweeperP2p.js
CHANGED
|
@@ -43,6 +43,12 @@ const FILE_NAME_MAP = {
|
|
|
43
43
|
},
|
|
44
44
|
'aiHD_XXXX_YYYY.bin.stream': {
|
|
45
45
|
type: 5
|
|
46
|
+
},
|
|
47
|
+
'wifi_map.bin': {
|
|
48
|
+
type: 7
|
|
49
|
+
},
|
|
50
|
+
'wifi_map.bin.stream': {
|
|
51
|
+
type: 7
|
|
46
52
|
}
|
|
47
53
|
};
|
|
48
54
|
|
|
@@ -191,6 +197,9 @@ export class SweeperP2p extends P2pApi {
|
|
|
191
197
|
if (filename.indexOf('aiHD') !== -1) {
|
|
192
198
|
return 5;
|
|
193
199
|
}
|
|
200
|
+
if (filename.indexOf('wifi_map') !== -1) {
|
|
201
|
+
return 7;
|
|
202
|
+
}
|
|
194
203
|
return 2;
|
|
195
204
|
};
|
|
196
205
|
|
|
@@ -216,7 +225,7 @@ export class SweeperP2p extends P2pApi {
|
|
|
216
225
|
if (!this.isConnecting) {
|
|
217
226
|
this.reconnectP2p(() => {
|
|
218
227
|
// 重连之后重新开启文件下载, 这里的成功不需要注册断开事件
|
|
219
|
-
this.startObserverSweeperDataByP2P(this.downloadType, this.devId, this.onReceiveMapData, this.onReceivePathData, this.onReceiveAIPicData, this.onReceiveAIPicHDData);
|
|
228
|
+
this.startObserverSweeperDataByP2P(this.downloadType, this.devId, this.onReceiveMapData, this.onReceivePathData, this.onReceiveAIPicData, this.onReceiveAIPicHDData, this.onReceiveWifiMapData);
|
|
220
229
|
}, '');
|
|
221
230
|
} else {
|
|
222
231
|
logger('warn', {
|
|
@@ -232,7 +241,7 @@ export class SweeperP2p extends P2pApi {
|
|
|
232
241
|
* @param downloadType
|
|
233
242
|
* 0: 下载断开 1: 持续下载
|
|
234
243
|
*/
|
|
235
|
-
startObserverSweeperDataByP2P = async (downloadType, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData, onDefineStructuredMode) => {
|
|
244
|
+
startObserverSweeperDataByP2P = async (downloadType, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData, onReceiveWifiMapData, onDefineStructuredMode) => {
|
|
236
245
|
var _this$file$items;
|
|
237
246
|
if (![0, 1].some(item => item === downloadType)) {
|
|
238
247
|
logger('warn', {
|
|
@@ -242,6 +251,7 @@ export class SweeperP2p extends P2pApi {
|
|
|
242
251
|
}
|
|
243
252
|
this.onReceiveMapData = onReceiveMapData;
|
|
244
253
|
this.onReceivePathData = onReceivePathData;
|
|
254
|
+
this.onReceiveWifiMapData = onReceiveWifiMapData;
|
|
245
255
|
this.onDefineStructuredMode = onDefineStructuredMode;
|
|
246
256
|
this.onReceiveAIPicData = onReceiveAIPicData || (() => {
|
|
247
257
|
// do nothing
|
|
@@ -290,7 +300,7 @@ export class SweeperP2p extends P2pApi {
|
|
|
290
300
|
this.isConnecting = false;
|
|
291
301
|
this.connectDevice(() => {
|
|
292
302
|
// 重连之后重新开启文件下载, 这里的成功不需要注册断开事件
|
|
293
|
-
this.startObserverSweeperDataByP2P(this.downloadType, this.devId, this.onReceiveMapData, this.onReceivePathData, this.onReceiveAIPicData, this.onReceiveAIPicHDData);
|
|
303
|
+
this.startObserverSweeperDataByP2P(this.downloadType, this.devId, this.onReceiveMapData, this.onReceivePathData, this.onReceiveAIPicData, this.onReceiveAIPicHDData, this.onReceiveWifiMapData);
|
|
294
304
|
});
|
|
295
305
|
});
|
|
296
306
|
});
|
|
@@ -324,7 +334,7 @@ export class SweeperP2p extends P2pApi {
|
|
|
324
334
|
this.isConnecting = false;
|
|
325
335
|
this.connectDevice(() => {
|
|
326
336
|
// 重连之后重新开启文件下载, 这里的成功不需要注册断开事件
|
|
327
|
-
this.startObserverSweeperDataByP2P(this.downloadType, this.devId, this.onReceiveMapData, this.onReceivePathData, this.onReceiveAIPicData, this.onReceiveAIPicHDData);
|
|
337
|
+
this.startObserverSweeperDataByP2P(this.downloadType, this.devId, this.onReceiveMapData, this.onReceivePathData, this.onReceiveAIPicData, this.onReceiveAIPicHDData, this.onReceiveWifiMapData);
|
|
328
338
|
});
|
|
329
339
|
});
|
|
330
340
|
});
|
|
@@ -530,6 +540,9 @@ export class SweeperP2p extends P2pApi {
|
|
|
530
540
|
if (type === 5) {
|
|
531
541
|
this.onReceiveAIPicHDData(hexValue);
|
|
532
542
|
}
|
|
543
|
+
if (type === 7) {
|
|
544
|
+
this.onReceiveWifiMapData(hexValue);
|
|
545
|
+
}
|
|
533
546
|
}
|
|
534
547
|
}
|
|
535
548
|
}
|
|
@@ -571,6 +584,9 @@ export class SweeperP2p extends P2pApi {
|
|
|
571
584
|
if (type === 5) {
|
|
572
585
|
this.onReceiveAIPicHDData(hexValue);
|
|
573
586
|
}
|
|
587
|
+
if (type === 7) {
|
|
588
|
+
this.onReceiveWifiMapData(hexValue);
|
|
589
|
+
}
|
|
574
590
|
this.cacheData[type] = hexValue;
|
|
575
591
|
}
|
|
576
592
|
},
|
package/lib/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare const useP2PDataStream: (devId: string, onReceiveMapData: (data: string)
|
|
|
5
5
|
logTag?: string | undefined;
|
|
6
6
|
onReceiveAIPicData?: ((data: string) => void) | undefined;
|
|
7
7
|
onReceiveAIPicHDData?: ((data: string) => void) | undefined;
|
|
8
|
+
onReceiveWifiMapData?: ((data: string) => void) | undefined;
|
|
8
9
|
onLogger?: TOnLogger | undefined;
|
|
9
10
|
onDefineStructuredMode?: ((isStructured: boolean) => void) | undefined;
|
|
10
11
|
} | undefined) => {
|
package/lib/index.js
CHANGED
|
@@ -14,6 +14,7 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
|
|
|
14
14
|
logTag,
|
|
15
15
|
onReceiveAIPicData,
|
|
16
16
|
onReceiveAIPicHDData,
|
|
17
|
+
onReceiveWifiMapData,
|
|
17
18
|
onLogger,
|
|
18
19
|
onDefineStructuredMode
|
|
19
20
|
} = opt || {};
|
|
@@ -127,7 +128,7 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
|
|
|
127
128
|
eventName: 'connectDeviceSuccess'
|
|
128
129
|
});
|
|
129
130
|
isInit.current = true;
|
|
130
|
-
SweeperP2pInstance.startObserverSweeperDataByP2P(1, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData, onDefineStructuredMode);
|
|
131
|
+
SweeperP2pInstance.startObserverSweeperDataByP2P(1, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData, onReceiveWifiMapData, onDefineStructuredMode);
|
|
131
132
|
offSessionStatusChange.current = SweeperP2pInstance.onSessionStatusChange(SweeperP2pInstance.sessionStatusCallback);
|
|
132
133
|
}, () => {
|
|
133
134
|
trace.pointFn({
|
|
@@ -140,7 +141,7 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
|
|
|
140
141
|
devId,
|
|
141
142
|
eventName: 'reconnectP2p'
|
|
142
143
|
});
|
|
143
|
-
SweeperP2pInstance.startObserverSweeperDataByP2P(1, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData);
|
|
144
|
+
SweeperP2pInstance.startObserverSweeperDataByP2P(1, devId, onReceiveMapData, onReceivePathData, onReceiveAIPicData, onReceiveAIPicHDData, onReceiveWifiMapData);
|
|
144
145
|
// 这里失败重连需要注册断开重连的事件
|
|
145
146
|
offSessionStatusChange.current = SweeperP2pInstance.onSessionStatusChange(SweeperP2pInstance.sessionStatusCallback);
|
|
146
147
|
}, '');
|
package/lib/mqtt/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { useDevInfo } from './useDevInfo';
|
|
|
3
3
|
import { usePartDivision } from './usePartDivision';
|
|
4
4
|
import { usePartMerge } from './usePartMerge';
|
|
5
5
|
import { usePassword } from './usePassword';
|
|
6
|
+
import { useWifiMap } from './useWifiMap';
|
|
6
7
|
import { useQuiteHours } from './useQuiteHours';
|
|
7
8
|
import { useVirtualArea } from './useVirtualArea';
|
|
8
9
|
import { useSpotClean } from './useSpotClean';
|
|
@@ -14,4 +15,4 @@ import { useHistoryMap } from './useHistoryMap';
|
|
|
14
15
|
import { useVoice } from './useVoice';
|
|
15
16
|
import { useRoomProperty } from './useRoomProperty';
|
|
16
17
|
import { useResetMap } from './useResetMap';
|
|
17
|
-
export { useVoice, MqttProvider, useDevInfo, usePartMerge, usePartDivision, usePassword, useQuiteHours, useVirtualArea, useSpotClean, useZoneClean, useSelectRoomClean, useVirtualWall, useSchedule, useHistoryMap, useRoomProperty, useResetMap, };
|
|
18
|
+
export { useVoice, MqttProvider, useDevInfo, usePartMerge, usePartDivision, usePassword, useWifiMap, useQuiteHours, useVirtualArea, useSpotClean, useZoneClean, useSelectRoomClean, useVirtualWall, useSchedule, useHistoryMap, useRoomProperty, useResetMap, };
|
package/lib/mqtt/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { useDevInfo } from './useDevInfo';
|
|
|
3
3
|
import { usePartDivision } from './usePartDivision';
|
|
4
4
|
import { usePartMerge } from './usePartMerge';
|
|
5
5
|
import { usePassword } from './usePassword';
|
|
6
|
+
import { useWifiMap } from './useWifiMap';
|
|
6
7
|
import { useQuiteHours } from './useQuiteHours';
|
|
7
8
|
import { useVirtualArea } from './useVirtualArea';
|
|
8
9
|
import { useSpotClean } from './useSpotClean';
|
|
@@ -14,4 +15,4 @@ import { useHistoryMap } from './useHistoryMap';
|
|
|
14
15
|
import { useVoice } from './useVoice';
|
|
15
16
|
import { useRoomProperty } from './useRoomProperty';
|
|
16
17
|
import { useResetMap } from './useResetMap';
|
|
17
|
-
export { useVoice, MqttProvider, useDevInfo, usePartMerge, usePartDivision, usePassword, useQuiteHours, useVirtualArea, useSpotClean, useZoneClean, useSelectRoomClean, useVirtualWall, useSchedule, useHistoryMap, useRoomProperty, useResetMap };
|
|
18
|
+
export { useVoice, MqttProvider, useDevInfo, usePartMerge, usePartDivision, usePassword, useWifiMap, useQuiteHours, useVirtualArea, useSpotClean, useZoneClean, useSelectRoomClean, useVirtualWall, useSchedule, useHistoryMap, useRoomProperty, useResetMap };
|
package/lib/mqtt/type/index.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ export declare enum PasswordEnum {
|
|
|
13
13
|
check = "passwordCheck",
|
|
14
14
|
checkRst = "passwordCheckRst"
|
|
15
15
|
}
|
|
16
|
+
export declare enum WifiMapEnum {
|
|
17
|
+
query = "WifiMapQry",
|
|
18
|
+
set = "WifiMapSet",
|
|
19
|
+
rst = "WifiMapRst"
|
|
20
|
+
}
|
|
16
21
|
export type RoomPreference = {
|
|
17
22
|
suctions?: string[];
|
|
18
23
|
cisterns?: string[];
|
package/lib/mqtt/type/index.js
CHANGED
|
@@ -8,4 +8,10 @@ export let PasswordEnum = /*#__PURE__*/function (PasswordEnum) {
|
|
|
8
8
|
PasswordEnum["check"] = "passwordCheck";
|
|
9
9
|
PasswordEnum["checkRst"] = "passwordCheckRst";
|
|
10
10
|
return PasswordEnum;
|
|
11
|
+
}({});
|
|
12
|
+
export let WifiMapEnum = /*#__PURE__*/function (WifiMapEnum) {
|
|
13
|
+
WifiMapEnum["query"] = "WifiMapQry";
|
|
14
|
+
WifiMapEnum["set"] = "WifiMapSet";
|
|
15
|
+
WifiMapEnum["rst"] = "WifiMapRst";
|
|
16
|
+
return WifiMapEnum;
|
|
11
17
|
}({});
|
|
@@ -21,6 +21,11 @@ export declare enum PasswordEnum {
|
|
|
21
21
|
check = "passwordCheck",
|
|
22
22
|
checkRst = "passwordCheckRst"
|
|
23
23
|
}
|
|
24
|
+
export declare enum WifiMapEnum {
|
|
25
|
+
query = "WifiMapQry",
|
|
26
|
+
set = "WifiMapSet",
|
|
27
|
+
rst = "WifiMapRst"
|
|
28
|
+
}
|
|
24
29
|
export declare enum RoomPropertyEnum {
|
|
25
30
|
set = "roomPropertySet",
|
|
26
31
|
query = "roomPropertyQry"
|
|
@@ -32,6 +32,12 @@ export let PasswordEnum = /*#__PURE__*/function (PasswordEnum) {
|
|
|
32
32
|
PasswordEnum["checkRst"] = "passwordCheckRst";
|
|
33
33
|
return PasswordEnum;
|
|
34
34
|
}({});
|
|
35
|
+
export let WifiMapEnum = /*#__PURE__*/function (WifiMapEnum) {
|
|
36
|
+
WifiMapEnum["query"] = "WifiMapQry";
|
|
37
|
+
WifiMapEnum["set"] = "WifiMapSet";
|
|
38
|
+
WifiMapEnum["rst"] = "WifiMapRst";
|
|
39
|
+
return WifiMapEnum;
|
|
40
|
+
}({});
|
|
35
41
|
export let RoomPropertyEnum = /*#__PURE__*/function (RoomPropertyEnum) {
|
|
36
42
|
RoomPropertyEnum["set"] = "roomPropertySet";
|
|
37
43
|
RoomPropertyEnum["query"] = "roomPropertyQry";
|
package/lib/mqtt/useSpotClean.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "core-js/modules/esnext.iterator.map.js";
|
|
1
2
|
// 定点清扫
|
|
2
3
|
|
|
3
4
|
import { isArray } from 'lodash-es';
|
|
@@ -73,7 +74,7 @@ export const useSpotClean = devId => {
|
|
|
73
74
|
reqType: SpotCleanEnum.set,
|
|
74
75
|
message: {
|
|
75
76
|
num,
|
|
76
|
-
polygons:
|
|
77
|
+
polygons: spots.map(spot => pointsToString([spot], origin)),
|
|
77
78
|
suctions,
|
|
78
79
|
cisterns,
|
|
79
80
|
cleanCounts,
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PromiseWithRejection } from './promise';
|
|
2
|
+
type TRequestWifiMap = () => PromiseWithRejection | Promise<void>;
|
|
3
|
+
type TSetWifiMap = () => PromiseWithRejection;
|
|
4
|
+
export declare const useWifiMap: (devId: string) => {
|
|
5
|
+
requestWifiMap: TRequestWifiMap;
|
|
6
|
+
setWifiMap: TSetWifiMap;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createSetCommonParams } from './createCommonOptions';
|
|
2
|
+
import { normalResolve } from './promise';
|
|
3
|
+
import { WifiMapEnum } from './type';
|
|
4
|
+
import { useContext } from 'react';
|
|
5
|
+
import { SingletonContext } from './mqttProvider';
|
|
6
|
+
export const useWifiMap = devId => {
|
|
7
|
+
const {
|
|
8
|
+
useMqtt
|
|
9
|
+
} = useContext(SingletonContext);
|
|
10
|
+
|
|
11
|
+
// 请求密码状态
|
|
12
|
+
|
|
13
|
+
// 设置密码
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
requestWifiMap: () => {
|
|
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);
|
|
24
|
+
},
|
|
25
|
+
setWifiMap: () => {
|
|
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);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|