microbit-web-bluetooth
Advanced tools
Comparing version 0.2.0 to 0.2.1-next.9304435.0
@@ -1,2 +0,2 @@ | ||
var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};function t(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function r(e,t,r,n){return new(r||(r=Promise))(function(i,a){function s(e){try{c(n.next(e))}catch(e){a(e)}}function o(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){e.done?i(e.value):new r(function(t){t(e.value)}).then(s,o)}c((n=n.apply(e,t||[])).next())})}function n(e,t){var r,n,i,a,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}var i;!function(e){e.modelNumber="00002a24-0000-1000-8000-00805f9b34fb",e.serialNumber="00002a25-0000-1000-8000-00805f9b34fb",e.firmwareRevision="00002a26-0000-1000-8000-00805f9b34fb",e.hardwareRevision="00002a27-0000-1000-8000-00805f9b34fb",e.manufacturer="00002a29-0000-1000-8000-00805f9b34fb"}(i||(i={}));var a=function(){function e(e){this.service=e}return e.createService=function(t){var r=t.find(function(e){return"0000180a-0000-1000-8000-00805f9b34fb"===e.uuid});if(r)return new e(r)},e.prototype.readDeviceInformation=function(){return r(this,void 0,void 0,function(){var e,t,r,a,s,o,c,u,h,f,d,l;return n(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristics()];case 1:return e=n.sent(),t={},(r=e.find(function(e){return e.uuid===i.modelNumber}))?(a=t,[4,this.readStringCharacteristic(r)]):[3,3];case 2:a.modelNumber=n.sent(),n.label=3;case 3:return(s=e.find(function(e){return e.uuid===i.serialNumber}))?(o=t,[4,this.readStringCharacteristic(s)]):[3,5];case 4:o.serialNumber=n.sent(),n.label=5;case 5:return(c=e.find(function(e){return e.uuid===i.firmwareRevision}))?(u=t,[4,this.readStringCharacteristic(c)]):[3,7];case 6:u.firmwareRevision=n.sent(),n.label=7;case 7:return(h=e.find(function(e){return e.uuid===i.hardwareRevision}))?(f=t,[4,this.readStringCharacteristic(h)]):[3,9];case 8:f.hardwareRevision=n.sent(),n.label=9;case 9:return(d=e.find(function(e){return e.uuid===i.manufacturer}))?(l=t,[4,this.readStringCharacteristic(d)]):[3,11];case 10:l.manufacturer=n.sent(),n.label=11;case 11:return[2,t]}})})},e.prototype.readStringCharacteristic=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return[4,e.readValue()];case 1:return t=n.sent(),r=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),[2,String.fromCharCode.apply(null,Array.from(new Uint8Array(r)))]}})})},e}();function s(){}function o(){o.init.call(this)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var i,a,o,u;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),o=a[t]):(a=e._events=new s,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),!o.warned&&(i=c(e))&&i>0&&o.length>i){o.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=o.length,u=h,"function"==typeof console.warn?console.warn(u):console.log(u)}}else o=a[t]=r,++e._eventsCount;return e}function h(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function f(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function d(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}s.prototype=Object.create(null),o.EventEmitter=o,o.usingDomains=!1,o.prototype.domain=void 0,o.prototype._events=void 0,o.prototype._maxListeners=void 0,o.defaultMaxListeners=10,o.init=function(){this.domain=null,o.usingDomains&&(void 0).active&&(void 0).Domain,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new s,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){var t,r,n,i,a,s,o,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(o=this.domain,c){if(t=arguments[1],!o){if(t instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=o,t.domainThrown=!1,o.emit("error",t),!1}if(!(r=s[e]))return!1;var h="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=d(e,n),a=0;a<n;++a)i[a].call(r)}(r,h,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,a=d(e,i),s=0;s<i;++s)a[s].call(r,n)}(r,h,this,arguments[1]);break;case 3:!function(e,t,r,n,i){if(t)e.call(r,n,i);else for(var a=e.length,s=d(e,a),o=0;o<a;++o)s[o].call(r,n,i)}(r,h,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,i,a){if(t)e.call(r,n,i,a);else for(var s=e.length,o=d(e,s),c=0;c<s;++c)o[c].call(r,n,i,a)}(r,h,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),a=1;a<n;a++)i[a-1]=arguments[a];!function(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,a=d(e,i),s=0;s<i;++s)a[s].apply(r,n)}(r,h,this,i)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,h(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,h(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,n,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new s:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,a=r.length;a-- >0;)if(r[a]===t||r[a].listener&&r[a].listener===t){o=r[a].listener,i=a;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new s,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,o||t)}return this},o.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new s,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new s:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),a=0;a<i.length;++a)"removeListener"!==(n=i[a])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new s,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},o.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):f.call(e,t)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var l,v,p=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.isEventListenerObject=function(e){return void 0!==e.handleEvent},t}return t(r,e),r.prototype.addEventListener=function(t,r){if(r){var n=this.isEventListenerObject(r)?r.handleEvent:r;e.prototype.addListener.call(this,t,n)}},r.prototype.removeEventListener=function(t,r){if(r){var n=this.isEventListenerObject(r)?r.handleEvent:r;e.prototype.removeListener.call(this,t,n)}},r.prototype.dispatchEvent=function(t,r){var n;return n="string"==typeof t?new CustomEvent(t,{detail:r}):t,e.prototype.emit.call(this,n.type,n)},r}(o),g="e95d9882-251d-470a-a062-fa1922dfa9a8";!function(e){e.buttonAState="e95dda90-251d-470a-a062-fa1922dfa9a8",e.buttonBState="e95dda91-251d-470a-a062-fa1922dfa9a8"}(l||(l={})),function(e){e[e.Release=0]="Release",e[e.ShortPress=1]="ShortPress",e[e.LongPress=2]="LongPress"}(v||(v={}));var b,m=function(e){function i(t){var r=e.call(this)||this;return r.service=t,r}return t(i,e),i.createService=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return(t=e.find(function(e){return e.uuid===g}))?[4,(r=new i(t)).init()]:[2,void 0];case 1:return n.sent(),[2,r]}})})},i.prototype.init=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.startNotifications(l.buttonAState)];case 1:return e.sent(),[4,this.startNotifications(l.buttonBState)];case 2:return e.sent(),this.on("newListener",this.onNewListener.bind(this)),this.on("removeListener",this.onRemoveListener.bind(this)),[2]}})})},i.prototype.readButtonAState=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.getCharacteristValue(l.buttonAState)];case 1:return[2,e.sent().getUint8(0)]}})})},i.prototype.readButtonBState=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.getCharacteristValue(l.buttonBState)];case 1:return[2,e.sent().getUint8(0)]}})})},i.prototype.getCharacteristValue=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,this.service];case 1:return[4,t.sent().getCharacteristic(e)];case 2:return[4,t.sent().readValue()];case 3:return[2,t.sent()]}})})},i.prototype.startNotifications=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().startNotifications()];case 2:return t.sent(),[2]}})})},i.prototype.onNewListener=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"buttonastatechanged"!==e?[3,2]:[4,this.service.getCharacteristic(l.buttonAState)];case 1:t.sent().addEventListener("characteristicvaluechanged",this.buttonAStateChangedHandler.bind(this)),t.label=2;case 2:return"buttonbstatechanged"!==e?[3,4]:[4,this.service.getCharacteristic(l.buttonBState)];case 3:t.sent().addEventListener("characteristicvaluechanged",this.buttonBStateChangedHandler.bind(this)),t.label=4;case 4:return[2]}})})},i.prototype.onRemoveListener=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return this.listenerCount(e)>0?[2]:"buttonastatechanged"!==e?[3,4]:[4,this.service];case 1:return[4,r.sent().getCharacteristic(l.buttonAState)];case 2:return(t=r.sent()).removeEventListener("characteristicvaluechanged",this.buttonAStateChangedHandler.bind(this)),[4,t.stopNotifications()];case 3:r.sent(),r.label=4;case 4:return"buttonbstatechanged"!==e?[3,8]:[4,this.service];case 5:return[4,r.sent().getCharacteristic(l.buttonBState)];case 6:return(t=r.sent()).removeEventListener("characteristicvaluechanged",this.buttonBStateChangedHandler.bind(this)),[4,t.stopNotifications()];case 7:r.sent(),r.label=8;case 8:return[2]}})})},i.prototype.buttonAStateChangedHandler=function(e){var t=e.target.value;this.dispatchEvent("buttonastatechanged",t.getUint8(0))},i.prototype.buttonBStateChangedHandler=function(e){var t=e.target.value;this.dispatchEvent("buttonbstatechanged",t.getUint8(0))},i}(p),w="e95dd91d-251d-470a-a062-fa1922dfa9a8";!function(e){e.ledMatrixState="e95d7b77-251d-470a-a062-fa1922dfa9a8",e.ledText="e95d93ee-251d-470a-a062-fa1922dfa9a8",e.scrollingDelay="e95d0d2d-251d-470a-a062-fa1922dfa9a8"}(b||(b={}));var y,C=function(){function e(e){this.service=e}return e.createService=function(t){var r=t.find(function(e){return e.uuid===w});if(r)return new e(r)},e.prototype.writeText=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristic(b.ledText)];case 1:return t=n.sent(),r=this.encodeString(e),[2,t.writeValue(r)]}})})},e.prototype.getMatrixState=function(){return r(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return[4,this.getCharacteristValue(b.ledMatrixState)];case 1:return e=t.sent(),[2,this.viewToLedMatrix(e)]}})})},e.prototype.setMatrixState=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristic(b.ledMatrixState)];case 1:return t=n.sent(),r=this.ledMatrixToView(e),[2,t.writeValue(r)]}})})},e.prototype.getScrollingDelay=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.getCharacteristValue(b.scrollingDelay)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},e.prototype.setScrollingDelay=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristic(b.scrollingDelay)];case 1:return t=n.sent(),(r=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[2,t.writeValue(r)]}})})},e.prototype.getCharacteristValue=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().readValue()];case 2:return[2,t.sent()]}})})},e.prototype.encodeString=function(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return t},e.prototype.viewToLedMatrix=function(e){for(var t=[],r=0;r<5;r++)t[r]=this.byteToBoolArray(e.getUint8(r));return t},e.prototype.byteToBoolArray=function(e){for(var t=[!1,!1,!1,!1,!1],r=0;r<t.length;r++)t[r]=1==(1&e),e>>=1;return t.reverse()},e.prototype.ledMatrixToView=function(e){for(var t=new DataView(new ArrayBuffer(5)),r=0;r<5;r++)t.setUint8(r,this.boolArrayToByte(e[r]));return t},e.prototype.boolArrayToByte=function(e){return e.reduce(function(e,t){return e<<1|(t?1:0)},0)},e}();!function(e){e.temperature="e95d9250-251d-470a-a062-fa1922dfa9a8",e.temperaturePeriod="e95d1b25-251d-470a-a062-fa1922dfa9a8"}(y||(y={}));var L,E=function(e){function i(t){var r=e.call(this)||this;return r.service=t,r}return t(i,e),i.createService=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return(t=e.find(function(e){return"e95d6100-251d-470a-a062-fa1922dfa9a8"===e.uuid}))?[4,(r=new i(t)).init()]:[2,void 0];case 1:return n.sent(),[2,r]}})})},i.prototype.init=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.startNotifications(y.temperature)];case 1:return e.sent(),this.on("newListener",this.onNewListener.bind(this)),this.on("removeListener",this.onRemoveListener.bind(this)),[2]}})})},i.prototype.readTemperature=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.getCharacteristValue(y.temperature)];case 1:return[2,e.sent().getInt8(0)]}})})},i.prototype.getTemperaturePeriod=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.getCharacteristValue(y.temperaturePeriod)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},i.prototype.setTemperaturePeriod=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristic(y.temperaturePeriod)];case 1:return t=n.sent(),(r=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[2,t.writeValue(r)]}})})},i.prototype.getCharacteristValue=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().readValue()];case 2:return[2,t.sent()]}})})},i.prototype.startNotifications=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().startNotifications()];case 2:return t.sent(),[2]}})})},i.prototype.onNewListener=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"temperaturechanged"!==e?[3,2]:[4,this.service.getCharacteristic(y.temperature)];case 1:t.sent().addEventListener("characteristicvaluechanged",this.temperatureChangedHandler.bind(this)),t.label=2;case 2:return[2]}})})},i.prototype.onRemoveListener=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"temperaturechanged"!==e?[3,2]:[4,this.service.getCharacteristic(y.temperature)];case 1:t.sent().removeEventListener("characteristicvaluechanged",this.temperatureChangedHandler.bind(this)),t.label=2;case 2:return[2]}})})},i.prototype.temperatureChangedHandler=function(e){var t=e.target.value;this.dispatchEvent("temperaturechanged",t.getInt8(0))},i}(p);!function(e){e.accelerometerData="e95dca4b-251d-470a-a062-fa1922dfa9a8",e.accelerometerPeriod="e95dfb24-251d-470a-a062-fa1922dfa9a8"}(L||(L={}));var S,V,A=function(e){function i(t){var r=e.call(this)||this;return r.service=t,r}return t(i,e),i.createService=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return(t=e.find(function(e){return"e95d0753-251d-470a-a062-fa1922dfa9a8"===e.uuid}))?[4,(r=new i(t)).init()]:[2,void 0];case 1:return n.sent(),[2,r]}})})},i.prototype.init=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.startNotifications(L.accelerometerData)];case 1:return e.sent(),this.on("newListener",this.onNewListener.bind(this)),this.on("removeListener",this.onRemoveListener.bind(this)),[2]}})})},i.prototype.readAccelerometerData=function(){return r(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return[4,this.getCharacteristValue(L.accelerometerData)];case 1:return e=t.sent(),[2,this.dataViewToAccelerometerData(e)]}})})},i.prototype.getAccelerometerPeriod=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.getCharacteristValue(L.accelerometerPeriod)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},i.prototype.setAccelerometerPeriod=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristic(L.accelerometerPeriod)];case 1:return t=n.sent(),(r=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[2,t.writeValue(r)]}})})},i.prototype.getCharacteristValue=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().readValue()];case 2:return[2,t.sent()]}})})},i.prototype.startNotifications=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().startNotifications()];case 2:return t.sent(),[2]}})})},i.prototype.onNewListener=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"accelerometerdatachanged"!==e?[3,2]:[4,this.service.getCharacteristic(L.accelerometerData)];case 1:t.sent().addEventListener("characteristicvaluechanged",this.accelerometerDataChangedHandler.bind(this)),t.label=2;case 2:return[2]}})})},i.prototype.onRemoveListener=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"accelerometerdatachanged"!==e?[3,2]:[4,this.service.getCharacteristic(L.accelerometerData)];case 1:t.sent().removeEventListener("characteristicvaluechanged",this.accelerometerDataChangedHandler.bind(this)),t.label=2;case 2:return[2]}})})},i.prototype.accelerometerDataChangedHandler=function(e){var t=e.target.value,r=this.dataViewToAccelerometerData(t);this.dispatchEvent("accelerometerdatachanged",r)},i.prototype.dataViewToAccelerometerData=function(e){return{x:e.getInt16(0,!0)/1e3,y:e.getInt16(2,!0)/1e3,z:e.getInt16(4,!0)/1e3}},i}(p);!function(e){e.magnetometerData="e95dfb11-251d-470a-a062-fa1922dfa9a8",e.magnetometerPeriod="e95d386c-251d-470a-a062-fa1922dfa9a8",e.magnetometerBearing="e95d9715-251d-470a-a062-fa1922dfa9a8",e.magnetometerCalibration="e95db358-251d-470a-a062-fa1922dfa9a8"}(S||(S={})),function(e){e[e.unknown=0]="unknown",e[e.requested=1]="requested",e[e.completed=2]="completed",e[e.errored=3]="errored"}(V||(V={}));var N,x=function(e){function i(t){var r=e.call(this)||this;return r.service=t,r}return t(i,e),i.createService=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return(t=e.find(function(e){return"e95df2d8-251d-470a-a062-fa1922dfa9a8"===e.uuid}))?[4,(r=new i(t)).init()]:[2,void 0];case 1:return n.sent(),[2,r]}})})},i.prototype.init=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.startNotifications(S.magnetometerData)];case 1:return e.sent(),[4,this.startNotifications(S.magnetometerBearing)];case 2:return e.sent(),[4,this.startNotifications(S.magnetometerCalibration)];case 3:return e.sent(),this.on("newListener",this.onNewListener.bind(this)),this.on("removeListener",this.onRemoveListener.bind(this)),[2]}})})},i.prototype.calibrate=function(){return r(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return[4,this.getCharacteristic(S.magnetometerCalibration)];case 1:if(!(e=t.sent()))throw new Error("Unable to locate calibration characteristic");return[2,e.writeValue(new Uint8Array([1]))]}})})},i.prototype.readMagnetometerData=function(){return r(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return[4,this.getCharacteristValue(S.magnetometerData)];case 1:return e=t.sent(),[2,this.dataViewToMagnetometerData(e)]}})})},i.prototype.getMagnetometerBearing=function(){return r(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return[4,this.getCharacteristValue(S.magnetometerBearing)];case 1:return 2===(e=t.sent()).byteLength?[2,e.getUint16(0,!0)]:[2,void 0]}})})},i.prototype.getMagnetometerPeriod=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.getCharacteristValue(S.magnetometerPeriod)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},i.prototype.setMagnetometerPeriod=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return[4,this.getCharacteristic(S.magnetometerPeriod)];case 1:if(!(t=n.sent()))throw new Error("Unable to locate period characteristic");return(r=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[2,t.writeValue(r)]}})})},i.prototype.getCharacteristic=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.service.getCharacteristic(e)];case 1:return[2,t.sent()];case 2:return t.sent(),[2,void 0];case 3:return[2]}})})},i.prototype.getCharacteristValue=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return[4,this.getCharacteristic(e)];case 1:if(!(t=r.sent()))throw new Error("Unable to locate characteristic");return[4,t.readValue()];case 2:return[2,r.sent()]}})})},i.prototype.startNotifications=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return[4,this.getCharacteristic(e)];case 1:return(t=r.sent())?[4,t.startNotifications()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}})})},i.prototype.onNewListener=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return this.listenerCount(e)>0?[2]:"magnetometerdatachanged"!==e?[3,2]:[4,this.getCharacteristic(S.magnetometerData)];case 1:(t=r.sent())&&t.addEventListener("characteristicvaluechanged",this.magnetometerDataChangedHandler.bind(this)),r.label=2;case 2:return"magnetometerbearingchanged"!==e?[3,4]:[4,this.getCharacteristic(S.magnetometerBearing)];case 3:(t=r.sent())&&t.addEventListener("characteristicvaluechanged",this.magnetometerBearingChangedHandler.bind(this)),r.label=4;case 4:return"magnetometercalibrationchanged"!==e?[3,6]:[4,this.getCharacteristic(S.magnetometerCalibration)];case 5:(t=r.sent())&&t.addEventListener("characteristicvaluechanged",this.magnetometerCalibrationChangedHandler.bind(this)),r.label=6;case 6:return[2]}})})},i.prototype.onRemoveListener=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return this.listenerCount(e)>0?[2]:"magnetometerdatachanged"!==e?[3,2]:[4,this.getCharacteristic(S.magnetometerData)];case 1:(t=r.sent())&&t.removeEventListener("characteristicvaluechanged",this.magnetometerDataChangedHandler.bind(this)),r.label=2;case 2:return"magnetometerbearingchanged"!==e?[3,4]:[4,this.getCharacteristic(S.magnetometerBearing)];case 3:(t=r.sent())&&t.removeEventListener("characteristicvaluechanged",this.magnetometerBearingChangedHandler.bind(this)),r.label=4;case 4:return"magnetometercalibrationchanged"!==e?[3,6]:[4,this.getCharacteristic(S.magnetometerCalibration)];case 5:(t=r.sent())&&t.removeEventListener("characteristicvaluechanged",this.magnetometerCalibrationChangedHandler.bind(this)),r.label=6;case 6:return[2]}})})},i.prototype.magnetometerDataChangedHandler=function(e){var t=e.target.value,r=this.dataViewToMagnetometerData(t);this.dispatchEvent("magnetometerdatachanged",r)},i.prototype.magnetometerBearingChangedHandler=function(e){var t=e.target.value;2===t.byteLength&&this.dispatchEvent("magnetometerbearingchanged",t.getUint16(0,!0))},i.prototype.magnetometerCalibrationChangedHandler=function(e){var t=e.target.value;1===t.byteLength&&this.dispatchEvent("magnetometercalibrationchanged",t.getUint8(0))},i.prototype.dataViewToMagnetometerData=function(e){return{x:e.getInt16(0,!0),y:e.getInt16(1,!0),z:e.getInt16(2,!0)}},i}(p);!function(e){e.pinData="e95d8d00-251d-470a-a062-fa1922dfa9a8",e.pinAdConfiguration="e95d5899-251d-470a-a062-fa1922dfa9a8",e.pinIoConfiguration="e95db9fe-251d-470a-a062-fa1922dfa9a8",e.pwmControl="e95dd822-251d-470a-a062-fa1922dfa9a8"}(N||(N={}));var B,D="6e400001-b5a3-f393-e0a9-e50e24dcca9e";!function(e){e.tx="6e400002-b5a3-f393-e0a9-e50e24dcca9e",e.rx="6e400003-b5a3-f393-e0a9-e50e24dcca9e"}(B||(B={}));var _,U=function(e){function i(t){var r=e.call(this)||this;return r.service=t,r}return t(i,e),i.createService=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return(t=e.find(function(e){return e.uuid===D}))?[4,(r=new i(t)).init()]:[2,void 0];case 1:return n.sent(),[2,r]}})})},i.prototype.init=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.startNotifications(B.tx)];case 1:return e.sent(),this.on("newListener",this.onNewListener.bind(this)),this.on("removeListener",this.onRemoveListener.bind(this)),[2]}})})},i.prototype.send=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(B.rx)];case 1:return[2,t.sent().writeValue(e)]}})})},i.prototype.sendString=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristic(B.rx)];case 1:return t=n.sent(),r=e.split("").map(function(e){return e.charCodeAt(0)}),[2,t.writeValue(new Uint8Array(r).buffer)]}})})},i.prototype.startNotifications=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().startNotifications()];case 2:return t.sent(),[2]}})})},i.prototype.onNewListener=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"receive"!==e?[3,2]:[4,this.service.getCharacteristic(B.tx)];case 1:t.sent().addEventListener("characteristicvaluechanged",this.receiveHandler.bind(this)),t.label=2;case 2:return"receiveString"!==e?[3,4]:[4,this.service.getCharacteristic(B.tx)];case 3:t.sent().addEventListener("characteristicvaluechanged",this.receiveStringHandler.bind(this)),t.label=4;case 4:return[2]}})})},i.prototype.onRemoveListener=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"receive"!==e?[3,2]:[4,this.service.getCharacteristic(B.tx)];case 1:t.sent().removeEventListener("characteristicvaluechanged",this.receiveHandler.bind(this)),t.label=2;case 2:return"receiveString"!==e?[3,4]:[4,this.service.getCharacteristic(B.tx)];case 3:t.sent().removeEventListener("characteristicvaluechanged",this.receiveStringHandler.bind(this)),t.label=4;case 4:return[2]}})})},i.prototype.receiveHandler=function(e){var t=e.target.value,r=new Uint8Array(t.buffer);this.dispatchEvent("receive",r)},i.prototype.receiveStringHandler=function(e){var t=e.target.value,r=Array.prototype.slice.call(new Uint8Array(t.buffer)),n=String.fromCharCode.apply(null,r);this.dispatchEvent("receiveString",n)},i}(p),H="e95d93af-251d-470a-a062-fa1922dfa9a8";!function(e){e.microBitRequirements="e95db84c-251d-470a-a062-fa1922dfa9a8",e.microBitEvent="e95d9775-251d-470a-a062-fa1922dfa9a8",e.clientRequirements="e95d23c4-251d-470a-a062-fa1922dfa9a8",e.clientEvent="e95d5404-251d-470a-a062-fa1922dfa9a8"}(_||(_={}));var R,T=function(e){function i(t){var r=e.call(this)||this;return r.service=t,r}return t(i,e),i.createService=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return(t=e.find(function(e){return e.uuid===H}))?[4,(r=new i(t)).init()]:[2,void 0];case 1:return n.sent(),[2,r]}})})},i.prototype.init=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.startNotifications(_.microBitEvent)];case 1:return e.sent(),[4,this.startNotifications(_.microBitRequirements)];case 2:return e.sent(),this.on("newListener",this.onNewListener.bind(this)),this.on("removeListener",this.onRemoveListener.bind(this)),[2]}})})},i.prototype.getMicrobitRequirements=function(){return r(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return[4,this.getCharacteristValue(_.microBitRequirements)];case 1:return e=t.sent(),[2,this.viewToMicrobitEvent(e)]}})})},i.prototype.setClientRequirements=function(e,t){return r(this,void 0,void 0,function(){var r,i;return n(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristic(_.clientRequirements)];case 1:return r=n.sent(),(i=new DataView(new ArrayBuffer(4))).setUint16(0,e,!0),i.setUint16(1,t,!0),[2,r.writeValue(i)]}})})},i.prototype.readMicrobitEvent=function(){return r(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return[4,this.getCharacteristValue(_.microBitEvent)];case 1:return e=t.sent(),[2,this.viewToMicrobitEvent(e)]}})})},i.prototype.writeClientEvent=function(e,t){return r(this,void 0,void 0,function(){var r,i;return n(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristic(_.clientEvent)];case 1:return r=n.sent(),(i=new DataView(new ArrayBuffer(4))).setUint16(0,e,!0),i.setUint16(1,t,!0),[2,r.writeValue(i)]}})})},i.prototype.getCharacteristValue=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().readValue()];case 2:return[2,t.sent()]}})})},i.prototype.startNotifications=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().startNotifications()];case 2:return t.sent(),[2]}})})},i.prototype.onNewListener=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"microbitevent"!==e?[3,2]:[4,this.service.getCharacteristic(_.microBitEvent)];case 1:t.sent().addEventListener("characteristicvaluechanged",this.eventHandler.bind(this)),t.label=2;case 2:return"microbitrequirementschanged"!==e?[3,4]:[4,this.service.getCharacteristic(_.microBitRequirements)];case 3:t.sent().addEventListener("characteristicvaluechanged",this.microbitRequirementsChangedHandler.bind(this)),t.label=4;case 4:return[2]}})})},i.prototype.onRemoveListener=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"microbitevent"!==e?[3,2]:[4,this.service.getCharacteristic(_.microBitEvent)];case 1:t.sent().removeEventListener("characteristicvaluechanged",this.eventHandler.bind(this)),t.label=2;case 2:return"microbitrequirementschanged"!==e?[3,4]:[4,this.service.getCharacteristic(_.microBitRequirements)];case 3:t.sent().removeEventListener("characteristicvaluechanged",this.microbitRequirementsChangedHandler.bind(this)),t.label=4;case 4:return[2]}})})},i.prototype.microbitRequirementsChangedHandler=function(e){var t=e.target.value,r=this.viewToMicrobitEvent(t);this.dispatchEvent("microbitrequirementschanged",r)},i.prototype.eventHandler=function(e){var t=e.target.value,r=this.viewToMicrobitEvent(t);this.dispatchEvent("microbitevent",r)},i.prototype.viewToMicrobitEvent=function(e){return{type:e.getUint16(0,!0),value:e.getUint16(1,!0)}},i}(p);!function(e){e.dfuControl="e95d93b1-251d-470a-a062-fa1922dfa9a8"}(R||(R={}));var M=function(e){return r(void 0,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,e.requestDevice({filters:[{namePrefix:"BBC micro:bit"}],optionalServices:["0000180a-0000-1000-8000-00805f9b34fb",g,w,"e95d6100-251d-470a-a062-fa1922dfa9a8","e95d0753-251d-470a-a062-fa1922dfa9a8","e95df2d8-251d-470a-a062-fa1922dfa9a8","e95d127b-251d-470a-a062-fa1922dfa9a8",D,H,"e95d93b0-251d-470a-a062-fa1922dfa9a8"]})];case 1:return[2,t.sent()]}})})},P=function(e){return r(void 0,void 0,void 0,function(){var t,r,i,s,o,c,u,h,f;return n(this,function(n){switch(n.label){case 0:return e&&e.gatt?e.gatt.connected?[3,2]:[4,e.gatt.connect()]:[2,{}];case 1:n.sent(),n.label=2;case 2:return[4,e.gatt.getPrimaryServices()];case 3:return t=n.sent(),[4,a.createService(t)];case 4:return r=n.sent(),[4,m.createService(t)];case 5:return i=n.sent(),[4,C.createService(t)];case 6:return s=n.sent(),[4,E.createService(t)];case 7:return o=n.sent(),[4,A.createService(t)];case 8:return c=n.sent(),[4,x.createService(t)];case 9:return u=n.sent(),[4,U.createService(t)];case 10:return h=n.sent(),[4,T.createService(t)];case 11:return f=n.sent(),[2,{deviceInformationService:r,buttonService:i,ledService:s,temperatureService:o,accelerometerService:c,magnetometerService:u,uartService:h,eventService:f}]}})})};export{P as getServices,M as requestMicrobit}; | ||
var e=function(t,r){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(t,r)};function t(t,r){function n(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function r(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){e.done?i(e.value):new r(function(t){t(e.value)}).then(o,s)}u((n=n.apply(e,t||[])).next())})}function n(e,t){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}var i,a=3,o=function(){function e(e,t,r){void 0===r&&(r=a),this.service=e,this.emitter=t,this.retries=r}return e.prototype.getCharacteristic=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return this.characteristics?[3,2]:(t=this,[4,this.service.getCharacteristics()]);case 1:t.characteristics=r.sent(),r.label=2;case 2:return[2,this.characteristics.find(function(t){return t.uuid===e})]}})})},e.prototype.retry=function(e){for(var t=0;;){t++;try{return e()}catch(e){if(t===this.retries)throw e}}},e.prototype.getCharacteristicValue=function(e){return r(this,void 0,void 0,function(){var t,i=this;return n(this,function(a){switch(a.label){case 0:return[4,this.getCharacteristic(e)];case 1:if(!(t=a.sent()))throw new Error("Unable to locate characteristic");return[4,this.retry(function(){return r(i,void 0,void 0,function(){return n(this,function(e){return[2,t.readValue()]})})})];case 2:return[2,a.sent()]}})})},e.prototype.setCharacteristicValue=function(e,t){return r(this,void 0,void 0,function(){var i,a=this;return n(this,function(o){switch(o.label){case 0:return[4,this.getCharacteristic(e)];case 1:if(!(i=o.sent()))throw new Error("Unable to locate characteristic");return[4,this.retry(function(){return r(a,void 0,void 0,function(){return n(this,function(e){return[2,i.writeValue(t)]})})})];case 2:return o.sent(),[2]}})})},e.prototype.handleListener=function(e,t,i){return r(this,void 0,void 0,function(){var a,o=this;return n(this,function(s){switch(s.label){case 0:return[4,this.getCharacteristic(t)];case 1:return(a=s.sent())?[4,this.retry(function(){return r(o,void 0,void 0,function(){return n(this,function(e){return[2,a.startNotifications()]})})})]:[2];case 2:return s.sent(),this.emitter.on("newListener",function(t){if(!(t!==e||o.emitter.listenerCount(e)>0))return o.retry(function(){return r(o,void 0,void 0,function(){return n(this,function(e){return[2,a.addEventListener("characteristicvaluechanged",i)]})})})}),this.emitter.on("removeListener",function(t){if(!(t!==e||o.emitter.listenerCount(e)>0))return o.retry(function(){return r(o,void 0,void 0,function(){return n(this,function(e){return[2,a.removeEventListener("characteristicvaluechanged",i)]})})})}),[2]}})})},e}();!function(e){e.modelNumber="00002a24-0000-1000-8000-00805f9b34fb",e.serialNumber="00002a25-0000-1000-8000-00805f9b34fb",e.firmwareRevision="00002a26-0000-1000-8000-00805f9b34fb",e.hardwareRevision="00002a27-0000-1000-8000-00805f9b34fb",e.manufacturer="00002a29-0000-1000-8000-00805f9b34fb"}(i||(i={}));var s=function(){function e(e){this.helper=new o(e)}return e.create=function(t){return r(this,void 0,void 0,function(){return n(this,function(r){return[2,new e(t)]})})},e.prototype.readDeviceInformation=function(){return r(this,void 0,void 0,function(){var e,t,r,a,o,s;return n(this,function(n){switch(n.label){case 0:return e={},[4,this.readStringCharacteristic(i.modelNumber)];case 1:return(t=n.sent())&&(e.modelNumber=t),[4,this.readStringCharacteristic(i.serialNumber)];case 2:return(r=n.sent())&&(e.serialNumber=r),[4,this.readStringCharacteristic(i.firmwareRevision)];case 3:return(a=n.sent())&&(e.firmwareRevision=a),[4,this.readStringCharacteristic(i.hardwareRevision)];case 4:return(o=n.sent())&&(e.hardwareRevision=o),[4,this.readStringCharacteristic(i.manufacturer)];case 5:return(s=n.sent())&&(e.manufacturer=s),[2,e]}})})},e.prototype.readStringCharacteristic=function(e){return r(this,void 0,void 0,function(){var t,r;return n(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.helper.getCharacteristicValue(e)];case 1:return t=n.sent(),r=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),[2,String.fromCharCode.apply(null,Array.from(new Uint8Array(r)))];case 2:return n.sent(),[2,void 0];case 3:return[2]}})})},e.uuid="0000180a-0000-1000-8000-00805f9b34fb",e}();function u(){}function c(){c.init.call(this)}function h(e){return void 0===e._maxListeners?c.defaultMaxListeners:e._maxListeners}function f(e,t,r,n){var i,a,o,s;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),o=a[t]):(a=e._events=new u,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),!o.warned&&(i=h(e))&&i>0&&o.length>i){o.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=o.length,s=c,"function"==typeof console.warn?console.warn(s):console.log(s)}}else o=a[t]=r,++e._eventsCount;return e}function d(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function l(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function v(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}u.prototype=Object.create(null),c.EventEmitter=c,c.usingDomains=!1,c.prototype.domain=void 0,c.prototype._events=void 0,c.prototype._maxListeners=void 0,c.defaultMaxListeners=10,c.init=function(){this.domain=null,c.usingDomains&&(void 0).active&&(void 0).Domain,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new u,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},c.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},c.prototype.getMaxListeners=function(){return h(this)},c.prototype.emit=function(e){var t,r,n,i,a,o,s,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(r=o[e]))return!1;var h="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=v(e,n),a=0;a<n;++a)i[a].call(r)}(r,h,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,a=v(e,i),o=0;o<i;++o)a[o].call(r,n)}(r,h,this,arguments[1]);break;case 3:!function(e,t,r,n,i){if(t)e.call(r,n,i);else for(var a=e.length,o=v(e,a),s=0;s<a;++s)o[s].call(r,n,i)}(r,h,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,i,a){if(t)e.call(r,n,i,a);else for(var o=e.length,s=v(e,o),u=0;u<o;++u)s[u].call(r,n,i,a)}(r,h,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),a=1;a<n;a++)i[a-1]=arguments[a];!function(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,a=v(e,i),o=0;o<i;++o)a[o].apply(r,n)}(r,h,this,i)}return!0},c.prototype.addListener=function(e,t){return f(this,e,t,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(e,t){return f(this,e,t,!0)},c.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,d(this,e,t)),this},c.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,d(this,e,t)),this},c.prototype.removeListener=function(e,t){var r,n,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new u:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,a=r.length;a-- >0;)if(r[a]===t||r[a].listener&&r[a].listener===t){o=r[a].listener,i=a;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new u,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,o||t)}return this},c.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new u,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new u:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),a=0;a<i.length;++a)"removeListener"!==(n=i[a])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new u,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},c.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},c.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):l.call(e,t)},c.prototype.listenerCount=l,c.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var p,m,g=function(e){function r(){var t=null!==e&&e.apply(this,arguments)||this;return t.isEventListenerObject=function(e){return void 0!==e.handleEvent},t}return t(r,e),r.prototype.addEventListener=function(t,r){if(r){var n=this.isEventListenerObject(r)?r.handleEvent:r;e.prototype.addListener.call(this,t,n)}},r.prototype.removeEventListener=function(t,r){if(r){var n=this.isEventListenerObject(r)?r.handleEvent:r;e.prototype.removeListener.call(this,t,n)}},r.prototype.dispatchEvent=function(t,r){var n;return n="string"==typeof t?new CustomEvent(t,{detail:r}):t,e.prototype.emit.call(this,n.type,n)},r}(c);!function(e){e.buttonAState="e95dda90-251d-470a-a062-fa1922dfa9a8",e.buttonBState="e95dda91-251d-470a-a062-fa1922dfa9a8"}(p||(p={})),function(e){e[e.Release=0]="Release",e[e.ShortPress=1]="ShortPress",e[e.LongPress=2]="LongPress"}(m||(m={}));var y,b=function(e){function i(t){var r=e.call(this)||this;return r.helper=new o(t,r),r}return t(i,e),i.create=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return[4,(t=new i(e)).init()];case 1:return r.sent(),[2,t]}})})},i.prototype.init=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.helper.handleListener("buttonastatechanged",p.buttonAState,this.buttonAStateChangedHandler.bind(this))];case 1:return e.sent(),[4,this.helper.handleListener("buttonbstatechanged",p.buttonBState,this.buttonBStateChangedHandler.bind(this))];case 2:return e.sent(),[2]}})})},i.prototype.readButtonAState=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.helper.getCharacteristicValue(p.buttonAState)];case 1:return[2,e.sent().getUint8(0)]}})})},i.prototype.readButtonBState=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.helper.getCharacteristicValue(p.buttonBState)];case 1:return[2,e.sent().getUint8(0)]}})})},i.prototype.buttonAStateChangedHandler=function(e){var t=e.target.value;this.dispatchEvent("buttonastatechanged",t.getUint8(0))},i.prototype.buttonBStateChangedHandler=function(e){var t=e.target.value;this.dispatchEvent("buttonbstatechanged",t.getUint8(0))},i.uuid="e95d9882-251d-470a-a062-fa1922dfa9a8",i}(g);!function(e){e.ledMatrixState="e95d7b77-251d-470a-a062-fa1922dfa9a8",e.ledText="e95d93ee-251d-470a-a062-fa1922dfa9a8",e.scrollingDelay="e95d0d2d-251d-470a-a062-fa1922dfa9a8"}(y||(y={}));var w,C=function(){function e(e){this.helper=new o(e)}return e.create=function(t){return r(this,void 0,void 0,function(){return n(this,function(r){return[2,new e(t)]})})},e.prototype.writeText=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){return t=this.encodeString(e),[2,this.helper.setCharacteristicValue(y.ledText,t)]})})},e.prototype.getMatrixState=function(){return r(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return[4,this.helper.getCharacteristicValue(y.ledMatrixState)];case 1:return e=t.sent(),[2,this.viewToLedMatrix(e)]}})})},e.prototype.setMatrixState=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){return t=this.ledMatrixToView(e),[2,this.helper.setCharacteristicValue(y.ledMatrixState,t)]})})},e.prototype.getScrollingDelay=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.helper.getCharacteristicValue(y.scrollingDelay)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},e.prototype.setScrollingDelay=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){return(t=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[2,this.helper.setCharacteristicValue(y.scrollingDelay,t)]})})},e.prototype.encodeString=function(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return t},e.prototype.viewToLedMatrix=function(e){for(var t=[],r=0;r<5;r++)t[r]=this.byteToBoolArray(e.getUint8(r));return t},e.prototype.byteToBoolArray=function(e){for(var t=[!1,!1,!1,!1,!1],r=0;r<t.length;r++)t[r]=1==(1&e),e>>=1;return t.reverse()},e.prototype.ledMatrixToView=function(e){for(var t=new DataView(new ArrayBuffer(5)),r=0;r<5;r++)t.setUint8(r,this.boolArrayToByte(e[r]));return t},e.prototype.boolArrayToByte=function(e){return e.reduce(function(e,t){return e<<1|(t?1:0)},0)},e.uuid="e95dd91d-251d-470a-a062-fa1922dfa9a8",e}();!function(e){e.temperature="e95d9250-251d-470a-a062-fa1922dfa9a8",e.temperaturePeriod="e95d1b25-251d-470a-a062-fa1922dfa9a8"}(w||(w={}));var L,S=function(e){function i(t){var r=e.call(this)||this;return r.helper=new o(t,r),r}return t(i,e),i.create=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return[4,(t=new i(e)).init()];case 1:return r.sent(),[2,t]}})})},i.prototype.init=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.helper.handleListener("temperaturechanged",w.temperature,this.temperatureChangedHandler.bind(this))];case 1:return e.sent(),[2]}})})},i.prototype.readTemperature=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.helper.getCharacteristicValue(w.temperature)];case 1:return[2,e.sent().getInt8(0)]}})})},i.prototype.getTemperaturePeriod=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.helper.getCharacteristicValue(w.temperaturePeriod)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},i.prototype.setTemperaturePeriod=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return(t=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[4,this.helper.setCharacteristicValue(w.temperaturePeriod,t)];case 1:return[2,r.sent()]}})})},i.prototype.temperatureChangedHandler=function(e){var t=e.target.value;this.dispatchEvent("temperaturechanged",t.getInt8(0))},i.uuid="e95d6100-251d-470a-a062-fa1922dfa9a8",i}(g);!function(e){e.accelerometerData="e95dca4b-251d-470a-a062-fa1922dfa9a8",e.accelerometerPeriod="e95dfb24-251d-470a-a062-fa1922dfa9a8"}(L||(L={}));var E,V,A=function(e){function i(t){var r=e.call(this)||this;return r.helper=new o(t,r),r}return t(i,e),i.create=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return[4,(t=new i(e)).init()];case 1:return r.sent(),[2,t]}})})},i.prototype.init=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.helper.handleListener("accelerometerdatachanged",L.accelerometerData,this.accelerometerDataChangedHandler.bind(this))];case 1:return e.sent(),[2]}})})},i.prototype.readAccelerometerData=function(){return r(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return[4,this.helper.getCharacteristicValue(L.accelerometerData)];case 1:return e=t.sent(),[2,this.dataViewToAccelerometerData(e)]}})})},i.prototype.getAccelerometerPeriod=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.helper.getCharacteristicValue(L.accelerometerPeriod)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},i.prototype.setAccelerometerPeriod=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){return(t=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[2,this.helper.setCharacteristicValue(L.accelerometerPeriod,t)]})})},i.prototype.accelerometerDataChangedHandler=function(e){var t=e.target.value,r=this.dataViewToAccelerometerData(t);this.dispatchEvent("accelerometerdatachanged",r)},i.prototype.dataViewToAccelerometerData=function(e){return{x:e.getInt16(0,!0)/1e3,y:e.getInt16(2,!0)/1e3,z:e.getInt16(4,!0)/1e3}},i.uuid="e95d0753-251d-470a-a062-fa1922dfa9a8",i}(g);!function(e){e.magnetometerData="e95dfb11-251d-470a-a062-fa1922dfa9a8",e.magnetometerPeriod="e95d386c-251d-470a-a062-fa1922dfa9a8",e.magnetometerBearing="e95d9715-251d-470a-a062-fa1922dfa9a8",e.magnetometerCalibration="e95db358-251d-470a-a062-fa1922dfa9a8"}(E||(E={})),function(e){e[e.unknown=0]="unknown",e[e.requested=1]="requested",e[e.completed=2]="completed",e[e.errored=3]="errored"}(V||(V={}));var _,x=function(e){function i(t){var r=e.call(this)||this;return r.helper=new o(t,r),r}return t(i,e),i.create=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return[4,(t=new i(e)).init()];case 1:return r.sent(),[2,t]}})})},i.prototype.init=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.helper.handleListener("magnetometerdatachanged",E.magnetometerData,this.magnetometerDataChangedHandler.bind(this))];case 1:return e.sent(),[4,this.helper.handleListener("magnetometerbearingchanged",E.magnetometerBearing,this.magnetometerBearingChangedHandler.bind(this))];case 2:return e.sent(),[4,this.helper.handleListener("magnetometercalibrationchanged",E.magnetometerCalibration,this.magnetometerCalibrationChangedHandler.bind(this))];case 3:return e.sent(),[2]}})})},i.prototype.calibrate=function(){return r(this,void 0,void 0,function(){return n(this,function(e){return[2,this.helper.setCharacteristicValue(E.magnetometerCalibration,new Uint8Array([1]))]})})},i.prototype.readMagnetometerData=function(){return r(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return[4,this.helper.getCharacteristicValue(E.magnetometerData)];case 1:return e=t.sent(),[2,this.dataViewToMagnetometerData(e)]}})})},i.prototype.getMagnetometerBearing=function(){return r(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return[4,this.helper.getCharacteristicValue(E.magnetometerBearing)];case 1:return 2===(e=t.sent()).byteLength?[2,e.getUint16(0,!0)]:[2,void 0]}})})},i.prototype.getMagnetometerPeriod=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.helper.getCharacteristicValue(E.magnetometerPeriod)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},i.prototype.setMagnetometerPeriod=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){return(t=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[2,this.helper.setCharacteristicValue(E.magnetometerPeriod,t)]})})},i.prototype.magnetometerDataChangedHandler=function(e){var t=e.target.value,r=this.dataViewToMagnetometerData(t);this.dispatchEvent("magnetometerdatachanged",r)},i.prototype.magnetometerBearingChangedHandler=function(e){var t=e.target.value;2===t.byteLength&&this.dispatchEvent("magnetometerbearingchanged",t.getUint16(0,!0))},i.prototype.magnetometerCalibrationChangedHandler=function(e){var t=e.target.value;1===t.byteLength&&this.dispatchEvent("magnetometercalibrationchanged",t.getUint8(0))},i.prototype.dataViewToMagnetometerData=function(e){return{x:e.getInt16(0,!0),y:e.getInt16(1,!0),z:e.getInt16(2,!0)}},i.uuid="e95df2d8-251d-470a-a062-fa1922dfa9a8",i}(g);!function(e){e.pinData="e95d8d00-251d-470a-a062-fa1922dfa9a8",e.pinAdConfiguration="e95d5899-251d-470a-a062-fa1922dfa9a8",e.pinIoConfiguration="e95db9fe-251d-470a-a062-fa1922dfa9a8",e.pwmControl="e95dd822-251d-470a-a062-fa1922dfa9a8"}(_||(_={}));var D,B=function(){function e(e){this.helper=new o(e)}return e.create=function(t){return r(this,void 0,void 0,function(){return n(this,function(r){return[2,new e(t)]})})},e.uuid="e95d127b-251d-470a-a062-fa1922dfa9a8",e}();!function(e){e.tx="6e400002-b5a3-f393-e0a9-e50e24dcca9e",e.rx="6e400003-b5a3-f393-e0a9-e50e24dcca9e"}(D||(D={}));var U,T=function(e){function i(t){var r=e.call(this)||this;return r.helper=new o(t,r),r}return t(i,e),i.create=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return[4,(t=new i(e)).init()];case 1:return r.sent(),[2,t]}})})},i.prototype.init=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.helper.handleListener("receive",D.tx,this.receiveHandler.bind(this))];case 1:return e.sent(),[4,this.helper.handleListener("receiveString",D.tx,this.receiveStringHandler.bind(this))];case 2:return e.sent(),[2]}})})},i.prototype.send=function(e){return r(this,void 0,void 0,function(){return n(this,function(t){return[2,this.helper.setCharacteristicValue(D.rx,e)]})})},i.prototype.sendString=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){return t=e.split("").map(function(e){return e.charCodeAt(0)}),[2,this.helper.setCharacteristicValue(D.rx,new Uint8Array(t).buffer)]})})},i.prototype.receiveHandler=function(e){var t=e.target.value,r=new Uint8Array(t.buffer);this.dispatchEvent("receive",r)},i.prototype.receiveStringHandler=function(e){var t=e.target.value,r=Array.prototype.slice.call(new Uint8Array(t.buffer)),n=String.fromCharCode.apply(null,r);this.dispatchEvent("receiveString",n)},i.uuid="6e400001-b5a3-f393-e0a9-e50e24dcca9e",i}(g);!function(e){e.microBitRequirements="e95db84c-251d-470a-a062-fa1922dfa9a8",e.microBitEvent="e95d9775-251d-470a-a062-fa1922dfa9a8",e.clientRequirements="e95d23c4-251d-470a-a062-fa1922dfa9a8",e.clientEvent="e95d5404-251d-470a-a062-fa1922dfa9a8"}(U||(U={}));var M,P=function(e){function i(t){var r=e.call(this)||this;return r.helper=new o(t,r),r}return t(i,e),i.create=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return[4,(t=new i(e)).init()];case 1:return r.sent(),[2,t]}})})},i.prototype.init=function(){return r(this,void 0,void 0,function(){return n(this,function(e){switch(e.label){case 0:return[4,this.helper.handleListener("microbitevent",U.microBitEvent,this.eventHandler.bind(this))];case 1:return e.sent(),[4,this.helper.handleListener("microbitrequirementschanged",U.microBitRequirements,this.microbitRequirementsChangedHandler.bind(this))];case 2:return e.sent(),[2]}})})},i.prototype.getMicrobitRequirements=function(){return r(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return[4,this.helper.getCharacteristicValue(U.microBitRequirements)];case 1:return e=t.sent(),[2,this.viewToMicrobitEvent(e)]}})})},i.prototype.setClientRequirements=function(e,t){return r(this,void 0,void 0,function(){var r;return n(this,function(n){switch(n.label){case 0:return(r=new DataView(new ArrayBuffer(4))).setUint16(0,e,!0),r.setUint16(1,t,!0),[4,this.helper.setCharacteristicValue(U.clientRequirements,r)];case 1:return[2,n.sent()]}})})},i.prototype.readMicrobitEvent=function(){return r(this,void 0,void 0,function(){var e;return n(this,function(t){switch(t.label){case 0:return[4,this.helper.getCharacteristicValue(U.microBitEvent)];case 1:return e=t.sent(),[2,this.viewToMicrobitEvent(e)]}})})},i.prototype.writeClientEvent=function(e,t){return r(this,void 0,void 0,function(){var r;return n(this,function(n){switch(n.label){case 0:return(r=new DataView(new ArrayBuffer(4))).setUint16(0,e,!0),r.setUint16(1,t,!0),[4,this.helper.setCharacteristicValue(U.clientEvent,r)];case 1:return[2,n.sent()]}})})},i.prototype.microbitRequirementsChangedHandler=function(e){var t=e.target.value,r=this.viewToMicrobitEvent(t);this.dispatchEvent("microbitrequirementschanged",r)},i.prototype.eventHandler=function(e){var t=e.target.value,r=this.viewToMicrobitEvent(t);this.dispatchEvent("microbitevent",r)},i.prototype.viewToMicrobitEvent=function(e){return{type:e.getUint16(0,!0),value:e.getUint16(1,!0)}},i.uuid="e95d93af-251d-470a-a062-fa1922dfa9a8",i}(g);!function(e){e.dfuControl="e95d93b1-251d-470a-a062-fa1922dfa9a8"}(M||(M={}));var H=function(){function e(e){this.helper=new o(e)}return e.create=function(t){return r(this,void 0,void 0,function(){return n(this,function(r){return[2,new e(t)]})})},e.uuid="e95d93b0-251d-470a-a062-fa1922dfa9a8",e}(),R=function(){function e(e){this.services=e}return e.prototype.createService=function(e){return r(this,void 0,void 0,function(){var t;return n(this,function(r){switch(r.label){case 0:return(t=this.services.find(function(t){return t.uuid===e.uuid}))?[4,e.create(t)]:[2,void 0];case 1:return[2,r.sent()]}})})},e}(),q=function(e){return r(void 0,void 0,void 0,function(){return n(this,function(t){switch(t.label){case 0:return[4,e.requestDevice({filters:[{namePrefix:"BBC micro:bit"}],optionalServices:[s.uuid,b.uuid,C.uuid,S.uuid,A.uuid,x.uuid,B.uuid,T.uuid,P.uuid,H.uuid]})];case 1:return[2,t.sent()]}})})},O=function(e){return r(void 0,void 0,void 0,function(){var t,r,i,a,o,u,c,h,f,d;return n(this,function(n){switch(n.label){case 0:return e&&e.gatt?e.gatt.connected?[3,2]:[4,e.gatt.connect()]:[2,{}];case 1:n.sent(),n.label=2;case 2:return[4,e.gatt.getPrimaryServices()];case 3:return t=n.sent(),[4,(r=new R(t)).createService(s)];case 4:return i=n.sent(),[4,r.createService(b)];case 5:return a=n.sent(),[4,r.createService(C)];case 6:return o=n.sent(),[4,r.createService(S)];case 7:return u=n.sent(),[4,r.createService(A)];case 8:return c=n.sent(),[4,r.createService(x)];case 9:return h=n.sent(),[4,r.createService(T)];case 10:return f=n.sent(),[4,r.createService(P)];case 11:return d=n.sent(),[2,{deviceInformationService:i,buttonService:a,ledService:o,temperatureService:u,accelerometerService:c,magnetometerService:h,uartService:f,eventService:d}]}})})};export{O as getServices,q as requestMicrobit}; | ||
//# sourceMappingURL=microbit.esm.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).microbit={})}(this,function(e){"use strict";var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,r)};function r(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function n(e,t,r,n){return new(r||(r=Promise))(function(i,a){function s(e){try{c(n.next(e))}catch(e){a(e)}}function o(e){try{c(n.throw(e))}catch(e){a(e)}}function c(e){e.done?i(e.value):new r(function(t){t(e.value)}).then(s,o)}c((n=n.apply(e,t||[])).next())})}function i(e,t){var r,n,i,a,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function o(a){return function(o){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=(i=s.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){s.label=a[1];break}if(6===a[0]&&s.label<i[1]){s.label=i[1],i=a;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(a);break}i[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,o])}}}var a;!function(e){e.modelNumber="00002a24-0000-1000-8000-00805f9b34fb",e.serialNumber="00002a25-0000-1000-8000-00805f9b34fb",e.firmwareRevision="00002a26-0000-1000-8000-00805f9b34fb",e.hardwareRevision="00002a27-0000-1000-8000-00805f9b34fb",e.manufacturer="00002a29-0000-1000-8000-00805f9b34fb"}(a||(a={}));var s=function(){function e(e){this.service=e}return e.createService=function(t){var r=t.find(function(e){return"0000180a-0000-1000-8000-00805f9b34fb"===e.uuid});if(r)return new e(r)},e.prototype.readDeviceInformation=function(){return n(this,void 0,void 0,function(){var e,t,r,n,s,o,c,u,h,f,d,l;return i(this,function(i){switch(i.label){case 0:return[4,this.service.getCharacteristics()];case 1:return e=i.sent(),t={},(r=e.find(function(e){return e.uuid===a.modelNumber}))?(n=t,[4,this.readStringCharacteristic(r)]):[3,3];case 2:n.modelNumber=i.sent(),i.label=3;case 3:return(s=e.find(function(e){return e.uuid===a.serialNumber}))?(o=t,[4,this.readStringCharacteristic(s)]):[3,5];case 4:o.serialNumber=i.sent(),i.label=5;case 5:return(c=e.find(function(e){return e.uuid===a.firmwareRevision}))?(u=t,[4,this.readStringCharacteristic(c)]):[3,7];case 6:u.firmwareRevision=i.sent(),i.label=7;case 7:return(h=e.find(function(e){return e.uuid===a.hardwareRevision}))?(f=t,[4,this.readStringCharacteristic(h)]):[3,9];case 8:f.hardwareRevision=i.sent(),i.label=9;case 9:return(d=e.find(function(e){return e.uuid===a.manufacturer}))?(l=t,[4,this.readStringCharacteristic(d)]):[3,11];case 10:l.manufacturer=i.sent(),i.label=11;case 11:return[2,t]}})})},e.prototype.readStringCharacteristic=function(e){return n(this,void 0,void 0,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return[4,e.readValue()];case 1:return t=n.sent(),r=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),[2,String.fromCharCode.apply(null,Array.from(new Uint8Array(r)))]}})})},e}();function o(){}function c(){c.init.call(this)}function u(e){return void 0===e._maxListeners?c.defaultMaxListeners:e._maxListeners}function h(e,t,r,n){var i,a,s,c;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),s=a[t]):(a=e._events=new o,e._eventsCount=0),s){if("function"==typeof s?s=a[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=u(e))&&i>0&&s.length>i){s.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=s.length,c=h,"function"==typeof console.warn?console.warn(c):console.log(c)}}else s=a[t]=r,++e._eventsCount;return e}function f(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function d(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function l(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}o.prototype=Object.create(null),c.EventEmitter=c,c.usingDomains=!1,c.prototype.domain=void 0,c.prototype._events=void 0,c.prototype._maxListeners=void 0,c.defaultMaxListeners=10,c.init=function(){this.domain=null,c.usingDomains&&(void 0).active&&(void 0).Domain,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new o,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},c.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},c.prototype.getMaxListeners=function(){return u(this)},c.prototype.emit=function(e){var t,r,n,i,a,s,o,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(o=this.domain,c){if(t=arguments[1],!o){if(t instanceof Error)throw t;var u=new Error('Uncaught, unspecified "error" event. ('+t+")");throw u.context=t,u}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=o,t.domainThrown=!1,o.emit("error",t),!1}if(!(r=s[e]))return!1;var h="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=l(e,n),a=0;a<n;++a)i[a].call(r)}(r,h,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,a=l(e,i),s=0;s<i;++s)a[s].call(r,n)}(r,h,this,arguments[1]);break;case 3:!function(e,t,r,n,i){if(t)e.call(r,n,i);else for(var a=e.length,s=l(e,a),o=0;o<a;++o)s[o].call(r,n,i)}(r,h,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,i,a){if(t)e.call(r,n,i,a);else for(var s=e.length,o=l(e,s),c=0;c<s;++c)o[c].call(r,n,i,a)}(r,h,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),a=1;a<n;a++)i[a-1]=arguments[a];!function(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,a=l(e,i),s=0;s<i;++s)a[s].apply(r,n)}(r,h,this,i)}return!0},c.prototype.addListener=function(e,t){return h(this,e,t,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(e,t){return h(this,e,t,!0)},c.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,f(this,e,t)),this},c.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,f(this,e,t)),this},c.prototype.removeListener=function(e,t){var r,n,i,a,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new o:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,a=r.length;a-- >0;)if(r[a]===t||r[a].listener&&r[a].listener===t){s=r[a].listener,i=a;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new o,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,s||t)}return this},c.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new o,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new o:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),a=0;a<i.length;++a)"removeListener"!==(n=i[a])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new o,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},c.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},c.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):d.call(e,t)},c.prototype.listenerCount=d,c.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var v,p,g=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.isEventListenerObject=function(e){return void 0!==e.handleEvent},t}return r(t,e),t.prototype.addEventListener=function(t,r){if(r){var n=this.isEventListenerObject(r)?r.handleEvent:r;e.prototype.addListener.call(this,t,n)}},t.prototype.removeEventListener=function(t,r){if(r){var n=this.isEventListenerObject(r)?r.handleEvent:r;e.prototype.removeListener.call(this,t,n)}},t.prototype.dispatchEvent=function(t,r){var n;return n="string"==typeof t?new CustomEvent(t,{detail:r}):t,e.prototype.emit.call(this,n.type,n)},t}(c),b="e95d9882-251d-470a-a062-fa1922dfa9a8";!function(e){e.buttonAState="e95dda90-251d-470a-a062-fa1922dfa9a8",e.buttonBState="e95dda91-251d-470a-a062-fa1922dfa9a8"}(v||(v={})),function(e){e[e.Release=0]="Release",e[e.ShortPress=1]="ShortPress",e[e.LongPress=2]="LongPress"}(p||(p={}));var m,w=function(e){function t(t){var r=e.call(this)||this;return r.service=t,r}return r(t,e),t.createService=function(e){return n(this,void 0,void 0,function(){var r,n;return i(this,function(i){switch(i.label){case 0:return(r=e.find(function(e){return e.uuid===b}))?[4,(n=new t(r)).init()]:[2,void 0];case 1:return i.sent(),[2,n]}})})},t.prototype.init=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.startNotifications(v.buttonAState)];case 1:return e.sent(),[4,this.startNotifications(v.buttonBState)];case 2:return e.sent(),this.on("newListener",this.onNewListener.bind(this)),this.on("removeListener",this.onRemoveListener.bind(this)),[2]}})})},t.prototype.readButtonAState=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.getCharacteristValue(v.buttonAState)];case 1:return[2,e.sent().getUint8(0)]}})})},t.prototype.readButtonBState=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.getCharacteristValue(v.buttonBState)];case 1:return[2,e.sent().getUint8(0)]}})})},t.prototype.getCharacteristValue=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.service];case 1:return[4,t.sent().getCharacteristic(e)];case 2:return[4,t.sent().readValue()];case 3:return[2,t.sent()]}})})},t.prototype.startNotifications=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().startNotifications()];case 2:return t.sent(),[2]}})})},t.prototype.onNewListener=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"buttonastatechanged"!==e?[3,2]:[4,this.service.getCharacteristic(v.buttonAState)];case 1:t.sent().addEventListener("characteristicvaluechanged",this.buttonAStateChangedHandler.bind(this)),t.label=2;case 2:return"buttonbstatechanged"!==e?[3,4]:[4,this.service.getCharacteristic(v.buttonBState)];case 3:t.sent().addEventListener("characteristicvaluechanged",this.buttonBStateChangedHandler.bind(this)),t.label=4;case 4:return[2]}})})},t.prototype.onRemoveListener=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return this.listenerCount(e)>0?[2]:"buttonastatechanged"!==e?[3,4]:[4,this.service];case 1:return[4,r.sent().getCharacteristic(v.buttonAState)];case 2:return(t=r.sent()).removeEventListener("characteristicvaluechanged",this.buttonAStateChangedHandler.bind(this)),[4,t.stopNotifications()];case 3:r.sent(),r.label=4;case 4:return"buttonbstatechanged"!==e?[3,8]:[4,this.service];case 5:return[4,r.sent().getCharacteristic(v.buttonBState)];case 6:return(t=r.sent()).removeEventListener("characteristicvaluechanged",this.buttonBStateChangedHandler.bind(this)),[4,t.stopNotifications()];case 7:r.sent(),r.label=8;case 8:return[2]}})})},t.prototype.buttonAStateChangedHandler=function(e){var t=e.target.value;this.dispatchEvent("buttonastatechanged",t.getUint8(0))},t.prototype.buttonBStateChangedHandler=function(e){var t=e.target.value;this.dispatchEvent("buttonbstatechanged",t.getUint8(0))},t}(g),y="e95dd91d-251d-470a-a062-fa1922dfa9a8";!function(e){e.ledMatrixState="e95d7b77-251d-470a-a062-fa1922dfa9a8",e.ledText="e95d93ee-251d-470a-a062-fa1922dfa9a8",e.scrollingDelay="e95d0d2d-251d-470a-a062-fa1922dfa9a8"}(m||(m={}));var C,L=function(){function e(e){this.service=e}return e.createService=function(t){var r=t.find(function(e){return e.uuid===y});if(r)return new e(r)},e.prototype.writeText=function(e){return n(this,void 0,void 0,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristic(m.ledText)];case 1:return t=n.sent(),r=this.encodeString(e),[2,t.writeValue(r)]}})})},e.prototype.getMatrixState=function(){return n(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,this.getCharacteristValue(m.ledMatrixState)];case 1:return e=t.sent(),[2,this.viewToLedMatrix(e)]}})})},e.prototype.setMatrixState=function(e){return n(this,void 0,void 0,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristic(m.ledMatrixState)];case 1:return t=n.sent(),r=this.ledMatrixToView(e),[2,t.writeValue(r)]}})})},e.prototype.getScrollingDelay=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.getCharacteristValue(m.scrollingDelay)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},e.prototype.setScrollingDelay=function(e){return n(this,void 0,void 0,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristic(m.scrollingDelay)];case 1:return t=n.sent(),(r=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[2,t.writeValue(r)]}})})},e.prototype.getCharacteristValue=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().readValue()];case 2:return[2,t.sent()]}})})},e.prototype.encodeString=function(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return t},e.prototype.viewToLedMatrix=function(e){for(var t=[],r=0;r<5;r++)t[r]=this.byteToBoolArray(e.getUint8(r));return t},e.prototype.byteToBoolArray=function(e){for(var t=[!1,!1,!1,!1,!1],r=0;r<t.length;r++)t[r]=1==(1&e),e>>=1;return t.reverse()},e.prototype.ledMatrixToView=function(e){for(var t=new DataView(new ArrayBuffer(5)),r=0;r<5;r++)t.setUint8(r,this.boolArrayToByte(e[r]));return t},e.prototype.boolArrayToByte=function(e){return e.reduce(function(e,t){return e<<1|(t?1:0)},0)},e}();!function(e){e.temperature="e95d9250-251d-470a-a062-fa1922dfa9a8",e.temperaturePeriod="e95d1b25-251d-470a-a062-fa1922dfa9a8"}(C||(C={}));var E,S=function(e){function t(t){var r=e.call(this)||this;return r.service=t,r}return r(t,e),t.createService=function(e){return n(this,void 0,void 0,function(){var r,n;return i(this,function(i){switch(i.label){case 0:return(r=e.find(function(e){return"e95d6100-251d-470a-a062-fa1922dfa9a8"===e.uuid}))?[4,(n=new t(r)).init()]:[2,void 0];case 1:return i.sent(),[2,n]}})})},t.prototype.init=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.startNotifications(C.temperature)];case 1:return e.sent(),this.on("newListener",this.onNewListener.bind(this)),this.on("removeListener",this.onRemoveListener.bind(this)),[2]}})})},t.prototype.readTemperature=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.getCharacteristValue(C.temperature)];case 1:return[2,e.sent().getInt8(0)]}})})},t.prototype.getTemperaturePeriod=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.getCharacteristValue(C.temperaturePeriod)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},t.prototype.setTemperaturePeriod=function(e){return n(this,void 0,void 0,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristic(C.temperaturePeriod)];case 1:return t=n.sent(),(r=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[2,t.writeValue(r)]}})})},t.prototype.getCharacteristValue=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().readValue()];case 2:return[2,t.sent()]}})})},t.prototype.startNotifications=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().startNotifications()];case 2:return t.sent(),[2]}})})},t.prototype.onNewListener=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"temperaturechanged"!==e?[3,2]:[4,this.service.getCharacteristic(C.temperature)];case 1:t.sent().addEventListener("characteristicvaluechanged",this.temperatureChangedHandler.bind(this)),t.label=2;case 2:return[2]}})})},t.prototype.onRemoveListener=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"temperaturechanged"!==e?[3,2]:[4,this.service.getCharacteristic(C.temperature)];case 1:t.sent().removeEventListener("characteristicvaluechanged",this.temperatureChangedHandler.bind(this)),t.label=2;case 2:return[2]}})})},t.prototype.temperatureChangedHandler=function(e){var t=e.target.value;this.dispatchEvent("temperaturechanged",t.getInt8(0))},t}(g);!function(e){e.accelerometerData="e95dca4b-251d-470a-a062-fa1922dfa9a8",e.accelerometerPeriod="e95dfb24-251d-470a-a062-fa1922dfa9a8"}(E||(E={}));var V,x,A=function(e){function t(t){var r=e.call(this)||this;return r.service=t,r}return r(t,e),t.createService=function(e){return n(this,void 0,void 0,function(){var r,n;return i(this,function(i){switch(i.label){case 0:return(r=e.find(function(e){return"e95d0753-251d-470a-a062-fa1922dfa9a8"===e.uuid}))?[4,(n=new t(r)).init()]:[2,void 0];case 1:return i.sent(),[2,n]}})})},t.prototype.init=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.startNotifications(E.accelerometerData)];case 1:return e.sent(),this.on("newListener",this.onNewListener.bind(this)),this.on("removeListener",this.onRemoveListener.bind(this)),[2]}})})},t.prototype.readAccelerometerData=function(){return n(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,this.getCharacteristValue(E.accelerometerData)];case 1:return e=t.sent(),[2,this.dataViewToAccelerometerData(e)]}})})},t.prototype.getAccelerometerPeriod=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.getCharacteristValue(E.accelerometerPeriod)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},t.prototype.setAccelerometerPeriod=function(e){return n(this,void 0,void 0,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristic(E.accelerometerPeriod)];case 1:return t=n.sent(),(r=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[2,t.writeValue(r)]}})})},t.prototype.getCharacteristValue=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().readValue()];case 2:return[2,t.sent()]}})})},t.prototype.startNotifications=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().startNotifications()];case 2:return t.sent(),[2]}})})},t.prototype.onNewListener=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"accelerometerdatachanged"!==e?[3,2]:[4,this.service.getCharacteristic(E.accelerometerData)];case 1:t.sent().addEventListener("characteristicvaluechanged",this.accelerometerDataChangedHandler.bind(this)),t.label=2;case 2:return[2]}})})},t.prototype.onRemoveListener=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"accelerometerdatachanged"!==e?[3,2]:[4,this.service.getCharacteristic(E.accelerometerData)];case 1:t.sent().removeEventListener("characteristicvaluechanged",this.accelerometerDataChangedHandler.bind(this)),t.label=2;case 2:return[2]}})})},t.prototype.accelerometerDataChangedHandler=function(e){var t=e.target.value,r=this.dataViewToAccelerometerData(t);this.dispatchEvent("accelerometerdatachanged",r)},t.prototype.dataViewToAccelerometerData=function(e){return{x:e.getInt16(0,!0)/1e3,y:e.getInt16(2,!0)/1e3,z:e.getInt16(4,!0)/1e3}},t}(g);!function(e){e.magnetometerData="e95dfb11-251d-470a-a062-fa1922dfa9a8",e.magnetometerPeriod="e95d386c-251d-470a-a062-fa1922dfa9a8",e.magnetometerBearing="e95d9715-251d-470a-a062-fa1922dfa9a8",e.magnetometerCalibration="e95db358-251d-470a-a062-fa1922dfa9a8"}(V||(V={})),function(e){e[e.unknown=0]="unknown",e[e.requested=1]="requested",e[e.completed=2]="completed",e[e.errored=3]="errored"}(x||(x={}));var N,B=function(e){function t(t){var r=e.call(this)||this;return r.service=t,r}return r(t,e),t.createService=function(e){return n(this,void 0,void 0,function(){var r,n;return i(this,function(i){switch(i.label){case 0:return(r=e.find(function(e){return"e95df2d8-251d-470a-a062-fa1922dfa9a8"===e.uuid}))?[4,(n=new t(r)).init()]:[2,void 0];case 1:return i.sent(),[2,n]}})})},t.prototype.init=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.startNotifications(V.magnetometerData)];case 1:return e.sent(),[4,this.startNotifications(V.magnetometerBearing)];case 2:return e.sent(),[4,this.startNotifications(V.magnetometerCalibration)];case 3:return e.sent(),this.on("newListener",this.onNewListener.bind(this)),this.on("removeListener",this.onRemoveListener.bind(this)),[2]}})})},t.prototype.calibrate=function(){return n(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,this.getCharacteristic(V.magnetometerCalibration)];case 1:if(!(e=t.sent()))throw new Error("Unable to locate calibration characteristic");return[2,e.writeValue(new Uint8Array([1]))]}})})},t.prototype.readMagnetometerData=function(){return n(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,this.getCharacteristValue(V.magnetometerData)];case 1:return e=t.sent(),[2,this.dataViewToMagnetometerData(e)]}})})},t.prototype.getMagnetometerBearing=function(){return n(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,this.getCharacteristValue(V.magnetometerBearing)];case 1:return 2===(e=t.sent()).byteLength?[2,e.getUint16(0,!0)]:[2,void 0]}})})},t.prototype.getMagnetometerPeriod=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.getCharacteristValue(V.magnetometerPeriod)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},t.prototype.setMagnetometerPeriod=function(e){return n(this,void 0,void 0,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return[4,this.getCharacteristic(V.magnetometerPeriod)];case 1:if(!(t=n.sent()))throw new Error("Unable to locate period characteristic");return(r=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[2,t.writeValue(r)]}})})},t.prototype.getCharacteristic=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this.service.getCharacteristic(e)];case 1:return[2,t.sent()];case 2:return t.sent(),[2,void 0];case 3:return[2]}})})},t.prototype.getCharacteristValue=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return[4,this.getCharacteristic(e)];case 1:if(!(t=r.sent()))throw new Error("Unable to locate characteristic");return[4,t.readValue()];case 2:return[2,r.sent()]}})})},t.prototype.startNotifications=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return[4,this.getCharacteristic(e)];case 1:return(t=r.sent())?[4,t.startNotifications()]:[3,3];case 2:r.sent(),r.label=3;case 3:return[2]}})})},t.prototype.onNewListener=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return this.listenerCount(e)>0?[2]:"magnetometerdatachanged"!==e?[3,2]:[4,this.getCharacteristic(V.magnetometerData)];case 1:(t=r.sent())&&t.addEventListener("characteristicvaluechanged",this.magnetometerDataChangedHandler.bind(this)),r.label=2;case 2:return"magnetometerbearingchanged"!==e?[3,4]:[4,this.getCharacteristic(V.magnetometerBearing)];case 3:(t=r.sent())&&t.addEventListener("characteristicvaluechanged",this.magnetometerBearingChangedHandler.bind(this)),r.label=4;case 4:return"magnetometercalibrationchanged"!==e?[3,6]:[4,this.getCharacteristic(V.magnetometerCalibration)];case 5:(t=r.sent())&&t.addEventListener("characteristicvaluechanged",this.magnetometerCalibrationChangedHandler.bind(this)),r.label=6;case 6:return[2]}})})},t.prototype.onRemoveListener=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return this.listenerCount(e)>0?[2]:"magnetometerdatachanged"!==e?[3,2]:[4,this.getCharacteristic(V.magnetometerData)];case 1:(t=r.sent())&&t.removeEventListener("characteristicvaluechanged",this.magnetometerDataChangedHandler.bind(this)),r.label=2;case 2:return"magnetometerbearingchanged"!==e?[3,4]:[4,this.getCharacteristic(V.magnetometerBearing)];case 3:(t=r.sent())&&t.removeEventListener("characteristicvaluechanged",this.magnetometerBearingChangedHandler.bind(this)),r.label=4;case 4:return"magnetometercalibrationchanged"!==e?[3,6]:[4,this.getCharacteristic(V.magnetometerCalibration)];case 5:(t=r.sent())&&t.removeEventListener("characteristicvaluechanged",this.magnetometerCalibrationChangedHandler.bind(this)),r.label=6;case 6:return[2]}})})},t.prototype.magnetometerDataChangedHandler=function(e){var t=e.target.value,r=this.dataViewToMagnetometerData(t);this.dispatchEvent("magnetometerdatachanged",r)},t.prototype.magnetometerBearingChangedHandler=function(e){var t=e.target.value;2===t.byteLength&&this.dispatchEvent("magnetometerbearingchanged",t.getUint16(0,!0))},t.prototype.magnetometerCalibrationChangedHandler=function(e){var t=e.target.value;1===t.byteLength&&this.dispatchEvent("magnetometercalibrationchanged",t.getUint8(0))},t.prototype.dataViewToMagnetometerData=function(e){return{x:e.getInt16(0,!0),y:e.getInt16(1,!0),z:e.getInt16(2,!0)}},t}(g);!function(e){e.pinData="e95d8d00-251d-470a-a062-fa1922dfa9a8",e.pinAdConfiguration="e95d5899-251d-470a-a062-fa1922dfa9a8",e.pinIoConfiguration="e95db9fe-251d-470a-a062-fa1922dfa9a8",e.pwmControl="e95dd822-251d-470a-a062-fa1922dfa9a8"}(N||(N={}));var _,D="6e400001-b5a3-f393-e0a9-e50e24dcca9e";!function(e){e.tx="6e400002-b5a3-f393-e0a9-e50e24dcca9e",e.rx="6e400003-b5a3-f393-e0a9-e50e24dcca9e"}(_||(_={}));var U,H=function(e){function t(t){var r=e.call(this)||this;return r.service=t,r}return r(t,e),t.createService=function(e){return n(this,void 0,void 0,function(){var r,n;return i(this,function(i){switch(i.label){case 0:return(r=e.find(function(e){return e.uuid===D}))?[4,(n=new t(r)).init()]:[2,void 0];case 1:return i.sent(),[2,n]}})})},t.prototype.init=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.startNotifications(_.tx)];case 1:return e.sent(),this.on("newListener",this.onNewListener.bind(this)),this.on("removeListener",this.onRemoveListener.bind(this)),[2]}})})},t.prototype.send=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(_.rx)];case 1:return[2,t.sent().writeValue(e)]}})})},t.prototype.sendString=function(e){return n(this,void 0,void 0,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return[4,this.service.getCharacteristic(_.rx)];case 1:return t=n.sent(),r=e.split("").map(function(e){return e.charCodeAt(0)}),[2,t.writeValue(new Uint8Array(r).buffer)]}})})},t.prototype.startNotifications=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().startNotifications()];case 2:return t.sent(),[2]}})})},t.prototype.onNewListener=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"receive"!==e?[3,2]:[4,this.service.getCharacteristic(_.tx)];case 1:t.sent().addEventListener("characteristicvaluechanged",this.receiveHandler.bind(this)),t.label=2;case 2:return"receiveString"!==e?[3,4]:[4,this.service.getCharacteristic(_.tx)];case 3:t.sent().addEventListener("characteristicvaluechanged",this.receiveStringHandler.bind(this)),t.label=4;case 4:return[2]}})})},t.prototype.onRemoveListener=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"receive"!==e?[3,2]:[4,this.service.getCharacteristic(_.tx)];case 1:t.sent().removeEventListener("characteristicvaluechanged",this.receiveHandler.bind(this)),t.label=2;case 2:return"receiveString"!==e?[3,4]:[4,this.service.getCharacteristic(_.tx)];case 3:t.sent().removeEventListener("characteristicvaluechanged",this.receiveStringHandler.bind(this)),t.label=4;case 4:return[2]}})})},t.prototype.receiveHandler=function(e){var t=e.target.value,r=new Uint8Array(t.buffer);this.dispatchEvent("receive",r)},t.prototype.receiveStringHandler=function(e){var t=e.target.value,r=Array.prototype.slice.call(new Uint8Array(t.buffer)),n=String.fromCharCode.apply(null,r);this.dispatchEvent("receiveString",n)},t}(g),R="e95d93af-251d-470a-a062-fa1922dfa9a8";!function(e){e.microBitRequirements="e95db84c-251d-470a-a062-fa1922dfa9a8",e.microBitEvent="e95d9775-251d-470a-a062-fa1922dfa9a8",e.clientRequirements="e95d23c4-251d-470a-a062-fa1922dfa9a8",e.clientEvent="e95d5404-251d-470a-a062-fa1922dfa9a8"}(U||(U={}));var T,M=function(e){function t(t){var r=e.call(this)||this;return r.service=t,r}return r(t,e),t.createService=function(e){return n(this,void 0,void 0,function(){var r,n;return i(this,function(i){switch(i.label){case 0:return(r=e.find(function(e){return e.uuid===R}))?[4,(n=new t(r)).init()]:[2,void 0];case 1:return i.sent(),[2,n]}})})},t.prototype.init=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.startNotifications(U.microBitEvent)];case 1:return e.sent(),[4,this.startNotifications(U.microBitRequirements)];case 2:return e.sent(),this.on("newListener",this.onNewListener.bind(this)),this.on("removeListener",this.onRemoveListener.bind(this)),[2]}})})},t.prototype.getMicrobitRequirements=function(){return n(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,this.getCharacteristValue(U.microBitRequirements)];case 1:return e=t.sent(),[2,this.viewToMicrobitEvent(e)]}})})},t.prototype.setClientRequirements=function(e,t){return n(this,void 0,void 0,function(){var r,n;return i(this,function(i){switch(i.label){case 0:return[4,this.service.getCharacteristic(U.clientRequirements)];case 1:return r=i.sent(),(n=new DataView(new ArrayBuffer(4))).setUint16(0,e,!0),n.setUint16(1,t,!0),[2,r.writeValue(n)]}})})},t.prototype.readMicrobitEvent=function(){return n(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,this.getCharacteristValue(U.microBitEvent)];case 1:return e=t.sent(),[2,this.viewToMicrobitEvent(e)]}})})},t.prototype.writeClientEvent=function(e,t){return n(this,void 0,void 0,function(){var r,n;return i(this,function(i){switch(i.label){case 0:return[4,this.service.getCharacteristic(U.clientEvent)];case 1:return r=i.sent(),(n=new DataView(new ArrayBuffer(4))).setUint16(0,e,!0),n.setUint16(1,t,!0),[2,r.writeValue(n)]}})})},t.prototype.getCharacteristValue=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().readValue()];case 2:return[2,t.sent()]}})})},t.prototype.startNotifications=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this.service.getCharacteristic(e)];case 1:return[4,t.sent().startNotifications()];case 2:return t.sent(),[2]}})})},t.prototype.onNewListener=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"microbitevent"!==e?[3,2]:[4,this.service.getCharacteristic(U.microBitEvent)];case 1:t.sent().addEventListener("characteristicvaluechanged",this.eventHandler.bind(this)),t.label=2;case 2:return"microbitrequirementschanged"!==e?[3,4]:[4,this.service.getCharacteristic(U.microBitRequirements)];case 3:t.sent().addEventListener("characteristicvaluechanged",this.microbitRequirementsChangedHandler.bind(this)),t.label=4;case 4:return[2]}})})},t.prototype.onRemoveListener=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return this.listenerCount(e)>0?[2]:"microbitevent"!==e?[3,2]:[4,this.service.getCharacteristic(U.microBitEvent)];case 1:t.sent().removeEventListener("characteristicvaluechanged",this.eventHandler.bind(this)),t.label=2;case 2:return"microbitrequirementschanged"!==e?[3,4]:[4,this.service.getCharacteristic(U.microBitRequirements)];case 3:t.sent().removeEventListener("characteristicvaluechanged",this.microbitRequirementsChangedHandler.bind(this)),t.label=4;case 4:return[2]}})})},t.prototype.microbitRequirementsChangedHandler=function(e){var t=e.target.value,r=this.viewToMicrobitEvent(t);this.dispatchEvent("microbitrequirementschanged",r)},t.prototype.eventHandler=function(e){var t=e.target.value,r=this.viewToMicrobitEvent(t);this.dispatchEvent("microbitevent",r)},t.prototype.viewToMicrobitEvent=function(e){return{type:e.getUint16(0,!0),value:e.getUint16(1,!0)}},t}(g);!function(e){e.dfuControl="e95d93b1-251d-470a-a062-fa1922dfa9a8"}(T||(T={}));e.getServices=function(e){return n(void 0,void 0,void 0,function(){var t,r,n,a,o,c,u,h,f;return i(this,function(i){switch(i.label){case 0:return e&&e.gatt?e.gatt.connected?[3,2]:[4,e.gatt.connect()]:[2,{}];case 1:i.sent(),i.label=2;case 2:return[4,e.gatt.getPrimaryServices()];case 3:return t=i.sent(),[4,s.createService(t)];case 4:return r=i.sent(),[4,w.createService(t)];case 5:return n=i.sent(),[4,L.createService(t)];case 6:return a=i.sent(),[4,S.createService(t)];case 7:return o=i.sent(),[4,A.createService(t)];case 8:return c=i.sent(),[4,B.createService(t)];case 9:return u=i.sent(),[4,H.createService(t)];case 10:return h=i.sent(),[4,M.createService(t)];case 11:return f=i.sent(),[2,{deviceInformationService:r,buttonService:n,ledService:a,temperatureService:o,accelerometerService:c,magnetometerService:u,uartService:h,eventService:f}]}})})},e.requestMicrobit=function(e){return n(void 0,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,e.requestDevice({filters:[{namePrefix:"BBC micro:bit"}],optionalServices:["0000180a-0000-1000-8000-00805f9b34fb",b,y,"e95d6100-251d-470a-a062-fa1922dfa9a8","e95d0753-251d-470a-a062-fa1922dfa9a8","e95df2d8-251d-470a-a062-fa1922dfa9a8","e95d127b-251d-470a-a062-fa1922dfa9a8",D,R,"e95d93b0-251d-470a-a062-fa1922dfa9a8"]})];case 1:return[2,t.sent()]}})})},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).microbit={})}(this,function(e){"use strict";var t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,r)};function r(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}function n(e,t,r,n){return new(r||(r=Promise))(function(i,a){function o(e){try{u(n.next(e))}catch(e){a(e)}}function s(e){try{u(n.throw(e))}catch(e){a(e)}}function u(e){e.done?i(e.value):new r(function(t){t(e.value)}).then(o,s)}u((n=n.apply(e,t||[])).next())})}function i(e,t){var r,n,i,a,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=(i=o.trys).length>0&&i[i.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}var a,o=3,s=function(){function e(e,t,r){void 0===r&&(r=o),this.service=e,this.emitter=t,this.retries=r}return e.prototype.getCharacteristic=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return this.characteristics?[3,2]:(t=this,[4,this.service.getCharacteristics()]);case 1:t.characteristics=r.sent(),r.label=2;case 2:return[2,this.characteristics.find(function(t){return t.uuid===e})]}})})},e.prototype.retry=function(e){for(var t=0;;){t++;try{return e()}catch(e){if(t===this.retries)throw e}}},e.prototype.getCharacteristicValue=function(e){return n(this,void 0,void 0,function(){var t,r=this;return i(this,function(a){switch(a.label){case 0:return[4,this.getCharacteristic(e)];case 1:if(!(t=a.sent()))throw new Error("Unable to locate characteristic");return[4,this.retry(function(){return n(r,void 0,void 0,function(){return i(this,function(e){return[2,t.readValue()]})})})];case 2:return[2,a.sent()]}})})},e.prototype.setCharacteristicValue=function(e,t){return n(this,void 0,void 0,function(){var r,a=this;return i(this,function(o){switch(o.label){case 0:return[4,this.getCharacteristic(e)];case 1:if(!(r=o.sent()))throw new Error("Unable to locate characteristic");return[4,this.retry(function(){return n(a,void 0,void 0,function(){return i(this,function(e){return[2,r.writeValue(t)]})})})];case 2:return o.sent(),[2]}})})},e.prototype.handleListener=function(e,t,r){return n(this,void 0,void 0,function(){var a,o=this;return i(this,function(s){switch(s.label){case 0:return[4,this.getCharacteristic(t)];case 1:return(a=s.sent())?[4,this.retry(function(){return n(o,void 0,void 0,function(){return i(this,function(e){return[2,a.startNotifications()]})})})]:[2];case 2:return s.sent(),this.emitter.on("newListener",function(t){if(!(t!==e||o.emitter.listenerCount(e)>0))return o.retry(function(){return n(o,void 0,void 0,function(){return i(this,function(e){return[2,a.addEventListener("characteristicvaluechanged",r)]})})})}),this.emitter.on("removeListener",function(t){if(!(t!==e||o.emitter.listenerCount(e)>0))return o.retry(function(){return n(o,void 0,void 0,function(){return i(this,function(e){return[2,a.removeEventListener("characteristicvaluechanged",r)]})})})}),[2]}})})},e}();!function(e){e.modelNumber="00002a24-0000-1000-8000-00805f9b34fb",e.serialNumber="00002a25-0000-1000-8000-00805f9b34fb",e.firmwareRevision="00002a26-0000-1000-8000-00805f9b34fb",e.hardwareRevision="00002a27-0000-1000-8000-00805f9b34fb",e.manufacturer="00002a29-0000-1000-8000-00805f9b34fb"}(a||(a={}));var u=function(){function e(e){this.helper=new s(e)}return e.create=function(t){return n(this,void 0,void 0,function(){return i(this,function(r){return[2,new e(t)]})})},e.prototype.readDeviceInformation=function(){return n(this,void 0,void 0,function(){var e,t,r,n,o,s;return i(this,function(i){switch(i.label){case 0:return e={},[4,this.readStringCharacteristic(a.modelNumber)];case 1:return(t=i.sent())&&(e.modelNumber=t),[4,this.readStringCharacteristic(a.serialNumber)];case 2:return(r=i.sent())&&(e.serialNumber=r),[4,this.readStringCharacteristic(a.firmwareRevision)];case 3:return(n=i.sent())&&(e.firmwareRevision=n),[4,this.readStringCharacteristic(a.hardwareRevision)];case 4:return(o=i.sent())&&(e.hardwareRevision=o),[4,this.readStringCharacteristic(a.manufacturer)];case 5:return(s=i.sent())&&(e.manufacturer=s),[2,e]}})})},e.prototype.readStringCharacteristic=function(e){return n(this,void 0,void 0,function(){var t,r;return i(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.helper.getCharacteristicValue(e)];case 1:return t=n.sent(),r=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),[2,String.fromCharCode.apply(null,Array.from(new Uint8Array(r)))];case 2:return n.sent(),[2,void 0];case 3:return[2]}})})},e.uuid="0000180a-0000-1000-8000-00805f9b34fb",e}();function c(){}function h(){h.init.call(this)}function f(e){return void 0===e._maxListeners?h.defaultMaxListeners:e._maxListeners}function d(e,t,r,n){var i,a,o,s;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((a=e._events)?(a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),o=a[t]):(a=e._events=new c,e._eventsCount=0),o){if("function"==typeof o?o=a[t]=n?[r,o]:[o,r]:n?o.unshift(r):o.push(r),!o.warned&&(i=f(e))&&i>0&&o.length>i){o.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=o.length,s=u,"function"==typeof console.warn?console.warn(s):console.log(s)}}else o=a[t]=r,++e._eventsCount;return e}function l(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function v(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function p(e,t){for(var r=new Array(t);t--;)r[t]=e[t];return r}c.prototype=Object.create(null),h.EventEmitter=h,h.usingDomains=!1,h.prototype.domain=void 0,h.prototype._events=void 0,h.prototype._maxListeners=void 0,h.defaultMaxListeners=10,h.init=function(){this.domain=null,h.usingDomains&&(void 0).active&&(void 0).Domain,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new c,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},h.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},h.prototype.getMaxListeners=function(){return f(this)},h.prototype.emit=function(e){var t,r,n,i,a,o,s,u="error"===e;if(o=this._events)u=u&&null==o.error;else if(!u)return!1;if(s=this.domain,u){if(t=arguments[1],!s){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=s,t.domainThrown=!1,s.emit("error",t),!1}if(!(r=o[e]))return!1;var h="function"==typeof r;switch(n=arguments.length){case 1:!function(e,t,r){if(t)e.call(r);else for(var n=e.length,i=p(e,n),a=0;a<n;++a)i[a].call(r)}(r,h,this);break;case 2:!function(e,t,r,n){if(t)e.call(r,n);else for(var i=e.length,a=p(e,i),o=0;o<i;++o)a[o].call(r,n)}(r,h,this,arguments[1]);break;case 3:!function(e,t,r,n,i){if(t)e.call(r,n,i);else for(var a=e.length,o=p(e,a),s=0;s<a;++s)o[s].call(r,n,i)}(r,h,this,arguments[1],arguments[2]);break;case 4:!function(e,t,r,n,i,a){if(t)e.call(r,n,i,a);else for(var o=e.length,s=p(e,o),u=0;u<o;++u)s[u].call(r,n,i,a)}(r,h,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),a=1;a<n;a++)i[a-1]=arguments[a];!function(e,t,r,n){if(t)e.apply(r,n);else for(var i=e.length,a=p(e,i),o=0;o<i;++o)a[o].apply(r,n)}(r,h,this,i)}return!0},h.prototype.addListener=function(e,t){return d(this,e,t,!1)},h.prototype.on=h.prototype.addListener,h.prototype.prependListener=function(e,t){return d(this,e,t,!0)},h.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,l(this,e,t)),this},h.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,l(this,e,t)),this},h.prototype.removeListener=function(e,t){var r,n,i,a,o;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(n=this._events))return this;if(!(r=n[e]))return this;if(r===t||r.listener&&r.listener===t)0==--this._eventsCount?this._events=new c:(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,a=r.length;a-- >0;)if(r[a]===t||r[a].listener&&r[a].listener===t){o=r[a].listener,i=a;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new c,this;delete n[e]}else!function(e,t){for(var r=t,n=r+1,i=e.length;n<i;r+=1,n+=1)e[r]=e[n];e.pop()}(r,i);n.removeListener&&this.emit("removeListener",e,o||t)}return this},h.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new c,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new c:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),a=0;a<i.length;++a)"removeListener"!==(n=i[a])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=new c,this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},h.prototype.listeners=function(e){var t,r=this._events;return r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(t):[]},h.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):v.call(e,t)},h.prototype.listenerCount=v,h.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var m,g,y=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.isEventListenerObject=function(e){return void 0!==e.handleEvent},t}return r(t,e),t.prototype.addEventListener=function(t,r){if(r){var n=this.isEventListenerObject(r)?r.handleEvent:r;e.prototype.addListener.call(this,t,n)}},t.prototype.removeEventListener=function(t,r){if(r){var n=this.isEventListenerObject(r)?r.handleEvent:r;e.prototype.removeListener.call(this,t,n)}},t.prototype.dispatchEvent=function(t,r){var n;return n="string"==typeof t?new CustomEvent(t,{detail:r}):t,e.prototype.emit.call(this,n.type,n)},t}(h);!function(e){e.buttonAState="e95dda90-251d-470a-a062-fa1922dfa9a8",e.buttonBState="e95dda91-251d-470a-a062-fa1922dfa9a8"}(m||(m={})),function(e){e[e.Release=0]="Release",e[e.ShortPress=1]="ShortPress",e[e.LongPress=2]="LongPress"}(g||(g={}));var b,w=function(e){function t(t){var r=e.call(this)||this;return r.helper=new s(t,r),r}return r(t,e),t.create=function(e){return n(this,void 0,void 0,function(){var r;return i(this,function(n){switch(n.label){case 0:return[4,(r=new t(e)).init()];case 1:return n.sent(),[2,r]}})})},t.prototype.init=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.helper.handleListener("buttonastatechanged",m.buttonAState,this.buttonAStateChangedHandler.bind(this))];case 1:return e.sent(),[4,this.helper.handleListener("buttonbstatechanged",m.buttonBState,this.buttonBStateChangedHandler.bind(this))];case 2:return e.sent(),[2]}})})},t.prototype.readButtonAState=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.helper.getCharacteristicValue(m.buttonAState)];case 1:return[2,e.sent().getUint8(0)]}})})},t.prototype.readButtonBState=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.helper.getCharacteristicValue(m.buttonBState)];case 1:return[2,e.sent().getUint8(0)]}})})},t.prototype.buttonAStateChangedHandler=function(e){var t=e.target.value;this.dispatchEvent("buttonastatechanged",t.getUint8(0))},t.prototype.buttonBStateChangedHandler=function(e){var t=e.target.value;this.dispatchEvent("buttonbstatechanged",t.getUint8(0))},t.uuid="e95d9882-251d-470a-a062-fa1922dfa9a8",t}(y);!function(e){e.ledMatrixState="e95d7b77-251d-470a-a062-fa1922dfa9a8",e.ledText="e95d93ee-251d-470a-a062-fa1922dfa9a8",e.scrollingDelay="e95d0d2d-251d-470a-a062-fa1922dfa9a8"}(b||(b={}));var C,L=function(){function e(e){this.helper=new s(e)}return e.create=function(t){return n(this,void 0,void 0,function(){return i(this,function(r){return[2,new e(t)]})})},e.prototype.writeText=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){return t=this.encodeString(e),[2,this.helper.setCharacteristicValue(b.ledText,t)]})})},e.prototype.getMatrixState=function(){return n(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,this.helper.getCharacteristicValue(b.ledMatrixState)];case 1:return e=t.sent(),[2,this.viewToLedMatrix(e)]}})})},e.prototype.setMatrixState=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){return t=this.ledMatrixToView(e),[2,this.helper.setCharacteristicValue(b.ledMatrixState,t)]})})},e.prototype.getScrollingDelay=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.helper.getCharacteristicValue(b.scrollingDelay)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},e.prototype.setScrollingDelay=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){return(t=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[2,this.helper.setCharacteristicValue(b.scrollingDelay,t)]})})},e.prototype.encodeString=function(e){for(var t=new ArrayBuffer(e.length),r=new Uint8Array(t),n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return t},e.prototype.viewToLedMatrix=function(e){for(var t=[],r=0;r<5;r++)t[r]=this.byteToBoolArray(e.getUint8(r));return t},e.prototype.byteToBoolArray=function(e){for(var t=[!1,!1,!1,!1,!1],r=0;r<t.length;r++)t[r]=1==(1&e),e>>=1;return t.reverse()},e.prototype.ledMatrixToView=function(e){for(var t=new DataView(new ArrayBuffer(5)),r=0;r<5;r++)t.setUint8(r,this.boolArrayToByte(e[r]));return t},e.prototype.boolArrayToByte=function(e){return e.reduce(function(e,t){return e<<1|(t?1:0)},0)},e.uuid="e95dd91d-251d-470a-a062-fa1922dfa9a8",e}();!function(e){e.temperature="e95d9250-251d-470a-a062-fa1922dfa9a8",e.temperaturePeriod="e95d1b25-251d-470a-a062-fa1922dfa9a8"}(C||(C={}));var S,E=function(e){function t(t){var r=e.call(this)||this;return r.helper=new s(t,r),r}return r(t,e),t.create=function(e){return n(this,void 0,void 0,function(){var r;return i(this,function(n){switch(n.label){case 0:return[4,(r=new t(e)).init()];case 1:return n.sent(),[2,r]}})})},t.prototype.init=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.helper.handleListener("temperaturechanged",C.temperature,this.temperatureChangedHandler.bind(this))];case 1:return e.sent(),[2]}})})},t.prototype.readTemperature=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.helper.getCharacteristicValue(C.temperature)];case 1:return[2,e.sent().getInt8(0)]}})})},t.prototype.getTemperaturePeriod=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.helper.getCharacteristicValue(C.temperaturePeriod)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},t.prototype.setTemperaturePeriod=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return(t=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[4,this.helper.setCharacteristicValue(C.temperaturePeriod,t)];case 1:return[2,r.sent()]}})})},t.prototype.temperatureChangedHandler=function(e){var t=e.target.value;this.dispatchEvent("temperaturechanged",t.getInt8(0))},t.uuid="e95d6100-251d-470a-a062-fa1922dfa9a8",t}(y);!function(e){e.accelerometerData="e95dca4b-251d-470a-a062-fa1922dfa9a8",e.accelerometerPeriod="e95dfb24-251d-470a-a062-fa1922dfa9a8"}(S||(S={}));var V,_,x=function(e){function t(t){var r=e.call(this)||this;return r.helper=new s(t,r),r}return r(t,e),t.create=function(e){return n(this,void 0,void 0,function(){var r;return i(this,function(n){switch(n.label){case 0:return[4,(r=new t(e)).init()];case 1:return n.sent(),[2,r]}})})},t.prototype.init=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.helper.handleListener("accelerometerdatachanged",S.accelerometerData,this.accelerometerDataChangedHandler.bind(this))];case 1:return e.sent(),[2]}})})},t.prototype.readAccelerometerData=function(){return n(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,this.helper.getCharacteristicValue(S.accelerometerData)];case 1:return e=t.sent(),[2,this.dataViewToAccelerometerData(e)]}})})},t.prototype.getAccelerometerPeriod=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.helper.getCharacteristicValue(S.accelerometerPeriod)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},t.prototype.setAccelerometerPeriod=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){return(t=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[2,this.helper.setCharacteristicValue(S.accelerometerPeriod,t)]})})},t.prototype.accelerometerDataChangedHandler=function(e){var t=e.target.value,r=this.dataViewToAccelerometerData(t);this.dispatchEvent("accelerometerdatachanged",r)},t.prototype.dataViewToAccelerometerData=function(e){return{x:e.getInt16(0,!0)/1e3,y:e.getInt16(2,!0)/1e3,z:e.getInt16(4,!0)/1e3}},t.uuid="e95d0753-251d-470a-a062-fa1922dfa9a8",t}(y);!function(e){e.magnetometerData="e95dfb11-251d-470a-a062-fa1922dfa9a8",e.magnetometerPeriod="e95d386c-251d-470a-a062-fa1922dfa9a8",e.magnetometerBearing="e95d9715-251d-470a-a062-fa1922dfa9a8",e.magnetometerCalibration="e95db358-251d-470a-a062-fa1922dfa9a8"}(V||(V={})),function(e){e[e.unknown=0]="unknown",e[e.requested=1]="requested",e[e.completed=2]="completed",e[e.errored=3]="errored"}(_||(_={}));var A,D=function(e){function t(t){var r=e.call(this)||this;return r.helper=new s(t,r),r}return r(t,e),t.create=function(e){return n(this,void 0,void 0,function(){var r;return i(this,function(n){switch(n.label){case 0:return[4,(r=new t(e)).init()];case 1:return n.sent(),[2,r]}})})},t.prototype.init=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.helper.handleListener("magnetometerdatachanged",V.magnetometerData,this.magnetometerDataChangedHandler.bind(this))];case 1:return e.sent(),[4,this.helper.handleListener("magnetometerbearingchanged",V.magnetometerBearing,this.magnetometerBearingChangedHandler.bind(this))];case 2:return e.sent(),[4,this.helper.handleListener("magnetometercalibrationchanged",V.magnetometerCalibration,this.magnetometerCalibrationChangedHandler.bind(this))];case 3:return e.sent(),[2]}})})},t.prototype.calibrate=function(){return n(this,void 0,void 0,function(){return i(this,function(e){return[2,this.helper.setCharacteristicValue(V.magnetometerCalibration,new Uint8Array([1]))]})})},t.prototype.readMagnetometerData=function(){return n(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,this.helper.getCharacteristicValue(V.magnetometerData)];case 1:return e=t.sent(),[2,this.dataViewToMagnetometerData(e)]}})})},t.prototype.getMagnetometerBearing=function(){return n(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,this.helper.getCharacteristicValue(V.magnetometerBearing)];case 1:return 2===(e=t.sent()).byteLength?[2,e.getUint16(0,!0)]:[2,void 0]}})})},t.prototype.getMagnetometerPeriod=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.helper.getCharacteristicValue(V.magnetometerPeriod)];case 1:return[2,e.sent().getUint16(0,!0)]}})})},t.prototype.setMagnetometerPeriod=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){return(t=new DataView(new ArrayBuffer(2))).setUint16(0,e,!0),[2,this.helper.setCharacteristicValue(V.magnetometerPeriod,t)]})})},t.prototype.magnetometerDataChangedHandler=function(e){var t=e.target.value,r=this.dataViewToMagnetometerData(t);this.dispatchEvent("magnetometerdatachanged",r)},t.prototype.magnetometerBearingChangedHandler=function(e){var t=e.target.value;2===t.byteLength&&this.dispatchEvent("magnetometerbearingchanged",t.getUint16(0,!0))},t.prototype.magnetometerCalibrationChangedHandler=function(e){var t=e.target.value;1===t.byteLength&&this.dispatchEvent("magnetometercalibrationchanged",t.getUint8(0))},t.prototype.dataViewToMagnetometerData=function(e){return{x:e.getInt16(0,!0),y:e.getInt16(1,!0),z:e.getInt16(2,!0)}},t.uuid="e95df2d8-251d-470a-a062-fa1922dfa9a8",t}(y);!function(e){e.pinData="e95d8d00-251d-470a-a062-fa1922dfa9a8",e.pinAdConfiguration="e95d5899-251d-470a-a062-fa1922dfa9a8",e.pinIoConfiguration="e95db9fe-251d-470a-a062-fa1922dfa9a8",e.pwmControl="e95dd822-251d-470a-a062-fa1922dfa9a8"}(A||(A={}));var B,U=function(){function e(e){this.helper=new s(e)}return e.create=function(t){return n(this,void 0,void 0,function(){return i(this,function(r){return[2,new e(t)]})})},e.uuid="e95d127b-251d-470a-a062-fa1922dfa9a8",e}();!function(e){e.tx="6e400002-b5a3-f393-e0a9-e50e24dcca9e",e.rx="6e400003-b5a3-f393-e0a9-e50e24dcca9e"}(B||(B={}));var T,M=function(e){function t(t){var r=e.call(this)||this;return r.helper=new s(t,r),r}return r(t,e),t.create=function(e){return n(this,void 0,void 0,function(){var r;return i(this,function(n){switch(n.label){case 0:return[4,(r=new t(e)).init()];case 1:return n.sent(),[2,r]}})})},t.prototype.init=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.helper.handleListener("receive",B.tx,this.receiveHandler.bind(this))];case 1:return e.sent(),[4,this.helper.handleListener("receiveString",B.tx,this.receiveStringHandler.bind(this))];case 2:return e.sent(),[2]}})})},t.prototype.send=function(e){return n(this,void 0,void 0,function(){return i(this,function(t){return[2,this.helper.setCharacteristicValue(B.rx,e)]})})},t.prototype.sendString=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){return t=e.split("").map(function(e){return e.charCodeAt(0)}),[2,this.helper.setCharacteristicValue(B.rx,new Uint8Array(t).buffer)]})})},t.prototype.receiveHandler=function(e){var t=e.target.value,r=new Uint8Array(t.buffer);this.dispatchEvent("receive",r)},t.prototype.receiveStringHandler=function(e){var t=e.target.value,r=Array.prototype.slice.call(new Uint8Array(t.buffer)),n=String.fromCharCode.apply(null,r);this.dispatchEvent("receiveString",n)},t.uuid="6e400001-b5a3-f393-e0a9-e50e24dcca9e",t}(y);!function(e){e.microBitRequirements="e95db84c-251d-470a-a062-fa1922dfa9a8",e.microBitEvent="e95d9775-251d-470a-a062-fa1922dfa9a8",e.clientRequirements="e95d23c4-251d-470a-a062-fa1922dfa9a8",e.clientEvent="e95d5404-251d-470a-a062-fa1922dfa9a8"}(T||(T={}));var P,H=function(e){function t(t){var r=e.call(this)||this;return r.helper=new s(t,r),r}return r(t,e),t.create=function(e){return n(this,void 0,void 0,function(){var r;return i(this,function(n){switch(n.label){case 0:return[4,(r=new t(e)).init()];case 1:return n.sent(),[2,r]}})})},t.prototype.init=function(){return n(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this.helper.handleListener("microbitevent",T.microBitEvent,this.eventHandler.bind(this))];case 1:return e.sent(),[4,this.helper.handleListener("microbitrequirementschanged",T.microBitRequirements,this.microbitRequirementsChangedHandler.bind(this))];case 2:return e.sent(),[2]}})})},t.prototype.getMicrobitRequirements=function(){return n(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,this.helper.getCharacteristicValue(T.microBitRequirements)];case 1:return e=t.sent(),[2,this.viewToMicrobitEvent(e)]}})})},t.prototype.setClientRequirements=function(e,t){return n(this,void 0,void 0,function(){var r;return i(this,function(n){switch(n.label){case 0:return(r=new DataView(new ArrayBuffer(4))).setUint16(0,e,!0),r.setUint16(1,t,!0),[4,this.helper.setCharacteristicValue(T.clientRequirements,r)];case 1:return[2,n.sent()]}})})},t.prototype.readMicrobitEvent=function(){return n(this,void 0,void 0,function(){var e;return i(this,function(t){switch(t.label){case 0:return[4,this.helper.getCharacteristicValue(T.microBitEvent)];case 1:return e=t.sent(),[2,this.viewToMicrobitEvent(e)]}})})},t.prototype.writeClientEvent=function(e,t){return n(this,void 0,void 0,function(){var r;return i(this,function(n){switch(n.label){case 0:return(r=new DataView(new ArrayBuffer(4))).setUint16(0,e,!0),r.setUint16(1,t,!0),[4,this.helper.setCharacteristicValue(T.clientEvent,r)];case 1:return[2,n.sent()]}})})},t.prototype.microbitRequirementsChangedHandler=function(e){var t=e.target.value,r=this.viewToMicrobitEvent(t);this.dispatchEvent("microbitrequirementschanged",r)},t.prototype.eventHandler=function(e){var t=e.target.value,r=this.viewToMicrobitEvent(t);this.dispatchEvent("microbitevent",r)},t.prototype.viewToMicrobitEvent=function(e){return{type:e.getUint16(0,!0),value:e.getUint16(1,!0)}},t.uuid="e95d93af-251d-470a-a062-fa1922dfa9a8",t}(y);!function(e){e.dfuControl="e95d93b1-251d-470a-a062-fa1922dfa9a8"}(P||(P={}));var R=function(){function e(e){this.helper=new s(e)}return e.create=function(t){return n(this,void 0,void 0,function(){return i(this,function(r){return[2,new e(t)]})})},e.uuid="e95d93b0-251d-470a-a062-fa1922dfa9a8",e}(),q=function(){function e(e){this.services=e}return e.prototype.createService=function(e){return n(this,void 0,void 0,function(){var t;return i(this,function(r){switch(r.label){case 0:return(t=this.services.find(function(t){return t.uuid===e.uuid}))?[4,e.create(t)]:[2,void 0];case 1:return[2,r.sent()]}})})},e}();e.getServices=function(e){return n(void 0,void 0,void 0,function(){var t,r,n,a,o,s,c,h,f,d;return i(this,function(i){switch(i.label){case 0:return e&&e.gatt?e.gatt.connected?[3,2]:[4,e.gatt.connect()]:[2,{}];case 1:i.sent(),i.label=2;case 2:return[4,e.gatt.getPrimaryServices()];case 3:return t=i.sent(),[4,(r=new q(t)).createService(u)];case 4:return n=i.sent(),[4,r.createService(w)];case 5:return a=i.sent(),[4,r.createService(L)];case 6:return o=i.sent(),[4,r.createService(E)];case 7:return s=i.sent(),[4,r.createService(x)];case 8:return c=i.sent(),[4,r.createService(D)];case 9:return h=i.sent(),[4,r.createService(M)];case 10:return f=i.sent(),[4,r.createService(H)];case 11:return d=i.sent(),[2,{deviceInformationService:n,buttonService:a,ledService:o,temperatureService:s,accelerometerService:c,magnetometerService:h,uartService:f,eventService:d}]}})})},e.requestMicrobit=function(e){return n(void 0,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,e.requestDevice({filters:[{namePrefix:"BBC micro:bit"}],optionalServices:[u.uuid,w.uuid,L.uuid,E.uuid,x.uuid,D.uuid,U.uuid,M.uuid,H.uuid,R.uuid]})];case 1:return[2,t.sent()]}})})},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=microbit.umd.js.map |
var typedoc = typedoc || {}; | ||
typedoc.search = typedoc.search || {}; | ||
typedoc.search.data = {"kinds":{"4":"Enumeration","16":"Enumeration member","64":"Function","128":"Class","256":"Interface","512":"Constructor","1024":"Property","2048":"Method","4194304":"Type alias"},"rows":[{"id":0,"kind":256,"name":"DeviceInformation","url":"interfaces/deviceinformation.html","classes":"tsd-kind-interface"},{"id":1,"kind":1024,"name":"modelNumber","url":"interfaces/deviceinformation.html#modelnumber","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"DeviceInformation"},{"id":2,"kind":1024,"name":"serialNumber","url":"interfaces/deviceinformation.html#serialnumber","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"DeviceInformation"},{"id":3,"kind":1024,"name":"firmwareRevision","url":"interfaces/deviceinformation.html#firmwarerevision","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"DeviceInformation"},{"id":4,"kind":1024,"name":"hardwareRevision","url":"interfaces/deviceinformation.html#hardwarerevision","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"DeviceInformation"},{"id":5,"kind":1024,"name":"manufacturer","url":"interfaces/deviceinformation.html#manufacturer","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"DeviceInformation"},{"id":6,"kind":128,"name":"DeviceInformationService","url":"classes/deviceinformationservice.html","classes":"tsd-kind-class"},{"id":7,"kind":2048,"name":"createService","url":"classes/deviceinformationservice.html#createservice","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"DeviceInformationService"},{"id":8,"kind":512,"name":"constructor","url":"classes/deviceinformationservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"DeviceInformationService"},{"id":9,"kind":2048,"name":"readDeviceInformation","url":"classes/deviceinformationservice.html#readdeviceinformation","classes":"tsd-kind-method tsd-parent-kind-class","parent":"DeviceInformationService"},{"id":10,"kind":4,"name":"ButtonState","url":"enums/buttonstate.html","classes":"tsd-kind-enum"},{"id":11,"kind":16,"name":"Release","url":"enums/buttonstate.html#release","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"ButtonState"},{"id":12,"kind":16,"name":"ShortPress","url":"enums/buttonstate.html#shortpress","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"ButtonState"},{"id":13,"kind":16,"name":"LongPress","url":"enums/buttonstate.html#longpress","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"ButtonState"},{"id":14,"kind":256,"name":"ButtonEvents","url":"interfaces/buttonevents.html","classes":"tsd-kind-interface"},{"id":15,"kind":1024,"name":"newListener","url":"interfaces/buttonevents.html#newlistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ButtonEvents"},{"id":16,"kind":1024,"name":"removeListener","url":"interfaces/buttonevents.html#removelistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ButtonEvents"},{"id":17,"kind":1024,"name":"buttonastatechanged","url":"interfaces/buttonevents.html#buttonastatechanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ButtonEvents"},{"id":18,"kind":1024,"name":"buttonbstatechanged","url":"interfaces/buttonevents.html#buttonbstatechanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ButtonEvents"},{"id":19,"kind":128,"name":"ButtonService","url":"classes/buttonservice.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":20,"kind":2048,"name":"createService","url":"classes/buttonservice.html#createservice","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"ButtonService"},{"id":21,"kind":512,"name":"constructor","url":"classes/buttonservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"ButtonService"},{"id":22,"kind":2048,"name":"readButtonAState","url":"classes/buttonservice.html#readbuttonastate","classes":"tsd-kind-method tsd-parent-kind-class","parent":"ButtonService"},{"id":23,"kind":2048,"name":"readButtonBState","url":"classes/buttonservice.html#readbuttonbstate","classes":"tsd-kind-method tsd-parent-kind-class","parent":"ButtonService"},{"id":24,"kind":2048,"name":"addEventListener","url":"classes/buttonservice.html#addeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":25,"kind":2048,"name":"removeEventListener","url":"classes/buttonservice.html#removeeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":26,"kind":2048,"name":"dispatchEvent","url":"classes/buttonservice.html#dispatchevent","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":27,"kind":2048,"name":"addListener","url":"classes/buttonservice.html#addlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":28,"kind":2048,"name":"on","url":"classes/buttonservice.html#on","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":29,"kind":2048,"name":"once","url":"classes/buttonservice.html#once","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":30,"kind":2048,"name":"prependListener","url":"classes/buttonservice.html#prependlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":31,"kind":2048,"name":"prependOnceListener","url":"classes/buttonservice.html#prependoncelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":32,"kind":2048,"name":"removeListener","url":"classes/buttonservice.html#removelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":33,"kind":2048,"name":"removeAllListeners","url":"classes/buttonservice.html#removealllisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":34,"kind":2048,"name":"listeners","url":"classes/buttonservice.html#listeners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":35,"kind":2048,"name":"emit","url":"classes/buttonservice.html#emit","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":36,"kind":2048,"name":"eventNames","url":"classes/buttonservice.html#eventnames","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":37,"kind":2048,"name":"listenerCount","url":"classes/buttonservice.html#listenercount","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":38,"kind":128,"name":"LedService","url":"classes/ledservice.html","classes":"tsd-kind-class"},{"id":39,"kind":2048,"name":"createService","url":"classes/ledservice.html#createservice","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"LedService"},{"id":40,"kind":512,"name":"constructor","url":"classes/ledservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"LedService"},{"id":41,"kind":2048,"name":"writeText","url":"classes/ledservice.html#writetext","classes":"tsd-kind-method tsd-parent-kind-class","parent":"LedService"},{"id":42,"kind":2048,"name":"getMatrixState","url":"classes/ledservice.html#getmatrixstate","classes":"tsd-kind-method tsd-parent-kind-class","parent":"LedService"},{"id":43,"kind":2048,"name":"setMatrixState","url":"classes/ledservice.html#setmatrixstate","classes":"tsd-kind-method tsd-parent-kind-class","parent":"LedService"},{"id":44,"kind":2048,"name":"getScrollingDelay","url":"classes/ledservice.html#getscrollingdelay","classes":"tsd-kind-method tsd-parent-kind-class","parent":"LedService"},{"id":45,"kind":2048,"name":"setScrollingDelay","url":"classes/ledservice.html#setscrollingdelay","classes":"tsd-kind-method tsd-parent-kind-class","parent":"LedService"},{"id":46,"kind":4194304,"name":"LedMatrix","url":"globals.html#ledmatrix","classes":"tsd-kind-type-alias"},{"id":47,"kind":256,"name":"TemperatureEvents","url":"interfaces/temperatureevents.html","classes":"tsd-kind-interface"},{"id":48,"kind":1024,"name":"newListener","url":"interfaces/temperatureevents.html#newlistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"TemperatureEvents"},{"id":49,"kind":1024,"name":"removeListener","url":"interfaces/temperatureevents.html#removelistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"TemperatureEvents"},{"id":50,"kind":1024,"name":"temperaturechanged","url":"interfaces/temperatureevents.html#temperaturechanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"TemperatureEvents"},{"id":51,"kind":128,"name":"TemperatureService","url":"classes/temperatureservice.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":52,"kind":2048,"name":"createService","url":"classes/temperatureservice.html#createservice","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"TemperatureService"},{"id":53,"kind":512,"name":"constructor","url":"classes/temperatureservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"TemperatureService"},{"id":54,"kind":2048,"name":"readTemperature","url":"classes/temperatureservice.html#readtemperature","classes":"tsd-kind-method tsd-parent-kind-class","parent":"TemperatureService"},{"id":55,"kind":2048,"name":"getTemperaturePeriod","url":"classes/temperatureservice.html#gettemperatureperiod","classes":"tsd-kind-method tsd-parent-kind-class","parent":"TemperatureService"},{"id":56,"kind":2048,"name":"setTemperaturePeriod","url":"classes/temperatureservice.html#settemperatureperiod","classes":"tsd-kind-method tsd-parent-kind-class","parent":"TemperatureService"},{"id":57,"kind":2048,"name":"addEventListener","url":"classes/temperatureservice.html#addeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":58,"kind":2048,"name":"removeEventListener","url":"classes/temperatureservice.html#removeeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":59,"kind":2048,"name":"dispatchEvent","url":"classes/temperatureservice.html#dispatchevent","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":60,"kind":2048,"name":"addListener","url":"classes/temperatureservice.html#addlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":61,"kind":2048,"name":"on","url":"classes/temperatureservice.html#on","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":62,"kind":2048,"name":"once","url":"classes/temperatureservice.html#once","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":63,"kind":2048,"name":"prependListener","url":"classes/temperatureservice.html#prependlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":64,"kind":2048,"name":"prependOnceListener","url":"classes/temperatureservice.html#prependoncelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":65,"kind":2048,"name":"removeListener","url":"classes/temperatureservice.html#removelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":66,"kind":2048,"name":"removeAllListeners","url":"classes/temperatureservice.html#removealllisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":67,"kind":2048,"name":"listeners","url":"classes/temperatureservice.html#listeners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":68,"kind":2048,"name":"emit","url":"classes/temperatureservice.html#emit","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":69,"kind":2048,"name":"eventNames","url":"classes/temperatureservice.html#eventnames","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":70,"kind":2048,"name":"listenerCount","url":"classes/temperatureservice.html#listenercount","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":71,"kind":256,"name":"AccelerometerData","url":"interfaces/accelerometerdata.html","classes":"tsd-kind-interface"},{"id":72,"kind":1024,"name":"x","url":"interfaces/accelerometerdata.html#x","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"AccelerometerData"},{"id":73,"kind":1024,"name":"y","url":"interfaces/accelerometerdata.html#y","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"AccelerometerData"},{"id":74,"kind":1024,"name":"z","url":"interfaces/accelerometerdata.html#z","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"AccelerometerData"},{"id":75,"kind":256,"name":"AccelerometerEvents","url":"interfaces/accelerometerevents.html","classes":"tsd-kind-interface"},{"id":76,"kind":1024,"name":"newListener","url":"interfaces/accelerometerevents.html#newlistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"AccelerometerEvents"},{"id":77,"kind":1024,"name":"removeListener","url":"interfaces/accelerometerevents.html#removelistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"AccelerometerEvents"},{"id":78,"kind":1024,"name":"accelerometerdatachanged","url":"interfaces/accelerometerevents.html#accelerometerdatachanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"AccelerometerEvents"},{"id":79,"kind":128,"name":"AccelerometerService","url":"classes/accelerometerservice.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":80,"kind":2048,"name":"createService","url":"classes/accelerometerservice.html#createservice","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"AccelerometerService"},{"id":81,"kind":512,"name":"constructor","url":"classes/accelerometerservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"AccelerometerService"},{"id":82,"kind":2048,"name":"readAccelerometerData","url":"classes/accelerometerservice.html#readaccelerometerdata","classes":"tsd-kind-method tsd-parent-kind-class","parent":"AccelerometerService"},{"id":83,"kind":2048,"name":"getAccelerometerPeriod","url":"classes/accelerometerservice.html#getaccelerometerperiod","classes":"tsd-kind-method tsd-parent-kind-class","parent":"AccelerometerService"},{"id":84,"kind":2048,"name":"setAccelerometerPeriod","url":"classes/accelerometerservice.html#setaccelerometerperiod","classes":"tsd-kind-method tsd-parent-kind-class","parent":"AccelerometerService"},{"id":85,"kind":2048,"name":"addEventListener","url":"classes/accelerometerservice.html#addeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":86,"kind":2048,"name":"removeEventListener","url":"classes/accelerometerservice.html#removeeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":87,"kind":2048,"name":"dispatchEvent","url":"classes/accelerometerservice.html#dispatchevent","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":88,"kind":2048,"name":"addListener","url":"classes/accelerometerservice.html#addlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":89,"kind":2048,"name":"on","url":"classes/accelerometerservice.html#on","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":90,"kind":2048,"name":"once","url":"classes/accelerometerservice.html#once","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":91,"kind":2048,"name":"prependListener","url":"classes/accelerometerservice.html#prependlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":92,"kind":2048,"name":"prependOnceListener","url":"classes/accelerometerservice.html#prependoncelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":93,"kind":2048,"name":"removeListener","url":"classes/accelerometerservice.html#removelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":94,"kind":2048,"name":"removeAllListeners","url":"classes/accelerometerservice.html#removealllisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":95,"kind":2048,"name":"listeners","url":"classes/accelerometerservice.html#listeners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":96,"kind":2048,"name":"emit","url":"classes/accelerometerservice.html#emit","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":97,"kind":2048,"name":"eventNames","url":"classes/accelerometerservice.html#eventnames","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":98,"kind":2048,"name":"listenerCount","url":"classes/accelerometerservice.html#listenercount","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":99,"kind":4194304,"name":"AccelerometerPeriod","url":"globals.html#accelerometerperiod","classes":"tsd-kind-type-alias"},{"id":100,"kind":256,"name":"MagnetometerData","url":"interfaces/magnetometerdata.html","classes":"tsd-kind-interface"},{"id":101,"kind":1024,"name":"x","url":"interfaces/magnetometerdata.html#x","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerData"},{"id":102,"kind":1024,"name":"y","url":"interfaces/magnetometerdata.html#y","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerData"},{"id":103,"kind":1024,"name":"z","url":"interfaces/magnetometerdata.html#z","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerData"},{"id":104,"kind":4,"name":"MagnetometerCalibration","url":"enums/magnetometercalibration.html","classes":"tsd-kind-enum"},{"id":105,"kind":16,"name":"unknown","url":"enums/magnetometercalibration.html#unknown","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"MagnetometerCalibration"},{"id":106,"kind":16,"name":"requested","url":"enums/magnetometercalibration.html#requested","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"MagnetometerCalibration"},{"id":107,"kind":16,"name":"completed","url":"enums/magnetometercalibration.html#completed","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"MagnetometerCalibration"},{"id":108,"kind":16,"name":"errored","url":"enums/magnetometercalibration.html#errored","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"MagnetometerCalibration"},{"id":109,"kind":256,"name":"MagnetometerEvents","url":"interfaces/magnetometerevents.html","classes":"tsd-kind-interface"},{"id":110,"kind":1024,"name":"newListener","url":"interfaces/magnetometerevents.html#newlistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerEvents"},{"id":111,"kind":1024,"name":"removeListener","url":"interfaces/magnetometerevents.html#removelistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerEvents"},{"id":112,"kind":1024,"name":"magnetometerdatachanged","url":"interfaces/magnetometerevents.html#magnetometerdatachanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerEvents"},{"id":113,"kind":1024,"name":"magnetometerbearingchanged","url":"interfaces/magnetometerevents.html#magnetometerbearingchanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerEvents"},{"id":114,"kind":1024,"name":"magnetometercalibrationchanged","url":"interfaces/magnetometerevents.html#magnetometercalibrationchanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerEvents"},{"id":115,"kind":128,"name":"MagnetometerService","url":"classes/magnetometerservice.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":116,"kind":2048,"name":"createService","url":"classes/magnetometerservice.html#createservice","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"MagnetometerService"},{"id":117,"kind":512,"name":"constructor","url":"classes/magnetometerservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"MagnetometerService"},{"id":118,"kind":2048,"name":"calibrate","url":"classes/magnetometerservice.html#calibrate","classes":"tsd-kind-method tsd-parent-kind-class","parent":"MagnetometerService"},{"id":119,"kind":2048,"name":"readMagnetometerData","url":"classes/magnetometerservice.html#readmagnetometerdata","classes":"tsd-kind-method tsd-parent-kind-class","parent":"MagnetometerService"},{"id":120,"kind":2048,"name":"getMagnetometerBearing","url":"classes/magnetometerservice.html#getmagnetometerbearing","classes":"tsd-kind-method tsd-parent-kind-class","parent":"MagnetometerService"},{"id":121,"kind":2048,"name":"getMagnetometerPeriod","url":"classes/magnetometerservice.html#getmagnetometerperiod","classes":"tsd-kind-method tsd-parent-kind-class","parent":"MagnetometerService"},{"id":122,"kind":2048,"name":"setMagnetometerPeriod","url":"classes/magnetometerservice.html#setmagnetometerperiod","classes":"tsd-kind-method tsd-parent-kind-class","parent":"MagnetometerService"},{"id":123,"kind":2048,"name":"addEventListener","url":"classes/magnetometerservice.html#addeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":124,"kind":2048,"name":"removeEventListener","url":"classes/magnetometerservice.html#removeeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":125,"kind":2048,"name":"dispatchEvent","url":"classes/magnetometerservice.html#dispatchevent","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":126,"kind":2048,"name":"addListener","url":"classes/magnetometerservice.html#addlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":127,"kind":2048,"name":"on","url":"classes/magnetometerservice.html#on","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":128,"kind":2048,"name":"once","url":"classes/magnetometerservice.html#once","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":129,"kind":2048,"name":"prependListener","url":"classes/magnetometerservice.html#prependlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":130,"kind":2048,"name":"prependOnceListener","url":"classes/magnetometerservice.html#prependoncelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":131,"kind":2048,"name":"removeListener","url":"classes/magnetometerservice.html#removelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":132,"kind":2048,"name":"removeAllListeners","url":"classes/magnetometerservice.html#removealllisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":133,"kind":2048,"name":"listeners","url":"classes/magnetometerservice.html#listeners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":134,"kind":2048,"name":"emit","url":"classes/magnetometerservice.html#emit","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":135,"kind":2048,"name":"eventNames","url":"classes/magnetometerservice.html#eventnames","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":136,"kind":2048,"name":"listenerCount","url":"classes/magnetometerservice.html#listenercount","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":137,"kind":4194304,"name":"MagnetometerPeriod","url":"globals.html#magnetometerperiod","classes":"tsd-kind-type-alias"},{"id":138,"kind":256,"name":"UartEvents","url":"interfaces/uartevents.html","classes":"tsd-kind-interface"},{"id":139,"kind":1024,"name":"newListener","url":"interfaces/uartevents.html#newlistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"UartEvents"},{"id":140,"kind":1024,"name":"removeListener","url":"interfaces/uartevents.html#removelistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"UartEvents"},{"id":141,"kind":1024,"name":"receive","url":"interfaces/uartevents.html#receive","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"UartEvents"},{"id":142,"kind":1024,"name":"receiveString","url":"interfaces/uartevents.html#receivestring","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"UartEvents"},{"id":143,"kind":128,"name":"UartService","url":"classes/uartservice.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":144,"kind":2048,"name":"createService","url":"classes/uartservice.html#createservice","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"UartService"},{"id":145,"kind":512,"name":"constructor","url":"classes/uartservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"UartService"},{"id":146,"kind":2048,"name":"send","url":"classes/uartservice.html#send","classes":"tsd-kind-method tsd-parent-kind-class","parent":"UartService"},{"id":147,"kind":2048,"name":"sendString","url":"classes/uartservice.html#sendstring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"UartService"},{"id":148,"kind":2048,"name":"addEventListener","url":"classes/uartservice.html#addeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":149,"kind":2048,"name":"removeEventListener","url":"classes/uartservice.html#removeeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":150,"kind":2048,"name":"dispatchEvent","url":"classes/uartservice.html#dispatchevent","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":151,"kind":2048,"name":"addListener","url":"classes/uartservice.html#addlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":152,"kind":2048,"name":"on","url":"classes/uartservice.html#on","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":153,"kind":2048,"name":"once","url":"classes/uartservice.html#once","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":154,"kind":2048,"name":"prependListener","url":"classes/uartservice.html#prependlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":155,"kind":2048,"name":"prependOnceListener","url":"classes/uartservice.html#prependoncelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":156,"kind":2048,"name":"removeListener","url":"classes/uartservice.html#removelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":157,"kind":2048,"name":"removeAllListeners","url":"classes/uartservice.html#removealllisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":158,"kind":2048,"name":"listeners","url":"classes/uartservice.html#listeners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":159,"kind":2048,"name":"emit","url":"classes/uartservice.html#emit","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":160,"kind":2048,"name":"eventNames","url":"classes/uartservice.html#eventnames","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":161,"kind":2048,"name":"listenerCount","url":"classes/uartservice.html#listenercount","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":162,"kind":256,"name":"MicrobitEvent","url":"interfaces/microbitevent.html","classes":"tsd-kind-interface"},{"id":163,"kind":1024,"name":"type","url":"interfaces/microbitevent.html#type","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MicrobitEvent"},{"id":164,"kind":1024,"name":"value","url":"interfaces/microbitevent.html#value","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MicrobitEvent"},{"id":165,"kind":256,"name":"MicrobitEvents","url":"interfaces/microbitevents.html","classes":"tsd-kind-interface"},{"id":166,"kind":1024,"name":"newListener","url":"interfaces/microbitevents.html#newlistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MicrobitEvents"},{"id":167,"kind":1024,"name":"removeListener","url":"interfaces/microbitevents.html#removelistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MicrobitEvents"},{"id":168,"kind":1024,"name":"microbitrequirementschanged","url":"interfaces/microbitevents.html#microbitrequirementschanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MicrobitEvents"},{"id":169,"kind":1024,"name":"microbitevent","url":"interfaces/microbitevents.html#microbitevent","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MicrobitEvents"},{"id":170,"kind":128,"name":"EventService","url":"classes/eventservice.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":171,"kind":2048,"name":"createService","url":"classes/eventservice.html#createservice","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-static","parent":"EventService"},{"id":172,"kind":512,"name":"constructor","url":"classes/eventservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"EventService"},{"id":173,"kind":2048,"name":"getMicrobitRequirements","url":"classes/eventservice.html#getmicrobitrequirements","classes":"tsd-kind-method tsd-parent-kind-class","parent":"EventService"},{"id":174,"kind":2048,"name":"setClientRequirements","url":"classes/eventservice.html#setclientrequirements","classes":"tsd-kind-method tsd-parent-kind-class","parent":"EventService"},{"id":175,"kind":2048,"name":"readMicrobitEvent","url":"classes/eventservice.html#readmicrobitevent","classes":"tsd-kind-method tsd-parent-kind-class","parent":"EventService"},{"id":176,"kind":2048,"name":"writeClientEvent","url":"classes/eventservice.html#writeclientevent","classes":"tsd-kind-method tsd-parent-kind-class","parent":"EventService"},{"id":177,"kind":2048,"name":"addEventListener","url":"classes/eventservice.html#addeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":178,"kind":2048,"name":"removeEventListener","url":"classes/eventservice.html#removeeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":179,"kind":2048,"name":"dispatchEvent","url":"classes/eventservice.html#dispatchevent","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":180,"kind":2048,"name":"addListener","url":"classes/eventservice.html#addlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":181,"kind":2048,"name":"on","url":"classes/eventservice.html#on","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":182,"kind":2048,"name":"once","url":"classes/eventservice.html#once","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":183,"kind":2048,"name":"prependListener","url":"classes/eventservice.html#prependlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":184,"kind":2048,"name":"prependOnceListener","url":"classes/eventservice.html#prependoncelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":185,"kind":2048,"name":"removeListener","url":"classes/eventservice.html#removelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":186,"kind":2048,"name":"removeAllListeners","url":"classes/eventservice.html#removealllisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":187,"kind":2048,"name":"listeners","url":"classes/eventservice.html#listeners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":188,"kind":2048,"name":"emit","url":"classes/eventservice.html#emit","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":189,"kind":2048,"name":"eventNames","url":"classes/eventservice.html#eventnames","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":190,"kind":2048,"name":"listenerCount","url":"classes/eventservice.html#listenercount","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":191,"kind":256,"name":"Services","url":"interfaces/services.html","classes":"tsd-kind-interface"},{"id":192,"kind":1024,"name":"deviceInformationService","url":"interfaces/services.html#deviceinformationservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":193,"kind":1024,"name":"buttonService","url":"interfaces/services.html#buttonservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":194,"kind":1024,"name":"ledService","url":"interfaces/services.html#ledservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":195,"kind":1024,"name":"temperatureService","url":"interfaces/services.html#temperatureservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":196,"kind":1024,"name":"accelerometerService","url":"interfaces/services.html#accelerometerservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":197,"kind":1024,"name":"magnetometerService","url":"interfaces/services.html#magnetometerservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":198,"kind":1024,"name":"uartService","url":"interfaces/services.html#uartservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":199,"kind":1024,"name":"eventService","url":"interfaces/services.html#eventservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":200,"kind":64,"name":"requestMicrobit","url":"globals.html#requestmicrobit","classes":"tsd-kind-function"},{"id":201,"kind":64,"name":"getServices","url":"globals.html#getservices","classes":"tsd-kind-function"}]}; | ||
typedoc.search.data = {"kinds":{"4":"Enumeration","16":"Enumeration member","32":"Variable","64":"Function","128":"Class","256":"Interface","512":"Constructor","1024":"Property","2048":"Method","65536":"Type literal","4194304":"Type alias"},"rows":[{"id":0,"kind":256,"name":"ServiceEventHandler","url":"interfaces/serviceeventhandler.html","classes":"tsd-kind-interface"},{"id":1,"kind":1024,"name":"characteristic","url":"interfaces/serviceeventhandler.html#characteristic","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ServiceEventHandler"},{"id":2,"kind":1024,"name":"handler","url":"interfaces/serviceeventhandler.html#handler","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ServiceEventHandler"},{"id":3,"kind":65536,"name":"__type","url":"interfaces/serviceeventhandler.html#handler.__type","classes":"tsd-kind-type-literal tsd-parent-kind-property tsd-is-not-exported","parent":"ServiceEventHandler.handler"},{"id":4,"kind":128,"name":"ServiceHelper","url":"classes/servicehelper.html","classes":"tsd-kind-class"},{"id":5,"kind":512,"name":"constructor","url":"classes/servicehelper.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"ServiceHelper"},{"id":6,"kind":2048,"name":"getCharacteristicValue","url":"classes/servicehelper.html#getcharacteristicvalue","classes":"tsd-kind-method tsd-parent-kind-class","parent":"ServiceHelper"},{"id":7,"kind":2048,"name":"setCharacteristicValue","url":"classes/servicehelper.html#setcharacteristicvalue","classes":"tsd-kind-method tsd-parent-kind-class","parent":"ServiceHelper"},{"id":8,"kind":2048,"name":"handleListener","url":"classes/servicehelper.html#handlelistener","classes":"tsd-kind-method tsd-parent-kind-class","parent":"ServiceHelper"},{"id":9,"kind":32,"name":"DEFAULT_RETRIES","url":"globals.html#default_retries","classes":"tsd-kind-variable tsd-is-not-exported"},{"id":10,"kind":256,"name":"DeviceInformation","url":"interfaces/deviceinformation.html","classes":"tsd-kind-interface"},{"id":11,"kind":1024,"name":"modelNumber","url":"interfaces/deviceinformation.html#modelnumber","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"DeviceInformation"},{"id":12,"kind":1024,"name":"serialNumber","url":"interfaces/deviceinformation.html#serialnumber","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"DeviceInformation"},{"id":13,"kind":1024,"name":"firmwareRevision","url":"interfaces/deviceinformation.html#firmwarerevision","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"DeviceInformation"},{"id":14,"kind":1024,"name":"hardwareRevision","url":"interfaces/deviceinformation.html#hardwarerevision","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"DeviceInformation"},{"id":15,"kind":1024,"name":"manufacturer","url":"interfaces/deviceinformation.html#manufacturer","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"DeviceInformation"},{"id":16,"kind":128,"name":"DeviceInformationService","url":"classes/deviceinformationservice.html","classes":"tsd-kind-class"},{"id":17,"kind":512,"name":"constructor","url":"classes/deviceinformationservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"DeviceInformationService"},{"id":18,"kind":2048,"name":"readDeviceInformation","url":"classes/deviceinformationservice.html#readdeviceinformation","classes":"tsd-kind-method tsd-parent-kind-class","parent":"DeviceInformationService"},{"id":19,"kind":4,"name":"ButtonState","url":"enums/buttonstate.html","classes":"tsd-kind-enum"},{"id":20,"kind":16,"name":"Release","url":"enums/buttonstate.html#release","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"ButtonState"},{"id":21,"kind":16,"name":"ShortPress","url":"enums/buttonstate.html#shortpress","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"ButtonState"},{"id":22,"kind":16,"name":"LongPress","url":"enums/buttonstate.html#longpress","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"ButtonState"},{"id":23,"kind":256,"name":"ButtonEvents","url":"interfaces/buttonevents.html","classes":"tsd-kind-interface"},{"id":24,"kind":1024,"name":"newListener","url":"interfaces/buttonevents.html#newlistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ButtonEvents"},{"id":25,"kind":1024,"name":"removeListener","url":"interfaces/buttonevents.html#removelistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ButtonEvents"},{"id":26,"kind":1024,"name":"buttonastatechanged","url":"interfaces/buttonevents.html#buttonastatechanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ButtonEvents"},{"id":27,"kind":1024,"name":"buttonbstatechanged","url":"interfaces/buttonevents.html#buttonbstatechanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"ButtonEvents"},{"id":28,"kind":128,"name":"ButtonService","url":"classes/buttonservice.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":29,"kind":512,"name":"constructor","url":"classes/buttonservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"ButtonService"},{"id":30,"kind":2048,"name":"readButtonAState","url":"classes/buttonservice.html#readbuttonastate","classes":"tsd-kind-method tsd-parent-kind-class","parent":"ButtonService"},{"id":31,"kind":2048,"name":"readButtonBState","url":"classes/buttonservice.html#readbuttonbstate","classes":"tsd-kind-method tsd-parent-kind-class","parent":"ButtonService"},{"id":32,"kind":2048,"name":"addEventListener","url":"classes/buttonservice.html#addeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":33,"kind":2048,"name":"removeEventListener","url":"classes/buttonservice.html#removeeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":34,"kind":2048,"name":"dispatchEvent","url":"classes/buttonservice.html#dispatchevent","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":35,"kind":2048,"name":"addListener","url":"classes/buttonservice.html#addlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":36,"kind":2048,"name":"on","url":"classes/buttonservice.html#on","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":37,"kind":2048,"name":"once","url":"classes/buttonservice.html#once","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":38,"kind":2048,"name":"prependListener","url":"classes/buttonservice.html#prependlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":39,"kind":2048,"name":"prependOnceListener","url":"classes/buttonservice.html#prependoncelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":40,"kind":2048,"name":"removeListener","url":"classes/buttonservice.html#removelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":41,"kind":2048,"name":"removeAllListeners","url":"classes/buttonservice.html#removealllisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":42,"kind":2048,"name":"listeners","url":"classes/buttonservice.html#listeners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":43,"kind":2048,"name":"emit","url":"classes/buttonservice.html#emit","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":44,"kind":2048,"name":"eventNames","url":"classes/buttonservice.html#eventnames","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":45,"kind":2048,"name":"listenerCount","url":"classes/buttonservice.html#listenercount","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"ButtonService"},{"id":46,"kind":2048,"name":"setMaxListeners","url":"classes/buttonservice.html#setmaxlisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"ButtonService"},{"id":47,"kind":2048,"name":"getMaxListeners","url":"classes/buttonservice.html#getmaxlisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"ButtonService"},{"id":48,"kind":128,"name":"LedService","url":"classes/ledservice.html","classes":"tsd-kind-class"},{"id":49,"kind":512,"name":"constructor","url":"classes/ledservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"LedService"},{"id":50,"kind":2048,"name":"writeText","url":"classes/ledservice.html#writetext","classes":"tsd-kind-method tsd-parent-kind-class","parent":"LedService"},{"id":51,"kind":2048,"name":"getMatrixState","url":"classes/ledservice.html#getmatrixstate","classes":"tsd-kind-method tsd-parent-kind-class","parent":"LedService"},{"id":52,"kind":2048,"name":"setMatrixState","url":"classes/ledservice.html#setmatrixstate","classes":"tsd-kind-method tsd-parent-kind-class","parent":"LedService"},{"id":53,"kind":2048,"name":"getScrollingDelay","url":"classes/ledservice.html#getscrollingdelay","classes":"tsd-kind-method tsd-parent-kind-class","parent":"LedService"},{"id":54,"kind":2048,"name":"setScrollingDelay","url":"classes/ledservice.html#setscrollingdelay","classes":"tsd-kind-method tsd-parent-kind-class","parent":"LedService"},{"id":55,"kind":4194304,"name":"LedMatrix","url":"globals.html#ledmatrix","classes":"tsd-kind-type-alias"},{"id":56,"kind":256,"name":"TemperatureEvents","url":"interfaces/temperatureevents.html","classes":"tsd-kind-interface"},{"id":57,"kind":1024,"name":"newListener","url":"interfaces/temperatureevents.html#newlistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"TemperatureEvents"},{"id":58,"kind":1024,"name":"removeListener","url":"interfaces/temperatureevents.html#removelistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"TemperatureEvents"},{"id":59,"kind":1024,"name":"temperaturechanged","url":"interfaces/temperatureevents.html#temperaturechanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"TemperatureEvents"},{"id":60,"kind":128,"name":"TemperatureService","url":"classes/temperatureservice.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":61,"kind":512,"name":"constructor","url":"classes/temperatureservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"TemperatureService"},{"id":62,"kind":2048,"name":"readTemperature","url":"classes/temperatureservice.html#readtemperature","classes":"tsd-kind-method tsd-parent-kind-class","parent":"TemperatureService"},{"id":63,"kind":2048,"name":"getTemperaturePeriod","url":"classes/temperatureservice.html#gettemperatureperiod","classes":"tsd-kind-method tsd-parent-kind-class","parent":"TemperatureService"},{"id":64,"kind":2048,"name":"setTemperaturePeriod","url":"classes/temperatureservice.html#settemperatureperiod","classes":"tsd-kind-method tsd-parent-kind-class","parent":"TemperatureService"},{"id":65,"kind":2048,"name":"addEventListener","url":"classes/temperatureservice.html#addeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":66,"kind":2048,"name":"removeEventListener","url":"classes/temperatureservice.html#removeeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":67,"kind":2048,"name":"dispatchEvent","url":"classes/temperatureservice.html#dispatchevent","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":68,"kind":2048,"name":"addListener","url":"classes/temperatureservice.html#addlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":69,"kind":2048,"name":"on","url":"classes/temperatureservice.html#on","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":70,"kind":2048,"name":"once","url":"classes/temperatureservice.html#once","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":71,"kind":2048,"name":"prependListener","url":"classes/temperatureservice.html#prependlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":72,"kind":2048,"name":"prependOnceListener","url":"classes/temperatureservice.html#prependoncelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":73,"kind":2048,"name":"removeListener","url":"classes/temperatureservice.html#removelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":74,"kind":2048,"name":"removeAllListeners","url":"classes/temperatureservice.html#removealllisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":75,"kind":2048,"name":"listeners","url":"classes/temperatureservice.html#listeners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":76,"kind":2048,"name":"emit","url":"classes/temperatureservice.html#emit","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":77,"kind":2048,"name":"eventNames","url":"classes/temperatureservice.html#eventnames","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":78,"kind":2048,"name":"listenerCount","url":"classes/temperatureservice.html#listenercount","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"TemperatureService"},{"id":79,"kind":2048,"name":"setMaxListeners","url":"classes/temperatureservice.html#setmaxlisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"TemperatureService"},{"id":80,"kind":2048,"name":"getMaxListeners","url":"classes/temperatureservice.html#getmaxlisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"TemperatureService"},{"id":81,"kind":256,"name":"AccelerometerData","url":"interfaces/accelerometerdata.html","classes":"tsd-kind-interface"},{"id":82,"kind":1024,"name":"x","url":"interfaces/accelerometerdata.html#x","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"AccelerometerData"},{"id":83,"kind":1024,"name":"y","url":"interfaces/accelerometerdata.html#y","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"AccelerometerData"},{"id":84,"kind":1024,"name":"z","url":"interfaces/accelerometerdata.html#z","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"AccelerometerData"},{"id":85,"kind":256,"name":"AccelerometerEvents","url":"interfaces/accelerometerevents.html","classes":"tsd-kind-interface"},{"id":86,"kind":1024,"name":"newListener","url":"interfaces/accelerometerevents.html#newlistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"AccelerometerEvents"},{"id":87,"kind":1024,"name":"removeListener","url":"interfaces/accelerometerevents.html#removelistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"AccelerometerEvents"},{"id":88,"kind":1024,"name":"accelerometerdatachanged","url":"interfaces/accelerometerevents.html#accelerometerdatachanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"AccelerometerEvents"},{"id":89,"kind":128,"name":"AccelerometerService","url":"classes/accelerometerservice.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":90,"kind":512,"name":"constructor","url":"classes/accelerometerservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"AccelerometerService"},{"id":91,"kind":2048,"name":"readAccelerometerData","url":"classes/accelerometerservice.html#readaccelerometerdata","classes":"tsd-kind-method tsd-parent-kind-class","parent":"AccelerometerService"},{"id":92,"kind":2048,"name":"getAccelerometerPeriod","url":"classes/accelerometerservice.html#getaccelerometerperiod","classes":"tsd-kind-method tsd-parent-kind-class","parent":"AccelerometerService"},{"id":93,"kind":2048,"name":"setAccelerometerPeriod","url":"classes/accelerometerservice.html#setaccelerometerperiod","classes":"tsd-kind-method tsd-parent-kind-class","parent":"AccelerometerService"},{"id":94,"kind":2048,"name":"addEventListener","url":"classes/accelerometerservice.html#addeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":95,"kind":2048,"name":"removeEventListener","url":"classes/accelerometerservice.html#removeeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":96,"kind":2048,"name":"dispatchEvent","url":"classes/accelerometerservice.html#dispatchevent","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":97,"kind":2048,"name":"addListener","url":"classes/accelerometerservice.html#addlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":98,"kind":2048,"name":"on","url":"classes/accelerometerservice.html#on","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":99,"kind":2048,"name":"once","url":"classes/accelerometerservice.html#once","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":100,"kind":2048,"name":"prependListener","url":"classes/accelerometerservice.html#prependlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":101,"kind":2048,"name":"prependOnceListener","url":"classes/accelerometerservice.html#prependoncelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":102,"kind":2048,"name":"removeListener","url":"classes/accelerometerservice.html#removelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":103,"kind":2048,"name":"removeAllListeners","url":"classes/accelerometerservice.html#removealllisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":104,"kind":2048,"name":"listeners","url":"classes/accelerometerservice.html#listeners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":105,"kind":2048,"name":"emit","url":"classes/accelerometerservice.html#emit","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":106,"kind":2048,"name":"eventNames","url":"classes/accelerometerservice.html#eventnames","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":107,"kind":2048,"name":"listenerCount","url":"classes/accelerometerservice.html#listenercount","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"AccelerometerService"},{"id":108,"kind":2048,"name":"setMaxListeners","url":"classes/accelerometerservice.html#setmaxlisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"AccelerometerService"},{"id":109,"kind":2048,"name":"getMaxListeners","url":"classes/accelerometerservice.html#getmaxlisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"AccelerometerService"},{"id":110,"kind":4194304,"name":"AccelerometerPeriod","url":"globals.html#accelerometerperiod","classes":"tsd-kind-type-alias"},{"id":111,"kind":256,"name":"MagnetometerData","url":"interfaces/magnetometerdata.html","classes":"tsd-kind-interface"},{"id":112,"kind":1024,"name":"x","url":"interfaces/magnetometerdata.html#x","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerData"},{"id":113,"kind":1024,"name":"y","url":"interfaces/magnetometerdata.html#y","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerData"},{"id":114,"kind":1024,"name":"z","url":"interfaces/magnetometerdata.html#z","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerData"},{"id":115,"kind":4,"name":"MagnetometerCalibration","url":"enums/magnetometercalibration.html","classes":"tsd-kind-enum"},{"id":116,"kind":16,"name":"unknown","url":"enums/magnetometercalibration.html#unknown","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"MagnetometerCalibration"},{"id":117,"kind":16,"name":"requested","url":"enums/magnetometercalibration.html#requested","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"MagnetometerCalibration"},{"id":118,"kind":16,"name":"completed","url":"enums/magnetometercalibration.html#completed","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"MagnetometerCalibration"},{"id":119,"kind":16,"name":"errored","url":"enums/magnetometercalibration.html#errored","classes":"tsd-kind-enum-member tsd-parent-kind-enum","parent":"MagnetometerCalibration"},{"id":120,"kind":256,"name":"MagnetometerEvents","url":"interfaces/magnetometerevents.html","classes":"tsd-kind-interface"},{"id":121,"kind":1024,"name":"newListener","url":"interfaces/magnetometerevents.html#newlistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerEvents"},{"id":122,"kind":1024,"name":"removeListener","url":"interfaces/magnetometerevents.html#removelistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerEvents"},{"id":123,"kind":1024,"name":"magnetometerdatachanged","url":"interfaces/magnetometerevents.html#magnetometerdatachanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerEvents"},{"id":124,"kind":1024,"name":"magnetometerbearingchanged","url":"interfaces/magnetometerevents.html#magnetometerbearingchanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerEvents"},{"id":125,"kind":1024,"name":"magnetometercalibrationchanged","url":"interfaces/magnetometerevents.html#magnetometercalibrationchanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MagnetometerEvents"},{"id":126,"kind":128,"name":"MagnetometerService","url":"classes/magnetometerservice.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":127,"kind":512,"name":"constructor","url":"classes/magnetometerservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"MagnetometerService"},{"id":128,"kind":2048,"name":"calibrate","url":"classes/magnetometerservice.html#calibrate","classes":"tsd-kind-method tsd-parent-kind-class","parent":"MagnetometerService"},{"id":129,"kind":2048,"name":"readMagnetometerData","url":"classes/magnetometerservice.html#readmagnetometerdata","classes":"tsd-kind-method tsd-parent-kind-class","parent":"MagnetometerService"},{"id":130,"kind":2048,"name":"getMagnetometerBearing","url":"classes/magnetometerservice.html#getmagnetometerbearing","classes":"tsd-kind-method tsd-parent-kind-class","parent":"MagnetometerService"},{"id":131,"kind":2048,"name":"getMagnetometerPeriod","url":"classes/magnetometerservice.html#getmagnetometerperiod","classes":"tsd-kind-method tsd-parent-kind-class","parent":"MagnetometerService"},{"id":132,"kind":2048,"name":"setMagnetometerPeriod","url":"classes/magnetometerservice.html#setmagnetometerperiod","classes":"tsd-kind-method tsd-parent-kind-class","parent":"MagnetometerService"},{"id":133,"kind":2048,"name":"addEventListener","url":"classes/magnetometerservice.html#addeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":134,"kind":2048,"name":"removeEventListener","url":"classes/magnetometerservice.html#removeeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":135,"kind":2048,"name":"dispatchEvent","url":"classes/magnetometerservice.html#dispatchevent","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":136,"kind":2048,"name":"addListener","url":"classes/magnetometerservice.html#addlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":137,"kind":2048,"name":"on","url":"classes/magnetometerservice.html#on","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":138,"kind":2048,"name":"once","url":"classes/magnetometerservice.html#once","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":139,"kind":2048,"name":"prependListener","url":"classes/magnetometerservice.html#prependlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":140,"kind":2048,"name":"prependOnceListener","url":"classes/magnetometerservice.html#prependoncelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":141,"kind":2048,"name":"removeListener","url":"classes/magnetometerservice.html#removelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":142,"kind":2048,"name":"removeAllListeners","url":"classes/magnetometerservice.html#removealllisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":143,"kind":2048,"name":"listeners","url":"classes/magnetometerservice.html#listeners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":144,"kind":2048,"name":"emit","url":"classes/magnetometerservice.html#emit","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":145,"kind":2048,"name":"eventNames","url":"classes/magnetometerservice.html#eventnames","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":146,"kind":2048,"name":"listenerCount","url":"classes/magnetometerservice.html#listenercount","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"MagnetometerService"},{"id":147,"kind":2048,"name":"setMaxListeners","url":"classes/magnetometerservice.html#setmaxlisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"MagnetometerService"},{"id":148,"kind":2048,"name":"getMaxListeners","url":"classes/magnetometerservice.html#getmaxlisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"MagnetometerService"},{"id":149,"kind":4194304,"name":"MagnetometerPeriod","url":"globals.html#magnetometerperiod","classes":"tsd-kind-type-alias"},{"id":150,"kind":128,"name":"IoPinService","url":"classes/iopinservice.html","classes":"tsd-kind-class"},{"id":151,"kind":1024,"name":"helper","url":"classes/iopinservice.html#helper","classes":"tsd-kind-property tsd-parent-kind-class","parent":"IoPinService"},{"id":152,"kind":512,"name":"constructor","url":"classes/iopinservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"IoPinService"},{"id":153,"kind":256,"name":"UartEvents","url":"interfaces/uartevents.html","classes":"tsd-kind-interface"},{"id":154,"kind":1024,"name":"newListener","url":"interfaces/uartevents.html#newlistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"UartEvents"},{"id":155,"kind":1024,"name":"removeListener","url":"interfaces/uartevents.html#removelistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"UartEvents"},{"id":156,"kind":1024,"name":"receive","url":"interfaces/uartevents.html#receive","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"UartEvents"},{"id":157,"kind":1024,"name":"receiveString","url":"interfaces/uartevents.html#receivestring","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"UartEvents"},{"id":158,"kind":128,"name":"UartService","url":"classes/uartservice.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":159,"kind":512,"name":"constructor","url":"classes/uartservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"UartService"},{"id":160,"kind":2048,"name":"send","url":"classes/uartservice.html#send","classes":"tsd-kind-method tsd-parent-kind-class","parent":"UartService"},{"id":161,"kind":2048,"name":"sendString","url":"classes/uartservice.html#sendstring","classes":"tsd-kind-method tsd-parent-kind-class","parent":"UartService"},{"id":162,"kind":2048,"name":"addEventListener","url":"classes/uartservice.html#addeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":163,"kind":2048,"name":"removeEventListener","url":"classes/uartservice.html#removeeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":164,"kind":2048,"name":"dispatchEvent","url":"classes/uartservice.html#dispatchevent","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":165,"kind":2048,"name":"addListener","url":"classes/uartservice.html#addlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":166,"kind":2048,"name":"on","url":"classes/uartservice.html#on","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":167,"kind":2048,"name":"once","url":"classes/uartservice.html#once","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":168,"kind":2048,"name":"prependListener","url":"classes/uartservice.html#prependlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":169,"kind":2048,"name":"prependOnceListener","url":"classes/uartservice.html#prependoncelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":170,"kind":2048,"name":"removeListener","url":"classes/uartservice.html#removelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":171,"kind":2048,"name":"removeAllListeners","url":"classes/uartservice.html#removealllisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":172,"kind":2048,"name":"listeners","url":"classes/uartservice.html#listeners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":173,"kind":2048,"name":"emit","url":"classes/uartservice.html#emit","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":174,"kind":2048,"name":"eventNames","url":"classes/uartservice.html#eventnames","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":175,"kind":2048,"name":"listenerCount","url":"classes/uartservice.html#listenercount","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"UartService"},{"id":176,"kind":2048,"name":"setMaxListeners","url":"classes/uartservice.html#setmaxlisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"UartService"},{"id":177,"kind":2048,"name":"getMaxListeners","url":"classes/uartservice.html#getmaxlisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"UartService"},{"id":178,"kind":256,"name":"MicrobitEvent","url":"interfaces/microbitevent.html","classes":"tsd-kind-interface"},{"id":179,"kind":1024,"name":"type","url":"interfaces/microbitevent.html#type","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MicrobitEvent"},{"id":180,"kind":1024,"name":"value","url":"interfaces/microbitevent.html#value","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MicrobitEvent"},{"id":181,"kind":256,"name":"MicrobitEvents","url":"interfaces/microbitevents.html","classes":"tsd-kind-interface"},{"id":182,"kind":1024,"name":"newListener","url":"interfaces/microbitevents.html#newlistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MicrobitEvents"},{"id":183,"kind":1024,"name":"removeListener","url":"interfaces/microbitevents.html#removelistener","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MicrobitEvents"},{"id":184,"kind":1024,"name":"microbitrequirementschanged","url":"interfaces/microbitevents.html#microbitrequirementschanged","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MicrobitEvents"},{"id":185,"kind":1024,"name":"microbitevent","url":"interfaces/microbitevents.html#microbitevent","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"MicrobitEvents"},{"id":186,"kind":128,"name":"EventService","url":"classes/eventservice.html","classes":"tsd-kind-class tsd-has-type-parameter"},{"id":187,"kind":512,"name":"constructor","url":"classes/eventservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"EventService"},{"id":188,"kind":2048,"name":"getMicrobitRequirements","url":"classes/eventservice.html#getmicrobitrequirements","classes":"tsd-kind-method tsd-parent-kind-class","parent":"EventService"},{"id":189,"kind":2048,"name":"setClientRequirements","url":"classes/eventservice.html#setclientrequirements","classes":"tsd-kind-method tsd-parent-kind-class","parent":"EventService"},{"id":190,"kind":2048,"name":"readMicrobitEvent","url":"classes/eventservice.html#readmicrobitevent","classes":"tsd-kind-method tsd-parent-kind-class","parent":"EventService"},{"id":191,"kind":2048,"name":"writeClientEvent","url":"classes/eventservice.html#writeclientevent","classes":"tsd-kind-method tsd-parent-kind-class","parent":"EventService"},{"id":192,"kind":2048,"name":"addEventListener","url":"classes/eventservice.html#addeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":193,"kind":2048,"name":"removeEventListener","url":"classes/eventservice.html#removeeventlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":194,"kind":2048,"name":"dispatchEvent","url":"classes/eventservice.html#dispatchevent","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":195,"kind":2048,"name":"addListener","url":"classes/eventservice.html#addlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":196,"kind":2048,"name":"on","url":"classes/eventservice.html#on","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":197,"kind":2048,"name":"once","url":"classes/eventservice.html#once","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":198,"kind":2048,"name":"prependListener","url":"classes/eventservice.html#prependlistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":199,"kind":2048,"name":"prependOnceListener","url":"classes/eventservice.html#prependoncelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":200,"kind":2048,"name":"removeListener","url":"classes/eventservice.html#removelistener","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":201,"kind":2048,"name":"removeAllListeners","url":"classes/eventservice.html#removealllisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":202,"kind":2048,"name":"listeners","url":"classes/eventservice.html#listeners","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":203,"kind":2048,"name":"emit","url":"classes/eventservice.html#emit","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":204,"kind":2048,"name":"eventNames","url":"classes/eventservice.html#eventnames","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":205,"kind":2048,"name":"listenerCount","url":"classes/eventservice.html#listenercount","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-inherited","parent":"EventService"},{"id":206,"kind":2048,"name":"setMaxListeners","url":"classes/eventservice.html#setmaxlisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"EventService"},{"id":207,"kind":2048,"name":"getMaxListeners","url":"classes/eventservice.html#getmaxlisteners","classes":"tsd-kind-method tsd-parent-kind-class tsd-is-inherited","parent":"EventService"},{"id":208,"kind":128,"name":"DfuControlService","url":"classes/dfucontrolservice.html","classes":"tsd-kind-class"},{"id":209,"kind":1024,"name":"helper","url":"classes/dfucontrolservice.html#helper","classes":"tsd-kind-property tsd-parent-kind-class","parent":"DfuControlService"},{"id":210,"kind":512,"name":"constructor","url":"classes/dfucontrolservice.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class","parent":"DfuControlService"},{"id":211,"kind":256,"name":"Services","url":"interfaces/services.html","classes":"tsd-kind-interface"},{"id":212,"kind":1024,"name":"deviceInformationService","url":"interfaces/services.html#deviceinformationservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":213,"kind":1024,"name":"buttonService","url":"interfaces/services.html#buttonservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":214,"kind":1024,"name":"ledService","url":"interfaces/services.html#ledservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":215,"kind":1024,"name":"temperatureService","url":"interfaces/services.html#temperatureservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":216,"kind":1024,"name":"accelerometerService","url":"interfaces/services.html#accelerometerservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":217,"kind":1024,"name":"magnetometerService","url":"interfaces/services.html#magnetometerservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":218,"kind":1024,"name":"uartService","url":"interfaces/services.html#uartservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":219,"kind":1024,"name":"eventService","url":"interfaces/services.html#eventservice","classes":"tsd-kind-property tsd-parent-kind-interface","parent":"Services"},{"id":220,"kind":256,"name":"Service","url":"interfaces/service.html","classes":"tsd-kind-interface tsd-is-not-exported"},{"id":221,"kind":1024,"name":"uuid","url":"interfaces/service.html#uuid","classes":"tsd-kind-property tsd-parent-kind-interface tsd-is-not-exported","parent":"Service"},{"id":222,"kind":2048,"name":"create","url":"interfaces/service.html#create","classes":"tsd-kind-method tsd-parent-kind-interface tsd-is-not-exported","parent":"Service"},{"id":223,"kind":128,"name":"ServiceBuilder","url":"classes/servicebuilder.html","classes":"tsd-kind-class tsd-is-not-exported"},{"id":224,"kind":512,"name":"constructor","url":"classes/servicebuilder.html#constructor","classes":"tsd-kind-constructor tsd-parent-kind-class tsd-is-not-exported","parent":"ServiceBuilder"},{"id":225,"kind":2048,"name":"createService","url":"classes/servicebuilder.html#createservice","classes":"tsd-kind-method tsd-parent-kind-class tsd-has-type-parameter tsd-is-not-exported","parent":"ServiceBuilder"},{"id":226,"kind":64,"name":"requestMicrobit","url":"globals.html#requestmicrobit","classes":"tsd-kind-function"},{"id":227,"kind":64,"name":"getServices","url":"globals.html#getservices","classes":"tsd-kind-function"}]}; |
{ | ||
"name": "microbit-web-bluetooth", | ||
"version": "0.2.0", | ||
"version": "0.2.1-next.9304435.0", | ||
"description": "Web Bluetooth library for micro:bit", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/thegecko/microbit-web-bluetooth", |
# micro:bit Web Bluetooth | ||
[![Circle CI](https://circleci.com/gh/thegecko/microbit-web-bluetooth.svg?style=shield&circle-token=a6f81fc05746394a595d8fe2b7c02eaf3120794b)](https://circleci.com/gh/thegecko/microbit-web-bluetooth/) | ||
[![npm](https://img.shields.io/npm/dm/microbit-web-bluetooth.svg)](https://www.npmjs.com/package/microbit-web-bluetooth) | ||
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://spdx.org/licenses/MIT.html) | ||
@@ -57,9 +58,2 @@ | ||
### IO Pin Service | ||
- [ ] Pin Data | ||
- [ ] Pin Data Changed Event | ||
- [ ] Pin AD Configuration | ||
- [ ] Pin IO Configuration | ||
- [ ] PWM Control | ||
### UART Service | ||
@@ -77,4 +71,11 @@ - [x] Send | ||
### IO Pin Service | ||
- [ ] Pin Data | ||
- [ ] Pin Data Changed Event | ||
- [ ] Pin AD Configuration | ||
- [ ] Pin IO Configuration | ||
- [ ] PWM Control | ||
### DFU Control Service | ||
- [ ] DFU Control | ||
- [ ] Partial Flashing |
@@ -11,3 +11,3 @@ import del from "rollup-plugin-delete"; | ||
const name = "microbit"; | ||
const pkg = require('./package.json') | ||
const pkg = require('./package.json'); | ||
const watch = process.env.ROLLUP_WATCH; | ||
@@ -14,0 +14,0 @@ |
@@ -49,2 +49,4 @@ /* | ||
listenerCount<K extends keyof T>(type: K): number; | ||
setMaxListeners(n: number): this; | ||
getMaxListeners(): number; | ||
} | ||
@@ -51,0 +53,0 @@ |
@@ -26,12 +26,12 @@ /* | ||
import { DeviceInformationUuid, DeviceInformationService } from "./services/device-information"; | ||
import { ButtonUuid, ButtonService } from "./services/button"; | ||
import { LedUuid, LedService } from "./services/led"; | ||
import { TemperatureUuid, TemperatureService } from "./services/temperature"; | ||
import { AccelerometerUuid, AccelerometerService } from "./services/accelerometer"; | ||
import { MagnetometerUuid, MagnetometerService } from "./services/magnetometer"; | ||
import { IoPinUuid } from "./services/io-pin"; | ||
import { UartUuid, UartService } from "./services/uart"; | ||
import { EventUuid, EventService } from "./services/event"; | ||
import { DfuUuid } from "./services/dfu-control"; | ||
import { DeviceInformationService } from "./services/device-information"; | ||
import { ButtonService } from "./services/button"; | ||
import { LedService } from "./services/led"; | ||
import { TemperatureService } from "./services/temperature"; | ||
import { AccelerometerService } from "./services/accelerometer"; | ||
import { MagnetometerService } from "./services/magnetometer"; | ||
import { IoPinService } from "./services/io-pin"; | ||
import { UartService } from "./services/uart"; | ||
import { EventService } from "./services/event"; | ||
import { DfuControlService } from "./services/dfu-control"; | ||
@@ -49,2 +49,23 @@ export interface Services { | ||
interface Service { | ||
uuid: BluetoothCharacteristicUUID; | ||
create(service: BluetoothRemoteGATTService): Promise<any>; | ||
} | ||
class ServiceBuilder { | ||
constructor(private services: BluetoothRemoteGATTService[]) { | ||
} | ||
public async createService<T>(serviceClass: (new (service: BluetoothRemoteGATTService) => T) & Service): Promise<T | undefined> { | ||
const found = this.services.find(service => service.uuid === serviceClass.uuid); | ||
if (!found) { | ||
return undefined; | ||
} | ||
return await serviceClass.create(found); | ||
} | ||
} | ||
export const requestMicrobit = async (bluetooth: Bluetooth): Promise<BluetoothDevice | undefined> => { | ||
@@ -58,12 +79,12 @@ const device = await bluetooth.requestDevice({ | ||
optionalServices: [ | ||
DeviceInformationUuid, | ||
ButtonUuid, | ||
LedUuid, | ||
TemperatureUuid, | ||
AccelerometerUuid, | ||
MagnetometerUuid, | ||
IoPinUuid, | ||
UartUuid, | ||
EventUuid, | ||
DfuUuid | ||
DeviceInformationService.uuid, | ||
ButtonService.uuid, | ||
LedService.uuid, | ||
TemperatureService.uuid, | ||
AccelerometerService.uuid, | ||
MagnetometerService.uuid, | ||
IoPinService.uuid, | ||
UartService.uuid, | ||
EventService.uuid, | ||
DfuControlService.uuid | ||
] | ||
@@ -85,11 +106,13 @@ }); | ||
const services = await device.gatt.getPrimaryServices(); | ||
const deviceInformationService = await DeviceInformationService.createService(services); | ||
const buttonService = await ButtonService.createService(services); | ||
const ledService = await LedService.createService(services); | ||
const temperatureService = await TemperatureService.createService(services); | ||
const accelerometerService = await AccelerometerService.createService(services); | ||
const magnetometerService = await MagnetometerService.createService(services); | ||
const uartService = await UartService.createService(services); | ||
const eventService = await EventService.createService(services); | ||
const builder = new ServiceBuilder(services); | ||
const deviceInformationService = await builder.createService(DeviceInformationService); | ||
const buttonService = await builder.createService(ButtonService); | ||
const ledService = await builder.createService(LedService); | ||
const temperatureService = await builder.createService(TemperatureService); | ||
const accelerometerService = await builder.createService(AccelerometerService); | ||
const magnetometerService = await builder.createService(MagnetometerService); | ||
const uartService = await builder.createService(UartService); | ||
const eventService = await builder.createService(EventService); | ||
return { | ||
@@ -96,0 +119,0 @@ deviceInformationService, |
@@ -27,2 +27,3 @@ /* | ||
import { EventDispatcher, TypedDispatcher } from "../event-dispatcher"; | ||
import { ServiceHelper } from "../service-helper"; | ||
@@ -32,7 +33,2 @@ /** | ||
*/ | ||
export const AccelerometerUuid = "e95d0753-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
export enum AccelerometerCharacteristic { | ||
@@ -59,26 +55,29 @@ accelerometerData = "e95dca4b-251d-470a-a062-fa1922dfa9a8", | ||
public static async createService(services: BluetoothRemoteGATTService[]): Promise<AccelerometerService | undefined> { | ||
const found = services.find(service => service.uuid === AccelerometerUuid); | ||
if (!found) { | ||
return undefined; | ||
} | ||
/** | ||
* @hidden | ||
*/ | ||
public static uuid = "e95d0753-251d-470a-a062-fa1922dfa9a8"; | ||
const accelerometerService = new AccelerometerService(found); | ||
await accelerometerService.init(); | ||
return accelerometerService; | ||
/** | ||
* @hidden | ||
*/ | ||
public static async create(service: BluetoothRemoteGATTService): Promise<AccelerometerService> { | ||
const bluetoothService = new AccelerometerService(service); | ||
await bluetoothService.init(); | ||
return bluetoothService; | ||
} | ||
constructor(private service: BluetoothRemoteGATTService) { | ||
private helper: ServiceHelper; | ||
constructor(service: BluetoothRemoteGATTService) { | ||
super(); | ||
this.helper = new ServiceHelper(service, this); | ||
} | ||
private async init() { | ||
await this.startNotifications(AccelerometerCharacteristic.accelerometerData); | ||
this.on("newListener", this.onNewListener.bind(this)); | ||
this.on("removeListener", this.onRemoveListener.bind(this)); | ||
await this.helper.handleListener("accelerometerdatachanged", AccelerometerCharacteristic.accelerometerData, this.accelerometerDataChangedHandler.bind(this)); | ||
} | ||
public async readAccelerometerData(): Promise<AccelerometerData> { | ||
const view = await this.getCharacteristValue(AccelerometerCharacteristic.accelerometerData); | ||
const view = await this.helper.getCharacteristicValue(AccelerometerCharacteristic.accelerometerData); | ||
return this.dataViewToAccelerometerData(view); | ||
@@ -88,3 +87,3 @@ } | ||
public async getAccelerometerPeriod(): Promise<AccelerometerPeriod> { | ||
const value = await this.getCharacteristValue(AccelerometerCharacteristic.accelerometerPeriod); | ||
const value = await this.helper.getCharacteristicValue(AccelerometerCharacteristic.accelerometerPeriod); | ||
return value.getUint16(0, true) as AccelerometerPeriod; | ||
@@ -94,44 +93,7 @@ } | ||
public async setAccelerometerPeriod(frequency: AccelerometerPeriod): Promise<void> { | ||
const char = await this.service.getCharacteristic(AccelerometerCharacteristic.accelerometerPeriod); | ||
const view = new DataView(new ArrayBuffer(2)); | ||
view.setUint16(0, frequency, true); | ||
return char.writeValue(view); | ||
return this.helper.setCharacteristicValue(AccelerometerCharacteristic.accelerometerPeriod, view); | ||
} | ||
private async getCharacteristValue(characteristic: BluetoothCharacteristicUUID): Promise<DataView> { | ||
const char = await this.service.getCharacteristic(characteristic); | ||
return await char.readValue(); | ||
} | ||
private async startNotifications(characteristic: BluetoothCharacteristicUUID) { | ||
const char = await this.service.getCharacteristic(characteristic); | ||
await char.startNotifications(); | ||
} | ||
private async onNewListener(event: keyof AccelerometerEvents): Promise<void> { | ||
const listenerCount = this.listenerCount(event); | ||
if (listenerCount > 0) { | ||
return; | ||
} | ||
if (event === "accelerometerdatachanged") { | ||
const char = await this.service.getCharacteristic(AccelerometerCharacteristic.accelerometerData); | ||
char.addEventListener("characteristicvaluechanged", this.accelerometerDataChangedHandler.bind(this)); | ||
} | ||
} | ||
private async onRemoveListener(event: keyof AccelerometerEvents) { | ||
const listenerCount = this.listenerCount(event); | ||
if (listenerCount > 0) { | ||
return; | ||
} | ||
if (event === "accelerometerdatachanged") { | ||
const char = await this.service.getCharacteristic(AccelerometerCharacteristic.accelerometerData); | ||
char.removeEventListener("characteristicvaluechanged", this.accelerometerDataChangedHandler.bind(this)); | ||
} | ||
} | ||
private accelerometerDataChangedHandler(event: Event) { | ||
@@ -138,0 +100,0 @@ const view = (event.target as BluetoothRemoteGATTCharacteristic).value!; |
@@ -27,2 +27,3 @@ /* | ||
import { EventDispatcher, TypedDispatcher } from "../event-dispatcher"; | ||
import { ServiceHelper } from "../service-helper"; | ||
@@ -32,7 +33,2 @@ /** | ||
*/ | ||
export const ButtonUuid = "e95d9882-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
export enum ButtonCharacteristic { | ||
@@ -58,27 +54,30 @@ buttonAState = "e95dda90-251d-470a-a062-fa1922dfa9a8", | ||
public static async createService(services: BluetoothRemoteGATTService[]): Promise<ButtonService | undefined> { | ||
const found = services.find(service => service.uuid === ButtonUuid); | ||
if (!found) { | ||
return undefined; | ||
} | ||
/** | ||
* @hidden | ||
*/ | ||
public static uuid = "e95d9882-251d-470a-a062-fa1922dfa9a8"; | ||
const buttonService = new ButtonService(found); | ||
await buttonService.init(); | ||
return buttonService; | ||
/** | ||
* @hidden | ||
*/ | ||
public static async create(service: BluetoothRemoteGATTService): Promise<ButtonService> { | ||
const bluetoothService = new ButtonService(service); | ||
await bluetoothService.init(); | ||
return bluetoothService; | ||
} | ||
constructor(private service: BluetoothRemoteGATTService) { | ||
private helper: ServiceHelper; | ||
constructor(service: BluetoothRemoteGATTService) { | ||
super(); | ||
this.helper = new ServiceHelper(service, this); | ||
} | ||
private async init() { | ||
await this.startNotifications(ButtonCharacteristic.buttonAState); | ||
await this.startNotifications(ButtonCharacteristic.buttonBState); | ||
this.on("newListener", this.onNewListener.bind(this)); | ||
this.on("removeListener", this.onRemoveListener.bind(this)); | ||
await this.helper.handleListener("buttonastatechanged", ButtonCharacteristic.buttonAState, this.buttonAStateChangedHandler.bind(this)); | ||
await this.helper.handleListener("buttonbstatechanged", ButtonCharacteristic.buttonBState, this.buttonBStateChangedHandler.bind(this)); | ||
} | ||
public async readButtonAState(): Promise<ButtonState> { | ||
const value = await this.getCharacteristValue(ButtonCharacteristic.buttonAState); | ||
const value = await this.helper.getCharacteristicValue(ButtonCharacteristic.buttonAState); | ||
return value.getUint8(0); | ||
@@ -88,57 +87,6 @@ } | ||
public async readButtonBState(): Promise<ButtonState> { | ||
const value = await this.getCharacteristValue(ButtonCharacteristic.buttonBState); | ||
const value = await this.helper.getCharacteristicValue(ButtonCharacteristic.buttonBState); | ||
return value.getUint8(0); | ||
} | ||
private async getCharacteristValue(characteristic: BluetoothCharacteristicUUID): Promise<DataView> { | ||
const service = await this.service; | ||
const char = await service.getCharacteristic(characteristic); | ||
return await char.readValue(); | ||
} | ||
private async startNotifications(characteristic: BluetoothCharacteristicUUID) { | ||
const char = await this.service.getCharacteristic(characteristic); | ||
await char.startNotifications(); | ||
} | ||
private async onNewListener(event: keyof ButtonEvents): Promise<void> { | ||
const listenerCount = this.listenerCount(event); | ||
if (listenerCount > 0) { | ||
return; | ||
} | ||
if (event === "buttonastatechanged") { | ||
const char = await this.service.getCharacteristic(ButtonCharacteristic.buttonAState); | ||
char.addEventListener("characteristicvaluechanged", this.buttonAStateChangedHandler.bind(this)); | ||
} | ||
if (event === "buttonbstatechanged") { | ||
const char = await this.service.getCharacteristic(ButtonCharacteristic.buttonBState); | ||
char.addEventListener("characteristicvaluechanged", this.buttonBStateChangedHandler.bind(this)); | ||
} | ||
} | ||
private async onRemoveListener(event: keyof ButtonEvents) { | ||
const listenerCount = this.listenerCount(event); | ||
if (listenerCount > 0) { | ||
return; | ||
} | ||
if (event === "buttonastatechanged") { | ||
const service = await this.service; | ||
const char = await service.getCharacteristic(ButtonCharacteristic.buttonAState); | ||
char.removeEventListener("characteristicvaluechanged", this.buttonAStateChangedHandler.bind(this)); | ||
await char.stopNotifications(); | ||
} | ||
if (event === "buttonbstatechanged") { | ||
const service = await this.service; | ||
const char = await service.getCharacteristic(ButtonCharacteristic.buttonBState); | ||
char.removeEventListener("characteristicvaluechanged", this.buttonBStateChangedHandler.bind(this)); | ||
await char.stopNotifications(); | ||
} | ||
} | ||
private buttonAStateChangedHandler(event: Event) { | ||
@@ -145,0 +93,0 @@ const view = (event.target as BluetoothRemoteGATTCharacteristic).value!; |
@@ -26,6 +26,3 @@ /* | ||
/** | ||
* @hidden | ||
*/ | ||
export const DeviceInformationUuid = "0000180a-0000-1000-8000-00805f9b34fb"; | ||
import { ServiceHelper } from "../service-helper"; | ||
@@ -53,36 +50,50 @@ /** | ||
public static createService(services: BluetoothRemoteGATTService[]): DeviceInformationService | undefined { | ||
const found = services.find(service => service.uuid === DeviceInformationUuid); | ||
if (found) { | ||
return new DeviceInformationService(found); | ||
} | ||
return undefined; | ||
/** | ||
* @hidden | ||
*/ | ||
public static uuid = "0000180a-0000-1000-8000-00805f9b34fb"; | ||
/** | ||
* @hidden | ||
*/ | ||
public static async create(service: BluetoothRemoteGATTService): Promise<DeviceInformationService> { | ||
return new DeviceInformationService(service); | ||
} | ||
constructor(private service: BluetoothRemoteGATTService) { | ||
private helper: ServiceHelper; | ||
constructor(service: BluetoothRemoteGATTService) { | ||
this.helper = new ServiceHelper(service); | ||
} | ||
public async readDeviceInformation(): Promise<DeviceInformation> { | ||
const characteristics = await this.service.getCharacteristics(); | ||
const info: DeviceInformation = {}; | ||
const modelNumberChar = characteristics.find(char => char.uuid === DeviceInformationCharacteristic.modelNumber); | ||
if (modelNumberChar) info.modelNumber = await this.readStringCharacteristic(modelNumberChar); | ||
const serialNumberChar = characteristics.find(char => char.uuid === DeviceInformationCharacteristic.serialNumber); | ||
if (serialNumberChar) info.serialNumber = await this.readStringCharacteristic(serialNumberChar); | ||
const firmwareRevisionChar = characteristics.find(char => char.uuid === DeviceInformationCharacteristic.firmwareRevision); | ||
if (firmwareRevisionChar) info.firmwareRevision = await this.readStringCharacteristic(firmwareRevisionChar); | ||
const hardwareRevisionChar = characteristics.find(char => char.uuid === DeviceInformationCharacteristic.hardwareRevision); | ||
if (hardwareRevisionChar) info.hardwareRevision = await this.readStringCharacteristic(hardwareRevisionChar); | ||
const manufacturerChar = characteristics.find(char => char.uuid === DeviceInformationCharacteristic.manufacturer); | ||
if (manufacturerChar) info.manufacturer = await this.readStringCharacteristic(manufacturerChar); | ||
const modelNumber = await this.readStringCharacteristic(DeviceInformationCharacteristic.modelNumber); | ||
if (modelNumber) info.modelNumber = modelNumber; | ||
const serialNumber = await this.readStringCharacteristic(DeviceInformationCharacteristic.serialNumber); | ||
if (serialNumber) info.serialNumber = serialNumber; | ||
const firmwareRevision = await this.readStringCharacteristic(DeviceInformationCharacteristic.firmwareRevision); | ||
if (firmwareRevision) info.firmwareRevision = firmwareRevision; | ||
const hardwareRevision = await this.readStringCharacteristic(DeviceInformationCharacteristic.hardwareRevision); | ||
if (hardwareRevision) info.hardwareRevision = hardwareRevision; | ||
const manufacturer = await this.readStringCharacteristic(DeviceInformationCharacteristic.manufacturer); | ||
if (manufacturer) info.manufacturer = manufacturer; | ||
return info; | ||
} | ||
private async readStringCharacteristic(characteristic: BluetoothRemoteGATTCharacteristic): Promise<string> { | ||
const view = await characteristic.readValue(); | ||
const buffer = view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength); | ||
return String.fromCharCode.apply(null, Array.from(new Uint8Array(buffer))); | ||
private async readStringCharacteristic(uuid: BluetoothCharacteristicUUID): Promise<string | undefined> { | ||
try { | ||
const view = await this.helper.getCharacteristicValue(uuid); | ||
const buffer = view.buffer.slice(view.byteOffset, view.byteOffset + view.byteLength); | ||
return String.fromCharCode.apply(null, Array.from(new Uint8Array(buffer))); | ||
} catch (_e) { | ||
return undefined; | ||
} | ||
} | ||
} |
@@ -26,6 +26,3 @@ /* | ||
/** | ||
* @hidden | ||
*/ | ||
export const DfuUuid = "e95d93b0-251d-470a-a062-fa1922dfa9a8"; | ||
import { ServiceHelper } from "../service-helper"; | ||
@@ -38,1 +35,22 @@ /** | ||
} | ||
export class DfuControlService { | ||
/** | ||
* @hidden | ||
*/ | ||
public static uuid = "e95d93b0-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
public static async create(service: BluetoothRemoteGATTService): Promise<DfuControlService> { | ||
return new DfuControlService(service); | ||
} | ||
public helper: ServiceHelper; | ||
constructor(service: BluetoothRemoteGATTService) { | ||
this.helper = new ServiceHelper(service); | ||
} | ||
} |
@@ -27,2 +27,3 @@ /* | ||
import { EventDispatcher, TypedDispatcher } from "../event-dispatcher"; | ||
import { ServiceHelper } from "../service-helper"; | ||
@@ -32,7 +33,2 @@ /** | ||
*/ | ||
export const EventUuid = "e95d93af-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
export enum EventCharacteristic { | ||
@@ -59,27 +55,30 @@ microBitRequirements = "e95db84c-251d-470a-a062-fa1922dfa9a8", | ||
public static async createService(services: BluetoothRemoteGATTService[]): Promise<EventService | undefined> { | ||
const found = services.find(service => service.uuid === EventUuid); | ||
if (!found) { | ||
return undefined; | ||
} | ||
/** | ||
* @hidden | ||
*/ | ||
public static uuid = "e95d93af-251d-470a-a062-fa1922dfa9a8"; | ||
const eventService = new EventService(found); | ||
await eventService.init(); | ||
return eventService; | ||
/** | ||
* @hidden | ||
*/ | ||
public static async create(service: BluetoothRemoteGATTService): Promise<EventService> { | ||
const bluetoothService = new EventService(service); | ||
await bluetoothService.init(); | ||
return bluetoothService; | ||
} | ||
constructor(private service: BluetoothRemoteGATTService) { | ||
private helper: ServiceHelper; | ||
constructor(service: BluetoothRemoteGATTService) { | ||
super(); | ||
this.helper = new ServiceHelper(service, this); | ||
} | ||
private async init() { | ||
await this.startNotifications(EventCharacteristic.microBitEvent); | ||
await this.startNotifications(EventCharacteristic.microBitRequirements); | ||
this.on("newListener", this.onNewListener.bind(this)); | ||
this.on("removeListener", this.onRemoveListener.bind(this)); | ||
await this.helper.handleListener("microbitevent", EventCharacteristic.microBitEvent, this.eventHandler.bind(this)); | ||
await this.helper.handleListener("microbitrequirementschanged", EventCharacteristic.microBitRequirements, this.microbitRequirementsChangedHandler.bind(this)); | ||
} | ||
public async getMicrobitRequirements(): Promise<MicrobitEvent> { | ||
const value = await this.getCharacteristValue(EventCharacteristic.microBitRequirements); | ||
const value = await this.helper.getCharacteristicValue(EventCharacteristic.microBitRequirements); | ||
return this.viewToMicrobitEvent(value); | ||
@@ -89,11 +88,10 @@ } | ||
public async setClientRequirements(type: number, value: number): Promise<void> { | ||
const char = await this.service.getCharacteristic(EventCharacteristic.clientRequirements); | ||
const view = new DataView(new ArrayBuffer(4)); | ||
view.setUint16(0, type, true); | ||
view.setUint16(1, value, true); | ||
return char.writeValue(view); | ||
return await this.helper.setCharacteristicValue(EventCharacteristic.clientRequirements, view); | ||
} | ||
public async readMicrobitEvent(): Promise<MicrobitEvent> { | ||
const value = await this.getCharacteristValue(EventCharacteristic.microBitEvent); | ||
const value = await this.helper.getCharacteristicValue(EventCharacteristic.microBitEvent); | ||
return this.viewToMicrobitEvent(value); | ||
@@ -103,55 +101,8 @@ } | ||
public async writeClientEvent(type: number, value: number): Promise<void> { | ||
const char = await this.service.getCharacteristic(EventCharacteristic.clientEvent); | ||
const view = new DataView(new ArrayBuffer(4)); | ||
view.setUint16(0, type, true); | ||
view.setUint16(1, value, true); | ||
return char.writeValue(view); | ||
return await this.helper.setCharacteristicValue(EventCharacteristic.clientEvent, view); | ||
} | ||
private async getCharacteristValue(characteristic: BluetoothCharacteristicUUID): Promise<DataView> { | ||
const char = await this.service.getCharacteristic(characteristic); | ||
return await char.readValue(); | ||
} | ||
private async startNotifications(characteristic: BluetoothCharacteristicUUID) { | ||
const char = await this.service.getCharacteristic(characteristic); | ||
await char.startNotifications(); | ||
} | ||
private async onNewListener(event: keyof MicrobitEvents): Promise<void> { | ||
const listenerCount = this.listenerCount(event); | ||
if (listenerCount > 0) { | ||
return; | ||
} | ||
if (event === "microbitevent") { | ||
const char = await this.service.getCharacteristic(EventCharacteristic.microBitEvent); | ||
char.addEventListener("characteristicvaluechanged", this.eventHandler.bind(this)); | ||
} | ||
if (event === "microbitrequirementschanged") { | ||
const char = await this.service.getCharacteristic(EventCharacteristic.microBitRequirements); | ||
char.addEventListener("characteristicvaluechanged", this.microbitRequirementsChangedHandler.bind(this)); | ||
} | ||
} | ||
private async onRemoveListener(event: keyof MicrobitEvents) { | ||
const listenerCount = this.listenerCount(event); | ||
if (listenerCount > 0) { | ||
return; | ||
} | ||
if (event === "microbitevent") { | ||
const char = await this.service.getCharacteristic(EventCharacteristic.microBitEvent); | ||
char.removeEventListener("characteristicvaluechanged", this.eventHandler.bind(this)); | ||
} | ||
if (event === "microbitrequirementschanged") { | ||
const char = await this.service.getCharacteristic(EventCharacteristic.microBitRequirements); | ||
char.removeEventListener("characteristicvaluechanged", this.microbitRequirementsChangedHandler.bind(this)); | ||
} | ||
} | ||
private microbitRequirementsChangedHandler(event: Event) { | ||
@@ -158,0 +109,0 @@ const view = (event.target as BluetoothRemoteGATTCharacteristic).value!; |
@@ -26,6 +26,3 @@ /* | ||
/** | ||
* @hidden | ||
*/ | ||
export const IoPinUuid = "e95d127b-251d-470a-a062-fa1922dfa9a8"; | ||
import { ServiceHelper } from "../service-helper"; | ||
@@ -41,1 +38,22 @@ /** | ||
} | ||
export class IoPinService { | ||
/** | ||
* @hidden | ||
*/ | ||
public static uuid = "e95d127b-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
public static async create(service: BluetoothRemoteGATTService): Promise<IoPinService> { | ||
return new IoPinService(service); | ||
} | ||
public helper: ServiceHelper; | ||
constructor(service: BluetoothRemoteGATTService) { | ||
this.helper = new ServiceHelper(service); | ||
} | ||
} |
@@ -26,6 +26,3 @@ /* | ||
/** | ||
* @hidden | ||
*/ | ||
export const LedUuid = "e95dd91d-251d-470a-a062-fa1922dfa9a8"; | ||
import { ServiceHelper } from "../service-helper"; | ||
@@ -51,21 +48,27 @@ /** | ||
public static createService(services: BluetoothRemoteGATTService[]): LedService | undefined { | ||
const found = services.find(service => service.uuid === LedUuid); | ||
if (found) { | ||
return new LedService(found); | ||
} | ||
return undefined; | ||
/** | ||
* @hidden | ||
*/ | ||
public static uuid = "e95dd91d-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
public static async create(service: BluetoothRemoteGATTService): Promise<LedService> { | ||
return new LedService(service); | ||
} | ||
constructor(private service: BluetoothRemoteGATTService) { | ||
private helper: ServiceHelper; | ||
constructor(service: BluetoothRemoteGATTService) { | ||
this.helper = new ServiceHelper(service); | ||
} | ||
public async writeText(text: string): Promise<void> { | ||
const characteristic = await this.service.getCharacteristic(LedCharacteristic.ledText); | ||
const encoded = this.encodeString(text); | ||
return characteristic.writeValue(encoded); | ||
return this.helper.setCharacteristicValue(LedCharacteristic.ledText, encoded); | ||
} | ||
public async getMatrixState(): Promise<LedMatrix> { | ||
const view = await this.getCharacteristValue(LedCharacteristic.ledMatrixState); | ||
const view = await this.helper.getCharacteristicValue(LedCharacteristic.ledMatrixState); | ||
return this.viewToLedMatrix(view); | ||
@@ -75,9 +78,8 @@ } | ||
public async setMatrixState(state: LedMatrix): Promise<void> { | ||
const characteristic = await this.service.getCharacteristic(LedCharacteristic.ledMatrixState); | ||
const view = this.ledMatrixToView(state); | ||
return characteristic.writeValue(view); | ||
return this.helper.setCharacteristicValue(LedCharacteristic.ledMatrixState, view); | ||
} | ||
public async getScrollingDelay(): Promise<number> { | ||
const value = await this.getCharacteristValue(LedCharacteristic.scrollingDelay); | ||
const value = await this.helper.getCharacteristicValue(LedCharacteristic.scrollingDelay); | ||
return value.getUint16(0, true); | ||
@@ -87,13 +89,7 @@ } | ||
public async setScrollingDelay(delay: number): Promise<void> { | ||
const char = await this.service.getCharacteristic(LedCharacteristic.scrollingDelay); | ||
const view = new DataView(new ArrayBuffer(2)); | ||
view.setUint16(0, delay, true); | ||
return char.writeValue(view); | ||
return this.helper.setCharacteristicValue(LedCharacteristic.scrollingDelay, view); | ||
} | ||
private async getCharacteristValue(characteristic: BluetoothCharacteristicUUID): Promise<DataView> { | ||
const char = await this.service.getCharacteristic(characteristic); | ||
return await char.readValue(); | ||
} | ||
private encodeString(text: string): ArrayBuffer { | ||
@@ -100,0 +96,0 @@ const buffer = new ArrayBuffer(text.length); |
@@ -27,2 +27,3 @@ /* | ||
import { EventDispatcher, TypedDispatcher } from "../event-dispatcher"; | ||
import { ServiceHelper } from "../service-helper"; | ||
@@ -32,7 +33,2 @@ /** | ||
*/ | ||
export const MagnetometerUuid = "e95df2d8-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
export enum MagnetometerCharacteristic { | ||
@@ -70,37 +66,35 @@ magnetometerData = "e95dfb11-251d-470a-a062-fa1922dfa9a8", | ||
public static async createService(services: BluetoothRemoteGATTService[]): Promise<MagnetometerService | undefined> { | ||
const found = services.find(service => service.uuid === MagnetometerUuid); | ||
if (!found) { | ||
return undefined; | ||
} | ||
/** | ||
* @hidden | ||
*/ | ||
public static uuid = "e95df2d8-251d-470a-a062-fa1922dfa9a8"; | ||
const magnetometerService = new MagnetometerService(found); | ||
await magnetometerService.init(); | ||
return magnetometerService; | ||
/** | ||
* @hidden | ||
*/ | ||
public static async create(service: BluetoothRemoteGATTService): Promise<MagnetometerService> { | ||
const bluetoothService = new MagnetometerService(service); | ||
await bluetoothService.init(); | ||
return bluetoothService; | ||
} | ||
constructor(private service: BluetoothRemoteGATTService) { | ||
private helper: ServiceHelper; | ||
constructor(service: BluetoothRemoteGATTService) { | ||
super(); | ||
this.helper = new ServiceHelper(service, this); | ||
} | ||
private async init() { | ||
await this.startNotifications(MagnetometerCharacteristic.magnetometerData); | ||
await this.startNotifications(MagnetometerCharacteristic.magnetometerBearing); | ||
await this.startNotifications(MagnetometerCharacteristic.magnetometerCalibration); | ||
this.on("newListener", this.onNewListener.bind(this)); | ||
this.on("removeListener", this.onRemoveListener.bind(this)); | ||
await this.helper.handleListener("magnetometerdatachanged", MagnetometerCharacteristic.magnetometerData, this.magnetometerDataChangedHandler.bind(this)); | ||
await this.helper.handleListener("magnetometerbearingchanged", MagnetometerCharacteristic.magnetometerBearing, this.magnetometerBearingChangedHandler.bind(this)); | ||
await this.helper.handleListener("magnetometercalibrationchanged", MagnetometerCharacteristic.magnetometerCalibration, this.magnetometerCalibrationChangedHandler.bind(this)); | ||
} | ||
public async calibrate() { | ||
const char = await this.getCharacteristic(MagnetometerCharacteristic.magnetometerCalibration); | ||
if (!char) { | ||
throw new Error("Unable to locate calibration characteristic"); | ||
} | ||
return char.writeValue(new Uint8Array([1])); | ||
return this.helper.setCharacteristicValue(MagnetometerCharacteristic.magnetometerCalibration, new Uint8Array([1])); | ||
} | ||
public async readMagnetometerData(): Promise<MagnetometerData> { | ||
const view = await this.getCharacteristValue(MagnetometerCharacteristic.magnetometerData); | ||
const view = await this.helper.getCharacteristicValue(MagnetometerCharacteristic.magnetometerData); | ||
return this.dataViewToMagnetometerData(view); | ||
@@ -110,3 +104,3 @@ } | ||
public async getMagnetometerBearing(): Promise<number | undefined> { | ||
const view = await this.getCharacteristValue(MagnetometerCharacteristic.magnetometerBearing); | ||
const view = await this.helper.getCharacteristicValue(MagnetometerCharacteristic.magnetometerBearing); | ||
if (view.byteLength === 2) { | ||
@@ -119,3 +113,3 @@ return view.getUint16(0, true); | ||
public async getMagnetometerPeriod(): Promise<MagnetometerPeriod> { | ||
const value = await this.getCharacteristValue(MagnetometerCharacteristic.magnetometerPeriod); | ||
const value = await this.helper.getCharacteristicValue(MagnetometerCharacteristic.magnetometerPeriod); | ||
return value.getUint16(0, true) as MagnetometerPeriod; | ||
@@ -125,94 +119,7 @@ } | ||
public async setMagnetometerPeriod(frequency: MagnetometerPeriod): Promise<void> { | ||
const char = await this.getCharacteristic(MagnetometerCharacteristic.magnetometerPeriod); | ||
if (!char) { | ||
throw new Error("Unable to locate period characteristic"); | ||
} | ||
const view = new DataView(new ArrayBuffer(2)); | ||
view.setUint16(0, frequency, true); | ||
return char.writeValue(view); | ||
return this.helper.setCharacteristicValue(MagnetometerCharacteristic.magnetometerPeriod, view); | ||
} | ||
private async getCharacteristic(characteristic: BluetoothCharacteristicUUID): Promise<BluetoothRemoteGATTCharacteristic | undefined> { | ||
try { | ||
return await this.service.getCharacteristic(characteristic); | ||
} catch (e) { | ||
return undefined; | ||
} | ||
} | ||
private async getCharacteristValue(characteristic: BluetoothCharacteristicUUID): Promise<DataView> { | ||
const char = await this.getCharacteristic(characteristic); | ||
if (!char) { | ||
throw new Error("Unable to locate characteristic"); | ||
} | ||
return await char.readValue(); | ||
} | ||
private async startNotifications(characteristic: BluetoothCharacteristicUUID) { | ||
const char = await this.getCharacteristic(characteristic); | ||
if (char) { | ||
await char.startNotifications(); | ||
} | ||
} | ||
private async onNewListener(event: keyof MagnetometerEvents): Promise<void> { | ||
const listenerCount = this.listenerCount(event); | ||
if (listenerCount > 0) { | ||
return; | ||
} | ||
if (event === "magnetometerdatachanged") { | ||
const char = await this.getCharacteristic(MagnetometerCharacteristic.magnetometerData); | ||
if (char) { | ||
char.addEventListener("characteristicvaluechanged", this.magnetometerDataChangedHandler.bind(this)); | ||
} | ||
} | ||
if (event === "magnetometerbearingchanged") { | ||
const char = await this.getCharacteristic(MagnetometerCharacteristic.magnetometerBearing); | ||
if (char) { | ||
char.addEventListener("characteristicvaluechanged", this.magnetometerBearingChangedHandler.bind(this)); | ||
} | ||
} | ||
if (event === "magnetometercalibrationchanged") { | ||
const char = await this.getCharacteristic(MagnetometerCharacteristic.magnetometerCalibration); | ||
if (char) { | ||
char.addEventListener("characteristicvaluechanged", this.magnetometerCalibrationChangedHandler.bind(this)); | ||
} | ||
} | ||
} | ||
private async onRemoveListener(event: keyof MagnetometerEvents) { | ||
const listenerCount = this.listenerCount(event); | ||
if (listenerCount > 0) { | ||
return; | ||
} | ||
if (event === "magnetometerdatachanged") { | ||
const char = await this.getCharacteristic(MagnetometerCharacteristic.magnetometerData); | ||
if (char) { | ||
char.removeEventListener("characteristicvaluechanged", this.magnetometerDataChangedHandler.bind(this)); | ||
} | ||
} | ||
if (event === "magnetometerbearingchanged") { | ||
const char = await this.getCharacteristic(MagnetometerCharacteristic.magnetometerBearing); | ||
if (char) { | ||
char.removeEventListener("characteristicvaluechanged", this.magnetometerBearingChangedHandler.bind(this)); | ||
} | ||
} | ||
if (event === "magnetometercalibrationchanged") { | ||
const char = await this.getCharacteristic(MagnetometerCharacteristic.magnetometerCalibration); | ||
if (char) { | ||
char.removeEventListener("characteristicvaluechanged", this.magnetometerCalibrationChangedHandler.bind(this)); | ||
} | ||
} | ||
} | ||
private magnetometerDataChangedHandler(event: Event) { | ||
@@ -219,0 +126,0 @@ const view = (event.target as BluetoothRemoteGATTCharacteristic).value!; |
@@ -27,2 +27,3 @@ /* | ||
import { TypedDispatcher, EventDispatcher } from "../event-dispatcher"; | ||
import { ServiceHelper } from "../service-helper"; | ||
@@ -32,7 +33,2 @@ /** | ||
*/ | ||
export const TemperatureUuid = "e95d6100-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
export enum TemperatureCharacteristic { | ||
@@ -51,26 +47,29 @@ temperature = "e95d9250-251d-470a-a062-fa1922dfa9a8", | ||
public static async createService(services: BluetoothRemoteGATTService[]): Promise<TemperatureService | undefined> { | ||
const found = services.find(service => service.uuid === TemperatureUuid); | ||
if (!found) { | ||
return undefined; | ||
} | ||
/** | ||
* @hidden | ||
*/ | ||
public static uuid = "e95d6100-251d-470a-a062-fa1922dfa9a8"; | ||
const temperatureService = new TemperatureService(found); | ||
await temperatureService.init(); | ||
return temperatureService; | ||
/** | ||
* @hidden | ||
*/ | ||
public static async create(service: BluetoothRemoteGATTService): Promise<TemperatureService> { | ||
const bluetoothService = new TemperatureService(service); | ||
await bluetoothService.init(); | ||
return bluetoothService; | ||
} | ||
constructor(private service: BluetoothRemoteGATTService) { | ||
private helper: ServiceHelper; | ||
constructor(service: BluetoothRemoteGATTService) { | ||
super(); | ||
this.helper = new ServiceHelper(service, this); | ||
} | ||
private async init() { | ||
await this.startNotifications(TemperatureCharacteristic.temperature); | ||
this.on("newListener", this.onNewListener.bind(this)); | ||
this.on("removeListener", this.onRemoveListener.bind(this)); | ||
await this.helper.handleListener("temperaturechanged", TemperatureCharacteristic.temperature, this.temperatureChangedHandler.bind(this)); | ||
} | ||
public async readTemperature(): Promise<number> { | ||
const value = await this.getCharacteristValue(TemperatureCharacteristic.temperature); | ||
const value = await this.helper.getCharacteristicValue(TemperatureCharacteristic.temperature); | ||
return value.getInt8(0); | ||
@@ -80,3 +79,3 @@ } | ||
public async getTemperaturePeriod(): Promise<number> { | ||
const value = await this.getCharacteristValue(TemperatureCharacteristic.temperaturePeriod); | ||
const value = await this.helper.getCharacteristicValue(TemperatureCharacteristic.temperaturePeriod); | ||
return value.getUint16(0, true); | ||
@@ -86,44 +85,7 @@ } | ||
public async setTemperaturePeriod(frequency: number): Promise<void> { | ||
const char = await this.service.getCharacteristic(TemperatureCharacteristic.temperaturePeriod); | ||
const view = new DataView(new ArrayBuffer(2)); | ||
view.setUint16(0, frequency, true); | ||
return char.writeValue(view); | ||
return await this.helper.setCharacteristicValue(TemperatureCharacteristic.temperaturePeriod, view); | ||
} | ||
private async getCharacteristValue(characteristic: BluetoothCharacteristicUUID): Promise<DataView> { | ||
const char = await this.service.getCharacteristic(characteristic); | ||
return await char.readValue(); | ||
} | ||
private async startNotifications(characteristic: BluetoothCharacteristicUUID) { | ||
const char = await this.service.getCharacteristic(characteristic); | ||
await char.startNotifications(); | ||
} | ||
private async onNewListener(event: keyof TemperatureEvents): Promise<void> { | ||
const listenerCount = this.listenerCount(event); | ||
if (listenerCount > 0) { | ||
return; | ||
} | ||
if (event === "temperaturechanged") { | ||
const char = await this.service.getCharacteristic(TemperatureCharacteristic.temperature); | ||
char.addEventListener("characteristicvaluechanged", this.temperatureChangedHandler.bind(this)); | ||
} | ||
} | ||
private async onRemoveListener(event: keyof TemperatureEvents) { | ||
const listenerCount = this.listenerCount(event); | ||
if (listenerCount > 0) { | ||
return; | ||
} | ||
if (event === "temperaturechanged") { | ||
const char = await this.service.getCharacteristic(TemperatureCharacteristic.temperature); | ||
char.removeEventListener("characteristicvaluechanged", this.temperatureChangedHandler.bind(this)); | ||
} | ||
} | ||
private temperatureChangedHandler(event: Event) { | ||
@@ -130,0 +92,0 @@ const view = (event.target as BluetoothRemoteGATTCharacteristic).value!; |
@@ -27,2 +27,3 @@ /* | ||
import { EventDispatcher, TypedDispatcher } from "../event-dispatcher"; | ||
import { ServiceHelper } from "../service-helper"; | ||
@@ -32,7 +33,2 @@ /** | ||
*/ | ||
export const UartUuid = "6e400001-b5a3-f393-e0a9-e50e24dcca9e"; | ||
/** | ||
* @hidden | ||
*/ | ||
export enum UartCharacteristic { | ||
@@ -52,76 +48,37 @@ tx = "6e400002-b5a3-f393-e0a9-e50e24dcca9e", | ||
public static async createService(services: BluetoothRemoteGATTService[]): Promise<UartService | undefined> { | ||
const found = services.find(service => service.uuid === UartUuid); | ||
if (!found) { | ||
return undefined; | ||
} | ||
/** | ||
* @hidden | ||
*/ | ||
public static uuid = "6e400001-b5a3-f393-e0a9-e50e24dcca9e"; | ||
const uartService = new UartService(found); | ||
await uartService.init(); | ||
return uartService; | ||
/** | ||
* @hidden | ||
*/ | ||
public static async create(service: BluetoothRemoteGATTService): Promise<UartService> { | ||
const bluetoothService = new UartService(service); | ||
await bluetoothService.init(); | ||
return bluetoothService; | ||
} | ||
constructor(private service: BluetoothRemoteGATTService) { | ||
private helper: ServiceHelper; | ||
constructor(service: BluetoothRemoteGATTService) { | ||
super(); | ||
this.helper = new ServiceHelper(service, this); | ||
} | ||
private async init() { | ||
await this.startNotifications(UartCharacteristic.tx); | ||
this.on("newListener", this.onNewListener.bind(this)); | ||
this.on("removeListener", this.onRemoveListener.bind(this)); | ||
await this.helper.handleListener("receive", UartCharacteristic.tx, this.receiveHandler.bind(this)); | ||
await this.helper.handleListener("receiveString", UartCharacteristic.tx, this.receiveStringHandler.bind(this)); | ||
} | ||
public async send(value: BufferSource): Promise<void> { | ||
const char = await this.service.getCharacteristic(UartCharacteristic.rx); | ||
return char.writeValue(value); | ||
return this.helper.setCharacteristicValue(UartCharacteristic.rx, value); | ||
} | ||
public async sendString(value: string): Promise<void> { | ||
const char = await this.service.getCharacteristic(UartCharacteristic.rx); | ||
const arrayData = value.split("").map((e: string) => e.charCodeAt(0)); | ||
return char.writeValue(new Uint8Array(arrayData).buffer); | ||
return this.helper.setCharacteristicValue(UartCharacteristic.rx, new Uint8Array(arrayData).buffer); | ||
} | ||
private async startNotifications(characteristic: BluetoothCharacteristicUUID) { | ||
const char = await this.service.getCharacteristic(characteristic); | ||
await char.startNotifications(); | ||
} | ||
private async onNewListener(event: keyof UartEvents): Promise<void> { | ||
const listenerCount = this.listenerCount(event); | ||
if (listenerCount > 0) { | ||
return; | ||
} | ||
if (event === "receive") { | ||
const char = await this.service.getCharacteristic(UartCharacteristic.tx); | ||
char.addEventListener("characteristicvaluechanged", this.receiveHandler.bind(this)); | ||
} | ||
if (event === "receiveString") { | ||
const char = await this.service.getCharacteristic(UartCharacteristic.tx); | ||
char.addEventListener("characteristicvaluechanged", this.receiveStringHandler.bind(this)); | ||
} | ||
} | ||
private async onRemoveListener(event: keyof UartEvents) { | ||
const listenerCount = this.listenerCount(event); | ||
if (listenerCount > 0) { | ||
return; | ||
} | ||
if (event === "receive") { | ||
const char = await this.service.getCharacteristic(UartCharacteristic.tx); | ||
char.removeEventListener("characteristicvaluechanged", this.receiveHandler.bind(this)); | ||
} | ||
if (event === "receiveString") { | ||
const char = await this.service.getCharacteristic(UartCharacteristic.tx); | ||
char.removeEventListener("characteristicvaluechanged", this.receiveStringHandler.bind(this)); | ||
} | ||
} | ||
private receiveHandler(event: Event) { | ||
@@ -128,0 +85,0 @@ const view = (event.target as BluetoothRemoteGATTCharacteristic).value!; |
@@ -22,2 +22,4 @@ /// <reference types="node" /> | ||
listenerCount<K extends keyof T>(type: K): number; | ||
setMaxListeners(n: number): this; | ||
getMaxListeners(): number; | ||
} | ||
@@ -24,0 +26,0 @@ /** |
@@ -6,6 +6,2 @@ /// <reference types="web-bluetooth" /> | ||
*/ | ||
export declare const AccelerometerUuid = "e95d0753-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare enum AccelerometerCharacteristic { | ||
@@ -28,4 +24,11 @@ accelerometerData = "e95dca4b-251d-470a-a062-fa1922dfa9a8", | ||
export declare class AccelerometerService extends AccelerometerService_base { | ||
private service; | ||
static createService(services: BluetoothRemoteGATTService[]): Promise<AccelerometerService | undefined>; | ||
/** | ||
* @hidden | ||
*/ | ||
static uuid: string; | ||
/** | ||
* @hidden | ||
*/ | ||
static create(service: BluetoothRemoteGATTService): Promise<AccelerometerService>; | ||
private helper; | ||
constructor(service: BluetoothRemoteGATTService); | ||
@@ -36,6 +39,2 @@ private init; | ||
setAccelerometerPeriod(frequency: AccelerometerPeriod): Promise<void>; | ||
private getCharacteristValue; | ||
private startNotifications; | ||
private onNewListener; | ||
private onRemoveListener; | ||
private accelerometerDataChangedHandler; | ||
@@ -42,0 +41,0 @@ private dataViewToAccelerometerData; |
@@ -6,6 +6,2 @@ /// <reference types="web-bluetooth" /> | ||
*/ | ||
export declare const ButtonUuid = "e95d9882-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare enum ButtonCharacteristic { | ||
@@ -28,4 +24,11 @@ buttonAState = "e95dda90-251d-470a-a062-fa1922dfa9a8", | ||
export declare class ButtonService extends ButtonService_base { | ||
private service; | ||
static createService(services: BluetoothRemoteGATTService[]): Promise<ButtonService | undefined>; | ||
/** | ||
* @hidden | ||
*/ | ||
static uuid: string; | ||
/** | ||
* @hidden | ||
*/ | ||
static create(service: BluetoothRemoteGATTService): Promise<ButtonService>; | ||
private helper; | ||
constructor(service: BluetoothRemoteGATTService); | ||
@@ -35,6 +38,2 @@ private init; | ||
readButtonBState(): Promise<ButtonState>; | ||
private getCharacteristValue; | ||
private startNotifications; | ||
private onNewListener; | ||
private onRemoveListener; | ||
private buttonAStateChangedHandler; | ||
@@ -41,0 +40,0 @@ private buttonBStateChangedHandler; |
@@ -5,6 +5,2 @@ /// <reference types="web-bluetooth" /> | ||
*/ | ||
export declare const DeviceInformationUuid = "0000180a-0000-1000-8000-00805f9b34fb"; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare enum DeviceInformationCharacteristic { | ||
@@ -25,4 +21,11 @@ modelNumber = "00002a24-0000-1000-8000-00805f9b34fb", | ||
export declare class DeviceInformationService { | ||
private service; | ||
static createService(services: BluetoothRemoteGATTService[]): DeviceInformationService | undefined; | ||
/** | ||
* @hidden | ||
*/ | ||
static uuid: string; | ||
/** | ||
* @hidden | ||
*/ | ||
static create(service: BluetoothRemoteGATTService): Promise<DeviceInformationService>; | ||
private helper; | ||
constructor(service: BluetoothRemoteGATTService); | ||
@@ -29,0 +32,0 @@ readDeviceInformation(): Promise<DeviceInformation>; |
@@ -0,10 +1,20 @@ | ||
/// <reference types="web-bluetooth" /> | ||
import { ServiceHelper } from "../service-helper"; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare const DfuUuid = "e95d93b0-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare enum DfuCharacteristic { | ||
dfuControl = "e95d93b1-251d-470a-a062-fa1922dfa9a8" | ||
} | ||
export declare class DfuControlService { | ||
/** | ||
* @hidden | ||
*/ | ||
static uuid: string; | ||
/** | ||
* @hidden | ||
*/ | ||
static create(service: BluetoothRemoteGATTService): Promise<DfuControlService>; | ||
helper: ServiceHelper; | ||
constructor(service: BluetoothRemoteGATTService); | ||
} |
@@ -6,6 +6,2 @@ /// <reference types="web-bluetooth" /> | ||
*/ | ||
export declare const EventUuid = "e95d93af-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare enum EventCharacteristic { | ||
@@ -29,4 +25,11 @@ microBitRequirements = "e95db84c-251d-470a-a062-fa1922dfa9a8", | ||
export declare class EventService extends EventService_base { | ||
private service; | ||
static createService(services: BluetoothRemoteGATTService[]): Promise<EventService | undefined>; | ||
/** | ||
* @hidden | ||
*/ | ||
static uuid: string; | ||
/** | ||
* @hidden | ||
*/ | ||
static create(service: BluetoothRemoteGATTService): Promise<EventService>; | ||
private helper; | ||
constructor(service: BluetoothRemoteGATTService); | ||
@@ -38,6 +41,2 @@ private init; | ||
writeClientEvent(type: number, value: number): Promise<void>; | ||
private getCharacteristValue; | ||
private startNotifications; | ||
private onNewListener; | ||
private onRemoveListener; | ||
private microbitRequirementsChangedHandler; | ||
@@ -44,0 +43,0 @@ private eventHandler; |
@@ -0,8 +1,6 @@ | ||
/// <reference types="web-bluetooth" /> | ||
import { ServiceHelper } from "../service-helper"; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare const IoPinUuid = "e95d127b-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare enum IoPinCharacteristic { | ||
@@ -14,1 +12,13 @@ pinData = "e95d8d00-251d-470a-a062-fa1922dfa9a8", | ||
} | ||
export declare class IoPinService { | ||
/** | ||
* @hidden | ||
*/ | ||
static uuid: string; | ||
/** | ||
* @hidden | ||
*/ | ||
static create(service: BluetoothRemoteGATTService): Promise<IoPinService>; | ||
helper: ServiceHelper; | ||
constructor(service: BluetoothRemoteGATTService); | ||
} |
@@ -5,6 +5,2 @@ /// <reference types="web-bluetooth" /> | ||
*/ | ||
export declare const LedUuid = "e95dd91d-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare enum LedCharacteristic { | ||
@@ -17,4 +13,11 @@ ledMatrixState = "e95d7b77-251d-470a-a062-fa1922dfa9a8", | ||
export declare class LedService { | ||
private service; | ||
static createService(services: BluetoothRemoteGATTService[]): LedService | undefined; | ||
/** | ||
* @hidden | ||
*/ | ||
static uuid: string; | ||
/** | ||
* @hidden | ||
*/ | ||
static create(service: BluetoothRemoteGATTService): Promise<LedService>; | ||
private helper; | ||
constructor(service: BluetoothRemoteGATTService); | ||
@@ -26,3 +29,2 @@ writeText(text: string): Promise<void>; | ||
setScrollingDelay(delay: number): Promise<void>; | ||
private getCharacteristValue; | ||
private encodeString; | ||
@@ -29,0 +31,0 @@ private viewToLedMatrix; |
@@ -6,6 +6,2 @@ /// <reference types="web-bluetooth" /> | ||
*/ | ||
export declare const MagnetometerUuid = "e95df2d8-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare enum MagnetometerCharacteristic { | ||
@@ -38,4 +34,11 @@ magnetometerData = "e95dfb11-251d-470a-a062-fa1922dfa9a8", | ||
export declare class MagnetometerService extends MagnetometerService_base { | ||
private service; | ||
static createService(services: BluetoothRemoteGATTService[]): Promise<MagnetometerService | undefined>; | ||
/** | ||
* @hidden | ||
*/ | ||
static uuid: string; | ||
/** | ||
* @hidden | ||
*/ | ||
static create(service: BluetoothRemoteGATTService): Promise<MagnetometerService>; | ||
private helper; | ||
constructor(service: BluetoothRemoteGATTService); | ||
@@ -48,7 +51,2 @@ private init; | ||
setMagnetometerPeriod(frequency: MagnetometerPeriod): Promise<void>; | ||
private getCharacteristic; | ||
private getCharacteristValue; | ||
private startNotifications; | ||
private onNewListener; | ||
private onRemoveListener; | ||
private magnetometerDataChangedHandler; | ||
@@ -55,0 +53,0 @@ private magnetometerBearingChangedHandler; |
@@ -6,6 +6,2 @@ /// <reference types="web-bluetooth" /> | ||
*/ | ||
export declare const TemperatureUuid = "e95d6100-251d-470a-a062-fa1922dfa9a8"; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare enum TemperatureCharacteristic { | ||
@@ -22,4 +18,11 @@ temperature = "e95d9250-251d-470a-a062-fa1922dfa9a8", | ||
export declare class TemperatureService extends TemperatureService_base { | ||
private service; | ||
static createService(services: BluetoothRemoteGATTService[]): Promise<TemperatureService | undefined>; | ||
/** | ||
* @hidden | ||
*/ | ||
static uuid: string; | ||
/** | ||
* @hidden | ||
*/ | ||
static create(service: BluetoothRemoteGATTService): Promise<TemperatureService>; | ||
private helper; | ||
constructor(service: BluetoothRemoteGATTService); | ||
@@ -30,8 +33,4 @@ private init; | ||
setTemperaturePeriod(frequency: number): Promise<void>; | ||
private getCharacteristValue; | ||
private startNotifications; | ||
private onNewListener; | ||
private onRemoveListener; | ||
private temperatureChangedHandler; | ||
} | ||
export {}; |
@@ -6,6 +6,2 @@ /// <reference types="web-bluetooth" /> | ||
*/ | ||
export declare const UartUuid = "6e400001-b5a3-f393-e0a9-e50e24dcca9e"; | ||
/** | ||
* @hidden | ||
*/ | ||
export declare enum UartCharacteristic { | ||
@@ -23,4 +19,11 @@ tx = "6e400002-b5a3-f393-e0a9-e50e24dcca9e", | ||
export declare class UartService extends UartService_base { | ||
private service; | ||
static createService(services: BluetoothRemoteGATTService[]): Promise<UartService | undefined>; | ||
/** | ||
* @hidden | ||
*/ | ||
static uuid: string; | ||
/** | ||
* @hidden | ||
*/ | ||
static create(service: BluetoothRemoteGATTService): Promise<UartService>; | ||
private helper; | ||
constructor(service: BluetoothRemoteGATTService); | ||
@@ -30,5 +33,2 @@ private init; | ||
sendString(value: string): Promise<void>; | ||
private startNotifications; | ||
private onNewListener; | ||
private onRemoveListener; | ||
private receiveHandler; | ||
@@ -35,0 +35,0 @@ private receiveStringHandler; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1314760
73
80
3
3099