diff --git a/.babelrc b/.babelrc
deleted file mode 100644
index 71dbc86b..00000000
--- a/.babelrc
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "presets": [
- "react-native" // this is required for debugging with react-native/packager/transformer
- ],
- "plugins": [],
- "sourceMaps": true // must be true react-native/packager/transformer using with node-module-debug
- // because of some bugs from vscode-node-debug & vscode-react-native, "sourceMaps" cannot be "inline" or "both"
-}
\ No newline at end of file
diff --git a/.flowconfig b/.flowconfig
deleted file mode 100644
index 8e838d96..00000000
--- a/.flowconfig
+++ /dev/null
@@ -1,94 +0,0 @@
-[ignore]
-
-# We fork some components by platform.
-.*/*.web.js
-.*/*.android.js
-
-# Some modules have their own node_modules with overlap
-.*/node_modules/node-haste/.*
-
-# Ugh
-.*/node_modules/babel.*
-.*/node_modules/babylon.*
-.*/node_modules/invariant.*
-
-# Ignore react and fbjs where there are overlaps, but don't ignore
-# anything that react-native relies on
-.*/node_modules/fbjs/lib/Map.js
-.*/node_modules/fbjs/lib/ErrorUtils.js
-
-# Flow has a built-in definition for the 'react' module which we prefer to use
-# over the currently-untyped source
-.*/node_modules/react/react.js
-.*/node_modules/react/lib/React.js
-.*/node_modules/react/lib/ReactDOM.js
-
-.*/__mocks__/.*
-.*/__tests__/.*
-
-.*/commoner/test/source/widget/share.js
-
-# Ignore commoner tests
-.*/node_modules/commoner/test/.*
-
-# See https://github.com/facebook/flow/issues/442
-.*/react-tools/node_modules/commoner/lib/reader.js
-
-# Ignore jest
-.*/node_modules/jest-cli/.*
-
-# Ignore Website
-.*/website/.*
-
-# Ignore generators
-.*/local-cli/generator.*
-
-# Ignore BUCK generated folders
-.*\.buckd/
-
-.*/node_modules/is-my-json-valid/test/.*\.json
-.*/node_modules/iconv-lite/encodings/tables/.*\.json
-.*/node_modules/y18n/test/.*\.json
-.*/node_modules/spdx-license-ids/spdx-license-ids.json
-.*/node_modules/spdx-exceptions/index.json
-.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json
-.*/node_modules/resolve/lib/core.json
-.*/node_modules/jsonparse/samplejson/.*\.json
-.*/node_modules/json5/test/.*\.json
-.*/node_modules/ua-parser-js/test/.*\.json
-.*/node_modules/builtin-modules/builtin-modules.json
-.*/node_modules/binary-extensions/binary-extensions.json
-.*/node_modules/url-regex/tlds.json
-.*/node_modules/joi/.*\.json
-.*/node_modules/isemail/.*\.json
-.*/node_modules/tr46/.*\.json
-
-
-[include]
-
-[libs]
-node_modules/react-native/Libraries/react-native/react-native-interface.js
-node_modules/react-native/flow
-flow/
-
-[options]
-module.system=haste
-
-esproposal.class_static_fields=enable
-esproposal.class_instance_fields=enable
-
-munge_underscores=true
-
-module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
-module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
-
-suppress_type=$FlowIssue
-suppress_type=$FlowFixMe
-suppress_type=$FixMe
-
-suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
-suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
-suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
-
-[version]
-0.24.0
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 00000000..1e107f52
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1 @@
+examples
diff --git a/android/EmptyProject.iml b/android/EmptyProject.iml
deleted file mode 100644
index 16a7f7b6..00000000
--- a/android/EmptyProject.iml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/app/app.iml b/android/app/app.iml
deleted file mode 100644
index 4a3d0aec..00000000
--- a/android/app/app.iml
+++ /dev/null
@@ -1,136 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/app/src/main/java/com/emptyproject/MainActivity.java b/android/app/src/main/java/com/emptyproject/MainActivity.java
deleted file mode 100644
index 7886adeb..00000000
--- a/android/app/src/main/java/com/emptyproject/MainActivity.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.emptyproject;
-
-import com.facebook.react.ReactActivity;
-import com.facebook.react.ReactPackage;
-import com.facebook.react.shell.MainReactPackage;
-import java.util.Arrays;
-import java.util.List;
-import org.konradkrakowiak.blereactnative.BlePackage;
-
-import com.burnweb.rnpermissions.RNPermissionsPackage;
-
-public class MainActivity extends ReactActivity {
-
- /**
- * Returns the name of the main component registered from JavaScript.
- * This is used to schedule rendering of the component.
- */
- @Override
- protected String getMainComponentName() {
- return "EmptyProject";
- }
-
- @Override
- public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
- RNPermissionsPackage.onRequestPermissionsResult(requestCode, permissions, grantResults); // very important event callback
- super.onRequestPermissionsResult(requestCode, permissions, grantResults);
- }
-}
diff --git a/android/app/src/main/java/com/emptyproject/MainApplication.java b/android/app/src/main/java/com/emptyproject/MainApplication.java
deleted file mode 100644
index b208f971..00000000
--- a/android/app/src/main/java/com/emptyproject/MainApplication.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.emptyproject;
-
-import android.Manifest;
-import android.app.Application;
-import android.content.pm.PackageManager;
-import android.support.v4.app.ActivityCompat;
-import android.util.Log;
-
-import com.facebook.react.ReactApplication;
-import com.facebook.react.ReactInstanceManager;
-import com.facebook.react.ReactNativeHost;
-import com.facebook.react.ReactPackage;
-import com.facebook.react.shell.MainReactPackage;
-
-import com.burnweb.rnpermissions.RNPermissionsPackage;
-
-import org.konradkrakowiak.blereactnative.BlePackage;
-
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Created by konradrodzik on 7/26/16.
- */
-public class MainApplication extends Application implements ReactApplication {
-
- private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
- @Override
- protected boolean getUseDeveloperSupport() {
- return BuildConfig.DEBUG;
- }
-
- @Override
- protected List getPackages() {
- return Arrays.asList(
- new MainReactPackage(),
- new TestBLEPackage(),
- new BlePackage(),
- new RNPermissionsPackage()
- );
- }
- };
-
- @Override
- public ReactNativeHost getReactNativeHost() {
- return mReactNativeHost;
- }
-}
diff --git a/android/app/src/main/java/com/emptyproject/RxBleReactContextBaseJavaModule.java b/android/app/src/main/java/com/emptyproject/RxBleReactContextBaseJavaModule.java
deleted file mode 100644
index 68a3cdb5..00000000
--- a/android/app/src/main/java/com/emptyproject/RxBleReactContextBaseJavaModule.java
+++ /dev/null
@@ -1,343 +0,0 @@
-package com.emptyproject;
-
-import android.bluetooth.BluetoothGattCharacteristic;
-import android.bluetooth.BluetoothGattService;
-import android.support.annotation.Nullable;
-import android.util.Base64;
-import android.util.Log;
-import com.facebook.react.bridge.Arguments;
-import com.facebook.react.bridge.Callback;
-import com.facebook.react.bridge.Promise;
-import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.react.bridge.ReactContext;
-import com.facebook.react.bridge.ReactContextBaseJavaModule;
-import com.facebook.react.bridge.ReactMethod;
-import com.facebook.react.bridge.WritableMap;
-import com.facebook.react.modules.core.DeviceEventManagerModule;
-import com.polidea.rxandroidble.RxBleClient;
-import com.polidea.rxandroidble.RxBleConnection;
-import com.polidea.rxandroidble.RxBleDevice;
-import com.polidea.rxandroidble.RxBleDeviceServices;
-import com.polidea.rxandroidble.RxBleScanResult;
-import com.polidea.rxandroidble.exceptions.BleDisconnectedException;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-import org.konradkrakowiak.blereactnative.converter.ConverterManager;
-import rx.Observable;
-import rx.Subscription;
-
-public class RxBleReactContextBaseJavaModule extends ReactContextBaseJavaModule {
-
- private static final String TAG = RxBleReactContextBaseJavaModule.class.getSimpleName();
-
- interface Metadata {
-
- }
-
-
- ConverterManager converterManager;
-
-
- RxBleClient rxBleClient;
-
- Subscription scanBleDevicesSubscription;
-
- //TODO maps are not the best solution!!!
-
- Map deviceMap;
-
- Map connectionMap;
-
- Map deviceServicesMap;
-
- Map establishConnectionSubscriptionMap;
-
- Map establishDeviceServicesSubscriptionMap;
-
-
- public RxBleReactContextBaseJavaModule(ReactApplicationContext reactContext) {
- super(reactContext);
- converterManager = new ConverterManager();
- deviceMap = new HashMap<>();
- deviceServicesMap = new HashMap<>();
- establishConnectionSubscriptionMap = new HashMap<>();
- establishDeviceServicesSubscriptionMap = new HashMap<>();
- connectionMap = new HashMap<>();
- }
-
- @Override
- public String getName() {
- return "RxBleClient";
- }
-
- @ReactMethod
- public void createContext(Callback success) {
- rxBleClient = RxBleClient.create(getReactApplicationContext());
- success.invoke(true);
- }
-
- @ReactMethod
- public void scanBleDevices() {
- scanBleDevicesSubscription = rxBleClient.scanBleDevices().subscribe(
- this::sendEventOnScanBleDevice,
- throwable -> {
-
- }
- );
- }
-
- private void sendEventOnScanBleDevice(RxBleScanResult rxBleScanResult) {
- final WritableMap params = converterManager.convert(rxBleScanResult);
- final RxBleDevice bleDevice = rxBleScanResult.getBleDevice();
- deviceMap.put(bleDevice.getMacAddress(), bleDevice);
- sendEvent(getReactApplicationContext(), "BLE_SCAN_RESULT", params);
- }
-
- @ReactMethod
- public void establishConnection(String mac, boolean autoConnect, Promise promise) {
- final RxBleDevice rxBleDevice = deviceMap.get(mac);
- if (rxBleDevice == null) {
- promise.reject(new RuntimeException()); // Todo Create NoFoundDeviceException or sth like that.
- return;
- }
-
- final Subscription oldSubscription = establishConnectionSubscriptionMap.get(mac);
- if (oldSubscription != null && !oldSubscription.isUnsubscribed()) {
- return;
- }
- final RxBleConnection connection = connectionMap.get(mac);
- if (!rxBleDevice.getConnectionState().equals(RxBleConnection.RxBleConnectionState.CONNECTED) && connection != null) {
- promise.resolve(mac);
- return;
- }
-
- final Subscription subscription = rxBleDevice
- .establishConnection(getReactApplicationContext(), autoConnect)
- .subscribe(
- rxBleConnection -> onEstablishConnectionSuccess(mac, rxBleConnection, promise),
- throwable -> onEstablishConnectionFailure(mac, throwable, promise),
- () -> Log.d(TAG, "establishConnection onComplete for " + mac));
- establishConnectionSubscriptionMap.put(mac, subscription);
-
- Observable.just(Observable.just("test")).flatMap(obs -> obs).subscribe(str -> str.substring(1));
- }
-
- private void onEstablishConnectionSuccess(String mac, RxBleConnection rxBleConnection, Promise promise) {
- connectionMap.put(mac, rxBleConnection);
- promise.resolve(mac);
- }
-
- private void onEstablishConnectionFailure(String mac, Throwable throwable, Promise promise) {
- final Subscription establishConnectionSubscription = establishConnectionSubscriptionMap.get(mac);
- if (establishConnectionSubscription != null) {
- establishConnectionSubscription.unsubscribe();
- establishConnectionSubscriptionMap.remove(mac);
- }
- connectionMap.remove(mac);
- promise.reject(throwable);
- }
-
- @ReactMethod
- public void discoverServices(String mac, Promise promise) {
- final RxBleConnection rxBleConnection = connectionMap.get(mac);
- if (rxBleConnection == null) {
- promise.reject(new RuntimeException()); // Todo Create NoFoundConnectionException or sth like that.
- return;
- }
- final Subscription subscribe = rxBleConnection.discoverServices()
- .subscribe(
- rxBleDeviceServices -> onDiscoverDeviceServicesSuccess(mac, rxBleDeviceServices, promise));
- establishDeviceServicesSubscriptionMap.put(mac, subscribe);
- }
-
- private void onDiscoverDeviceServicesSuccess(String mac, RxBleDeviceServices rxBleDeviceServices, Promise promise) {
- deviceServicesMap.put(mac, rxBleDeviceServices);
- promise.resolve(converterManager.convert(rxBleDeviceServices));
- }
-
- @ReactMethod
- public void getService(String mac, String uuid, Promise promise) {
- final RxBleDeviceServices rxBleDeviceServices = deviceServicesMap.get(mac);
- if (rxBleDeviceServices == null) {
- promise.reject(new RuntimeException("NoSuchServiceException for " + mac)); // TODO Create NoSuchServiceException
- return;
- }
-
- final Subscription subscribe = rxBleDeviceServices
- .getService(UUID.fromString(uuid))
- .subscribe(bluetoothGattService -> onGetServiceSuccess(bluetoothGattService, promise),
- throwable -> onGetCharacteristicFailure(throwable, promise));
- }
-
- private void onGetServiceSuccess(BluetoothGattService bluetoothGattService, Promise promise) {
- Log.d(TAG, "Characteristic is read");
- promise.resolve(bluetoothGattService.getUuid().toString());
- }
-
- private void onGetServiceFailure(Throwable throwable, Promise promise) {
- Log.d(TAG, "Characteristic reading is failure");
- promise.reject(throwable);
- }
-
- @ReactMethod
- public void getFirstCharacteristic(String mac, String characteristicUUID, Promise promise) {
- final RxBleDeviceServices rxBleDeviceServices = deviceServicesMap.get(mac);
- if (rxBleDeviceServices == null) {
- promise.reject(new RuntimeException("NoSuchServiceException for " + mac)); // TODO Create NoSuchServiceException
- return;
- }
-
- final Subscription subscribe = rxBleDeviceServices
- .getCharacteristic(UUID.fromString(characteristicUUID))
- .subscribe(bluetoothGattCharacteristic -> onGetCharacteristicSuccess(bluetoothGattCharacteristic, promise),
- throwable -> onGetCharacteristicFailure(throwable, promise));
- }
-
- @ReactMethod
- public void getCharacteristic(String mac, String serviceUUID, String characteristicUUID, Promise promise) {
- final RxBleDeviceServices rxBleDeviceServices = deviceServicesMap.get(mac);
- if (rxBleDeviceServices == null) {
- promise.reject(new RuntimeException("NoSuchServiceException for " + mac)); // TODO Create NoSuchServiceException
- return;
- }
- final Subscription subscribe = rxBleDeviceServices
- .getCharacteristic(UUID.fromString(serviceUUID), UUID.fromString(characteristicUUID))
- .subscribe(bluetoothGattCharacteristic -> onGetCharacteristicSuccess(bluetoothGattCharacteristic, promise),
- throwable -> onGetCharacteristicFailure(throwable, promise));
- }
-
- private void onGetCharacteristicSuccess(BluetoothGattCharacteristic bluetoothGattCharacteristic, Promise promise) {
- Log.d(TAG, "Characteristic is read");
- promise.resolve(bluetoothGattCharacteristic.getUuid().toString());
- }
-
- private void onGetCharacteristicFailure(Throwable throwable, Promise promise) {
- Log.d(TAG, "Characteristic reading is failure");
- promise.reject(throwable);
- }
-
- @ReactMethod
- public void readCharacteristic(String mac, String uuid, Promise promise) {
- final RxBleConnection rxBleConnection = connectionMap.get(mac);
- if (rxBleConnection == null) {
- promise.reject(new RuntimeException("NoSuchConnection for " + mac)); // TODO Create NoSuchConnection
- return;
- }
- final Subscription subscribe = rxBleConnection.readCharacteristic(UUID.fromString(uuid))
- .doOnNext(xx -> doOnNext())
- .subscribe(bytes -> onReadCharacteristicSuccess(promise, bytes));
- }
-
- private void doOnNext() {
- Log.d(TAG, "doOnNext: test");
- }
-
- private void onReadCharacteristicSuccess(Promise promise, byte[] bytes) {
- promise.resolve(Base64.encodeToString(bytes, Base64.DEFAULT));
- Log.d(TAG, "onReadCharacteristicSuccess: " + Arrays.toString(bytes));
- }
-
- @ReactMethod
- public void writeCharacteristic(String mac, String uuid, String data, Promise promise) {
- final RxBleConnection rxBleConnection = connectionMap.get(mac);
- if (rxBleConnection == null) {
- promise.reject(new RuntimeException("NoSuchConnection for " + mac)); // TODO Create NoSuchConnection
- return;
- }
- final Subscription subscribe = rxBleConnection.writeCharacteristic(UUID.fromString(uuid), Base64.decode(data, Base64.DEFAULT))
- .subscribe(bytes -> onWriteCharacteristicSuccess(promise, bytes));
- }
-
- private void onWriteCharacteristicSuccess(Promise promise, byte[] bytes) {
- promise.resolve(Base64.encodeToString(bytes, Base64.DEFAULT));
- Log.d(TAG, "onWriteCharacteristicSuccess: " + Arrays.toString(bytes));
- }
-
- private static final UUID accelerometerCharacteristicDataUuid = UUID.fromString("F000AA11-0451-4000-B000-000000000000");
-
- private static final UUID accelerometerCharacteristicConfigUuid = UUID.fromString("F000AA12-0451-4000-B000-000000000000");
-
- @ReactMethod
- public void xxXX() {
- final RxBleDevice bleDevice = rxBleClient.getBleDevice("34:B1:F7:D5:04:01");
- final Subscription dataSubscription = bleDevice
- .establishConnection(getReactApplicationContext(), false)
- .flatMap(rxBleConnection ->
- rxBleConnection.writeCharacteristic(accelerometerCharacteristicConfigUuid, new byte[]{1})
- .flatMap(ignoredBytes -> rxBleConnection.setupNotification(accelerometerCharacteristicDataUuid))
- )
- .flatMap(observable -> observable)
- .retryWhen(observable -> observable.delay(5, TimeUnit.SECONDS).filter(throwable -> throwable instanceof BleDisconnectedException))
- .subscribe(
- this::onNotification//,
-// throwable -> Toast.makeText(this, throwable.toString(), Toast.LENGTH_LONG).show()
- );
- }
-
- @ReactMethod
- public void wTeoriiDzialajacaMetoda(String mac, Promise promise) {
- final RxBleDevice rxBleDevice = deviceMap.get(mac);
- if (rxBleDevice == null) {
- promise.reject(new RuntimeException()); // Todo Create NoFoundDeviceException or sth like that.
- return;
- }
-
- final RxBleConnection connection = connectionMap.get(mac);
- if (connection == null) {
- return;
- }
- if (!rxBleDevice.getConnectionState().equals(RxBleConnection.RxBleConnectionState.CONNECTED)) {
- promise.reject(new RuntimeException());
- return;
- }
- connection.writeCharacteristic(accelerometerCharacteristicConfigUuid, new byte[]{1})
- .flatMap(ignoredBytes -> connection.setupNotification(accelerometerCharacteristicDataUuid))
- .flatMap(observable -> observable)
- .retryWhen(observable -> observable.delay(5, TimeUnit.SECONDS).filter(throwable -> throwable instanceof BleDisconnectedException))
- .subscribe(
- this::onNotification//,
-// throwable -> Toast.makeText(this, throwable.toString(), Toast.LENGTH_LONG).show()
- );
- }
-
- @ReactMethod
- public void setupNotification(String mac, String uuid, Promise promise) {
- final RxBleConnection rxBleConnection = connectionMap.get(mac);
- if (rxBleConnection == null) {
- promise.reject(new RuntimeException("NoSuchConnection for " + mac)); // TODO Create NoSuchConnection
- return;
- }
- final Subscription subscribe = rxBleConnection.setupNotification(UUID.fromString(uuid)).subscribe(this::onSetupNotificationSuccess,
- throwable -> Log.e(TAG, "Error : ", throwable));
- }
-
- private void onSetupNotificationSuccess(Observable byteObservable) {
- byteObservable.subscribe(this::onNotification);
- Log.d(TAG, "onWriteCharacteristicSuccess");
- }
-
- private void onNotification(byte[] bytes) {
- Log.d(TAG, "onWriteCharacteristicSuccess: " + Arrays.toString(bytes));
- WritableMap result = Arguments.createMap();
- result.putString("test", Arrays.toString(bytes));
- sendEvent(getReactApplicationContext(), "NOTIFICATION_EVENT", result);
- }
-
-
- @ReactMethod
- public void stopScanDevice() {
- if (scanBleDevicesSubscription == null) {
- return;
- }
- scanBleDevicesSubscription.unsubscribe();
- }
-
- private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
- reactContext
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
- .emit(eventName, params);
- }
-}
diff --git a/android/app/src/main/java/com/emptyproject/TestBLEModule.java b/android/app/src/main/java/com/emptyproject/TestBLEModule.java
deleted file mode 100644
index 1abf6e8a..00000000
--- a/android/app/src/main/java/com/emptyproject/TestBLEModule.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package com.emptyproject;
-
-import android.os.Handler;
-import android.support.annotation.Nullable;
-import android.util.Log;
-import android.widget.Toast;
-import com.facebook.react.bridge.Arguments;
-import com.facebook.react.bridge.Callback;
-import com.facebook.react.bridge.Promise;
-import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.react.bridge.ReactContext;
-import com.facebook.react.bridge.ReactContextBaseJavaModule;
-import com.facebook.react.bridge.ReactMethod;
-import com.facebook.react.bridge.WritableMap;
-import com.facebook.react.modules.core.DeviceEventManagerModule;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Created by Konrad on 23/05/16.
- */
-public class TestBLEModule extends ReactContextBaseJavaModule {
-
- private static final String DURATION_SHORT_KEY = "SHORT";
- private static final String DURATION_LONG_KEY = "LONG";
-
- public TestBLEModule(ReactApplicationContext reactContext) {
- super(reactContext);
- }
-
- @Override
- public String getName() {
- return "TestBLEModule";
- }
- @Override
- public Map getConstants() {
- final Map constants = new HashMap<>();
- constants.put(DURATION_SHORT_KEY, Toast.LENGTH_SHORT);
- constants.put(DURATION_LONG_KEY, Toast.LENGTH_LONG);
- return constants;
- }
-
-
- @ReactMethod
- public void show(String message, int duration) {
- Toast.makeText(getReactApplicationContext(), message, duration).show();
- }
-
- @ReactMethod
- public void showV2(String message, int duration) {
- Toast.makeText(getReactApplicationContext(), message, duration).show();
- }
-
-
- @ReactMethod
- public void LogE(String message, Callback successCallback) {
- Log.e("TEST", message);
- successCallback.invoke("wygolono");
- }
-
- @ReactMethod
- public void justLogE(String message) {
- Log.e("React", message);
- }
-
-
-
- @ReactMethod
- public void ping(String msg, Callback callback) {
- callback.invoke(msg);
- }
-
- @ReactMethod
- public void pingPromise(String msg, Promise promise) {
-// promise.resolve(msg);
-
- promise.reject("RejectCode", "rejected");
- }
-
-
- @ReactMethod
- public void pingEvent(String msg) {
- new Handler().postDelayed(new Runnable() {
- @Override
- public void run() {
-
- WritableMap params = Arguments.createMap();
- params.putString("CONNECTION_STATE", "connected");
- params.putString("MAC_ADDRESS", "00:FF:34:b6:23");
- sendEvent(getReactApplicationContext(), "BLE_EVENT", params);
- }
- },5000);
- }
-
- private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) {
- reactContext
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
- .emit(eventName, params);
- }
-}
diff --git a/android/app/src/main/java/com/emptyproject/TestBLEPackage.java b/android/app/src/main/java/com/emptyproject/TestBLEPackage.java
deleted file mode 100644
index fc2d0bef..00000000
--- a/android/app/src/main/java/com/emptyproject/TestBLEPackage.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.emptyproject;
-
-import com.facebook.react.ReactPackage;
-import com.facebook.react.bridge.JavaScriptModule;
-import com.facebook.react.bridge.NativeModule;
-import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.react.uimanager.ViewManager;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Created by Konrad on 23/05/16.
- */
-public class TestBLEPackage implements ReactPackage {
-
- @Override
- public List> createJSModules() {
- return Collections.emptyList();
- }
-
- @Override
- public List createViewManagers(ReactApplicationContext reactContext) {
- return Collections.emptyList();
- }
-
- @Override
- public List createNativeModules(
- ReactApplicationContext reactContext) {
- List modules = new ArrayList<>();
-
- modules.add(new TestBLEModule(reactContext));
- modules.add(new RxBleReactContextBaseJavaModule(reactContext));
-
- return modules;
- }
-}
diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml
deleted file mode 100644
index f9260ab0..00000000
--- a/android/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- EmptyProject
-
diff --git a/android/blereactnative/.gitignore b/android/blereactnative/.gitignore
deleted file mode 100644
index 796b96d1..00000000
--- a/android/blereactnative/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/android/blereactnative/blereactnative.iml b/android/blereactnative/blereactnative.iml
deleted file mode 100644
index f4437b06..00000000
--- a/android/blereactnative/blereactnative.iml
+++ /dev/null
@@ -1,130 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- generateDebugSources
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/android/blereactnative/build.gradle b/android/blereactnative/build.gradle
deleted file mode 100644
index 0aca0879..00000000
--- a/android/blereactnative/build.gradle
+++ /dev/null
@@ -1,35 +0,0 @@
-apply plugin: 'com.android.library'
-apply plugin: 'me.tatarka.retrolambda'
-
-android {
- compileSdkVersion 23
- buildToolsVersion "23.0.3"
-
- defaultConfig {
- minSdkVersion 18
- targetSdkVersion 22
- versionCode 1
- versionName "1.0"
- ndk {
- abiFilters "armeabi-v7a", "x86"
- }
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- testCompile 'junit:junit:4.12'
- compile 'com.android.support:appcompat-v7:23.4.0'
- compile "com.facebook.react:react-native:+"
- compile "com.polidea.rxandroidble:rxandroidble:1.0.1"
-}
diff --git a/android/blereactnative/proguard-rules.pro b/android/blereactnative/proguard-rules.pro
deleted file mode 100644
index f28ee095..00000000
--- a/android/blereactnative/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/Konrad/Library/Android/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/android/blereactnative/src/androidTest/java/org/konradkrakowiak/blereactnative/ApplicationTest.java b/android/blereactnative/src/androidTest/java/org/konradkrakowiak/blereactnative/ApplicationTest.java
deleted file mode 100644
index fbf53a13..00000000
--- a/android/blereactnative/src/androidTest/java/org/konradkrakowiak/blereactnative/ApplicationTest.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package org.konradkrakowiak.blereactnative;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * Testing Fundamentals
- */
-public class ApplicationTest extends ApplicationTestCase {
-
- public ApplicationTest() {
- super(Application.class);
- }
-}
\ No newline at end of file
diff --git a/android/blereactnative/src/main/AndroidManifest.xml b/android/blereactnative/src/main/AndroidManifest.xml
deleted file mode 100644
index 76e80479..00000000
--- a/android/blereactnative/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
diff --git a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/BleModule.java b/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/BleModule.java
deleted file mode 100644
index 7cd0f41a..00000000
--- a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/BleModule.java
+++ /dev/null
@@ -1,393 +0,0 @@
-package org.konradkrakowiak.blereactnative;
-
-import android.bluetooth.BluetoothGattCharacteristic;
-import android.bluetooth.BluetoothGattService;
-import android.support.annotation.Nullable;
-import android.util.Base64;
-import android.util.Log;
-
-import com.facebook.react.bridge.Arguments;
-import com.facebook.react.bridge.Promise;
-import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.react.bridge.ReactContextBaseJavaModule;
-import com.facebook.react.bridge.ReactMethod;
-import com.facebook.react.bridge.ReadableArray;
-import com.facebook.react.bridge.WritableArray;
-import com.facebook.react.bridge.WritableMap;
-import com.facebook.react.modules.core.DeviceEventManagerModule;
-import com.polidea.rxandroidble.RxBleClient;
-import com.polidea.rxandroidble.RxBleConnection;
-import com.polidea.rxandroidble.RxBleDevice;
-import com.polidea.rxandroidble.RxBleScanResult;
-
-import org.konradkrakowiak.blereactnative.converter.ConverterManager;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import rx.Subscription;
-
-public class BleModule extends ReactContextBaseJavaModule {
-
- private static final String NAME = "BleClientManager";
-
- private static final String TAG = BleModule.class.getSimpleName();
-
- private final ErrorConverter errorConverter = new ErrorConverter();
-
- private final ConverterManager converterManager = new ConverterManager();
-
- private RxBleClient rxBleClient;
-
- private Subscription scanSubscription;
-
- private HashMap connectionSubscriptionMap;
-
- private HashMap characteristicOperationMap;
-
- private HashMap connectionMap;
-
-
- public BleModule(ReactApplicationContext reactContext) {
- super(reactContext);
- connectionSubscriptionMap = new HashMap<>();
- connectionMap = new HashMap<>();
- characteristicOperationMap = new HashMap<>();
- }
-
- @Override
- public String getName() {
- return NAME;
- }
-
- @Override
- public Map getConstants() {
- final Map constants = new HashMap<>();
- constants.put(EventKey.SCAN_EVENT, EventKey.SCAN_EVENT);
- constants.put(EventKey.NOTIFICATION_EVENT, EventKey.NOTIFICATION_EVENT);
- return constants;
- }
-
- private UUID[] convertToUUIDs(@Nullable String... filteredUUIDs) {
- if (filteredUUIDs == null) {
- return null;
- }
-
- ArrayList result = new ArrayList<>();
- for (String uuidStr : filteredUUIDs) {
- UUID uuid = UUID.fromString(uuidStr);
- result.add(uuid);
- }
- return result.toArray(new UUID[result.size()]);
- }
-
- @ReactMethod
- public void createClient() {
- Log.d(TAG, "createClient was called");
- rxBleClient = RxBleClient.create(getReactApplicationContext());
- }
-
- @ReactMethod
- public void destroyClient() {
- Log.d(TAG, "destroyClient was called");
- if (scanSubscription != null) {
- scanSubscription.unsubscribe();
- scanSubscription = null;
- }
- rxBleClient = null;
- }
-
- @ReactMethod
- public void scanBleDevices(ReadableArray filteredUUIDs) {
- Log.d(TAG, "scanBleDevices was called");
-
- if (rxBleClient == null) {
- // TODO: check if ble client is already initialized
- }
-
- UUID[] uuids = convertToUUIDs(null);
-
- // TODO: Check if UUIDs are valid
-
- scanSubscription = rxBleClient
- .scanBleDevices(uuids)
- .subscribe(
- this::onScanBleDevicesSuccess,
- throwable -> onScanBleDevicesFailure(throwable));
- }
-
- @ReactMethod
- public void stopScanBleDevices() {
- Log.d(TAG, "stopScanBleDevices was called");
- if (scanSubscription != null) {
- scanSubscription.unsubscribe();
- scanSubscription = null;
- }
- }
-
- @ReactMethod
- public void establishConnection(String deviceId, Promise promise) {
- Log.d(TAG, "establishConnection was called");
-
- final RxBleDevice device = rxBleClient.getBleDevice(deviceId);
- if (device == null) {
- promise.reject(new RuntimeException(ErrorKey.NO_DEVICE_FOUND));
- return;
- }
- boolean autoConnect = false;
- final Subscription subscribe = device
- .establishConnection(getReactApplicationContext(), autoConnect)
- .subscribe(
- rxBleConnection -> onEstablishConnectionSuccessSuccess(deviceId, rxBleConnection, promise),
- throwable -> onEstablishConnectionSuccessFailure(throwable, promise)
- );
- connectionSubscriptionMap.put(deviceId, subscribe);
- }
-
- @ReactMethod
- public void closeConnection(String deviceId, Promise promise) {
- Log.d(TAG, "closeConnection was called");
- final Subscription connectionSubscription = connectionSubscriptionMap.get(deviceId);
- if (connectionSubscription != null) {
- connectionSubscription.unsubscribe();
- connectionSubscriptionMap.remove(deviceId);
- Log.d(TAG, "Connection was closed for device: " + deviceId);
- promise.resolve(deviceId);
- } else {
- Log.d(TAG, "There is no open connection for device: " + deviceId);
- // TODO: handle errors
- String error = ErrorKey.BLE_GATT_CANNOT_START_EXCEPTION;
- promise.reject(error, error);
- }
- }
-
- @ReactMethod
- public void serviceIdsForDevice(String deviceIdentifier, Promise promise) {
- final RxBleConnection rxBleConnection = connectionMap.get(deviceIdentifier);
- if (rxBleConnection == null) {
- // TODO: handle error
- String error = ErrorKey.BLE_GATT_CANNOT_START_EXCEPTION;
- promise.reject(error, error);
- return;
- }
- rxBleConnection.discoverServices().subscribe(
- rxBleDeviceServices -> {
- List services = rxBleDeviceServices.getBluetoothGattServices();
- WritableArray resultServices = Arguments.createArray();
- for (BluetoothGattService service : services) {
- resultServices.pushString(service.getUuid().toString());
- }
- promise.resolve(resultServices);
- },
- throwable -> {
- final String error = errorConverter.convert(throwable);
- promise.reject(error, error);
- }
- );
- }
-
- @ReactMethod
- public void characteristicIdsForDevice(String deviceIdentifier, String serviceIdentifier, Promise promise) {
- final RxBleConnection rxBleConnection = connectionMap.get(deviceIdentifier);
- if (rxBleConnection == null) {
- // TODO: handle error
- String error = ErrorKey.BLE_GATT_CANNOT_START_EXCEPTION;
- promise.reject(error, error);
- return;
- }
- rxBleConnection.discoverServices().subscribe(
- rxBleDeviceServices -> {
- WritableArray resultCharacteristics = Arguments.createArray();
- List services = rxBleDeviceServices.getBluetoothGattServices();
- for (BluetoothGattService service : services) {
- if (service.getUuid().toString().compareToIgnoreCase(serviceIdentifier) == 0) {
- List characteristics = service.getCharacteristics();
- for (BluetoothGattCharacteristic characteristic : characteristics) {
- resultCharacteristics.pushString(characteristic.getUuid().toString());
- }
- break;
- }
- }
- promise.resolve(resultCharacteristics);
- },
- throwable -> {
- // TODO: handle error
- final String error = errorConverter.convert(throwable);
- promise.reject(error, error);
- }
- );
- }
-
- @ReactMethod
- public void detailsForCharacteristic(String deviceIdentifier, String serviceIdentifier, String characteristicIdentifier, Promise promise) {
- final RxBleConnection rxBleConnection = connectionMap.get(deviceIdentifier);
- if (rxBleConnection == null) {
- // TODO: handle error
- String error = ErrorKey.BLE_GATT_CANNOT_START_EXCEPTION;
- promise.reject(error, error);
- return;
- }
- rxBleConnection.discoverServices().subscribe(rxBleDeviceServices -> {
- List services = rxBleDeviceServices.getBluetoothGattServices();
- for (BluetoothGattService service : services) {
- if (service.getUuid().toString().compareToIgnoreCase(serviceIdentifier) == 0) {
- List characteristics = service.getCharacteristics();
- for (BluetoothGattCharacteristic characteristic : characteristics) {
- if (characteristic.getUuid().toString().compareToIgnoreCase(characteristicIdentifier) == 0) {
- WritableMap result = Arguments.createMap();
- result.putBoolean("isWritable", isCharacteristicWriteable(characteristic));
- result.putBoolean("isReadable", isCharacterisitcReadable(characteristic));
- result.putBoolean("isNotifiable", isCharacterisiticNotifiable(characteristic));
- result.putString("uuid", characteristic.getUuid().toString());
- promise.resolve(result);
- }
- }
- }
- }
- // TODO: handle error
-// final String error = errorConverter.convert(throwable);
-// promise.reject(error, error);
- }, throwable -> {
- // TODO: handle error
- final String error = errorConverter.convert(throwable);
- promise.reject(error, error);
- });
- }
-
- @ReactMethod
- public void writeCharacteristic(String deviceIdentifier, String serviceIdentifier, String characteristicIdentifier, String valueBase64, String transactionId, Promise promise) {
- Log.d(TAG, "writeCharacteristic was called");
- final RxBleConnection rxBleConnection = connectionMap.get(deviceIdentifier);
- if (rxBleConnection == null) {
- // TODO: handle errors
- String error = "Write characteristic error!";
- promise.reject(error, error);
- return;
- }
- final Subscription subscription = rxBleConnection
- // TODO: later user also serviceIdentifier to be sure that we are writing to the correct characteristic
- .writeCharacteristic(UUID.fromString(characteristicIdentifier), Base64.decode(valueBase64, Base64.DEFAULT))
- .subscribe(
- bytes -> onWriteCharacteristicSuccess(bytes, promise),
- throwable -> onWriteCharacteristicFailure(throwable, promise));
-
- characteristicOperationMap.put(transactionId, subscription);
- }
-
- @ReactMethod
- public void readCharacteristic(String deviceIdentifier, String serviceIdentifier, String characteristicIdentifier, String transactionId, Promise promise) {
- Log.d(TAG, "readCharacteristic was called");
- final RxBleConnection rxBleConnection = connectionMap.get(deviceIdentifier);
- if (rxBleConnection == null) {
- // TODO: handle errors
- String error = "Write characteristic error!";
- promise.reject(error, error);
- return;
- }
- final Subscription subscription = rxBleConnection
- // TODO: later user also serviceIdentifier to be sure that we are reading to the correct characteristic
- .readCharacteristic(UUID.fromString(characteristicIdentifier))
- .subscribe(
- bytes -> onReadCharacteristicSuccess(bytes, promise),
- throwable -> onReadCharacteristicFailure(throwable, promise));
-
- characteristicOperationMap.put(transactionId, subscription);
- }
-
- @ReactMethod
- public void cancelCharacteristicOperation(String transactionId) {
- // TODO: handle canceling of the pending operation
- final Subscription subscription = characteristicOperationMap.get(transactionId);
- if (subscription == null || !subscription.isUnsubscribed()) {
- Log.d(TAG, "Read characteristic is missing for transactionId : " + transactionId);
- return;
- }
- Log.d(TAG, "Read characteristic was canceled for transactionId : " + transactionId);
- subscription.unsubscribe();
- characteristicOperationMap.remove(transactionId);
- }
-
- // Support for scanBleDevices(...)
-
- private void onScanBleDevicesSuccess(RxBleScanResult rxBleScanResult) {
- Log.d(TAG, "onScanBleDevicesSuccess: " + rxBleScanResult.toString());
- sendEvent(EventKey.SCAN_EVENT, converterManager.convert(rxBleScanResult));
- }
-
- private void onScanBleDevicesFailure(Throwable throwable) {
- final String error = errorConverter.convert(throwable);
- Log.e(TAG, "onScanBleDevicesFailure: ", throwable);
-
- // TODO: send scan error and stop
- }
-
- //Support for establishConnection(...)
-
- private void onEstablishConnectionSuccessSuccess(String deviceId, RxBleConnection rxBleConnection, Promise promise) {
- connectionMap.put(deviceId, rxBleConnection);
- promise.resolve(deviceId);
- Log.d(TAG, "Establish connection success for : " + deviceId);
- }
-
- private void onEstablishConnectionSuccessFailure(Throwable throwable, Promise promise) {
- final String error = errorConverter.convert(throwable);
- Log.e(TAG, "onEstablishConnectionSuccessFailure: ", throwable);
- promise.reject(error, error);
- }
-
- //Support for readCharacteristic(...)
-
- private void onReadCharacteristicSuccess(byte[] data, Promise promise) {
- final String value = Base64.encodeToString(data, Base64.DEFAULT);
- promise.resolve(value);
- Log.d(TAG, "Read characteristic with : " + value);
-
- }
-
- private void onReadCharacteristicFailure(Throwable throwable, Promise errorCallback) {
- final String error = errorConverter.convert(throwable);
- Log.e(TAG, "onReadCharacteristicFailure: ", throwable);
- errorCallback.reject(error, error);
- }
-
- //Support for writeCharacteristic(...)
-
- private void onWriteCharacteristicSuccess(byte[] data, Promise promise) {
- final String value = Base64.encodeToString(data, Base64.DEFAULT);
- promise.resolve(value);
- Log.d(TAG, "Write characteristic success with : " + value);
-
- }
-
- private void onWriteCharacteristicFailure(Throwable throwable, Promise promise) {
- final String error = errorConverter.convert(throwable);
- Log.e(TAG, "onWriteCharacteristicFailure: ", throwable);
- promise.reject(error, error);
- }
-
- //Common support method
- private void sendEvent(String eventName, @Nullable WritableMap params) {
- getReactApplicationContext()
- .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
-// .getJSModule(RCTNativeAppEventEmitter.class)
- .emit(eventName, params);
- }
-
- // Get properties from characteristic and check against flags
- // TODO: move it to the helper class
-
- private boolean isCharacteristicWriteable(BluetoothGattCharacteristic pChar) {
- return (pChar.getProperties() & BluetoothGattCharacteristic.PROPERTY_WRITE) != 0;
- }
-
- private boolean isCharacterisitcReadable(BluetoothGattCharacteristic pChar) {
- return (pChar.getProperties() & BluetoothGattCharacteristic.PROPERTY_READ) != 0;
- }
-
- private boolean isCharacterisiticNotifiable(BluetoothGattCharacteristic pChar) {
- return (pChar.getProperties() & BluetoothGattCharacteristic.PROPERTY_NOTIFY) != 0;
- }
-}
diff --git a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/BlePackage.java b/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/BlePackage.java
deleted file mode 100644
index 494f2f91..00000000
--- a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/BlePackage.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.konradkrakowiak.blereactnative;
-
-import com.facebook.react.ReactPackage;
-import com.facebook.react.bridge.JavaScriptModule;
-import com.facebook.react.bridge.NativeModule;
-import com.facebook.react.bridge.ReactApplicationContext;
-import com.facebook.react.uimanager.ViewManager;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class BlePackage implements ReactPackage {
-
- @Override
- public List> createJSModules() {
- return Collections.emptyList();
- }
-
- @Override
- public List createViewManagers(ReactApplicationContext reactContext) {
- return Collections.emptyList();
- }
-
- @Override
- public List createNativeModules(ReactApplicationContext reactContext) {
- List modules = new ArrayList<>();
- modules.add(new BleModule(reactContext));
- return modules;
- }
-}
diff --git a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/ErrorConverter.java b/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/ErrorConverter.java
deleted file mode 100644
index 1b38d712..00000000
--- a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/ErrorConverter.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.konradkrakowiak.blereactnative;
-
-import com.polidea.rxandroidble.exceptions.BleAlreadyConnectedException;
-import com.polidea.rxandroidble.exceptions.BleCannotSetCharacteristicNotificationException;
-import com.polidea.rxandroidble.exceptions.BleCharacteristicNotFoundException;
-import com.polidea.rxandroidble.exceptions.BleGattCannotStartException;
-import com.polidea.rxandroidble.exceptions.BleGattException;
-import com.polidea.rxandroidble.exceptions.BleScanException;
-
-class ErrorConverter {
-
- String convert(Throwable throwable) {
- if (throwable instanceof BleScanException) {
- return convert((BleScanException) throwable);
- }
- if (throwable instanceof BleAlreadyConnectedException) {
- return ErrorKey.BLE_ALREADY_CONNECTED_EXCEPTION;
- }
- if (throwable instanceof BleCharacteristicNotFoundException) {
- return ErrorKey.BLE_CHARACTERISTIC_NOT_FOUND_EXCEPTION;
- }
- if (throwable instanceof BleGattCannotStartException) {
- return ErrorKey.BLE_GATT_CANNOT_START_EXCEPTION;
- }
- if (throwable instanceof BleGattException) {
- return ErrorKey.BLE_GATT_EXCEPTION;
- }
- if (throwable instanceof BleCannotSetCharacteristicNotificationException) {
- return ErrorKey.BLE_CANNOT_SET_CHARACTERISTIC_NOTIFICATION_EXCEPTION;
- }
- return ErrorKey.UNKNOWN_ERROR;
- }
-
- private String convert(BleScanException bleScanException) {
- final int reason = bleScanException.getReason();
- switch (reason) {
- case BleScanException.BLUETOOTH_CANNOT_START:
- return ErrorKey.BLUETOOTH_CANNOT_START;
- case BleScanException.BLUETOOTH_DISABLED:
- return ErrorKey.BLUETOOTH_DISABLED;
- case BleScanException.BLUETOOTH_NOT_AVAILABLE:
- return ErrorKey.BLUETOOTH_NOT_AVAILABLE;
- case BleScanException.LOCATION_PERMISSION_MISSING:
- return ErrorKey.LOCATION_PERMISSION_MISSING;
- case BleScanException.LOCATION_SERVICES_DISABLED:
- return ErrorKey.LOCATION_SERVICES_DISABLED;
- default:
- throw bleScanException;
- }
- }
-}
\ No newline at end of file
diff --git a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/ErrorKey.java b/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/ErrorKey.java
deleted file mode 100644
index 2a69c2b6..00000000
--- a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/ErrorKey.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package org.konradkrakowiak.blereactnative;
-
-interface ErrorKey {
-
- /**
- * According to React Native documentation {@link com.facebook.react.bridge.Promise#reject(String)}
- */
- String CODE = "EUNSPECIFIED";
-
- String NO_CLIENT = "NO_CLIENT";
- String BLUETOOTH_CANNOT_START = "BLUETOOTH_CANNOT_START";
- String BLUETOOTH_DISABLED = "BLUETOOTH_DISABLED";
- String BLUETOOTH_NOT_AVAILABLE = "BLUETOOTH_NOT_AVAILABLE";
- String LOCATION_PERMISSION_MISSING = "LOCATION_PERMISSION_MISSING";
- String LOCATION_SERVICES_DISABLED = "LOCATION_SERVICES_DISABLED";
- String NO_DEVICE_FOUND = "NO_DEVICE_FOUND";
- String BLE_ALREADY_CONNECTED_EXCEPTION = "BLE_ALREADY_CONNECTED_EXCEPTION";
- String BLE_CHARACTERISTIC_NOT_FOUND_EXCEPTION = "BLE_CHARACTERISTIC_NOT_FOUND_EXCEPTION";
- String BLE_GATT_CANNOT_START_EXCEPTION = "BLE_GATT_CANNOT_START_EXCEPTION";
- String BLE_GATT_EXCEPTION = "BLE_GATT_EXCEPTION";
- String UNKNOWN_ERROR = "UNKNOWN_ERROR";
- String NO_CONNECTION = "NO_CONNECTION";
- String BLE_CANNOT_SET_CHARACTERISTIC_NOTIFICATION_EXCEPTION = "BLE_CANNOT_SET_CHARACTERISTIC_NOTIFICATION_EXCEPTION";
-}
diff --git a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/EventKey.java b/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/EventKey.java
deleted file mode 100644
index 0c03d48a..00000000
--- a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/EventKey.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.konradkrakowiak.blereactnative;
-
-
-interface EventKey {
-
- String SCAN_EVENT = "ScanEvent";
- String NOTIFICATION_EVENT = "NotificationEvent";
-}
diff --git a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/BluetoothGattCharacteristicConverter.java b/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/BluetoothGattCharacteristicConverter.java
deleted file mode 100644
index e57a3e8d..00000000
--- a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/BluetoothGattCharacteristicConverter.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.konradkrakowiak.blereactnative.converter;
-
-import android.bluetooth.BluetoothGattCharacteristic;
-import com.facebook.react.bridge.Arguments;
-import com.facebook.react.bridge.WritableMap;
-
-class BluetoothGattCharacteristicConverter implements Converter {
-
- private interface Metadata {
-
- String UUID = "UUID";
- }
-
- @Override
- public WritableMap convert(BluetoothGattCharacteristic bluetoothGattCharacteristic) {
- WritableMap result = Arguments.createMap();
- result.putString(Metadata.UUID, bluetoothGattCharacteristic.getUuid().toString());
- return result;
- }
-
-}
diff --git a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/BluetoothGattServiceConverter.java b/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/BluetoothGattServiceConverter.java
deleted file mode 100644
index 28cd764b..00000000
--- a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/BluetoothGattServiceConverter.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.konradkrakowiak.blereactnative.converter;
-
-import android.bluetooth.BluetoothGattCharacteristic;
-import android.bluetooth.BluetoothGattService;
-import com.facebook.react.bridge.Arguments;
-import com.facebook.react.bridge.WritableArray;
-import com.facebook.react.bridge.WritableMap;
-import java.util.List;
-
-class BluetoothGattServiceConverter implements Converter {
-
- private interface Metadata {
-
- String UUID = "UUID";
- String CHARACTERISTICS = "CHARACTERISTICS";
- }
-
- private final BluetoothGattCharacteristicConverter bluetoothGattCharacteristicConverter;
-
- BluetoothGattServiceConverter(BluetoothGattCharacteristicConverter bluetoothGattCharacteristicConverter) {
-
- this.bluetoothGattCharacteristicConverter = bluetoothGattCharacteristicConverter;
- }
-
- @Override
- public WritableMap convert(BluetoothGattService bluetoothGattService) {
- WritableMap result = Arguments.createMap();
- result.putString(Metadata.UUID, bluetoothGattService.getUuid().toString());
- final List bluetoothGattCharacteristics = bluetoothGattService.getCharacteristics();
- WritableArray characteristics = Arguments.createArray();
- for (BluetoothGattCharacteristic bluetoothGattCharacteristic : bluetoothGattCharacteristics) {
- characteristics.pushMap(bluetoothGattCharacteristicConverter.convert(bluetoothGattCharacteristic));
- }
- result.putArray(Metadata.CHARACTERISTICS, characteristics);
- return result;
- }
-}
diff --git a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/Converter.java b/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/Converter.java
deleted file mode 100644
index 21d3ee8c..00000000
--- a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/Converter.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.konradkrakowiak.blereactnative.converter;
-
-import com.facebook.react.bridge.WritableMap;
-
-interface Converter {
-
- WritableMap convert(JAVA_OBJECT javaObject);
-}
diff --git a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/ConverterManager.java b/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/ConverterManager.java
deleted file mode 100644
index 5b94ee06..00000000
--- a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/ConverterManager.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package org.konradkrakowiak.blereactnative.converter;
-
-import com.facebook.react.bridge.WritableMap;
-import com.polidea.rxandroidble.RxBleDevice;
-import com.polidea.rxandroidble.RxBleDeviceServices;
-import com.polidea.rxandroidble.RxBleScanResult;
-
-public class ConverterManager {
-
-
- private final RxBleScanResultConverter rxBleScanResultConverter;
-
- private final RxBleDeviceConverter bleDeviceConverter;
-
- private final RxBleConnectionStateConverter rxBleConnectionStateConverter;
-
- private final RxBleDeviceServicesConverter rxBleDeviceServicesConverter;
-
- private final BluetoothGattServiceConverter bluetoothGattServiceConverter;
-
- private final BluetoothGattCharacteristicConverter bluetoothGattCharacteristicConverter;
-
- public ConverterManager() {
- rxBleConnectionStateConverter = new RxBleConnectionStateConverter();
- bluetoothGattCharacteristicConverter = new BluetoothGattCharacteristicConverter();
- bluetoothGattServiceConverter = new BluetoothGattServiceConverter(bluetoothGattCharacteristicConverter);
- rxBleDeviceServicesConverter = new RxBleDeviceServicesConverter(bluetoothGattServiceConverter);
- bleDeviceConverter = new RxBleDeviceConverter(rxBleConnectionStateConverter);
- rxBleScanResultConverter = new RxBleScanResultConverter(bleDeviceConverter);
- }
-
- public WritableMap convert(RxBleScanResult rxBleScanResult) {
- return rxBleScanResultConverter.convert(rxBleScanResult);
- }
-
- public WritableMap convert(RxBleDevice rxBleDevice) {
- return bleDeviceConverter.convert(rxBleDevice);
- }
-
- public WritableMap convert(RxBleDeviceServices rxBleDeviceServices) {
- return rxBleDeviceServicesConverter.convert(rxBleDeviceServices);
- }
-}
diff --git a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/RxBleConnectionStateConverter.java b/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/RxBleConnectionStateConverter.java
deleted file mode 100644
index ea096c39..00000000
--- a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/RxBleConnectionStateConverter.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.konradkrakowiak.blereactnative.converter;
-
-
-import com.facebook.react.bridge.Arguments;
-import com.facebook.react.bridge.WritableMap;
-import com.polidea.rxandroidble.RxBleConnection;
-
-class RxBleConnectionStateConverter implements Converter {
-
- private interface Metadata {
-
- String STATE = "STATE";
- }
-
- interface State {
-
- String CONNECTING = "CONNECTING";
- String CONNECTED = "CONNECTED";
- String DISCONNECTED = "DISCONNECTED";
- String DISCONNECTING = "DISCONNECTING";
- }
-
- @Override
- public WritableMap convert(RxBleConnection.RxBleConnectionState rxBleConnectionState) {
- final WritableMap result = Arguments.createMap();
- result.putString(Metadata.STATE, connectionStateToString(rxBleConnectionState));
- return result;
- }
-
- String connectionStateToString(RxBleConnection.RxBleConnectionState rxBleConnectionState) {
-
- if (RxBleConnection.RxBleConnectionState.CONNECTING.equals(rxBleConnectionState)) {
- return State.CONNECTING;
- }
- if (RxBleConnection.RxBleConnectionState.CONNECTED.equals(rxBleConnectionState)) {
- return State.CONNECTED;
- }
- if (RxBleConnection.RxBleConnectionState.DISCONNECTED.equals(rxBleConnectionState)) {
- return State.DISCONNECTED;
- }
- if (RxBleConnection.RxBleConnectionState.DISCONNECTING.equals(rxBleConnectionState)) {
- return State.DISCONNECTING;
- }
- throw new UnsupportedOperationException("This method is not supported for " + rxBleConnectionState);
- }
-}
diff --git a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/RxBleDeviceConverter.java b/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/RxBleDeviceConverter.java
deleted file mode 100644
index 39779dda..00000000
--- a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/RxBleDeviceConverter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package org.konradkrakowiak.blereactnative.converter;
-
-
-import com.facebook.react.bridge.Arguments;
-import com.facebook.react.bridge.WritableMap;
-import com.polidea.rxandroidble.RxBleDevice;
-
-class RxBleDeviceConverter implements Converter {
-
- private interface Metadata {
-
- String NAME = "NAME";
- String MAC_ADDRESS = "MAC_ADDRESS";
- String CONNECTION_STATE = "CONNECTION_STATE";
- }
-
- private final RxBleConnectionStateConverter rxBleConnectionStateConverter;
-
- RxBleDeviceConverter(RxBleConnectionStateConverter rxBleConnectionStateConverter) {
- this.rxBleConnectionStateConverter = rxBleConnectionStateConverter;
- }
-
- @Override
- public WritableMap convert(RxBleDevice bleDevice) {
- WritableMap result = Arguments.createMap();
- result.putString(Metadata.NAME, bleDevice.getName());
- result.putString(Metadata.MAC_ADDRESS, bleDevice.getMacAddress());
- result.putMap(Metadata.CONNECTION_STATE, rxBleConnectionStateConverter.convert(bleDevice.getConnectionState()));
- return result;
- }
-}
diff --git a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/RxBleDeviceServicesConverter.java b/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/RxBleDeviceServicesConverter.java
deleted file mode 100644
index 6112cfca..00000000
--- a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/RxBleDeviceServicesConverter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.konradkrakowiak.blereactnative.converter;
-
-import android.bluetooth.BluetoothGattService;
-import com.facebook.react.bridge.Arguments;
-import com.facebook.react.bridge.WritableArray;
-import com.facebook.react.bridge.WritableMap;
-import com.polidea.rxandroidble.RxBleDeviceServices;
-import java.util.List;
-
-public class RxBleDeviceServicesConverter implements Converter {
-
- private interface Metadata {
-
- String SERVICES = "SERVICES";
- }
-
- private final BluetoothGattServiceConverter bluetoothGattServiceConverter;
-
- RxBleDeviceServicesConverter(BluetoothGattServiceConverter bluetoothGattServiceConverter) {
- this.bluetoothGattServiceConverter = bluetoothGattServiceConverter;
- }
-
- @Override
- public WritableMap convert(RxBleDeviceServices rxBleDeviceServices) {
- WritableMap result = Arguments.createMap();
- final List bluetoothGattServices = rxBleDeviceServices.getBluetoothGattServices();
- WritableArray services = Arguments.createArray();
- for (BluetoothGattService bluetoothGattService : bluetoothGattServices) {
- services.pushMap(bluetoothGattServiceConverter.convert(bluetoothGattService));
- }
- result.putArray(Metadata.SERVICES, services);
- return result;
- }
-}
diff --git a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/RxBleScanResultConverter.java b/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/RxBleScanResultConverter.java
deleted file mode 100644
index 071a90f1..00000000
--- a/android/blereactnative/src/main/java/org/konradkrakowiak/blereactnative/converter/RxBleScanResultConverter.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.konradkrakowiak.blereactnative.converter;
-
-
-import android.util.Base64;
-import com.facebook.react.bridge.Arguments;
-import com.facebook.react.bridge.WritableMap;
-import com.polidea.rxandroidble.RxBleScanResult;
-
-import java.util.UUID;
-
-public class RxBleScanResultConverter implements Converter {
-
- interface Metadata {
- String UUID = "uuid";
- String NAME = "name";
- String RSSI = "rssi";
- }
-
- private final RxBleDeviceConverter bleDeviceConverter;
-
- RxBleScanResultConverter(RxBleDeviceConverter bleDeviceConverter) {
- this.bleDeviceConverter = bleDeviceConverter;
- }
-
- @Override
- public WritableMap convert(RxBleScanResult rxBleScanResult) {
- WritableMap result = Arguments.createMap();
- result.putString(Metadata.UUID, rxBleScanResult.getBleDevice().getMacAddress());
- result.putString(Metadata.NAME, rxBleScanResult.getBleDevice().getName());
- result.putInt(Metadata.RSSI, rxBleScanResult.getRssi());
- return result;
- }
-}
diff --git a/android/blereactnative/src/main/res/values/strings.xml b/android/blereactnative/src/main/res/values/strings.xml
deleted file mode 100644
index dcf96e42..00000000
--- a/android/blereactnative/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- BleReactNative
-
diff --git a/android/blereactnative/src/test/java/org/konradkrakowiak/blereactnative/ExampleUnitTest.java b/android/blereactnative/src/test/java/org/konradkrakowiak/blereactnative/ExampleUnitTest.java
deleted file mode 100644
index 5f0ec05c..00000000
--- a/android/blereactnative/src/test/java/org/konradkrakowiak/blereactnative/ExampleUnitTest.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package org.konradkrakowiak.blereactnative;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * To work on unit tests, switch the Test Artifact in the Build Variants view.
- */
-public class ExampleUnitTest {
-
- @Test
- public void addition_isCorrect() throws Exception {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/android/settings.gradle b/android/settings.gradle
deleted file mode 100644
index d3c7056b..00000000
--- a/android/settings.gradle
+++ /dev/null
@@ -1,6 +0,0 @@
-rootProject.name = 'EmptyProject'
-
-include ':app', ':blereactnative'
-
-include ':RNPermissionsModule', ':app'
-project(':RNPermissionsModule').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-permissions/android')
\ No newline at end of file
diff --git a/.buckconfig b/examples/ReactBLEScanner/.buckconfig
similarity index 100%
rename from .buckconfig
rename to examples/ReactBLEScanner/.buckconfig
diff --git a/examples/ReactBLEScanner/.flowconfig b/examples/ReactBLEScanner/.flowconfig
new file mode 100644
index 00000000..e28e2f5b
--- /dev/null
+++ b/examples/ReactBLEScanner/.flowconfig
@@ -0,0 +1,41 @@
+[ignore]
+
+# We fork some components by platform.
+.*/*.android.js
+
+# Ignore templates with `@flow` in header
+.*/local-cli/generator.*
+
+# Ignore malformed json
+.*/node_modules/y18n/test/.*\.json
+
+[include]
+
+[libs]
+node_modules/react-native/Libraries/react-native/react-native-interface.js
+node_modules/react-native/flow
+flow/
+
+[options]
+module.system=haste
+
+esproposal.class_static_fields=enable
+esproposal.class_instance_fields=enable
+
+experimental.strict_type_args=true
+
+munge_underscores=true
+
+module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
+module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
+
+suppress_type=$FlowIssue
+suppress_type=$FlowFixMe
+suppress_type=$FixMe
+
+suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
+suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
+suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
+
+[version]
+^0.27.0
diff --git a/examples/ReactBLEScanner/.gitignore b/examples/ReactBLEScanner/.gitignore
new file mode 100644
index 00000000..eb1535e4
--- /dev/null
+++ b/examples/ReactBLEScanner/.gitignore
@@ -0,0 +1,41 @@
+# OSX
+#
+.DS_Store
+
+# Xcode
+#
+build/
+*.pbxuser
+!default.pbxuser
+*.mode1v3
+!default.mode1v3
+*.mode2v3
+!default.mode2v3
+*.perspectivev3
+!default.perspectivev3
+xcuserdata
+*.xccheckout
+*.moved-aside
+DerivedData
+*.hmap
+*.ipa
+*.xcuserstate
+project.xcworkspace
+
+# Android/IJ
+#
+*.iml
+.idea
+.gradle
+local.properties
+
+# node.js
+#
+node_modules/
+npm-debug.log
+
+# BUCK
+buck-out/
+\.buckd/
+android/app/libs
+android/keystores/debug.keystore
diff --git a/.watchmanconfig b/examples/ReactBLEScanner/.watchmanconfig
similarity index 100%
rename from .watchmanconfig
rename to examples/ReactBLEScanner/.watchmanconfig
diff --git a/android/app/BUCK b/examples/ReactBLEScanner/android/app/BUCK
similarity index 93%
rename from android/app/BUCK
rename to examples/ReactBLEScanner/android/app/BUCK
index 65f4d275..c9114443 100644
--- a/android/app/BUCK
+++ b/examples/ReactBLEScanner/android/app/BUCK
@@ -5,7 +5,7 @@ import re
# - install Buck
# - `npm start` - to start the packager
# - `cd android`
-# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US`
+# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
# - `buck install -r android/app` - compile, install and run application
#
@@ -46,13 +46,13 @@ android_library(
android_build_config(
name = 'build_config',
- package = 'com.emptyproject',
+ package = 'com.reactblescanner',
)
android_resource(
name = 'res',
res = 'src/main/res',
- package = 'com.emptyproject',
+ package = 'com.reactblescanner',
)
android_binary(
diff --git a/android/app/build.gradle b/examples/ReactBLEScanner/android/app/build.gradle
similarity index 88%
rename from android/app/build.gradle
rename to examples/ReactBLEScanner/android/app/build.gradle
index 5ec4f976..0d958bef 100644
--- a/android/app/build.gradle
+++ b/examples/ReactBLEScanner/android/app/build.gradle
@@ -1,5 +1,4 @@
apply plugin: "com.android.application"
-apply plugin: 'me.tatarka.retrolambda'
import com.android.build.OutputFile
@@ -56,7 +55,13 @@ import com.android.build.OutputFile
* // date; if you have any other folders that you want to ignore for performance reasons (gradle
* // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
* // for example, you might want to remove it from here.
- * inputExcludes: ["android/**", "ios/**"]
+ * inputExcludes: ["android/**", "ios/**"],
+ *
+ * // override which node gets called and with what additional arguments
+ * nodeExecutableAndArgs: ["node"]
+ *
+ * // supply additional arguments to the packager
+ * extraPackagerArgs: []
* ]
*/
@@ -82,8 +87,8 @@ android {
buildToolsVersion "23.0.1"
defaultConfig {
- applicationId "com.emptyproject"
- minSdkVersion 18
+ applicationId "com.reactblescanner"
+ minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
@@ -99,10 +104,6 @@ android {
include "armeabi-v7a", "x86"
}
}
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
- }
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
@@ -125,15 +126,9 @@ android {
}
dependencies {
- compile fileTree(include: ['*.jar'], dir: 'libs')
- compile 'com.android.support:appcompat-v7:23.0.1'
- compile 'com.facebook.react:react-native:+'
- // From node_modules
- compile 'com.polidea.rxandroidble:rxandroidble:1.0.1'
- compile 'me.tatarka:gradle-retrolambda:3.2.4'
- compile project(':blereactnative')
-
- compile project(':RNPermissionsModule')
+ compile fileTree(dir: "libs", include: ["*.jar"])
+ compile "com.android.support:appcompat-v7:23.0.1"
+ compile "com.facebook.react:react-native:+" // From node_modules
}
// Run this once to be able to run the application with BUCK
diff --git a/android/app/proguard-rules.pro b/examples/ReactBLEScanner/android/app/proguard-rules.pro
similarity index 89%
rename from android/app/proguard-rules.pro
rename to examples/ReactBLEScanner/android/app/proguard-rules.pro
index 347a13ce..48361a90 100644
--- a/android/app/proguard-rules.pro
+++ b/examples/ReactBLEScanner/android/app/proguard-rules.pro
@@ -26,11 +26,14 @@
# See http://sourceforge.net/p/proguard/bugs/466/
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters
+-keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip
# Do not strip any method/class that is annotated with @DoNotStrip
-keep @com.facebook.proguard.annotations.DoNotStrip class *
+-keep @com.facebook.common.internal.DoNotStrip class *
-keepclassmembers class * {
@com.facebook.proguard.annotations.DoNotStrip *;
+ @com.facebook.common.internal.DoNotStrip *;
}
-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
@@ -51,9 +54,9 @@
-keepattributes Signature
-keepattributes *Annotation*
--keep class com.squareup.okhttp.** { *; }
--keep interface com.squareup.okhttp.** { *; }
--dontwarn com.squareup.okhttp.**
+-keep class okhttp3.** { *; }
+-keep interface okhttp3.** { *; }
+-dontwarn okhttp3.**
# okio
diff --git a/android/app/src/main/AndroidManifest.xml b/examples/ReactBLEScanner/android/app/src/main/AndroidManifest.xml
similarity index 75%
rename from android/app/src/main/AndroidManifest.xml
rename to examples/ReactBLEScanner/android/app/src/main/AndroidManifest.xml
index 3e3cf5e8..9bd929ae 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/examples/ReactBLEScanner/android/app/src/main/AndroidManifest.xml
@@ -1,17 +1,17 @@
-
-
-
+
-
- getPackages() {
+ return Arrays.asList(
+ new MainReactPackage()
+ );
+ }
+ };
+
+ @Override
+ public ReactNativeHost getReactNativeHost() {
+ return mReactNativeHost;
+ }
+}
diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/examples/ReactBLEScanner/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
similarity index 100%
rename from android/app/src/main/res/mipmap-hdpi/ic_launcher.png
rename to examples/ReactBLEScanner/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/examples/ReactBLEScanner/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
similarity index 100%
rename from android/app/src/main/res/mipmap-mdpi/ic_launcher.png
rename to examples/ReactBLEScanner/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/examples/ReactBLEScanner/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
similarity index 100%
rename from android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
rename to examples/ReactBLEScanner/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/examples/ReactBLEScanner/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
similarity index 100%
rename from android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
rename to examples/ReactBLEScanner/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
diff --git a/examples/ReactBLEScanner/android/app/src/main/res/values/strings.xml b/examples/ReactBLEScanner/android/app/src/main/res/values/strings.xml
new file mode 100644
index 00000000..3d22e76c
--- /dev/null
+++ b/examples/ReactBLEScanner/android/app/src/main/res/values/strings.xml
@@ -0,0 +1,3 @@
+
+ ReactBLEScanner
+
diff --git a/android/app/src/main/res/values/styles.xml b/examples/ReactBLEScanner/android/app/src/main/res/values/styles.xml
similarity index 100%
rename from android/app/src/main/res/values/styles.xml
rename to examples/ReactBLEScanner/android/app/src/main/res/values/styles.xml
diff --git a/android/build.gradle b/examples/ReactBLEScanner/android/build.gradle
similarity index 64%
rename from android/build.gradle
rename to examples/ReactBLEScanner/android/build.gradle
index 473552d8..fcba4c58 100644
--- a/android/build.gradle
+++ b/examples/ReactBLEScanner/android/build.gradle
@@ -5,8 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.2'
- classpath 'me.tatarka:gradle-retrolambda:3.2.5'
+ classpath 'com.android.tools.build:gradle:1.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@@ -19,10 +18,7 @@ allprojects {
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
- url "$projectDir/../../node_modules/react-native/android"
- }
- maven {
- url "https://oss.sonatype.org/content/repositories/snapshots"
+ url "$rootDir/../node_modules/react-native/android"
}
}
}
diff --git a/android/gradle.properties b/examples/ReactBLEScanner/android/gradle.properties
similarity index 100%
rename from android/gradle.properties
rename to examples/ReactBLEScanner/android/gradle.properties
diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/examples/ReactBLEScanner/android/gradle/wrapper/gradle-wrapper.jar
similarity index 100%
rename from android/gradle/wrapper/gradle-wrapper.jar
rename to examples/ReactBLEScanner/android/gradle/wrapper/gradle-wrapper.jar
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/examples/ReactBLEScanner/android/gradle/wrapper/gradle-wrapper.properties
similarity index 80%
rename from android/gradle/wrapper/gradle-wrapper.properties
rename to examples/ReactBLEScanner/android/gradle/wrapper/gradle-wrapper.properties
index 2d2dcea6..b9fbfaba 100644
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/ReactBLEScanner/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Mon May 23 13:33:40 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
diff --git a/android/gradlew b/examples/ReactBLEScanner/android/gradlew
similarity index 100%
rename from android/gradlew
rename to examples/ReactBLEScanner/android/gradlew
diff --git a/android/gradlew.bat b/examples/ReactBLEScanner/android/gradlew.bat
similarity index 100%
rename from android/gradlew.bat
rename to examples/ReactBLEScanner/android/gradlew.bat
diff --git a/android/keystores/BUCK b/examples/ReactBLEScanner/android/keystores/BUCK
similarity index 100%
rename from android/keystores/BUCK
rename to examples/ReactBLEScanner/android/keystores/BUCK
diff --git a/android/keystores/debug.keystore.properties b/examples/ReactBLEScanner/android/keystores/debug.keystore.properties
similarity index 100%
rename from android/keystores/debug.keystore.properties
rename to examples/ReactBLEScanner/android/keystores/debug.keystore.properties
diff --git a/examples/ReactBLEScanner/android/settings.gradle b/examples/ReactBLEScanner/android/settings.gradle
new file mode 100644
index 00000000..61df26c8
--- /dev/null
+++ b/examples/ReactBLEScanner/android/settings.gradle
@@ -0,0 +1,3 @@
+rootProject.name = 'ReactBLEScanner'
+
+include ':app'
diff --git a/app/ble/BleActions.js b/examples/ReactBLEScanner/app/ble/BleActions.js
similarity index 100%
rename from app/ble/BleActions.js
rename to examples/ReactBLEScanner/app/ble/BleActions.js
diff --git a/app/ble/BleComponent.js b/examples/ReactBLEScanner/app/ble/BleComponent.js
similarity index 100%
rename from app/ble/BleComponent.js
rename to examples/ReactBLEScanner/app/ble/BleComponent.js
diff --git a/app/ble/BleReducer.js b/examples/ReactBLEScanner/app/ble/BleReducer.js
similarity index 100%
rename from app/ble/BleReducer.js
rename to examples/ReactBLEScanner/app/ble/BleReducer.js
diff --git a/app/characteristics/CharacteristicDetailsComponent.js b/examples/ReactBLEScanner/app/characteristics/CharacteristicDetailsComponent.js
similarity index 100%
rename from app/characteristics/CharacteristicDetailsComponent.js
rename to examples/ReactBLEScanner/app/characteristics/CharacteristicDetailsComponent.js
diff --git a/app/characteristics/CharacteristicView.js b/examples/ReactBLEScanner/app/characteristics/CharacteristicView.js
similarity index 100%
rename from app/characteristics/CharacteristicView.js
rename to examples/ReactBLEScanner/app/characteristics/CharacteristicView.js
diff --git a/app/characteristics/CharacteristicsComponent.js b/examples/ReactBLEScanner/app/characteristics/CharacteristicsComponent.js
similarity index 100%
rename from app/characteristics/CharacteristicsComponent.js
rename to examples/ReactBLEScanner/app/characteristics/CharacteristicsComponent.js
diff --git a/app/root/ErrorComponent.js b/examples/ReactBLEScanner/app/root/ErrorComponent.js
similarity index 100%
rename from app/root/ErrorComponent.js
rename to examples/ReactBLEScanner/app/root/ErrorComponent.js
diff --git a/app/root/Reducer.js b/examples/ReactBLEScanner/app/root/Reducer.js
similarity index 100%
rename from app/root/Reducer.js
rename to examples/ReactBLEScanner/app/root/Reducer.js
diff --git a/app/root/RootComponent.js b/examples/ReactBLEScanner/app/root/RootComponent.js
similarity index 100%
rename from app/root/RootComponent.js
rename to examples/ReactBLEScanner/app/root/RootComponent.js
diff --git a/app/scanning/ScannedDeviceView.js b/examples/ReactBLEScanner/app/scanning/ScannedDeviceView.js
similarity index 100%
rename from app/scanning/ScannedDeviceView.js
rename to examples/ReactBLEScanner/app/scanning/ScannedDeviceView.js
diff --git a/app/scanning/ScannedDevicesComponent.js b/examples/ReactBLEScanner/app/scanning/ScannedDevicesComponent.js
similarity index 100%
rename from app/scanning/ScannedDevicesComponent.js
rename to examples/ReactBLEScanner/app/scanning/ScannedDevicesComponent.js
diff --git a/app/scene/Const.js b/examples/ReactBLEScanner/app/scene/Const.js
similarity index 100%
rename from app/scene/Const.js
rename to examples/ReactBLEScanner/app/scene/Const.js
diff --git a/app/scene/SceneReducer.js b/examples/ReactBLEScanner/app/scene/SceneReducer.js
similarity index 100%
rename from app/scene/SceneReducer.js
rename to examples/ReactBLEScanner/app/scene/SceneReducer.js
diff --git a/app/services/ServiceView.js b/examples/ReactBLEScanner/app/services/ServiceView.js
similarity index 100%
rename from app/services/ServiceView.js
rename to examples/ReactBLEScanner/app/services/ServiceView.js
diff --git a/app/services/ServicesComponent.js b/examples/ReactBLEScanner/app/services/ServicesComponent.js
similarity index 100%
rename from app/services/ServicesComponent.js
rename to examples/ReactBLEScanner/app/services/ServicesComponent.js
diff --git a/app/view/ButtonView.js b/examples/ReactBLEScanner/app/view/ButtonView.js
similarity index 75%
rename from app/view/ButtonView.js
rename to examples/ReactBLEScanner/app/view/ButtonView.js
index 913c2e3b..fa1cf9d6 100644
--- a/app/view/ButtonView.js
+++ b/examples/ReactBLEScanner/app/view/ButtonView.js
@@ -2,20 +2,21 @@
import React, { Component, PropTypes } from 'react';
import { TouchableOpacity, Text, StyleSheet } from 'react-native';
-import Button from 'react-native-button'
const ButtonView = ({onClick, disabled, color, text}) => {
- var style = [styles.containerStyle];
+ var style = [styles.button];
style.push({backgroundColor: color})
if (disabled) style.push(styles.buttonDisabled)
return (
-
+
+
)
}
@@ -27,12 +28,12 @@ ButtonView.propTypes = {
}
var styles = StyleSheet.create({
- containerStyle: {
- padding: 10,
- height: 45,
- overflow: 'hidden',
+ button: {
+ fontWeight: 'bold',
borderRadius: 10,
borderWidth: 1,
+ overflow: 'hidden',
+ padding: 10
},
buttonDisabled: {
backgroundColor: '#ede9eb'
diff --git a/app/view/ImmutableListView.js b/examples/ReactBLEScanner/app/view/ImmutableListView.js
similarity index 100%
rename from app/view/ImmutableListView.js
rename to examples/ReactBLEScanner/app/view/ImmutableListView.js
diff --git a/app/view/Style.js b/examples/ReactBLEScanner/app/view/Style.js
similarity index 100%
rename from app/view/Style.js
rename to examples/ReactBLEScanner/app/view/Style.js
diff --git a/examples/ReactBLEScanner/index.android.js b/examples/ReactBLEScanner/index.android.js
new file mode 100644
index 00000000..acc985d4
--- /dev/null
+++ b/examples/ReactBLEScanner/index.android.js
@@ -0,0 +1,230 @@
+/**
+ * Sample React Native App
+ * https://github.com/facebook/react-native
+ */
+'use strict';
+import React, {
+ Component,
+} from 'react';
+import {
+ AppRegistry,
+ Image,
+ ListView,
+ StyleSheet,
+ Text,
+ View,
+ NativeModules,
+ DeviceEventEmitter,
+ Subscribable,
+ TouchableNativeFeedback
+} from 'react-native';
+const ToastModule = NativeModules.TestBLEModule;
+const RxBleClient = NativeModules.RxBleClient;
+const BleModule = NativeModules.BleModule;
+
+var array = [];
+
+var arrayCount = 0;
+var REQUEST_URL = 'https://raw.githubusercontent.com/facebook/react-native/master/docs/MoviesExample.json';
+class ReactNativeTest extends Component {
+ constructor(props) {
+ super(props);
+ this.renderTest = this.renderTest.bind(this);
+ this._onPressButton = this._onPressButton.bind(this);
+ this.state = {
+ dataSource: new ListView.DataSource({
+ rowHasChanged: (row1, row2) => row1 !== row2,
+ }),
+ loaded: false,
+ };
+ }
+
+ componentWillMount() {
+ DeviceEventEmitter.addListener('SCAN_RESULT', (e) => {
+ array[arrayCount] = e.BLE_DEVICE.MAC_ADDRESS;
+ arrayCount = arrayCount + 1;
+ this.setState({
+ dataSource: this.state.dataSource.cloneWithRows(array),
+ loaded: true,
+ });
+ });
+
+ DeviceEventEmitter.addListener('ON_NOTIFICATION_GET', (e) => {
+ ToastModule.show(JSON.stringify(e), ToastModule.SHORT);
+ });
+ }
+
+
+ componentDidMount() {
+ // ToastModule.pingEvent("costam");
+ // RxBleClient.createContext((b) => {
+ // RxBleClient.scanBleDevices();
+ // });
+
+ BleModule.createClient();
+ BleModule.scanBleDevices((e)=> {ToastModule.show(e, ToastModule.SHORT)});
+ setTimeout(
+ () => {
+ ToastModule.show("Scan stop", ToastModule.SHORT);
+ BleModule.stopScanBleDevices(); },
+ 20000
+ );
+ // this.ping();
+ // this.fetchData();
+ }
+
+ fetchData() {
+ fetch(REQUEST_URL)
+ .then((response) => response.json())
+ .then((responseData) => {
+ this.setState({
+ dataSource: this.state.dataSource.cloneWithRows(responseData.movies),
+ loaded: true,
+ });
+ })
+ // .then(() => ToastModule.ping("Myk", (msg) => ToastModule.show(msg, ToastModule.SHORT)))
+ .done();
+ }
+
+
+
+ render() {
+ // if (!this.state.loaded) {
+ // return this.renderLoadingView();
+ // }
+
+ return ( < ListView dataSource = {
+ this.state.dataSource
+ }
+ renderRow = {this.renderTest}
+ style = {
+ styles.listView
+ }
+ />
+ );
+ }
+ renderTest(text) {
+ return (
+ this._onPressButton(text)
+ }
+ background = {
+ TouchableNativeFeedback.SelectableBackground()
+ }>
+ {text}
+
+ )
+ }
+ renderLoadingView() {
+ return ( < View style = {
+ styles.container
+ } >
+ < Text >
+ Loading movies... < /Text> < /View >
+ );
+ }
+ _onPressButton(text){
+ ToastModule.justLogE(text);
+ this.asyncConnect(text);
+ }
+
+/*
+{
+ SERVICES :[ {
+ UUID : "00a-sa-das-dasd-a"
+ CHARACTERISTICS : [{
+ UUID : "00a-sa-das-dasd-a"
+ }
+ ]
+ }]
+}
+*/
+ async asyncConnect(text) {
+ try {
+
+ var isConnected = await BleModule.establishConnection("34:B1:F7:D5:04:01", true);
+ var saved = await BleModule.writeCharacteristic("34:B1:F7:D5:04:01", "xxx", "F000AA12-0451-4000-B000-000000000000", "MQ==");
+ BleModule.setupNotification("34:B1:F7:D5:04:01", "xxx", "F000AA11-0451-4000-B000-000000000000", (e)=> {ToastModule.show(e.DATA, ToastModule.SHORT)});
+ //var response1 = await RxBleClient.establishConnection(text, false);
+ // var response2 = await RxBleClient.discoverServices(text);
+ //First option
+ //var response3 = await RxBleClient.getFirstCharacteristic(text, response2.SERVICES[0].CHARACTERISTICS[1].UUID);
+ //Socond option
+ // var response3 = await RxBleClient.getCharacteristic(text, response2.SERVICES[0].UUID, response2.SERVICES[0].CHARACTERISTICS[0].UUID);
+ //var response = await RxBleClient.readCharacteristic(text, response3);
+ //Third option
+ // var response = await RxBleClient.readCharacteristic(text, response2.SERVICES[0].CHARACTERISTICS[0].UUID);
+ //RxBleClient.setupNotification(text, response2.SERVICES[0].CHARACTERISTICS[0].UUID)
+ // RxBleClient.xxXX();
+
+ // ToastModule.show(JSON.stringify(response), ToastModule.SHORT);
+
+ //New solution
+
+
+ } catch (e) {
+ ToastModule.show(e.code, ToastModule.SHORT);
+ }
+ }
+
+ async delay(){
+
+ }
+ renderMovie(movie) {
+ return ( < View style = {
+ styles.container
+ } >
+ < Image source = {
+ {
+ uri: movie.posters.thumbnail
+ }
+ }
+ style = {
+ styles.thumbnail
+ }
+ /> < View style = {
+ styles.rightContainer
+ } >
+ < Text style = {
+ styles.title
+ } > {
+ movie.title
+ } < /Text> < Text style = {
+ styles.year
+ } > {
+ movie.year
+ } < /Text> < /View > < /View>
+);
+}
+}
+var styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ flexDirection: 'row',
+ justifyContent: 'center',
+ alignItems: 'center',
+ backgroundColor: '#F5FCFF',
+ },
+ rightContainer: {
+ flex: 1,
+ },
+ title: {
+ fontSize: 20,
+ marginBottom: 8,
+ textAlign: 'center',
+ },
+ year: {
+ textAlign: 'center',
+ },
+ thumbnail: {
+ width: 53,
+ height: 81,
+ },
+ listView: {
+ paddingTop: 20,
+ backgroundColor: '#F5FCFF',
+ },
+});
+
+AppRegistry.registerComponent('EmptyProject', () => ReactNativeTest);
diff --git a/index.ios.js b/examples/ReactBLEScanner/index.ios.js
similarity index 89%
rename from index.ios.js
rename to examples/ReactBLEScanner/index.ios.js
index 8eb67aa0..a3fa7ea4 100644
--- a/index.ios.js
+++ b/examples/ReactBLEScanner/index.ios.js
@@ -24,7 +24,7 @@ const stateTransformer = (state) => {
const logger = createLogger({ stateTransformer });
const store = createStore(reducer, applyMiddleware(logger))
-class EmptyProject extends Component {
+class ReactBLEScanner extends Component {
render() {
return (
@@ -38,4 +38,4 @@ class EmptyProject extends Component {
}
}
-AppRegistry.registerComponent('EmptyProject', () => EmptyProject);
+AppRegistry.registerComponent('ReactBLEScanner', () => ReactBLEScanner);
diff --git a/ios/EmptyProject.xcodeproj/project.pbxproj b/examples/ReactBLEScanner/ios/ReactBLEScanner.xcodeproj/project.pbxproj
similarity index 75%
rename from ios/EmptyProject.xcodeproj/project.pbxproj
rename to examples/ReactBLEScanner/ios/ReactBLEScanner.xcodeproj/project.pbxproj
index edee79ec..9d815393 100644
--- a/ios/EmptyProject.xcodeproj/project.pbxproj
+++ b/examples/ReactBLEScanner/ios/ReactBLEScanner.xcodeproj/project.pbxproj
@@ -12,7 +12,7 @@
00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; };
00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; };
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; };
- 00E356F31AD99517003FC87E /* EmptyProjectTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* EmptyProjectTests.m */; };
+ 00E356F31AD99517003FC87E /* ReactBLEScannerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* ReactBLEScannerTests.m */; };
133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; };
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; };
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */; };
@@ -20,14 +20,18 @@
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
+ 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
- 40F1497E1D2ABE57000B14FD /* BleModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40F1497D1D2ABE57000B14FD /* BleModule.swift */; };
- 40F149801D2ABF2A000B14FD /* BleModuleBridge.m in Sources */ = {isa = PBXBuildFile; fileRef = 40F1497F1D2ABF2A000B14FD /* BleModuleBridge.m */; };
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; };
- AB95D09AA596A9C16670B74F /* Pods_EmptyProject.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 56D4E438B06B66D85ADD2A01 /* Pods_EmptyProject.framework */; };
- D754D9811D3F8241000E0C47 /* BleUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = D754D9801D3F8241000E0C47 /* BleUtils.swift */; };
- D7822AC71D460427006DF66A /* BleEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7822AC61D460427006DF66A /* BleEvent.swift */; };
- D7822AD31D46104D006DF66A /* BleError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7822AD21D46104D006DF66A /* BleError.swift */; };
+ D7D0F43D1D4A232D00BA9E3E /* libBleClient.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D7D0F4321D4A231600BA9E3E /* libBleClient.a */; };
+ D7D0F4411D4A2BD400BA9E3E /* RxBluetoothKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D7D0F43E1D4A2BD400BA9E3E /* RxBluetoothKit.framework */; };
+ D7D0F4421D4A2BD400BA9E3E /* RxBluetoothKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D7D0F43E1D4A2BD400BA9E3E /* RxBluetoothKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
+ D7D0F4431D4A2BD400BA9E3E /* RxCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D7D0F43F1D4A2BD400BA9E3E /* RxCocoa.framework */; };
+ D7D0F4441D4A2BD400BA9E3E /* RxCocoa.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D7D0F43F1D4A2BD400BA9E3E /* RxCocoa.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
+ D7D0F4451D4A2BD400BA9E3E /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D7D0F4401D4A2BD400BA9E3E /* RxSwift.framework */; };
+ D7D0F4461D4A2BD400BA9E3E /* RxSwift.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D7D0F4401D4A2BD400BA9E3E /* RxSwift.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
+ D7D0F4491D4A2D1800BA9E3E /* BleClientManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D7D0F4481D4A2D1800BA9E3E /* BleClientManager.framework */; };
+ D7D0F44A1D4A2D1800BA9E3E /* BleClientManager.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D7D0F4481D4A2D1800BA9E3E /* BleClientManager.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -71,7 +75,7 @@
containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 13B07F861A680F5B00A75B9A;
- remoteInfo = EmptyProject;
+ remoteInfo = ReactBLEScanner;
};
139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
@@ -108,8 +112,32 @@
remoteGlobalIDString = 58B5119B1A9E6C1200147676;
remoteInfo = RCTText;
};
+ D7D0F4311D4A231600BA9E3E /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = D7D0F42C1D4A231500BA9E3E /* BleClient.xcodeproj */;
+ proxyType = 2;
+ remoteGlobalIDString = D73F06E81D48E17B00AD5963;
+ remoteInfo = BleClient;
+ };
/* End PBXContainerItemProxy section */
+/* Begin PBXCopyFilesBuildPhase section */
+ D7D0F4471D4A2BD500BA9E3E /* Embed Frameworks */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "";
+ dstSubfolderSpec = 10;
+ files = (
+ D7D0F4441D4A2BD400BA9E3E /* RxCocoa.framework in Embed Frameworks */,
+ D7D0F4421D4A2BD400BA9E3E /* RxBluetoothKit.framework in Embed Frameworks */,
+ D7D0F4461D4A2BD400BA9E3E /* RxSwift.framework in Embed Frameworks */,
+ D7D0F44A1D4A2D1800BA9E3E /* BleClientManager.framework in Embed Frameworks */,
+ );
+ name = "Embed Frameworks";
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
/* Begin PBXFileReference section */
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = ""; };
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = "../node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj"; sourceTree = ""; };
@@ -117,30 +145,26 @@
00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = "../node_modules/react-native/Libraries/Image/RCTImage.xcodeproj"; sourceTree = ""; };
00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = "../node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj"; sourceTree = ""; };
00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = "../node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj"; sourceTree = ""; };
- 00E356EE1AD99517003FC87E /* EmptyProjectTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = EmptyProjectTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
+ 00E356EE1AD99517003FC87E /* ReactBLEScannerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ReactBLEScannerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
- 00E356F21AD99517003FC87E /* EmptyProjectTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EmptyProjectTests.m; sourceTree = ""; };
+ 00E356F21AD99517003FC87E /* ReactBLEScannerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ReactBLEScannerTests.m; sourceTree = ""; };
139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = ""; };
139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = "../node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj"; sourceTree = ""; };
- 13B07F961A680F5B00A75B9A /* EmptyProject.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = EmptyProject.app; sourceTree = BUILT_PRODUCTS_DIR; };
- 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = EmptyProject/AppDelegate.h; sourceTree = ""; };
- 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = EmptyProject/AppDelegate.m; sourceTree = ""; };
+ 13B07F961A680F5B00A75B9A /* ReactBLEScanner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ReactBLEScanner.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = ReactBLEScanner/AppDelegate.h; sourceTree = ""; };
+ 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = ReactBLEScanner/AppDelegate.m; sourceTree = ""; };
13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
- 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = EmptyProject/Images.xcassets; sourceTree = ""; };
- 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = EmptyProject/Info.plist; sourceTree = ""; };
- 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = EmptyProject/main.m; sourceTree = ""; };
+ 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = ReactBLEScanner/Images.xcassets; sourceTree = ""; };
+ 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ReactBLEScanner/Info.plist; sourceTree = ""; };
+ 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = ReactBLEScanner/main.m; sourceTree = ""; };
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = ""; };
- 1605BCAC913392BB0A9E7BAB /* Pods-EmptyProject.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EmptyProject.debug.xcconfig"; path = "Pods/Target Support Files/Pods-EmptyProject/Pods-EmptyProject.debug.xcconfig"; sourceTree = ""; };
- 40F149701D2ABB53000B14FD /* EmptyProject-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "EmptyProject-Bridging-Header.h"; sourceTree = ""; };
- 40F1497D1D2ABE57000B14FD /* BleModule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BleModule.swift; sourceTree = ""; };
- 40F1497F1D2ABF2A000B14FD /* BleModuleBridge.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BleModuleBridge.m; sourceTree = ""; };
- 56D4E438B06B66D85ADD2A01 /* Pods_EmptyProject.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_EmptyProject.framework; sourceTree = BUILT_PRODUCTS_DIR; };
78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = "../node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj"; sourceTree = ""; };
832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = "../node_modules/react-native/Libraries/Text/RCTText.xcodeproj"; sourceTree = ""; };
- D754D9801D3F8241000E0C47 /* BleUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BleUtils.swift; sourceTree = ""; };
- D7822AC61D460427006DF66A /* BleEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BleEvent.swift; sourceTree = ""; };
- D7822AD21D46104D006DF66A /* BleError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BleError.swift; sourceTree = ""; };
- F2242B47225D0A7F62E8A990 /* Pods-EmptyProject.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-EmptyProject.release.xcconfig"; path = "Pods/Target Support Files/Pods-EmptyProject/Pods-EmptyProject.release.xcconfig"; sourceTree = ""; };
+ D7D0F42C1D4A231500BA9E3E /* BleClient.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = BleClient.xcodeproj; path = ../node_modules/BleClient/BleClient.xcodeproj; sourceTree = ""; };
+ D7D0F43E1D4A2BD400BA9E3E /* RxBluetoothKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxBluetoothKit.framework; path = ../node_modules/BleClient/BleClientManager/Carthage/Build/iOS/RxBluetoothKit.framework; sourceTree = ""; };
+ D7D0F43F1D4A2BD400BA9E3E /* RxCocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxCocoa.framework; path = ../node_modules/BleClient/BleClientManager/Carthage/Build/iOS/RxCocoa.framework; sourceTree = ""; };
+ D7D0F4401D4A2BD400BA9E3E /* RxSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxSwift.framework; path = ../node_modules/BleClient/BleClientManager/Carthage/Build/iOS/RxSwift.framework; sourceTree = ""; };
+ D7D0F4481D4A2D1800BA9E3E /* BleClientManager.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = BleClientManager.framework; path = "/Users/cierpliwy/Library/Developer/Xcode/DerivedData/ReactBLEScanner-aunhyrbalgpkjxfxrkikodzyqpuw/Build/Products/Debug-iphoneos/BleClientManager.framework"; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -148,6 +172,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 140ED2AC1D01E1AD002B40FF /* libReact.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -155,17 +180,21 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ D7D0F43D1D4A232D00BA9E3E /* libBleClient.a in Frameworks */,
146834051AC3E58100842450 /* libReact.a in Frameworks */,
+ D7D0F4451D4A2BD400BA9E3E /* RxSwift.framework in Frameworks */,
+ D7D0F4431D4A2BD400BA9E3E /* RxCocoa.framework in Frameworks */,
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */,
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */,
00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */,
133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */,
00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */,
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */,
+ D7D0F4491D4A2D1800BA9E3E /* BleClientManager.framework in Frameworks */,
+ D7D0F4411D4A2BD400BA9E3E /* RxBluetoothKit.framework in Frameworks */,
832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */,
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */,
139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */,
- AB95D09AA596A9C16670B74F /* Pods_EmptyProject.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -212,13 +241,13 @@
name = Products;
sourceTree = "";
};
- 00E356EF1AD99517003FC87E /* EmptyProjectTests */ = {
+ 00E356EF1AD99517003FC87E /* ReactBLEScannerTests */ = {
isa = PBXGroup;
children = (
- 00E356F21AD99517003FC87E /* EmptyProjectTests.m */,
+ 00E356F21AD99517003FC87E /* ReactBLEScannerTests.m */,
00E356F01AD99517003FC87E /* Supporting Files */,
);
- path = EmptyProjectTests;
+ path = ReactBLEScannerTests;
sourceTree = "";
};
00E356F01AD99517003FC87E /* Supporting Files */ = {
@@ -245,7 +274,7 @@
name = Products;
sourceTree = "";
};
- 13B07FAE1A68108700A75B9A /* EmptyProject */ = {
+ 13B07FAE1A68108700A75B9A /* ReactBLEScanner */ = {
isa = PBXGroup;
children = (
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
@@ -255,14 +284,8 @@
13B07FB61A68108700A75B9A /* Info.plist */,
13B07FB11A68108700A75B9A /* LaunchScreen.xib */,
13B07FB71A68108700A75B9A /* main.m */,
- 40F149701D2ABB53000B14FD /* EmptyProject-Bridging-Header.h */,
- 40F1497F1D2ABF2A000B14FD /* BleModuleBridge.m */,
- 40F1497D1D2ABE57000B14FD /* BleModule.swift */,
- D754D9801D3F8241000E0C47 /* BleUtils.swift */,
- D7822AC61D460427006DF66A /* BleEvent.swift */,
- D7822AD21D46104D006DF66A /* BleError.swift */,
- );
- name = EmptyProject;
+ );
+ name = ReactBLEScanner;
sourceTree = "";
};
146834001AC3E56700842450 /* Products */ = {
@@ -273,15 +296,6 @@
name = Products;
sourceTree = "";
};
- 43B305309D7117172E19D502 /* Pods */ = {
- isa = PBXGroup;
- children = (
- 1605BCAC913392BB0A9E7BAB /* Pods-EmptyProject.debug.xcconfig */,
- F2242B47225D0A7F62E8A990 /* Pods-EmptyProject.release.xcconfig */,
- );
- name = Pods;
- sourceTree = "";
- };
78C398B11ACF4ADC00677621 /* Products */ = {
isa = PBXGroup;
children = (
@@ -293,6 +307,7 @@
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
+ D7D0F42C1D4A231500BA9E3E /* BleClient.xcodeproj */,
146833FF1AC3E56700842450 /* React.xcodeproj */,
00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */,
00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */,
@@ -318,12 +333,14 @@
83CBB9F61A601CBA00E9B192 = {
isa = PBXGroup;
children = (
- 13B07FAE1A68108700A75B9A /* EmptyProject */,
+ D7D0F4481D4A2D1800BA9E3E /* BleClientManager.framework */,
+ D7D0F43E1D4A2BD400BA9E3E /* RxBluetoothKit.framework */,
+ D7D0F43F1D4A2BD400BA9E3E /* RxCocoa.framework */,
+ D7D0F4401D4A2BD400BA9E3E /* RxSwift.framework */,
+ 13B07FAE1A68108700A75B9A /* ReactBLEScanner */,
832341AE1AAA6A7D00B99B32 /* Libraries */,
- 00E356EF1AD99517003FC87E /* EmptyProjectTests */,
+ 00E356EF1AD99517003FC87E /* ReactBLEScannerTests */,
83CBBA001A601CBA00E9B192 /* Products */,
- 43B305309D7117172E19D502 /* Pods */,
- E84EBA05043F1FE63BFEFD71 /* Frameworks */,
);
indentWidth = 2;
sourceTree = "";
@@ -332,26 +349,26 @@
83CBBA001A601CBA00E9B192 /* Products */ = {
isa = PBXGroup;
children = (
- 13B07F961A680F5B00A75B9A /* EmptyProject.app */,
- 00E356EE1AD99517003FC87E /* EmptyProjectTests.xctest */,
+ 13B07F961A680F5B00A75B9A /* ReactBLEScanner.app */,
+ 00E356EE1AD99517003FC87E /* ReactBLEScannerTests.xctest */,
);
name = Products;
sourceTree = "";
};
- E84EBA05043F1FE63BFEFD71 /* Frameworks */ = {
+ D7D0F42D1D4A231500BA9E3E /* Products */ = {
isa = PBXGroup;
children = (
- 56D4E438B06B66D85ADD2A01 /* Pods_EmptyProject.framework */,
+ D7D0F4321D4A231600BA9E3E /* libBleClient.a */,
);
- name = Frameworks;
+ name = Products;
sourceTree = "";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
- 00E356ED1AD99517003FC87E /* EmptyProjectTests */ = {
+ 00E356ED1AD99517003FC87E /* ReactBLEScannerTests */ = {
isa = PBXNativeTarget;
- buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "EmptyProjectTests" */;
+ buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "ReactBLEScannerTests" */;
buildPhases = (
00E356EA1AD99517003FC87E /* Sources */,
00E356EB1AD99517003FC87E /* Frameworks */,
@@ -362,30 +379,28 @@
dependencies = (
00E356F51AD99517003FC87E /* PBXTargetDependency */,
);
- name = EmptyProjectTests;
- productName = EmptyProjectTests;
- productReference = 00E356EE1AD99517003FC87E /* EmptyProjectTests.xctest */;
+ name = ReactBLEScannerTests;
+ productName = ReactBLEScannerTests;
+ productReference = 00E356EE1AD99517003FC87E /* ReactBLEScannerTests.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
- 13B07F861A680F5B00A75B9A /* EmptyProject */ = {
+ 13B07F861A680F5B00A75B9A /* ReactBLEScanner */ = {
isa = PBXNativeTarget;
- buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "EmptyProject" */;
+ buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "ReactBLEScanner" */;
buildPhases = (
- 7D42AA3CB8B2BB32D3CC3A35 /* [CP] Check Pods Manifest.lock */,
13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
- 411D8C3BC000350D26755BEA /* [CP] Embed Pods Frameworks */,
- EC2785ADD3C40A4984B079B8 /* [CP] Copy Pods Resources */,
+ D7D0F4471D4A2BD500BA9E3E /* Embed Frameworks */,
);
buildRules = (
);
dependencies = (
);
- name = EmptyProject;
+ name = ReactBLEScanner;
productName = "Hello World";
- productReference = 13B07F961A680F5B00A75B9A /* EmptyProject.app */;
+ productReference = 13B07F961A680F5B00A75B9A /* ReactBLEScanner.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
@@ -394,7 +409,6 @@
83CBB9F71A601CBA00E9B192 /* Project object */ = {
isa = PBXProject;
attributes = {
- LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0610;
ORGANIZATIONNAME = Facebook;
TargetAttributes = {
@@ -402,9 +416,12 @@
CreatedOnToolsVersion = 6.2;
TestTargetID = 13B07F861A680F5B00A75B9A;
};
+ 13B07F861A680F5B00A75B9A = {
+ DevelopmentTeam = WR35VQMY5K;
+ };
};
};
- buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "EmptyProject" */;
+ buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "ReactBLEScanner" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
@@ -416,6 +433,10 @@
productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
projectDirPath = "";
projectReferences = (
+ {
+ ProductGroup = D7D0F42D1D4A231500BA9E3E /* Products */;
+ ProjectRef = D7D0F42C1D4A231500BA9E3E /* BleClient.xcodeproj */;
+ },
{
ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */;
ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */;
@@ -459,8 +480,8 @@
);
projectRoot = "";
targets = (
- 13B07F861A680F5B00A75B9A /* EmptyProject */,
- 00E356ED1AD99517003FC87E /* EmptyProjectTests */,
+ 13B07F861A680F5B00A75B9A /* ReactBLEScanner */,
+ 00E356ED1AD99517003FC87E /* ReactBLEScannerTests */,
);
};
/* End PBXProject section */
@@ -536,6 +557,13 @@
remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
+ D7D0F4321D4A231600BA9E3E /* libBleClient.a */ = {
+ isa = PBXReferenceProxy;
+ fileType = archive.ar;
+ path = libBleClient.a;
+ remoteRef = D7D0F4311D4A231600BA9E3E /* PBXContainerItemProxy */;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
@@ -572,51 +600,6 @@
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh";
};
- 411D8C3BC000350D26755BEA /* [CP] Embed Pods Frameworks */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- );
- name = "[CP] Embed Pods Frameworks";
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/sh;
- shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-EmptyProject/Pods-EmptyProject-frameworks.sh\"\n";
- showEnvVarsInLog = 0;
- };
- 7D42AA3CB8B2BB32D3CC3A35 /* [CP] Check Pods Manifest.lock */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- );
- name = "[CP] Check Pods Manifest.lock";
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/sh;
- shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
- showEnvVarsInLog = 0;
- };
- EC2785ADD3C40A4984B079B8 /* [CP] Copy Pods Resources */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- );
- name = "[CP] Copy Pods Resources";
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/sh;
- shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-EmptyProject/Pods-EmptyProject-resources.sh\"\n";
- showEnvVarsInLog = 0;
- };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -624,7 +607,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
- 00E356F31AD99517003FC87E /* EmptyProjectTests.m in Sources */,
+ 00E356F31AD99517003FC87E /* ReactBLEScannerTests.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -633,12 +616,7 @@
buildActionMask = 2147483647;
files = (
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */,
- 40F149801D2ABF2A000B14FD /* BleModuleBridge.m in Sources */,
13B07FC11A68108700A75B9A /* main.m in Sources */,
- D754D9811D3F8241000E0C47 /* BleUtils.swift in Sources */,
- D7822AC71D460427006DF66A /* BleEvent.swift in Sources */,
- D7822AD31D46104D006DF66A /* BleError.swift in Sources */,
- 40F1497E1D2ABE57000B14FD /* BleModule.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -647,7 +625,7 @@
/* Begin PBXTargetDependency section */
00E356F51AD99517003FC87E /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
- target = 13B07F861A680F5B00A75B9A /* EmptyProject */;
+ target = 13B07F861A680F5B00A75B9A /* ReactBLEScanner */;
targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
@@ -659,7 +637,7 @@
13B07FB21A68108700A75B9A /* Base */,
);
name = LaunchScreen.xib;
- path = EmptyProject;
+ path = ReactBLEScanner;
sourceTree = "";
};
/* End PBXVariantGroup section */
@@ -673,11 +651,11 @@
"DEBUG=1",
"$(inherited)",
);
- INFOPLIST_FILE = EmptyProjectTests/Info.plist;
+ INFOPLIST_FILE = ReactBLEScannerTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
- TEST_HOST = "$(BUILT_PRODUCTS_DIR)/EmptyProject.app/EmptyProject";
+ TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ReactBLEScanner.app/ReactBLEScanner";
};
name = Debug;
};
@@ -686,59 +664,64 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
COPY_PHASE_STRIP = NO;
- INFOPLIST_FILE = EmptyProjectTests/Info.plist;
+ INFOPLIST_FILE = ReactBLEScannerTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
- TEST_HOST = "$(BUILT_PRODUCTS_DIR)/EmptyProject.app/EmptyProject";
+ TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ReactBLEScanner.app/ReactBLEScanner";
};
name = Release;
};
13B07F941A680F5B00A75B9A /* Debug */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = 1605BCAC913392BB0A9E7BAB /* Pods-EmptyProject.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
DEAD_CODE_STRIPPING = NO;
+ EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
+ FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../node_modules/BleClient/**";
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**",
);
- INFOPLIST_FILE = EmptyProject/Info.plist;
+ INFOPLIST_FILE = ReactBLEScanner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
+ "$(inherited)",
"-ObjC",
"-lc++",
);
- PRODUCT_NAME = EmptyProject;
- SWIFT_OBJC_BRIDGING_HEADER = "EmptyProject-Bridging-Header.h";
- SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ PRODUCT_NAME = ReactBLEScanner;
+ PROVISIONING_PROFILE = "";
};
name = Debug;
};
13B07F951A680F5B00A75B9A /* Release */ = {
isa = XCBuildConfiguration;
- baseConfigurationReference = F2242B47225D0A7F62E8A990 /* Pods-EmptyProject.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
- CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_IDENTITY = "iPhone Developer";
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
+ FRAMEWORK_SEARCH_PATHS = "$(SRCROOT)/../node_modules/BleClient/**";
HEADER_SEARCH_PATHS = (
"$(inherited)",
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../node_modules/react-native/React/**",
);
- INFOPLIST_FILE = EmptyProject/Info.plist;
+ INFOPLIST_FILE = ReactBLEScanner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
OTHER_LDFLAGS = (
+ "$(inherited)",
"-ObjC",
"-lc++",
);
- PRODUCT_NAME = EmptyProject;
- SWIFT_OBJC_BRIDGING_HEADER = "EmptyProject-Bridging-Header.h";
+ PRODUCT_NAME = ReactBLEScanner;
+ PROVISIONING_PROFILE = "";
};
name = Release;
};
@@ -831,7 +814,7 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
- 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "EmptyProjectTests" */ = {
+ 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "ReactBLEScannerTests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
00E356F61AD99517003FC87E /* Debug */,
@@ -840,7 +823,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
- 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "EmptyProject" */ = {
+ 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "ReactBLEScanner" */ = {
isa = XCConfigurationList;
buildConfigurations = (
13B07F941A680F5B00A75B9A /* Debug */,
@@ -849,7 +832,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
- 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "EmptyProject" */ = {
+ 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "ReactBLEScanner" */ = {
isa = XCConfigurationList;
buildConfigurations = (
83CBBA201A601CBA00E9B192 /* Debug */,
diff --git a/ios/EmptyProject.xcodeproj/xcshareddata/xcschemes/EmptyProject.xcscheme b/examples/ReactBLEScanner/ios/ReactBLEScanner.xcodeproj/xcshareddata/xcschemes/ReactBLEScanner.xcscheme
similarity index 76%
rename from ios/EmptyProject.xcodeproj/xcshareddata/xcschemes/EmptyProject.xcscheme
rename to examples/ReactBLEScanner/ios/ReactBLEScanner.xcodeproj/xcshareddata/xcschemes/ReactBLEScanner.xcscheme
index a0adcb8e..b30c36bf 100644
--- a/ios/EmptyProject.xcodeproj/xcshareddata/xcschemes/EmptyProject.xcscheme
+++ b/examples/ReactBLEScanner/ios/ReactBLEScanner.xcodeproj/xcshareddata/xcschemes/ReactBLEScanner.xcscheme
@@ -15,9 +15,9 @@
+ BuildableName = "ReactBLEScanner.app"
+ BlueprintName = "ReactBLEScanner"
+ ReferencedContainer = "container:ReactBLEScanner.xcodeproj">
+ BuildableName = "ReactBLEScannerTests.xctest"
+ BlueprintName = "ReactBLEScannerTests"
+ ReferencedContainer = "container:ReactBLEScanner.xcodeproj">
@@ -47,9 +47,9 @@
+ BuildableName = "ReactBLEScannerTests.xctest"
+ BlueprintName = "ReactBLEScannerTests"
+ ReferencedContainer = "container:ReactBLEScanner.xcodeproj">
@@ -57,9 +57,9 @@
+ BuildableName = "ReactBLEScanner.app"
+ BlueprintName = "ReactBLEScanner"
+ ReferencedContainer = "container:ReactBLEScanner.xcodeproj">
@@ -77,9 +77,9 @@
+ BuildableName = "ReactBLEScanner.app"
+ BlueprintName = "ReactBLEScanner"
+ ReferencedContainer = "container:ReactBLEScanner.xcodeproj">
@@ -96,9 +96,9 @@
+ BuildableName = "ReactBLEScanner.app"
+ BlueprintName = "ReactBLEScanner"
+ ReferencedContainer = "container:ReactBLEScanner.xcodeproj">
diff --git a/ios/EmptyProject/AppDelegate.h b/examples/ReactBLEScanner/ios/ReactBLEScanner/AppDelegate.h
similarity index 100%
rename from ios/EmptyProject/AppDelegate.h
rename to examples/ReactBLEScanner/ios/ReactBLEScanner/AppDelegate.h
diff --git a/ios/EmptyProject/AppDelegate.m b/examples/ReactBLEScanner/ios/ReactBLEScanner/AppDelegate.m
similarity index 50%
rename from ios/EmptyProject/AppDelegate.m
rename to examples/ReactBLEScanner/ios/ReactBLEScanner/AppDelegate.m
index d7b7036b..fab3e1e2 100644
--- a/ios/EmptyProject/AppDelegate.m
+++ b/examples/ReactBLEScanner/ios/ReactBLEScanner/AppDelegate.m
@@ -9,6 +9,7 @@
#import "AppDelegate.h"
+#import "RCTBundleURLProvider.h"
#import "RCTRootView.h"
@implementation AppDelegate
@@ -17,37 +18,13 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
{
NSURL *jsCodeLocation;
- /**
- * Loading JavaScript code - uncomment the one you want.
- *
- * OPTION 1
- * Load from development server. Start the server from the repository root:
- *
- * $ npm start
- *
- * To run on device, change `localhost` to the IP address of your computer
- * (you can get this by typing `ifconfig` into the terminal and selecting the
- * `inet` value under `en0:`) and make sure your computer and iOS device are
- * on the same Wi-Fi network.
- */
-
-// jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
- jsCodeLocation = [NSURL URLWithString:@"http://10.0.3.124:8081/index.ios.bundle?platform=ios&dev=true"];
-
- /**
- * OPTION 2
- * Load from pre-bundled file on disk. The static bundle is automatically
- * generated by the "Bundle React Native code and images" build step when
- * running the project on an actual device or running the project on the
- * simulator in the "Release" build configuration.
- */
-
-// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
+ jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
- moduleName:@"EmptyProject"
+ moduleName:@"ReactBLEScanner"
initialProperties:nil
launchOptions:launchOptions];
+ rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [UIViewController new];
diff --git a/ios/EmptyProject/Base.lproj/LaunchScreen.xib b/examples/ReactBLEScanner/ios/ReactBLEScanner/Base.lproj/LaunchScreen.xib
similarity index 60%
rename from ios/EmptyProject/Base.lproj/LaunchScreen.xib
rename to examples/ReactBLEScanner/ios/ReactBLEScanner/Base.lproj/LaunchScreen.xib
index c72e9de4..6b77042d 100644
--- a/ios/EmptyProject/Base.lproj/LaunchScreen.xib
+++ b/examples/ReactBLEScanner/ios/ReactBLEScanner/Base.lproj/LaunchScreen.xib
@@ -1,8 +1,8 @@
-
+
-
+
@@ -12,25 +12,26 @@
-
-
+
+
+
+
diff --git a/ios/EmptyProject/Images.xcassets/AppIcon.appiconset/Contents.json b/examples/ReactBLEScanner/ios/ReactBLEScanner/Images.xcassets/AppIcon.appiconset/Contents.json
similarity index 100%
rename from ios/EmptyProject/Images.xcassets/AppIcon.appiconset/Contents.json
rename to examples/ReactBLEScanner/ios/ReactBLEScanner/Images.xcassets/AppIcon.appiconset/Contents.json
diff --git a/ios/EmptyProject/Info.plist b/examples/ReactBLEScanner/ios/ReactBLEScanner/Info.plist
similarity index 80%
rename from ios/EmptyProject/Info.plist
rename to examples/ReactBLEScanner/ios/ReactBLEScanner/Info.plist
index 91963b26..e98ebb00 100644
--- a/ios/EmptyProject/Info.plist
+++ b/examples/ReactBLEScanner/ios/ReactBLEScanner/Info.plist
@@ -38,11 +38,17 @@
NSLocationWhenInUseUsageDescription
- NSAppTransportSecurity
-
-
- NSAllowsArbitraryLoads
-
-
+ NSAppTransportSecurity
+
+
+ NSExceptionDomains
+
+ localhost
+
+ NSTemporaryExceptionAllowsInsecureHTTPLoads
+
+
+
+
diff --git a/ios/EmptyProject/main.m b/examples/ReactBLEScanner/ios/ReactBLEScanner/main.m
similarity index 100%
rename from ios/EmptyProject/main.m
rename to examples/ReactBLEScanner/ios/ReactBLEScanner/main.m
diff --git a/ios/EmptyProjectTests/Info.plist b/examples/ReactBLEScanner/ios/ReactBLEScannerTests/Info.plist
similarity index 100%
rename from ios/EmptyProjectTests/Info.plist
rename to examples/ReactBLEScanner/ios/ReactBLEScannerTests/Info.plist
diff --git a/ios/EmptyProjectTests/EmptyProjectTests.m b/examples/ReactBLEScanner/ios/ReactBLEScannerTests/ReactBLEScannerTests.m
similarity index 96%
rename from ios/EmptyProjectTests/EmptyProjectTests.m
rename to examples/ReactBLEScanner/ios/ReactBLEScannerTests/ReactBLEScannerTests.m
index 384f3fea..ce14c064 100644
--- a/ios/EmptyProjectTests/EmptyProjectTests.m
+++ b/examples/ReactBLEScanner/ios/ReactBLEScannerTests/ReactBLEScannerTests.m
@@ -16,11 +16,11 @@
#define TIMEOUT_SECONDS 600
#define TEXT_TO_LOOK_FOR @"Welcome to React Native!"
-@interface EmptyProjectTests : XCTestCase
+@interface ReactBLEScannerTests : XCTestCase
@end
-@implementation EmptyProjectTests
+@implementation ReactBLEScannerTests
- (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
{
diff --git a/package.json b/examples/ReactBLEScanner/package.json
similarity index 61%
rename from package.json
rename to examples/ReactBLEScanner/package.json
index 8fafbcde..e64a9c75 100644
--- a/package.json
+++ b/examples/ReactBLEScanner/package.json
@@ -1,5 +1,5 @@
{
- "name": "EmptyProject",
+ "name": "ReactBLEScanner",
"version": "0.0.1",
"private": true,
"scripts": {
@@ -7,15 +7,13 @@
},
"dependencies": {
"react": "15.2.1",
- "react-native": "0.29.2",
- "redux": "3.5.2",
- "react-redux": "4.4.5",
- "redux-logger": "2.6.1",
- "react-native-router-flux": "3.31.1",
+ "react-native": "0.30.0",
"immutable": "3.8.1",
- "redux-immutable": "3.0.6",
"react-immutable-proptypes": "1.7.1",
- "react-native-button": "1.6.0",
- "react-native-android-permissions": "0.0.6"
+ "react-native-router-flux": "3.32.0",
+ "react-redux": "4.4.5",
+ "redux": "3.5.2",
+ "redux-immutable": "3.0.6",
+ "redux-logger": "2.6.1"
}
}
diff --git a/tsconfig.json b/examples/ReactBLEScanner/tsconfig.json
similarity index 100%
rename from tsconfig.json
rename to examples/ReactBLEScanner/tsconfig.json
diff --git a/index.android.js b/index.android.js
deleted file mode 100644
index f153b28c..00000000
--- a/index.android.js
+++ /dev/null
@@ -1,66 +0,0 @@
-'use strict';
-
-import React, { Component } from 'react';
-import { View, AppRegistry } from 'react-native';
-import { applyMiddleware, createStore } from 'redux';
-import { Provider } from 'react-redux';
-import createLogger from 'redux-logger';
-
-import RootComponent from './app/root/RootComponent';
-import ErrorComponent from './app/root/ErrorComponent';
-import BleComponent from './app/ble/BleComponent';
-import reducer from './app/root/Reducer';
-
-import { Iterable } from 'immutable';
-
-import {checkPermission} from 'react-native-android-permissions';
-import {requestPermission} from 'react-native-android-permissions';
-
-const stateTransformer = (state) => {
- if (Iterable.isIterable(state)) {
- return state.toJS()
- } else {
- return state;
- }
-};
-
-const logger = createLogger({ stateTransformer });
-const store = createStore(reducer, applyMiddleware(logger))
-
-class EmptyProject extends Component {
-
- componentDidMount() {
- this.checkAndGrantPermissions()
- }
-
- checkAndGrantPermissions() {
- checkPermission("android.permission.ACCESS_COARSE_LOCATION").then((result) => {
- console.log("Already Granted!");
- console.log(result);
- }, (result) => {
- console.log("Not Granted!");
- console.log(result);
-
- requestPermission("android.permission.ACCESS_COARSE_LOCATION").then((result) => {
- console.log("Granted!", result);
- }, (result) => {
- console.log("Not Granted!");
- console.log(result);
- });
- });
- }
-
- render() {
- return (
-
-
-
-
-
-
-
- );
- }
-}
-
-AppRegistry.registerComponent('EmptyProject', () => EmptyProject);
diff --git a/index.js b/index.js
new file mode 100644
index 00000000..2061200b
--- /dev/null
+++ b/index.js
@@ -0,0 +1 @@
+export { default as BleManager } from './src/BleManager'
\ No newline at end of file
diff --git a/ios/BleClient.h b/ios/BleClient.h
new file mode 100644
index 00000000..a6a26dec
--- /dev/null
+++ b/ios/BleClient.h
@@ -0,0 +1,15 @@
+//
+// BleClient.h
+// BleClient
+//
+// Created by Przemysław Lenart on 27/07/16.
+// Copyright © 2016 Polidea. All rights reserved.
+//
+
+#import
+#import "RCTBridgeModule.h"
+#import "RCTEventEmitter.h"
+
+@interface BleModule : RCTEventEmitter
+
+@end
diff --git a/ios/BleClient.m b/ios/BleClient.m
new file mode 100644
index 00000000..c3f5323b
--- /dev/null
+++ b/ios/BleClient.m
@@ -0,0 +1,126 @@
+//
+// BleClient.m
+// BleClient
+//
+// Created by Przemysław Lenart on 27/07/16.
+// Copyright © 2016 Polidea. All rights reserved.
+//
+
+#import "BleClient.h"
+@import BleClientManager;
+
+@interface BleModule ()
+@property(nonatomic) BleClientManager* manager;
+@end
+
+@implementation BleModule
+
+RCT_EXPORT_MODULE(BleClientManager);
+
+- (void)dispatchEvent:(NSString * _Nonnull)name value:(id _Nonnull)value {
+ [self sendEventWithName:name body:value];
+}
+
+- (NSArray *)supportedEvents {
+ // TODO: More generic
+ return @[@"BleClientManagerScanEvent"];
+}
+
+- (NSDictionary *)constantsToExport {
+ // TODO: More generic
+ return @{@"ScanEvent": @"BleClientManagerScanEvent"};
+}
+
+RCT_EXPORT_METHOD(createClient) {
+ // TODO: Method queue
+ _manager = [[BleClientManager alloc] initWithQueue:dispatch_get_main_queue()];
+ _manager.delegate = self;
+}
+
+RCT_EXPORT_METHOD(destroyClient) {
+ _manager = nil;
+}
+
+RCT_EXPORT_METHOD(scanBleDevices:(NSArray*)filteredUUIDs) {
+ [_manager scanBleDevices:filteredUUIDs];
+}
+
+RCT_EXPORT_METHOD(stopScanBleDevices) {
+ [_manager stopScanBleDevices];
+}
+
+RCT_EXPORT_METHOD(establishConnection:(NSString*)deviceIdentifier
+ resolver:(RCTPromiseResolveBlock)resolve
+ rejecter:(RCTPromiseRejectBlock)reject) {
+ [_manager establishConnection:deviceIdentifier resolve:resolve reject:reject];
+}
+
+RCT_EXPORT_METHOD(closeConnection:(NSString*)deviceIdentifier
+ resolver:(RCTPromiseResolveBlock)resolve
+ rejecter:(RCTPromiseRejectBlock)reject) {
+ [_manager closeConnection:deviceIdentifier resolve:resolve reject:reject];
+}
+
+RCT_EXPORT_METHOD(serviceIdsForDevice:(NSString*)deviceIdentifier
+ resolver:(RCTPromiseResolveBlock)resolve
+ rejecter:(RCTPromiseRejectBlock)reject) {
+ [_manager serviceIdsForDevice:deviceIdentifier resolve:resolve reject:reject];
+}
+
+RCT_EXPORT_METHOD(characteristicIdsForDevice:(NSString*)deviceIdentifier
+ serviceIdentifier:(NSString*)serviceIdentifier
+ resolver:(RCTPromiseResolveBlock)resolve
+ rejecter:(RCTPromiseRejectBlock)reject) {
+ [_manager characteristicIdsForDevice:deviceIdentifier
+ serviceIdentifier:serviceIdentifier
+ resolve:resolve
+ reject:reject];
+}
+
+RCT_EXPORT_METHOD(detailsForCharacteristic:(NSString*)deviceIdentifier
+ serviceIdentifier:(NSString*)serviceIdentifier
+ characteristicIdentifier:(NSString*)characteristicIdentifier
+ resolver:(RCTPromiseResolveBlock)resolve
+ rejecter:(RCTPromiseRejectBlock)reject) {
+ [_manager detailsForCharacteristic:deviceIdentifier
+ serviceIdentifier:serviceIdentifier
+ characteristicIdentifier:characteristicIdentifier
+ resolve:resolve
+ reject:reject];
+}
+
+RCT_EXPORT_METHOD( writeCharacteristic:(NSString*)deviceIdentifier
+ serviceIdentifier:(NSString*)serviceIdentifier
+ characteristicIdentifier:(NSString*)characteristicIdentifier
+ valueBase64:(NSString*)valueBase64
+ transactionId:(NSString*)transactionId
+ resolver:(RCTPromiseResolveBlock)resolve
+ rejecter:(RCTPromiseRejectBlock)reject) {
+ [_manager writeCharacteristic:deviceIdentifier
+ serviceIdentifier:serviceIdentifier
+ characteristicIdentifier:characteristicIdentifier
+ valueBase64:valueBase64
+ transactionId:transactionId
+ resolve:resolve
+ reject:reject];
+}
+
+RCT_EXPORT_METHOD( readCharacteristic:(NSString*)deviceIdentifier
+ serviceIdentifier:(NSString*)serviceIdentifier
+ characteristicIdentifier:(NSString*)characteristicIdentifier
+ transactionId:(NSString*)transactionId
+ resolver:(RCTPromiseResolveBlock)resolve
+ rejecter:(RCTPromiseRejectBlock)reject) {
+ [_manager readCharacteristic:deviceIdentifier
+ serviceIdentifier:serviceIdentifier
+ characteristicIdentifier:characteristicIdentifier
+ transactionId:transactionId
+ resolve:resolve
+ reject:reject];
+}
+
+RCT_EXPORT_METHOD(cancelCharacteristicOperation:(NSString*)transactionId) {
+ [_manager cancelCharacteristicOperation:transactionId];
+}
+
+@end
diff --git a/ios/BleClient.xcodeproj/project.pbxproj b/ios/BleClient.xcodeproj/project.pbxproj
new file mode 100644
index 00000000..05630fc8
--- /dev/null
+++ b/ios/BleClient.xcodeproj/project.pbxproj
@@ -0,0 +1,312 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ D73F06EC1D48E17B00AD5963 /* BleClient.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = D73F06EB1D48E17B00AD5963 /* BleClient.h */; };
+ D73F06EE1D48E17B00AD5963 /* BleClient.m in Sources */ = {isa = PBXBuildFile; fileRef = D73F06ED1D48E17B00AD5963 /* BleClient.m */; };
+ D73F07961D48FB8600AD5963 /* BleClientManager.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73F07931D48FB5400AD5963 /* BleClientManager.framework */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXContainerItemProxy section */
+ D73F07921D48FB5400AD5963 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = D73F078E1D48FB5400AD5963 /* BleClientManager.xcodeproj */;
+ proxyType = 2;
+ remoteGlobalIDString = D73F06FE1D48E5BB00AD5963;
+ remoteInfo = BleClientManager;
+ };
+ D73F07941D48FB8000AD5963 /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = D73F078E1D48FB5400AD5963 /* BleClientManager.xcodeproj */;
+ proxyType = 1;
+ remoteGlobalIDString = D73F06FD1D48E5BB00AD5963;
+ remoteInfo = BleClientManager;
+ };
+/* End PBXContainerItemProxy section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ D73F06E61D48E17B00AD5963 /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = "include/$(PRODUCT_NAME)";
+ dstSubfolderSpec = 16;
+ files = (
+ D73F06EC1D48E17B00AD5963 /* BleClient.h in CopyFiles */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ D73F06E81D48E17B00AD5963 /* libBleClient.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libBleClient.a; sourceTree = BUILT_PRODUCTS_DIR; };
+ D73F06EB1D48E17B00AD5963 /* BleClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BleClient.h; sourceTree = ""; };
+ D73F06ED1D48E17B00AD5963 /* BleClient.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BleClient.m; sourceTree = ""; };
+ D73F078E1D48FB5400AD5963 /* BleClientManager.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = BleClientManager.xcodeproj; path = BleClientManager/BleClientManager.xcodeproj; sourceTree = ""; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ D73F06E51D48E17B00AD5963 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D73F07961D48FB8600AD5963 /* BleClientManager.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ D73F06DF1D48E17B00AD5963 = {
+ isa = PBXGroup;
+ children = (
+ D73F078E1D48FB5400AD5963 /* BleClientManager.xcodeproj */,
+ D73F06EA1D48E17B00AD5963 /* BleClient */,
+ D73F06E91D48E17B00AD5963 /* Products */,
+ );
+ sourceTree = "";
+ };
+ D73F06E91D48E17B00AD5963 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ D73F06E81D48E17B00AD5963 /* libBleClient.a */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+ D73F06EA1D48E17B00AD5963 /* BleClient */ = {
+ isa = PBXGroup;
+ children = (
+ D73F06EB1D48E17B00AD5963 /* BleClient.h */,
+ D73F06ED1D48E17B00AD5963 /* BleClient.m */,
+ );
+ path = BleClient;
+ sourceTree = "";
+ };
+ D73F078F1D48FB5400AD5963 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ D73F07931D48FB5400AD5963 /* BleClientManager.framework */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ D73F06E71D48E17B00AD5963 /* BleClient */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = D73F06F11D48E17B00AD5963 /* Build configuration list for PBXNativeTarget "BleClient" */;
+ buildPhases = (
+ D73F06E41D48E17B00AD5963 /* Sources */,
+ D73F06E51D48E17B00AD5963 /* Frameworks */,
+ D73F06E61D48E17B00AD5963 /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ D73F07951D48FB8000AD5963 /* PBXTargetDependency */,
+ );
+ name = BleClient;
+ productName = BleClient;
+ productReference = D73F06E81D48E17B00AD5963 /* libBleClient.a */;
+ productType = "com.apple.product-type.library.static";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ D73F06E01D48E17B00AD5963 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0730;
+ ORGANIZATIONNAME = Polidea;
+ TargetAttributes = {
+ D73F06E71D48E17B00AD5963 = {
+ CreatedOnToolsVersion = 7.3;
+ };
+ };
+ };
+ buildConfigurationList = D73F06E31D48E17B00AD5963 /* Build configuration list for PBXProject "BleClient" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = D73F06DF1D48E17B00AD5963;
+ productRefGroup = D73F06E91D48E17B00AD5963 /* Products */;
+ projectDirPath = "";
+ projectReferences = (
+ {
+ ProductGroup = D73F078F1D48FB5400AD5963 /* Products */;
+ ProjectRef = D73F078E1D48FB5400AD5963 /* BleClientManager.xcodeproj */;
+ },
+ );
+ projectRoot = "";
+ targets = (
+ D73F06E71D48E17B00AD5963 /* BleClient */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXReferenceProxy section */
+ D73F07931D48FB5400AD5963 /* BleClientManager.framework */ = {
+ isa = PBXReferenceProxy;
+ fileType = wrapper.framework;
+ path = BleClientManager.framework;
+ remoteRef = D73F07921D48FB5400AD5963 /* PBXContainerItemProxy */;
+ sourceTree = BUILT_PRODUCTS_DIR;
+ };
+/* End PBXReferenceProxy section */
+
+/* Begin PBXSourcesBuildPhase section */
+ D73F06E41D48E17B00AD5963 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D73F06EE1D48E17B00AD5963 /* BleClient.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXTargetDependency section */
+ D73F07951D48FB8000AD5963 /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ name = BleClientManager;
+ targetProxy = D73F07941D48FB8000AD5963 /* PBXContainerItemProxy */;
+ };
+/* End PBXTargetDependency section */
+
+/* Begin XCBuildConfiguration section */
+ D73F06EF1D48E17B00AD5963 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 9.3;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ D73F06F01D48E17B00AD5963 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 9.3;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = iphoneos;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ D73F06F21D48E17B00AD5963 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ HEADER_SEARCH_PATHS = "$(SRCROOT)/../react-native/React/**";
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ };
+ name = Debug;
+ };
+ D73F06F31D48E17B00AD5963 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ HEADER_SEARCH_PATHS = "$(SRCROOT)/../react-native/React/**";
+ OTHER_LDFLAGS = "-ObjC";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ D73F06E31D48E17B00AD5963 /* Build configuration list for PBXProject "BleClient" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ D73F06EF1D48E17B00AD5963 /* Debug */,
+ D73F06F01D48E17B00AD5963 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ D73F06F11D48E17B00AD5963 /* Build configuration list for PBXNativeTarget "BleClient" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ D73F06F21D48E17B00AD5963 /* Debug */,
+ D73F06F31D48E17B00AD5963 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = D73F06E01D48E17B00AD5963 /* Project object */;
+}
diff --git a/ios/BleClientManager/BleClientManager.h b/ios/BleClientManager/BleClientManager.h
new file mode 100644
index 00000000..b33b5a66
--- /dev/null
+++ b/ios/BleClientManager/BleClientManager.h
@@ -0,0 +1,19 @@
+//
+// BleClientManager.h
+// BleClientManager
+//
+// Created by Przemysław Lenart on 27/07/16.
+// Copyright © 2016 Polidea. All rights reserved.
+//
+
+#import
+
+//! Project version number for BleClientManager.
+FOUNDATION_EXPORT double BleClientManagerVersionNumber;
+
+//! Project version string for BleClientManager.
+FOUNDATION_EXPORT const unsigned char BleClientManagerVersionString[];
+
+// In this header, you should import all the public headers of your framework using statements like #import
+
+
diff --git a/ios/BleClientManager/BleClientManager.xcodeproj/project.pbxproj b/ios/BleClientManager/BleClientManager.xcodeproj/project.pbxproj
new file mode 100644
index 00000000..8749b0b0
--- /dev/null
+++ b/ios/BleClientManager/BleClientManager.xcodeproj/project.pbxproj
@@ -0,0 +1,344 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ D73F07A51D49033A00AD5963 /* BleClientManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D73F07A41D49033A00AD5963 /* BleClientManager.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ D73F07B11D49037B00AD5963 /* BleModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = D73F07AC1D49037B00AD5963 /* BleModule.swift */; };
+ D73F07B21D49037B00AD5963 /* BleError.swift in Sources */ = {isa = PBXBuildFile; fileRef = D73F07AD1D49037B00AD5963 /* BleError.swift */; };
+ D73F07B31D49037B00AD5963 /* BleUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = D73F07AE1D49037B00AD5963 /* BleUtils.swift */; };
+ D73F07B51D49037B00AD5963 /* BleEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D73F07B01D49037B00AD5963 /* BleEvent.swift */; };
+ D73F07CF1D49083300AD5963 /* RxBluetoothKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73F07CE1D49083300AD5963 /* RxBluetoothKit.framework */; };
+ D73F07D11D49083900AD5963 /* RxSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73F07D01D49083900AD5963 /* RxSwift.framework */; };
+ D73F07EB1D49F71000AD5963 /* RxCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73F07EA1D49F71000AD5963 /* RxCocoa.framework */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ D73F07A11D49033A00AD5963 /* BleClientManager.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = BleClientManager.framework; sourceTree = BUILT_PRODUCTS_DIR; };
+ D73F07A41D49033A00AD5963 /* BleClientManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BleClientManager.h; sourceTree = ""; };
+ D73F07A61D49033A00AD5963 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
+ D73F07AC1D49037B00AD5963 /* BleModule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BleModule.swift; sourceTree = ""; };
+ D73F07AD1D49037B00AD5963 /* BleError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BleError.swift; sourceTree = ""; };
+ D73F07AE1D49037B00AD5963 /* BleUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BleUtils.swift; sourceTree = ""; };
+ D73F07B01D49037B00AD5963 /* BleEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BleEvent.swift; sourceTree = ""; };
+ D73F07CE1D49083300AD5963 /* RxBluetoothKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxBluetoothKit.framework; path = Carthage/Build/iOS/RxBluetoothKit.framework; sourceTree = ""; };
+ D73F07D01D49083900AD5963 /* RxSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxSwift.framework; path = Carthage/Build/iOS/RxSwift.framework; sourceTree = ""; };
+ D73F07EA1D49F71000AD5963 /* RxCocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RxCocoa.framework; path = Carthage/Build/iOS/RxCocoa.framework; sourceTree = ""; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ D73F079D1D49033A00AD5963 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D73F07CF1D49083300AD5963 /* RxBluetoothKit.framework in Frameworks */,
+ D73F07EB1D49F71000AD5963 /* RxCocoa.framework in Frameworks */,
+ D73F07D11D49083900AD5963 /* RxSwift.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ D73F07971D49033A00AD5963 = {
+ isa = PBXGroup;
+ children = (
+ D73F07EA1D49F71000AD5963 /* RxCocoa.framework */,
+ D73F07D01D49083900AD5963 /* RxSwift.framework */,
+ D73F07CE1D49083300AD5963 /* RxBluetoothKit.framework */,
+ D73F07A31D49033A00AD5963 /* BleClientManager */,
+ D73F07A21D49033A00AD5963 /* Products */,
+ );
+ sourceTree = "";
+ };
+ D73F07A21D49033A00AD5963 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ D73F07A11D49033A00AD5963 /* BleClientManager.framework */,
+ );
+ name = Products;
+ sourceTree = "";
+ };
+ D73F07A31D49033A00AD5963 /* BleClientManager */ = {
+ isa = PBXGroup;
+ children = (
+ D73F07AC1D49037B00AD5963 /* BleModule.swift */,
+ D73F07AD1D49037B00AD5963 /* BleError.swift */,
+ D73F07AE1D49037B00AD5963 /* BleUtils.swift */,
+ D73F07B01D49037B00AD5963 /* BleEvent.swift */,
+ D73F07A41D49033A00AD5963 /* BleClientManager.h */,
+ D73F07A61D49033A00AD5963 /* Info.plist */,
+ );
+ path = BleClientManager;
+ sourceTree = "";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXHeadersBuildPhase section */
+ D73F079E1D49033A00AD5963 /* Headers */ = {
+ isa = PBXHeadersBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D73F07A51D49033A00AD5963 /* BleClientManager.h in Headers */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXHeadersBuildPhase section */
+
+/* Begin PBXNativeTarget section */
+ D73F07A01D49033A00AD5963 /* BleClientManager */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = D73F07A91D49033A00AD5963 /* Build configuration list for PBXNativeTarget "BleClientManager" */;
+ buildPhases = (
+ D73F079C1D49033A00AD5963 /* Sources */,
+ D73F079D1D49033A00AD5963 /* Frameworks */,
+ D73F079E1D49033A00AD5963 /* Headers */,
+ D73F079F1D49033A00AD5963 /* Resources */,
+ D73F07DD1D4908E100AD5963 /* ShellScript */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = BleClientManager;
+ productName = BleClientManager;
+ productReference = D73F07A11D49033A00AD5963 /* BleClientManager.framework */;
+ productType = "com.apple.product-type.framework";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ D73F07981D49033A00AD5963 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0730;
+ ORGANIZATIONNAME = Polidea;
+ TargetAttributes = {
+ D73F07A01D49033A00AD5963 = {
+ CreatedOnToolsVersion = 7.3;
+ };
+ };
+ };
+ buildConfigurationList = D73F079B1D49033A00AD5963 /* Build configuration list for PBXProject "BleClientManager" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = D73F07971D49033A00AD5963;
+ productRefGroup = D73F07A21D49033A00AD5963 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ D73F07A01D49033A00AD5963 /* BleClientManager */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ D73F079F1D49033A00AD5963 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXShellScriptBuildPhase section */
+ D73F07DD1D4908E100AD5963 /* ShellScript */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ "$(SRCROOT)/Carthage/Build/iOS/RxBluetoothKit.framework",
+ "$(SRCROOT)/Carthage/Build/iOS/RxSwift.framework",
+ );
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "/usr/local/bin/carthage copy-frameworks";
+ };
+/* End PBXShellScriptBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ D73F079C1D49033A00AD5963 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ D73F07B51D49037B00AD5963 /* BleEvent.swift in Sources */,
+ D73F07B21D49037B00AD5963 /* BleError.swift in Sources */,
+ D73F07B31D49037B00AD5963 /* BleUtils.swift in Sources */,
+ D73F07B11D49037B00AD5963 /* BleModule.swift in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ D73F07A71D49033A00AD5963 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ CURRENT_PROJECT_VERSION = 1;
+ DEBUG_INFORMATION_FORMAT = dwarf;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ ENABLE_TESTABILITY = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 9.3;
+ MTL_ENABLE_DEBUG_INFO = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ SDKROOT = iphoneos;
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ TARGETED_DEVICE_FAMILY = "1,2";
+ VERSIONING_SYSTEM = "apple-generic";
+ VERSION_INFO_PREFIX = "";
+ };
+ name = Debug;
+ };
+ D73F07A81D49033A00AD5963 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_ANALYZER_NONNULL = YES;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_MODULES = YES;
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN_UNREACHABLE_CODE = YES;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ CURRENT_PROJECT_VERSION = 1;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ ENABLE_NS_ASSERTIONS = NO;
+ ENABLE_STRICT_OBJC_MSGSEND = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_NO_COMMON_BLOCKS = YES;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 9.3;
+ MTL_ENABLE_DEBUG_INFO = NO;
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ VALIDATE_PRODUCT = YES;
+ VERSIONING_SYSTEM = "apple-generic";
+ VERSION_INFO_PREFIX = "";
+ };
+ name = Release;
+ };
+ D73F07AA1D49033A00AD5963 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CLANG_ENABLE_MODULES = YES;
+ DEFINES_MODULE = YES;
+ DYLIB_COMPATIBILITY_VERSION = 1;
+ DYLIB_CURRENT_VERSION = 1;
+ DYLIB_INSTALL_NAME_BASE = "@rpath";
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "$(PROJECT_DIR)/Carthage/Build/iOS",
+ );
+ INFOPLIST_FILE = BleClientManager/Info.plist;
+ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.polidea.BleClientManager;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ SWIFT_OPTIMIZATION_LEVEL = "-Onone";
+ };
+ name = Debug;
+ };
+ D73F07AB1D49033A00AD5963 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CLANG_ENABLE_MODULES = YES;
+ DEFINES_MODULE = YES;
+ DYLIB_COMPATIBILITY_VERSION = 1;
+ DYLIB_CURRENT_VERSION = 1;
+ DYLIB_INSTALL_NAME_BASE = "@rpath";
+ FRAMEWORK_SEARCH_PATHS = (
+ "$(inherited)",
+ "$(PROJECT_DIR)/Carthage/Build/iOS",
+ );
+ INFOPLIST_FILE = BleClientManager/Info.plist;
+ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
+ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
+ PRODUCT_BUNDLE_IDENTIFIER = com.polidea.BleClientManager;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ SKIP_INSTALL = YES;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ D73F079B1D49033A00AD5963 /* Build configuration list for PBXProject "BleClientManager" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ D73F07A71D49033A00AD5963 /* Debug */,
+ D73F07A81D49033A00AD5963 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ D73F07A91D49033A00AD5963 /* Build configuration list for PBXNativeTarget "BleClientManager" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ D73F07AA1D49033A00AD5963 /* Debug */,
+ D73F07AB1D49033A00AD5963 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = D73F07981D49033A00AD5963 /* Project object */;
+}
diff --git a/ios/BleError.swift b/ios/BleClientManager/BleError.swift
similarity index 98%
rename from ios/BleError.swift
rename to ios/BleClientManager/BleError.swift
index 7ac14791..e58fa1aa 100644
--- a/ios/BleError.swift
+++ b/ios/BleClientManager/BleError.swift
@@ -20,7 +20,7 @@ extension BleError {
var toJS: AnyObject {
return ["name": "BleClientModule", "code": code, "message": message]
}
- func callReject(reject: RCTPromiseRejectBlock) {
+ func callReject(reject: Reject) {
reject("\(self.code)", self.message, nil)
}
}
diff --git a/ios/BleEvent.swift b/ios/BleClientManager/BleEvent.swift
similarity index 100%
rename from ios/BleEvent.swift
rename to ios/BleClientManager/BleEvent.swift
diff --git a/ios/BleClientManager/BleModule.swift b/ios/BleClientManager/BleModule.swift
new file mode 100644
index 00000000..3d4a03f5
--- /dev/null
+++ b/ios/BleClientManager/BleModule.swift
@@ -0,0 +1,288 @@
+//
+// BleModule.swift
+// EmptyProject
+//
+// Created by Konrad Rodzik on 7/4/16.
+//
+
+import Foundation
+import CoreBluetooth
+import RxBluetoothKit
+import RxSwift
+
+@objc
+public protocol BleClientManagerDelegate {
+ func dispatchEvent(name: String, value: AnyObject)
+}
+
+@objc
+public class BleClientManager : NSObject {
+
+ private let manager : BluetoothManager
+ public var delegate: BleClientManagerDelegate?
+ private var connectedDevices = Dictionary()
+
+ // Disposables
+ private var scanSubscription = SerialDisposable()
+ private var connectingDevices = DisposableMap()
+ private var operationsInProgress = DisposableMap()
+
+ // MARK: Public interface
+
+ // Lifecycle -------------------------------
+
+ public init(queue: dispatch_queue_t) {
+ manager = BluetoothManager(queue: queue)
+ }
+
+ deinit {
+ scanSubscription.disposable = NopDisposable.instance
+ }
+
+ // Discovery --------------------------------
+
+ public func scanBleDevices(filteredUUIDs: [String]?) {
+ var uuids: [CBUUID]? = nil
+ if let filteredUUIDs = filteredUUIDs {
+ guard let cbuuids = filteredUUIDs.toCBUUIDS() else {
+ self.dispatchEvent(.scan, value: BleError.invalidUUIDs(filteredUUIDs).toJSResult)
+ return
+ }
+ uuids = cbuuids
+ }
+
+ scanSubscription.disposable = manager.rx_state
+ .filter { $0 == .PoweredOn }
+ .take(1)
+ .flatMap { _ in self.manager.scanForPeripherals(uuids) }
+ .subscribe(onNext: { scannedPeripheral in
+ let peripheral = [
+ "uuid": scannedPeripheral.peripheral.identifier.UUIDString,
+ "name": scannedPeripheral.advertisementData.localName ?? NSNull(),
+ "rssi": scannedPeripheral.RSSI
+ ]
+ self.dispatchEvent(.scan, value: [NSNull(), peripheral])
+ }, onError: { errorType in
+ self.dispatchEvent(.scan, value: errorType.bleError.toJSResult)
+ })
+ }
+
+ public func stopScanBleDevices() {
+ scanSubscription.disposable = NopDisposable.instance
+ }
+
+ // Connections state --------------------------------
+
+ public func establishConnection(deviceIdentifier: String, resolve: Resolve, reject: Reject) {
+
+ var peripheral: Peripheral? = nil
+ guard let nsuuid = NSUUID(UUIDString: deviceIdentifier) else {
+ BleError.invalidUUID(deviceIdentifier).callReject(reject)
+ return
+ }
+
+ let connectionDisp = manager.retrievePeripheralsWithIdentifiers([nsuuid])
+ .flatMap { devices -> Observable in
+ guard let device = devices.first else {
+ return Observable.error(BleError.peripheralNotFound(deviceIdentifier))
+ }
+ return Observable.just(device)
+ }
+ .flatMap { $0.connect() }
+ .doOnNext { peripheral = $0 }
+ .flatMap { Observable.from($0.discoverServices(nil)) }
+ .flatMap { Observable.from($0.discoverCharacteristics(nil))}
+ .subscribe(
+ onNext: nil,
+ onError: { error in
+ peripheral?.cancelConnection()
+ error.bleError.callReject(reject)
+ },
+ onCompleted: {
+ self.connectedDevices[deviceIdentifier] = peripheral
+ resolve(deviceIdentifier)
+ },
+ onDisposed: {
+ self.connectingDevices.removeDisposable(deviceIdentifier)
+ }
+ );
+
+ connectingDevices.replaceDisposable(deviceIdentifier, disposable: connectionDisp)
+ }
+
+ public func closeConnection(deviceIdentifier: String, resolve: Resolve, reject: Reject) {
+ if let device = connectedDevices[deviceIdentifier] {
+ _ = device.cancelConnection()
+ .subscribe(
+ onNext: nil,
+ onError: { error in
+ error.bleError.callReject(reject)
+ },
+ onCompleted: {
+ resolve(deviceIdentifier)
+ },
+ onDisposed: {
+ self.connectedDevices[deviceIdentifier] = nil
+ }
+ );
+ } else {
+ connectingDevices.removeDisposable(deviceIdentifier)
+ }
+ }
+
+ // Services and characteristics -----------------------------------
+
+ public func serviceIdsForDevice(deviceIdentifier: String, resolve: Resolve, reject: Reject) {
+ guard let device = connectedDevices[deviceIdentifier] else {
+ BleError.peripheralNotConnected(deviceIdentifier).callReject(reject)
+ return
+ }
+
+ let serviceUUIDs = device.services?.map { $0.UUID.UUIDString } ?? []
+ resolve(serviceUUIDs)
+ }
+
+ public func characteristicIdsForDevice(deviceIdentifier: String,
+ serviceIdentifier: String,
+ resolve: Resolve,
+ reject: Reject) {
+ guard let device = connectedDevices[deviceIdentifier] else {
+ BleError.peripheralNotConnected(deviceIdentifier).callReject(reject)
+ return
+ }
+
+ let serviceUUIDs = device.services?.filter {
+ serviceIdentifier.caseInsensitiveCompare($0.UUID.UUIDString) == .OrderedSame
+ } ?? []
+
+ let characteristicsUUIDs = serviceUUIDs
+ .flatMap { $0.characteristics ?? [] }
+ .map { $0.UUID.UUIDString }
+
+ resolve(characteristicsUUIDs)
+ }
+
+ public func detailsForCharacteristic(deviceIdentifier: String,
+ serviceIdentifier: String,
+ characteristicIdentifier: String,
+ resolve: Resolve,
+ reject: Reject) {
+
+ guard let device = connectedDevices[deviceIdentifier] else {
+ BleError.peripheralNotConnected(deviceIdentifier).callReject(reject)
+ return
+ }
+
+ let service = device.services?.filter {
+ serviceIdentifier.caseInsensitiveCompare($0.UUID.UUIDString) == .OrderedSame
+ }.first
+
+ guard let characteristic = (service?.characteristics?
+ .filter { characteristicIdentifier.caseInsensitiveCompare($0.UUID.UUIDString) == .OrderedSame }
+ .first)
+ else {
+ BleError.characteristicNotFound(characteristicIdentifier).callReject(reject)
+ return
+ }
+
+ var result = Dictionary()
+ result["isWritable"] = characteristic.properties.contains(.Write)
+ result["isReadable"] = characteristic.properties.contains(.Read)
+ result["isNotifiable"] = characteristic.properties.contains(.Notify)
+ result["uuid"] = characteristic.UUID.UUIDString
+
+ resolve(result)
+ }
+
+ public func writeCharacteristic(deviceIdentifier: String,
+ serviceIdentifier: String,
+ characteristicIdentifier: String,
+ valueBase64: String,
+ transactionId: String,
+ resolve: Resolve,
+ reject: Reject) {
+
+ let writeDisp = characteristicObservable(deviceIdentifier,
+ serviceIdentifier: serviceIdentifier,
+ characteristicIdentifier: characteristicIdentifier)
+ .flatMap { characteristic -> Observable in
+ guard let data = NSData(base64EncodedString: valueBase64, options: .IgnoreUnknownCharacters) else {
+ return Observable.error(BleError.invalidWriteDataForCharacteristic(characteristicIdentifier, data: valueBase64))
+ }
+ return characteristic.writeValue(data, type: .WithResponse)
+ }
+ .subscribe(
+ onNext: nil,
+ onError: { error in
+ error.bleError.callReject(reject)
+ },
+ onCompleted: {
+ resolve(valueBase64)
+ },
+ onDisposed: {
+ self.operationsInProgress.removeDisposable(transactionId)
+ })
+
+ operationsInProgress.replaceDisposable(transactionId, disposable: writeDisp)
+ }
+
+ public func readCharacteristic(deviceIdentifier: String,
+ serviceIdentifier: String,
+ characteristicIdentifier: String,
+ transactionId: String,
+ resolve: Resolve,
+ reject: Reject) {
+
+ var valueBase64: String?
+ let readDisp = characteristicObservable(deviceIdentifier,
+ serviceIdentifier: serviceIdentifier,
+ characteristicIdentifier: characteristicIdentifier)
+ .flatMap { $0.readValue() }
+ .subscribe(
+ onNext: { characteristic in
+ valueBase64 = characteristic.value?.base64EncodedStringWithOptions(.EncodingEndLineWithCarriageReturn)
+ },
+ onError: { error in
+ error.bleError.callReject(reject)
+ },
+ onCompleted: {
+ resolve(valueBase64 ?? "")
+ },
+ onDisposed: {
+ self.operationsInProgress.removeDisposable(transactionId)
+ })
+
+ operationsInProgress.replaceDisposable(transactionId, disposable: readDisp)
+ }
+
+ public func cancelCharacteristicOperation(transactionId: String) {
+ operationsInProgress.removeDisposable(transactionId)
+ }
+
+ // MARK: Private interface ------------------------------------------------------------------------------------------
+
+ private func dispatchEvent(event: BleEvent, value: AnyObject) {
+ delegate?.dispatchEvent(event.id, value: value)
+ }
+
+ private func characteristicObservable(deviceIdentifier: String,
+ serviceIdentifier: String,
+ characteristicIdentifier: String) -> Observable {
+ return Observable.deferred {
+ guard let device = self.connectedDevices[deviceIdentifier] else {
+ return Observable.error(BleError.peripheralNotConnected(deviceIdentifier))
+ }
+
+ let characteristics = device.services?
+ .filter { serviceIdentifier.caseInsensitiveCompare($0.UUID.UUIDString) == .OrderedSame }
+ .flatMap { $0.characteristics ?? [] }
+ .filter { characteristicIdentifier.caseInsensitiveCompare($0.UUID.UUIDString) == .OrderedSame } ?? []
+
+ if characteristics.isEmpty {
+ return Observable.error(BleError.characteristicNotFound(characteristicIdentifier))
+ }
+
+ return Observable.from(Observable.just(characteristics))
+ }
+ }
+}
\ No newline at end of file
diff --git a/ios/BleUtils.swift b/ios/BleClientManager/BleUtils.swift
similarity index 87%
rename from ios/BleUtils.swift
rename to ios/BleClientManager/BleUtils.swift
index 6274d94d..ef866088 100644
--- a/ios/BleUtils.swift
+++ b/ios/BleClientManager/BleUtils.swift
@@ -9,6 +9,9 @@ import Foundation
import RxSwift
import CoreBluetooth
+public typealias Resolve = AnyObject? -> ()
+public typealias Reject = (NSString?, NSString?, NSError?) -> ()
+
class DisposableMap {
private var disposables = Dictionary()
diff --git a/ios/BleClientManager/Cartfile b/ios/BleClientManager/Cartfile
new file mode 100644
index 00000000..3581cbdb
--- /dev/null
+++ b/ios/BleClientManager/Cartfile
@@ -0,0 +1 @@
+github "Polidea/RxBluetoothKit"
diff --git a/ios/BleClientManager/Info.plist b/ios/BleClientManager/Info.plist
new file mode 100644
index 00000000..d3de8eef
--- /dev/null
+++ b/ios/BleClientManager/Info.plist
@@ -0,0 +1,26 @@
+
+
+
+
+ CFBundleDevelopmentRegion
+ en
+ CFBundleExecutable
+ $(EXECUTABLE_NAME)
+ CFBundleIdentifier
+ $(PRODUCT_BUNDLE_IDENTIFIER)
+ CFBundleInfoDictionaryVersion
+ 6.0
+ CFBundleName
+ $(PRODUCT_NAME)
+ CFBundlePackageType
+ FMWK
+ CFBundleShortVersionString
+ 1.0
+ CFBundleSignature
+ ????
+ CFBundleVersion
+ $(CURRENT_PROJECT_VERSION)
+ NSPrincipalClass
+
+
+
diff --git a/ios/BleModule.swift b/ios/BleModule.swift
deleted file mode 100644
index 766b3cbf..00000000
--- a/ios/BleModule.swift
+++ /dev/null
@@ -1,331 +0,0 @@
-//
-// BleModule.swift
-// EmptyProject
-//
-// Created by Konrad Rodzik on 7/4/16.
-//
-
-import Foundation
-import CoreBluetooth
-import RxBluetoothKit
-import RxSwift
-
-@objc(BleClientManager)
-class BleClientManager : RCTEventEmitter {
-
- private var manager : BluetoothManager!
- private var connectedDevices = Dictionary()
-
- // TODO: add timeout mechanism
-
- // Disposables
- private var scanSubscription = SerialDisposable()
- private var connectingDevices = DisposableMap()
- private var operationsInProgress = DisposableMap()
-
- // MARK: Public interface
-
- // React functions --------------------------
-
- /// Module name
- override class func moduleName() -> String {
- return "BleClientManager"
- }
-
- /// Global variables visible by user of BLE module
- override func constantsToExport() -> [String : AnyObject]! {
- var dictionary = [String:AnyObject]()
- for event in BleEvent.supportedEvents {
- dictionary[event.name] = event.id
- }
- return dictionary
- }
-
- /// List of all supported events to which user can register
- override func supportedEvents() -> [String]! {
- return BleEvent.supportedEvents.map { $0.id }
- }
-
- // Initialization ---------------------------
-
- @objc
- func createClient() {
- manager = BluetoothManager(queue: dispatch_get_main_queue())
- }
-
- @objc
- func destroyClient() {
- scanSubscription.disposable = NopDisposable.instance
- manager = nil
- }
-
- // Event observations -----------------------
-
- override func startObserving() {
- print("Start Observing")
- }
-
- override func stopObserving() {
- print("Stop Observing")
- }
-
- // Discovery --------------------------------
-
- @objc
- func scanBleDevices(filteredUUIDs: [String]?) {
- // TODO: check if ble client is already initialized
-
- var uuids: [CBUUID]? = nil
- if let filteredUUIDs = filteredUUIDs {
- guard let cbuuids = filteredUUIDs.toCBUUIDS() else {
- self.dispatchEvent(.scan, value: [BleError.invalidUUIDs(filteredUUIDs).toJSResult, NSNull()])
- return
- }
- uuids = cbuuids
- }
-
- scanSubscription.disposable = manager.rx_state
- .filter { $0 == .PoweredOn }
- .take(1)
- .flatMap { _ in self.manager.scanForPeripherals(uuids) }
- .subscribe(onNext: { scannedPeripheral in
- let peripheral = [
- "uuid": scannedPeripheral.peripheral.identifier.UUIDString,
- "name": scannedPeripheral.advertisementData.localName ?? NSNull(),
- "rssi": scannedPeripheral.RSSI
- ]
- self.dispatchEvent(.scan, value: [NSNull(), peripheral])
- }, onError: { errorType in
- self.dispatchEvent(.scan, value: errorType.bleError.toJSResult)
- })
- }
-
- @objc
- func stopScanBleDevices() {
- scanSubscription.disposable = NopDisposable.instance
- }
-
- // Connections state --------------------------------
-
- @objc
- func establishConnection(deviceIdentifier: String,
- resolver resolve: RCTPromiseResolveBlock,
- rejecter reject: RCTPromiseRejectBlock) {
-
- var peripheral: Peripheral? = nil
- guard let nsuuid = NSUUID(UUIDString: deviceIdentifier) else {
- BleError.invalidUUID(deviceIdentifier).callReject(reject)
- return
- }
-
- let connectionDisp = manager.retrievePeripheralsWithIdentifiers([nsuuid])
- .flatMap { devices -> Observable in
- guard let device = devices.first else {
- return Observable.error(BleError.peripheralNotFound(deviceIdentifier))
- }
- return Observable.just(device)
- }
- .flatMap { $0.connect() }
- .doOnNext { peripheral = $0 }
- .flatMap { Observable.from($0.discoverServices(nil)) }
- .flatMap { Observable.from($0.discoverCharacteristics(nil))}
- .subscribe(
- onNext: nil,
- onError: { error in
- peripheral?.cancelConnection()
- error.bleError.callReject(reject)
- },
- onCompleted: {
- self.connectedDevices[deviceIdentifier] = peripheral
- resolve(deviceIdentifier)
- },
- onDisposed: {
- self.connectingDevices.removeDisposable(deviceIdentifier)
- }
- );
-
- connectingDevices.replaceDisposable(deviceIdentifier, disposable: connectionDisp)
- }
-
- @objc
- func closeConnection(deviceIdentifier: String,
- resolver resolve: RCTPromiseResolveBlock,
- rejecter reject: RCTPromiseRejectBlock) {
- if let device = connectedDevices[deviceIdentifier] {
- _ = device.cancelConnection()
- .subscribe(
- onNext: nil,
- onError: { error in
- error.bleError.callReject(reject)
- },
- onCompleted: {
- resolve(deviceIdentifier)
- },
- onDisposed: {
- self.connectedDevices[deviceIdentifier] = nil
- }
- );
- } else {
- connectingDevices.removeDisposable(deviceIdentifier)
- }
- }
-
- // Services and characteristics -----------------------------------
-
- @objc
- func serviceIdsForDevice(deviceIdentifier: String,
- resolver resolve: RCTPromiseResolveBlock,
- rejecter reject: RCTPromiseRejectBlock) {
- guard let device = connectedDevices[deviceIdentifier] else {
- BleError.peripheralNotConnected(deviceIdentifier).callReject(reject)
- return
- }
-
- let serviceUUIDs = device.services?.map { $0.UUID.UUIDString } ?? []
- resolve(serviceUUIDs)
- }
-
- @objc
- func characteristicIdsForDevice(deviceIdentifier: String,
- serviceIdentifier: String,
- resolver resolve: RCTPromiseResolveBlock,
- rejecter reject: RCTPromiseRejectBlock) {
- guard let device = connectedDevices[deviceIdentifier] else {
- BleError.peripheralNotConnected(deviceIdentifier).callReject(reject)
- return
- }
-
- let serviceUUIDs = device.services?.filter {
- serviceIdentifier.caseInsensitiveCompare($0.UUID.UUIDString) == .OrderedSame
- } ?? []
-
- let characteristicsUUIDs = serviceUUIDs
- .flatMap { $0.characteristics ?? [] }
- .map { $0.UUID.UUIDString }
-
- resolve(characteristicsUUIDs)
- }
-
- @objc
- func detailsForCharacteristic(deviceIdentifier: String,
- serviceIdentifier: String,
- characteristicIdentifier: String,
- resolver resolve: RCTPromiseResolveBlock,
- rejecter reject: RCTPromiseRejectBlock) {
-
- guard let device = connectedDevices[deviceIdentifier] else {
- BleError.peripheralNotConnected(deviceIdentifier).callReject(reject)
- return
- }
-
- let service = device.services?.filter {
- serviceIdentifier.caseInsensitiveCompare($0.UUID.UUIDString) == .OrderedSame
- }.first
-
- guard let characteristic = (service?.characteristics?
- .filter { characteristicIdentifier.caseInsensitiveCompare($0.UUID.UUIDString) == .OrderedSame }
- .first)
- else {
- BleError.characteristicNotFound(characteristicIdentifier).callReject(reject)
- return
- }
-
- var result = Dictionary()
- result["isWritable"] = characteristic.properties.contains(.Write)
- result["isReadable"] = characteristic.properties.contains(.Read)
- result["isNotifiable"] = characteristic.properties.contains(.Notify)
- result["uuid"] = characteristic.UUID.UUIDString
-
- resolve(result)
- }
-
- @objc
- func writeCharacteristic(deviceIdentifier: String,
- serviceIdentifier: String,
- characteristicIdentifier: String,
- valueBase64: String,
- transactionId: String,
- resolver resolve: RCTPromiseResolveBlock,
- rejecter reject: RCTPromiseRejectBlock) {
-
- let writeDisp = characteristicObservable(deviceIdentifier,
- serviceIdentifier: serviceIdentifier,
- characteristicIdentifier: characteristicIdentifier)
- .flatMap { characteristic -> Observable in
- guard let data = NSData(base64EncodedString: valueBase64, options: .IgnoreUnknownCharacters) else {
- return Observable.error(BleError.invalidWriteDataForCharacteristic(characteristicIdentifier, data: valueBase64))
- }
- return characteristic.writeValue(data, type: .WithResponse)
- }
- .subscribe(
- onNext: nil,
- onError: { error in
- error.bleError.callReject(reject)
- },
- onCompleted: {
- resolve(valueBase64)
- },
- onDisposed: {
- self.operationsInProgress.removeDisposable(transactionId)
- })
-
- operationsInProgress.replaceDisposable(transactionId, disposable: writeDisp)
- }
-
- @objc
- func readCharacteristic(deviceIdentifier: String,
- serviceIdentifier: String,
- characteristicIdentifier: String,
- transactionId: String,
- resolver resolve: RCTPromiseResolveBlock,
- rejecter reject: RCTPromiseRejectBlock) {
-
- var valueBase64: String?
- let readDisp = characteristicObservable(deviceIdentifier,
- serviceIdentifier: serviceIdentifier,
- characteristicIdentifier: characteristicIdentifier)
- .flatMap { $0.readValue() }
- .subscribe(
- onNext: { characteristic in
- valueBase64 = characteristic.value?.base64EncodedStringWithOptions(.EncodingEndLineWithCarriageReturn)
- },
- onError: { error in
- error.bleError.callReject(reject)
- },
- onCompleted: {
- resolve(valueBase64 ?? "")
- },
- onDisposed: {
- self.operationsInProgress.removeDisposable(transactionId)
- })
-
- operationsInProgress.replaceDisposable(transactionId, disposable: readDisp)
- }
-
- // MARK: Private interface ------------------------------------------------------------------------------------------
-
- private func dispatchEvent(type: BleEvent, value: AnyObject) {
- sendEventWithName(type.id, body: value)
- }
-
- private func characteristicObservable(deviceIdentifier: String,
- serviceIdentifier: String,
- characteristicIdentifier: String) -> Observable {
- return Observable.deferred {
- guard let device = self.connectedDevices[deviceIdentifier] else {
- return Observable.error(BleError.peripheralNotConnected(deviceIdentifier))
- }
-
- let characteristics = device.services?
- .filter { serviceIdentifier.caseInsensitiveCompare($0.UUID.UUIDString) == .OrderedSame }
- .flatMap { $0.characteristics ?? [] }
- .filter { characteristicIdentifier.caseInsensitiveCompare($0.UUID.UUIDString) == .OrderedSame } ?? []
-
- if characteristics.isEmpty {
- return Observable.error(BleError.characteristicNotFound(characteristicIdentifier))
- }
-
- return Observable.from(Observable.just(characteristics))
- }
- }
-}
\ No newline at end of file
diff --git a/ios/BleModuleBridge.m b/ios/BleModuleBridge.m
deleted file mode 100644
index 1e18d46f..00000000
--- a/ios/BleModuleBridge.m
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-// BleModuleBridge.m
-// EmptyProject
-//
-// Created by Konrad Rodzik on 7/4/16.
-// Copyright © 2016 Facebook. All rights reserved.
-//
-
-#import
-
-#import "RCTBridgeModule.h"
-
-@interface RCT_EXTERN_MODULE(BleClientManager, NSObject)
-
-RCT_EXTERN_METHOD(createClient)
-RCT_EXTERN_METHOD(destroyClient)
-
-RCT_EXTERN_METHOD(scanBleDevices:(NSArray*)filteredUUIDs)
-RCT_EXTERN_METHOD(stopScanBleDevices)
-
-RCT_EXTERN_METHOD(establishConnection:(NSString*)deviceIdentifier
- resolver:(RCTPromiseResolveBlock)resolve
- rejecter:(RCTPromiseRejectBlock)reject)
-
-RCT_EXTERN_METHOD(closeConnection:(NSString*)deviceIdentifier
- resolver:(RCTPromiseResolveBlock)resolve
- rejecter:(RCTPromiseRejectBlock)reject)
-
-RCT_EXTERN_METHOD(serviceIdsForDevice:(NSString*)deviceIdentifier
- resolver:(RCTPromiseResolveBlock)resolve
- rejecter:(RCTPromiseRejectBlock)reject)
-
-RCT_EXTERN_METHOD(characteristicIdsForDevice:(NSString*)deviceIdentifier
- serviceIdentifier:(NSString*)serviceIdentifier
- resolver:(RCTPromiseResolveBlock)resolve
- rejecter:(RCTPromiseRejectBlock)reject)
-
-RCT_EXTERN_METHOD(detailsForCharacteristic:(NSString*)deviceIdentifier
- serviceIdentifier:(NSString*)serviceIdentifier
- characteristicIdentifier:(NSString*)characteristicIdentifier
- resolver:(RCTPromiseResolveBlock)resolve
- rejecter:(RCTPromiseRejectBlock)reject)
-
-RCT_EXTERN_METHOD( writeCharacteristic:(NSString*)deviceIdentifier
- serviceIdentifier:(NSString*)serviceIdentifier
- characteristicIdentifier:(NSString*)characteristicIdentifier
- valueBase64:(NSString*)valueBase64
- transactionId:(NSString*)transactionId
- resolver:(RCTPromiseResolveBlock)resolve
- rejecter:(RCTPromiseRejectBlock)reject)
-
-RCT_EXTERN_METHOD( readCharacteristic:(NSString*)deviceIdentifier
- serviceIdentifier:(NSString*)serviceIdentifier
- characteristicIdentifier:(NSString*)characteristicIdentifier
- transactionId:(NSString*)transactionId
- resolver:(RCTPromiseResolveBlock)resolve
- rejecter:(RCTPromiseRejectBlock)reject)
-
-RCT_EXTERN_METHOD(cancelCharacteristicOperation:(NSString*)transactionId)
-
-@end
\ No newline at end of file
diff --git a/ios/EmptyProject-Bridging-Header.h b/ios/EmptyProject-Bridging-Header.h
deleted file mode 100644
index 168c9901..00000000
--- a/ios/EmptyProject-Bridging-Header.h
+++ /dev/null
@@ -1,8 +0,0 @@
-//
-// Use this file to import your target's public headers that you would like to expose to Swift.
-//
-
-#import "RCTBridge.h"
-#import "RCTBridgeModule.h"
-#import "RCTEventDispatcher.h"
-#import "RCTEventEmitter.h"
\ No newline at end of file
diff --git a/ios/EmptyProject.xcworkspace/contents.xcworkspacedata b/ios/EmptyProject.xcworkspace/contents.xcworkspacedata
deleted file mode 100644
index 947b7e44..00000000
--- a/ios/EmptyProject.xcworkspace/contents.xcworkspacedata
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
diff --git a/ios/Podfile b/ios/Podfile
deleted file mode 100644
index e28d6466..00000000
--- a/ios/Podfile
+++ /dev/null
@@ -1,5 +0,0 @@
-target 'EmptyProject' do
- pod 'RxBluetoothKit'
-
- use_frameworks! //
-end
diff --git a/app/ble/BleManager.js b/src/BleManager.js
similarity index 77%
rename from app/ble/BleManager.js
rename to src/BleManager.js
index 5b87b254..5ce93539 100644
--- a/app/ble/BleManager.js
+++ b/src/BleManager.js
@@ -1,6 +1,6 @@
'use strict';
-import { NativeModules, NativeEventEmitter, DeviceEventEmitter, Platform} from 'react-native';
+import { NativeModules, NativeEventEmitter} from 'react-native';
const BleModule = NativeModules.BleClientManager;
export default class BleManager {
@@ -21,27 +21,15 @@ export default class BleManager {
const scanListener = ([error, scannedDevice]) => {
listener(error, scannedDevice)
};
-
- if(Platform.OS === 'ios') {
- this._scanEventSubscription = this.eventEmitter.addListener(BleModule.ScanEvent, scanListener);
- } else if(Platform.OS === 'android') {
- DeviceEventEmitter.addListener(BleModule.ScanEvent, (scannedDevice) => {
- listener(null, scannedDevice);
- });
- }
-
+ this._scanEventSubscription = this.eventEmitter.addListener(BleModule.ScanEvent, scanListener);
BleModule.scanBleDevices(uuids);
}
stopDeviceScan() {
console.log("Stop device scan");
- if(Platform.OS === 'ios') {
- if (this._scanEventSubscription) {
- this._scanEventSubscription.remove()
- delete this._scanEventSubscription
- }
- } else if(Platform.OS === 'android') {
- DeviceEventEmitter.removeListener(BleModule.ScanEvent);
+ if (this._scanEventSubscription) {
+ this._scanEventSubscription.remove()
+ delete this._scanEventSubscription
}
BleModule.stopScanBleDevices();
}
@@ -61,13 +49,23 @@ export default class BleManager {
}
async serviceIdsForDevice(deviceIdentifier) {
+ try {
var services = await BleModule.serviceIdsForDevice(deviceIdentifier);
return services;
+ } catch(e) {
+ console.log(e);
+ }
+ return nil;
}
async characteristicIdsForDevice(deviceIdentifier, serviceIdentifier) {
+ try {
var characteristics = await BleModule.characteristicIdsForDevice(deviceIdentifier, serviceIdentifier);
return characteristics;
+ } catch(e) {
+ console.log(e);
+ }
+ return nil;
}
async characteristicDetails(deviceIdentifier, serviceIdentifier, characteristicIdentifier) {