Using RPC capabilities

NDU allows you to send remote procedure calls (RPC) from server side applications to devices and vice versa. Basically, this feature allows you to send commands to devices and receive results of commands execution. Similar, you can execute request from the device, apply some calculations or other server-side logic on the back-end and push the response back to the device. This guide covers NDU RPC capabilities. After reading this guide, you will get familiar with following topics:

RPC call types

NDU RPC feature can be divided into two types based on originator: device-originated and server-originated RPC calls. In order to use more familiar names, we will name device-originated RPC calls as a client-side RPC calls and server-originated RPC calls as server-side RPC calls.

image

Server-side RPC calls can be divided into one-way and two-way:

Device RPC API

NDU provides convenient API to send and receive RPC commands from applications running on the device. This API is specific for each supported network protocol. You can review API and examples in corresponding reference page:

Server-side RPC API

NDU provides System RPC Service that allows you to send RPC calls from server-side applications to the device. In order to send RPC request you need execute HTTP POST request to the following URL:

1
https://smartapp.netcad.com/api/plugins/rpc/{callType}/{deviceId}

where

The request body should be a valid json object with two elements:

For example:

resources/set-gpio-request.sh
1
2
3
curl -v -X POST -d @set-gpio-request.json http://localhost:8080/api/plugins/rpc/twoway/$DEVICE_ID \
--header "Content-Type:application/json" \
--header "X-Authorization: $JWT_TOKEN"
resources/set-gpio-request.json
1
2
3
4
5
6
7
{
  "method": "setGpio",
  "params": {
    "pin": "23",
    "value": 1
  }
}

Please note that in order to execute this request, you will need to substitute $JWT_TOKEN with a valid JWT token. This token should belong to either

You can use following guide to get the token.

RPC Rule Nodes

It is possible to integrate RPC actions into processing workflow. There are 2 Rule Nodes for working with RPC requests.

RPC widgets

See widgets library for more details.