<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Santiago,<br>
<br>
Thank you very much for your reply. I've already spent a decent
amount of time on this; the thought of digging deep into DBus and
dbus-java isn't very appealing, not to mention my qualifications to
do so. The requirement for Java comes from the ability to
seamlessly integrate with the wealth of Java back-end software.
Just curious if you or anyone on this alias has an opinion on the
notion of taking the Python HDP code and running it in a Jython
environment. This would rehost the software to a Java Virtual
Machine and make Java back-end integration straightforward.<br>
<br>
Thanks,<br>
-- Jim C<br>
<br>
On 7/15/2011 3:38 AM, Santiago Perez wrote:
<blockquote cite="mid:DUB101-W59775A085BDD2E779916D9E0490@phx.gbl"
type="cite">
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
<div dir="ltr">
Hi Jim.<br>
I have tried to develop a X73 Manager for a Blood Pressure
Monitor with BT HDP and Java, but nowadays the Java binding
doesn't support the datatype "File Descriptor". <br>
<br>
A file descriptor is needed because is the way in which the
device sends data to the manager. It is defined in the "health
API" doc of bluez, the <span lang="ES-MODERN">org.bluez.HealthChannel
interface has the method "<span lang="ES-MODERN">fd Acquire()"
(fd: file descriptor).</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN"></span></span> <br>
<span lang="ES-MODERN"><span lang="ES-MODERN">The Java binding's
author (Matthew Johnson <a moz-do-not-send="true"
href="mailto:dbus@matthew.ath.cx">dbus@matthew.ath.cx</a>)
said to me that he cannot to incorporate that datatype at
the moment. I tried it, but it isn't easy...</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN"></span></span> <br>
<span lang="ES-MODERN"><span lang="ES-MODERN">Anyway, related to
your code I see a few things:</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN">- You have to work
with a dBus connection for the current Session, no with the
dBus system... way? I don't know. I just know that the
Bluetooth HDP only creates the HealthManager in the dBus
Session, not in the dBus System...</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN">- You don't need
to get the remote object for the dBus connection! </span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN"></span></span> <br>
<span lang="ES-MODERN"><span lang="ES-MODERN">This is my code
and it works, I hope it is useful for you:</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN"></span></span> <br>
<span lang="ES-MODERN"><span lang="ES-MODERN">Cheers,</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN">Santiago</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN"></span></span> <br>
<span lang="ES-MODERN"><span lang="ES-MODERN">-------------</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN"></span></span> <br>
<span lang="ES-MODERN"><span lang="ES-MODERN"> <br>
<strong>//Getting a DBus connection<br>
</strong>try {<br>
dbusConn = DBusConnection.getConnection(<strong>DBusConnection.SESSION</strong>);<br>
} catch (DBusException e) { <br>
throw new
BusinessRuleException(BusinessRuleError.ERROR_CONNECTION_DBUS,
errorBundle.getString(Integer.toString(BusinessRuleError.ERROR_CONNECTION_DBUS)));<br>
}<br>
if(dbusConn == null)<br>
{<br>
throw new
BusinessRuleException(BusinessRuleError.ERROR_CONNECTION_DBUS,
errorBundle.getString(Integer.toString(BusinessRuleError.ERROR_CONNECTION_DBUS))); <br>
}<br>
</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN"><strong>//Getting
the HealthManager object<br>
</strong>try {<br>
bluezHealthManager = dbusConn.getRemoteObject("org.bluez",
"/org/bluez", org.bluez.HealthManager.class);<br>
} catch (DBusException e) {<br>
throw new
BusinessRuleException(BusinessRuleError.ERROR_HEALTHMANAGER_BLUEZ,
errorBundle.getString(Integer.toString(BusinessRuleError.ERROR_HEALTHMANAGER_BLUEZ)));<br>
}<br>
if(bluezHealthManager == null)<br>
{<br>
throw new
BusinessRuleException(BusinessRuleError.ERROR_HEALTHMANAGER_BLUEZ,
errorBundle.getString(Integer.toString(BusinessRuleError.ERROR_HEALTHMANAGER_BLUEZ))); <br>
}<br>
<br>
<strong>//Registering the X73 Manager for a Blood Pressure
Monitor in dBus<br>
</strong></span></span><span lang="ES-MODERN"><span
lang="ES-MODERN">Map<String, Variant> dictionary = new
HashMap<String, Variant>();</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN"></span></span> <br>
<span lang="ES-MODERN"><span lang="ES-MODERN">UInt16 managerType
= new UInt16(0x1007); <br>
</span></span><span lang="ES-MODERN"><span lang="ES-MODERN">dictionary.put("DataType",
new Variant(managerType)); <br>
dictionary.put("Role",new Variant(strRole));<br>
dictionary.put("Description",new Variant(strDescription));<br>
dictionary.put("ChannelType",new Variant(strChannelType));<br>
<br>
Path managerPath = null;<br>
managerPath =
bluezHealthManager.CreateApplication(dictionary);<br>
if(managerPath == null)<br>
{<br>
throw new
BusinessRuleException(BusinessRuleError.ERROR_REGISTER_X73MANAGER_DBUS,
errorBundle.getString(Integer.toString(BusinessRuleError.ERROR_REGISTER_X73MANAGER_DBUS))); <br>
}</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN"></span></span> <br>
<span lang="ES-MODERN"><span lang="ES-MODERN"></span></span> <br>
<span lang="ES-MODERN"><span lang="ES-MODERN"></span></span> <br>
<span lang="ES-MODERN"><span lang="ES-MODERN"><strong>The
HealthManager interface in Java is defined as:</strong></span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN"></span></span> <br>
<span lang="ES-MODERN"><span lang="ES-MODERN">package org.bluez;</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN">import
java.util.Map;</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN"><br>
import org.freedesktop.dbus.DBusInterface;<br>
import org.freedesktop.dbus.Path;<br>
import org.freedesktop.dbus.Variant;</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN"></span></span> <br>
<span lang="ES-MODERN"><span lang="ES-MODERN">public interface
HealthManager extends DBusInterface<br>
{</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN"> public Path
CreateApplication(Map<String,Variant> dic);<br>
public void DestroyApplication(Path o);</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN">}</span></span><br>
<span lang="ES-MODERN"><span lang="ES-MODERN"><br>
</span></span> <br>
<span lang="ES-MODERN"><span lang="ES-MODERN"></span></span> <br>
---------------<br>
<br>
<br>
<div>
> Date: Thu, 14 Jul 2011 17:21:46 -0400<br>
> From: <a class="moz-txt-link-abbreviated" href="mailto:james.connors@oracle.com">james.connors@oracle.com</a><br>
> To: <a class="moz-txt-link-abbreviated" href="mailto:dbus@lists.freedesktop.org">dbus@lists.freedesktop.org</a><br>
> Subject: dbus-java for Bluetooth HDP<br>
> <br>
> Hello,<br>
> <br>
> I'm trying to use dbus-java to communicate with a
bluetooth Heathcare <br>
> Device Profile (HDP) cpmpliant pulse oxymiter. There has
been some work <br>
> demonstrating this capability with the Python dbus
binding, but next to <br>
> nothing on the Java front from what I see. Not being a
Python <br>
> aficionado, trying to map the Python stuff over to Java
isn't working <br>
> out too well. The example below attempts to make a remote
invocation <br>
> on a method called CreateApplication() as specified by
the following <br>
> interface:<br>
> <br>
> package org.bluez;<br>
> import java.util.Map;<br>
> import org.freedesktop.dbus.DBusInterface;<br>
> import org.freedesktop.dbus.Variant;<br>
> <br>
> public interface HealthManager extends DBusInterface<br>
> {<br>
> public DBusInterface
CreateApplication(Map<String,Variant> a);<br>
> public void DestroyApplication(DBusInterface a);<br>
> }<br>
> <br>
> The simple application below throws a DBusExecution
exception when <br>
> reaching the CreateApplication() method call:<br>
> <br>
> package testhdp;<br>
> <br>
> import java.util.Map;<br>
> import java.util.HashMap;<br>
> import org.freedesktop.DBus;<br>
> import org.freedesktop.dbus.DBusConnection;<br>
> import org.freedesktop.dbus.DBusInterface;<br>
> import org.freedesktop.dbus.Variant;<br>
> import org.freedesktop.dbus.UInt16;<br>
> import org.bluez.Manager;<br>
> import org.bluez.HealthManager;<br>
> import org.freedesktop.DBus.Introspectable;<br>
> <br>
> class TestHDP {<br>
> <br>
> public static void main(String[] args) throws<br>
> org.freedesktop.dbus.exceptions.DBusException {<br>
> <br>
> DBusConnection conn =<br>
> DBusConnection.getConnection(DBusConnection.SYSTEM);<br>
> <br>
> DBus dbus = conn.getRemoteObject(<br>
> "org.freedesktop.DBus", "/org/freedesktop/DBus", <br>
> DBus.class);<br>
> <br>
> String ORG_BLUEZ = "org.bluez";<br>
> System.out.print("Searching dbus.ListNames() return for "
+<br>
> "\"" + ORG_BLUEZ + "\": ");<br>
> String[] names = dbus.ListNames();<br>
> boolean bluezFound = false;<br>
> for (String name: names)<br>
> if (name.equals(ORG_BLUEZ)) {<br>
> bluezFound = true;<br>
> break;<br>
> }<br>
> if (bluezFound)<br>
> System.out.println(ORG_BLUEZ + " found.");<br>
> else<br>
> System.out.println(ORG_BLUEZ + " not found.");<br>
> <br>
> Manager m = (Manager) conn.getRemoteObject("org.bluez",
"/",<br>
> Manager.class);<br>
> System.out.println(m.toString());<br>
> Map<String, Variant> props = m.GetProperties();<br>
> <br>
> HealthManager hm = (HealthManager) conn.getRemoteObject(<br>
> "org.bluez", "/org/bluez", HealthManager.class);<br>
> System.out.println(hm.toString());<br>
> <br>
> Map<String, Variant> config = new
HashMap<String, Variant>();<br>
> config.put("DataType", new Variant<UInt16>(new
UInt16(0x1004)));<br>
> config.put("Role", new Variant<String>("Sink"));<br>
> config.put("Description", new
Variant<String>("Oximeter Sink"));<br>
> <br>
> DBusInterface app = hm.CreateApplication(config);<br>
> <br>
> conn.disconnect();<br>
> }<br>
> }<br>
> <br>
> Output is as follows:<br>
> <br>
> Searching dbus.ListNames() return for "org.bluez":
org.bluez found.<br>
> org.bluez:/:interface org.bluez.Manager<br>
> org.bluez:/org/bluez:interface org.bluez.HealthManager<br>
> Exception in thread "main" <br>
> org.freedesktop.dbus.exceptions.DBusExecutionException:
Wrong return <br>
> type (failed to de-serialize correct types: Failed to
create proxy <br>
> object for /org/bluez/health_app_30 exported by :1.51.
Reason: Could not <br>
> find an interface to cast to )<br>
> at
org.freedesktop.dbus.RemoteInvocationHandler.convertRV(Unknown
<br>
> Source)<br>
> at <br>
>
org.freedesktop.dbus.RemoteInvocationHandler.executeRemoteMethod(Unknown
<br>
> Source)<br>
> at
org.freedesktop.dbus.RemoteInvocationHandler.invoke(Unknown
Source)<br>
> at $Proxy2.CreateApplication(Unknown Source)<br>
> at testhdp.TestHDP.main(TestHDP.java:66)<br>
> <br>
> <br>
> <br>
> Any guidance would be greatly appreciated.<br>
> <br>
> Thanks,<br>
> Jim Connors<br>
> <br>
> _______________________________________________<br>
> dbus mailing list<br>
> <a class="moz-txt-link-abbreviated" href="mailto:dbus@lists.freedesktop.org">dbus@lists.freedesktop.org</a><br>
> <a class="moz-txt-link-freetext" href="http://lists.freedesktop.org/mailman/listinfo/dbus">http://lists.freedesktop.org/mailman/listinfo/dbus</a><br>
</div>
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
dbus mailing list
<a class="moz-txt-link-abbreviated" href="mailto:dbus@lists.freedesktop.org">dbus@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freedesktop.org/mailman/listinfo/dbus">http://lists.freedesktop.org/mailman/listinfo/dbus</a>
</pre>
</blockquote>
<br>
</body>
</html>