Skip to content

Commit

Permalink
Send event when device is disconnected
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolak committed May 20, 2020
1 parent 10d3be8 commit 5c576a7
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.bridge.WritableArray;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.polidea.multiplatformbleadapter.BleAdapter;
import com.polidea.multiplatformbleadapter.BleModule;
Expand Down Expand Up @@ -338,7 +339,14 @@ public void onSuccess(Device data) {
new OnEventCallback<ConnectionState>() {
@Override
public void onEvent(ConnectionState connectionState) {

if (connectionState == ConnectionState.DISCONNECTED) {
WritableArray event = Arguments.createArray();
event.pushNull();
WritableMap device = Arguments.createMap();
device.putString("id", deviceId);
event.pushMap(device);
sendEvent(Event.DisconnectionEvent, event);
}
}
},
new OnErrorCallback() {
Expand Down

0 comments on commit 5c576a7

Please sign in to comment.