Esempio n. 1
0
    def mqtt_client(self, mqtt, config_list):
        """mqtt_client function. This function includes the main looping for incoming messages.
        Args:
            param1 (Cn2Mqtt): The mqtt object instance
            param1 (list): A list containing extracted data from the XML

        """
        # After entering active mode, the client subscribes to the necessary topics.
        #self.active_connections(mqtt,config_list)
        #gc.collect()
        #print("Memory after all subscriptions:")
        #print(gc.mem_free())

        # Infinite loop. The program stands by for any incomming message.
        while True:
            gc.collect()
            # Call of standby_loop, to set the program waiting for a new message.
            # mqtt.standby_loop()
            #print(mqtt.r_topic + ": " + mqtt.r_message)
            measurements = Sensors()
            measurements.get_fire_status()
            time.sleep(0.05)
            measurements.get_temp_hum_status()
            time.sleep(10)