mini_program_gizwits_sdk 3.7.1-kuka → 3.7.2-beta.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.
Files changed (134) hide show
  1. package/README.md +209 -25
  2. package/{index.ts → dist/index.d.ts} +3 -3
  3. package/dist/index.js +6 -4
  4. package/dist/src/crc/calculators/crc16modbus.d.ts +2 -0
  5. package/dist/src/crc/calculators/crc32.d.ts +2 -0
  6. package/dist/src/crc/crc16modbus.d.ts +7 -0
  7. package/dist/src/crc/crc32.d.ts +7 -0
  8. package/dist/src/crc/create_buffer.d.ts +3 -0
  9. package/dist/src/crc/define_crc.d.ts +7 -0
  10. package/dist/src/crc/index.d.ts +19 -0
  11. package/{src/crc/types.ts → dist/src/crc/types.d.ts} +1 -1
  12. package/dist/src/handler/EventListener.d.ts +9 -0
  13. package/dist/src/handler/ble.d.ts +130 -0
  14. package/dist/src/handler/lan.d.ts +78 -0
  15. package/dist/src/handler/socket.d.ts +161 -0
  16. package/dist/src/protocol/Bind.d.ts +7 -0
  17. package/dist/src/protocol/DeviceInfo.d.ts +11 -0
  18. package/dist/src/protocol/DiscoverUDP.d.ts +17 -0
  19. package/dist/src/protocol/GetDeviceStatus.d.ts +5 -0
  20. package/dist/src/protocol/Login.d.ts +12 -0
  21. package/dist/src/protocol/Ntp.d.ts +5 -0
  22. package/dist/src/protocol/OTA/AwaitNoti.d.ts +7 -0
  23. package/dist/src/protocol/OTA/CheckCanOTA.d.ts +10 -0
  24. package/dist/src/protocol/OTA/OTAPackPackage.d.ts +8 -0
  25. package/dist/src/protocol/OTA/OtaComplete.d.ts +8 -0
  26. package/dist/src/protocol/OTA/PreOTA.d.ts +11 -0
  27. package/dist/src/protocol/OTA/ResetPosition.d.ts +6 -0
  28. package/dist/src/protocol/OffLineData.d.ts +23 -0
  29. package/dist/src/protocol/ProtocolBase.d.ts +12 -0
  30. package/dist/src/protocol/Reset.d.ts +8 -0
  31. package/dist/src/protocol/SetReset.d.ts +7 -0
  32. package/dist/src/protocol/TransparentData.d.ts +12 -0
  33. package/dist/src/protocol/WifiConfig.d.ts +11 -0
  34. package/dist/src/protocol/dataPoint.d.ts +34 -0
  35. package/dist/src/protocol/tool.d.ts +14 -0
  36. package/dist/src/sdk.d.ts +154 -0
  37. package/dist/src/services/devices.d.ts +52 -0
  38. package/dist/src/services/login.d.ts +4 -0
  39. package/dist/src/services/monitor.d.ts +12 -0
  40. package/dist/src/services/ota.d.ts +7 -0
  41. package/dist/src/services/tool.d.ts +4 -0
  42. package/dist/src/services/uploadP0.d.ts +14 -0
  43. package/dist/src/types/index.d.ts +398 -0
  44. package/dist/src/utils/GizLog.d.ts +18 -0
  45. package/dist/src/utils/bleConfigLog.d.ts +11 -0
  46. package/dist/src/utils/connectedBssid.d.ts +6 -0
  47. package/dist/src/utils/errorCode.d.ts +3 -0
  48. package/dist/src/utils/globalData.d.ts +2 -0
  49. package/dist/src/utils/openApiRequest.d.ts +27 -0
  50. package/dist/src/utils/productConfigFileManage.d.ts +15 -0
  51. package/dist/src/utils/randomCode.d.ts +3 -0
  52. package/dist/src/utils/request.d.ts +1 -0
  53. package/dist/src/utils/sentry.d.ts +2 -0
  54. package/dist/src/utils/sleep.d.ts +2 -0
  55. package/dist/src/utils/utils.d.ts +55 -0
  56. package/dist/src/utils/wechatApi.d.ts +24 -0
  57. package/dist/src/utils/wifiConfigLogReport.d.ts +28 -0
  58. package/dist/src/wifiConfig/ConfigBase.d.ts +27 -0
  59. package/dist/src/wifiConfig/ap.d.ts +11 -0
  60. package/dist/src/wifiConfig/ble.d.ts +43 -0
  61. package/dist/src/wifiConfig/nfc/disposeData.d.ts +2 -0
  62. package/dist/src/wifiConfig/nfc/formatData.d.ts +3 -0
  63. package/dist/src/wifiConfig/nfc/formatSSID.d.ts +6 -0
  64. package/dist/src/wifiConfig/nfc/index.d.ts +22 -0
  65. package/dist/src/wifiConfig/nfc/isIncludedCH.d.ts +1 -0
  66. package/dist/src/wifiConfig/nfc/nfcAConnect.d.ts +6 -0
  67. package/dist/src/wifiConfig/nfc/nfcATransceive.d.ts +5 -0
  68. package/dist/src/wifiConfig/nfc/ssIDToASC.d.ts +1 -0
  69. package/dist/src/wifiConfig/nfc/stringToGbk.d.ts +1 -0
  70. package/dist/src/wifiConfig/nfc/transceive.wx.d.ts +2 -0
  71. package/dist/src/wifiConfig/nfc/types.d.ts +15 -0
  72. package/global.d.ts +3 -19
  73. package/package.json +16 -7
  74. package/.istanbul.yml +0 -4
  75. package/.travis.yml +0 -23
  76. package/.vscode/launch.json +0 -19
  77. package/.vscode/settings.json +0 -3
  78. package/src/GizLog.ts +0 -51
  79. package/src/aepApi/aepApiRequest.ts +0 -61
  80. package/src/crc/calculators/crc16modbus.ts +0 -36
  81. package/src/crc/calculators/crc32.ts +0 -47
  82. package/src/crc/crc16modbus.ts +0 -3
  83. package/src/crc/crc32.ts +0 -4
  84. package/src/crc/create_buffer.ts +0 -7
  85. package/src/crc/define_crc.ts +0 -9
  86. package/src/crc/index.ts +0 -10
  87. package/src/crc/package.json +0 -3
  88. package/src/errorCode.ts +0 -84
  89. package/src/global.d.ts +0 -53
  90. package/src/globalData.ts +0 -9
  91. package/src/handler/EventListener.ts +0 -44
  92. package/src/handler/ble.ts +0 -1485
  93. package/src/handler/lan.ts +0 -409
  94. package/src/handler/socket.ts +0 -625
  95. package/src/openApiRequest.ts +0 -62
  96. package/src/productConfigFileManage.ts +0 -58
  97. package/src/protocol/Bind.ts +0 -22
  98. package/src/protocol/DeviceInfo.ts +0 -36
  99. package/src/protocol/DiscoverUDP.ts +0 -80
  100. package/src/protocol/GetDeviceStatus.ts +0 -63
  101. package/src/protocol/Login.ts +0 -43
  102. package/src/protocol/Ntp.ts +0 -13
  103. package/src/protocol/OTA/AwaitNoti.ts +0 -14
  104. package/src/protocol/OTA/CheckCanOTA.ts +0 -23
  105. package/src/protocol/OTA/OTAPackPackage.ts +0 -36
  106. package/src/protocol/OTA/OtaComplete.ts +0 -17
  107. package/src/protocol/OTA/PreOTA.ts +0 -47
  108. package/src/protocol/OTA/ResetPosition.ts +0 -14
  109. package/src/protocol/OffLineData.ts +0 -81
  110. package/src/protocol/ProtocolBase.ts +0 -54
  111. package/src/protocol/Reset.ts +0 -15
  112. package/src/protocol/SetReset.ts +0 -11
  113. package/src/protocol/WifiConfig.ts +0 -42
  114. package/src/protocol/dataPoint.ts +0 -769
  115. package/src/protocol/thirdProtocol/YunZhiMianBleProtocolBase.ts +0 -39
  116. package/src/protocol/tool.ts +0 -147
  117. package/src/randomCode.ts +0 -36
  118. package/src/request.ts +0 -22
  119. package/src/sdk.ts +0 -1472
  120. package/src/sentry.ts +0 -55
  121. package/src/services/devices.ts +0 -309
  122. package/src/services/login.ts +0 -15
  123. package/src/services/ota.ts +0 -30
  124. package/src/services/tool.ts +0 -10
  125. package/src/services/uploadP0.ts +0 -56
  126. package/src/sleep.ts +0 -2
  127. package/src/types/index.ts +0 -48
  128. package/src/utils.ts +0 -419
  129. package/src/wechatApi.ts +0 -286
  130. package/src/wifiConfig/ConfigBase.ts +0 -185
  131. package/src/wifiConfig/ap.ts +0 -192
  132. package/src/wifiConfig/ble.ts +0 -436
  133. package/src/wifiConfig/ble_ailCloud.ts +0 -554
  134. package/yarn-error.log +0 -6901
