moved controller tests into subdir

This commit is contained in:
badaix 2015-09-09 08:51:48 +02:00
parent c277f87491
commit 67ba050a6c
3 changed files with 50 additions and 16 deletions

50
control/setVolume.py Executable file
View file

@ -0,0 +1,50 @@
import sys
import telnetlib
import json
import threading
import time
telnet = telnetlib.Telnet(sys.argv[1], 1705)
class ReaderThread(threading.Thread):
def __init__(self, tn, stop_event):
super(ReaderThread, self).__init__()
self.tn = tn
self.stop_event = stop_event
def run(self):
while (not self.stop_event.is_set()):
response = self.tn.read_until("\r\n", 2)
if response:
print("received: " + response)
jresponse = json.loads(response)
print(json.dumps(jresponse, indent=2))
print("\r\n")
def doRequest( str ):
print("send: " + str)
telnet.write(str)
time.sleep(1)
return;
t_stop= threading.Event()
#t = ReaderThread(telnet, t_stop)
#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")
time.sleep(2)
#s = raw_input("")
#print(s)
#t_stop.set();
#t.join()
telnet.close

View file

@ -97,22 +97,6 @@ void StreamServer::onMessageReceived(ControlSession* connection, const std::stri
try
{
request.parse(message);
//{"jsonrpc": "2.0", "method": "System.GetStatus", "id": 2}
//{"jsonrpc": "2.0", "method": "System.GetStatus", "params": {"client": "00:21:6a:7d:74:fc"}, "id": 2}
//{"jsonrpc": "2.0", "method": "Client.SetVolume", "params": {"client": "00:21:6a:7d:74:fc", "volume": 83}, "id": 2}
//{"jsonrpc": "2.0", "method": "Client.SetLatency", "params": {"client": "00:21:6a:7d:74:fc", "latency": 10}, "id": 2}
//{"jsonrpc": "2.0", "method": "Client.SetName", "params": {"client": "00:21:6a:7d:74:fc", "name": "living room"}, "id": 2}
//{"jsonrpc": "2.0", "method": "Client.SetMute", "params": {"client": "00:21:6a:7d:74:fc", "mute": false}, "id": 2}
//curl -X POST -H "Content-Type: application/json" -d '{"jsonrpc": "2.0", "method": "Application.SetVolume", "params": {"volume":100}, "id": 1}' http://i3c.pla.lcl:8080/jsonrpc
//https://en.wikipedia.org/wiki/JSON-RPC
//https://github.com/pla1/utils/blob/master/kodi_remote.desktop
//http://forum.fhem.de/index.php?topic=10075.130;wap2
//http://kodi.wiki/view/JSON-RPC_API/v6#Application.SetVolume
logO << "method: " << request.method << ", " << "id: " << request.id << "\n";
json response;