mini_program_gizwits_sdk 3.5.13-kuka → 3.6.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 (103) hide show
  1. package/README.md +55 -30
  2. package/dist/index.js +10 -3
  3. package/dist/src/GizLog.d.ts +1 -1
  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/dist/src/crc/types.d.ts +11 -0
  12. package/dist/src/handler/ble.d.ts +64 -17
  13. package/dist/src/handler/lan.d.ts +5 -5
  14. package/dist/src/handler/socket.d.ts +15 -4
  15. package/dist/src/productConfigFileManage.d.ts +2 -1
  16. package/dist/src/protocol/DataPoint.d.ts +6 -5
  17. package/dist/src/protocol/DeviceInfo.d.ts +11 -0
  18. package/dist/src/protocol/{DiscoverUdp.d.ts → DiscoverUDP.d.ts} +1 -1
  19. package/dist/src/protocol/OTA/AwaitNoti.d.ts +7 -0
  20. package/dist/src/protocol/OTA/CheckCanOTA.d.ts +10 -0
  21. package/dist/src/protocol/OTA/OTAPackPackage.d.ts +8 -0
  22. package/dist/src/protocol/OTA/OtaComplete.d.ts +8 -0
  23. package/dist/src/protocol/OTA/PreOTA.d.ts +11 -0
  24. package/dist/src/protocol/OTA/ResetPosition.d.ts +6 -0
  25. package/dist/src/protocol/Reset.d.ts +8 -0
  26. package/dist/src/protocol/SetReset.d.ts +7 -0
  27. package/dist/src/protocol/tool.d.ts +4 -1
  28. package/dist/src/sdk.d.ts +63 -52
  29. package/dist/src/services/monitor.d.ts +11 -0
  30. package/dist/src/services/ota.d.ts +11 -0
  31. package/dist/src/utils.d.ts +6 -2
  32. package/dist/src/wechatApi.d.ts +5 -1
  33. package/dist/src/wifiConfig/ConfigBase.d.ts +11 -3
  34. package/dist/src/wifiConfig/ble.d.ts +15 -12
  35. package/dist/src/wifiConfig/nfc/disposeData.d.ts +2 -0
  36. package/dist/src/wifiConfig/nfc/formatData.d.ts +3 -0
  37. package/dist/src/wifiConfig/nfc/formatSSID.d.ts +6 -0
  38. package/dist/src/wifiConfig/nfc/index.d.ts +22 -0
  39. package/dist/src/wifiConfig/nfc/isIncludedCH.d.ts +1 -0
  40. package/dist/src/wifiConfig/nfc/nfcAConnect.d.ts +6 -0
  41. package/dist/src/wifiConfig/nfc/nfcATransceive.d.ts +5 -0
  42. package/dist/src/wifiConfig/nfc/ssIDToASC.d.ts +1 -0
  43. package/dist/src/wifiConfig/nfc/stringToGbk.d.ts +1 -0
  44. package/dist/src/wifiConfig/nfc/transceive.wx.d.ts +2 -0
  45. package/dist/src/wifiConfig/nfc/types.d.ts +15 -0
  46. package/package.json +4 -4
  47. package/src/crc/calculators/crc16modbus.ts +36 -0
  48. package/src/crc/calculators/crc32.ts +47 -0
  49. package/src/crc/crc16modbus.ts +3 -0
  50. package/src/crc/crc32.ts +4 -0
  51. package/src/crc/create_buffer.ts +7 -0
  52. package/src/crc/define_crc.ts +9 -0
  53. package/src/crc/index.ts +10 -0
  54. package/src/crc/package.json +3 -0
  55. package/src/crc/types.ts +10 -0
  56. package/src/errorCode.ts +20 -1
  57. package/src/handler/ble.ts +872 -257
  58. package/src/handler/lan.ts +8 -8
  59. package/src/handler/socket.ts +81 -23
  60. package/src/openApiRequest.ts +4 -4
  61. package/src/productConfigFileManage.ts +33 -17
  62. package/src/protocol/DeviceInfo.ts +37 -0
  63. package/src/protocol/OTA/AwaitNoti.ts +16 -0
  64. package/src/protocol/OTA/CheckCanOTA.ts +24 -0
  65. package/src/protocol/OTA/OTAPackPackage.ts +37 -0
  66. package/src/protocol/OTA/OtaComplete.ts +17 -0
  67. package/src/protocol/OTA/PreOTA.ts +49 -0
  68. package/src/protocol/OTA/ResetPosition.ts +15 -0
  69. package/src/protocol/OffLineData.ts +4 -4
  70. package/src/protocol/Reset.ts +16 -0
  71. package/src/protocol/SetReset.ts +13 -0
  72. package/src/protocol/dataPoint.ts +1 -1
  73. package/src/protocol/tool.ts +30 -1
  74. package/src/randomCode.ts +1 -1
  75. package/src/sdk.ts +603 -313
  76. package/src/sentry.ts +1 -1
  77. package/src/services/devices.ts +93 -4
  78. package/src/services/monitor.ts +116 -0
  79. package/src/services/ota.ts +21 -0
  80. package/src/utils.ts +35 -15
  81. package/src/wechatApi.ts +35 -6
  82. package/src/wifiConfig/ConfigBase.ts +62 -4
  83. package/src/wifiConfig/ap.ts +5 -1
  84. package/src/wifiConfig/ble.ts +284 -232
  85. package/src/wifiConfig/nfc/disposeData.ts +63 -0
  86. package/src/wifiConfig/nfc/formatData.ts +46 -0
  87. package/src/wifiConfig/nfc/formatSSID.ts +59 -0
  88. package/src/wifiConfig/nfc/index.ts +136 -0
  89. package/src/wifiConfig/nfc/isIncludedCH.ts +8 -0
  90. package/src/wifiConfig/nfc/nfcAConnect.ts +30 -0
  91. package/src/wifiConfig/nfc/nfcATransceive.ts +29 -0
  92. package/src/wifiConfig/nfc/ssIDToASC.ts +12 -0
  93. package/src/wifiConfig/nfc/stringToGbk.ts +51 -0
  94. package/src/wifiConfig/nfc/transceive.wx.ts +124 -0
  95. package/src/wifiConfig/nfc/types.ts +18 -0
  96. package/src/wifiConfig/timeZoneName.json +1 -0
  97. package/dist/src/aepApi/aepApiRequest.d.ts +0 -7
  98. package/dist/src/protocol/thirdProtocol/YunZhiMianBleProtocolBase.d.ts +0 -10
  99. package/dist/src/wifiConfig/ble_ailCloud.d.ts +0 -69
  100. package/src/aepApi/aepApiRequest.ts +0 -62
  101. package/src/protocol/thirdProtocol/YunZhiMianBleProtocolBase.ts +0 -39
  102. package/src/wifiConfig/ble_ailCloud.ts +0 -531
  103. package/yarn-error.log +0 -3415
