• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DBusConnection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.freedesktop.dbus.DBusConnection的典型用法代码示例。如果您正苦于以下问题:Java DBusConnection类的具体用法?Java DBusConnection怎么用?Java DBusConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DBusConnection类属于org.freedesktop.dbus包,在下文中一共展示了DBusConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: dbusConnect

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
@Override
public void dbusConnect(final String busName, final String busPath, DBusInterface iface) throws DBusException {
  this.busPath = busPath;

  connection = DBusConnection.getConnection(AgileObjectInterface.DEFAULT_DBUS_CONNECTION);

  connection.requestBusName(busName);
  connection.exportObject(busPath, iface);

  // ensure DBus object is unregistered
  Runtime.getRuntime().addShutdownHook(new Thread() {
    public void run() {
      try {
        connection.releaseBusName(busName);
        dbusDisconnect();
      } catch (DBusException ex) {
      }
    }
  });

}
 
开发者ID:Agile-IoT,项目名称:agile-api-spec,代码行数:22,代码来源:AbstractAgileObject.java


示例2: findAdapterPath

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
/**
 * Search for a Adapter that has GattManager1 and LEAdvertisement1 interfaces, otherwise return null.
 * @return
 * @throws DBusException
 */
public static String findAdapterPath() throws DBusException {
	DBusConnection dbusConnection = DBusConnection.getConnection(DBusConnection.SYSTEM);
	ObjectManager bluezObjectManager = (ObjectManager) dbusConnection.getRemoteObject(BLUEZ_DBUS_BUSNAME, "/", ObjectManager.class);
	if(bluezObjectManager == null) { return null; }
	
	Map<Path, Map<String, Map<String, Variant>>> bluezManagedObject = bluezObjectManager.GetManagedObjects();
	if(bluezManagedObject == null) { return null; }
	
	for (Path path : bluezManagedObject.keySet()) {
		Map<String, Map<String, Variant>> value = bluezManagedObject.get(path);
		boolean hasGattManager = false;
		boolean hasAdvManager = false;
		
		for(String key : value.keySet()) {
			if(key.equals(BLUEZ_GATT_INTERFACE)) { hasGattManager = true; }
			if(key.equals(BLUEZ_LE_ADV_INTERFACE)) { hasAdvManager = true; }
			
			if(hasGattManager && hasAdvManager) { return path.toString(); }
		}
	}
	
	return null;
}
 
开发者ID:tongo,项目名称:ble-java,代码行数:29,代码来源:BleApplication.java


示例3: showNotification

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
public void showNotification(String message) throws TrayIconException {
	try {
		if (isRunning()) {
			DBusConnection sessionBus = DBusConnection
					.getConnection(DBusConnection.SESSION);
			PanboxTrayInterface p = sessionBus.getRemoteObject(DBUS,
					DBUS_PATH, PanboxTrayInterface.class);
			p.show_notification(message);
			sessionBus.disconnect();
		} else {
			throw new TrayIconException("Tray script ot running!");
		}
	} catch (Exception e) {
		logger.error("Error displaying notification with message \""
				+ message + "\"", e);
	}
}
 
开发者ID:Rohde-Schwarz-Cybersecurity,项目名称:PanBox,代码行数:18,代码来源:PanboxTrayIcon.java


示例4: Daemon

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
public Daemon ( int threads,
                String svc_type,
                String name,
                int port,
                ServerPlayerWrapper.BootstrapPlayerInfo[] players )
        throws IOException, DBusException
{
    m_server_name = name;
    m_service_type = svc_type;

    m_gson = new GsonBuilder ().create ();
    m_commands = new QueueRunner <> ( new ArrayDeque < TransactionWrapper > (), m_act_command );
    m_responses = new QueueRunner <> ( new ArrayDeque < TransactionWrapper > (), m_act_response );
    m_minions = new ArrayList <> ();
    m_exection_pool = Executors.newFixedThreadPool ( threads );

    // Open Port
    m_socket_connection = new ServerSocket ( port );

    // Enumerate Media Players
    m_dbus_connection = DBusConnection.getConnection ( DBusConnection.SESSION );
    m_players = new PlayerManager ( m_dbus_connection, players );
    m_players.addListener ( m_listen_players );
}
 
开发者ID:arfbtwn,项目名称:MPRIS2-Remote,代码行数:25,代码来源:Daemon.java


