mirror of https://github.com/arendst/Tasmota.git
Change some defines to const
Change some defines to const
This commit is contained in:
parent
eb9617e3f9
commit
2aad0567bf
|
@ -1,5 +1,6 @@
|
|||
/* 6.5.0.3 20190328
|
||||
* Add command Sensor20 1..255 to change Nova Fitness SDS01 working period in minutes (#5452)
|
||||
* Change some defines to const
|
||||
*
|
||||
* 6.5.0.2 20190325
|
||||
* Change UDP initial message handling from string to char using static memory and add debug info (#5505)
|
||||
|
|
190
sonoff/sonoff.h
190
sonoff/sonoff.h
|
@ -42,109 +42,109 @@
|
|||
\*********************************************************************************************/
|
||||
|
||||
typedef unsigned long power_t; // Power (Relay) type
|
||||
#define POWER_MASK 0xffffffffUL // Power (Relay) full mask
|
||||
const uint32_t POWER_MASK = 0xffffffffUL; // Power (Relay) full mask
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Constants
|
||||
\*********************************************************************************************/
|
||||
|
||||
// Changes to the following MAX_ defines will impact settings layout
|
||||
const uint8_t MAX_SWITCHES = 8; // Max number of switches
|
||||
const uint8_t MAX_RELAYS = 8; // Max number of relays
|
||||
const uint8_t MAX_INTERLOCKS = 4; // Max number of interlock groups (MAX_RELAYS / 2)
|
||||
const uint8_t MAX_LEDS = 4; // Max number of leds
|
||||
const uint8_t MAX_KEYS = 4; // Max number of keys or buttons
|
||||
const uint8_t MAX_PWMS = 5; // Max number of PWM channels
|
||||
const uint8_t MAX_COUNTERS = 4; // Max number of counter sensors
|
||||
const uint8_t MAX_TIMERS = 16; // Max number of Timers
|
||||
const uint8_t MAX_PULSETIMERS = 8; // Max number of supported pulse timers
|
||||
const uint8_t MAX_FRIENDLYNAMES = 4; // Max number of Friendly names
|
||||
const uint8_t MAX_DOMOTICZ_IDX = 4; // Max number of Domoticz device, key and switch indices
|
||||
const uint8_t MAX_DOMOTICZ_SNS_IDX = 12; // Max number of Domoticz sensors indices
|
||||
const uint8_t MAX_KNX_GA = 10; // Max number of KNX Group Addresses to read that can be set
|
||||
const uint8_t MAX_KNX_CB = 10; // Max number of KNX Group Addresses to write that can be set
|
||||
const uint8_t MAX_XNRG_DRIVERS = 32; // Max number of allowed energy drivers
|
||||
const uint8_t MAX_XDSP_DRIVERS = 32; // Max number of allowed display drivers
|
||||
const uint8_t MAX_XDRV_DRIVERS = 96; // Max number of allowed driver drivers
|
||||
const uint8_t MAX_XSNS_DRIVERS = 96; // Max number of allowed sensor drivers
|
||||
const uint8_t MAX_RULE_MEMS = 5; // Max number of saved vars
|
||||
const uint8_t MAX_RULE_SETS = 3; // Max number of rule sets of size 512 characters
|
||||
const uint16_t MAX_RULE_SIZE = 512; // Max number of characters in rules
|
||||
|
||||
const uint8_t MAX_FAN_SPEED = 4; // Max number of iFan02 fan speeds (0 .. 3)
|
||||
|
||||
const char MQTT_TOKEN_PREFIX[] PROGMEM = "%prefix%"; // To be substituted by mqtt_prefix[x]
|
||||
const char MQTT_TOKEN_TOPIC[] PROGMEM = "%topic%"; // To be substituted by mqtt_topic, mqtt_grptopic, mqtt_buttontopic, mqtt_switchtopic
|
||||
const char WIFI_HOSTNAME[] = "%s-%04d"; // Expands to <MQTT_TOPIC>-<last 4 decimal chars of MAC address>
|
||||
|
||||
const uint8_t CONFIG_FILE_SIGN = 0xA5; // Configuration file signature
|
||||
const uint8_t CONFIG_FILE_XOR = 0x5A; // Configuration file xor (0 = No Xor)
|
||||
|
||||
const uint32_t HLW_PREF_PULSE = 12530; // was 4975us = 201Hz = 1000W
|
||||
const uint32_t HLW_UREF_PULSE = 1950; // was 1666us = 600Hz = 220V
|
||||
const uint32_t HLW_IREF_PULSE = 3500; // was 1666us = 600Hz = 4.545A
|
||||
|
||||
const uint8_t MQTT_RETRY_SECS = 10; // Minimum seconds to retry MQTT connection
|
||||
const uint32_t GLOBAL_VALUES_VALID = 300; // Max number of seconds to keep last received values
|
||||
const power_t APP_POWER = 0; // Default saved power state Off
|
||||
const uint16_t WS2812_MAX_LEDS = 512; // Max number of LEDs
|
||||
|
||||
const uint32_t PWM_RANGE = 1023; // 255..1023 needs to be devisible by 256
|
||||
//const uint16_t PWM_FREQ = 1000; // 100..1000 Hz led refresh
|
||||
//const uint16_t PWM_FREQ = 910; // 100..1000 Hz led refresh (iTead value)
|
||||
const uint16_t PWM_FREQ = 880; // 100..1000 Hz led refresh (BN-SZ01 value)
|
||||
const uint16_t PWM_MAX = 4000; // [PWM_MAX] Maximum frequency - Default: 4000
|
||||
const uint16_t PWM_MIN = 100; // [PWM_MIN] Minimum frequency - Default: 100
|
||||
// For Dimmers use double of your mains AC frequecy (100 for 50Hz and 120 for 60Hz)
|
||||
// For Controlling Servos use 50 and also set PWM_FREQ as 50 (DO NOT USE THESE VALUES FOR DIMMERS)
|
||||
//#define PWM_LIGHTSCHEME0_IGNORE_SLEEP // Do not change sleep value for LightAnimate() scheme 0
|
||||
|
||||
const uint8_t DEFAULT_POWER_DELTA = 80; // Power change percentage
|
||||
const uint16_t MAX_POWER_HOLD = 10; // Time in SECONDS to allow max agreed power
|
||||
const uint16_t MAX_POWER_WINDOW = 30; // Time in SECONDS to disable allow max agreed power
|
||||
const uint16_t SAFE_POWER_HOLD = 10; // Time in SECONDS to allow max unit safe power
|
||||
const uint16_t SAFE_POWER_WINDOW = 30; // Time in MINUTES to disable allow max unit safe power
|
||||
const uint8_t MAX_POWER_RETRY = 5; // Retry count allowing agreed power limit overflow
|
||||
|
||||
const uint8_t STATES = 20; // Number of states per second using 50 mSec interval
|
||||
const uint8_t IMMINENT_RESET_FACTOR = 10; // Factor to extent button hold time for imminent Reset to default 40 seconds using KEY_HOLD_TIME of 40
|
||||
const uint32_t BOOT_LOOP_TIME = 10; // Number of seconds to stop detecting boot loops
|
||||
const uint16_t SYSLOG_TIMER = 600; // Seconds to restore syslog_level
|
||||
const uint16_t SERIALLOG_TIMER = 600; // Seconds to disable SerialLog
|
||||
const uint8_t OTA_ATTEMPTS = 5; // Number of times to try fetching the new firmware
|
||||
|
||||
const uint16_t INPUT_BUFFER_SIZE = 520; // Max number of characters in (serial and http) command buffer
|
||||
const uint16_t CMDSZ = 24; // Max number of characters in command
|
||||
const uint16_t TOPSZ = 100; // Max number of characters in topic string
|
||||
const uint16_t LOGSZ = 520; // Max number of characters in log
|
||||
const uint16_t MIN_MESSZ = 893; // Min number of characters in MQTT message
|
||||
|
||||
const uint8_t SENSOR_MAX_MISS = 5; // Max number of missed sensor reads before deciding it's offline
|
||||
|
||||
#ifdef USE_MQTT_TLS
|
||||
const uint16_t WEB_LOG_SIZE = 2000; // Max number of characters in weblog
|
||||
#else
|
||||
const uint16_t WEB_LOG_SIZE = 4000; // Max number of characters in weblog
|
||||
#endif
|
||||
|
||||
const uint8_t MAX_BACKLOG = 30; // Max number of commands in backlog
|
||||
const uint32_t MIN_BACKLOG_DELAY = 2; // Minimal backlog delay in 0.1 seconds
|
||||
|
||||
const uint32_t SOFT_BAUDRATE = 9600; // Default software serial baudrate
|
||||
const uint32_t APP_BAUDRATE = 115200; // Default serial baudrate
|
||||
const uint32_t SERIAL_POLLING = 100; // Serial receive polling in ms
|
||||
const uint8_t MAX_STATUS = 11; // Max number of status lines
|
||||
|
||||
const uint32_t DRIVER_BOOT_DELAY = 1; // Number of milliseconds to retard driver cycles during boot-up time to reduce overall CPU load whilst Wifi is connecting
|
||||
const uint32_t LOOP_SLEEP_DELAY = 50; // Lowest number of milliseconds to go through the main loop using delay when needed
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Defines
|
||||
\*********************************************************************************************/
|
||||
|
||||
// Changes to the following MAX_ defines will impact settings layout
|
||||
#define MAX_SWITCHES 8 // Max number of switches
|
||||
#define MAX_RELAYS 8 // Max number of relays
|
||||
#define MAX_INTERLOCKS 4 // Max number of interlock groups (MAX_RELAYS / 2)
|
||||
#define MAX_LEDS 4 // Max number of leds
|
||||
#define MAX_KEYS 4 // Max number of keys or buttons
|
||||
#define MAX_PWMS 5 // Max number of PWM channels
|
||||
#define MAX_COUNTERS 4 // Max number of counter sensors
|
||||
#define MAX_TIMERS 16 // Max number of Timers
|
||||
#define MAX_PULSETIMERS 8 // Max number of supported pulse timers
|
||||
#define MAX_FRIENDLYNAMES 4 // Max number of Friendly names
|
||||
#define MAX_DOMOTICZ_IDX 4 // Max number of Domoticz device, key and switch indices
|
||||
#define MAX_DOMOTICZ_SNS_IDX 12 // Max number of Domoticz sensors indices
|
||||
#define MAX_KNX_GA 10 // Max number of KNX Group Addresses to read that can be set
|
||||
#define MAX_KNX_CB 10 // Max number of KNX Group Addresses to write that can be set
|
||||
#define MAX_XNRG_DRIVERS 32 // Max number of allowed energy drivers
|
||||
#define MAX_XDSP_DRIVERS 32 // Max number of allowed display drivers
|
||||
#define MAX_XDRV_DRIVERS 96 // Max number of allowed driver drivers
|
||||
#define MAX_XSNS_DRIVERS 96 // Max number of allowed sensor drivers
|
||||
#define MAX_RULE_MEMS 5 // Max number of saved vars
|
||||
#define MAX_RULE_SETS 3 // Max number of rule sets of size 512 characters
|
||||
#define MAX_RULE_SIZE 512 // Max number of characters in rules
|
||||
|
||||
// Changes to the following defines have no impact on settings layout
|
||||
#define MAX_RULE_TIMERS 8 // Max number of rule timers (4 bytes / timer)
|
||||
#define MAX_RULE_VARS 5 // Max number of rule variables (10 bytes / variable)
|
||||
|
||||
#define MAX_FAN_SPEED 4 // Max number of iFan02 fan speeds (0 .. 3)
|
||||
|
||||
#define MQTT_TOKEN_PREFIX "%prefix%" // To be substituted by mqtt_prefix[x]
|
||||
#define MQTT_TOKEN_TOPIC "%topic%" // To be substituted by mqtt_topic, mqtt_grptopic, mqtt_buttontopic, mqtt_switchtopic
|
||||
#define MQTT_TOKEN_HOSTNAME "%hostname%" // To be substituted by mqtt_topic, mqtt_grptopic, mqtt_buttontopic, mqtt_switchtopic
|
||||
#define MQTT_TOKEN_ID "%id%" // To be substituted by mqtt_topic, mqtt_grptopic, mqtt_buttontopic, mqtt_switchtopic
|
||||
|
||||
#define WIFI_HOSTNAME "%s-%04d" // Expands to <MQTT_TOPIC>-<last 4 decimal chars of MAC address>
|
||||
|
||||
#define CONFIG_FILE_SIGN 0xA5 // Configuration file signature
|
||||
#define CONFIG_FILE_XOR 0x5A // Configuration file xor (0 = No Xor)
|
||||
|
||||
#define HLW_PREF_PULSE 12530 // was 4975us = 201Hz = 1000W
|
||||
#define HLW_UREF_PULSE 1950 // was 1666us = 600Hz = 220V
|
||||
#define HLW_IREF_PULSE 3500 // was 1666us = 600Hz = 4.545A
|
||||
|
||||
#define MQTT_RETRY_SECS 10 // Minimum seconds to retry MQTT connection
|
||||
#define GLOBAL_VALUES_VALID 300 // Max number of seconds to keep last received values
|
||||
#define APP_POWER 0 // Default saved power state Off
|
||||
#define WS2812_MAX_LEDS 512 // Max number of LEDs
|
||||
|
||||
#define PWM_RANGE 1023 // 255..1023 needs to be devisible by 256
|
||||
//#define PWM_FREQ 1000 // 100..1000 Hz led refresh
|
||||
//#define PWM_FREQ 910 // 100..1000 Hz led refresh (iTead value)
|
||||
#define PWM_FREQ 880 // 100..1000 Hz led refresh (BN-SZ01 value)
|
||||
#define PWM_MAX 4000 // [PWM_MAX] Maximum frequency - Default: 4000
|
||||
#define PWM_MIN 100 // [PWM_MIN] Minimum frequency - Default: 100
|
||||
// For Dimmers use double of your mains AC frequecy (100 for 50Hz and 120 for 60Hz)
|
||||
// For Controlling Servos use 50 and also set PWM_FREQ as 50 (DO NOT USE THESE VALUES FOR DIMMERS)
|
||||
//#define PWM_LIGHTSCHEME0_IGNORE_SLEEP // Do not change sleep value for LightAnimate() scheme 0
|
||||
|
||||
#define DEFAULT_POWER_DELTA 80 // Power change percentage
|
||||
#define MAX_POWER_HOLD 10 // Time in SECONDS to allow max agreed power
|
||||
#define MAX_POWER_WINDOW 30 // Time in SECONDS to disable allow max agreed power
|
||||
#define SAFE_POWER_HOLD 10 // Time in SECONDS to allow max unit safe power
|
||||
#define SAFE_POWER_WINDOW 30 // Time in MINUTES to disable allow max unit safe power
|
||||
#define MAX_POWER_RETRY 5 // Retry count allowing agreed power limit overflow
|
||||
|
||||
#define STATES 20 // Number of states per second using 50 mSec interval
|
||||
#define IMMINENT_RESET_FACTOR 10 // Factor to extent button hold time for imminent Reset to default 40 seconds using KEY_HOLD_TIME of 40
|
||||
#define BOOT_LOOP_TIME 10 // Number of seconds to stop detecting boot loops
|
||||
#define SYSLOG_TIMER 600 // Seconds to restore syslog_level
|
||||
#define SERIALLOG_TIMER 600 // Seconds to disable SerialLog
|
||||
#define OTA_ATTEMPTS 5 // Number of times to try fetching the new firmware
|
||||
|
||||
#define INPUT_BUFFER_SIZE 520 // Max number of characters in (serial and http) command buffer
|
||||
#define CMDSZ 24 // Max number of characters in command
|
||||
#define TOPSZ 100 // Max number of characters in topic string
|
||||
#define LOGSZ 520 // Max number of characters in log
|
||||
#define MIN_MESSZ 893 // Min number of characters in MQTT message
|
||||
|
||||
#define SENSOR_MAX_MISS 5 // Max number of missed sensor reads before deciding it's offline
|
||||
|
||||
#ifdef USE_MQTT_TLS
|
||||
#define WEB_LOG_SIZE 2000 // Max number of characters in weblog
|
||||
#else
|
||||
#define WEB_LOG_SIZE 4000 // Max number of characters in weblog
|
||||
#endif
|
||||
|
||||
#define MAX_BACKLOG 30 // Max number of commands in backlog
|
||||
#define MIN_BACKLOG_DELAY 2 // Minimal backlog delay in 0.1 seconds
|
||||
|
||||
#define SOFT_BAUDRATE 9600 // Default software serial baudrate
|
||||
#define APP_BAUDRATE 115200 // Default serial baudrate
|
||||
#define SERIAL_POLLING 100 // Serial receive polling in ms
|
||||
#define MAX_STATUS 11 // Max number of status lines
|
||||
|
||||
#define DRIVER_BOOT_DELAY 1 // Number of milliseconds to retard driver cycles during boot-up time to reduce overall CPU load whilst Wifi is connecting
|
||||
#define LOOP_SLEEP_DELAY 50 // Lowest number of milliseconds to go through the main loop using delay when needed
|
||||
|
||||
#define NO_EXTRA_4K_HEAP // Allocate 4k heap for WPS in ESP8166/Arduino core v2.4.2 (was always allocated in previous versions)
|
||||
|
||||
/*
|
||||
|
|
|
@ -254,20 +254,21 @@ char* GetTopic_P(char *stopic, uint8_t prefix, char *topic, const char* subtopic
|
|||
fulltopic += F("_fb"); // cmnd/<mqttclient>_fb
|
||||
} else {
|
||||
fulltopic = Settings.mqtt_fulltopic;
|
||||
if ((0 == prefix) && (-1 == fulltopic.indexOf(F(MQTT_TOKEN_PREFIX)))) {
|
||||
fulltopic += F("/" MQTT_TOKEN_PREFIX); // Need prefix for commands to handle mqtt topic loops
|
||||
if ((0 == prefix) && (-1 == fulltopic.indexOf(FPSTR(MQTT_TOKEN_PREFIX)))) {
|
||||
fulltopic += F("/");
|
||||
fulltopic += FPSTR(MQTT_TOKEN_PREFIX); // Need prefix for commands to handle mqtt topic loops
|
||||
}
|
||||
for (uint8_t i = 0; i < 3; i++) {
|
||||
if ('\0' == Settings.mqtt_prefix[i][0]) {
|
||||
snprintf_P(Settings.mqtt_prefix[i], sizeof(Settings.mqtt_prefix[i]), kPrefixes[i]);
|
||||
}
|
||||
}
|
||||
fulltopic.replace(F(MQTT_TOKEN_PREFIX), Settings.mqtt_prefix[prefix]);
|
||||
fulltopic.replace(F(MQTT_TOKEN_TOPIC), topic);
|
||||
fulltopic.replace(F(MQTT_TOKEN_HOSTNAME), my_hostname);
|
||||
fulltopic.replace(FPSTR(MQTT_TOKEN_PREFIX), Settings.mqtt_prefix[prefix]);
|
||||
fulltopic.replace(FPSTR(MQTT_TOKEN_TOPIC), topic);
|
||||
fulltopic.replace(F("%hostname%"), my_hostname);
|
||||
String token_id = WiFi.macAddress();
|
||||
token_id.replace(":", "");
|
||||
fulltopic.replace(F(MQTT_TOKEN_ID), token_id);
|
||||
fulltopic.replace(F("%id%"), token_id);
|
||||
}
|
||||
fulltopic.replace(F("#"), "");
|
||||
fulltopic.replace(F("//"), "/");
|
||||
|
|
|
@ -22,10 +22,11 @@
|
|||
* Timezone by Jack Christensen (https://github.com/JChristensen/Timezone)
|
||||
\*********************************************************************************************/
|
||||
|
||||
#define SECS_PER_MIN ((uint32_t)(60UL))
|
||||
#define SECS_PER_HOUR ((uint32_t)(3600UL))
|
||||
#define SECS_PER_DAY ((uint32_t)(SECS_PER_HOUR * 24UL))
|
||||
#define MINS_PER_HOUR ((uint32_t)(60UL))
|
||||
const uint32_t SECS_PER_MIN = 60UL;
|
||||
const uint32_t SECS_PER_HOUR = 3600UL;
|
||||
const uint32_t SECS_PER_DAY = SECS_PER_HOUR * 24UL;
|
||||
const uint32_t MINS_PER_HOUR = 60UL;
|
||||
|
||||
#define LEAP_YEAR(Y) (((1970+Y)>0) && !((1970+Y)%4) && (((1970+Y)%100) || !((1970+Y)%400)))
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -295,7 +295,7 @@ void MqttConnected(void)
|
|||
|
||||
GetTopic_P(stopic, CMND, mqtt_topic, PSTR("#"));
|
||||
MqttSubscribe(stopic);
|
||||
if (strstr(Settings.mqtt_fulltopic, MQTT_TOKEN_TOPIC) != nullptr) {
|
||||
if (strstr_P(Settings.mqtt_fulltopic, MQTT_TOKEN_TOPIC) != nullptr) {
|
||||
GetTopic_P(stopic, CMND, Settings.mqtt_grptopic, PSTR("#"));
|
||||
MqttSubscribe(stopic);
|
||||
GetFallbackTopic_P(stopic, CMND, PSTR("#"));
|
||||
|
|
|
@ -830,7 +830,7 @@ void DisplayMqttSubscribe(void)
|
|||
strlcpy(stopic, Settings.mqtt_fulltopic, sizeof(stopic));
|
||||
char *tp = strtok(stopic, "/");
|
||||
while (tp != nullptr) {
|
||||
if (!strcmp_P(tp, PSTR(MQTT_TOKEN_PREFIX))) {
|
||||
if (!strcmp_P(tp, MQTT_TOKEN_PREFIX)) {
|
||||
break;
|
||||
}
|
||||
strncat_P(ntopic, PSTR("+/"), sizeof(ntopic) - strlen(ntopic) -1); // Add single-level wildcards
|
||||
|
|
Loading…
Reference in New Issue