@@ -0,0 +1,43 @@
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
+ usesBssid?: boolean;
15
+ serviceUUIDSuffix?: string;
16
+ characteristicUUIDSuffix?: string;
17
+ bleHandle: BleHandle;
18
+ eventCallBack?: (event: ConfigEventData) => void;
19
+ }
20
+ interface ISetDeviceOnboardingDeployProps {
21
+ timeout: number;
22
+ isBind: boolean;
23
+ softAPSSIDPrefix: string;
24
+ productKey?: string;
25
+ eventCallBack?: (event: ConfigEventData) => void;
26
+ }
27
+ declare class BLEConfig extends ConfigBase {
28
+ bleHandle: BleHandle;
29
+ constructor(ssid: string, bssid: string, password: string, specialProductKeys: string[], specialProductKeySecrets: string[], bleHandle: BleHandle);
30
+ sendBLEConfigCmd: ({ bleDeviceId, arrayBuffer, usesBssid, serviceUUIDSuffix, characteristicUUIDSuffix, bleHandle, eventCallBack }: IArgs) => Promise<boolean | void>;
31
+ destroy: () => void;
32
+ isValidBleDevice: (device: IDevice, softAPSSIDPrefix?: string) => boolean;
33
+ enableBluetoothDevicesDescovery: () => Promise<{
34
+ success: false;
35
+ err: IError;
36
+ } | {
37
+ success: true;
38
+ }>;
39
+ enableAndGetBluetoothDevices: (softAPSSIDPrefix?: string) => EnableAndGetBluetoothDevicesRes;
40
+ setDeviceOnboardingDeploy: ({ timeout, isBind, softAPSSIDPrefix, productKey, eventCallBack, }: ISetDeviceOnboardingDeployProps) => Promise<IResult<IDevice[]>>;
41
+ configBLEDevice: ({ ssid, password, softAPSSIDPrefix, }: configBLEDeviceParams) => Promise<IResult<IRandomCodesResult[]>>;
42
+ }
43
+ export default BLEConfig;
@@ -0,0 +1,2 @@
1
+ import { IDATA } from './types';
2
+ export declare const disposeData: (SSID: Uint8Array, isSSIDincludeCH: boolean, pwd: Uint8Array, passIP: Uint8Array, BSSID: Uint8Array) => IDATA;
@@ -0,0 +1,3 @@
1
+ type IType = 'BSSID' | 'pwd' | 'address';
2
+ export declare const formatData: (data: string, type: IType) => Uint8Array;
3
+ export {};
@@ -0,0 +1,6 @@
1
+ interface IExport {
2
+ SSIDTLV: any;
3
+ isSSIDIncludedCH: boolean;
4
+ }
5
+ export declare const formatSSID: (SSID: string) => IExport;
6
+ export {};
@@ -0,0 +1,22 @@
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;
@@ -0,0 +1 @@
1
+ export default function isIncludedCH(str: string): boolean;
@@ -0,0 +1,6 @@
1
+ type T = {
2
+ success: boolean;
3
+ nfcA: any;
4
+ };
5
+ export declare const nfcAConnect: (NFCAdapter: any) => Promise<T>;
6
+ export {};
@@ -0,0 +1,5 @@
1
+ type T = {
2
+ transceiveSuccess: boolean;
3
+ };
4
+ export declare const nfcATransceive: (nfcA: any, buffer: ArrayBuffer) => Promise<T>;
5
+ export {};
@@ -0,0 +1 @@
1
+ export declare const ssIDToASC: (SSID: string) => Uint8Array;
@@ -0,0 +1 @@
1
+ export default function stringToGbk(str: string): Uint8Array;
@@ -0,0 +1,2 @@
1
+ import { IDATA } from './types';
2
+ export declare const transceive: (DATA: IDATA) => void;
@@ -0,0 +1,15 @@
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/global.d.ts CHANGED
@@ -6,23 +6,7 @@ declare namespace md5 {
6
6
 
7
7
  declare function md5(data: any): any;
8
8
 
9
- type TUtf8 = {
10
- toBytes: (data: any) => any
11
- }
12
-
13
- type TUtils = {
14
- utf8: TUtf8;
15
- }
16
-
17
- interface ecb {
18
- new(data: any): any;
19
- }
20
-
21
- type TModeOfOperation = {
22
- ecb: ecb;
23
- }
24
-
25
9
  declare namespace aesjs {
26
- const utils: TUtils;
27
- const ModeOfOperation: TModeOfOperation;
28
- }
10
+ const utils: any;
11
+ const ModeOfOperation: any;
12
+ }
package/package.json CHANGED
@@ -1,12 +1,16 @@
1
1
  {
2
2
  "name": "mini_program_gizwits_sdk",
3
- "version": "3.7.1-kuka",
4
- "description": "bump sdk version",
3
+ "version": "3.7.2-beta.0",
4
+ "description": "mini_program_gizwits_sdk",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
7
+ "test:bssid": "mocha -r ts-node/register tests/bssid/*.spec.ts --timeout 5000",
7
8
  "test": "node_modules/mocha/bin/_mocha -r ts-node/register tests/**/*.spec.ts -file ./tests/setup-wx.js -timeout 60s",
8
9
  "testBle": "node_modules/mocha/bin/_mocha -r ts-node/register tests/utils/randomCode.spec.ts -file ./tests/setup-wx.js -timeout 60s",
9
- "build": "[ -d './dist' ] && rm -r ./dist; webpack",
10
+ "build": "rm -rf ./dist && webpack",
11
+ "link:dev": "yarn link && webpack --watch --mode development --devtool source-map",
12
+ "test:transparent": "mocha -r ts-node/register --file ./tests/setup-wx.js tests/protocol/transparentData.spec.ts tests/protocol/otaTransferLock.spec.ts --timeout 5000",
13
+ "pack:local": "npm run build && npm pack",
10
14
  "release": "npm run build && release-it",
11
15
  "cover": "istanbul cover node_modules/mocha/bin/_mocha -- -r ts-node/register tests/**/*.spec.ts -file ./tests/setup-wx.js -timeout 60s",
12
16
  "coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls"
@@ -31,13 +35,13 @@
31
35
  "chai": "^4.2.0",
32
36
  "coveralls": "^3.0.11",
33
37
  "istanbul": "^1.1.0-alpha.1",
34
- "miniprogram-api-typings": "^3.5.0",
38
+ "miniprogram-api-typings": "^4.1.2",
35
39
  "mocha": "^7.1.1",
36
40
  "release-it": "^14.2.2",
37
41
  "sinon": "^9.2.4",
38
42
  "ts-loader": "^6.2.2",
39
43
  "ts-node": "^8.8.1",
40
- "typescript": "^3.8.3",
44
+ "typescript": "^4.9.5",
41
45
  "uglifyjs-webpack-plugin": "^2.2.0",
42
46
  "webpack": "^4.42.1",
43
47
  "webpack-bundle-analyzer": "^4.5.0",
@@ -51,5 +55,10 @@
51
55
  "homepage": "https://github.com/gizwits/mini_program_gizwits_sdk#readme",
52
56
  "dependencies": {
53
57
  "crypto-js": "^4.1.1"
54
- }
55
- }
58
+ },
59
+ "files": [
60
+ "dist",
61
+ "global.d.ts",
62
+ "README.md"
63
+ ]
64
+ }
package/.istanbul.yml DELETED
@@ -1,4 +0,0 @@
1
- instrumentation:
2
- root: . # 执行的根目录
3
- extensions:
4
- - .ts # 检查覆盖率的文件扩张名
package/.travis.yml DELETED
@@ -1,23 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - 10
4
- branches:
5
- only:
6
- - master
7
- install:
8
- - npm install
9
- script:
10
- - npm run test
11
- - npm run build
12
- after_success:
13
- - npm run coveralls
14
- deploy:
15
- provider: npm
16
- email: rbwang@gizwits.com
17
- api_key:
18
- secure: GrkNtVOo77beuB+ZyMWIeXQa2rYJtpstJYBX7aLQlg7Fb/yvlOywIARI+sW4RmvnrIOVYwVwhX24m9Jq2B/IU6ToiH5LNKeqLVeBaZmcYE2ribl3XkImzO6ZJLDEvMA7/cW8ZP6Pqm5rd1H5xHLYrwe6cwyp4S2LH8FF8scf3HVlDLlkpK+umMgep6nMgXSV0GVz0lrHfFEECvEY4UAuS/gZb9bPk8N8WMW8oqIZHP+yJ/floDopAAEJ+iCvl6SdykZjwmIQf0ZI/l6glgEUITGiai3CYkGcoyENm/itQC0y+wtZhjQmKyHI0zznwswnj33DE2kUla0BLu0P2mW78hlHEKwgdpvbZGlPnS94MTZ7qPkDtHwujJz7/oy54AiNR5LWYdUxLby7n495PKO+eJjYa/zuwjMRavLY86bZIsHTzHTjOVutD9IfsbyeAOSGeowuA3sw5n24R7CmG2oDCbGaQznXayWCcnZteJqLmFmY5B15v3QfcOM5dX/QqLUEZOy6l10bXXElnGqsWLs8Te2a6WeT5TmxqAKA+ljPMzcp7E2jIAiLny7EcRN7yxnTXVO8cVJ42MHlFX93TlFNJlWBi663dV2imb6xi2gK6m66OWgH7pfx32l8PhsAtv9mI43ADRWrRd7E5/jy1hgPbar6dDaDK4tR/gtunWh6KgQ=
19
- skip_cleanup: true
20
- on:
21
- branch: master
22
- tag: latest
23
- condition: "$TRAVIS_TAG =~ ^v[0-9]+.[0-9]+.[0-9]+$"
@@ -1,19 +0,0 @@
1
- {
2
- // 使用 IntelliSense 了解相关属性。
3
- // 悬停以查看现有属性的描述。
4
- // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "Mocha Tests",
11
- "url": "http://localhost:8080",
12
- "webRoot": "${workspaceFolder}",
13
- "skipFiles": [
14
- "<node_internals>/**"
15
- ],
16
- "program":"${workspaceFolder}/node_modules/mocha/bin/_mocha -r ts-node/register tests/bleConfig/sdk.ble.spec.ts -file ./tests/setup-wx.js -timeout 60s"
17
- }
18
- ]
19
- }
@@ -1,3 +0,0 @@
1
- {
2
- "mocha.enabled": true
3
- }
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,61 +0,0 @@
1
- import request from '../request';
2
- import { getGlobalData } from '../globalData';
3
- import errorCode from '../errorCode';
4
- import GizLog from '../GizLog';
5
-
6
- interface IResult<T> {
7
- data: T;
8
- errMsg: string;
9
- statusCode: number;
10
- }
11
-
12
- export interface IServiceResult<T> {
13
- success: boolean;
14
- data?: T;
15
- err?: IError;
16
- }
17
-
18
- const aepApiRequest = async <T>(url: string, options: any, needToken: boolean = true): Promise<IServiceResult<T>> => {
19
- const requestOptions = { ...options };
20
- const headers: any = {
21
- 'Content-Type': 'application/json',
22
- 'X-Gizwits-Application-Id': getGlobalData('appID'),
23
- };
24
-
25
- if (needToken) {
26
- headers['Authorization'] = getGlobalData('token');
27
- }
28
-
29
- requestOptions.header = { ...headers, ...options.headers };
30
- delete requestOptions.headers;
31
- const aepApiUrl = getGlobalData('cloudServiceInfo').aepInfo;
32
- GizLog.debug('aepApiRequest', aepApiUrl + url);
33
- const res = await request<IResult<T>>(aepApiUrl + url, requestOptions);
34
- // 统一封装OPEN API的错误码
35
- if (res.statusCode >= 200 && res.statusCode < 300) {
36
- return {
37
- success: true,
38
- data: res.data,
39
- };
40
- }
41
-
42
- let baseError = {
43
- success: false,
44
- err: {
45
- errorCode: errorCode.GIZ_SDK_HTTP_REQUEST_FAILED.errorCode,
46
- errorMessage: '',
47
- },
48
- };
49
- try {
50
- baseError = {
51
- success: false,
52
- err: {
53
- errorCode: (res.data as any).error_code,
54
- errorMessage: (res.data as any).error_message,
55
- },
56
- };
57
- } catch (error) {}
58
- return baseError;
59
- };
60
-
61
- export default aepApiRequest;
@@ -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/errorCode.ts DELETED
@@ -1,84 +0,0 @@
1
- interface IErrorCode {
2
- [key: string]: IError;
3
- }
4
-
5
- const errorCode: IErrorCode = {
6
- GIZ_OPENAPI_DEVICE_NOT_BOUND: {
7
- errorCode: 9017,
8
- errorMessage: 'not bind',
9
- },
10
- GIZ_SDK_HTTP_REQUEST_FAILED: {
11
- errorCode: 8099,
12
- errorMessage: '网络请求失败',
13
- },
14
- GIZ_SDK_DEVICE_NO_RESPONSE: {
15
- errorCode: 8030,
16
- errorMessage: '设备未响应',
17
- },
18
- GIZ_SDK_SDK_NOT_INITIALIZED: {
19
- errorCode: 8300,
20
- errorMessage: 'not init',
21
- },
22
- CONFIG_TIME_OUT: {
23
- errorCode: 8023,
24
- errorMessage: 'Config Timeout',
25
- },
26
- WECHAT_ERROR: {
27
- errorCode: 10000,
28
- errorMessage: 'wechat error',
29
- },
30
- GIZ_SDK_ONBOARDING_STOPPED: {
31
- errorCode: 8318,
32
- errorMessage: '配网中断',
33
- },
34
- GIZ_SDK_DEVICE_CONFIG_IS_RUNNING: {
35
- errorCode: 8022,
36
- errorMessage: '配置正在进行中',
37
- },
38
- GIZ_OPENAPI_TOKEN_INVALID: {
39
- errorCode: 9004,
40
- errorMessage: 'token 失效',
41
- },
42
- GIZ_SDK_BIND_DEVICE_FAILED: {
43
- errorCode: 8039,
44
- errorMessage: '设备绑定失败',
45
- },
46
- GIZ_SDK_BLE_BLUETOOTH_FUNCTION_NOT_TURNED_ON: {
47
- errorCode: 8281,
48
- errorMessage: '蓝牙未启用',
49
- },
50
- GIZ_SDK_OTHERWISE: {
51
- errorCode: 8100,
52
- errorMessage: '',
53
- },
54
- GIZ_SDK_DEVICE_NOT_SUBSCRIBED: {
55
- errorCode: 8029,
56
- errorMessage: '设备还未订阅',
57
- },
58
- GIZ_SDK_PRODUCTKEY_NOT_IN_SPECIFY: {
59
- errorCode: 8250,
60
- errorMessage: '产品类型不在指定范围内',
61
- },
62
- GIZ_SDK_LOG_LEVEL_INVALID: {
63
- errorCode: 8009,
64
- errorMessage: '产品类型不在指定范围内',
65
- },
66
- GIZ_SDK_OTA_DEVICE_NOT_SUPPORT: {
67
- errorCode: 8360,
68
- errorMessage: '设备不支持手机OTA升级',
69
- },
70
- GIZ_SDK_OTA_DEVICE_BUSY_IN_UPGRADE: {
71
- errorCode: 8354,
72
- errorMessage: '设备忙,固件正在升级',
73
- },
74
- GIZ_SDK_OTA_FIRMWARE_DOWNLOAD_FAILED: {
75
- errorCode: 8353,
76
- errorMessage: '固件下载失败',
77
- },
78
- GIZ_SDK_OTA_FIRMWARE_TYPE_NOT_MATCH: {
79
- errorCode: 8361,
80
- errorMessage: '蓝牙OTA设备返回的固件类型与当前要升级的固件类型不匹配',
81
- },
82
- };
83
-
84
- export default errorCode;
package/src/global.d.ts DELETED
@@ -1,53 +0,0 @@
1
- interface IError {
2
- errorCode: number;
3
- errorMessage?: string;
4
- }
5
-
6
- interface ICommonObj {
7
- [key: string]: any
8
- }
9
-
10
- interface IDeviceStatusChangedProps {
11
- did: string;
12
- attrs: ICommonObj;
13
- }
14
-
15
- interface IDeviceRawStatusChangedProps {
16
- did: string;
17
- raw: Uint8Array;
18
- }
19
-
20
- interface IOnDeviceStatusChanged {
21
- (data: IDeviceStatusChangedProps | IDeviceRawStatusChangedProps): void;
22
- }
23
-
24
- interface IOnSocketStatusChanged {
25
- (dids: string[], enabled: boolean): void;
26
- }
27
-
28
- interface IEmptyFn {
29
- (): void;
30
- }
31
-
32
- interface IDevice {
33
- mac: string;
34
- productKey: string;
35
- did: string;
36
- bleWorkStatus?: number; // 0 默认状态 1 配网状态
37
- name: string;
38
- isBind: boolean;
39
- rootDeviceId?: string;
40
- bleDeviceID?: string;
41
- remark?: string;
42
- passcode?: string;
43
- connectType: TConnectType;
44
- isOnline: boolean; // 代表大循环在线
45
- isLanOnline: boolean; // 代表小循环在线
46
- isBleOnline: boolean; // 代表蓝牙在线
47
- host?: string;
48
- wss_port?: number;
49
- ctime?: number;
50
- RSSI?: number; // 蓝牙信号强度
51
- }
52
-
53
- type TConnectType = 'BLE' | 'BLE_BROADCAST' | 'LAN' | 'WAN' | 'NONE';
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
- }