Added shutdown method for WeDo 2.0 Smart Hub

This commit is contained in:
Nathan Kellenicki 2019-02-04 10:01:35 -08:00
parent 31795fa4b4
commit aaccfb7182
24 changed files with 179 additions and 39 deletions

View File

@ -5585,7 +5585,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -4188,7 +4188,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -2467,7 +2467,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -4444,7 +4444,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -5157,7 +5157,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -3409,7 +3409,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -1018,7 +1018,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -1092,7 +1092,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-171">line 171</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-183">line 183</a>
</li>
</ul>
</dd>
@ -1809,7 +1809,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-180">line 180</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-192">line 192</a>
</li>
</ul>
</dd>
@ -2043,7 +2043,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-151">line 151</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-163">line 163</a>
</li>
</ul>
</dd>
@ -2415,7 +2415,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-100">line 100</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-112">line 112</a>
</li>
</ul>
</dd>
@ -2653,7 +2653,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-196">line 196</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-208">line 208</a>
</li>
</ul>
</dd>
@ -2891,7 +2891,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-117">line 117</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-129">line 129</a>
</li>
</ul>
</dd>
@ -3104,6 +3104,118 @@
</dd>
<hr>
<dt>
<h4 class="name" id="shutdown"><span class="type-signature"></span>shutdown()</h4>
</dt>
<dd>
<div class="description">
<p>Shutdown the Hub.</p>
</div>
<dl class="details">
<dt class="tag-source method-doc-label method-doc-details-label">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-100">line 100</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
<p>Resolved upon successful disconnect.</p>
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Promise</span>
</dd>
</dl>
</dd>
@ -4148,7 +4260,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-280">line 280</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-292">line 292</a>
</li>
</ul>
</dd>
@ -4310,7 +4422,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-325">line 325</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-337">line 337</a>
</li>
</ul>
</dd>
@ -4619,7 +4731,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-314">line 314</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-326">line 326</a>
</li>
</ul>
</dd>
@ -4781,7 +4893,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-355">line 355</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-367">line 367</a>
</li>
</ul>
</dd>
@ -4967,7 +5079,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-343">line 343</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-355">line 355</a>
</li>
</ul>
</dd>
@ -5046,7 +5158,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -349,7 +349,7 @@ exports.BoostMoveHub = BoostMoveHub;
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -5783,7 +5783,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-280">line 280</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-292">line 292</a>
</li>
</ul>
</dd>
@ -5945,7 +5945,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-325">line 325</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-337">line 337</a>
</li>
</ul>
</dd>
@ -6254,7 +6254,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-314">line 314</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-326">line 326</a>
</li>
</ul>
</dd>
@ -6416,7 +6416,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-355">line 355</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-367">line 367</a>
</li>
</ul>
</dd>
@ -6602,7 +6602,7 @@
<ul class="dummy">
<li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-343">line 343</a>
<a href="wedo2smarthub.js.html#sunlight-1-line-355">line 355</a>
</li>
</ul>
</dd>
@ -6681,7 +6681,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -225,6 +225,7 @@ var BLECharacteristic;
BLECharacteristic["WEDO2_LOW_VOLTAGE_ALERT"] = "00001528-1212-efde-1523-785feabcd123";
BLECharacteristic["WEDO2_HIGH_CURRENT_ALERT"] = "00001529-1212-efde-1523-785feabcd123";
BLECharacteristic["WEDO2_LOW_SIGNAL_ALERT"] = "0000152a-1212-efde-1523-785feabcd123";
BLECharacteristic["WEDO2_DISCONNECT"] = "0000152b-1212-efde-1523-785feabcd123";
BLECharacteristic["WEDO2_SENSOR_VALUE"] = "00001560-1212-efde-1523-785feabcd123";
BLECharacteristic["WEDO2_VALUE_FORMAT"] = "00001561-1212-efde-1523-785feabcd123";
BLECharacteristic["WEDO2_PORT_TYPE_WRITE"] = "00001563-1212-efde-1523-785feabcd123";
@ -277,7 +278,7 @@ var BLECharacteristic;
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -298,7 +298,7 @@ exports.DuploTrainBase = DuploTrainBase;
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -3272,7 +3272,7 @@
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -485,7 +485,7 @@ exports.Hub = Hub;
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -314,7 +314,7 @@ poweredUP.scan(); // Start scanning for Hubs</code></pre><p>More examples are av
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -507,7 +507,7 @@ exports.LPF2Hub = LPF2Hub;
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -284,7 +284,7 @@ exports.PoweredUP = PoweredUP;
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -306,7 +306,7 @@ exports.PUPHub = PUPHub;
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -236,7 +236,7 @@ exports.PUPRemote = PUPRemote;
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

File diff suppressed because one or more lines are too long

View File

@ -183,6 +183,18 @@ class WeDo2SmartHub extends hub_1.Hub {
return resolve();
});
}
/**
* Shutdown the Hub.
* @method WeDo2SmartHub#shutdown
* @returns {Promise} Resolved upon successful disconnect.
*/
shutdown() {
return new Promise((resolve, reject) => {
this._writeMessage(Consts.BLECharacteristic.WEDO2_DISCONNECT, Buffer.from([0x00]), () => {
return resolve();
});
});
}
/**
* Set the color of the LED on the Hub via RGB values.
* @method WeDo2SmartHub#setLEDRGB
@ -496,7 +508,7 @@ exports.WeDo2SmartHub = WeDo2SmartHub;
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Fri Feb 1st 2019
on Mon Feb 4th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>

View File

@ -1,6 +1,6 @@
{
"name": "node-poweredup",
"version": "1.8.1",
"version": "1.9.1",
"description": "A Node.js module to interface with LEGO Powered UP components.",
"homepage": "https://github.com/nathankellenicki/node-poweredup/",
"main": "dist/index.js",

View File

@ -142,7 +142,8 @@ export enum BLECharacteristic {
WEDO2_PORT_TYPE = "00001527-1212-efde-1523-785feabcd123", // "1527" // Handles plugging and unplugging of devices on WeDo 2.0 Smart Hub
WEDO2_LOW_VOLTAGE_ALERT = "00001528-1212-efde-1523-785feabcd123", // "1528"
WEDO2_HIGH_CURRENT_ALERT = "00001529-1212-efde-1523-785feabcd123", // "1529"
WEDO2_LOW_SIGNAL_ALERT = "0000152a-1212-efde-1523-785feabcd123", // "152a"
WEDO2_LOW_SIGNAL_ALERT = "0000152a-1212-efde-1523-785feabcd123", // "152a",
WEDO2_DISCONNECT = "0000152b-1212-efde-1523-785feabcd123", // "152b"
WEDO2_SENSOR_VALUE = "00001560-1212-efde-1523-785feabcd123", // "1560"
WEDO2_VALUE_FORMAT = "00001561-1212-efde-1523-785feabcd123", // "1561"
WEDO2_PORT_TYPE_WRITE = "00001563-1212-efde-1523-785feabcd123", // "1563"

View File

@ -111,6 +111,20 @@ export class WeDo2SmartHub extends Hub {
}
/**
* Shutdown the Hub.
* @method WeDo2SmartHub#shutdown
* @returns {Promise} Resolved upon successful disconnect.
*/
public shutdown () {
return new Promise((resolve, reject) => {
this._writeMessage(Consts.BLECharacteristic.WEDO2_DISCONNECT, Buffer.from([0x00]), () => {
return resolve();
});
});
}
/**
* Set the color of the LED on the Hub via RGB values.
* @method WeDo2SmartHub#setLEDRGB