Comparing version 0.1.2 to 0.2.0
@@ -6,2 +6,3 @@ | ||
var MetaWear = require('../index')//require('metawear'); | ||
var ref = require('ref') | ||
@@ -13,4 +14,4 @@ // MetaWear.discoverByAddress('f6:3d:13:48:ce:ab', function (device) { | ||
console.log('connected!'); | ||
MetaWear.mbl_mw_metawearboard_create_anonymous_datasignals(device.board, | ||
MetaWear.FnVoid_MetaWearBoardP_AnonymousDataSignalP_UInt.toPointer(function (board, anonymousSignals, size) { | ||
MetaWear.mbl_mw_metawearboard_create_anonymous_datasignals(device.board, ref.NULL, | ||
MetaWear.FnVoid_VoidP_MetaWearBoardP_AnonymousDataSignalP_UInt.toPointer(function (context, board, anonymousSignals, size) { | ||
if (!anonymousSignals) { | ||
@@ -25,3 +26,3 @@ console.log('nothing being logged'); | ||
var identifier = MetaWear.mbl_mw_anonymous_datasignal_get_identifier(anonymousSignals[i]); | ||
MetaWear.mbl_mw_anonymous_datasignal_subscribe(anonymousSignals[i], MetaWear.FnVoid_DataP.toPointer(function onSignal(dataPtr) { | ||
MetaWear.mbl_mw_anonymous_datasignal_subscribe(anonymousSignals[i], ref.NULL, MetaWear.FnVoid_VoidP_DataP.toPointer(function onSignal(context, dataPtr) { | ||
var data = dataPtr.deref(); | ||
@@ -47,3 +48,3 @@ var pt = data.parseValue(); | ||
var downloadHandler = new MetaWear.LogDownloadHandler(); | ||
downloadHandler.received_progress_update = MetaWear.FnVoid_UInt_UInt.toPointer(function onSignal(entriesLeft, totalEntries) { | ||
downloadHandler.received_progress_update = MetaWear.FnVoid_VoidP_UInt_UInt.toPointer(function onSignal(context, entriesLeft, totalEntries) { | ||
console.log('received_progress_update entriesLeft:' + entriesLeft + ' totalEntries:' + totalEntries); | ||
@@ -54,6 +55,6 @@ if (entriesLeft === 0) { | ||
}); | ||
downloadHandler.received_unknown_entry = MetaWear.FnVoid_UByte_Long_UByteP_UByte.toPointer(function onSignal(id, epoch, data, length) { | ||
downloadHandler.received_unknown_entry = MetaWear.FnVoid_VoidP_UByte_Long_UByteP_UByte.toPointer(function onSignal(context, id, epoch, data, length) { | ||
console.log('received_unknown_entry'); | ||
}); | ||
downloadHandler.received_unhandled_entry = MetaWear.FnVoid_DataP.toPointer(function onSignal(dataPtr) { | ||
downloadHandler.received_unhandled_entry = MetaWear.FnVoid_VoidP_DataP.toPointer(function onSignal(context, dataPtr) { | ||
var data = dataPtr.deref(); | ||
@@ -60,0 +61,0 @@ var dataPoint = data.parseValue(); |
var MetaWear = require('../index')//require('metawear'); | ||
var ref = require('ref'); | ||
// Store the log event for later download. If your program needs to terminate | ||
@@ -45,3 +46,3 @@ // before performing the log download, you will need to use mbl_mw_metawearboard_serialize | ||
// Setup handerl for accel data points | ||
MetaWear.mbl_mw_logger_subscribe(accelLogger, MetaWear.FnVoid_DataP.toPointer(function onSignal(dataPtr) { | ||
MetaWear.mbl_mw_logger_subscribe(accelLogger, ref.NULL, MetaWear.FnVoid_VoidP_DataP.toPointer(function onSignal(context, dataPtr) { | ||
var data = dataPtr.deref(); | ||
@@ -53,3 +54,3 @@ var pt = data.parseValue(); | ||
var downloadHandler = new MetaWear.LogDownloadHandler(); | ||
downloadHandler.received_progress_update = MetaWear.FnVoid_UInt_UInt.toPointer(function onSignal(entriesLeft, totalEntries) { | ||
downloadHandler.received_progress_update = MetaWear.FnVoid_VoidP_UInt_UInt.toPointer(function onSignal(context, entriesLeft, totalEntries) { | ||
console.log('received_progress_update entriesLeft:' + entriesLeft + ' totalEntries:' + totalEntries); | ||
@@ -62,6 +63,6 @@ if (entriesLeft === 0) { | ||
}); | ||
downloadHandler.received_unknown_entry = MetaWear.FnVoid_UByte_Long_UByteP_UByte.toPointer(function onSignal(id, epoch, data, length) { | ||
downloadHandler.received_unknown_entry = MetaWear.FnVoid_VoidP_UByte_Long_UByteP_UByte.toPointer(function onSignal(context, id, epoch, data, length) { | ||
console.log('received_unknown_entry'); | ||
}); | ||
downloadHandler.received_unhandled_entry = MetaWear.FnVoid_DataP.toPointer(function onSignal(dataPtr) { | ||
downloadHandler.received_unhandled_entry = MetaWear.FnVoid_VoidP_DataP.toPointer(function onSignal(context, dataPtr) { | ||
var data = dataPtr.deref(); | ||
@@ -80,10 +81,12 @@ var dataPoint = data.parseValue(); | ||
MetaWear.mbl_mw_acc_enable_acceleration_sampling(device.board); | ||
MetaWear.mbl_mw_acc_start(device.board); | ||
// See if we already created a logger | ||
var accSignal = MetaWear.mbl_mw_acc_get_acceleration_data_signal(device.board); | ||
MetaWear.mbl_mw_datasignal_log(accSignal, MetaWear.FnVoid_DataLoggerP.toPointer(function (logger) { | ||
MetaWear.mbl_mw_datasignal_log(accSignal, ref.NULL, MetaWear.FnVoid_VoidP_DataLoggerP.toPointer(function (context, logger) { | ||
accelLogger = logger; | ||
callback(logger.address() ? null : new Error('failed to start logging accel')); | ||
})); | ||
MetaWear.mbl_mw_logging_start(device.board, 0); | ||
MetaWear.mbl_mw_acc_enable_acceleration_sampling(device.board); | ||
MetaWear.mbl_mw_acc_start(device.board); | ||
} |
var MetaWear = require('../index')//require('metawear'); | ||
var fs = require('fs'); | ||
var ref = require('ref'); | ||
@@ -42,3 +43,3 @@ var addresses = [ | ||
var accSignal = MetaWear.mbl_mw_acc_get_acceleration_data_signal(device.board); | ||
MetaWear.mbl_mw_datasignal_subscribe(accSignal, MetaWear.FnVoid_DataP.toPointer(function gotTimer(dataPtr) { | ||
MetaWear.mbl_mw_datasignal_subscribe(accSignal, ref.NULL, MetaWear.FnVoid_VoidP_DataP.toPointer(function gotTimer(context, dataPtr) { | ||
var data = dataPtr.deref(); | ||
@@ -45,0 +46,0 @@ var pt = data.parseValue(); |
@@ -8,2 +8,3 @@ /** | ||
var NobleDevice = require('noble-device'); | ||
var noble = require('noble'); | ||
var ref = require('ref'); | ||
@@ -45,6 +46,7 @@ var events = require('events'); | ||
var connection = new MetaWear.BtleConnection(); | ||
connection.write_gatt_char = MetaWear.FnVoid_VoidP_GattCharWriteType_GattCharP_UByteP_UByte.toPointer(writeGattChar.bind(this)); | ||
connection.read_gatt_char = MetaWear.FnVoid_VoidP_GattCharP_FnIntVoidPtrArray.toPointer(readGattChar.bind(this)); | ||
connection.enable_notifications = MetaWear.FnVoid_VoidP_GattCharP_FnIntVoidPtrArray_FnVoidVoidPtrInt.toPointer(enableNotifications.bind(this)); | ||
connection.on_disconnect = MetaWear.FnVoid_VoidP_FnVoidVoidPtrInt.toPointer(onDisconnect.bind(this)); | ||
connection.context = ref.NULL; | ||
connection.write_gatt_char = MetaWear.FnVoid_VoidP_VoidP_GattCharWriteType_GattCharP_UByteP_UByte.toPointer(writeGattChar.bind(this)); | ||
connection.read_gatt_char = MetaWear.FnVoid_VoidP_VoidP_GattCharP_FnIntVoidPtrArray.toPointer(readGattChar.bind(this)); | ||
connection.enable_notifications = MetaWear.FnVoid_VoidP_VoidP_GattCharP_FnIntVoidPtrArray_FnVoidVoidPtrInt.toPointer(enableNotifications.bind(this)); | ||
connection.on_disconnect = MetaWear.FnVoid_VoidP_VoidP_FnVoidVoidPtrInt.toPointer(onDisconnect.bind(this)); | ||
this.board = MetaWear.mbl_mw_metawearboard_create(connection.ref()); | ||
@@ -69,2 +71,20 @@ // No timeout during debug and enabling | ||
MetaWear.spoof = function (address) { | ||
var addressType = 'random' | ||
var connectable = true | ||
var advertisement = { | ||
localName: 'MetaWear', | ||
txPowerLevel: undefined, | ||
manufacturerData: undefined, | ||
serviceData: [], | ||
serviceUuids: ['326a900085cb9195d9dd464cfbbae75a'], | ||
solicitationServiceUuids: [], | ||
serviceSolicitationUuids: [] | ||
}; | ||
var rssi = -27; | ||
var readToTriggerNobleInit = noble.state; | ||
var peripheral = noble.spoofPeripheral(address.toLowerCase(), addressType, connectable, advertisement, rssi); | ||
return new MetaWear(peripheral); | ||
}; | ||
MetaWear.prototype.writeCommandCharacteristic = function (data, callback) { | ||
@@ -107,4 +127,4 @@ var sanitaizedCallback = (typeof callback === 'function') ? callback : function () { }; | ||
// Setup the CPP SDK | ||
MetaWear.mbl_mw_metawearboard_initialize(this.board, MetaWear.FnVoid_MetaWearBoardP_Int.toPointer(function onInitialize(board, code) { | ||
// Adjust link speed for macOS only since we can't adujust it elsewhere | ||
MetaWear.mbl_mw_metawearboard_initialize(this.board, ref.NULL, MetaWear.FnVoid_VoidP_MetaWearBoardP_Int.toPointer(function onInitialize(context, board, code) { | ||
// Adjust link speed for macOS only since we can't adjust it elsewhere | ||
if (os.platform() === 'darwin') { | ||
@@ -164,2 +184,10 @@ MetaWear.mbl_mw_settings_set_connection_parameters(this.board, 15.0, 15.0, 0, 4000); | ||
return MetaWear.SensorOrientation.enums[ref.get(value, 0, ref.types.int32)]; | ||
case MetaWear.DataTypeId.LOGGING_TIME: | ||
return ref.get(value, 0, MetaWear.LoggingTime); | ||
case MetaWear.DataTypeId.BTLE_ADDRESS: | ||
return ref.get(value, 0, MetaWear.BtleAddress); | ||
case MetaWear.DataTypeId.BOSCH_ANY_MOTION: | ||
return ref.get(value, 0, MetaWear.BoschAnyMotion); | ||
case MetaWear.DataTypeId.CALIBRATION_STATE: | ||
return ref.get(value, 0, MetaWear.CalibrationState); | ||
default: | ||
@@ -191,3 +219,3 @@ throw 'Unrecognized data type id: ' + this.type_id; | ||
function writeGattChar(caller, writeType, characteristicPtr, valuePtr, length) { | ||
function writeGattChar(context, caller, writeType, characteristicPtr, valuePtr, length) { | ||
var data = ref.reinterpret(valuePtr, length, 0); | ||
@@ -219,3 +247,3 @@ var characteristic = new NativeGattChar(characteristicPtr); | ||
function readGattChar(caller, characteristicPtr, callback) { | ||
function readGattChar(context, caller, characteristicPtr, callback) { | ||
var characteristic = new NativeGattChar(characteristicPtr); | ||
@@ -236,3 +264,3 @@ var charToRead = this._characteristics[characteristic.shortServiceUUID][characteristic.shortCharacteristicUUID]; | ||
function enableNotifications(caller, characteristicPtr, onData, subscribeComplete) { | ||
function enableNotifications(context, caller, characteristicPtr, onData, subscribeComplete) { | ||
var characteristic = new NativeGattChar(characteristicPtr); | ||
@@ -260,3 +288,3 @@ var charToNotify = this._characteristics[characteristic.serviceUUID][characteristic.characteristicUUID]; | ||
function onDisconnect(caller, handler) { | ||
function onDisconnect(context, caller, handler) { | ||
this.once('disconnect', function () { | ||
@@ -329,7 +357,8 @@ handler(caller, 0); | ||
var delegate = new MetaWear.DfuDelegate(); | ||
delegate.on_dfu_started = MetaWear.FnVoid.toPointer(onDfuStarted.bind(this)); | ||
delegate.on_dfu_cancelled = MetaWear.FnVoid.toPointer(onDfuCancelled.bind(this)); | ||
delegate.on_transfer_percentage = MetaWear.FnVoid_Int.toPointer(onTransferPercentage.bind(this)); | ||
delegate.on_successful_file_transferred = MetaWear.FnVoid.toPointer(onSuccessfulFileTransfer.bind(this)); | ||
delegate.on_error = MetaWear.FnVoid_charP.toPointer(onError.bind(this)); | ||
delegate.context = ref.NULL; | ||
delegate.on_dfu_started = MetaWear.FnVoid_VoidP.toPointer(onDfuStarted.bind(this)); | ||
delegate.on_dfu_cancelled = MetaWear.FnVoid_VoidP.toPointer(onDfuCancelled.bind(this)); | ||
delegate.on_transfer_percentage = MetaWear.FnVoid_VoidP_Int.toPointer(onTransferPercentage.bind(this)); | ||
delegate.on_successful_file_transferred = MetaWear.FnVoid_VoidP.toPointer(onSuccessfulFileTransfer.bind(this)); | ||
delegate.on_error = MetaWear.FnVoid_VoidP_charP.toPointer(onError.bind(this)); | ||
MetaWear.mbl_mw_metawearboard_perform_dfu(this.board, delegate.ref(), ref.allocCString(filename)); | ||
@@ -404,10 +433,10 @@ } | ||
// | ||
function onDfuStarted() { | ||
function onDfuStarted(context) { | ||
this.emit('dfuStarted'); | ||
debug('onDfuStarted'); | ||
} | ||
function onDfuCancelled() { | ||
function onDfuCancelled(context) { | ||
debug('onDfuCancelled'); | ||
} | ||
function onTransferPercentage(percentage) { | ||
function onTransferPercentage(context, percentage) { | ||
debug('transferPercentage ' + percentage); | ||
@@ -417,7 +446,7 @@ this.percentage = percentage; | ||
} | ||
function onSuccessfulFileTransfer() { | ||
function onSuccessfulFileTransfer(context) { | ||
debug('onSuccessfulFileTransfer'); | ||
this.emit('onSuccessfulFileTransfer'); | ||
} | ||
function onError(message) { | ||
function onError(context, message) { | ||
debug('dfu error: ' + message); | ||
@@ -424,0 +453,0 @@ invokeAndClearCallback.call(this, new Error(message)); |
@@ -7,3 +7,3 @@ # MetaWear C++ API # | ||
# Build # | ||
Building the project has been tested on \*nix systems with Clang 4.0.0, and on Windows with Visual Studio Community 2017. | ||
Building the project has been tested on \*nix systems with Clang 4, and on Windows with Visual Studio Community 2017. | ||
@@ -43,4 +43,4 @@ ```sh | ||
├── libmetawear.so -> libmetawear.so.0 | ||
├── libmetawear.so.0 -> libmetawear.so.0.11.0 | ||
└── libmetawear.so.0.11.0 | ||
├── libmetawear.so.0 -> libmetawear.so.0.15.2 | ||
└── libmetawear.so.0.15.2 | ||
@@ -96,6 +96,7 @@ ``` | ||
................................................................................ | ||
...................................................s............................ | ||
.......................................................... | ||
................................................................................ | ||
...................s............................................................ | ||
................................. | ||
---------------------------------------------------------------------- | ||
Ran 378 tests in 17.750s | ||
Ran 433 tests in 27.417s | ||
@@ -102,0 +103,0 @@ OK (skipped=1) |
{ | ||
"name": "metawear", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"author": "Stephen Schiffli <stephen@mbientlab.com>", | ||
@@ -28,3 +28,3 @@ "license": "SEE LICENSE IN LICENSE", | ||
"dependencies": { | ||
"noble-device": "git://github.com/mbientlab/noble-device.git#7c8bccf", | ||
"noble-device": "git://github.com/mbientlab/noble-device.git#205d172", | ||
"ref": "^1.3.5", | ||
@@ -31,0 +31,0 @@ "ffi": "git://github.com/king6cong/node-ffi.git#ce274be", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
2134733
278
3456