Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions firmware/include/extensions/AlexaExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
class AlexaExtension final : public ExtensionModule
{
private:
fauxmoESP fauxmo = fauxmoESP();
static constexpr std::string_view name{"Alexa"};

static inline fauxmoESP fauxmo = fauxmoESP();

static void onGet(AsyncWebServerRequest *request);
static void onSet(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total);
static void onSetState(unsigned char deviceId, const char *deviceName, bool state, unsigned char value);

public:
explicit AlexaExtension();
explicit AlexaExtension() : ExtensionModule(name) {};

void begin() override;
void handle() override;

void onTransmit(JsonObjectConst payload, const char *source) override;
void onTransmit(JsonObjectConst payload, std::string_view source) override;
};

extern AlexaExtension *Alexa; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

#endif // EXTENSION_ALEXA
22 changes: 11 additions & 11 deletions firmware/include/extensions/ButtonExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,41 @@
class ButtonExtension final : public ExtensionModule
{
private:
static constexpr std::string_view name{"Button"};

#ifdef PIN_SW1
bool brightnessIncrease = false;
bool powerLong = false;
bool powerShort = false;
inline static bool powerLong = false;
inline static bool powerShort = false;
#endif
#ifdef PIN_SW2
bool modeLong = false;
bool modeShort = false;
inline static bool modeLong = false;
inline static bool modeShort = false;
#endif

#ifdef PIN_SW1
volatile bool powerState = false;
static inline volatile bool powerState = false;
#endif
#ifdef PIN_SW2
volatile bool modeState = false;
inline static volatile bool modeState = false;
#endif

#ifdef PIN_SW1
volatile unsigned long powerMillis = 0;
static inline volatile unsigned long powerMillis = 0;
#endif
#ifdef PIN_SW2
volatile unsigned long modeMillis = 0;
static inline volatile unsigned long modeMillis = 0;
#endif

static IRAM_ATTR void onInterrupt();

static void event(const char *key, const char *value);

public:
explicit ButtonExtension();
explicit ButtonExtension() : ExtensionModule(name) {};

void configure() override;
void handle() override;
};

extern ButtonExtension *Button; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

#endif // EXTENSION_BUTTON
6 changes: 3 additions & 3 deletions firmware/include/extensions/HeapExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
class HeapExtension final : public ExtensionModule
{
private:
static constexpr std::string_view name{"Heap"};

unsigned long lastMillis = 0;

public:
explicit HeapExtension();
explicit HeapExtension() : ExtensionModule(name) {};

#if EXTENSION_HOMEASSISTANT
void configure() override;
Expand All @@ -20,6 +22,4 @@ class HeapExtension final : public ExtensionModule
void transmit();
};

extern HeapExtension *Heap; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

#endif // EXTENSION_HEAP
8 changes: 4 additions & 4 deletions firmware/include/extensions/HomeAssistantExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class HomeAssistantExtension final : public ExtensionModule
{
private:
static constexpr std::string_view name{"Home Assistant"};

bool pending = false;

inline static const std::string discoveryTopic =
Expand All @@ -20,11 +22,11 @@
void transmit();

public:
explicit HomeAssistantExtension();
explicit HomeAssistantExtension() : ExtensionModule(name) {};

inline static const std::string uniquePrefix = std::format("0x{:x}_", ESP.getEfuseMac());

JsonDocument *discovery = new JsonDocument();

Check warning on line 29 in firmware/include/extensions/HomeAssistantExtension.h

View workflow job for this annotation

GitHub Actions / Tidy (IKEA_FREKVENS, esp32-c5-devkitc-1)

firmware/include/extensions/HomeAssistantExtension.h:29:19 [cppcoreguidelines-non-private-member-variables-in-classes]

member variable 'discovery' has public visibility

Check warning on line 29 in firmware/include/extensions/HomeAssistantExtension.h

View workflow job for this annotation

GitHub Actions / Tidy (IKEA_FREKVENS, esp32-c6-devkitm-1)

firmware/include/extensions/HomeAssistantExtension.h:29:19 [cppcoreguidelines-non-private-member-variables-in-classes]

member variable 'discovery' has public visibility

void configure() override;
void begin() override;
Expand All @@ -32,11 +34,9 @@

void undiscover();

void onTransmit(JsonObjectConst payload, const char *source) override;
void onTransmit(JsonObjectConst payload, std::string_view source) override;
};