package/README.md CHANGED
@@ -3,13 +3,6 @@
3
3
  # 机智云小程序 SDK
4
4
 
5
5
 
6
- ## 🔴 破坏性更新
7
-
8
- - 3.2.4(含)开始蓝牙广播包过滤增加了 `['ABF8', 'ABF0', 'F0AB', 'F8AB']` 四个过滤字段,为了兼容部分低端手机不过滤,长时间挂机会假死的问题。
9
- - 乐鑫_0ESP32C3_0403000G 和 博流_00BL602L_0403000B 之后的版本都支持这个特性。
10
- - 如果您使用的是更早期的固件,请联系我们。
11
-
12
-
13
6
  ## ⚠️ 重要
14
7
 
15
8
  使用小程序 sdk 前,请在微信开发者后台-开发管理-开发设置-服务器域名添加以下请求地址。
@@ -28,6 +21,17 @@ wss://wxstage.gizwits.com
28
21
  wss://wxm2m.gizwits.com
29
22
  ```
30
23
 
24
+ - 关于services
25
+
26
+ 为了搜索效率,sdk会根据`services `过滤蓝牙设备。默认 ['ABF8', 'ABF0', 'F0AB', 'F8AB']。
27
+ 如果有特殊情况,不想用`services `过滤设备,可以
28
+
29
+ ```js
30
+ sdk.scanBleDevice(3000, [])
31
+ sdk.startAutoScan([])
32
+ ```
33
+
34
+
31
35
  ## 🔧 安装
32
36
 
33
37
  ```bash
@@ -40,13 +44,13 @@ yarn add mini_program_gizwits_sdk
40
44
 
41
45
  > 采用小程序代码片段,安装新版小程序开发工具,点击链接即可打开
42
46
 
43
- ### 蓝牙和 softAp 配网
47
+ ### 蓝牙配网
44
48
 
