1.0.15 • Published 2 years ago
react-native-neurosdk v1.0.15
react-native-neurosdk
Getting started
$ npm install react-native-neurosdk --save
Mostly automatic installation
$ react-native link react-native-neurosdk
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-neurosdk
and addRNNeurosdk.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNNeurosdk.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- 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 thegetPackages()
method
- 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')
- 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:
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