Web Bluetooth WeDo 2.0 support

This commit is contained in:
Nathan Kellenicki 2019-02-06 17:46:59 -08:00
parent e7b5e977d9
commit edf5606814
29 changed files with 4602 additions and 255 deletions

View File

@ -1376,7 +1376,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-147">line 147</a> <a href="hub.js.html#sunlight-1-line-103">line 103</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1502,7 +1502,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-211">line 211</a> <a href="hub.js.html#sunlight-1-line-167">line 167</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1674,7 +1674,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-219">line 219</a> <a href="hub.js.html#sunlight-1-line-175">line 175</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3499,7 +3499,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-187">line 187</a> <a href="hub.js.html#sunlight-1-line-143">line 143</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3719,7 +3719,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-155">line 155</a> <a href="hub.js.html#sunlight-1-line-111">line 111</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3895,7 +3895,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-173">line 173</a> <a href="hub.js.html#sunlight-1-line-129">line 129</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4072,7 +4072,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-200">line 200</a> <a href="hub.js.html#sunlight-1-line-156">line 156</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4280,7 +4280,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-256">line 256</a> <a href="hub.js.html#sunlight-1-line-212">line 212</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4969,7 +4969,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-268">line 268</a> <a href="hub.js.html#sunlight-1-line-224">line 224</a>
</li> </li>
</ul> </ul>
</dd> </dd>

View File

@ -1376,7 +1376,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-147">line 147</a> <a href="hub.js.html#sunlight-1-line-103">line 103</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1502,7 +1502,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-211">line 211</a> <a href="hub.js.html#sunlight-1-line-167">line 167</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1674,7 +1674,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-219">line 219</a> <a href="hub.js.html#sunlight-1-line-175">line 175</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3162,7 +3162,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-187">line 187</a> <a href="hub.js.html#sunlight-1-line-143">line 143</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3382,7 +3382,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-155">line 155</a> <a href="hub.js.html#sunlight-1-line-111">line 111</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3558,7 +3558,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-173">line 173</a> <a href="hub.js.html#sunlight-1-line-129">line 129</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3735,7 +3735,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-200">line 200</a> <a href="hub.js.html#sunlight-1-line-156">line 156</a>
</li> </li>
</ul> </ul>
</dd> </dd>

View File

@ -1096,7 +1096,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-147">line 147</a> <a href="hub.js.html#sunlight-1-line-103">line 103</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1208,7 +1208,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-211">line 211</a> <a href="hub.js.html#sunlight-1-line-167">line 167</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1366,7 +1366,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-219">line 219</a> <a href="hub.js.html#sunlight-1-line-175">line 175</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1525,7 +1525,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-187">line 187</a> <a href="hub.js.html#sunlight-1-line-143">line 143</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1731,7 +1731,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-155">line 155</a> <a href="hub.js.html#sunlight-1-line-111">line 111</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1893,7 +1893,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-173">line 173</a> <a href="hub.js.html#sunlight-1-line-129">line 129</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2056,7 +2056,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-200">line 200</a> <a href="hub.js.html#sunlight-1-line-156">line 156</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2250,7 +2250,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-256">line 256</a> <a href="hub.js.html#sunlight-1-line-212">line 212</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2388,7 +2388,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-268">line 268</a> <a href="hub.js.html#sunlight-1-line-224">line 224</a>
</li> </li>
</ul> </ul>
</dd> </dd>

View File

@ -1173,7 +1173,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-147">line 147</a> <a href="hub.js.html#sunlight-1-line-103">line 103</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1294,7 +1294,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-211">line 211</a> <a href="hub.js.html#sunlight-1-line-167">line 167</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1461,7 +1461,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-219">line 219</a> <a href="hub.js.html#sunlight-1-line-175">line 175</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2275,7 +2275,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-187">line 187</a> <a href="hub.js.html#sunlight-1-line-143">line 143</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2490,7 +2490,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-155">line 155</a> <a href="hub.js.html#sunlight-1-line-111">line 111</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2661,7 +2661,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-173">line 173</a> <a href="hub.js.html#sunlight-1-line-129">line 129</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2833,7 +2833,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-200">line 200</a> <a href="hub.js.html#sunlight-1-line-156">line 156</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3036,7 +3036,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-256">line 256</a> <a href="hub.js.html#sunlight-1-line-212">line 212</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3693,7 +3693,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-268">line 268</a> <a href="hub.js.html#sunlight-1-line-224">line 224</a>
</li> </li>
</ul> </ul>
</dd> </dd>

View File

@ -1376,7 +1376,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-147">line 147</a> <a href="hub.js.html#sunlight-1-line-103">line 103</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1502,7 +1502,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-211">line 211</a> <a href="hub.js.html#sunlight-1-line-167">line 167</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1674,7 +1674,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-219">line 219</a> <a href="hub.js.html#sunlight-1-line-175">line 175</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3242,7 +3242,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-187">line 187</a> <a href="hub.js.html#sunlight-1-line-143">line 143</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3462,7 +3462,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-155">line 155</a> <a href="hub.js.html#sunlight-1-line-111">line 111</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3638,7 +3638,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-173">line 173</a> <a href="hub.js.html#sunlight-1-line-129">line 129</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3815,7 +3815,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-200">line 200</a> <a href="hub.js.html#sunlight-1-line-156">line 156</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4023,7 +4023,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-256">line 256</a> <a href="hub.js.html#sunlight-1-line-212">line 212</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4712,7 +4712,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-268">line 268</a> <a href="hub.js.html#sunlight-1-line-224">line 224</a>
</li> </li>
</ul> </ul>
</dd> </dd>

View File

@ -1214,7 +1214,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-147">line 147</a> <a href="hub.js.html#sunlight-1-line-103">line 103</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1340,7 +1340,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-211">line 211</a> <a href="hub.js.html#sunlight-1-line-167">line 167</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1512,7 +1512,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-219">line 219</a> <a href="hub.js.html#sunlight-1-line-175">line 175</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2359,7 +2359,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-187">line 187</a> <a href="hub.js.html#sunlight-1-line-143">line 143</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2579,7 +2579,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-155">line 155</a> <a href="hub.js.html#sunlight-1-line-111">line 111</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2755,7 +2755,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-173">line 173</a> <a href="hub.js.html#sunlight-1-line-129">line 129</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2932,7 +2932,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-200">line 200</a> <a href="hub.js.html#sunlight-1-line-156">line 156</a>
</li> </li>
</ul> </ul>
</dd> </dd>

View File

