@@ -161,14 +161,16 @@ def start_advertising(self, advertisement, scan_response=None, interval=0.1):
161
161
Starts advertising the given advertisement.
162
162
163
163
: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`.
165
166
:param float interval: advertising interval, in seconds
166
167
"""
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
170
172
self ._adapter .start_advertising (bytes (advertisement ),
171
- scan_response = scan_response_data ,
173
+ scan_response = bytes ( scan_response ) ,
172
174
connectable = advertisement .connectable ,
173
175
interval = interval )
174
176
@@ -243,7 +245,7 @@ def connect(self, advertisement, *, timeout=4):
243
245
244
246
@property
245
247
def connected (self ):
246
- """True if any peers are connected to the adapter ."""
248
+ """True if any peers are connected."""
247
249
return self ._adapter .connected
248
250
249
251
@property
@@ -257,3 +259,28 @@ def connections(self):
257
259
wrapped_connections [i ] = self ._connection_cache [connection ]
258
260
259
261
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