10
10
This module provides Services used by MicroChip
11
11
12
12
"""
13
-
14
13
from adafruit_ble import Service
15
14
from adafruit_ble .uuid import VendorUUID
16
15
from adafruit_ble .characteristics .stream import StreamOut , StreamIn
17
16
17
+ try :
18
+ from typing import Union
19
+ except ImportError :
20
+ pass
21
+
18
22
__version__ = "0.0.0-auto.0"
19
23
__repo__ = (
20
24
"https://github.com/adafruit/Adafruit_CircuitPython_BLE_Contec_Pulse_Oximeter.git"
@@ -44,7 +48,7 @@ class TransparentUARTService(Service):
44
48
buffer_size = 64 ,
45
49
)
46
50
47
- def __init__ (self , service = None ):
51
+ def __init__ (self , service : Union [ Service , None ] = None ):
48
52
super ().__init__ (service = service )
49
53
self .connectable = True
50
54
if not service :
@@ -55,7 +59,7 @@ def __init__(self, service=None):
55
59
self ._tx = self ._server_rx
56
60
self ._rx = self ._server_tx
57
61
58
- def read (self , nbytes = None ):
62
+ def read (self , nbytes : Union [ bytes , None ] = None ) -> Union [ bytes , None ] :
59
63
"""
60
64
Read characters. If ``nbytes`` is specified then read at most that many bytes.
61
65
Otherwise, read everything that arrives until the connection times out.
@@ -66,7 +70,9 @@ def read(self, nbytes=None):
66
70
"""
67
71
return self ._rx .read (nbytes )
68
72
69
- def readinto (self , buf , nbytes = None ):
73
+ def readinto (
74
+ self , buf : bytes , nbytes : Union [bytes , None ] = None
75
+ ) -> Union [int , None ]:
70
76
"""
71
77
Read bytes into the ``buf``. If ``nbytes`` is specified then read at most
72
78
that many bytes. Otherwise, read at most ``len(buf)`` bytes.
@@ -76,7 +82,7 @@ def readinto(self, buf, nbytes=None):
76
82
"""
77
83
return self ._rx .readinto (buf , nbytes )
78
84
79
- def readline (self ):
85
+ def readline (self ) -> Union [ int , None ] :
80
86
"""
81
87
Read a line, ending in a newline character.
82
88
@@ -86,14 +92,14 @@ def readline(self):
86
92
return self ._rx .readline ()
87
93
88
94
@property
89
- def in_waiting (self ):
95
+ def in_waiting (self ) -> int :
90
96
"""The number of bytes in the input buffer, available to be read."""
91
97
return self ._rx .in_waiting
92
98
93
- def reset_input_buffer (self ):
99
+ def reset_input_buffer (self ) -> None :
94
100
"""Discard any unread characters in the input buffer."""
95
101
self ._rx .reset_input_buffer ()
96
102
97
- def write (self , buf ) :
103
+ def write (self , buf : bytes ) -> None :
98
104
"""Write a buffer of bytes."""
99
105
self ._tx .write (buf )
0 commit comments