Add files via upload

This commit is contained in:
LukeSpad 2022-02-13 19:37:06 +00:00 committed by GitHub
parent 717bb641ac
commit 82b2ae560a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 33 deletions

View file

@ -143,6 +143,7 @@ beo4_commanddict = OrderedDict(
(0xDA, "Cinema_On"), (0xDA, "Cinema_On"),
(0xDB, "Cinema_Off"), (0xDB, "Cinema_Off"),
# Other controls: # Other controls:
(0x7C, "Status"), #??? 0x5D ???
(0xF7, "Stand"), (0xF7, "Stand"),
(0x0A, "Clear"), (0x0A, "Clear"),
(0x0B, "Store"), (0x0B, "Store"),
@ -344,6 +345,7 @@ beoremoteone_keydict = OrderedDict(
(0xDA, "Cinema_On"), (0xDA, "Cinema_On"),
(0xDB, "Cinema_Off"), (0xDB, "Cinema_Off"),
# Other controls: # Other controls:
(0x7C, "Status"), #??? 0x5D ???
(0xF7, "Stand"), (0xF7, "Stand"),
(0x0A, "Clear"), (0x0A, "Clear"),
(0x0B, "Store"), (0x0B, "Store"),
@ -575,17 +577,6 @@ ml_trackinfo_subtype_dict = dict([(0x05, "Current Source"), (0x07, "Change Sourc
ml_sourcekind_dict = dict([(0x01, "audio source"), (0x02, "video source"), (0xFF, "undefined")]) ml_sourcekind_dict = dict([(0x01, "audio source"), (0x02, "video source"), (0xFF, "undefined")])
ml_selectedsource_type_dict = dict(
[
("VIDEO", (0x0B, 0x1F)),
("VIDEO_PAUSABLE", (0x15, 0x16, 0x29, 0x33)),
("AUDIO", (0x6F, 0x97)),
("AUDIO_PAUSABLE", (0x8D, 0x79, 0x7A, 0xA1, 0x8D)),
("ALL", (0xFE, 0xFF)),
("OTHER", (0x47, 0x3E)),
]
)
# ######################################################################################## # ########################################################################################
# ##### MLGW Protocol packet constants # ##### MLGW Protocol packet constants
mlgw_payloadtypedict = dict( mlgw_payloadtypedict = dict(

View file

@ -178,13 +178,6 @@ class MLCLIClient(asynchat.async_chat):
result = self._hexbyte(s) result = self._hexbyte(s)
return str(result) return str(result)
@staticmethod
def _get_type(d, s):
rev_dict = {value: key for key, value in d.items()}
for i in range(len(list(rev_dict))):
if s in list(rev_dict)[i]:
return rev_dict.get(list(rev_dict)[i])
# ######################################################################################## # ########################################################################################
# ##### Decode Masterlink Protocol packet to a serializable dict # ##### Decode Masterlink Protocol packet to a serializable dict
def _decode(self, telegram): def _decode(self, telegram):
@ -256,7 +249,7 @@ class MLCLIClient(asynchat.async_chat):
[ [
("source", source), ("source", source),
("sourceID", telegram[10]), ("sourceID", telegram[10]),
("source_type", self._get_type(CONST.ml_selectedsource_type_dict, telegram[10])), ("source_type", self._get_source_type(source)),
("command", self._dictsanitize(CONST.beo4_commanddict, telegram[11])) ("command", self._dictsanitize(CONST.beo4_commanddict, telegram[11]))
] ]
) )
@ -264,13 +257,13 @@ class MLCLIClient(asynchat.async_chat):
# audio track info long # audio track info long
if message.get("payload_type") == "TRACK_INFO_LONG": if message.get("payload_type") == "TRACK_INFO_LONG":
message["State_Update"]["nowPlaying"] = 'Unknown' message["State_Update"]["nowPlaying"] = 'Unknown'
source = self._dictsanitize(CONST.ml_selectedsourcedict, telegram[11])
message["State_Update"]["nowPlayingDetails"] = OrderedDict( message["State_Update"]["nowPlayingDetails"] = OrderedDict(
[ [
("type", self._get_type(CONST.ml_selectedsource_type_dict, telegram[11])), ("type", self._get_source_type(source)),
("channel_track", telegram[12]), ("channel_track", telegram[12]),
] ]
) )
source = self._dictsanitize(CONST.ml_selectedsourcedict, telegram[11])
self._get_source_name(source, message) self._get_source_name(source, message)
message["State_Update"]["source"] = source message["State_Update"]["source"] = source
message["State_Update"]["sourceID"] = telegram[11] message["State_Update"]["sourceID"] = telegram[11]
@ -280,13 +273,13 @@ class MLCLIClient(asynchat.async_chat):
# video track info # video track info
if message.get("payload_type") == "VIDEO_TRACK_INFO": if message.get("payload_type") == "VIDEO_TRACK_INFO":
message["State_Update"]["nowPlaying"] = 'Unknown' message["State_Update"]["nowPlaying"] = 'Unknown'
source = self._dictsanitize(CONST.ml_selectedsourcedict, telegram[13])
message["State_Update"]["nowPlayingDetails"] = OrderedDict( message["State_Update"]["nowPlayingDetails"] = OrderedDict(
[ [
("source_type", self._get_type(CONST.ml_selectedsource_type_dict, telegram[13])), ("source_type", self._get_source_type(source)),
("channel_track", telegram[11] * 256 + telegram[12]) ("channel_track", telegram[11] * 256 + telegram[12])
] ]
) )
source = self._dictsanitize(CONST.ml_selectedsourcedict, telegram[13])
self._get_source_name(source, message) self._get_source_name(source, message)
message["State_Update"]["source"] = source message["State_Update"]["source"] = source
message["State_Update"]["sourceID"] = telegram[13] message["State_Update"]["sourceID"] = telegram[13]
@ -299,10 +292,10 @@ class MLCLIClient(asynchat.async_chat):
# Change source # Change source
if message["State_Update"].get("subtype") == "Change Source": if message["State_Update"].get("subtype") == "Change Source":
message["State_Update"]["prev_source"] = self._dictsanitize(CONST.ml_selectedsourcedict, telegram[11]) prev_source = self._dictsanitize(CONST.ml_selectedsourcedict, telegram[11])
message["State_Update"]["prev_source"] = prev_source
message["State_Update"]["prev_sourceID"] = telegram[11] message["State_Update"]["prev_sourceID"] = telegram[11]
message["State_Update"]["prev_source_type"] = self._get_type( message["State_Update"]["prev_source_type"] = self._get_source_type(prev_source)
CONST.ml_selectedsource_type_dict, telegram[11])
if len(telegram) > 18: if len(telegram) > 18:
source = self._dictsanitize(CONST.ml_selectedsourcedict, telegram[22]) source = self._dictsanitize(CONST.ml_selectedsourcedict, telegram[22])
self._get_source_name(source, message) self._get_source_name(source, message)
@ -315,7 +308,7 @@ class MLCLIClient(asynchat.async_chat):
self._get_source_name(source, message) self._get_source_name(source, message)
message["State_Update"]["source"] = source message["State_Update"]["source"] = source
message["State_Update"]["sourceID"] = telegram[11] message["State_Update"]["sourceID"] = telegram[11]
message["State_Update"]["source_type"] = self._get_type(CONST.ml_selectedsource_type_dict, telegram[11]) message["State_Update"]["source_type"] = self._get_source_type(source)
message["State_Update"]["state"] = 'Unknown' message["State_Update"]["state"] = 'Unknown'
else: else:
message["State_Update"]["subtype"] = "Undefined: " + self._hexbyte(telegram[9]) message["State_Update"]["subtype"] = "Undefined: " + self._hexbyte(telegram[9])
@ -323,13 +316,13 @@ class MLCLIClient(asynchat.async_chat):
# goto source # goto source
if message.get("payload_type") == "GOTO_SOURCE": if message.get("payload_type") == "GOTO_SOURCE":
message["State_Update"]["nowPlaying"] = 'Unknown' message["State_Update"]["nowPlaying"] = 'Unknown'
source = self._dictsanitize(CONST.ml_selectedsourcedict, telegram[11])
message["State_Update"]["nowPlayingDetails"] = OrderedDict( message["State_Update"]["nowPlayingDetails"] = OrderedDict(
[ [
("source_type", self._get_type(CONST.ml_selectedsource_type_dict, telegram[11])), ("source_type", self._get_source_type(source)),
("channel_track", telegram[12]) ("channel_track", telegram[12])
] ]
) )
source = self._dictsanitize(CONST.ml_selectedsourcedict, telegram[11])
self._get_source_name(source, message) self._get_source_name(source, message)
message["State_Update"]["source"] = source message["State_Update"]["source"] = source
message["State_Update"]["sourceID"] = telegram[11] message["State_Update"]["sourceID"] = telegram[11]
@ -356,7 +349,7 @@ class MLCLIClient(asynchat.async_chat):
self._get_source_name(source, message) self._get_source_name(source, message)
message["State_Update"]["source"] = source message["State_Update"]["source"] = source
message["State_Update"]["sourceID"] = telegram[13] message["State_Update"]["sourceID"] = telegram[13]
message["State_Update"]["source_type"] = self._get_type(CONST.ml_selectedsource_type_dict, telegram[13]) message["State_Update"]["source_type"] = self._get_source_type(source)
# request local audio source # request local audio source
if message.get("payload_type") == "REQUEST_LOCAL_SOURCE": if message.get("payload_type") == "REQUEST_LOCAL_SOURCE":
@ -366,7 +359,7 @@ class MLCLIClient(asynchat.async_chat):
self._get_source_name(source, message) self._get_source_name(source, message)
message["State_Update"]["source"] = source message["State_Update"]["source"] = source
message["State_Update"]["sourceID"] = telegram[11] message["State_Update"]["sourceID"] = telegram[11]
message["State_Update"]["source_type"] = self._get_type(CONST.ml_selectedsource_type_dict, telegram[11]) message["State_Update"]["source_type"] = self._get_source_type(source)
# request local audio source # request local audio source
if message.get("payload_type") == "PICTURE_AND_SOUND_STATUS": if message.get("payload_type") == "PICTURE_AND_SOUND_STATUS":
@ -382,7 +375,7 @@ class MLCLIClient(asynchat.async_chat):
message['State_Update']['source'] = 'Unknown' message['State_Update']['source'] = 'Unknown'
message['State_Update']['sourceName'] = 'Unknown' message['State_Update']['sourceName'] = 'Unknown'
message["State_Update"]["state"] = 'Unknown' message["State_Update"]["state"] = 'Unknown'
message["volume"] = int(telegram[12]) message["State_Update"]["volume"] = int(telegram[12])
return message return message
@ -460,3 +453,12 @@ class MLCLIClient(asynchat.async_chat):
return return
# If source list exhausted then return Unknown # If source list exhausted then return Unknown
message["State_Update"]["sourceName"] = 'Unknown' message["State_Update"]["sourceName"] = 'Unknown'
@staticmethod
def _get_source_type(source):
if source in CONST.source_type_dict.get('Audio Sources'):
return "AUDIO"
elif source in CONST.source_type_dict.get('Video Sources'):
return "VIDEO"
else:
return "OTHER"

View file

@ -159,7 +159,7 @@ class MLGWClient(asynchat.async_chat):
] ]
) )
message["State_Update"]["state"] = 'Unknown' message["State_Update"]["state"] = 'Unknown'
message["volume"] = int(payload[3]) message["State_Update"]["volume"] = int(payload[3])
elif payload_type == "All standby notification": elif payload_type == "All standby notification":
message["payload_type"] = payload_type message["payload_type"] = payload_type