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

Commit bcdb325

Browse files
committed
Support C++ SDK 0.17.0 features
1 parent a8fd64d commit bcdb325

File tree

3 files changed

+241
-224
lines changed

3 files changed

+241
-224
lines changed

lib/metawear.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ MetaWear.prototype.connectAndSetUp = function (callback, initBuf) {
150150
};
151151

152152
// Helper function to parse data types
153-
MetaWear.Data.prototype.parseValue = function () {
153+
MetaWear.Data.prototype.parseValue = function (options) {
154154
var value = ref.reinterpret(this.value, this.length, 0);
155155
switch (this.type_id) {
156156
case MetaWear.DataTypeId.UINT32:
@@ -185,6 +185,20 @@ MetaWear.Data.prototype.parseValue = function () {
185185
return ref.get(value, 0, MetaWear.BoschAnyMotion);
186186
case MetaWear.DataTypeId.CALIBRATION_STATE:
187187
return ref.get(value, 0, MetaWear.CalibrationState);
188+
case MetaWear.DataTypeId.DATA_ARRAY:
189+
if (options === undefined || !('nElem' in options)) {
190+
throw "Missing optional parameter 'nElem' for parsing DataTypeId.DATA_ARRAY value"
191+
}
192+
193+
let mapped = []
194+
let offset = this.length / options['nElem']
195+
196+
for(var i = 0; i < options['nElem']; i++) {
197+
mapped.push(ref.get(value, offset * 0, ref.refType(MetaWear.Data)).deref().parseValue())
198+
}
199+
return mapped
200+
case MetaWear.DataTypeId.BOSCH_TAP:
201+
return ref.get(value, 0, MetaWear.BoschTap);
188202
default:
189203
throw 'Unrecognized data type id: ' + this.type_id;
190204
}

0 commit comments

Comments
 (0)