• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/python
2
3import sys
4import time
5import dbus
6
7xml = ' \
8<?xml version="1.0" encoding="UTF-8" ?> 	\
9<record>					\
10  <attribute id="0x0001">			\
11    <sequence>					\
12      <uuid value="0x1101"/>			\
13    </sequence>					\
14  </attribute>					\
15						\
16  <attribute id="0x0002">			\
17     <uint32 value="0"/>			\
18  </attribute>					\
19						\
20  <attribute id="0x0003">			\
21    <uuid value="00001101-0000-1000-8000-00805f9b34fb"/> \
22  </attribute>					\
23						\
24  <attribute id="0x0004">			\
25    <sequence>					\
26      <sequence>				\
27        <uuid value="0x0100"/>			\
28      </sequence>				\
29      <sequence>				\
30        <uuid value="0x0003"/>			\
31        <uint8 value="23"/>			\
32      </sequence>				\
33    </sequence>					\
34  </attribute>					\
35						\
36  <attribute id="0x0005">			\
37    <sequence>					\
38      <uuid value="0x1002"/>			\
39    </sequence>					\
40  </attribute>					\
41						\
42  <attribute id="0x0006">			\
43    <sequence>					\
44      <uint16 value="0x656e"/>			\
45      <uint16 value="0x006a"/>			\
46      <uint16 value="0x0100"/>			\
47    </sequence>					\
48  </attribute>					\
49						\
50  <attribute id="0x0007">			\
51     <uint32 value="0"/>			\
52  </attribute>					\
53						\
54  <attribute id="0x0008">			\
55     <uint8 value="0xff"/>			\
56  </attribute>					\
57						\
58  <attribute id="0x0009">			\
59    <sequence>					\
60      <sequence>				\
61        <uuid value="0x1101"/>			\
62        <uint16 value="0x0100"/>		\
63      </sequence>				\
64    </sequence>					\
65  </attribute>					\
66						\
67  <attribute id="0x000a">			\
68    <url value="http://www.bluez.org/"/>	\
69  </attribute>					\
70						\
71  <attribute id="0x000b">			\
72    <url value="http://www.bluez.org/"/>	\
73  </attribute>					\
74						\
75  <attribute id="0x000c">			\
76    <url value="http://www.bluez.org/"/>	\
77  </attribute>					\
78						\
79  <attribute id="0x0100">			\
80    <text value="Serial Port"/>			\
81  </attribute>					\
82						\
83  <attribute id="0x0101">			\
84    <text value="Serial Port Service"/>		\
85  </attribute>					\
86						\
87  <attribute id="0x0102">			\
88     <text value="BlueZ"/>			\
89  </attribute>					\
90						\
91  <attribute id="0x0200">			\
92    <sequence>					\
93      <uint16 value="0x0100"/>			\
94    </sequence>					\
95  </attribute>					\
96						\
97  <attribute id="0x0201">			\
98     <uint32 value="0"/>			\
99  </attribute>					\
100</record>					\
101'
102
103bus = dbus.SystemBus()
104manager = dbus.Interface(bus.get_object("org.bluez", "/"),
105						"org.bluez.Manager")
106
107if len(sys.argv) > 1:
108	path = manager.FindAdapter(sys.argv[1])
109else:
110	path = manager.DefaultAdapter()
111
112service = dbus.Interface(bus.get_object("org.bluez", path),
113						"org.bluez.Service")
114
115handle = service.AddRecord(xml)
116
117print "Service record with handle 0x%04x added" % (handle)
118
119print "Press CTRL-C to remove service record"
120
121try:
122	time.sleep(1000)
123	print "Terminating session"
124except:
125	pass
126
127service.RemoveRecord(dbus.UInt32(handle))
128