.
/*
This file describes the nats events that the u-sense app sends to the nats-server.
These events can be consumed by a user application, e.g. a NodeRed flow, by subscribing to the subject "US67-V1T-BLE".

Please note that this is an invalid json file as comments are not supported by JSON.
This file is only for documentation purposes.

There are five different event types that are published: deviceInfo, debug, timeDomain, freqDomain and error.

deviceInfo - Contains basic information about the sensor and its status. Gets sent once new telemetry is received or telemetry is missed.
timeDomain - Contains calculated metrics and statistics of the measured velocity and acceleration. Gets sent once new telemetry is received.
freqDomain - Contains the frequency domain specific telemetry data (FFT). Gets sent once new telemetry is received.
error      - This event indicates that something went wrong. The data contains an error reason and further information.
debug      - An extension to the deviceInfo event with additional fields for debugging. Always gets send alongside deviceInfo events.
             Contains expert info and is not documented in detail here.

During nominal operation, the u-sense app sends the events in a fixed order: deviceInfo, debug, timeDomain, freqDomain.
However, deviceInfo, debug and error events can additionally occur out of order in case of missed telemetry or errors.

Please see the examples and comments below for more information.
*/

//Device Info Event
{
    //Type of the event
    "eventType": "deviceInfo",
    //Event version. This will be changed each time the json format of the events changes, so that user applications can handle changes to the structure properly.
    "eventVersion": 2,
    //UTC timestamp in milliseconds since epoch (1. Jan 1970). 
    //Timestamp gets generated on the gateway once the event itself it created. Sending and receiving the event may be delayed slightly.
    "timestamp": 1720170808256,
    //MAC bluetooth address of the sensor that triggered the event
    "sensorAddress": "00:15:7e:30:28:a3",
    //This is the begin of the actual event payload, all previous fields are standard event header
    "data": {
        //Fw Version of the sensor. Changes after DFU.
        "firmwareVersion": "1.1.0",
        //HW Revision of the sensor
        "hardwareRevision": "01.04.00",
        //Sensor manufacturer
        "manufacturer": "Weidmueller",
        //Model name
        "model": "u-sense vibration 1",
        //Serial number of sensor
        "serialNumber": "AW5U24PA5200114",
        //Version of the Trusted Object on the Sensor.
        "trustedObjectVersion": "4.8.0",
        "config": {
            //Name of the sensor as given by the user during onboarding
            "name": "US67-V1T-BLE_00:15:7E:30:28:A3",
            //Transmission interval of the sensor in seconds
            "transmissionInterval": 10
        },
        "status": {
            //How many telemetries have been missed since the last successful receive.
            //The app will try to receive the telemetry from the sensor regularly, depending on the transmissionInterval.
            //Once a certain tolerance has passed and no connection the sensor could be established, the telemetry is considered missed.
            //This can happen because the sensor is offline or due to heavy interference of the bluetooth channel, or a weak signal.
            "missedTelemetry": 3,
            //First successful connection to the sensor (UTC timestamp in milliseconds since epoch (1. Jan 1970) )
            "firstConnectionTimestamp": 1720089240320
        },
        "lastTransmission": {
            //Timestamp of the last successful transmission of telemetry.
            //This is a UTC timestamp in milliseconds since epoch (1. Jan 1970). 
            "timestamp": 1720170754244,
            //Last received battery voltage in mV
            "batteryVoltage": 3434,
            //Last received Bluetooth RSSI (Received Signal Strength Indicator)
            "rssi": -51
        }
    }
}
//Time domain Event
{
    //Same header as all other events, see deviceInfo for more documentation
    "eventType": "timeDomain",
    "eventVersion": 2,
    "timestamp": 1720170755063,
    "sensorAddress": "00:15:7e:30:28:a3",
    "data": {
        //Root mean square calculation of the velocity of the vibration sensor data for all 3 dimensions in mm/s
        "vRms": {
            "x": 0.1449439,
            "y": 0.07145125,
            "z": 0.08111124
        },
        //Root mean square calculation of the acceleration of the vibration sensor data for all 3 dimensions in mm/s^2
        "aRms": {
            "x": 22.585985,
            "y": 22.82983,
            "z": 27.110014
        },
        //Peek to peek calculation of the acceleration for all 3 dimensions in mm/s^2
        "aP2P": {
            "x": 180.10251,
            "y": 169.76021,
            "z": 241.1409
        },
        //Mean value of the acceleration for all 3 dimensions in mm/s^2
        "aMean": {
            "x": 0.5542694,
            "y": 0.430234,
            "z": 0.3944679
        },
        //Variance of the acceleration for all 3 dimensions in mm^2/s^4
        "aVariance": {
            "x": 509.8187,
            "y": 521.0164,
            "z": 734.7965
        },
        //Unitless skewness of the acceleration for all 3 dimensions
        "aSkewness": {
            "x": -0.021945,
            "y": 0.08594923,
            "z": 0.064247444
        },
        //Unitless kurtosis of the acceleration for all 3 dimensions
        "aKurtosis": {
            "x": 3.3025165,
            "y": 3.047971,
            "z": 3.5335486
        },
        //Unitless crest factor of the acceleration for all 3 dimensions
        "aCrest": {
            "x": 3.97512,
            "y": 3.5886142,
            "z": 4.32128
        },
        //Temperature in degrees celcius
        "temperature": 23.6
    }
}
//Frequency Domain Event
{
    //Same header as all other events, see deviceInfo for more documentation
    "eventType": "frequencyDomain",
    "eventVersion": 2,
    "timestamp": 1720170627455,
    "sensorAddress": "00:15:7e:30:28:a3",
    "data": {
        //The real sampling rate of the sensor in Hz. 
        //Each sensor has a slightly different sampling rate, but FFT data gets unified and interpolated to match between sensors automatically
        "sensorOdr": 7126,
        //FFT data of the vibration measurement for all 3 dimensions. Contains 3301 data points for each axis. 
        //The index equals the frequency in Hz (0..3300) while the value is the acceleration amplitude in mm/s^2
        "fft": {
            //Note: These are just random example values to explain the structure of the data
            "axisData": {
                "x": [
                    0,
                    1,
                    0,
                    0,
                    0, //... FFT values continue here
                ],
                "y": [
                    0,
                    0,
                    0,
                    0,
                    0, //... FFT values continue here
                ],
                "z": [
                    0,
                    0,
                    1,
                    0,
                    2, //... FFT values continue here
                ]
            }
        }
    }
}
//Error Event
{
    //Same header as all other events, see deviceInfo for more documentation
    "eventType": "error",
    "eventVersion": 2,
    "timestamp": 1718348732000,
    "sensorAddress": "00:15:7e:30:28:a3",
    "data": {
        "error": {
            //Error code, currently only 255 is used
            "code": 255,
            //Description of the error
            "message": "Possible deadlock condition. Please restart the gateway if condition persists"
        }
    }
}
//Debug Event
//Included for completeness, but not documented as it is meant for expert users only.
{
    //Same header as all other events, see deviceInfo for more documentation
    "eventType": "debug",
    "eventVersion": 2,
    "timestamp": 1720170808256,
    "sensorAddress": "00:15:7e:30:28:a3",
    "data": {
        "config": {
            "cachedHash": "0a00000000000000000000000000000000000000000000000000000000000000",
            "version": 0,
            "pendingConfig": false,
            "newConfig": null
        },
        "dfu": {
            "pendingVersion": "None",
            "dfuRetryCount": 0,
            "dfuLastResult": 0
        },
        "lastTransmission": {
            "powerOnReason": 0,
            "errorStatus": "0000000000000000"
        },
        "status": {
            "removeBonding": false,
            "dfuState": 0,
            "missedTelemetry": 3,
            "connectableAdv": true
        }
    }
}