ble-ble113
Version:
Library to run the Bluetooth BLE113 Tessel Module.
63 lines (51 loc) • 1.47 kB
JavaScript
var events = require('events');
var util = require('util');
var services;// = require('./services.json');
function Service(noble, peripheralUuid, uuid) {
this._noble = noble;
this._peripheralUuid = peripheralUuid;
this.uuid = uuid;
this.name = null;
this.type = null;
this.includedServiceUuids = null;
this.characteristics = null;
var service = services[uuid];
if (service) {
this.name = service.name;
this.type = service.type;
}
}
util.inherits(Service, events.EventEmitter);
Service.prototype.toString = function() {
return JSON.stringify({
uuid: this.uuid,
name: this.name,
type: this.type,
includedServiceUuids: this.includedServiceUuids
});
};
Service.prototype.discoverIncludedServices = function(serviceUuids, callback) {
// if (callback) {
// this.once('includedServicesDiscover', function(includedServiceUuids) {
// callback(null, includedServiceUuids);
// });
// }
// this._noble.discoverIncludedServices(
// this._peripheralUuid,
// this.uuid,
// serviceUuids
// );
};
Service.prototype.discoverCharacteristics = function(characteristicUuids, callback) {
// if (callback) {
// this.once('characteristicsDiscover', function(characteristics) {
// callback(null, characteristics);
// });
// }
// this._noble.discoverCharacteristics(
// this._peripheralUuid,
// this.uuid,
// characteristicUuids
// );
};
module.exports = Service;