Skip to content

Instantly share code, notes, and snippets.

@costastf
Forked from danielfaust/samsung_remote.py
Last active September 9, 2021 11:19
Show Gist options
  • Save costastf/5729057 to your computer and use it in GitHub Desktop.
Save costastf/5729057 to your computer and use it in GitHub Desktop.
Code used to create a class for a samsung remote
import time
import socket
import base64
src = '192.168.1.2' # ip of remote
mac = '00-AB-11-11-11-11' # mac of remote
remote = 'python remote' # remote name
dst = '192.168.1.3' # ip of tv
app = 'python' # iphone..iapp.samsung
tv = 'LE32C650' # iphone.LE32C650.iapp.samsung
def push(key):
new = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
new.connect((dst, 55000))
msg = chr(0x64) + chr(0x00) +\
chr(len(base64.b64encode(src))) + chr(0x00) + base64.b64encode(src) +\
chr(len(base64.b64encode(mac))) + chr(0x00) + base64.b64encode(mac) +\
chr(len(base64.b64encode(remote))) + chr(0x00) + base64.b64encode(remote)
pkt = chr(0x00) +\
chr(len(app)) + chr(0x00) + app +\
chr(len(msg)) + chr(0x00) + msg
new.send(pkt)
msg = chr(0x00) + chr(0x00) + chr(0x00) +\
chr(len(base64.b64encode(key))) + chr(0x00) + base64.b64encode(key)
pkt = chr(0x00) +\
chr(len(tv)) + chr(0x00) + tv +\
chr(len(msg)) + chr(0x00) + msg
new.send(pkt)
new.close()
time.sleep(0.1)
while True:
# switch to tv
push("KEY_TV")
# switch to channel one
push("KEY_1")
push("KEY_ENTER")
time.sleep(5)
# switch to channel 15
push("KEY_1")
push("KEY_5")
push("KEY_ENTER")
time.sleep(5)
# switch to HDMI
push("KEY_HDMI")
time.sleep(5)
@nandishyb
Copy link

How to we send the mouse pointer coordinates , I see in on of the app below:
Can you help me decode and help me send the mouse position:

0000  00 14 00 69 70 68 6f 6e  65 2e 2e 69 61 70 70 2e       ...iphon e..iapp.
0010  73 61 6d 73 75 6e 67 0e  00 07 00 0d 00 00 00 e5   samsung. ........
0020  ff ff ff 1d 01 00 00                               .......

@costastf
Copy link
Author

costastf commented Sep 9, 2021

Hi @nandishyb, this code is very old... I do not have access to a samsung TV so i am afraid that I would not be able to help. If you have the capability of dumping the different actions you can dedact the data from the headers because the headers would be static. I hope i could help more..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment