Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Make programming with OpenBCI reliable, easy, research grade and fun!
First and foremost, Welcome! :tada: Willkommen! :confetti_ball: Bienvenue! :balloon::balloon::balloon:
Thank you for visiting the OpenBCI WiFi Shield NodeJS SDK repository.
This document (the README file) is a hub to give you some information about the project. Jump straight to one of the sections below, or just scroll down to find out more.
So, if even the very best developers integrate the current easy to use Cyton and Ganglion NodeJS drivers, they are still burdened by the limitations of the physical hardware on the OpenBCI system.
The OpenBCI WiFi Shield NodeJS SDK will:
Using WiFi physically solves limitations with the current state-of-the-art open source bio sensor. The goal for the WiFi Shield firmware was to create a one up data pipeline, where scientific data in JSON is sent instead of raw/compressed ADC counts (yuk!) to make programming with OpenBCI reliable, easy, research grade and fun!
The founder of the OpenBCI WiFi Shield NodeJS SDK is AJ Keller. There's more information about him (and some pictures) in the MeetTheTeam file.
AJ is an invited member of the 4th cohort Open Leaders Cohort of the Mozilla Science Lab who brought together open science advocates from around the world to participate in the first Working Open Workshop in Berlin in February 2016. The training exercises (which are free and easy to reuse) focused on how to build and effectively engage communities so they can work together to develop tools and resources for the greater good.
You! In whatever way you can help.
We need expertise in programming, user experience, software sustainability, documentation and technical writing and project management.
We'd love your feedback along the way.
Our primary goal is to make programming with OpenBCI reliable, easy, research grade and fun, and we're excited to support the professional development of any and all of our contributors. If you're looking to learn to code, try out working collaboratively, or translate you skills to the digital domain, we're here to help.
If you think you can help in any of the areas listed above (and we bet you can) or in any of the many areas that we haven't yet thought of (and here we're sure you can) then please check out our contributors' guidelines and our roadmap.
Please note that it's very important to us that we maintain a positive and supportive environment for everyone who wants to participate. When you join us we ask that you follow our code of conduct in all interactions both on and offline.
If you want to report a problem or suggest an enhancement we'd love for you to open an issue at this github repository because then we can get right on it. But you can also contact AJ by email (pushtheworldllc AT gmail DOT com) or on twitter.
You can also hang out, ask questions and share stories in the OpenBCI NodeJS room on Gitter.
You might be interested in:
And of course, you'll want to know our:
Thank you so much (Danke schön! Merci beaucoup!) for visiting the project and we do hope that you'll join us on this amazing journey to make programming with OpenBCI fun and easy.
npm install openbci-wifi
Get connected and start streaming right now with the example code.
const Wifi = require('openbci-wifi');
let wifi = new Wifi({
debug: false,
verbose: true,
latency: 10000
});
wifi.on(k.OBCIEmitterSample, (sample) => {
for (let i = 0; i < wifi.getNumberOfChannels(); i++) {
console.log("Channel " + (i + 1) + ": " + sample.channelData[i].toFixed(8) + " Volts.");
// prints to the console
// "Channel 1: 0.00001987 Volts."
// "Channel 2: 0.00002255 Volts."
// ...
// "Channel 8: -0.00001875 Volts."
}
});
wifi.searchToStream({
sampleRate: 1000 // Custom sample rate
shieldName: 'OpenBCI-2C34', // Enter the unique name for your wifi shield
streamStart: true // Call to start streaming in this function
}).catch(console.log);
Initializing the board:
const Wifi = require('openbci-wifi');
const ourBoard = new Wifi();
Go checkout out the get streaming example!
For initializing with options, such as verbose print outs:
const Wifi = require('openbci-wifi');
const wifi = new Wifi({
verbose: true
});
or if you are using ES6:
import Wifi from 'openbci-wifi';
import { Constants } from 'openbci-utilities';
const wifi = new Wifi();
wifi.connect("OpenBCI-2114");
To debug, it's amazing, do:
const Wifi = require('openbci-wifi');
const wifi = new Wifi({
debug: true
});
startByte
(Number
should be 0xA0
)sampleNumber
(a Number
between 0-255)channelData
(channel data indexed at 0 filled with floating point Numbers
in Volts) if sendCounts
is falsechannelDataCounts
(channel data indexed at 0 filled with floating point Numbers
in Volts) if sendCounts
is trueaccelData
(Array
with X, Y, Z accelerometer values when new data available) if sendCounts
is falseaccelDataCounts
(Array
with X, Y, Z accelerometer values when new data available) Only present if sendCounts
is trueauxData
(Buffer
filled with either 2 bytes (if time synced) or 6 bytes (not time synced))stopByte
(Number
should be 0xCx
where x is 0-15 in hex)boardTime
(Number
the raw board time)timeStamp
(Number
the boardTime
plus the NTP calculated offset)The power of this module is in using the sample emitter, to be provided with samples to do with as you wish.
.searchToStream(_options_)
const Wifi = require('openbci-wifi');
let wifi = new Wifi({
debug: false,
verbose: true,
latency: 10000
});
wifi.on(k.OBCIEmitterSample, (sample) => {
for (let i = 0; i < wifi.getNumberOfChannels(); i++) {
console.log("Channel " + (i + 1) + ": " + sample.channelData[i].toFixed(8) + " Volts.");
// prints to the console
// "Channel 1: 0.00001987 Volts."
// "Channel 2: 0.00002255 Volts."
// ...
// "Channel 8: -0.00001875 Volts."
}
});
wifi.searchToStream({
sampleRate: 1000 // Custom sample rate
shieldName: 'OpenBCI-2C34', // Enter the unique name for your wifi shield
streamStart: true // Call to start streaming in this function
}).catch(console.log);
Close the connection with .streamStop()
and disconnect with .disconnect()
const Wifi = require('openbci-wifi');
const wifi = new Wifi();
wifi.streamStop().then(wifi.disconnect());
Object
Kind: global class Author: AJ Keller (@aj-ptw)
InitializationObject
Promise.<T>
Promise.<T>
| *
Promise
Promise
Promise
Promise
boolean
boolean
boolean
*
String
null
| String
Number
null
| String
Number
Number
null
| String
global.Promise
| Promise
global.Promise
| Promise
Promise
Promise
Promise
Promise
global.Promise
| Promise
Promise
Promise.<T>
| *
Promise
Promise
Promise
Promise
Promise.<TResult>
Promise
The initialization method to call first, before any other method.
Param | Type | Description |
---|---|---|
options | InitializationObject | (optional) - Board optional configurations. |
InitializationObject
Kind: instance property of Wifi
Public Properties (keep alphabetical)
Kind: instance property of Wifi
Promise.<T>
Send a command to the board to turn a specified channel off
Kind: instance method of Wifi
Author: AJ Keller (@aj-ptw)
Param |
---|
channelNumber |
Promise.<T>
| *
Send a command to the board to turn a specified channel on
Kind: instance method of Wifi
Author: AJ Keller (@aj-ptw)
Param |
---|
channelNumber |
Promise
To send a channel setting command to the board
Kind: instance method of Wifi
Returns: Promise
- resolves if sent, rejects on bad input or no board
Author: AJ Keller (@aj-ptw)
Param | Description |
---|---|
channelNumber | Number (1-16) |
powerDown | Bool (true -> OFF, false -> ON (default)) turns the channel on or off |
gain | Number (1,2,4,6,8,12,24(default)) sets the gain for the channel |
inputType | String (normal,shorted,biasMethod,mvdd,temp,testsig,biasDrp,biasDrn) selects the ADC channel input source |
bias | Bool (true -> Include in bias (default), false -> remove from bias) selects to include the channel input in bias generation |
srb2 | Bool (true -> Connect this input to SRB2 (default), false -> Disconnect this input from SRB2) Select to connect (true) this channel's P input to the SRB2 pin. This closes a switch between P input and SRB2 for the given channel, and allows the P input to also remain connected to the ADC. |
srb1 | Bool (true -> connect all N inputs to SRB1, false -> Disconnect all N inputs from SRB1 (default)) Select to connect (true) all channels' N inputs to SRB1. This effects all pins, and disconnects all N inputs from the ADC. |
Promise
To send an impedance setting command to the board
Kind: instance method of Wifi
Returns: Promise
- resolves if sent, rejects on bad input or no board
Author: AJ Keller (@aj-ptw)
Param | Type | Description |
---|---|---|
channelNumber | Number | (1-16) |
pInputApplied | Boolean | (true -> ON, false -> OFF (default)) |
nInputApplied | Boolean | (true -> ON, false -> OFF (default)) |
Promise
The essential precursor method to be called initially to establish a ble connection to the OpenBCI ganglion board.
Kind: instance method of Wifi
Returns: Promise
- If the board was able to connect.
Author: AJ Keller (@aj-ptw)
Param | Type | Description |
---|---|---|
o | Object | |
o.examineMode | Boolean | Set this option true to connect to the WiFi Shield even if there is no board attached. |
o.ipAddress | String | The ip address of the shield if you know it |
o.latency | Number | If you want to set the latency of the system you can here too. |
o.sampleRate | The sample rate to set the board connected to the wifi shield | |
o.shieldName | String | If supplied, will search for a shield by this name, if not supplied, will connect to the first shield found. |
o.streamStart | Boolean | Set true if you want the board to start streaming. |
Promise
Closes the connection to the board. Waits for stop streaming command to be sent if currently streaming.
Kind: instance method of Wifi
Returns: Promise
- - fulfilled by a successful close, rejected otherwise.
Author: AJ Keller (@aj-ptw)
boolean
Checks if the driver is connected to a board.
Kind: instance method of Wifi
Returns: boolean
- - True if connected.
boolean
Checks if noble is currently scanning.
Kind: instance method of Wifi
Returns: boolean
- - True if streaming.
boolean
Checks if the board is currently sending samples.
Kind: instance method of Wifi
Returns: boolean
- - True if streaming.
*
Get the current board type
Kind: instance method of Wifi
String
Get the firmware version of connected and synced wifi shield.
Kind: instance method of Wifi
Returns: String
- The version number
Note: This is dependent on if you called connect
null
| String
Return the ip address of the attached WiFi Shield device.
Kind: instance method of Wifi
Number
Return the latency to be set on the WiFi Shield.
Kind: instance method of Wifi
null
| String
Return the MAC address of the attached WiFi Shield device.
Kind: instance method of Wifi
Number
This function is used as a convenience method to determine how many channels the current board is using.
Kind: instance method of Wifi
Returns: Number
- A number
Note: This is dependent on if your wifi shield is attached to another board and how many channels are there.
Author: AJ Keller (@aj-ptw)
Number
Get the the current sample rate is.
Kind: instance method of Wifi
Returns: Number
- The sample rate
Note: This is dependent on if you configured the board correctly on setup options
null
| String
Return the shield name of the attached WiFi Shield device.
Kind: instance method of Wifi
global.Promise
| Promise
Call to start testing impedance.
Kind: instance method of Wifi
global.Promise
| Promise
Call to stop testing impedance.
Kind: instance method of Wifi
Promise
Used to search for an OpenBCI WiFi Shield. Will connect to the first one if no shieldName
is supplied.
Kind: instance method of Wifi
Returns: Promise
- - Resolves after successful connection, rejects otherwise with Error.
Param | Type | Description |
---|---|---|
o | Object | (optional) |
o.sampleRate | The sample rate to set the board connected to the wifi shield | |
o.shieldName | String | If supplied, will search for a shield by this name, if not supplied, will connect to the first shield found. |
o.streamStart | Boolean | Set true if you want the board to start streaming. |
o.timeout | Number | The time in milli seconds to wait for the system to try and auto find and connect to the shield. |
Promise
Set the sample rate of the remote OpenBCI shield
Kind: instance method of Wifi
Param | Type | Description |
---|---|---|
sampleRate | Number | the sample rate you want to set to. |
Promise
Returns the sample rate from the board
Kind: instance method of Wifi
Promise
List available peripherals so the user can choose a device when not automatically found.
Kind: instance method of Wifi
Returns: Promise
- - If scan was started
global.Promise
| Promise
Called to end a search.
Kind: instance method of Wifi
Promise
Sends the stop SD logging command to the board. If not streaming then eot
event will be emitted
with request response from the board.
Kind: instance method of Wifi
Returns: Promise
- - Resolves when written
Author: AJ Keller (@aj-ptw)
Promise.<T>
| *
Syncs the internal channel settings object with a cyton, this will take about over a second because there are delays between the register reads in the firmware.
Kind: instance method of Wifi
Returns: Promise.<T>
| *
- Resolved once synced, rejects on error or 2 second timeout
Author: AJ Keller (@aj-ptw)
Promise
Sends a soft reset command to the board
Kind: instance method of Wifi
Returns: Promise
- - Fulfilled if the command was sent to board.
Author: AJ Keller (@aj-ptw)
Promise
Tells the WiFi Shield to forget it's network credentials. This will cause the board to drop all connections.
Kind: instance method of Wifi
Returns: Promise
- Resolves when WiFi Shield has been reset and the module disconnects.
Promise
Sends a start streaming command to the board.
Kind: instance method of Wifi
Returns: Promise
- indicating if the signal was able to be sent.
Note: You must have successfully connected to an OpenBCI board using the connect
method. Just because the signal was able to be sent to the board, does not
mean the board will start streaming.
Author: AJ Keller (@aj-ptw)
Promise
Sends a stop streaming command to the board.
Kind: instance method of Wifi
Returns: Promise
- indicating if the signal was able to be sent.
Note: You must have successfully connected to an OpenBCI board using the connect
method. Just because the signal was able to be sent to the board, does not
mean the board stopped streaming.
Author: AJ Keller (@aj-ptw)
Promise.<TResult>
Sync the info of this wifi module
Kind: instance method of Wifi
Param | Type | Description |
---|---|---|
o | Object | |
o.examineMode | Boolean | Set this option true to connect to the WiFi Shield even if there is no board attached. |
Promise
Used to send data to the board.
Kind: instance method of Wifi
Returns: Promise
- - fulfilled if command was able to be sent
Author: AJ Keller (@aj-ptw)
Param | Type | Description |
---|---|---|
data | Array | Buffer | Number | String | The data to write out |
Call this to shut down the servers.
Kind: instance method of Wifi
Configuring Options
Kind: inner property of Wifi
Object
Kind: global typedef Properties
Name | Type | Description |
---|---|---|
attempts | Number | The number of times to try and perform an SSDP search before quitting. (Default 10) |
debug | Boolean | Print out a raw dump of bytes sent and received. (Default false ) |
latency | Number | The latency, or amount of time between packet sends, of the WiFi shield. The time is in micro seconds! |
sampleRate | Number | The sample rate to set the board to. (Default is zero) |
sendCounts | Boolean | Send integer raw counts instead of scaled floats. (Default false ) |
verbose | Boolean | Print out useful debugging events. (Default false ) |
npm install
npm test
development
: git checkout development
git checkout -b my-new-feature
npm test
)git commit -m 'Add some feature'
git push origin my-new-feature
development
branch when submitting! :DMIT
0.0.5
FAQs
The official SDK for the Push The World Nexus Device.
We found that ptw-nexus demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.