-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlooMsgPl.py
More file actions
25 lines (21 loc) · 712 Bytes
/
FlooMsgPl.py
File metadata and controls
25 lines (21 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from FlooMessage import FlooMessage
class FlooMsgPl(FlooMessage):
"""
BC:PL
PL=index(U8),addr(U48),name(str)
"""
HEADER = "PL"
def __init__(self, isSend, index = None, addr = None, name = None, payload = None):
self.index = index
self.addr = addr
self.name = name
if isSend:
super().__init__(isSend, FlooMsgPl.HEADER)
else:
super().__init__(isSend, FlooMsgPl.HEADER, payload)
@classmethod
def create_valid_msg(cls, payload: bytes):
msgLen = len(payload)
if msgLen < 20:
return None
return cls(False, int(payload[3:5].decode('utf-8')), payload[6:18], payload[19:], payload[3:])