wait for response

This commit is contained in:
badaix 2015-09-09 08:59:53 +02:00
parent 67ba050a6c
commit 934bf4e03f

View file

@ -22,10 +22,10 @@ class ReaderThread(threading.Thread):
print("\r\n")
def doRequest( str ):
def doRequest( str, id ):
print("send: " + str)
telnet.write(str)
time.sleep(1)
response = telnet.read_until("\r\n", 2)
return;
@ -34,14 +34,14 @@ t_stop= threading.Event()
#t.start()
volume = sys.argv[2]
doRequest("{\"jsonrpc\": \"2.0\", \"method\": \"System.GetStatus\", \"id\": 1}\r\n")
doRequest("{\"jsonrpc\": \"2.0\", \"method\": \"Client.SetVolume\", \"params\": {\"client\": \"00:21:6a:7d:74:fc\", \"volume\": " + volume + "}, \"id\": 1}\r\n")
doRequest("{\"jsonrpc\": \"2.0\", \"method\": \"Client.SetVolume\", \"params\": {\"client\": \"80:1f:02:ed:fd:e0\", \"volume\": " + volume + "}, \"id\": 2}\r\n")
doRequest("{\"jsonrpc\": \"2.0\", \"method\": \"Client.SetVolume\", \"params\": {\"client\": \"74:da:38:00:85:e2\", \"volume\": " + volume + "}, \"id\": 3}\r\n")
doRequest("{\"jsonrpc\": \"2.0\", \"method\": \"Client.SetVolume\", \"params\": {\"client\": \"80:1f:02:ff:79:6e\", \"volume\": " + volume + "}, \"id\": 4}\r\n")
doRequest("{\"jsonrpc\": \"2.0\", \"method\": \"Client.SetVolume\", \"params\": {\"client\": \"bc:5f:f4:ca:cd:64\", \"volume\": " + volume + "}, \"id\": 5}\r\n")
doRequest("{\"jsonrpc\": \"2.0\", \"method\": \"System.GetStatus\", \"id\": 1}\r\n", 1)
doRequest("{\"jsonrpc\": \"2.0\", \"method\": \"Client.SetVolume\", \"params\": {\"client\": \"00:21:6a:7d:74:fc\", \"volume\": " + volume + "}, \"id\": 2}\r\n", 2)
doRequest("{\"jsonrpc\": \"2.0\", \"method\": \"Client.SetVolume\", \"params\": {\"client\": \"80:1f:02:ed:fd:e0\", \"volume\": " + volume + "}, \"id\": 3}\r\n", 3)
doRequest("{\"jsonrpc\": \"2.0\", \"method\": \"Client.SetVolume\", \"params\": {\"client\": \"74:da:38:00:85:e2\", \"volume\": " + volume + "}, \"id\": 4}\r\n", 4)
doRequest("{\"jsonrpc\": \"2.0\", \"method\": \"Client.SetVolume\", \"params\": {\"client\": \"80:1f:02:ff:79:6e\", \"volume\": " + volume + "}, \"id\": 5}\r\n", 5)
doRequest("{\"jsonrpc\": \"2.0\", \"method\": \"Client.SetVolume\", \"params\": {\"client\": \"bc:5f:f4:ca:cd:64\", \"volume\": " + volume + "}, \"id\": 6}\r\n", 6)
time.sleep(2)
time.sleep(1)
#s = raw_input("")
#print(s)
#t_stop.set();