* [Bluez-devel] Patch proposal for serial manager
@ 2007-12-11 11:00 Geoffrey Doret
2007-12-13 16:15 ` Marcel Holtmann
0 siblings, 1 reply; 8+ messages in thread
From: Geoffrey Doret @ 2007-12-11 11:00 UTC (permalink / raw)
To: bluez-devel
[-- Attachment #1.1: Type: text/plain, Size: 349 bytes --]
Hello,
I have added a connect service method in the serial service manager that
take the address of an adapter as first parameter to be able to use more
than one adapter. I realy would like to contribute to bluez and see my patch
applied to the CVS. This is a first proposal, if you have any remarks, I
will take them into account.
Geoffrey Doret
[-- Attachment #1.2: Type: text/html, Size: 374 bytes --]
[-- Attachment #2: patch4 --]
[-- Type: application/octet-stream, Size: 3344 bytes --]
Index: utils/serial/manager.c
===================================================================
RCS file: /cvsroot/bluez/utils/serial/manager.c,v
retrieving revision 1.99
diff -u -r1.99 manager.c
--- utils/serial/manager.c 26 Nov 2007 13:43:57 -0000 1.99
+++ utils/serial/manager.c 11 Dec 2007 10:14:20 -0000
@@ -1917,26 +1917,43 @@
struct pending_connect *pending, *pc;
DBusError derr;
bdaddr_t src;
- const char *bda, *pattern;
+ const char *adapter, *bda, *pattern;
long val;
int dev_id, err;
char uuid[MAX_LEN_UUID_STR];
dbus_error_init(&derr);
- if (!dbus_message_get_args(msg, &derr,
- DBUS_TYPE_STRING, &bda,
- DBUS_TYPE_STRING, &pattern,
- DBUS_TYPE_INVALID)) {
- error_invalid_arguments(conn, msg, derr.message);
- dbus_error_free(&derr);
- return DBUS_HANDLER_RESULT_HANDLED;
+ if(dbus_message_has_signature(msg, "sss")) {
+ if (!dbus_message_get_args(msg, &derr,
+ DBUS_TYPE_STRING, &adapter,
+ DBUS_TYPE_STRING, &bda,
+ DBUS_TYPE_STRING, &pattern,
+ DBUS_TYPE_INVALID)) {
+ error_invalid_arguments(conn, msg, derr.message);
+ dbus_error_free(&derr);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ /* Handle empty adapter as the default */
+ if(!adapter[0])
+ adapter = NULL;
+ } else {
+ if (!dbus_message_get_args(msg, &derr,
+ DBUS_TYPE_STRING, &bda,
+ DBUS_TYPE_STRING, &pattern,
+ DBUS_TYPE_INVALID)) {
+ error_invalid_arguments(conn, msg, derr.message);
+ dbus_error_free(&derr);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ /* Use the default adapter */
+ adapter = NULL;
}
pending = find_pending_connect_by_pattern(bda, pattern);
if (pending)
return error_in_progress(conn, msg, "Connection in progress");
- dev_id = hci_get_route(NULL);
+ dev_id = adapter ? hci_devid(adapter) : hci_get_route(NULL);
if ((dev_id < 0) || (hci_devba(dev_id, &src) < 0))
return error_failed(conn, msg, "Adapter not available");
@@ -2146,6 +2163,7 @@
{ "ListProxies", list_proxies, "", "as" },
{ "RemoveProxy", remove_proxy, "s", "" },
{ "ConnectService", connect_service, "ss", "s" },
+ { "ConnectServiceToAdapter", connect_service, "sss", "s" },
{ "DisconnectService", disconnect_service, "s", "" },
{ "CancelConnectService", cancel_connect_service, "ss", "" },
{ NULL, NULL, NULL, NULL },
Index: utils/serial/serial-api.txt
===================================================================
RCS file: /cvsroot/bluez/utils/serial/serial-api.txt,v
retrieving revision 1.21
diff -u -r1.21 serial-api.txt
--- utils/serial/serial-api.txt 26 Nov 2007 13:41:39 -0000 1.21
+++ utils/serial/serial-api.txt 11 Dec 2007 10:14:20 -0000
@@ -67,6 +67,21 @@
org.bluez.Error.ConnectionAttemptFailed
org.bluez.Error.NotSupported
org.bluez.Error.Failed
+
+ string ConnectServiceToAdapter(string adapter, string address,
+ string pattern)
+
+ Connects to a specific RFCOMM based service on a
+ remote device using the specified adapter and then
+ creates a RFCOMM TTY device for it. The RFCOMM TTY
+ device is returned.
+
+ Possible errors:org.bluez.Error.InvalidArguments
+ org.bluez.Error.Canceled
+ org.bluez.Error.InProgress
+ org.bluez.Error.ConnectionAttemptFailed
+ org.bluez.Error.NotSupported
+ org.bluez.Error.Failed
void CancelConnectService(string address, string pattern)
[-- Attachment #3: Type: text/plain, Size: 277 bytes --]
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
[-- Attachment #4: Type: text/plain, Size: 164 bytes --]
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [Bluez-devel] Patch proposal for serial manager 2007-12-11 11:00 [Bluez-devel] Patch proposal for serial manager Geoffrey Doret @ 2007-12-13 16:15 ` Marcel Holtmann 2007-12-20 14:15 ` Geoffrey Doret 0 siblings, 1 reply; 8+ messages in thread From: Marcel Holtmann @ 2007-12-13 16:15 UTC (permalink / raw) To: BlueZ development Hi Geoffrey, > I have added a connect service method in the serial service manager > that take the address of an adapter as first parameter to be able to > use more than one adapter. I realy would like to contribute to bluez > and see my patch applied to the CVS. This is a first proposal, if you > have any remarks, I will take them into account. first issue is the naming. You don't connect something to an adapter. You use the adapter to connect to something. So it needs either to be named ConnectServiceByAdapter or ConnectServiceFromAdapter. Join #bluez channel on freenode.org to discuss this. Second is that you did a nasty thing with the signature checking. That is not how this should be implement. You should have your own callback in the callback table. If code is shared between two callbacks then a common function has to be created and both callbacks become a small shim to call this function. Otherwise the code gets to complex and nobody will understand it a year later. Third is that we have to agree on the adapter parameter. Should it be the adapter address or the adapter object path. Pros and cons needs to be discussed on #bluez. Regards Marcel ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] Patch proposal for serial manager 2007-12-13 16:15 ` Marcel Holtmann @ 2007-12-20 14:15 ` Geoffrey Doret 2007-12-20 15:17 ` Marcel Holtmann 0 siblings, 1 reply; 8+ messages in thread From: Geoffrey Doret @ 2007-12-20 14:15 UTC (permalink / raw) To: BlueZ development [-- Attachment #1.1: Type: text/plain, Size: 371 bytes --] Hi, I tied to speak on the channel two times but it seems we are not present at the same time. So I noted your remarks and reformulated my patch. First, I opted for "ConnectServiceByAdapter" but changing the naming is quite simple. Second, the format of the new adapter parameter is a string "hciX" or a string representing the adapter address. Regards, Geoffrey Doret [-- Attachment #1.2: Type: text/html, Size: 418 bytes --] [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: connect_service.patch --] [-- Type: text/x-patch; name=connect_service.patch, Size: 3830 bytes --] Index: utils/serial/manager.c =================================================================== RCS file: /cvsroot/bluez/utils/serial/manager.c,v retrieving revision 1.100 diff -u -r1.100 manager.c --- utils/serial/manager.c 13 Dec 2007 19:07:37 -0000 1.100 +++ utils/serial/manager.c 20 Dec 2007 13:18:19 -0000 @@ -1991,32 +1991,20 @@ dbus_message_new_method_return(msg)); } -static DBusHandlerResult connect_service(DBusConnection *conn, - DBusMessage *msg, void *data) +static DBusHandlerResult connect_service_by_devid(DBusConnection *conn, + DBusMessage *msg, void *data, int dev_id, + const char *bda, const char *pattern) { struct pending_connect *pending, *pc; - DBusError derr; bdaddr_t src; - const char *bda, *pattern; long val; - int dev_id, err; + int err; char uuid[MAX_LEN_UUID_STR]; - dbus_error_init(&derr); - if (!dbus_message_get_args(msg, &derr, - DBUS_TYPE_STRING, &bda, - DBUS_TYPE_STRING, &pattern, - DBUS_TYPE_INVALID)) { - error_invalid_arguments(conn, msg, derr.message); - dbus_error_free(&derr); - return DBUS_HANDLER_RESULT_HANDLED; - } - pending = find_pending_connect_by_pattern(bda, pattern); if (pending) return error_in_progress(conn, msg, "Connection in progress"); - dev_id = hci_get_route(NULL); if ((dev_id < 0) || (hci_devba(dev_id, &src) < 0)) return error_failed(conn, msg, "Adapter not available"); @@ -2091,6 +2079,49 @@ return DBUS_HANDLER_RESULT_HANDLED; } +static DBusHandlerResult connect_service(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusError derr; + const char *bda, *pattern; + int devid; + + dbus_error_init(&derr); + if (!dbus_message_get_args(msg, &derr, + DBUS_TYPE_STRING, &bda, + DBUS_TYPE_STRING, &pattern, + DBUS_TYPE_INVALID)) { + error_invalid_arguments(conn, msg, derr.message); + dbus_error_free(&derr); + return DBUS_HANDLER_RESULT_HANDLED; + } + devid = hci_get_route(NULL); + + return connect_service_by_devid(conn, msg, data, devid, bda, pattern); +} + +static DBusHandlerResult connect_service_by_adapter(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusError derr; + const char *adapter, *bda, *pattern; + int devid; + + dbus_error_init(&derr); + if (!dbus_message_get_args(msg, &derr, + DBUS_TYPE_STRING, &adapter, + DBUS_TYPE_STRING, &bda, + DBUS_TYPE_STRING, &pattern, + DBUS_TYPE_INVALID)) { + error_invalid_arguments(conn, msg, derr.message); + dbus_error_free(&derr); + return DBUS_HANDLER_RESULT_HANDLED; + } + devid = hci_devid(adapter); + + return connect_service_by_devid(conn, msg, data, devid, bda, pattern); +} + static DBusHandlerResult disconnect_service(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -2219,15 +2250,16 @@ } static DBusMethodVTable manager_methods[] = { - { "CreatePort", create_port, "ss", "s" }, - { "ListPorts", list_ports, "", "as" }, - { "RemovePort", remove_port, "s", "" }, - { "CreateProxy", create_proxy, "ss", "s" }, - { "ListProxies", list_proxies, "", "as" }, - { "RemoveProxy", remove_proxy, "s", "" }, - { "ConnectService", connect_service, "ss", "s" }, - { "DisconnectService", disconnect_service, "s", "" }, - { "CancelConnectService", cancel_connect_service, "ss", "" }, + { "CreatePort", create_port, "ss", "s" }, + { "ListPorts", list_ports, "", "as" }, + { "RemovePort", remove_port, "s", "" }, + { "CreateProxy", create_proxy, "ss", "s" }, + { "ListProxies", list_proxies, "", "as" }, + { "RemoveProxy", remove_proxy, "s", "" }, + { "ConnectService", connect_service, "ss", "s" }, + { "ConnectServiceByAdapter", connect_service_by_adapter, "sss", "s" }, + { "DisconnectService", disconnect_service, "s", "" }, + { "CancelConnectService", cancel_connect_service, "ss", "" }, { NULL, NULL, NULL, NULL }, }; [-- Attachment #3: Type: text/plain, Size: 308 bytes --] ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace [-- Attachment #4: Type: text/plain, Size: 164 bytes --] _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] Patch proposal for serial manager 2007-12-20 14:15 ` Geoffrey Doret @ 2007-12-20 15:17 ` Marcel Holtmann 2007-12-21 9:16 ` Geoffrey Doret 2007-12-21 9:17 ` Geoffrey Doret 0 siblings, 2 replies; 8+ messages in thread From: Marcel Holtmann @ 2007-12-20 15:17 UTC (permalink / raw) To: BlueZ development Hi Geoffrey, > I tied to speak on the channel two times but it seems we are not > present at the same time. So I noted your remarks and reformulated my > patch. > First, I opted for "ConnectServiceByAdapter" but changing the naming > is quite simple. > Second, the format of the new adapter parameter is a string "hciX" or > a string representing the adapter address. it has to take "hciX" strings or the local BD_ADDR of the adapter. Both must work. This is how other methods handle this. The reason behind it is that as an application developer using this method, you should not worry about the details. The service should do all the heavy lifting. Don't forget to document this new method in serial-api.txt. Try the IRC channel again. At some point, I might pick up the conversation. If I am not responding, ask Johan. Regards Marcel ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] Patch proposal for serial manager 2007-12-20 15:17 ` Marcel Holtmann @ 2007-12-21 9:16 ` Geoffrey Doret 2007-12-21 9:17 ` Geoffrey Doret 1 sibling, 0 replies; 8+ messages in thread From: Geoffrey Doret @ 2007-12-21 9:16 UTC (permalink / raw) To: BlueZ development Hi Marcel, > > it has to take "hciX" strings or the local BD_ADDR of the adapter. Both > must work. This is how other methods handle this. The reason behind it > is that as an application developer using this method, you should not > worry about the details. The service should do all the heavy lifting. If I've understood, that is how hci_devid handle its parameter? If that is correct, the new adapter parameter is correctly handled. > > Don't forget to document this new method in serial-api.txt. Documentation is included in the last patch. Regards, Geoffrey Doret ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] Patch proposal for serial manager 2007-12-20 15:17 ` Marcel Holtmann 2007-12-21 9:16 ` Geoffrey Doret @ 2007-12-21 9:17 ` Geoffrey Doret 2007-12-21 15:35 ` Geoffrey Doret 1 sibling, 1 reply; 8+ messages in thread From: Geoffrey Doret @ 2007-12-21 9:17 UTC (permalink / raw) To: BlueZ development [-- Attachment #1: Type: text/plain, Size: 573 bytes --] Hi Marcel, > > it has to take "hciX" strings or the local BD_ADDR of the adapter. Both > must work. This is how other methods handle this. The reason behind it > is that as an application developer using this method, you should not > worry about the details. The service should do all the heavy lifting. If I've understood, that is how hci_devid handle its parameter? If that is correct, the new adapter parameter is correctly handled. > > Don't forget to document this new method in serial-api.txt. Documentation is included in the last patch. Regards, Geoffrey Doret [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: connect_service.patch --] [-- Type: text/x-patch; name=connect_service.patch, Size: 4868 bytes --] Index: utils/serial/manager.c =================================================================== RCS file: /cvsroot/bluez/utils/serial/manager.c,v retrieving revision 1.100 diff -u -r1.100 manager.c --- utils/serial/manager.c 13 Dec 2007 19:07:37 -0000 1.100 +++ utils/serial/manager.c 20 Dec 2007 15:58:05 -0000 @@ -1991,32 +1991,20 @@ dbus_message_new_method_return(msg)); } -static DBusHandlerResult connect_service(DBusConnection *conn, - DBusMessage *msg, void *data) +static DBusHandlerResult connect_service_by_devid(DBusConnection *conn, + DBusMessage *msg, void *data, int dev_id, + const char *bda, const char *pattern) { struct pending_connect *pending, *pc; - DBusError derr; bdaddr_t src; - const char *bda, *pattern; long val; - int dev_id, err; + int err; char uuid[MAX_LEN_UUID_STR]; - dbus_error_init(&derr); - if (!dbus_message_get_args(msg, &derr, - DBUS_TYPE_STRING, &bda, - DBUS_TYPE_STRING, &pattern, - DBUS_TYPE_INVALID)) { - error_invalid_arguments(conn, msg, derr.message); - dbus_error_free(&derr); - return DBUS_HANDLER_RESULT_HANDLED; - } - pending = find_pending_connect_by_pattern(bda, pattern); if (pending) return error_in_progress(conn, msg, "Connection in progress"); - dev_id = hci_get_route(NULL); if ((dev_id < 0) || (hci_devba(dev_id, &src) < 0)) return error_failed(conn, msg, "Adapter not available"); @@ -2091,6 +2079,49 @@ return DBUS_HANDLER_RESULT_HANDLED; } +static DBusHandlerResult connect_service(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusError derr; + const char *bda, *pattern; + int devid; + + dbus_error_init(&derr); + if (!dbus_message_get_args(msg, &derr, + DBUS_TYPE_STRING, &bda, + DBUS_TYPE_STRING, &pattern, + DBUS_TYPE_INVALID)) { + error_invalid_arguments(conn, msg, derr.message); + dbus_error_free(&derr); + return DBUS_HANDLER_RESULT_HANDLED; + } + devid = hci_get_route(NULL); + + return connect_service_by_devid(conn, msg, data, devid, bda, pattern); +} + +static DBusHandlerResult connect_service_by_adapter(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusError derr; + const char *adapter, *bda, *pattern; + int devid; + + dbus_error_init(&derr); + if (!dbus_message_get_args(msg, &derr, + DBUS_TYPE_STRING, &adapter, + DBUS_TYPE_STRING, &bda, + DBUS_TYPE_STRING, &pattern, + DBUS_TYPE_INVALID)) { + error_invalid_arguments(conn, msg, derr.message); + dbus_error_free(&derr); + return DBUS_HANDLER_RESULT_HANDLED; + } + devid = hci_devid(adapter); + + return connect_service_by_devid(conn, msg, data, devid, bda, pattern); +} + static DBusHandlerResult disconnect_service(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -2219,15 +2250,16 @@ } static DBusMethodVTable manager_methods[] = { - { "CreatePort", create_port, "ss", "s" }, - { "ListPorts", list_ports, "", "as" }, - { "RemovePort", remove_port, "s", "" }, - { "CreateProxy", create_proxy, "ss", "s" }, - { "ListProxies", list_proxies, "", "as" }, - { "RemoveProxy", remove_proxy, "s", "" }, - { "ConnectService", connect_service, "ss", "s" }, - { "DisconnectService", disconnect_service, "s", "" }, - { "CancelConnectService", cancel_connect_service, "ss", "" }, + { "CreatePort", create_port, "ss", "s" }, + { "ListPorts", list_ports, "", "as" }, + { "RemovePort", remove_port, "s", "" }, + { "CreateProxy", create_proxy, "ss", "s" }, + { "ListProxies", list_proxies, "", "as" }, + { "RemoveProxy", remove_proxy, "s", "" }, + { "ConnectService", connect_service, "ss", "s" }, + { "ConnectServiceByAdapter", connect_service_by_adapter, "sss", "s" }, + { "DisconnectService", disconnect_service, "s", "" }, + { "CancelConnectService", cancel_connect_service, "ss", "" }, { NULL, NULL, NULL, NULL }, }; Index: utils/serial/serial-api.txt =================================================================== RCS file: /cvsroot/bluez/utils/serial/serial-api.txt,v retrieving revision 1.21 diff -u -r1.21 serial-api.txt --- utils/serial/serial-api.txt 26 Nov 2007 13:41:39 -0000 1.21 +++ utils/serial/serial-api.txt 20 Dec 2007 15:58:05 -0000 @@ -68,6 +68,21 @@ org.bluez.Error.NotSupported org.bluez.Error.Failed + string ConnectServiceByAdapter(string adapter, string address, + string pattern) + + Use the given adapter to connects to a specific RFCOMM + based service on a remote device and then creates a + RFCOMM TTY device for it. The RFCOMM TTY device is + returned. + + Possible errors:org.bluez.Error.InvalidArguments + org.bluez.Error.Canceled + org.bluez.Error.InProgress + org.bluez.Error.ConnectionAttemptFailed + org.bluez.Error.NotSupported + org.bluez.Error.Failed + void CancelConnectService(string address, string pattern) Cancel a previous ConnectService method call. [-- Attachment #3: Type: text/plain, Size: 228 bytes --] ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ [-- Attachment #4: Type: text/plain, Size: 164 bytes --] _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] Patch proposal for serial manager 2007-12-21 9:17 ` Geoffrey Doret @ 2007-12-21 15:35 ` Geoffrey Doret 2007-12-21 21:20 ` Claudio Takahasi 0 siblings, 1 reply; 8+ messages in thread From: Geoffrey Doret @ 2007-12-21 15:35 UTC (permalink / raw) To: BlueZ development [-- Attachment #1: Type: text/plain, Size: 205 bytes --] The same patch as the previous one but with "ConnectServiceFromAdapter" naming and the method noted experimental in the documentation. Let me know if the patch is accepted or not. Regards, Geoffrey Doret [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: connect_service.patch --] [-- Type: text/x-patch; name=connect_service.patch, Size: 4901 bytes --] Index: utils/serial/manager.c =================================================================== RCS file: /cvsroot/bluez/utils/serial/manager.c,v retrieving revision 1.100 diff -u -r1.100 manager.c --- utils/serial/manager.c 13 Dec 2007 19:07:37 -0000 1.100 +++ utils/serial/manager.c 21 Dec 2007 15:22:02 -0000 @@ -1991,32 +1991,20 @@ dbus_message_new_method_return(msg)); } -static DBusHandlerResult connect_service(DBusConnection *conn, - DBusMessage *msg, void *data) +static DBusHandlerResult connect_service_from_devid(DBusConnection *conn, + DBusMessage *msg, void *data, int dev_id, + const char *bda, const char *pattern) { struct pending_connect *pending, *pc; - DBusError derr; bdaddr_t src; - const char *bda, *pattern; long val; - int dev_id, err; + int err; char uuid[MAX_LEN_UUID_STR]; - dbus_error_init(&derr); - if (!dbus_message_get_args(msg, &derr, - DBUS_TYPE_STRING, &bda, - DBUS_TYPE_STRING, &pattern, - DBUS_TYPE_INVALID)) { - error_invalid_arguments(conn, msg, derr.message); - dbus_error_free(&derr); - return DBUS_HANDLER_RESULT_HANDLED; - } - pending = find_pending_connect_by_pattern(bda, pattern); if (pending) return error_in_progress(conn, msg, "Connection in progress"); - dev_id = hci_get_route(NULL); if ((dev_id < 0) || (hci_devba(dev_id, &src) < 0)) return error_failed(conn, msg, "Adapter not available"); @@ -2091,6 +2079,51 @@ return DBUS_HANDLER_RESULT_HANDLED; } +static DBusHandlerResult connect_service(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusError derr; + const char *bda, *pattern; + int devid; + + dbus_error_init(&derr); + if (!dbus_message_get_args(msg, &derr, + DBUS_TYPE_STRING, &bda, + DBUS_TYPE_STRING, &pattern, + DBUS_TYPE_INVALID)) { + error_invalid_arguments(conn, msg, derr.message); + dbus_error_free(&derr); + return DBUS_HANDLER_RESULT_HANDLED; + } + + devid = hci_get_route(NULL); + + return connect_service_from_devid(conn, msg, data, devid, bda, pattern); +} + +static DBusHandlerResult connect_service_from_adapter(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusError derr; + const char *adapter, *bda, *pattern; + int devid; + + dbus_error_init(&derr); + if (!dbus_message_get_args(msg, &derr, + DBUS_TYPE_STRING, &adapter, + DBUS_TYPE_STRING, &bda, + DBUS_TYPE_STRING, &pattern, + DBUS_TYPE_INVALID)) { + error_invalid_arguments(conn, msg, derr.message); + dbus_error_free(&derr); + return DBUS_HANDLER_RESULT_HANDLED; + } + + devid = hci_devid(adapter); + + return connect_service_from_devid(conn, msg, data, devid, bda, pattern); +} + static DBusHandlerResult disconnect_service(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -2219,15 +2252,16 @@ } static DBusMethodVTable manager_methods[] = { - { "CreatePort", create_port, "ss", "s" }, - { "ListPorts", list_ports, "", "as" }, - { "RemovePort", remove_port, "s", "" }, - { "CreateProxy", create_proxy, "ss", "s" }, - { "ListProxies", list_proxies, "", "as" }, - { "RemoveProxy", remove_proxy, "s", "" }, - { "ConnectService", connect_service, "ss", "s" }, - { "DisconnectService", disconnect_service, "s", "" }, - { "CancelConnectService", cancel_connect_service, "ss", "" }, + { "CreatePort", create_port, "ss", "s" }, + { "ListPorts", list_ports, "", "as" }, + { "RemovePort", remove_port, "s", "" }, + { "CreateProxy", create_proxy, "ss", "s" }, + { "ListProxies", list_proxies, "", "as" }, + { "RemoveProxy", remove_proxy, "s", "" }, + { "ConnectService", connect_service, "ss", "s" }, + { "ConnectServiceFromAdapter", connect_service_from_adapter, "sss", "s" }, + { "DisconnectService", disconnect_service, "s", "" }, + { "CancelConnectService", cancel_connect_service, "ss", "" }, { NULL, NULL, NULL, NULL }, }; Index: utils/serial/serial-api.txt =================================================================== RCS file: /cvsroot/bluez/utils/serial/serial-api.txt,v retrieving revision 1.21 diff -u -r1.21 serial-api.txt --- utils/serial/serial-api.txt 26 Nov 2007 13:41:39 -0000 1.21 +++ utils/serial/serial-api.txt 21 Dec 2007 15:22:02 -0000 @@ -68,6 +68,21 @@ org.bluez.Error.NotSupported org.bluez.Error.Failed + string ConnectServiceFromAdapter(string adapter, string address, + string pattern) [experimental] + + Use the given adapter to connects to a specific RFCOMM + based service on a remote device and then creates a + RFCOMM TTY device for it. The RFCOMM TTY device is + returned. + + Possible errors:org.bluez.Error.InvalidArguments + org.bluez.Error.Canceled + org.bluez.Error.InProgress + org.bluez.Error.ConnectionAttemptFailed + org.bluez.Error.NotSupported + org.bluez.Error.Failed + void CancelConnectService(string address, string pattern) Cancel a previous ConnectService method call. [-- Attachment #3: Type: text/plain, Size: 228 bytes --] ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ [-- Attachment #4: Type: text/plain, Size: 164 bytes --] _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Bluez-devel] Patch proposal for serial manager 2007-12-21 15:35 ` Geoffrey Doret @ 2007-12-21 21:20 ` Claudio Takahasi 0 siblings, 0 replies; 8+ messages in thread From: Claudio Takahasi @ 2007-12-21 21:20 UTC (permalink / raw) To: BlueZ development On Dec 21, 2007 12:35 PM, Geoffrey Doret <gdoret@gmail.com> wrote: > The same patch as the previous one but with > "ConnectServiceFromAdapter" naming and the method noted experimental > in the documentation. > Let me know if the patch is accepted or not. > > Regards, > Geoffrey Doret > Hi Geoffrey, patch committed! I added an example and some comments in the wiki: http://wiki.bluez.org/wiki/Serial http://wiki.bluez.org/wiki/HOWTO/SerialConnections BR, Claudio. -- --------------------------------------------------------- Claudio Takahasi Instituto Nokia de Tecnologia - INdT ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-12-21 21:20 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-12-11 11:00 [Bluez-devel] Patch proposal for serial manager Geoffrey Doret 2007-12-13 16:15 ` Marcel Holtmann 2007-12-20 14:15 ` Geoffrey Doret 2007-12-20 15:17 ` Marcel Holtmann 2007-12-21 9:16 ` Geoffrey Doret 2007-12-21 9:17 ` Geoffrey Doret 2007-12-21 15:35 ` Geoffrey Doret 2007-12-21 21:20 ` Claudio Takahasi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox