Skip to content

Commit

Permalink
Merge pull request dotintent#725 from Polidea/feature/support-for-ble…
Browse files Browse the repository at this point in the history
…mulator

Add support for blemulator
  • Loading branch information
Cierpliwy authored Sep 15, 2020
2 parents c4fef4c + 4df6425 commit 881ee88
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.polidea.reactnativeble;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
Expand All @@ -15,7 +12,7 @@
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.polidea.multiplatformbleadapter.BleAdapter;
import com.polidea.multiplatformbleadapter.BleModule;
import com.polidea.multiplatformbleadapter.BleAdapterFactory;
import com.polidea.multiplatformbleadapter.Characteristic;
import com.polidea.multiplatformbleadapter.ConnectionOptions;
import com.polidea.multiplatformbleadapter.ConnectionState;
Expand All @@ -41,6 +38,9 @@
import java.util.List;
import java.util.Map;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;


public class BleClientManager extends ReactContextBaseJavaModule {

Expand All @@ -59,7 +59,6 @@ public class BleClientManager extends ReactContextBaseJavaModule {

public BleClientManager(ReactApplicationContext reactContext) {
super(reactContext);
bleAdapter = new BleModule(reactContext);
}

@Override
Expand All @@ -80,6 +79,7 @@ public Map<String, Object> getConstants() {

@ReactMethod
public void createClient(String restoreStateIdentifier) {
bleAdapter = BleAdapterFactory.getNewAdapter(getReactApplicationContext());
bleAdapter.createClient(restoreStateIdentifier,
new OnEventCallback<String>() {
@Override
Expand All @@ -97,6 +97,7 @@ public void onEvent(Integer data) {
@ReactMethod
public void destroyClient() {
bleAdapter.destroyClient();
bleAdapter = null;
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions ios/BleClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ + (BOOL)requiresMainQueueSetup {
}

RCT_EXPORT_METHOD(createClient:(NSString*)restoreIdentifierKey) {
_manager = [[BleClientManager alloc] initWithQueue:self.methodQueue
restoreIdentifierKey:restoreIdentifierKey];
_manager = [BleAdapterFactory getNewAdapterWithQueue:self.methodQueue
restoreIdentifierKey:restoreIdentifierKey];
_manager.delegate = self;
}

Expand Down

0 comments on commit 881ee88

Please sign in to comment.