22
33from typing import List , Dict , TYPE_CHECKING
44
5- from txdbus .objects import DBusObject , DBusProperty , dbusMethod # type: ignore
6- from txdbus .interface import DBusInterface , Method , Property # type: ignore
5+ from dbus_next .service import ServiceInterface , method , dbus_property # type: ignore
76
87if TYPE_CHECKING :
98 from bless .backends .bluezdbus .dbus .application import ( # type: ignore
@@ -16,33 +15,13 @@ class Type(Enum):
1615 PERIPHERAL = "peripheral"
1716
1817
19- class BlueZLEAdvertisement (DBusObject ):
18+ class BlueZLEAdvertisement (ServiceInterface ):
2019 """
2120 org.bluez.LEAdvertisement1 interface implementation
2221 """
2322
2423 interface_name : str = "org.bluez.LEAdvertisement1"
2524
26- iface : DBusInterface = DBusInterface (
27- interface_name ,
28- Method ("Release" ),
29- Property ("Type" , "s" ),
30- Property ("ServiceUUIDs" , "as" ),
31- Property ("ManufacturerData" , "a{qay}" ),
32- Property ("SolicitUUIDs" , "as" ),
33- Property ("ServiceData" , "a{sv}" ),
34- Property ("IncludeTxPower" , "b" ),
35- )
36-
37- dbusInterfaces : List [DBusInterface ] = [iface ]
38-
39- ad_type : DBusProperty = DBusProperty ("Type" )
40- service_uuids : DBusProperty = DBusProperty ("ServiceUUIDs" )
41- # manufacturer_data = DBusProperty("ManufacturerData")
42- # solicit_uuids = DBusProperty("SolicitUUIDs")
43- # service_data = DBusProperty("ServiceData")
44- include_tx_power : DBusProperty = DBusProperty ("IncludeTxPower" )
45-
4625 def __init__ (
4726 self ,
4827 advertising_type : Type ,
@@ -61,19 +40,67 @@ def __init__(
6140 app : BlueZGattApplication
6241 The Application that is responsible for this advertisement
6342 """
64- self .ad_type : str = advertising_type .value
6543 self .path = app .base_path + "/advertisement" + str (index )
6644
67- self .service_uuids : List [str ] = []
68- self .manufacturer_data : Dict = {}
69- self .solicit_uuids = ["" ]
70- self .service_data = {"" : 0 }
45+ self ._type : str = advertising_type .value
46+ self ._service_uuids : List [str ] = []
47+ self ._manufacturer_data : Dict = {}
48+ self ._solicit_uuids : List [str ] = ["" ]
49+ self ._service_data : Dict = {}
7150
72- self .include_tx_power : bool = False
51+ self ._include_tx_power : bool = False
7352
7453 self .data = None
75- super (BlueZLEAdvertisement , self ).__init__ (self .path )
54+ super (BlueZLEAdvertisement , self ).__init__ (self .interface_name )
7655
77- @dbusMethod ( interface_name , "Release" )
56+ @method ( )
7857 def Release (self ): # noqa: N802
7958 print ("%s: Released!" % self .path )
59+
60+ @dbus_property ()
61+ def Type (self ) -> "s" : # type: ignore # noqa: F821
62+ return self ._type
63+
64+ @Type .setter # type: ignore
65+ def Type (self , type : "s" ): # type: ignore # noqa: F821 F722
66+ self ._type = type
67+
68+ @dbus_property () # noqa: F722
69+ def ServiceUUIDs (self ) -> "as" : # type: ignore # noqa: F821 F722
70+ return self ._service_uuids
71+
72+ @ServiceUUIDs .setter # type: ignore # noqa: 722
73+ def ServiceUUIDs (self , service_uuids : "as" ): # type: ignore # noqa: F821 F722
74+ self ._service_uuids = service_uuids
75+
76+ @dbus_property () # noqa: 722
77+ def ManufacturerData (self ) -> "a{qv}" : # type: ignore # noqa: F821 F722
78+ return self ._manufacturer_data
79+
80+ @ManufacturerData .setter # type: ignore # noqa: F722
81+ def ManufacturerData (self , data : "a{qv}" ): # type: ignore # noqa: F821 F722
82+ self ._manufacturer_data = data
83+
84+ # @dbus_property()
85+ # def SolicitUUIDs(self) -> "as": # type: ignore # noqa: F821 F722
86+ # return self._solicit_uuids
87+
88+ # @SolicitUUIDs.setter # type: ignore
89+ # def SolicitUUIDs(self, uuids: "as"): # type: ignore # noqa: F821 F722
90+ # self._solicit_uuids = uuids
91+
92+ @dbus_property () # noqa: F722
93+ def ServiceData (self ) -> "a{sv}" : # type: ignore # noqa: F821 F722
94+ return self ._service_data
95+
96+ @ServiceData .setter # type: ignore # noqa: F722
97+ def ServiceData (self , data : "a{sv}" ): # type: ignore # noqa: F821 F722
98+ self ._service_data = data
99+
100+ @dbus_property ()
101+ def IncludeTxPower (self ) -> "b" : # type: ignore # noqa: F821
102+ return self ._include_tx_power
103+
104+ @IncludeTxPower .setter # type: ignore
105+ def IncludeTxPower (self , include : "b" ): # type: ignore # noqa: F821
106+ self ._include_tx_power = include
0 commit comments