Skip to content
This repository was archived by the owner on Jul 20, 2025. It is now read-only.

Commit 20b0114

Browse files
committed
release 1.0.0
1 parent 0c35a96 commit 20b0114

File tree

6 files changed

+319
-326
lines changed

6 files changed

+319
-326
lines changed

MetaWear-SDK-Cpp

Submodule MetaWear-SDK-Cpp updated 227 files

examples/log_acc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var ref = require('ref');
88
var accelLogger = null;
99

1010
// If you know the MAC address, you can uncomment this line
11-
MetaWear.discoverByAddress('c8:4b:aa:97:50:05', function (device) {
11+
MetaWear.discoverByAddress('d1:e7:65:2a:ad:6f', function (device) {
1212
//MetaWear.discover(function (device) {
1313
console.log('discovered ' + device.address);
1414
device.connectAndSetUp(function (error) {

examples/log_acc_bmi270.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
var MetaWear = require('../index')//require('metawear');
2+
var ref = require('ref');
3+
// Store the log event for later download. If your program needs to terminate
4+
// before performing the log download, you will need to use mbl_mw_metawearboard_serialize
5+
// to store the device state and that pass that state as the second argument to
6+
// connectAndSetUp when you are ready to download. Use mbl_mw_logger_lookup_id
7+
// to retrieve this accelLogger object
8+
var accelLogger = null;
9+
10+
// If you know the MAC address, you can uncomment this line
11+
MetaWear.discoverByAddress('c7:06:35:93:2d:12', function (device) {
12+
//MetaWear.discover(function (device) {
13+
console.log('discovered ' + device.address);
14+
device.connectAndSetUp(function (error) {
15+
if (error) {
16+
console.log(error);
17+
process.exit(1);
18+
}
19+
console.log('connected ' + device.address);
20+
// Start logging
21+
startLogging(device, function (error) {
22+
if (error) {
23+
console.log(error);
24+
process.exit(1);
25+
}
26+
// Stop logging after 10 seconds
27+
setTimeout(function () {
28+
downloadLog(device, function (error) {
29+
device.once('disconnect', function (reason) {
30+
process.exit(0);
31+
});
32+
MetaWear.mbl_mw_debug_reset(device.board);
33+
});
34+
}, 10000);
35+
});
36+
});
37+
});
38+
39+
function downloadLog(device, callback) {
40+
// Shutdown accel
41+
MetaWear.mbl_mw_acc_stop(device.board);
42+
MetaWear.mbl_mw_acc_disable_acceleration_sampling(device.board);
43+
// Shutdown log
44+
MetaWear.mbl_mw_logging_stop(device.board);
45+
MetaWear.mbl_mw_logging_flush_page(device.board);
46+
// Setup handerl for accel data points
47+
MetaWear.mbl_mw_logger_subscribe(accelLogger, ref.NULL, MetaWear.FnVoid_VoidP_DataP.toPointer(function onSignal(context, dataPtr) {
48+
var data = dataPtr.deref();
49+
var pt = data.parseValue();
50+
console.log(data.epoch + ' ' + pt.x + ',' + pt.y + ',' + pt.z);
51+
}));
52+
// Setup the handlers for events during the download
53+
var downloadHandler = new MetaWear.LogDownloadHandler();
54+
downloadHandler.received_progress_update = MetaWear.FnVoid_VoidP_UInt_UInt.toPointer(function onSignal(context, entriesLeft, totalEntries) {
55+
console.log('received_progress_update entriesLeft:' + entriesLeft + ' totalEntries:' + totalEntries);
56+
if (entriesLeft === 0) {
57+
// Remove all log entries if told to stop logging
58+
MetaWear.mbl_mw_metawearboard_tear_down(device.board);
59+
callback(null);
60+
}
61+
});
62+
downloadHandler.received_unknown_entry = MetaWear.FnVoid_VoidP_UByte_Long_UByteP_UByte.toPointer(function onSignal(context, id, epoch, data, length) {
63+
console.log('received_unknown_entry');
64+
});
65+
downloadHandler.received_unhandled_entry = MetaWear.FnVoid_VoidP_DataP.toPointer(function onSignal(context, dataPtr) {
66+
var data = dataPtr.deref();
67+
var dataPoint = data.parseValue();
68+
console.log('received_unhandled_entry: ' + dataPoint);
69+
});
70+
// Actually start the log download, this will cause all the handlers we setup to be invoked
71+
MetaWear.mbl_mw_logging_download(device.board, 20, downloadHandler.ref());
72+
}
73+
74+
function startLogging(device, callback) {
75+
MetaWear.mbl_mw_acc_set_odr(device.board, 50.0);
76+
MetaWear.mbl_mw_acc_set_range(device.board, 16.0);
77+
MetaWear.mbl_mw_acc_write_acceleration_config(device.board);
78+
79+
// See if we already created a logger
80+
var accSignal = MetaWear.mbl_mw_acc_get_acceleration_data_signal(device.board);
81+
MetaWear.mbl_mw_datasignal_log(accSignal, ref.NULL, MetaWear.FnVoid_VoidP_DataLoggerP.toPointer(function (context, logger) {
82+
accelLogger = logger;
83+
callback(logger.address() ? null : new Error('failed to start logging accel'));
84+
}));
85+
86+
MetaWear.mbl_mw_logging_start(device.board, 0);
87+
MetaWear.mbl_mw_acc_enable_acceleration_sampling(device.board);
88+
MetaWear.mbl_mw_acc_start(device.board);
89+
}

examples/stream_acc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
var MetaWear = require('metawear');
1+
var MetaWear = require('../index.js');
2+
//var MetaWear = require('metawear');
23
var ref = require('ref')
34

45
async function mainAsync(mac) {

0 commit comments

Comments
 (0)