
# react-native-neurosdk

## Getting started

`$ npm install react-native-neurosdk --save`

### Mostly automatic installation

`$ react-native link react-native-neurosdk`

### Manual installation


#### iOS

1. In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
2. Go to `node_modules` ➜ `react-native-neurosdk` and add `RNNeurosdk.xcodeproj`
3. In XCode, in the project navigator, select your project. Add `libRNNeurosdk.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
4. Run your project (`Cmd+R`)<

#### Android

1. Open up `android/app/src/main/java/[...]/MainActivity.java`
  - Add `import com.reactlibrary.RNNeurosdkPackage;` to the imports at the top of the file
  - Add `new RNNeurosdkPackage()` to the list returned by the `getPackages()` method
2. Append the following lines to `android/settings.gradle`:
  	```
  	include ':react-native-neurosdk'
  	project(':react-native-neurosdk').projectDir = new File(rootProject.projectDir, 	'../node_modules/react-native-neurosdk/android')
  	```
3. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
  	```
      compile project(':react-native-neurosdk')
  	```


## Usage
See sample: https://gitlab.com/brainbit-inc/brainbit-examples/-/tree/master/react_native/BrainBit

We are recommended to use classes from sample names DeviceEnumerator, Device and Channels or use library manually like:

```javascript
import RNNeurosdk from 'react-native-neurosdk';

// to start search device
RNNeurosdk.CreateDeviceEnumerator(); 

// to create and connect device
RNNeurosdk.CreateDevice(deviceInfo);
RNNeurosdk.Connect(deviceInfo);

// to create bond with BrainBit Black 
RNNeurosdk.BondTo(deviceInfo.address);

// to read data from channel
batteryChannel.addLengthChanged(length =>{
  batteryChannel.totalLength().then(totalLength =>{
    batteryChannel.readData(totalLength.totalLength - 1,1).then((data)=>{
		console.log("Power: " + data[0]);
     });
   }); 
});

// and more

```
