@ray-js/robot-data-stream 0.0.17-beta.3 → 0.0.17-beta.5
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/mqtt/index.d.ts +2 -1
- package/lib/mqtt/index.js +2 -1
- package/lib/mqtt/type/protocols/cruiseProtocol.d.ts +8 -10
- package/lib/mqtt/type/protocols/index.d.ts +1 -0
- package/lib/mqtt/type/protocols/index.js +2 -1
- package/lib/mqtt/type/protocols/mcsRoomInfoProtocol.d.ts +18 -0
- package/lib/mqtt/type/protocols/mcsRoomInfoProtocol.js +1 -0
- package/lib/mqtt/type/protocols/purifierScheduleProtocol.d.ts +10 -4
- package/lib/mqtt/type/requestType.d.ts +3 -0
- package/lib/mqtt/type/requestType.js +6 -0
- package/lib/mqtt/useMcsRoomInfo.d.ts +9 -0
- package/lib/mqtt/useMcsRoomInfo.js +43 -0
- package/package.json +1 -1
package/lib/mqtt/index.d.ts
CHANGED
|
@@ -21,4 +21,5 @@ import { useDeviceModel } from './useDeviceModel';
|
|
|
21
21
|
import { useFurnitureModel } from './useFurnitureModel';
|
|
22
22
|
import { usePurifierSchedule } from './usePurifierSchedule';
|
|
23
23
|
import { useCruise } from './useCruise';
|
|
24
|
-
|
|
24
|
+
import { useMcsRoomInfo } from './useMcsRoomInfo';
|
|
25
|
+
export { useCarpet, useCarpetClean, useVoice, MqttProvider, useDeviceModel, useFurnitureModel, useDevInfo, usePartMerge, usePartDivision, usePassword, useWifiMap, useQuiteHours, useVirtualArea, useSpotClean, useZoneClean, useSelectRoomClean, useVirtualWall, useSchedule, useHistoryMap, useRoomProperty, useResetMap, usePurifierSchedule, useCruise, useMcsRoomInfo, };
|
package/lib/mqtt/index.js
CHANGED
|
@@ -21,4 +21,5 @@ import { useDeviceModel } from './useDeviceModel';
|
|
|
21
21
|
import { useFurnitureModel } from './useFurnitureModel';
|
|
22
22
|
import { usePurifierSchedule } from './usePurifierSchedule';
|
|
23
23
|
import { useCruise } from './useCruise';
|
|
24
|
-
|
|
24
|
+
import { useMcsRoomInfo } from './useMcsRoomInfo';
|
|
25
|
+
export { useCarpet, useCarpetClean, useVoice, MqttProvider, useDeviceModel, useFurnitureModel, useDevInfo, usePartMerge, usePartDivision, usePassword, useWifiMap, useQuiteHours, useVirtualArea, useSpotClean, useZoneClean, useSelectRoomClean, useVirtualWall, useSchedule, useHistoryMap, useRoomProperty, useResetMap, usePurifierSchedule, useCruise, useMcsRoomInfo };
|
|
@@ -3,15 +3,15 @@ import type { BaseResponse } from './base';
|
|
|
3
3
|
export type CruiseCmd = 'start' | 'pause' | 'resume' | 'stop';
|
|
4
4
|
/** 巡航状态:idle 未巡航 / cruising 巡航中 / paused 已暂停 */
|
|
5
5
|
export type CruiseStatus = 'idle' | 'cruising' | 'paused';
|
|
6
|
-
/** 巡航类型:whole_house 全屋巡航 /
|
|
7
|
-
export type CruiseType = 'whole_house' | '
|
|
6
|
+
/** 巡航类型:whole_house 全屋巡航 / spot 定点巡航(按净化点坐标) */
|
|
7
|
+
export type CruiseType = 'whole_house' | 'spot';
|
|
8
8
|
export interface SetCruiseData {
|
|
9
9
|
/** start 开始 / pause 暂停 / resume 继续 / stop 结束 */
|
|
10
10
|
cmd: CruiseCmd;
|
|
11
11
|
/** 巡航类型,cmd 为 start 时必填 */
|
|
12
12
|
cruiseType?: CruiseType;
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/** spot 定点巡航时的净化点坐标列表,格式 "x, y";不传表示全部净化点 */
|
|
14
|
+
polygons?: string[];
|
|
15
15
|
version?: string;
|
|
16
16
|
}
|
|
17
17
|
export interface RequestCruiseData {
|
|
@@ -23,12 +23,10 @@ export interface CruiseResponse extends BaseResponse {
|
|
|
23
23
|
mapId: number;
|
|
24
24
|
/** 巡航类型;idle 时可不携带 */
|
|
25
25
|
cruiseType?: CruiseType;
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
|
|
30
|
-
/** 当前工作点坐标 "x, y" */
|
|
31
|
-
polygon?: string;
|
|
26
|
+
/** spot 定点巡航时的净化点坐标列表,格式 "x, y" */
|
|
27
|
+
polygons?: string[];
|
|
28
|
+
/** 当前正在净化的坐标 "x, y" */
|
|
29
|
+
currentPolygon?: string;
|
|
32
30
|
}
|
|
33
31
|
export type TRequestCruise = (message?: RequestCruiseData) => Promise<CruiseResponse>;
|
|
34
32
|
export type TSetCruise = (message: SetCruiseData) => Promise<CruiseResponse>;
|
|
@@ -19,4 +19,5 @@ export * from './carpetCleanProtocol';
|
|
|
19
19
|
export * from './devInfoProtocol';
|
|
20
20
|
export * from './roomPropertyProtocol';
|
|
21
21
|
export * from './purifierScheduleProtocol';
|
|
22
|
-
export * from './cruiseProtocol';
|
|
22
|
+
export * from './cruiseProtocol';
|
|
23
|
+
export * from './mcsRoomInfoProtocol';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BaseResponse } from './base';
|
|
2
|
+
export interface RequestMcsRoomInfoData {
|
|
3
|
+
/** 协议版本;默认 '1.0.0' */
|
|
4
|
+
version?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* McsRoomInfoQry 应答(RVC SDK Alexa 语音方案协议)。
|
|
8
|
+
* 注意:房间字段为 snake_case(与设备端 MCS_ROOM_INFO_S 结构体对应)。
|
|
9
|
+
*/
|
|
10
|
+
export interface McsRoomInfoResponse extends BaseResponse {
|
|
11
|
+
/** 当前地图 ID */
|
|
12
|
+
mapId: number;
|
|
13
|
+
/** 设备当前所在房间 ID(与 roomPropertyQry 的 ids 对应) */
|
|
14
|
+
curr_room_id: number;
|
|
15
|
+
/** 设备当前所在房间名称 */
|
|
16
|
+
curr_room_name: string;
|
|
17
|
+
}
|
|
18
|
+
export type TRequestMcsRoomInfo = (message?: RequestMcsRoomInfoData) => Promise<McsRoomInfoResponse>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { BaseResponse } from './base';
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* 工作类型:
|
|
4
|
+
* - select_room 选房净化(携带 ids)
|
|
5
|
+
* - whole_house 整屋净化
|
|
6
|
+
* - spot 定点净化
|
|
7
|
+
* - current_location 原地净化
|
|
8
|
+
*/
|
|
9
|
+
export type PurifierWorkType = 'select_room' | 'whole_house' | 'spot' | 'current_location';
|
|
4
10
|
/** 风速档位,透传字符串,不限制具体取值(不同设备支持的档位不同) */
|
|
5
11
|
export type PurifierFanMode = string;
|
|
6
12
|
export interface PurifierScheduleItem {
|
|
@@ -10,9 +16,9 @@ export interface PurifierScheduleItem {
|
|
|
10
16
|
cycle: number[];
|
|
11
17
|
/** 执行时间 [时, 分],24 小时制 */
|
|
12
18
|
time: number[];
|
|
13
|
-
/** 房间 ID 列表;workTypes 为 whole_house 时为空数组 */
|
|
19
|
+
/** 房间 ID 列表;workTypes 为 whole_house / spot / current_location 时为空数组 */
|
|
14
20
|
ids: number[];
|
|
15
|
-
/** 工作类型,与 ids
|
|
21
|
+
/** 工作类型,与 ids 对齐;非 select_room 时为单元素 */
|
|
16
22
|
workTypes: PurifierWorkType[];
|
|
17
23
|
/** 风速,与 ids 对齐(整屋时单元素) */
|
|
18
24
|
fanModes: PurifierFanMode[];
|
|
@@ -151,4 +151,10 @@ export let CruiseEnum = /*#__PURE__*/function (CruiseEnum) {
|
|
|
151
151
|
CruiseEnum["query"] = "purifierCruiseQry";
|
|
152
152
|
CruiseEnum["set"] = "purifierCruiseSet";
|
|
153
153
|
return CruiseEnum;
|
|
154
|
+
}({});
|
|
155
|
+
|
|
156
|
+
// 设备当前所在房间(MCS 房间信息;RVC SDK Alexa 语音方案协议,通常仅在任务中查询)
|
|
157
|
+
export let McsRoomInfoEnum = /*#__PURE__*/function (McsRoomInfoEnum) {
|
|
158
|
+
McsRoomInfoEnum["query"] = "McsRoomInfoQry";
|
|
159
|
+
return McsRoomInfoEnum;
|
|
154
160
|
}({});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type TRequestMcsRoomInfo } from './type/protocols/mcsRoomInfoProtocol';
|
|
2
|
+
/**
|
|
3
|
+
* 自定义 Hook,用于查询设备当前所在房间(mapId / currNameId / currName)。
|
|
4
|
+
* 面板通常仅在设备处于任务中时查询,用于展示「当前位置」。
|
|
5
|
+
* @returns 包含 requestMcsRoomInfo 函数的对象
|
|
6
|
+
*/
|
|
7
|
+
export declare const useMcsRoomInfo: () => {
|
|
8
|
+
requestMcsRoomInfo: TRequestMcsRoomInfo;
|
|
9
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// 设备当前所在房间(MCS 房间信息)
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { handleMqttError, useStructuredMessage } from './hooks/useStructuredMessage';
|
|
4
|
+
import { SingletonContext } from './mqttProvider';
|
|
5
|
+
import { McsRoomInfoEnum } from './type';
|
|
6
|
+
/**
|
|
7
|
+
* 自定义 Hook,用于查询设备当前所在房间(mapId / currNameId / currName)。
|
|
8
|
+
* 面板通常仅在设备处于任务中时查询,用于展示「当前位置」。
|
|
9
|
+
* @returns 包含 requestMcsRoomInfo 函数的对象
|
|
10
|
+
*/
|
|
11
|
+
export const useMcsRoomInfo = () => {
|
|
12
|
+
const {
|
|
13
|
+
useMqtt
|
|
14
|
+
} = useContext(SingletonContext);
|
|
15
|
+
const {
|
|
16
|
+
sendStructuredMessage
|
|
17
|
+
} = useStructuredMessage();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 查询设备当前所在房间
|
|
21
|
+
* @param message 可选参数,包含版本号
|
|
22
|
+
* @returns Promise<McsRoomInfoResponse> 响应结果
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
requestMcsRoomInfo: function () {
|
|
27
|
+
let message = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
28
|
+
version: '1.0.0'
|
|
29
|
+
};
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
try {
|
|
32
|
+
if (!useMqtt) {
|
|
33
|
+
reject(new Error('useMqtt is not used'));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
sendStructuredMessage(McsRoomInfoEnum.query, message, resolve, error => reject(handleMqttError(error, 'Failed to request mcs room info')));
|
|
37
|
+
} catch (error) {
|
|
38
|
+
reject(handleMqttError(error, 'Failed to request mcs room info'));
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|