mini_program_gizwits_sdk 3.6.7 → 3.6.8-kuka

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 (63) hide show
  1. package/README.md +25 -96
  2. package/dist/index.js +6 -4
  3. package/global.d.ts +19 -3
  4. package/{dist/index.d.ts → index.ts} +3 -3
  5. package/package.json +5 -5
  6. package/src/GizLog.ts +51 -0
  7. package/src/aepApi/aepApiRequest.ts +61 -0
  8. package/src/crc/calculators/crc16modbus.ts +36 -0
  9. package/src/crc/calculators/crc32.ts +47 -0
  10. package/src/crc/crc16modbus.ts +3 -0
  11. package/src/crc/crc32.ts +4 -0
  12. package/src/crc/create_buffer.ts +7 -0
  13. package/src/crc/define_crc.ts +9 -0
  14. package/src/crc/index.ts +10 -0
  15. package/src/crc/package.json +3 -0
  16. package/src/crc/types.ts +10 -0
  17. package/src/errorCode.ts +84 -0
  18. package/src/global.d.ts +52 -0
  19. package/src/globalData.ts +9 -0
  20. package/src/handler/EventListener.ts +44 -0
  21. package/src/handler/ble.ts +1482 -0
  22. package/src/handler/lan.ts +409 -0
  23. package/src/handler/socket.ts +625 -0
  24. package/src/openApiRequest.ts +62 -0
  25. package/src/productConfigFileManage.ts +58 -0
  26. package/src/protocol/Bind.ts +22 -0
  27. package/src/protocol/DeviceInfo.ts +36 -0
  28. package/src/protocol/DiscoverUDP.ts +80 -0
  29. package/src/protocol/GetDeviceStatus.ts +63 -0
  30. package/src/protocol/Login.ts +43 -0
  31. package/src/protocol/Ntp.ts +13 -0
  32. package/src/protocol/OTA/AwaitNoti.ts +14 -0
  33. package/src/protocol/OTA/CheckCanOTA.ts +23 -0
  34. package/src/protocol/OTA/OTAPackPackage.ts +36 -0
  35. package/src/protocol/OTA/OtaComplete.ts +17 -0
  36. package/src/protocol/OTA/PreOTA.ts +47 -0
  37. package/src/protocol/OTA/ResetPosition.ts +14 -0
  38. package/src/protocol/OffLineData.ts +81 -0
  39. package/src/protocol/ProtocolBase.ts +54 -0
  40. package/src/protocol/Reset.ts +15 -0
  41. package/src/protocol/SetReset.ts +11 -0
  42. package/src/protocol/WifiConfig.ts +42 -0
  43. package/src/protocol/dataPoint.ts +769 -0
  44. package/src/protocol/thirdProtocol/YunZhiMianBleProtocolBase.ts +39 -0
  45. package/src/protocol/tool.ts +147 -0
  46. package/src/randomCode.ts +36 -0
  47. package/src/request.ts +22 -0
  48. package/src/sdk.ts +1472 -0
  49. package/src/sentry.ts +55 -0
  50. package/src/services/devices.ts +309 -0
  51. package/src/services/login.ts +15 -0
  52. package/src/services/ota.ts +30 -0
  53. package/src/services/tool.ts +10 -0
  54. package/src/services/uploadP0.ts +56 -0
  55. package/src/sleep.ts +2 -0
  56. package/src/types/index.ts +48 -0
  57. package/src/utils.ts +418 -0
  58. package/src/wechatApi.ts +210 -0
  59. package/src/wifiConfig/ConfigBase.ts +185 -0
  60. package/src/wifiConfig/ap.ts +192 -0
  61. package/src/wifiConfig/ble.ts +436 -0
  62. package/src/wifiConfig/ble_ailCloud.ts +552 -0
  63. package/yarn-error.log +34 -34
package/README.md CHANGED
@@ -3,6 +3,13 @@
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
+
6
13
  ## ⚠️ 重要
7
14
 
8
15
  使用小程序 sdk 前,请在微信开发者后台-开发管理-开发设置-服务器域名添加以下请求地址。
