forked from Flairmesh/FlooCast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlooMsgSt.py
More file actions
36 lines (32 loc) · 893 Bytes
/
Copy pathFlooMsgSt.py
File metadata and controls
36 lines (32 loc) · 893 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
26
27
28
29
30
31
32
33
34
35
36
from FlooMessage import FlooMessage
class FlooMsgSt(FlooMessage):
"""
BC:ST
ST=xx
xx: 00 Init
01 Idle
02 Pairing
03 Connecting
04 Connected
05 Audio starting
06 Audio streaming
07 Audio stopping
08 Disconnecting
09 Voice staring
0A Voice streaming
0B Voice stopping
"""
HEADER = "ST"
def __init__(self, isSend, state = None):
self.state = state
if state != None:
stateStr = "%02X" % state
super().__init__(isSend, FlooMsgSt.HEADER, bytes(stateStr, 'ascii'))
else:
super().__init__(isSend, FlooMsgSt.HEADER)
@classmethod
def create_valid_msg(cls, payload: bytes):
msgLen = len(payload)
if msgLen != 5:
return None
return cls(False, int(payload[3:5].decode('ascii'), 16))