UNPKG

@tanislav000/bluez

Version:

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

176 lines 11.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.OrgBluezAdapter1 = void 0; const utilts_1 = require("../utilts"); /* * Generated by dbus-next interface generator * Template: typescript-class-auto.ts.hbs */ // Introspection XML of org.bluez at /org/bluez/hci0 const XMLObjectData = `<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> <node><interface name="org.freedesktop.DBus.Introspectable"><method name="Introspect"><arg name="xml" type="s" direction="out"/></method></interface><interface name="org.bluez.Adapter1"><method name="StartDiscovery"/><method name="SetDiscoveryFilter"><arg name="properties" type="a{sv}" direction="in"/></method><method name="StopDiscovery"/><method name="RemoveDevice"><arg name="device" type="o" direction="in"/></method><method name="GetDiscoveryFilters"><arg name="filters" type="as" direction="out"/></method><property name="Address" type="s" access="read"/><property name="AddressType" type="s" access="read"/><property name="Name" type="s" access="read"/><property name="Alias" type="s" access="readwrite"/><property name="Class" type="u" access="read"/><property name="Powered" type="b" access="readwrite"/><property name="Discoverable" type="b" access="readwrite"/><property name="DiscoverableTimeout" type="u" access="readwrite"/><property name="Pairable" type="b" access="readwrite"/><property name="PairableTimeout" type="u" access="readwrite"/><property name="Discovering" type="b" access="read"/><property name="UUIDs" type="as" access="read"/><property name="Modalias" type="s" access="read"/></interface><interface name="org.freedesktop.DBus.Properties"><method name="Get"><arg name="interface" type="s" direction="in"/><arg name="name" type="s" direction="in"/><arg name="value" type="v" direction="out"/></method><method name="Set"><arg name="interface" type="s" direction="in"/><arg name="name" type="s" direction="in"/><arg name="value" type="v" direction="in"/></method><method name="GetAll"><arg name="interface" type="s" direction="in"/><arg name="properties" type="a{sv}" direction="out"/></method><signal name="PropertiesChanged"><arg name="interface" type="s"/><arg name="changed_properties" type="a{sv}"/><arg name="invalidated_properties" type="as"/></signal></interface><interface name="org.bluez.GattManager1"><method name="RegisterApplication"><arg name="application" type="o" direction="in"/><arg name="options" type="a{sv}" direction="in"/></method><method name="UnregisterApplication"><arg name="application" type="o" direction="in"/></method></interface><interface name="org.bluez.LEAdvertisingManager1"><method name="RegisterAdvertisement"><arg name="advertisement" type="o" direction="in"/><arg name="options" type="a{sv}" direction="in"/></method><method name="UnregisterAdvertisement"><arg name="service" type="o" direction="in"/></method><property name="ActiveInstances" type="y" access="read"/><property name="SupportedInstances" type="y" access="read"/><property name="SupportedIncludes" type="as" access="read"/><property name="SupportedSecondaryChannels" type="as" access="read"/></interface><interface name="org.bluez.Media1"><method name="RegisterEndpoint"><arg name="endpoint" type="o" direction="in"/><arg name="properties" type="a{sv}" direction="in"/></method><method name="UnregisterEndpoint"><arg name="endpoint" type="o" direction="in"/></method><method name="RegisterPlayer"><arg name="player" type="o" direction="in"/><arg name="properties" type="a{sv}" direction="in"/></method><method name="UnregisterPlayer"><arg name="player" type="o" direction="in"/></method><method name="RegisterApplication"><arg name="application" type="o" direction="in"/><arg name="options" type="a{sv}" direction="in"/></method><method name="UnregisterApplication"><arg name="application" type="o" direction="in"/></method></interface><interface name="org.bluez.NetworkServer1"><method name="Register"><arg name="uuid" type="s" direction="in"/><arg name="bridge" type="s" direction="in"/></method><method name="Unregister"><arg name="uuid" type="s" direction="in"/></method></interface></node>`; /** * Service: org.bluez * ObjectPath: /org/bluez/hci0 * Interface: org.bluez.Adapter1 */ class OrgBluezAdapter1 extends utilts_1.LooselyTypedEmitter { static Connect(bus, objectPath = "/org/bluez/hci0", xml = XMLObjectData) { return bus.getProxyObject("org.bluez", objectPath, xml).then((obj) => new OrgBluezAdapter1(obj)); } constructor(dbusObject) { super(); this.dbusObject = dbusObject; this.thisDBusInterface = this.dbusObject.getInterface("org.bluez.Adapter1"); this.propertiesDBusInterface = this.dbusObject.getInterface("org.freedesktop.DBus.Properties"); // forward property change events const forwardPropertyChange = (iface, changed, invalidated) => { if (iface === OrgBluezAdapter1.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(OrgBluezAdapter1.DbusInterfaceName).then(utilts_1.unwrapDbusVariantObject); } getProperty(name) { return this.propertiesDBusInterface.Get(OrgBluezAdapter1.DbusInterfaceName, name).then(utilts_1.unwrapDbusVariant); } setProperty(name, value) { return this.propertiesDBusInterface.Set(OrgBluezAdapter1.DbusInterfaceName, name, (0, utilts_1.wrapDbusVariant)(value)); } //@property({ name: 'Address', signature: 's', access: ACCESS_READ }) Address() { return this.propertiesDBusInterface.Get(OrgBluezAdapter1.DbusInterfaceName, "Address").then(utilts_1.unwrapDbusVariant); } //@property({ name: 'AddressType', signature: 's', access: ACCESS_READ }) AddressType() { return this.propertiesDBusInterface .Get(OrgBluezAdapter1.DbusInterfaceName, "AddressType") .then(utilts_1.unwrapDbusVariant); } //@property({ name: 'Name', signature: 's', access: ACCESS_READ }) Name() { return this.propertiesDBusInterface.Get(OrgBluezAdapter1.DbusInterfaceName, "Name").then(utilts_1.unwrapDbusVariant); } Alias(value) { if (value !== undefined) { return this.propertiesDBusInterface.Set(OrgBluezAdapter1.DbusInterfaceName, "Alias", (0, utilts_1.wrapDbusVariant)(value, "s")); } else { return this.propertiesDBusInterface .Get(OrgBluezAdapter1.DbusInterfaceName, "Alias") .then(utilts_1.unwrapDbusVariant); } } //@property({ name: 'Class', signature: 'u', access: ACCESS_READ }) Class() { return this.propertiesDBusInterface.Get(OrgBluezAdapter1.DbusInterfaceName, "Class").then(utilts_1.unwrapDbusVariant); } Powered(value) { if (value !== undefined) { return this.propertiesDBusInterface.Set(OrgBluezAdapter1.DbusInterfaceName, "Powered", (0, utilts_1.wrapDbusVariant)(value, "b")); } else { return this.propertiesDBusInterface .Get(OrgBluezAdapter1.DbusInterfaceName, "Powered") .then(utilts_1.unwrapDbusVariant); } } Discoverable(value) { if (value !== undefined) { return this.propertiesDBusInterface.Set(OrgBluezAdapter1.DbusInterfaceName, "Discoverable", (0, utilts_1.wrapDbusVariant)(value, "b")); } else { return this.propertiesDBusInterface .Get(OrgBluezAdapter1.DbusInterfaceName, "Discoverable") .then(utilts_1.unwrapDbusVariant); } } DiscoverableTimeout(value) { if (value !== undefined) { return this.propertiesDBusInterface.Set(OrgBluezAdapter1.DbusInterfaceName, "DiscoverableTimeout", (0, utilts_1.wrapDbusVariant)(value, "u")); } else { return this.propertiesDBusInterface .Get(OrgBluezAdapter1.DbusInterfaceName, "DiscoverableTimeout") .then(utilts_1.unwrapDbusVariant); } } Pairable(value) { if (value !== undefined) { return this.propertiesDBusInterface.Set(OrgBluezAdapter1.DbusInterfaceName, "Pairable", (0, utilts_1.wrapDbusVariant)(value, "b")); } else { return this.propertiesDBusInterface .Get(OrgBluezAdapter1.DbusInterfaceName, "Pairable") .then(utilts_1.unwrapDbusVariant); } } PairableTimeout(value) { if (value !== undefined) { return this.propertiesDBusInterface.Set(OrgBluezAdapter1.DbusInterfaceName, "PairableTimeout", (0, utilts_1.wrapDbusVariant)(value, "u")); } else { return this.propertiesDBusInterface .Get(OrgBluezAdapter1.DbusInterfaceName, "PairableTimeout") .then(utilts_1.unwrapDbusVariant); } } //@property({ name: 'Discovering', signature: 'b', access: ACCESS_READ }) Discovering() { return this.propertiesDBusInterface .Get(OrgBluezAdapter1.DbusInterfaceName, "Discovering") .then(utilts_1.unwrapDbusVariant); } //@property({ name: 'UUIDs', signature: 'as', access: ACCESS_READ }) UUIDs() { return this.propertiesDBusInterface.Get(OrgBluezAdapter1.DbusInterfaceName, "UUIDs").then(utilts_1.unwrapDbusVariant); } //@property({ name: 'Modalias', signature: 's', access: ACCESS_READ }) Modalias() { return this.propertiesDBusInterface.Get(OrgBluezAdapter1.DbusInterfaceName, "Modalias").then(utilts_1.unwrapDbusVariant); } /***** Methods *****/ //@method({ name: 'StartDiscovery', inSignature: '', outSignature: '' }) StartDiscovery() { return this.thisDBusInterface.StartDiscovery(); } //@method({ name: 'SetDiscoveryFilter', inSignature: 'a{sv}', outSignature: '' }) SetDiscoveryFilter(properties) { return this.thisDBusInterface.SetDiscoveryFilter((0, utilts_1.wrapDbusSignature)(properties, "a{sv}")); } //@method({ name: 'StopDiscovery', inSignature: '', outSignature: '' }) StopDiscovery() { return this.thisDBusInterface.StopDiscovery(); } //@method({ name: 'RemoveDevice', inSignature: 'o', outSignature: '' }) RemoveDevice(device) { return this.thisDBusInterface.RemoveDevice((0, utilts_1.wrapDbusSignature)(device, "o")); } //@method({ name: 'GetDiscoveryFilters', inSignature: '', outSignature: 'as' }) GetDiscoveryFilters() { return this.thisDBusInterface.GetDiscoveryFilters().then((0, utilts_1.unwrapDbusSignature)("as")); } } exports.OrgBluezAdapter1 = OrgBluezAdapter1; OrgBluezAdapter1.DbusInterfaceName = "org.bluez.Adapter1"; //# sourceMappingURL=Adapter1.js.map