@@ -21,17 +28,6 @@ wss://wxstage.gizwits.com
21
28
  wss://wxm2m.gizwits.com
22
29
  ```
23
30
 
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
-
35
31
  ## 🔧 安装
36
32
 
37
33
  ```bash
@@ -44,13 +40,13 @@ yarn add mini_program_gizwits_sdk
44
40
 
45
41
  > 采用小程序代码片段,安装新版小程序开发工具,点击链接即可打开
46
42
 
47
- ### 蓝牙配网
43
+ ### 蓝牙和 softAp 配网
48
44
 
49
- [点击打开微信开发者工具](https://developers.weixin.qq.com/s/Wk0aZlmg7jOR)
45
+ [点击打开微信开发者工具](https://developers.weixin.qq.com/s/UQI8fpm87jDI)
50
46
 
51
47
  ### 设备控制
52
48
 
53
- [点击打开微信开发者工具](https://developers.weixin.qq.com/s/Kh0CMlmq77OA)
49
+ [点击打开微信开发者工具](https://developers.weixin.qq.com/s/NZI5gpmX7qD1)
54
50
 
55
51
  ## 🏍 初始化 Sdk
56
52
 
@@ -86,9 +82,9 @@ export default class Index extends Component {
86
82
  ## 📋 日志
87
83
  sdk.setLogLevel("debug")
88
84
 
89
- ## 📖 API
85
+ ## 📖 BLE API
90
86
 
91
- 小程序相关 API。
87
+ 小程序 BLE 相关 API。
92
88
 
93
89
  ### sdk.initBle()
94
90
 
@@ -112,7 +108,7 @@ sdk.setLogLevel("debug")
112
108
 
113
109
  ### sdk.deviceSafetyRegister(Object object)
114
110
 
115
- 安全注册目标设备,蓝牙设备绑定前,需要调用这个接口,否则无法发起设备绑定。返回值中可以拿到注册结果。
111
+ 安全注册目标设备,否则无法发起设备绑定。返回值中可以拿到注册结果。
116
112
 
117
113
  #### 参数
118
114
 
@@ -127,10 +123,6 @@ sdk.setLogLevel("debug")
127
123
 
128
124
  绑定远程设备,否则无法发起设备订阅。返回值中可以拿到绑定结果。
129
125
 
130
- ### sdk.unbindDevice({devices: [IDevice]})
131
-
132
- 解绑设备
133
-
134
126
  #### 参数
135
127
 
136
128
  - Object object
@@ -140,14 +132,10 @@ sdk.setLogLevel("debug")
140
132
  | mac | string | 待绑定设备 mac |
141
133
  | productKey | string | 待绑定设备所属产品 |
142
134
 
143
- ### sdk.subscribe(device:[IDevice](#IDevice),connectType:[TConnectType](#TConnectType))
135
+ ### sdk.subscribe(device:[IDevice](#IDevice) )
144
136
 
145
137
  订阅目标设备,订阅成功后可控制设备。返回值中可以拿到订阅结果。
146
138
 
147
- ### sdk.getDeviceStatus(device:[IDevice](#IDevice), attrNames?: string[])
148
-
149
- 查询目标设备当前状态,attrNames 不传则查询所有数据
150
-
151
139
  ### sdk.write(device:[IDevice](#IDevice),cmd:{[key]:value})
152
140
 
153
141
  向目标设备发送指令。 其中`key`为数据点名称,value 为数据点的值。
@@ -156,49 +144,16 @@ sdk.setLogLevel("debug")
156
144
 
157
145
  取消订阅目标设备。蓝牙设备会断开连接。返回值中可拿到取消订阅结果。
158
146
 
159
- ### sdk.getDevices()
160
- 刷新设备列表(同时也会在 GizDeviceListNotifications 事件里推送)
161
- ```ts
162
- const data = await sdk.getDevices()
163
- console.log(data)
164
- ```
165
-
166
- ### sdk.stopDeviceOnboardingDeploy
167
- 停止配网
168
-
169
- ### sdk.setDeviceOnboardingDeploy
170
- 开始配网
171
-
172
- 详细参数请查阅类型定义
173
-
174
147
  ### sdk.addEventListener(type,listener)
175
148
 
176
149
  #### 概览
177
150
 
178
151
  | 事件种类 type | 回调参数类型 | 回调参数描述 |
179
152
  | --------------------------- | ------------------------------------- | -------------------- |
180
- | GizDeviceListNotifications | [IDevice[]](#IDevice) | 设备列表变更 |
181
- | GizDeviceStatusNotifications | [IDeviceStatusNoti](#IDeviceStatusNoti) | 设备在线状态变更 |
182
- | GizDeviceAttrsNotifications | [IDeviceAttrsNoti](#IDeviceAttrsNoti) | 设备数据点变更通知 |
183
153
  | onScanListChange | [IDevice[]](#IDevice) | 扫描设备列表变更通知 |
154
+ | GizDeviceAttrsNotifications | [IDeviceAttrsNoti](#IDeviceAttrsNoti) | 设备数据点变更通知 |
184
155
  | onBleHandleError | [IError](#IError) | ble 错误通知 |
185
156
 
186
- - <a id="GizDeviceListNotifications"> GizDeviceListNotifications </a>
187
-
188
- ```ts
189
- this.gizSdk.addEventListener('GizDeviceListNotifications', (deviceList: IDevice[]) => {
190
- console.log('列表发生变化', deviceList);
191
- });
192
- ```
193
-
194
- - <a id="GizDeviceStatusNotifications"> GizDeviceStatusNotifications </a>
195
-
196
- ```ts
197
- this.gizSdk.addEventListener('GizDeviceStatusNotifications', (e: IDeviceStatusNoti) => {
198
- console.log('设备在线状态变化', e);
199
- });
200
- ```
201
-
202
157
  - <a id="onScanListChange">onScanListChange</a>
203
158
 
204
159
  ```ts
@@ -248,15 +203,6 @@ interface IDevice {
248
203
  isOnline: boolean; // 代表大循环在线
249
204
  isLanOnline: boolean; // 代表小循环在线
250
205
  isBleOnline: boolean; // 代表蓝牙在线
251
- bleWorkStatus?: number; // 蓝牙设备状态 0 默认状态 1 配网状态
252
- connectType: TConnectType; // 当前连接类型
253
- }
254
- ```
255
-
256
- - <a id="TConnectType">TConnectType</a>
257
-
258
- ```ts
259
- type TConnectType = 'BLE' | 'BLE_BROADCAST' | 'LAN' | 'WAN' | 'NONE';
260
206
  }
261
207
  ```
262
208
 
@@ -269,21 +215,6 @@ interface IDeviceAttrsNoti {
269
215
  }
270
216
  ```
271
217
 
272
- - <a id="IDeviceStatusNoti">IDeviceStatusNoti</a>
273
-
274
- ```ts
275
- interface IDeviceStatusNoti {
276
- device: IDevice;
277
- connectType: TConnectType;
278
- }
279
- ```
280
-
281
- - <a id="TConnectType">TConnectType</a>
282
-
283
- ```ts
284
- type TConnectType = 'BLE' | 'BLE_BROADCAST' | 'LAN' | 'WAN' | 'NONE';
285
- ```
286
-
287
218
  - <a id="IError">IError</a>
288
219
 
289
220
  ```ts
@@ -297,24 +228,22 @@ interface IError {
297
228
 
298
229
  销毁事件监听。
299
230
 
300
- # 配网相关
231
+ # 机智云小程序 wifi SDK
301
232
 
302
233
  ## 使用方法
303
234
 
304
235
  ```javascript
305
236
  import GizwitsSdk, { errorCode } from 'mini_program_gizwits_sdk';
306
237
 
307
- const configData = {
308
- appID: "xxx",
309
- appSecret: "xxx",
310
- productInfo: [
311
- {
312
- productKey: "xxx",
313
- productSecret: "xxx",
314
- },
315
- ],
316
- };
317
- const sdk = new GizwitsSdk(configData);
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
+ });
318
247
 
319
248
  try {
320
249
  const data = await sdk.setDeviceOnboardingDeploy({