Browse Source

Include library headers in .cpp

mcspr-patch-1
Maxim Prokhorov 4 years ago
committed by Max Prokhorov
parent
commit
3d7449c202
16 changed files with 84 additions and 81 deletions
  1. +3
    -0
      code/espurna/alexa.cpp
  2. +0
    -3
      code/espurna/alexa.h
  3. +3
    -0
      code/espurna/api.cpp
  4. +0
    -3
      code/espurna/api.h
  5. +2
    -0
      code/espurna/influxdb.cpp
  6. +0
    -2
      code/espurna/influxdb.h
  7. +0
    -2
      code/espurna/libs/AsyncClientHelpers.h
  8. +11
    -0
      code/espurna/mqtt.cpp
  9. +0
    -9
      code/espurna/mqtt.h
  10. +0
    -4
      code/espurna/ota.h
  11. +2
    -0
      code/espurna/ota_arduinoota.cpp
  12. +4
    -1
      code/espurna/ota_asynctcp.cpp
  13. +50
    -0
      code/espurna/telnet.cpp
  14. +0
    -49
      code/espurna/telnet.h
  15. +9
    -2
      code/espurna/web.cpp
  16. +0
    -6
      code/espurna/web.h

+ 3
- 0
code/espurna/alexa.cpp View File

