@tanislav000/bluez
Version:
Bluez5 D-Bus bindings for easy to use bluetooth access in Node.js
80 lines • 3.6 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrgBluezGattService1 = void 0;
const utilts_1 = require("../utilts");
/**
* Service: org.bluez
* ObjectPath: /org/bluez/hci0/dev_80_E1_26_08_94_85/-
* Interface: org.bluez.GattService1
*/
class OrgBluezGattService1 extends utilts_1.LooselyTypedEmitter {
static Connect(bus, objectPath, xml) {
return bus.getProxyObject("org.bluez", objectPath, xml).then((obj) => new OrgBluezGattService1(obj));
}
constructor(dbusObject) {
super();
this.dbusObject = dbusObject;
this.thisDBusInterface = this.dbusObject.getInterface("org.bluez.GattService1");
this.propertiesDBusInterface = this.dbusObject.getInterface("org.freedesktop.DBus.Properties");
// forward property change events
const forwardPropertyChange = (iface, changed, invalidated) => {
if (iface === OrgBluezGattService1.DbusInterfaceName) {
this.emit("PropertiesChanged", iface, (0, utilts_1.unwrapDbusVariantObject)(changed), invalidated);
}
};
// forward all signals
this.on("newListener", (event, listener) => {
if (event === "PropertiesChanged" && this.listenerCount("PropertiesChanged") === 0) {
this.propertiesDBusInterface.addListener("PropertiesChanged", forwardPropertyChange);
}
else {
this.thisDBusInterface.addListener(event, listener);
}
});
this.on("removeListener", (event, listener) => {
if (event === "PropertiesChanged" && this.listenerCount("PropertiesChanged") === 0) {
this.propertiesDBusInterface.removeListener("PropertiesChanged", forwardPropertyChange);
}
else {
this.thisDBusInterface.removeListener(event, listener);
}
});
}
/***** Properties *****/
getProperties() {
return this.propertiesDBusInterface
.GetAll(OrgBluezGattService1.DbusInterfaceName)
.then(utilts_1.unwrapDbusVariantObject);
}
getProperty(name) {
return this.propertiesDBusInterface.Get(OrgBluezGattService1.DbusInterfaceName, name).then(utilts_1.unwrapDbusVariant);
}
setProperty(name, value) {
return this.propertiesDBusInterface.Set(OrgBluezGattService1.DbusInterfaceName, name, (0, utilts_1.wrapDbusVariant)(value));
}
//@property({ name: 'UUID', signature: 's', access: ACCESS_READ })
UUID() {
return this.propertiesDBusInterface.Get(OrgBluezGattService1.DbusInterfaceName, "UUID").then(utilts_1.unwrapDbusVariant);
}
//@property({ name: 'Device', signature: 'o', access: ACCESS_READ })
Device() {
return this.propertiesDBusInterface
.Get(OrgBluezGattService1.DbusInterfaceName, "Device")
.then(utilts_1.unwrapDbusVariant);
}
//@property({ name: 'Primary', signature: 'b', access: ACCESS_READ })
Primary() {
return this.propertiesDBusInterface
.Get(OrgBluezGattService1.DbusInterfaceName, "Primary")
.then(utilts_1.unwrapDbusVariant);
}
//@property({ name: 'Includes', signature: 'ao', access: ACCESS_READ })
Includes() {
return this.propertiesDBusInterface
.Get(OrgBluezGattService1.DbusInterfaceName, "Includes")
.then(utilts_1.unwrapDbusVariant);
}
}
exports.OrgBluezGattService1 = OrgBluezGattService1;
OrgBluezGattService1.DbusInterfaceName = "org.bluez.GattService1";
//# sourceMappingURL=GattService1.js.map