콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3658 화면


based on below code am fetching uid data from RFID tag(Hardware Device) through mqtt broker but it is not storing in database
import paho.mqtt.client as mqtt
class iot(models.Model):
_name = 'iot.iot'
name = fields.Char()
uid=fields.Char()
global mqttc

mqttc = mqtt.Client("python_pub")
mqttc.connect("172.16.73.4", 1883)
mqttc.publish("light", "light subscribed")
print "mqtt"


def on_message(client, userdata, message):
print("message received ", str(message.payload.decode("utf-8")))
global uid
uid=str(message.payload.decode("utf-8"))

mqttc.on_message = on_message
mqttc.loop_start()
mqttc.subscribe("sub")

In on_message method self object not available so give me suggestion how to store uid data in database
아바타
취소