|
@@ -359,6 +359,7 @@ void GpioHandler::init()
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void GpioHandler::taskHandler() {
|
|
void GpioHandler::taskHandler() {
|
|
|
|
|
+ std::lock_guard<std::mutex> lock(_mapMutex);
|
|
|
if (gpioMap != NULL) {
|
|
if (gpioMap != NULL) {
|
|
|
for(std::map<gpio_num_t, GpioPin*>::iterator it = gpioMap->begin(); it != gpioMap->end(); ++it) {
|
|
for(std::map<gpio_num_t, GpioPin*>::iterator it = gpioMap->begin(); it != gpioMap->end(); ++it) {
|
|
|
if ((it->second->getInterruptType() == GPIO_INTR_DISABLE))
|
|
if ((it->second->getInterruptType() == GPIO_INTR_DISABLE))
|
|
@@ -370,6 +371,7 @@ void GpioHandler::taskHandler() {
|
|
|
#ifdef ENABLE_MQTT
|
|
#ifdef ENABLE_MQTT
|
|
|
void GpioHandler::handleMQTTconnect()
|
|
void GpioHandler::handleMQTTconnect()
|
|
|
{
|
|
{
|
|
|
|
|
+ std::lock_guard<std::mutex> lock(_mapMutex);
|
|
|
if (gpioMap != NULL) {
|
|
if (gpioMap != NULL) {
|
|
|
for(std::map<gpio_num_t, GpioPin*>::iterator it = gpioMap->begin(); it != gpioMap->end(); ++it) {
|
|
for(std::map<gpio_num_t, GpioPin*>::iterator it = gpioMap->begin(); it != gpioMap->end(); ++it) {
|
|
|
if ((it->second->getMode() == GPIO_PIN_MODE_INPUT) || (it->second->getMode() == GPIO_PIN_MODE_INPUT_PULLDOWN) || (it->second->getMode() == GPIO_PIN_MODE_INPUT_PULLUP))
|
|
if ((it->second->getMode() == GPIO_PIN_MODE_INPUT) || (it->second->getMode() == GPIO_PIN_MODE_INPUT_PULLDOWN) || (it->second->getMode() == GPIO_PIN_MODE_INPUT_PULLUP))
|
|
@@ -451,6 +453,7 @@ void GpioHandler::workerLoop() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void GpioHandler::gpioInterrupt(GpioResult* gpioResult) {
|
|
void GpioHandler::gpioInterrupt(GpioResult* gpioResult) {
|
|
|
|
|
+ std::lock_guard<std::mutex> lock(_mapMutex);
|
|
|
if ((gpioMap != NULL) && (gpioMap->find(gpioResult->gpio) != gpioMap->end())) {
|
|
if ((gpioMap != NULL) && (gpioMap->find(gpioResult->gpio) != gpioMap->end())) {
|
|
|
(*gpioMap)[gpioResult->gpio]->gpioInterrupt(gpioResult->value);
|
|
(*gpioMap)[gpioResult->gpio]->gpioInterrupt(gpioResult->value);
|
|
|
}
|
|
}
|
|
@@ -647,6 +650,7 @@ void GpioHandler::registerGpioUri()
|
|
|
|
|
|
|
|
esp_err_t GpioHandler::handleHttpRequest(httpd_req_t *req)
|
|
esp_err_t GpioHandler::handleHttpRequest(httpd_req_t *req)
|
|
|
{
|
|
{
|
|
|
|
|
+ std::lock_guard<std::mutex> lock(_mapMutex);
|
|
|
ESP_LOGD(TAG, "handleHttpRequest");
|
|
ESP_LOGD(TAG, "handleHttpRequest");
|
|
|
|
|
|
|
|
if (gpioMap == NULL) {
|
|
if (gpioMap == NULL) {
|
|
@@ -746,6 +750,7 @@ esp_err_t GpioHandler::handleHttpRequest(httpd_req_t *req)
|
|
|
|
|
|
|
|
void GpioHandler::flashLightEnable(bool value)
|
|
void GpioHandler::flashLightEnable(bool value)
|
|
|
{
|
|
{
|
|
|
|
|
+ std::lock_guard<std::mutex> lock(_mapMutex);
|
|
|
ESP_LOGD(TAG, "GpioHandler::flashLightEnable %s", value ? "true" : "false");
|
|
ESP_LOGD(TAG, "GpioHandler::flashLightEnable %s", value ? "true" : "false");
|
|
|
|
|
|
|
|
if (gpioMap != NULL) {
|
|
if (gpioMap != NULL) {
|