OneNET supports user-defined data forwarding rules based on data stream
OneNET supports the user to use regular expression to self-define the filtering and matching rules for data stream names when filtering
The reference filter expression is:
.*
Expression syntax:
Data stream name
Or
^Data stream name $
Example: If you need to select only the data stream ccc from aaa, bbb, ccc data streams, the reference filter expression is:
ccc
Or
^ccc$
Expression syntax:
Data stream name 1 | data stream name 2 | data stream name 3
Or
^Data stream name 1$|^Data stream name 2$|^Data stream name 3$
If you need to select only the data streams aaa, ccc, from aaa, bbb, and ccc data streams, the reference filter expression is: aaa|ccc
Or
^aaa$|^ccc$
(1) If you need to select only the data stream (abc, bcd) containing bc from abc, bcd, cde data streams, the reference filter expression is:
.*bc.*
(2) If you need to select only test0 test1 test2 from test0, test1, test2, test3, abctest0 data streams, the reference filter expression is:
^test[0-2]
If you need to select only test0 test01 humi2 from test0, test01, humi2, humi3, abctest0 data streams, the reference filter expression is:
^test0.*|humi2
The data filtered by the rules is distributed to subsequent services in a uniform data format (json). The data format is as follows:
The message in the forward data stream is actually a new data point (deviceDatapoint) in the forward data stream. The data format is as follows:
Parameter | Property | Format | Description | Example |
---|---|---|---|---|
sysProperty | messageType | String | Message type: Fixed as deviceDatapoint | |
timestamp | Int | The timestamp of the message using the rule engine, unix time, in second | 15980987429 | |
productId | string | Product ID | 90273 | |
appProperty | deviceId | String | Device ID | 102839 |
dataTimestamp | Int | Device data point production timestamp, which can be self-defined and carried when uploading | 15980987429 | |
datastream | string | Data stream name | weather | |
body | object/string | Detailed message content of data point | See the example below |
Data json example 1, json data
{
"sysProperty": {
"messageType": "deviceDatapoint",
"timestamp": 15980987429,
"productId": "90273",
},
"appProperty":{
"deviceId": "102839",
"dataTimestamp": 15980987429,
"datastream":"weather"
},
"body":{
"temperature": 30,
"humidity": "47%"
}
}
Data json example 2, string data
{
"sysProperty": {
"messageType": "deviceDatapoint",
"timestamp": 15980987429,
"productId": "90273",
},
"appProperty":{
"deviceId": "102839",
"dataTimestamp": 15980987429,
"datastream":"weather"
},
"body":"sunny with wind"
}
Data json example 3, binary data
{
"sysProperty": {
"messageType": "deviceDatapoint",
"timestamp": 15980987429,
"productId": "90273",
},
"appProperty":{
"deviceId": "102839",
"dataTimestamp": 15980987429,
"datastream":"weather"
},
"body":{
"index": "3491506_1475204886914_bin"
}
}