Skip to content

Commit 739afff

Browse files
committed
update ffi for node 10, update to use @abandonware official releases
1 parent 5045fcf commit 739afff

File tree

7 files changed

+822
-292
lines changed

7 files changed

+822
-292
lines changed

README.md

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ node -v
7474
Check the latest version of NVM before you install (it might be higher than v0.35.3). You can go online to learn how to use NVM to switch node versions on the fly.
7575

7676
##### Using sudo - a Warning
77-
It is important to note that because our scripts use OS level Bluetooth libraries, it may be required to use sudo (or you will get a warning and the scripts won't work). You need to decide if you are ok to use sudo or not.
77+
It is important to note that because our scripts use OS level Bluetooth libraries, it may be required to use sudo (or you will get a warning and the scripts won't work). You need to decide if you are ok to use sudo or not. If you are not, follow this [guide](https://github.com/sandeepmistry/noble#running-on-linux)
7878

7979
You also need to check that the version of node you are using is as expected for sudo:
8080
```
@@ -84,10 +84,28 @@ $ sudo node -v
8484
v0.11.8-pre
8585
```
8686
As you can see here, the sudo node version is not the same as the current user version. Here's a [workaround](https://stackoverflow.com/questions/21215059/cant-use-nvm-from-root-or-sudo). You can google-fu more about this topic.
87+
```
88+
n=$(which node); \
89+
n=${n%/bin/node}; \
90+
chmod -R 755 $n/bin/*; \
91+
sudo cp -r $n/{bin,lib,share} /usr/local
92+
```
93+
94+
##### Using bluez, BLE Dongles, and Node
95+
At the time of this release, Node 10 is supported. Node 12 is not currently supported as `node-ffi` and some other libraries have not been updated.
96+
We have to use a custom fork of node-ffi until then (see package.json). Hopefully node-ffi will be updated to support Node 10 and Node 12 officially.
97+
98+
Bluez 5.50 works but 5.54 might not work. Here's a good [tutorial](https://learn.adafruit.com/install-bluez-on-the-raspberry-pi/installation)
99+
100+
If you are not using a BLE dongle, you need to make sure your system is working and supports Bluetooth 4.0 or later (Bluetooth low energy).
101+
102+
If you are using a BLE dongle, you need to make sure it's working. You can google-fu how to use tools such as `bluetoothctl`, `hciconfig`, `btmon` and more to confirm this.
103+
104+
This may or may not work on arm64. Works on armhf and raspberryPi 3 and RaspberryPi 4.
87105

88106
### Installation
89107

90-
You have two options for installation:
108+
You have three options for installation:
91109

92110
#### 1. Use NPM
93111
The Mbient JavaScript SDK relies on [Noble](https://github.com/mbientlab/noble) and [Noble-Device](https://github.com/mbientlab/noble-device) for Bluetooth Low Energy communications.
@@ -104,6 +122,13 @@ npm update metawear
104122
```
105123

106124
#### 2. Use our Repository
125+
You can install the metawear package straight from our repository by using:
126+
```
127+
npm install https://github.com/mbientlab/MetaWear-SDK-JavaScript.git
128+
```
129+
This step takes a long time as all the packages are installed and the MetaWear CPP library will be compiled on your machine.
130+
131+
#### 3. Clone our Repository
107132
We packaged everything for you already in this repository with the package.json file ready to be installed with npm.
108133

109134
Make sure that when you clone this repository, that you clone the submodule with it.
@@ -117,7 +142,24 @@ npm install
117142
```
118143
This step takes a long time as all the packages are installed and the MetaWear CPP library will be compiled as well.
119144

120-
Once the install is success, you can run our example scripts in the example folder:
145+
#### Errors and Issues
146+
If you have any issues with the npm installation, make sure you are using the correct version of node, npm, nvm (if used), bluez, and that your machine is bluetoothLE compliant. Follow the errors and correct them as indicated by the npm output log.
147+
148+
If you have any issues compiling the `MetaWear-CPP-SDK` (this is a post script that runs at the end of npm install), simply build it from source.
149+
If you cloned the repo:
150+
```
151+
cd MetaWear-SDK-Cpp/
152+
make
153+
```
154+
If you ran an npm command:
155+
```
156+
cd node_modules/
157+
cd MetaWear-SDK-Cpp/
158+
make
159+
```
160+
161+
#### Running your first Script
162+
Once the install is successful, you can run our example scripts in the example folder (see the example folder in our repository):
121163
```javascript
122164
node led.js
123165
```
@@ -126,25 +168,23 @@ Please note that depending on your node and npm installation, you may need to ru
126168
```javascript
127169
sudo node led.js
128170
```
129-
This can be avoided with proper installation steps but it will depend on whether or not your application and requirements are ok with sudo or not (to each their own).
130171

131172
Please note that the examples in our examples folder will use the local metawear libraries (as this repository is meant for development):
132173
```javascript
133174
var MetaWear = require('../index')
134175
```
135-
This would be using the local metawear code. You will probably never need this unless you are planning to change our internal libraries.
176+
This is using the local metawear code.
136177

137178
Simply change it to this:
138179
```javascript
139180
var MetaWear = require('metawear');
140181
```
141-
This would be using the metawear code in your local npm `node_modules` directory as installed. This is the prefered way.
182+
This would be using the metawear code in your local npm `node_modules` directory as installed with npn.
142183

143184
#### Notes
144185
You should familiarize yourself with this README and our tutorials since there a few limitiations and other gotchas spelled out, such as the maximum number of simultaneous Bluetooth connections.
145186

146187
### Usage
147-
148188
Require the metawear package
149189

150190
```javascript
@@ -197,5 +237,4 @@ MetaWear.discover(function (device) {
197237
```
198238
199239
### Tutorials
200-
201240
Tutorials can be found [here](https://mbientlab.com/tutorials/).

examples/full_reset.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var MetaWear = require('../index')//require('metawear');
22

3-
MetaWear.discoverByAddress('f9:b5:f9:81:3f:77', function(device) {
3+
MetaWear.discoverByAddress('c8:4b:aa:97:50:05', function(device) {
44
console.log('Discovered');
55
//MetaWear.discover(function (device) {
66
device.connectAndSetUp(function (error) {

examples/log_acc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ var ref = require('ref');
88
var accelLogger = null;
99

1010
// If you know the MAC address, you can uncomment this line
11-
//MetaWear.discoverByAddress('f3:97:6b:cc:71:97', function (device) {
12-
MetaWear.discover(function (device) {
11+
MetaWear.discoverByAddress('c8:4b:aa:97:50:05', function (device) {
12+
//MetaWear.discover(function (device) {
1313
console.log('discovered ' + device.address);
1414
device.connectAndSetUp(function (error) {
1515
if (error) {

examples/scan_connect.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
var MetaWear = require('../index')//require('metawear');
22

33
// If you know the MAC address, you can uncomment this line
4-
//MetaWear.discoverByAddress('cb:7d:c5:b0:20:8f', function(device) {
5-
MetaWear.discover(function (device) {
4+
MetaWear.discoverByAddress('c8:4b:aa:97:50:05', function(device) {
5+
//MetaWear.discover(function (device) {
66
console.log('got em');
77
// you can be notified of disconnects
88
device.on('disconnect', function () {

lib/metawear.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var debug = require('debug')('metawear');
55
var debugRaw = require('debug')('metaboot');
66

77
var NobleDevice = require('noble-device');
8-
var noble = require('noble');
8+
var noble = require('@abandonware/noble');
99
var ref = require('ref');
1010
var events = require('events');
1111
var util = require('util');
@@ -99,7 +99,7 @@ MetaWear.prototype.writeCommandCharacteristic = function (data, callback) {
9999

100100
MetaWear.prototype.connectAndSetUp = function (callback, initBuf) {
101101
var initializeCallback = (typeof callback === 'function') ? callback : function () { };
102-
102+
103103
NobleDevice.prototype.connectAndSetUp.call(this, function (error) {
104104
if (error) {
105105
initializeCallback(error);

0 commit comments

Comments
 (0)