react-native-gizwits-sdk-v5 1.3.65 → 1.3.66

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.
@@ -97,6 +97,14 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
97
97
 
98
98
  override fun initialize() {
99
99
  super.initialize()
100
+ CoroutineScope(Dispatchers.IO).launch {
101
+ GizSDKManager.subscribeBindEvent().collect { data ->
102
+ val data = JSONObject()
103
+ data.put("did", data.first)
104
+ data.put("isBind", data.second)
105
+ sendEvent(EventName.DeviceBindStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
106
+ }
107
+ }
100
108
  CoroutineScope(Dispatchers.IO).launch {
101
109
  deviceListState.debounce(500).collect { deviceList ->
102
110
  val newDevices = deviceList - devices
@@ -107,9 +115,13 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
107
115
  // 新增的设备挂监听
108
116
  // 被移除的设备携程会自动销毁
109
117
  scope.launch {
110
- dev.bleCapacity.subscribeStatus().debounce(500).collectLatest{
118
+ combineLatest(
119
+ dev.bleCapacity.subscribeStatus(),
120
+ dev.bleCapacity.subscribeIsLogin(),
121
+ ).debounce(500).collectLatest { status, isLogin ->
111
122
  val data = JSONObject()
112
- data.put("state", it.toInt())
123
+ data.put("state", status.toInt())
124
+ data.put("isLogin", isLogin)
113
125
  data.put("type", "BLE")
114
126
  data.put("device", dev.toJsonObject())
115
127
  sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
@@ -134,9 +146,13 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
134
146
 
135
147
 
136
148
  scope.launch {
137
- dev.lanCapacity.subscribeStatus().debounce(500).collectLatest{
149
+ combineLatest(
150
+ dev.lanCapacity.subscribeStatus(),
151
+ dev.lanCapacity.subscribeIsLogin(),
152
+ ).debounce(500).collectLatest { status, isLogin ->
138
153
  val data = JSONObject()
139
- data.put("state", it.toInt())
154
+ data.put("state", status.toInt())
155
+ data.put("isLogin", isLogin)
140
156
  data.put("type", "LAN")
141
157
  data.put("device", dev.toJsonObject())
142
158
  sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
@@ -161,9 +177,13 @@ class RNGizSDKManagerModule(reactContext: ReactApplicationContext) : ReactContex
161
177
 
162
178
 
163
179
  scope.launch {
164
- dev.mqttCapacity.subscribeStatus().debounce(500).collectLatest{
180
+ combineLatest(
181
+ dev.mqttCapacity.subscribeStatus(),
182
+ dev.mqttCapacity.subscribeIsLogin(),
183
+ ).debounce(500).collectLatest { status, isLogin ->
165
184
  val data = JSONObject()
166
- data.put("state", it.toInt())
185
+ data.put("state", status.toInt())
186
+ data.put("isLogin", isLogin)
167
187
  data.put("type", "MQTT")
168
188
  data.put("device", dev.toJsonObject())
169
189
  sendEvent(EventName.DeviceStateListener.name, GizRNCallbackManager.jsonObject2WriteableMap(data))
@@ -58,12 +58,11 @@ class RNGizSDKManagerModule: RCTEventEmitter, GizSdkEventHandlerDelegate {
58
58
  sendEvent(withName: "DeviceDataListener", body: data)
59
59
  }
60
60
 
61
- func onDeviceState(device: GizwitsiOSSDK.GizDevice, state: GizwitsiOSSDK.GizWifiDeviceNetStatus, isOnline: Bool, isLogin: Bool, type: GizwitsiOSSDK.GizCapability) {
61
+ func onDeviceState(device: GizwitsiOSSDK.GizDevice, state: GizwitsiOSSDK.GizWifiDeviceNetStatus, isLogin: Bool, type: GizwitsiOSSDK.GizCapability) {
62
62
  let data = [
63
63
  "device": GizRNCallbackManager.convertToDictionary(object: device) ?? [:],
64
64
  "state": state.rawValue,
65
65
  "type": type.rawValue,
66
- "isOnline": isOnline,
67
66
  "isLogin": isLogin
68
67
  ] as [String : Any]
69
68
  sendEvent(withName: "DeviceStateListener", body: data)
package/lib/types.d.ts CHANGED
@@ -2,7 +2,6 @@ export declare type AuthenticationMethod = 0 | 1;
2
2
  export interface GizBaseCapability {
3
3
  name: string;
4
4
  isActive: boolean;
5
- isOnline: boolean;
6
5
  isLogin: boolean;
7
6
  netStatus: NetStatus;
8
7
  connect: () => Promise<GizResult<any, any>>;
@@ -119,7 +118,6 @@ export interface DeviceDataRes {
119
118
  export interface DeviceStateRes {
120
119
  device: IDevice;
121
120
  state: GizDeviceNetStatus;
122
- isOnline: boolean;
123
121
  isLogin: boolean;
124
122
  type: GizCapability;
125
123
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-gizwits-sdk-v5",
3
- "version": "1.3.65",
3
+ "version": "1.3.66",
4
4
  "description": "Gizwits",
5
5
  "homepage": "https://github.com/demchenkoalex/react-native-gizwits-sdk-v5#readme",
6
6
  "main": "lib/index.js",