sensortoy/www/js/test.js
Martin Donnelly 939a7aff4c init
2016-05-20 17:10:40 +01:00

56 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Created by martin on 2016-05-20.
*/
var DEVICEBASE = function(p) {
this.controller = p.controller || null;
this.settings = p.settings || {};
this.data = {};
this.standards = {
button: {
service: 'FFE0',
data: 'FFE1' // Bit 2: side key, Bit 1- right key, Bit 0 left key
},
heartRate: {
service: '180d',
measurement: '2a37'
}
};
this.custom = {};
this.capabilities = [];
this.deviceID = null;
this.inherits = function(a, b) {
var c = function() {};
c.prototype = b.prototype;
a.superClass_ = b.prototype;
a.prototype = new c;
a.prototype.constructor = a;
};
this.register = function(c) {
c.registerPage(this);
};
this.bytesToString = function(buffer) {
return String.fromCharCode.apply(null, new Uint8Array(buffer));
};
// ASCII only
this.stringToBytes = function(string) {
var array = new Uint8Array(string.length);
for (var i = 0, l = string.length; i < l; i++) {
array[i] = string.charCodeAt(i);
}
return array.buffer;
};
this.register(this.controller);
};