mini_program_gizwits_sdk 3.6.0 → 3.6.2

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 (59) hide show
  1. package/README.md +57 -15
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.js +3 -3
  4. package/dist/package.json +55 -0
  5. package/dist/src/GizLog.d.ts +1 -1
  6. package/dist/src/errorCode.d.ts +1 -3
  7. package/dist/src/handler/ble.d.ts +5 -66
  8. package/dist/src/handler/lan.d.ts +3 -18
  9. package/dist/src/handler/socket.d.ts +1 -0
  10. package/dist/src/openApiRequest.d.ts +1 -5
  11. package/dist/src/productConfigFileManage.d.ts +3 -6
  12. package/dist/src/protocol/OTA/CheckCanOTA.d.ts +1 -1
  13. package/dist/src/protocol/{DataPoint.d.ts → dataPoint.d.ts} +0 -34
  14. package/dist/src/randomCode.d.ts +1 -5
  15. package/dist/src/sdk.d.ts +9 -104
  16. package/dist/src/sdk.js +1101 -0
  17. package/dist/src/services/devices.d.ts +1 -17
  18. package/dist/src/services/login.d.ts +2 -6
  19. package/dist/src/services/monitor.d.ts +2 -1
  20. package/dist/src/services/monitor.js +72 -0
  21. package/dist/src/services/ota.d.ts +2 -6
  22. package/dist/src/services/uploadP0.d.ts +2 -1
  23. package/dist/src/types/index.d.ts +360 -0
  24. package/dist/src/utils.d.ts +1 -6
  25. package/dist/src/wechatApi.d.ts +1 -22
  26. package/dist/src/wifiConfig/ConfigBase.d.ts +2 -9
  27. package/dist/src/wifiConfig/ap.d.ts +1 -11
  28. package/dist/src/wifiConfig/ble.d.ts +2 -8
  29. package/dist/src/wifiConfig/nfc/index.d.ts +2 -2
  30. package/global.d.ts +3 -19
  31. package/index.ts +2 -0
  32. package/package.json +2 -2
  33. package/src/errorCode.ts +3 -3
  34. package/src/handler/ble.ts +4 -79
  35. package/src/handler/lan.ts +3 -24
  36. package/src/handler/socket.ts +3 -0
  37. package/src/openApiRequest.ts +2 -14
  38. package/src/productConfigFileManage.ts +3 -5
  39. package/src/protocol/OTA/AwaitNoti.ts +0 -2
  40. package/src/protocol/OTA/CheckCanOTA.ts +1 -2
  41. package/src/protocol/OTA/OTAPackPackage.ts +1 -1
  42. package/src/protocol/OTA/PreOTA.ts +2 -3
  43. package/src/protocol/OTA/ResetPosition.ts +1 -2
  44. package/src/protocol/dataPoint.ts +1 -42
  45. package/src/randomCode.ts +1 -12
  46. package/src/sdk.ts +11 -114
  47. package/src/services/devices.ts +2 -22
  48. package/src/services/login.ts +1 -5
  49. package/src/services/monitor.ts +1 -0
  50. package/src/services/ota.ts +1 -5
  51. package/src/services/uploadP0.ts +1 -0
  52. package/src/types/index.ts +455 -0
  53. package/src/utils.ts +1 -6
  54. package/src/wechatApi.ts +1 -22
  55. package/src/wifiConfig/ConfigBase.ts +2 -10
  56. package/src/wifiConfig/ap.ts +1 -13
  57. package/src/wifiConfig/ble.ts +2 -9
  58. package/src/wifiConfig/nfc/index.ts +1 -4
  59. package/src/global.d.ts +0 -52
package/README.md CHANGED
@@ -152,16 +152,49 @@ sdk.setLogLevel("debug")
152
152
 
153
153
  取消订阅目标设备。蓝牙设备会断开连接。返回值中可拿到取消订阅结果。
154
154
 
