mini_program_gizwits_sdk 3.7.0-kuka → 3.7.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 (63) 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/global.d.ts +3 -19
  5. package/package.json +5 -5
  6. package/yarn-error.log +34 -34
  7. package/src/GizLog.ts +0 -51
  8. package/src/aepApi/aepApiRequest.ts +0 -61
  9. package/src/crc/calculators/crc16modbus.ts +0 -36
  10. package/src/crc/calculators/crc32.ts +0 -47
  11. package/src/crc/crc16modbus.ts +0 -3
  12. package/src/crc/crc32.ts +0 -4
  13. package/src/crc/create_buffer.ts +0 -7
  14. package/src/crc/define_crc.ts +0 -9
  15. package/src/crc/index.ts +0 -10
  16. package/src/crc/package.json +0 -3
  17. package/src/crc/types.ts +0 -10
  18. package/src/errorCode.ts +0 -84
  19. package/src/global.d.ts +0 -53
  20. package/src/globalData.ts +0 -9
  21. package/src/handler/EventListener.ts +0 -44
  22. package/src/handler/ble.ts +0 -1485
  23. package/src/handler/lan.ts +0 -409
  24. package/src/handler/socket.ts +0 -625
  25. package/src/openApiRequest.ts +0 -62
  26. package/src/productConfigFileManage.ts +0 -58
  27. package/src/protocol/Bind.ts +0 -22
  28. package/src/protocol/DeviceInfo.ts +0 -36
  29. package/src/protocol/DiscoverUDP.ts +0 -80
  30. package/src/protocol/GetDeviceStatus.ts +0 -63
  31. package/src/protocol/Login.ts +0 -43
  32. package/src/protocol/Ntp.ts +0 -13
  33. package/src/protocol/OTA/AwaitNoti.ts +0 -14
  34. package/src/protocol/OTA/CheckCanOTA.ts +0 -23
  35. package/src/protocol/OTA/OTAPackPackage.ts +0 -36
  36. package/src/protocol/OTA/OtaComplete.ts +0 -17
  37. package/src/protocol/OTA/PreOTA.ts +0 -47
  38. package/src/protocol/OTA/ResetPosition.ts +0 -14
  39. package/src/protocol/OffLineData.ts +0 -81
  40. package/src/protocol/ProtocolBase.ts +0 -54
  41. package/src/protocol/Reset.ts +0 -15
  42. package/src/protocol/SetReset.ts +0 -11
  43. package/src/protocol/WifiConfig.ts +0 -42
  44. package/src/protocol/dataPoint.ts +0 -769
  45. package/src/protocol/thirdProtocol/YunZhiMianBleProtocolBase.ts +0 -39
  46. package/src/protocol/tool.ts +0 -147
  47. package/src/randomCode.ts +0 -36
  48. package/src/request.ts +0 -22
  49. package/src/sdk.ts +0 -1472
  50. package/src/sentry.ts +0 -55
  51. package/src/services/devices.ts +0 -309
  52. package/src/services/login.ts +0 -15
  53. package/src/services/ota.ts +0 -30
  54. package/src/services/tool.ts +0 -10
  55. package/src/services/uploadP0.ts +0 -56
  56. package/src/sleep.ts +0 -2
  57. package/src/types/index.ts +0 -48
  58. package/src/utils.ts +0 -419
  59. package/src/wechatApi.ts +0 -210
  60. package/src/wifiConfig/ConfigBase.ts +0 -185
  61. package/src/wifiConfig/ap.ts +0 -192
  62. package/src/wifiConfig/ble.ts +0 -436
  63. package/src/wifiConfig/ble_ailCloud.ts +0 -554
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
 
@@ -123,6 +127,10 @@ sdk.setLogLevel("debug")
123
127
 
124
128
  绑定远程设备,否则无法发起设备订阅。返回值中可以拿到绑定结果。
125
129
 
