2121class inspec_sensor :
2222 def __init__ (self ):
2323 print (f'INSPEC { version } ' )
24+ self .error = None
2425 self .config = inspec_config ()
2526 self .configure_sensor ()
2627
@@ -127,11 +128,16 @@ def monitor(self):
127128
128129 if self .comms .sending_image or self .comms .sending_file :
129130 self .comms .process_file ()
130-
131+
132+ if self .error != None and self .comms .send_errors :
133+ self .comms .send_data (f'error:{ self .error } ' )
134+ self .error = None
135+
131136 except Exception as e :
132- print ("Error" , str (e ))
137+ self .error = str (e )
138+ print ("Error" , self .error )
133139 self .led .blink ("R" , 8 )
134- if str ( e ) == "IDE interrupt" :
140+ if self . error == "IDE interrupt" :
135141 break
136142
137143 def ble_message_received (self , message ):
@@ -152,9 +158,12 @@ def ble_message_received(self, message):
152158 if message == "request.ip" and not self .stream == None :
153159 self .comms .send_data (f'ip:{ self .stream .ip } ' )
154160
155- if message == "request.version" and not self . stream == None :
161+ if message == "request.version" :
156162 self .comms .send_data (f'version:{ version } ' )
157163
164+ if message == "request.errors" :
165+ self .comms .send_errors = True
166+
158167 if message .startswith ("update.setting." ):
159168 message = message .replace ("update.setting." , "" )
160169 setting , value = message .split (':' )
@@ -267,7 +276,8 @@ def init_stream(self):
267276 self .stream = inspec_stream ("Station" , self .config .get ('WiFiNetworkName' ), self .config .get ('WiFiKey' ))
268277
269278 except Exception as e :
270- print ("init_stream error: " , str (e ))
279+ self .error = str (e )
280+ print ("init_stream error: " , self .error )
271281 self .stream = None
272282
273283 def send_stream (self ):
0 commit comments