45
- [点击打开微信开发者工具](https://developers.weixin.qq.com/s/UQI8fpm87jDI)
49
+ [点击打开微信开发者工具](https://developers.weixin.qq.com/s/Wk0aZlmg7jOR)
46
50
 
47
51
  ### 设备控制
48
52
 
49
- [点击打开微信开发者工具](https://developers.weixin.qq.com/s/NZI5gpmX7qD1)
53
+ [点击打开微信开发者工具](https://developers.weixin.qq.com/s/Kh0CMlmq77OA)
50
54
 
51
55
  ## 🏍 初始化 Sdk
52
56
 
@@ -82,9 +86,9 @@ export default class Index extends Component {
82
86
  ## 📋 日志
83
87
  sdk.setLogLevel("debug")
84
88
 
85
- ## 📖 BLE API
89
+ ## 📖 API
86
90
 
87
- 小程序 BLE 相关 API。
91
+ 小程序相关 API。
88
92
 
89
93
  ### sdk.initBle()
90
94
 
@@ -108,7 +112,7 @@ sdk.setLogLevel("debug")
108
112
 
109
113
  ### sdk.deviceSafetyRegister(Object object)
110
114
 
111
- 安全注册目标设备,否则无法发起设备绑定。返回值中可以拿到注册结果。
115
+ 安全注册目标设备,蓝牙设备绑定前,需要调用这个接口,否则无法发起设备绑定。返回值中可以拿到注册结果。
112
116
 
113
117
  #### 参数
114
118
 
@@ -132,10 +136,14 @@ sdk.setLogLevel("debug")
132
136
  | mac | string | 待绑定设备 mac |
133
137
  | productKey | string | 待绑定设备所属产品 |
134
138
 
135
- ### sdk.subscribe(device:[IDevice](#IDevice) )
139
+ ### sdk.subscribe(device:[IDevice](#IDevice),connectType:[TConnectType](#TConnectType))
136
140
 
137
141
  订阅目标设备,订阅成功后可控制设备。返回值中可以拿到订阅结果。
138
142
 
143
+ ### sdk.getDeviceStatus(device:[IDevice](#IDevice), attrNames?: string[])
144
+
145
+ 查询目标设备当前状态,attrNames 不传则查询所有数据
146
+
139
147
  ### sdk.write(device:[IDevice](#IDevice),cmd:{[key]:value})
140
148
 
141
149
  向目标设备发送指令。 其中`key`为数据点名称,value 为数据点的值。
@@ -194,15 +202,30 @@ this.gizSdk.addEventListener(
194
202
 
195
203
  ```ts
196
204
  interface IDevice {
197
- mac: string; // 设备mac
198
- productKey: string; // 机智云pk
199
- did?: string; // 云平台did
200
- name: string; // 设备名称
201
- isBind: boolean; // 是否绑定
202
- bleDeviceID?: string; // 本地蓝牙设备id
205
+ mac: string;
206
+ productKey: string;
207
+ did: string;
208
+ bleWorkStatus?: number; // 0 默认状态 1 配网状态
209
+ name: string;
210
+ isBind: boolean;
211
+ rootDeviceId?: string;
212
+ bleDeviceID?: string;
213
+ remark?: string;
214
+ passcode?: string;
215
+ connectType: TConnectType;
203
216
  isOnline: boolean; // 代表大循环在线
204
217
  isLanOnline: boolean; // 代表小循环在线
205
218
  isBleOnline: boolean; // 代表蓝牙在线
219
+ host?: string;
220
+ wss_port?: number;
221
+ ctime?: number;
222
+ }
223
+ ```
224
+
225
+ - <a id="TConnectType">TConnectType</a>
226
+
227
+ ```ts
228
+ type TConnectType = 'BLE' | 'BLE_BROADCAST' | 'LAN' | 'WAN' | 'NONE';
206
229
  }
207
230
  ```
208
231
 
@@ -228,22 +251,24 @@ interface IError {
228
251
 
229
252
  销毁事件监听。
230
253
 
231
- # 机智云小程序 wifi SDK
254
+ # 配网相关
232
255
 
233
256
  ## 使用方法
234
257
 
235
258
  ```javascript
236
259
  import GizwitsSdk, { errorCode } from 'mini_program_gizwits_sdk';
237
260
 
238
- const sdk = new GizwitsSdk({
239
- appID: '8f187b1deb9e44b6aa1374b8f13bccb1',
240
- appSecret: 'd73fa6d6d7c04d37b6b2cc13a18a9f37',
241
- specialProductKeys: ['00e7e327afa74a3d8ff1cc190bad78c0'],
242
- specialProductKeySecrets: ['aa3d301fa291466fbed20e4204609abc'],
243
- token: token,
244
- uid: uid,
245
- cloudServiceInfo: null,
246
- });
261
+ const configData = {
262
+ appID: "xxx",
263
+ appSecret: "xxx",
264
+ productInfo: [
265
+ {
266
+ productKey: "xxx",
267
+ productSecret: "xxx",
268
+ },
269
+ ],
270
+ };
271
+ const sdk = new GizwitsSdk(configData);
247
272
 
248
273
  try {
249
274
  const data = await sdk.setDeviceOnboardingDeploy({