{
    "$id": "https://openwrt.org/ucentral.state.json",
    "$schema": "http://json-schema.org/draft-07/schema#",
    "description": "OpenWrt uCentral state schema",
    "type": "object",
    "properties": {
        "version": {
            "type": "number",
            "const": 1
        },
        "uuid": {
            "description": "The unique ID of the configuration. This is the unix timestamp of when the config was created.",
            "type": "integer"
        },
        "serial": {
            "description": "The unique serial number of the device.",
            "type": "string"
        },
        "unit": {
            "$ref": "#/$defs/unit"
        },
        "gps": {
            "$ref": "#/$defs/gps"
        },
        "radios": {
            "$ref": "#/$defs/radio"
        },
        "interfaces": {
            "$ref": "#/$defs/interface"
        },
        "lldp-peers": {
            "type": "object",
            "properties": {
                "upstream": {
                    "type": "object",
                    "patternProperties": {
                        "^(eth|lan|wan)[0-9]*$": {
                            "$ref": "#/$defs/lldp-peers"
                        }
                    }
                },
                "downstream": {
                    "type": "object",
                    "patternProperties": {
                        "^(eth|lan|wan)[0-9]*$": {
                            "$ref": "#/$defs/lldp-peers"
                        }
                    }
                }
            }
        },
        "link-state": {
            "type": "object",
            "properties": {
                "upstream": {
                    "type": "object",
                    "patternProperties": {
                        "^(eth|lan|wan)[0-9]*$": {
                            "$ref": "#/$defs/link-state"
                        }
                    }
                },
                "downstream": {
                    "type": "object",
                    "patternProperties": {
                        "^(eth|lan|wan)[0-9]*$": {
                            "$ref": "#/$defs/link-state"
                        }
                    }
                }
            }
        }
    },
    "$defs": {
        "unit": {
            "type": "object",
            "description": "This section describes the current state of the OS running on the device.",
            "properties": {
                "load": {
                    "type": "array",
                    "description": "This array hold 3 values describing the average system load for the last 1, 5 and 15 minutes.",
                    "items": {
                        "type": "number"
                    }
                },
                "localtime": {
                    "type": "number",
                    "description": "This property contains the current unix time of the device."
                },
                "memory": {
                    "type": "object",
                    "description": "This section describes the current memory uasge of the device.",
                    "properties": {
                        "free": {
                            "type": "number",
                            "description": "The amount of free memory."
                        },
                        "total": {
                            "type": "number",
                            "description": "The total amount of memory."
                        },
                        "cached": {
                            "type": "number",
                            "description": "The total amount of cached memory."
                        },
                        "buffered": {
                            "type": "number",
                            "description": "The total amount of buffered memory."
                        }
                    }
                },
                "uptime": {
                    "type": "number",
                    "description": "The number of seconds since the unit last booted."
                },
                "temperature": {
                    "description": "The average and maximum thermal reading from the CPU.",
                    "type": "array",
                    "items": {
                        "type": "number"
                    }
                },
                "poe": {
                    "description": "This section describes the current state of the PoE unit on the device",
                    "type": "object",
                    "properties": {
                        "max-power-budget": {
                            "description": "Reports the total power available (power budget) (in watts, W) device's Power sourcing equipment is able to source.",
                            "type": "number"
                        },
                        "power-threshold": {
                            "description": "Reports configured power alarm threshold value for the Power sourcing equipment (in milliwatts, mW).",
                            "type": "number"
                        },
                        "power-consumed": {
                            "description": "Reports a total power Powered Devices are draining from the device's Power sourcing equipment (in milliwatts, mW).",
                            "type": "number"
                        },
                        "power-status": {
                            "description": "Reports power status of the device's Power sourcing equipment.",
                            "type": "string",
                            "examples": [
                                "ON",
                                "OFF"
                            ]
                        }
                    }
                }
            }
        },
        "gps": {
            "type": "object",
            "description": "This section describes the GPS location of the device.",
            "properties": {
                "latitude": {
                    "type": "number",
                    "description": "The latitude in WGS84."
                },
                "longitude": {
                    "type": "number",
                    "description": "The longitude in WGS84."
                },
                "elevation": {
                    "type": "number",
                    "description": "The elevation above sea level in meters."
                }
            }
        },
        "radio": {
            "type": "array",
            "description": "An array containing the current operational state of all wifi radios that the unit has.",
            "items": {
                "type": "object",
                "properties": {
                    "channel": {
                        "description": "The primary channel that the radio is currently operating on.",
                        "type": "number"
                    },
                    "channels": {
                        "description": "The list of all channels that the radio is currently operating on.",
                        "type": "array",
                        "items": {
                            "type": "number"
                        }
                    },
                    "frequency": {
                        "description": "The list of all frequencies that the radio is currently operating on.",
                        "type": "array",
                        "items": {
                            "type": "number"
                        }
                    },
                    "channel_width": {
                        "type": "number",
                        "description": "The channel width currently being used.",
                        "enum": [
                            20,
                            40,
                            80,
                            160,
                            320
                        ]
                    },
                    "tx_power": {
                        "type": "number",
                        "description": "The currently configure TX power of the radio in dBm."
                    },
                    "phy": {
                        "type": "string",
                        "description": "The unique path identifying the radio"
                    },
                    "band": {
                        "description": "The wireless band that the radio is currently operating on.",
                        "type": "array",
                        "items": {
                            "type": "string"
                        }
                    },
                    "temperature": {
                        "description": "The current temperature of the Wireless radio.",
                        "type": "number"
                    }
                }
            }
        },
        "interface.ipv4-lease": {
            "type": "array",
            "items": {
                "type": "object",
                "description": "This section describes an IPv4 lease that we have served",
                "properties": {
                    "address": {
                        "type": "string",
                        "description": "The IPv4 that has been assigned to the networking client."
                    },
                    "assigned": {
                        "type": "string",
                        "description": "The unix time stamp when this lease was assigned."
                    },
                    "hostname": {
                        "type": "string",
                        "description": "The hostname that the client included in his request."
                    },
                    "mac": {
                        "type": "string",
                        "description": "The MAC address of the client that this lease was assigned to."
                    }
                }
            }
        },
        "interface.ipv4": {
            "type": "object",
            "properties": {
                "addresses": {
                    "type": "array",
                    "description": "The list of IPv4 addresses being used by this logical interface.",
                    "items": {
                        "type": "string",
                        "description": "An IPv4 addreess."
                    }
                },
                "leasetime": {
                    "type": "number",
                    "description": "This is the leasetime if the IPv4 address of this logical interface was acquired via DHCPv4."
                },
                "dhcp_server": {
                    "type": "string",
                    "description": "The IPv4 address of the DHCPv4 server that assigned the active lease."
                },
                "leases": {
                    "$ref": "#/$defs/interface.ipv4-lease"
                }
            }
        },
        "interface.ipv6-address": {
            "type": "array",
            "items": {
                "type": "object",
                "description": "An IPv6 address assigned to this logical interface.",
                "properties": {
                    "address": {
                        "type": "string",
                        "description": "The actual IPv6 address/mask"
                    },
                    "valid": {
                        "type": "number",
                        "description": "How much longer this delegation is valid for."
                    }
                }
            }
        },
        "interface.ipv6-lease": {
            "type": "array",
            "description": null,
            "items": {
                "type": "object",
                "description": "This section describes an IPv6 lease that we have served.",
                "properties": {
                    "addresses": {
                        "type": "array",
                        "description": "A list of all IPv6 addresses that were assigned to this host.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "hostname": {
                        "type": "string",
                        "description": "The hostname that the client sent in its solicit message."
                    }
                }
            }
        },
        "interface.clients": {
            "type": "array",
            "items": {
                "type": "object",
                "description": "This section describes a network neighbour.",
                "properties": {
                    "mac": {
                        "type": "string",
                        "description": "The MAC address of the neighbour."
                    },
                    "ipv4_addresses": {
                        "type": "array",
                        "description": "The IPv4 addresses that the neighbour is known to use.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "ipv6_addresses": {
                        "type": "array",
                        "description": "The IPv4 addresses that the neighbour is known to use.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "ports": {
                        "type": "array",
                        "description": "The physical network devices that that the neighbour has been seen on.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "last_seen": {
                        "type": "number",
                        "description": "How long along was traffic from this neighbour last seen."
                    }
                }
            }
        },
        "interface.counter": {
            "type": "object",
            "description": "This section contains the traffic counters of the logical interface.",
            "properties": {
                "collisions": {
                    "type": "number"
                },
                "multicast": {
                    "type": "number"
                },
                "rx_bytes": {
                    "type": "number",
                    "description": "The number of bytes received."
                },
                "rx_packets": {
                    "type": "number",
                    "description": "The number of packets received."
                },
                "rx_error": {
                    "type": "number",
                    "description": "The number of receive errors."
                },
                "rx_dropped": {
                    "type": "number",
                    "description": "The number of received packets that were dropped."
                },
                "tx_bytes": {
                    "type": "number",
                    "description": "The number of bytes transmitted."
                },
                "tx_packets": {
                    "type": "number",
                    "description": "The number of packets transmitted."
                },
                "tx_error": {
                    "type": "number",
                    "description": "The number of transmit errors."
                },
                "tx_dropped": {
                    "type": "number",
                    "description": "The number of transmitted packets that were dropped."
                }
            }
        },
        "interface.mesh-path": {
            "type": "object",
            "description": "This section contains info about connected mesh nodes.",
            "properties": {
                "destiination": {
                    "type": "string"
                },
                "next_hop": {
                    "type": "string"
                },
                "metric": {
                    "type": "number"
                },
                "expire": {
                    "type": "number"
                },
                "hop_count": {
                    "type": "number"
                }
            }
        },
        "interface.ssid.association": {
            "type": "array",
            "description": "A list all OBSS that this BSS is connected to. The contained entries depend opertational mode. * AP - all associated stationd * STA - the remote AP * mesh - all mesh peers that we can see * wds - the remote wds peer",
            "items": {
                "description": "An explanation about the purpose of this instance.",
                "properties": {
                    "bssid": {
                        "type": "string",
                        "description": "The BSSID of the remote BSS."
                    },
                    "station": {
                        "type": "string",
                        "description": "The MAC address of the station."
                    },
                    "rssi": {
                        "type": "number",
                        "description": "The RX signal strength of the remore BSS. (dBm)"
                    },
                    "connected": {
                        "type": "number",
                        "description": "The time since connected"
                    },
                    "inactive": {
                        "type": "number",
                        "description": "The time since inactive"
                    },
                    "tx_duration": {
                        "type": "number",
                        "description": "The tx duration"
                    },
                    "rx_duration": {
                        "type": "number",
                        "description": "The rx duration"
                    },
                    "rx_bytes": {
                        "type": "number",
                        "description": "The number of bytes received."
                    },
                    "ack_signal": {
                        "type": "number"
                    },
                    "ack_signal_avg": {
                        "type": "number"
                    },
                    "rx_packets": {
                        "type": "number",
                        "description": "The number of packets received."
                    },
                    "tx_packets": {
                        "type": "number",
                        "description": "The number of packets received."
                    },
                    "tx_bytes": {
                        "type": "number",
                        "description": "The number of bytes transmitted."
                    },
                    "tx_retries": {
                        "type": "number"
                    },
                    "tx_failed": {
                        "type": "number",
                        "description": "The number of packets transmitted."
                    },
                    "rx_rate": {
                        "type": "array",
                        "items": {
                            "properties": {
                                "bitrate": {
                                    "type": "number"
                                },
                                "sgi": {
                                    "type": "boolean"
                                },
                                "vht": {
                                    "type": "boolean"
                                },
                                "mcs": {
                                    "type": "number"
                                },
                                "nss": {
                                    "type": "number"
                                },
                                "chwidth": {
                                    "type": "number"
                                },
                                "he": {
                                    "type": "boolean"
                                },
                                "he_gi": {
                                    "type": "number"
                                },
                                "he_dcm": {
                                    "type": "number"
                                }
                            }
                        }
                    },
                    "tx_rate": {
                        "type": "array",
                        "items": {
                            "properties": {
                                "bitrate": {
                                    "type": "number"
                                },
                                "sgi": {
                                    "type": "boolean"
                                },
                                "vht": {
                                    "type": "boolean"
                                },
                                "mcs": {
                                    "type": "number"
                                },
                                "nss": {
                                    "type": "number"
                                },
                                "chwidth": {
                                    "type": "number"
                                },
                                "he": {
                                    "type": "boolean"
                                },
                                "he_gi": {
                                    "type": "number"
                                },
                                "he_dcm": {
                                    "type": "number"
                                }
                            }
                        }
                    },
                    "tid_stats": {
                        "type": "array",
                        "items": {
                            "properties": {
                                "rx_msdu": {
                                    "type": "number"
                                },
                                "tx_msdu": {
                                    "type": "number"
                                },
                                "tx_msdu_retries": {
                                    "type": "number"
                                },
                                "tx_msdu_failed": {
                                    "type": "number"
                                }
                            }
                        }
                    }
                }
            }
        },
        "interface.ssid": {
            "type": "array",
            "items": {
                "type": "object",
                "description": "This section contains the current state of a SSID being brodcasted or connected to by this device.",
                "properties": {
                    "bssid": {
                        "type": "string",
                        "description": "The BSSID used by this BSS instance."
                    },
                    "location": {
                        "type": "string",
                        "description": "The json-schema path within the configuration where this logical interface is located."
                    },
                    "phy": {
                        "type": "string",
                        "description": "The unique path identifying the radio"
                    },
                    "band": {
                        "description": "The wireless band that the radio is currently operating on.",
                        "type": "string"
                    },
                    "ssid": {
                        "type": "string",
                        "description": "The SSID that we are broadcasting or connecting to."
                    },
                    "iface": {
                        "type": "string",
                        "description": "The physical network device used."
                    },
                    "mode": {
                        "type": "string",
                        "description": "The operational mode of the BSS.",
                        "enum": [
                            "ap",
                            "sta",
                            "mesh",
                            "wds"
                        ]
                    },
                    "radio": {
                        "type": "object",
                        "description": "A reference to the section describing the physical radio within this document. (#/radios/X)",
                        "properties": {
                            "ref": {
                                "type": "string"
                            }
                        }
                    },
                    "frequency": {
                        "description": "The list of all frequencies that the radio is currently operating on.",
                        "type": "array",
                        "items": {
                            "type": "number"
                        }
                    },
                    "associations": {
                        "$ref": "#/$defs/interface.ssid.association"
                    },
                    "counters": {
                        "$ref": "#/$defs/interface.counter"
                    }
                }
            }
        },
        "interface": {
            "type": "array",
            "description": "An array containing the runtime state of all logical interfaces.items",
            "items": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "The json-schema path within the configuration where this logical interface is located."
                    },
                    "uptime": {
                        "type": "number",
                        "description": "The number of seconds since the interface was brought up."
                    },
                    "name": {
                        "type": "string",
                        "description": "The administrative name of this logical interface. This field is freetext"
                    },
                    "ntp_server": {
                        "type": "string",
                        "description": "The upstream NTP server being used by this interface."
                    },
                    "dns_servers": {
                        "type": "array",
                        "description": "The list of remote DNS servers that this logical interface uses for domain name resolution.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "ipv4": {
                        "$ref": "#/$defs/interface.ipv4"
                    },
                    "ipv6_addresses": {
                        "$ref": "#/$defs/interface.ipv6-address"
                    },
                    "ipv6_leases": {
                        "$ref": "#/$defs/interface.ipv6-lease"
                    },
                    "clients": {
                        "$ref": "#/$defs/interface.clients"
                    },
                    "counters": {
                        "$ref": "#/$defs/interface.counter"
                    },
                    "mesh-path": {
                        "$ref": "#/$defs/interface.mesh-path"
                    },
                    "ssids": {
                        "$ref": "#/$defs/interface.ssid"
                    }
                }
            }
        },
        "lldp-peers": {
            "type": "array",
            "items": {
                "type": "object",
                "description": "A list of all LLDP peers that this logical interface is connected to.",
                "properties": {
                    "capability": {
                        "type": "array",
                        "description": "The device capabilities that our neighbour is announcing.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "description": {
                        "type": "string",
                        "description": "The chassis description that our neighbour is announcing."
                    },
                    "mac": {
                        "type": "string",
                        "description": "The chassis ID/MAC that our neighbour is announcing."
                    },
                    "management_ips": {
                        "type": "array",
                        "description": "The management IPs that our neighbour is announcing.",
                        "items": {
                            "type": "string"
                        }
                    },
                    "port": {
                        "type": "string",
                        "description": "The physical network port that we see this neighbour on."
                    }
                }
            }
        },
        "link-state": {
            "type": "object",
            "description": "A list of all LLDP peers that this logical interface is connected to.",
            "properties": {
                "carrier": {
                    "type": "boolean",
                    "description": "The physical interfaces carrier state."
                },
                "speed": {
                    "type": "number",
                    "description": "The speed of the physical link."
                },
                "duplex": {
                    "type": "string",
                    "description": "The physical links duplex mode.",
                    "enum": [
                        "full",
                        "half"
                    ]
                },
                "counters": {
                    "$ref": "#/$defs/interface.counter"
                },
                "poe": {
                    "description": "This section describes the ethernet poe-port link-state object (statistics + PD info). Present only in case if port has any Power sourcing capabilities.",
                    "type": "object",
                    "properties": {
                        "class-requested": {
                            "description": "Reports which PoE power class PD requested.",
                            "type": "number"
                        },
                        "class-assigned": {
                            "description": "Reports which PoE power class PD has been assigned by the Power sourcing equipment.",
                            "type": "number"
                        },
                        "output-power": {
                            "description": "Reports the power-value (in milliwatts, mW) poe-port's Powered Device is currently draining.",
                            "type": "number"
                        },
                        "output-current": {
                            "description": "Reports the current value (in milliamps, mA) poe-port's Powered Device is currently draining.",
                            "type": "number"
                        },
                        "output-voltage": {
                            "description": "Reports the operational voltage-level-value of poe-port's Power sourcing equipment (in Volts, V).",
                            "type": "string",
                            "examples": [
                                "54.14"
                            ]
                        },
                        "temp": {
                            "description": "Reports the operational temperature of poe-port's Power sourcing equipment (in Celsius, C).",
                            "type": "string",
                            "examples": [
                                "22.5"
                            ]
                        },
                        "status": {
                            "description": "Reports the operational status of poe-port's Power sourcing equipment. Searching option - the poe-port's PSE is trying to detect a Powered Device. Delivering option - the poe-port's PSE is delivering power to a Powered Device. Disabled option - the poe-port's PSE is either disabled or PoE power is enabled but the PoE module does not have enough power available to supply the port's power needs. Fault option - the poe-port's PSE detects a problem with the Powered Device. Other Fault option - the PSE has detected an internal fault that prevents it from supplying power on that port.",
                            "type": "string",
                            "examples": [
                                "DELIVERING_POWER",
                                "DISABLED"
                            ]
                        },
                        "fault-status": {
                            "description": "Reports the fault status of poe-port's PSE (in case if any).",
                            "type": "string",
                            "examples": [
                                "NO_ERROR"
                            ]
                        },
                        "counters": {
                            "description": null,
                            "type": "object",
                            "properties": {
                                "overload": {
                                    "description": "Displays the total number of power overload occurrences. (Powered Device is consuming more power than the maximum limit of a port)",
                                    "type": "number"
                                },
                                "short": {
                                    "description": "Displays the total number of power shortage occurrences.",
                                    "type": "number"
                                },
                                "power-denied": {
                                    "description": "Displays the number of times that the powered device was denied power. (possible cause could be that Requested power exceeds PSE capability)",
                                    "type": "number"
                                },
                                "absent": {
                                    "description": "Displays the number of times that the power was stopped to the powered device because the powered device was no longer detected.",
                                    "type": "number"
                                },
                                "invalid-signature": {
                                    "description": "Displays the times that an invalid signature was received. Signatures are the means by which the powered device identifies itself to the PSE. Signatures are generated during powered device detection, classification, or maintenance.",
                                    "type": "number"
                                }
                            }
                        }
                    }
                },
                "ieee8021x": {
                    "description": "This section describes the per-port specific 802.1X (port access control) link-state object (authenticated clients). Present only in case if port has enabled EAP processing and has any authenticated clients.",
                    "type": "object",
                    "properties": null,
                    "authenticated-clients": {
                        "description": "List of authenticated clients and (their) authentication data.",
                        "type": "array",
                        "items": {
                            "type": "object",
                            "properties": {
                                "authenticated-method": {
                                    "description": "Authentication method used by client for it's authentication.",
                                    "type": "string"
                                },
                                "mac-address": {
                                    "description": "MAC address of authenticated client.",
                                    "type": "string",
                                    "format": "uc-mac"
                                },
                                "session-time": {
                                    "description": "Client session time.",
                                    "type": "integer"
                                },
                                "username": {
                                    "description": "Client username.",
                                    "type": "string"
                                },
                                "vlan-type": {
                                    "description": "Vlan type of authenticated client (Authorization status of the client).",
                                    "type": "string"
                                },
                                "vlan-id": {
                                    "description": "Vlan type of authenticated client (Authorization status of the client).",
                                    "type": "integer",
                                    "maximum": 4095
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}