UNPKG

@tanislav000/bluez

Version:

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

106 lines (97 loc) 3.83 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProfileWrapper = void 0; const DBus = __importStar(require("dbus-next")); const debug_1 = __importDefault(require("debug")); const debug = (0, debug_1.default)("bluez:ProfileWrapper"); class ProfileWrapper extends DBus.interface.Interface { constructor(profile, bluez) { super("org.bluez.Profile1"); this.impl = profile; this.bluez = bluez; } /** void Release() [noreply] This method gets called when the service daemon unregisters the profile. A profile can use it to do cleanup tasks. There is no need to unregister the profile, because when this method gets called it has already been unregistered. */ Release() { debug("Release"); if (this.impl.Release) return this.impl.Release(); } /** void NewConnection(object device, fd, dict fd_properties) This method gets called when a new service level connection has been made and authorized. Common fd_properties: uint16 Version Profile version (optional) uint16 Features Profile features (optional) Possible errors: org.bluez.Error.Rejected org.bluez.Error.Canceled */ async NewConnection(device, fd, options) { debug("NewConnection", device); const dev = await this.bluez.getDeviceFromObject(device); return this.impl.NewConnection(dev, fd, options); } /** void RequestDisconnection(object device) This method gets called when a profile gets disconnected. The file descriptor is no longer owned by the service daemon and the profile implementation needs to take care of cleaning up all connections. If multiple file descriptors are indicated via NewConnection, it is expected that all of them are disconnected before returning from this method call. Possible errors: org.bluez.Error.Rejected org.bluez.Error.Canceled */ async RequestDisconnection(device) { debug("RequestDisconnection", device); if (this.impl.RequestDisconnection) { const dev = await this.bluez.getDeviceFromObject(device); return this.impl.RequestDisconnection(dev); } } } exports.ProfileWrapper = ProfileWrapper; ProfileWrapper.configureMembers({ methods: { Release: {}, NewConnection: { inSignature: "oha{sv}" }, RequestDisconnection: { inSignature: "o" }, }, }); //# sourceMappingURL=profileWrapper.js.map