@@ -161,14 +161,16 @@ def start_advertising(self, advertisement, scan_response=None, interval=0.1):
161161 Starts advertising the given advertisement.
162162
163163 :param buf scan_response: scan response data packet bytes.
164- ``None`` if no scan response is needed.
164+ If ``None``, a default scan response will be generated that includes
165+ `BLERadio.name` and `BLERadio.tx_power`.
165166 :param float interval: advertising interval, in seconds
166167 """
167- scan_response_data = None
168- if scan_response :
169- scan_response_data = bytes (scan_response )
168+ if not scan_response :
169+ scan_response = Advertisement ()
170+ scan_response .complete_name = self .name
171+ scan_response .tx_power = self .tx_power
170172 self ._adapter .start_advertising (bytes (advertisement ),
171- scan_response = scan_response_data ,
173+ scan_response = bytes ( scan_response ) ,
172174 connectable = advertisement .connectable ,
173175 interval = interval )
174176
@@ -243,7 +245,7 @@ def connect(self, advertisement, *, timeout=4):
243245
244246 @property
245247 def connected (self ):
246- """True if any peers are connected to the adapter ."""
248+ """True if any peers are connected."""
247249 return self ._adapter .connected
248250
249251 @property
@@ -257,3 +259,28 @@ def connections(self):
257259 wrapped_connections [i ] = self ._connection_cache [connection ]
258260
259261 return tuple (wrapped_connections )
262+
263+ @property
264+ def name (self ):
265+ """The name for this device. Used in advertisements and
266+ as the Device Name in the Generic Access Service, available to a connected peer.
267+ """
268+ return self ._adapter .name
269+
270+ @name .setter
271+ def name (self , value ):
272+ self ._adapter .name = value
273+
274+ @property
275+ def tx_power (self ):
276+ """Transmit power, in dBm."""
277+ return 0
278+
279+ @tx_power .setter
280+ def tx_power (self , value ):
281+ raise NotImplementedError ("setting tx_power not yet implemented" )
282+
283+ @property
284+ def address_bytes (self ):
285+ """The device address, as a ``bytes()`` object of length 6."""
286+ return self ._adapter .address .address_bytes
0 commit comments