
com.github.hypfvieh.bluetooth.wrapper.ProfileManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bluez-dbus-osgi Show documentation
Show all versions of bluez-dbus-osgi Show documentation
Java native bluetooth library which uses bluez via dbus (linux only).
This is the OSGi compliant bundle of all required libraries in one bundle.
The newest version!
package com.github.hypfvieh.bluetooth.wrapper;
import com.github.hypfvieh.DbusHelper;
import org.bluez.ProfileManager1;
import org.bluez.exceptions.*;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.connections.impl.DBusConnection;
import org.freedesktop.dbus.interfaces.DBusInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
import java.util.UUID;
public class ProfileManager extends AbstractBluetoothObject {
private final Logger logger = LoggerFactory.getLogger(getClass());
private final ProfileManager1 rawProfileManager;
public ProfileManager(DBusConnection _dbusConnection) {
super(BluetoothDeviceType.PROFILE_MANAGER, _dbusConnection, "/org/bluez");
rawProfileManager = DbusHelper.getRemoteObject(_dbusConnection, getDbusPath(), ProfileManager1.class);
}
@Override
protected Class extends DBusInterface> getInterfaceClass() {
return ProfileManager1.class;
}
public boolean registerProfile(String _path, String _uuid, Map _options) {
try {
rawProfileManager.RegisterProfile(new DBusPath(_path), _uuid, optionsToVariantMap(_options));
return true;
} catch (BluezAlreadyExistsException e) {
logger.debug("Profile already exists (UUID: {}, Path: {}).", _uuid, _path, e);
return true;
} catch (BluezInvalidArgumentsException e) {
logger.error("Error while registering Profile (UUID: {}, Path: {}).", _uuid, _path, e);
return false;
}
}
public boolean unregisterProfile(UUID _uuid, String _path) {
try {
rawProfileManager.UnregisterProfile(new DBusPath(_path));
return true;
} catch (BluezDoesNotExistException e) {
logger.trace("Profile does not exist (UUID: {}, Path: {}).", _uuid, _path, e);
return false;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy