Automatic Curtain  MVP
Software repository for an automatic curtain using stepper motor, TMC2209 and ESP32
alexa_interaction.h
Go to the documentation of this file.
1 
12 #ifndef _ALEXA_INT_INCLUDE_GUARD
13 #define _ALEXA_INT_INCLUDE_GUARD
14 
15 #include <mutex>
16 #include <sstream>
17 #include <string>
18 #include <tuple>
19 
20 #include "../config/config.h"
21 #include "../logging/logging.h"
22 #include "fauxmoESP.h"
23 
24 class AlexaInteraction : private fauxmoESP {
25  public:
30  AlexaInteraction(std::shared_ptr<Logging>& logging, String device_id);
31 
37 
43  std::tuple<bool, CONFIG_SET::MOTION_REQUEST> GetAlexaRequest();
44 
49  void HandleFauxmo();
50 
56 
57  private:
58  std::shared_ptr<Logging> logger_;
59  static std::mutex alexa_request_mutex_;
60  static String device_id_;
63 
72  static void Callback(unsigned char id, const char* device_name, bool state, unsigned char percentage);
73 };
74 
75 #endif
std::shared_ptr< Logging > logger_
Definition: alexa_interaction.h:58
AlexaInteraction(std::shared_ptr< Logging > &logging, String device_id)
Construct a new AlexaInteraction object, initializes fauxmoesp.
Definition: alexa_interaction.cpp:29
static String device_id_
Definition: alexa_interaction.h:60
Definition: config.h:160
static CONFIG_SET::MOTION_REQUEST latest_alexa_request_
Definition: alexa_interaction.h:62
static void Callback(unsigned char id, const char *device_name, bool state, unsigned char percentage)
Gets called by fauxmo esp when a alexa calls the device.
Definition: alexa_interaction.cpp:38
void SetState(CONFIG_SET::MOTION_REQUEST request)
Set the object state to alexa.
Definition: alexa_interaction.cpp:65
static std::mutex alexa_request_mutex_
Definition: alexa_interaction.h:59
static bool is_new_request_available_
Definition: alexa_interaction.h:61
Definition: alexa_interaction.h:24
std::tuple< bool, CONFIG_SET::MOTION_REQUEST > GetAlexaRequest()
Get the latest Alexa Request object.
Definition: alexa_interaction.cpp:54
~AlexaInteraction()
Destroy the AlexaInteraction object.
Definition: alexa_interaction.cpp:52
void HandleFauxmo()
Handler function for the class.
Definition: alexa_interaction.cpp:61