<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def connect(self):
 """Connect to MQTT server and wait for server to acknowledge"""

        if not self.connect_attempted:
            self.connect_attempted = True
            self.client.connect(self.host, port=self.port)
            self.client.loop_start()

            while not self.connected:
                log.info('waiting for MQTT connection...')
                time.sleep(1)