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:
- CRM
- e-Commerce
- Kế toán
- Tồn kho
- PoS
- Project
- MRP
Câu hỏi này đã bị gắn cờ
3645
Lượt xem
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng ký