mirror of
https://github.com/BotChain-Robots/firmware.git
synced 2026-07-08 17:47:21 +02:00
Fix mDNS integration with rmt
This commit is contained in:
@@ -95,7 +95,9 @@ void CommunicationRouter::update_leader() {
|
|||||||
|
|
||||||
this->m_leader = max;
|
this->m_leader = max;
|
||||||
|
|
||||||
mDNSDiscoveryService::set_connected_boards(connected_module_ids);
|
if (this->m_leader == m_module_id) {
|
||||||
|
mDNSDiscoveryService::set_connected_boards(connected_module_ids);
|
||||||
|
}
|
||||||
|
|
||||||
this->m_last_leader_updated = std::chrono::system_clock::now();
|
this->m_last_leader_updated = std::chrono::system_clock::now();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <esp_event.h>
|
#include <esp_event.h>
|
||||||
#include <freertos/semphr.h>
|
#include <freertos/semphr.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <mDNSDiscoveryService.h>
|
||||||
|
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
@@ -188,6 +189,7 @@ void WifiManager::wifi_event_handler(void *event_handler_arg, esp_event_base_t e
|
|||||||
} else if (WIFI_EVENT_STA_CONNECTED == event_id) {
|
} else if (WIFI_EVENT_STA_CONNECTED == event_id) {
|
||||||
printf("Connected to wifi in station mode\n");
|
printf("Connected to wifi in station mode\n");
|
||||||
that->update_state(wifi_state::connected);
|
that->update_state(wifi_state::connected);
|
||||||
|
mDNSDiscoveryService::setup();
|
||||||
} else if (WIFI_EVENT_STA_DISCONNECTED == event_id) {
|
} else if (WIFI_EVENT_STA_DISCONNECTED == event_id) {
|
||||||
printf("Station mode shutdown\n");
|
printf("Station mode shutdown\n");
|
||||||
xSemaphoreTake(that->m_mutex, portMAX_DELAY);
|
xSemaphoreTake(that->m_mutex, portMAX_DELAY);
|
||||||
@@ -204,5 +206,8 @@ void WifiManager::wifi_event_handler(void *event_handler_arg, esp_event_base_t e
|
|||||||
printf("User connected to AP\n");
|
printf("User connected to AP\n");
|
||||||
} else if (WIFI_EVENT_AP_STADISCONNECTED == event_id) {
|
} else if (WIFI_EVENT_AP_STADISCONNECTED == event_id) {
|
||||||
printf("User disconnected from AP\n");
|
printf("User disconnected from AP\n");
|
||||||
|
} else if (WIFI_EVENT_AP_START == event_id) {
|
||||||
|
mDNSDiscoveryService::setup();
|
||||||
|
printf("AP started\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public:
|
|||||||
~mDNSDiscoveryService() = delete;
|
~mDNSDiscoveryService() = delete;
|
||||||
|
|
||||||
static void setup();
|
static void setup();
|
||||||
static void set_connected_boards(std::vector<int>& boards);
|
static void set_connected_boards(const std::vector<int>& boards);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //DISCOVERYSERVICE_H
|
#endif //DISCOVERYSERVICE_H
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ void mDNSDiscoveryService::setup() {
|
|||||||
mdns_service_txt_set("_robotcontrol", "_tcp", service_txt_data, 3);
|
mdns_service_txt_set("_robotcontrol", "_tcp", service_txt_data, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mDNSDiscoveryService::set_connected_boards(std::vector<int>& boards) {
|
void mDNSDiscoveryService::set_connected_boards(const std::vector<int>& boards) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
for (int i = 0; i < boards.size(); i++) {
|
for (int i = 0; i < boards.size(); i++) {
|
||||||
|
|||||||
@@ -16,6 +16,5 @@ extern "C" [[noreturn]] void app_main(void) {
|
|||||||
ESP_LOGI("MEM", "Free PSRAM: %d", heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
|
ESP_LOGI("MEM", "Free PSRAM: %d", heap_caps_get_free_size(MALLOC_CAP_SPIRAM));
|
||||||
|
|
||||||
ConfigManager::init_config();
|
ConfigManager::init_config();
|
||||||
mDNSDiscoveryService::setup();
|
|
||||||
LoopManager::control_loop();
|
LoopManager::control_loop();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user