On Tue, 27 Dec 2005, Johan Hedberg wrote:

Hi Andrew,

On Tue, Dec 27, 2005, Andrew Ramsay wrote:
I started off with the basic example program which just connects to the
session bus, lists the services available, then exits. That works fine
with both session and system buses. I then tried to modify it slightly to
obtain a proxy for the "com.nokia.btcond" service, which didn't work until
I discovered you had to connect to the system rather than the session bus.
Once I'd got the proxy, I tried to call the rfcomm_bind method as
suggested in the wiki. However, all I get back is an error saying that
this method doesn't exist on the com.nokia.btcond.request interface.
Calling any of the other methods results in the error
"com.nokia.btcond.invalid_dev", which is supposed to indicate an invalid
BDA from what I can tell, although the address I'm using is definitely
correct.

You didn't mention which object path you're using, but it should be
"/com/nokia/btcond/request". You should also be giving the rfcomm_bind
method call two arguments: the BT address (e.g. "11:22:33:44:55:66")
and the profile name (e.g. "SPP").
I'm sure the device address is correct, although I wasn't certain that was the correct format for it, and I was using SPP for the profile name. For the path/interface names, I was using the strings #defined in bt-dbus.h, so they should be OK too.

Can anyone help me out here? As I said, I have no previous experience with
D-BUS programming, so I may well be doing something very wrong and just
haven't noticed yet. I'm using the Glib bindings for D-BUS since that was
what the example code used. If anyone has actually done this already I'd
be very interested to hear how you did it.

It is quite possible that the GLib bindings are buggy in the D-BUS
version that the current 770 SW images use. If you are still
experiencing problems I'd recommend trying out the low level C-bindings.

Johan

I've tried converting the code I had to the basic C bindings, but I'm still seeing exactly the same problems (rfcomm_bind apparently doesn't exist, other methods return com.nokia.btcond.error.invalid_dev).

Here are the important bits of the code I'm using..

#define BDA "00:02:76:C0:56:A4"

DBusError error;
DBusConnection* connection;
DBusMessage* message, *reply;
char* ret1, *ret2;
int reply_timeout, i;

dbus_error_init(&error);

connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
if(connection == NULL) {
fprintf(stderr, "Failed to open bus connection: %s\n", error.message);
        return 1;
}

message = dbus_message_new_method_call(BTCOND_SERVICE,
                        BTCOND_REQ_PATH,
                        BTCOND_REQ_INTERFACE,
                        BTCOND_RFCOMM_BIND_REQ);

dbus_message_append_args(message, DBUS_TYPE_STRING, BDA,
                                DBUS_TYPE_STRING, "SPP",
                                DBUS_TYPE_INVALID);

reply_timeout = -1;
reply = dbus_connection_send_with_reply_and_block(connection,
                                                message,
                                                reply_timeout,
                                                &error);

if(dbus_error_is_set(&error)) {
        fprintf(stderr, "Error: %s\n", error.message);
        return 1;
}

if(!dbus_message_get_args(reply, &error, DBUS_TYPE_STRING, ret1,
                                        DBUS_TYPE_INVALID)) {
        fprintf(stderr, "get_args failed: %s\n", error.message);
        return 1;
}

printf("returned: %s\n", ret1);

dbus_message_unref(message);
dbus_message_unref(reply);
...

Is there anything obviously wrong with that?

Andrew
_______________________________________________
maemo-developers mailing list
maemo-developers@maemo.org
https://maemo.org/mailman/listinfo/maemo-developers

Reply via email to