@ray-js/robot-data-stream 0.0.17-beta.3 → 0.0.17-beta.4
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/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/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 };
|
|
@@ -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 {};
|
|
@@ -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
|
+
};
|