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.


ssh -L 9000:localhost:9998 -p 10022 root@10.42.0.21

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


Send JSON RPC request to the Thunder

BOX example

curl -X POST http://127.0.0.1:9998/Service/ -d '{"jsonrpc": "2.0", "id": 1234567890, "method": "DisplaySettings.1.getConnectedVideoDisplays"}'
{"jsonrpc":"2.0","id":1234567890,"result":{"connectedVideoDisplays":["HDMI0"],"success":true}}


Local machine example

curl -X POST http://127.0.0.1:9000/Service/ -d '{"jsonrpc": "2.0", "id": 1234567890, "method": "DisplaySettings.1.getConnectedVideoDisplays"}'
{"jsonrpc":"2.0","id":1234567890,"result":{"connectedVideoDisplays":["HDMI0"],"success":true}}


Postman example


Sending/Receiving message with Browser WebSocket Client

  1. Make sure that you have SSH enabled, and redirected ports (look above in this page)
  2. From chrome extenstion download "Browser WebSocket Client"
  3. URL and Protocol can be taken from "thunder-wifimanager-test.js", when creating this instruction it was:

    ws = new WebSocket('ws://localhost:9998/jsonrpc', 'notification');

  4. 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.

  5. 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.

  6. 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:

curl --location --request GET 'http://127.0.0.1:9998/Service/Controller' | json_reformat

There you can find all services.

  • No labels