[PATCH 6/9] Adds HDP record adder script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This script creates an HDP profile from a service dictionary
(in a format that hdp_record module understands), generates
the XML and adds the service in SDP using D-BUS.
---
 test/hdp/hdp_record_add.py |   49 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 49 insertions(+), 0 deletions(-)
 create mode 100755 test/hdp/hdp_record_add.py

diff --git a/test/hdp/hdp_record_add.py b/test/hdp/hdp_record_add.py
new file mode 100755
index 0000000..2574570
--- /dev/null
+++ b/test/hdp/hdp_record_add.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+
+import hdp_record
+import sys
+import time
+import dbus
+
+feature1 = {'mdep_id': 0x01, 'role': 'source',
+		'data_type': 0x1004, 'description': "Fake oximeter"}
+# feature2 = {'mdep_id': 0x01, 'role': 'source', 'data_type': 0x4005}
+# feature3 = {'mdep_id': 0x02, 'role': 'sink', 'data_type': 0x4006}
+# feature4 = {'mdep_id': 0x04, 'role': 'sink', 'data_type': 0x4007}
+# features = [feature1, feature2, feature3, feature4]
+features = [feature1]
+hdp = {'features': features}
+hdp['mcap_control_psm'] = 0x1001
+hdp['mcap_data_psm'] = 0x1003
+hdp['name'] = "Fake oximeter"
+hdp['description'] = "A fake HDP record"
+hdp['provider'] = "Epx Inc."
+hdp['mcap_procedures'] = ('csp', 'csp_master', 'reconnect_init', \
+				'reconnect_accept')
+xml = hdp_record.gen_xml(hdp)
+
+bus = dbus.SystemBus()
+manager = dbus.Interface(bus.get_object("org.bluez", "/"),
+						"org.bluez.Manager")
+
+if len(sys.argv) > 1:
+	path = manager.FindAdapter(sys.argv[1])
+else:
+	path = manager.DefaultAdapter()
+
+service = dbus.Interface(bus.get_object("org.bluez", path),
+						"org.bluez.Service")
+
+handle = service.AddRecord(xml)
+
+print "Service record with handle 0x%04x added" % (handle)
+
+print "Press CTRL-C to remove service record"
+
+try:
+	time.sleep(1000)
+	print "Terminating session"
+except:
+	pass
+
+service.RemoveRecord(dbus.UInt32(handle))
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux