Files
xiaozhi-esp32/main/boards/common/nt26_board.h
Xiaoxia 89674f8838 v2.2.0: Add bread-compact-nt26 board (#1663)
* Refactor application error handling and improve network task logic

- Updated error handling for modem initialization failure in Application::Initialize().
- Added new error message for modem initialization in English and Chinese language files.
- Simplified lambda captures in NetworkTask to avoid unnecessary references.
- Set main task priority in Application::Run() for better performance.

* Add support for Bread Compact NT26 board

- Introduced new board configuration for Bread Compact NT26 in CMakeLists.txt and Kconfig.
- Added board-specific implementation in compact_nt26_board.cc and nt26_board.cc.
- Created configuration files for NT26, including config.h and config.json.
- Updated dependencies in idf_component.yml to include uart-eth-modem.
- Translated error messages in config.h for OLED display type selection to English.
- Enhanced display and button initialization logic for NT26 board.

* Update project version and improve build configuration

- Updated project version from 2.1.0 to 2.2.0 in CMakeLists.txt.
- Enabled minimal build configuration to include only essential components.
- Updated README files to replace QQ group links with Discord links for community engagement.

* Update Bread Compact NT26 board configuration name in config.json

* fix compile errors

* Update uart-eth-modem dependency format in idf_component.yml

* fix esp32 compiling errors

* Update CMakeLists.txt to change component dependency from REQUIRES to PRIV_REQUIRES for esp_pm, esp_psram, and esp_driver_gpio

* Refactor CMakeLists.txt to explicitly list board common source files and update include directories for better clarity and organization.

* Add esp_driver_ppa as a dependency in CMakeLists.txt
2026-01-19 21:46:21 +08:00

63 lines
2.0 KiB
C++

#ifndef NT26_BOARD_H
#define NT26_BOARD_H
#include <memory>
#include <uart_eth_modem.h>
#include <esp_network.h>
#include <esp_pm.h>
#include <esp_timer.h>
#include "board.h"
struct Nt26CeregState {
int stat = 0;
std::string tac;
std::string ci;
int AcT = -1;
std::string ToString() const {
std::string json = "{";
json += "\"stat\":" + std::to_string(stat);
if (!tac.empty()) json += ",\"tac\":\"" + tac + "\"";
if (!ci.empty()) json += ",\"ci\":\"" + ci + "\"";
if (AcT >= 0) json += ",\"AcT\":" + std::to_string(AcT);
json += "}";
return json;
}
};
class Nt26Board : public Board {
protected:
std::unique_ptr<UartEthModem> modem_;
gpio_num_t tx_pin_;
gpio_num_t rx_pin_;
gpio_num_t dtr_pin_; // mrdy_pin
gpio_num_t ri_pin_; // srdy_pin
gpio_num_t reset_pin_;
NetworkEventCallback network_event_callback_;
esp_pm_lock_handle_t pm_lock_cpu_max_ = nullptr;
PowerSaveLevel current_power_level_ = PowerSaveLevel::LOW_POWER;
esp_timer_handle_t network_ready_timer_ = nullptr;
virtual std::string GetBoardJson() override;
void OnNetworkEvent(NetworkEvent event, const std::string& data = "");
static void OnNetworkReadyTimeout(void* arg);
void ScheduleAsyncStop();
public:
Nt26Board(gpio_num_t tx_pin, gpio_num_t rx_pin, gpio_num_t dtr_pin, gpio_num_t ri_pin, gpio_num_t reset_pin = GPIO_NUM_NC);
virtual ~Nt26Board();
virtual std::string GetBoardType() override;
virtual void StartNetwork() override;
virtual void SetNetworkEventCallback(NetworkEventCallback callback) override;
virtual NetworkInterface* GetNetwork() override;
virtual const char* GetNetworkStateIcon() override;
virtual void SetPowerSaveLevel(PowerSaveLevel level) override;
virtual AudioCodec* GetAudioCodec() override { return nullptr; }
virtual std::string GetDeviceStatusJson() override;
Nt26CeregState GetRegistrationState();
};
#endif // NT26_BOARD_H