[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/bluetooth 2746c62 23/33: change connect and disconnect
From: |
Stefan Monnier |
Subject: |
[elpa] externals/bluetooth 2746c62 23/33: change connect and disconnect functions to handle single profiles |
Date: |
Sat, 19 Sep 2020 08:43:24 -0400 (EDT) |
branch: externals/bluetooth
commit 2746c62a5181e746b8bc8c9b9fc2556c09794704
Author: Raffael Stocker <r.stocker@mnet-mail.de>
Commit: Raffael Stocker <r.stocker@mnet-mail.de>
change connect and disconnect functions to handle single profiles
---
bluetooth.el | 41 +++++++++++++++++++++++++++++++++++++----
1 file changed, 37 insertions(+), 4 deletions(-)
diff --git a/bluetooth.el b/bluetooth.el
index 68d415e..75dc404 100644
--- a/bluetooth.el
+++ b/bluetooth.el
@@ -149,6 +149,43 @@ The generated function name has the form
`bluetoothPREFIX-NAME'."
(lambda (x) (concat "-" (downcase x)))
name t)))))
+(defun bluetooth-connect (uuid)
+ "Connect to the Bluetooth device at point.
+When called with a prefix argument, ask for a profile and
+connect only this profile. Otherwise, or when called
+non-interactively with UUID set to nil, connect to all profiles."
+ (interactive
+ (if current-prefix-arg
+ (let* ((dev-id (tabulated-list-get-id))
+ (uuids (bluetooth--device-uuids
+ (bluetooth--device-properties
dev-id)))
+ (profile (completing-read "Profile: "
+
(mapcar #'cadadr uuids) nil t)))
+ (list (cl-rassoc profile uuids :key #'cadar :test #'string=)))
+ '(nil)))
+ (if uuid
+ (bluetooth--dbus-method "ConnectProfile" :device (car uuid))
+ (bluetooth--dbus-method "Connect" :device)))
+
+(defun bluetooth-disconnect (uuid)
+ "Disconnect the Bluetooth device at point.
+When called with a prefix argument, ask for a profile and
+disconnect only this profile. Otherwise, or when called
+non-interactively with UUID set to nil, disconnect to all
+profiles."
+ (interactive
+ (if current-prefix-arg
+ (let* ((dev-id (tabulated-list-get-id))
+ (uuids (bluetooth--device-uuids
+ (bluetooth--device-properties
dev-id)))
+ (profile (completing-read "Profile: "
+
(mapcar #'cadadr uuids) nil t)))
+ (list (cl-rassoc profile uuids :key #'cadar :test #'string=)))
+ '(nil)))
+ (if uuid
+ (bluetooth--dbus-method "DisconnectProfile" :device (car uuid))
+ (bluetooth--dbus-method "Disconnect" :device)))
+
(defmacro bluetooth-defun-method (method api docstring)
(declare (doc-string 3) (indent 2))
(let ((name (bluetooth--function-name method)))
@@ -156,10 +193,6 @@ The generated function name has the form
`bluetoothPREFIX-NAME'."
(interactive)
(bluetooth--dbus-method ,method ,api))))
-(bluetooth-defun-method "Connect" :device
- "Connect to the Bluetooth device at point.")
-(bluetooth-defun-method "Disconnect" :device
- "Disconnect Bluetooth device at point.")
(bluetooth-defun-method "StartDiscovery" :adapter
"Start discovery mode.")
(bluetooth-defun-method "StopDiscovery" :adapter
- [elpa] externals/bluetooth 8f3dcaa 11/33: move some of the comments into docstrings, (continued)
- [elpa] externals/bluetooth 8f3dcaa 11/33: move some of the comments into docstrings, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth e86e01f 12/33: add local variable for flycheck mode, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth f107d6f 13/33: Add menu entries to bluetooth-mode-map, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth eb4b158 15/33: Merge commit 'f107d6f', Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth b12caf1 16/33: update author list, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 5d72618 17/33: add page breaks and section headings, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 8e8b6d0 19/33: bump up the copyright year, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 943ddf3 21/33: Clean up the UUID and class descriptions, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 98afd71 22/33: add property and uuid functions, update info display, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 518ebdf 29/33: update company ids (bluetooth--manufacturer-ids), Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 2746c62 23/33: change connect and disconnect functions to handle single profiles,
Stefan Monnier <=
- [elpa] externals/bluetooth 0ca89cf 24/33: clean up the connect and disconnect functions, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 7bb793f 26/33: remove unneeded hydra reference from Makefile, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 950cc77 27/33: add more menu entries, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth b5fc5c2 28/33: correct docstring in bluetooth-disconnect, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 28d16f6 33/33: set version number to 0.2, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth dc4b63b 30/33: correct docstrings, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 6599093 31/33: update list of member UUIDs (bluetooth--member-uuid-alist)., Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth 2ae073b 25/33: update readme with single profile connect information, Stefan Monnier, 2020/09/19
- [elpa] externals/bluetooth eebb593 32/33: refactor variable names of hash tables (were: -alist), Stefan Monnier, 2020/09/19