@ -19,6 +19,9 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include "web.h" #include "web.h"
#include "ws.h" #include "ws.h"
#include <fauxmoESP.h>
#include <ArduinoJson.h>
struct alexa_queue_element_t { struct alexa_queue_element_t {
unsigned char device_id; unsigned char device_id;
bool state; bool state;


+ 0
- 3
code/espurna/alexa.h View File

@ -12,9 +12,6 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#if ALEXA_SUPPORT #if ALEXA_SUPPORT
#include <fauxmoESP.h>
#include <ArduinoJson.h>
bool alexaEnabled(); bool alexaEnabled();
void alexaSetup(); void alexaSetup();


+ 3
- 0
code/espurna/api.cpp View File

@ -18,6 +18,9 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include "web.h" #include "web.h"
#include "rpc.h" #include "rpc.h"
#include <ESPAsyncTCP.h>
#include <ArduinoJson.h>
struct web_api_t { struct web_api_t {
explicit web_api_t(const String& key, api_get_callback_f getFn, api_put_callback_f putFn) : explicit web_api_t(const String& key, api_get_callback_f getFn, api_put_callback_f putFn) :
key(key), key(key),


+ 0
- 3
code/espurna/api.h View File

@ -24,9 +24,6 @@ String apiKey();
#include <functional> #include <functional>
#include <ESPAsyncTCP.h>
#include <ArduinoJson.h>
using api_get_callback_f = std::function<void(char * buffer, size_t size)>; using api_get_callback_f = std::function<void(char * buffer, size_t size)>;
using api_put_callback_f = std::function<void(const char * payload)> ; using api_put_callback_f = std::function<void(const char * payload)> ;


+ 2
- 0
code/espurna/influxdb.cpp View File

@ -20,6 +20,8 @@ Copyright (C) 2017-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include "ws.h" #include "ws.h"
#include "libs/AsyncClientHelpers.h" #include "libs/AsyncClientHelpers.h"
#include <ESPAsyncTCP.h>
const char InfluxDb_http_success[] = "HTTP/1.1 204"; const char InfluxDb_http_success[] = "HTTP/1.1 204";
const char InfluxDb_http_template[] PROGMEM = "POST /write?db=%s&u=%s&p=%s HTTP/1.1\r\nHost: %s:%u\r\nContent-Length: %d\r\n\r\n"; const char InfluxDb_http_template[] PROGMEM = "POST /write?db=%s&u=%s&p=%s HTTP/1.1\r\nHost: %s:%u\r\nContent-Length: %d\r\n\r\n";


+ 0
- 2
code/espurna/influxdb.h View File

@ -10,8 +10,6 @@ Copyright (C) 2017-2019 by Xose Pérez <xose dot perez at gmail dot com>
#if INFLUXDB_SUPPORT #if INFLUXDB_SUPPORT
#include <ESPAsyncTCP.h>
bool idbSend(const char * topic, unsigned char id, const char * payload); bool idbSend(const char * topic, unsigned char id, const char * payload);
bool idbSend(const char * topic, const char * payload); bool idbSend(const char * topic, const char * payload);
bool idbEnabled(); bool idbEnabled();


+ 0
- 2
code/espurna/libs/AsyncClientHelpers.h View File

@ -4,8 +4,6 @@
#pragma once #pragma once
#include <ESPAsyncTCP.h>
enum class AsyncClientState { enum class AsyncClientState {
Disconnected, Disconnected,
Connecting, Connecting,


+ 11
- 0
code/espurna/mqtt.cpp View File

@ -26,6 +26,17 @@ Updated secure client support by Niek van der Maas < mail at niekvandermaas dot
#include "libs/AsyncClientHelpers.h" #include "libs/AsyncClientHelpers.h"
#include "libs/SecureClientHelpers.h" #include "libs/SecureClientHelpers.h"
#if MQTT_LIBRARY == MQTT_LIBRARY_ASYNCMQTTCLIENT
#include <ESPAsyncTCP.h>
#include <AsyncMqttClient.h>
#elif MQTT_LIBRARY == MQTT_LIBRARY_ARDUINOMQTT
#include <MQTTClient.h>
#elif MQTT_LIBRARY == MQTT_LIBRARY_PUBSUBCLIENT
#include <PubSubClient.h>
#endif
// -----------------------------------------------------------------------------
#if MQTT_LIBRARY == MQTT_LIBRARY_ASYNCMQTTCLIENT #if MQTT_LIBRARY == MQTT_LIBRARY_ASYNCMQTTCLIENT
AsyncMqttClient _mqtt; AsyncMqttClient _mqtt;


+ 0
- 9
code/espurna/mqtt.h View File

@ -21,15 +21,6 @@ using mqtt_msg_t = std::pair<String, String>; // topic, payload
#if MQTT_SUPPORT #if MQTT_SUPPORT
#if MQTT_LIBRARY == MQTT_LIBRARY_ASYNCMQTTCLIENT
#include <ESPAsyncTCP.h>
#include <AsyncMqttClient.h>
#elif MQTT_LIBRARY == MQTT_LIBRARY_ARDUINOMQTT
#include <MQTTClient.h>
#elif MQTT_LIBRARY == MQTT_LIBRARY_PUBSUBCLIENT
#include <PubSubClient.h>
#endif
void mqttRegister(mqtt_callback_f callback); void mqttRegister(mqtt_callback_f callback);
String mqttTopic(const char * magnitude, bool is_set); String mqttTopic(const char * magnitude, bool is_set);


+ 0
- 4
code/espurna/ota.h View File

@ -8,9 +8,6 @@ OTA MODULE
#include "espurna.h" #include "espurna.h"
#include <ArduinoOTA.h>
#include <Updater.h>
#if OTA_WEB_SUPPORT #if OTA_WEB_SUPPORT
void otaWebSetup(); void otaWebSetup();
@ -25,7 +22,6 @@ void arduinoOtaSetup();
#if OTA_CLIENT == OTA_CLIENT_ASYNCTCP #if OTA_CLIENT == OTA_CLIENT_ASYNCTCP
#include <ESPAsyncTCP.h>
void otaClientSetup(); void otaClientSetup();
#endif // OTA_CLIENT == OTA_CLIENT_ASYNCTCP #endif // OTA_CLIENT == OTA_CLIENT_ASYNCTCP


+ 2
- 0
code/espurna/ota_arduinoota.cpp View File

@ -13,6 +13,8 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include "system.h" #include "system.h"
#include "ws.h" #include "ws.h"
#include <ArduinoOTA.h>
// TODO: allocate ArduinoOTAClass on-demand, stop using global instance // TODO: allocate ArduinoOTAClass on-demand, stop using global instance
void _arduinoOtaConfigure() { void _arduinoOtaConfigure() {


+ 4
- 1
code/espurna/ota_asynctcp.cpp View File

@ -20,7 +20,6 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#if TERMINAL_SUPPORT || OTA_MQTT_SUPPORT #if TERMINAL_SUPPORT || OTA_MQTT_SUPPORT
#include <Schedule.h> #include <Schedule.h>
#include <ESPAsyncTCP.h>
#include "mqtt.h" #include "mqtt.h"
#include "system.h" #include "system.h"
@ -29,6 +28,10 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include "libs/URL.h" #include "libs/URL.h"
#include <Updater.h>
#include <ESPAsyncTCP.h>
const char OTA_REQUEST_TEMPLATE[] PROGMEM = const char OTA_REQUEST_TEMPLATE[] PROGMEM =
"GET %s HTTP/1.1\r\n" "GET %s HTTP/1.1\r\n"
"Host: %s\r\n" "Host: %s\r\n"


+ 50
- 0
code/espurna/telnet.cpp View File

@ -25,6 +25,56 @@ Updated to use WiFiServer and support reverse connections by Niek van der Maas <
#include "board.h" #include "board.h"
#include "ws.h" #include "ws.h"
#if TELNET_SERVER == TELNET_SERVER_ASYNC
#include <ESPAsyncTCP.h>
struct AsyncBufferedClient {
public:
constexpr static const size_t BUFFERS_MAX = 5;
using buffer_t = std::vector<uint8_t>;
AsyncBufferedClient(AsyncClient* client);
size_t write(char c);
size_t write(const char* data, size_t size=0);
void flush();
size_t available();
bool connect(const char *host, uint16_t port);
void close(bool now = false);
bool connected();
private:
void _addBuffer();
static void _trySend(AsyncBufferedClient* client);
static void _s_onAck(void* client_ptr, AsyncClient*, size_t, uint32_t);
static void _s_onPoll(void* client_ptr, AsyncClient* client);
std::unique_ptr<AsyncClient> _client;
std::list<buffer_t> _buffers;
};
using TTelnetServer = AsyncServer;
#if TELNET_SERVER_ASYNC_BUFFERED
using TTelnetClient = AsyncBufferedClient;
#else
using TTelnetClient = AsyncClient;
#endif // TELNET_SERVER_ASYNC_BUFFERED
#elif TELNET_SERVER == TELNET_SERVER_WIFISERVER
using TTelnetServer = WiFiServer;
using TTelnetClient = WiFiClient;
#else
#error "TELNET_SERVER value was not properly set"
#endif
TTelnetServer _telnetServer(TELNET_PORT); TTelnetServer _telnetServer(TELNET_PORT);
std::unique_ptr<TTelnetClient> _telnetClients[TELNET_MAX_CLIENTS]; std::unique_ptr<TTelnetClient> _telnetClients[TELNET_MAX_CLIENTS];


+ 0
- 49
code/espurna/telnet.h View File

@ -16,55 +16,6 @@ Copyright (C) 2017-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include <memory> #include <memory>
#include <list> #include <list>
#if TELNET_SERVER == TELNET_SERVER_ASYNC
#include <ESPAsyncTCP.h>
struct AsyncBufferedClient {
public:
constexpr static const size_t BUFFERS_MAX = 5;
using buffer_t = std::vector<uint8_t>;
AsyncBufferedClient(AsyncClient* client);
size_t write(char c);
size_t write(const char* data, size_t size=0);
void flush();
size_t available();
bool connect(const char *host, uint16_t port);
void close(bool now = false);
bool connected();
private:
void _addBuffer();
static void _trySend(AsyncBufferedClient* client);
static void _s_onAck(void* client_ptr, AsyncClient*, size_t, uint32_t);
static void _s_onPoll(void* client_ptr, AsyncClient* client);
std::unique_ptr<AsyncClient> _client;
std::list<buffer_t> _buffers;
};
using TTelnetServer = AsyncServer;
#if TELNET_SERVER_ASYNC_BUFFERED
using TTelnetClient = AsyncBufferedClient;
#else
using TTelnetClient = AsyncClient;
#endif // TELNET_SERVER_ASYNC_BUFFERED
#elif TELNET_SERVER == TELNET_SERVER_WIFISERVER
using TTelnetServer = WiFiServer;
using TTelnetClient = WiFiClient;
#else
#error "TELNET_SERVER value was not properly set"
#endif
constexpr unsigned char TELNET_IAC = 0xFF; constexpr unsigned char TELNET_IAC = 0xFF;
constexpr unsigned char TELNET_XEOF = 0xEC; constexpr unsigned char TELNET_XEOF = 0xEC;


+ 9
- 2
code/espurna/web.cpp View File

@ -14,12 +14,19 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <Schedule.h>
#include "system.h" #include "system.h"
#include "utils.h" #include "utils.h"
#include "ntp.h" #include "ntp.h"
#include <Schedule.h>
#include <Print.h>
#include <Hash.h>
#include <FS.h>
#include <ArduinoJson.h>
#include <ESPAsyncWebServer.h>
#include <AsyncJson.h>
#if WEB_EMBEDDED #if WEB_EMBEDDED
#if WEBUI_IMAGE == WEBUI_IMAGE_SMALL #if WEBUI_IMAGE == WEBUI_IMAGE_SMALL


+ 0
- 6
code/espurna/web.h View File

@ -16,13 +16,7 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include <list> #include <list>
#include <vector> #include <vector>
#include <Print.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h> #include <ESPAsyncWebServer.h>
#include <Hash.h>
#include <FS.h>
#include <AsyncJson.h>
#include <ArduinoJson.h>
struct AsyncWebPrintConfig { struct AsyncWebPrintConfig {
const char* const mimeType; const char* const mimeType;


Loading…
Cancel
Save