mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-07 20:16:55 +03:00
work on GPIO handler
bigfix: memory leak in GetJPGStream
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
#ifndef SERVER_GPIO_H
|
||||
#define SERVER_GPIO_H
|
||||
|
||||
#include <esp_log.h>
|
||||
|
||||
#include <esp_http_server.h>
|
||||
#include <map>
|
||||
#include "driver/gpio.h"
|
||||
|
||||
//#include "ClassControllCamera.h"
|
||||
|
||||
static const char *TAGPARTGPIO = "server_GPIO";
|
||||
|
||||
typedef enum {
|
||||
GPIO_PIN_MODE_DISABLED = 0x0,
|
||||
GPIO_PIN_MODE_INPUT = 0x1,
|
||||
@@ -18,20 +20,24 @@ typedef enum {
|
||||
GPIO_PIN_MODE_EXTERNAL_FLASH_WS281X = 0x5,
|
||||
} gpio_pin_mode_t;
|
||||
|
||||
|
||||
class GpioPin {
|
||||
public:
|
||||
GpioPin(gpio_num_t gpio, const char* name, gpio_pin_mode_t mode, gpio_int_type_t interruptType, uint8_t dutyResolution, bool mqttEnable, bool httpEnable);
|
||||
GpioPin(gpio_num_t gpio, const char* name, gpio_pin_mode_t mode, gpio_int_type_t interruptType, uint8_t dutyResolution, std::string mqttTopic, bool httpEnable);
|
||||
~GpioPin();
|
||||
|
||||
bool getValue(std::string* errorText);
|
||||
void setValue(bool value, std::string* errorText);
|
||||
void init();
|
||||
bool handleMQTT(std::string, char* data, int data_len);
|
||||
void gpioInterrupt();
|
||||
|
||||
private:
|
||||
gpio_num_t _gpio;
|
||||
const char* _name;
|
||||
gpio_pin_mode_t _mode;
|
||||
gpio_int_type_t _interruptType;
|
||||
std::string _mqttTopic;
|
||||
};
|
||||
|
||||
esp_err_t callHandleHttpRequest(httpd_req_t *req);
|
||||
@@ -43,7 +49,7 @@ public:
|
||||
~GpioHandler();
|
||||
|
||||
void init();
|
||||
void clear();
|
||||
void destroy();
|
||||
void registerGpioUri();
|
||||
esp_err_t handleHttpRequest(httpd_req_t *req);
|
||||
|
||||
@@ -54,9 +60,13 @@ private:
|
||||
TaskHandle_t xHandletaskGpioHandler = NULL;
|
||||
|
||||
bool readConfig();
|
||||
void clear();
|
||||
|
||||
gpio_num_t resolvePinNr(uint8_t pinNr);
|
||||
gpio_pin_mode_t resolvePinMode(std::string input);
|
||||
gpio_int_type_t resolveIntType(std::string input);
|
||||
};
|
||||
|
||||
void GpioHandlerStart();
|
||||
void GpioHandlerStart();
|
||||
|
||||
#endif //SERVER_GPIO_H
|
||||
Reference in New Issue
Block a user