155
+ ### sdk.getDevices()
156
+ 刷新设备列表(同时也会在 GizDeviceListNotifications 事件里推送)
157
+ ```ts
158
+ const data = await sdk.getDevices()
159
+ console.log(data)
160
+ ```
161
+
162
+ ### sdk.stopDeviceOnboardingDeploy
163
+ 停止配网
164
+
165
+ ### sdk.setDeviceOnboardingDeploy
166
+ 开始配网
167
+
168
+ 详细参数请查阅类型定义
169
+
155
170
  ### sdk.addEventListener(type,listener)
156
171
 
157
172
  #### 概览
158
173
 
159
174
  | 事件种类 type | 回调参数类型 | 回调参数描述 |
160
175
  | --------------------------- | ------------------------------------- | -------------------- |
161
- | onScanListChange | [IDevice[]](#IDevice) | 扫描设备列表变更通知 |
176
+ | GizDeviceListNotifications | [IDevice[]](#IDevice) | 设备列表变更 |
177
+ | GizDeviceStatusNotifications | [IDeviceStatusNoti](#IDeviceStatusNoti) | 设备在线状态变更 |
162
178
  | GizDeviceAttrsNotifications | [IDeviceAttrsNoti](#IDeviceAttrsNoti) | 设备数据点变更通知 |
179
+ | onScanListChange | [IDevice[]](#IDevice) | 扫描设备列表变更通知 |
163
180
  | onBleHandleError | [IError](#IError) | ble 错误通知 |
164
181
 
182
+ - <a id="GizDeviceListNotifications"> GizDeviceListNotifications </a>
183
+
184
+ ```ts
185
+ this.gizSdk.addEventListener('GizDeviceListNotifications', (deviceList: IDevice[]) => {
186
+ console.log('列表发生变化', deviceList);
187
+ });
188
+ ```
189
+
190
+ - <a id="GizDeviceStatusNotifications"> GizDeviceStatusNotifications </a>
191
+
192
+ ```ts
193
+ this.gizSdk.addEventListener('GizDeviceStatusNotifications', (e: IDeviceStatusNoti) => {
194
+ console.log('设备在线状态变化', e);
195
+ });
196
+ ```
197
+
165
198
  - <a id="onScanListChange">onScanListChange</a>
166
199
 
167
200
  ```ts
@@ -202,23 +235,17 @@ this.gizSdk.addEventListener(
202
235
 
203
236
  ```ts
204
237
  interface IDevice {
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;
238
+ mac: string; // 设备mac
239
+ productKey: string; // 机智云pk
240
+ did?: string; // 云平台did
241
+ name: string; // 设备名称
242
+ isBind: boolean; // 是否绑定
243
+ bleDeviceID?: string; // 本地蓝牙设备id
216
244
  isOnline: boolean; // 代表大循环在线
217
245
  isLanOnline: boolean; // 代表小循环在线
218
246
  isBleOnline: boolean; // 代表蓝牙在线
219
- host?: string;
220
- wss_port?: number;
221
- ctime?: number;
247
+ bleWorkStatus?: number; // 蓝牙设备状态 0 默认状态 1 配网状态
248
+ connectType: TConnectType; // 当前连接类型
222
249
  }
223
250
  ```
224
251
 
@@ -238,6 +265,21 @@ interface IDeviceAttrsNoti {
238
265
  }
239
266
  ```
240
267
 
268
+ - <a id="IDeviceStatusNoti">IDeviceStatusNoti</a>
269
+
270
+ ```ts
271
+ interface IDeviceStatusNoti {
272
+ device: IDevice;
273
+ connectType: TConnectType;
274
+ }
275
+ ```
276
+
277
+ - <a id="TConnectType">TConnectType</a>
278
+
279
+ ```ts
280
+ type TConnectType = 'BLE' | 'BLE_BROADCAST' | 'LAN' | 'WAN' | 'NONE';
281
+ ```
282
+
241
283
  - <a id="IError">IError</a>
242
284
 
243
285
  ```ts
package/dist/index.d.ts CHANGED
@@ -2,5 +2,7 @@ import 'miniprogram-api-typings';
2
2
  import gizwitsSdk from './src/sdk';
3
3
  import errorCode from './src/errorCode';
4
4
  import { BleHandle } from './src/handler/ble';
5
+ import * as types from './src/types';
5
6
  export { errorCode, BleHandle };
7
+ export { types };
6
8
  export default gizwitsSdk;