Skip to content

Commit 04d3c59

Browse files
committed
Merge branch 'feature/persistent-rpc' of https://github.com/Dshcherbyna/thingsboard.github.io
2 parents b90ed04 + d722b3b commit 04d3c59

34 files changed

+134
-0
lines changed

_includes/docs/user-guide/install/config.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,18 @@ We will list only main configuration parameters below to avoid duplication of th
662662
<td>604800</td>
663663
<td>The parameter to specify TTL(Time To Live) value for Debug Events(DEBUG_CONVERTER, DEBUG_INTEGRATION, DEBUG_RULE_NODE, DEBUG_RULE_CHAIN) records. Value set in seconds. 0 - records are never expired. Default value corresponds to one week.</td>
664664
</tr>
665+
<tr>
666+
<td>sql.ttl.rpc.enabled</td>
667+
<td>SQL_TTL_RPC_ENABLED</td>
668+
<td>true</td>
669+
<td>Parameter to enable or disable TTL(Time To Live) for Persistent RPC.</td>
670+
</tr>
671+
<tr>
672+
<td>sql.ttl.rpc.checking_interval</td>
673+
<td>SQL_RPC_TTL_CHECKING_INTERVAL</td>
674+
<td>7200000</td>
675+
<td>Parameter to specify how often TTL(Time To Live) will be checked.</td>
676+
</tr>
665677
<tr>
666678
<td colspan="4"><span style="font-weight: bold; font-size: 24px;">PostgreSQL database parameters</span></td>
667679
</tr>

_includes/docs/user-guide/rpc.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,70 @@ This token should belong to either
8282

