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
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- 客户关系管理
- e-Commerce
- 会计
- 库存
- PoS
- Project
- MRP
此问题已终结
3632
查看