11
11
* Author(s): Dan Halbert for Adafruit Industries
12
12
13
13
"""
14
+
15
+ from __future__ import annotations
16
+
14
17
import struct
15
18
16
19
from micropython import const
23
26
24
27
from .. import Service
25
28
29
+ try :
30
+ from typing import Dict , Optional
31
+ except ImportError :
32
+ pass
33
+
26
34
__version__ = "0.0.0-auto.0"
27
35
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BLE.git"
28
36
@@ -165,7 +173,15 @@ class ReportIn:
165
173
166
174
uuid = StandardUUID (_REPORT_UUID_NUM )
167
175
168
- def __init__ (self , service , report_id , usage_page , usage , * , max_length ):
176
+ def __init__ (
177
+ self ,
178
+ service : Service ,
179
+ report_id : int ,
180
+ usage_page : bytes ,
181
+ usage : bytes ,
182
+ * ,
183
+ max_length : int ,
184
+ ) -> None :
169
185
self ._characteristic = _bleio .Characteristic .add_to_service (
170
186
service .bleio_service ,
171
187
self .uuid .bleio_uuid ,
@@ -187,7 +203,7 @@ def __init__(self, service, report_id, usage_page, usage, *, max_length):
187
203
initial_value = struct .pack ("<BB" , self ._report_id , _REPORT_TYPE_INPUT ),
188
204
)
189
205
190
- def send_report (self , report ) :
206
+ def send_report (self , report : Dict ) -> None :
191
207
"""Send a report to the peers"""
192
208
self ._characteristic .value = report
193
209
@@ -198,7 +214,15 @@ class ReportOut:
198
214
# pylint: disable=too-few-public-methods
199
215
uuid = StandardUUID (_REPORT_UUID_NUM )
200
216
201
- def __init__ (self , service , report_id , usage_page , usage , * , max_length ):
217
+ def __init__ (
218
+ self ,
219
+ service : Service ,
220
+ report_id : int ,
221
+ usage_page : bytes ,
222
+ usage : bytes ,
223
+ * ,
224
+ max_length : int ,
225
+ ) -> None :
202
226
self ._characteristic = _bleio .Characteristic .add_to_service (
203
227
service .bleio_service ,
204
228
self .uuid .bleio_uuid ,
@@ -225,7 +249,7 @@ def __init__(self, service, report_id, usage_page, usage, *, max_length):
225
249
)
226
250
227
251
@property
228
- def report (self ):
252
+ def report (self ) -> Dict :
229
253
"""The HID OUT report"""
230
254
return self ._characteristic .value
231
255
@@ -320,14 +344,18 @@ class HIDService(Service):
320
344
)
321
345
"""Controls whether the device should be suspended (0) or not (1)."""
322
346
323
- def __init__ (self , hid_descriptor = DEFAULT_HID_DESCRIPTOR , service = None ):
347
+ def __init__ (
348
+ self ,
349
+ hid_descriptor : bytes = DEFAULT_HID_DESCRIPTOR ,
350
+ service : Optional [Service ] = None ,
351
+ ) -> None :
324
352
super ().__init__ (report_map = hid_descriptor )
325
353
if service :
326
354
# TODO: Add support for connecting to a remote hid server.
327
355
pass
328
356
self ._init_devices ()
329
357
330
- def _init_devices (self ):
358
+ def _init_devices (self ) -> None :
331
359
# pylint: disable=too-many-branches,too-many-statements,too-many-locals
332
360
self .devices = []
333
361
hid_descriptor = self .report_map
@@ -389,7 +417,7 @@ def _init_devices(self):
389
417
390
418
i += size
391
419
392
- def get_report_info (collection , reports ) :
420
+ def get_report_info (collection : Dict , reports : Dict ) -> None :
393
421
"""Gets info about hid reports"""
394
422
for main in collection ["mains" ]:
395
423
if "type" in main :
0 commit comments