UNPKG

@tanislav000/bluez

Version:

Bluez5 D-Bus bindings for easy to use bluetooth access in Node.js

189 lines 8.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OrgBluezDevice1 = void 0; const utilts_1 = require("../utilts"); /** * Service: org.bluez * ObjectPath: /org/bluez/hci0/- * Interface: org.bluez.Device1 */ class OrgBluezDevice1 extends utilts_1.LooselyTypedEmitter { static Connect(bus, objectPath, xml) { return bus.getProxyObject("org.bluez", objectPath, xml).then((obj) => new OrgBluezDevice1(obj)); } constructor(dbusObject) { super(); this.dbusObject = dbusObject; this.thisDBusInterface = this.dbusObject.getInterface("org.bluez.Device1"); this.propertiesDBusInterface = this.dbusObject.getInterface("org.freedesktop.DBus.Properties"); // forward property change events const forwardPropertyChange = (iface, changed, invalidated) => { if (iface === OrgBluezDevice1.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(OrgBluezDevice1.DbusInterfaceName).then(utilts_1.unwrapDbusVariantObject); } getProperty(name) { return this.propertiesDBusInterface.Get(OrgBluezDevice1.DbusInterfaceName, name).then(utilts_1.unwrapDbusVariant); } setProperty(name, value) { return this.propertiesDBusInterface.Set(OrgBluezDevice1.DbusInterfaceName, name, (0, utilts_1.wrapDbusVariant)(value)); } //@property({ name: 'Address', signature: 's', access: ACCESS_READ }) Address() { return this.propertiesDBusInterface.Get(OrgBluezDevice1.DbusInterfaceName, "Address").then(utilts_1.unwrapDbusVariant); } //@property({ name: 'AddressType', signature: 's', access: ACCESS_READ }) AddressType() { return this.propertiesDBusInterface .Get(OrgBluezDevice1.DbusInterfaceName, "AddressType") .then(utilts_1.unwrapDbusVariant); } //@property({ name: 'Name', signature: 's', access: ACCESS_READ }) Name() { return this.propertiesDBusInterface.Get(OrgBluezDevice1.DbusInterfaceName, "Name").then(utilts_1.unwrapDbusVariant); } Alias(value) { if (value !== undefined) { return this.propertiesDBusInterface.Set(OrgBluezDevice1.DbusInterfaceName, "Alias", (0, utilts_1.wrapDbusVariant)(value, "s")); } else { return this.propertiesDBusInterface.Get(OrgBluezDevice1.DbusInterfaceName, "Alias").then(utilts_1.unwrapDbusVariant); } } //@property({ name: 'Class', signature: 'u', access: ACCESS_READ }) Class() { return this.propertiesDBusInterface.Get(OrgBluezDevice1.DbusInterfaceName, "Class").then(utilts_1.unwrapDbusVariant); } //@property({ name: 'Appearance', signature: 'q', access: ACCESS_READ }) Appearance() { return this.propertiesDBusInterface .Get(OrgBluezDevice1.DbusInterfaceName, "Appearance") .then(utilts_1.unwrapDbusVariant); } //@property({ name: 'Icon', signature: 's', access: ACCESS_READ }) Icon() { return this.propertiesDBusInterface.Get(OrgBluezDevice1.DbusInterfaceName, "Icon").then(utilts_1.unwrapDbusVariant); } //@property({ name: 'Paired', signature: 'b', access: ACCESS_READ }) Paired() { return this.propertiesDBusInterface.Get(OrgBluezDevice1.DbusInterfaceName, "Paired").then(utilts_1.unwrapDbusVariant); } Trusted(value) { if (value !== undefined) { return this.propertiesDBusInterface.Set(OrgBluezDevice1.DbusInterfaceName, "Trusted", (0, utilts_1.wrapDbusVariant)(value, "b")); } else { return this.propertiesDBusInterface .Get(OrgBluezDevice1.DbusInterfaceName, "Trusted") .then(utilts_1.unwrapDbusVariant); } } Blocked(value) { if (value !== undefined) { return this.propertiesDBusInterface.Set(OrgBluezDevice1.DbusInterfaceName, "Blocked", (0, utilts_1.wrapDbusVariant)(value, "b")); } else { return this.propertiesDBusInterface .Get(OrgBluezDevice1.DbusInterfaceName, "Blocked") .then(utilts_1.unwrapDbusVariant); } } //@property({ name: 'LegacyPairing', signature: 'b', access: ACCESS_READ }) LegacyPairing() { return this.propertiesDBusInterface .Get(OrgBluezDevice1.DbusInterfaceName, "LegacyPairing") .then(utilts_1.unwrapDbusVariant); } //@property({ name: 'RSSI', signature: 'n', access: ACCESS_READ }) RSSI() { return this.propertiesDBusInterface.Get(OrgBluezDevice1.DbusInterfaceName, "RSSI").then(utilts_1.unwrapDbusVariant); } //@property({ name: 'Connected', signature: 'b', access: ACCESS_READ }) Connected() { return this.propertiesDBusInterface.Get(OrgBluezDevice1.DbusInterfaceName, "Connected").then(utilts_1.unwrapDbusVariant); } //@property({ name: 'UUIDs', signature: 'as', access: ACCESS_READ }) UUIDs() { return this.propertiesDBusInterface.Get(OrgBluezDevice1.DbusInterfaceName, "UUIDs").then(utilts_1.unwrapDbusVariant); } //@property({ name: 'Modalias', signature: 's', access: ACCESS_READ }) Modalias() { return this.propertiesDBusInterface.Get(OrgBluezDevice1.DbusInterfaceName, "Modalias").then(utilts_1.unwrapDbusVariant); } //@property({ name: 'Adapter', signature: 'o', access: ACCESS_READ }) Adapter() { return this.propertiesDBusInterface.Get(OrgBluezDevice1.DbusInterfaceName, "Adapter").then(utilts_1.unwrapDbusVariant); } //@property({ name: 'ManufacturerData', signature: 'a{qv}', access: ACCESS_READ }) ManufacturerData() { return this.propertiesDBusInterface .Get(OrgBluezDevice1.DbusInterfaceName, "ManufacturerData") .then(utilts_1.unwrapDbusVariant); } //@property({ name: 'ServiceData', signature: 'a{sv}', access: ACCESS_READ }) ServiceData() { return this.propertiesDBusInterface .Get(OrgBluezDevice1.DbusInterfaceName, "ServiceData") .then(utilts_1.unwrapDbusVariant); } //@property({ name: 'TxPower', signature: 'n', access: ACCESS_READ }) TxPower() { return this.propertiesDBusInterface.Get(OrgBluezDevice1.DbusInterfaceName, "TxPower").then(utilts_1.unwrapDbusVariant); } //@property({ name: 'ServicesResolved', signature: 'b', access: ACCESS_READ }) ServicesResolved() { return this.propertiesDBusInterface .Get(OrgBluezDevice1.DbusInterfaceName, "ServicesResolved") .then(utilts_1.unwrapDbusVariant); } /***** Methods *****/ //@method({ name: 'Disconnect', inSignature: '', outSignature: '' }) Disconnect() { return this.thisDBusInterface.Disconnect(); } //@method({ name: 'Connect', inSignature: '', outSignature: '' }) Connect() { return this.thisDBusInterface.Connect(); } //@method({ name: 'ConnectProfile', inSignature: 's', outSignature: '' }) ConnectProfile(UUID) { return this.thisDBusInterface.ConnectProfile((0, utilts_1.wrapDbusSignature)(UUID, "s")); } //@method({ name: 'DisconnectProfile', inSignature: 's', outSignature: '' }) DisconnectProfile(UUID) { return this.thisDBusInterface.DisconnectProfile((0, utilts_1.wrapDbusSignature)(UUID, "s")); } //@method({ name: 'Pair', inSignature: '', outSignature: '' }) Pair() { return this.thisDBusInterface.Pair(); } //@method({ name: 'CancelPairing', inSignature: '', outSignature: '' }) CancelPairing() { return this.thisDBusInterface.CancelPairing(); } } exports.OrgBluezDevice1 = OrgBluezDevice1; OrgBluezDevice1.DbusInterfaceName = "org.bluez.Device1"; //# sourceMappingURL=Device1.js.map