@tanislav000/bluez
Version:
Bluez5 D-Bus bindings for easy to use bluetooth access in Node.js
85 lines (84 loc) • 3.35 kB
TypeScript
import * as DBus from "dbus-next";
import { Profile } from "./profile";
import { Agent } from "./agent";
import { Adapter } from "./adapter";
import { Device } from "./device";
import { OrgFreedesktopDBusObjectManager } from "./dbus/DBus-ObjectManager";
export interface BluezOptions {
bus: DBus.MessageBus;
userInterfacesPath: DBus.ObjectPath;
}
export declare class Bluez {
private bus;
private options;
private objectManager;
private agentManager;
private profileManager;
private bluezRootObject;
private adapterCache;
constructor(options?: Partial<BluezOptions>);
init(): Promise<void>;
getBus(): DBus.MessageBus;
getObjectManager(): OrgFreedesktopDBusObjectManager;
getAdapter(searchedName?: string): Promise<Adapter>;
listAdapters(): Promise<Adapter[]>;
/**
* This registers a profile implementation.
* If an application disconnects from the bus all
* its registered profiles will be removed.
* HFP HS UUID: 0000111e-0000-1000-8000-00805f9b34fb
* Default RFCOMM channel is 6. And this requires
* authentication.
* Possible errors: org.bluez.Error.InvalidArguments
* org.bluez.Error.AlreadyExists
**/
registerProfile(profile: Profile, path?: string): Promise<void>;
unregisterProfile(path?: string): Promise<void>;
/**
* This registers an agent handler.
* The object path defines the path of the agent
* that will be called when user input is needed.
* Every application can register its own agent and
* for all actions triggered by that application its
* agent is used.
* It is not required by an application to register
* an agent. If an application does chooses to not
* register an agent, the default agent is used. This
* is on most cases a good idea. Only application
* like a pairing wizard should register their own
* agent.
* An application can only register one agent. Multiple
* agents per application is not supported.
* The capability parameter can have the values
* "DisplayOnly", "DisplayYesNo", "KeyboardOnly",
* "NoInputNoOutput" and "KeyboardDisplay" which
* reflects the input and output capabilities of the
* agent.
* If an empty string is used it will fallback to
* "KeyboardDisplay".
* Possible errors: org.bluez.Error.InvalidArguments
* org.bluez.Error.AlreadyExists
**/
registerAgent(agent: Agent, requestAsDefault?: boolean): Promise<void>;
unregisterAgent(agent: Agent): Promise<void>;
/**
* Gat an Adapter from at that path.
* For node > 14.6 Adapters are cached using WeakRefs
* @param object
*/
getAdapterFromObject(object: DBus.ObjectPath): Promise<Adapter>;
/**
* Get a Device Interface at the Object.
* Shortcut for `Bluez.getDbusObjectInterface(Device, object)`
* @param object
*/
getDeviceFromObject(object: DBus.ObjectPath): Promise<Device>;
/**
* Get an low level dbus interface from the given object path
* @param type Low level dbus interface from ./dbus/*
* @param object dbus object path
*/
getDbusObjectInterface<T>(type: {
new (obj: DBus.ProxyObject, bluez: Bluez): T;
}, object: DBus.ObjectPath): Promise<T>;
}