react-native-gizwits-sdk-v5 1.6.2 → 1.6.3

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.
package/src/index.tsx ADDED
@@ -0,0 +1,433 @@
1
+ import { NativeEventEmitter, NativeModules } from 'react-native'
2
+
3
+ import Base from './Base'
4
+ import RNGizDeviceManagerModule, {
5
+ RNGizDeviceManagerModule as RNGizDeviceManagerModuleClass,
6
+ } from './device'
7
+ import {
8
+ DeviceDataCallback,
9
+ DeviceDataRes,
10
+ DeviceListCallback,
11
+ DeviceBindCallback,
12
+ DeviceStateCallback,
13
+ DeviceBindRes,
14
+ DeviceStateRes,
15
+ GizCallback,
16
+ GizConfigStruct,
17
+ IDevice,
18
+ } from './types'
19
+ import * as Types from './types'
20
+ import RNGizUserManagerModule, {
21
+ RNGizUserManagerModule as RNGizUserManagerModuleClass,
22
+ } from './user'
23
+
24
+ const eventEmitter = new NativeEventEmitter(NativeModules.RNGizSDKManagerModule)
25
+
26
+ class RNGizSDKManagerModuleClass extends Base {
27
+ deviceDataCallbacks: DeviceDataCallback[] = []
28
+ deviceListCallbacks: DeviceListCallback[] = []
29
+ deviceStateCallbacks: DeviceStateCallback[] = []
30
+ deviceBindCallbacks: DeviceBindCallback[] = []
31
+
32
+ constructor() {
33
+ super()
34
+ }
35
+
36
+ public registerListener = () => {
37
+ eventEmitter.addListener('DeviceDataListener', this.deviceDataCallback)
38
+ eventEmitter.addListener('DeviceListListener', this.deviceListCallback)
39
+ eventEmitter.addListener('DeviceStateListener', this.deviceStateCallback)
40
+ eventEmitter.addListener('DeviceBindStateListener', this.deviceBindCallback)
41
+ }
42
+ appendDeviceFunction = (device: IDevice) => {
43
+ // 补充对应的设备方法
44
+ device.startMusicalRhythm = (
45
+ sensitivity: number,
46
+ mode: Types.MusicalRhythmParseMode,
47
+ callback?: Types.GizMusicalRhythmCallback
48
+ ) => {
49
+ return RNGizDeviceManagerModule.startMusicalRhythm(
50
+ device.id,
51
+ sensitivity,
52
+ mode,
53
+ callback
54
+ )
55
+ }
56
+ device.stopMusicalRhythm = () => {
57
+ return RNGizDeviceManagerModule.stopMusicalRhythm(device.id)
58
+ }
59
+ device.bleCapability.connect = () => {
60
+ return RNGizDeviceManagerModule.connect(device.id, 'BLE')
61
+ }
62
+ device.lanCapability.connect = () => {
63
+ return RNGizDeviceManagerModule.connect(device.id, 'LAN')
64
+ }
65
+ device.mqttCapability.connect = () => {
66
+ return RNGizDeviceManagerModule.connect(device.id, 'MQTT')
67
+ }
68
+ device.bleCapability.disConnect = () => {
69
+ return RNGizDeviceManagerModule.disConnect(device.id, 'BLE')
70
+ }
71
+ device.lanCapability.disConnect = () => {
72
+ return RNGizDeviceManagerModule.disConnect(device.id, 'LAN')
73
+ }
74
+ device.mqttCapability.disConnect = () => {
75
+ return RNGizDeviceManagerModule.disConnect(device.id, 'MQTT')
76
+ }
77
+
78
+ device.bleCapability.sendDp = (data: Object) => {
79
+ return RNGizDeviceManagerModule.sendDp(device.id, 'BLE', data)
80
+ }
81
+ device.lanCapability.sendDp = (data: Object) => {
82
+ return RNGizDeviceManagerModule.sendDp(device.id, 'LAN', data)
83
+ }
84
+ device.mqttCapability.sendDp = (data: Object) => {
85
+ return RNGizDeviceManagerModule.sendDp(device.id, 'MQTT', data)
86
+ }
87
+
88
+ device.bleCapability.getDp = (attrs?: string[]) => {
89
+ return RNGizDeviceManagerModule.getDp(device.id, 'BLE', attrs)
90
+ }
91
+ device.lanCapability.getDp = (attrs?: string[]) => {
92
+ return RNGizDeviceManagerModule.getDp(device.id, 'LAN', attrs)
93
+ }
94
+ device.mqttCapability.getDp = (attrs?: string[]) => {
95
+ return RNGizDeviceManagerModule.getDp(device.id, 'MQTT', attrs)
96
+ }
97
+
98
+ device.bleCapability.getDeviceInfo = () => {
99
+ return RNGizDeviceManagerModule.getDeviceInfo(device.id, 'BLE')
100
+ }
101
+ device.lanCapability.getDeviceInfo = () => {
102
+ return RNGizDeviceManagerModule.getDeviceInfo(device.id, 'LAN')
103
+ }
104
+ device.mqttCapability.getDeviceInfo = () => {
105
+ return RNGizDeviceManagerModule.getDeviceInfo(device.id, 'MQTT')
106
+ }
107
+
108
+ device.bleCapability.startUpgrade = (
109
+ firmwareType: Types.GizOTAFirmwareType,
110
+ callback: Types.GizOtaProgressCallback
111
+ ) => {
112
+ return RNGizDeviceManagerModule.startUpgrade(
113
+ device.id,
114
+ 'BLE',
115
+ firmwareType,
116
+ callback
117
+ )
118
+ }
119
+ device.lanCapability.startUpgrade = (
120
+ firmwareType: Types.GizOTAFirmwareType,
121
+ callback: Types.GizOtaProgressCallback
122
+ ) => {
123
+ return RNGizDeviceManagerModule.startUpgrade(
124
+ device.id,
125
+ 'LAN',
126
+ firmwareType,
127
+ callback
128
+ )
129
+ }
130
+ device.mqttCapability.startUpgrade = (
131
+ firmwareType: Types.GizOTAFirmwareType,
132
+ callback: Types.GizOtaProgressCallback
133
+ ) => {
134
+ return RNGizDeviceManagerModule.startUpgrade(
135
+ device.id,
136
+ 'MQTT',
137
+ firmwareType,
138
+ callback
139
+ )
140
+ }
141
+
142
+ /**
143
+ * 配网相关
144
+ */
145
+ device.bleCapability.provideWiFiCredentials = (
146
+ ssid: string,
147
+ password: string,
148
+ timeout: number,
149
+ callback: Types.GizProvideWiFiCredentialsCallback,
150
+ bindWithUid?: boolean
151
+ ) => {
152
+ return RNGizDeviceManagerModule.provideWiFiCredentials(
153
+ device.id,
154
+ 'BLE',
155
+ ssid,
156
+ password,
157
+ timeout,
158
+ callback,
159
+ bindWithUid ?? false
160
+ )
161
+ }
162
+ device.lanCapability.provideWiFiCredentials = (
163
+ ssid: string,
164
+ password: string,
165
+ timeout: number,
166
+ callback: Types.GizProvideWiFiCredentialsCallback
167
+ ) => {
168
+ return RNGizDeviceManagerModule.provideWiFiCredentials(
169
+ device.id,
170
+ 'LAN',
171
+ ssid,
172
+ password,
173
+ timeout,
174
+ callback,
175
+ false
176
+ )
177
+ }
178
+ device.mqttCapability.provideWiFiCredentials = (
179
+ ssid: string,
180
+ password: string,
181
+ timeout: number,
182
+ callback: Types.GizProvideWiFiCredentialsCallback
183
+ ) => {
184
+ return RNGizDeviceManagerModule.provideWiFiCredentials(
185
+ device.id,
186
+ 'MQTT',
187
+ ssid,
188
+ password,
189
+ timeout,
190
+ callback,
191
+ false
192
+ )
193
+ }
194
+ device.bleCapability.stopProvideWiFiCredentials = () => {
195
+ return RNGizDeviceManagerModule.stopProvideWiFiCredentials(
196
+ device.id,
197
+ 'BLE'
198
+ )
199
+ }
200
+ device.lanCapability.stopProvideWiFiCredentials = () => {
201
+ return RNGizDeviceManagerModule.stopProvideWiFiCredentials(
202
+ device.id,
203
+ 'LAN'
204
+ )
205
+ }
206
+ device.mqttCapability.stopProvideWiFiCredentials = () => {
207
+ return RNGizDeviceManagerModule.stopProvideWiFiCredentials(
208
+ device.id,
209
+ 'MQTT'
210
+ )
211
+ }
212
+
213
+ /**
214
+ * 配网相关
215
+ */
216
+
217
+ device.updateDeviceInfo = (alias?: string, remark?: string) => {
218
+ return RNGizDeviceManagerModule.updateDeviceInfo(device.id, alias, remark)
219
+ }
220
+ device.bind = (alias?: string, remark?: string) => {
221
+ return RNGizDeviceManagerModule.bind(device.id, alias, remark)
222
+ }
223
+ device.unBind = () => {
224
+ return RNGizDeviceManagerModule.unBind(device.id)
225
+ }
226
+ device.register = () => {
227
+ return RNGizDeviceManagerModule.register(device.id)
228
+ }
229
+
230
+ device.bleCapability.checkUpdate = (
231
+ firmwareType: Types.GizOTAFirmwareType
232
+ ) => {
233
+ return RNGizDeviceManagerModule.checkUpdate(
234
+ device.id,
235
+ 'BLE',
236
+ firmwareType
237
+ )
238
+ }
239
+ device.lanCapability.checkUpdate = (
240
+ firmwareType: Types.GizOTAFirmwareType
241
+ ) => {
242
+ return RNGizDeviceManagerModule.checkUpdate(
243
+ device.id,
244
+ 'LAN',
245
+ firmwareType
246
+ )
247
+ }
248
+ device.mqttCapability.checkUpdate = (
249
+ firmwareType: Types.GizOTAFirmwareType
250
+ ) => {
251
+ return RNGizDeviceManagerModule.checkUpdate(
252
+ device.id,
253
+ 'MQTT',
254
+ firmwareType
255
+ )
256
+ }
257
+
258
+ device.bleCapability.provideWiFiCredentials = (
259
+ ssid: string,
260
+ password: string,
261
+ timeout: number,
262
+ processHandler: Types.GizProvideWiFiCredentialsCallback
263
+ ) => {
264
+ return RNGizDeviceManagerModule.provideWiFiCredentials(
265
+ device.id,
266
+ 'BLE',
267
+ ssid,
268
+ password,
269
+ timeout,
270
+ processHandler
271
+ )
272
+ }
273
+ device.lanCapability.provideWiFiCredentials = (
274
+ ssid: string,
275
+ password: string,
276
+ timeout: number,
277
+ processHandler: Types.GizProvideWiFiCredentialsCallback
278
+ ) => {
279
+ return RNGizDeviceManagerModule.provideWiFiCredentials(
280
+ device.id,
281
+ 'LAN',
282
+ ssid,
283
+ password,
284
+ timeout,
285
+ processHandler
286
+ )
287
+ }
288
+ device.mqttCapability.provideWiFiCredentials = (
289
+ ssid: string,
290
+ password: string,
291
+ timeout: number,
292
+ processHandler: Types.GizProvideWiFiCredentialsCallback
293
+ ) => {
294
+ return RNGizDeviceManagerModule.provideWiFiCredentials(
295
+ device.id,
296
+ 'MQTT',
297
+ ssid,
298
+ password,
299
+ timeout,
300
+ processHandler
301
+ )
302
+ }
303
+ }
304
+
305
+ deviceDataCallback = (data: DeviceDataRes) => {
306
+ this.deviceDataCallbacks.map((item) => {
307
+ item(data)
308
+ })
309
+ }
310
+ deviceListCallback = (data: IDevice[]) => {
311
+ this.deviceListCallbacks.map((item) => {
312
+ data.map((d) => {
313
+ this.appendDeviceFunction(d)
314
+ })
315
+ item(data)
316
+ })
317
+ }
318
+ deviceStateCallback = (data: DeviceStateRes) => {
319
+ this.deviceStateCallbacks.map((item) => {
320
+ item(data)
321
+ })
322
+ }
323
+ deviceBindCallback = (data: DeviceBindRes) => {
324
+ this.deviceBindCallbacks.map((item) => {
325
+ item(data)
326
+ })
327
+ }
328
+
329
+ async initSDK(config: GizConfigStruct): Promise<Types.GizResult<any, any>> {
330
+ this.registerListener()
331
+ return this.callbackWapper((callback: GizCallback<any, any>) => {
332
+ NativeModules.RNGizSDKManagerModule.initSDK(config, callback)
333
+ })
334
+ }
335
+ async getProductDataPointConfig(
336
+ productKey: String
337
+ ): Promise<Types.GizResult<string, any>> {
338
+ return this.callbackWapper((callback: GizCallback<any, any>) => {
339
+ NativeModules.RNGizSDKManagerModule.getProductDataPointConfig(
340
+ { productKey },
341
+ callback
342
+ )
343
+ })
344
+ }
345
+
346
+ async startBleScan(): Promise<Types.GizResult<any, any>> {
347
+ return this.callbackWapper((callback: GizCallback<any, any>) => {
348
+ NativeModules.RNGizSDKManagerModule.startBleScan({}, callback)
349
+ })
350
+ }
351
+ async stopBleScan(): Promise<Types.GizResult<any, any>> {
352
+ return this.callbackWapper((callback: GizCallback<any, any>) => {
353
+ NativeModules.RNGizSDKManagerModule.stopBleScan({}, callback)
354
+ })
355
+ }
356
+
357
+ async feedback(
358
+ uploadLog: boolean,
359
+ contact: string,
360
+ content: string
361
+ ): Promise<Types.GizResult<any, any>> {
362
+ return this.callbackWapper((callback: GizCallback<any, any>) => {
363
+ NativeModules.RNGizSDKManagerModule.feedback(
364
+ { uploadLog, contact, content },
365
+ callback
366
+ )
367
+ })
368
+ }
369
+
370
+ async cleanCache(): Promise<Types.GizResult<any, any>> {
371
+ return this.callbackWapper((callback: GizCallback<any, any>) => {
372
+ NativeModules.RNGizSDKManagerModule.cleanCache({}, callback)
373
+ })
374
+ }
375
+ /**
376
+ * 查询设备列表
377
+ */
378
+ async getDevices(): Promise<Types.GizResult<[IDevice], any>> {
379
+ const data = await this.callbackWapper(
380
+ (callback: GizCallback<IDevice[], any>) => {
381
+ NativeModules.RNGizSDKManagerModule.getDevices({}, callback)
382
+ }
383
+ )
384
+ if (data.success) {
385
+ data.data?.map((item: IDevice) => {
386
+ // 补充一些方法
387
+ this.appendDeviceFunction(item)
388
+ })
389
+ }
390
+ return data
391
+ }
392
+
393
+ // 添加监听
394
+ addDeviceDataListener(callback: DeviceDataCallback) {
395
+ this.deviceDataCallbacks.push(callback)
396
+ }
397
+ addDeviceListListener(callback: DeviceListCallback) {
398
+ this.deviceListCallbacks.push(callback)
399
+ }
400
+ addDeviceStateListener(callback: DeviceStateCallback) {
401
+ this.deviceStateCallbacks.push(callback)
402
+ }
403
+ addDeviceBindStateListener(callback: DeviceBindCallback) {
404
+ this.deviceBindCallbacks.push(callback)
405
+ }
406
+
407
+ // 解除
408
+ removeDeviceDataListener(callback: DeviceDataCallback) {
409
+ this.deleteCallBack(this.deviceDataCallbacks, callback)
410
+ }
411
+ removeDeviceListListener(callback: DeviceListCallback) {
412
+ this.deleteCallBack(this.deviceListCallbacks, callback)
413
+ }
414
+ removeDeviceStateListener(callback: DeviceStateCallback) {
415
+ this.deleteCallBack(this.deviceStateCallbacks, callback)
416
+ }
417
+ removeDeviceBindStateListener(callback: DeviceBindCallback) {
418
+ this.deleteCallBack(this.deviceBindCallbacks, callback)
419
+ }
420
+ }
421
+
422
+ const RNGizSDKManagerModule = new RNGizSDKManagerModuleClass()
423
+ export default RNGizSDKManagerModule
424
+
425
+ export {
426
+ RNGizDeviceManagerModule,
427
+ RNGizUserManagerModule,
428
+ RNGizSDKManagerModule,
429
+ Types,
430
+ RNGizSDKManagerModuleClass,
431
+ RNGizDeviceManagerModuleClass,
432
+ RNGizUserManagerModuleClass,
433
+ }
package/src/types.ts ADDED
@@ -0,0 +1,253 @@
1
+ export type AuthenticationMethod = 0 | 1 // 一型一密 | 一机一密
2
+
3
+ export interface GizBaseCapability {
4
+ name: string
5
+ isActive: boolean
6
+ isLogin: boolean
7
+ netStatus: NetStatus
8
+ connect: () => Promise<GizResult<any, any>>
9
+ disConnect: () => Promise<GizResult<any, any>>
10
+ getDeviceInfo: () => Promise<GizResult<GizDeviceInfoProfile, any>>
11
+ sendDp: (data: Object) => Promise<GizResult<GizDeviceData, any>>
12
+ getDp: (attrs?: string[]) => Promise<GizResult<GizDeviceData, any>>
13
+ checkUpdate: (
14
+ firmwareType: GizOTAFirmwareType
15
+ ) => Promise<GizResult<GizCheckUpdateResultInfo, any>>
16
+ startUpgrade: (
17
+ firmwareType: GizOTAFirmwareType,
18
+ callback: GizOtaProgressCallback
19
+ ) => Promise<GizResult<GizCheckUpdateResultInfo, any>>
20
+ provideWiFiCredentials: (
21
+ ssid: string,
22
+ password: string,
23
+ timeout: number,
24
+ callback: GizProvideWiFiCredentialsCallback,
25
+ bindWithUid?: boolean
26
+ ) => Promise<GizResult<any, any>>
27
+
28
+ stopProvideWiFiCredentials: () => Promise<GizResult<any, any>>
29
+ }
30
+
31
+ export type GizOTAEvent =
32
+ | 'GizOTAEventCheckingDeviceVersion'
33
+ | 'GizOTAEventDownloading'
34
+ | 'GizOTAEventTransferring'
35
+ | 'GizOTAEventFinish'
36
+
37
+ export interface LightDanceData {
38
+ isBeat: boolean
39
+ bpm: number
40
+ midiValue: number
41
+ fft: number[]
42
+ powerLevel: number
43
+ hue: number
44
+ }
45
+ export interface GizLightDanceDataEvent {
46
+ deviceID: string
47
+ data: LightDanceData
48
+ }
49
+
50
+ export interface GizOTAProgressData {
51
+ percentage: number
52
+ event: GizOTAEvent
53
+ }
54
+
55
+ // RN 推送的callback
56
+ export type GizOtaProgressEventCallback = (data: {
57
+ device: IDevice
58
+ data: GizOTAProgressData
59
+ }) => void
60
+
61
+ // ota 原始callback
62
+ export type GizOtaProgressCallback = (event: GizOTAProgressData) => void
63
+
64
+ export type GizProvideWiFiCredentialsCallback = (
65
+ event: GizWiFiActivatorEvent
66
+ ) => void
67
+
68
+ export type GizMusicalRhythmCallback = (event: GizLightDanceDataEvent) => void
69
+
70
+ export type MusicalRhythmParseMode = 'ROCK' | 'SOOTHING'
71
+ export interface GizCheckUpdateResultInfo {
72
+ downloadUrl: string
73
+ softVersion: string
74
+ currentSoftVersion: string
75
+ }
76
+ export interface GizBaseProfile {
77
+ protocolVersion: number
78
+ supportOTA: boolean
79
+ requiresAuthentication: boolean
80
+ authenticationMethod: AuthenticationMethod
81
+ rootDid?: string
82
+ configured: boolean
83
+ }
84
+
85
+ export type BlueToothType = 'Mesh' | 'Beacon' | 'Voice' | 'GATT'
86
+ export type BlueToothVersion = 'BLE4' | 'BLE42' | 'BLE50'
87
+ export type NetStatus = 0 | 1 | 2
88
+
89
+ export type GizWiFiActivatorEventTypeAndroid =
90
+ | 'START_WIFI_CONFIG'
91
+ | 'START_CONNECT_DEVICE'
92
+ | 'CONNECT_DEVICE_SUCCESS'
93
+ | 'CONNECT_DEVICE_FAIL'
94
+ | 'START_SEND_WIFI_CONFIG'
95
+ | 'START_SEND_WIFI_CONFIG_SUCCESS'
96
+ | 'START_SEND_WIFI_CONFIG_FAIL'
97
+ | 'WIFI_CONFIG_RECV_SUCCESS'
98
+ | 'START_SEARCH_RANDOM_CODE'
99
+ | 'START_SEARCH_RANDOM_CODE_SUCCESS'
100
+ | 'WIFI_CONFIG_SUCCESS'
101
+ | 'WIFI_CONFIG_CANCEL'
102
+ | 'WIFI_CONFIG_FAIL'
103
+
104
+ export type GizWiFiActivatorEventTypeiOS =
105
+ | 1000
106
+ | 1005
107
+ | 1006
108
+ | 1007
109
+ | 1008
110
+ | 1009
111
+ | 1010
112
+ | 1001
113
+ | 1011
114
+ | 1012
115
+ | 1013
116
+ | 1014
117
+ | 1015
118
+
119
+ export interface GizWiFiActivatorEvent {
120
+ data: GizWiFiActivatorEventTypeAndroid | GizWiFiActivatorEventTypeiOS
121
+ }
122
+ export interface GizLanProfile extends GizBaseProfile {
123
+ ip: string
124
+ port: number
125
+ cTime: number // 创建时间
126
+ }
127
+ export interface GizBleProfile extends GizBaseProfile {
128
+ deviceId: string // 设备uuid
129
+ cTime: number // 创建时间
130
+ RSSI: number
131
+ blueToothType: BlueToothType
132
+ blueToothVersion: BlueToothVersion
133
+ }
134
+ export interface GizMQTTProfile extends GizBaseProfile {
135
+ host: string
136
+ port: number
137
+ }
138
+
139
+ export interface GizBleCapability extends GizBaseCapability {
140
+ profile: GizBleProfile
141
+ }
142
+ export interface GizLanCapability extends GizBaseCapability {
143
+ profile: GizLanProfile
144
+ }
145
+ export interface GizMQTTCapability extends GizBaseCapability {
146
+ profile: GizMQTTProfile
147
+ }
148
+
149
+ export interface IDevice {
150
+ id: string
151
+ mac: string
152
+ productKey: string
153
+ did?: string
154
+ isBind: boolean
155
+ name: string
156
+
157
+ bleCapability: GizBleCapability
158
+ lanCapability: GizLanCapability
159
+ mqttCapability: GizMQTTCapability
160
+
161
+ startMusicalRhythm: (
162
+ sensitivity: number,
163
+ mode: MusicalRhythmParseMode,
164
+ callback?: GizMusicalRhythmCallback
165
+ ) => Promise<GizResult<any, any>>
166
+ stopMusicalRhythm: () => Promise<GizResult<any, any>>
167
+
168
+ bind: (alias?: string, remark?: string) => Promise<GizResult<any, any>>
169
+ updateDeviceInfo: (
170
+ alias?: string,
171
+ remark?: string
172
+ ) => Promise<GizResult<any, any>>
173
+ unBind: () => Promise<GizResult<any, any>>
174
+ register: () => Promise<GizResult<any, any>>
175
+ }
176
+
177
+ export interface IUpdateAuthorizeDataParams {
178
+ uid: string
179
+ token: string
180
+ }
181
+
182
+ export interface GizResult<T, E> {
183
+ success: boolean
184
+ message: string
185
+ data?: T
186
+ error?: E
187
+ }
188
+ export type GizCallback<T, E> = (
189
+ error: GizResult<T, E>,
190
+ data: GizResult<T, E>
191
+ ) => void
192
+ export interface ServerInfoStruct {
193
+ openAPIInfo: string
194
+ }
195
+ export interface ProductInfoStruct {
196
+ productKey: string
197
+ productSecret: string
198
+ }
199
+ export interface GizConfigStruct {
200
+ appID: string
201
+ appSecret: string
202
+ productInfos: ProductInfoStruct[]
203
+ serverInfo?: ServerInfoStruct
204
+ }
205
+
206
+ export type GizDeviceNetStatus = 0 | 1 | 2
207
+ export type GizCapability = 'BLE' | 'LAN' | 'MQTT'
208
+ export type GizOTAFirmwareType = 'Module' | 'MCU'
209
+
210
+ export interface DeviceDataRes {
211
+ device: IDevice
212
+ data: GizDeviceData
213
+ type: GizCapability
214
+ }
215
+ export interface DeviceStateRes {
216
+ device: IDevice
217
+ state: GizDeviceNetStatus
218
+ isLogin: boolean
219
+ type: GizCapability
220
+ }
221
+ export interface DeviceBindRes {
222
+ did: string
223
+ isBind: boolean
224
+ }
225
+ export type DeviceDataCallback = (data: DeviceDataRes) => void
226
+ export type DeviceStateCallback = (data: DeviceStateRes) => void
227
+ export type DeviceBindCallback = (data: DeviceBindRes) => void
228
+ export type DeviceListCallback = (data: IDevice[]) => void
229
+
230
+ // sdk 传递过来的设备状态
231
+ export interface GizDeviceDataItem {
232
+ [keyof: string]: number | Array<number> | boolean
233
+ }
234
+ export interface GizDeviceData {
235
+ sn: number
236
+ cmd: number
237
+ data: GizDeviceDataItem
238
+ alerts: GizDeviceDataItem
239
+ faults: GizDeviceDataItem
240
+ }
241
+
242
+ export interface GizDeviceInfoProfile {
243
+ moduleHardVersion: string
244
+ moduleSoftVersion: string
245
+ mcuHardVersion: string
246
+ mcuSoftVersion: string
247
+ protocolVersion: string
248
+ serialPortprotocolVersion: string
249
+ reserve1: string
250
+ reserve2: string
251
+ productKey: string
252
+ hardwareInfo: string
253
+ }