Removed base 64 encoding
This commit is contained in:
@@ -7,9 +7,9 @@ from services.mqtt_service import MQTTService
|
|||||||
screen = Screen()
|
screen = Screen()
|
||||||
service = MQTTService("127.0.0.1", 1883)
|
service = MQTTService("127.0.0.1", 1883)
|
||||||
|
|
||||||
def publish(uid : int) :
|
def publish(chip_id : int) :
|
||||||
screen.displayMessage(str(uid))
|
screen.displayMessage(str(chip_id))
|
||||||
service.publish("app", "/board-mate/rfid/scan", str(uid), 0)
|
service.publish("app", "/board-mate/rfid/scan", str(chip_id), 0)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
screen.enableBackground()
|
screen.enableBackground()
|
||||||
|
|||||||
@@ -9,16 +9,15 @@ class MQTTService:
|
|||||||
self.address = address
|
self.address = address
|
||||||
self.port = port
|
self.port = port
|
||||||
|
|
||||||
def publish(self, client_id: str, topic: str, message: str, qos: int = 0):
|
def publish(self, client_id: str, topic: str, data: str, qos: int = 0):
|
||||||
client = mqtt.Client(client_id=client_id)
|
client = mqtt.Client(client_id=client_id)
|
||||||
try:
|
try:
|
||||||
client.connect(self.address, self.port)
|
client.connect(self.address, self.port)
|
||||||
client.loop_start()
|
client.loop_start()
|
||||||
data = str(message).encode()
|
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"timestamp": int(time.time()),
|
"timestamp": int(time.time()),
|
||||||
"data": base64.b64encode(data).decode('utf-8')
|
"data": data
|
||||||
}
|
}
|
||||||
result = client.publish(topic, json.dumps(payload), qos=qos)
|
result = client.publish(topic, json.dumps(payload), qos=qos)
|
||||||
result.wait_for_publish()
|
result.wait_for_publish()
|
||||||
|
|||||||
Reference in New Issue
Block a user