Enhance memory management in asset download and OTA processes by repl… (#1716)
* Enhance memory management in asset download and OTA processes by replacing static buffer allocations with dynamic memory allocation using heap capabilities. Update SPIRAM configuration values for improved memory usage. Add logging for error handling in buffer allocation failures. Introduce a new parameter in CloseAudioChannel to control goodbye message sending in MQTT and WebSocket protocols. * Update component versions in idf_component.yml and refactor GIF decoder functions for improved performance. Bump versions for audio effects, audio codec, LED strip, and other dependencies. Change GIF read and seek functions to inline for optimization. * Update language files to include new phrases for flight mode and connection status across multiple locales. Added translations for "FLIGHT_MODE_ON", "FLIGHT_MODE_OFF", "CONNECTION_SUCCESSFUL", and "MODEM_INIT_ERROR" in various languages, enhancing user experience and localization support. * fix wechat display
This commit is contained in:
@ -119,7 +119,8 @@ bool MqttProtocol::StartMqttClient(bool report_error) {
|
||||
auto alive = alive_; // Capture alive flag
|
||||
Application::GetInstance().Schedule([this, alive]() {
|
||||
if (*alive) {
|
||||
CloseAudioChannel();
|
||||
// Server initiated goodbye, don't send goodbye back to avoid ping-pong
|
||||
CloseAudioChannel(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -188,17 +189,23 @@ bool MqttProtocol::SendAudio(std::unique_ptr<AudioStreamPacket> packet) {
|
||||
return udp_->Send(encrypted) > 0;
|
||||
}
|
||||
|
||||
void MqttProtocol::CloseAudioChannel() {
|
||||
void MqttProtocol::CloseAudioChannel(bool send_goodbye) {
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(channel_mutex_);
|
||||
udp_.reset();
|
||||
}
|
||||
|
||||
std::string message = "{";
|
||||
message += "\"session_id\":\"" + session_id_ + "\",";
|
||||
message += "\"type\":\"goodbye\"";
|
||||
message += "}";
|
||||
SendText(message);
|
||||
ESP_LOGI(TAG, "Closing audio channel, send_goodbye: %d", send_goodbye);
|
||||
|
||||
// Only send goodbye when client initiates the close
|
||||
// Don't send if server already sent goodbye (to avoid ping-pong)
|
||||
if (send_goodbye) {
|
||||
std::string message = "{";
|
||||
message += "\"session_id\":\"" + session_id_ + "\",";
|
||||
message += "\"type\":\"goodbye\"";
|
||||
message += "}";
|
||||
SendText(message);
|
||||
}
|
||||
|
||||
if (on_audio_channel_closed_ != nullptr) {
|
||||
on_audio_channel_closed_();
|
||||
|
||||
Reference in New Issue
Block a user