8383
You can use the following [guide](/docs/{{docsPrefix}}reference/rest-api/#rest-api-auth) to get the token.
8484

85+
## Persistent RPC
86+
87+
Since version 3.3, ThingsBoard provides the new feature: **Persistent RPC**.
88+
Unlike basic RPC, Persistent RPC has an increased timeout and the command is stored in the database for configurable amount of time.
89+
Persistent RPC is extremely useful when your device is in power-saving mode.
90+
Power-saving mode (or PSM) is when the device temporary is turning off to save the battery energy.
91+
You can set the PSM in the device profile or device configuration. This feature is available for [CoAP](/docs/{{docsPrefix}}reference/coap-api/) and [LWM2M](/docs/{{docsPrefix}}reference/lwm2m-api/) only.
92+
After you send an RPC request to this device, the request will be saved in the database for the time you configured and the device will receive the request and send the response when it is turned on again.
93+
In addition, every time you send the Persistent RPC, the response will contain RPC ID. Whenever you need to find a specific RPC and view its states and responses, you can do it with that ID through the database.
94+
95+
#### Persistent RPC Configuration
96+
97+
To configure parameters for sending a Persistent RPC request, first, you need to edit the ThingsBoard configuration file:
98+
99+
```
100+
sudo nano /etc/thingsboard/conf/thingsboard.conf
101+
```
102+
{: .copy-code}
103+
104+
Then, add the following lines to the configuration file to add these parameters:
105+
106+
```
107+
export SQL_TTL_RPC_ENABLED=true
108+
export SQL_RPC_TTL_CHECKING_INTERVAL=7200000
109+
```
110+
{: .copy-code}
111+
112+
Where:
113+
114+
1. **SQL_TTL_RPC_ENABLED** <br>parameter is for configuring whether Persistent RPC data will be removed from the database in case it's outdated.
115+
116+
2. **SQL_RPC_TTL_CHECKING_INTERVAL** <br>parameter is for configuring how often Persistent RPC will be checked whether it's outdated. By default, this parameter is set to two hours (in milliseconds).
117+
118+
The system administrator can configure the default parameter for the tenants through the Tenant Profile. This is **RPC TTL days configuration** parameter.
119+
Configuring this parameter will change the number of days when RPC will be deleted from the database. See the screenshot below:
120+
121+
{% include images-gallery.html imageCollection="tenant-profile-rpc" %}
122+
123+
#### RPC Rule chain events
124+
125+
In the Rule chain, you are able to configure events that will be dispatched every time you send an RPC request: RPC queued, RPC delivered, RPC successful, RPC timeout, RPC failed.
126+
Configured RPC events reflect [RPC states](/docs/{{docsPrefix}}user-guide/rpc/#rpc-states).
127+
128+
{% include images-gallery.html imageCollection="rule-chain" %}
129+
130+
#### Persistent RPC States
131+
132+
Once you send an RPC, you can observe what exactly happened with the request that you sent in the Rule node events tab.
133+
RPC states determine steps that happen when you send RPC request. There are five possible states that can occur when the request is sent:
134+
135+
**QUEUED** - RPC was saved to the database;
136+
**DELIVERED** - RPC was delivered to the device (for two-way RPC);
137+
**SUCCESSFUL** - if RPC is one-way, SUCCESSFUL means that RPC was delivered to the device. If RPC is two-way, SUCCESSFUL means that we've already received response from the device;
138+
**TIMEOUT** - RPC was not delivered to the device;
139+
**FAILED** - an error occurred either while sending RPC, or during one of the steps.
140+
141+
#### Usage of Persistent RPC
142+
143+
To send the Persistent RPC through ThingsBoard, you need to add RPC Debug Terminal widget to your dashboard.
144+
How to add RPC Debug Terminal and use this widget, you can read [here](/docs/{{docsPrefix}}reference/lwm2m-api/#rpc-commands).
145+
Then, follow these steps to test the Persistent RPC:
146+
147+
{% include images-gallery.html imageCollection="rpc-test" showListImageTitles="true" %}
148+
85149
## RPC Rule Nodes
86150
It is possible to integrate RPC actions into processing workflow. There are 2 Rule Nodes for working with RPC requests.
87151

docs/pe/user-guide/rpc.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,35 @@ assignees:
55
title: Using RPC capabilities
66
description: Remote control of IoT devices from the ThingsBoard IoT cloud using RPC feature
77

8+
tenant-profile-rpc:
9+
0:
10+
image: /images/user-guide/persistent-rpc/tenant-rpc-pe.png
11+
title: 'Click the orange pencil icon in the upper corner of the screen to enter dashboard edit mode.'
12+
1:
13+
image: /images/user-guide/persistent-rpc/tenant-rpc-1-pe.png
14+
title: 'Set the number of days in the RPC TTL days line. Apply changes by clicking the orange checkmark icon in the upper right corner of the page.'
15+
16+
rule-chain:
17+
0:
18+
image: /images/user-guide/persistent-rpc/rule-chain-pe.png
19+
20+
rpc-test:
21+
0:
22+
image: /images/user-guide/persistent-rpc/rpc-test-pe.png
23+
title: 'Click the orange pencil icon in the lower corner of the screen to enter dashboard edit mode.'
24+
1:
25+
image: /images/user-guide/persistent-rpc/rpc-test-1-pe.png
26+
title: 'Click the pencil icon in the upper right corner of the RPC debug terminal to enter widget edit mode.'
27+
3:
28+
image: /images/user-guide/persistent-rpc/rpc-test-2-pe.png
29+
title: 'Move to the Advanced tab, increase request timeout of RPC and check the box "RPC request persistent" to enable it. Click the orange checkmark icon in the upper corner of the window to apply the changes.'
30+
4:
31+
image: /images/user-guide/persistent-rpc/rpc-test-3-pe.png
32+
title: 'Click the orange checkmark icon in the lower corner of the screen to save all applied changes.'
33+
5:
34+
image: /images/user-guide/persistent-rpc/rpc-test-4-pe.png
35+
title: 'In the tutorial, we will use the command "test". As you can see, the response contains RPC ID.'
36+
837
---
938

1039
{% assign docsPrefix = "pe/" %}

docs/user-guide/rpc.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,35 @@ assignees:
55
title: Using RPC capabilities
66
description: Remote control of IoT devices from the ThingsBoard IoT cloud using RPC feature
77

8+
rule-chain:
9+
0:
10+
image: /images/user-guide/persistent-rpc/rule-chain-ce.png
11+
12+
rpc-test:
13+
0:
14+
image: /images/user-guide/persistent-rpc/rpc-test-ce.png
15+
title: 'Click the orange pencil icon in the lower corner of the screen to enter dashboard edit mode.'
16+
1:
17+
image: /images/user-guide/persistent-rpc/rpc-test-1-ce.png
18+
title: 'Click the pencil icon in the upper right corner of the RPC debug terminal to enter widget edit mode.'
19+
3:
20+
image: /images/user-guide/persistent-rpc/rpc-test-2-ce.png
21+
title: 'Move to the Advanced tab, increase request timeout of RPC and check the box "RPC request persistent" to enable it. Click the orange checkmark icon in the upper corner of the window to apply the changes.'
22+
4:
23+
image: /images/user-guide/persistent-rpc/rpc-test-3-ce.png
24+
title: 'Click the orange checkmark icon in the lower corner of the screen to save all applied changes.'
25+
5:
26+
image: /images/user-guide/persistent-rpc/rpc-test-4-ce.png
27+
title: 'In the tutorial, we will use the command "test". As you can see, the response contains RPC ID.'
28+
29+
tenant-profile-rpc:
30+
0:
31+
image: /images/user-guide/persistent-rpc/tenant-rpc-ce.png
32+
title: 'Click the orange pencil icon in the upper corner of the screen to enter dashboard edit mode.'
33+
1:
34+
image: /images/user-guide/persistent-rpc/tenant-rpc-1-ce.png
35+
title: 'Set the number of days in the RPC TTL days line. Apply changes by clicking the orange checkmark icon in the upper right corner of the page.'
36+
837
---
938

1039
{% include docs/user-guide/rpc.md %}
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
98.9 KB
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)