@ray-js/robot-data-stream 0.0.12-beta-6 → 0.0.12-beta-7

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/index.js CHANGED
@@ -29,7 +29,7 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
29
29
  // 判断进入后台之后,维持定时器,如果进入后台超过2分钟, 则断开P2P
30
30
  timer.current = setTimeout(() => {
31
31
  logger('info', {
32
- msg: 'background timer has been exe'
32
+ msg: `background timer has been exe,isAppOnBackground: ${isAppOnBackground.current}`
33
33
  }, onLogger);
34
34
  if (isAppOnBackground.current) {
35
35
  unmount();
@@ -45,8 +45,13 @@ const useP2PDataStream = (devId, onReceiveMapData, onReceivePathData, opt) => {
45
45
  }, onLogger);
46
46
  timer.current && clearTimeout(timer.current);
47
47
  setTimeout(() => {
48
- var _ty$p2p$isP2PActiveSy, _ty$p2p;
49
- if (!isInit.current || !((_ty$p2p$isP2PActiveSy = (_ty$p2p = ty.p2p).isP2PActiveSync) !== null && _ty$p2p$isP2PActiveSy !== void 0 && _ty$p2p$isP2PActiveSy.call(_ty$p2p, {
48
+ var _ty$p2p$isP2PActiveSy, _ty$p2p, _ty$p2p$isP2PActiveSy2, _ty$p2p2;
49
+ logger('info', {
50
+ msg: `hooks onAppShow and after 500ms : ${isInit.current} isP2PActiveSync: ${(_ty$p2p$isP2PActiveSy = (_ty$p2p = ty.p2p).isP2PActiveSync) === null || _ty$p2p$isP2PActiveSy === void 0 ? void 0 : _ty$p2p$isP2PActiveSy.call(_ty$p2p, {
51
+ deviceId: devId
52
+ })}`
53
+ }, onLogger);
54
+ if (!isInit.current || !((_ty$p2p$isP2PActiveSy2 = (_ty$p2p2 = ty.p2p).isP2PActiveSync) !== null && _ty$p2p$isP2PActiveSy2 !== void 0 && _ty$p2p$isP2PActiveSy2.call(_ty$p2p2, {
50
55
  deviceId: devId
51
56
  }))) {
52
57
  connectP2p();
@@ -32,17 +32,21 @@ export const usePartDivision = devId => {
32
32
  return {
33
33
  setPartDivision: (points, roomId, origin) => {
34
34
  if (useMqtt) {
35
- const pointStr = pointsToString(points, origin);
36
- const params = createSetCommonParams({
37
- deviceId: devId,
38
- reqType: PartDivisionEnum.set,
39
- message: {
40
- lines: [pointStr],
41
- ids: [roomId]
42
- }
43
- });
44
- ty.device.sendMqttMessage(params);
45
- return normalResolve(PartDivisionEnum.query, params.message.taskId);
35
+ try {
36
+ const pointStr = pointsToString(points, origin);
37
+ const params = createSetCommonParams({
38
+ deviceId: devId,
39
+ reqType: PartDivisionEnum.set,
40
+ message: {
41
+ lines: [pointStr],
42
+ ids: [roomId]
43
+ }
44
+ });
45
+ ty.device.sendMqttMessage(params);
46
+ return normalResolve(PartDivisionEnum.query, params.message.taskId);
47
+ } catch (e) {
48
+ throw new Error('房间分隔失败');
49
+ }
46
50
  }
47
51
  const command = encodePartitionDivision0x1c({
48
52
  version: commandVersion,
@@ -7,15 +7,20 @@ const pointToString = point => {
7
7
  };
8
8
  export const pointsToString = (points, origin) => {
9
9
  let newPoints = [];
10
- const ox = origin.x;
11
- const oy = origin.y;
12
- newPoints = map(points, i => {
13
- return {
14
- x: floor(i.x - ox, 0),
15
- y: floor(-(i.y - oy), 0)
16
- };
17
- });
18
- return join(map(newPoints, pointToString), ',');
10
+ try {
11
+ const ox = origin.x;
12
+ const oy = origin.y;
13
+ newPoints = map(points, i => {
14
+ return {
15
+ x: floor(i.x - ox, 0),
16
+ y: floor(-(i.y - oy), 0)
17
+ };
18
+ });
19
+ return join(map(newPoints, pointToString), ',');
20
+ } catch (e) {
21
+ console.error('pointsToString error', e);
22
+ throw new Error('pointsToString error');
23
+ }
19
24
  };
20
25
  export const isJSONString = str => {
21
26
  if (typeof str !== 'string') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/robot-data-stream",
3
- "version": "0.0.12-beta-6",
3
+ "version": "0.0.12-beta-7",
4
4
  "description": "扫地机P2P数据流标准化组件",
5
5
  "main": "lib/index",
6
6
  "files": [