mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 09:18:00 +01:00
comply with function naming convention
This commit is contained in:
parent
f8cbbbb19f
commit
8cbc49bf2b
4 changed files with 22 additions and 26 deletions
|
@ -12,15 +12,15 @@ namespace mqtt {
|
|||
|
||||
static const char *const TAG = "mqtt-backend-esp8266";
|
||||
|
||||
void MQTTBackendESP8266::on_mqtt_message_wrapper_(MQTTClient *client, char topic[], char bytes[], int length) {
|
||||
static_cast<MQTTBackendESP8266 *>(client->ref)->on_mqtt_message_(client, topic, bytes, length);
|
||||
void MQTTBackendESP8266::on_mqtt_message_wrapper(MQTTClient *client, char topic[], char bytes[], int length) {
|
||||
static_cast<MQTTBackendESP8266 *>(client->ref)->on_mqtt_message(client, topic, bytes, length);
|
||||
}
|
||||
|
||||
void MQTTBackendESP8266::on_mqtt_message_(MQTTClient *client, char topic[], char bytes[], int length) {
|
||||
void MQTTBackendESP8266::on_mqtt_message(MQTTClient *client, char topic[], char bytes[], int length) {
|
||||
this->on_message_.call(topic, bytes, length, 0, length);
|
||||
}
|
||||
|
||||
void MQTTBackendESP8266::initialize_() {
|
||||
void MQTTBackendESP8266::initialize() {
|
||||
#ifdef USE_MQTT_SECURE_CLIENT
|
||||
if (this->ca_certificate_str_.has_value()) {
|
||||
this->ca_certificate_.append(this->ca_certificate_str_.value().c_str());
|
||||
|
@ -39,7 +39,7 @@ void MQTTBackendESP8266::initialize_() {
|
|||
this->is_initalized_ = true;
|
||||
}
|
||||
|
||||
void MQTTBackendESP8266::handleErrors_() {
|
||||
void MQTTBackendESP8266::handleErrors() {
|
||||
lwmqtt_err_t error = this->mqtt_client_.lastError();
|
||||
lwmqtt_return_code_t return_code = this->mqtt_client_.returnCode();
|
||||
if (error != LWMQTT_SUCCESS) {
|
||||
|
@ -84,11 +84,11 @@ void MQTTBackendESP8266::handleErrors_() {
|
|||
|
||||
void MQTTBackendESP8266::connect() {
|
||||
if (!this->is_initalized_) {
|
||||
this->initialize_();
|
||||
this->initialize();
|
||||
}
|
||||
this->mqtt_client_.begin(this->host_.c_str(), this->port_, this->wifi_client_);
|
||||
this->mqtt_client_.connect(this->client_id_.c_str(), this->username_.c_str(), this->password_.c_str());
|
||||
this->handleErrors_();
|
||||
this->handleErrors();
|
||||
}
|
||||
|
||||
void MQTTBackendESP8266::loop() {
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#ifdef USE_MQTT
|
||||
#ifdef USE_ESP8266
|
||||
|
||||
#include "mqtt_backend.h"
|
||||
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <BearSSLHelpers.h>
|
||||
|
@ -96,10 +94,10 @@ class MQTTBackendESP8266 final : public MQTTBackend {
|
|||
void set_ssl_fingerprint(const std::array<uint8_t, 20> &fingerprint) { this->ssl_fingerprint_ = fingerprint; };
|
||||
|
||||
protected:
|
||||
void initialize_();
|
||||
void handleErrors_();
|
||||
static void on_mqtt_message_wrapper_(MQTTClient *client, char topic[], char bytes[], int length);
|
||||
void on_mqtt_message_(MQTTClient *client, char topic[], char bytes[], int length);
|
||||
void initialize();
|
||||
void handleErrors();
|
||||
static void on_mqtt_message_wrapper(MQTTClient *client, char topic[], char bytes[], int length);
|
||||
void on_mqtt_message(MQTTClient *client, char topic[], char bytes[], int length);
|
||||
|
||||
#ifdef USE_MQTT_SECURE_CLIENT
|
||||
WiFiClientSecure wifi_client_;
|
||||
|
|
|
@ -12,21 +12,21 @@ namespace mqtt {
|
|||
|
||||
static const char *const TAG = "mqtt-backend-libretiny";
|
||||
|
||||
void MQTTBackendLibreTiny::on_mqtt_message_wrapper_(MQTTClient *client, char topic[], char bytes[], int length) {
|
||||
static_cast<MQTTBackendLibreTiny *>(client->ref)->on_mqtt_message_(client, topic, bytes, length);
|
||||
void MQTTBackendLibreTiny::on_mqtt_message_wrapper(MQTTClient *client, char topic[], char bytes[], int length) {
|
||||
static_cast<MQTTBackendLibreTiny *>(client->ref)->on_mqtt_message(client, topic, bytes, length);
|
||||
}
|
||||
|
||||
void MQTTBackendLibreTiny::on_mqtt_message_(MQTTClient *client, char topic[], char bytes[], int length) {
|
||||
void MQTTBackendLibreTiny::on_mqtt_message(MQTTClient *client, char topic[], char bytes[], int length) {
|
||||
this->on_message_.call(topic, bytes, length, 0, length);
|
||||
}
|
||||
|
||||
void MQTTBackendLibreTiny::initialize_() {
|
||||
void MQTTBackendLibreTiny::initialize() {
|
||||
this->mqtt_client_.ref = this;
|
||||
mqtt_client_.onMessageAdvanced(MQTTBackendLibreTiny::on_mqtt_message_wrapper_);
|
||||
this->is_initalized_ = true;
|
||||
}
|
||||
|
||||
void MQTTBackendLibreTiny::handleErrors_() {
|
||||
void MQTTBackendLibreTiny::handleErrors() {
|
||||
lwmqtt_err_t error = this->mqtt_client_.lastError();
|
||||
lwmqtt_return_code_t return_code = this->mqtt_client_.returnCode();
|
||||
if (error != LWMQTT_SUCCESS) {
|
||||
|
@ -65,11 +65,11 @@ void MQTTBackendLibreTiny::handleErrors_() {
|
|||
|
||||
void MQTTBackendLibreTiny::connect() {
|
||||
if (!this->is_initalized_) {
|
||||
this->initialize_();
|
||||
this->initialize();
|
||||
}
|
||||
this->mqtt_client_.begin(this->host_.c_str(), this->port_, this->wifi_client_);
|
||||
this->mqtt_client_.connect(this->client_id_.c_str(), this->username_.c_str(), this->password_.c_str());
|
||||
this->handleErrors_();
|
||||
this->handleErrors();
|
||||
}
|
||||
|
||||
void MQTTBackendLibreTiny::loop() {
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
#ifdef USE_MQTT
|
||||
#ifdef USE_LIBRETINY
|
||||
|
||||
#include "mqtt_backend.h"
|
||||
|
||||
#include "esphome/core/log.h"
|
||||
|
||||
#include <WiFiClient.h>
|
||||
|
@ -95,10 +93,10 @@ class MQTTBackendLibreTiny final : public MQTTBackend {
|
|||
void set_ssl_fingerprint(const std::array<uint8_t, 20> &fingerprint) { this->ssl_fingerprint_ = fingerprint; };
|
||||
|
||||
protected:
|
||||
void initialize_();
|
||||
void handleErrors_();
|
||||
static void on_mqtt_message_wrapper_(MQTTClient *client, char topic[], char bytes[], int length);
|
||||
void on_mqtt_message_(MQTTClient *client, char topic[], char bytes[], int length);
|
||||
void initialize();
|
||||
void handleErrors();
|
||||
static void on_mqtt_message_wrapper(MQTTClient *client, char topic[], char bytes[], int length);
|
||||
void on_mqtt_message(MQTTClient *client, char topic[], char bytes[], int length);
|
||||
|
||||
WiFiClient wifi_client_;
|
||||
MQTTClient mqtt_client_;
|
||||
|
|
Loading…
Reference in a new issue