示例5: createInstance

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
/**
 * Create a new {@link DeviceManager} instance using the given DBus address (e.g. tcp://127.0.0.1:13245)
 * @param _address address to connect to
 * @throws DBusException on error
 *
 * @return {@link DeviceManager}
 */
public static DeviceManager createInstance(String _address) throws DBusException {
    if (_address == null) {
        throw new DBusException("Null is not a valid address");
    }
    if (_address.contains("unix://")) {
        loadLibrary();
    }
    INSTANCE = new DeviceManager(DBusConnection.getConnection(_address));
    return INSTANCE;
}
 
开发者ID:hypfvieh,项目名称:bluez-dbus,代码行数:18,代码来源:DeviceManager.java


示例6: BluetoothAdapter

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
public BluetoothAdapter(Adapter1 _adapter, String _dbusPath, DBusConnection _dbusConnection) {
    super(BluetoothDeviceType.ADAPTER, _dbusConnection, _dbusPath);
    adapter = _adapter;

    supportedFilterOptions.put("UUIDs", String[].class);
    supportedFilterOptions.put("RSSI", short.class);
    supportedFilterOptions.put("Pathloss", UInt16.class);
    supportedFilterOptions.put("Transport", String.class);
}
 
开发者ID:hypfvieh,项目名称:bluez-dbus,代码行数:10,代码来源:BluetoothAdapter.java


示例7: getRemoteObject

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
/**
 * Creates an java object from a bluez dbus response.
 * @param _connection Dbus connection to use
 * @param _path dbus request path
 * @param _objClass interface class to use
 * @param <T> some class/interface implementing/extending {@link DBusInterface}
 * @return the created object or null on error
 */
public static <T extends DBusInterface> T getRemoteObject(DBusConnection _connection, String _path, Class<T> _objClass) {
    try {
        return _connection.getRemoteObject("org.bluez", _path, _objClass);
    } catch (DBusException _ex) {
        LOGGER.warn("Error while converting dbus response to object.", _ex);
    }
    return null;
}
 
开发者ID:hypfvieh,项目名称:bluez-dbus,代码行数:17,代码来源:DbusHelper.java


示例8: start

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
/**
 * First of all the method power-on the adapter.
 * Then publish the service with their characteristic and start the advertisement (only primary service can advertise).
 * @throws DBusException
 * @throws InterruptedException
 */
public void start() throws DBusException, InterruptedException {
	DBusConnection dbusConnection = DBusConnection.getConnection(DBusConnection.SYSTEM);
	
	adapterPath = findAdapterPath();
	if(adapterPath == null) { throw new RuntimeException("No BLE adapter found"); }
	
	this.export(dbusConnection);
	
	Properties adapterProperties = (Properties) dbusConnection.getRemoteObject(BLUEZ_DBUS_BUSNAME, adapterPath, Properties.class);
	adapterProperties.Set(BLUEZ_ADAPTER_INTERFACE, "Powered", new Variant<Boolean>(true));
	if(adapterAlias != null) {
		adapterProperties.Set(BLUEZ_ADAPTER_INTERFACE, "Alias", new Variant<String>(adapterAlias));
	}
	
	GattManager1 gattManager = (GattManager1) dbusConnection.getRemoteObject(BLUEZ_DBUS_BUSNAME, adapterPath, GattManager1.class);
	
	LEAdvertisingManager1 advManager = (LEAdvertisingManager1) dbusConnection.getRemoteObject(BLUEZ_DBUS_BUSNAME, adapterPath, LEAdvertisingManager1.class);

	String advPath = path + "/advertisement";
	adv = new BleAdvertisement(BleAdvertisement.ADVERTISEMENT_TYPE_PERIPHERAL, advPath);
	for (BleService service : servicesList) {
		if(service.isPrimary()) {
			advService = service;
			adv.addService(service);
			break;
		}
	}
	adv.export(dbusConnection);
	
	Map<String, Variant> advOptions = new HashMap<String, Variant>();
	advManager.RegisterAdvertisement(adv, advOptions);
	
	Map<String, Variant> appOptions = new HashMap<String, Variant>();
	gattManager.RegisterApplication(this, appOptions);
	
	initInterfacesHandler();
}
 
开发者ID:tongo,项目名称:ble-java,代码行数:44,代码来源:BleApplication.java


示例9: stop

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
/**
 * Stop the advertisement and unpublish the service.
 * @throws DBusException
 * @throws InterruptedException
 */
