@tanislav000/bluez
Version:
Bluez5 D-Bus bindings for easy to use bluetooth access in Node.js
87 lines • 4.02 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrgBluezGattDescriptor1 = void 0;
const utilts_1 = require("../utilts");
/**
* Service: org.bluez
* ObjectPath: /org/bluez/hci0/dev_80_E1_26_08_94_85/-/-/-
* Interface: org.bluez.GattDescriptor1
*/
class OrgBluezGattDescriptor1 extends utilts_1.LooselyTypedEmitter {
static Connect(bus, objectPath, xml) {
return bus.getProxyObject("org.bluez", objectPath, xml).then((obj) => new OrgBluezGattDescriptor1(obj));
}
constructor(dbusObject) {
super();
this.dbusObject = dbusObject;
this.thisDBusInterface = this.dbusObject.getInterface("org.bluez.GattDescriptor1");
this.propertiesDBusInterface = this.dbusObject.getInterface("org.freedesktop.DBus.Properties");
// forward property change events
const forwardPropertyChange = (iface, changed, invalidated) => {
if (iface === OrgBluezGattDescriptor1.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(OrgBluezGattDescriptor1.DbusInterfaceName)
.then(utilts_1.unwrapDbusVariantObject);
}
getProperty(name) {
return this.propertiesDBusInterface
.Get(OrgBluezGattDescriptor1.DbusInterfaceName, name)
.then(utilts_1.unwrapDbusVariant);
}
setProperty(name, value) {
return this.propertiesDBusInterface.Set(OrgBluezGattDescriptor1.DbusInterfaceName, name, (0, utilts_1.wrapDbusVariant)(value));
}
//@property({ name: 'UUID', signature: 's', access: ACCESS_READ })
UUID() {
return this.propertiesDBusInterface
.Get(OrgBluezGattDescriptor1.DbusInterfaceName, "UUID")
.then(utilts_1.unwrapDbusVariant);
}
//@property({ name: 'Characteristic', signature: 'o', access: ACCESS_READ })
Characteristic() {
return this.propertiesDBusInterface
.Get(OrgBluezGattDescriptor1.DbusInterfaceName, "Characteristic")
.then(utilts_1.unwrapDbusVariant);
}
//@property({ name: 'Value', signature: 'ay', access: ACCESS_READ })
Value() {
return this.propertiesDBusInterface
.Get(OrgBluezGattDescriptor1.DbusInterfaceName, "Value")
.then(utilts_1.unwrapDbusVariant);
}
/***** Methods *****/
//@method({ name: 'ReadValue', inSignature: 'a{sv}', outSignature: 'ay' })
ReadValue(options) {
return this.thisDBusInterface.ReadValue((0, utilts_1.wrapDbusSignature)(options, "a{sv}")).then((0, utilts_1.unwrapDbusSignature)("ay"));
}
//@method({ name: 'WriteValue', inSignature: 'aya{sv}', outSignature: '' })
WriteValue(value, options) {
return this.thisDBusInterface.WriteValue((0, utilts_1.wrapDbusSignature)(value, "ay"), (0, utilts_1.wrapDbusSignature)(options, "a{sv}"));
}
}
exports.OrgBluezGattDescriptor1 = OrgBluezGattDescriptor1;
OrgBluezGattDescriptor1.DbusInterfaceName = "org.bluez.GattDescriptor1";
//# sourceMappingURL=GattDescriptor1.js.map