clangtidy corrections part 2
This commit is contained in:
+44
-43
@@ -1,12 +1,12 @@
|
||||
/**
|
||||
* @file network.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2023-09-18
|
||||
*
|
||||
*
|
||||
* @copyright Copyright (c) 2023
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef NETWORK_H
|
||||
@@ -20,10 +20,11 @@
|
||||
#include <esp_now.h>
|
||||
#include <esp_wifi.h>
|
||||
|
||||
typedef void (*recieveCallbackPtr) (const uint8_t * mac, const uint8_t *incomingData, int len);
|
||||
typedef void (*sendCallbackPtr) (const uint8_t *mac_addr, esp_now_send_status_t status);
|
||||
typedef void (*recieveCallbackPtr)(const uint8_t *mac, const uint8_t *incomingData, int len);
|
||||
typedef void (*sendCallbackPtr)(const uint8_t *mac_addr, esp_now_send_status_t status);
|
||||
|
||||
struct NetworkAdresses {
|
||||
struct NetworkAdresses
|
||||
{
|
||||
IPAddress localIP;
|
||||
IPAddress gateway;
|
||||
IPAddress subnet;
|
||||
@@ -32,53 +33,53 @@ struct NetworkAdresses {
|
||||
uint16_t mqttPort = 1883;
|
||||
};
|
||||
|
||||
class Network : public Component {
|
||||
public:
|
||||
Network(const char *ssid, const char *passphrase);
|
||||
Network(const char *ssid, const char *passphrase, NetworkAdresses adresses);
|
||||
class Network : public Component
|
||||
{
|
||||
public:
|
||||
Network(const char *ssid, const char *passphrase);
|
||||
Network(const char *ssid, const char *passphrase, NetworkAdresses adresses);
|
||||
|
||||
~Network();
|
||||
~Network();
|
||||
|
||||
bool activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send);
|
||||
bool activateMqtt(const char *user = nullptr, const char *passphrase = nullptr);
|
||||
bool activateEspNow(recieveCallbackPtr reci, sendCallbackPtr send);
|
||||
bool activateMqtt(const char *user = nullptr, const char *passphrase = nullptr);
|
||||
|
||||
void printIPs();
|
||||
const void printIPs();
|
||||
|
||||
bool isWifiConnected() const { return this->wifiConnected; }
|
||||
bool isMqttConnected() const { return this->mqttConnected; }
|
||||
const uint8_t* getBroadcastAddress() const { return this->broadcastAddress; }
|
||||
PubSubClient* getMqttClient() const { return this->mqttClient; }
|
||||
bool isWifiConnected() const { return this->wifiConnected; }
|
||||
bool isMqttConnected() const { return this->mqttConnected; }
|
||||
const uint8_t *getBroadcastAddress() const { return this->broadcastAddress; }
|
||||
PubSubClient *getMqttClient() const { return this->mqttClient; }
|
||||
|
||||
static uint8_t getCurrentChannel();
|
||||
|
||||
private:
|
||||
void run() override {};
|
||||
void runAsChild() override;
|
||||
void init(const char *ssid, const char *passphrase);
|
||||
void checkWifi();
|
||||
void checkMqtt();
|
||||
bool connectMqtt();
|
||||
static uint8_t getCurrentChannel();
|
||||
|
||||
NetworkAdresses adresses;
|
||||
WiFiClient wifiClient;
|
||||
PubSubClient* mqttClient = nullptr;
|
||||
private:
|
||||
void run() override{};
|
||||
void runAsChild() override;
|
||||
void init(const char *ssid, const char *passphrase);
|
||||
void checkWifi();
|
||||
void checkMqtt();
|
||||
bool connectMqtt();
|
||||
|
||||
bool initSucessful = false;
|
||||
bool wifiConnected = false;
|
||||
bool mqttConnected = false;
|
||||
NetworkAdresses adresses;
|
||||
WiFiClient wifiClient;
|
||||
PubSubClient *mqttClient = nullptr;
|
||||
|
||||
const char *mqttUser;
|
||||
const char *mqttPassphrase;
|
||||
bool initSucessful = false;
|
||||
bool wifiConnected = false;
|
||||
bool mqttConnected = false;
|
||||
|
||||
uint8_t broadcastAddress[6] = {0xC8, 0xC9, 0xA3, 0xC8, 0x57, 0x10};
|
||||
uint32_t lastWifiRecoonectAttemp = 0;
|
||||
uint32_t lastMqttReconnectAttemp = 0;
|
||||
const char *mqttUser = nullptr;
|
||||
const char *mqttPassphrase = nullptr;
|
||||
|
||||
static constexpr uint8_t wifiConnectTimeout = 20;
|
||||
static constexpr uint16_t wifiConnectLoopTime = 500;
|
||||
static constexpr uint16_t wifiReconnectDelay = 5000;
|
||||
static constexpr uint16_t mqttReconnectDelay = 2500;
|
||||
uint8_t broadcastAddress[6] = {0xC8, 0xC9, 0xA3, 0xC8, 0x57, 0x10};
|
||||
uint32_t lastWifiRecoonectAttemp = 0;
|
||||
uint32_t lastMqttReconnectAttemp = 0;
|
||||
|
||||
static constexpr uint8_t wifiConnectTimeout = 20;
|
||||
static constexpr uint16_t wifiConnectLoopTime = 500;
|
||||
static constexpr uint16_t wifiReconnectDelay = 5000;
|
||||
static constexpr uint16_t mqttReconnectDelay = 2500;
|
||||
};
|
||||
|
||||
#endif //NETWORK_H
|
||||
#endif // NETWORK_H
|
||||
|
||||
Reference in New Issue
Block a user