public void stop() throws DBusException, InterruptedException {
	if(adapterPath == null) { return; }
	DBusConnection dbusConnection = DBusConnection.getConnection(DBusConnection.SYSTEM);
	GattManager1 gattManager = (GattManager1) dbusConnection.getRemoteObject(BLUEZ_DBUS_BUSNAME, adapterPath, GattManager1.class);
	LEAdvertisingManager1 advManager = (LEAdvertisingManager1) dbusConnection.getRemoteObject(BLUEZ_DBUS_BUSNAME, adapterPath, LEAdvertisingManager1.class);
	
	if(adv != null) { advManager.UnregisterAdvertisement(adv); }
	gattManager.UnregisterApplication(this);
	
	dbusConnection.removeSigHandler(InterfacesAdded.class, interfacesAddedSignalHandler);
	dbusConnection.removeSigHandler(InterfacesRemoved.class, interfacesRemovedSignalHandler);
	dbusConnection.disconnect();
}
 
开发者ID:tongo,项目名称:ble-java,代码行数:19,代码来源:BleApplication.java


示例10: initInterfacesHandler

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
protected void initInterfacesHandler() throws DBusException {
	DBusConnection dbusConnection = DBusConnection.getConnection(DBusConnection.SYSTEM);
	DBus dbus = dbusConnection.getRemoteObject(DBUS_BUSNAME, "/or/freedesktop/DBus", DBus.class);
	String bluezDbusBusName = dbus.GetNameOwner(BLUEZ_DBUS_BUSNAME);
	ObjectManager bluezObjectManager = (ObjectManager) dbusConnection.getRemoteObject(BLUEZ_DBUS_BUSNAME, "/", ObjectManager.class);
	
	interfacesAddedSignalHandler = new DBusSigHandler<InterfacesAdded>() {
		@Override
		public void handle(InterfacesAdded signal) {
			Map<String, Variant> iamap = signal.getInterfacesAdded().get(BLUEZ_DEVICE_INTERFACE);
			if(iamap != null) {
				Variant<String> address = iamap.get("Address");
				System.out.println("Device address: " + address.getValue());
				System.out.println("Device added path: " + signal.getObjectPath().toString());
				hasDeviceConnected = true;
				if(listener != null) { listener.deviceConnected(); }
			}
		}
	};

	interfacesRemovedSignalHandler = new DBusSigHandler<InterfacesRemoved>() {
		@Override
		public void handle(InterfacesRemoved signal) {
			List<String> irlist = signal.getInterfacesRemoved();
			for (String ir : irlist) {
				if(BLUEZ_DEVICE_INTERFACE.equals(ir)) {
					System.out.println("Device Removed path: " + signal.getObjectPath().toString());
					hasDeviceConnected = false;
					if(listener != null) { listener.deviceDisconnected(); }
				}
			}
		}
	};

	dbusConnection.addSigHandler(InterfacesAdded.class, bluezDbusBusName, bluezObjectManager, interfacesAddedSignalHandler);
	dbusConnection.addSigHandler(InterfacesRemoved.class, bluezDbusBusName, bluezObjectManager, interfacesRemovedSignalHandler);
}
 
开发者ID:tongo,项目名称:ble-java,代码行数:38,代码来源:BleApplication.java


示例11: export

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
/**
 * Export the application in Dbus system.
 * @param dbusConnection
 * @throws DBusException
 */
private void export(DBusConnection dbusConnection) throws DBusException {
	for (BleService service : servicesList) {
		service.export(dbusConnection);
	}
	dbusConnection.exportObject(path, this);
}
 
开发者ID:tongo,项目名称:ble-java,代码行数:12,代码来源:BleApplication.java


示例12: sendNotification

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
/**
 * Call this method to send a notification to a central.
 */
