İçereği Atla
Menü
Bu soru işaretlendi
3641 Görünümler


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
Avatar
Vazgeç