Browse Source

system: move prototypes to a separate header

master
Maxim Prokhorov 4 years ago
parent
commit
03e6443ac6
13 changed files with 49 additions and 10 deletions
  1. +2
    -0
      code/espurna/api.ino
  2. +1
    -0
      code/espurna/button.ino
  3. +0
    -4
      code/espurna/config/prototypes.h
  4. +7
    -4
      code/espurna/espurna.ino
  5. +1
    -0
      code/espurna/mqtt.ino
  6. +2
    -0
      code/espurna/ota_arduinoota.ino
  7. +2
    -0
      code/espurna/ota_asynctcp.ino
  8. +1
    -0
      code/espurna/ota_httpupdate.ino
  9. +25
    -0
      code/espurna/system.h
  10. +4
    -2
      code/espurna/system.ino
  11. +1
    -0
      code/espurna/terminal.ino
  12. +1
    -0
      code/espurna/web.ino
  13. +2
    -0
      code/espurna/ws.ino

+ 2
- 0
code/espurna/api.ino View File

@ -13,6 +13,8 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <vector> #include <vector>
#include "system.h"
typedef struct { typedef struct {
char * key; char * key;
api_get_callback_f getFn = NULL; api_get_callback_f getFn = NULL;


+ 1
- 0
code/espurna/button.ino View File

@ -15,6 +15,7 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include <DebounceEvent.h> #include <DebounceEvent.h>
#include <vector> #include <vector>
#include "system.h"
#include "relay.h" #include "relay.h"
#include "light.h" #include "light.h"


+ 0
- 4
code/espurna/config/prototypes.h View File

@ -38,10 +38,6 @@ extern "C" {
#define TCP_MSS (1460) #define TCP_MSS (1460)
#endif #endif
uint32_t systemResetReason();
uint8_t systemStabilityCounter();
void systemStabilityCounter(uint8_t);
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// PROGMEM // PROGMEM
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------


+ 7
- 4
code/espurna/espurna.ino View File

@ -22,14 +22,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "config/all.h" #include "config/all.h"
#include <vector> #include <vector>
#include "system.h"
#include "utils.h" #include "utils.h"
#include "relay.h" #include "relay.h"
#include "broker.h" #include "broker.h"
#include "tuya.h" #include "tuya.h"
#include "libs/HeapStats.h" #include "libs/HeapStats.h"
std::vector<void (*)()> _loop_callbacks;
std::vector<void (*)()> _reload_callbacks;
using void_callback_f = void (*)();
std::vector<void_callback_f> _loop_callbacks;
std::vector<void_callback_f> _reload_callbacks;
bool _reload_config = false; bool _reload_config = false;
unsigned long _loop_delay = 0; unsigned long _loop_delay = 0;
@ -38,11 +41,11 @@ unsigned long _loop_delay = 0;
// GENERAL CALLBACKS // GENERAL CALLBACKS
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void espurnaRegisterLoop(void (*callback)()) {
void espurnaRegisterLoop(void_callback_f callback) {
_loop_callbacks.push_back(callback); _loop_callbacks.push_back(callback);
} }
void espurnaRegisterReload(void (*callback)()) {
void espurnaRegisterReload(void_callback_f callback) {
_reload_callbacks.push_back(callback); _reload_callbacks.push_back(callback);
} }


+ 1
- 0
code/espurna/mqtt.ino View File

@ -18,6 +18,7 @@ Updated secure client support by Niek van der Maas < mail at niekvandermaas dot
#include <Ticker.h> #include <Ticker.h>
#include <TimeLib.h> #include <TimeLib.h>
#include "system.h"
#include "libs/SecureClientHelpers.h" #include "libs/SecureClientHelpers.h"
#if MQTT_LIBRARY == MQTT_LIBRARY_ASYNCMQTTCLIENT #if MQTT_LIBRARY == MQTT_LIBRARY_ASYNCMQTTCLIENT


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

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


+ 2
- 0
code/espurna/ota_asynctcp.ino View File

@ -15,6 +15,8 @@ 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 <ESPAsyncTCP.h> #include <ESPAsyncTCP.h>
#include "system.h"
#include "libs/URL.h" #include "libs/URL.h"
std::unique_ptr<AsyncClient> _ota_client = nullptr; std::unique_ptr<AsyncClient> _ota_client = nullptr;


+ 1
- 0
code/espurna/ota_httpupdate.ino View File

@ -18,6 +18,7 @@ Copyright (C) 2019 by Maxim Prokhorov <prokhorov dot max at outlook dot com>
#include <ESP8266httpUpdate.h> #include <ESP8266httpUpdate.h>
#include <Schedule.h> #include <Schedule.h>
#include "system.h"
#include "libs/URL.h" #include "libs/URL.h"
#include "libs/TypeChecks.h" #include "libs/TypeChecks.h"
#include "libs/SecureClientHelpers.h" #include "libs/SecureClientHelpers.h"


+ 25
- 0
code/espurna/system.h View File

@ -0,0 +1,25 @@
/*
SYSTEM MODULE
Copyright (C) 2019 by Xose Pérez <xose dot perez at gmail dot com>
*/
#pragma once
#include <cstdint>
uint32_t systemResetReason();
uint8_t systemStabilityCounter();
void systemStabilityCounter(uint8_t count);
void systemCheck(bool stable);
bool systemCheck();
uint32_t systemResetReason();
unsigned char customResetReason();
void customResetReason(unsigned char reason);
void deferredReset(unsigned long delay, unsigned char reason);
bool checkNeedsReset();

+ 4
- 2
code/espurna/system.ino View File

@ -9,6 +9,8 @@ Copyright (C) 2019 by Xose Pérez <xose dot perez at gmail dot com>
#include <Ticker.h> #include <Ticker.h>
#include <EEPROM_Rotate.h> #include <EEPROM_Rotate.h>
#include "system.h"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
bool _system_send_heartbeat = false; bool _system_send_heartbeat = false;
@ -35,10 +37,10 @@ uint8_t systemStabilityCounter() {
return data.parts.stability_counter; return data.parts.stability_counter;
} }
void systemStabilityCounter(uint8_t counter) {
void systemStabilityCounter(uint8_t count) {
system_rtcmem_t data; system_rtcmem_t data;
data.value = Rtcmem->sys; data.value = Rtcmem->sys;
data.parts.stability_counter = counter;
data.parts.stability_counter = count;
Rtcmem->sys = data.value; Rtcmem->sys = data.value;
} }


+ 1
- 0
code/espurna/terminal.ino View File

@ -8,6 +8,7 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#if TERMINAL_SUPPORT #if TERMINAL_SUPPORT
#include "system.h"
#include "utils.h" #include "utils.h"
#include "libs/EmbedisWrap.h" #include "libs/EmbedisWrap.h"
#include "libs/StreamInjector.h" #include "libs/StreamInjector.h"


+ 1
- 0
code/espurna/web.ino View File

@ -8,6 +8,7 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#if WEB_SUPPORT #if WEB_SUPPORT
#include "system.h"
#include "utils.h" #include "utils.h"
#include <ESPAsyncTCP.h> #include <ESPAsyncTCP.h>


+ 2
- 0
code/espurna/ws.ino View File

@ -13,6 +13,8 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include <ArduinoJson.h> #include <ArduinoJson.h>
#include <Ticker.h> #include <Ticker.h>
#include <vector> #include <vector>
#include "system.h"
#include "libs/WebSocketIncommingBuffer.h" #include "libs/WebSocketIncommingBuffer.h"
AsyncWebSocket _ws("/ws"); AsyncWebSocket _ws("/ws");


Loading…
Cancel
Save