OSDN Git Service

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