@ray-js/lock-sdk 1.1.0-beta.1 → 1.1.0

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/other.d.ts CHANGED
@@ -23,8 +23,6 @@ export declare const parseDpPeriodTime: (dpValue: string) => {
23
23
  end: number;
24
24
  };
25
25
  export declare const formatDpPeriodTime: (start: number, end: number) => string;
26
- export declare const awakeDevice: (timeout?: number) => Promise<unknown>;
27
- export declare const connectBle: (devId: string) => Promise<unknown>;
28
26
  export declare const connectDevice: () => Promise<unknown>;
29
27
  export declare const gotoService: (params?: {
30
28
  tab?: "cloudStorage" | "AI";
package/lib/other.js CHANGED
@@ -169,7 +169,7 @@ export const formatDpPeriodTime = (start, end) => {
169
169
  endMinute,
170
170
  }, periodDpMap);
171
171
  };
172
- export const awakeDevice = async (timeout) => {
172
+ const awakeDevice = async (timeout) => {
173
173
  return new Promise((resolve, reject) => {
174
174
  const handleChangeDp = (dpCodes) => {
175
175
  if (dpCodes[wirelessAwake] === true) {
@@ -204,17 +204,17 @@ export const awakeDevice = async (timeout) => {
204
204
  run();
205
205
  });
206
206
  };
207
- export const connectBle = async (devId) => {
207
+ const connectBle = async () => {
208
208
  return new Promise((resolve, reject) => {
209
209
  const handleConnect = () => {
210
210
  const handleStatusChange = ({ deviceId, status }) => {
211
- if (deviceId === devId && status === "CONNECTED") {
211
+ if (deviceId === config.devInfo.devId && status === "CONNECTED") {
212
212
  clearTimer();
213
213
  resolve(true);
214
214
  }
215
215
  };
216
216
  const handleOnline = ({ deviceId, online }) => {
217
- if (deviceId === devId && online) {
217
+ if (deviceId === config.devInfo.devId && online) {
218
218
  clearTimer();
219
219
  resolve(true);
220
220
  }
@@ -231,12 +231,12 @@ export const connectBle = async (devId) => {
231
231
  offBleChange(handleStatusChange);
232
232
  offOnlineChange(handleOnline);
233
233
  };
234
- connectBLEDevice(devId).catch((e) => {
234
+ connectBLEDevice(config.devInfo.devId).catch((e) => {
235
235
  clearTimer();
236
236
  reject(e);
237
237
  });
238
238
  };
239
- getBLEOnlineState(devId)
239
+ getBLEOnlineState(config.devInfo.devId)
240
240
  .then((isBleOnline) => {
241
241
  if (isBleOnline) {
242
242
  resolve(true);
@@ -262,7 +262,7 @@ export const connectDevice = async () => {
262
262
  if (deviceStatus.type === "online" && deviceStatus.onlineType === "ble") {
263
263
  return true;
264
264
  }
265
- return await connectBle(config.devInfo.devId);
265
+ return await connectBle();
266
266
  }
267
267
  throw getError(1062);
268
268
  };
package/lib/signal.d.ts CHANGED
@@ -4,6 +4,7 @@ export declare const getWiFiSignal: () => Promise<{
4
4
  timeStamp: number;
5
5
  }>;
6
6
  } | null>;
7
+ export declare const getCurrentWiFiSignal: () => number | "unknown";
7
8
  type WiFiSignalChangeListener = (params: {
8
9
  signal: number;
9
10
  level: "good" | "normal" | "weak" | "bad";
package/lib/signal.js CHANGED
@@ -2,6 +2,7 @@ import config from "./config";
2
2
  import { sendMqttMessage } from "./utils/device";
3
3
  import { getError } from "./utils/errors";
4
4
  import emitter from "./utils/event";
5
+ let currentWiFiSignal = "unknown";
5
6
  export const getWiFiSignal = () => {
6
7
  if (config.devInfo.isCloudOnline) {
7
8
  return sendMqttMessage({
@@ -16,9 +17,15 @@ export const getWiFiSignal = () => {
16
17
  throw getError(1001);
17
18
  }
18
19
  };
20
+ export const getCurrentWiFiSignal = () => {
21
+ return currentWiFiSignal;
22
+ };
19
23
  export const onWiFiSignalChange = (cb) => {
20
24
  emitter.on("onWiFiSignalChange", cb);
21
25
  };
22
26
  export const offWiFiSignalChange = (cb) => {
23
27
  emitter.off("onWiFiSignalChange", cb);
24
28
  };
29
+ onWiFiSignalChange(({ signal }) => {
30
+ currentWiFiSignal = signal;
31
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/lock-sdk",
3
- "version": "1.1.0-beta.1",
3
+ "version": "1.1.0",
4
4
  "files": [
5
5
  "lib",
6
6
  "LICENSE.md"