extern HomeAssistantExtension *HomeAssistant; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

namespace HomeAssistantAbbreviations
{
static constexpr std::string_view action_template = "act_tpl";
Expand Down
8 changes: 4 additions & 4 deletions firmware/include/extensions/InfraredExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
class InfraredExtension final : public ExtensionModule
{
private:
static constexpr std::string_view name{"Infrared"};

struct Code
{
decode_type_t protocol{};
Expand Down Expand Up @@ -137,7 +139,7 @@ class InfraredExtension final : public ExtensionModule
void transmit();

public:
explicit InfraredExtension();
explicit InfraredExtension() : ExtensionModule(name) {};

void configure() override;
void begin() override;
Expand All @@ -147,9 +149,7 @@ class InfraredExtension final : public ExtensionModule
void setActive(bool active);
void parse();

void onReceive(JsonObjectConst payload, const char *source) override;
void onReceive(JsonObjectConst payload, std::string_view source) override;
};

extern InfraredExtension *Infrared; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

#endif // EXTENSION_INFRARED
8 changes: 4 additions & 4 deletions firmware/include/extensions/MessageExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class MessageExtension final : public ExtensionModule
{
private:
static constexpr std::string_view name{"Message"};

bool active = false;
bool pending = false;

Expand Down Expand Up @@ -46,17 +48,15 @@ class MessageExtension final : public ExtensionModule
void transmit();

public:
explicit MessageExtension();
explicit MessageExtension() : ExtensionModule(name) {};

#if EXTENSION_HOMEASSISTANT
void configure() override;
#endif

void begin() override;
void handle() override;
void onReceive(JsonObjectConst payload, const char *source) override;
void onReceive(JsonObjectConst payload, std::string_view source) override;
};

extern MessageExtension *Message; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

#endif // EXTENSION_MESSAGE
8 changes: 4 additions & 4 deletions firmware/include/extensions/MicrophoneExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
class MicrophoneExtension final : public ExtensionModule
{
private:
static constexpr std::string_view name{"Microphone"};

bool active = false;
bool detected = false;
bool pending = false;
Expand All @@ -21,7 +23,7 @@ class MicrophoneExtension final : public ExtensionModule
void transmit();

public:
explicit MicrophoneExtension();
explicit MicrophoneExtension() : ExtensionModule(name) {};

void configure() override;
void begin() override;
Expand All @@ -32,9 +34,7 @@ class MicrophoneExtension final : public ExtensionModule
void setThreshold(uint16_t _threshold);
[[nodiscard]] bool isTriggered() const;

void onReceive(JsonObjectConst payload, const char *source) override;
void onReceive(JsonObjectConst payload, std::string_view source) override;
};

extern MicrophoneExtension *Microphone; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

#endif // EXTENSION_MICROPHONE
8 changes: 4 additions & 4 deletions firmware/include/extensions/MqttExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class MqttExtension final : public ExtensionModule
{
private:
static constexpr std::string_view name{"MQTT"};

unsigned long lastMillis = 0;

static inline bool subscribed = false;
Expand All @@ -22,7 +24,7 @@ class MqttExtension final : public ExtensionModule
const uint8_t *payload, size_t len, size_t index, size_t total);

public:
explicit MqttExtension();
explicit MqttExtension() : ExtensionModule(name) {};

espMqttClient client;

Expand All @@ -31,9 +33,7 @@ class MqttExtension final : public ExtensionModule

void disconnect();

void onTransmit(JsonObjectConst payload, const char *source) override;
void onTransmit(JsonObjectConst payload, std::string_view source) override;
};

extern MqttExtension *Mqtt; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

#endif // EXTENSION_MQTT
6 changes: 3 additions & 3 deletions firmware/include/extensions/OtaExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
class OtaExtension final : public ExtensionModule
{
private:
static constexpr std::string_view name{"OTA"};

ArduinoOTAClass ArduinoOTA;

static void onStart();
Expand All @@ -21,13 +23,11 @@ class OtaExtension final : public ExtensionModule
#endif

public:
explicit OtaExtension();
explicit OtaExtension() : ExtensionModule(name) {};

void configure() override;
void begin() override;
void handle() override;
};

extern OtaExtension *Ota; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

#endif // EXTENSION_OTA
10 changes: 5 additions & 5 deletions firmware/include/extensions/PhotocellExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
class PhotocellExtension final : public ExtensionModule
{
private:
static constexpr std::string_view name{"Photocell"};

bool active = false;
bool direction = false;
bool pending = false;
Expand All @@ -27,7 +29,7 @@ class PhotocellExtension final : public ExtensionModule
void transmit();

public:
explicit PhotocellExtension();
explicit PhotocellExtension() : ExtensionModule(name) {};

void configure() override;
void begin() override;
Expand All @@ -36,10 +38,8 @@ class PhotocellExtension final : public ExtensionModule
[[nodiscard]] bool getActive() const;
void setActive(bool active);

void onReceive(JsonObjectConst payload, const char *source) override;
void onTransmit(JsonObjectConst payload, const char *source) override;
void onReceive(JsonObjectConst payload, std::string_view source) override;
void onTransmit(JsonObjectConst payload, std::string_view source) override;
};

extern PhotocellExtension *Photocell; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

#endif // EXTENSION_PHOTOCELL
10 changes: 5 additions & 5 deletions firmware/include/extensions/PlaylistExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class PlaylistExtension final : public ExtensionModule
{
public:
explicit PlaylistExtension();
explicit PlaylistExtension() : ExtensionModule(name) {};

struct Mode
{
Expand All @@ -24,10 +24,12 @@ class PlaylistExtension final : public ExtensionModule
[[nodiscard]] bool getActive() const;
void setActive(bool active);

void onReceive(JsonObjectConst payload, const char *source) override;
void onTransmit(JsonObjectConst payload, const char *source) override;
void onReceive(JsonObjectConst payload, std::string_view source) override;
void onTransmit(JsonObjectConst payload, std::string_view source) override;

private:
static constexpr std::string_view name{"Playlist"};

bool active = false;

uint8_t step = 0;
Expand All @@ -40,6 +42,4 @@ class PlaylistExtension final : public ExtensionModule
void transmit();
};

extern PlaylistExtension *Playlist; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

#endif // EXTENSION_PLAYLIST
6 changes: 3 additions & 3 deletions firmware/include/extensions/RestfulExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
class RestfulExtension final : public ExtensionModule
{
private:
static constexpr std::string_view name{"Restful"};

static constexpr size_t prefixLength = sizeof("/restful/") - 1;

static void onGet(AsyncWebServerRequest *request);
static void onPatch(AsyncWebServerRequest *request, const uint8_t *data, size_t len, size_t index, size_t total);

public:
explicit RestfulExtension();
explicit RestfulExtension() : ExtensionModule(name) {};

void begin() override;
};

extern RestfulExtension *Restful; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

#endif // EXTENSION_RESTFUL
16 changes: 8 additions & 8 deletions firmware/include/extensions/RtcExtension.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
class RtcExtension final : public ExtensionModule
{
private:
static constexpr std::string_view name{"RTC"};

#ifdef PIN_INT
bool pending = true;
inline static bool pending = true;
#endif

#if defined(RTC_DS3231) || defined(RTC_DS3232)
Expand All @@ -33,16 +35,16 @@ class RtcExtension final : public ExtensionModule
#endif

public:
explicit RtcExtension();
explicit RtcExtension() : ExtensionModule(name) {};

#ifdef RTC_DS1307
RtcDS1307<TwoWire> rtc{Wire};
inline static RtcDS1307<TwoWire> rtc{Wire};
#elif defined(RTC_DS3231)
RtcDS3231<TwoWire> rtc{Wire};
inline static RtcDS3231<TwoWire> rtc{Wire};
#elif defined(RTC_DS3232)
RtcDS3232<TwoWire> rtc{Wire};
inline static RtcDS3232<TwoWire> rtc{Wire};
#elif defined(RTC_PCF8563)
RtcPCF8563<TwoWire> rtc{Wire};
inline static RtcPCF8563<TwoWire> rtc{Wire};
#endif // RTC_DS1307

void configure() override;
Expand All @@ -51,6 +53,4 @@ class RtcExtension final : public ExtensionModule
#endif
};

extern RtcExtension *Rtc; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)

#endif // EXTENSION_RTC
Loading
Loading