firmware-base/cli-ts/ast/RestServer.json

2662 lines
95 KiB
JSON

{
"type": "translation_unit",
"children": [
{
"type": "preproc_ifdef",
"children": [
{
"type": "#ifndef",
"text": "#ifndef"
},
{
"type": "identifier",
"text": "REST_SERVER_H"
},
{
"type": "preproc_def",
"children": [
{
"type": "#define",
"text": "#define"
},
{
"type": "identifier",
"text": "REST_SERVER_H"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<ESPAsyncWebServer.h>"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<AsyncJson.h>"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<ArduinoJson.h>"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<ArduinoLog.h>"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<AsyncTCP.h>"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<enums.h>"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "string_literal",
"children": [
{
"type": "\"",
"text": "\""
},
{
"type": "string_content",
"text": "MessageQueue.h"
},
{
"type": "\"",
"text": "\""
}
]
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<Component.h>"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<Bridge.h>"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<functional>"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<vector>"
}
]
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<utility>"
}
]
},
{
"type": "preproc_ifdef",
"children": [
{
"type": "#ifdef",
"text": "#ifdef"
},
{
"type": "identifier",
"text": "ENABLE_WEBSOCKET"
},
{
"type": "preproc_include",
"children": [
{
"type": "#include",
"text": "#include"
},
{
"type": "system_lib_string",
"text": "<AsyncWebSocket.h>"
}
]
},
{
"type": "#endif",
"text": "#endif"
}
]
},
{
"type": "preproc_def",
"children": [
{
"type": "#define",
"text": "#define"
},
{
"type": "identifier",
"text": "MAX_JSON_DOCUMENT_SIZE"
},
{
"type": "preproc_arg",
"text": "1024"
}
]
},
{
"type": "preproc_def",
"children": [
{
"type": "#define",
"text": "#define"
},
{
"type": "identifier",
"text": "WS_BROADCAST_RATE_LIMIT_MS"
},
{
"type": "preproc_arg",
"text": "50"
}
]
},
{
"type": "preproc_def",
"children": [
{
"type": "#define",
"text": "#define"
},
{
"type": "identifier",
"text": "MAX_WEBSOCKET_MESSAGE_SIZE"
},
{
"type": "preproc_arg",
"text": "4096 * 3"
}
]
},
{
"type": "preproc_def",
"children": [
{
"type": "#define",
"text": "#define"
},
{
"type": "identifier",
"text": "DEFAULT_WS_COMMAND_HANDLER_CAPACITY"
},
{
"type": "preproc_arg",
"text": "10"
}
]
},
{
"type": "comment",
"text": "// Define BroadcastMessageType enum here"
},
{
"type": "type_definition",
"children": [
{
"type": "typedef",
"text": "typedef"
},
{
"type": "enum_specifier",
"children": [
{
"type": "enum",
"text": "enum"
},
{
"type": "type_identifier",
"text": ""
},
{
"type": ":",
"text": ":"
},
{
"type": "primitive_type",
"text": "uint8_t"
},
{
"type": "enumerator_list",
"children": [
{
"type": "{",
"text": "{"
},
{
"type": "enumerator",
"children": [
{
"type": "identifier",
"text": "BROADCAST_UNKNOWN"
},
{
"type": "=",
"text": "="
},
{
"type": "number_literal",
"text": "0"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "enumerator",
"children": [
{
"type": "identifier",
"text": "BROADCAST_COIL_UPDATE"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "enumerator",
"children": [
{
"type": "identifier",
"text": "BROADCAST_REGISTER_UPDATE"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "enumerator",
"children": [
{
"type": "identifier",
"text": "BROADCAST_LOG_ENTRY"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "enumerator",
"children": [
{
"type": "identifier",
"text": "BROADCAST_SYSTEM_STATUS"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "enumerator",
"children": [
{
"type": "identifier",
"text": "BROADCAST_USER_DEFINED"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "enumerator",
"children": [
{
"type": "identifier",
"text": "BROADCAST_USER_MESSAGE"
}
]
},
{
"type": "}",
"text": "}"
}
]
}
]
},
{
"type": "type_identifier",
"text": "BroadcastMessageType"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "class_specifier",
"children": [
{
"type": "class",
"text": "class"
},
{
"type": "type_identifier",
"text": "ModbusTCP"
}
]
},
{
"type": ";",
"text": ";"
},
{
"type": "comment",
"text": "/**\n * @brief RESTful API server generated from Swagger spec.\n * This class implements a RESTful API server that interfaces with the Modbus system.\n */"
},
{
"type": "class_specifier",
"children": [
{
"type": "class",
"text": "class"
},
{
"type": "type_identifier",
"text": "RESTServer"
},
{
"type": "base_class_clause",
"children": [
{
"type": ":",
"text": ":"
},
{
"type": "access_specifier",
"children": [
{
"type": "public",
"text": "public"
}
]
},
{
"type": "type_identifier",
"text": "Component"
}
]
},
{
"type": "field_declaration_list",
"children": [
{
"type": "{",
"text": "{"
},
{
"type": "comment",
"text": "// Inherit from Component"
},
{
"type": "access_specifier",
"children": [
{
"type": "public",
"text": "public"
}
]
},
{
"type": ":",
"text": ":"
},
{
"type": "preproc_ifdef",
"children": [
{
"type": "#ifdef",
"text": "#ifdef"
},
{
"type": "identifier",
"text": "ENABLE_WEBSOCKET"
},
{
"type": "alias_declaration",
"children": [
{
"type": "using",
"text": "using"
},
{
"type": "type_identifier",
"text": "WsCommandHandler"
},
{
"type": "=",
"text": "="
},
{
"type": "type_descriptor",
"children": [
{
"type": "qualified_identifier",
"children": [
{
"type": "namespace_identifier",
"text": "std"
},
{
"type": "::",
"text": "::"
},
{
"type": "template_type",
"children": [
{
"type": "type_identifier",
"text": "function"
},
{
"type": "template_argument_list",
"children": [
{
"type": "<",
"text": "<"
},
{
"type": "type_descriptor",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "abstract_function_declarator",
"children": [
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebSocketClient"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "client"
}
]
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "JsonVariant"
},
{
"type": "reference_declarator",
"children": [
{
"type": "&",
"text": "&"
},
{
"type": "identifier",
"text": "json"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
}
]
},
{
"type": ">",
"text": ">"
}
]
}
]
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "#endif",
"text": "#endif"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebServer"
},
{
"type": "field_identifier",
"text": "server"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "type_identifier",
"text": "ModbusTCP"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "field_identifier",
"text": "modbusManager"
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "preproc_ifdef",
"children": [
{
"type": "#ifdef",
"text": "#ifdef"
},
{
"type": "identifier",
"text": "ENABLE_WEBSOCKET"
},
{
"type": "field_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebSocket"
},
{
"type": "field_identifier",
"text": "ws"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "setupWebSocket"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "// Initialize WebSocket handlers"
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "handleWebSocketMessage"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebSocketClient"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "client"
}
]
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "arg"
}
]
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "uint8_t"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "data"
}
]
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "size_t"
},
{
"type": "identifier",
"text": "len"
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "uint8_t"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "getConnectedClientsCount"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
},
{
"type": "type_qualifier",
"children": [
{
"type": "const",
"text": "const"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "// Get number of connected WebSocket clients"
},
{
"type": "field_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "unsigned",
"text": "unsigned"
},
{
"type": "long",
"text": "long"
}
]
},
{
"type": "field_identifier",
"text": "lastBroadcastTime"
},
{
"type": "=",
"text": "="
},
{
"type": "number_literal",
"text": "0"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "registerWsCommandHandler"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_qualifier",
"children": [
{
"type": "const",
"text": "const"
}
]
},
{
"type": "type_identifier",
"text": "String"
},
{
"type": "reference_declarator",
"children": [
{
"type": "&",
"text": "&"
},
{
"type": "identifier",
"text": "command"
}
]
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "WsCommandHandler"
},
{
"type": "identifier",
"text": "handler"
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "#endif",
"text": "#endif"
}
]
},
{
"type": "comment",
"text": "// Handler methods "
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "getSystemInfoHandler"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebServerRequest"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "request"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "getCoilsHandler"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebServerRequest"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "request"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "getCoilHandler"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebServerRequest"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "request"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "setCoilQueryHandler"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebServerRequest"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "request"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "getRegistersHandler"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebServerRequest"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "request"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "getRegisterHandler"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebServerRequest"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "request"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "getLogLevelHandler"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebServerRequest"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "request"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "setLogLevelHandler"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebServerRequest"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "request"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "getRtuOperationQueueHandler"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebServerRequest"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "request"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "getMappingsHandler"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebServerRequest"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "request"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "listFsHandler"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "AsyncWebServerRequest"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "request"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "setupRoutes"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "access_specifier",
"children": [
{
"type": "public",
"text": "public"
}
]
},
{
"type": ":",
"text": ":"
},
{
"type": "field_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "short",
"text": "short"
}
]
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "onRun"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
},
{
"type": "virtual_specifier",
"children": [
{
"type": "override",
"text": "override"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "/**\n * @brief Construct a new RESTServer object\n * \n * @param port The port to run the server on\n * @param manager Pointer to the ModbusManager instance.\n * @param app Pointer to the PHApp instance.\n */"
},
{
"type": "declaration",
"children": [
{
"type": "function_declarator",
"children": [
{
"type": "identifier",
"text": "RESTServer"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_qualifier",
"children": [
{
"type": "const",
"text": "const"
}
]
},
{
"type": "type_identifier",
"text": "IPAddress"
},
{
"type": "reference_declarator",
"children": [
{
"type": "&",
"text": "&"
},
{
"type": "identifier",
"text": "ip"
}
]
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "uint16_t"
},
{
"type": "identifier",
"text": "port"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "ModbusTCP"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "manager"
}
]
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "Component"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "owner"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "/**\n * @brief Destroy the RESTServer object\n */"
},
{
"type": "declaration",
"children": [
{
"type": "function_declarator",
"children": [
{
"type": "destructor_name",
"children": [
{
"type": "~",
"text": "~"
},
{
"type": "identifier",
"text": "RESTServer"
}
]
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "/**\n * @brief Run periodically to handle server tasks\n */"
},
{
"type": "field_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "short",
"text": "short"
}
]
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "loop"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
},
{
"type": "virtual_specifier",
"children": [
{
"type": "override",
"text": "override"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "/**\n * @brief Setup the RESTServer\n */"
},
{
"type": "field_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "short",
"text": "short"
}
]
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "setup"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
},
{
"type": "virtual_specifier",
"children": [
{
"type": "override",
"text": "override"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "/**\n * @brief Handles incoming messages (e.g., from PHApp for broadcasts).\n */"
},
{
"type": "field_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "short",
"text": "short"
}
]
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "onMessage"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "int"
},
{
"type": "identifier",
"text": "id"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "E_CALLS"
},
{
"type": "identifier",
"text": "verb"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "E_MessageFlags"
},
{
"type": "identifier",
"text": "flags"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "user"
}
]
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "Component"
},
{
"type": "pointer_declarator",
"children": [
{
"type": "*",
"text": "*"
},
{
"type": "identifier",
"text": "src"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
},
{
"type": "virtual_specifier",
"children": [
{
"type": "override",
"text": "override"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "preproc_ifdef",
"children": [
{
"type": "#ifdef",
"text": "#ifdef"
},
{
"type": "identifier",
"text": "ENABLE_WEBSOCKET"
},
{
"type": "comment",
"text": "/**\n * @brief Broadcast a message to all connected WebSocket clients.\n * \n * @param type The type of message to send.\n * @param data The data to send with the message.\n */"
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "broadcast"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "BroadcastMessageType"
},
{
"type": "identifier",
"text": "type"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_qualifier",
"children": [
{
"type": "const",
"text": "const"
}
]
},
{
"type": "type_identifier",
"text": "JsonDocument"
},
{
"type": "reference_declarator",
"children": [
{
"type": "&",
"text": "&"
},
{
"type": "identifier",
"text": "data"
}
]
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "comment",
"text": "// New broadcast method"
},
{
"type": "#endif",
"text": "#endif"
}
]
},
{
"type": "access_specifier",
"children": [
{
"type": "private",
"text": "private"
}
]
},
{
"type": ":",
"text": ":"
},
{
"type": "preproc_ifdef",
"children": [
{
"type": "#ifdef",
"text": "#ifdef"
},
{
"type": "identifier",
"text": "ENABLE_WEBSOCKET"
},
{
"type": "field_declaration",
"children": [
{
"type": "qualified_identifier",
"children": [
{
"type": "namespace_identifier",
"text": "std"
},
{
"type": "::",
"text": "::"
},
{
"type": "template_type",
"children": [
{
"type": "type_identifier",
"text": "vector"
},
{
"type": "template_argument_list",
"children": [
{
"type": "<",
"text": "<"
},
{
"type": "type_descriptor",
"children": [
{
"type": "qualified_identifier",
"children": [
{
"type": "namespace_identifier",
"text": "std"
},
{
"type": "::",
"text": "::"
},
{
"type": "template_type",
"children": [
{
"type": "type_identifier",
"text": "pair"
},
{
"type": "template_argument_list",
"children": [
{
"type": "<",
"text": "<"
},
{
"type": "type_descriptor",
"children": [
{
"type": "type_identifier",
"text": "String"
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "type_descriptor",
"children": [
{
"type": "type_identifier",
"text": "WsCommandHandler"
}
]
},
{
"type": ">",
"text": ">"
}
]
}
]
}
]
}
]
},
{
"type": ">",
"text": ">"
}
]
}
]
}
]
},
{
"type": "field_identifier",
"text": "wsCommandHandlers"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "#endif",
"text": "#endif"
}
]
},
{
"type": "comment",
"text": "// Message History"
},
{
"type": "field_declaration",
"children": [
{
"type": "type_identifier",
"text": "MessageQueue"
},
{
"type": "field_identifier",
"text": "userMessageHistory"
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "primitive_type",
"text": "void"
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "_buildRegistersJson"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": "parameter_declaration",
"children": [
{
"type": "type_identifier",
"text": "JsonArray"
},
{
"type": "reference_declarator",
"children": [
{
"type": "&",
"text": "&"
},
{
"type": "identifier",
"text": "registersArray"
}
]
}
]
},
{
"type": ",",
"text": ","
},
{
"type": "optional_parameter_declaration",
"children": [
{
"type": "primitive_type",
"text": "int"
},
{
"type": "identifier",
"text": "specificAddress"
},
{
"type": "=",
"text": "="
},
{
"type": "number_literal",
"text": "-1"
}
]
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "field_declaration",
"children": [
{
"type": "sized_type_specifier",
"children": [
{
"type": "short",
"text": "short"
}
]
},
{
"type": "function_declarator",
"children": [
{
"type": "field_identifier",
"text": "mountLittleFS"
},
{
"type": "parameter_list",
"children": [
{
"type": "(",
"text": "("
},
{
"type": ")",
"text": ")"
}
]
}
]
},
{
"type": ";",
"text": ";"
}
]
},
{
"type": "}",
"text": "}"
}
]
}
]
},
{
"type": ";",
"text": ";"
},
{
"type": "#endif",
"text": "#endif"
}
]
},
{
"type": "comment",
"text": "// REST_SERVER_H"
}
]
}