my code stock.com

ESP-Server protocol

Snippet options

Download: Download snippet as protocol.js.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

var protocol = {
    "deviceInfo": {
        "name": "Thermo",
        "description": "Termo device that measure temp and humidity",
        "versionFirmware": 1,
        "macAddress": "34235235255",
        "availableCommands": ["changeCommunicationConfig", "updateFirmware", "startDebug"],
        //More info here
    },
    "deviceConfig": {
        "data": [
            {
                "type": "CommunicationConfig",
                "version": 1,
                "wifiName": "SimplyHomeWIFI",
                "wifiPassword": "fWd3fdwWdff4çda4d",
                "serverAddress": "server.simplyhome.tech",
                "serverPort": "80",
                "protocol": "https",
                "fingerprint": "4F:4f:2E:2T:EF:AC:23:23"
            }    
            //More configs
        ]
    },
    "deviceState": {
        "data": [
            {
                "type": ["System", "Hardware", "memory"],
                "description": "Memory available",
                "unit": "Byte",
                "value": "23000000"
            },
            {
                "type": ["Runtime", "Mode"],
                "description": "Current mode",
                "unit": "Mode type",
                "value": "Debug"
            },
            {
                "type": ["Hardware", "Battery"],
                "description": "Battery voltage",
                "unit": "Volt",
                "value": "4.23"
            },
            {
                "type": ["Software", "Logs"],
                "description": "Last N logs, N is defined in the device config",
                "listLogs": [
                    {
                        "code": 342342, //00000000000001100101
                        "timestamp": 12341241234907
                    },
                    {
                        "code": 2342342,
                        "timestamp": 21234141242334
                    }
                ]
            }
            //More states
        ]
    },
    "sensorMeasurement": {
        "numberSensors": "2",
        "data": [
            {
                "type": "Temperature",
                "values": [
                    {
                        "unit": "°C",
                        "value": "24"
                    }
                ]
            },
            {
                "type": "Humidity",
                "values": [
                    {
                        "unit": "%",
                        "value": "30"
                    }
                ]
            }
            //More sensors measurements
        ]
    },
    "deviceActions": {
        "commandsQueue": [
            {
                "commandName": "changeCommunicationConfig",
                "timestamp": "104423423423", // Identificatore univoco del comando per poterlo verificare poi dai logs per esempio
                "data": {
                    "version": 1,
                    "wifiName": "Bel comune",
                    "wifiPassword": "afdasdfasfasefae",
                    "serverAddress": "server.simplyhome.com",
                    "serverPort": "80",
                    "protocol": "https",
                    "fingerprint": "FG:45:FF:45:EF:AC:ZZ:AA"
                }
            }
            //More commands not yet executed on the devices
        ]
    }
}

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.