You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/2a_general.md
+18-16Lines changed: 18 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,17 +14,17 @@ ThingSet defines three types of messages: Requests, responses and publication me
14
14
15
15
### Request/response or client/server model
16
16
17
-
The communication between two specific devices uses a request/response messaging pattern via so-called communication channels. A channel can be established either directly (e.g. serial interface, USB, Bluetooth) or via a network or bus with several devices attached (e.g. CAN, Ethernet, WiFi, LoRa). In case of a network, each device/node has to be uniquely addressable.
17
+
The communication between two specific devices uses a request/response messaging pattern. A connection can be established either directly (e.g. serial interface, USB, Bluetooth) or via a network or bus with several devices attached (e.g. CAN, Ethernet, WiFi, LoRa). In case of a network, each device/node has to be uniquely addressable.
The device acts as the server and responds to the requests by a client. The client might be a laptop or mobile phone with a human interface application or a gateway.
21
+
The device acts as the server and responds to the requests by a client. The client might be a display, a mobile phone application or a gateway.
22
22
23
23
The data transfer is always synchronous: The client sends a request, waits for the response (status code and requested data), processes the response and possibly starts with additional requests.
24
24
25
25
### Publication messages
26
26
27
-
Monitoring data is not intended for only a single device, but could be interesting for several devices (e.g. data logger, display, human interface device, etc.). Thus, the monitoring data is exchanged via a publish/subscribe messaging pattern.
27
+
Monitoring data is not intended for only a single device, but could be interesting for several devices (e.g. data logger and display). Thus, the monitoring data can be exchanged via a publish/subscribe messaging pattern.
28
28
29
29
Publication messages are directly broadcast through the network. Unlike in MQTT, there is no intermediate broker to store the messages and published messages are not confirmed by recipients, so there is no guarantee if the message was received.
30
30
@@ -34,17 +34,17 @@ Similar to Modbus, the ThingSet protocol supports two different modes: A human-r
34
34
35
35
In the text mode, payload data is encoded in JSON format ([RFC 8259](https://tools.ietf.org/html/rfc8259)). This mode is recommended when using serial communication interfaces as the low layer protocol, as it can be easily used directly on a terminal.
36
36
37
-
The binary mode uses the CBOR binary encoding ([RFC 7049](https://tools.ietf.org/html/rfc7049)) instead of JSON payload data in order to reduce the protocol overhead for ressource-constrained devices or low bandwith communication protocols like CAN and LoRa.
37
+
The binary mode uses the CBOR ([RFC 7049](https://tools.ietf.org/html/rfc7049)) instead of JSON for payload data encoding in order to reduce the protocol overhead for ressource-constrained devices or low bandwith communication protocols like CAN and LoRa.
38
38
39
39
A device may implement both variants of the protocol, but it is also allowed to support only the mode most suitable for the application.
40
40
41
41
## Data Structure
42
42
43
-
All accessible data of a device is [structured as a tree](https://en.wikipedia.org/wiki/Tree_(data_structure)). Actual data is stored in leaf nodes, called data nodes. The data can be any kind of measurements (e.g. temperature), device configuration (e.g. setpoint of a controller) or similar. Internal nodes are used to structure the data and define paths for data access.
43
+
All accessible data of a device is [structured as a tree](https://en.wikipedia.org/wiki/Tree_(data_structure)). Internal nodes are used to define paths or endpoints for data access. Actual data is stored in the leaf nodes and can be any kind of measurements (e.g. temperature), device configuration (e.g. setpoint of a controller) or similar information.
44
44
45
-
Each node is identified by a unique node ID and a name. The ID can be chosen by the firmware developer. The name of a data node must be unique per device. It is a short case-sensitive ASCII string containing only alphanumeric characters, an underscore, dots or dashes without any whitespace characters. The underscore is only used to specify the unit of the data (if applicable, also see below). No additional underscore is allowed in the name.
45
+
Each node is identified by a unique node ID and a name. The ID can be chosen by the firmware developer. The name is a short case-sensitive ASCII string containing only alphanumeric characters, an underscore, dots or dashes without any whitespace characters. The underscore is only used to specify the unit of the data (if applicable, also see below). No additional underscore is allowed in the name and it should be unique per device at least for nodes that are used in publication messages.
46
46
47
-
The numeric IDs are used to define the relations between each nodes and to directly access data nodes in the binary protocol for reduced message size. For all interactions with users and in the text-based mode, only the node names and paths consisting of node names are used.
47
+
The numeric IDs are used to define the relations between nodes and to directly access data nodes in the binary protocol for reduced message size. For all interactions with users and in the text-based mode, only the node names and paths (consisting of multiple node names) are used.
48
48
49
49
### Example
50
50
@@ -71,8 +71,8 @@ For explanation of the protocol, the following simplified data structure of an M
71
71
},
72
72
"exec": {
73
73
"reset": null,
74
-
"auth": "password"
75
74
},
75
+
"auth": ["Password"],
76
76
"pub": {
77
77
"serial": {
78
78
"Enable": true,
@@ -88,11 +88,11 @@ For explanation of the protocol, the following simplified data structure of an M
88
88
}
89
89
```
90
90
91
-
The data nodes are structured in 5 different categories info, conf, input, output and rec. By convention, data node names use [upper camel case](https://en.wikipedia.org/wiki/Camel_case), inner nodes nodes use lower case names.
91
+
The data nodes are structured in the main different categories info, conf, input, output and rec. By convention, data node names use [upper camel case](https://en.wikipedia.org/wiki/Camel_case), inner nodes nodes use lower case names.
92
92
93
-
The exec category is special, as it contains functions that can be called. In order to distinguish it from a normal data node, executable node names are lower case.
93
+
The exec category is special, as it provides functions that can be called. In order to distinguish functions from a normal data nodes, executable node names are lower case.
94
94
95
-
The pub node is used to configure different types of publication messages, so it doesn't hold actual data nodes.
95
+
The pub node is used to configure different types of publication messages, so it doesn't hold normal data nodes.
96
96
97
97
### Categories
98
98
@@ -101,20 +101,20 @@ The following categories for data nodes are used for the ThingSet protocol by de
101
101
| Category | Description | Access |
102
102
|----------|-------------|---------|
103
103
| info | Device information (e.g. manufacturer, software version) | read access |
104
-
| conf | Configurable settings, stored in non-volatile memory after change | read/write access, may be protected with user password |
104
+
| conf | Configurable settings, stored in non-volatile memory after change | read/write access, expert settings may be password-protected|
The nodes of input and output categories are used for instantaneous data. Changes to input nodes are only stored in RAM, so they get lost after a reset of the device. In contrast to that, conf data is stored in non-volatile memory (e.g. flash or EEPROM) after a change. As non-volatile memory has a limited amount of write cycles, configuration data should not be changed continously.
112
112
113
113
The recorded data category is used for history-dependent data like error memory, energy counters or min/max values of certain measurements. In contrast to data of output category, recorded data cannot be obtained through measurement after reset, so the current state has to be stored in non-volatile memory on a regular basis.
114
114
115
-
Factory calibration is only accessible for the manufacturer after authentication.
115
+
Factory calibration data nodes are only accessible for the manufacturer after authentication.
116
116
117
-
Excecutable data means that they trigger a function call in the device firmware. Currently, only void functions without any parameters are supported.
117
+
Excecutable data means that they trigger a function call in the device firmware. Child nodes of the executable node can be used to define parameters that can be passed to the function.
118
118
119
119
Data node IDs are stored as unsigned integers. The firmware developer should assign the lowest IDs to the most used data objects, as they consume less bytes during transfer (see CBOR representation of unsigned integers).
120
120
@@ -139,7 +139,7 @@ The first byte of a ThingSet message is either a text-mode identifier ('?', '=',
139
139
140
140
### Requests
141
141
142
-
The protocol supports the typical [CRUD operations](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete). Request codes match with CoAP in order to allow transparent translation and routing between ThingSet and HTTP APIs or CoAP devices.
142
+
The protocol supports the typical [CRUD operations](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete). Request codes match with CoAP to allow transparent translation and routing between ThingSet and HTTP APIs or CoAP devices.
@@ -149,6 +149,8 @@ The protocol supports the typical [CRUD operations](https://en.wikipedia.org/wik
149
149
| 0x05 | ? | FETCH | Retrieve a subset of data from a node |
150
150
| 0x07 | = | iPATCH | Update (overwrite) data of a node |
151
151
152
+
The CoAP PUT and PATCH methods are not explicitly implemented. PUT is equivalent to an update of all sub-nodes of a resource using a PATCH request. PATCH requests for ThingSet are always idempotent, so only the iPATCH request code is supported. The two different text IDs for POST requests are synonyms. It is decided based on the type of the node if the request is understood as a function call or a request to create a resource.
153
+
152
154
Additional request codes may be introduced in the future. Codes 0x0A, 0x0D and 0x20-0x7F are reserved, as they represent the ASCII characters for readable text including LF and CR.
Copy file name to clipboardExpand all lines: docs/2b_text_mode.md
+25-25Lines changed: 25 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,26 +1,26 @@
1
1
# Text Mode
2
2
3
-
The following description of the ThingSet text mode grammar uses ABNF according to [RFC 5234](https://tools.ietf.org/html/rfc5234) and [RFC 7405](https://tools.ietf.org/html/rfc7405).
3
+
The following description of the ThingSet text mode grammar uses ABNF according to [RFC 5234](https://tools.ietf.org/html/rfc5234).
4
4
5
-
For rule names prefixed with `json-` consider the JSON specification in [RFC 8259](https://tools.ietf.org/html/rfc8259). For the ThingSet protocol, JSON data must be in the most compact form, i.e. not contain any unnecessary whitespaces or line breaks.
5
+
For rule names prefixed with `json-` consider the JSON specification in [RFC 8259](https://tools.ietf.org/html/rfc8259). In context of the ThingSet protocol, JSON data must be in the most compact form, i.e. not contain any unnecessary whitespaces or line breaks.
6
6
7
7
### Requests
8
8
9
9
Each request message consists of a first character as the request method identifier, a path specifying the endpoint of the request and a JSON string for the payload data (if applicable).
@@ -30,31 +30,33 @@ The path to access a specific node is a JSON pointer ([RFC 6901](https://tools.i
30
30
31
31
### Response
32
32
33
-
The response starts with a colon ':' followed by the the status code and a plain text description of the status finished with a '.'. The description message content is not strictly specified and can be either the description from the table in the [General Concept chapter](2a_general.md) or a more verbose message. However, it must contain only one dot at the end of the description, signifying the end of the description.
33
+
The response starts with a colon ':' followed by the the status code and a plain text description of the status finished with a '.'. The description is not strictly specified and can be according to the table in the [General Concept chapter](2a_general.md) or a more verbose message. However, it must contain only one dot at the end of the description, signifying the end of the description.
34
34
35
35
The bytes after the dot contain the requested data.
36
36
37
-
response = ":" status [ " " json-value ] ; response code and data
37
+
txt-response = ":" status [ " " json-value ] ; response code and data
38
38
39
39
status = status-code [ " " status-msg ] "."
40
40
41
41
status-code = 2( hex )
42
42
43
43
status-msg = *( ALPHA / SP )
44
44
45
-
hex = DIGIT / %x41-46 ; upper-case HEXDIG
45
+
hex = DIGIT / %x41-46 ; upper-case HEXDIG
46
46
47
47
### Publication message
48
48
49
-
pub-msg = "# " json-map ; publication message
49
+
The publication message is very simple and consists of a hash sign and a whitespace at the beginning, followed by a map of data node name/value pairs.
50
+
51
+
txt-pubmsg = "# " json-map ; publication message
50
52
51
53
## Read data
52
54
53
-
The GET function allows to read all child nodes of the specified path. If a forward slash is appended at the end of the path, only an array with the node names of the next level is returned. Otherwise all content below that path (names and values) is returned.
55
+
The GET function allows to read all child nodes of the specified path. If a forward slash is appended at the end of the path, only an array with the child node names is returned. Otherwise all content below that path (names and values) is returned.
54
56
55
57
The FETCH function allows to retrieve only subset of the child nodes, defined by an array with the node names passed to the function.
56
58
57
-
Only those data objects are returned which are at least readable. Thus, the result might differ after authentication.
59
+
Only those data nodes are returned which are at least readable. Thus, the result might differ after authentication.
58
60
59
61
**Example 1:** Discover all child nodes of the root node (i.e. categories)
60
62
@@ -64,7 +66,7 @@ Only those data objects are returned which are at least readable. Thus, the resu
64
66
**Example 2:** Retrieve all content of output path (keys + values)
**Example 3:** List all sub-nodes of output path as an array
70
72
@@ -80,7 +82,7 @@ Only those data objects are returned which are at least readable. Thus, the resu
80
82
81
83
Requests to overwrite the value of a data node.
82
84
83
-
Data of category *conf* will be written into persistent memory, so it is not allowed to change settings periodically. Only data of category *input* can be changed regularly.
85
+
Data of category conf will be written into persistent memory, so it is not allowed to change settings periodically. Only data of category input can be changed regularly.
84
86
85
87
**Example 1:** Disable charging
86
88
@@ -121,22 +123,20 @@ Executes a function identified by a data object name of category "exec"
121
123
122
124
## Authentication
123
125
124
-
Some of the device parameters like calibration or config settings should be protected against unauthorized change. The protocol provides a simple authentication method. Multiple user levels can be implemented in the firmware using different passwords. The manufacturer would use a different one to authenticate than a normal user and thus get more rights to access data objects.
126
+
Some of the device parameters like calibration or config settings should be protected against unauthorized change. A simple authentication method is suggested where multiple user levels can be implemented in the firmware using different passwords. The manufacturer would use a different one to authenticate than a normal user and thus get more rights to access data objects.
125
127
126
128
The password is transferred as a plain text string. Encryption has to be provided by lower layers.
127
129
128
130
Internally, the authentication function is implemented as a data node of exec type.
129
131
130
-
!exec/auth "mypass"
132
+
!auth "mypass"
131
133
:83 Valid.
132
134
133
-
After successful authentication, the device exposes restricted data objects via the normal data object access commands. The authentication stays valid until another auth command is received, either without password or with a password that doesn't match.
135
+
After successful authentication, the device exposes restricted data nodes via the normal data access requests. The authentication stays valid until another auth command is received, either without password or with a password that doesn't match.
134
136
135
137
## Publication messages
136
138
137
-
A publication request configures the device to publish certain data on a regular basis through a defined communication channel (UART, CAN, LoRa, etc.). If implemented in the firmware, the publication interval may be adjustable.
138
-
139
-
The publication subsystem is configured via the pub endpoint.
139
+
The pub node is used to configure the device to publish certain data on a regular basis through a defined communication channel (UART, CAN, LoRa, etc.). If implemented in the firmware, the publication interval may be adjustable.
140
140
141
141
**Example 1:** List all available publication channels
142
142
@@ -148,10 +148,10 @@ The publication subsystem is configured via the pub endpoint.
148
148
?pub/serial {"Enable":true}
149
149
:84 Changed.
150
150
151
-
With this setting, the following message is automatically sent by the device once per hour:
151
+
With this setting, the following message is automatically sent by the device once per second:
152
152
153
153
# {"Bat_V":14.1,"Bat_A":5.13}
154
154
155
155
Publication messages are broadcast to all connected devices. No response is sent from devices receiving the message.
156
156
157
-
The data nodes to be published in each message can be configured using POST and DELETE requests to the pub/serial/IDs channel, as shown in the examples above.
157
+
The data nodes to be published in each message can be configured using POST and DELETE requests to the pub/serial/IDs endpoint, as shown in the examples above.
0 commit comments