@ -148,8 +148,8 @@
<dd class="tag-source"> <dd class="tag-source">
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="poweredup.js.html">poweredup.js</a>, <a href="poweredup-node.js.html">poweredup-node.js</a>,
<a href="poweredup.js.html#sunlight-1-line-45">line 45</a> <a href="poweredup-node.js.html#sunlight-1-line-45">line 45</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -315,8 +315,8 @@
<dd class="tag-source"> <dd class="tag-source">
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="poweredup.js.html">poweredup.js</a>, <a href="poweredup-node.js.html">poweredup-node.js</a>,
<a href="poweredup.js.html#sunlight-1-line-91">line 91</a> <a href="poweredup-node.js.html#sunlight-1-line-91">line 91</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -426,8 +426,8 @@
<dd class="tag-source"> <dd class="tag-source">
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="poweredup.js.html">poweredup.js</a>, <a href="poweredup-node.js.html">poweredup-node.js</a>,
<a href="poweredup.js.html#sunlight-1-line-83">line 83</a> <a href="poweredup-node.js.html#sunlight-1-line-83">line 83</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -584,8 +584,8 @@
<dd class="tag-source"> <dd class="tag-source">
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="poweredup.js.html">poweredup.js</a>, <a href="poweredup-node.js.html">poweredup-node.js</a>,
<a href="poweredup.js.html#sunlight-1-line-100">line 100</a> <a href="poweredup-node.js.html#sunlight-1-line-100">line 100</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -692,8 +692,8 @@
<dd class="tag-source"> <dd class="tag-source">
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="poweredup.js.html">poweredup.js</a>, <a href="poweredup-node.js.html">poweredup-node.js</a>,
<a href="poweredup.js.html#sunlight-1-line-56">line 56</a> <a href="poweredup-node.js.html#sunlight-1-line-56">line 56</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -780,8 +780,8 @@
<dd class="tag-source"> <dd class="tag-source">
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="poweredup.js.html">poweredup.js</a>, <a href="poweredup-node.js.html">poweredup-node.js</a>,
<a href="poweredup.js.html#sunlight-1-line-71">line 71</a> <a href="poweredup-node.js.html#sunlight-1-line-71">line 71</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -938,8 +938,8 @@
<dd class="tag-source"> <dd class="tag-source">
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="poweredup.js.html">poweredup.js</a>, <a href="poweredup-node.js.html">poweredup-node.js</a>,
<a href="poweredup.js.html#sunlight-1-line-148">line 148</a> <a href="poweredup-node.js.html#sunlight-1-line-148">line 148</a>
</li> </li>
</ul> </ul>
</dd> </dd>

View File

@ -153,7 +153,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-15">line 15</a> <a href="wedo2smarthub.js.html#sunlight-1-line-16">line 16</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1092,7 +1092,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-195">line 195</a> <a href="wedo2smarthub.js.html#sunlight-1-line-221">line 221</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1339,7 +1339,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-147">line 147</a> <a href="hub.js.html#sunlight-1-line-103">line 103</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1460,7 +1460,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-211">line 211</a> <a href="hub.js.html#sunlight-1-line-167">line 167</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1627,7 +1627,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-219">line 219</a> <a href="hub.js.html#sunlight-1-line-175">line 175</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1809,7 +1809,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-204">line 204</a> <a href="wedo2smarthub.js.html#sunlight-1-line-230">line 230</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2043,7 +2043,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-175">line 175</a> <a href="wedo2smarthub.js.html#sunlight-1-line-201">line 201</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2205,7 +2205,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-94">line 94</a> <a href="wedo2smarthub.js.html#sunlight-1-line-120">line 120</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2415,7 +2415,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-124">line 124</a> <a href="wedo2smarthub.js.html#sunlight-1-line-150">line 150</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2653,7 +2653,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-220">line 220</a> <a href="wedo2smarthub.js.html#sunlight-1-line-246">line 246</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2891,7 +2891,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-141">line 141</a> <a href="wedo2smarthub.js.html#sunlight-1-line-167">line 167</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3053,7 +3053,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-75">line 75</a> <a href="wedo2smarthub.js.html#sunlight-1-line-101">line 101</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3165,7 +3165,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-112">line 112</a> <a href="wedo2smarthub.js.html#sunlight-1-line-138">line 138</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3337,7 +3337,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-187">line 187</a> <a href="hub.js.html#sunlight-1-line-143">line 143</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3552,7 +3552,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-155">line 155</a> <a href="hub.js.html#sunlight-1-line-111">line 111</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3723,7 +3723,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-173">line 173</a> <a href="hub.js.html#sunlight-1-line-129">line 129</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3895,7 +3895,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-200">line 200</a> <a href="hub.js.html#sunlight-1-line-156">line 156</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4098,7 +4098,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-256">line 256</a> <a href="hub.js.html#sunlight-1-line-212">line 212</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4260,7 +4260,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-301">line 301</a> <a href="wedo2smarthub.js.html#sunlight-1-line-326">line 326</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4422,7 +4422,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-346">line 346</a> <a href="wedo2smarthub.js.html#sunlight-1-line-371">line 371</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4569,7 +4569,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-268">line 268</a> <a href="hub.js.html#sunlight-1-line-224">line 224</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4731,7 +4731,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-335">line 335</a> <a href="wedo2smarthub.js.html#sunlight-1-line-360">line 360</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4893,7 +4893,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-376">line 376</a> <a href="wedo2smarthub.js.html#sunlight-1-line-401">line 401</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -5079,7 +5079,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-364">line 364</a> <a href="wedo2smarthub.js.html#sunlight-1-line-389">line 389</a>
</li> </li>
</ul> </ul>
</dd> </dd>

View File

@ -115,8 +115,8 @@ class BoostMoveHub extends lpf2hub_1.LPF2Hub {
peripheral.advertisement.serviceUuids &amp;&amp; peripheral.advertisement.serviceUuids &amp;&amp;
peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &amp;&amp; peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.BOOST_MOVE_HUB_ID); peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &amp;&amp; peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.BOOST_MOVE_HUB_ID);
} }
constructor(peripheral, autoSubscribe = true) { constructor(device, autoSubscribe = true) {
super(peripheral, autoSubscribe); super(device, autoSubscribe);
this.type = Consts.HubType.BOOST_MOVE_HUB; this.type = Consts.HubType.BOOST_MOVE_HUB;
this._ports = { this._ports = {
"A": new port_1.Port("A", 55), "A": new port_1.Port("A", 55),
@ -306,7 +306,7 @@ class BoostMoveHub extends lpf2hub_1.LPF2Hub {
} }
} }
exports.BoostMoveHub = BoostMoveHub; exports.BoostMoveHub = BoostMoveHub;
</pre> //# sourceMappingURL=boostmovehub.js.map</pre>
</article> </article>
</section> </section>

View File

@ -335,7 +335,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-256">line 256</a> <a href="hub.js.html#sunlight-1-line-212">line 212</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -1024,7 +1024,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-268">line 268</a> <a href="hub.js.html#sunlight-1-line-224">line 224</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2065,7 +2065,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-256">line 256</a> <a href="hub.js.html#sunlight-1-line-212">line 212</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2203,7 +2203,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-268">line 268</a> <a href="hub.js.html#sunlight-1-line-224">line 224</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -2374,7 +2374,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-256">line 256</a> <a href="hub.js.html#sunlight-1-line-212">line 212</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3031,7 +3031,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-268">line 268</a> <a href="hub.js.html#sunlight-1-line-224">line 224</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -3852,8 +3852,8 @@
<dd class="tag-source"> <dd class="tag-source">
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="poweredup.js.html">poweredup.js</a>, <a href="poweredup-node.js.html">poweredup-node.js</a>,
<a href="poweredup.js.html#sunlight-1-line-148">line 148</a> <a href="poweredup-node.js.html#sunlight-1-line-148">line 148</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4029,7 +4029,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-256">line 256</a> <a href="hub.js.html#sunlight-1-line-212">line 212</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -4718,7 +4718,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-268">line 268</a> <a href="hub.js.html#sunlight-1-line-224">line 224</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -5621,7 +5621,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-256">line 256</a> <a href="hub.js.html#sunlight-1-line-212">line 212</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -5783,7 +5783,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-301">line 301</a> <a href="wedo2smarthub.js.html#sunlight-1-line-326">line 326</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -5945,7 +5945,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-346">line 346</a> <a href="wedo2smarthub.js.html#sunlight-1-line-371">line 371</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -6092,7 +6092,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="hub.js.html">hub.js</a>, <a href="hub.js.html">hub.js</a>,
<a href="hub.js.html#sunlight-1-line-268">line 268</a> <a href="hub.js.html#sunlight-1-line-224">line 224</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -6254,7 +6254,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-335">line 335</a> <a href="wedo2smarthub.js.html#sunlight-1-line-360">line 360</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -6416,7 +6416,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-376">line 376</a> <a href="wedo2smarthub.js.html#sunlight-1-line-401">line 401</a>
</li> </li>
</ul> </ul>
</dd> </dd>
@ -6602,7 +6602,7 @@
<ul class="dummy"> <ul class="dummy">
<li> <li>
<a href="wedo2smarthub.js.html">wedo2smarthub.js</a>, <a href="wedo2smarthub.js.html">wedo2smarthub.js</a>,
<a href="wedo2smarthub.js.html#sunlight-1-line-364">line 364</a> <a href="wedo2smarthub.js.html#sunlight-1-line-389">line 389</a>
</li> </li>
</ul> </ul>
</dd> </dd>

View File

@ -237,7 +237,7 @@ var BLECharacteristic;
BLECharacteristic["WEDO2_NAME_ID"] = "00001524-1212-efde-1523-785feabcd123"; BLECharacteristic["WEDO2_NAME_ID"] = "00001524-1212-efde-1523-785feabcd123";
BLECharacteristic["LPF2_ALL"] = "00001624-1212-efde-1623-785feabcd123"; BLECharacteristic["LPF2_ALL"] = "00001624-1212-efde-1623-785feabcd123";
})(BLECharacteristic = exports.BLECharacteristic || (exports.BLECharacteristic = {})); })(BLECharacteristic = exports.BLECharacteristic || (exports.BLECharacteristic = {}));
</pre> //# sourceMappingURL=consts.js.map</pre>
</article> </article>
</section> </section>

