diff --git a/src/EMSESPDevicesService.cpp b/src/EMSESPDevicesService.cpp index 585b2b4c8..8b77d3b94 100644 --- a/src/EMSESPDevicesService.cpp +++ b/src/EMSESPDevicesService.cpp @@ -1,3 +1,21 @@ +/* + * EMS-ESP - https://github.com/proddy/EMS-ESP + * Copyright 2019 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "EMSESPDevicesService.h" #include "emsesp.h" #include "mqtt.h" @@ -5,9 +23,8 @@ namespace emsesp { EMSESPDevicesService::EMSESPDevicesService(AsyncWebServer * server, SecurityManager * securityManager) - : _timeHandler(DEVICE_DATA_SERVICE_PATH, - securityManager->wrapCallback(std::bind(&EMSESPDevicesService::device_data, this, _1, _2), AuthenticationPredicates::IS_AUTHENTICATED)) { - // body + : _device_dataHandler(DEVICE_DATA_SERVICE_PATH, + securityManager->wrapCallback(std::bind(&EMSESPDevicesService::device_data, this, _1, _2), AuthenticationPredicates::IS_AUTHENTICATED)) { server->on(EMSESP_DEVICES_SERVICE_PATH, HTTP_GET, securityManager->wrapRequest(std::bind(&EMSESPDevicesService::all_devices, this, _1), AuthenticationPredicates::IS_AUTHENTICATED)); @@ -16,9 +33,9 @@ EMSESPDevicesService::EMSESPDevicesService(AsyncWebServer * server, SecurityMana HTTP_GET, securityManager->wrapRequest(std::bind(&EMSESPDevicesService::scan_devices, this, _1), AuthenticationPredicates::IS_AUTHENTICATED)); - _timeHandler.setMethod(HTTP_POST); - _timeHandler.setMaxContentLength(256); - server->addHandler(&_timeHandler); + _device_dataHandler.setMethod(HTTP_POST); + _device_dataHandler.setMaxContentLength(256); + server->addHandler(&_device_dataHandler); } void EMSESPDevicesService::scan_devices(AsyncWebServerRequest * request) { diff --git a/src/EMSESPDevicesService.h b/src/EMSESPDevicesService.h index db242984e..05cc58577 100644 --- a/src/EMSESPDevicesService.h +++ b/src/EMSESPDevicesService.h @@ -1,3 +1,21 @@ +/* + * EMS-ESP - https://github.com/proddy/EMS-ESP + * Copyright 2019 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef EMSESPDevicesService_h #define EMSESPDevicesService_h @@ -23,9 +41,9 @@ class EMSESPDevicesService { private: void all_devices(AsyncWebServerRequest * request); void scan_devices(AsyncWebServerRequest * request); - - AsyncCallbackJsonWebHandler _timeHandler; void device_data(AsyncWebServerRequest * request, JsonVariant & json); + + AsyncCallbackJsonWebHandler _device_dataHandler; }; } // namespace emsesp diff --git a/src/EMSESPSettingsService.cpp b/src/EMSESPSettingsService.cpp index 0adac9027..41c5fb6a4 100644 --- a/src/EMSESPSettingsService.cpp +++ b/src/EMSESPSettingsService.cpp @@ -1,3 +1,21 @@ +/* + * EMS-ESP - https://github.com/proddy/EMS-ESP + * Copyright 2019 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "EMSESPSettingsService.h" #include "emsesp.h" diff --git a/src/EMSESPSettingsService.h b/src/EMSESPSettingsService.h index 174138576..bc4f53931 100644 --- a/src/EMSESPSettingsService.h +++ b/src/EMSESPSettingsService.h @@ -1,3 +1,21 @@ +/* + * EMS-ESP - https://github.com/proddy/EMS-ESP + * Copyright 2019 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef EMSESPSettingsConfig_h #define EMSESPSettingsConfig_h @@ -7,7 +25,7 @@ #define EMSESP_SETTINGS_FILE "/config/emsespSettings.json" #define EMSESP_SETTINGS_SERVICE_PATH "/rest/emsespSettings" -#define EMSESP_DEFAULT_TX_MODE 1 // EMS1.0 +#define EMSESP_DEFAULT_TX_MODE 1 // EMS1.0 #define EMSESP_DEFAULT_EMS_BUS_ID 0x0B // service key #define EMSESP_DEFAULT_SYSLOG_LEVEL -1 // OFF diff --git a/src/EMSESPStatusService.cpp b/src/EMSESPStatusService.cpp index 0aaaca257..c0f6252b9 100644 --- a/src/EMSESPStatusService.cpp +++ b/src/EMSESPStatusService.cpp @@ -1,3 +1,21 @@ +/* + * EMS-ESP - https://github.com/proddy/EMS-ESP + * Copyright 2019 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "EMSESPStatusService.h" #include "emsesp.h" #include "mqtt.h" @@ -12,7 +30,7 @@ EMSESPStatusService::EMSESPStatusService(AsyncWebServer * server, SecurityManage securityManager->wrapRequest(std::bind(&EMSESPStatusService::emsespStatusService, this, std::placeholders::_1), AuthenticationPredicates::IS_AUTHENTICATED)); -// trigger on wifi connects +// trigger on wifi connects/disconnects #ifdef ESP32 WiFi.onEvent(onStationModeDisconnected, WiFiEvent_t::SYSTEM_EVENT_STA_DISCONNECTED); WiFi.onEvent(onStationModeGotIP, WiFiEvent_t::SYSTEM_EVENT_STA_GOT_IP); diff --git a/src/EMSESPStatusService.h b/src/EMSESPStatusService.h index c2abfddb2..8ee99071a 100644 --- a/src/EMSESPStatusService.h +++ b/src/EMSESPStatusService.h @@ -1,3 +1,21 @@ +/* + * EMS-ESP - https://github.com/proddy/EMS-ESP + * Copyright 2019 Paul Derbyshire + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef EMSESPStatusService_h #define EMSESPStatusService_h @@ -20,14 +38,11 @@ class EMSESPStatusService { void emsespStatusService(AsyncWebServerRequest * request); #ifdef ESP32 - static void onStationModeConnected(WiFiEvent_t event, WiFiEventInfo_t info); static void onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info); static void onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info); #elif defined(ESP8266) - WiFiEventHandler _onStationModeConnectedHandler; WiFiEventHandler _onStationModeDisconnectedHandler; WiFiEventHandler _onStationModeGotIPHandler; - static void onStationModeConnected(const WiFiEventStationModeConnected & event); static void onStationModeDisconnected(const WiFiEventStationModeDisconnected & event); static void onStationModeGotIP(const WiFiEventStationModeGotIP & event); #endif