mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-27 12:46:34 +00:00
Bump version to v11.1.0.4
- Restructure tasmota
This commit is contained in:
parent
6d58e801f6
commit
c08561f67c
@ -21,6 +21,6 @@
|
|||||||
#define __TASMOTA_INCLUDE__
|
#define __TASMOTA_INCLUDE__
|
||||||
|
|
||||||
#include "../tasmota/my_user_config.h"
|
#include "../tasmota/my_user_config.h"
|
||||||
#include "../tasmota/tasmota_configurations.h"
|
#include "../tasmota/include/tasmota_configurations.h"
|
||||||
|
|
||||||
#endif // __TASMOTA_INCLUDE__
|
#endif // __TASMOTA_INCLUDE__
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
#ifdef COMPILE_BERRY_LIB
|
#ifdef COMPILE_BERRY_LIB
|
||||||
#include "my_user_config.h"
|
#include "my_user_config.h"
|
||||||
#include "tasmota_configurations.h"
|
#include "include/tasmota_configurations.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Macro: BE_DEBUG
|
/* Macro: BE_DEBUG
|
||||||
|
@ -6,7 +6,7 @@ Import("env")
|
|||||||
def FindInoNodes(env):
|
def FindInoNodes(env):
|
||||||
src_dir = glob.escape(env.subst("$PROJECT_SRC_DIR"))
|
src_dir = glob.escape(env.subst("$PROJECT_SRC_DIR"))
|
||||||
return env.Glob(os.path.join(src_dir, "*.ino")) + env.Glob(
|
return env.Glob(os.path.join(src_dir, "*.ino")) + env.Glob(
|
||||||
os.path.join(src_dir, "ino_*", "*.ino")
|
os.path.join(src_dir, "tasmota_*", "*.ino")
|
||||||
)
|
)
|
||||||
|
|
||||||
env.AddMethod(FindInoNodes)
|
env.AddMethod(FindInoNodes)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Configuration
|
// Configuration
|
||||||
|
|
||||||
#include "my_user_config.h"
|
#include "my_user_config.h"
|
||||||
#include "tasmota_configurations.h"
|
#include "include/tasmota_configurations.h"
|
||||||
|
@ -37,15 +37,15 @@ Be sure to generate both files: local_ca_data.h, and local_ca_descriptor.h
|
|||||||
//
|
//
|
||||||
// this is what the result will look like, except there will be
|
// this is what the result will look like, except there will be
|
||||||
// a lot of data bytes defined in the first three arrays
|
// a lot of data bytes defined in the first three arrays
|
||||||
//
|
//
|
||||||
static const unsigned char PROGMEM TA0_DN[] = {
|
static const unsigned char PROGMEM TA0_DN[] = {
|
||||||
// variable number of bytes go here (typically 100-140 or so) for the DN
|
// variable number of bytes go here (typically 100-140 or so) for the DN
|
||||||
};
|
};
|
||||||
|
|
||||||
static const unsigned char PROGMEM TA0_RSA_N[] = {
|
static const unsigned char PROGMEM TA0_RSA_N[] = {
|
||||||
// 256 bytes go here for the public key modulus
|
// 256 bytes go here for the public key modulus
|
||||||
};
|
};
|
||||||
|
|
||||||
static const unsigned char PROGMEM TA0_RSA_E[] = {
|
static const unsigned char PROGMEM TA0_RSA_E[] = {
|
||||||
// 3 bytes go here for the public key exponent
|
// 3 bytes go here for the public key exponent
|
||||||
};
|
};
|
@ -37,14 +37,14 @@ Be sure to generate both files: local_ca_data.h, and local_ca_descriptor.h
|
|||||||
//
|
//
|
||||||
// this is what the result will look like
|
// this is what the result will look like
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
{ (unsigned char *)TA0_DN, sizeof TA0_DN },
|
{ (unsigned char *)TA0_DN, sizeof TA0_DN },
|
||||||
BR_X509_TA_CA,
|
BR_X509_TA_CA,
|
||||||
{
|
{
|
||||||
BR_KEYTYPE_RSA,
|
BR_KEYTYPE_RSA,
|
||||||
{ .rsa = {
|
{ .rsa = {
|
||||||
(unsigned char *)TA0_RSA_N, sizeof TA0_RSA_N,
|
(unsigned char *)TA0_RSA_N, sizeof TA0_RSA_N,
|
||||||
(unsigned char *)TA0_RSA_E, sizeof TA0_RSA_E,
|
(unsigned char *)TA0_RSA_E, sizeof TA0_RSA_E,
|
||||||
} }
|
} }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -63,7 +63,7 @@ String EthernetMacAddress(void);
|
|||||||
* Preconfigured configurations
|
* Preconfigured configurations
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
#include "tasmota_configurations.h" // Preconfigured configurations
|
#include "include/tasmota_configurations.h" // Preconfigured configurations
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* ESP8266 specific parameters
|
* ESP8266 specific parameters
|
@ -1239,7 +1239,7 @@ typedef struct MYTMPLT {
|
|||||||
//********************************************************************************************
|
//********************************************************************************************
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#include "tasmota_template_legacy.h"
|
#include "include/tasmota_template_legacy.h"
|
||||||
|
|
||||||
/********************************************************************************************\
|
/********************************************************************************************\
|
||||||
* ESP8266 Module Templates
|
* ESP8266 Module Templates
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
settings.h - setting variables for Tasmota
|
tasmota_types.h - setting variables for Tasmota
|
||||||
|
|
||||||
Copyright (C) 2021 Theo Arends
|
Copyright (C) 2021 Theo Arends
|
||||||
|
|
||||||
@ -17,10 +17,8 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SETTINGS_H_
|
#ifndef _TASMOTA_TYPES_H_
|
||||||
#define _SETTINGS_H_
|
#define _TASMOTA_TYPES_H_
|
||||||
|
|
||||||
const uint8_t PARAM8_SIZE = 18; // Number of param bytes (SetOption)
|
|
||||||
|
|
||||||
// Bitfield to be used for any SetOption0 .. SetOption31 persistent single bit
|
// Bitfield to be used for any SetOption0 .. SetOption31 persistent single bit
|
||||||
typedef union { // Restricted by MISRA-C Rule 18.4 but so useful...
|
typedef union { // Restricted by MISRA-C Rule 18.4 but so useful...
|
||||||
@ -490,6 +488,7 @@ typedef union {
|
|||||||
|
|
||||||
const uint32_t settings_text_size = 699; // Settings->text_pool[size] = Settings->display_model (2D2) - Settings->text_pool (017)
|
const uint32_t settings_text_size = 699; // Settings->text_pool[size] = Settings->display_model (2D2) - Settings->text_pool (017)
|
||||||
const uint8_t MAX_TUYA_FUNCTIONS = 16;
|
const uint8_t MAX_TUYA_FUNCTIONS = 16;
|
||||||
|
const uint8_t PARAM8_SIZE = 18; // Number of param bytes (SetOption)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16_t cfg_holder; // 000 v6 header
|
uint16_t cfg_holder; // 000 v6 header
|
||||||
@ -867,70 +866,6 @@ typedef struct {
|
|||||||
|
|
||||||
static_assert(sizeof(TSettings) == 4096, "TSettings Size is not correct");
|
static_assert(sizeof(TSettings) == 4096, "TSettings Size is not correct");
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint16_t valid; // 280 (RTC memory offset 100 - sizeof(RTCRBT))
|
|
||||||
uint8_t fast_reboot_count; // 282
|
|
||||||
uint8_t free_003[1]; // 283
|
|
||||||
} TRtcReboot;
|
|
||||||
TRtcReboot RtcReboot;
|
|
||||||
#ifdef ESP32
|
|
||||||
RTC_NOINIT_ATTR TRtcReboot RtcDataReboot;
|
|
||||||
#endif // ESP32
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint16_t valid; // 290 (RTC memory offset 100)
|
|
||||||
uint8_t oswatch_blocked_loop; // 292
|
|
||||||
uint8_t ota_loader; // 293
|
|
||||||
uint32_t energy_kWhtoday; // 294
|
|
||||||
uint32_t energy_kWhtotal; // 298
|
|
||||||
volatile uint32_t pulse_counter[MAX_COUNTERS]; // 29C - See #9521 why volatile
|
|
||||||
power_t power; // 2AC
|
|
||||||
EnergyUsage energy_usage; // 2B0
|
|
||||||
uint32_t nextwakeup; // 2C8
|
|
||||||
uint32_t baudrate; // 2CC
|
|
||||||
uint32_t ultradeepsleep; // 2D0
|
|
||||||
uint16_t deepsleep_slip; // 2D4
|
|
||||||
uint8_t improv_state; // 2D6
|
|
||||||
|
|
||||||
uint8_t free_2d7[1]; // 2D7
|
|
||||||
|
|
||||||
int32_t energy_kWhtoday_ph[3]; // 2D8
|
|
||||||
int32_t energy_kWhtotal_ph[3]; // 2E4
|
|
||||||
int32_t energy_kWhexport_ph[3]; // 2F0
|
|
||||||
|
|
||||||
uint8_t free_2fc[4]; // 2FC
|
|
||||||
} TRtcSettings;
|
|
||||||
TRtcSettings RtcSettings;
|
|
||||||
#ifdef ESP32
|
|
||||||
RTC_NOINIT_ATTR TRtcSettings RtcDataSettings;
|
|
||||||
#endif // ESP32
|
|
||||||
|
|
||||||
struct TIME_T {
|
|
||||||
uint8_t second;
|
|
||||||
uint8_t minute;
|
|
||||||
uint8_t hour;
|
|
||||||
uint8_t day_of_week; // sunday is day 1
|
|
||||||
uint8_t day_of_month;
|
|
||||||
uint8_t month;
|
|
||||||
char name_of_month[4];
|
|
||||||
uint16_t day_of_year;
|
|
||||||
uint16_t year;
|
|
||||||
uint32_t days;
|
|
||||||
uint32_t valid;
|
|
||||||
} RtcTime;
|
|
||||||
|
|
||||||
struct XDRVMAILBOX {
|
|
||||||
bool grpflg;
|
|
||||||
bool usridx;
|
|
||||||
uint16_t command_code;
|
|
||||||
uint32_t index;
|
|
||||||
uint32_t data_len;
|
|
||||||
int32_t payload;
|
|
||||||
char *topic;
|
|
||||||
char *data;
|
|
||||||
char *command;
|
|
||||||
} XdrvMailbox;
|
|
||||||
|
|
||||||
typedef union { // Restricted by MISRA-C Rule 18.4 but so useful...
|
typedef union { // Restricted by MISRA-C Rule 18.4 but so useful...
|
||||||
uint16_t data; // Allow bit manipulation
|
uint16_t data; // Allow bit manipulation
|
||||||
struct {
|
struct {
|
||||||
@ -974,4 +909,4 @@ typedef union {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // _SETTINGS_H_
|
#endif // _TASMOTA_TYPES_H_
|
@ -20,6 +20,6 @@
|
|||||||
#ifndef _TASMOTA_VERSION_H_
|
#ifndef _TASMOTA_VERSION_H_
|
||||||
#define _TASMOTA_VERSION_H_
|
#define _TASMOTA_VERSION_H_
|
||||||
|
|
||||||
const uint32_t VERSION = 0x0B010003; // 11.1.0.3
|
const uint32_t VERSION = 0x0B010004; // 11.1.0.4
|
||||||
|
|
||||||
#endif // _TASMOTA_VERSION_H_
|
#endif // _TASMOTA_VERSION_H_
|
@ -21,16 +21,16 @@
|
|||||||
#ifndef ESP32_STAGE // ESP32 Stage has no core_version.h file. Disable include via PlatformIO Option
|
#ifndef ESP32_STAGE // ESP32 Stage has no core_version.h file. Disable include via PlatformIO Option
|
||||||
#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_7_1)
|
#include <core_version.h> // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_7_1)
|
||||||
#endif // ESP32_STAGE
|
#endif // ESP32_STAGE
|
||||||
#include "tasmota_compat.h"
|
#include "include/tasmota_compat.h"
|
||||||
#include "tasmota_version.h" // Tasmota version information
|
#include "include/tasmota_version.h" // Tasmota version information
|
||||||
#include "tasmota.h" // Enumeration used in my_user_config.h
|
#include "include/tasmota.h" // Enumeration used in my_user_config.h
|
||||||
#include "my_user_config.h" // Fixed user configurable options
|
#include "my_user_config.h" // Fixed user configurable options
|
||||||
#ifdef USE_TLS
|
#ifdef USE_TLS
|
||||||
#include <t_bearssl.h> // We need to include before "tasmota_globals.h" to take precedence over the BearSSL version in Arduino
|
#include <t_bearssl.h> // We need to include before "tasmota_globals.h" to take precedence over the BearSSL version in Arduino
|
||||||
#endif // USE_TLS
|
#endif // USE_TLS
|
||||||
#include "tasmota_globals.h" // Function prototypes and global configuration
|
#include "include/tasmota_globals.h" // Function prototypes and global configuration
|
||||||
#include "i18n.h" // Language support configured by my_user_config.h
|
#include "include/i18n.h" // Language support configured by my_user_config.h
|
||||||
#include "tasmota_template.h" // Hardware configuration
|
#include "include/tasmota_template.h" // Hardware configuration
|
||||||
|
|
||||||
// Libraries
|
// Libraries
|
||||||
#include <ESP8266HTTPClient.h> // Ota
|
#include <ESP8266HTTPClient.h> // Ota
|
||||||
@ -83,7 +83,7 @@
|
|||||||
#endif // USE_UFILESYS
|
#endif // USE_UFILESYS
|
||||||
|
|
||||||
// Structs
|
// Structs
|
||||||
#include "settings.h"
|
#include "include/tasmota_types.h"
|
||||||
|
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||||
#include "soc/efuse_reg.h"
|
#include "soc/efuse_reg.h"
|
||||||
@ -95,6 +95,70 @@
|
|||||||
|
|
||||||
const uint32_t VERSION_MARKER[] PROGMEM = { 0x5AA55AA5, 0xFFFFFFFF, 0xA55AA55A };
|
const uint32_t VERSION_MARKER[] PROGMEM = { 0x5AA55AA5, 0xFFFFFFFF, 0xA55AA55A };
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t valid; // 280 (RTC memory offset 100 - sizeof(RTCRBT))
|
||||||
|
uint8_t fast_reboot_count; // 282
|
||||||
|
uint8_t free_003[1]; // 283
|
||||||
|
} TRtcReboot;
|
||||||
|
TRtcReboot RtcReboot;
|
||||||
|
#ifdef ESP32
|
||||||
|
RTC_NOINIT_ATTR TRtcReboot RtcDataReboot;
|
||||||
|
#endif // ESP32
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint16_t valid; // 290 (RTC memory offset 100)
|
||||||
|
uint8_t oswatch_blocked_loop; // 292
|
||||||
|
uint8_t ota_loader; // 293
|
||||||
|
uint32_t energy_kWhtoday; // 294
|
||||||
|
uint32_t energy_kWhtotal; // 298
|
||||||
|
volatile uint32_t pulse_counter[MAX_COUNTERS]; // 29C - See #9521 why volatile
|
||||||
|
power_t power; // 2AC
|
||||||
|
EnergyUsage energy_usage; // 2B0
|
||||||
|
uint32_t nextwakeup; // 2C8
|
||||||
|
uint32_t baudrate; // 2CC
|
||||||
|
uint32_t ultradeepsleep; // 2D0
|
||||||
|
uint16_t deepsleep_slip; // 2D4
|
||||||
|
uint8_t improv_state; // 2D6
|
||||||
|
|
||||||
|
uint8_t free_2d7[1]; // 2D7
|
||||||
|
|
||||||
|
int32_t energy_kWhtoday_ph[3]; // 2D8
|
||||||
|
int32_t energy_kWhtotal_ph[3]; // 2E4
|
||||||
|
int32_t energy_kWhexport_ph[3]; // 2F0
|
||||||
|
|
||||||
|
uint8_t free_2fc[4]; // 2FC
|
||||||
|
} TRtcSettings;
|
||||||
|
TRtcSettings RtcSettings;
|
||||||
|
#ifdef ESP32
|
||||||
|
RTC_NOINIT_ATTR TRtcSettings RtcDataSettings;
|
||||||
|
#endif // ESP32
|
||||||
|
|
||||||
|
struct TIME_T {
|
||||||
|
uint8_t second;
|
||||||
|
uint8_t minute;
|
||||||
|
uint8_t hour;
|
||||||
|
uint8_t day_of_week; // sunday is day 1
|
||||||
|
uint8_t day_of_month;
|
||||||
|
uint8_t month;
|
||||||
|
char name_of_month[4];
|
||||||
|
uint16_t day_of_year;
|
||||||
|
uint16_t year;
|
||||||
|
uint32_t days;
|
||||||
|
uint32_t valid;
|
||||||
|
} RtcTime;
|
||||||
|
|
||||||
|
struct XDRVMAILBOX {
|
||||||
|
bool grpflg;
|
||||||
|
bool usridx;
|
||||||
|
uint16_t command_code;
|
||||||
|
uint32_t index;
|
||||||
|
uint32_t data_len;
|
||||||
|
int32_t payload;
|
||||||
|
char *topic;
|
||||||
|
char *data;
|
||||||
|
char *command;
|
||||||
|
} XdrvMailbox;
|
||||||
|
|
||||||
WiFiUDP PortUdp; // UDP Syslog and Alexa
|
WiFiUDP PortUdp; // UDP Syslog and Alexa
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
|
0
tasmota/homekit.c → tasmota/tasmota_support/homekit.c
Executable file → Normal file
0
tasmota/homekit.c → tasmota/tasmota_support/homekit.c
Executable file → Normal file
@ -1,6 +1,6 @@
|
|||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#ifdef USE_SENDMAIL
|
#ifdef USE_SENDMAIL
|
||||||
#include "sendemail_ESP8266.h"
|
#include "include/sendemail_ESP8266.h"
|
||||||
|
|
||||||
// enable serial debugging
|
// enable serial debugging
|
||||||
//#define DEBUG_EMAIL_PORT
|
//#define DEBUG_EMAIL_PORT
|
@ -1,430 +1,430 @@
|
|||||||
/*
|
/*
|
||||||
support_flash_log.ino - log to flash support for Sonoff-Tasmota
|
support_flash_log.ino - log to flash support for Sonoff-Tasmota
|
||||||
|
|
||||||
Copyright (C) 2021 Theo Arends & Christian Baars
|
Copyright (C) 2021 Theo Arends & Christian Baars
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
(at your option) any later version.
|
(at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
GNU General Public License for more details.
|
GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
--------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------
|
||||||
Version Date Action Description
|
Version Date Action Description
|
||||||
--------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
1.0.0.0 20190923 started - further development by Christian Baars - https://github.com/Staars/Sonoff-Tasmota
|
1.0.0.0 20190923 started - further development by Christian Baars - https://github.com/Staars/Sonoff-Tasmota
|
||||||
forked - from arendst/tasmota - https://github.com/arendst/Sonoff-Tasmota
|
forked - from arendst/tasmota - https://github.com/arendst/Sonoff-Tasmota
|
||||||
base - code base from arendst and - written from scratch
|
base - code base from arendst and - written from scratch
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/********************************************************************************************\
|
/********************************************************************************************\
|
||||||
| * Generic helper class to log arbitrary data to the OTA-partition
|
| * Generic helper class to log arbitrary data to the OTA-partition
|
||||||
| * Working principle: Add preferrable small chunks of data to the sector buffer, which will
|
| * Working principle: Add preferrable small chunks of data to the sector buffer, which will
|
||||||
| * be written to FLASH when full automatically. The next sector will be
|
| * be written to FLASH when full automatically. The next sector will be
|
||||||
| * erased and is the anchor point for downloading and state configuration
|
| * erased and is the anchor point for downloading and state configuration
|
||||||
| * after reboot.
|
| * after reboot.
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
#ifdef USE_FLOG
|
#ifdef USE_FLOG
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
|
||||||
class FLOG
|
class FLOG
|
||||||
|
|
||||||
#define MAGIC_WORD_FL 0x464c //F, L
|
#define MAGIC_WORD_FL 0x464c //F, L
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
struct header_t{
|
struct header_t{
|
||||||
uint16_t magic_word; // FL
|
uint16_t magic_word; // FL
|
||||||
uint16_t padding; // leave something for the future
|
uint16_t padding; // leave something for the future
|
||||||
uint32_t physical_start_sector:10; //first used sector of the current FLOG
|
uint32_t physical_start_sector:10; //first used sector of the current FLOG
|
||||||
uint32_t number:10; // number of this sector, starting with 0 for the first sector
|
uint32_t number:10; // number of this sector, starting with 0 for the first sector
|
||||||
uint32_t buf_pointer:12; //internal pointer to the next free position in the buffer = first empty byte when reading
|
uint32_t buf_pointer:12; //internal pointer to the next free position in the buffer = first empty byte when reading
|
||||||
}; // should be 4-byte-aligned
|
}; // should be 4-byte-aligned
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _readSector(uint8_t one_sector);
|
void _readSector(uint8_t one_sector);
|
||||||
void _eraseSector(uint8_t one_sector);
|
void _eraseSector(uint8_t one_sector);
|
||||||
void _writeSector(uint8_t one_sector);
|
void _writeSector(uint8_t one_sector);
|
||||||
void _clearBuffer(void);
|
void _clearBuffer(void);
|
||||||
void _searchSaves(void);
|
void _searchSaves(void);
|
||||||
void _findFirstErasedSector(void);
|
void _findFirstErasedSector(void);
|
||||||
void _showBuffer(void);
|
void _showBuffer(void);
|
||||||
void _initBuffer(void);
|
void _initBuffer(void);
|
||||||
void _saveBufferToSector(void);
|
void _saveBufferToSector(void);
|
||||||
header_t _saved_header;
|
header_t _saved_header;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint32_t size; // size of OTA-partition
|
uint32_t size; // size of OTA-partition
|
||||||
uint32_t start; // start position of OTA-partition in bytes
|
uint32_t start; // start position of OTA-partition in bytes
|
||||||
uint32_t end; // end position of OTA-partition in bytes
|
uint32_t end; // end position of OTA-partition in bytes
|
||||||
uint16_t num_sectors; // calculated number of sectors with a size of 4096 bytes
|
uint16_t num_sectors; // calculated number of sectors with a size of 4096 bytes
|
||||||
|
|
||||||
uint16_t first_erased_sector; // this will be our new start
|
uint16_t first_erased_sector; // this will be our new start
|
||||||
uint16_t current_sector; // always point to next sector, where data from the buffer will be written to
|
uint16_t current_sector; // always point to next sector, where data from the buffer will be written to
|
||||||
|
|
||||||
uint16_t bytes_left; // byte per buffer (of sector size 4096 bytes - 8 byte header size)
|
uint16_t bytes_left; // byte per buffer (of sector size 4096 bytes - 8 byte header size)
|
||||||
uint16_t sectors_left; // number of saved sectors for download
|
uint16_t sectors_left; // number of saved sectors for download
|
||||||
|
|
||||||
uint8_t mode = 0; // 0 - write once on all sectors, then stop, 1 - write infinitely through the sectors
|
uint8_t mode = 0; // 0 - write once on all sectors, then stop, 1 - write infinitely through the sectors
|
||||||
bool found_saved_data = false; // possible saved data has been found
|
bool found_saved_data = false; // possible saved data has been found
|
||||||
bool ready = false; // the FLOG is initialized
|
bool ready = false; // the FLOG is initialized
|
||||||
bool running_download = false; // a download operation is running
|
bool running_download = false; // a download operation is running
|
||||||
bool recording = false; // ready for recording
|
bool recording = false; // ready for recording
|
||||||
|
|
||||||
union sector_t{
|
union sector_t{
|
||||||
uint32_t dword_buffer[FLASH_SECTOR_SIZE/4];
|
uint32_t dword_buffer[FLASH_SECTOR_SIZE/4];
|
||||||
uint8_t byte_buffer[FLASH_SECTOR_SIZE];
|
uint8_t byte_buffer[FLASH_SECTOR_SIZE];
|
||||||
header_t header; // should be 4-byte-aligned
|
header_t header; // should be 4-byte-aligned
|
||||||
} sector; // the global buffer of 4096 bytes, used for reading and writing
|
} sector; // the global buffer of 4096 bytes, used for reading and writing
|
||||||
|
|
||||||
void init(void);
|
void init(void);
|
||||||
void addToBuffer(uint8_t src[], uint32_t size);
|
void addToBuffer(uint8_t src[], uint32_t size);
|
||||||
void startRecording(bool append);
|
void startRecording(bool append);
|
||||||
void stopRecording(void);
|
void stopRecording(void);
|
||||||
|
|
||||||
typedef void (*CallbackNoArgs) (); // simple typedef for a callback
|
typedef void (*CallbackNoArgs) (); // simple typedef for a callback
|
||||||
typedef void (*CallbackWithArgs) (uint8_t *_record); // typedef for a callback with one argument
|
typedef void (*CallbackWithArgs) (uint8_t *_record); // typedef for a callback with one argument
|
||||||
|
|
||||||
void startDownload(size_t size, CallbackNoArgs sendHeader, CallbackWithArgs sendRecord, CallbackNoArgs sendFooter);
|
void startDownload(size_t size, CallbackNoArgs sendHeader, CallbackWithArgs sendRecord, CallbackNoArgs sendFooter);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" uint32_t _SPIFFS_start; // we make shure later, that only one of the two is really used ...
|
extern "C" uint32_t _SPIFFS_start; // we make shure later, that only one of the two is really used ...
|
||||||
extern "C" uint32_t _FS_start; // ... depending on core-sdk-version
|
extern "C" uint32_t _FS_start; // ... depending on core-sdk-version
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Will examine the start and end of the OTA-partition. Then the sector size will be computed, saved data should be found and the initial state will be configured.
|
* @brief Will examine the start and end of the OTA-partition. Then the sector size will be computed, saved data should be found and the initial state will be configured.
|
||||||
*/
|
*/
|
||||||
void FLOG::init(void)
|
void FLOG::init(void)
|
||||||
{
|
{
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: init ..."));
|
DEBUG_SENSOR_LOG(PSTR("FLOG: init ..."));
|
||||||
size = ESP.getSketchSize();
|
size = ESP.getSketchSize();
|
||||||
// round one sector up
|
// round one sector up
|
||||||
start = (size + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));
|
start = (size + FLASH_SECTOR_SIZE - 1) & (~(FLASH_SECTOR_SIZE - 1));
|
||||||
end = (uint32_t)&_FS_start - 0x40200000;
|
end = (uint32_t)&_FS_start - 0x40200000;
|
||||||
num_sectors = (end - start)/FLASH_SECTOR_SIZE;
|
num_sectors = (end - start)/FLASH_SECTOR_SIZE;
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: size: 0x%lx, start: 0x%lx, end: 0x%lx, num_sectors(dec): %lu"), size, start, end, num_sectors );
|
DEBUG_SENSOR_LOG(PSTR("FLOG: size: 0x%lx, start: 0x%lx, end: 0x%lx, num_sectors(dec): %lu"), size, start, end, num_sectors );
|
||||||
_findFirstErasedSector();
|
_findFirstErasedSector();
|
||||||
if(first_erased_sector == 0xffff){
|
if(first_erased_sector == 0xffff){
|
||||||
_eraseSector(0);
|
_eraseSector(0);
|
||||||
first_erased_sector = 0; // start with sector 0, could be first run or after crash
|
first_erased_sector = 0; // start with sector 0, could be first run or after crash
|
||||||
}
|
}
|
||||||
_searchSaves();
|
_searchSaves();
|
||||||
_initBuffer();
|
_initBuffer();
|
||||||
ready = true;
|
ready = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************************************\
|
/********************************************************************************************\
|
||||||
| *
|
| *
|
||||||
| * private helper functions
|
| * private helper functions
|
||||||
| *
|
| *
|
||||||
\*********************************************************************************************/
|
\*********************************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read a sector into the global buffer
|
* @brief Read a sector into the global buffer
|
||||||
*
|
*
|
||||||
* @param one_sector as an uint8_t
|
* @param one_sector as an uint8_t
|
||||||
*/
|
*/
|
||||||
void FLOG::_readSector(uint8_t one_sector){
|
void FLOG::_readSector(uint8_t one_sector){
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: read sector number: %u" ), one_sector);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: read sector number: %u" ), one_sector);
|
||||||
ESP.flashRead(start+(one_sector * FLASH_SECTOR_SIZE),(uint32_t *)§or.dword_buffer, FLASH_SECTOR_SIZE);
|
ESP.flashRead(start+(one_sector * FLASH_SECTOR_SIZE),(uint32_t *)§or.dword_buffer, FLASH_SECTOR_SIZE);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Erase the given sector og the OTA-partition
|
* @brief Erase the given sector og the OTA-partition
|
||||||
*
|
*
|
||||||
* @param one_sector as an uint8_t
|
* @param one_sector as an uint8_t
|
||||||
*/
|
*/
|
||||||
void FLOG::_eraseSector(uint8_t one_sector){ // Erase sector of FLOG/OTA
|
void FLOG::_eraseSector(uint8_t one_sector){ // Erase sector of FLOG/OTA
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: erasing sector number: %u" ), one_sector);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: erasing sector number: %u" ), one_sector);
|
||||||
ESP.flashEraseSector((start/FLASH_SECTOR_SIZE)+one_sector);
|
ESP.flashEraseSector((start/FLASH_SECTOR_SIZE)+one_sector);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Write the global buffer to the given sector
|
* @brief Write the global buffer to the given sector
|
||||||
*
|
*
|
||||||
* @param one_sector as an uint8_t
|
* @param one_sector as an uint8_t
|
||||||
*/
|
*/
|
||||||
void FLOG::_writeSector(uint8_t one_sector){ // Write sector of FLOG/OTA
|
void FLOG::_writeSector(uint8_t one_sector){ // Write sector of FLOG/OTA
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: write buffer to sector number: %u" ), one_sector);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: write buffer to sector number: %u" ), one_sector);
|
||||||
ESP.flashWrite(start+(one_sector * FLASH_SECTOR_SIZE),(uint32_t *)§or.dword_buffer, FLASH_SECTOR_SIZE);
|
ESP.flashWrite(start+(one_sector * FLASH_SECTOR_SIZE),(uint32_t *)§or.dword_buffer, FLASH_SECTOR_SIZE);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Clear the global buffer, but leave the header intact
|
* @brief Clear the global buffer, but leave the header intact
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void FLOG::_clearBuffer(){ //not the header
|
void FLOG::_clearBuffer(){ //not the header
|
||||||
for (uint32_t i = sizeof(sector.header)/4; i<(sizeof(sector.dword_buffer)/4); i++){
|
for (uint32_t i = sizeof(sector.header)/4; i<(sizeof(sector.dword_buffer)/4); i++){
|
||||||
sector.dword_buffer[i] = 0;
|
sector.dword_buffer[i] = 0;
|
||||||
}
|
}
|
||||||
sector.header.buf_pointer = sizeof(sector.header);
|
sector.header.buf_pointer = sizeof(sector.header);
|
||||||
// _showBuffer();
|
// _showBuffer();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Write global buffer to FLASH and set the current sector to the next valid position, maybe to 0
|
* @brief Write global buffer to FLASH and set the current sector to the next valid position, maybe to 0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void FLOG::_saveBufferToSector(){ // save buffer to already erased(!) sector, erase next sector, clear buffer, increment number
|
void FLOG::_saveBufferToSector(){ // save buffer to already erased(!) sector, erase next sector, clear buffer, increment number
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: write buffer to current sector: %u" ),current_sector);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: write buffer to current sector: %u" ),current_sector);
|
||||||
_writeSector(current_sector);
|
_writeSector(current_sector);
|
||||||
if(current_sector == num_sectors){ // 1 MB means ~110 sectors in OTA-partition, if we reach this, start a again
|
if(current_sector == num_sectors){ // 1 MB means ~110 sectors in OTA-partition, if we reach this, start a again
|
||||||
current_sector = 0;
|
current_sector = 0;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
current_sector++;
|
current_sector++;
|
||||||
}
|
}
|
||||||
_eraseSector(current_sector); // we always erase the next sector, to find out were we are after restart
|
_eraseSector(current_sector); // we always erase the next sector, to find out were we are after restart
|
||||||
_clearBuffer();
|
_clearBuffer();
|
||||||
sector.header.number++;
|
sector.header.number++;
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: new sector header number: %u" ),sector.header.number);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: new sector header number: %u" ),sector.header.number);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Typically after restart find the first erased sector as a starting point for further operations
|
* @brief Typically after restart find the first erased sector as a starting point for further operations
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void FLOG::_findFirstErasedSector(){
|
void FLOG::_findFirstErasedSector(){
|
||||||
for (uint32_t i = 0; i<num_sectors; i++){
|
for (uint32_t i = 0; i<num_sectors; i++){
|
||||||
bool success = true;
|
bool success = true;
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: read sector: %u"), i);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: read sector: %u"), i);
|
||||||
_readSector(i);
|
_readSector(i);
|
||||||
for (uint32_t j = 0; j<(sizeof(sector.dword_buffer)/4); j++){
|
for (uint32_t j = 0; j<(sizeof(sector.dword_buffer)/4); j++){
|
||||||
if(sector.dword_buffer[j]!=0xffffffff){
|
if(sector.dword_buffer[j]!=0xffffffff){
|
||||||
// DEBUG_SENSOR_LOG(PSTR("FLOG: buffer_dword: %u"), sector.dword_buffer[j]);
|
// DEBUG_SENSOR_LOG(PSTR("FLOG: buffer_dword: %u"), sector.dword_buffer[j]);
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(success){
|
if(success){
|
||||||
first_erased_sector = i; // save this for the whole next write operation
|
first_erased_sector = i; // save this for the whole next write operation
|
||||||
sector.header.physical_start_sector = i; // save to header for every sector
|
sector.header.physical_start_sector = i; // save to header for every sector
|
||||||
current_sector = i; // this is our actual sector to write to
|
current_sector = i; // this is our actual sector to write to
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: first erased sector: %u, now init ..."), first_erased_sector);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: first erased sector: %u, now init ..."), first_erased_sector);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: no erased sector found"));
|
DEBUG_SENSOR_LOG(PSTR("FLOG: no erased sector found"));
|
||||||
first_erased_sector = 0xffff; // this will not happen unless we have 256 MByte FLASH
|
first_erased_sector = 0xffff; // this will not happen unless we have 256 MByte FLASH
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Look at the sector before the first erased sector to check, if there could be saved data
|
* @brief Look at the sector before the first erased sector to check, if there could be saved data
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void FLOG::_searchSaves(void){
|
void FLOG::_searchSaves(void){
|
||||||
//check if old Data is present
|
//check if old Data is present
|
||||||
found_saved_data = false;
|
found_saved_data = false;
|
||||||
uint32_t s;
|
uint32_t s;
|
||||||
if(first_erased_sector==0){
|
if(first_erased_sector==0){
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: sector 0 was erased before, examine sector: %u"), num_sectors);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: sector 0 was erased before, examine sector: %u"), num_sectors);
|
||||||
s = num_sectors; //count back to the highest possible sector
|
s = num_sectors; //count back to the highest possible sector
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
s = first_erased_sector-1;
|
s = first_erased_sector-1;
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: examine sector: %u"), s);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: examine sector: %u"), s);
|
||||||
}
|
}
|
||||||
_readSector(s); //read the sector before the first erased sector
|
_readSector(s); //read the sector before the first erased sector
|
||||||
if(sector.header.magic_word!=MAGIC_WORD_FL){
|
if(sector.header.magic_word!=MAGIC_WORD_FL){
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: wrong magic number, no saved data found"));
|
DEBUG_SENSOR_LOG(PSTR("FLOG: wrong magic number, no saved data found"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sectors_left = sector.header.number + 1; // this might be wrong, but this less important
|
sectors_left = sector.header.number + 1; // this might be wrong, but this less important
|
||||||
_saved_header = sector.header; // back this up for appending mode
|
_saved_header = sector.header; // back this up for appending mode
|
||||||
s = sector.header.physical_start_sector;
|
s = sector.header.physical_start_sector;
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: will check pysical start sector: %u"), s);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: will check pysical start sector: %u"), s);
|
||||||
_readSector(s); //read the physical_start_sector
|
_readSector(s); //read the physical_start_sector
|
||||||
_showBuffer();
|
_showBuffer();
|
||||||
if(sector.header.magic_word!=MAGIC_WORD_FL){ //F, L
|
if(sector.header.magic_word!=MAGIC_WORD_FL){ //F, L
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: wrong magic number, no saved data found"));
|
DEBUG_SENSOR_LOG(PSTR("FLOG: wrong magic number, no saved data found"));
|
||||||
sectors_left = 0;
|
sectors_left = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(sector.header.number==0){ //physical_start_sector should have number 0
|
if(sector.header.number==0){ //physical_start_sector should have number 0
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: possible saved data found"));
|
DEBUG_SENSOR_LOG(PSTR("FLOG: possible saved data found"));
|
||||||
found_saved_data = true; // TODO: this is only a very rough check and should be completed later
|
found_saved_data = true; // TODO: this is only a very rough check and should be completed later
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: number: %u should be 0"), sector.header.number);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: number: %u should be 0"), sector.header.number);
|
||||||
sectors_left = 0;
|
sectors_left = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief Start with a new buffer to be able to start a write session
|
* @brief Start with a new buffer to be able to start a write session
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void FLOG::_initBuffer(void){
|
void FLOG::_initBuffer(void){
|
||||||
if(!found_saved_data){ // we must re-init this, because the buffer is in an undefined state
|
if(!found_saved_data){ // we must re-init this, because the buffer is in an undefined state
|
||||||
sector.header.physical_start_sector = (uint16_t)first_erased_sector;
|
sector.header.physical_start_sector = (uint16_t)first_erased_sector;
|
||||||
}
|
}
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: init header"));
|
DEBUG_SENSOR_LOG(PSTR("FLOG: init header"));
|
||||||
sector.header.magic_word = MAGIC_WORD_FL; //F, L
|
sector.header.magic_word = MAGIC_WORD_FL; //F, L
|
||||||
sector.header.number = 0;
|
sector.header.number = 0;
|
||||||
sector.header.buf_pointer = (uint16_t)sizeof(sector.header);
|
sector.header.buf_pointer = (uint16_t)sizeof(sector.header);
|
||||||
current_sector = first_erased_sector;
|
current_sector = first_erased_sector;
|
||||||
ready = true;
|
ready = true;
|
||||||
_clearBuffer();
|
_clearBuffer();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief - a pure debug function
|
* @brief - a pure debug function
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void FLOG::_showBuffer(void){
|
void FLOG::_showBuffer(void){
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: Header: %c %c"), sector.byte_buffer[0],sector.byte_buffer[1]);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: Header: %c %c"), sector.byte_buffer[0],sector.byte_buffer[1]);
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: V_Start_sector: %u, sector number: %u, pointer: %u "), sector.header.physical_start_sector, sector.header.number, sector.header.buf_pointer);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: V_Start_sector: %u, sector number: %u, pointer: %u "), sector.header.physical_start_sector, sector.header.number, sector.header.buf_pointer);
|
||||||
uint32_t j = 0;
|
uint32_t j = 0;
|
||||||
for (uint32_t i = sector.header.buf_pointer-16; i<(sizeof(sector.byte_buffer)); i+=8){
|
for (uint32_t i = sector.header.buf_pointer-16; i<(sizeof(sector.byte_buffer)); i+=8){
|
||||||
// DEBUG_SENSOR_LOG(PSTR("FLOG: buffer: %c %c %c %c %c %c %c %c "), sector.byte_buffer[i], sector.byte_buffer[i+1], sector.byte_buffer[i+2], sector.byte_buffer[i+3], sector.byte_buffer[i+4], sector.byte_buffer[i+5], sector.byte_buffer[i+6], sector.byte_buffer[i+7]);
|
// DEBUG_SENSOR_LOG(PSTR("FLOG: buffer: %c %c %c %c %c %c %c %c "), sector.byte_buffer[i], sector.byte_buffer[i+1], sector.byte_buffer[i+2], sector.byte_buffer[i+3], sector.byte_buffer[i+4], sector.byte_buffer[i+5], sector.byte_buffer[i+6], sector.byte_buffer[i+7]);
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: buffer: %u %u %u %u %u %u %u %u "), sector.byte_buffer[i], sector.byte_buffer[i+1], sector.byte_buffer[i+2], sector.byte_buffer[i+3], sector.byte_buffer[i+4], sector.byte_buffer[i+5], sector.byte_buffer[i+6], sector.byte_buffer[i+7]);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: buffer: %u %u %u %u %u %u %u %u "), sector.byte_buffer[i], sector.byte_buffer[i+1], sector.byte_buffer[i+2], sector.byte_buffer[i+3], sector.byte_buffer[i+4], sector.byte_buffer[i+5], sector.byte_buffer[i+6], sector.byte_buffer[i+7]);
|
||||||
j++;
|
j++;
|
||||||
if(j>3){
|
if(j>3){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief pass a data entry/record as uint8_t array with its size
|
* @brief pass a data entry/record as uint8_t array with its size
|
||||||
*
|
*
|
||||||
* @param src uint8_t array
|
* @param src uint8_t array
|
||||||
* @param size uint32_t size of the array
|
* @param size uint32_t size of the array
|
||||||
*/
|
*/
|
||||||
void FLOG::addToBuffer(uint8_t src[], uint32_t size){
|
void FLOG::addToBuffer(uint8_t src[], uint32_t size){
|
||||||
if(mode == 0){
|
if(mode == 0){
|
||||||
if(sector.header.number == num_sectors && !ready){
|
if(sector.header.number == num_sectors && !ready){
|
||||||
return; // we ignore additional calls and are done, TODO: maybe use meaningful return values
|
return; // we ignore additional calls and are done, TODO: maybe use meaningful return values
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((FLASH_SECTOR_SIZE-sector.header.buf_pointer-sizeof(sector.header))>size){
|
if((FLASH_SECTOR_SIZE-sector.header.buf_pointer-sizeof(sector.header))>size){
|
||||||
// DEBUG_SENSOR_LOG(PSTR("FLOG: enough space left in buffer: %u"), FLASH_SECTOR_SIZE - sector.header.buf_pointer - sizeof(sector.header));
|
// DEBUG_SENSOR_LOG(PSTR("FLOG: enough space left in buffer: %u"), FLASH_SECTOR_SIZE - sector.header.buf_pointer - sizeof(sector.header));
|
||||||
// DEBUG_SENSOR_LOG(PSTR("FLOG: current buf_pointer: %u, size of added: %u"), sector.header.buf_pointer, size);
|
// DEBUG_SENSOR_LOG(PSTR("FLOG: current buf_pointer: %u, size of added: %u"), sector.header.buf_pointer, size);
|
||||||
|
|
||||||
memcpy(sector.byte_buffer + sector.header.buf_pointer, src, size);
|
memcpy(sector.byte_buffer + sector.header.buf_pointer, src, size);
|
||||||
sector.header.buf_pointer+=size; // this is the next free spot
|
sector.header.buf_pointer+=size; // this is the next free spot
|
||||||
// DEBUG_SENSOR_LOG(PSTR("FLOG: current buf_pointer: %u"), sector.header.buf_pointer);
|
// DEBUG_SENSOR_LOG(PSTR("FLOG: current buf_pointer: %u"), sector.header.buf_pointer);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: save buffer to flash sector: %u"), current_sector);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: save buffer to flash sector: %u"), current_sector);
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: current buf_pointer: %u"), sector.header.buf_pointer);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: current buf_pointer: %u"), sector.header.buf_pointer);
|
||||||
_saveBufferToSector();
|
_saveBufferToSector();
|
||||||
sectors_left++;
|
sectors_left++;
|
||||||
// but now save the data to the fresh buffer
|
// but now save the data to the fresh buffer
|
||||||
if((FLASH_SECTOR_SIZE-sector.header.buf_pointer-sizeof(sector.header))>size){
|
if((FLASH_SECTOR_SIZE-sector.header.buf_pointer-sizeof(sector.header))>size){
|
||||||
memcpy(sector.byte_buffer + sector.header.buf_pointer, src, size);
|
memcpy(sector.byte_buffer + sector.header.buf_pointer, src, size);
|
||||||
sector.header.buf_pointer+=size; // this is the next free spot
|
sector.header.buf_pointer+=size; // this is the next free spot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief shows that it is ready to accept recording
|
* @brief shows that it is ready to accept recording
|
||||||
*
|
*
|
||||||
* @param append - if true append to current log, else start a new log
|
* @param append - if true append to current log, else start a new log
|
||||||
*/
|
*/
|
||||||
void FLOG::startRecording(bool append){
|
void FLOG::startRecording(bool append){
|
||||||
if(recording){
|
if(recording){
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: already recording"));
|
DEBUG_SENSOR_LOG(PSTR("FLOG: already recording"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
recording = true;
|
recording = true;
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: start recording"));
|
DEBUG_SENSOR_LOG(PSTR("FLOG: start recording"));
|
||||||
_initBuffer();
|
_initBuffer();
|
||||||
if(!found_saved_data) {
|
if(!found_saved_data) {
|
||||||
append = false; // nothing to append to, we silently start a new log
|
append = false; // nothing to append to, we silently start a new log
|
||||||
}
|
}
|
||||||
if(append){
|
if(append){
|
||||||
sector.header.number = _saved_header.number+1; // continue with the next number
|
sector.header.number = _saved_header.number+1; // continue with the next number
|
||||||
sector.header.physical_start_sector = _saved_header.physical_start_sector; // keep the old start sector
|
sector.header.physical_start_sector = _saved_header.physical_start_sector; // keep the old start sector
|
||||||
}
|
}
|
||||||
else{ //new log, old data is lost
|
else{ //new log, old data is lost
|
||||||
sector.header.physical_start_sector = (uint16_t)first_erased_sector;
|
sector.header.physical_start_sector = (uint16_t)first_erased_sector;
|
||||||
found_saved_data = false;
|
found_saved_data = false;
|
||||||
sectors_left = 0;
|
sectors_left = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief stop recording including saving current buffer to FLASH
|
* @brief stop recording including saving current buffer to FLASH
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void FLOG::stopRecording(void){
|
void FLOG::stopRecording(void){
|
||||||
_saveBufferToSector();
|
_saveBufferToSector();
|
||||||
_findFirstErasedSector();
|
_findFirstErasedSector();
|
||||||
_searchSaves();
|
_searchSaves();
|
||||||
_initBuffer();
|
_initBuffer();
|
||||||
recording = false;
|
recording = false;
|
||||||
found_saved_data = true;
|
found_saved_data = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Will start a downloads, needs the correct implementation of 3 callback functions
|
* @brief Will start a downloads, needs the correct implementation of 3 callback functions
|
||||||
*
|
*
|
||||||
* @param size: size of the data entry/record in bytes, i.e. sizeof(myStruct)
|
* @param size: size of the data entry/record in bytes, i.e. sizeof(myStruct)
|
||||||
* @param sendHeader: should implement at least something like:
|
* @param sendHeader: should implement at least something like:
|
||||||
* @example Webserver->setContentLength(CONTENT_LENGTH_UNKNOWN); // This is very likely unknown!!
|
* @example Webserver->setContentLength(CONTENT_LENGTH_UNKNOWN); // This is very likely unknown!!
|
||||||
* Webserver->sendHeader(F("Content-Disposition"), F("attachment; filename=myfile.txt"));
|
* Webserver->sendHeader(F("Content-Disposition"), F("attachment; filename=myfile.txt"));
|
||||||
* @param sendRecord: will receive the memory address as "uint8_t* addr" and should consume the current entry/record
|
* @param sendRecord: will receive the memory address as "uint8_t* addr" and should consume the current entry/record
|
||||||
* @example myStruct_t *entry = (myStruct_t*)addr;
|
* @example myStruct_t *entry = (myStruct_t*)addr;
|
||||||
* Then make useful Strings and send it, i.e.: Webserver->sendContent_P(myString);
|
* Then make useful Strings and send it, i.e.: Webserver->sendContent_P(myString);
|
||||||
* @param sendFooter: finish the download, should implement at least:
|
* @param sendFooter: finish the download, should implement at least:
|
||||||
* @example Webserver->sendContent("");
|
* @example Webserver->sendContent("");
|
||||||
*/
|
*/
|
||||||
void FLOG::startDownload(size_t size, CallbackNoArgs sendHeader, CallbackWithArgs sendRecord, CallbackNoArgs sendFooter){
|
void FLOG::startDownload(size_t size, CallbackNoArgs sendHeader, CallbackWithArgs sendRecord, CallbackNoArgs sendFooter){
|
||||||
|
|
||||||
_readSector(sector.header.physical_start_sector);
|
_readSector(sector.header.physical_start_sector);
|
||||||
uint32_t next_sector = sector.header.physical_start_sector;
|
uint32_t next_sector = sector.header.physical_start_sector;
|
||||||
bytes_left = sector.header.buf_pointer - sizeof(sector.header);
|
bytes_left = sector.header.buf_pointer - sizeof(sector.header);
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: create file for download, will process %u bytes"), bytes_left);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: create file for download, will process %u bytes"), bytes_left);
|
||||||
running_download = true;
|
running_download = true;
|
||||||
// Callback 1: Create the header incl. file name, content length (probably unknown!!) and additional header stuff
|
// Callback 1: Create the header incl. file name, content length (probably unknown!!) and additional header stuff
|
||||||
sendHeader();
|
sendHeader();
|
||||||
|
|
||||||
while(sectors_left){
|
while(sectors_left){
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: next sector: %u"), next_sector);
|
DEBUG_SENSOR_LOG(PSTR("FLOG: next sector: %u"), next_sector);
|
||||||
//initially we have the first sector already loaded, so we do it at the bottom
|
//initially we have the first sector already loaded, so we do it at the bottom
|
||||||
uint32_t k = sizeof(sector.header);
|
uint32_t k = sizeof(sector.header);
|
||||||
while(bytes_left){
|
while(bytes_left){
|
||||||
// DEBUG_SENSOR_LOG(PSTR("FLOG: DL %u %u"), Flog->sector.byte_buffer[k],Flog->sector.byte_buffer[k+1]);
|
// DEBUG_SENSOR_LOG(PSTR("FLOG: DL %u %u"), Flog->sector.byte_buffer[k],Flog->sector.byte_buffer[k+1]);
|
||||||
uint8_t *_record_start = (uint8_t*)§or.byte_buffer[k]; // this is basically the start address of the current record/entry of the Log
|
uint8_t *_record_start = (uint8_t*)§or.byte_buffer[k]; // this is basically the start address of the current record/entry of the Log
|
||||||
// Callback 2: send the pointer for consuming the next record/entry and doing something useful to create a file
|
// Callback 2: send the pointer for consuming the next record/entry and doing something useful to create a file
|
||||||
sendRecord(_record_start);
|
sendRecord(_record_start);
|
||||||
if(k%128 == 0){ // give control to the system every x iteration, TODO: This will fail, when record/entry-size is not 8
|
if(k%128 == 0){ // give control to the system every x iteration, TODO: This will fail, when record/entry-size is not 8
|
||||||
// DEBUG_SENSOR_LOG(PSTR("FLOG: now loop(), %u bytes left"), Flog->bytes_left);
|
// DEBUG_SENSOR_LOG(PSTR("FLOG: now loop(), %u bytes left"), Flog->bytes_left);
|
||||||
OsWatchLoop();
|
OsWatchLoop();
|
||||||
delay(TasmotaGlobal.sleep);
|
delay(TasmotaGlobal.sleep);
|
||||||
}
|
}
|
||||||
k+=size;
|
k+=size;
|
||||||
if(bytes_left>7){
|
if(bytes_left>7){
|
||||||
bytes_left-=size;
|
bytes_left-=size;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
bytes_left = 0;
|
bytes_left = 0;
|
||||||
DEBUG_SENSOR_LOG(PSTR("FLOG: Flog->bytes_left not dividable by 8 ??????"));
|
DEBUG_SENSOR_LOG(PSTR("FLOG: Flog->bytes_left not dividable by 8 ??????"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
next_sector++;
|
next_sector++;
|
||||||
if(next_sector>num_sectors){
|
if(next_sector>num_sectors){
|
||||||
next_sector = 0;
|
next_sector = 0;
|
||||||
}
|
}
|
||||||
sectors_left--;
|
sectors_left--;
|
||||||
_readSector(next_sector);
|
_readSector(next_sector);
|
||||||
bytes_left = sector.header.buf_pointer - sizeof(sector.header);
|
bytes_left = sector.header.buf_pointer - sizeof(sector.header);
|
||||||
OsWatchLoop();
|
OsWatchLoop();
|
||||||
delay(TasmotaGlobal.sleep);
|
delay(TasmotaGlobal.sleep);
|
||||||
}
|
}
|
||||||
running_download = false;
|
running_download = false;
|
||||||
// Callback 3: create a footer or simply finish the download with an empty payload
|
// Callback 3: create a footer or simply finish the download with an empty payload
|
||||||
sendFooter();
|
sendFooter();
|
||||||
// refresh settings for another download
|
// refresh settings for another download
|
||||||
_searchSaves();
|
_searchSaves();
|
||||||
_initBuffer();
|
_initBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // ESP8266
|
#endif // ESP8266
|
||||||
#endif // USE_FLOG
|
#endif // USE_FLOG
|
@ -20,17 +20,17 @@
|
|||||||
//
|
//
|
||||||
// Certificates are stored in flash (PROGMEM) to avoid consuming valuable RAM.
|
// Certificates are stored in flash (PROGMEM) to avoid consuming valuable RAM.
|
||||||
//
|
//
|
||||||
// To save space in flash, the Let's Encrypt and Amazon AWS certificates may be
|
// To save space in flash, the Let's Encrypt and Amazon AWS certificates may be
|
||||||
// individually omitted if TLS is enabled, but the certificates are not used.
|
// individually omitted if TLS is enabled, but the certificates are not used.
|
||||||
// This is typically the case when a locally generated root certificate is used
|
// This is typically the case when a locally generated root certificate is used
|
||||||
// for TLS authentication.
|
// for TLS authentication.
|
||||||
//
|
//
|
||||||
// To omit these certificates, define one or both of the
|
// To omit these certificates, define one or both of the
|
||||||
// OMIT_LETS_ENCRYPT_CERT and/or OMIT_AWS_CERT macros in user_config_override.h.
|
// OMIT_LETS_ENCRYPT_CERT and/or OMIT_AWS_CERT macros in user_config_override.h.
|
||||||
//
|
//
|
||||||
// To include a locally generated root certificate, define the
|
// To include a locally generated root certificate, define the
|
||||||
// INCLUDE_LOCAL_CERT macro in user_config_override.h.
|
// INCLUDE_LOCAL_CERT macro in user_config_override.h.
|
||||||
//
|
//
|
||||||
// See the files tasmota/local_ca_data_sample.h and tasmota/local_ca_descriptor_sample.h
|
// See the files tasmota/local_ca_data_sample.h and tasmota/local_ca_descriptor_sample.h
|
||||||
// in the Tasmota source for instructions for generating them from a local root
|
// in the Tasmota source for instructions for generating them from a local root
|
||||||
// certificate in .crt format.
|
// certificate in .crt format.
|
||||||
@ -145,7 +145,7 @@ static const unsigned char PROGMEM AmazonRootCA1_RSA_E[] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(INCLUDE_LOCAL_CERT)
|
#if defined(INCLUDE_LOCAL_CERT)
|
||||||
#include <local_ca_data.h>
|
#include <include/local_ca_data.h>
|
||||||
#endif
|
#endif
|
||||||
//
|
//
|
||||||
// ========== cumulative CA =================
|
// ========== cumulative CA =================
|
0
tasmota/xdrv_10_scripter.ino → tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino
Executable file → Normal file
0
tasmota/xdrv_10_scripter.ino → tasmota/tasmota_xdrv_driver/xdrv_10_scripter.ino
Executable file → Normal file
0
tasmota/xdrv_13_display.ino → tasmota/tasmota_xdrv_driver/xdrv_13_display.ino
Executable file → Normal file
0
tasmota/xdrv_13_display.ino → tasmota/tasmota_xdrv_driver/xdrv_13_display.ino
Executable file → Normal file
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user