proxy forward also other command than p2p
This commit is contained in:
parent
fdb934980d
commit
7cbac37c4d
1 changed files with 14 additions and 9 deletions
|
|
@ -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
|
||||||
|
|
@ -278,7 +279,7 @@ class BumperProxyModeMQTTClient(MQTTClient):
|
||||||
reader = StreamReaderAdapter(conn_reader)
|
reader = StreamReaderAdapter(conn_reader)
|
||||||
writer = StreamWriterAdapter(conn_writer)
|
writer = StreamWriterAdapter(conn_writer)
|
||||||
elif scheme in ('ws', 'wss'):
|
elif scheme in ('ws', 'wss'):
|
||||||
websocket = await websockets.connect(
|
websocket = await websockets.connect(
|
||||||
self.session.broker_uri,
|
self.session.broker_uri,
|
||||||
subprotocols=['mqtt'],
|
subprotocols=['mqtt'],
|
||||||
loop=self._loop,
|
loop=self._loop,
|
||||||
|
|
@ -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
|
||||||
self.ecohelpername = ttopic[3]
|
ttopic = topic.split("/")
|
||||||
ttopic[3] = "proxyhelper"
|
if ttopic[1] == "p2p":
|
||||||
ttopic_comb = "/".join(ttopic)
|
self.ecohelpername = ttopic[3]
|
||||||
proxymodelog.info(f"MQTT Proxy Client - Converted Topic From {message.topic} TO {ttopic_comb}")
|
ttopic[3] = "proxyhelper"
|
||||||
proxymodelog.info(f"MQTT Proxy Client - Proxy Forward Message to Helperbot - Topic: {ttopic_comb} - Message: {msgdata.encode()}")
|
topic = "/".join(ttopic)
|
||||||
|
proxymodelog.info(f"MQTT Proxy Client - Converted Topic From {message.topic} TO {topic}")
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue