#!/usr/bin/python import sys import time import dbus xml = ' \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ' 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))