@@ -153,14 +153,16 @@ def start_advertising(self, advertisement, scan_response=None, interval=0.1):
153
153
Starts advertising the given advertisement.
154
154
155
155
:param buf scan_response: scan response data packet bytes.
156
- ``None`` if no scan response is needed.
156
+ If ``None``, a default scan response will be generated that includes
157
+ `BLERadio.name` and `BLERadio.tx_power`.
157
158
:param float interval: advertising interval, in seconds
158
159
"""
159
- scan_response_data = None
160
- if scan_response :
161
- scan_response_data = bytes (scan_response )
160
+ if not scan_response :
161
+ scan_response = Advertisement ()
162
+ scan_response .complete_name = self .name
163
+ scan_response .tx_power = self .tx_power
162
164
self ._adapter .start_advertising (bytes (advertisement ),
163
- scan_response = scan_response_data ,
165
+ scan_response = bytes ( scan_response ) ,
164
166
connectable = advertisement .connectable ,
165
167
interval = interval )
166
168
@@ -235,7 +237,7 @@ def connect(self, advertisement, *, timeout=4):
235
237
236
238
@property
237
239
def connected (self ):
238
- """True if any peers are connected to the adapter ."""
240
+ """True if any peers are connected."""
239
241
return self ._adapter .connected
240
242
241
243
@property
@@ -249,3 +251,28 @@ def connections(self):
249
251
wrapped_connections [i ] = self ._connection_cache [connection ]
250
252
251
253
return tuple (wrapped_connections )
254
+
255
+ @property
256
+ def name (self ):
257
+ """The default name for this device. Used in advertisements and
258
+ as the Device Name in the Generic Access Service, available to a connected peer.
259
+ """
260
+ return self ._adapter .name
261
+
262
+ @name .setter
263
+ def name (self , value ):
264
+ self ._adapter .name = value
265
+
266
+ @property
267
+ def tx_power (self ):
268
+ """Transmit power, in dBm."""
269
+ return 0
270
+
271
+ @tx_power .setter
272
+ def tx_power (self , value ):
273
+ raise NotImplementedError ("setting tx_power not yet implemented" )
274
+
275
+ @property
276
+ def address_bytes (self ):
277
+ """The device address, as a ``bytes()`` object of length 6."""
278
+ return self ._adapter .address .address_bytes
0 commit comments