View File

@ -139,8 +139,8 @@ class DuploTrainBase extends lpf2hub_1.LPF2Hub {
peripheral.advertisement.serviceUuids &amp;&amp; peripheral.advertisement.serviceUuids &amp;&amp;
peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &amp;&amp; peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.DUPLO_TRAIN_HUB_ID); peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &amp;&amp; peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.DUPLO_TRAIN_HUB_ID);
} }
constructor(peripheral, autoSubscribe = true) { constructor(device, autoSubscribe = true) {
super(peripheral, autoSubscribe); super(device, autoSubscribe);
this.type = Consts.HubType.DUPLO_TRAIN_HUB; this.type = Consts.HubType.DUPLO_TRAIN_HUB;
this._ports = { this._ports = {
"MOTOR": new port_1.Port("MOTOR", 0), "MOTOR": new port_1.Port("MOTOR", 0),
@ -255,7 +255,7 @@ class DuploTrainBase extends lpf2hub_1.LPF2Hub {
} }
} }
exports.DuploTrainBase = DuploTrainBase; exports.DuploTrainBase = DuploTrainBase;
</pre> //# sourceMappingURL=duplotrainbase.js.map</pre>
</article> </article>
</section> </section>

View File

@ -175,7 +175,6 @@ class Hub extends events_1.EventEmitter {
*/ */
connect() { connect() {
return new Promise(async (connectResolve, connectReject) => { return new Promise(async (connectResolve, connectReject) => {
const self = this;
if (this._isConnecting) { if (this._isConnecting) {
return connectReject("Already connecting"); return connectReject("Already connecting");
} }
@ -185,49 +184,6 @@ class Hub extends events_1.EventEmitter {
this._isConnecting = true; this._isConnecting = true;
await this._bleDevice.connect(); await this._bleDevice.connect();
return connectResolve(); return connectResolve();
// this._peripheral.connect((err: string) => {
// this._rssi = this._peripheral.rssi;
// const rssiUpdateInterval = setInterval(() => {
// this._peripheral.updateRssi((err: string, rssi: number) => {
// if (!err) {
// if (this._rssi !== rssi) {
// this._rssi = rssi;
// }
// }
// });
// }, 2000);
// self._peripheral.on("disconnect", () => {
// clearInterval(rssiUpdateInterval);
// this._isConnecting = false;
// this._isConnected = false;
// this.emit("disconnect");
// });
// self._peripheral.discoverServices([], (err: string, services: Service[]) => {
// if (err) {
// this.emit("error", err);
// return;
// }
// debug("Service/characteristic discovery started");
// const servicePromises: Array&lt;Promise&lt;null>> = [];
// services.forEach((service) => {
// servicePromises.push(new Promise((resolve, reject) => {
// service.discoverCharacteristics([], (err, characteristics) => {
// characteristics.forEach((characteristic) => {
// this._characteristics[characteristic.uuid] = characteristic;
// });
// return resolve();
// });
// }));
// });
// Promise.all(servicePromises).then(() => {
// debug("Service/characteristic discovery finished");
// this._isConnecting = false;
// this._isConnected = true;
// this.emit("connect");
// return connectResolve();
// });
// });
// });
}); });
} }
/** /**
@ -444,7 +400,7 @@ class Hub extends events_1.EventEmitter {
} }
} }
exports.Hub = Hub; exports.Hub = Hub;
</pre> //# sourceMappingURL=hub.js.map</pre>
</article> </article>
</section> </section>

View File

@ -460,7 +460,7 @@ class LPF2Hub extends hub_1.Hub {
} }
} }
exports.LPF2Hub = LPF2Hub; exports.LPF2Hub = LPF2Hub;
</pre> //# sourceMappingURL=lpf2hub.js.map</pre>
</article> </article>
</section> </section>

380
docs/poweredup-node.js.html Normal file
View File

@ -0,0 +1,380 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>DocStrap Source: poweredup-node.js</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
<link type="text/css" rel="stylesheet" href="styles/site.simplex.css">
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top navbar-inverse">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.html">DocStrap</a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="topNavigation">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="BoostMoveHub.html">BoostMoveHub</a></li><li><a href="DuploTrainBase.html">DuploTrainBase</a></li><li><a href="Hub.html">Hub</a></li><li><a href="LPF2Hub.html">LPF2Hub</a></li><li><a href="PoweredUP.html">PoweredUP</a></li><li><a href="PUPHub.html">PUPHub</a></li><li><a href="PUPRemote.html">PUPRemote</a></li><li><a href="WeDo2SmartHub.html">WeDo2SmartHub</a></li>
</ul>
</li>
<li class="dropdown">
<a href="events.list.html" class="dropdown-toggle" data-toggle="dropdown">Events<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="BoostMoveHub.html#event:attach">BoostMoveHub#event:attach</a></li><li><a href="BoostMoveHub.html#event:button">BoostMoveHub#event:button</a></li><li><a href="BoostMoveHub.html#event:color">BoostMoveHub#event:color</a></li><li><a href="BoostMoveHub.html#event:colorAndDistance">BoostMoveHub#event:colorAndDistance</a></li><li><a href="BoostMoveHub.html#event:detach">BoostMoveHub#event:detach</a></li><li><a href="BoostMoveHub.html#event:distance">BoostMoveHub#event:distance</a></li><li><a href="BoostMoveHub.html#event:rotate">BoostMoveHub#event:rotate</a></li><li><a href="BoostMoveHub.html#event:tilt">BoostMoveHub#event:tilt</a></li><li><a href="DuploTrainBase.html#event:color">DuploTrainBase#event:color</a></li><li><a href="DuploTrainBase.html#event:speed">DuploTrainBase#event:speed</a></li><li><a href="Hub.html#event:attach">Hub#event:attach</a></li><li><a href="Hub.html#event:detach">Hub#event:detach</a></li><li><a href="LPF2Hub.html#event:attach">LPF2Hub#event:attach</a></li><li><a href="LPF2Hub.html#event:button">LPF2Hub#event:button</a></li><li><a href="LPF2Hub.html#event:color">LPF2Hub#event:color</a></li><li><a href="LPF2Hub.html#event:colorAndDistance">LPF2Hub#event:colorAndDistance</a></li><li><a href="LPF2Hub.html#event:detach">LPF2Hub#event:detach</a></li><li><a href="LPF2Hub.html#event:distance">LPF2Hub#event:distance</a></li><li><a href="LPF2Hub.html#event:rotate">LPF2Hub#event:rotate</a></li><li><a href="LPF2Hub.html#event:speed">LPF2Hub#event:speed</a></li><li><a href="LPF2Hub.html#event:tilt">LPF2Hub#event:tilt</a></li><li><a href="PoweredUP.html#event:discover">PoweredUP#event:discover</a></li><li><a href="PUPHub.html#event:attach">PUPHub#event:attach</a></li><li><a href="PUPHub.html#event:button">PUPHub#event:button</a></li><li><a href="PUPHub.html#event:color">PUPHub#event:color</a></li><li><a href="PUPHub.html#event:colorAndDistance">PUPHub#event:colorAndDistance</a></li><li><a href="PUPHub.html#event:detach">PUPHub#event:detach</a></li><li><a href="PUPHub.html#event:distance">PUPHub#event:distance</a></li><li><a href="PUPHub.html#event:tilt">PUPHub#event:tilt</a></li><li><a href="PUPRemote.html#event:button">PUPRemote#event:button</a></li><li><a href="PUPRemote.html#event:colorAndDistance">PUPRemote#event:colorAndDistance</a></li><li><a href="WeDo2SmartHub.html#event:attach">WeDo2SmartHub#event:attach</a></li><li><a href="WeDo2SmartHub.html#event:button">WeDo2SmartHub#event:button</a></li><li><a href="WeDo2SmartHub.html#event:color">WeDo2SmartHub#event:color</a></li><li><a href="WeDo2SmartHub.html#event:detach">WeDo2SmartHub#event:detach</a></li><li><a href="WeDo2SmartHub.html#event:distance">WeDo2SmartHub#event:distance</a></li><li><a href="WeDo2SmartHub.html#event:rotate">WeDo2SmartHub#event:rotate</a></li><li><a href="WeDo2SmartHub.html#event:tilt">WeDo2SmartHub#event:tilt</a></li>
</ul>
</li>
<li class="dropdown">
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
<ul class="dropdown-menu ">
<li><a href="global.html">Global</a></li>
</ul>
</li>
</ul>
<div class="col-sm-3 col-md-3">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
<div class="input-group-btn">
<button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<div class="container" id="toc-content">
<div class="row">
<div class="col-md-12">
<div id="main">
<h1 class="page-title">Source: poweredup-node.js</h1>
<section>
<article>
<pre
class="sunlight-highlight-javascript linenums">"use strict";
var __importStar = (this &amp;&amp; this.__importStar) || function (mod) {
if (mod &amp;&amp; mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const bledevice_1 = require("./bledevice");
const boostmovehub_1 = require("./boostmovehub");
const duplotrainbase_1 = require("./duplotrainbase");
const puphub_1 = require("./puphub");
const pupremote_1 = require("./pupremote");
const wedo2smarthub_1 = require("./wedo2smarthub");
const utils_1 = require("./utils");
const Consts = __importStar(require("./consts"));
const events_1 = require("events");
const Debug = require("debug");
const debug = Debug("poweredup");
const noble = require("noble-mac");
let ready = false;
let wantScan = false;
let discoveryEventAttached = false;
const startScanning = () => {
if (utils_1.isBrowserContext) {
noble.startScanning([Consts.BLEService.WEDO2_SMART_HUB, Consts.BLEService.LPF2_HUB]);
}
else {
noble.startScanning();
}
};
noble.on("stateChange", (state) => {
ready = (state === "poweredOn");
if (ready) {
if (wantScan) {
debug("Scanning started");
startScanning();
}
}
else {
noble.stopScanning();
}
});
/**
* @class PoweredUP
* @extends EventEmitter
*/
class PoweredUP extends events_1.EventEmitter {
constructor() {
super();
this.autoSubscribe = true;
this._connectedHubs = {};
this._discoveryEventHandler = this._discoveryEventHandler.bind(this);
}
/**
* Begin scanning for Powered UP Hub devices.
* @method PoweredUP#scan
*/
scan() {
wantScan = true;
if (!discoveryEventAttached) {
noble.on("discover", this._discoveryEventHandler);
discoveryEventAttached = true;
}
if (ready) {
debug("Scanning started");
startScanning();
}
}
/**
* Stop scanning for Powered UP Hub devices.
* @method PoweredUP#stop
*/
stop() {
wantScan = false;
if (discoveryEventAttached) {
noble.removeListener("discover", this._discoveryEventHandler);
discoveryEventAttached = false;
}
noble.stopScanning();
}
/**
* Retrieve a list of Powered UP Hubs.
* @method PoweredUP#getConnectedHubs
* @returns {Hub[]}
*/
getConnectedHubs() {
return Object.keys(this._connectedHubs).map((uuid) => this._connectedHubs[uuid]);
}
/**
* Retrieve a Powered UP Hub by UUID.
* @method PoweredUP#getConnectedHubByUUID
* @param {string} uuid
* @returns {Hub | null}
*/
getConnectedHubByUUID(uuid) {
return this._connectedHubs[uuid];
}
/**
* Retrieve a list of Powered UP Hub by name.
* @method PoweredUP#getConnectedHubsByName
* @param {string} name
* @returns {Hub[]}
*/
getConnectedHubsByName(name) {
return Object.keys(this._connectedHubs).map((uuid) => this._connectedHubs[uuid]).filter((hub) => hub.name === name);
}
async _discoveryEventHandler(peripheral) {
const device = new bledevice_1.BLEDevice(peripheral);
let hub;
if (await wedo2smarthub_1.WeDo2SmartHub.IsWeDo2SmartHub(peripheral)) {
hub = new wedo2smarthub_1.WeDo2SmartHub(device, this.autoSubscribe);
}
else if (await boostmovehub_1.BoostMoveHub.IsBoostMoveHub(peripheral)) {
hub = new boostmovehub_1.BoostMoveHub(device, this.autoSubscribe);
}
else if (await puphub_1.PUPHub.IsPUPHub(peripheral)) {
hub = new puphub_1.PUPHub(device, this.autoSubscribe);
}
else if (await pupremote_1.PUPRemote.IsPUPRemote(peripheral)) {
hub = new pupremote_1.PUPRemote(device, this.autoSubscribe);
}
else if (await duplotrainbase_1.DuploTrainBase.IsDuploTrainBase(peripheral)) {
hub = new duplotrainbase_1.DuploTrainBase(device, this.autoSubscribe);
}
else {
return;
}
peripheral.removeAllListeners();
// noble.stopScanning();
// if (!isBrowserContext) {
// startScanning();
// }
device.on("discoverComplete", () => {
hub.on("connect", () => {
debug(`Hub ${hub.uuid} connected`);
this._connectedHubs[hub.uuid] = hub;
});
hub.on("disconnect", () => {
debug(`Hub ${hub.uuid} disconnected`);
delete this._connectedHubs[hub.uuid];
if (wantScan) {
startScanning();
}
});
debug(`Hub ${hub.uuid} discovered`);
/**
* Emits when a Powered UP Hub device is found.
* @event PoweredUP#discover
* @param {WeDo2SmartHub | BoostMoveHub | PUPHub | PUPRemote | DuploTrainBase} hub
*/
this.emit("discover", hub);
});
}
}
exports.PoweredUP = PoweredUP;
//# sourceMappingURL=poweredup-node.js.map</pre>
</article>
</section>
</div>
</div>
<div class="clearfix"></div>
</div>
</div>
<div class="modal fade" id="searchResults">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Search results</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<footer>
<span class="copyright">
node-poweredup by Nathan Kellenicki licensed under the MIT license.
</span>
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
on Wed Feb 6th 2019
using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
</span>
</footer>
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/toc.js"></script>
<script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
<script>
$( function () {
$( "[id*='$']" ).each( function () {
var $this = $( this );
$this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
} );
$( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
var $this = $( this );
var example = $this.find( "code" );
exampleText = example.html();
var lang = /{@lang (.*?)}/.exec( exampleText );
if ( lang && lang[1] ) {
exampleText = exampleText.replace( lang[0], "" );
example.html( exampleText );
lang = lang[1];
} else {
var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
lang = langClassMatch ? langClassMatch[1] : "javascript";
}
if ( lang ) {
$this
.addClass( "sunlight-highlight-" + lang )
.addClass( "linenums" )
.html( example.html() );
}
} );
Sunlight.highlightAll( {
lineNumbers : true,
showMenu : true,
enableDoclinks : true
} );
$.catchAnchorLinks( {
navbarOffset: 10
} );
$( "#toc" ).toc( {
anchorName : function ( i, heading, prefix ) {
return $( heading ).attr( "id" ) || ( prefix + i );
},
selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
showAndHide : false,
smoothScrolling: true
} );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
$( '.dropdown-toggle' ).dropdown();
$( "table" ).each( function () {
var $this = $( this );
$this.addClass('table');
} );
} );
</script>
<!--Navigation and Symbol Display-->
<!--Google Analytics-->
<script type="text/javascript">
$(document).ready(function() {
SearcherDisplay.init();
});
</script>
</body>
</html>

View File

@ -119,8 +119,8 @@ class PUPHub extends lpf2hub_1.LPF2Hub {
peripheral.advertisement.serviceUuids &amp;&amp; peripheral.advertisement.serviceUuids &amp;&amp;
peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &amp;&amp; peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.POWERED_UP_HUB_ID); peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &amp;&amp; peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.POWERED_UP_HUB_ID);
} }
constructor(peripheral, autoSubscribe = true) { constructor(device, autoSubscribe = true) {
super(peripheral, autoSubscribe); super(device, autoSubscribe);
this.type = Consts.HubType.POWERED_UP_HUB; this.type = Consts.HubType.POWERED_UP_HUB;
this._ports = { this._ports = {
"A": new port_1.Port("A", 0), "A": new port_1.Port("A", 0),
@ -263,7 +263,7 @@ class PUPHub extends lpf2hub_1.LPF2Hub {
} }
} }
exports.PUPHub = PUPHub; exports.PUPHub = PUPHub;
</pre> //# sourceMappingURL=puphub.js.map</pre>
</article> </article>
</section> </section>

View File

@ -139,8 +139,8 @@ class PUPRemote extends lpf2hub_1.LPF2Hub {
peripheral.advertisement.serviceUuids &amp;&amp; peripheral.advertisement.serviceUuids &amp;&amp;
peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &amp;&amp; peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.POWERED_UP_REMOTE_ID); peripheral.advertisement.serviceUuids.indexOf(Consts.BLEService.LPF2_HUB.replace(/-/g, "")) >= 0 &amp;&amp; peripheral.advertisement.manufacturerData[3] === Consts.BLEManufacturerData.POWERED_UP_REMOTE_ID);
} }
constructor(peripheral, autoSubscribe = true) { constructor(device, autoSubscribe = true) {
super(peripheral, autoSubscribe); super(device, autoSubscribe);
this.type = Consts.HubType.POWERED_UP_REMOTE; this.type = Consts.HubType.POWERED_UP_REMOTE;
this._ports = { this._ports = {
"LEFT": new port_1.Port("LEFT", 0), "LEFT": new port_1.Port("LEFT", 0),
@ -193,7 +193,7 @@ class PUPRemote extends lpf2hub_1.LPF2Hub {
} }
} }
exports.PUPRemote = PUPRemote; exports.PUPRemote = PUPRemote;
</pre> //# sourceMappingURL=pupremote.js.map</pre>
</article> </article>
</section> </section>

File diff suppressed because one or more lines are too long

View File

@ -97,6 +97,7 @@ const hub_1 = require("./hub");
const port_1 = require("./port"); const port_1 = require("./port");
const Consts = __importStar(require("./consts")); const Consts = __importStar(require("./consts"));
const Debug = require("debug"); const Debug = require("debug");
const utils_1 = require("./utils");
const debug = Debug("wedo2smarthub"); const debug = Debug("wedo2smarthub");
/** /**
* The WeDo2SmartHub is emitted if the discovered device is a WeDo 2.0 Smart Hub. * The WeDo2SmartHub is emitted if the discovered device is a WeDo 2.0 Smart Hub.
@ -104,8 +105,8 @@ const debug = Debug("wedo2smarthub");
* @extends Hub * @extends Hub
*/ */
class WeDo2SmartHub extends hub_1.Hub { class WeDo2SmartHub extends hub_1.Hub {
constructor(peripheral, autoSubscribe = true) { constructor(device, autoSubscribe = true) {
super(peripheral, autoSubscribe); super(device, autoSubscribe);
this._lastTiltX = 0; this._lastTiltX = 0;
this._lastTiltY = 0; this._lastTiltY = 0;
this.type = Consts.HubType.WEDO2_SMART_HUB; this.type = Consts.HubType.WEDO2_SMART_HUB;
@ -131,27 +132,52 @@ class WeDo2SmartHub extends hub_1.Hub {
await super.connect(); await super.connect();
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB); await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB);
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_2); await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_2);
if (!utils_1.isBrowserContext) {
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_3); await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_3);
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_4); await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_4);
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_5); await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_5);
}
else {
await this._bleDevice.discoverCharacteristicsForService("battery_service");
await this._bleDevice.discoverCharacteristicsForService("device_information");
}
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_PORT_TYPE, this._parsePortMessage.bind(this)); this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_PORT_TYPE, this._parsePortMessage.bind(this));
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_SENSOR_VALUE, this._parseSensorMessage.bind(this)); this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_SENSOR_VALUE, this._parseSensorMessage.bind(this));
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_BUTTON, this._parseSensorMessage.bind(this)); this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_BUTTON, this._parseSensorMessage.bind(this));
if (!utils_1.isBrowserContext) {
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY, this._parseBatteryMessage.bind(this)); this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY, this._parseBatteryMessage.bind(this));
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_HIGH_CURRENT_ALERT, this._parseHighCurrentAlert.bind(this));
this._bleDevice.readFromCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY, (err, data) => { this._bleDevice.readFromCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY, (err, data) => {
if (data) { if (data) {
this._parseBatteryMessage(data); this._parseBatteryMessage(data);
} }
}); });
}
else {
this._bleDevice.readFromCharacteristic("00002a19-0000-1000-8000-00805f9b34fb", (err, data) => {
if (data) {
this._parseBatteryMessage(data);
}
});
this._bleDevice.subscribeToCharacteristic("00002a19-0000-1000-8000-00805f9b34fb", this._parseHighCurrentAlert.bind(this));
}
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_HIGH_CURRENT_ALERT, this._parseHighCurrentAlert.bind(this));
if (!utils_1.isBrowserContext) {
this._bleDevice.readFromCharacteristic(Consts.BLECharacteristic.WEDO2_FIRMWARE_REVISION, (err, data) => { this._bleDevice.readFromCharacteristic(Consts.BLECharacteristic.WEDO2_FIRMWARE_REVISION, (err, data) => {
if (data) { if (data) {
this._parseFirmwareRevisionString(data); this._parseFirmwareRevisionString(data);
} }
}); });
}
else {
this._bleDevice.readFromCharacteristic("00002a26-0000-1000-8000-00805f9b34fb", (err, data) => {
if (data) {
this._parseFirmwareRevisionString(data);
}
});
}
setTimeout(() => { setTimeout(() => {
this._activatePortDevice(0x03, 0x15, 0x00, 0x00); // Activate voltage reports // this._activatePortDevice(0x03, 0x15, 0x00, 0x00); // Activate voltage reports
this._activatePortDevice(0x04, 0x14, 0x00, 0x00); // Activate current reports // this._activatePortDevice(0x04, 0x14, 0x00, 0x00); // Activate current reports
debug("Connect completed"); debug("Connect completed");
this.emit("connect"); this.emit("connect");
return resolve(); return resolve();
@ -361,7 +387,6 @@ class WeDo2SmartHub extends hub_1.Hub {
} }
_parseHighCurrentAlert(data) { _parseHighCurrentAlert(data) {
debug("Received Message (WEDO2_HIGH_CURRENT_ALERT)", data); debug("Received Message (WEDO2_HIGH_CURRENT_ALERT)", data);
// console.log(data);
} }
_parseBatteryMessage(data) { _parseBatteryMessage(data) {
debug("Received Message (WEDO2_BATTERY)", data); debug("Received Message (WEDO2_BATTERY)", data);
@ -472,7 +497,7 @@ class WeDo2SmartHub extends hub_1.Hub {
} }
} }
exports.WeDo2SmartHub = WeDo2SmartHub; exports.WeDo2SmartHub = WeDo2SmartHub;
</pre> //# sourceMappingURL=wedo2smarthub.js.map</pre>
</article> </article>
</section> </section>

3753
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,30 +3,35 @@
"version": "1.9.1", "version": "1.9.1",
"description": "A Node.js module to interface with LEGO Powered UP components.", "description": "A Node.js module to interface with LEGO Powered UP components.",
"homepage": "https://github.com/nathankellenicki/node-poweredup/", "homepage": "https://github.com/nathankellenicki/node-poweredup/",
"main": "dist/index.js", "main": "dist/index-node.js",
"types": "dist/index.d.ts", "types": "dist/index-node.d.ts",
"scripts": { "scripts": {
"build": "tslint -c tslint.json \"src/*.ts\" && tsc", "build:node": "tslint -c tslint.json \"./src/*.ts\" && tsc",
"docs": "jsdoc -d docs -c jsdoc.conf.json -t ./node_modules/ink-docstrap/template -R README.md dist/consts.js dist/poweredup.js dist/lpf2hub.js dist/wedo2smarthub.js dist/boostmovehub.js dist/puphub.js dist/pupremote.js dist/duplotrainbase.js dist/hub.js dist/consts.js", "build:browser": "webpack --mode=production",
"all": "npm run build && npm run docs", "docs": "jsdoc -d docs -c jsdoc.conf.json -t ./node_modules/ink-docstrap/template -R README.md dist/consts.js dist/poweredup-node.js dist/lpf2hub.js dist/wedo2smarthub.js dist/boostmovehub.js dist/puphub.js dist/pupremote.js dist/duplotrainbase.js dist/hub.js dist/consts.js",
"prepublishOnly": "npm run build" "all": "npm run build:node && npm run docs",
"prepublishOnly": "npm run build:node"
}, },
"author": "Nathan Kellenicki <nathan@kellenicki.com>", "author": "Nathan Kellenicki <nathan@kellenicki.com>",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"debug": "^4.1.1", "debug": "^4.1.1",
"noble": "1.9.1", "noble": "1.9.1",
"noble-mac": "https://github.com/Timeular/noble-mac.git#af4418e" "noble-mac": "git+https://github.com/Timeular/noble-mac.git#af4418e"
}, },
"devDependencies": { "devDependencies": {
"@types/debug": "0.0.31", "@types/debug": "0.0.31",
"@types/noble": "0.0.38", "@types/noble": "0.0.38",
"@types/node": "^10.12.18", "@types/node": "^10.12.21",
"@types/web-bluetooth": "0.0.4",
"ink-docstrap": "^1.3.2", "ink-docstrap": "^1.3.2",
"jsdoc": "^3.5.5", "jsdoc": "^3.5.5",
"jsdoc-to-markdown": "^4.0.1", "jsdoc-to-markdown": "^4.0.1",
"tslint": "^5.12.0", "ts-loader": "^5.3.3",
"typescript": "^3.2.2" "tslint": "^5.12.1",
"typescript": "^3.3.1",
"webpack": "^4.29.2",
"webpack-cli": "^3.2.3"
}, },
"resolutions": { "resolutions": {
"xpc-connection": "sandeepmistry/node-xpc-connection#pull/26/head" "xpc-connection": "sandeepmistry/node-xpc-connection#pull/26/head"

View File

@ -2,6 +2,7 @@ import { Characteristic, Peripheral, Service } from "noble";
import Debug = require("debug"); import Debug = require("debug");
import { EventEmitter } from "events"; import { EventEmitter } from "events";
import { write } from "fs";
const debug = Debug("bledevice"); const debug = Debug("bledevice");
@ -16,6 +17,8 @@ export class BLEDevice extends EventEmitter {
private _characteristics: {[uuid: string]: Characteristic} = {}; private _characteristics: {[uuid: string]: Characteristic} = {};
private _writeQueue: Promise<any> = Promise.resolve();
constructor (device: any) { constructor (device: any) {
super(); super();
@ -29,9 +32,11 @@ export class BLEDevice extends EventEmitter {
}, 1000); }, 1000);
} else { } else {
this._webBLEServer = device; this._webBLEServer = device;
this._uuid = device.id; this._uuid = device.device.id;
this._name = device.name; this._name = device.device.name;
setTimeout(() => {
this.emit("discoverComplete"); this.emit("discoverComplete");
}, 5000);
} }
} }
@ -73,9 +78,9 @@ export class BLEDevice extends EventEmitter {
public discoverCharacteristicsForService (uuid: string) { public discoverCharacteristicsForService (uuid: string) {
uuid = this._sanitizeUUID(uuid);
return new Promise(async (discoverResolve, discoverReject) => { return new Promise(async (discoverResolve, discoverReject) => {
if (this._noblePeripheral) { if (this._noblePeripheral) {
uuid = this._sanitizeUUID(uuid);
this._noblePeripheral.discoverServices([uuid], (err: string, services: Service[]) => { this._noblePeripheral.discoverServices([uuid], (err: string, services: Service[]) => {
if (err) { if (err) {
return discoverReject(err); return discoverReject(err);
@ -118,8 +123,8 @@ export class BLEDevice extends EventEmitter {
public subscribeToCharacteristic (uuid: string, callback: (data: Buffer) => void) { public subscribeToCharacteristic (uuid: string, callback: (data: Buffer) => void) {
uuid = this._sanitizeUUID(uuid);
if (this._noblePeripheral) { if (this._noblePeripheral) {
uuid = this._sanitizeUUID(uuid);
this._characteristics[uuid].on("data", (data: Buffer) => { this._characteristics[uuid].on("data", (data: Buffer) => {
return callback(data); return callback(data);
}); });
@ -131,35 +136,50 @@ export class BLEDevice extends EventEmitter {
} else if (this._webBLEServer) { } else if (this._webBLEServer) {
// @ts-ignore // @ts-ignore
this._characteristics[uuid].addEventListener("characteristicvaluechanged", (event) => { this._characteristics[uuid].addEventListener("characteristicvaluechanged", (event) => {
return callback(event.target.value.buffer); const buf = Buffer.alloc(event.target.value.buffer.byteLength);
const view = new Uint8Array(event.target.value.buffer);
for (let i = 0; i < buf.length; i++) {
buf[i] = view[i];
}
return callback(buf);
}); });
// @ts-ignore
this._characteristics[uuid].startNotifications();
} }
} }
public readFromCharacteristic (uuid: string, callback: (err: string | null, data: Buffer | null) => void) { public readFromCharacteristic (uuid: string, callback: (err: string | null, data: Buffer | null) => void) {
uuid = this._sanitizeUUID(uuid);
if (this._noblePeripheral) { if (this._noblePeripheral) {
uuid = this._sanitizeUUID(uuid);
this._characteristics[uuid].read((err: string, data: Buffer) => { this._characteristics[uuid].read((err: string, data: Buffer) => {
return callback(err, data); return callback(err, data);
}); });
} else if (this._webBLEServer) { } else if (this._webBLEServer) {
try {
// @ts-ignore // @ts-ignore
this._characteristics[uuid].readValue().then((data) => { this._characteristics[uuid].readValue().then((data) => {
callback(null, data); const buf = Buffer.alloc(data.buffer.byteLength);
}); const view = new Uint8Array(data.buffer);
} catch (err) { for (let i = 0; i < buf.length; i++) {
callback(err, null); buf[i] = view[i];
} }
callback(null, buf);
});
} }
} }
public writeToCharacteristic (uuid: string, data: Buffer, callback?: () => void) { public writeToCharacteristic (uuid: string, data: Buffer, callback?: () => void) {
uuid = this._sanitizeUUID(uuid);
if (this._noblePeripheral) { if (this._noblePeripheral) {
uuid = this._sanitizeUUID(uuid);
this._characteristics[uuid].write(data, false, callback); this._characteristics[uuid].write(data, false, callback);
} else {
// @ts-ignore
this._writeQueue = this._writeQueue.then(() => this._characteristics[uuid].writeValue(data)).then(() => {
if (callback) {
callback();
}
});
} }
} }

11
src/index-browser.ts Normal file
View File

@ -0,0 +1,11 @@
import { BoostMoveHub } from "./boostmovehub";
import * as Consts from "./consts";
import { DuploTrainBase } from "./duplotrainbase";
import { Hub } from "./hub";
import { PoweredUP } from "./poweredup-browser";
import { PUPHub } from "./puphub";
import { PUPRemote } from "./pupremote";
import { WeDo2SmartHub } from "./wedo2smarthub";
// @ts-ignore
window.PoweredUP = { PoweredUP, Hub, WeDo2SmartHub, BoostMoveHub, PUPHub, PUPRemote, DuploTrainBase, Consts };

View File

@ -2,17 +2,10 @@ import { BoostMoveHub } from "./boostmovehub";
import * as Consts from "./consts"; import * as Consts from "./consts";
import { DuploTrainBase } from "./duplotrainbase"; import { DuploTrainBase } from "./duplotrainbase";
import { Hub } from "./hub"; import { Hub } from "./hub";
import { PoweredUP as PoweredUPNode } from "./poweredup-node"; import { PoweredUP } from "./poweredup-node";
import { PUPHub } from "./puphub"; import { PUPHub } from "./puphub";
import { PUPRemote } from "./pupremote"; import { PUPRemote } from "./pupremote";
import { WeDo2SmartHub } from "./wedo2smarthub"; import { WeDo2SmartHub } from "./wedo2smarthub";
import { isBrowserContext } from "./utils";
let PoweredUP;
export default PoweredUP; export default PoweredUP;
export { PoweredUP, Hub, WeDo2SmartHub, BoostMoveHub, PUPHub, PUPRemote, DuploTrainBase, Consts }; export { PoweredUP, Hub, WeDo2SmartHub, BoostMoveHub, PUPHub, PUPRemote, DuploTrainBase, Consts };
if (!isBrowserContext) {
PoweredUP = PoweredUPNode;
}

149
src/poweredup-browser.ts Normal file
View File

@ -0,0 +1,149 @@
import { BLEDevice } from "./bledevice";
import { BoostMoveHub } from "./boostmovehub";
import { DuploTrainBase } from "./duplotrainbase";
import { Hub } from "./hub";
import { PUPHub } from "./puphub";
import { PUPRemote } from "./pupremote";
import { WeDo2SmartHub } from "./wedo2smarthub";
import * as Consts from "./consts";
import { EventEmitter } from "events";
import Debug = require("debug");
const debug = Debug("poweredup");
/**
* @class PoweredUP
* @extends EventEmitter
*/
export class PoweredUP extends EventEmitter {
public autoSubscribe: boolean = true;
private _connectedHubs: {[uuid: string]: Hub} = {};
constructor () {
super();
this._discoveryEventHandler = this._discoveryEventHandler.bind(this);
}
/**
* Begin scanning for Powered UP Hub devices.
* @method PoweredUP#scan
*/
public async scan () {
const device = await navigator.bluetooth.requestDevice({
filters: [
{
services: [
Consts.BLEService.WEDO2_SMART_HUB
]
},
{
services: [
Consts.BLEService.LPF2_HUB
]
}
],
optionalServices: [
Consts.BLEService.WEDO2_SMART_HUB_2,
"battery_service",
"device_information"
]
});
// @ts-ignore
const server = await device.gatt.connect();
this._discoveryEventHandler.call(this, server);
}
/**
* Retrieve a list of Powered UP Hubs.
* @method PoweredUP#getConnectedHubs
* @returns {Hub[]}
*/
public getConnectedHubs () {
return Object.keys(this._connectedHubs).map((uuid) => this._connectedHubs[uuid]);
}
/**
* Retrieve a Powered UP Hub by UUID.
* @method PoweredUP#getConnectedHubByUUID
* @param {string} uuid
* @returns {Hub | null}
*/
public getConnectedHubByUUID (uuid: string) {
return this._connectedHubs[uuid];
}
/**
* Retrieve a list of Powered UP Hub by name.
* @method PoweredUP#getConnectedHubsByName
* @param {string} name
* @returns {Hub[]}
*/
public getConnectedHubsByName (name: string) {
return Object.keys(this._connectedHubs).map((uuid) => this._connectedHubs[uuid]).filter((hub) => hub.name === name);
}
private async _discoveryEventHandler (server: BluetoothRemoteGATTServer) {
const device = new BLEDevice(server);
let hub: Hub;
let hubType = Consts.HubType.UNKNOWN;
let isLPF2Hub = false;
try {
await device.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB);
hubType = Consts.HubType.WEDO2_SMART_HUB;
// tslint:disable-next-line
} catch (error) {}
try {
if (hubType !== Consts.HubType.WEDO2_SMART_HUB) {
await device.discoverCharacteristicsForService(Consts.BLEService.LPF2_HUB);
isLPF2Hub = true;
}
// tslint:disable-next-line
} catch (error) {}
hub = new WeDo2SmartHub(device, this.autoSubscribe);
device.on("discoverComplete", () => {
hub.on("connect", () => {
debug(`Hub ${hub.uuid} connected`);
this._connectedHubs[hub.uuid] = hub;
});
hub.on("disconnect", () => {
debug(`Hub ${hub.uuid} disconnected`);
delete this._connectedHubs[hub.uuid];
});
debug(`Hub ${hub.uuid} discovered`);
/**
* Emits when a Powered UP Hub device is found.
* @event PoweredUP#discover
* @param {WeDo2SmartHub | BoostMoveHub | PUPHub | PUPRemote | DuploTrainBase} hub
*/
this.emit("discover", hub);
});
}
}

View File

@ -7,6 +7,7 @@ import { Port } from "./port";
import * as Consts from "./consts"; import * as Consts from "./consts";
import Debug = require("debug"); import Debug = require("debug");
import { isBrowserContext } from "./utils";
const debug = Debug("wedo2smarthub"); const debug = Debug("wedo2smarthub");
@ -54,27 +55,49 @@ export class WeDo2SmartHub extends Hub {
await super.connect(); await super.connect();
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB); await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB);
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_2); await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_2);
if (!isBrowserContext) {
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_3); await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_3);
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_4); await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_4);
await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_5); await this._bleDevice.discoverCharacteristicsForService(Consts.BLEService.WEDO2_SMART_HUB_5);
} else {
await this._bleDevice.discoverCharacteristicsForService("battery_service");
await this._bleDevice.discoverCharacteristicsForService("device_information");
}
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_PORT_TYPE, this._parsePortMessage.bind(this)); this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_PORT_TYPE, this._parsePortMessage.bind(this));
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_SENSOR_VALUE, this._parseSensorMessage.bind(this)); this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_SENSOR_VALUE, this._parseSensorMessage.bind(this));
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_BUTTON, this._parseSensorMessage.bind(this)); this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_BUTTON, this._parseSensorMessage.bind(this));
if (!isBrowserContext) {
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY, this._parseBatteryMessage.bind(this)); this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY, this._parseBatteryMessage.bind(this));
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_HIGH_CURRENT_ALERT, this._parseHighCurrentAlert.bind(this));
this._bleDevice.readFromCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY, (err, data) => { this._bleDevice.readFromCharacteristic(Consts.BLECharacteristic.WEDO2_BATTERY, (err, data) => {
if (data) { if (data) {
this._parseBatteryMessage(data); this._parseBatteryMessage(data);
} }
}); });
} else {
this._bleDevice.readFromCharacteristic("00002a19-0000-1000-8000-00805f9b34fb", (err, data) => {
if (data) {
this._parseBatteryMessage(data);
}
});
this._bleDevice.subscribeToCharacteristic("00002a19-0000-1000-8000-00805f9b34fb", this._parseHighCurrentAlert.bind(this));
}
this._bleDevice.subscribeToCharacteristic(Consts.BLECharacteristic.WEDO2_HIGH_CURRENT_ALERT, this._parseHighCurrentAlert.bind(this));
if (!isBrowserContext) {
this._bleDevice.readFromCharacteristic(Consts.BLECharacteristic.WEDO2_FIRMWARE_REVISION, (err, data) => { this._bleDevice.readFromCharacteristic(Consts.BLECharacteristic.WEDO2_FIRMWARE_REVISION, (err, data) => {
if (data) { if (data) {
this._parseFirmwareRevisionString(data); this._parseFirmwareRevisionString(data);
} }
}); });
} else {
this._bleDevice.readFromCharacteristic("00002a26-0000-1000-8000-00805f9b34fb", (err, data) => {
if (data) {
this._parseFirmwareRevisionString(data);
}
});
}
setTimeout(() => { setTimeout(() => {
this._activatePortDevice(0x03, 0x15, 0x00, 0x00); // Activate voltage reports // this._activatePortDevice(0x03, 0x15, 0x00, 0x00); // Activate voltage reports
this._activatePortDevice(0x04, 0x14, 0x00, 0x00); // Activate current reports // this._activatePortDevice(0x04, 0x14, 0x00, 0x00); // Activate current reports
debug("Connect completed"); debug("Connect completed");
this.emit("connect"); this.emit("connect");
return resolve(); return resolve();

44
test.html Normal file
View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<title>node-poweredup Web Bluetooth Test</title>
<script src="./dist/bundle.js"></script>
<script>
const scan = async function () {
localStorage.debug = "";
const poweredUP = new PoweredUP.PoweredUP();
poweredUP.scan(); // Start scanning for hubs
poweredUP.on("discover", async (hub) => { // Wait to discover hubs
await hub.connect(); // Connect to hub
console.log(`Connected to ${hub.name}!`);
await hub.sleep(2000);
console.log(hub.firmwareVersion);
hub.setLEDColor(PoweredUP.Consts.Color.RED);
hub.rampMotorSpeed("A", 0, 100, 10000);
hub.on("disconnect", () => {
console.log("Hub disconnected");
})
});
}
</script>
</head>
<body>
<div>
<button onclick="scan()">Scan</button>
</div>
</body>
</html>

View File

@ -9,7 +9,7 @@
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true, /* Generates corresponding '.d.ts' file. */ "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */ "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */ // "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist", /* Redirect output structure to the directory. */ "outDir": "./dist", /* Redirect output structure to the directory. */
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */

26
webpack.config.js Normal file
View File

@ -0,0 +1,26 @@
const path = require("path");
module.exports = {
entry: "./src/index-browser.ts",
devtool: "source-map",
module: {
rules: [
{
test: /\.ts?$/,
use: "ts-loader",
exclude: /node_modules/
}
],
},
externals: {
"noble": "noble",
"noble-mac": "noble-mac"
},
resolve: {
extensions: [".ts", ".js"]
},
output: {
filename: "bundle.js",
path: path.resolve(__dirname, "dist")
}
};