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

Commit c1b2e80

Browse files
author
Stephen Schiffli
committed
Add deserialize
1 parent 7e8d4ab commit c1b2e80

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/metawear.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ MetaWear.prototype.writeCommandCharacteristic = function (data, callback) {
7777
});
7878
};
7979

80-
MetaWear.prototype.connectAndSetUp = function (callback) {
80+
MetaWear.prototype.connectAndSetUp = function (callback, initBuf) {
8181
var initializeCallback = (typeof callback === 'function') ? callback : function () { };
8282

8383
NobleDevice.prototype.connectAndSetUp.call(this, function (error) {
@@ -96,6 +96,10 @@ MetaWear.prototype.connectAndSetUp = function (callback) {
9696
if (this.hasCharacteristic(METAWEAR_SERVICE_UUID, METAWEAR_COMMAND_UUID)) {
9797
this._characteristics[METAWEAR_SERVICE_UUID][METAWEAR_COMMAND_UUID].setMaxListeners(50);
9898
}
99+
// Deserialize if buffer provided
100+
if (initBuf) {
101+
MetaWear.mbl_mw_metawearboard_deserialize(this.board, initBuf, initBuf.length);
102+
}
99103
// Setup the CPP SDK
100104
MetaWear.mbl_mw_metawearboard_initialize(this.board, MetaWear.FnVoid_MetaWearBoardP_Int.toPointer(function onInitialize(board, code) {
101105
// Adjust link speed for macOS only since we can't adujust it elsewhere

0 commit comments

Comments
 (0)