27 lines
712 B
Markdown
27 lines
712 B
Markdown
Two new built-in functions `sparkplug_decode` and `sparkplug_encode` have been added to the rule engine SQL like language. These functions are used to decode and encode Sparkplug B messages. The functions are used as follows:
|
|
|
|
Decode a Sparkplug B message:
|
|
|
|
```sql
|
|
select
|
|
sparkplug_decode(payload) as decoded
|
|
from t
|
|
|
|
```
|
|
|
|
Encode a Sparkplug B message:
|
|
|
|
```sql
|
|
select
|
|
sparkplug_encode(json_decode(payload)) as encoded
|
|
from t
|
|
```
|
|
|
|
One can also specify a Sparkplug B message type by specifying it as the second argument to the `sparkplug_decode` and `sparkplug_encode` functions. The default is `Payload`:
|
|
|
|
```sql
|
|
select
|
|
sparkplug_encode(sparkplug_decode(payload, 'Payload'), 'Payload') as encoded
|
|
from t
|
|
```
|