Removed base 64 encoding
This commit is contained in:
@@ -9,16 +9,15 @@ class MQTTService:
|
||||
self.address = address
|
||||
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)
|
||||
try:
|
||||
client.connect(self.address, self.port)
|
||||
client.loop_start()
|
||||
data = str(message).encode()
|
||||
|
||||
payload = {
|
||||
"timestamp": int(time.time()),
|
||||
"data": base64.b64encode(data).decode('utf-8')
|
||||
"data": data
|
||||
}
|
||||
result = client.publish(topic, json.dumps(payload), qos=qos)
|
||||
result.wait_for_publish()
|
||||
|
||||
Reference in New Issue
Block a user