feat: Add DALI raw frame handling and USB setup bridge
- Introduced DaliRawFrame structure to encapsulate raw frame data. - Enhanced DaliDomainService to manage raw frame sinks and processing. - Implemented raw frame task for asynchronous handling of incoming DALI frames. - Integrated raw frame handling in GatewayBleBridge and GatewayNetworkService. - Added GatewayUsbSetupBridge to facilitate USB Serial/JTAG communication with DALI. - Configured ESP-NOW for wireless communication and setup management. - Updated GatewayRuntime to support clearing wireless credentials on boot button long press. - Enhanced CMakeLists to include new components and dependencies. Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -33,6 +33,7 @@ struct GatewayRuntimeConfig {
|
||||
std::string_view project_name;
|
||||
std::string_view version;
|
||||
std::string serial_id;
|
||||
bool default_ble_enabled{true};
|
||||
size_t command_queue_capacity{16};
|
||||
};
|
||||
|
||||
@@ -60,6 +61,7 @@ class GatewaySettingsStore {
|
||||
std::optional<std::string> getWifiSsid() const;
|
||||
std::optional<std::string> getWifiPassword() const;
|
||||
bool setWifiCredentials(std::string_view ssid, std::string_view password);
|
||||
bool clearWifiCredentials();
|
||||
|
||||
std::string getGatewayName(uint8_t gateway_id, std::string_view fallback) const;
|
||||
bool setGatewayName(uint8_t gateway_id, std::string_view name);
|
||||
@@ -99,6 +101,7 @@ class GatewayRuntime {
|
||||
|
||||
void setGatewayCount(size_t gateway_count);
|
||||
void setWirelessInfo(WirelessInfo info);
|
||||
bool clearWirelessInfo();
|
||||
void setCommandAddressResolver(std::function<uint8_t(uint8_t gw, uint8_t raw_addr)> resolver);
|
||||
|
||||
GatewayDeviceInfo deviceInfo() const;
|
||||
|
||||
@@ -122,6 +122,22 @@ bool GatewaySettingsStore::setWifiCredentials(std::string_view ssid,
|
||||
return writeString(kWifiSsidKey, ssid) && writeString(kWifiPasswordKey, password);
|
||||
}
|
||||
|
||||
bool GatewaySettingsStore::clearWifiCredentials() {
|
||||
if (handle_ == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
esp_err_t ssid_err = nvs_erase_key(handle_, kWifiSsidKey);
|
||||
esp_err_t password_err = nvs_erase_key(handle_, kWifiPasswordKey);
|
||||
if (ssid_err == ESP_ERR_NVS_NOT_FOUND) {
|
||||
ssid_err = ESP_OK;
|
||||
}
|
||||
if (password_err == ESP_ERR_NVS_NOT_FOUND) {
|
||||
password_err = ESP_OK;
|
||||
}
|
||||
return ssid_err == ESP_OK && password_err == ESP_OK && nvs_commit(handle_) == ESP_OK;
|
||||
}
|
||||
|
||||
std::string GatewaySettingsStore::getGatewayName(uint8_t gateway_id,
|
||||
std::string_view fallback) const {
|
||||
const auto value = readString(makeGatewayNameKey(gateway_id));
|
||||
@@ -193,7 +209,7 @@ esp_err_t GatewayRuntime::start() {
|
||||
return err;
|
||||
}
|
||||
|
||||
ble_enabled_ = settings_.getBleEnabled(profile_.enable_ble);
|
||||
ble_enabled_ = settings_.getBleEnabled(config_.default_ble_enabled);
|
||||
|
||||
if (!wireless_info_.has_value()) {
|
||||
WirelessInfo info;
|
||||
@@ -331,6 +347,14 @@ void GatewayRuntime::setWirelessInfo(WirelessInfo info) {
|
||||
}
|
||||
}
|
||||
|
||||
bool GatewayRuntime::clearWirelessInfo() {
|
||||
{
|
||||
LockGuard guard(command_lock_);
|
||||
wireless_info_.reset();
|
||||
}
|
||||
return settings_.clearWifiCredentials();
|
||||
}
|
||||
|
||||
void GatewayRuntime::setCommandAddressResolver(
|
||||
std::function<uint8_t(uint8_t gw, uint8_t raw_addr)> resolver) {
|
||||
LockGuard guard(command_lock_);
|
||||
|
||||
Reference in New Issue
Block a user