You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 6, 2023. It is now read-only.
`bluetooth.Service(uuid, is_primary = True)` GATTS - create a new GATTSService object. `uuid` is either an integer or a `bytes(16)`. UUIDs are globally unique with in GATTS. If you attempt to create a service with a UUID that is the same as an existing (but not closed) service, you will receive the same service object, and no new service will be created.
109
109
110
-
`bluetooth.services` GATTS - returns the existing GATTS services.
110
+
`bluetooth.services()` GATTS - returns the existing GATTS services.
111
111
112
112
`bluetooth.callback(<callback>, <callback_data>)` used to set the callback function for bluetooth-object-level callbacks. `<callback>` can be set to None. If `<callback_data>` is not specified, it will be set to None. Always returns a 2-tuple of the present `<callback>` and `<callback_data>`. If called with no parameters, the values remain unchanged. `<callback>` will be called with 4 parameters:
`bluetooth.scan_stop()` GATTC - terminate scanning early. If called before the scan timeout, you will _not_ receive a `bluetooth.SCAN_CMPL` event.
149
149
150
-
`bluetooth.is_scanning` GATTC - returns `True` if the scan is still active
150
+
`bluetooth.is_scanning()` GATTC - returns `True` if the scan is still active
151
151
152
152
## GAP
153
153
@@ -190,11 +190,11 @@ GATTSService objects are created by calling the `bluetooth.Service()` constructo
190
190
*`bluetooth.PROP_AUTH`
191
191
*`bluetooth.PROP_EXT_PROP`
192
192
193
-
`service.chars` Get the characteristics attached to this service.
193
+
`service.chars()` Get the characteristics attached to this service.
194
194
195
-
`service.is_primary` Get the value of the srvice `primary` flag.
195
+
`service.is_primary()` Get the value of the srvice `primary` flag.
196
196
197
-
`char.uuid` Get the service UUID.
197
+
`char.uuid()` Get the service UUID.
198
198
199
199
`service.start()` Start the service; it will be visible to any connecting GATTC.
200
200
@@ -223,23 +223,23 @@ In the absence of a callback, then the characteristic value is return for a read
223
223
224
224
`char.notify(<value>)` Send a notify value. `<value>` is `string`, `bytearray`, `bytes` or `None`.
225
225
226
-
`char.uuid` Get the characteristic UUID.
226
+
`char.uuid()` Get the characteristic UUID.
227
227
228
-
`char.value` Get or set the characteristic value.
228
+
`char.value([value])` Get or set the characteristic value.
229
229
230
-
`char.service` Get the parent service.
230
+
`char.service()` Get the parent service.
231
231
232
232
`char.Descr(uuid, value = None, perm = bluetooth.PERM_READ | bluetooth.PERM_WRITE)` Create a new descriptor for a characteristic.
233
233
234
234
`char.descrs` Get the descriptors associated with the characteristic
235
235
236
236
### GATTSDescr objects
237
237
238
-
`descr.uuid` Get the descriptor UUID.
238
+
`descr.uuid()` Get the descriptor UUID.
239
239
240
-
`descr.value` Get or set the value.
240
+
`descr.value([value])` Get or set the value.
241
241
242
-
`descr.char` Get the parent characteristic.
242
+
`descr.char()` Get the parent characteristic.
243
243
244
244
`descr.callback(<callback>, <callback_data>)` See `char.callback()`, above.
245
245
@@ -251,19 +251,19 @@ Use `bluetooth.scan_start()`, to find GATTS devices. You'll need to set up a Bl
251
251
252
252
### GATTCConn objects
253
253
254
-
`conn.services` Returns the services associated with the connection. This is a list of [`GATTCService`](#gattcservice-objects) objects.
254
+
`conn.services()` Returns the services associated with the connection. This is a list of [`GATTCService`](#gattcservice-objects) objects.
255
255
256
-
`conn.is_connected` Returns whether the connection is active or not.
256
+
`conn.is_connected()` Returns whether the connection is active or not.
257
257
258
-
`conn.disconnect()` Disconnect
258
+
`conn.disconnect()` Disconnect
259
259
260
260
### GATTCService objects
261
261
262
-
`service.is_primary` Returns a boolean indicating if the service is a primary service or not.
262
+
`service.is_primary()` Returns a boolean indicating if the service is a primary service or not.
263
263
264
-
`service.uuid` Returns the service UUID
264
+
`service.uuid()` Returns the service UUID
265
265
266
-
`service.chars` Returns a list of [`GATTCChar`](#gattcchar-objects) objects associated with this service
266
+
`service.chars()` Returns a list of [`GATTCChar`](#gattcchar-objects) objects associated with this service
267
267
268
268
### GATTCChar objects
269
269
@@ -277,23 +277,23 @@ When the callback is called, it will be called with 4 parameters:
277
277
3. The value of the notify/indicate
278
278
4. the `<callback_data>`
279
279
280
-
`char.descrs` Returns a list of [`GATTCDescr`](#gattcdescr-objects) associated with this characteristic.
280
+
`char.descrs()` Returns a list of [`GATTCDescr`](#gattcdescr-objects) associated with this characteristic.
281
281
282
282
`char.read()` Read the characteristic value
283
283
284
284
`char.write(<value>)` Write a value to the characteristic. `<value>` can be `str`, `bytearray`, `bytes`, or `None`
285
285
286
286
### GATTCDescr objects
287
287
288
-
`GATTCChar` objects often have associated BLE desriptor objects. These can be obtained by accessing the `char.descrs` property of [`GATTCChar`](#gattcchar-objects) objects.
288
+
`GATTCChar` objects often have associated BLE desriptor objects. These can be obtained by calling `char.descrs()` function of [`GATTCChar`](#gattcchar-objects) objects.
289
289
290
290
`descr.read()` Read from the descriptor.
291
291
292
292
`descr.write(<value>)` Write a value to the characteristic. `<value>` can be `str`, `bytearray`, `bytes`, or `None`
293
293
294
-
`descr.uuid` Get the descriptor UUID.
294
+
`descr.uuid()` Get the descriptor UUID.
295
295
296
-
`descr.char` Get the [`GATTCChar`](#gattcchar-objects) the descriptor is attached to
296
+
`descr.char()` Get the [`GATTCChar`](#gattcchar-objects) the descriptor is attached to
297
297
298
298
## Examples
299
299
@@ -364,20 +364,24 @@ def hr(bda):
364
364
''' Will connect to a BLE heartrate monitor, and enable HR notifications '''
365
365
366
366
conn = b.connect(bda)
367
-
whilenot conn.is_connected:
367
+
whilenot conn.is_connected():
368
368
time.sleep(.1)
369
369
370
+
print ('Connected')
371
+
370
372
time.sleep(2) # Wait for services
371
373
372
-
service = ([s for s in conn.services if s.uuid[0:4] ==b'\x00\x00\x18\x0d'] + [None])[0]
374
+
service = ([s for s in conn.services()if s.uuid()[0:4] ==b'\x00\x00\x18\x0d'] + [None])[0]
373
375
if service:
374
-
char = ([c for c in service.chars if c.uuid[0:4] ==b'\x00\x00\x2a\x37'] + [None])[0]
376
+
char = ([c for c in service.chars()if c.uuid()[0:4] ==b'\x00\x00\x2a\x37'] + [None])[0]
375
377
if char:
376
-
descr = ([d for d in char.descrs if d.uuid[0:4] ==b'\x00\x00\x29\x02'] + [None])[0]
378
+
descr = ([d for d in char.descrs()if d.uuid()[0:4] ==b'\x00\x00\x29\x02'] + [None])[0]
0 commit comments