@tanislav000/bluez
Version:
Bluez5 D-Bus bindings for easy to use bluetooth access in Node.js
100 lines • 8.61 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OrgBluezLEAdvertisingManager1 = 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 = `
<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.LEAdvertisingManager1
*/
class OrgBluezLEAdvertisingManager1 extends utilts_1.LooselyTypedEmitter {
static Connect(bus, objectPath = "/org/bluez/hci0", xml = XMLObjectData) {
return bus.getProxyObject("org.bluez", objectPath, xml).then((obj) => new OrgBluezLEAdvertisingManager1(obj));
}
constructor(dbusObject) {
super();
this.dbusObject = dbusObject;
this.thisDBusInterface = this.dbusObject.getInterface("org.bluez.LEAdvertisingManager1");
this.propertiesDBusInterface = this.dbusObject.getInterface("org.freedesktop.DBus.Properties");
// forward property change events
const forwardPropertyChange = (iface, changed, invalidated) => {
if (iface === OrgBluezLEAdvertisingManager1.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(OrgBluezLEAdvertisingManager1.DbusInterfaceName)
.then(utilts_1.unwrapDbusVariantObject);
}
getProperty(name) {
return this.propertiesDBusInterface
.Get(OrgBluezLEAdvertisingManager1.DbusInterfaceName, name)
.then(utilts_1.unwrapDbusVariant);
}
setProperty(name, value) {
return this.propertiesDBusInterface.Set(OrgBluezLEAdvertisingManager1.DbusInterfaceName, name, (0, utilts_1.wrapDbusVariant)(value));
}
//@property({ name: 'ActiveInstances', signature: 'y', access: ACCESS_READ })
ActiveInstances() {
return this.propertiesDBusInterface
.Get(OrgBluezLEAdvertisingManager1.DbusInterfaceName, "ActiveInstances")
.then(utilts_1.unwrapDbusVariant);
}
//@property({ name: 'SupportedInstances', signature: 'y', access: ACCESS_READ })
SupportedInstances() {
return this.propertiesDBusInterface
.Get(OrgBluezLEAdvertisingManager1.DbusInterfaceName, "SupportedInstances")
.then(utilts_1.unwrapDbusVariant);
}
//@property({ name: 'SupportedIncludes', signature: 'as', access: ACCESS_READ })
SupportedIncludes() {
return this.propertiesDBusInterface
.Get(OrgBluezLEAdvertisingManager1.DbusInterfaceName, "SupportedIncludes")
.then(utilts_1.unwrapDbusVariant);
}
//@property({ name: 'SupportedSecondaryChannels', signature: 'as', access: ACCESS_READ })
SupportedSecondaryChannels() {
return this.propertiesDBusInterface
.Get(OrgBluezLEAdvertisingManager1.DbusInterfaceName, "SupportedSecondaryChannels")
.then(utilts_1.unwrapDbusVariant);
}
/***** Methods *****/
//@method({ name: 'RegisterAdvertisement', inSignature: 'oa{sv}', outSignature: '' })
RegisterAdvertisement(advertisement, options) {
return this.thisDBusInterface.RegisterAdvertisement((0, utilts_1.wrapDbusSignature)(advertisement, "o"), (0, utilts_1.wrapDbusSignature)(options, "a{sv}"));
}
//@method({ name: 'UnregisterAdvertisement', inSignature: 'o', outSignature: '' })
UnregisterAdvertisement(service) {
return this.thisDBusInterface.UnregisterAdvertisement((0, utilts_1.wrapDbusSignature)(service, "o"));
}
}
exports.OrgBluezLEAdvertisingManager1 = OrgBluezLEAdvertisingManager1;
OrgBluezLEAdvertisingManager1.DbusInterfaceName = "org.bluez.LEAdvertisingManager1";
//# sourceMappingURL=LEAdvertisingManager1.js.map