Пример #1
0
 def do_cloud_connect(self):
     log.Ilog("do_cloud_connect");
     self.set_cloud_connect_attempt_state(True);
     self.cloud_cli = mqtt.Client(self.app.config[self.app.app_name]['mqtt']['cloud_mqtt_client_id'],True);
     self.cloud_cli.user_data_set("cloud")
     self.cloud_cli.on_connect = self.cloud_on_connect;
     self.cloud_cli.on_message = self.cloud_on_message;
     self.cloud_cli.on_disconnect = self.cloud_on_disconnect
     self.cloud_cli.connect(self.app.config[self.app.app_name]['mqtt']['cloud_mqtt_host'],self.app.config[self.app.app_name]['mqtt']['cloud_mqtt_port'],self.app.config[self.app.app_name]['mqtt']['cloud_mqtt_keepalive'])
     self.cloud_cli.loop_start()
Пример #2
0
    def __init__(self):
        log.Ilog("mqtt_cli Singleton __init__");
        self.app= GW_APP();


        ###############
        # auto connect#
        ###############


        self.local_auto_connect = self.app.config[self.app.app_name]['mqtt']['local_mqtt_auto_connect']
        self.cloud_auto_connect = self.app.config[self.app.app_name]['mqtt']['cloud_mqtt_auto_connect']
        if self.local_auto_connect is True: self.do_local_connect();
        if self.cloud_auto_connect is True: self.do_cloud_connect();
Пример #3
0
 def __init__(self,app_name=None,config_file_path=None):
     log.Ilog("GW_APP Singleton instace __init__");
     self.app_name =app_name
     self.config = config(config_file_path=config_file_path);
Пример #4
0
 def local_on_message(self,client, userdata, msg):
     log.Ilog("local_on_message");
Пример #5
0
 def local_on_connect(self,client, userdata, flags, rc):
     log.Ilog("local_on_connect");
     self.set_local_connect_state(True);
Пример #6
0
 def set_cloud_connect_state(self,state):
     log.Ilog("set_cloud_connect_state")
     self.__cloud_mqtt_connect_state=state
Пример #7
0
 def set_local_connect_state(self,state):
     log.Ilog("set_local_connect_state")
     self.__local_mqtt_connect_state =state;
Пример #8
0
 def cloud_on_disconnect(self, _, __, ___):
     log.Ilog("cloud_on_disconnect")
     self.set_cloud_connect_state(False)
Пример #9
0
    def cloud_on_message(self,client, userdata, msg):
        log.Ilog("cloud_on_message")

        topic = str(msg.topic).split('/');

        stre = str(msg.topic)+"               "+str(msg.payload);
Пример #10
0
 def cloud_on_connect(self,client, userdata, flags, rc):
     log.Ilog("cloud_on_connect")
     self.set_cloud_connect_state(True)
Пример #11
0
 def local_on_disconnect(self, _, __, ___):
     log.Ilog("local_on_disconnect");
     self.set_local_connect_state(False);