You are viewing an old version of this page. View the current version.
Compare with Current
View Page History
Version 1
Next »
Setup SSH on a board
To setup the ssh server it is necessary to connect via minicom (serial port) and pass the comands below.
dropbearkey -t rsa -f /tmp/data/sky-ssh-hostkey
dropbear -p :<SSH_PORT> -P /var/run/dropbear2 .pid -r /tmp/data/sky-ssh-hostkey -B
iptables -I INPUT 1 -p tcp --dport <SSH_PORT> -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
iptables -I OUTPUT 1 -p tcp --sport <SSH_PORT> -m conntrack --ctstate ESTABLISHED -j ACCEPT
|
With suggestet SSH_PORT = 10022
dropbearkey -t rsa -f /tmp/data/sky-ssh-hostkey
dropbear -p :10022 -P /var/run/dropbear2 .pid -r /tmp/data/sky-ssh-hostkey -B
iptables -I INPUT 1 -p tcp --dport 10022 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
iptables -I OUTPUT 1 -p tcp --sport 10022 -m conntrack --ctstate ESTABLISHED -j ACCEPT
|
Redirect ports
The command below will log into the box via ssh and redirect the ports between local machine and box.
ssh -L <LOCAL_PORT>:localhost:<THUNDER_PORT> -p <SSH_PORT> root@<IP>
|
In my case (I'm relying on local port 9000, ssh port is equal to 10022, thunder port is default 9998, and box ip equals 10.42.0.212.
Send HTTP request to the Thunder
I'm using the Postman, but even curl can be fine enough.
BOX example
Expand source
Local machine example
Expand source
Postman example
![](https://etwiki.sys.comcast.net/download/attachments/626742153/image2019-12-4_11-25-36.png?version=1&modificationDate=1575455238000&api=v2)
Send JSON RPC request to the Thunder
BOX example
curl -X POST http:
{ "jsonrpc" : "2.0" , "id" : 1234567890 , "result" :{ "connectedVideoDisplays" :[ "HDMI0" ], "success" : true }}
|
Local machine example
curl -X POST http:
{ "jsonrpc" : "2.0" , "id" : 1234567890 , "result" :{ "connectedVideoDisplays" :[ "HDMI0" ], "success" : true }}
|
Postman example
![](https://etwiki.sys.comcast.net/download/attachments/626742153/image2019-12-4_12-38-56.png?version=1&modificationDate=1575459537000&api=v2)
Sending/Receiving message with Browser WebSocket Client
- Make sure that you have SSH enabled, and redirected ports (look above in this page)
- From chrome extenstion download "Browser WebSocket Client"
URL and Protocol can be taken from "thunder-wifimanager-test.js", when creating this instruction it was:
Going with this example our URL should be 'ws://localhost:9000/jsonrpc' (NOTICE: port is different as we redirected it before), and Protocol should be 'notification'. All those fields should not have [ ' ] characters.
Now we can register to get some message, In Send a Message field just paste request, i.e.
{
"jsonrpc" : "2.0" ,
"id" : 123123123 ,
"method" : "Controller.1.register" ,
"params" : {
"event" : "all" ,
"id" : "client.events.1"
}
}
|
and press Send. In reveived Messages should be shown response.
Then we can check if we will get new message if registered even appeard. We can do it be i.e.
{
"jsonrpc" : "2.0" ,
"id" : 1234567890 ,
"method" : "Controller.1.deactivate" ,
"params" : {
"callsign" : "DeviceInfo"
}
}
|
We should get 2 messages. One about success of this operation and second about event that we are registered.
Getting events from desired service
To get event from specific service we need to set service name and event that we want to catch. So if we want i.e. get from HomeNetworking, get event deviceDiscoveryUpdate. We need to
{
"jsonrpc" : "2.0" ,
"id" : 123123123 ,
"method" : "org.rdk.HomeNetworking.1.register" ,
"params" : {
"event" : "deviceDiscoveryUpdate" ,
"id" : "client.events.1"
}
}
|
Important: name of service can be different on the box (here "org.rdk." was prefixed) to check how service is called in the box use command:
There you can find all services.