proxy forward also other command than p2p

This commit is contained in:
Robert Resch 2021-05-21 13:46:05 +02:00
parent fdb934980d
commit 7cbac37c4d
No known key found for this signature in database
GPG key ID: 6B360759EB2ACAEE

View file

@ -4,8 +4,9 @@ import logging
import asyncio import asyncio
import os import os
import hbmqtt import hbmqtt
import websockets
from hbmqtt.broker import Broker from hbmqtt.broker import Broker
from hbmqtt.client import MQTTClient from hbmqtt.client import MQTTClient, ConnectException
from hbmqtt.mqtt.constants import QOS_0, QOS_1, QOS_2 from hbmqtt.mqtt.constants import QOS_0, QOS_1, QOS_2
import pkg_resources import pkg_resources
import time import time
@ -322,14 +323,18 @@ class BumperProxyModeMQTTClient(MQTTClient):
msgdata = str(message.data.decode("utf-8")) msgdata = str(message.data.decode("utf-8"))
proxymodelog.info(f"MQTT Proxy Client - Message Received From Ecovacs - Topic: {message.topic} - Message: {msgdata}") proxymodelog.info(f"MQTT Proxy Client - Message Received From Ecovacs - Topic: {message.topic} - Message: {msgdata}")
ttopic = message.topic.split("/") topic = message.topic
ttopic = topic.split("/")
if ttopic[1] == "p2p":
self.ecohelpername = ttopic[3] self.ecohelpername = ttopic[3]
ttopic[3] = "proxyhelper" ttopic[3] = "proxyhelper"
ttopic_comb = "/".join(ttopic) topic = "/".join(ttopic)
proxymodelog.info(f"MQTT Proxy Client - Converted Topic From {message.topic} TO {ttopic_comb}") proxymodelog.info(f"MQTT Proxy Client - Converted Topic From {message.topic} TO {topic}")
proxymodelog.info(f"MQTT Proxy Client - Proxy Forward Message to Helperbot - Topic: {ttopic_comb} - Message: {msgdata.encode()}")
proxymodelog.info(
f"MQTT Proxy Client - Proxy Forward Message to Robot - Topic: {topic} - Message: {msgdata.encode()}")
await bumper.mqtt_helperbot.Client.publish( await bumper.mqtt_helperbot.Client.publish(
ttopic_comb, msgdata.encode(), QOS_0 topic, msgdata.encode(), QOS_0
) )
except Exception as e: except Exception as e: