# -*- coding: utf-8 -*- ######################################################################## #audio setup ######################################################################## import json import os.path from os import path import pygame import os from gtts import gTTS import threading from MqttClient import MQTTClient Mqtt = MQTTClient() Mqtt.MqttPathPublish = "your path to publish" Mqtt.MqttPathSubcribe = "AudioPlay" class myThread(threading.Thread): def __init__(self, threadID, name): threading.Thread.__init__(self) self.threadID = threadID self.name = name def run(self): Mqtt.mqttSubcribe() queueLock = threading.Lock()
from MqttClient import MQTTClient import json Mqtt = MQTTClient() _dataWriteAudioPlay = {"source": "APIGetPost", "func": "play", "data": ""} _dataWriteAudioPlay["data"] = "truongtrinhdakhoidongxong" Mqtt.MqttPathPublish = "AudioPlay" Mqtt.mqttPublish(json.dumps(_dataWriteAudioPlay)) print "test"
# -*- coding: utf8 -*- ######################################################################## #API face detect setup ######################################################################## import json import requests import base64 from datetime import datetime from ftplib import FTP import time import os import threading from MqttClient import MQTTClient Mqtt = MQTTClient() Mqtt.MqttPathPublish = "your path to publish" Mqtt.MqttPathSubcribe = "APIGetPost" def getDataMqtt(): __waitData = Mqtt.getData() if (__waitData != None): try: _waitData = json.loads(__waitData) return _waitData except ValueError as e: print "error: ", str(e) return False else: return False
#!/usr/bin/python # -*- coding: utf8 -*- #!/bin/bash import threading from MqttClient import MQTTClient Mqtt = MQTTClient() Mqtt.MqttPathPublish = "MainApp" Mqtt.MqttPathSubcribe = "MainApp" class myThread (threading.Thread): def __init__(self, threadID, name): threading.Thread.__init__(self) self.threadID = threadID self.name = name def run(self): Mqtt.mqttSubcribe() queueLock = threading.Lock() thread = myThread(1, "thread1") thread.start() _dataWriteAPIGetPost = {"source":"MainApp","func":"capture","data":{"ID":"","base64image":""}}
#!/usr/bin/python # -*- coding: utf8 -*- ######################################################################## #IdCardReader setup ######################################################################## import json import os import time import urllib2 import threading from MqttClient import MQTTClient Mqtt = MQTTClient() Mqtt.MqttPathPublish = "your path to publish" Mqtt.MqttPathSubcribe = "WifiStatus" class myThread (threading.Thread): def __init__(self, threadID, name): threading.Thread.__init__(self) self.threadID = threadID self.name = name def run(self): Mqtt.mqttSubcribe() # queueLock = threading.Lock() # thread = myThread(1, "thread1") # thread.start() #########################################################################
import threading from MqttClient import MQTTClient Mqtt = MQTTClient() Mqtt.MqttPathPublish = "killer" class myThread (threading.Thread): def __init__(self, threadID, name): threading.Thread.__init__(self) self.threadID = threadID self.name = name def run(self): Mqtt.mqttSubcribe() queueLock = threading.Lock() thread = myThread(1, "thread1") thread.start() print Mqtt.MqttServer,Mqtt.MqttPort while True: t = Mqtt.getData() if t != None: print "client get: ", t Mqtt.mqttPublish("killer")