mini_program_gizwits_sdk 3.6.4 → 3.6.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.
Files changed (134) hide show
  1. package/dist/index.js +3 -3
  2. package/package.json +1 -1
  3. package/yarn-error.log +6901 -0
  4. package/dist/src/GizLog.d.ts +0 -18
  5. package/dist/src/crc/calculators/crc16modbus.d.ts +0 -2
  6. package/dist/src/crc/calculators/crc32.d.ts +0 -2
  7. package/dist/src/crc/crc16modbus.d.ts +0 -7
  8. package/dist/src/crc/crc32.d.ts +0 -7
  9. package/dist/src/crc/create_buffer.d.ts +0 -3
  10. package/dist/src/crc/define_crc.d.ts +0 -7
  11. package/dist/src/crc/index.d.ts +0 -19
  12. package/dist/src/crc/types.d.ts +0 -11
  13. package/dist/src/errorCode.d.ts +0 -3
  14. package/dist/src/globalData.d.ts +0 -2
  15. package/dist/src/handler/EventListener.d.ts +0 -9
  16. package/dist/src/handler/ble.d.ts +0 -105
  17. package/dist/src/handler/lan.d.ts +0 -78
  18. package/dist/src/handler/socket.d.ts +0 -151
  19. package/dist/src/openApiRequest.d.ts +0 -3
  20. package/dist/src/productConfigFileManage.d.ts +0 -11
  21. package/dist/src/protocol/Bind.d.ts +0 -7
  22. package/dist/src/protocol/DeviceInfo.d.ts +0 -11
  23. package/dist/src/protocol/DiscoverUDP.d.ts +0 -17
  24. package/dist/src/protocol/GetDeviceStatus.d.ts +0 -5
  25. package/dist/src/protocol/Login.d.ts +0 -12
  26. package/dist/src/protocol/Ntp.d.ts +0 -5
  27. package/dist/src/protocol/OTA/AwaitNoti.d.ts +0 -7
  28. package/dist/src/protocol/OTA/CheckCanOTA.d.ts +0 -10
  29. package/dist/src/protocol/OTA/OTAPackPackage.d.ts +0 -8
  30. package/dist/src/protocol/OTA/OtaComplete.d.ts +0 -8
  31. package/dist/src/protocol/OTA/PreOTA.d.ts +0 -11
  32. package/dist/src/protocol/OTA/ResetPosition.d.ts +0 -6
  33. package/dist/src/protocol/OffLineData.d.ts +0 -23
  34. package/dist/src/protocol/ProtocolBase.d.ts +0 -11
  35. package/dist/src/protocol/Reset.d.ts +0 -8
  36. package/dist/src/protocol/SetReset.d.ts +0 -7
  37. package/dist/src/protocol/WifiConfig.d.ts +0 -6
  38. package/dist/src/protocol/dataPoint.d.ts +0 -34
  39. package/dist/src/protocol/tool.d.ts +0 -14
  40. package/dist/src/randomCode.d.ts +0 -3
  41. package/dist/src/request.d.ts +0 -1
  42. package/dist/src/sdk.d.ts +0 -136
  43. package/dist/src/sentry.d.ts +0 -2
  44. package/dist/src/services/devices.d.ts +0 -47
  45. package/dist/src/services/login.d.ts +0 -4
  46. package/dist/src/services/monitor.d.ts +0 -12
  47. package/dist/src/services/ota.d.ts +0 -7
  48. package/dist/src/services/tool.d.ts +0 -4
  49. package/dist/src/services/uploadP0.d.ts +0 -14
  50. package/dist/src/sleep.d.ts +0 -2
  51. package/dist/src/types/index.d.ts +0 -361
  52. package/dist/src/utils.d.ts +0 -46
  53. package/dist/src/wechatApi.d.ts +0 -19
  54. package/dist/src/wifiConfig/ConfigBase.d.ts +0 -27
  55. package/dist/src/wifiConfig/ap.d.ts +0 -11
  56. package/dist/src/wifiConfig/ble.d.ts +0 -41
  57. package/dist/src/wifiConfig/nfc/disposeData.d.ts +0 -2
  58. package/dist/src/wifiConfig/nfc/formatData.d.ts +0 -3
  59. package/dist/src/wifiConfig/nfc/formatSSID.d.ts +0 -6
  60. package/dist/src/wifiConfig/nfc/index.d.ts +0 -22
  61. package/dist/src/wifiConfig/nfc/isIncludedCH.d.ts +0 -1
  62. package/dist/src/wifiConfig/nfc/nfcAConnect.d.ts +0 -6
  63. package/dist/src/wifiConfig/nfc/nfcATransceive.d.ts +0 -5
  64. package/dist/src/wifiConfig/nfc/ssIDToASC.d.ts +0 -1
  65. package/dist/src/wifiConfig/nfc/stringToGbk.d.ts +0 -1
  66. package/dist/src/wifiConfig/nfc/transceive.wx.d.ts +0 -2
  67. package/dist/src/wifiConfig/nfc/types.d.ts +0 -15
  68. package/index.ts +0 -8
  69. package/src/GizLog.ts +0 -51
  70. package/src/crc/calculators/crc16modbus.ts +0 -36
  71. package/src/crc/calculators/crc32.ts +0 -47
  72. package/src/crc/crc16modbus.ts +0 -3
  73. package/src/crc/crc32.ts +0 -4
  74. package/src/crc/create_buffer.ts +0 -7
  75. package/src/crc/define_crc.ts +0 -9
  76. package/src/crc/index.ts +0 -10
  77. package/src/crc/package.json +0 -3
  78. package/src/crc/types.ts +0 -10
  79. package/src/errorCode.ts +0 -83
  80. package/src/globalData.ts +0 -9
  81. package/src/handler/EventListener.ts +0 -44
  82. package/src/handler/ble.ts +0 -1369
  83. package/src/handler/lan.ts +0 -389
  84. package/src/handler/socket.ts +0 -686
  85. package/src/openApiRequest.ts +0 -50
  86. package/src/productConfigFileManage.ts +0 -72
  87. package/src/protocol/Bind.ts +0 -22
  88. package/src/protocol/DeviceInfo.ts +0 -37
  89. package/src/protocol/DiscoverUDP.ts +0 -80
  90. package/src/protocol/GetDeviceStatus.ts +0 -61
  91. package/src/protocol/Login.ts +0 -43
  92. package/src/protocol/Ntp.ts +0 -13
  93. package/src/protocol/OTA/AwaitNoti.ts +0 -14
  94. package/src/protocol/OTA/CheckCanOTA.ts +0 -23
  95. package/src/protocol/OTA/OTAPackPackage.ts +0 -37
  96. package/src/protocol/OTA/OtaComplete.ts +0 -17
  97. package/src/protocol/OTA/PreOTA.ts +0 -48
  98. package/src/protocol/OTA/ResetPosition.ts +0 -14
  99. package/src/protocol/OffLineData.ts +0 -81
  100. package/src/protocol/ProtocolBase.ts +0 -54
  101. package/src/protocol/Reset.ts +0 -16
  102. package/src/protocol/SetReset.ts +0 -13
  103. package/src/protocol/WifiConfig.ts +0 -42
  104. package/src/protocol/dataPoint.ts +0 -687
  105. package/src/protocol/tool.ts +0 -140
  106. package/src/randomCode.ts +0 -25
  107. package/src/request.ts +0 -22
  108. package/src/sdk.ts +0 -1536
  109. package/src/sentry.ts +0 -55
  110. package/src/services/devices.ts +0 -313
  111. package/src/services/login.ts +0 -11
  112. package/src/services/monitor.ts +0 -117
  113. package/src/services/ota.ts +0 -17
  114. package/src/services/tool.ts +0 -10
  115. package/src/services/uploadP0.ts +0 -57
  116. package/src/sleep.ts +0 -2
  117. package/src/types/index.ts +0 -456
  118. package/src/utils.ts +0 -449
  119. package/src/wechatApi.ts +0 -211
  120. package/src/wifiConfig/ConfigBase.ts +0 -235
  121. package/src/wifiConfig/ap.ts +0 -185
  122. package/src/wifiConfig/ble.ts +0 -460
  123. package/src/wifiConfig/nfc/disposeData.ts +0 -63
  124. package/src/wifiConfig/nfc/formatData.ts +0 -46
  125. package/src/wifiConfig/nfc/formatSSID.ts +0 -59
  126. package/src/wifiConfig/nfc/index.ts +0 -134
  127. package/src/wifiConfig/nfc/isIncludedCH.ts +0 -8
  128. package/src/wifiConfig/nfc/nfcAConnect.ts +0 -30
  129. package/src/wifiConfig/nfc/nfcATransceive.ts +0 -29
  130. package/src/wifiConfig/nfc/ssIDToASC.ts +0 -12
  131. package/src/wifiConfig/nfc/stringToGbk.ts +0 -51
  132. package/src/wifiConfig/nfc/transceive.wx.ts +0 -124
  133. package/src/wifiConfig/nfc/types.ts +0 -18
  134. package/src/wifiConfig/timeZoneName.json +0 -1
