Merge branch 'development' into neopool-dev

This commit is contained in:
Norbert Richter 2021-01-31 21:02:36 +01:00
commit 5a4de23730
No known key found for this signature in database
GPG Key ID: 6628701A626FA674
22 changed files with 270 additions and 244 deletions

View File

@ -2,13 +2,13 @@ name: "Mark or close stale issues and PRs"
on:
schedule:
- cron: "15 05 * * *"
- cron: "30 * * * *"
jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v3.0.14
- uses: actions/stale@v3.0.15
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 25

View File

@ -166,7 +166,7 @@ lib_extra_dirs =
; *** EXPERIMENTAL Tasmota version for ESP32solo1 (used in some Xiaomi devices)
[env:tasmota32solo1]
extends = env:tasmota32
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/raw/framework-arduinoespressif32/framework-arduinoespressif32-solo1-release_v3.3-7e63061fa.tar.gz
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/raw/framework-arduinoespressif32/framework-arduinoespressif32-release_v3.3-solo1-bd65eb8d1.tar.gz
platformio/tool-mklittlefs @ ~1.203.200522
platformio/tool-esptoolpy @ ~1.30000.0
build_unflags = ${esp32_defaults.build_unflags}

View File

@ -92,7 +92,7 @@ build_flags = ${esp_defaults.build_flags}
[core32]
platform = espressif32 @ 2.1.0
platform = espressif32 @ 3.0.0
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/arduino-esp32/releases/download/1.0.5-rc6/esp32-1.0.5-rc6.zip
platformio/tool-mklittlefs @ ~1.203.200522
build_unflags = ${esp32_defaults.build_unflags}

View File

@ -540,10 +540,9 @@
#define D_SO_ZIGBEE_NOAUTOBIND "NoAutoBind"
#define D_SO_ZIGBEE_NAMETOPIC "NameTopic"
#define D_SO_ZIGBEE_ENDPOINTTOPIC "EndpointTopic"
#define D_SO_ZIGBEE_NOAUTOBIND "NoAutoBind"
#define D_SO_ZIGBEE_NOAUTOQUERY "NoAutoQuery"
#define D_SO_ZIGBEE_ZBRECEIVEDTOPIC "ReceivedTopic"
#define D_SO_ZIGBEE_OMITDEVICE "OmitDevice"
#define D_ZIGBEE_NOT_STARTED "Zigbee not started"
#define D_CMND_ZIGBEE_PERMITJOIN "PermitJoin"
#define D_CMND_ZIGBEE_STATUS "Status"
#define D_CMND_ZIGBEE_RESET "Reset"

View File

@ -960,54 +960,54 @@
// xsns_83_neopool.ino
#define D_NEOPOOL_MACH_NONE "NeoPool" // Machine names
#define D_NEOPOOL_MACH_HIDROLIFE "Hidrolife (yellow)"
#define D_NEOPOOL_MACH_AQUASCENIC "Aquascenic (blue)"
#define D_NEOPOOL_MACH_OXILIFE "Oxilife (green)"
#define D_NEOPOOL_MACH_BIONET "Bionet (light blue)"
#define D_NEOPOOL_MACH_HIDRONISER "Hidroniser (red)"
#define D_NEOPOOL_MACH_UVSCENIC "UVScenic (lilac)"
#define D_NEOPOOL_MACH_STATION "Station (orange)"
#define D_NEOPOOL_MACH_HIDROLIFE "Hidrolife (geel)"
#define D_NEOPOOL_MACH_AQUASCENIC "Aquascenic (blou)"
#define D_NEOPOOL_MACH_OXILIFE "Oxilife (groen)"
#define D_NEOPOOL_MACH_BIONET "Bionet (ligblou)"
#define D_NEOPOOL_MACH_HIDRONISER "Hidroniser (rooi)"
#define D_NEOPOOL_MACH_UVSCENIC "UVScenic (sering)"
#define D_NEOPOOL_MACH_STATION "Station (oranje)"
#define D_NEOPOOL_MACH_BRILIX "Brilix"
#define D_NEOPOOL_MACH_GENERIC "Generic"
#define D_NEOPOOL_MACH_BAYROL "Bayrol"
#define D_NEOPOOL_MACH_HAY "Hay"
#define D_NEOPOOL_FILTRATION_MANUAL "Manual" // Filtration modes
#define D_NEOPOOL_FILTRATION_AUTO "Auto"
#define D_NEOPOOL_FILTRATION_HEATING "Heating"
#define D_NEOPOOL_FILTRATION_SMART "Smart"
#define D_NEOPOOL_FILTRATION_MANUAL "Handmatig" // Filtration modes
#define D_NEOPOOL_FILTRATION_AUTO "Outomaties"
#define D_NEOPOOL_FILTRATION_HEATING "Verhitting"
#define D_NEOPOOL_FILTRATION_SMART "Slim"
#define D_NEOPOOL_FILTRATION_INTELLIGENT "Intelligent"
#define D_NEOPOOL_FILTRATION_BACKWASH "Backwash"
#define D_NEOPOOL_FILTRATION_BACKWASH "Terugspoel"
#define D_NEOPOOL_FILTRATION_NONE "" // Filtration speed level
#define D_NEOPOOL_FILTRATION_SLOW "slow"
#define D_NEOPOOL_FILTRATION_SLOW "stadig"
#define D_NEOPOOL_FILTRATION_MEDIUM "medium"
#define D_NEOPOOL_FILTRATION_FAST "fast"
#define D_NEOPOOL_TYPE "Type" // Sensor & relais names
#define D_NEOPOOL_REDOX "Redox"
#define D_NEOPOOL_CHLORINE "Chlorine"
#define D_NEOPOOL_CONDUCTIVITY "Conductivity"
#define D_NEOPOOL_IONIZATION "Ionization"
#define D_NEOPOOL_HYDROLYSIS "Hydrolysis"
#define D_NEOPOOL_RELAY "Relay"
#define D_NEOPOOL_RELAY_FILTRATION "Filtration"
#define D_NEOPOOL_RELAY_LIGHT "Light"
#define D_NEOPOOL_RELAY_PH_ACID "Acid pump"
#define D_NEOPOOL_RELAY_PH_BASE "Base pump"
#define D_NEOPOOL_RELAY_RX "Redox level"
#define D_NEOPOOL_RELAY_CL "Chlorine pump"
#define D_NEOPOOL_RELAY_CD "Brine pump"
#define D_NEOPOOL_TIME "Time"
#define D_NEOPOOL_FILT_MODE "Filtration"
#define D_NEOPOOL_FILTRATION_FAST "vinnig"
#define D_NEOPOOL_TYPE "Tipe" // Sensor & relais names
#define D_NEOPOOL_REDOX "Redoks"
#define D_NEOPOOL_CHLORINE "Chloor"
#define D_NEOPOOL_CONDUCTIVITY "Geleidingsvermoë"
#define D_NEOPOOL_IONIZATION "Ionisering"
#define D_NEOPOOL_HYDROLYSIS "Hidrolise"
#define D_NEOPOOL_RELAY "Relais"
#define D_NEOPOOL_RELAY_FILTRATION "Filtrasie"
#define D_NEOPOOL_RELAY_LIGHT "Lig"
#define D_NEOPOOL_RELAY_PH_ACID "Suurpomp"
#define D_NEOPOOL_RELAY_PH_BASE "Basispump"
#define D_NEOPOOL_RELAY_RX "Redoksvlak"
#define D_NEOPOOL_RELAY_CL "Chloorpomp"
#define D_NEOPOOL_RELAY_CD "Pekelwaterpomp"
#define D_NEOPOOL_TIME "Tyd"
#define D_NEOPOOL_FILT_MODE "Filtrasie"
#define D_NEOPOOL_POLARIZATION "Pol" // Sensor status
#define D_NEOPOOL_PR_OFF "PrOff"
#define D_NEOPOOL_SETPOINT_OK "Ok"
#define D_NEOPOOL_COVER "Cover"
#define D_NEOPOOL_SHOCK "Shock"
#define D_NEOPOOL_SETPOINT_OK "Oké"
#define D_NEOPOOL_COVER "Voorblad"
#define D_NEOPOOL_SHOCK "Skok"
#define D_NEOPOOL_ALARM "! "
#define D_NEOPOOL_LOW "Low"
#define D_NEOPOOL_LOW "Laag"
#define D_NEOPOOL_FLOW1 "FL1"
#define D_NEOPOOL_FLOW2 "FL2"
#define D_NEOPOOL_PH_HIGH "too high" // ph Alarms
#define D_NEOPOOL_PH_LOW "too low"
#define D_NEOPOOL_PUMP_TIME_EXCEEDED "pump time exceeded"
#define D_NEOPOOL_PH_HIGH "te hoog" // ph Alarms
#define D_NEOPOOL_PH_LOW "te laag"
#define D_NEOPOOL_PUMP_TIME_EXCEEDED "pomptyd oorskry"
#endif // _LANGUAGE_AF_AF_H_

