Stand with Ukraine flag
Try it now Pricing
IoT Gateway
Documentation > IoT Gateway features > Service RPC methods
Getting Started
Installation
On this page

Service RPC Methods

This guide explains how to use RPC API in ThingsBoard IoT Gateway.

For the purpose of this tutorial, you need:

  1. Locally installed instance of ThingsBoard platform (In case you are new with ThingsBoard use this ‘how to install’ documentation).
  2. Installed and configured ThingsBoard IoT Gateway.

Step 1. Create a dashboard to use RPC API in ThingsBoard IoT Gateway

To use the debug terminal we have to add RPC debug terminal widget from Control widget bundle.
To do this we use following steps:

  • Open Dashboards tab;

  • Add a new dashboard;

  • Open created dashboard, enter edit mode by clicking pencil button in the bottom right corner and click “Add new widget” button;

  • Select widget bundle - “Control widgets”;

  • Scroll down and select RPC debug terminal widget;

  • We haven’t specify the entity type for the widget so we will create a new one;

  • Fill in required fields and same the entity. Gateway - is our gateway device;

  • Apply all changes;

  • The connected widget looks like (Connection setups automatically).
    Now you can use Debug Terminal to send RPC requests to the gateway.

Step 2. Gateway RPC methods

To send RPC requests to the gateway the one should use RPC Debug Terminal from Control widgets bundle.
ThingsBoard IoT gateway has several RPC methods, which called from WEB UI, available by default.
The list of OOTB methods will be extended within upcoming releases.

gateway_ping RPC method

gateway_ping RPC method is used to check connection to the gateway and RPC processing status. Every command with prefix “gateway_” will be interpreted as a command to general gateway service and not as an RPC request to the connector or device. Command:

1
gateway_ping

The response is:

1
2
3
4
{
  "code": 200,
  "resp": "pong"
}

Gateway RPC ping method

gateway_devices RPC method

gateway_devices RPC method is used to list devices connected through the gateway with info about the type of connector used. This method returns object in “resp” with key-value parameters, where: key — is a device name value — identifies the connector

Command:

1
gateway_devices

Returns object like:

1
2
3
4
5
6
{
  "code": 200,
  "resp": {
    "Device Number One": "OPC-UA Connector"
  }
}

Gateway RPC devices method

gateway_restart RPC method

gateway_restart RPC method is used to schedule restart action, e.g. bash gateway_restart 60 set up the restart of the gateway service in 60 seconds. This method uses seconds as measuring unit.

Note: The response will be returned after adding the task to the gateway scheduler.

Command:

1
gateway_restart 60

The response is:

1
{"success": true}

Gateway RPC restart method

gateway_reboot RPC method

gateway_reboot RPC method is used to schedule rebooting of the gateway device (hardware?), e. g. bash gateway_reboot 60 set up the reboot of the gateway device in one minute. Take into account: this method available if you start the gateway service as a python module instead of daemon approach and the user that is running the gateway has reboot permissions. Command:

1
gateway_reboot 60

The response is:

1
{"success": true}

Notate: The response will be returned after adding the task to the gateway scheduler.

Gateway RPC reboot method

Next steps

Explore guides related to main ThingsBoard features: