
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
react-native-neurosdk2
Advanced tools
ReactNative NeuroSDK2 is a set of libraries for iOS and Android operating systems providing tools needed for configuring and receiving raw data from neuro sensors.
Neurosdk is a powerful tool for working with neuro-sensors BrainBit, BrainBitBlack, Callibri and Kolibri. All these devices work with BLE 4.0+ technology. SDK allows you to connect, read the parameters of devices, as well as receive signals of various types from the selected device.
Firstly, you need to install package.
Available for iOS and Android platforms
$ npm install react-native-neurosdk2 --save
$ react-native link react-native-neurosdk2
Because sdk uses the bluetooth api you need to set up the project.
For Android you need to request runtime permission:
export async function requestPermissionAndroid() {
try {
const granted = await PermissionsAndroid.requestMultiple([
PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT,
]);
if (
granted[PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION] ===
PermissionsAndroid.RESULTS.GRANTED
) {
...
}
if (
granted[PermissionsAndroid.PERMISSIONS.BLUETOOTH_CONNECT] ===
PermissionsAndroid.RESULTS.GRANTED
) {
...
}
} catch (err) { }
}
For iOS you need to add a key to Info.plist because it uses bluetooth too:
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Explanation to using bluetooth</string>
SDK can be conditionally divided into two parts: device search (Scanner object) and the device itself (Sensor object).
The scanner allows you to find devices nearby, it is also responsible for the first creation of the device. When created, the device is automatically connected. In the future, the connection state can be controlled through the sensor object. Whatever type of device you work with, the use of the scanner will be the same.
The sensor allows you to monitor the status of the device, set parameters, receive a signal of various types.
It is recommended to work with both parts in a separate thread. During the connection, the SDK also reads the main characteristics of the device, which significantly increases the time of the connection method, which will cause the application to freeze.
If an error occurs while working with the library, you will receive an exception for any of the methods.
Package contains tree main modules:
import { Scanner } from 'react-native-neurosdk2'
import { Sensor, BrainBitSensor, CallibriSensor } from 'react-native-neurosdk2'
import {SensorSamplingFrequency,
SensorGain,
SensorDataOffset,
SensorExternalSwitchInput,
SensorADCInput,
SensorAccelerometerSensitivity,
SensorGyroscopeSensitivity,
SensorFirmwareMode,
IrAmplitude,
RedAmplitude,
FPGData,
SensorAmpMode,
SensorCommand,
SensorParamAccess,
SensorParameter,
SensorFeature,
SensorFilter,
SensorFamily,
SensorInfo,
SensorVersion,
MEMSData,
Point3D,
BrainBitSignalData,
BrainBitResistData,
CallibriSignalData,
CallibriEnvelopeData,
CallibriRespirationData,
CallibriColorType,
CallibriSignalType,
CallibriStimulatorMAState,
CallibriStimulationParams,
CallibriMotionAssistantParams,
CallibriMotionCounterParam,
QuaternionData,
CallibriElectrodeState,
CallibriMotionAssistantLimb,
CallibriStimulatorState,
SensorState} from 'react-native-neurosdk2'
Here is a list of exceptions that occur when working with SDK. You need to be guided by this list in order to understand what happened in the process of executing a particular method.
| Code | Description |
|---|---|
| 100 | Invalid scan parameters are specified |
| 101 | Invalid sensor types are specified for the search |
| 102 | Failed to create sensor scanner |
| 103 | Failed to started sensor scanner |
| 104 | Failed to stopped sensor scanner |
| 105 | Failed to get a list of sensors |
| 106 | Failed to get a list of sensors |
| 107 | Invalid parameters for creating a sensor |
| 108 | Failed to create sensor |
| 109 | Sensor not founded |
| 110 | Failed to connect the sensor |
| 111 | Failed to disconnect the sensor |
| 112 | Failed to get a list of sensor features |
| 113 | Invalid parameters for get a list features of the sensor |
| 114 | Invalid parameters for get a list commands of the sensor |
| 115 | Failed to get a list of sensor commands |
| 116 | Invalid parameters for get a list parameters of the sensor |
| 117 | Failed to get a list of sensor parameters |
| 118 | Failed to execute the sensor command |
| 119 | Failed read the sensor parameter |
| 120 | Failed read the sensor parameter |
| 121 | Failed write the sensor parameter |
| 122 | Failed write the sensor parameter |
| 123 | Failed add callback the sensor |
| 124 | Failed add callback the sensor |
The scanner works like this:
import {Scanner} from 'react-native-neurosdk2'
...
var scanner = new Scanner()
await scanner.init([SensorFamily.LECallibri, SensorFamily.LEBrainBit])
scanner.AddSensorListChanged(sensors => {
console.log(sensors)
});
...
scanner.RemoveSensorListChanged();
scanner.start()
scanner.stop()
var sensors = await scanner.sensors()
SensorInfo contains information about device:
scanner.close();
Important! When restarting the search, the callback will only be called when a new device is found. If you need to get all devices found by the current scanner instance, call the appropriate method.
You need to create a device using a scanner. All manipulations with the device will be performed without errors only if the device is connected.
import { CallibriSensor, BrainBitSensor, Sensor, } from "react-native-neurosdk2";
// BrainBit
var sensor: BrainBitSensor = await scanner.createSensor(sensorInfo) as BrainBitSensor;
// Callibri
var sensor: CallibriSensor = await scanner.createSensor(deviceInfo) as CallibriSensor
Device creation is a blocking method, so it must be called from separate thread.
For all types of devices, you can use the same methods to control the device's connection status, invoke commands, and check for functionality.
Connection status can be obtained in two ways. The first one is using the sensor property State.
The second way is in real time using a callback:
sensor.AddConnectionChanged((state)=>{
console.log(SensorState[state])
})
...
sensor.RemoveConnectionChanged()
A connection can be in two states: connected (InRange) and disconnected (OutOfRange).
Important! The state change callback will not come after the device is created, only after disconnecting (device lost from the scope or using a method) and then connected. The device does not automatically reconnect.
You can connect and disconnect from device manually by methods Connect() and Disconnect(). To receive connection state in real time you need to subscribe to stateChanged event. Also you can get connection state by sensor's property.
await sensor.disconnect()
...
await sensor.connect()
Method
Connectis blocking too, so it need to be call from separate thread.
Also, you can get power value from each device by sensor property BattPower or by callback in real time:
sensor.AddBatteryChanged((power)=>{
console.log(power)
})
...
sensor.RemoveBatteryChanged()
Each device has its own settings, and some of them can be configured as you need. Not all settings can be changed and not every device supports all settings.
First you need to find out what parameters the device supports and whether they can be changed:
console.log(sensor.getParameters().map(parameter => SensorParameter[parameter.Param] + ": " + SensorParamAccess[parameter.ParamAccess]))
// Output:
//
// ["Name: Read",
// "FirmwareMode: Read",
// "FirmwareVersion: Read",
// "State: ReadNotify", ... ]
Info about parameter includes two fields:
You can also check if the parameter is supported, for example Gain:
if(sensor.isSupportedParameter(SensorParameter.Gain)){
...
}
Name of device. String value.
var name: string = sensor.getName()
...
sensor.setName('new_name') // <- this is throw an exeption, you cannot set device name
Information about the connection status of a device. Может принимать два значения:
var state: SensorState = sensor.getState()
MAC-address of device. For iOS/MacOS represents by UUID. String value.
var address: string = sensor.getAddress()
Serial number of device. String value.
For callibri device families, this field is empty in SensorInfo when searching, and you can get it immediately after connecting using this property.
var sn: string = sensor.getSerialNumber()
Only to Callibri MF sensor!
Device signal filter activity states. If the parameter is supported by the device, it becomes possible to set the desired filters using the HardwareFilters property. The next filters are available:
If sensor does not support filter in input list the method throw an exception
var filters: Array<SensorFilter> = sensor.getHardwareFilters()
...
sensor.getHardwareFilters([SensorFilter.FilterBSFBwhLvl2CutoffFreq55_65Hz, SensorFilter.FilterHPFBwhLvl2CutoffFreq10Hz])
Information about the current mode of operation of the device firmware. It can be in two states:
var mode: SensorFirmwareMode = sensor.getFirmwareMode()
...
// Setter supports only with Callibri MF
sensor.setFirmwareMode(SensorFirmwareMode.ModeApplication)
An property that is used to set or get the sample rate of a physiological signal. The higher the value, the more data flow from the device to the application, which means the higher the power consumption, but also the higher the range of measured frequencies. And there are also limitations on the physical communication channel (BLE) in terms of bandwidth.
Recommendations for choosing a value:
It is unchanged for BrainBit and BrainBitBlack and is 250 Hz. Can be changed for Signal Callibri/Kolibri and can take on the following values:
Not available for Callibi EMS. If you try to set an unsupported value to the device, an exception will be thrown.
var sf: SensorSamplingFrequency = sensor.getSamplingFrequency()
...
// Setter supports only with Callibri MF
sensor.setSamplingFrequency(SensorSamplingFrequency.FrequencyHz1000)
Gain of an ADC signal. The higher the gain of the input signal, the less noise in the signal, but also the lower the maximum amplitude of the input signal. It is unchanged for BrainBit and BrainBitBlack and is 6. For Callibi/Kolibri MF you can set the desired value. Not available for Callibi/Kolibri EMS.
var gain: SensorGain = sensor.getGain()
...
// Setter supports only with Callibri MF
sensor.setGain(SensorGain.Gain3)
If you try to set an unsupported value to the device, an exception will be thrown.
Signal offset. It is unchanged for BrainBit and BrainBitBlack and is 0. For Callibi/Kolibri MF you can set the desired value. Not available for Callibi/Kolibri EMS.
var offset: SensorDataOffset = sensor.getDataOffset()
...
sensor.setDataOffset(SensorDataOffset.DataOffset0)
If you try to set an unsupported value to the device, an exception will be thrown.
Switched signal source. This parameter is available only to Callibi/Kolibri. It is can take on the following values:
var extSwInp: SensorExternalSwitchInput = sensor.getExtSwInput()
...
sensor.setExtSwInput(SensorExternalSwitchInput.ExtSwInElectrodes)
If you try to set an unsupported value to the device, an exception will be thrown.
State value of an ADC (Analog to Digital Converter) input of a device. This property is available only to Callibi/Kolibri. It is can take on the following values:
The value is stored and changed in the ADCInput property.
var input: SensorADCInput = sensor.getADCInput()
...
sensor.setADCInput(SensorADCInput.Electrodes)
If you try to set an unsupported value to the device, an exception will be thrown.
The sensitivity value of the accelerometer, if the device supports it. This property is available only to Callibi/Kolibri. It is recommended to check the presence of the MEMS module before use. It is can take on the following values:
The value is stored and changed in the AccSens property.
If you try to set an unsupported value to the device, an exception will be thrown.
The gyroscope gain value, if the device supports it. This property is available only to Callibi/Kolibri. It is recommended to check the presence of the MEMS module before use. It is can take on the following values:
The value is stored and changed in the GyroSens property.
If you try to set an unsupported value to the device, an exception will be thrown.
Parameter for obtaining information about the state of the stimulation mode and the motion assistant mode. This parameter is available only to Callibi/Kolibri EMS. Contains:
Each of the fields can be in three states:
If you try to set an unsupported value to the device, an exception will be thrown.
Stimulation parameters. This property is available only to Callibi/Kolibri EMS. Contains:
The value is stored and changed in the StimulatorParamCallibri property.
If you try to set an unsupported value to the device, an exception will be thrown.
Parameter for describing a stimulation mode, if the device supports this mode. This structure describes the parameters for starting the stimulation mode depending on the place of application of the device, the position of the limb in space and the pause between the starts of this mode while the specified conditions are met. Параметр доступен только для Callibi/Kolibri стимулятора. Contain a structure named CallibriMotionAssistantParams with fields:
The value is stored and changed in the MotionAssistantParamCallibri property.
If you try to set an unsupported value to the device, an exception will be thrown.
Information about the device firmware version. Contain a structure named SensorVersion with fields:
The value is stored and changed in the Version property.
var version: SensorVersion = sensor.getVersion()
This parameter is available only to Callibi/Kolibri. Contain a structure named MotionCounterParamCallibri with fields:
The value is stored and changed in the CallibriMotionCounterParam property.
Contains the number of motions. This parameter is available only to Callibi/Kolibri. A numeric value that cannot be changed. The value is stored and changed in the MotionCounterCallibri property.
Battery power value. Integer value.
var power = sensor.getBattPower()
Type of device. Enumeration.
var family: SensorFamily = sensor.getSensFamily()
Operating mode of the physiological amplifier. Parameter is available only for BraibBitBlack. The value is stored in the SensorAmpMode property.
Frequency of updating resistance values. Immutable value. Not available for Callibri/Kolibri. Don't has a fixed value for BrainBit/BrainBitBlack.
Frequency of updating MEMS values. Immutable value. Available for Callibri/Kolibri supporting MEMS.
Frequency of updating breath values. Неизмениемое значение. Available for Callibri/Kolibri supporting breath.
Each device has a specific set of modules. You can find out which modules the device has using the property Feature:
console.log(sensor.getFeatures().map(feature => SensorFeature[feature]))
// Output:
//
// ["Signal", "Resist"]
You can also check if the feature is supported, for example Signal:
if(sensor.isSupportedFeature(SensorFeature.Signal)){
...
}
The device can execute certain commands. The list of supported commands can be obtained as follows:
console.log(sensor.getCommands().map(command => SensorCommand[command]))
// Output:
//
// ["StartSignal", "StopSignal", ...]
And also check if the device can execute the desired command:
if(sensor.isSupportedCommand(SensorCommand.StartSignal)){
...
}
The BrainBit and BrainBitBlack is a headband with 4 electrodes and 4 data channels - O1, O2, T3, T4. The device has a frequency of 250 Hz, which means that data on each of the channels will come at a frequency of 250 samples per second. The parameters of this device, such as gain, data offset and the other, cannot be changed, if you try to do this, an exception will appear.
sensor.setName("newname") // <- This throw an exeption!
You can distinguish BrainBit device from Flex by the firmware version number: if the
SensorVersion.FwMajoris more than 100 - it's Flex, if it's less than BrainBit.
BrainBitBlack, unlike BrainBit, requires pairing with a PC/mobile device. So, before connecting to the BBB, you must put it into pairing mode. SDK starts the pairing process automatically.
To receive signal data, you need to subscribe to the corresponding callback. The values will be received as a packet from four channels at once, which will avoid desynchronization between them. The values come in volts. In order for the device to start transmitting data, you need to start a signal using the execute command. This method is also recommended to be run in an separate thread.
sensor.AddSignalReceived((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartSignal)
...
sensor.RemoveSignalReceived();
sensor.ExecuteCommand(SensorCommand.StopSignal)
You get signal values as a list of samples, each containing:
Some devices support signal quality check functions using signal ping. You can send a specific value (marker) to the device and it will return that marker with the next signal data packet. Marker is small value one byte in size.
Available only to BrainBitBlack
sensor.pingNeuroSmart(5)
BrainBit and BrainBitBlack also allow you to get resistance values. With their help, you can determine the quality of the electrodes to the skin. Initial resistance values are infinity. The values change when the BB is on the head.
For BrainBit the upper limit of resistance is 2.5 ohms.
sensor.AddResistanceReceived((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartResist)
...
sensor.RemoveResistanceReceived();
sensor.execute(SensorCommand.StopResist)
You get resistance values structure of samples for each channel:
The Callibri family of devices has a wide range of built-in modules. For each of these modules, the SDK contains its own processing area. It is recommended before using any of the modules to check if the module is supported by the device using one of the methods isSupportedFeature, isSupportedCommand or isSupportedParameter
To receive signal data, you need to subscribe to the corresponding callback. The values come in volts. In order for the device to start transmitting data, you need to start a signal using the execute command. This method is also recommended to be run in an separate thread.
The sampling rate can be controlled using the SamplingFrequency property. For example, at a frequency of 1000 Hz, the device will send 1000 samples per second. Supports frequencies 125/250/500/1000/2000 Hz. You can also adjust the signal offset (DataOffset) and signal power (Gain).
sensor.AddSignalReceived((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartSignal)
...
sensor.RemoveSignalReceived();
sensor.execute(SensorCommand.StopSignal)
You get signal values as a list of samples, each containing:
By default, the Callibri/Kolibri gives a signal without filters. In order to receive a certain type of signal, for example, EEG or ECG, you need to configure the device in a certain way. For this there is a property SignalTypeCallibri. Preset signal types include:
ExtSwInput property.Hardware filters disabled by default for all signal types. You can enable filters by HardwareFilters property, for example LP filter.
Important! When using an LP filter in the sensor, you will not see the constant component of the signal.
var signalType = sensor.getSignalTypeCallibri()
...
sensor.setSignalTypeCallibri(CallibriSignalType.ECG)
To get the values of the envelope, you need to subscribe to a specific event and start pickup. The channel must be configured in the same way as for a normal signal, and all parameters work the same way. Then the signal is filtered and decimated at 20 Hz.
sensor.AddEnvelopeDataChanged((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartEnvelope)
...
sensor.RemoveEnvelopeDataChanged();
sensor.execute(SensorCommand.StopEnvelope)
You get signal values as a list of samples, each containing:
Allows you to determine the presence of electrical contact of the device electrodes with human skin. It can be in three states:
To receive data, you need to subscribe to the corresponding callback and start signal pickup.
sensor.AddElectrodeStateChanged((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartSignal)
...
sensor.RemoveElectrodeStateChanged();
sensor.execute(SensorCommand.StopSignal)
You get signal values as a list of samples, each containing:
The breathing microcircuit is optional on request. Its presence can be checked using the IsSupportedFeature method. To receive data, you need to connect to the device, subscribe to the notification of data receipt and start picking up.
if(sensor.isSupportedFeature(SensorFeature.Respiration))
{
sensor.AddRespirationChanged((data)=>{
console.log(data)
});
sensor.execute(SensorCommand.StartRespiration)
...
sensor.RemoveRespirationChanged();
sensor.execute(SensorCommand.StopRespiration)
}
You get signal values as a list of samples, each containing:
The MEMS microcircuit is optional on request. Its presence can be checked using the IsSupportedFeature method. This means that the device contains an accelerometer and a gyroscope. Contains information about the position of the device in space. Channel sampling frequency is 100 Hz.
MEMS data is a structure:
Quaternion data is a structure:
It is recommended to perform calibration on a flat, horizontal non-vibrating surface before starting work using the CalibrateMEMS command. Calibration state can be checked using the MEMSCalibrateStateCallibri property, it can take only two values: calibrated (true), not calibrated (false).
MEMS and quaternion available only to Callibri/Kolibri MF!
// For receiving MEMS
sensor.AddMMEMSDataReceived((data)=>{
console.log(data)
})
sensor.execute(SensorCommand.StartMEMS)
...
sensor.RemoveMEMSDataReceived()
sensor.execute(SensorCommand.StopMEMS)
// For quarternion
sensor.AddQuaternionDataReceived((data)=>{
console.log(data)
})
sensor.execute(SensorCommand.StartAngle)
...
sensor.RemoveQuaternionDataReceived()
sensor.execute(SensorCommand.StopAngle)
Представляет собой счетчик движений. Настроить можно с помощью свойства CallibriMotionCounterParam, в нем:
You can find out the current number of movements using the MotionCounterCallibri property. You can reset the counter with the ResetMotionCounter command. No additional commands are needed to start the counter, it will be incremented all the time until the reset command is executed.
if(sensor.isSupportedParameter(SensorParameter.MotionCounter)
{
sensor.setMotionCounterParamCallibri({
InsenseThresholdMG: 250, InsenseThresholdSample:250
})
var motionCount = sensor.getMotionCounterCallibri()
sensor.execute(SensorCommand.ResetMotionCounter)
}
Callibri is a EMS if it supports the stimulation module:
var isStimulator = sensor.isSupportedFeature(SensorFeature.CurrentStimulator)
Before starting the session, you need to correctly configure the device, otherwise the current strength may be too strong or the duration of stimulation too long. The setting is done using the StimulatorParamCallibri property. You can set the following options:
You can start and stop stimulation with the following commands:
sensor.execute(SensorCommand.StartCurrentStimulation)
...
sensor.execute(SensorCommand.StopCurrentStimulation)
Stimulation does not stop after the
StimulusDurationtime has elapsed.
You can check the state of stimulation using the StimulatorMAStateCallibri property. Contains two parameters:
Each of the parameters can be in 4 states:
The Callibri EMS, which contains the MEMS module, can act as a motion corrector. You can set the initial and final angle of the device and the limb on which the Callibri/Kolibri is installed, as well as a pause between stimulations and turn on the motion assistant. All the time while the device is tilted in the set range, stimulation will met. Stimulation will take place according to the settings of StimulatorParamCallibri.
The motion corrector works in the background. After turning on the motion assistant mode, it will work regardless of the connection to a mobile device/PC. You can turn on the motion corrector mode using a special command. When the device is rebooted, it is also reset.
Motion corrector parameters are a structure with fields:
sensor.setMotionAssistantParamCallibri({
GyroStart: 45,
GyroStop:10,
Limb: CallibriMotionAssistantLimb.RightLeg,
MinPauseMs: 10
})
sensor.execute(SensorCommand.EnableMotionAssistant)
...
sensor.execute(SensorCommand.StopCurrentStimulation)
FAQs
ReactNative NeuroSDK2 is a set of libraries for iOS and Android operating systems providing tools needed for configuring and receiving raw data from neuro sensors.
We found that react-native-neurosdk2 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.