View File

@ -252,22 +252,59 @@ uint32_t ChrCount(const char *str, const char *delim) {
return count;
}
// Function to return a substring defined by a delimiter at an index
char* subStr(char* dest, char* str, const char *delim, int index)
{
char *act;
char *sub = nullptr;
char *ptr;
int i;
uint32_t ArgC(void) {
return (XdrvMailbox.data_len > 0) ? ChrCount(XdrvMailbox.data, ",") +1 : 0;
}
// Since strtok consumes the first arg, make a copy
strncpy(dest, str, strlen(str)+1);
for (i = 1, act = dest; i <= index; i++, act = nullptr) {
sub = strtok_r(act, delim, &ptr);
if (sub == nullptr) break;
// Function to return a substring defined by a delimiter at an index
char* subStr(char* dest, char* str, const char *delim, int index) {
char* write = dest;
char* read = str;
char ch = '.';
while (index && (ch != '\0')) {
ch = *read++;
if (strchr(delim, ch)) {
index--;
if (index) { write = dest; }
} else {
*write++ = ch;
}
}
sub = Trim(sub);
return sub;
*write = '\0';
dest = Trim(dest);
return dest;
}
char* ArgV(char* dest, int index) {
return subStr(dest, XdrvMailbox.data, ",", index);
}
uint32_t ArgVul(uint32_t *args, uint32_t count) {
uint32_t argc = ArgC();
if (argc > count) { argc = count; }
count = argc;
if (argc) {
char argument[XdrvMailbox.data_len];
for (uint32_t i = 0; i < argc; i++) {
if (strlen(ArgV(argument, i +1))) {
args[i] = strtoul(argument, nullptr, 0);
} else {
count--;
}
}
}
return count;
}
uint32_t ParseParameters(uint32_t count, uint32_t *params) {
// Destroys XdrvMailbox.data
char *p;
uint32_t i = 0;
for (char *str = strtok_r(XdrvMailbox.data, ", ", &p); str && i < count; str = strtok_r(nullptr, ", ", &p), i++) {
params[i] = strtoul(str, nullptr, 0);
}
return i;
}
float CharToFloat(const char *str)
@ -620,16 +657,6 @@ bool ParseIPv4(uint32_t* addr, const char* str_p)
return (3 == i);
}
uint32_t ParseParameters(uint32_t count, uint32_t *params)
{
char *p;
uint32_t i = 0;
for (char *str = strtok_r(XdrvMailbox.data, ", ", &p); str && i < count; str = strtok_r(nullptr, ", ", &p), i++) {
params[i] = strtoul(str, nullptr, 0);
}
return i;
}
// Function to parse & check if version_str is newer than our currently installed version.
bool NewerVersion(char* version_str)
{

View File

@ -76,48 +76,47 @@ const char kWifiConfig[] PROGMEM =
/********************************************************************************************/
void ResponseCmndNumber(int value)
{
void ResponseCmndNumber(int value) {
Response_P(S_JSON_COMMAND_NVALUE, XdrvMailbox.command, value);
}
void ResponseCmndFloat(float value, uint32_t decimals)
{
void ResponseCmndFloat(float value, uint32_t decimals) {
Response_P(PSTR("{\"%s\":%*_f}"), XdrvMailbox.command, decimals, &value); // Return float value without quotes
}
void ResponseCmndIdxNumber(int value)
{
void ResponseCmndIdxNumber(int value) {
Response_P(S_JSON_COMMAND_INDEX_NVALUE, XdrvMailbox.command, XdrvMailbox.index, value);
}
void ResponseCmndChar_P(const char* value)
{
void ResponseCmndChar_P(const char* value) {
Response_P(S_JSON_COMMAND_SVALUE, XdrvMailbox.command, value);
}
void ResponseCmndChar(const char* value)
{
void ResponseCmndChar(const char* value) {
Response_P(S_JSON_COMMAND_SVALUE, XdrvMailbox.command, EscapeJSONString(value).c_str());
}
void ResponseCmndStateText(uint32_t value)
{
void ResponseCmndStateText(uint32_t value) {
ResponseCmndChar(GetStateText(value));
}
void ResponseCmndDone(void)
{
ResponseCmndChar(PSTR(D_JSON_DONE));
void ResponseCmndDone(void) {
ResponseCmndChar_P(PSTR(D_JSON_DONE));
}
void ResponseCmndIdxChar(const char* value)
{
void ResponseCmndError(void) {
ResponseCmndChar_P(PSTR(D_JSON_ERROR));
}
void ResponseCmndIdxChar(const char* value) {
Response_P(S_JSON_COMMAND_INDEX_SVALUE, XdrvMailbox.command, XdrvMailbox.index, EscapeJSONString(value).c_str());
}
void ResponseCmndAll(uint32_t text_index, uint32_t count)
{
void ResponseCmndIdxError(void) {
ResponseCmndIdxChar(PSTR(D_JSON_ERROR));
}
void ResponseCmndAll(uint32_t text_index, uint32_t count) {
uint32_t real_index = text_index;
ResponseClear();
for (uint32_t i = 0; i < count; i++) {
@ -1509,7 +1508,7 @@ void CmndIpAddress(void)
{
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= 4)) {
char network_address[22];
ext_snprintf_P(network_address, sizeof(network_address), PSTR(" = %_I"), (uint32_t)NetworkAddress());
ext_snprintf_P(network_address, sizeof(network_address), PSTR(" (%_I)"), (uint32_t)NetworkAddress());
if (!XdrvMailbox.usridx) {
ResponseClear();
for (uint32_t i = 0; i < 4; i++) {

View File

@ -530,7 +530,7 @@ void EnergyEverySecond(void)
}
}
if (!data_valid) {
Energy.start_energy = 0;
//Energy.start_energy = 0;
AddLog(LOG_LEVEL_DEBUG, PSTR("NRG: Energy reset by " STR(ENERGY_WATCHDOG) " seconds invalid data"));
XnrgCall(FUNC_ENERGY_RESET);

View File

@ -99,8 +99,10 @@
#define COMPARE_OPERATOR_STRING_ENDS_WITH 8
#define COMPARE_OPERATOR_STRING_STARTS_WITH 9
#define COMPARE_OPERATOR_STRING_CONTAINS 10
#define MAXIMUM_COMPARE_OPERATOR COMPARE_OPERATOR_STRING_CONTAINS
const char kCompareOperators[] PROGMEM = "=\0>\0<\0|\0==!=>=<=$>$<$|";
#define COMPARE_OPERATOR_STRING_NOT_EQUAL 11
#define COMPARE_OPERATOR_STRING_NOT_CONTAINS 12
#define MAXIMUM_COMPARE_OPERATOR COMPARE_OPERATOR_STRING_NOT_CONTAINS
const char kCompareOperators[] PROGMEM = "=\0>\0<\0|\0==!=>=<=$>$<$|$!$^";
#ifdef USE_EXPRESSION
#include <LinkedList.h> // Import LinkedList library
@ -589,7 +591,13 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all
match = str_str_value.startsWith(rule_svalue);
break;
case COMPARE_OPERATOR_STRING_CONTAINS:
match = (str_str_value.indexOf(rule_svalue) > 0);
match = (str_str_value.indexOf(rule_svalue) >= 0);
break;
case COMPARE_OPERATOR_STRING_NOT_EQUAL:
match = (0!=strcasecmp(str_value, rule_svalue)); // Compare strings - this also works for hexadecimals
break;
case COMPARE_OPERATOR_STRING_NOT_CONTAINS:
match = (str_str_value.indexOf(rule_svalue) < 0);
break;
default:
match = true;
@ -1634,7 +1642,13 @@ bool evaluateComparisonExpression(const char *expression, int len)
bResult = leftExpr.startsWith(rightExpr);
break;
case COMPARE_OPERATOR_STRING_CONTAINS:
bResult = (leftExpr.indexOf(rightExpr) > 0);
bResult = (leftExpr.indexOf(rightExpr) >= 0);
break;
case COMPARE_OPERATOR_STRING_NOT_EQUAL:
bResult = !leftExpr.equalsIgnoreCase(rightExpr); // Compare strings - this also works for hexadecimals
break;
case COMPARE_OPERATOR_STRING_NOT_CONTAINS:
bResult = (leftExpr.indexOf(rightExpr) < 0);
break;
}
return bResult;
@ -2283,17 +2297,20 @@ void CmndScale(void)
{
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_RULE_VARS)) {
if (XdrvMailbox.data_len > 0) {
if (strchr(XdrvMailbox.data, ',') != nullptr) { // Process parameter entry
char sub_string[XdrvMailbox.data_len +1];
if (ArgC() == 5) { // Process parameter entry
char argument[XdrvMailbox.data_len];
float valueIN = CharToFloat(subStr(sub_string, XdrvMailbox.data, ",", 1));
float fromLow = CharToFloat(subStr(sub_string, XdrvMailbox.data, ",", 2));
float fromHigh = CharToFloat(subStr(sub_string, XdrvMailbox.data, ",", 3));
float toLow = CharToFloat(subStr(sub_string, XdrvMailbox.data, ",", 4));
float toHigh = CharToFloat(subStr(sub_string, XdrvMailbox.data, ",", 5));
float valueIN = CharToFloat(ArgV(argument, 1));
float fromLow = CharToFloat(ArgV(argument, 2));
float fromHigh = CharToFloat(ArgV(argument, 3));
float toLow = CharToFloat(ArgV(argument, 4));
float toHigh = CharToFloat(ArgV(argument, 5));
float value = map_double(valueIN, fromLow, fromHigh, toLow, toHigh);
dtostrfd(value, Settings.flag2.calc_resolution, rules_vars[XdrvMailbox.index -1]);
bitSet(Rules.vars_event, XdrvMailbox.index -1);
} else {
ResponseCmndIdxError();
return;
}
}
ResponseCmndIdxChar(rules_vars[XdrvMailbox.index -1]);

View File

@ -1189,7 +1189,7 @@ void CmndKnxPa(void)
if ( ((pa_area == 0) && (pa_line == 0) && (pa_member == 0))
|| (pa_area > 15) || (pa_line > 15) || (pa_member > 255) ) {
Response_P (PSTR("{\"%s\":\"" D_ERROR "\"}"), XdrvMailbox.command );
ResponseCmndError();
return;
} // Invalid command
@ -1208,19 +1208,19 @@ void CmndKnxGa(void)
{
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_KNX_GA)) {
if (XdrvMailbox.data_len) {
if (strchr(XdrvMailbox.data, ',') != nullptr) { // Process parameter entry
char sub_string[XdrvMailbox.data_len];
if (ArgC() > 1) { // Process parameter entry
char argument[XdrvMailbox.data_len];
int ga_option = atoi(subStr(sub_string, XdrvMailbox.data, ",", 1));
int ga_area = atoi(subStr(sub_string, XdrvMailbox.data, ",", 2));
int ga_line = atoi(subStr(sub_string, XdrvMailbox.data, ",", 3));
int ga_member = atoi(subStr(sub_string, XdrvMailbox.data, ",", 4));
int ga_option = atoi(ArgV(argument, 1));
int ga_area = atoi(ArgV(argument, 2));
int ga_line = atoi(ArgV(argument, 3));
int ga_member = atoi(ArgV(argument, 4));
if ( ((ga_area == 0) && (ga_line == 0) && (ga_member == 0))
|| (ga_area > 31) || (ga_line > 7) || (ga_member > 255)
|| (ga_option < 0) || ((ga_option > KNX_MAX_device_param ) && (ga_option != KNX_Empty))
|| (!device_param[ga_option-1].show) ) {
Response_P (PSTR("{\"%s\":\"" D_ERROR "\"}"), XdrvMailbox.command );
ResponseCmndIdxError();
return;
} // Invalid command
@ -1239,7 +1239,7 @@ void CmndKnxGa(void)
if ( (XdrvMailbox.payload <= Settings.knx_GA_registered) && (XdrvMailbox.payload > 0) ) {
XdrvMailbox.index = XdrvMailbox.payload;
} else {
Response_P (PSTR("{\"%s\":\"" D_ERROR "\"}"), XdrvMailbox.command );
ResponseCmndIdxError();
return;
}
}
@ -1250,7 +1250,7 @@ void CmndKnxGa(void)
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member );
}
} else {
ResponseCmndNumber (Settings.knx_GA_registered );
ResponseCmndIdxNumber (Settings.knx_GA_registered );
}
}
}
@ -1259,19 +1259,19 @@ void CmndKnxCb(void)
{
if ((XdrvMailbox.index > 0) && (XdrvMailbox.index <= MAX_KNX_CB)) {
if (XdrvMailbox.data_len) {
if (strchr(XdrvMailbox.data, ',') != nullptr) { // Process parameter entry
char sub_string[XdrvMailbox.data_len];
if (ArgC() > 1) { // Process parameter entry
char argument[XdrvMailbox.data_len];
int cb_option = atoi(subStr(sub_string, XdrvMailbox.data, ",", 1));
int cb_area = atoi(subStr(sub_string, XdrvMailbox.data, ",", 2));
int cb_line = atoi(subStr(sub_string, XdrvMailbox.data, ",", 3));
int cb_member = atoi(subStr(sub_string, XdrvMailbox.data, ",", 4));
int cb_option = atoi(ArgV(argument, 1));
int cb_area = atoi(ArgV(argument, 2));
int cb_line = atoi(ArgV(argument, 3));
int cb_member = atoi(ArgV(argument, 4));
if ( ((cb_area == 0) && (cb_line == 0) && (cb_member == 0))
|| (cb_area > 31) || (cb_line > 7) || (cb_member > 255)
|| (cb_option < 0) || ((cb_option > KNX_MAX_device_param ) && (cb_option != KNX_Empty))
|| (!device_param[cb_option-1].show) ) {
Response_P (PSTR("{\"%s\":\"" D_ERROR "\"}"), XdrvMailbox.command );
ResponseCmndIdxError();
return;
} // Invalid command
@ -1290,7 +1290,7 @@ void CmndKnxCb(void)
if ( (XdrvMailbox.payload <= Settings.knx_CB_registered) && (XdrvMailbox.payload > 0) ) {
XdrvMailbox.index = XdrvMailbox.payload;
} else {
Response_P (PSTR("{\"%s\":\"" D_ERROR "\"}"), XdrvMailbox.command );
ResponseCmndIdxError();
return;
}
}
@ -1301,7 +1301,7 @@ void CmndKnxCb(void)
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member );
}
} else {
ResponseCmndNumber (Settings.knx_CB_registered );
ResponseCmndIdxNumber (Settings.knx_CB_registered );
}
}
}

View File

@ -1045,7 +1045,7 @@ void DisplayLogBufferInit(void)
DisplayLogBufferAdd(buffer);
snprintf_P(buffer, sizeof(buffer), PSTR(D_JSON_MAC " %s"), NetworkMacAddress().c_str());
DisplayLogBufferAdd(buffer);
snprintf_P(buffer, sizeof(buffer), PSTR("IP %_I"), (uint32_t)NetworkAddress());
ext_snprintf_P(buffer, sizeof(buffer), PSTR("IP %_I"), (uint32_t)NetworkAddress());
DisplayLogBufferAdd(buffer);
if (!TasmotaGlobal.global_state.wifi_down) {
snprintf_P(buffer, sizeof(buffer), PSTR(D_JSON_SSID " %s"), SettingsText(SET_STASSID1 + Settings.sta_active));

View File

@ -119,20 +119,20 @@ bool PCA9685_Command(void)
serviced = false;
return serviced;
}
char sub_string[XdrvMailbox.data_len];
char argument[XdrvMailbox.data_len];
for (uint32_t ca=0;ca<XdrvMailbox.data_len;ca++) {
if ((' ' == XdrvMailbox.data[ca]) || ('=' == XdrvMailbox.data[ca])) { XdrvMailbox.data[ca] = ','; }
if (',' == XdrvMailbox.data[ca]) { paramcount++; }
}
UpperCase(XdrvMailbox.data,XdrvMailbox.data);
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"RESET")) { PCA9685_Reset(); return serviced; }
if (!strcmp(ArgV(argument, 1),"RESET")) { PCA9685_Reset(); return serviced; }
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"STATUS")) { PCA9685_OutputTelemetry(false); return serviced; }
if (!strcmp(ArgV(argument, 1),"STATUS")) { PCA9685_OutputTelemetry(false); return serviced; }
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"PWMF")) {
if (!strcmp(ArgV(argument, 1),"PWMF")) {
if (paramcount > 1) {
uint16_t new_freq = atoi(subStr(sub_string, XdrvMailbox.data, ",", 2));
uint16_t new_freq = atoi(ArgV(argument, 2));
if ((new_freq >= 24) && (new_freq <= 1526)) {
PCA9685_SetPWMfreq(new_freq);
Response_P(PSTR("{\"PCA9685\":{\"PWMF\":%i, \"Result\":\"OK\"}}"),new_freq);
@ -143,23 +143,23 @@ bool PCA9685_Command(void)
return serviced;
}
}
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"PWM")) {
if (!strcmp(ArgV(argument, 1),"PWM")) {
if (paramcount > 1) {
uint8_t pin = atoi(subStr(sub_string, XdrvMailbox.data, ",", 2));
uint8_t pin = atoi(ArgV(argument, 2));
if (paramcount > 2) {
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 3), "ON")) {
if (!strcmp(ArgV(argument, 3), "ON")) {
PCA9685_SetPWM(pin, 4096, false);
Response_P(PSTR("{\"PCA9685\":{\"PIN\":%i,\"PWM\":%i}}"),pin,4096);
serviced = true;
return serviced;
}
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 3), "OFF")) {
if (!strcmp(ArgV(argument, 3), "OFF")) {
PCA9685_SetPWM(pin, 0, false);
Response_P(PSTR("{\"PCA9685\":{\"PIN\":%i,\"PWM\":%i}}"),pin,0);
serviced = true;
return serviced;
}
uint16_t pwm = atoi(subStr(sub_string, XdrvMailbox.data, ",", 3));
uint16_t pwm = atoi(ArgV(argument, 3));
if ((pin >= 0 && pin <= 15) && (pwm >= 0 && pwm <= 4096)) {
PCA9685_SetPWM(pin, pwm, false);
Response_P(PSTR("{\"PCA9685\":{\"PIN\":%i,\"PWM\":%i}}"),pin,pwm);

View File

@ -26,7 +26,7 @@
const char kZbCommands[] PROGMEM = D_PRFX_ZB "|" // prefix
// SetOption synonyms
D_SO_ZIGBEE_NAMEKEY "|" D_SO_ZIGBEE_DEVICETOPIC "|" D_SO_ZIGBEE_NOPREFIX "|" D_SO_ZIGBEE_ENDPOINTSUFFIX "|" D_SO_ZIGBEE_NOAUTOBIND "|"
D_SO_ZIGBEE_NAMETOPIC "|" D_SO_ZIGBEE_ENDPOINTTOPIC "|" D_SO_ZIGBEE_NOAUTOBIND "|" D_SO_ZIGBEE_ZBRECEIVEDTOPIC "|" D_SO_ZIGBEE_OMITDEVICE "|"
D_SO_ZIGBEE_NAMETOPIC "|" D_SO_ZIGBEE_ENDPOINTTOPIC "|" D_SO_ZIGBEE_NOAUTOQUERY "|" D_SO_ZIGBEE_ZBRECEIVEDTOPIC "|" D_SO_ZIGBEE_OMITDEVICE "|"
#ifdef USE_ZIGBEE_ZNP
D_CMND_ZIGBEEZNPSEND "|" D_CMND_ZIGBEEZNPRECEIVE "|"
#endif // USE_ZIGBEE_ZNP

View File

@ -201,11 +201,13 @@ void CmndBuzzer(void) {
if (XdrvMailbox.data_len > 0) {
if (XdrvMailbox.payload != 0) {
uint32_t parm[4] = { 0 };
uint32_t mode = 0;
ParseParameters(4, parm);
if (XdrvMailbox.payload <= 0) {
uint32_t mode = 0;
if (XdrvMailbox.payload < 0) {
parm[0] = 1; // Default Count
mode = -XdrvMailbox.payload; // 0, 1 or 2
if (XdrvMailbox.payload > -3) {
mode = -XdrvMailbox.payload; // 0, 1 or 2
}
}
for (uint32_t i = 1; i < 3; i++) {
if (parm[i] < 1) { parm[i] = 1; } // Default On time, Off time

View File

@ -188,7 +188,7 @@ void CmndDeepsleepTime(void)
}
}
}
Response_P(S_JSON_COMMAND_NVALUE, XdrvMailbox.command, Settings.deepsleep);
ResponseCmndNumber(Settings.deepsleep);
}
/*********************************************************************************************\

View File

@ -562,7 +562,7 @@ void UfsListDir(char *path, uint8_t depth) {
sprintf(cp, format, ep);
if (entry.isDirectory()) {
snprintf_P(npath, sizeof(npath), UFS_FORM_SDC_HREF, (uint32_t)WiFi.localIP(), pp, ep);
ext_snprintf_P(npath, sizeof(npath), UFS_FORM_SDC_HREF, (uint32_t)WiFi.localIP(), pp, ep);
WSContentSend_P(UFS_FORM_SDC_DIRd, npath, ep, name);
uint8_t plen = strlen(path);
if (plen > 1) {
@ -574,12 +574,12 @@ void UfsListDir(char *path, uint8_t depth) {
} else {
#ifdef GUI_TRASH_FILE
char delpath[128];
snprintf_P(delpath, sizeof(delpath), UFS_FORM_SDC_HREFdel, (uint32_t)WiFi.localIP(), pp, ep);
ext_snprintf_P(delpath, sizeof(delpath), UFS_FORM_SDC_HREFdel, (uint32_t)WiFi.localIP(), pp, ep);
#else
char delpath[2];
delpath[0]=0;
#endif // GUI_TRASH_FILE
snprintf_P(npath, sizeof(npath), UFS_FORM_SDC_HREF, (uint32_t)WiFi.localIP(), pp, ep);
ext_snprintf_P(npath, sizeof(npath), UFS_FORM_SDC_HREF, (uint32_t)WiFi.localIP(), pp, ep);
WSContentSend_P(UFS_FORM_SDC_DIRb, npath, ep, name, tstr.c_str(), entry.size(), delpath);
}
}

View File

@ -154,7 +154,7 @@ void Ade7953GetData(void)
uint32_t current_rms_sum = Ade7953.current_rms[0] + Ade7953.current_rms[1];
uint32_t active_power_sum = Ade7953.active_power[0] + Ade7953.active_power[1];
AddLog(LOG_LEVEL_DEBUG, PSTR("ADE: U %d, C %d, I %d + %d = %d, P %d + %d = %d"),
AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("ADE: U %d, C %d, I %d + %d = %d, P %d + %d = %d"),
Ade7953.voltage_rms, Ade7953.period,
Ade7953.current_rms[0], Ade7953.current_rms[1], current_rms_sum,
Ade7953.active_power[0], Ade7953.active_power[1], active_power_sum);
@ -289,4 +289,4 @@ bool Xnrg07(uint8_t function)
#endif // USE_ADE7953
#endif // USE_ENERGY_SENSOR
#endif // USE_I2C
#endif // USE_I2C

View File

@ -591,8 +591,8 @@ void CmndAdcParam(void) {
if (XdrvMailbox.data_len) {
if (XdrvMailbox.payload > ADC_INPUT) {
AdcGetSettings(idx);
if (ChrCount(XdrvMailbox.data, ",") > 2) { // Process parameter entry
char sub_string[XdrvMailbox.data_len +1];
if (ArgC() > 3) { // Process parameter entry
char argument[XdrvMailbox.data_len];
// AdcParam 2, 32000, 10000, 3350
// AdcParam 3, 10000, 12518931, -1.405
// AdcParam 4, 128, 0, 0
@ -601,29 +601,24 @@ void CmndAdcParam(void) {
// AdcParam 7, 0, 2146, 0.23
// AdcParam 8, 1000, 0, 0
Adc[idx].type = XdrvMailbox.payload;
Adc[idx].param1 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
Adc[idx].param2 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 3), nullptr, 10);
Adc[idx].param1 = strtol(ArgV(argument, 2), nullptr, 10);
Adc[idx].param2 = strtol(ArgV(argument, 3), nullptr, 10);
if (ADC_RANGE == XdrvMailbox.payload) {
Adc[idx].param3 = abs(strtol(subStr(sub_string, XdrvMailbox.data, ",", 4), nullptr, 10));
Adc[idx].param4 = abs(strtol(subStr(sub_string, XdrvMailbox.data, ",", 5), nullptr, 10));
Adc[idx].param3 = abs(strtol(ArgV(argument, 4), nullptr, 10));
Adc[idx].param4 = abs(strtol(ArgV(argument, 5), nullptr, 10));
} else {
Adc[idx].param3 = (int)(CharToFloat(subStr(sub_string, XdrvMailbox.data, ",", 4)) * 10000);
Adc[idx].param3 = (int)(CharToFloat(ArgV(argument, 4)) * 10000);
}
if (ADC_PH == XdrvMailbox.payload) {
char *phLow_chr = subStr(sub_string, XdrvMailbox.data, ",", 2);
char *phHigh_chr = subStr(sub_string, XdrvMailbox.data, ",", 4);
float phLow = CharToFloat(phLow_chr);
float phHigh = CharToFloat(phHigh_chr);
float phLow = CharToFloat(ArgV(argument, 2));
float phHigh = CharToFloat(ArgV(argument, 4));
Adc[idx].param1 = phLow * ANALOG_PH_DECIMAL_MULTIPLIER;
Adc[idx].param2 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 3), nullptr, 10);
Adc[idx].param2 = strtol(ArgV(argument, 3), nullptr, 10);
Adc[idx].param3 = phHigh * ANALOG_PH_DECIMAL_MULTIPLIER;
Adc[idx].param4 = strtol(subStr(sub_string, XdrvMailbox.data, ",", 5), nullptr, 10);
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Analog pH probe calibrated. cal-low(pH=ADC): %s=%d, cal-high(pH=ADC): %s=%d"), phLow_chr, Adc[idx].param2, phHigh_chr, Adc[idx].param4);
Adc[idx].param4 = strtol(ArgV(argument, 5), nullptr, 10);
AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION "Analog pH probe calibrated. cal-low(pH=ADC) %2_f=%d, cal-high(pH=ADC) %2_f=%d"),
&phLow, Adc[idx].param2, &phHigh, Adc[idx].param4);
}
if (ADC_CT_POWER == XdrvMailbox.payload) {
if (((1 == Adc[idx].param1) & CT_FLAG_ENERGY_RESET) > 0) {
for (uint32_t idx = 0; idx < MAX_ADCS; idx++) {

View File

@ -451,25 +451,25 @@ bool MCP230xx_Command(void)
serviced = false;
return serviced;
}
char sub_string[XdrvMailbox.data_len];
char argument[XdrvMailbox.data_len];
for (uint32_t ca=0;ca<XdrvMailbox.data_len;ca++) {
if ((' ' == XdrvMailbox.data[ca]) || ('=' == XdrvMailbox.data[ca])) { XdrvMailbox.data[ca] = ','; }
if (',' == XdrvMailbox.data[ca]) { paramcount++; }
}
UpperCase(XdrvMailbox.data,XdrvMailbox.data);
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"RESET")) { MCP230xx_Reset(1); return serviced; }
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"RESET1")) { MCP230xx_Reset(1); return serviced; }
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"RESET2")) { MCP230xx_Reset(2); return serviced; }
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"RESET3")) { MCP230xx_Reset(3); return serviced; }
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"RESET4")) { MCP230xx_Reset(4); return serviced; }
if (!strcmp(ArgV(argument, 1),"RESET")) { MCP230xx_Reset(1); return serviced; }
if (!strcmp(ArgV(argument, 1),"RESET1")) { MCP230xx_Reset(1); return serviced; }
if (!strcmp(ArgV(argument, 1),"RESET2")) { MCP230xx_Reset(2); return serviced; }
if (!strcmp(ArgV(argument, 1),"RESET3")) { MCP230xx_Reset(3); return serviced; }
if (!strcmp(ArgV(argument, 1),"RESET4")) { MCP230xx_Reset(4); return serviced; }
#ifdef USE_MCP230xx_OUTPUT
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"RESET5")) { MCP230xx_Reset(5); return serviced; }
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"RESET6")) { MCP230xx_Reset(6); return serviced; }
if (!strcmp(ArgV(argument, 1),"RESET5")) { MCP230xx_Reset(5); return serviced; }
if (!strcmp(ArgV(argument, 1),"RESET6")) { MCP230xx_Reset(6); return serviced; }
#endif // USE_MCP230xx_OUTPUT
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"INTPRI")) {
if (!strcmp(ArgV(argument, 1),"INTPRI")) {
if (paramcount > 1) {
uint8_t intpri = atoi(subStr(sub_string, XdrvMailbox.data, ",", 2));
uint8_t intpri = atoi(ArgV(argument, 2));
if ((intpri >= 0) && (intpri <= 20)) {
Settings.mcp230xx_int_prio = intpri;
Response_P(MCP230XX_INTCFG_RESPONSE,"PRI",99,Settings.mcp230xx_int_prio); // "{\"MCP230xx_INT%s\":{\"D_%i\":%i}}";
@ -481,9 +481,9 @@ bool MCP230xx_Command(void)
}
}
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"INTTIMER")) {
if (!strcmp(ArgV(argument, 1),"INTTIMER")) {
if (paramcount > 1) {
uint8_t inttim = atoi(subStr(sub_string, XdrvMailbox.data, ",", 2));
uint8_t inttim = atoi(ArgV(argument, 2));
if ((inttim >= 0) && (inttim <= 3600)) {
Settings.mcp230xx_int_timer = inttim;
MCP230xx_CheckForIntCounter(); // update register on whether or not we should be counting interrupts
@ -496,19 +496,19 @@ bool MCP230xx_Command(void)
}
}
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"INTDEF")) {
if (!strcmp(ArgV(argument, 1),"INTDEF")) {
if (paramcount > 1) {
uint8_t pin = atoi(subStr(sub_string, XdrvMailbox.data, ",", 2));
uint8_t pin = atoi(ArgV(argument, 2));
if (pin < mcp230xx_pincount) {
if (pin == 0) {
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 2), "0")) validpin=true;
if (!strcmp(ArgV(argument, 2), "0")) validpin=true;
} else {
validpin = true;
}
}
if (validpin) {
if (paramcount > 2) {
uint8_t intdef = atoi(subStr(sub_string, XdrvMailbox.data, ",", 3));
uint8_t intdef = atoi(ArgV(argument, 3));
if ((intdef >= 0) && (intdef <= 15)) {
Settings.mcp230xx_config[pin].int_report_defer=intdef;
if (Settings.mcp230xx_config[pin].int_count_en) {
@ -535,19 +535,19 @@ bool MCP230xx_Command(void)
}
}
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"INTCNT")) {
if (!strcmp(ArgV(argument, 1),"INTCNT")) {
if (paramcount > 1) {
uint8_t pin = atoi(subStr(sub_string, XdrvMailbox.data, ",", 2));
uint8_t pin = atoi(ArgV(argument, 2));
if (pin < mcp230xx_pincount) {
if (pin == 0) {
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 2), "0")) validpin=true;
if (!strcmp(ArgV(argument, 2), "0")) validpin=true;
} else {
validpin = true;
}
}
if (validpin) {
if (paramcount > 2) {
uint8_t intcnt = atoi(subStr(sub_string, XdrvMailbox.data, ",", 3));
uint8_t intcnt = atoi(ArgV(argument, 3));
if ((intcnt >= 0) && (intcnt <= 1)) {
Settings.mcp230xx_config[pin].int_count_en=intcnt;
if (Settings.mcp230xx_config[pin].int_report_defer) {
@ -581,19 +581,19 @@ bool MCP230xx_Command(void)
}
}
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"INTRETAIN")) {
if (!strcmp(ArgV(argument, 1),"INTRETAIN")) {
if (paramcount > 1) {
uint8_t pin = atoi(subStr(sub_string, XdrvMailbox.data, ",", 2));
uint8_t pin = atoi(ArgV(argument, 2));
if (pin < mcp230xx_pincount) {
if (pin == 0) {
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 2), "0")) validpin=true;
if (!strcmp(ArgV(argument, 2), "0")) validpin=true;
} else {
validpin = true;
}
}
if (validpin) {
if (paramcount > 2) {
uint8_t int_retain = atoi(subStr(sub_string, XdrvMailbox.data, ",", 3));
uint8_t int_retain = atoi(ArgV(argument, 3));
if ((int_retain >= 0) && (int_retain <= 1)) {
Settings.mcp230xx_config[pin].int_retain_flag=int_retain;
Response_P(MCP230XX_INTCFG_RESPONSE,"INT_RETAIN",pin,Settings.mcp230xx_config[pin].int_retain_flag);
@ -616,17 +616,17 @@ bool MCP230xx_Command(void)
}
}
uint8_t pin = atoi(subStr(sub_string, XdrvMailbox.data, ",", 1));
uint8_t pin = atoi(ArgV(argument, 1));
if (pin < mcp230xx_pincount) {
if (0 == pin) {
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1), "0")) validpin=true;
if (!strcmp(ArgV(argument, 1), "0")) validpin=true;
} else {
validpin=true;
}
}
if (validpin && (paramcount > 1)) {
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 2), "?")) {
if (!strcmp(ArgV(argument, 2), "?")) {
uint8_t port = 0;
if (pin > 7) { port = 1; }
uint8_t portdata = MCP230xx_readGPIO(port);
@ -652,15 +652,15 @@ bool MCP230xx_Command(void)
if ( mcp230xx_outpinmapping[relay_no] == pin) break;
}
relay_no = TasmotaGlobal.devices_present - mcp230xx_oldoutpincount + relay_no +1;
if ((!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 2), "ON")) || (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 2), "1"))) {
if ((!strcmp(ArgV(argument, 2), "ON")) || (!strcmp(ArgV(argument, 2), "1"))) {
ExecuteCommandPower(relay_no, 1, SRC_IGNORE);
return serviced;
}
if ((!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 2), "OFF")) || (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 2), "0"))) {
if ((!strcmp(ArgV(argument, 2), "OFF")) || (!strcmp(ArgV(argument, 2), "0"))) {
ExecuteCommandPower(relay_no, 0, SRC_IGNORE);
return serviced;
}
if ((!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 2), "T")) || (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 2), "2"))) {
if ((!strcmp(ArgV(argument, 2), "T")) || (!strcmp(ArgV(argument, 2), "2"))) {
ExecuteCommandPower(relay_no, 2, SRC_IGNORE);
return serviced;
}
@ -670,13 +670,13 @@ bool MCP230xx_Command(void)
uint8_t pullup = 0;
uint8_t intmode = 0;
if (paramcount > 1) {
pinmode = atoi(subStr(sub_string, XdrvMailbox.data, ",", 2));
pinmode = atoi(ArgV(argument, 2));
}
if (paramcount > 2) {
pullup = atoi(subStr(sub_string, XdrvMailbox.data, ",", 3));
pullup = atoi(ArgV(argument, 3));
}
if (paramcount > 3) {
intmode = atoi(subStr(sub_string, XdrvMailbox.data, ",", 4));
intmode = atoi(ArgV(argument, 4));
}
#ifdef USE_MCP230xx_OUTPUT
if ((pin < mcp230xx_pincount) && (pinmode > 0) && (pinmode < 7) && (pullup < 2) && (paramcount > 2)) {

View File

@ -193,7 +193,7 @@ bool HxCommand(void)
{
bool serviced = true;
bool show_parms = false;
char sub_string[XdrvMailbox.data_len +1];
char argument[XdrvMailbox.data_len];
for (uint32_t ca = 0; ca < XdrvMailbox.data_len; ca++) {
if ((' ' == XdrvMailbox.data[ca]) || ('=' == XdrvMailbox.data[ca])) { XdrvMailbox.data[ca] = ','; }
@ -206,7 +206,7 @@ bool HxCommand(void)
break;
case 2: // Calibrate
if (strchr(XdrvMailbox.data, ',') != nullptr) {
Settings.weight_reference = strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
Settings.weight_reference = strtol(ArgV(argument, 2), nullptr, 10);
}
Hx.scale = 1;
HxReset();
@ -216,26 +216,26 @@ bool HxCommand(void)
break;
case 3: // WeightRef to user reference
if (strchr(XdrvMailbox.data, ',') != nullptr) {
Settings.weight_reference = strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
Settings.weight_reference = strtol(ArgV(argument, 2), nullptr, 10);
}
show_parms = true;
break;
case 4: // WeightCal to user calculated value
if (strchr(XdrvMailbox.data, ',') != nullptr) {
Settings.weight_calibration = strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
Settings.weight_calibration = strtol(ArgV(argument, 2), nullptr, 10);
Hx.scale = Settings.weight_calibration;
}
show_parms = true;
break;
case 5: // WeightMax
if (strchr(XdrvMailbox.data, ',') != nullptr) {
Settings.weight_max = strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10) / 1000;
Settings.weight_max = strtol(ArgV(argument, 2), nullptr, 10) / 1000;
}
show_parms = true;
break;
case 6: // WeightItem
if (strchr(XdrvMailbox.data, ',') != nullptr) {
Settings.weight_item = (unsigned long)(CharToFloat(subStr(sub_string, XdrvMailbox.data, ",", 2)) * 10);
Settings.weight_item = (unsigned long)(CharToFloat(ArgV(argument, 2)) * 10);
}
show_parms = true;
break;
@ -245,13 +245,13 @@ bool HxCommand(void)
break;
case 8: // Json on weight change
if (strchr(XdrvMailbox.data, ',') != nullptr) {
Settings.SensorBits1.hx711_json_weight_change = strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10) & 1;
Settings.SensorBits1.hx711_json_weight_change = strtol(ArgV(argument, 2), nullptr, 10) & 1;
}
show_parms = true;
break;
case 9: // WeightDelta
if (strchr(XdrvMailbox.data, ',') != nullptr) {
Settings.weight_change = strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
Settings.weight_change = strtol(ArgV(argument, 2), nullptr, 10);
SetWeightDelta();
}
show_parms = true;

View File

@ -500,29 +500,28 @@ bool PN532_Command(void) {
serviced = false;
return serviced;
}
char sub_string[XdrvMailbox.data_len];
char sub_string_tmp[XdrvMailbox.data_len];
char argument[XdrvMailbox.data_len];
for (uint32_t ca=0;ca<XdrvMailbox.data_len;ca++) {
if ((' ' == XdrvMailbox.data[ca]) || ('=' == XdrvMailbox.data[ca])) { XdrvMailbox.data[ca] = ','; }
if (',' == XdrvMailbox.data[ca]) { paramcount++; }
}
UpperCase(XdrvMailbox.data,XdrvMailbox.data);
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"E")) {
if (!strcmp(ArgV(argument, 1),"E")) {
Pn532.function = 1; // Block 1 of next card/tag will be reset to 0x00...
AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Next scanned tag data block 1 will be erased"));
ResponseTime_P(PSTR(",\"PN532\":{\"COMMAND\":\"E\"}}"));
return serviced;
}
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"S")) {
if (!strcmp(ArgV(argument, 1),"S")) {
if (paramcount > 1) {
if (XdrvMailbox.data[XdrvMailbox.data_len-1] == ',') {
serviced = false;
return serviced;
}
sprintf(sub_string_tmp,subStr(sub_string, XdrvMailbox.data, ",", 2));
Pn532.newdata_len = strlen(sub_string_tmp);
ArgV(argument, 2);
Pn532.newdata_len = strlen(argument);
if (Pn532.newdata_len > 15) { Pn532.newdata_len = 15; }
memcpy(&Pn532.newdata,&sub_string_tmp,Pn532.newdata_len);
memcpy(&Pn532.newdata,&argument,Pn532.newdata_len);
Pn532.newdata[Pn532.newdata_len] = 0x00; // Null terminate the string
Pn532.function = 2;
AddLog(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Next scanned tag data block 1 will be set to '%s'"), Pn532.newdata);

View File

@ -289,48 +289,36 @@ void WindMeterTriggerTele(void)
bool Xsns68Cmnd(void)
{
bool serviced = true;
bool show_parms = true;
char sub_string[XdrvMailbox.data_len +1];
switch (XdrvMailbox.payload) {
case 1:
if (strchr(XdrvMailbox.data, ',') != nullptr) {
Settings.windmeter_radius = (uint16_t)strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
}
break;
case 2:
if (strchr(XdrvMailbox.data, ',') != nullptr) {
Settings.windmeter_pulses_x_rot = (uint8_t)strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
}
break;
case 3:
if (strchr(XdrvMailbox.data, ',') != nullptr) {
Settings.windmeter_pulse_debounce = (uint16_t)strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
}
break;
case 4:
if (strchr(XdrvMailbox.data, ',') != nullptr) {
Settings.windmeter_speed_factor = (int16_t)(CharToFloat(subStr(sub_string, XdrvMailbox.data, ",", 2)) * 1000);
}
break;
case 5:
if (strchr(XdrvMailbox.data, ',') != nullptr) {
Settings.windmeter_tele_pchange = (uint8_t)strtol(subStr(sub_string, XdrvMailbox.data, ",", 2), nullptr, 10);
}
break;
if (ArgC() > 1) {
char argument[XdrvMailbox.data_len];
switch (XdrvMailbox.payload) {
case 1:
Settings.windmeter_radius = (uint16_t)strtol(ArgV(argument, 2), nullptr, 10);
break;
case 2:
Settings.windmeter_pulses_x_rot = (uint8_t)strtol(ArgV(argument, 2), nullptr, 10);
break;
case 3:
Settings.windmeter_pulse_debounce = (uint16_t)strtol(ArgV(argument, 2), nullptr, 10);
break;
case 4:
Settings.windmeter_speed_factor = (int16_t)(CharToFloat(ArgV(argument, 2)) * 1000);
break;
case 5:
Settings.windmeter_tele_pchange = (uint8_t)strtol(ArgV(argument, 2), nullptr, 10);
break;
}
}
if (show_parms) {
char speed_factor_string[FLOATSZ];
dtostrfd((float)Settings.windmeter_speed_factor / 1000, 3, speed_factor_string);
char tele_pchange_string[4] = "off";
if (Settings.windmeter_tele_pchange <= 100) {
itoa(Settings.windmeter_tele_pchange, tele_pchange_string, 10);
}
Response_P(PSTR("{\"" D_WINDMETER_NAME "\":{\"Radius\":%d,\"PulsesPerRot\":%d,\"PulseDebounce\":%d,\"SpeedFactor\":%s,\"TeleTriggerMin%Change\":%s}}"),
Settings.windmeter_radius, Settings.windmeter_pulses_x_rot, Settings.windmeter_pulse_debounce, speed_factor_string, tele_pchange_string);
float speed_factor = (float)Settings.windmeter_speed_factor / 1000;
char tele_pchange_string[4] = "off";
if (Settings.windmeter_tele_pchange <= 100) {
itoa(Settings.windmeter_tele_pchange, tele_pchange_string, 10);
}
return serviced;
Response_P(PSTR("{\"" D_WINDMETER_NAME "\":{\"Radius\":%d,\"PulsesPerRot\":%d,\"PulseDebounce\":%d,\"SpeedFactor\":%3_f,\"TeleTriggerMin%Change\":%s}}"),
Settings.windmeter_radius, Settings.windmeter_pulses_x_rot, Settings.windmeter_pulse_debounce, &speed_factor, tele_pchange_string);
return true;
}
/*********************************************************************************************\