@ray-js/lock-sdk 1.2.1-beta.7 → 1.2.1-beta.8

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.
@@ -48,4 +48,9 @@ interface GetDeviceCurrentMeidaConfigResult {
48
48
  vedioClaritys: number[];
49
49
  }
50
50
  export declare const getDeviceCurrentMeidaConfig: (devId: string) => Promise<GetDeviceCurrentMeidaConfigResult>;
51
+ interface GetVideoResolutionMarkResult {
52
+ capability: number[];
53
+ cloudCapability: string[];
54
+ }
55
+ export declare const getVideoResolutionMark: (devId: string) => Promise<GetVideoResolutionMarkResult>;
51
56
  export {};
package/lib/api/video.js CHANGED
@@ -70,3 +70,13 @@ export const getDeviceCurrentMeidaConfig = (devId) => {
70
70
  },
71
71
  });
72
72
  };
73
+ export const getVideoResolutionMark = (devId) => {
74
+ return requestApi({
75
+ logName: "getVideoResolutionMark",
76
+ api: `${THING}.m.device.lock.capability.cloud.get`,
77
+ version: "1.0",
78
+ data: {
79
+ devId,
80
+ },
81
+ });
82
+ };
@@ -16,3 +16,7 @@ export declare function updateDpPeriodTime(dpCode: string, data: UpdateDpPeriodT
16
16
  export declare function connectDevice(options?: ConnectDeviceOptions): Promise<true>;
17
17
  export declare function gotoService(params?: GotoServiceParams): Promise<void>;
18
18
  export declare function validatePwdComplexity(password: string): Promise<boolean>;
19
+ export interface AwakeDeviceOptions {
20
+ timeout?: number;
21
+ }
22
+ export declare function awakeDevice(options?: AwakeDeviceOptions): Promise<true>;
@@ -2,7 +2,7 @@ import { resolveRuntimeFromExportThis } from "../bootstrap/resolve-runtime-from-
2
2
  import { openSceneForRuntime } from "../../../feature/misc/open-scene";
3
3
  import { isSupportBleControlForRuntime } from "../../../feature/misc/ble-control";
4
4
  import { getDpPeriodTimeForRuntime, updateDpPeriodTimeForRuntime, } from "../../../feature/misc/dp-period";
5
- import { connectDeviceForRuntime } from "../../../feature/misc/connect-device";
5
+ import { awakeDeviceForRuntime, connectDeviceForRuntime, } from "../../../feature/misc/connect-device";
6
6
  import { validatePwdComplexityForRuntime } from "../../../feature/misc/validate-pwd";
7
7
  import { gotoServiceForRuntime, } from "../../../feature/service/goto-service";
8
8
  export { parseDpPeriodTime } from "../../../feature/misc/dp-period";
@@ -28,3 +28,6 @@ export async function gotoService(params) {
28
28
  export async function validatePwdComplexity(password) {
29
29
  return validatePwdComplexityForRuntime(resolveRuntimeFromExportThis(this), password);
30
30
  }
31
+ export async function awakeDevice(options) {
32
+ return awakeDeviceForRuntime(resolveRuntimeFromExportThis(this), options);
33
+ }
@@ -3,6 +3,9 @@ import { CommunicationType, ProductCommunicationType } from "../../constant";
3
3
  import { checkShowMatterMutilpleShare } from "../../platform/device";
4
4
  import { ipc } from "../../platform";
5
5
  import { getWithLocalCache } from "../storage/swr-cache";
6
+ import { getVideoResolutionMark } from "../../api/video";
7
+ import dpCodes from "../../config/dp-code";
8
+ import { hasDpForRuntime } from "../dp/has-dp";
6
9
  export const hasCapabilityForRuntime = (runtime, capability) => runtime.config.communication.includes(capability);
7
10
  export const isBlePureDeviceForRuntime = (rt) => hasCapabilityForRuntime(rt, ProductCommunicationType.BLUETOOTH) &&
8
11
  rt.config.communication.length === 1;
@@ -68,7 +71,7 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
68
71
  return rt.cache.deviceAdvanceAbilityCache;
69
72
  }
70
73
  const devId = rt.config.devInfo.devId;
71
- const [productAbilitiesRes, deviceAdvancedAbilityRes, tttList] = await Promise.allSettled([
74
+ const [productAbilitiesRes, deviceAdvancedAbilityRes, tttList, videoMarkRes] = await Promise.allSettled([
72
75
  getWithLocalCache(rt, "productAbilities", () => getProductAbilities(devId, [
73
76
  "tyabi4ucx5",
74
77
  "tyabis9tpe",
@@ -76,18 +79,25 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
76
79
  "tyabipd4hh",
77
80
  "tyabin4u5v",
78
81
  "visual_door_lock_cloud_store",
79
- "tyabixkep7",
80
- "tyabig3wt9",
81
82
  ])),
82
83
  getWithLocalCache(rt, "deviceAdvancedAbility", () => getDeviceAdvancedAbility(devId)),
83
84
  ipc.getTTTAbilityKeyList("isSupportedVRMode"),
85
+ hasDpForRuntime(rt, dpCodes.initiativeMessage)
86
+ ? getWithLocalCache(rt, "videoResolutionMark", () => getVideoResolutionMark(devId))
87
+ : Promise.resolve({
88
+ capability: [],
89
+ cloudCapability: [],
90
+ }),
84
91
  ]);
85
92
  const productAbilities = productAbilitiesRes.status === "fulfilled" ? productAbilitiesRes.value : [];
86
93
  const tttAbList = tttList.status === "fulfilled" ? tttList.value.abilityList : [];
94
+ const videoMark = videoMarkRes.status === "fulfilled"
95
+ ? videoMarkRes.value
96
+ : { capability: [], cloudCapability: [] };
87
97
  const deviceAdvanceAbilityCache = {
88
98
  videoConfig: {
89
- isLowResolution: false,
90
- isHighResolution: false,
99
+ isLowResolution: videoMark?.cloudCapability?.includes("tyabig3wt9"),
100
+ isHighResolution: videoMark?.cloudCapability?.includes("tyabixkep7"),
91
101
  },
92
102
  cloudStorage: {
93
103
  support: false,
@@ -129,14 +139,6 @@ export const getDeviceAdvancedAbilitiesForRuntime = async (rt) => {
129
139
  if (item.isOpen) {
130
140
  const data = item.extConfig ? JSON.parse(item.extConfig) : {};
131
141
  switch (item.abilityCode) {
132
- case "tyabixkep7": {
133
- deviceAdvanceAbilityCache.videoConfig.isHighResolution = true;
134
- break;
135
- }
136
- case "tyabig3wt9": {
137
- deviceAdvanceAbilityCache.videoConfig.isLowResolution = true;
138
- break;
139
- }
140
142
  case "visual_door_lock_cloud_store":
141
143
  deviceAdvanceAbilityCache.cloudStorage.support = true;
142
144
  break;
@@ -1,2 +1,5 @@
1
1
  import type { LockDeviceRuntime } from "../../runtime/LockDeviceRuntime";
2
2
  export declare function connectDeviceForRuntime(rt: LockDeviceRuntime, timeout?: number): Promise<true>;
3
+ export declare const awakeDeviceForRuntime: (runtime: LockDeviceRuntime, options?: {
4
+ timeout?: number;
5
+ }) => Promise<true>;
@@ -205,3 +205,8 @@ export async function connectDeviceForRuntime(rt, timeout) {
205
205
  });
206
206
  throw error;
207
207
  }
208
+ export const awakeDeviceForRuntime = (runtime, options) => {
209
+ const cfg = runtime.config;
210
+ const devId = cfg.devInfo.devId;
211
+ return awakeDevice(devId, options?.timeout);
212
+ };
@@ -172,8 +172,10 @@ export const initState = async (runtime) => {
172
172
  });
173
173
  setTimeout(() => {
174
174
  sdkLog("debug", "initState", "scheduledSyncUnlock", { devId });
175
- syncT0(runtime);
176
- autoSyncUnlockMethod(runtime);
175
+ if (getDeviceStatusForRuntime(runtime).type === "online") {
176
+ syncT0(runtime);
177
+ autoSyncUnlockMethod(runtime);
178
+ }
177
179
  }, 2000);
178
180
  setTimeout(() => {
179
181
  sdkLog("debug", "initState", "scheduledSyncTempAndUsers", { devId });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.2.1-beta.7",
3
+ "version": "1.2.1-beta.8",
4
4
  "files": [
5
5
  "lib",
6
6
  "LICENSE.md"