{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$id": "https://apidocs.iqrf.org/openapi/iqrf-gateway-webapp/v2.7.0-rc3/schemas/controllerConfig.json",
    "type": "object",
    "title": "IQRF Gateway Controller configuration",
    "description": "Schema of the Controller configuration file.",
    "examples": [
        {
            "daemonApi": {
                "autoNetwork": {
                    "actionRetries": 1,
                    "discoveryBeforeStart": true,
                    "discoveryTxPower": 6,
                    "skipDiscoveryEachWave": false,
                    "stopConditions": {
                        "abortOnTooManyNodesFound": false,
                        "emptyWaves": 2,
                        "waves": 2
                    },
                    "returnVerbose": false
                },
                "discovery": {
                    "maxAddr": 0,
                    "txPower": 6,
                    "returnVerbose": false
                }
            },
            "factoryReset": {
                "coordinator": false,
                "daemon": true,
                "network": false,
                "webapp": false
            },
            "logger": {
                "severity": "info",
                "sinks": {
                    "file": true,
                    "syslog": false
                }
            },
            "powerOff": {
                "sda": -1,
                "sck": -1
            },
            "resetButton": {
                "api": "autoNetwork",
                "button": 2
            },
            "statusLed": {
                "greenLed": 0,
                "redLed": 1
            },
            "wsServers": {
                "api": "ws://localhost:1338",
                "monitor": "ws://localhost:1438",
                "token": "iqrfgd2;1;ETi3v8RGLVGXb/uNenhskEiSH/2KussEbantcvjfGQ4="
            }
        }
    ],
    "required": [
        "daemonApi",
        "factoryReset",
        "logger",
        "powerOff",
        "resetButton",
        "statusLed",
        "wsServers"
    ],
    "additionalProperties": false,
    "properties": {
        "daemonApi": {
            "type": "object",
            "title": "Daemon API configuration",
            "description": "Configuration of Daemon API calls executed by controller.",
            "examples": [
                {
                    "autoNetwork": {
                        "actionRetries": 1,
                        "discoveryBeforeStart": true,
                        "discoveryTxPower": 6,
                        "skipDiscoveryEachWave": false,
                        "stopConditions": {
                            "abortOnTooManyNodesFound": false,
                            "emptyWaves": 2,
                            "waves": 2
                        },
                        "returnVerbose": false
                    },
                    "discovery": {
                        "maxAddr": 0,
                        "txPower": 6,
                        "returnVerbose": false
                    }
                }
            ],
            "required": [
                "autoNetwork",
                "discovery"
            ],
            "properties": {
                "autoNetwork": {
                    "type": "object",
                    "title": "AutoNetwork",
                    "description": "Configuration of the AutoNetwork Daemon API call.",
                    "examples": [
                        {
                            "actionRetries": 1,
                            "discoveryBeforeStart": true,
                            "discoveryTxPower": 6,
                            "skipDiscoveryEachWave": false,
                            "stopConditions": {
                                "abortOnTooManyNodesFound": false,
                                "emptyWaves": 2,
                                "waves": 2
                            },
                            "returnVerbose": false
                        }
                    ],
                    "required": [
                        "actionRetries",
                        "discoveryBeforeStart",
                        "discoveryTxPower",
                        "skipDiscoveryEachWave",
                        "stopConditions",
                        "returnVerbose"
                    ],
                    "properties": {
                        "actionRetries": {
                            "type": "integer",
                            "title": "Number of retry DPA transactions",
                            "minimum": 0,
                            "maximum": 3,
                            "default": 1,
                            "example": 1
                        },
                        "discoveryBeforeStart": {
                            "type": "boolean",
                            "title": "Run Discovery before the AutoNetwork process begins",
                            "default": true,
                            "example": true
                        },
                        "discoveryTxPower": {
                            "type": "integer",
                            "title": "TX power",
                            "minimum": 0,
                            "maximum": 7,
                            "default": 6,
                            "example": 6
                        },
                        "skipDiscoveryEachWave": {
                            "type": "boolean",
                            "title": "Skip Discovery in each wave",
                            "default": false,
                            "example": false
                        },
                        "stopConditions": {
                            "type": "object",
                            "title": "AutoNetwork process stop conditions",
                            "examples": [
                                {
                                    "abortOnTooManyNodesFound": false,
                                    "emptyWaves": 2,
                                    "waves": 2
                                }
                            ],
                            "required": [
                                "abortOnTooManyNodesFound",
                                "emptyWaves",
                                "waves"
                            ],
                            "properties": {
                                "abortOnTooManyNodesFound": {
                                    "type": "boolean",
                                    "title": "Abort Autonetwork if too many nodes were found",
                                    "default": false,
                                    "example": false
                                },
                                "emptyWaves": {
                                    "type": "integer",
                                    "title": "Empty waves",
                                    "description": "Number of consecutive AutoNetwork waves with no new nodes found.",
                                    "minimum": 1,
                                    "maximum": 127,
                                    "default": 2,
                                    "example": 2
                                },
                                "waves": {
                                    "type": "integer",
                                    "title": "Waves",
                                    "description": "Maximum number of AutoNetwork waves.",
                                    "minimum": 1,
                                    "maximum": 127,
                                    "default": 2,
                                    "example": 2
                                }
                            },
                            "additionalProperties": false
                        },
                        "returnVerbose": {
                            "type": "boolean",
                            "title": "Verbose mode",
                            "default": false,
                            "example": false
                        }
                    },
                    "additionalProperties": false
                },
                "discovery": {
                    "type": "object",
                    "title": "Discovery",
                    "description": "Configuration of the Discovery Daemon API call.",
                    "examples": [
                        {
                            "maxAddr": 0,
                            "txPower": 6,
                            "returnVerbose": false
                        }
                    ],
                    "required": [
                        "maxAddr",
                        "txPower",
                        "returnVerbose"
                    ],
                    "properties": {
                        "maxAddr": {
                            "type": "integer",
                            "title": "Maximum address",
                            "minimum": 0,
                            "maximum": 239,
                            "default": 0,
                            "example": 0
                        },
                        "txPower": {
                            "type": "integer",
                            "title": "TX power",
                            "minimum": 0,
                            "maximum": 7,
                            "default": 6,
                            "example": 6
                        },
                        "returnVerbose": {
                            "type": "boolean",
                            "title": "Verbose mode",
                            "default": false,
                            "example": false
                        }
                    },
                    "additionalProperties": false
                }
            },
            "additionalProperties": false
        },
        "factoryReset": {
            "type": "object",
            "title": "Factory reset",
            "description": "Configuration of the Factory reset action.",
            "examples": [
                {
                    "coordinator": false,
                    "daemon": true,
                    "network": false,
                    "webapp": false
                }
            ],
            "required": [
                "coordinator",
                "daemon",
                "network",
                "webapp"
            ],
            "properties": {
                "coordinator": {
                    "type": "boolean",
                    "title": "Reset Coordinator",
                    "default": false,
                    "example": false
                },
                "daemon": {
                    "type": "boolean",
                    "title": "Daemon",
                    "default": true,
                    "example": true
                },
                "iqaros": {
                    "type": "boolean",
                    "title": "Reset IQAROS",
                    "default": false,
                    "example": false
                },
                "network": {
                    "type": "boolean",
                    "title": "Reset network",
                    "default": false,
                    "example": false
                },
                "webapp": {
                    "type": "boolean",
                    "title": "Reset webapp",
                    "default": false,
                    "example": false
                }
            },
            "additionalProperties": false
        },
        "logger": {
            "type": "object",
            "title": "Logger configuration",
            "examples": [
                {
                    "severity": "info",
                    "sinks": {
                        "file": true,
                        "syslog": false
                    }
                }
            ],
            "required": [
                "severity",
                "sinks"
            ],
            "properties": {
                "severity": {
                    "type": "string",
                    "title": "Severity",
                    "description": "Specifies the level of logged information.",
                    "default": "info",
                    "enum": [
                        "debug",
                        "error",
                        "info",
                        "trace",
                        "warning"
                    ],
                    "example": "info"
                },
                "sinks": {
                    "type": "object",
                    "title": "Logger sinks",
                    "required": [
                        "file",
                        "syslog"
                    ],
                    "additionalProperties": false,
                    "properties": {
                        "file": {
                            "type": "boolean",
                            "title": "Log to file",
                            "example": true
                        },
                        "syslog": {
                            "type": "boolean",
                            "title": "Log to syslog",
                            "example": false
                        }
                    }
                }
            },
            "additionalProperties": false
        },
        "powerOff": {
            "type": "object",
            "title": "Power off pin configuration",
            "additionalProperties": false,
            "examples": [
                {
                    "sda": 12,
                    "sck": 12
                }
            ],
            "required": [
                "sda",
                "sck"
            ],
            "properties": {
                "sda": {
                    "type": "integer",
                    "title": "Data pin",
                    "description": "I2C data line pin.",
                    "example": 12
                },
                "sck": {
                    "type": "integer",
                    "title": "Clock pin",
                    "description": "I2C clock line pin.",
                    "example": 11
                }
            }
        },
        "resetButton": {
            "type": "object",
            "title": "Reset button configuration",
            "examples": [
                {
                    "api": "autoNetwork",
                    "button": 2
                }
            ],
            "required": [
                "api",
                "button"
            ],
            "properties": {
                "api": {
                    "type": "string",
                    "title": "API call",
                    "description": "Daemon API call to be executed by the controller, empty string = no API call.",
                    "enum": [
                        "",
                        "autoNetwork",
                        "discovery"
                    ],
                    "default": "",
                    "examples": [
                        "autoNetwork",
                        "discovery"
                    ]
                },
                "button": {
                    "type": "integer",
                    "title": "Button pin",
                    "default": 2,
                    "example": 2
                }
            },
            "additionalProperties": false
        },
        "statusLed": {
            "type": "object",
            "title": "Status LED configuration",
            "examples": [
                {
                    "greenLed": 0,
                    "redLed": 1
                }
            ],
            "required": [
                "greenLed",
                "redLed"
            ],
            "properties": {
                "greenLed": {
                    "type": "integer",
                    "title": "Green LED pin",
                    "default": 0,
                    "example": 0
                },
                "redLed": {
                    "type": "integer",
                    "title": "Red LED pin",
                    "default": 1,
                    "example": 1
                }
            },
            "additionalProperties": false
        },
        "wsServers": {
            "type": "object",
            "title": "Websocket servers",
            "description": "Addresses and ports for websocket connections.",
            "examples": [
                {
                    "api": "ws://localhost:1338",
                    "monitor": "ws://localhost:1438",
                    "token": "iqrfgd2;1;ETi3v8RGLVGXb/uNenhskEiSH/2KussEbantcvjfGQ4="
                }
            ],
            "required": [
                "api",
                "monitor",
                "token"
            ],
            "additionalProperties": false,
            "properties": {
                "api": {
                    "type": "string",
                    "title": "websocket API",
                    "description": "API websocket connection address and port.",
                    "example": "ws://localhost:1338"
                },
                "monitor": {
                    "type": "string",
                    "title": "The monitor schema",
                    "description": "Monitor websocket connection address and port.",
                    "example": "ws://localhost:1438"
                },
                "token": {
                    "type": "string",
                    "title": "Access token",
                    "description": "Daemon WebSocket API access token.",
                    "example": "iqrfgd2;1;ETi3v8RGLVGXb/uNenhskEiSH/2KussEbantcvjfGQ4="
                }
            }
        }
    }
}
