Implement PushButton packet
This commit is contained in:
parent
d18082596c
commit
d92af91893
30
MAXPacket.py
30
MAXPacket.py
@ -1,5 +1,5 @@
|
|||||||
import math
|
import math
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
class MAXPacketFactory:
|
class MAXPacketFactory:
|
||||||
def create_packet(rec: str):
|
def create_packet(rec: str):
|
||||||
@ -16,6 +16,8 @@ class MAXPacketFactory:
|
|||||||
return MAXWakeUpPacket(rec)
|
return MAXWakeUpPacket(rec)
|
||||||
elif pkt_type == 0xF0:
|
elif pkt_type == 0xF0:
|
||||||
return MAXResetPacket(rec)
|
return MAXResetPacket(rec)
|
||||||
|
elif pkt_type == 0x50:
|
||||||
|
return MAXPushButtonPacket(rec)
|
||||||
else:
|
else:
|
||||||
print("Unknown message type: {}".format(pkt_type))
|
print("Unknown message type: {}".format(pkt_type))
|
||||||
result = MAXPacket()
|
result = MAXPacket()
|
||||||
@ -116,6 +118,32 @@ class MAXAckPacket(MAXPacket):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
class PushButtonState(Enum):
|
||||||
|
AUTO = 0
|
||||||
|
ECO = 1
|
||||||
|
UNKNOWN = 2
|
||||||
|
|
||||||
|
|
||||||
|
class MAXPushButtonPacket(MAXPacket):
|
||||||
|
def __init__(self, rec: str):
|
||||||
|
self.from_received(rec)
|
||||||
|
if rec[26:27] == "0":
|
||||||
|
self.button_state = PushButtonState.ECO
|
||||||
|
elif rec[26:27] == "1":
|
||||||
|
self.button_state = PushButtonState.AUTO
|
||||||
|
else:
|
||||||
|
self.button_state = PushButtonState.UNKNOWN
|
||||||
|
if rec[23:24] == "5":
|
||||||
|
self.retransmit = 1
|
||||||
|
else:
|
||||||
|
self.retransmit = 0
|
||||||
|
|
||||||
|
def to_string(self):
|
||||||
|
result = "{}\nMAXPushButtonPacket: button_state={} retransmit={}".format(super().to_string(),
|
||||||
|
self.button_state, self.retransmit)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class MAXWakeUpPacket(MAXPacket):
|
class MAXWakeUpPacket(MAXPacket):
|
||||||
def __init__(self, rec):
|
def __init__(self, rec):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
Loading…
Reference in New Issue
Block a user