@@ -977,6 +977,49 @@ def onAckNak(self, p):
977977 print (f"Received an ACK." )
978978 self .iface ._acknowledgment .receivedAck = True
979979
980+ def sensorConfig (self , command : List = None ):
981+ """Send a sensor configuration command"""
982+ self .ensureSessionKey ()
983+
984+ p = admin_pb2 .AdminMessage ()
985+ if 'scd4x_config' in command [0 ]:
986+ if 'set_asc' in command [0 ]:
987+ if command [1 ] == "true" :
988+ p .sensor_config .scd4x_config .set_asc = True
989+ print ("Setting SCD4X ASC mode" )
990+ elif command [1 ] == "false" :
991+ p .sensor_config .scd4x_config .set_asc = False
992+ print ("Setting SCD4X FRC mode" )
993+ else :
994+ print (
995+ f'Not valid argument for sensor_config.scd4x.set_asc'
996+ )
997+ elif 'set_temperature' in command [0 ]:
998+ try :
999+ temperature = float (command [1 ])
1000+ except ValueError :
1001+ print (
1002+ f'Invalid value for reference temperature'
1003+ )
1004+ return
1005+ else :
1006+ print (f"Setting SCD4X Reference temperature to { temperature } " )
1007+ p .sensor_config .scd4x_config .set_temperature = temperature
1008+ elif 'factory_reset' in command [0 ]:
1009+ print ("Performing factory reset on SCD4X" )
1010+ p .sensor_config .scd4x_config .factory_reset = True
1011+ # TODO - add the rest?
1012+
1013+ elif 'sen5x_config' in command [0 ]:
1014+ raise NotImplementedError ("Not implemented" )
1015+
1016+ # How to represent a HANDLED event?
1017+ if self == self .iface .localNode :
1018+ onResponse = None
1019+ else :
1020+ onResponse = self .onAckNak
1021+ return self ._sendAdmin (p , onResponse = onResponse )
1022+
9801023 def _requestChannel (self , channelNum : int ):
9811024 """Done with initial config messages, now send regular
9821025 MeshPackets to ask for settings"""
0 commit comments