@@ -57,7 +57,7 @@ class UARTClient:
57
57
uart_client.write('abc')
58
58
"""
59
59
60
- def __init__ (self , * , timeout = 5 .0 , buffer_size = 64 ):
60
+ def __init__ (self , * , timeout = 1 .0 , buffer_size = 64 ):
61
61
self ._buffer_size = buffer_size
62
62
self ._timeout = timeout
63
63
self ._read_char = self ._write_char = self ._read_buffer = None
@@ -67,7 +67,8 @@ def connect(self, address, timeout):
67
67
"""Try to connect to the peripheral at the given address.
68
68
69
69
:param bleio.Address address: The address of the peripheral to connect to
70
- :param float/int timeout: Try to connect for timeout seconds.
70
+ :param float/int timeout: Try to connect for ``timeout`` seconds.
71
+ Not related to the timeout passed to ``UARTClient()``.
71
72
"""
72
73
self ._central .connect (address , timeout , service_uuids = (NUS_SERVICE_UUID ,))
73
74
@@ -83,10 +84,14 @@ def connect(self, address, timeout):
83
84
self ._read_char = characteristic
84
85
if not self ._write_char or not self ._read_char :
85
86
raise OSError ("Remote UART missing needed characteristic" )
87
+
88
+ # Enable notifications from the server (the peripheral).
89
+ self ._read_char .set_cccd (notify = True )
86
90
self ._read_buffer = CharacteristicBuffer (self ._read_char ,
87
91
timeout = self ._timeout ,
88
92
buffer_size = self ._buffer_size )
89
93
94
+
90
95
def disconnect (self ):
91
96
"""Disconnect from the peripheral."""
92
97
self ._central .disconnect ()
0 commit comments