npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

js-neurosdk2

v1.0.30

Published

Web SDK for Headband, BrainBit2, Flex4 and Flex8 devices

Readme

Documentation

Overview

Neurosdk is a powerful tool for working with neuro-sensors BrainBit, Headband, Flex, Flex Pro. 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.

Usage

SDK can be conditionally divided into two parts: device search and the device itself.

The scanner allows you to find devices nearby, it is also responsible for the first creation of the device.

If an error occurs while working with the library, you will receive an exception for any of the methods.

Connection to device functions

A list of functions that connects to specific device:

  • startScannerBrainBit() - function that connects BrainBit, return device object and uuid of device;

  • startScannerHeadband() - function that connects HeadBand, return device object and uuid of device; IMPORTANT! You must go into pairing mode with your pc and then connect device

  • connectFlex() - function that connects Flex device, return device object and uuid of device;;

  • connectFlexPro() - function that connects Flex Pro device, return device object and uuid of device;

device object has name of device and BluetoothDevice, {name: "Brainbit", device: BluetoothDevice}

Manage connection state

You can connect and disconnect from device manually by methods connect() and disconnect()

  • connect(device: BluetoothDevice, uuidService: string) => return {batteryLevel: batteryLevel, cmdError: cmdError, status: status, service: service};

  • disconnectDevice(device: BluetoothDevice, service: BluetoothRemoteGATTService, uuidService: string) - disconnect device and set your device to powerDown state

Manage device parameters

Battery

BatteryLevel is power value from your device.

Name

Name of device. String value.

State
Information about the connection status of a device. Status return number 0 - 4
{
   0: NSS_STATUS_INVALID, // Module status unknown
   1: NSS_STATUS_POWERDOWN, // Module disabled
   2: NSS_STATUS_IDLE, // Standby mode
   3: NSS_STATUS_SIGNAL, // Signal registration
   4: NSS_STATUS_RESIST, // Resistance registration
}

A module here refers to a chip that converts data from an analog signal to a digital one.

Information about the command errors(cmdError) of a device. Status return number 0 - 2
{
   0: NSS_ERROR_NOERROR, // No error
   1: NSS_ERROR_LEN, // Command size error
   2: NSS_ERROR_NOCOMMAND // Command number error (no such command)
}

Commands

Functions that control state of device:

  1. getDeviceStatus(service: BluetoothDevice, uuidService: string) - get current device status => return {batteryLevel: batteryLevel, cmdError: cmdError, status: status}

  2. goIdle(service: BluetoothDevice, uuidService: string) - set device to idle state;

    • Turning on the analog-to-digital power supply
  3. goPowerDown(service: BluetoothDevice, uuidService: string) - set device to powerdown state;

    • Switching to low power mode
  4. goSignal(service: BluetoothDevice, uuidService: string) - set device to signal state and get values from device;

    • 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.

    • You should connect to notifications from device to your project.

  5. goResist(service: BluetoothDevice, uuidService: string) - set device to resist state and get values from device;

    • You should connect to notifications from device to your project.

Transition from any state to any state is allowed, but it is recommended to use a sequence to start the measurement PowerDown→Idle→Signal(or Resist). When the measurement is stopped for a short time, it is recommended to switch to Idle, and when the session is terminated, to PowerDown. The transition from PowerDown to Idle takes about 1 second, further transitions from Idle to Signal and back, as well as to PowerDown from any state, take about 20 ms.

Handlers to subscribe on events from device

You get signal values as a list of samples, each containing:

  • PackNum - number for each packet
  • Marker - marker of sample, if it was sent and this feature is supported by the device
  • O1 - value of O1 channel in V
  • O2 - value of O2 channel in V
  • T3 - value of T3 channel in V
  • T4 - value of T4 channel in V

In resistance state marker wouldnt come to host

  • handleSignalNotification(event) - (signal)return object with 8 channels, packet_numer, marker
{
   marker: number,
   packet_number: number,

   ot0_ch0: number, // ch0 - O2
   ot0_ch1: number, // ch1 - T3
   ot0_ch2: number, // ch3 - T4
   ot0_ch3: number, // ch4 - O1

   ...

   ot7_ch2: number,
   ot7_ch3: number,
}
  • handleResistNotification(event) - (resist)return object with 4 channels and packet_number
{
   packet_number: number,
   ch0: number, // ch0 - O2
   ch1: number, // ch1 - T3
   ch2: number, // ch3 - T4
   ch3: number, // ch4 - O1
}
  • handleResistProNotification(event) - You should use this handler when you have FLEX PRO device (resist)return object with 8 channels and packet_number
{
   packet_number: number,
   ch0: number, // ch0 - O1
   ch1: number, // ch1 - PZ
   ch2: number, // ch3 - FZ
   ch3: number, // ch4 - CZ
   ch4: number, // ch5 - O2
   ch5: number, // ch6 - T4
   ch6: number, // ch7 - T3
   ch7: number // ch8 - not named
}