From: jimmy Date: Fri, 28 Jun 2024 01:23:54 +0000 (-0500) Subject: roku remote using POST requests via web X-Git-Url: https://vault307.fbx.one/gitweb/roku.git/commitdiff_plain/HEAD?ds=sidebyside roku remote using POST requests via web --- 073b6b845fa6f513e017ad2ea0ceb031af516293 diff --git a/rokuPOST.py b/rokuPOST.py new file mode 100644 index 0000000..cb09916 --- /dev/null +++ b/rokuPOST.py @@ -0,0 +1,71 @@ +import network, socket, time, requests, gc +from machine import Pin + +ssid='SSID' +password='PSWD' + +url='http://192.168.0.109:8060' + +homeKey='/keypress/home' +upKey='/keypress/up' +downKey='/keypress/down' +leftKey='/keypress/left' +rightKey='/keypress/right' +selectKey='/keypress/select' + +def connect(): + wlan=network.WLAN(network.STA_IF) + wlan.active(True) + wlan.connect(ssid,password) + while wlan.isconnected() == False: + print('Waiting for connection...') + time.sleep(1) + ip=wlan.ifconfig()[0] + print(f'Connected on {ip}') + return ip + +def gccol(): + gc.collect() + +connect() +gccol() + +""" +to use key presses: requests.post(url+keypress), ie, requests.post(url+homeKey) +need to run gcol() after each keypress, memory runs out quick +when setting up buttons, set resistor on board, do not use internal PULL_UP/PULL_DOWN +""" +""" +homebtn=Pin(#,Pin.IN) +upbtn=Pin(#,Pin.IN) +downbtn=Pin(#,Pin.IN) +leftbtn=Pin(#,Pin.IN) +rightbtn=Pin(#,Pin.IN) +selectbtn=Pin(#,Pin.IN) + +while True: + if homebtn.value()==1: + requests.post(url+homeKey) + gccol() + time.sleep(0.2) + if upbtn.value()==1: + requests.post(url+upKey) + gccol() + time.sleep(0.2) + if downbtn.value()==1: + requests.post(url+downKey) + gccol() + time.sleep(0.2) + if leftbtn.value()==1: + requests.post(url+leftKey) + gccol() + time.sleep(0.2) + if rightbtn.value()==1: + requests.post(url+rightKey) + gccol() + time.sleep(0.2) + if selectbtn.value()==1: + requests.post(url+selectKey) + gccol() + time.sleep(0.2) +"""