mini_program_gizwits_sdk 3.7.0-kuka → 3.7.1-beta

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 (64) hide show
  1. package/README.md +96 -25
  2. package/{index.ts → dist/index.d.ts} +3 -3
  3. package/dist/index.js +5 -5
  4. package/docs/ble-bssid.md +38 -0
  5. package/global.d.ts +3 -19
  6. package/package.json +6 -5
  7. package/yarn-error.log +34 -34
  8. package/src/GizLog.ts +0 -51
  9. package/src/aepApi/aepApiRequest.ts +0 -61
  10. package/src/crc/calculators/crc16modbus.ts +0 -36
  11. package/src/crc/calculators/crc32.ts +0 -47
  12. package/src/crc/crc16modbus.ts +0 -3
  13. package/src/crc/crc32.ts +0 -4
  14. package/src/crc/create_buffer.ts +0 -7
  15. package/src/crc/define_crc.ts +0 -9
  16. package/src/crc/index.ts +0 -10
  17. package/src/crc/package.json +0 -3
  18. package/src/crc/types.ts +0 -10
  19. package/src/errorCode.ts +0 -84
  20. package/src/global.d.ts +0 -53
  21. package/src/globalData.ts +0 -9
  22. package/src/handler/EventListener.ts +0 -44
  23. package/src/handler/ble.ts +0 -1485
  24. package/src/handler/lan.ts +0 -409
  25. package/src/handler/socket.ts +0 -625
  26. package/src/openApiRequest.ts +0 -62
  27. package/src/productConfigFileManage.ts +0 -58
  28. package/src/protocol/Bind.ts +0 -22
  29. package/src/protocol/DeviceInfo.ts +0 -36
  30. package/src/protocol/DiscoverUDP.ts +0 -80
  31. package/src/protocol/GetDeviceStatus.ts +0 -63
  32. package/src/protocol/Login.ts +0 -43
  33. package/src/protocol/Ntp.ts +0 -13
  34. package/src/protocol/OTA/AwaitNoti.ts +0 -14
  35. package/src/protocol/OTA/CheckCanOTA.ts +0 -23
  36. package/src/protocol/OTA/OTAPackPackage.ts +0 -36
  37. package/src/protocol/OTA/OtaComplete.ts +0 -17
  38. package/src/protocol/OTA/PreOTA.ts +0 -47
  39. package/src/protocol/OTA/ResetPosition.ts +0 -14
  40. package/src/protocol/OffLineData.ts +0 -81
  41. package/src/protocol/ProtocolBase.ts +0 -54
  42. package/src/protocol/Reset.ts +0 -15
  43. package/src/protocol/SetReset.ts +0 -11
  44. package/src/protocol/WifiConfig.ts +0 -42
  45. package/src/protocol/dataPoint.ts +0 -769
  46. package/src/protocol/thirdProtocol/YunZhiMianBleProtocolBase.ts +0 -39
  47. package/src/protocol/tool.ts +0 -147
  48. package/src/randomCode.ts +0 -36
  49. package/src/request.ts +0 -22
  50. package/src/sdk.ts +0 -1472
  51. package/src/sentry.ts +0 -55
  52. package/src/services/devices.ts +0 -309
  53. package/src/services/login.ts +0 -15
  54. package/src/services/ota.ts +0 -30
  55. package/src/services/tool.ts +0 -10
  56. package/src/services/uploadP0.ts +0 -56
  57. package/src/sleep.ts +0 -2
  58. package/src/types/index.ts +0 -48
  59. package/src/utils.ts +0 -419
  60. package/src/wechatApi.ts +0 -210
  61. package/src/wifiConfig/ConfigBase.ts +0 -185
  62. package/src/wifiConfig/ap.ts +0 -192
  63. package/src/wifiConfig/ble.ts +0 -436
  64. package/src/wifiConfig/ble_ailCloud.ts +0 -554
