Skip to content

Commit 6d5ae36

Browse files
authored
Merge pull request #24 from daniellasry/master
DOCS: Update to v1.0.0 and rename package to @openbci/wifi # v1.0.0 ### Breaking Changes Name of package is now @openbci/wifi ### Enhancements Include node 10 in testing
2 parents 663b21b + c732770 commit 6d5ae36

File tree

10 files changed

+257
-235
lines changed

10 files changed

+257
-235
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ language: node_js
22
node_js:
33
- "6.11"
44
- "8.5"
5+
- "10"
56
install:
67
- npm install --all
78
script:

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# v1.0.0
2+
3+
### Breaking Changes
4+
5+
Name of package is now @openbci/wifi
6+
7+
### Enhancements
8+
9+
Include node 10 in testing
10+
111
# v0.4.2
212

313
### Examples

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
[![codecov](https://codecov.io/gh/OpenBCI/OpenBCI_NodeJS_Wifi/branch/master/graph/badge.svg)](https://codecov.io/gh/OpenBCI/OpenBCI_NodeJS_Wifi)
1111
[![Dependency Status](https://david-dm.org/OpenBCI/OpenBCI_NodeJS_Wifi.svg)](https://david-dm.org/OpenBCI/OpenBCI_NodeJS_Wifi)
12-
[![npm](https://img.shields.io/npm/dm/openbci-wifi.svg?maxAge=2592000)](http://npmjs.com/package/openbci-wifi)
12+
[![npm](https://img.shields.io/npm/dm/@openbci/wifi.svg?maxAge=2592000)](http://npmjs.com/package/@openbci/wifi)
1313
[![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?style=flat-square)](https://github.com/Flet/semistandard)
1414

1515
## Welcome!
@@ -133,14 +133,14 @@ We assume you have NodeJS installed already, if you don't please [download the l
133133
Then simply using the node package manager command line tool, enter:
134134

135135
```
136-
npm install openbci-wifi
136+
npm install @openbci/wifi
137137
```
138138

139139
## <a name="tldr"></a> TL;DR:
140140
Get connected and [start streaming right now with the example code](examples/getStreaming/getStreaming.js).
141141

142142
```ecmascript 6
143-
const Wifi = require('openbci-wifi');
143+
const Wifi = require('@openbci/wifi');
144144
let wifi = new Wifi({
145145
debug: false,
146146
verbose: true,
@@ -202,31 +202,31 @@ Initialization
202202
Initializing the board:
203203

204204
```js
205-
const Wifi = require('openbci-wifi');
205+
const Wifi = require('../../openBCIWifi');
206206
const ourBoard = new Wifi();
207207
```
208208
Go [checkout out the get streaming example](examples/getStreaming/getStreaming.js)!
209209

210210
For initializing with options, such as verbose print outs:
211211

212212
```js
213-
const Wifi = require('openbci-wifi');
213+
const Wifi = require('../../openBCIWifi');
214214
const wifi = new Wifi({
215215
verbose: true
216216
});
217217
```
218218

219219
or if you are using ES6:
220220
```js
221-
import Wifi from 'openbci-wifi';
222-
import { Constants } from 'openbci-utilities';
221+
import Wifi from '../../openBCIWifi';
222+
import { constants } from '@openbci/utilities';
223223
const wifi = new Wifi();
224224
wifi.connect("OpenBCI-2114");
225225
```
226226

227227
To debug, it's amazing, do:
228228
```js
229-
const Wifi = require('openbci-wifi');
229+
const Wifi = require('../../openBCIWifi');
230230
const wifi = new Wifi({
231231
debug: true
232232
});
@@ -252,7 +252,7 @@ To get a 'sample' event, you need to:
252252
1. Install the 'sample' event emitter
253253
2. Call [`.searchToStream(_options_)`](#Wifi-connect)
254254
```js
255-
const Wifi = require('openbci-wifi');
255+
const Wifi = require('../../openBCIWifi');
256256
let wifi = new Wifi({
257257
debug: false,
258258
verbose: true,
@@ -278,7 +278,7 @@ wifi.searchToStream({
278278
```
279279
Close the connection with [`.streamStop()`](#Wifi+streamStop) and disconnect with [`.disconnect()`](#Wifi+disconnect)
280280
```js
281-
const Wifi = require('openbci-wifi');
281+
const Wifi = require('../../openBCIWifi');
282282
const wifi = new Wifi();
283283
wifi.streamStop().then(wifi.disconnect());
284284
```

examples/getStreaming/getStreaming.js

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*jslint es6*/
1+
/* jslint es6 */
22
/**
33
* This is an example from the readme.md
44
* On windows you should run with PowerShell not git bash.
@@ -10,16 +10,16 @@
1010
* do `npm install`
1111
* then `npm start`
1212
*/
13-
"use strict";
14-
const OBCIConsts = require("openbci-utilities").Constants;
15-
const OBCIWifi = require("../../openBCIWifi");
13+
'use strict';
14+
const OBCIConsts = require('@openbci/utilities').constants;
15+
const OBCIWifi = require('../../openBCIWifi');
1616

1717
const wifi = new OBCIWifi({
18-
debug: false, // Pretty print bytes
19-
verbose: true, // Verbose output
18+
debug: false, // Pretty print bytes
19+
verbose: true, // Verbose output
2020
sendCounts: false,
2121
latency: 16667,
22-
protocol: "tcp" // or "udp"
22+
protocol: 'tcp' // or "udp"
2323
});
2424

2525
let counter = 0;
@@ -49,7 +49,7 @@ const sampleFunc = (sample) => {
4949
console.log(`Dropped ${droppedPackets} packets`);
5050
console.log(`Dropped packet average: ${dpSum / droppedPacketArray.length}`);
5151
console.log(`Sample rate average: ${srSum / sampleRateArray.length}`);
52-
52+
5353
droppedPackets = 0;
5454
counter = 0;
5555
}, 1000);
@@ -63,7 +63,7 @@ const sampleFunc = (sample) => {
6363
console.log(`dropped ${packetDiff} packets | cur sn: ${sample.sampleNumber} | last sn: ${lastSampleNumber}`);
6464
droppedPackets += packetDiff;
6565
}
66-
66+
6767
lastSampleNumber = sample.sampleNumber;
6868
// console.log(JSON.stringify(sample));
6969
}
@@ -80,9 +80,9 @@ wifi.on(OBCIConsts.OBCIEmitterSample, sampleFunc);
8080
// wifi.on(OBCIConsts.OBCIEmitterRawDataPacket, console.log);
8181

8282
wifi.searchToStream({
83-
streamStart: true,
84-
sampleRate: 200
85-
})
83+
streamStart: true,
84+
sampleRate: 200
85+
})
8686
.then(() => {
8787
MAX_SAMPLE_NUMBER = wifi.getNumberOfChannels() === 4 ? 200 : 255;
8888
})
@@ -93,31 +93,31 @@ wifi.searchToStream({
9393

9494
function exitHandler (options, err) {
9595
if (options.cleanup) {
96-
if (options.verbose) console.log("clean");
96+
if (options.verbose) console.log('clean');
9797
/** Do additional clean up here */
9898
if (wifi.isConnected()) wifi.disconnect().catch(console.log);
99-
100-
wifi.removeAllListeners("rawDataPacket");
101-
wifi.removeAllListeners("sample");
99+
100+
wifi.removeAllListeners('rawDataPacket');
101+
wifi.removeAllListeners('sample');
102102
wifi.destroy();
103103

104104
if (sampleRateCounterInterval) clearInterval(sampleRateCounterInterval);
105105
}
106-
106+
107107
if (err) console.error(err.stack);
108-
108+
109109
if (options.exit) {
110-
if (options.verbose) console.log("exit");
110+
if (options.verbose) console.log('exit');
111111

112112
if (wifi.isStreaming()) {
113113
const _t = setTimeout(() => {
114-
console.log("timeout");
114+
console.log('timeout');
115115
process.exit(0);
116116
}, 1000);
117117

118118
wifi.streamStop()
119119
.then(() => {
120-
console.log("stream stopped");
120+
console.log('stream stopped');
121121
if (_t) clearTimeout(_t);
122122
process.exit(0);
123123
}).catch((err) => {
@@ -130,28 +130,28 @@ function exitHandler (options, err) {
130130
}
131131
}
132132

133-
if (process.platform === "win32") {
134-
const rl = require("readline").createInterface({
133+
if (process.platform === 'win32') {
134+
const rl = require('readline').createInterface({
135135
input: process.stdin,
136136
output: process.stdout
137137
});
138138

139-
rl.on("SIGINT", function () {
140-
process.emit("SIGINT");
139+
rl.on('SIGINT', function () {
140+
process.emit('SIGINT');
141141
});
142142
}
143143

144144
// Perform actions on exit
145-
process.on("exit", exitHandler.bind(null, {
145+
process.on('exit', exitHandler.bind(null, {
146146
cleanup: true
147147
}));
148148

149149
// Perform actions on SIGINT
150-
process.on("SIGINT", exitHandler.bind(null, {
150+
process.on('SIGINT', exitHandler.bind(null, {
151151
exit: true
152152
}));
153153

154154
// Perform actions on uncaught exceptions
155-
process.on("uncaughtException", exitHandler.bind(null, {
155+
process.on('uncaughtException', exitHandler.bind(null, {
156156
exit: true
157157
}));

examples/getStreamingWiFiDirect/getStreamingWiFiDirect.js

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*jslint es6*/
1+
/* jslint es6 */
22
/**
33
* This is an example from the readme.md
44
* On windows you should run with PowerShell not git bash.
@@ -10,18 +10,18 @@
1010
* do `npm install`
1111
* then `npm start`
1212
*/
13-
"use strict";
14-
const OpenBCIConsts = require("openbci-utilities").Constants;
15-
const OpenBCIWifi = require("../../openBCIWifi");
13+
'use strict';
14+
const OpenBCIConsts = require('@openbci/utilities').constants;
15+
const OpenBCIWifi = require('../../openBCIWifi');
1616

17-
const deviceAddr = "10.0.1.3";
17+
const deviceAddr = '10.0.1.3';
1818

1919
const wifi = new OpenBCIWifi({
20-
debug: false, // Pretty print bytes
21-
verbose: false, // Verbose output
20+
debug: false, // Pretty print bytes
21+
verbose: false, // Verbose output
2222
sendCounts: false,
2323
latency: 16667,
24-
protocol: "tcp", // or "udp"
24+
protocol: 'tcp', // or "udp"
2525
burst: true
2626
});
2727

@@ -45,7 +45,6 @@ const sampleFunc = (sample) => {
4545
droppedPacketArray.push(droppedPackets);
4646
sampleRateArray.push(counter);
4747

48-
4948
const dpSum = droppedPacketArray.reduce(sum, 0);
5049
const srSum = sampleRateArray.reduce(sum, 0);
5150

@@ -56,7 +55,6 @@ const sampleFunc = (sample) => {
5655

5756
droppedPackets = 0;
5857
counter = 0;
59-
6058
}, 1000);
6159
}
6260

@@ -85,10 +83,10 @@ wifi.on(OpenBCIConsts.OBCIEmitterSample, sampleFunc);
8583
// wifi.on(OpenBCIConsts.OBCIEmitterRawDataPacket, console.log);
8684

8785
wifi.connect({
88-
sampleRate: 200,
89-
streamStart: true,
90-
ipAddress: deviceAddr
91-
})
86+
sampleRate: 200,
87+
streamStart: true,
88+
ipAddress: deviceAddr
89+
})
9290
.then(() => {
9391
MAX_SAMPLE_NUMBER = wifi.getNumberOfChannels() === 4 ? 200 : 255;
9492
})
@@ -99,31 +97,31 @@ wifi.connect({
9997

10098
function exitHandler (options, err) {
10199
if (options.cleanup) {
102-
if (options.verbose) console.log("clean");
100+
if (options.verbose) console.log('clean');
103101
/** Do additional clean up here */
104102
if (wifi.isConnected()) wifi.disconnect().catch(console.log);
105103

106-
wifi.removeAllListeners("rawDataPacket");
107-
wifi.removeAllListeners("sample");
104+
wifi.removeAllListeners('rawDataPacket');
105+
wifi.removeAllListeners('sample');
108106
wifi.destroy();
109-
107+
110108
if (sampleRateCounterInterval) clearInterval(sampleRateCounterInterval);
111109
}
112110

113111
if (err) console.log(err.stack);
114-
112+
115113
if (options.exit) {
116-
if (options.verbose) console.log("exit");
114+
if (options.verbose) console.log('exit');
117115

118116
if (wifi.isStreaming()) {
119117
const _t = setTimeout(() => {
120-
console.log("timeout");
118+
console.log('timeout');
121119
process.exit(0);
122120
}, 1000);
123121

124122
wifi.streamStop()
125123
.then(() => {
126-
console.log("stream stopped");
124+
console.log('stream stopped');
127125
if (_t) clearTimeout(_t);
128126
process.exit(0);
129127
}).catch((err) => {
@@ -136,28 +134,28 @@ function exitHandler (options, err) {
136134
}
137135
}
138136

139-
if (process.platform === "win32") {
140-
const rl = require("readline").createInterface({
137+
if (process.platform === 'win32') {
138+
const rl = require('readline').createInterface({
141139
input: process.stdin,
142140
output: process.stdout
143141
});
144142

145-
rl.on("SIGINT", function () {
146-
process.emit("SIGINT");
143+
rl.on('SIGINT', function () {
144+
process.emit('SIGINT');
147145
});
148146
}
149147

150148
// do something when app is closing
151-
process.on("exit", exitHandler.bind(null, {
149+
process.on('exit', exitHandler.bind(null, {
152150
cleanup: true
153151
}));
154152

155153
// catches ctrl+c event
156-
process.on("SIGINT", exitHandler.bind(null, {
154+
process.on('SIGINT', exitHandler.bind(null, {
157155
exit: true
158156
}));
159157

160158
// catches uncaught exceptions
161-
process.on("uncaughtException", exitHandler.bind(null, {
159+
process.on('uncaughtException', exitHandler.bind(null, {
162160
exit: true
163-
}));
161+
}));

0 commit comments

Comments
 (0)