<repo_name>Nalox1/iotsystem<file_sep>/webservice/src/main/webapp/dashboardWebsocket.js
var wsRealtime;
var wsHistory;
var pathRealtime = "ws://" + location.hostname + (location.port ? ":" + location.port: "") + "/webservice/websocket/realtime/dashboard";
var pathHistory = "ws://" + location.hostname + (location.port ? ":" + location.port: "") + "/webservice/websocket/history";

function connectRealtime()
{    
    wsRealtime = new WebSocket(pathRealtime);
    
    wsRealtime.onmessage = function(event)
    {
        var receivedObject = JSON.parse(event.data);
        var measurementString = receivedObject.description;
        measurementString += "<br>" + receivedObject.dateTime;
    
        if (receivedObject.hasOwnProperty("temperature"))
        {
            measurementString += "<br>Temperature: " + receivedObject.temperature + " °C";
        }

        if (receivedObject.hasOwnProperty("humidity"))
        {
            measurementString += "<br>Humidity: " + receivedObject.humidity + " %";
        }

        if (receivedObject.hasOwnProperty("radiation"))
        {
            measurementString += "<br>Radiation: " + receivedObject.radiation + " µSv/h";
        }

        if (receivedObject.hasOwnProperty("light"))
        {
            measurementString += "<br>Light: " + receivedObject.light + " lux";
        }

        document.getElementById(receivedObject.mac).innerHTML = measurementString;
    };
}

function connectHistory()
{
    console.log("Connecting to history websocket...");
    wsHistory = new WebSocket(pathHistory);
    console.log("Connected to history websocket.");

    wsHistory.onmessage = function(event)
    {
        document.getElementById("history").innerHTML = event.data;
        console.log(event.data);
    };
}<file_sep>/device/esp8266-01/config.h
#define DEVICE_ID WiFi.macAddress()
#define DEVICE_SEND_INTERVAL 1000
#define DHT_PIN 2
#define DHT_TYPE DHT11
#define MESSAGE_MAX_LEN 256
#define WEBSOCKET_PATH_LENGTH 256

WebSocketClient websocketClient;
WiFiClient wifiClient;
unsigned long previousMillis = 0;

// WiFi settings
const static char* WIFI_SSID = "WIFI_SSID";
const static char* WIFI_PASS = "<PASSWORD>";

// Websocket settings
String connectionString = "/webservice/websocket/realtime/" + DEVICE_ID;
char* webserverHost = "echo.websocket.org";
const int webserverPort = 8080;
char websocketPath[WEBSOCKET_PATH_LENGTH];

// DHT11 Sensor
static DHT dht(DHT_PIN, DHT_TYPE);
