Golang module for Signaling Media Language (SigML)
SigML is to error messages and events what SenML is for sensor data. SigML can express events, errors and alerts. And even embedd SenML data.
SigML is based on JSON and tries to use the same name and notatons as SenML, where possible.
This is the Base name from SenML.
This is the Base time from SenML, expressed as seconds from 1970-0101 00:00 (UNIX epoch).
This is the Base version from SenML. Set to 1 for now.
x stands for eXception and is used for indicating exceptions upstream.
e stands for Error and is used for indicating different typs of hardware, software and system errors upstream.
s stands for Signal event and is used for transmitting events upstream.
se means Severity and is used to indicate how serious an exception/error/signal is.
None Severity : 0 Normal : 1 Incident : 50 Error : 100 Critical : 200 Catastrophic : 255
d stands for Description is is a human readable text indicating what has happened.
p is used for sending generic payloads, such as SenML encoded data belonging to an error or similiar.
[
{"bn": "urn:dev:mac:00170d451f62:", "bt": 176627612.2, "n": "sensor/gps", "x": "Sensor malfuction", "se": 200, "d": "GPS sensor not connected"},
{"n": "co2/0", "e": "Bad sensor reading", "se": 200, "d": "Negative value -4 ppm"},
{"n": "temperature/0", "e": "Bad sensor reading", "se": 200, "d": "Outside sensing range(-40 to +85): 6387.4"}
{"n": "battery", "e": "Low battery level", "se": 100, "d": "Battery at 12% capacity"}
]
[
{"bn": "urn:dev:name:twg0043:", "bt": 176627612.2, "n": "/dev/sda0", "x": "Storage full", "se": 255, "d": "Disk 100.0% full"},
{"n": "wlan0", "e": "Disconnected", "se": 100, "d": "Connection lost"},
{"n": "ufw", "x": "Disabled", "se": 100, "d": "Firewall disabled"}
]
Install
go get github.com/thingwave/go-sigml
First import using
import (
"fmt"
"time"
"encoding/json"
"github.com/thingwave/go-sigml"
)
Create message using:
var evt sigml.SigMLMessage
head := sigml.SigMLRecord{Bn: "urn:dev:mac:00170d451f62:", Bt: float64(time.now().Unixmilli())/1000.0, Bver: 1}
evt = append(evt, head)
payload, err := json.Marshal(evt)
if err == nil {
fmt.Printf("%s\n", string(payload))
}