130
+ ### sdk.unbindDevice({devices: [IDevice]})
131
+
132
+ 解绑设备
133
+
126
134
  #### 参数
127
135
 
128
136
  - Object object
@@ -132,10 +140,14 @@ sdk.setLogLevel("debug")
132
140
  | mac | string | 待绑定设备 mac |
133
141
  | productKey | string | 待绑定设备所属产品 |
134
142
 
135
- ### sdk.subscribe(device:[IDevice](#IDevice) )
143
+ ### sdk.subscribe(device:[IDevice](#IDevice),connectType:[TConnectType](#TConnectType))
136
144
 
137
145
  订阅目标设备,订阅成功后可控制设备。返回值中可以拿到订阅结果。
138
146
 
147
+ ### sdk.getDeviceStatus(device:[IDevice](#IDevice), attrNames?: string[])
148
+
149
+ 查询目标设备当前状态,attrNames 不传则查询所有数据
150
+
139
151
  ### sdk.write(device:[IDevice](#IDevice),cmd:{[key]:value})
140
152
 
141
153
  向目标设备发送指令。 其中`key`为数据点名称,value 为数据点的值。
@@ -144,16 +156,49 @@ sdk.setLogLevel("debug")
144
156
 
145
157
  取消订阅目标设备。蓝牙设备会断开连接。返回值中可拿到取消订阅结果。
146
158
 
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
+
147
174
  ### sdk.addEventListener(type,listener)
148
175
 
149
176
  #### 概览
150
177
 
151
178
  | 事件种类 type | 回调参数类型 | 回调参数描述 |
152
179
  | --------------------------- | ------------------------------------- | -------------------- |
153
- | onScanListChange | [IDevice[]](#IDevice) | 扫描设备列表变更通知 |
180
+ | GizDeviceListNotifications | [IDevice[]](#IDevice) | 设备列表变更 |
181
+ | GizDeviceStatusNotifications | [IDeviceStatusNoti](#IDeviceStatusNoti) | 设备在线状态变更 |
154
182
  | GizDeviceAttrsNotifications | [IDeviceAttrsNoti](#IDeviceAttrsNoti) | 设备数据点变更通知 |
183
+ | onScanListChange | [IDevice[]](#IDevice) | 扫描设备列表变更通知 |
155
184
  | onBleHandleError | [IError](#IError) | ble 错误通知 |
156
185
 
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
+
157
202
  - <a id="onScanListChange">onScanListChange</a>
158
203
 
159
204
  ```ts
@@ -203,6 +248,15 @@ interface IDevice {
203
248
  isOnline: boolean; // 代表大循环在线
204
249
  isLanOnline: boolean; // 代表小循环在线
205
250
  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';
206
260
  }
207
261
  ```
208
262
 
@@ -215,6 +269,21 @@ interface IDeviceAttrsNoti {
215
269
  }
216
270
  ```
217
271
 
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
+
218
287
  - <a id="IError">IError</a>
219
288
 
220
289
  ```ts
@@ -228,22 +297,24 @@ interface IError {
228
297
 
229
298
  销毁事件监听。
230
299
 
231
- # 机智云小程序 wifi SDK
300
+ # 配网相关
232
301
 
233
302
  ## 使用方法
234
303
 
235
304
  ```javascript
236
305
  import GizwitsSdk, { errorCode } from 'mini_program_gizwits_sdk';
237
306
 
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
- });
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);
247
318
 
248
319
  try {
249
320
  const data = await sdk.setDeviceOnboardingDeploy({
@@ -1,7 +1,7 @@
1
1
  import 'miniprogram-api-typings';
2
2
  import gizwitsSdk from './src/sdk';
3
- import errorCode from './src/errorCode';
3
+ import errorCode from './src/utils/errorCode';
4
4
  import { BleHandle } from './src/handler/ble';
5
-
6
5
  export { errorCode, BleHandle };
7
- export default gizwitsSdk;
6
+ export default gizwitsSdk;
7
+ export * from './src/types';