@@ -0,0 +1,38 @@
1
+ # 蓝牙配网 BSSID
2
+
3
+ BLE 模式(`mode: 3`)会按设备广播状态的 bit 3 (`support5GConfig`) 选择协议。
4
+
5
+ - 未声明支持新版协议的设备:保持原来的 `0x0001` 报文,不调用 Wi-Fi 查询。
6
+ - 支持新版协议:优先使用调用方提供的有效 `bssid`;否则调用原生 `wx.startWifi`,成功后 `wx.getConnectedWifi({ partialInfo: false })`。
7
+ - 只有返回 SSID 与目标 SSID 完全一致时才使用当前 BSSID。查询不触发主动授权,不调用 `stopWifi`,不会关闭页面共享的 Wi-Fi 模块。
8
+ - 缺少 API、权限拒绝、查询失败、SSID 不同、BSSID 无效或占位地址、1.5 秒内无回调,均降级为原来的报文,继续配网。
9
+ - 有有效 BSSID 且设备支持时,使用与 App SDK 一致的 `0x0100` 报文:Unix 秒时间戳(大端)、SSID、去除冒号的 12 字符 BSSID、密码及原有扩展信息。字符串使用 UTF-8 字节长度。
10
+ - 新报文匹配 `0x0101` 且状态为 0 的 ACK;旧报文仍匹配 `0x0002`。使用 BLE 层拼接后的完整帧,避免超过单包大小的 ACK 被误判。
11
+ - `WIFI_CONFIG_PROTOCOL` 日志仅记录是否使用 BSSID 和获取/降级原因,不新增 BSSID 或密码日志。
12
+
13
+ SDK 内部自动获取,不需要调用方增加 BSSID 参数。本次仅修改 SDK 源码及构建产物,不自动修改其他小程序项目的依赖版本,也不发布 npm。
14
+
15
+ ## 验证
16
+
17
+ `npm run test:bssid` 覆盖协议字节、广播能力解析、回调式 Wi-Fi API、超时与迟到回调、降级及真实 BLE 配网流程的协议选择和 ACK 清理。
18
+
19
+ 真机验收需分别测试支持新版协议的设备和旧设备:同 SSID、不同 SSID、关闭 Wi-Fi、拒绝定位权限,以及 Android / iOS / HarmonyOS;获取不到 BSSID 时应仍能按原方式配网。
20
+
21
+ ## 真机查看日志
22
+
23
+ 测试工程已经通过 `src/utils/sdk.ts` 引用这个本地 SDK。重新编译并真机调试后,执行一次 BLE 配网,在控制台筛选 `[BLE_CONFIG]`。
24
+ 如果应用调整过 SDK 日志级别,在初始化后执行 `sdk.setLogLevel('info')`(也可以用 `'debug'`)。
25
+
26
+ - `bssid_lookup`:开始查询;超时上限为 1500 ms。
27
+ - `bssid_result`:`reason`、`hasBssid`、`ssidMatched`、耗时;失败时包含 `api`、`errCode`、`errno`(如有)。
28
+ - `protocol_selected`:设备的 `support5GConfig`、是否实际使用 BSSID、选择原因、命令和报文长度。
29
+ - `send_start` / `write_result` / `write_retry`:实际请求命令、首次写入返回及重发次数。
30
+ - `ack_received`:收到的命令、状态(新版 ACK)、期望命令、`accepted` 是否通过 ACK 校验。
31
+ - `ack_timeout`:等待 ACK 超时和写入次数。
32
+ - `send_end`:是否收到有效 ACK、耗时,以及 SDK 主动请求断开连接。
33
+
34
+ 典型成功路径:`bssid_result` 的 `reason=current_wifi`、`hasBssid=true` → `protocol_selected` 的 `command=0x0100`、`usesBssid=true` → `ack_received` 的 `command=0x0101`、`state=0`、`accepted=true`。
35
+
36
+ 降级路径:`hasBssid=false` 或设备不支持新版协议 → `command=0x0001`、`usesBssid=false` → 期望 ACK 为 `0x0002`。降级本身不是配网失败。
37
+
38
+ 新日志不打印 SSID、完整 BSSID、密码或完整配网报文。`accepted=true` 只表示配置 ACK 校验通过,不代表设备已经联网成功。
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,13 @@
1
1
  {
2
2
  "name": "mini_program_gizwits_sdk",
3
- "version": "3.7.0-kuka",
4
- "description": "bump sdk version",
3
+ "version": "3.7.1-beta",
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",
10
11
  "release": "npm run build && release-it",
11
12
  "cover": "istanbul cover node_modules/mocha/bin/_mocha -- -r ts-node/register tests/**/*.spec.ts -file ./tests/setup-wx.js -timeout 60s",
12
13
  "coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls"
@@ -31,13 +32,13 @@
31
32
  "chai": "^4.2.0",
32
33
  "coveralls": "^3.0.11",
33
34
  "istanbul": "^1.1.0-alpha.1",
34
- "miniprogram-api-typings": "^3.5.0",
35
+ "miniprogram-api-typings": "^4.1.2",
35
36
  "mocha": "^7.1.1",
36
37
  "release-it": "^14.2.2",
37
38
  "sinon": "^9.2.4",
38
39
  "ts-loader": "^6.2.2",
39
40
  "ts-node": "^8.8.1",
40
- "typescript": "^3.8.3",
41
+ "typescript": "^4.9.5",
41
42
  "uglifyjs-webpack-plugin": "^2.2.0",
42
43
  "webpack": "^4.42.1",
43
44
  "webpack-bundle-analyzer": "^4.5.0",
package/yarn-error.log CHANGED
@@ -1,35 +1,35 @@
1
1
  Arguments:
2
- /Users/codemak1r/.nvm/versions/node/v18.2.0/bin/node /opt/homebrew/Cellar/yarn/1.22.19/libexec/bin/yarn.js
2
+ /usr/local/Cellar/node/20.7.0/bin/node /usr/local/bin/yarn add -D webpack-cli
3
3
 
4
4
  PATH:
5
- /usr/local/opt/tcl-tk/bin:/usr/local/var/pyenv/shims:/usr/local/var/pyenv/bin:/Users/codemak1r/.deno/bin:/usr/local/opt/ruby/bin:/opt/homebrew/opt/ruby/bin:/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin:/Users/codemak1r/.nvm/versions/node/v18.2.0/bin:/Users/codemak1r/.nvm/versions/node/v18.2.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/opt/tcl-tk/bin:/usr/local/var/pyenv/bin:/Users/codemak1r/.deno/bin:/usr/local/opt/ruby/bin:/opt/homebrew/opt/ruby/bin:/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin:/Users/codemak1r/.nvm/versions/node/v18.2.0/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/codemak1r/Library/Android/sdk/tools:/Users/codemak1r/Library/Android/sdk/platform-tools:/Users/codemak1r/Library/Android/sdk/build-tools/31.0.0:/Users/codemak1r/Library/Android/sdk/cmdline-tools/latest/bin:.:/Users/codemak1r/.rvm/bin:/Users/codemak1r/Library/Android/sdk/tools:/Users/codemak1r/Library/Android/sdk/platform-tools:/Users/codemak1r/Library/Android/sdk/build-tools/31.0.0:/Users/codemak1r/Library/Android/sdk/cmdline-tools/latest/bin:.:/Users/codemak1r/.rvm/bin
5
+ /Users/Kylewang/Documents/Project/mini_program_gizwits_sdk_test/mini_program_gizwits_sdk/node_modules/.bin:/Users/Kylewang/Documents/Project/mini_program_gizwits_sdk_test/node_modules/.bin:/Users/Kylewang/Documents/Project/node_modules/.bin:/Users/Kylewang/Documents/node_modules/.bin:/Users/Kylewang/node_modules/.bin:/Users/node_modules/.bin:/node_modules/.bin:/usr/local/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/node-gyp-bin:/Users/Kylewang/Library/pnpm:/usr/local/sbin:/usr/local/bin:/opt/homebrew/bin:/Users/Kylewang/opt/miniconda3/bin:/usr/local/opt/openjdk/bin:/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin:/Applications/CMake.app/Contents/bin:/Users/Kylewang/Library/Android/sdk/tools:/Users/Kylewang/Library/Android/sdk/platform-tools:/Users/Kylewang/.rvm/gems/ruby-3.0.0/bin:/Users/Kylewang/.rvm/gems/ruby-3.0.0@global/bin:/Users/Kylewang/.rvm/rubies/ruby-3.0.0/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/MacGPG2/bin:/Applications/VMware Fusion Tech Preview.app/Contents/Public:/usr/local/go/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/Kylewang/Library/pnpm:/usr/local/sbin:/opt/homebrew/bin:/Users/Kylewang/opt/miniconda3/bin:/usr/local/opt/openjdk/bin:/Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home/bin:/Applications/CMake.app/Contents/bin:/tools:/platform-tools:/Users/Kylewang/.rvm/gems/ruby-3.0.0/bin:/Users/Kylewang/.rvm/gems/ruby-3.0.0@global/bin:/Users/Kylewang/.rvm/rubies/ruby-3.0.0/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Users/Kylewang/Library/Android/sdk/platform-tools:/Users/Kylewang/Library/Android/sdk/tools:/usr/local/mysql/bin:/Users/Kylewang/flutter/bin:/Applications/Android Studio.app/Contents/gradle/gradle-5.1.1/bin:/Users/Kylewang/.rvm/bin:.:/Users/Kylewang/Library/Android/sdk/ndk/20.0.5594570/build:/Users/Kylewang/Documents/go_workspaces/bin:/Users/Kylewang/Library/Android/sdk/platform-tools:/Users/Kylewang/Library/Android/sdk/tools:/usr/local/mysql/bin:/Users/Kylewang/flutter/bin:/Applications/Android Studio.app/Contents/gradle/gradle-5.1.1/bin:.:/usr/local/go/bin:/Users/Kylewang/Library/Android/sdk/ndk/20.0.5594570/build:/usr/local/go/bin:/Users/Kylewang/Documents/go_workspaces/bin:
6
6
 
7
7
  Yarn version:
8
- 1.22.19
8
+ 1.22.11
9
9
 
10
10
  Node version:
11
- 18.2.0
11
+ 20.7.0
12
12
 
13
13
  Platform:
14
- darwin arm64
14
+ darwin x64
15
15
 
16
16
  Trace:
17
17
  Error: certificate has expired
18
- at TLSSocket.onConnectSecure (node:_tls_wrap:1531:34)
19
- at TLSSocket.emit (node:events:527:28)
20
- at TLSSocket._finishInit (node:_tls_wrap:945:8)
21
- at ssl.onhandshakedone (node:_tls_wrap:726:12)
18
+ at TLSSocket.onConnectSecure (node:_tls_wrap:1659:34)
19
+ at TLSSocket.emit (node:events:514:28)
20
+ at TLSSocket._finishInit (node:_tls_wrap:1070:8)
21
+ at ssl.onhandshakedone (node:_tls_wrap:856:12)
22
22
 
23
23
  npm manifest:
24
24
  {
25
25
  "name": "mini_program_gizwits_sdk",
26
- "version": "3.5.17-kuka",
27
- "description": "蓝牙配网标志位识别",
26
+ "version": "3.6.4",
27
+ "description": "更新类型",
28
28
  "main": "./dist/index.js",
29
29
  "scripts": {
30
30
  "test": "node_modules/mocha/bin/_mocha -r ts-node/register tests/**/*.spec.ts -file ./tests/setup-wx.js -timeout 60s",
31
31
  "testBle": "node_modules/mocha/bin/_mocha -r ts-node/register tests/utils/randomCode.spec.ts -file ./tests/setup-wx.js -timeout 60s",
32
- "build": "rm -r ./dist && webpack",
32
+ "build": "rm -rf ./dist && webpack",
33
33
  "release": "npm run build && release-it",
34
34
  "cover": "istanbul cover node_modules/mocha/bin/_mocha -- -r ts-node/register tests/**/*.spec.ts -file ./tests/setup-wx.js -timeout 60s",
35
35
  "coveralls": "npm run cover -- --report lcovonly && cat ./coverage/lcov.info | coveralls"
@@ -54,13 +54,13 @@ npm manifest:
54
54
  "chai": "^4.2.0",
55
55
  "coveralls": "^3.0.11",
56
56
  "istanbul": "^1.1.0-alpha.1",
57
- "miniprogram-api-typings": "^3.5.0",
57
+ "miniprogram-api-typings": "^3.9.0",
58
58
  "mocha": "^7.1.1",
59
59
  "release-it": "^14.2.2",
60
60
  "sinon": "^9.2.4",
61
61
  "ts-loader": "^6.2.2",
62
62
  "ts-node": "^8.8.1",
63
- "typescript": "^3.8.3",
63
+ "typescript": "^4.9.5",
64
64
  "uglifyjs-webpack-plugin": "^2.2.0",
65
65
  "webpack": "^4.42.1",
66
66
  "webpack-bundle-analyzer": "^4.5.0",
@@ -419,14 +419,14 @@ Lockfile:
419
419
 
420
420
  "@sinonjs/commons@^1.6.0", "@sinonjs/commons@^1.7.0", "@sinonjs/commons@^1.8.1":
421
421
  version "1.8.2"
422
- resolved "https://registry.npm.taobao.org/@sinonjs/commons/download/@sinonjs/commons-1.8.2.tgz?cache=0&sync_timestamp=1610537661254&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40sinonjs%2Fcommons%2Fdownload%2F%40sinonjs%2Fcommons-1.8.2.tgz#858f5c4b48d80778fde4b9d541f27edc0d56488b"
422
+ resolved "http://registry.npmmirror.com/@sinonjs/commons/download/@sinonjs/commons-1.8.2.tgz?cache=0&sync_timestamp=1610537661254&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40sinonjs%2Fcommons%2Fdownload%2F%40sinonjs%2Fcommons-1.8.2.tgz#858f5c4b48d80778fde4b9d541f27edc0d56488b"
423
423
  integrity sha1-hY9cS0jYB3j95LnVQfJ+3A1WSIs=
424
424
  dependencies:
425
425
  type-detect "4.0.8"
426
426
 
427
427
  "@sinonjs/fake-timers@^6.0.0", "@sinonjs/fake-timers@^6.0.1":
428
428
  version "6.0.1"
429
- resolved "https://registry.npm.taobao.org/@sinonjs/fake-timers/download/@sinonjs/fake-timers-6.0.1.tgz?cache=0&sync_timestamp=1610984831282&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40sinonjs%2Ffake-timers%2Fdownload%2F%40sinonjs%2Ffake-timers-6.0.1.tgz#293674fccb3262ac782c7aadfdeca86b10c75c40"
429
+ resolved "http://registry.npmmirror.com/@sinonjs/fake-timers/download/@sinonjs/fake-timers-6.0.1.tgz?cache=0&sync_timestamp=1610984831282&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40sinonjs%2Ffake-timers%2Fdownload%2F%40sinonjs%2Ffake-timers-6.0.1.tgz#293674fccb3262ac782c7aadfdeca86b10c75c40"
430
430
  integrity sha1-KTZ0/MsyYqx4LHqt/eyoaxDHXEA=
431
431
  dependencies:
432
432
  "@sinonjs/commons" "^1.7.0"
@@ -440,7 +440,7 @@ Lockfile:
440
440
 
441
441
  "@sinonjs/samsam@^5.3.1":
442
442
  version "5.3.1"
443
- resolved "https://registry.npm.taobao.org/@sinonjs/samsam/download/@sinonjs/samsam-5.3.1.tgz#375a45fe6ed4e92fca2fb920e007c48232a6507f"
443
+ resolved "http://registry.npmmirror.com/@sinonjs/samsam/download/@sinonjs/samsam-5.3.1.tgz#375a45fe6ed4e92fca2fb920e007c48232a6507f"
444
444
  integrity sha1-N1pF/m7U6S/KL7kg4AfEgjKmUH8=
445
445
  dependencies:
446
446
  "@sinonjs/commons" "^1.6.0"
@@ -449,7 +449,7 @@ Lockfile:
449
449
 
450
450
  "@sinonjs/text-encoding@^0.7.1":
451
451
  version "0.7.1"
452
- resolved "https://registry.npm.taobao.org/@sinonjs/text-encoding/download/@sinonjs/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5"
452
+ resolved "http://registry.npmmirror.com/@sinonjs/text-encoding/download/@sinonjs/text-encoding-0.7.1.tgz#8da5c6530915653f3a1f38fd5f101d8c3f8079c5"
453
453
  integrity sha1-jaXGUwkVZT86Hzj9XxAdjD+AecU=
454
454
 
455
455
  "@szmarczak/http-timer@^1.1.2":
@@ -3009,7 +3009,7 @@ Lockfile:
3009
3009
 
3010
3010
  has-flag@^4.0.0:
3011
3011
  version "4.0.0"
3012
- resolved "https://registry.npm.taobao.org/has-flag/download/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
3012
+ resolved "http://registry.npmmirror.com/has-flag/download/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
3013
3013
  integrity sha1-lEdx/ZyByBJlxNaUGGDaBrtZR5s=
3014
3014
 
3015
3015
  has-symbols@^1.0.0, has-symbols@^1.0.1:
@@ -3693,7 +3693,7 @@ Lockfile:
3693
3693
 
3694
3694
  isarray@0.0.1:
3695
3695
  version "0.0.1"
3696
- resolved "https://registry.npm.taobao.org/isarray/download/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
3696
+ resolved "http://registry.npmmirror.com/isarray/download/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf"
3697
3697
  integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=
3698
3698
 
3699
3699
  isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0:
@@ -3912,7 +3912,7 @@ Lockfile:
3912
3912
 
3913
3913
  just-extend@^4.0.2:
3914
3914
  version "4.1.1"
3915
- resolved "https://registry.npm.taobao.org/just-extend/download/just-extend-4.1.1.tgz#158f1fdb01f128c411dc8b286a7b4837b3545282"
3915
+ resolved "http://registry.npmmirror.com/just-extend/download/just-extend-4.1.1.tgz#158f1fdb01f128c411dc8b286a7b4837b3545282"
3916
3916
  integrity sha1-FY8f2wHxKMQR3IsoantIN7NUUoI=
3917
3917
 
3918
3918
  keyv@^3.0.0:
@@ -4028,7 +4028,7 @@ Lockfile:
4028
4028
 
4029
4029
  lodash.get@^4.4.2:
4030
4030
  version "4.4.2"
4031
- resolved "https://registry.npm.taobao.org/lodash.get/download/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
4031
+ resolved "http://registry.npmmirror.com/lodash.get/download/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99"
4032
4032
  integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=
4033
4033
 
4034
4034
  lodash.ismatch@^4.4.0:
@@ -4340,10 +4340,10 @@ Lockfile:
4340
4340
  resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf"
4341
4341
  integrity sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=
4342
4342
 
4343
- miniprogram-api-typings@^3.5.0:
4344
- version "3.5.0"
4345
- resolved "https://registry.yarnpkg.com/miniprogram-api-typings/-/miniprogram-api-typings-3.5.0.tgz#7e33cf3a48f5f647c8222c3aa178b4fdf9b2d142"
4346
- integrity sha512-cS/uXJTMGKujwoaeEFFFKqpCf7qp3R7iuQZWagZAwhKA3Z7U/xlhOcI3i1wqN+uo4YODg3AG1j2zCe1PDa9Wtg==
4343
+ miniprogram-api-typings@^3.9.0:
4344
+ version "3.9.0"
4345
+ resolved "https://registry.yarnpkg.com/miniprogram-api-typings/-/miniprogram-api-typings-3.9.0.tgz#c04a6b7eae5585733b5f8787297f2b9f1b60abac"
4346
+ integrity sha512-QCXHHW9H4XYazb8J9EMiFyaOWHXhBG4oehkQqi+76FJpKKIlpgL0ZkXxzJ2L+6T/c5OxKm7iegovKIQGVkZDLQ==
4347
4347
 
4348
4348
  mississippi@^3.0.0:
4349
4349
  version "3.0.0"
@@ -4496,7 +4496,7 @@ Lockfile:
4496
4496
 
4497
4497
  nise@^4.0.4:
4498
4498
  version "4.1.0"
4499
- resolved "https://registry.npm.taobao.org/nise/download/nise-4.1.0.tgz#8fb75a26e90b99202fa1e63f448f58efbcdedaf6"
4499
+ resolved "http://registry.npmmirror.com/nise/download/nise-4.1.0.tgz#8fb75a26e90b99202fa1e63f448f58efbcdedaf6"
4500
4500
  integrity sha1-j7daJukLmSAvoeY/RI9Y77ze2vY=
4501
4501
  dependencies:
4502
4502
  "@sinonjs/commons" "^1.7.0"
@@ -4975,7 +4975,7 @@ Lockfile:
4975
4975
 
4976
4976
  path-to-regexp@^1.7.0:
4977
4977
  version "1.8.0"
4978
- resolved "https://registry.npm.taobao.org/path-to-regexp/download/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a"
4978
+ resolved "http://registry.npmmirror.com/path-to-regexp/download/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a"
4979
4979
  integrity sha1-iHs7qdhDk+h6CgufTLdWGYtTVIo=
4980
4980
  dependencies:
4981
4981
  isarray "0.0.1"
@@ -5714,7 +5714,7 @@ Lockfile:
5714
5714
 
5715
5715
  sinon@^9.2.4:
5716
5716
  version "9.2.4"
5717
- resolved "https://registry.npm.taobao.org/sinon/download/sinon-9.2.4.tgz#e55af4d3b174a4443a8762fa8421c2976683752b"
5717
+ resolved "http://registry.npmmirror.com/sinon/download/sinon-9.2.4.tgz#e55af4d3b174a4443a8762fa8421c2976683752b"
5718
5718
  integrity sha1-5Vr007F0pEQ6h2L6hCHCl2aDdSs=
5719
5719
  dependencies:
5720
5720
  "@sinonjs/commons" "^1.8.1"
@@ -6108,7 +6108,7 @@ Lockfile:
6108
6108
 
6109
6109
  supports-color@^7.1.0:
6110
6110
  version "7.2.0"
6111
- resolved "https://registry.npm.taobao.org/supports-color/download/supports-color-7.2.0.tgz?cache=0&sync_timestamp=1611393963969&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsupports-color%2Fdownload%2Fsupports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
6111
+ resolved "http://registry.npmmirror.com/supports-color/download/supports-color-7.2.0.tgz?cache=0&sync_timestamp=1611393963969&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsupports-color%2Fdownload%2Fsupports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
6112
6112
  integrity sha1-G33NyzK4E4gBs+R4umpRyqiWSNo=
6113
6113
  dependencies:
6114
6114
  has-flag "^4.0.0"
@@ -6378,10 +6378,10 @@ Lockfile:
6378
6378
  resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
6379
6379
  integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
6380
6380
 
6381
- typescript@^3.8.3:
6382
- version "3.8.3"
6383
- resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"
6384
- integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==
6381
+ typescript@^4.9.5:
6382
+ version "4.9.5"
6383
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
6384
+ integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==
6385
6385
 
6386
6386
  uglify-js@^3.1.4:
6387
6387
  version "3.8.0"
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/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
- }