Updated mdns to use protobufs (completely untested)
This commit is contained in:
@@ -91,35 +91,6 @@ export type ServoConfiguration = {
|
||||
servos: Servo[]
|
||||
}
|
||||
|
||||
export interface MDNSServiceQuery {
|
||||
services: MDNSServiceItem[]
|
||||
}
|
||||
|
||||
export interface MDNSServiceItem {
|
||||
ip: string
|
||||
port: number
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface MDNSService {
|
||||
service: string
|
||||
protocol: string
|
||||
port: number
|
||||
}
|
||||
|
||||
export interface MDNSTxtRecord {
|
||||
key: string
|
||||
value: string
|
||||
}
|
||||
|
||||
export interface MDNSStatus {
|
||||
started: boolean
|
||||
hostname: string
|
||||
instance: string
|
||||
services: MDNSService[]
|
||||
global_txt_records: MDNSTxtRecord[]
|
||||
}
|
||||
|
||||
export interface Result {
|
||||
success: boolean
|
||||
error?: string
|
||||
|
||||
@@ -6,33 +6,46 @@
|
||||
import StatusItem from '$lib/components/StatusItem.svelte'
|
||||
import { cubicOut } from 'svelte/easing'
|
||||
import { slide } from 'svelte/transition'
|
||||
import type { MDNSStatus, MDNSServiceItem, MDNSServiceQuery } from '$lib/types/models'
|
||||
import {
|
||||
type MDNSStatus,
|
||||
type MDNSQueryResult,
|
||||
Request,
|
||||
type Response as ProtoResponse
|
||||
} from '$lib/platform_shared/api'
|
||||
import { compareIp } from '$lib/utilities'
|
||||
|
||||
let mdnsStatus: MDNSStatus | undefined = $state()
|
||||
let services: MDNSServiceItem[] = $state([])
|
||||
let mdnsStatus = $state<MDNSStatus | undefined>()
|
||||
let services = $state<MDNSQueryResult[]>([])
|
||||
let isLoading = $state(false)
|
||||
|
||||
const getMDNSStatus = async () => {
|
||||
const result = await api.get<MDNSStatus>('/api/mdns/status')
|
||||
const result = await api.get<ProtoResponse>('/api/mdns/status')
|
||||
if (result.isErr()) {
|
||||
console.error('Error:', result.inner)
|
||||
return
|
||||
}
|
||||
mdnsStatus = result.inner
|
||||
if (result.inner.mdnsStatus) {
|
||||
mdnsStatus = result.inner.mdnsStatus
|
||||
}
|
||||
}
|
||||
|
||||
const queryMDNSServices = async () => {
|
||||
isLoading = true
|
||||
const result = await api.post<MDNSServiceQuery>('/api/mdns/query', {
|
||||
service: 'http',
|
||||
protocol: 'tcp'
|
||||
const request = Request.create({
|
||||
mdnsQueryRequest: {
|
||||
service: 'http',
|
||||
protocol: 'tcp'
|
||||
}
|
||||
})
|
||||
const result = await api.post_proto<ProtoResponse>('/api/mdns/query', request)
|
||||
if (result.isErr()) {
|
||||
console.error('Error:', result.inner)
|
||||
isLoading = false
|
||||
return
|
||||
}
|
||||
services = result.inner.services.sort((a, b) => compareIp(a.ip, b.ip))
|
||||
if (result.inner.mdnsQueryResponse) {
|
||||
services = result.inner.mdnsQueryResponse.services.sort((a, b) => compareIp(a.ip, b.ip))
|
||||
}
|
||||
isLoading = false
|
||||
}
|
||||
|
||||
|
||||
@@ -8,13 +8,8 @@
|
||||
|
||||
#define ESP_FS LittleFS
|
||||
|
||||
#define AP_SETTINGS_FILE "/config/apSettings.json"
|
||||
#define CAMERA_SETTINGS_FILE "/config/cameraSettings.json"
|
||||
#define FS_CONFIG_DIRECTORY "/config"
|
||||
#define DEVICE_CONFIG_FILE "/config/peripheral.json"
|
||||
#define WIFI_SETTINGS_FILE "/config/wifiSettings.json"
|
||||
#define SERVO_SETTINGS_FILE "/config/servoSettings.json"
|
||||
#define MDNS_SETTINGS_FILE "/config/mdnsSettings.json"
|
||||
|
||||
namespace FileSystem {
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <esp_http_server.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <ESPmDNS.h>
|
||||
#include <template/stateful_service.h>
|
||||
#include <template/stateful_endpoint.h>
|
||||
#include <template/stateful_persistence.h>
|
||||
#include <template/stateful_proto_endpoint.h>
|
||||
#include <template/stateful_persistence_pb.h>
|
||||
#include <settings/mdns_settings.h>
|
||||
#include <utils/timing.h>
|
||||
#include <string>
|
||||
|
||||
#define MDNS_SETTINGS_FILE "/config/mdnsSettings.pb"
|
||||
|
||||
class MDNSService : public StatefulService<MDNSSettings> {
|
||||
private:
|
||||
FSPersistence<MDNSSettings> _persistence;
|
||||
FSPersistencePB<MDNSSettings> _persistence;
|
||||
bool _started {false};
|
||||
|
||||
void reconfigureMDNS();
|
||||
@@ -27,9 +27,7 @@ class MDNSService : public StatefulService<MDNSSettings> {
|
||||
void begin();
|
||||
|
||||
esp_err_t getStatus(httpd_req_t *request);
|
||||
void getStatus(JsonVariant &root);
|
||||
esp_err_t queryServices(httpd_req_t *request, api_Request *protoReq);
|
||||
|
||||
static esp_err_t queryServices(httpd_req_t *request, JsonVariant &json);
|
||||
|
||||
StatefulHttpEndpoint<MDNSSettings> endpoint;
|
||||
StatefulProtoEndpoint<MDNSSettings, api_MDNSSettings> protoEndpoint;
|
||||
};
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include <template/state_result.h>
|
||||
#include <filesystem.h>
|
||||
#include <platform_shared/api.pb.h>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
#ifndef FACTORY_MDNS_HOSTNAME
|
||||
#define FACTORY_MDNS_HOSTNAME "esp32"
|
||||
@@ -13,126 +13,45 @@
|
||||
#define FACTORY_MDNS_INSTANCE "ESP32 Device"
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
std::string key;
|
||||
std::string value;
|
||||
// Use proto types directly
|
||||
using MDNSTxtRecord = api_MDNSTxtRecord;
|
||||
using MDNSServiceDef = api_MDNSServiceDef;
|
||||
using MDNSSettings = api_MDNSSettings;
|
||||
using MDNSStatus = api_MDNSStatus;
|
||||
|
||||
void serialize(JsonVariant &json) const {
|
||||
json["key"] = key.c_str();
|
||||
json["value"] = value.c_str();
|
||||
}
|
||||
// Default factory settings
|
||||
inline MDNSSettings MDNSSettings_defaults() {
|
||||
MDNSSettings settings = api_MDNSSettings_init_zero;
|
||||
strncpy(settings.hostname, FACTORY_MDNS_HOSTNAME, sizeof(settings.hostname) - 1);
|
||||
strncpy(settings.instance, FACTORY_MDNS_INSTANCE, sizeof(settings.instance) - 1);
|
||||
|
||||
bool deserialize(const JsonVariant &json) {
|
||||
key = json["key"].as<std::string>();
|
||||
value = json["value"].as<std::string>();
|
||||
// Default HTTP service
|
||||
settings.services_count = 2;
|
||||
strncpy(settings.services[0].service, "http", sizeof(settings.services[0].service) - 1);
|
||||
strncpy(settings.services[0].protocol, "tcp", sizeof(settings.services[0].protocol) - 1);
|
||||
settings.services[0].port = 80;
|
||||
settings.services[0].txt_records_count = 0;
|
||||
|
||||
return key.length() > 0;
|
||||
}
|
||||
} mdns_txt_record_t;
|
||||
// Default WS service
|
||||
strncpy(settings.services[1].service, "ws", sizeof(settings.services[1].service) - 1);
|
||||
strncpy(settings.services[1].protocol, "tcp", sizeof(settings.services[1].protocol) - 1);
|
||||
settings.services[1].port = 80;
|
||||
settings.services[1].txt_records_count = 0;
|
||||
|
||||
typedef struct {
|
||||
std::string service;
|
||||
std::string protocol;
|
||||
uint16_t port;
|
||||
std::vector<mdns_txt_record_t> txtRecords;
|
||||
// Default global txt record
|
||||
settings.global_txt_records_count = 1;
|
||||
strncpy(settings.global_txt_records[0].key, "Firmware Version", sizeof(settings.global_txt_records[0].key) - 1);
|
||||
strncpy(settings.global_txt_records[0].value, APP_VERSION, sizeof(settings.global_txt_records[0].value) - 1);
|
||||
|
||||
void serialize(JsonVariant &json) const {
|
||||
json["service"] = service.c_str();
|
||||
json["protocol"] = protocol.c_str();
|
||||
json["port"] = port;
|
||||
return settings;
|
||||
}
|
||||
|
||||
if (txtRecords.size() > 0) {
|
||||
JsonArray txtArray = json["txt_records"].to<JsonArray>();
|
||||
for (const auto &txt : txtRecords) {
|
||||
JsonVariant txtObj = txtArray.add<JsonVariant>();
|
||||
txt.serialize(txtObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Proto read/update are identity functions since type is the same
|
||||
inline void MDNSSettings_read(const MDNSSettings& settings, MDNSSettings& proto) {
|
||||
proto = settings;
|
||||
}
|
||||
|
||||
bool deserialize(const JsonVariant &json) {
|
||||
service = json["service"].as<std::string>();
|
||||
protocol = json["protocol"].as<std::string>();
|
||||
port = json["port"] | 0;
|
||||
|
||||
txtRecords.clear();
|
||||
if (json["txt_records"].is<JsonArray>()) {
|
||||
JsonArray txtArray = json["txt_records"];
|
||||
for (JsonVariant txtObj : txtArray) {
|
||||
mdns_txt_record_t txt;
|
||||
if (txt.deserialize(txtObj)) {
|
||||
txtRecords.push_back(txt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return service.length() > 0 && protocol.length() > 0 && port > 0;
|
||||
}
|
||||
} mdns_service_t;
|
||||
|
||||
class MDNSSettings {
|
||||
public:
|
||||
std::string hostname;
|
||||
std::string instance;
|
||||
std::vector<mdns_service_t> services;
|
||||
std::vector<mdns_txt_record_t> globalTxtRecords;
|
||||
|
||||
static void read(MDNSSettings &settings, JsonVariant &root) {
|
||||
root["hostname"] = settings.hostname.c_str();
|
||||
root["instance"] = settings.instance.c_str();
|
||||
|
||||
JsonArray servicesArray = root["services"].to<JsonArray>();
|
||||
for (const auto &service : settings.services) {
|
||||
JsonVariant serviceObj = servicesArray.add<JsonVariant>();
|
||||
service.serialize(serviceObj);
|
||||
}
|
||||
|
||||
JsonArray txtArray = root["global_txt_records"].to<JsonArray>();
|
||||
for (const auto &txt : settings.globalTxtRecords) {
|
||||
JsonVariant txtObj = txtArray.add<JsonVariant>();
|
||||
txt.serialize(txtObj);
|
||||
}
|
||||
}
|
||||
|
||||
static StateUpdateResult update(JsonVariant &root, MDNSSettings &settings) {
|
||||
settings.hostname = root["hostname"] | FACTORY_MDNS_HOSTNAME;
|
||||
settings.instance = root["instance"] | FACTORY_MDNS_INSTANCE;
|
||||
|
||||
settings.services.clear();
|
||||
if (root["services"].is<JsonArray>()) {
|
||||
JsonArray servicesArray = root["services"];
|
||||
for (JsonVariant serviceObj : servicesArray) {
|
||||
mdns_service_t service;
|
||||
if (service.deserialize(serviceObj)) {
|
||||
settings.services.push_back(service);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.services.empty()) {
|
||||
mdns_service_t httpService = {.service = "http", .protocol = "tcp", .port = 80, .txtRecords = {}};
|
||||
settings.services.push_back(httpService);
|
||||
|
||||
mdns_service_t wsService = {.service = "ws", .protocol = "tcp", .port = 80, .txtRecords = {}};
|
||||
settings.services.push_back(wsService);
|
||||
}
|
||||
|
||||
settings.globalTxtRecords.clear();
|
||||
if (root["global_txt_records"].is<JsonArray>()) {
|
||||
JsonArray txtArray = root["global_txt_records"];
|
||||
for (JsonVariant txtObj : txtArray) {
|
||||
mdns_txt_record_t txt;
|
||||
if (txt.deserialize(txtObj)) {
|
||||
settings.globalTxtRecords.push_back(txt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.globalTxtRecords.empty()) {
|
||||
mdns_txt_record_t firmwareVersion = {.key = "Firmware Version", .value = APP_VERSION};
|
||||
settings.globalTxtRecords.push_back(firmwareVersion);
|
||||
}
|
||||
|
||||
return StateUpdateResult::CHANGED;
|
||||
}
|
||||
};
|
||||
inline StateUpdateResult MDNSSettings_update(const MDNSSettings& proto, MDNSSettings& settings) {
|
||||
settings = proto;
|
||||
return StateUpdateResult::CHANGED;
|
||||
}
|
||||
|
||||
+10
-8
@@ -82,7 +82,7 @@ void setupServer() {
|
||||
return apService.protoEndpoint.handleStateUpdate(request, protoReq);
|
||||
});
|
||||
|
||||
// TODO: REMAKE TO PROTO
|
||||
// TODO: REMAKE TO PROTO - note: these are unused?
|
||||
server.on("/api/peripherals", HTTP_GET,
|
||||
[&](httpd_req_t *request) { return peripherals.endpoint.getState(request); });
|
||||
server.on("/api/peripherals", HTTP_POST, [&](httpd_req_t *request, JsonVariant &json) {
|
||||
@@ -90,14 +90,16 @@ void setupServer() {
|
||||
});
|
||||
|
||||
#if FT_ENABLED(USE_MDNS)
|
||||
// TODO: REMAKE TO PROTO
|
||||
server.on("/api/mdns", HTTP_GET, [&](httpd_req_t *request) { return mdnsService.endpoint.getState(request); });
|
||||
server.on("/api/mdns", HTTP_POST, [&](httpd_req_t *request, JsonVariant &json) {
|
||||
return mdnsService.endpoint.handleStateUpdate(request, json);
|
||||
});
|
||||
server.on("/api/mdns/settings", HTTP_GET, [&](httpd_req_t *request) { return mdnsService.protoEndpoint.getState(request); });
|
||||
server.onProto("/api/mdns/settings", HTTP_POST,
|
||||
[&](httpd_req_t *request, api_Request *protoReq) {
|
||||
return mdnsService.protoEndpoint.handleStateUpdate(request, protoReq);
|
||||
});
|
||||
server.on("/api/mdns/status", HTTP_GET, [&](httpd_req_t *request) { return mdnsService.getStatus(request); });
|
||||
server.on("/api/mdns/query", HTTP_POST,
|
||||
[&](httpd_req_t *request, JsonVariant &json) { return mdnsService.queryServices(request, json); });
|
||||
server.onProto("/api/mdns/query", HTTP_POST,
|
||||
[&](httpd_req_t *request, api_Request *protoReq) {
|
||||
return mdnsService.queryServices(request, protoReq);
|
||||
});
|
||||
#endif
|
||||
|
||||
server.on("/api/config/*", HTTP_GET, [](httpd_req_t *request) { return FileSystem::getConfigFile(request); });
|
||||
|
||||
+64
-41
@@ -4,8 +4,12 @@
|
||||
static const char *TAG = "MDNSService";
|
||||
|
||||
MDNSService::MDNSService()
|
||||
: _persistence(MDNSSettings::read, MDNSSettings::update, this, MDNS_SETTINGS_FILE),
|
||||
endpoint(MDNSSettings::read, MDNSSettings::update, this) {
|
||||
: protoEndpoint(MDNSSettings_read, MDNSSettings_update, this,
|
||||
API_REQUEST_EXTRACTOR(mdns_settings, api_MDNSSettings),
|
||||
API_RESPONSE_ASSIGNER(mdns_settings, api_MDNSSettings)),
|
||||
_persistence(MDNSSettings_read, MDNSSettings_update, this,
|
||||
MDNS_SETTINGS_FILE, api_MDNSSettings_fields, api_MDNSSettings_size,
|
||||
MDNSSettings_defaults()) {
|
||||
addUpdateHandler([&](const std::string &originId) { reconfigureMDNS(); }, false);
|
||||
}
|
||||
|
||||
@@ -28,15 +32,15 @@ void MDNSService::reconfigureMDNS() {
|
||||
}
|
||||
|
||||
void MDNSService::startMDNS() {
|
||||
ESP_LOGV(TAG, "Starting MDNS with hostname: %s", state().hostname.c_str());
|
||||
ESP_LOGV(TAG, "Starting MDNS with hostname: %s", state().hostname);
|
||||
|
||||
if (MDNS.begin(state().hostname.c_str())) {
|
||||
if (MDNS.begin(state().hostname)) {
|
||||
_started = true;
|
||||
MDNS.setInstanceName(state().instance.c_str());
|
||||
MDNS.setInstanceName(state().instance);
|
||||
|
||||
addServices();
|
||||
|
||||
ESP_LOGI(TAG, "MDNS started successfully with hostname: %s", state().hostname.c_str());
|
||||
ESP_LOGI(TAG, "MDNS started successfully with hostname: %s", state().hostname);
|
||||
} else {
|
||||
_started = false;
|
||||
ESP_LOGE(TAG, "Failed to start MDNS");
|
||||
@@ -50,52 +54,71 @@ void MDNSService::stopMDNS() {
|
||||
}
|
||||
|
||||
void MDNSService::addServices() {
|
||||
for (const auto &service : state().services) {
|
||||
MDNS.addService(service.service.c_str(), service.protocol.c_str(), service.port);
|
||||
for (size_t i = 0; i < state().services_count; i++) {
|
||||
const auto &service = state().services[i];
|
||||
MDNS.addService(service.service, service.protocol, service.port);
|
||||
|
||||
for (const auto &txt : service.txtRecords) {
|
||||
MDNS.addServiceTxt(service.service.c_str(), service.protocol.c_str(), txt.key.c_str(), txt.value.c_str());
|
||||
for (size_t j = 0; j < service.txt_records_count; j++) {
|
||||
const auto &txt = service.txt_records[j];
|
||||
MDNS.addServiceTxt(service.service, service.protocol, txt.key, txt.value);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto &txt : state().globalTxtRecords) {
|
||||
for (const auto &service : state().services) {
|
||||
MDNS.addServiceTxt(service.service.c_str(), service.protocol.c_str(), txt.key.c_str(), txt.value.c_str());
|
||||
for (size_t i = 0; i < state().global_txt_records_count; i++) {
|
||||
const auto &txt = state().global_txt_records[i];
|
||||
for (size_t j = 0; j < state().services_count; j++) {
|
||||
const auto &service = state().services[j];
|
||||
MDNS.addServiceTxt(service.service, service.protocol, txt.key, txt.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t MDNSService::getStatus(httpd_req_t *request) {
|
||||
JsonDocument doc;
|
||||
JsonVariant root = doc.to<JsonVariant>();
|
||||
getStatus(root);
|
||||
return WebServer::sendJson(request, 200, doc);
|
||||
}
|
||||
api_Response response = api_Response_init_zero;
|
||||
response.which_payload = api_Response_mdns_status_tag;
|
||||
|
||||
void MDNSService::getStatus(JsonVariant &root) {
|
||||
state().read(state(), root);
|
||||
root["started"] = _started;
|
||||
}
|
||||
MDNSStatus &status = response.payload.mdns_status;
|
||||
status.started = _started;
|
||||
strncpy(status.hostname, state().hostname, sizeof(status.hostname) - 1);
|
||||
strncpy(status.instance, state().instance, sizeof(status.instance) - 1);
|
||||
|
||||
esp_err_t MDNSService::queryServices(httpd_req_t *request, JsonVariant &json) {
|
||||
std::string service = json["service"].as<std::string>();
|
||||
std::string proto = json["protocol"].as<std::string>();
|
||||
|
||||
JsonDocument doc;
|
||||
JsonVariant root = doc.to<JsonVariant>();
|
||||
|
||||
ESP_LOGI(TAG, "Querying for service: %s, protocol: %s", service.c_str(), proto.c_str());
|
||||
|
||||
int n = MDNS.queryService(service.c_str(), proto.c_str());
|
||||
ESP_LOGI(TAG, "Found %d services", n);
|
||||
|
||||
JsonArray servicesArray = root["services"].to<JsonArray>();
|
||||
for (int i = 0; i < n; i++) {
|
||||
JsonVariant serviceObj = servicesArray.add<JsonVariant>();
|
||||
serviceObj["name"] = MDNS.hostname(i);
|
||||
serviceObj["ip"] = MDNS.IP(i);
|
||||
serviceObj["port"] = MDNS.port(i);
|
||||
status.services_count = state().services_count;
|
||||
for (size_t i = 0; i < state().services_count; i++) {
|
||||
status.services[i] = state().services[i];
|
||||
}
|
||||
|
||||
return WebServer::sendJson(request, 200, doc);
|
||||
status.global_txt_records_count = state().global_txt_records_count;
|
||||
for (size_t i = 0; i < state().global_txt_records_count; i++) {
|
||||
status.global_txt_records[i] = state().global_txt_records[i];
|
||||
}
|
||||
|
||||
return WebServer::sendProto(request, 200, api_Response_fields, &response, api_Response_size);
|
||||
}
|
||||
|
||||
esp_err_t MDNSService::queryServices(httpd_req_t *request, api_Request *protoReq) {
|
||||
if (protoReq->which_payload != api_Request_mdns_query_request_tag) {
|
||||
return WebServer::sendError(request, 400, "Invalid request payload");
|
||||
}
|
||||
|
||||
const api_MDNSQueryRequest &queryReq = protoReq->payload.mdns_query_request;
|
||||
ESP_LOGI(TAG, "Querying for service: %s, protocol: %s", queryReq.service, queryReq.protocol);
|
||||
|
||||
int n = MDNS.queryService(queryReq.service, queryReq.protocol);
|
||||
ESP_LOGI(TAG, "Found %d services", n);
|
||||
|
||||
api_Response response = api_Response_init_zero;
|
||||
response.which_payload = api_Response_mdns_query_response_tag;
|
||||
api_MDNSQueryResponse &queryResp = response.payload.mdns_query_response;
|
||||
|
||||
// Limit to max_count from options file (16)
|
||||
size_t count = (n > 16) ? 16 : static_cast<size_t>(n);
|
||||
queryResp.services_count = count;
|
||||
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
strncpy(queryResp.services[i].name, MDNS.hostname(i).c_str(), sizeof(queryResp.services[i].name) - 1);
|
||||
strncpy(queryResp.services[i].ip, MDNS.IP(i).toString().c_str(), sizeof(queryResp.services[i].ip) - 1);
|
||||
queryResp.services[i].port = MDNS.port(i);
|
||||
}
|
||||
|
||||
return WebServer::sendProto(request, 200, api_Response_fields, &response, api_Response_size);
|
||||
}
|
||||
|
||||
@@ -23,3 +23,28 @@ api.WifiNetwork.ssid max_size:33
|
||||
api.WifiNetwork.password max_size:65
|
||||
api.WifiSettings.hostname max_size:33
|
||||
api.WifiSettings.wifi_networks max_count:5
|
||||
|
||||
api.MDNSTxtRecord.key max_size:32
|
||||
api.MDNSTxtRecord.value max_size:64
|
||||
|
||||
api.MDNSServiceDef.service max_size:16
|
||||
api.MDNSServiceDef.protocol max_size:8
|
||||
api.MDNSServiceDef.txt_records max_count:4
|
||||
|
||||
api.MDNSSettings.hostname max_size:33
|
||||
api.MDNSSettings.instance max_size:64
|
||||
api.MDNSSettings.services max_count:4
|
||||
api.MDNSSettings.global_txt_records max_count:4
|
||||
|
||||
api.MDNSStatus.hostname max_size:33
|
||||
api.MDNSStatus.instance max_size:64
|
||||
api.MDNSStatus.services max_count:4
|
||||
api.MDNSStatus.global_txt_records max_count:4
|
||||
|
||||
api.MDNSQueryRequest.service max_size:16
|
||||
api.MDNSQueryRequest.protocol max_size:8
|
||||
|
||||
api.MDNSQueryResult.name max_size:64
|
||||
api.MDNSQueryResult.ip max_size:46
|
||||
|
||||
api.MDNSQueryResponse.services max_count:16
|
||||
|
||||
@@ -125,6 +125,55 @@ message CameraSettings {
|
||||
|
||||
message CameraSettingsRequest {}
|
||||
|
||||
// =============================================================================
|
||||
// mDNS Settings - shared data types
|
||||
// =============================================================================
|
||||
|
||||
message MDNSTxtRecord {
|
||||
string key = 1;
|
||||
string value = 2;
|
||||
}
|
||||
|
||||
message MDNSServiceDef {
|
||||
string service = 1;
|
||||
string protocol = 2;
|
||||
uint32 port = 3;
|
||||
repeated MDNSTxtRecord txt_records = 4;
|
||||
}
|
||||
|
||||
message MDNSSettings {
|
||||
string hostname = 1;
|
||||
string instance = 2;
|
||||
repeated MDNSServiceDef services = 3;
|
||||
repeated MDNSTxtRecord global_txt_records = 4;
|
||||
}
|
||||
|
||||
message MDNSStatus {
|
||||
bool started = 1;
|
||||
string hostname = 2;
|
||||
string instance = 3;
|
||||
repeated MDNSServiceDef services = 4;
|
||||
repeated MDNSTxtRecord global_txt_records = 5;
|
||||
}
|
||||
|
||||
message MDNSSettingsRequest {}
|
||||
message MDNSStatusRequest {}
|
||||
|
||||
message MDNSQueryRequest {
|
||||
string service = 1;
|
||||
string protocol = 2;
|
||||
}
|
||||
|
||||
message MDNSQueryResult {
|
||||
string name = 1;
|
||||
string ip = 2;
|
||||
uint32 port = 3;
|
||||
}
|
||||
|
||||
message MDNSQueryResponse {
|
||||
repeated MDNSQueryResult services = 1;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// File System - shared data types
|
||||
// =============================================================================
|
||||
@@ -175,6 +224,10 @@ message Request {
|
||||
WifiSettingsRequest wifi_settings_request = 41;
|
||||
CameraSettings camera_settings = 50;
|
||||
CameraSettingsRequest camera_settings_request = 51;
|
||||
MDNSSettings mdns_settings = 60;
|
||||
MDNSSettingsRequest mdns_settings_request = 61;
|
||||
MDNSStatusRequest mdns_status_request = 62;
|
||||
MDNSQueryRequest mdns_query_request = 63;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,5 +244,8 @@ message Response {
|
||||
FileList file_list = 30;
|
||||
WifiSettings wifi_settings = 40;
|
||||
CameraSettings camera_settings = 50;
|
||||
MDNSSettings mdns_settings = 60;
|
||||
MDNSStatus mdns_status = 61;
|
||||
MDNSQueryResponse mdns_query_response = 62;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user