From: Mikel Astiz <mikel.astiz.oss@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Mikel Astiz <mikel.astiz@bmw-carit.de>
Subject: [RFC BlueZ v1 02/13] test: Add UUID alias table to bluezutils.py
Date: Thu, 6 Jun 2013 10:21:34 +0200 [thread overview]
Message-ID: <1370506905-19641-3-git-send-email-mikel.astiz.oss@gmail.com> (raw)
In-Reply-To: <1370506905-19641-1-git-send-email-mikel.astiz.oss@gmail.com>
From: Mikel Astiz <mikel.astiz@bmw-carit.de>
Add a helper function to parse human-friendly strings that can be
translated into UUID strings. The input string can be one of the
following types:
- Full UUID: e.g. "00001108-0000-1000-8000-00805f9b34fb"
- Short UUID: e.g. "00001108"
- Alias: e.g. HSP_HS_UUID
- Short alias: e.g. HSP_HS
---
test/bluezutils.py | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 84 insertions(+)
diff --git a/test/bluezutils.py b/test/bluezutils.py
index de08cbd..6fc55cb 100644
--- a/test/bluezutils.py
+++ b/test/bluezutils.py
@@ -3,6 +3,64 @@ import dbus
SERVICE_NAME = "org.bluez"
ADAPTER_INTERFACE = SERVICE_NAME + ".Adapter1"
DEVICE_INTERFACE = SERVICE_NAME + ".Device1"
+UUID_ALIAS_TABLE = {
+ "GENERIC_AUDIO_UUID": "00001203-0000-1000-8000-00805f9b34fb",
+ "HSP_HS_UUID": "00001108-0000-1000-8000-00805f9b34fb",
+ "HSP_AG_UUID": "00001112-0000-1000-8000-00805f9b34fb",
+ "HFP_HS_UUID": "0000111e-0000-1000-8000-00805f9b34fb",
+ "HFP_AG_UUID": "0000111f-0000-1000-8000-00805f9b34fb",
+ "ADVANCED_AUDIO_UUID": "0000110d-0000-1000-8000-00805f9b34fb",
+ "A2DP_SOURCE_UUID": "0000110a-0000-1000-8000-00805f9b34fb",
+ "A2DP_SINK_UUID": "0000110b-0000-1000-8000-00805f9b34fb",
+ "AVRCP_REMOTE_UUID": "0000110e-0000-1000-8000-00805f9b34fb",
+ "AVRCP_TARGET_UUID": "0000110c-0000-1000-8000-00805f9b34fb",
+ "PANU_UUID": "00001115-0000-1000-8000-00805f9b34fb",
+ "NAP_UUID": "00001116-0000-1000-8000-00805f9b34fb",
+ "GN_UUID": "00001117-0000-1000-8000-00805f9b34fb",
+ "BNEP_SVC_UUID": "0000000f-0000-1000-8000-00805f9b34fb",
+ "PNPID_UUID": "00002a50-0000-1000-8000-00805f9b34fb",
+ "DEVICE_INFORMATION_UUID": "0000180a-0000-1000-8000-00805f9b34fb",
+ "GATT_UUID": "00001801-0000-1000-8000-00805f9b34fb",
+ "IMMEDIATE_ALERT_UUID": "00001802-0000-1000-8000-00805f9b34fb",
+ "LINK_LOSS_UUID": "00001803-0000-1000-8000-00805f9b34fb",
+ "TX_POWER_UUID": "00001804-0000-1000-8000-00805f9b34fb",
+ "SAP_UUID": "0000112D-0000-1000-8000-00805f9b34fb",
+ "HEART_RATE_UUID": "0000180d-0000-1000-8000-00805f9b34fb",
+ "HEART_RATE_MEASUREMENT_UUID": "00002a37-0000-1000-8000-00805f9b34fb",
+ "BODY_SENSOR_LOCATION_UUID": "00002a38-0000-1000-8000-00805f9b34fb",
+ "HEART_RATE_CONTROL_POINT_UUID": "00002a39-0000-1000-8000-00805f9b34fb",
+ "HEALTH_THERMOMETER_UUID": "00001809-0000-1000-8000-00805f9b34fb",
+ "TEMPERATURE_MEASUREMENT_UUID": "00002a1c-0000-1000-8000-00805f9b34fb",
+ "TEMPERATURE_TYPE_UUID": "00002a1d-0000-1000-8000-00805f9b34fb",
+ "INTERMEDIATE_TEMPERATURE_UUID": "00002a1e-0000-1000-8000-00805f9b34fb",
+ "MEASUREMENT_INTERVAL_UUID": "00002a21-0000-1000-8000-00805f9b34fb",
+ "CYCLING_SC_UUID": "00001816-0000-1000-8000-00805f9b34fb",
+ "CSC_MEASUREMENT_UUID": "00002a5b-0000-1000-8000-00805f9b34fb",
+ "CSC_FEATURE_UUID": "00002a5c-0000-1000-8000-00805f9b34fb",
+ "SENSOR_LOCATION_UUID": "00002a5d-0000-1000-8000-00805f9b34fb",
+ "SC_CONTROL_POINT_UUID": "00002a55-0000-1000-8000-00805f9b34fb",
+ "RFCOMM_UUID_STR": "00000003-0000-1000-8000-00805f9b34fb",
+ "HDP_UUID": "00001400-0000-1000-8000-00805f9b34fb",
+ "HDP_SOURCE_UUID": "00001401-0000-1000-8000-00805f9b34fb",
+ "HDP_SINK_UUID": "00001402-0000-1000-8000-00805f9b34fb",
+ "HSP_HS_UUID": "00001108-0000-1000-8000-00805f9b34fb",
+ "HID_UUID": "00001124-0000-1000-8000-00805f9b34fb",
+ "DUN_GW_UUID": "00001103-0000-1000-8000-00805f9b34fb",
+ "GAP_UUID": "00001800-0000-1000-8000-00805f9b34fb",
+ "PNP_UUID": "00001200-0000-1000-8000-00805f9b34fb",
+ "SPP_UUID": "00001101-0000-1000-8000-00805f9b34fb",
+ "OBEX_SYNC_UUID": "00001104-0000-1000-8000-00805f9b34fb",
+ "OBEX_OPP_UUID": "00001105-0000-1000-8000-00805f9b34fb",
+ "OBEX_FTP_UUID": "00001106-0000-1000-8000-00805f9b34fb",
+ "OBEX_PCE_UUID": "0000112e-0000-1000-8000-00805f9b34fb",
+ "OBEX_PSE_UUID": "0000112f-0000-1000-8000-00805f9b34fb",
+ "OBEX_PBAP_UUID": "00001130-0000-1000-8000-00805f9b34fb",
+ "OBEX_MAS_UUID": "00001132-0000-1000-8000-00805f9b34fb",
+ "OBEX_MNS_UUID": "00001133-0000-1000-8000-00805f9b34fb",
+ "OBEX_MAP_UUID": "00001134-0000-1000-8000-00805f9b34fb"
+}
+
+INV_UUID_ALIAS_TABLE = { v:k for k, v in UUID_ALIAS_TABLE.items() }
def get_managed_objects():
bus = dbus.SystemBus()
@@ -45,3 +103,29 @@ def find_device_in_objects(objects, device_address, adapter_pattern=None):
return dbus.Interface(obj, DEVICE_INTERFACE)
raise Exception("Bluetooth device not found")
+
+def parse_uuid(s):
+ hex_digits = "0123456789abcdef"
+ uuid_digits = hex_digits + "-"
+ suffix = "-0000-1000-8000-00805f9b34fb"
+ short_len = 8
+ long_len = short_len + len(suffix)
+ us = s.upper()
+ ls = s.lower()
+
+ uuid = UUID_ALIAS_TABLE.get(us)
+ if uuid is None:
+ uuid = UUID_ALIAS_TABLE.get(us + "_UUID")
+ if not(uuid is None):
+ return uuid
+
+ if len(ls) == short_len and all((c in hex_digits) for c in ls):
+ return ls + suffix
+ elif len(ls) == long_len and all((c in uuid_digits) for c in ls):
+ return ls
+
+ raise Exception("Invalid profile UUID")
+
+def get_uuid_alias(uuid):
+ ul = uuid.lower()
+ return INV_UUID_ALIAS_TABLE.get(ul)
--
1.8.1.4
next prev parent reply other threads:[~2013-06-06 8:21 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-06 8:21 [RFC BlueZ v1 00/13] Add experimental org.bluez.Service1 Mikel Astiz
2013-06-06 8:21 ` [RFC BlueZ v1 01/13] test: Remove obsolete test script Mikel Astiz
2013-06-06 8:21 ` Mikel Astiz [this message]
2013-06-06 8:21 ` [RFC BlueZ v1 03/13] test: Support human-friendly UUIDs in test-device Mikel Astiz
2013-06-06 8:21 ` [RFC BlueZ v1 04/13] test: Show human-friendly UUIDs in list-devices Mikel Astiz
2013-06-06 8:21 ` [RFC BlueZ v1 05/13] dbus: Add new org.bluez.Service1 Mikel Astiz
2013-06-06 8:29 ` Gustavo Padovan
2013-06-06 9:26 ` Mikel Astiz
2013-06-06 8:21 ` [RFC BlueZ v1 06/13] dbus: Add Device property to org.bluez.Service1 Mikel Astiz
2013-06-06 8:21 ` [RFC BlueZ v1 07/13] dbus: Add UUID " Mikel Astiz
2013-06-06 8:21 ` [RFC BlueZ v1 08/13] dbus: Add state " Mikel Astiz
2013-06-06 8:21 ` [RFC BlueZ v1 09/13] dbus: Add Connect/Disconnect " Mikel Astiz
2013-06-06 8:21 ` [RFC BlueZ v1 10/13] doc: Add API documentation for org.bluez.Service1 Mikel Astiz
2013-06-06 8:21 ` [RFC BlueZ v1 11/13] dbus: Deprecate old profile-connecting API Mikel Astiz
2013-06-06 8:21 ` [RFC BlueZ v1 12/13] test: Add test-service script Mikel Astiz
2013-06-06 8:21 ` [RFC BlueZ v1 13/13] test: Add --uuid to test-service Mikel Astiz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1370506905-19641-3-git-send-email-mikel.astiz.oss@gmail.com \
--to=mikel.astiz.oss@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=mikel.astiz@bmw-carit.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).