mDNS service added
This commit is contained in:
parent
5778bee9b2
commit
4ea02adc42
|
|
@ -40,7 +40,7 @@ idf_component_register(
|
||||||
"src/MQTT.c"
|
"src/MQTT.c"
|
||||||
"src/MQTTSysHandler.c"
|
"src/MQTTSysHandler.c"
|
||||||
"src/OTA.c"
|
"src/OTA.c"
|
||||||
|
"src/mDNS.c"
|
||||||
|
|
||||||
INCLUDE_DIRS "."
|
INCLUDE_DIRS "."
|
||||||
"include"
|
"include"
|
||||||
|
|
@ -55,6 +55,7 @@ idf_component_register(
|
||||||
mqtt
|
mqtt
|
||||||
esp_https_ota
|
esp_https_ota
|
||||||
app_update
|
app_update
|
||||||
|
mdns
|
||||||
|
|
||||||
EMBED_FILES "upload_script.html"
|
EMBED_FILES "upload_script.html"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,5 +112,6 @@ void RegEthReset(void (*eth_rst)(uint8_t level));
|
||||||
void RegGSMReset(void (*gsm_rst)(uint8_t level));
|
void RegGSMReset(void (*gsm_rst)(uint8_t level));
|
||||||
|
|
||||||
void GenerateSystemSettingsJSONFile(void);
|
void GenerateSystemSettingsJSONFile(void);
|
||||||
|
void mDNSServiceStart(void);
|
||||||
|
|
||||||
#endif /* MAIN_INCLUDE_NETTRANSPORT_H_ */
|
#endif /* MAIN_INCLUDE_NETTRANSPORT_H_ */
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,10 @@ esp_err_t WebGuiAppInit(void)
|
||||||
init_rom_fs("/espfs");
|
init_rom_fs("/espfs");
|
||||||
init_spi_fs("/data");
|
init_spi_fs("/data");
|
||||||
|
|
||||||
|
mDNSServiceStart();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_WEBGUIAPP_GPRS_ENABLE
|
#if CONFIG_WEBGUIAPP_GPRS_ENABLE
|
||||||
/*Start PPP modem*/
|
/*Start PPP modem*/
|
||||||
if (GetSysConf()->gsmSettings.Flags1.bIsGSMEnabled)
|
if (GetSysConf()->gsmSettings.Flags1.bIsGSMEnabled)
|
||||||
|
|
@ -187,6 +191,8 @@ esp_err_t WebGuiAppInit(void)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
55
src/mDNS.c
Normal file
55
src/mDNS.c
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*! Copyright 2023 Bogdan Pilyugin
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* \file mDNS.c
|
||||||
|
* \version 1.0
|
||||||
|
* \date 2023-01-29
|
||||||
|
* \author Bogdan Pilyugin
|
||||||
|
* \brief
|
||||||
|
* \details
|
||||||
|
* \copyright Apache License, Version 2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mdns.h"
|
||||||
|
#include "webguiapp.h"
|
||||||
|
#include "esp_log.h"
|
||||||
|
|
||||||
|
static const char *TAG = "mDNS";
|
||||||
|
|
||||||
|
void mDNSServiceStart(void)
|
||||||
|
{
|
||||||
|
//char temp_str[32] = { 0 };
|
||||||
|
uint8_t sta_mac[6] = { 0 };
|
||||||
|
ESP_ERROR_CHECK(esp_read_mac(sta_mac, ESP_MAC_WIFI_STA));
|
||||||
|
char *hostname = GetSysConf()->NetBIOSName;
|
||||||
|
//initialize mDNS
|
||||||
|
ESP_ERROR_CHECK(mdns_init());
|
||||||
|
//set mDNS hostname (required if you want to advertise services)
|
||||||
|
ESP_ERROR_CHECK(mdns_hostname_set(hostname));
|
||||||
|
ESP_LOGI(TAG, "mdns hostname set to: [%s]", hostname);
|
||||||
|
|
||||||
|
//set default mDNS instance name
|
||||||
|
ESP_ERROR_CHECK(mdns_instance_name_set("testboard"));
|
||||||
|
|
||||||
|
//structure with TXT records
|
||||||
|
mdns_txt_item_t serviceTxtData[] = {
|
||||||
|
{ "board", "your_bord_id" }
|
||||||
|
};
|
||||||
|
|
||||||
|
//initialize service
|
||||||
|
ESP_ERROR_CHECK(mdns_service_add("WebServer", "_http", "_tcp", 80, serviceTxtData, 1));
|
||||||
|
ESP_ERROR_CHECK( mdns_service_txt_item_set("_http", "_tcp", "path", "/index.html") );
|
||||||
|
free(hostname);
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user