Skip to content

Instantly share code, notes, and snippets.

@sorah
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sorah/8161dc9ee36ea30bbae8 to your computer and use it in GitHub Desktop.
Save sorah/8161dc9ee36ea30bbae8 to your computer and use it in GitHub Desktop.
# STR-DN2030 TCP Control Protocol (analyze)
sock = TCPSocket.open('x.x.x.x', 33335)
###
get_vol_status = "\x02\x04\xa0\x92\x00\x03\x00"
vol_up = "\x02\x03\xA0U\x00\x00"
vol_down = "\x02\x03\xA0V\x00\x00"
set_vol = "\x02\x06\xa0\x52\x00\x03".b + [26].pack('s>') + "\x00".b
get_status = "\x02\x03\xA0\x82\x00\x00"
# *** zone
unmute = "\x02\x04\xa0\x53\x00\x00\x00"
mute = "\x02\x04\xa0\x53\x00\x01\x00"
get_equalizer = "\x02\x02\xa3\xa0\x00"
input_ps4 = "\x02\x04\xa0\x42\x00\x19\x00"
input_ps3 = "\x02\x04\xa0\x42\x00\x1c\x00"
input_appletv = "\x02\x04\xa0\x42\x00\x10\x00"
input_pc = "\x02\x04\xa0\x42\x00\x12\x00"
input_chromecast = "\x02\x04\xa0\x42\x00\x13\x00"
get_inputs_mainzone_a = "\x02\x04\xa0\x8b\x00\x00\x00"
get_inputs_mainzone_b = "\x02\x04\xa0\x8b\x00\x01\x00"
get_inputs_subzone_a = "\x02\x04\xa0\x8b\x01\x00\x00"
get_inputs_subzone_b = "\x02\x04\xa0\x8b\x01\x01\x00"
###
s.write get_status
p s.read_nonblock(100) #=> "\x02\x07\xA8\x82\x00\x10\x10\x23\x00\x8C" (10 bytes, muted)
p s.read_nonblock(100) #=> "\x02\x07\xA8\x82\x00\x10\x10\x21\x00\x8E" (10 bytes, not muted)
# #=> "\x02\x07\xA8\x82\x01\x0F\x0F\x03\x00\xAD" (10 bytes, muted, zone 2)
# #=> "\x02\x07\xA8\x82\x01\x0F\x0F\x01\x00\xAF" (10 bytes, not muted, zone 2)
# ^ ^ ^ ^ ^--- data2
# | | | L--- data1
# | | L--- video
# | L--- audio
# L--- zone
# data1
# 0x25 "--100101" zone 1, not muted, headphone
# 0x23 "--100011" zone 1, muted
# 0x21 "--100001" zone 1, not muted
# 0x03 "------11" zone 2, muted
# 0x01 "-------1" zone 2, not muted
76543210, 0=power?, 1=mute, 2=headphone, 5=?
s.write mute
p s.read_nonblock(100) #=> "\xFD\x02\x07\xA8\x82\x00\x10\x10#\x00\x8C" (11 bytes)
s.write unmute
p s.read_nonblock(100) #=> "\xFD\x02\x07\xA8\x82\x00\x10\x10!\x00\x8E" (11 bytes)
###
s.write get_vol_status
p s.read_nonblock(100) #=> "\x02\x06\xA8\x92\x00\x03\x00\x1A\xA3" (9 bytes)
# | ******* 0x1A => vol 26
# L 0x03 = vol num?
s.write vol_up
p s.read_nonblock(100) #=> "\xFD\x02\x06\xA8\x92\x00\x03\x00\x1E\x9F" (10 bytes)
# ** 0x1E => vol 30
s.write vol_down
p s.read_nonblock(100) #=> "\xFD\x02\x06\xA8\x92\x00\x03\x00\x1C\xA1" (10 bytes)
# ** 0x1C => vol 28
set_vol = "\x02\x06\xa0\x52\x00\x03".b + [26].pack('s>') + "\x00".b
s.write set_vol
###
s.write input_chromecast # 0x13
p "\x02\x07\xA8\x82\x00\x13\x13\x21\x00\x88\xFD"
s.write input_appletv # 0x10
p "\xFD\x02\x07\xA8\x82\x00\x10\x10\x21\x00\x8E"
### Retrieve inputs
# "\x02\xD7\xA8\x8B\x00" \
# "\x02\xD7\xA8\x8B\x01" \
# ^^^^ zone
# ^^^^^^^^^^^^^^^^^ header
# "\x01\x19\x19\x04 DVD PS4 \x10" \
# | | | | | | L skip flags
# | | | | | L user set name
# | | | | L preset name
# | | | L icon id
# | | L video id
# | L audio id
# L index
# skip:
# \x11 "--010001" #=> watch:hide listen:hide
# \x21 "--100001" #=> watch:hide listen:hide
# \x30 "--110000" #=> watch:show listen:show
# \x10 "--010000" #=> watch:show listen:hide
# \x20 "--100000" #=> watch:hide listen:show
s.write get_inputs_mainzone_a
p "\x02\xD7\xA8\x8B\x00" \
"\x00\x1B\x1B\x01 BD BD \x11" \
"\x01\x19\x19\x04 DVD PS4 \x10" \
"\x02\x1C\x1C\x04 GAME PS3 \x10" \
"\x03\x16\x16\x05SAT/CATVSAT/CATV\x11" \
"\x04\x10\x10\x10VIDEO 1 Apple TV\x10" \
"\x05\x11\x11\x1BVIDEO 2 VIDEO 2 \x11" \
"\x06\x12\x12\x10VIDEO 3 PC \x10" \
"\x07\x13\x13\x05VIDEO 4 Chrome \x30" \
"\x08\x1A\x1A\x07 TV TV \x11" \
"\x09\x02\x02\x0FSA-CD/CDSA-CD/CD\x21" \
"\x00\x00\xD9"
s.write get_inputs_mainzone_b
p "\x02\xD7\xA8\x8B\x00" \
"\x0A\x2E\x2E\x0CFM TUNERFM TUNER\x20" \
"\x0B\x2F\x2F\x0CAM TUNERAM TUNER\x20" \
"\x0C\x36\x36\x11Music Music \x20" \
"\x0D\x37\x37\x12Video Video \x10" \
"\x0E\x38\x38\x13Photo Photo \x10" \
"\x0F\x3A\x3A\x14InternetInternet\x20" \
"\x10\x3B\x3B\x15InternetInternet\x10" \
"\x11\x3C\x3C\x16InternetInternet\x10" \
"\x12\x3D\x3D\x17Network Network \x30" \
"\x13\x3E\x3E\x18Sony EntSony Ent\x30" \
"\x00\x00\x45"
s.write get_inputs_subzone_a
p "\x02\xD7\xA8\x8B\x01" \
"\x00\x0F\x0F\x00SOURCE SOURCE \x30" \
"\x01\x1B\x1B\x00 BD BD \x11" \
"\x02\x19\x19\x00 DVD DVD \x10" \
"\x03\x1C\x1C\x00 GAME GAME \x10" \
"\x04\x16\x16\x00SAT/CATVSAT/CATV\x11" \
"\x05\x10\x10\x00VIDEO 1 VIDEO 1 \x10" \
"\x06\x11\x11\x00VIDEO 2 VIDEO 2 \x11" \
"\x07\x12\x12\x00VIDEO 3 VIDEO 3 \x10" \
"\x08\x13\x13\x00VIDEO 4 VIDEO 4 \x30" \
"\x09\x02\x02\x00SA-CD/CDSA-CD/CD\x21" \
"\x00\x00\xAA"
s.write get_inputs_subzone_b
p "\x02\xD7\xA8\x8B\x01" \
"\x0A\x2E\x2E\x00FM TUNERFM TUNER\x20" \
"\x0B\x2F\x2F\x00AM TUNERAM TUNER\x20" \
"\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
"\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
"\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
"\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
"\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
"\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
"\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
"\xFF\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" \
"\x00\x00\xF4"
### Notification
# volume change
p s.read_nonblock(100) #=> "\x02\x06\xA8\x92\x00\x03\x00\x1C\xA1"
# muted
p "\x02\x07\xA8\x82\x00\x10\x10#\x00\x8C"
# unmuted +- differ
p "\x02\x07\xA8\x82\x00\x10\x10!\x00\x8E"
# switch chromecast
p "\x02\x07\xA8\x82\x00\x13\x13\x21\x00\x88"
# switch apple tv
p "\x02\x07\xA8\x82\x00\x10\x10\x21\x00\x8E"
# All bass -1.0
p "\x02\x20\xAB\xA0\x00\x00\x7F\xFF\x00\x00\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\xFF\x00\x7F\xFF\x00\x00\x2C"
# All bass -1.5
p "\x02\x20\xAB\xA0\x00\x00\x7F\xFF\x00\x00\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\xFE\x80\x7F\xFF\x00\x00\xAD"
# All bass -2.0
p "\x02\x20\xAB\xA0\x00\x00\x7F\xFF\x00\x00\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\xFE\x00\x7F\xFF\x00\x00\x2D"
# All bass -2.0 treble +1.5
p "\x02\x20\xAB\xA0\x00\x00\x7F\xFF\x00\x00\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\xFE\x00\x7F\xFF\x01\x80\xAC"
# All bass -2.0 treble +3.5
p "\x02\x20\xAB\xA0\x00\x00\x7F\xFF\x00\x00\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\xFE\x00\x7F\xFF\x03\x80\xAA"
# all bass 0 treble 0
p "\x02\x20\xAB\xA0\x00\x00\x7F\xFF\x00\x00\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x00\x00\x7F\xFF\x00\x00\x2B"
# all bass +1.5 treble 0.0
p "\x02\x20\xAB\xA0\x00\x00\x7F\xFF\x00\x00\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x01\x80\x7F\xFF\x00\x00\xAA"
# all bass 0.0 treble -2.5
p "\x02\x20\xAB\xA0\x00\x00\x7F\xFF\x00\x00\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x7F\xFF\x00\x00\x7F\xFF\xFD\x80\xAE"
# stream
p "\x02\x06\xA8\x92\x00\x03\x00\x1D\xA0\x02\x06\xA8\x92\x00\x03\x00\x1C\xA1\x02\x06\xA8\x92\x00\x03\x00\e\xA2\x02\x06\xA8\x92\x00\x03\x00\x1A\xA3\x02\x06\xA8\x92\x00\x03\x00\x19\xA4"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment