Skip to content

Commit

Permalink
디버그용 패킷 전송 코드 정리
Browse files Browse the repository at this point in the history
  • Loading branch information
n-andflash committed Jul 10, 2024
1 parent 54dde02 commit d67ed00
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions sds_wallpad/sds_wallpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,18 +711,26 @@ def mqtt_virtual(topics, payload):


def mqtt_debug(topics, payload):
device = topics[2]
group = topics[2]
command = topics[3]

if (device == "packet"):
if (group == "packet"):
if (command == "send"):
try:
packet = bytearray.fromhex(payload)
except Exception as e:
logger.warning(" failed to convert: {}".format(payload))
return

# parity는 여기서 재생성
packet = bytearray.fromhex(payload)
packet[-1] = serial_generate_checksum(packet)
packet = bytes(packet)

logger.info("prepare packet: {}".format(packet.hex()))
serial_queue[packet] = time.time()
return

logger.warning(" unknown debug topic: {}".format(topics))


def mqtt_device(topics, payload):
Expand Down Expand Up @@ -816,10 +824,16 @@ def mqtt_on_connect(mqtt, userdata, flags, rc):
mqtt.subscribe(topic, 0)

prefix = Options["mqtt"]["prefix"]

topic = "{}/debug/#".format(prefix)
logger.info("subscribe {}".format(topic))
mqtt.subscribe(topic, 0)

if Options["entrance_mode"] != "off" or Options["intercom_mode"] != "off":
topic = "{}/virtual/+/+/command".format(prefix)
logger.info("subscribe {}".format(topic))
mqtt.subscribe(topic, 0)

if Options["wallpad_mode"] != "off":
topic = "{}/+/+/+/command".format(prefix)
logger.info("subscribe {}".format(topic))
Expand Down

0 comments on commit d67ed00

Please sign in to comment.