public void sendNotification() {
	try {
		DBusConnection dbusConnection = DBusConnection.getConnection(DBusConnection.SYSTEM);
		
		Variant<byte[]> signalValueVariant = new Variant<byte[]>(listener.getValue());
		Map<String, Variant> signalValue = new HashMap<String, Variant>();
		signalValue.put(BleCharacteristic.CHARACTERISTIC_VALUE_PROPERTY_KEY, signalValueVariant);
		
		PropertiesChanged signal = new PropertiesChanged(this.getPath().toString(), GATT_CHARACTERISTIC_INTERFACE, signalValue, new ArrayList<String>());
		dbusConnection.sendSignal(signal);
	} catch(Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:tongo,项目名称:ble-java,代码行数:18,代码来源:BleCharacteristic.java


示例13: start

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
public void start() {
	try {

		conn = DBusConnection.getConnection(DBusConnection.SESSION);
		conn.requestBusName(DBUS);
		conn.exportObject(DBUS_PATH, new PanboxInterfaceImpl());
	} catch (DBusException e) {
		e.printStackTrace();
	}
}
 
开发者ID:Rohde-Schwarz-Cybersecurity,项目名称:PanBox,代码行数:11,代码来源:DBusService.java


示例14: PlayerManager

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
public PlayerManager ( DBusConnection dbus, ServerPlayerWrapper.BootstrapPlayerInfo... players )
        throws DBusException
{
    m_dbus_conn = dbus;
    m_dbus = dbus.getRemoteObject ( DBus.class.getCanonicalName (), OBJECT_DBUS, DBus.class );

    m_players = new HashMap <> ();
    m_owners = new HashMap <> ();

    m_player_info = new LinkedHashSet <> ();

    addSignalHandlers ();

    enumeratePlayers ( players );
}
 
开发者ID:arfbtwn,项目名称:MPRIS2-Remote,代码行数:16,代码来源:PlayerManager.java


示例15: PlayerWrapper

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
public PlayerWrapper ( DBusConnection dbus, BootstrapPlayerInfo info ) throws DBusException
{
    this.m_dbus = dbus;
    this.m_bootstrap = info;
    this.m_info_helper = new PlayerInfoHelper ( busname() );

    init ();
}
 
开发者ID:arfbtwn,项目名称:MPRIS2-Remote,代码行数:9,代码来源:PlayerWrapper.java


示例16: BluetoothDevice

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
public BluetoothDevice(Device1 _device, BluetoothAdapter _adapter, String _dbusPath, DBusConnection _dbusConnection) {
    super(BluetoothDeviceType.DEVICE, _dbusConnection, _dbusPath);
    rawdevice = _device;
    adapter = _adapter;
}
 
开发者ID:hypfvieh,项目名称:bluez-dbus,代码行数:6,代码来源:BluetoothDevice.java


示例17: BluetoothGattCharacteristic

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
public BluetoothGattCharacteristic(GattCharacteristic1 _gattCharacteristic, BluetoothGattService _service, String _dbusPath, DBusConnection _dbusConnection) {
    super(BluetoothDeviceType.GATT_CHARACTERISTIC, _dbusConnection, _dbusPath);

    gattCharacteristic = _gattCharacteristic;
    gattService = _service;
}
 
开发者ID:hypfvieh,项目名称:bluez-dbus,代码行数:7,代码来源:BluetoothGattCharacteristic.java


示例18: BluetoothGattService

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
public BluetoothGattService(GattService1 _service, BluetoothDevice _device, String _dbusPath, DBusConnection _dbusConnection) {
    super(BluetoothDeviceType.GATT_SERVICE, _dbusConnection, _dbusPath);
    service = _service;
    device = _device;
}
 
开发者ID:hypfvieh,项目名称:bluez-dbus,代码行数:6,代码来源:BluetoothGattService.java


示例19: BluetoothGattDescriptor

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
public BluetoothGattDescriptor(GattDescriptor1 _descriptor, BluetoothGattCharacteristic _characteristicWrapper, String _dbusPath, DBusConnection _dbusConnection) {
    super(BluetoothDeviceType.GATT_DESCRIPTOR, _dbusConnection, _dbusPath);
    characteristicWrapper = _characteristicWrapper;
    descriptor = _descriptor;
}
 
开发者ID:hypfvieh,项目名称:bluez-dbus,代码行数:6,代码来源:BluetoothGattDescriptor.java


示例20: AbstractBluetoothObject

import org.freedesktop.dbus.DBusConnection; //导入依赖的package包/类
public AbstractBluetoothObject(BluetoothDeviceType _bluetoothType, DBusConnection _dbusConnection, String _dbusPath) {
    bluetoothType = _bluetoothType;
    dbusConnection = _dbusConnection;
    dbusPath = _dbusPath;
}
 
开发者ID:hypfvieh,项目名称:bluez-dbus,代码行数:6,代码来源:AbstractBluetoothObject.java



注:本文中的org.freedesktop.dbus.DBusConnection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AnnotationMethodHandlerAdapter类代码示例发布时间:2022-05-23
下一篇:
Java IvyContext类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap