29
29
from adafruit_ble .uuid import VendorUUID
30
30
from adafruit_ble .characteristics import Characteristic , ComplexCharacteristic
31
31
32
+ try :
33
+ from typing import Optional , Tuple
34
+ except ImportError :
35
+ pass
36
+
32
37
__version__ = "0.0.0-auto.0"
33
38
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_BLE_LYWSD03MMC.git"
34
39
@@ -38,10 +43,10 @@ class _Readings(ComplexCharacteristic):
38
43
39
44
uuid = VendorUUID ("ebe0ccc1-7a0a-4b0c-8a1a-6ff2997da3a6" )
40
45
41
- def __init__ (self ):
46
+ def __init__ (self ) -> None :
42
47
super ().__init__ (properties = Characteristic .NOTIFY )
43
48
44
- def bind (self , service ) :
49
+ def bind (self , service : "LYWSD03MMCService" ) -> _bleio . PacketBuffer :
45
50
"""Bind to an LYWSD03MMCService."""
46
51
bound_characteristic = super ().bind (service )
47
52
bound_characteristic .set_cccd (notify = True )
@@ -52,7 +57,7 @@ def bind(self, service):
52
57
class LYWSD03MMCService (Service ):
53
58
"""Service for reading from an LYWSD03MMC sensor."""
54
59
55
- def __init__ (self , service = None ):
60
+ def __init__ (self , service : Optional [ "LYWSD03MMCService" ] = None ) -> None :
56
61
super ().__init__ (service = service )
57
62
# Defer creating buffers until needed, since MTU is not known yet.
58
63
self ._settings_result_buf = None
@@ -63,7 +68,7 @@ def __init__(self, service=None):
63
68
readings = _Readings ()
64
69
65
70
@property
66
- def temperature_humidity (self ):
71
+ def temperature_humidity (self ) -> Optional [ Tuple [ float , int ]] :
67
72
"""Return a tuple of (temperature, humidity)."""
68
73
if self ._readings_buf is None :
69
74
self ._readings_buf = bytearray (self .readings .incoming_packet_length )
0 commit comments