Skip to content

Commit 131ccb6

Browse files
authored
Add useful missing interfaces (#8)
* `AgentInterfaceAsync` * `AdapterInterface` * `AgentManagerInterface` * `ProfileManagerInterface` Thank you @jlucier !
1 parent 02d226c commit 131ccb6

6 files changed

Lines changed: 334 additions & 2 deletions

File tree

sdbus_async/bluez/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from __future__ import annotations
2121

2222
from .adapter_api import AdapterInterfaceAsync
23-
from .agent_api import AgentManagerInterfaceAsync
23+
from .agent_api import AgentInterfaceAsync, AgentManagerInterfaceAsync
2424
from .battery_api import BatteryInterfaceAsync
2525
from .device_api import DeviceInterfaceAsync
2626
from .gatt_api import (
@@ -30,11 +30,12 @@
3030
)
3131
from .media_api import MediaInterfaceAsync
3232
from .network_api import NetworkServerInterfaceAsync
33-
from .profile_api import ProfileManagerInterfaceAsync
33+
from .profile_api import ProfileInterfaceAsync, ProfileManagerInterfaceAsync
3434

3535
__all__ = (
3636
'AdapterInterfaceAsync',
3737

38+
'AgentInterfaceAsync',
3839
'AgentManagerInterfaceAsync',
3940

4041
'BatteryInterfaceAsync',
@@ -49,5 +50,6 @@
4950

5051
'NetworkServerInterfaceAsync',
5152

53+
'ProfileInterfaceAsync',
5254
'ProfileManagerInterfaceAsync',
5355
)

sdbus_async/bluez/agent_api.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,28 @@ async def request_default_agent(
5454
agent_path: str,
5555
) -> None:
5656
raise NotImplementedError
57+
58+
59+
class AgentInterfaceAsync(
60+
DbusInterfaceCommonAsync,
61+
interface_name='org.bluez.Agent1',
62+
):
63+
@dbus_method_async()
64+
async def cancel(self) -> None:
65+
raise NotImplementedError
66+
67+
@dbus_method_async()
68+
async def release(self) -> None:
69+
raise NotImplementedError
70+
71+
@dbus_method_async(
72+
input_signature='os',
73+
)
74+
async def authorize_service(self, device: str, uuid: str) -> None:
75+
raise NotImplementedError
76+
77+
@dbus_method_async(
78+
input_signature='o',
79+
)
80+
async def request_authorization(self, device: str) -> None:
81+
raise NotImplementedError

sdbus_block/bluez/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,15 @@
1818
# License along with this library; if not, write to the Free Software
1919
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2020
from __future__ import annotations
21+
22+
from .adapter_api import AdapterInterface
23+
from .agent_api import AgentManagerInterface
24+
from .profile_api import ProfileInterface, ProfileManagerInterface
25+
26+
__all__ = (
27+
'AdapterInterface',
28+
'AgentManagerInterface',
29+
30+
'ProfileInterface',
31+
'ProfileManagerInterface',
32+
)

sdbus_block/bluez/adapter_api.py

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
3+
# Copyright (C) 2022 igo95862
4+
5+
# This file is part of python-sdbus
6+
7+
# This library is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU Lesser General Public
9+
# License as published by the Free Software Foundation; either
10+
# version 2.1 of the License, or (at your option) any later version.
11+
12+
# This library is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
# Lesser General Public License for more details.
16+
17+
# You should have received a copy of the GNU Lesser General Public
18+
# License along with this library; if not, write to the Free Software
19+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
from __future__ import annotations
21+
22+
from typing import Any, Dict, List, Tuple
23+
24+
from sdbus import (
25+
DbusInterfaceCommon,
26+
dbus_method,
27+
dbus_property,
28+
)
29+
30+
31+
class AdapterInterface(
32+
DbusInterfaceCommon,
33+
interface_name='org.bluez.Adapter1',
34+
):
35+
@dbus_method()
36+
def start_discovery(
37+
self,
38+
) -> None:
39+
raise NotImplementedError
40+
41+
@dbus_method()
42+
def stop_discovery(
43+
self,
44+
) -> None:
45+
raise NotImplementedError
46+
47+
@dbus_method(
48+
input_signature='o',
49+
)
50+
def remove_device(
51+
self,
52+
device_path: str,
53+
) -> None:
54+
raise NotImplementedError
55+
56+
@dbus_method(
57+
input_signature='a{sv}',
58+
)
59+
def set_discovery_filter(
60+
self,
61+
properties: Dict[str, Tuple[str, Any]],
62+
) -> None:
63+
raise NotImplementedError
64+
65+
@dbus_method(
66+
result_signature='as',
67+
)
68+
def get_discovery_filters(
69+
self,
70+
) -> List[str]:
71+
raise NotImplementedError
72+
73+
@dbus_property(
74+
property_signature='s',
75+
)
76+
def address(self) -> str:
77+
raise NotImplementedError
78+
79+
@dbus_property(
80+
property_signature='s',
81+
)
82+
def address_type(self) -> str:
83+
raise NotImplementedError
84+
85+
@dbus_property(
86+
property_signature='s',
87+
)
88+
def name(self) -> str:
89+
raise NotImplementedError
90+
91+
@dbus_property(
92+
property_signature='s',
93+
)
94+
def alias(self) -> str:
95+
raise NotImplementedError
96+
97+
@dbus_property(property_signature='u', property_name='Class')
98+
def device_class(self) -> int:
99+
raise NotImplementedError
100+
101+
@dbus_property(
102+
property_signature='b',
103+
)
104+
def powered(self) -> bool:
105+
raise NotImplementedError
106+
107+
@dbus_property(
108+
property_signature='b',
109+
)
110+
def discoverable(self) -> bool:
111+
raise NotImplementedError
112+
113+
@dbus_property(
114+
property_signature='b',
115+
)
116+
def pairable(self) -> bool:
117+
raise NotImplementedError
118+
119+
@dbus_property(
120+
property_signature='u',
121+
)
122+
def pairable_timeout(self) -> int:
123+
raise NotImplementedError
124+
125+
@dbus_property(
126+
property_signature='u',
127+
)
128+
def discoverable_timeout(self) -> int:
129+
raise NotImplementedError
130+
131+
@dbus_property(
132+
property_signature='b',
133+
)
134+
def discovering(self) -> bool:
135+
raise NotImplementedError
136+
137+
@dbus_property(
138+
property_signature='as',
139+
property_name='UUIDs',
140+
)
141+
def uuids(self) -> List[str]:
142+
raise NotImplementedError
143+
144+
@dbus_property(
145+
property_signature='s',
146+
)
147+
def modalias(self) -> str:
148+
raise NotImplementedError
149+
150+
@dbus_property(property_signature='as')
151+
def roles(self) -> List[str]:
152+
raise NotImplementedError
153+
154+
@dbus_property(property_signature='as')
155+
def experimental_features(self) -> List[str]:
156+
raise NotImplementedError

sdbus_block/bluez/agent_api.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
3+
# Copyright (C) 2022 igo95862
4+
5+
# This file is part of python-sdbus
6+
7+
# This library is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU Lesser General Public
9+
# License as published by the Free Software Foundation; either
10+
# version 2.1 of the License, or (at your option) any later version.
11+
12+
# This library is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
# Lesser General Public License for more details.
16+
17+
# You should have received a copy of the GNU Lesser General Public
18+
# License along with this library; if not, write to the Free Software
19+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
from __future__ import annotations
21+
22+
from sdbus import (
23+
DbusInterfaceCommon,
24+
dbus_method,
25+
)
26+
27+
28+
class AgentManagerInterface(
29+
DbusInterfaceCommon,
30+
interface_name='org.bluez.AgentManager1',
31+
):
32+
@dbus_method(
33+
input_signature='os',
34+
)
35+
def register_agent(
36+
self,
37+
agent_path: str,
38+
capability: str,
39+
) -> None:
40+
raise NotImplementedError
41+
42+
@dbus_method(
43+
input_signature='o',
44+
)
45+
def unregister_agent(
46+
self,
47+
agent_path: str,
48+
) -> None:
49+
raise NotImplementedError
50+
51+
@dbus_method(
52+
input_signature='o',
53+
)
54+
def request_default_agent(
55+
self,
56+
agent_path: str,
57+
) -> None:
58+
raise NotImplementedError

sdbus_block/bluez/profile_api.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
3+
# Copyright (C) 2022 igo95862
4+
5+
# This file is part of python-sdbus
6+
7+
# This library is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU Lesser General Public
9+
# License as published by the Free Software Foundation; either
10+
# version 2.1 of the License, or (at your option) any later version.
11+
12+
# This library is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
# Lesser General Public License for more details.
16+
17+
# You should have received a copy of the GNU Lesser General Public
18+
# License along with this library; if not, write to the Free Software
19+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20+
from __future__ import annotations
21+
22+
from typing import Any, Dict, Tuple
23+
24+
from sdbus import DbusInterfaceCommon, dbus_method
25+
26+
27+
class ProfileManagerInterface(
28+
DbusInterfaceCommon,
29+
interface_name='org.bluez.ProfileManager1',
30+
):
31+
32+
@dbus_method(
33+
input_signature='osa{sv}',
34+
)
35+
def register_profile(
36+
self,
37+
profile_path: str,
38+
uuid: str,
39+
options: Dict[str, Tuple[str, Any]],
40+
) -> None:
41+
raise NotImplementedError
42+
43+
@dbus_method(
44+
input_signature='o',
45+
)
46+
def unregister_profile(
47+
self,
48+
profile_path: str,
49+
) -> None:
50+
raise NotImplementedError
51+
52+
class ProfileInterface(
53+
DbusInterfaceCommon,
54+
interface_name='org.bluez.Profile1',
55+
):
56+
57+
@dbus_method()
58+
def release(self) -> None:
59+
raise NotImplementedError
60+
61+
@dbus_method(
62+
input_signature='oha{sv}',
63+
)
64+
def new_connection(
65+
self,
66+
device: str,
67+
fd: int,
68+
fd_properties: Dict[str, Tuple[str, Any]],
69+
) -> None:
70+
raise NotImplementedError
71+
72+
@dbus_method(
73+
input_signature='o',
74+
)
75+
def request_disconnection(
76+
self,
77+
device: str,
78+
) -> None:
79+
raise NotImplementedError

0 commit comments

Comments
 (0)