@@ -1,46 +0,0 @@
1
- /// <reference types="crypto-js" />
2
- import { lib } from "crypto-js/core";
3
- import { IDevice, IError, IWXDevicesResult, TConnectType, IProductInfo, GizwitsWxBlueToothDevice } from "./types";
4
- export declare function ab2hex(buffer: ArrayBuffer): any;
5
- export declare function compareWXSDKVersion(v1: string, v2: string): 0 | 1 | -1;
6
- export declare const isError: (err: unknown) => err is IError;
7
- export declare const wrapErrorInfo: (errorMessage: string) => {
8
- errorCode: string;
9
- errorMessage: string;
10
- };
11
- export declare const unionBy: <T>(array: T[], key: string) => T[];
12
- export declare function isWXDevicesResult(res: unknown): res is IWXDevicesResult;
13
- export declare function str2Buf(arr: string): ArrayBuffer;
14
- export declare const numberArray2Uint8Array: (numArr: number[]) => Uint8Array;
15
- export declare const advertisData2PkAndMac: (advertisData: ArrayBuffer, pks: string[]) => {
16
- bleWorkStatus: number;
17
- productKey: any;
18
- mac: any;
19
- };
20
- export declare const isSameDevice: (deviceA: IDevice, deviceB: IDevice) => boolean;
21
- export declare const getDeviceId: (deivce: IDevice) => string;
22
- export declare const merageBleLocalDevices: (mainDevice: IDevice[], localDevice: IDevice[]) => IDevice[];
23
- export declare const merageLanLocalDevices: (mainDevice: IDevice[], localDevice: IDevice[]) => IDevice[];
24
- export declare const BTDevice2GDevice: (BTDevice: GizwitsWxBlueToothDevice, pks: string[]) => IDevice;
25
- export declare const getFirstConnectType: (device: IDevice, type?: TConnectType) => TConnectType;
26
- export declare const getProductInfoThroughPK: (pk: string, productInfos: IProductInfo[]) => IProductInfo;
27
- export declare const mergeObject: (obj1: any, obj2: any) => any;
28
- export declare function hex2ab(str: any): Uint8Array;
29
- type BroadcastCmd = 0x19 | 0x94;
30
- type TBoradcastRes = {
31
- mac: string;
32
- cmd: BroadcastCmd;
33
- data: string[];
34
- };
35
- export declare function parseBroadcastData(data: number[]): TBoradcastRes;
36
- export declare function ab2numbers(buffer: ArrayBuffer): any;
37
- export declare function encrypt(uuids: number[], key: number): string[];
38
- export declare const convertToServiceUuids: ({ len, data, index, mac }: {
39
- len?: any;
40
- data?: any;
41
- index?: number;
42
- mac: any;
43
- }) => any;
44
- export declare function convertToUuids(mac: number, sn: number, data: number[]): string[];
45
- export declare function arrayBufferToWordArray(arrayBuffer: any): lib.WordArray;
46
- export {};
@@ -1,19 +0,0 @@
1
- import { IBluetoothAdapterStateResult, IWechatResult, IBLEService, IBLECharacteristic } from "./types";
2
- export declare function retryConnect(deviceId: string, timeout?: number): Promise<IWechatResult | {
3
- success: boolean;
4
- }>;
5
- export declare function openBluetoothAdapter(): Promise<IWechatResult>;
6
- export declare function closeBluetoothAdapter(): Promise<IWechatResult>;
7
- export declare function getBluetoothAdapterState(): Promise<IBluetoothAdapterStateResult>;
8
- export declare function startBluetoothDevicesDiscovery(allowDuplicatesKey?: boolean): Promise<IWechatResult>;
9
- export declare function getBluetoothDevices(): Promise<WechatMiniprogram.BlueToothDevice[]>;
10
- export declare function createBLEConnection(deviceId: string, timeout: number): Promise<IWechatResult>;
11
- export declare function getBLEDeviceServices(deviceId: string): Promise<IBLEService[]>;
12
- export declare function getBLEDeviceCharacteristics(deviceId: string, serviceId: string): Promise<IBLECharacteristic[]>;
13
- export declare function notifyBLECharacteristicValueChange(deviceId: string, serviceId: string, characteristicId: string, state?: boolean): Promise<IWechatResult>;
14
- export declare function writeBLECharacteristicValue(deviceId: string, serviceId: string, characteristicId: string, value: ArrayBuffer): Promise<IWechatResult>;
15
- export declare function unpackWriteBLECharacteristicValue(deviceId: string, serviceId: string, characteristicId: string, value: ArrayBuffer, mtu?: number): Promise<IWechatResult>;
16
- export declare function downloadFile({ url }: {
17
- url: any;
18
- }): Promise<unknown>;
19
- export declare function setMtu(mtu: number, deviceId: string): Promise<unknown>;
@@ -1,27 +0,0 @@
1
- import { IRandomCodesResult, IRejectCallback, IResult, TimeoutHandle } from "../types";
2
- import { ConfigEventData, IDevice } from "../types";
3
- declare class ConfigBase {
4
- ssid: string;
5
- bssid: string;
6
- password: string;
7
- specialProductKeys: string[];
8
- disableSearchDevice: boolean;
9
- specialProductKeySecrets: string[];
10
- timeoutHandler: TimeoutHandle;
11
- eventCallBack: (event: ConfigEventData) => void;
12
- private setDeviceOnboardingDeployRej?;
13
- constructor(ssid: string, bssid: string, password: string, specialProductKeys: string[], specialProductKeySecrets: string[]);
14
- cleanTimeout: () => void;
15
- stopDeviceOnboardingDeploy: () => void;
16
- appendExtendData: (key: string) => string;
17
- hasTimeoutHandler: (cb?: IRejectCallback) => boolean;
18
- handleTimeout: () => void;
19
- protected searchDevice: ({ ssid, password }: {
20
- ssid: string;
21
- password: string;
22
- }) => Promise<IResult<IRandomCodesResult[]>>;
23
- initDeviceOnboardingDeploy: (_res: any, rej: any) => void;
24
- protected startTimeoutTimer: (timeout: number) => void;
25
- protected bindDevices: (devices: IDevice[]) => Promise<IResult<IDevice[]>>;
26
- }
27
- export default ConfigBase;
@@ -1,11 +0,0 @@
1
- import { IDevice, IRandomCodesResult, IResult, configDeviceParams, ISetDeviceOnboardingDeployProps } from "../types";
2
- import ConfigBase from "./ConfigBase";
3
- declare class ApConfig extends ConfigBase {
4
- disableSendUDP: boolean;
5
- private sendMessageInterval;
6
- private UDPSocketHandler;
7
- destroy: () => void;
8
- configDevice: ({ ssid, password, softAPSSIDPrefix }: configDeviceParams) => Promise<IResult<IRandomCodesResult[]>>;
9
- setDeviceOnboardingDeploy: ({ timeout, isBind, softAPSSIDPrefix, }: ISetDeviceOnboardingDeployProps) => Promise<IResult<IDevice[]>>;
10
- }
11
- export default ApConfig;
@@ -1,41 +0,0 @@
1
- import { BleHandle } from "../handler/ble";
2
- import ConfigBase from "./ConfigBase";
3
- import { IDevice, IError, ConfigEventData, IRandomCodesResult, IResult, configBLEDeviceParams } from "../types";
4
- type EnableAndGetBluetoothDevicesRes = Promise<{
5
- success: false;
6
- err: IError;
7
- } | {
8
- success: true;
9
- bleDevices?: IDevice[];
10
- }>;
11
- interface IArgs {
12
- bleDeviceId: string;
13
- arrayBuffer: ArrayBuffer;
14
- serviceUUIDSuffix?: string;
15
- characteristicUUIDSuffix?: string;
16
- bleHandle: BleHandle;
17
- eventCallBack: (event: ConfigEventData) => void;
18
- }
19
- interface ISetDeviceOnboardingDeployProps {
20
- timeout: number;
21
- isBind: boolean;
22
- softAPSSIDPrefix: string;
23
- eventCallBack: (event: ConfigEventData) => void;
24
- }
25
- declare class BLEConfig extends ConfigBase {
26
- bleHandle: BleHandle;
27
- constructor(ssid: string, bssid: string, password: string, specialProductKeys: string[], specialProductKeySecrets: string[], bleHandle: BleHandle);
28
- sendBLEConfigCmd: ({ bleDeviceId, arrayBuffer, serviceUUIDSuffix, characteristicUUIDSuffix, bleHandle, eventCallBack }: IArgs) => Promise<boolean | void>;
29
- destroy: () => void;
30
- isValidBleDevice: (device: IDevice, softAPSSIDPrefix?: string) => boolean;
31
- enableBluetoothDevicesDescovery: () => Promise<{
32
- success: false;
33
- err: IError;
34
- } | {
35
- success: true;
36
- }>;
37
- enableAndGetBluetoothDevices: (softAPSSIDPrefix?: string) => EnableAndGetBluetoothDevicesRes;
38
- setDeviceOnboardingDeploy: ({ timeout, isBind, softAPSSIDPrefix, eventCallBack, }: ISetDeviceOnboardingDeployProps) => Promise<IResult<IDevice[]>>;
39
- configBLEDevice: ({ ssid, password, softAPSSIDPrefix, }: configBLEDeviceParams) => Promise<IResult<IRandomCodesResult[]>>;
40
- }
41
- export default BLEConfig;
@@ -1,2 +0,0 @@
1
- import { IDATA } from './types';
2
- export declare const disposeData: (SSID: Uint8Array, isSSIDincludeCH: boolean, pwd: Uint8Array, passIP: Uint8Array, BSSID: Uint8Array) => IDATA;
@@ -1,3 +0,0 @@
1
- type IType = 'BSSID' | 'pwd' | 'address';
2
- export declare const formatData: (data: string, type: IType) => Uint8Array;
3
- export {};
@@ -1,6 +0,0 @@
1
- interface IExport {
2
- SSIDTLV: any;
3
- isSSIDIncludedCH: boolean;
4
- }
5
- export declare const formatSSID: (SSID: string) => IExport;
6
- export {};
@@ -1,22 +0,0 @@
1
- import ConfigBase from "../ConfigBase";
2
- import { IDevice, IResult } from '../../types';
3
- interface configDeviceParams {
4
- ssid: string;
5
- password: string;
6
- bssid: string;
7
- address: string;
8
- }
9
- interface ISetDeviceOnboardingDeployProps {
10
- timeout: number;
11
- isBind: boolean;
12
- BSSID: string;
13
- softAPSSIDPrefix: string;
14
- }
15
- declare class NFCConfig extends ConfigBase {
16
- address: string;
17
- constructor(ssid: string, bssid: string, password: string, specialProductKeys: string[], specialProductKeySecrets: string[], address: string);
18
- destroy: () => void;
19
- configDevice: ({ ssid, password, bssid, address }: configDeviceParams) => Promise<IResult<import("../../types").IRandomCodesResult[]>>;
20
- setDeviceOnboardingDeploy: ({ timeout, isBind, }: ISetDeviceOnboardingDeployProps) => Promise<IResult<IDevice[]>>;
21
- }
22
- export default NFCConfig;
@@ -1 +0,0 @@
1
- export default function isIncludedCH(str: string): boolean;
@@ -1,6 +0,0 @@
1
- type T = {
2
- success: boolean;
3
- nfcA: any;
4
- };
5
- export declare const nfcAConnect: (NFCAdapter: any) => Promise<T>;
6
- export {};
@@ -1,5 +0,0 @@
1
- type T = {
2
- transceiveSuccess: boolean;
3
- };
4
- export declare const nfcATransceive: (nfcA: any, buffer: ArrayBuffer) => Promise<T>;
5
- export {};
@@ -1 +0,0 @@
1
- export declare const ssIDToASC: (SSID: string) => Uint8Array;
@@ -1 +0,0 @@
1
- export default function stringToGbk(str: string): Uint8Array;
@@ -1,2 +0,0 @@
1
- import { IDATA } from './types';
2
- export declare const transceive: (DATA: IDATA) => void;
@@ -1,15 +0,0 @@
1
- type PageStateProps = {
2
- store: {};
3
- };
4
- interface WifiInfo {
5
- SSID: string;
6
- BSSID: string;
7
- secure: boolean;
8
- signalStrength: number;
9
- frequency: number;
10
- }
11
- type IDATA = {
12
- ArrayBuffer_sign: ArrayBuffer;
13
- ArrayBuffer_others: ArrayBuffer;
14
- };
15
- export { PageStateProps, WifiInfo, IDATA };
package/index.ts DELETED
@@ -1,8 +0,0 @@
1
- import 'miniprogram-api-typings';
2
- import gizwitsSdk from './src/sdk';
3
- import errorCode from './src/errorCode';
4
- import { BleHandle } from './src/handler/ble';
5
-
6
- export { errorCode, BleHandle };
7
- export default gizwitsSdk;
8
- export * from './src/types';
package/src/GizLog.ts DELETED
@@ -1,51 +0,0 @@
1
- import errorCode from './errorCode';
2
- import sentry from './sentry';
3
-
4
- export type TLogType = 'debug' | 'info' | 'warn' | 'error';
5
- class Log {
6
-
7
- logMap = [
8
- {id: 'debug'},
9
- {id: 'info'},
10
- {id: 'warn'},
11
- {id: 'error'}
12
- ]
13
-
14
- console = console
15
- // debug info(log) warn error
16
- debug = (...data)=> {
17
- this.console.debug(...data);
18
- }
19
- info = (...data) => {
20
- this.console.info(...data);
21
-
22
- }
23
- log = (...data) => {
24
- this.console.log(...data);
25
-
26
- }
27
- warn = (...data) => {
28
- this.console.warn(...data);
29
- }
30
- error = (info: string, error: Error) => {
31
- this.console.error(info, error);
32
- sentry(error)
33
- }
34
-
35
- setLogLevel = (type: TLogType) => {
36
- const targetIndex = this.logMap.findIndex(item => item.id === type);
37
- if (targetIndex !== -1) {
38
- this.console = {...console as any};
39
- this.logMap.map((item, index) => {
40
- if (index < targetIndex) {
41
- this.console[item.id] = () => {};
42
- }
43
- })
44
- return {success: true, err: null}
45
- } else {
46
- return {success: false,err: errorCode.GIZ_SDK_LOG_LEVEL_INVALID}
47
- }
48
- }
49
- }
50
-
51
- export default new Log();
@@ -1,36 +0,0 @@
1
- // Generated by `./pycrc.py --algorithm=table-driven --model=crc-16-modbus --generate=c`
2
- let TABLE: any = [
3
- 0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741,
4
- 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40,
5
- 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, 0x18c0, 0x1980, 0xd941,
6
- 0x1b00, 0xdbc1, 0xda81, 0x1a40, 0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41,
7
- 0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641, 0xd201, 0x12c0, 0x1380, 0xd341,
8
- 0x1100, 0xd1c1, 0xd081, 0x1040, 0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240,
9
- 0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441, 0x3c00, 0xfcc1, 0xfd81, 0x3d40,
10
- 0xff01, 0x3fc0, 0x3e80, 0xfe41, 0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840,
11
- 0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41, 0xee01, 0x2ec0, 0x2f80, 0xef41,
12
- 0x2d00, 0xedc1, 0xec81, 0x2c40, 0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640,
13
- 0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041, 0xa001, 0x60c0, 0x6180, 0xa141,
14
- 0x6300, 0xa3c1, 0xa281, 0x6240, 0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441,
15
- 0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41, 0xaa01, 0x6ac0, 0x6b80, 0xab41,
16
- 0x6900, 0xa9c1, 0xa881, 0x6840, 0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41,
17
- 0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40, 0xb401, 0x74c0, 0x7580, 0xb541,
18
- 0x7700, 0xb7c1, 0xb681, 0x7640, 0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041,
19
- 0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241, 0x9601, 0x56c0, 0x5780, 0x9741,
20
- 0x5500, 0x95c1, 0x9481, 0x5440, 0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40,
21
- 0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841, 0x8801, 0x48c0, 0x4980, 0x8941,
22
- 0x4b00, 0x8bc1, 0x8a81, 0x4a40, 0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41,
23
- 0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641, 0x8201, 0x42c0, 0x4380, 0x8341,
24
- 0x4100, 0x81c1, 0x8081, 0x4040,
25
- ];
26
- if (typeof Int32Array !== 'undefined') {
27
- TABLE = new Int32Array(TABLE);
28
- }
29
- const crc16modbus = (current, previous) => {
30
- let crc = typeof previous !== 'undefined' ? ~~previous : 0xffff;
31
- for (let index = 0; index < current.length; index++) {
32
- crc = (TABLE[(crc ^ current[index]) & 0xff] ^ (crc >> 8)) & 0xffff;
33
- }
34
- return crc;
35
- };
36
- export default crc16modbus;
@@ -1,47 +0,0 @@
1
- // Generated by `./pycrc.py --algorithm=table-driven --model=crc-32 --generate=c`
2
- let TABLE: any = [
3
- 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
4
- 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
5
- 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
6
- 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
7
- 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
8
- 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
9
- 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
10
- 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
11
- 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
12
- 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
13
- 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
14
- 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
15
- 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
16
- 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
17
- 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
18
- 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
19
- 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
20
- 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
21
- 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
22
- 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
23
- 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
24
- 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
25
- 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
26
- 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
27
- 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
28
- 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
29
- 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
30
- 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
31
- 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
32
- 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
33
- 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
34
- 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
35
- ];
36
- if (typeof Int32Array !== 'undefined') {
37
- TABLE = new Int32Array(TABLE);
38
- }
39
- const crc32 = (current, previous) => {
40
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
41
- let crc = previous === 0 ? 0 : ~~previous ^ -1;
42
- for (let index = 0; index < current.length; index++) {
43
- crc = TABLE[(crc ^ current[index]) & 0xff] ^ (crc >>> 8);
44
- }
45
- return crc ^ -1;
46
- };
47
- export default crc32;
@@ -1,3 +0,0 @@
1
- import crc16modbus from './calculators/crc16modbus';
2
- import defineCrc from './define_crc';
3
- export default defineCrc('crc-16-modbus', crc16modbus);
package/src/crc/crc32.ts DELETED
@@ -1,4 +0,0 @@
1
- import crc32 from './calculators/crc32';
2
- import defineCrc from './define_crc';
3
- export default defineCrc(
4
- 'crc-32', crc32);
@@ -1,7 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
- /* eslint-disable no-prototype-builtins */
3
- import { Buffer } from 'buffer';
4
- import { BufferInput } from './types';
5
-
6
- const createBuffer = (value: BufferInput, encoding?: BufferEncoding) => Buffer.from(value as any, encoding);
7
- export default createBuffer;
@@ -1,9 +0,0 @@
1
- import createBuffer from './create_buffer';
2
- import { CRCCalculator } from './types'
3
- export default function defineCrc(model: string, calculator: CRCCalculator<Uint8Array>) {
4
- const result = (value: any, previous?: any) => calculator(createBuffer(value), previous) >>> 0;
5
- result.signed = (value: any, previous?: any) => calculator(createBuffer(value), previous);
6
- result.unsigned = result;
7
- result.model = model;
8
- return result;
9
- }
package/src/crc/index.ts DELETED
@@ -1,10 +0,0 @@
1
-
2
- import crc16modbus from './crc16modbus';
3
- import crc32 from './crc32';
4
-
5
- export { crc16modbus };
6
- export { crc32 };
7
- export default {
8
- crc16modbus,
9
- crc32,
10
- };
@@ -1,3 +0,0 @@
1
- {
2
- "type": "module"
3
- }
package/src/crc/types.ts DELETED
@@ -1,10 +0,0 @@
1
- import { Buffer } from 'buffer';
2
- export type BufferInput = string | ArrayBuffer | Buffer;
3
- export interface CRCCalculator<T = BufferInput | Uint8Array> {
4
- (value: T, previous?: number): number;
5
- }
6
- export interface CRCModule extends CRCCalculator<BufferInput> {
7
- signed: CRCCalculator<BufferInput>;
8
- unsigned: CRCCalculator<BufferInput>;
9
- model: string;
10
- }
package/src/errorCode.ts DELETED
@@ -1,83 +0,0 @@
1
- import { IError, IErrorCode } from "./types";
2
-
3
-
4
- const errorCode: IErrorCode = {
5
- GIZ_OPENAPI_DEVICE_NOT_BOUND: {
6
- errorCode: 9017,
7
- errorMessage: 'not bind'
8
- },
9
- GIZ_SDK_HTTP_REQUEST_FAILED: {
10
- errorCode: 8099,
11
- errorMessage: '网络请求失败'
12
- },
13
- GIZ_SDK_DEVICE_NO_RESPONSE: {
14
- errorCode: 8030,
15
- errorMessage: '设备未响应'
16
- },
17
- GIZ_SDK_SDK_NOT_INITIALIZED: {
18
- errorCode: 8300,
19
- errorMessage: 'not init'
20
- },
21
- CONFIG_TIME_OUT: {
22
- errorCode: 8023,
23
- errorMessage: 'Config Timeout'
24
- },
25
- WECHAT_ERROR: {
26
- errorCode: 10000,
27
- errorMessage: 'wechat error'
28
- },
29
- GIZ_SDK_ONBOARDING_STOPPED: {
30
- errorCode: 8318,
31
- errorMessage: '配网中断'
32
- },
33
- GIZ_SDK_DEVICE_CONFIG_IS_RUNNING: {
34
- errorCode: 8022,
35
- errorMessage: '配置正在进行中'
36
- },
37
- GIZ_OPENAPI_TOKEN_INVALID: {
38
- errorCode: 9004,
39
- errorMessage: 'token 失效'
40
- },
41
- GIZ_SDK_BIND_DEVICE_FAILED: {
42
- errorCode: 8039,
43
- errorMessage: '设备绑定失败'
44
- },
45
- GIZ_SDK_BLE_BLUETOOTH_FUNCTION_NOT_TURNED_ON: {
46
- errorCode: 8281,
47
- errorMessage: "蓝牙未启用"
48
- },
49
- GIZ_SDK_OTHERWISE: {
50
- errorCode: 8100,
51
- errorMessage: ''
52
- },
53
- GIZ_SDK_DEVICE_NOT_SUBSCRIBED: {
54
- errorCode: 8029,
55
- errorMessage: '设备还未订阅'
56
- },
57
- GIZ_SDK_PRODUCTKEY_NOT_IN_SPECIFY: {
58
- errorCode: 8250,
59
- errorMessage: '产品类型不在指定范围内',
60
- },
61
- GIZ_SDK_LOG_LEVEL_INVALID: {
62
- errorCode: 8009,
63
- errorMessage: '产品类型不在指定范围内',
64
- },
65
- GIZ_SDK_OTA_DEVICE_NOT_SUPPORT: {
66
- errorCode: 8360,
67
- errorMessage: '设备不支持手机OTA升级',
68
- },
69
- GIZ_SDK_OTA_DEVICE_BUSY_IN_UPGRADE: {
70
- errorCode: 8354,
71
- errorMessage: '设备忙,固件正在升级'
72
- },
73
- GIZ_SDK_OTA_FIRMWARE_DOWNLOAD_FAILED: {
74
- errorCode: 8353,
75
- errorMessage: '固件下载失败'
76
- },
77
- GIZ_SDK_OTA_FIRMWARE_TYPE_NOT_MATCH: {
78
- errorCode: 8361,
79
- errorMessage: '蓝牙OTA设备返回的固件类型与当前要升级的固件类型不匹配'
80
- }
81
- };
82
-
83
- export default errorCode;
package/src/globalData.ts DELETED
@@ -1,9 +0,0 @@
1
- const globalData: any = {};
2
-
3
- export function setGlobalData(key: any, value: any) {
4
- globalData[key] = value;
5
- }
6
-
7
- export function getGlobalData(key: any) {
8
- return globalData[key];
9
- }
@@ -1,44 +0,0 @@
1
- export default class EventListener<T> {
2
- public listenerMap: any = {};
3
- public addEventListener = async <K extends keyof T>(
4
- type: K,
5
- func: T[K]
6
- ) => {
7
- if (!this.listenerMap[type]) {
8
- // 创建一个新的
9
- this.listenerMap[type] = [];
10
- }
11
-
12
- if (this.listenerMap[type].indexOf(func) === -1) {
13
- this.listenerMap[type].push(func);
14
- }
15
- return {
16
- success: true,
17
- };
18
- }
19
-
20
- /**
21
- * 移除事件监听
22
- * @param type 事件监听名称,详见下表
23
- * @param func 事件监听回调
24
- * @returns
25
- */
26
- public removeEventListener = <K extends keyof T>(
27
- type: K,
28
- func: T[K]
29
- ) => {
30
- if (this.listenerMap[type]) {
31
- const index = this.listenerMap[type].indexOf(func);
32
- if (index !== -1) {
33
- // 删除数组中的这一行
34
- this.listenerMap[type].splice(index, 1);
35
- return {
36
- success: true,
37
- };
38
- }
39
- }
40
- return {
41
- success: false,
42
- };
43
- };
44
- }