From 786d135cbbdd1d1ec02a22cac66ea366034dcced Mon Sep 17 00:00:00 2001 From: David Rapan Date: Sun, 22 Dec 2024 15:38:02 +0100 Subject: [PATCH] feat: Add V5_DATA and V5_WIFI handling for server mode --- pysolarmanv5/pysolarmanv5.py | 10 +++++++++- pysolarmanv5/pysolarmanv5_async.py | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pysolarmanv5/pysolarmanv5.py b/pysolarmanv5/pysolarmanv5.py index 67f904f..d606c9d 100644 --- a/pysolarmanv5/pysolarmanv5.py +++ b/pysolarmanv5/pysolarmanv5.py @@ -342,7 +342,15 @@ def _handle_protocol_frame(self, frame): self.log.debug("[%s] V5_HANDSHAKE: %s", self.serial, frame.hex(" ")) response_frame = self._v5_time_response_frame(frame) self.log.debug("[%s] V5_HANDSHAKE RESP: %s", self.serial, response_frame.hex(" ")) - if frame.startswith(self.v5_start + b"\x01\x00\x10\x47"): + if frame[4] == 0x42: + self.log.debug("[%s] V5_DATA: %s", self.serial, frame.hex(" ")) + response_frame = self._v5_time_response_frame(frame) + self.log.debug("[%s] V5_DATA RESP: %s", self.serial, response_frame.hex(" ")) + if frame[4] == 0x43: + self.log.debug("[%s] V5_WIFI: %s", self.serial, frame.hex(" ")) + response_frame = self._v5_time_response_frame(frame) + self.log.debug("[%s] V5_WIFI RESP: %s", self.serial, response_frame.hex(" ")) + if frame[4] == 0x47: self.log.debug("[%s] V5_HEARTBEAT: %s", self.serial, frame.hex(" ")) response_frame = self._v5_time_response_frame(frame) self.log.debug("[%s] V5_HEARTBEAT RESP: %s", self.serial, response_frame.hex(" ")) diff --git a/pysolarmanv5/pysolarmanv5_async.py b/pysolarmanv5/pysolarmanv5_async.py index b0d137b..fe379de 100644 --- a/pysolarmanv5/pysolarmanv5_async.py +++ b/pysolarmanv5/pysolarmanv5_async.py @@ -171,7 +171,15 @@ async def _handle_protocol_frame(self, frame): self.log.debug("[%s] V5_HANDSHAKE: %s", self.serial, frame.hex(" ")) response_frame = self._v5_time_response_frame(frame) self.log.debug("[%s] V5_HANDSHAKE RESP: %s", self.serial, response_frame.hex(" ")) - if frame.startswith(self.v5_start + b"\x01\x00\x10\x47"): + if frame[4] == 0x42: + self.log.debug("[%s] V5_DATA: %s", self.serial, frame.hex(" ")) + response_frame = self._v5_time_response_frame(frame) + self.log.debug("[%s] V5_DATA RESP: %s", self.serial, response_frame.hex(" ")) + if frame[4] == 0x43: + self.log.debug("[%s] V5_WIFI: %s", self.serial, frame.hex(" ")) + response_frame = self._v5_time_response_frame(frame) + self.log.debug("[%s] V5_WIFI RESP: %s", self.serial, response_frame.hex(" ")) + if frame[4] == 0x47: self.log.debug("[%s] V5_HEARTBEAT: %s", self.serial, frame.hex(" ")) response_frame = self._v5_time_response_frame(frame) self.log.debug("[%s] V5_HEARTBEAT RESP: %s", self.serial, response_frame.hex(" "))