openthread: apply clang-tidy suggestions

This commit is contained in:
Mathieu Rene 2024-10-14 21:56:26 -04:00
parent 0b8b82ba09
commit 51e1651992
2 changed files with 13 additions and 13 deletions

View file

@ -31,25 +31,25 @@ class OpenThreadComponent : public Component {
void ot_main(); void ot_main();
protected: protected:
void srp_setup(); void srp_setup_();
std::optional<otIp6Address> get_omr_address(std::optional<OpenThreadLockGuard> &lock); std::optional<otIp6Address> get_omr_address_(std::optional<OpenThreadLockGuard> &lock);
std::string host_name; std::string host_name_;
void *pool_alloc(size_t size); void *pool_alloc_(size_t size);
private: private:
// void platform_init(); // void platform_init();
esphome::mdns::MDNSComponent *mdns_{nullptr}; esphome::mdns::MDNSComponent *mdns_{nullptr};
std::vector<esphome::mdns::MDNSService> mdns_services_; std::vector<esphome::mdns::MDNSService> mdns_services_;
std::vector<std::unique_ptr<uint8_t[]>> _memory_pool; std::vector<std::unique_ptr<uint8_t[]>> memory_pool_;
}; };
extern OpenThreadComponent *global_openthread_component; extern OpenThreadComponent *global_openthread_component;
class OpenThreadLockGuard { class OpenThreadLockGuard {
public: public:
static std::optional<OpenThreadLockGuard> TryAcquire(int delay); static std::optional<OpenThreadLockGuard> try_acquire(int delay);
static std::optional<OpenThreadLockGuard> Acquire(); static std::optional<OpenThreadLockGuard> acquire();
~OpenThreadLockGuard(); ~OpenThreadLockGuard();
// Returns the global openthread instance guarded by this lock // Returns the global openthread instance guarded by this lock

View file

@ -45,14 +45,14 @@ void OpenThreadComponent::setup() {
xTaskCreate( xTaskCreate(
[](void *arg) { [](void *arg) {
static_cast<OpenThreadComponent *>(arg)->ot_main(); static_cast<OpenThreadComponent *>(arg)->ot_main();
vTaskDelete(NULL); vTaskDelete(nullptr);
}, },
"ot_main", 10240, this, 5, nullptr); "ot_main", 10240, this, 5, nullptr);
xTaskCreate( xTaskCreate(
[](void *arg) { [](void *arg) {
static_cast<OpenThreadComponent *>(arg)->srp_setup(); static_cast<OpenThreadComponent *>(arg)->srp_setup_();
vTaskDelete(NULL); vTaskDelete(nullptr);
}, },
"ot_srp_setup", 10240, this, 5, nullptr); "ot_srp_setup", 10240, this, 5, nullptr);
@ -62,7 +62,7 @@ void OpenThreadComponent::setup() {
static esp_netif_t *init_openthread_netif(const esp_openthread_platform_config_t *config) { static esp_netif_t *init_openthread_netif(const esp_openthread_platform_config_t *config) {
esp_netif_config_t cfg = ESP_NETIF_DEFAULT_OPENTHREAD(); esp_netif_config_t cfg = ESP_NETIF_DEFAULT_OPENTHREAD();
esp_netif_t *netif = esp_netif_new(&cfg); esp_netif_t *netif = esp_netif_new(&cfg);
assert(netif != NULL); assert(netif != nullptr);
ESP_ERROR_CHECK(esp_netif_attach(netif, esp_openthread_netif_glue_init(config))); ESP_ERROR_CHECK(esp_netif_attach(netif, esp_openthread_netif_glue_init(config)));
return netif; return netif;
@ -149,14 +149,14 @@ network::IPAddresses OpenThreadComponent::get_ip_addresses() {
return addresses; return addresses;
} }
std::optional<OpenThreadLockGuard> OpenThreadLockGuard::TryAcquire(int delay) { std::optional<OpenThreadLockGuard> OpenThreadLockGuard::try_acquire(int delay) {
if (esp_openthread_lock_acquire(delay)) { if (esp_openthread_lock_acquire(delay)) {
return OpenThreadLockGuard(); return OpenThreadLockGuard();
} }
return {}; return {};
} }
std::optional<OpenThreadLockGuard> OpenThreadLockGuard::Acquire() { std::optional<OpenThreadLockGuard> OpenThreadLockGuard::acquire() {
while (!esp_openthread_lock_acquire(100)) { while (!esp_openthread_lock_acquire(100)) {
esp_task_wdt_reset(); esp_task_wdt_reset();
} }