mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-25 11:46:31 +00:00
Merge branch 'development' into development
This commit is contained in:
commit
6ab6708c34
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -7,7 +7,7 @@
|
||||
- [ ] Only relevant files were touched
|
||||
- [ ] Only one feature/fix was added per PR and the code change compiles without warnings
|
||||
- [ ] The code change is tested and works on Tasmota core ESP8266 V.2.7.4.9
|
||||
- [ ] The code change is tested and works on Tasmota core ESP32 V.1.0.5-rc4
|
||||
- [ ] The code change is tested and works on Tasmota core ESP32 V.1.0.5-rc6
|
||||
- [ ] I accept the [CLA](https://github.com/arendst/Tasmota/blob/development/CONTRIBUTING.md#contributor-license-agreement-cla).
|
||||
|
||||
_NOTE: The code change must pass CI tests. **Your PR cannot be merged unless tests pass**_
|
||||
|
2
.github/workflows/Tasmota_build.yml
vendored
2
.github/workflows/Tasmota_build.yml
vendored
@ -1603,8 +1603,6 @@ jobs:
|
||||
[ ! -f ./mv_firmware/tasmota32-knx.* ] || mv ./mv_firmware/tasmota32-knx.* ./firmware/tasmota32/
|
||||
[ ! -f ./mv_firmware/tasmota32* ] || mv ./mv_firmware/tasmota32* ./firmware/tasmota32/languages/
|
||||
[ ! -f ./mv_firmware/* ] || mv ./mv_firmware/* ./firmware/tasmota/languages/
|
||||
rm ./firmware/tasmota32/*.gz
|
||||
rm ./firmware/tasmota32/languages/*.gz
|
||||
[ ! -f ./tools/Esptool/ESP32/*.* ] || mv ./tools/Esptool/ESP32/*.* ./firmware/tasmota32/ESP32_needed_files/
|
||||
[ ! -f ./tools/Esptool/Odroid_go/*.* ] || mv ./tools/Esptool/Odroid_go/*.* ./firmware/tasmota32/Odroid_go_needed_files/
|
||||
[ ! -f ./FIRMWARE.md ] || mv -f ./FIRMWARE.md ./README.md
|
||||
|
2
.github/workflows/Tasmota_build_master.yml
vendored
2
.github/workflows/Tasmota_build_master.yml
vendored
@ -1603,8 +1603,6 @@ jobs:
|
||||
[ ! -f ./mv_firmware/tasmota32-knx.* ] || mv ./mv_firmware/tasmota32-knx.* ./firmware/tasmota32/
|
||||
[ ! -f ./mv_firmware/tasmota32* ] || mv ./mv_firmware/tasmota32* ./firmware/tasmota32/languages/
|
||||
[ ! -f ./mv_firmware/* ] || mv ./mv_firmware/* ./firmware/tasmota/languages/
|
||||
rm ./firmware/tasmota32/*.gz
|
||||
rm ./firmware/tasmota32/languages/*.gz
|
||||
[ ! -f ./tools/Esptool/ESP32/*.* ] || mv ./tools/Esptool/ESP32/*.* ./firmware/tasmota32/ESP32_needed_files/
|
||||
[ ! -f ./tools/Esptool/Odroid_go/*.* ] || mv ./tools/Esptool/Odroid_go/*.* ./firmware/tasmota32/Odroid_go_needed_files/
|
||||
[ ! -f ./FIRMWARE.md ] || mv -f ./RELEASENOTES.md ./README.md
|
||||
|
@ -32,7 +32,7 @@ extern String EscapeJSONString(const char *str);
|
||||
class JsonGeneratorArray {
|
||||
public:
|
||||
|
||||
JsonGeneratorArray(): val("[]") {} // start with empty array
|
||||
JsonGeneratorArray(): val(F("[]")) {} // start with empty array
|
||||
|
||||
void add(uint32_t uval32);
|
||||
void add(int32_t uval32);
|
||||
@ -53,7 +53,7 @@ protected:
|
||||
class JsonGeneratorObject {
|
||||
public:
|
||||
|
||||
JsonGeneratorObject(): val("{}") {} // start with empty object
|
||||
JsonGeneratorObject(): val(F("{}")) {} // start with empty object
|
||||
|
||||
void add(const char* key, uint32_t uval32);
|
||||
void add(const char* key, int32_t uval32);
|
||||
|
@ -3,26 +3,32 @@ import os
|
||||
import shutil
|
||||
import gzip
|
||||
|
||||
OUTPUT_DIR = "build_output{}".format(os.path.sep)
|
||||
platform = env.PioPlatform()
|
||||
board = env.BoardConfig()
|
||||
mcu = board.get("build.mcu", "esp32")
|
||||
# gzip only for ESP8266
|
||||
if env["PIOPLATFORM"] != "espressif32":
|
||||
|
||||
def bin_gzip(source, target, env):
|
||||
variant = str(target[0]).split(os.path.sep)[2]
|
||||
|
||||
# create string with location and file names based on variant
|
||||
bin_file = "{}firmware{}{}.bin".format(OUTPUT_DIR, os.path.sep, variant)
|
||||
gzip_file = "{}firmware{}{}.bin.gz".format(OUTPUT_DIR, os.path.sep, variant)
|
||||
OUTPUT_DIR = "build_output{}".format(os.path.sep)
|
||||
|
||||
# check if new target files exist and remove if necessary
|
||||
if os.path.isfile(gzip_file): os.remove(gzip_file)
|
||||
def bin_gzip(source, target, env):
|
||||
variant = str(target[0]).split(os.path.sep)[2]
|
||||
|
||||
# write gzip firmware file
|
||||
with open(bin_file,"rb") as fp:
|
||||
with gzip.open(gzip_file, "wb", compresslevel = 9) as f:
|
||||
shutil.copyfileobj(fp, f)
|
||||
|
||||
ORG_FIRMWARE_SIZE = os.stat(bin_file).st_size
|
||||
GZ_FIRMWARE_SIZE = os.stat(gzip_file).st_size
|
||||
# create string with location and file names based on variant
|
||||
bin_file = "{}firmware{}{}.bin".format(OUTPUT_DIR, os.path.sep, variant)
|
||||
gzip_file = "{}firmware{}{}.bin.gz".format(OUTPUT_DIR, os.path.sep, variant)
|
||||
|
||||
print("Compression reduced firmware size by {:.0f}% (was {} bytes, now {} bytes)".format((GZ_FIRMWARE_SIZE / ORG_FIRMWARE_SIZE) * 100, ORG_FIRMWARE_SIZE, GZ_FIRMWARE_SIZE))
|
||||
# check if new target files exist and remove if necessary
|
||||
if os.path.isfile(gzip_file): os.remove(gzip_file)
|
||||
|
||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_gzip])
|
||||
# write gzip firmware file
|
||||
with open(bin_file,"rb") as fp:
|
||||
with gzip.open(gzip_file, "wb", compresslevel = 9) as f:
|
||||
shutil.copyfileobj(fp, f)
|
||||
|
||||
ORG_FIRMWARE_SIZE = os.stat(bin_file).st_size
|
||||
GZ_FIRMWARE_SIZE = os.stat(gzip_file).st_size
|
||||
|
||||
print("Compression reduced firmware size by {:.0f}% (was {} bytes, now {} bytes)".format((GZ_FIRMWARE_SIZE / ORG_FIRMWARE_SIZE) * 100, ORG_FIRMWARE_SIZE, GZ_FIRMWARE_SIZE))
|
||||
|
||||
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", [bin_gzip])
|
||||
|
@ -165,7 +165,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-release_v3.3-solo1-4b325f52e.tar.gz
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/raw/framework-arduinoespressif32/framework-arduinoespressif32-solo1-release_v3.3-7e63061fa.tar.gz
|
||||
platformio/tool-mklittlefs @ ~1.203.200522
|
||||
platformio/tool-esptoolpy @ ~1.30000.0
|
||||
build_unflags = ${esp32_defaults.build_unflags}
|
||||
|
@ -92,7 +92,7 @@ build_flags = ${esp_defaults.build_flags}
|
||||
|
||||
[core32]
|
||||
platform = espressif32 @ 2.1.0
|
||||
platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/arduino-esp32/releases/download/1.0.5-rc4/esp32-1.0.5-rc4.zip
|
||||
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}
|
||||
build_flags = ${esp32_defaults.build_flags}
|
||||
|
@ -812,10 +812,10 @@ void SettingsDefaultSet2(void)
|
||||
flag3.use_wifi_rescan |= WIFI_SCAN_REGULARLY;
|
||||
Settings.wifi_output_power = 170;
|
||||
Settings.param[P_ARP_GRATUITOUS] = WIFI_ARP_INTERVAL;
|
||||
ParseIPv4(&Settings.ipv4_address[0], WIFI_IP_ADDRESS);
|
||||
ParseIPv4(&Settings.ipv4_address[1], WIFI_GATEWAY);
|
||||
ParseIPv4(&Settings.ipv4_address[2], WIFI_SUBNETMASK);
|
||||
ParseIPv4(&Settings.ipv4_address[3], WIFI_DNS);
|
||||
ParseIPv4(&Settings.ipv4_address[0], PSTR(WIFI_IP_ADDRESS));
|
||||
ParseIPv4(&Settings.ipv4_address[1], PSTR(WIFI_GATEWAY));
|
||||
ParseIPv4(&Settings.ipv4_address[2], PSTR(WIFI_SUBNETMASK));
|
||||
ParseIPv4(&Settings.ipv4_address[3], PSTR(WIFI_DNS));
|
||||
Settings.sta_config = WIFI_CONFIG_TOOL;
|
||||
// Settings.sta_active = 0;
|
||||
SettingsUpdateText(SET_STASSID1, PSTR(STA_SSID1));
|
||||
@ -865,22 +865,22 @@ void SettingsDefaultSet2(void)
|
||||
flag3.grouptopic_mode |= MQTT_GROUPTOPIC_FORMAT;
|
||||
SettingsUpdateText(SET_MQTT_HOST, MQTT_HOST);
|
||||
Settings.mqtt_port = MQTT_PORT;
|
||||
SettingsUpdateText(SET_MQTT_CLIENT, MQTT_CLIENT_ID);
|
||||
SettingsUpdateText(SET_MQTT_USER, MQTT_USER);
|
||||
SettingsUpdateText(SET_MQTT_PWD, MQTT_PASS);
|
||||
SettingsUpdateText(SET_MQTT_TOPIC, MQTT_TOPIC);
|
||||
SettingsUpdateText(SET_MQTT_BUTTON_TOPIC, MQTT_BUTTON_TOPIC);
|
||||
SettingsUpdateText(SET_MQTT_SWITCH_TOPIC, MQTT_SWITCH_TOPIC);
|
||||
SettingsUpdateText(SET_MQTT_GRP_TOPIC, MQTT_GRPTOPIC);
|
||||
SettingsUpdateText(SET_MQTT_FULLTOPIC, MQTT_FULLTOPIC);
|
||||
SettingsUpdateText(SET_MQTT_CLIENT, PSTR(MQTT_CLIENT_ID));
|
||||
SettingsUpdateText(SET_MQTT_USER, PSTR(MQTT_USER));
|
||||
SettingsUpdateText(SET_MQTT_PWD, PSTR(MQTT_PASS));
|
||||
SettingsUpdateText(SET_MQTT_TOPIC, PSTR(MQTT_TOPIC));
|
||||
SettingsUpdateText(SET_MQTT_BUTTON_TOPIC, PSTR(MQTT_BUTTON_TOPIC));
|
||||
SettingsUpdateText(SET_MQTT_SWITCH_TOPIC, PSTR(MQTT_SWITCH_TOPIC));
|
||||
SettingsUpdateText(SET_MQTT_GRP_TOPIC, PSTR(MQTT_GRPTOPIC));
|
||||
SettingsUpdateText(SET_MQTT_FULLTOPIC, PSTR(MQTT_FULLTOPIC));
|
||||
Settings.mqtt_retry = MQTT_RETRY_SECS;
|
||||
SettingsUpdateText(SET_MQTTPREFIX1, SUB_PREFIX);
|
||||
SettingsUpdateText(SET_MQTTPREFIX2, PUB_PREFIX);
|
||||
SettingsUpdateText(SET_MQTTPREFIX3, PUB_PREFIX2);
|
||||
SettingsUpdateText(SET_STATE_TXT1, MQTT_STATUS_OFF);
|
||||
SettingsUpdateText(SET_STATE_TXT2, MQTT_STATUS_ON);
|
||||
SettingsUpdateText(SET_STATE_TXT3, MQTT_CMND_TOGGLE);
|
||||
SettingsUpdateText(SET_STATE_TXT4, MQTT_CMND_HOLD);
|
||||
SettingsUpdateText(SET_MQTTPREFIX1, PSTR(SUB_PREFIX));
|
||||
SettingsUpdateText(SET_MQTTPREFIX2, PSTR(PUB_PREFIX));
|
||||
SettingsUpdateText(SET_MQTTPREFIX3, PSTR(PUB_PREFIX2));
|
||||
SettingsUpdateText(SET_STATE_TXT1, PSTR(MQTT_STATUS_OFF));
|
||||
SettingsUpdateText(SET_STATE_TXT2, PSTR(MQTT_STATUS_ON));
|
||||
SettingsUpdateText(SET_STATE_TXT3, PSTR(MQTT_CMND_TOGGLE));
|
||||
SettingsUpdateText(SET_STATE_TXT4, PSTR(MQTT_CMND_HOLD));
|
||||
memcpy_P(Settings.mqtt_fingerprint[0], default_fingerprint1, sizeof(default_fingerprint1));
|
||||
memcpy_P(Settings.mqtt_fingerprint[1], default_fingerprint2, sizeof(default_fingerprint2));
|
||||
Settings.tele_period = TELE_PERIOD;
|
||||
|
@ -384,7 +384,7 @@ char* Uint64toHex(uint64_t value, char *str, uint16_t bits)
|
||||
char* dtostrfd(double number, unsigned char prec, char *s)
|
||||
{
|
||||
if ((isnan(number)) || (isinf(number))) { // Fix for JSON output (https://stackoverflow.com/questions/1423081/json-left-out-infinity-and-nan-json-status-in-ecmascript)
|
||||
strcpy(s, "null");
|
||||
strcpy_P(s, PSTR("null"));
|
||||
return s;
|
||||
} else {
|
||||
return dtostrf(number, 1, prec, s);
|
||||
@ -659,10 +659,14 @@ bool ValidIpAddress(const char* str)
|
||||
return ip_address.fromString(str);
|
||||
}
|
||||
|
||||
bool ParseIPv4(uint32_t* addr, const char* str)
|
||||
|
||||
bool ParseIPv4(uint32_t* addr, const char* str_p)
|
||||
{
|
||||
uint8_t *part = (uint8_t*)addr;
|
||||
uint8_t i;
|
||||
char str_r[strlen_P(str_p)+1];
|
||||
char * str = &str_r[0];
|
||||
strcpy_P(str, str_p);
|
||||
|
||||
*addr = 0;
|
||||
for (i = 0; i < 4; i++) {
|
||||
@ -859,7 +863,7 @@ float ConvertPressureForSeaLevel(float pressure)
|
||||
|
||||
String PressureUnit(void)
|
||||
{
|
||||
return (Settings.flag.pressure_conversion) ? String(D_UNIT_MILLIMETER_MERCURY) : String(D_UNIT_PRESSURE);
|
||||
return (Settings.flag.pressure_conversion) ? String(F(D_UNIT_MILLIMETER_MERCURY)) : String(F(D_UNIT_PRESSURE));
|
||||
}
|
||||
|
||||
float ConvertSpeed(float s)
|
||||
@ -1022,11 +1026,11 @@ String GetSerialConfig(void) {
|
||||
// b00000x00 - 1 or 2 stop bits
|
||||
// b000xx000 - None, Even or Odd parity
|
||||
|
||||
const char kParity[] = "NEOI";
|
||||
const static char kParity[] PROGMEM = "NEOI";
|
||||
|
||||
char config[4];
|
||||
config[0] = '5' + (Settings.serial_config & 0x3);
|
||||
config[1] = kParity[(Settings.serial_config >> 3) & 0x3];
|
||||
config[1] = pgm_read_byte(&kParity[(Settings.serial_config >> 3) & 0x3]);
|
||||
config[2] = '1' + ((Settings.serial_config >> 2) & 0x1);
|
||||
config[3] = '\0';
|
||||
return String(config);
|
||||
|
@ -110,7 +110,7 @@ void ResponseCmndStateText(uint32_t value)
|
||||
|
||||
void ResponseCmndDone(void)
|
||||
{
|
||||
ResponseCmndChar(D_JSON_DONE);
|
||||
ResponseCmndChar(PSTR(D_JSON_DONE));
|
||||
}
|
||||
|
||||
void ResponseCmndIdxChar(const char* value)
|
||||
@ -352,7 +352,7 @@ void CmndBacklog(void)
|
||||
#else
|
||||
TasmotaGlobal.backlog_pointer = TasmotaGlobal.backlog_index;
|
||||
#endif
|
||||
ResponseCmndChar(blflag ? D_JSON_EMPTY : D_JSON_ABORTED);
|
||||
ResponseCmndChar(blflag ? PSTR(D_JSON_EMPTY) : PSTR(D_JSON_ABORTED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1282,7 +1282,7 @@ void CmndTemplate(void)
|
||||
if (Settings.module != USER_MODULE) {
|
||||
ModuleDefault(Settings.module);
|
||||
}
|
||||
SettingsUpdateText(SET_TEMPLATE_NAME, "Merged");
|
||||
SettingsUpdateText(SET_TEMPLATE_NAME, PSTR("Merged"));
|
||||
uint32_t j = 0;
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(Settings.user_template.gp.io); i++) {
|
||||
if (6 == i) { j = 9; }
|
||||
|
@ -38,7 +38,7 @@ void StartMdns(void) {
|
||||
// mdns_delayed_start = Settings.param[P_MDNS_DELAYED_START];
|
||||
MDNS.end(); // close existing or MDNS.begin will fail
|
||||
Mdns.begun = (uint8_t)MDNS.begin(TasmotaGlobal.hostname);
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS "%s"), (Mdns.begun) ? D_INITIALIZED : D_FAILED);
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS "%s"), (Mdns.begun) ? PSTR(D_INITIALIZED) : PSTR(D_FAILED));
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ const uint32_t MINS_PER_HOUR = 60UL;
|
||||
|
||||
Ticker TickerRtc;
|
||||
|
||||
static const uint8_t kDaysInMonth[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; // API starts months from 1, this array starts from 0
|
||||
static const char kMonthNamesEnglish[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
|
||||
static const uint8_t kDaysInMonth[] PROGMEM = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; // API starts months from 1, this array starts from 0
|
||||
static const char kMonthNamesEnglish[] PROGMEM = "JanFebMarAprMayJunJulAugSepOctNovDec";
|
||||
|
||||
struct RTC {
|
||||
uint32_t utc_time = 0;
|
||||
@ -88,7 +88,9 @@ String GetBuildDateAndTime(void)
|
||||
// "2017-03-07T11:08:02" - ISO8601:2004
|
||||
char bdt[21];
|
||||
char *p;
|
||||
char mdate[] = __DATE__; // "Mar 7 2017"
|
||||
static const char mdate_P[] PROGMEM = __DATE__; // "Mar 7 2017"
|
||||
char mdate[strlen_P(mdate_P)+1]; // copy on stack first
|
||||
strcpy_P(mdate, mdate_P);
|
||||
char *smonth = mdate;
|
||||
int day = 0;
|
||||
int year = 0;
|
||||
@ -107,8 +109,10 @@ String GetBuildDateAndTime(void)
|
||||
year = atoi(str);
|
||||
}
|
||||
}
|
||||
int month = (strstr(kMonthNamesEnglish, smonth) -kMonthNamesEnglish) /3 +1;
|
||||
snprintf_P(bdt, sizeof(bdt), PSTR("%d" D_YEAR_MONTH_SEPARATOR "%02d" D_MONTH_DAY_SEPARATOR "%02d" D_DATE_TIME_SEPARATOR "%s"), year, month, day, __TIME__);
|
||||
char MonthNamesEnglish[sizeof(kMonthNamesEnglish)];
|
||||
strcpy_P(MonthNamesEnglish, kMonthNamesEnglish);
|
||||
int month = (strstr(MonthNamesEnglish, smonth) -MonthNamesEnglish) /3 +1;
|
||||
snprintf_P(bdt, sizeof(bdt), PSTR("%d" D_YEAR_MONTH_SEPARATOR "%02d" D_MONTH_DAY_SEPARATOR "%02d" D_DATE_TIME_SEPARATOR "%s"), year, month, day, PSTR(__TIME__));
|
||||
return String(bdt); // 2017-03-07T11:08:02
|
||||
}
|
||||
|
||||
@ -290,7 +294,7 @@ void BreakTime(uint32_t time_input, TIME_T &tm)
|
||||
month_length = 28;
|
||||
}
|
||||
} else {
|
||||
month_length = kDaysInMonth[month];
|
||||
month_length = pgm_read_byte(&kDaysInMonth[month]);
|
||||
}
|
||||
|
||||
if (time >= month_length) {
|
||||
@ -326,7 +330,7 @@ uint32_t MakeTime(TIME_T &tm)
|
||||
if ((2 == i) && LEAP_YEAR(tm.year)) {
|
||||
seconds += SECS_PER_DAY * 29;
|
||||
} else {
|
||||
seconds += SECS_PER_DAY * kDaysInMonth[i-1]; // monthDay array starts from 0
|
||||
seconds += SECS_PER_DAY * pgm_read_byte(&kDaysInMonth[i-1]); // monthDay array starts from 0
|
||||
}
|
||||
}
|
||||
seconds+= (tm.day_of_month - 1) * SECS_PER_DAY;
|
||||
|
@ -20,10 +20,12 @@
|
||||
const char kSleepMode[] PROGMEM = "Dynamic|Normal";
|
||||
const char kPrefixes[] PROGMEM = D_CMND "|" D_STAT "|" D_TELE;
|
||||
|
||||
char* Format(char* output, const char* input, int size)
|
||||
char* Format(char* output, const char* input_p, int size)
|
||||
{
|
||||
char *token;
|
||||
uint32_t digits = 0;
|
||||
char input[strlen_P(input_p)+1]; // copy from PMEM to RAM
|
||||
strcpy_P(input, input_p);
|
||||
|
||||
if (strchr(input, '%') != nullptr) {
|
||||
strlcpy(output, input, size);
|
||||
@ -102,7 +104,7 @@ char* GetTopic_P(char *stopic, uint32_t prefix, char *topic, const char* subtopi
|
||||
fulltopic += TasmotaGlobal.mqtt_client;
|
||||
fulltopic += F("_fb"); // cmnd/<mqttclient>_fb
|
||||
} else {
|
||||
fulltopic += topic; // cmnd/<grouptopic>
|
||||
fulltopic += (const __FlashStringHelper *)topic; // cmnd/<grouptopic>
|
||||
}
|
||||
} else {
|
||||
fulltopic = SettingsText(SET_MQTT_FULLTOPIC);
|
||||
@ -118,7 +120,7 @@ char* GetTopic_P(char *stopic, uint32_t prefix, char *topic, const char* subtopi
|
||||
}
|
||||
fulltopic.replace(FPSTR(MQTT_TOKEN_PREFIX), SettingsText(SET_MQTTPREFIX1 + prefix));
|
||||
|
||||
fulltopic.replace(FPSTR(MQTT_TOKEN_TOPIC), topic);
|
||||
fulltopic.replace(FPSTR(MQTT_TOKEN_TOPIC), (const __FlashStringHelper *)topic);
|
||||
fulltopic.replace(F("%hostname%"), TasmotaGlobal.hostname);
|
||||
String token_id = WiFi.macAddress();
|
||||
token_id.replace(":", "");
|
||||
@ -486,7 +488,7 @@ bool SendKey(uint32_t key, uint32_t device, uint32_t state)
|
||||
#endif // USE_DOMOTICZ
|
||||
result = !Settings.flag3.button_switch_force_local; // SetOption61 - Force local operation when button/switch topic is set
|
||||
} else {
|
||||
Response_P(PSTR("{\"%s%d\":{\"State\":%d}}"), (key) ? "Switch" : "Button", device, state);
|
||||
Response_P(PSTR("{\"%s%d\":{\"State\":%d}}"), (key) ? PSTR("Switch") : PSTR("Button"), device, state);
|
||||
result = XdrvRulesProcess();
|
||||
}
|
||||
#ifdef USE_PWM_DIMMER
|
||||
@ -742,7 +744,8 @@ void TempHumDewShow(bool json, bool pass_on, const char *types, float f_temperat
|
||||
String GetSwitchText(uint32_t i) {
|
||||
String switch_text = SettingsText(SET_SWITCH_TXT1 + i);
|
||||
if ('\0' == switch_text[0]) {
|
||||
switch_text = D_JSON_SWITCH + String(i +1);
|
||||
switch_text = F(D_JSON_SWITCH);
|
||||
switch_text += String(i+1);
|
||||
}
|
||||
return switch_text;
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ void WiFiSetSleepMode(void)
|
||||
|
||||
void WifiBegin(uint8_t flag, uint8_t channel)
|
||||
{
|
||||
const char kWifiPhyMode[] = " bgnl";
|
||||
const static char kWifiPhyMode[] PROGMEM = " bgnl";
|
||||
|
||||
#ifdef USE_EMULATION
|
||||
UdpDisconnect();
|
||||
@ -218,7 +218,7 @@ void WifiBegin(uint8_t flag, uint8_t channel)
|
||||
WiFi.begin(SettingsText(SET_STASSID1 + Settings.sta_active), SettingsText(SET_STAPWD1 + Settings.sta_active));
|
||||
}
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTING_TO_AP "%d %s%s " D_IN_MODE " 11%c " D_AS " %s..."),
|
||||
Settings.sta_active +1, SettingsText(SET_STASSID1 + Settings.sta_active), stemp, kWifiPhyMode[WiFi.getPhyMode() & 0x3], TasmotaGlobal.hostname);
|
||||
Settings.sta_active +1, SettingsText(SET_STASSID1 + Settings.sta_active), stemp, pgm_read_byte(&kWifiPhyMode[WiFi.getPhyMode() & 0x3]), TasmotaGlobal.hostname);
|
||||
|
||||
#if LWIP_IPV6
|
||||
for (bool configured = false; !configured;) {
|
||||
|
@ -302,7 +302,7 @@ void setup(void) {
|
||||
snprintf_P(TasmotaGlobal.version, sizeof(TasmotaGlobal.version), PSTR("%s.%d"), TasmotaGlobal.version, VERSION & 0xff);
|
||||
}
|
||||
// Thehackbox inserts "release" or "commit number" before compiling using sed -i -e 's/PSTR("(%s)")/PSTR("(85cff52-%s)")/g' tasmota.ino
|
||||
snprintf_P(TasmotaGlobal.image_name, sizeof(TasmotaGlobal.image_name), PSTR("(%s)"), CODE_IMAGE_STR); // Results in (85cff52-tasmota) or (release-tasmota)
|
||||
snprintf_P(TasmotaGlobal.image_name, sizeof(TasmotaGlobal.image_name), PSTR("(%s)"), PSTR(CODE_IMAGE_STR)); // Results in (85cff52-tasmota) or (release-tasmota)
|
||||
|
||||
Format(TasmotaGlobal.mqtt_client, SettingsText(SET_MQTT_CLIENT), sizeof(TasmotaGlobal.mqtt_client));
|
||||
Format(TasmotaGlobal.mqtt_topic, SettingsText(SET_MQTT_TOPIC), sizeof(TasmotaGlobal.mqtt_topic));
|
||||
@ -321,7 +321,7 @@ void setup(void) {
|
||||
SetPowerOnState();
|
||||
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_PROJECT " %s %s " D_VERSION " %s%s-" ARDUINO_CORE_RELEASE "(%s)"),
|
||||
PROJECT, SettingsText(SET_DEVICENAME), TasmotaGlobal.version, TasmotaGlobal.image_name, GetBuildDateAndTime().c_str());
|
||||
PSTR(PROJECT), SettingsText(SET_DEVICENAME), TasmotaGlobal.version, TasmotaGlobal.image_name, GetBuildDateAndTime().c_str());
|
||||
#ifdef FIRMWARE_MINIMAL
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_WARNING_MINIMAL_VERSION));
|
||||
#endif // FIRMWARE_MINIMAL
|
||||
|
@ -57,6 +57,7 @@
|
||||
#define USE_SPI
|
||||
#define USE_DISPLAY // Add SPI Display Support (+2k code)
|
||||
#define USE_DISPLAY_ILI9341 // [DisplayModel 4] Enable ILI9341 Tft 480x320 display (+19k code)
|
||||
#define USE_BLE_ESP32 // Enable new BLE driver
|
||||
#define USE_MI_ESP32 // (ESP32 only) Add support for ESP32 as a BLE-bridge (+9k2 mem, +292k flash)
|
||||
#endif // FIRMWARE_ODROID_GO
|
||||
|
||||
|
@ -376,9 +376,10 @@ struct WEB {
|
||||
} Web;
|
||||
|
||||
// Helper function to avoid code duplication (saves 4k Flash)
|
||||
// arg can be in PROGMEM
|
||||
static void WebGetArg(const char* arg, char* out, size_t max)
|
||||
{
|
||||
String s = Webserver->arg(arg);
|
||||
String s = Webserver->arg((const __FlashStringHelper *)arg);
|
||||
strlcpy(out, s.c_str(), max);
|
||||
// out[max-1] = '\0'; // Ensure terminating NUL
|
||||
}
|
||||
@ -460,7 +461,7 @@ void StartWebserver(int type, IPAddress ipweb)
|
||||
WebServer_on(uri, line.handler, pgm_read_byte(&line.method));
|
||||
}
|
||||
Webserver->onNotFound(HandleNotFound);
|
||||
Webserver->on("/u2", HTTP_POST, HandleUploadDone, HandleUploadLoop); // this call requires 2 functions so we keep a direct call
|
||||
Webserver->on(F("/u2"), HTTP_POST, HandleUploadDone, HandleUploadLoop); // this call requires 2 functions so we keep a direct call
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
XdrvCall(FUNC_WEB_ADD_HANDLER);
|
||||
XsnsCall(FUNC_WEB_ADD_HANDLER);
|
||||
@ -691,7 +692,7 @@ void WSContentStart_P(const char* title, bool auth)
|
||||
WSContentBegin(200, CT_HTML);
|
||||
|
||||
if (title != nullptr) {
|
||||
WSContentSend_P(HTTP_HEADER1, D_HTML_LANGUAGE, SettingsText(SET_DEVICENAME), title);
|
||||
WSContentSend_P(HTTP_HEADER1, PSTR(D_HTML_LANGUAGE), SettingsText(SET_DEVICENAME), title);
|
||||
}
|
||||
}
|
||||
|
||||
@ -767,7 +768,7 @@ void WSContentButton(uint32_t title_index)
|
||||
WSContentSend_P(PSTR("<p><form action='%s' method='get' onsubmit='return confirm(\"%s\");'><button name='%s' class='button bred'>%s</button></form></p>"),
|
||||
GetTextIndexed(action, sizeof(action), title_index, kButtonAction),
|
||||
GetTextIndexed(confirm, sizeof(confirm), title_index, kButtonConfirm),
|
||||
(!title_index) ? "rst" : "non",
|
||||
(!title_index) ? PSTR("rst") : PSTR("non"),
|
||||
GetTextIndexed(title, sizeof(title), title_index, kButtonTitle));
|
||||
} else {
|
||||
WSContentSend_P(PSTR("<p><form action='%s' method='get'><button>%s</button></form></p>"),
|
||||
@ -866,8 +867,8 @@ void HandleWifiLogin(void)
|
||||
void WebSliderColdWarm(void)
|
||||
{
|
||||
WSContentSend_P(HTTP_MSG_SLIDER_GRADIENT, // Cold Warm
|
||||
"a", // a - Unique HTML id
|
||||
"#eff", "#f81", // 6500k in RGB (White) to 2500k in RGB (Warm Yellow)
|
||||
PSTR("a"), // a - Unique HTML id
|
||||
PSTR("#eff"), PSTR("#f81"), // 6500k in RGB (White) to 2500k in RGB (Warm Yellow)
|
||||
1, // sl1
|
||||
153, 500, // Range color temperature
|
||||
LightGetColorTemp(),
|
||||
@ -879,17 +880,17 @@ void HandleRoot(void)
|
||||
{
|
||||
if (CaptivePortal()) { return; } // If captive portal redirect instead of displaying the page.
|
||||
|
||||
if (Webserver->hasArg("rst")) {
|
||||
if (Webserver->hasArg(F("rst"))) {
|
||||
WebRestart(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (WifiIsInManagerMode()) {
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
if (strlen(SettingsText(SET_WEBPWD)) && !(Webserver->hasArg("USER1")) && !(Webserver->hasArg("PASS1")) && HTTP_MANAGER_RESET_ONLY != Web.state) {
|
||||
if (strlen(SettingsText(SET_WEBPWD)) && !(Webserver->hasArg(F("USER1"))) && !(Webserver->hasArg(F("PASS1"))) && HTTP_MANAGER_RESET_ONLY != Web.state) {
|
||||
HandleWifiLogin();
|
||||
} else {
|
||||
if (!strlen(SettingsText(SET_WEBPWD)) || (((Webserver->arg("USER1") == WEB_USERNAME ) && (Webserver->arg("PASS1") == SettingsText(SET_WEBPWD) )) || HTTP_MANAGER_RESET_ONLY == Web.state)) {
|
||||
if (!strlen(SettingsText(SET_WEBPWD)) || (((Webserver->arg(F("USER1")) == WEB_USERNAME ) && (Webserver->arg(F("PASS1")) == SettingsText(SET_WEBPWD) )) || HTTP_MANAGER_RESET_ONLY == Web.state)) {
|
||||
HandleWifiConfiguration();
|
||||
} else {
|
||||
// wrong user and pass
|
||||
@ -936,8 +937,8 @@ void HandleRoot(void)
|
||||
LightGetHSB(&hue, &sat, nullptr);
|
||||
|
||||
WSContentSend_P(HTTP_MSG_SLIDER_GRADIENT, // Hue
|
||||
"b", // b - Unique HTML id
|
||||
"#800", PSTR("#f00 5%,#ff0 20%,#0f0 35%,#0ff 50%,#00f 65%,#f0f 80%,#f00 95%,#800"), // Hue colors
|
||||
PSTR("b"), // b - Unique HTML id
|
||||
PSTR("#800"), PSTR("#f00 5%,#ff0 20%,#0f0 35%,#0ff 50%,#00f 65%,#f0f 80%,#f00 95%,#800"), // Hue colors
|
||||
2, // sl2 - Unique range HTML id - Used as source for Saturation end color
|
||||
1, 359, // Range valid Hue
|
||||
hue,
|
||||
@ -951,7 +952,7 @@ void HandleRoot(void)
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("#%02X%02X%02X"), red, green, blue); // Saturation end color
|
||||
|
||||
WSContentSend_P(HTTP_MSG_SLIDER_GRADIENT, // Saturation
|
||||
"s", // s - Unique HTML id related to eb('s').style.background='linear-gradient(to right,rgb('+sl+'%%,'+sl+'%%,'+sl+'%%),hsl('+eb('sl2').value+',100%%,50%%))';
|
||||
PSTR("s"), // s - Unique HTML id related to eb('s').style.background='linear-gradient(to right,rgb('+sl+'%%,'+sl+'%%,'+sl+'%%),hsl('+eb('sl2').value+',100%%,50%%))';
|
||||
scolor, stemp, // Brightness to max current color
|
||||
3, // sl3 - Unique range HTML id - Not used
|
||||
0, 100, // Range 0 to 100%
|
||||
@ -960,8 +961,8 @@ void HandleRoot(void)
|
||||
}
|
||||
|
||||
WSContentSend_P(HTTP_MSG_SLIDER_GRADIENT, // Brightness - Black to White
|
||||
"c", // c - Unique HTML id
|
||||
"#000", "#fff", // Black to White
|
||||
PSTR("c"), // c - Unique HTML id
|
||||
PSTR("#000"), PSTR("#fff"), // Black to White
|
||||
4, // sl4 - Unique range HTML id - Used as source for Saturation begin color
|
||||
Settings.flag3.slider_dimmer_stay_on, 100, // Range 0/1 to 100% (SetOption77 - Do not power off if slider moved to far left)
|
||||
Settings.light_dimmer,
|
||||
@ -972,8 +973,8 @@ void HandleRoot(void)
|
||||
WebSliderColdWarm();
|
||||
}
|
||||
WSContentSend_P(HTTP_MSG_SLIDER_GRADIENT, // White brightness - Black to White
|
||||
"f", // f - Unique HTML id
|
||||
"#000", "#fff", // Black to White
|
||||
PSTR("f"), // f - Unique HTML id
|
||||
PSTR("#000"), PSTR("#fff"), // Black to White
|
||||
5, // sl5 - Unique range HTML id - Not used
|
||||
Settings.flag3.slider_dimmer_stay_on, 100, // Range 0/1 to 100% (SetOption77 - Do not power off if slider moved to far left)
|
||||
LightGetDimmer(2),
|
||||
@ -987,7 +988,7 @@ void HandleRoot(void)
|
||||
|
||||
WSContentSend_P(HTTP_MSG_SLIDER_GRADIENT, // Channel brightness - Black to White
|
||||
stemp, // e1 to e5 - Unique HTML id
|
||||
"#000", "#fff", // Black to White
|
||||
PSTR("#000"), PSTR("#fff"), // Black to White
|
||||
i+1, // sl1 to sl5 - Unique range HTML id - Not used
|
||||
1, 100, // Range 1 to 100%
|
||||
changeUIntScale(Settings.light_color[i], 0, 255, 0, 100),
|
||||
@ -1008,7 +1009,7 @@ void HandleRoot(void)
|
||||
#ifdef USE_SONOFF_IFAN
|
||||
if (IsModuleIfan()) {
|
||||
WSContentSend_P(HTTP_DEVICE_CONTROL, 36, 1,
|
||||
(strlen(SettingsText(SET_BUTTON1))) ? SettingsText(SET_BUTTON1) : D_BUTTON_TOGGLE,
|
||||
(strlen(SettingsText(SET_BUTTON1))) ? SettingsText(SET_BUTTON1) : PSTR(D_BUTTON_TOGGLE),
|
||||
"");
|
||||
for (uint32_t i = 0; i < MaxFanspeed(); i++) {
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("%d"), i);
|
||||
@ -1031,7 +1032,7 @@ void HandleRoot(void)
|
||||
#endif // USE_SHUTTER
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR(" %d"), idx);
|
||||
WSContentSend_P(HTTP_DEVICE_CONTROL, 100 / TasmotaGlobal.devices_present, idx,
|
||||
(set_button) ? SettingsText(SET_BUTTON1 + idx -1) : (TasmotaGlobal.devices_present < 5) ? D_BUTTON_TOGGLE : "",
|
||||
(set_button) ? SettingsText(SET_BUTTON1 + idx -1) : (TasmotaGlobal.devices_present < 5) ? PSTR(D_BUTTON_TOGGLE) : "",
|
||||
(set_button) ? "" : (TasmotaGlobal.devices_present > 1) ? stemp : "");
|
||||
}
|
||||
#ifdef USE_SONOFF_IFAN
|
||||
@ -1107,7 +1108,7 @@ bool HandleRootStatusRefresh(void)
|
||||
char svalue[32]; // Command and number parameter
|
||||
char webindex[5]; // WebGetArg name
|
||||
|
||||
WebGetArg("o", tmp, sizeof(tmp)); // 1 - 16 Device number for button Toggle or Fanspeed
|
||||
WebGetArg(PSTR("o"), tmp, sizeof(tmp)); // 1 - 16 Device number for button Toggle or Fanspeed
|
||||
if (strlen(tmp)) {
|
||||
ShowWebSource(SRC_WEBGUI);
|
||||
uint32_t device = atoi(tmp);
|
||||
@ -1153,12 +1154,12 @@ bool HandleRootStatusRefresh(void)
|
||||
#endif // USE_TUYA_MCU
|
||||
}
|
||||
#ifdef USE_LIGHT
|
||||
WebGetArg("d0", tmp, sizeof(tmp)); // 0 - 100 Dimmer value
|
||||
WebGetArg(PSTR("d0"), tmp, sizeof(tmp)); // 0 - 100 Dimmer value
|
||||
if (strlen(tmp)) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_DIMMER " %s"), tmp);
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
}
|
||||
WebGetArg("w0", tmp, sizeof(tmp)); // 0 - 100 White value
|
||||
WebGetArg(PSTR("w0"), tmp, sizeof(tmp)); // 0 - 100 White value
|
||||
if (strlen(tmp)) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_WHITE " %s"), tmp);
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
@ -1173,17 +1174,17 @@ bool HandleRootStatusRefresh(void)
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
}
|
||||
}
|
||||
WebGetArg("t0", tmp, sizeof(tmp)); // 153 - 500 Color temperature
|
||||
WebGetArg(PSTR("t0"), tmp, sizeof(tmp)); // 153 - 500 Color temperature
|
||||
if (strlen(tmp)) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_COLORTEMPERATURE " %s"), tmp);
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
}
|
||||
WebGetArg("h0", tmp, sizeof(tmp)); // 0 - 359 Hue value
|
||||
WebGetArg(PSTR("h0"), tmp, sizeof(tmp)); // 0 - 359 Hue value
|
||||
if (strlen(tmp)) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_HSBCOLOR "1 %s"), tmp);
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
}
|
||||
WebGetArg("n0", tmp, sizeof(tmp)); // 0 - 99 Saturation value
|
||||
WebGetArg(PSTR("n0"), tmp, sizeof(tmp)); // 0 - 99 Saturation value
|
||||
if (strlen(tmp)) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_HSBCOLOR "2 %s"), tmp);
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
@ -1200,19 +1201,19 @@ bool HandleRootStatusRefresh(void)
|
||||
}
|
||||
#endif // USE_SHUTTER
|
||||
#ifdef USE_SONOFF_RF
|
||||
WebGetArg("k", tmp, sizeof(tmp)); // 1 - 16 Pre defined RF keys
|
||||
WebGetArg(PSTR("k"), tmp, sizeof(tmp)); // 1 - 16 Pre defined RF keys
|
||||
if (strlen(tmp)) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_RFKEY "%s"), tmp);
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
}
|
||||
#endif // USE_SONOFF_RF
|
||||
#ifdef USE_ZIGBEE
|
||||
WebGetArg("zbj", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("zbj"), tmp, sizeof(tmp));
|
||||
if (strlen(tmp)) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("ZbPermitJoin"));
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
}
|
||||
WebGetArg("zbr", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("zbr"), tmp, sizeof(tmp));
|
||||
if (strlen(tmp)) {
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("ZbMap"));
|
||||
ExecuteWebCommand(svalue, SRC_WEBGUI);
|
||||
@ -1315,7 +1316,7 @@ void WSContentSendNiceLists(uint32_t option) {
|
||||
char stemp[30]; // Template number and Sensor name
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(kGpioNiceList); i++) { // GPIO: }2'0'>None (0)}3}2'17'>Button1 (17)}3...
|
||||
if (option && (1 == i)) {
|
||||
WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE_NO_INDEX, AGPIO(GPIO_USER), D_SENSOR_USER); // }2'255'>User}3
|
||||
WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE_NO_INDEX, AGPIO(GPIO_USER), PSTR(D_SENSOR_USER)); // }2'255'>User}3
|
||||
}
|
||||
uint32_t ridx = pgm_read_word(kGpioNiceList + i) & 0xFFE0;
|
||||
uint32_t midx = BGPIO(ridx);
|
||||
@ -1356,7 +1357,7 @@ void WSContentSendAdcNiceList(uint32_t option) {
|
||||
WSContentSend_P(PSTR("os=\""));
|
||||
for (uint32_t i = 0; i < ARRAY_SIZE(kAdcNiceList); i++) { // GPIO: }2'0'>None}3}2'17'>Analog}3...
|
||||
if (option && (1 == i)) {
|
||||
WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE_NO_INDEX, AGPIO(GPIO_USER), D_SENSOR_USER); // }2'15'>User}3
|
||||
WSContentSend_P(HTTP_MODULE_TEMPLATE_REPLACE_NO_INDEX, AGPIO(GPIO_USER), PSTR(D_SENSOR_USER)); // }2'15'>User}3
|
||||
}
|
||||
uint32_t ridx = pgm_read_word(kAdcNiceList + i) & 0xFFE0;
|
||||
uint32_t midx = BGPIO(ridx);
|
||||
@ -1372,7 +1373,7 @@ void HandleTemplateConfiguration(void)
|
||||
{
|
||||
if (!HttpCheckPriviledgedAccess()) { return; }
|
||||
|
||||
if (Webserver->hasArg("save")) {
|
||||
if (Webserver->hasArg(F("save"))) {
|
||||
TemplateSaveSettings();
|
||||
WebRestart(1);
|
||||
return;
|
||||
@ -1380,7 +1381,7 @@ void HandleTemplateConfiguration(void)
|
||||
|
||||
char stemp[30]; // Template number and Sensor name
|
||||
|
||||
WebGetArg("t", stemp, sizeof(stemp)); // 0 - 69 Template number
|
||||
WebGetArg(PSTR("t"), stemp, sizeof(stemp)); // 0 - 69 Template number
|
||||
if (strlen(stemp)) {
|
||||
uint32_t module = atoi(stemp);
|
||||
uint32_t module_save = Settings.module;
|
||||
@ -1474,7 +1475,7 @@ void TemplateSaveSettings(void)
|
||||
char tmp[TOPSZ]; // WebGetArg NAME and GPIO/BASE/FLAG byte value
|
||||
char svalue[300]; // Template command string
|
||||
|
||||
WebGetArg("s1", tmp, sizeof(tmp)); // NAME
|
||||
WebGetArg(PSTR("s1"), tmp, sizeof(tmp)); // NAME
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR(D_CMND_TEMPLATE " {\"" D_JSON_NAME "\":\"%s\",\"" D_JSON_GPIO "\":["), tmp);
|
||||
|
||||
uint32_t j = 0;
|
||||
@ -1492,7 +1493,7 @@ void TemplateSaveSettings(void)
|
||||
uint32_t state = Webserver->hasArg(webindex) << i; // FLAG
|
||||
flag += state;
|
||||
}
|
||||
WebGetArg("g99", tmp, sizeof(tmp)); // BASE
|
||||
WebGetArg(PSTR("g99"), tmp, sizeof(tmp)); // BASE
|
||||
uint32_t base = atoi(tmp) +1;
|
||||
|
||||
snprintf_P(svalue, sizeof(svalue), PSTR("%s],\"" D_JSON_FLAG "\":%d,\"" D_JSON_BASE "\":%d}"), svalue, flag, base);
|
||||
@ -1505,7 +1506,7 @@ void HandleModuleConfiguration(void)
|
||||
{
|
||||
if (!HttpCheckPriviledgedAccess()) { return; }
|
||||
|
||||
if (Webserver->hasArg("save")) {
|
||||
if (Webserver->hasArg(F("save"))) {
|
||||
ModuleSaveSettings();
|
||||
WebRestart(1);
|
||||
return;
|
||||
@ -1572,7 +1573,7 @@ void ModuleSaveSettings(void)
|
||||
{
|
||||
char tmp[8]; // WebGetArg numbers only
|
||||
|
||||
WebGetArg("g99", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("g99"), tmp, sizeof(tmp));
|
||||
uint32_t new_module = (!strlen(tmp)) ? MODULE : atoi(tmp);
|
||||
Settings.last_module = Settings.module;
|
||||
Settings.module = new_module;
|
||||
@ -1624,7 +1625,7 @@ void HandleWifiConfiguration(void)
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_WIFI));
|
||||
|
||||
if (Webserver->hasArg("save") && HTTP_MANAGER_RESET_ONLY != Web.state) {
|
||||
if (Webserver->hasArg(F("save")) && HTTP_MANAGER_RESET_ONLY != Web.state) {
|
||||
WifiSaveSettings();
|
||||
WebRestart(2);
|
||||
return;
|
||||
@ -1639,7 +1640,7 @@ void HandleWifiConfiguration(void)
|
||||
#endif // USE_ENHANCED_GUI_WIFI_SCAN
|
||||
|
||||
if (HTTP_MANAGER_RESET_ONLY != Web.state) {
|
||||
if (Webserver->hasArg("scan")) {
|
||||
if (Webserver->hasArg(F("scan"))) {
|
||||
#ifdef USE_EMULATION
|
||||
UdpDisconnect();
|
||||
#endif // USE_EMULATION
|
||||
@ -1776,20 +1777,20 @@ void WifiSaveSettings(void)
|
||||
{
|
||||
char tmp[TOPSZ]; // Max length is currently 150
|
||||
|
||||
WebGetArg("h", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("h"), tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_HOSTNAME, (!strlen(tmp)) ? WIFI_HOSTNAME : tmp);
|
||||
if (strchr(SettingsText(SET_HOSTNAME), '%') != nullptr) {
|
||||
SettingsUpdateText(SET_HOSTNAME, WIFI_HOSTNAME);
|
||||
}
|
||||
WebGetArg("c", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("c"), tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_CORS, (!strlen(tmp)) ? CORS_DOMAIN : tmp);
|
||||
WebGetArg("s1", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("s1"), tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_STASSID1, (!strlen(tmp)) ? STA_SSID1 : tmp);
|
||||
WebGetArg("s2", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("s2"), tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_STASSID2, (!strlen(tmp)) ? STA_SSID2 : tmp);
|
||||
WebGetArg("p1", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("p1"), tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_STAPWD1, (!strlen(tmp)) ? "" : (strlen(tmp) < 5) ? SettingsText(SET_STAPWD1) : tmp);
|
||||
WebGetArg("p2", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("p2"), tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_STAPWD2, (!strlen(tmp)) ? "" : (strlen(tmp) < 5) ? SettingsText(SET_STAPWD2) : tmp);
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CMND_HOSTNAME " %s, " D_CMND_SSID "1 %s, " D_CMND_SSID "2 %s, " D_CMND_CORS " %s"),
|
||||
SettingsText(SET_HOSTNAME), SettingsText(SET_STASSID1), SettingsText(SET_STASSID2), SettingsText(SET_CORS));
|
||||
@ -1839,19 +1840,19 @@ void LoggingSaveSettings(void)
|
||||
{
|
||||
char tmp[TOPSZ]; // Max length is currently 33
|
||||
|
||||
WebGetArg("l0", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("l0"), tmp, sizeof(tmp));
|
||||
SetSeriallog((!strlen(tmp)) ? SERIAL_LOG_LEVEL : atoi(tmp));
|
||||
WebGetArg("l1", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("l1"), tmp, sizeof(tmp));
|
||||
Settings.weblog_level = (!strlen(tmp)) ? WEB_LOG_LEVEL : atoi(tmp);
|
||||
WebGetArg("l2", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("l2"), tmp, sizeof(tmp));
|
||||
Settings.mqttlog_level = (!strlen(tmp)) ? MQTT_LOG_LEVEL : atoi(tmp);
|
||||
WebGetArg("l3", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("l3"), tmp, sizeof(tmp));
|
||||
SetSyslog((!strlen(tmp)) ? SYS_LOG_LEVEL : atoi(tmp));
|
||||
WebGetArg("lh", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("lh"), tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_SYSLOG_HOST, (!strlen(tmp)) ? SYS_LOG_HOST : tmp);
|
||||
WebGetArg("lp", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("lp"), tmp, sizeof(tmp));
|
||||
Settings.syslog_port = (!strlen(tmp)) ? SYS_LOG_PORT : atoi(tmp);
|
||||
WebGetArg("lt", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("lt"), tmp, sizeof(tmp));
|
||||
Settings.tele_period = (!strlen(tmp)) ? TELE_PERIOD : atoi(tmp);
|
||||
if ((Settings.tele_period > 0) && (Settings.tele_period < 10)) {
|
||||
Settings.tele_period = 10; // Do not allow periods < 10 seconds
|
||||
@ -1868,7 +1869,7 @@ void HandleOtherConfiguration(void)
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_OTHER));
|
||||
|
||||
if (Webserver->hasArg("save")) {
|
||||
if (Webserver->hasArg(F("save"))) {
|
||||
OtherSaveSettings();
|
||||
WebRestart(1);
|
||||
return;
|
||||
@ -1932,15 +1933,15 @@ void OtherSaveSettings(void)
|
||||
char friendlyname[TOPSZ];
|
||||
char message[MAX_LOGSZ];
|
||||
|
||||
WebGetArg("dn", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("dn"), tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_DEVICENAME, (!strlen(tmp)) ? "" : (!strcmp(tmp,"1")) ? SettingsText(SET_FRIENDLYNAME1) : tmp);
|
||||
WebGetArg("wp", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("wp"), tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_WEBPWD, (!strlen(tmp)) ? "" : (strchr(tmp,'*')) ? SettingsText(SET_WEBPWD) : tmp);
|
||||
Settings.flag.mqtt_enabled = Webserver->hasArg("b1"); // SetOption3 - Enable MQTT
|
||||
Settings.flag.mqtt_enabled = Webserver->hasArg(F("b1")); // SetOption3 - Enable MQTT
|
||||
#ifdef USE_EMULATION
|
||||
UdpDisconnect();
|
||||
#if defined(USE_EMULATION_WEMO) || defined(USE_EMULATION_HUE)
|
||||
WebGetArg("b2", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("b2"), tmp, sizeof(tmp));
|
||||
Settings.flag2.emulation = (!strlen(tmp)) ? 0 : atoi(tmp);
|
||||
#endif // USE_EMULATION_WEMO || USE_EMULATION_HUE
|
||||
#endif // USE_EMULATION
|
||||
@ -1951,14 +1952,14 @@ void OtherSaveSettings(void)
|
||||
snprintf_P(webindex, sizeof(webindex), PSTR("a%d"), i);
|
||||
WebGetArg(webindex, tmp, sizeof(tmp));
|
||||
snprintf_P(friendlyname, sizeof(friendlyname), PSTR(FRIENDLY_NAME"%d"), i +1);
|
||||
SettingsUpdateText(SET_FRIENDLYNAME1 +i, (!strlen(tmp)) ? (i) ? friendlyname : FRIENDLY_NAME : tmp);
|
||||
SettingsUpdateText(SET_FRIENDLYNAME1 +i, (!strlen(tmp)) ? (i) ? friendlyname : PSTR(FRIENDLY_NAME) : tmp);
|
||||
snprintf_P(message, sizeof(message), PSTR("%s%s %s"), message, (i) ? "," : "", SettingsText(SET_FRIENDLYNAME1 +i));
|
||||
}
|
||||
AddLogData(LOG_LEVEL_INFO, message);
|
||||
|
||||
WebGetArg("t1", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("t1"), tmp, sizeof(tmp));
|
||||
if (strlen(tmp)) { // {"NAME":"12345678901234","GPIO":[255,255,255,255,255,255,255,255,255,255,255,255,255],"FLAG":255,"BASE":255}
|
||||
snprintf_P(message, sizeof(message), PSTR(D_CMND_BACKLOG " " D_CMND_TEMPLATE " %s%s"), tmp, (Webserver->hasArg("t2")) ? "; " D_CMND_MODULE " 0" : "");
|
||||
snprintf_P(message, sizeof(message), PSTR(D_CMND_BACKLOG " " D_CMND_TEMPLATE " %s%s"), tmp, (Webserver->hasArg(F("t2"))) ? PSTR("; " D_CMND_MODULE " 0") : "");
|
||||
ExecuteWebCommand(message, SRC_WEBGUI);
|
||||
}
|
||||
}
|
||||
@ -2034,7 +2035,7 @@ void HandleRestoreConfiguration(void)
|
||||
WSContentStart_P(PSTR(D_RESTORE_CONFIGURATION));
|
||||
WSContentSendStyle();
|
||||
WSContentSend_P(HTTP_FORM_RST);
|
||||
WSContentSend_P(HTTP_FORM_RST_UPG, D_RESTORE);
|
||||
WSContentSend_P(HTTP_FORM_RST_UPG, PSTR(D_RESTORE));
|
||||
if (WifiIsInManagerMode()) {
|
||||
WSContentSpaceButton(BUTTON_MAIN);
|
||||
} else {
|
||||
@ -2126,7 +2127,7 @@ void HandleInformation(void)
|
||||
WSContentSend_P(PSTR("}1" D_MQTT_PORT "}2%d"), Settings.mqtt_port);
|
||||
#ifdef USE_MQTT_TLS
|
||||
WSContentSend_P(PSTR("}1" D_MQTT_TLS_ENABLE "}2%s"), Settings.flag4.mqtt_tls ? PSTR(D_ENABLED) : PSTR(D_DISABLED));
|
||||
#endif // USE_MQTT_TLS
|
||||
#endif // USE_MQTT_TLS
|
||||
WSContentSend_P(PSTR("}1" D_MQTT_USER "}2%s"), SettingsText(SET_MQTT_USER));
|
||||
WSContentSend_P(PSTR("}1" D_MQTT_CLIENT "}2%s"), TasmotaGlobal.mqtt_client);
|
||||
WSContentSend_P(PSTR("}1" D_MQTT_TOPIC "}2%s"), SettingsText(SET_MQTT_TOPIC));
|
||||
@ -2143,14 +2144,13 @@ void HandleInformation(void)
|
||||
} else {
|
||||
WSContentSend_P(PSTR("}1" D_MQTT "}2" D_DISABLED));
|
||||
}
|
||||
WSContentSend_P(PSTR("}1}2 ")); // Empty line
|
||||
|
||||
#if defined(USE_EMULATION) || defined(USE_DISCOVERY)
|
||||
WSContentSend_P(PSTR("}1}2 ")); // Empty line
|
||||
#endif // USE_EMULATION or USE_DISCOVERY
|
||||
#ifdef USE_EMULATION
|
||||
WSContentSend_P(PSTR("}1" D_EMULATION "}2%s"), GetTextIndexed(stopic, sizeof(stopic), Settings.flag2.emulation, kEmulationOptions));
|
||||
#else
|
||||
WSContentSend_P(PSTR("}1" D_EMULATION "}2" D_DISABLED));
|
||||
#endif // USE_EMULATION
|
||||
|
||||
#endif // USE_EMULATION
|
||||
#ifdef USE_DISCOVERY
|
||||
WSContentSend_P(PSTR("}1" D_MDNS_DISCOVERY "}2%s"), (Settings.flag3.mdns_enabled) ? D_ENABLED : D_DISABLED); // SetOption55 - Control mDNS service
|
||||
if (Settings.flag3.mdns_enabled) { // SetOption55 - Control mDNS service
|
||||
@ -2158,11 +2158,9 @@ void HandleInformation(void)
|
||||
WSContentSend_P(PSTR("}1" D_MDNS_ADVERTISE "}2" D_WEB_SERVER));
|
||||
#else
|
||||
WSContentSend_P(PSTR("}1" D_MDNS_ADVERTISE "}2" D_DISABLED));
|
||||
#endif // WEBSERVER_ADVERTISE
|
||||
#endif // WEBSERVER_ADVERTISE
|
||||
}
|
||||
#else
|
||||
WSContentSend_P(PSTR("}1" D_MDNS_DISCOVERY "}2" D_DISABLED));
|
||||
#endif // USE_DISCOVERY
|
||||
#endif // USE_DISCOVERY
|
||||
|
||||
WSContentSend_P(PSTR("}1}2 ")); // Empty line
|
||||
WSContentSend_P(PSTR("}1" D_ESP_CHIP_ID "}2%d"), ESP_getChipId());
|
||||
@ -2249,7 +2247,7 @@ void HandleUpgradeFirmware(void) {
|
||||
WSContentStart_P(PSTR(D_FIRMWARE_UPGRADE));
|
||||
WSContentSendStyle();
|
||||
WSContentSend_P(HTTP_FORM_UPG, SettingsText(SET_OTAURL));
|
||||
WSContentSend_P(HTTP_FORM_RST_UPG, D_UPGRADE);
|
||||
WSContentSend_P(HTTP_FORM_RST_UPG, PSTR(D_UPGRADE));
|
||||
WSContentSpaceButton(BUTTON_MAIN);
|
||||
WSContentStop();
|
||||
|
||||
@ -2265,7 +2263,7 @@ void HandleUpgradeFirmwareStart(void) {
|
||||
WifiConfigCounter();
|
||||
|
||||
char otaurl[TOPSZ];
|
||||
WebGetArg("o", otaurl, sizeof(otaurl));
|
||||
WebGetArg(PSTR("o"), otaurl, sizeof(otaurl));
|
||||
if (strlen(otaurl)) {
|
||||
snprintf_P(command, sizeof(command), PSTR(D_CMND_OTAURL " %s"), otaurl);
|
||||
ExecuteWebCommand(command, SRC_WEBGUI);
|
||||
@ -2343,7 +2341,6 @@ void UploadServices(uint32_t start_service) {
|
||||
if (start_service) {
|
||||
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("UPL: Services enabled"));
|
||||
|
||||
TasmotaGlobal.restart_flag = 0;
|
||||
/*
|
||||
MqttRetryCounter(0);
|
||||
*/
|
||||
@ -2378,7 +2375,6 @@ void UploadServices(uint32_t start_service) {
|
||||
MqttDisconnect();
|
||||
}
|
||||
*/
|
||||
TasmotaGlobal.restart_flag = 120; // Set restart watchdog after 2 minutes
|
||||
}
|
||||
}
|
||||
|
||||
@ -2431,7 +2427,6 @@ void HandleUploadLoop(void) {
|
||||
Web.upload_error = 2;
|
||||
return;
|
||||
}
|
||||
TasmotaGlobal.restart_flag = 0;
|
||||
}
|
||||
#endif // USE_UFILESYS
|
||||
}
|
||||
@ -2668,9 +2663,9 @@ void HandleHttpCommand(void)
|
||||
if (!WebAuthenticate()) {
|
||||
// Prefer authorization via HTTP header (Basic auth), if it fails, use legacy method via GET parameters
|
||||
char tmp1[33];
|
||||
WebGetArg("user", tmp1, sizeof(tmp1));
|
||||
WebGetArg(PSTR("user"), tmp1, sizeof(tmp1));
|
||||
char tmp2[strlen(SettingsText(SET_WEBPWD)) + 1];
|
||||
WebGetArg("password", tmp2, sizeof(tmp2));
|
||||
WebGetArg(PSTR("password"), tmp2, sizeof(tmp2));
|
||||
|
||||
if (!(!strcmp(tmp1, WEB_USERNAME) && !strcmp(tmp2, SettingsText(SET_WEBPWD)))) {
|
||||
WSContentBegin(401, CT_JSON);
|
||||
@ -2681,7 +2676,7 @@ void HandleHttpCommand(void)
|
||||
}
|
||||
|
||||
WSContentBegin(200, CT_JSON);
|
||||
String svalue = Webserver->arg("cmnd");
|
||||
String svalue = Webserver->arg(F("cmnd"));
|
||||
if (svalue.length() && (svalue.length() < MQTT_MAX_PACKET_SIZE)) {
|
||||
uint32_t curridx = TasmotaGlobal.log_buffer_pointer;
|
||||
TasmotaGlobal.templog_level = LOG_LEVEL_INFO;
|
||||
@ -2717,7 +2712,7 @@ void HandleConsole(void)
|
||||
{
|
||||
if (!HttpCheckPriviledgedAccess()) { return; }
|
||||
|
||||
if (Webserver->hasArg("c2")) { // Console refresh requested
|
||||
if (Webserver->hasArg(F("c2"))) { // Console refresh requested
|
||||
HandleConsoleRefresh();
|
||||
return;
|
||||
}
|
||||
@ -2734,14 +2729,14 @@ void HandleConsole(void)
|
||||
|
||||
void HandleConsoleRefresh(void)
|
||||
{
|
||||
String svalue = Webserver->arg("c1");
|
||||
String svalue = Webserver->arg(F("c1"));
|
||||
if (svalue.length() && (svalue.length() < MQTT_MAX_PACKET_SIZE)) {
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "%s"), svalue.c_str());
|
||||
ExecuteWebCommand((char*)svalue.c_str(), SRC_WEBCONSOLE);
|
||||
}
|
||||
|
||||
char stmp[8];
|
||||
WebGetArg("c2", stmp, sizeof(stmp));
|
||||
WebGetArg(PSTR("c2"), stmp, sizeof(stmp));
|
||||
uint32_t index = 0; // Initial start, dump all
|
||||
if (strlen(stmp)) { index = atoi(stmp); }
|
||||
|
||||
@ -2758,7 +2753,7 @@ void HandleConsoleRefresh(void)
|
||||
if (len > sizeof(TasmotaGlobal.mqtt_data) -2) { len = sizeof(TasmotaGlobal.mqtt_data); }
|
||||
char stemp[len +1];
|
||||
strlcpy(stemp, line, len);
|
||||
WSContentSend_P(PSTR("%s%s"), (cflg) ? "\n" : "", stemp);
|
||||
WSContentSend_P(PSTR("%s%s"), (cflg) ? PSTR("\n") : "", stemp);
|
||||
cflg = true;
|
||||
}
|
||||
WSContentSend_P(PSTR("}1"));
|
||||
@ -2776,14 +2771,14 @@ void HandleNotFound(void)
|
||||
#ifdef USE_EMULATION
|
||||
#ifdef USE_EMULATION_HUE
|
||||
String path = Webserver->uri();
|
||||
if ((EMUL_HUE == Settings.flag2.emulation) && (path.startsWith("/api"))) {
|
||||
if ((EMUL_HUE == Settings.flag2.emulation) && (path.startsWith(F("/api")))) {
|
||||
HandleHueApi(&path);
|
||||
} else
|
||||
#endif // USE_EMULATION_HUE
|
||||
#endif // USE_EMULATION
|
||||
{
|
||||
WSContentBegin(404, CT_PLAIN);
|
||||
WSContentSend_P(PSTR(D_FILE_NOT_FOUND "\n\nURI: %s\nMethod: %s\nArguments: %d\n"), Webserver->uri().c_str(), (Webserver->method() == HTTP_GET) ? "GET" : "POST", Webserver->args());
|
||||
WSContentSend_P(PSTR(D_FILE_NOT_FOUND "\n\nURI: %s\nMethod: %s\nArguments: %d\n"), Webserver->uri().c_str(), (Webserver->method() == HTTP_GET) ? PSTR("GET") : PSTR("POST"), Webserver->args());
|
||||
for (uint32_t i = 0; i < Webserver->args(); i++) {
|
||||
WSContentSend_P(PSTR(" %s: %s\n"), Webserver->argName(i).c_str(), Webserver->arg(i).c_str());
|
||||
}
|
||||
@ -2978,7 +2973,7 @@ void CmndWebServer(void)
|
||||
}
|
||||
if (Settings.webserver) {
|
||||
Response_P(PSTR("{\"" D_CMND_WEBSERVER "\":\"" D_JSON_ACTIVE_FOR " %s " D_JSON_ON_DEVICE " %s " D_JSON_WITH_IP_ADDRESS " %s\"}"),
|
||||
(2 == Settings.webserver) ? D_ADMIN : D_USER, NetworkHostname(), NetworkAddress().toString().c_str());
|
||||
(2 == Settings.webserver) ? PSTR(D_ADMIN) : PSTR(D_USER), NetworkHostname(), NetworkAddress().toString().c_str());
|
||||
} else {
|
||||
ResponseCmndStateText(0);
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ void MqttInit(void) {
|
||||
|
||||
// Detect AWS IoT and set default parameters
|
||||
String host = String(SettingsText(SET_MQTT_HOST));
|
||||
if (host.indexOf(".iot.") && host.endsWith(".amazonaws.com")) { // look for ".iot." and ".amazonaws.com" in the domain name
|
||||
if (host.indexOf(F(".iot.")) && host.endsWith(F(".amazonaws.com"))) { // look for ".iot." and ".amazonaws.com" in the domain name
|
||||
Settings.flag4.mqtt_no_retain = true;
|
||||
}
|
||||
|
||||
@ -527,10 +527,10 @@ void MqttConnected(void) {
|
||||
if (Settings.webserver) {
|
||||
#if LWIP_IPV6
|
||||
Response_P(PSTR("{\"" D_JSON_WEBSERVER_MODE "\":\"%s\",\"" D_CMND_HOSTNAME "\":\"%s\",\"" D_CMND_IPADDRESS "\":\"%s\",\"IPv6Address\":\"%s\"}"),
|
||||
(2 == Settings.webserver) ? D_ADMIN : D_USER, NetworkHostname(), NetworkAddress().toString().c_str(), WifiGetIPv6().c_str());
|
||||
(2 == Settings.webserver) ? PSTR(D_ADMIN) : PSTR(D_USER), NetworkHostname(), NetworkAddress().toString().c_str(), WifiGetIPv6().c_str());
|
||||
#else
|
||||
Response_P(PSTR("{\"" D_JSON_WEBSERVER_MODE "\":\"%s\",\"" D_CMND_HOSTNAME "\":\"%s\",\"" D_CMND_IPADDRESS "\":\"%s\"}"),
|
||||
(2 == Settings.webserver) ? D_ADMIN : D_USER, NetworkHostname(), NetworkAddress().toString().c_str());
|
||||
(2 == Settings.webserver) ? PSTR(D_ADMIN) : PSTR(D_USER), NetworkHostname(), NetworkAddress().toString().c_str());
|
||||
#endif // LWIP_IPV6 = 1
|
||||
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_INFO "2"));
|
||||
}
|
||||
@ -787,7 +787,7 @@ void CmndMqttFingerprint(void) {
|
||||
|
||||
void CmndMqttUser(void) {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
SettingsUpdateText(SET_MQTT_USER, (SC_CLEAR == Shortcut()) ? "" : (SC_DEFAULT == Shortcut()) ? MQTT_USER : XdrvMailbox.data);
|
||||
SettingsUpdateText(SET_MQTT_USER, (SC_CLEAR == Shortcut()) ? "" : (SC_DEFAULT == Shortcut()) ? PSTR(MQTT_USER) : XdrvMailbox.data);
|
||||
TasmotaGlobal.restart_flag = 2;
|
||||
}
|
||||
ResponseCmndChar(SettingsText(SET_MQTT_USER));
|
||||
@ -795,7 +795,7 @@ void CmndMqttUser(void) {
|
||||
|
||||
void CmndMqttPassword(void) {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
SettingsUpdateText(SET_MQTT_PWD, (SC_CLEAR == Shortcut()) ? "" : (SC_DEFAULT == Shortcut()) ? MQTT_PASS : XdrvMailbox.data);
|
||||
SettingsUpdateText(SET_MQTT_PWD, (SC_CLEAR == Shortcut()) ? "" : (SC_DEFAULT == Shortcut()) ? PSTR(MQTT_PASS) : XdrvMailbox.data);
|
||||
ResponseCmndChar(SettingsText(SET_MQTT_PWD));
|
||||
TasmotaGlobal.restart_flag = 2;
|
||||
} else {
|
||||
@ -852,7 +852,7 @@ void CmndStateText(void) {
|
||||
|
||||
void CmndMqttClient(void) {
|
||||
if (!XdrvMailbox.grpflg && (XdrvMailbox.data_len > 0)) {
|
||||
SettingsUpdateText(SET_MQTT_CLIENT, (SC_DEFAULT == Shortcut()) ? MQTT_CLIENT_ID : XdrvMailbox.data);
|
||||
SettingsUpdateText(SET_MQTT_CLIENT, (SC_DEFAULT == Shortcut()) ? PSTR(MQTT_CLIENT_ID) : XdrvMailbox.data);
|
||||
TasmotaGlobal.restart_flag = 2;
|
||||
}
|
||||
ResponseCmndChar(SettingsText(SET_MQTT_CLIENT));
|
||||
@ -882,7 +882,7 @@ void CmndPrefix(void) {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
MakeValidMqtt(0, XdrvMailbox.data);
|
||||
SettingsUpdateText(SET_MQTTPREFIX1 + XdrvMailbox.index -1,
|
||||
(SC_DEFAULT == Shortcut()) ? (1==XdrvMailbox.index) ? SUB_PREFIX : (2==XdrvMailbox.index) ? PUB_PREFIX : PUB_PREFIX2 : XdrvMailbox.data);
|
||||
(SC_DEFAULT == Shortcut()) ? (1==XdrvMailbox.index) ? PSTR(SUB_PREFIX) : (2==XdrvMailbox.index) ? PSTR(PUB_PREFIX) : PSTR(PUB_PREFIX2) : XdrvMailbox.data);
|
||||
TasmotaGlobal.restart_flag = 2;
|
||||
}
|
||||
ResponseCmndIdxChar(SettingsText(SET_MQTTPREFIX1 + XdrvMailbox.index -1));
|
||||
@ -918,7 +918,7 @@ void CmndGroupTopic(void) {
|
||||
uint32_t settings_text_index = (1 == XdrvMailbox.index) ? SET_MQTT_GRP_TOPIC : SET_MQTT_GRP_TOPIC2 + XdrvMailbox.index - 2;
|
||||
MakeValidMqtt(0, XdrvMailbox.data);
|
||||
if (!strcmp(XdrvMailbox.data, TasmotaGlobal.mqtt_client)) { SetShortcutDefault(); }
|
||||
SettingsUpdateText(settings_text_index, (SC_CLEAR == Shortcut()) ? "" : (SC_DEFAULT == Shortcut()) ? MQTT_GRPTOPIC : XdrvMailbox.data);
|
||||
SettingsUpdateText(settings_text_index, (SC_CLEAR == Shortcut()) ? "" : (SC_DEFAULT == Shortcut()) ? PSTR(MQTT_GRPTOPIC) : XdrvMailbox.data);
|
||||
|
||||
// Eliminate duplicates, have at least one and fill from index 1
|
||||
char stemp[MAX_GROUP_TOPICS][TOPSZ];
|
||||
@ -940,7 +940,7 @@ void CmndGroupTopic(void) {
|
||||
}
|
||||
}
|
||||
if (0 == read_index) {
|
||||
SettingsUpdateText(SET_MQTT_GRP_TOPIC, MQTT_GRPTOPIC);
|
||||
SettingsUpdateText(SET_MQTT_GRP_TOPIC, PSTR(MQTT_GRPTOPIC));
|
||||
} else {
|
||||
uint32_t write_index = 0;
|
||||
uint32_t real_index = SET_MQTT_GRP_TOPIC;
|
||||
@ -998,7 +998,7 @@ void CmndSwitchTopic(void) {
|
||||
switch (Shortcut()) {
|
||||
case SC_CLEAR: SettingsUpdateText(SET_MQTT_SWITCH_TOPIC, ""); break;
|
||||
case SC_DEFAULT: SettingsUpdateText(SET_MQTT_SWITCH_TOPIC, TasmotaGlobal.mqtt_topic); break;
|
||||
case SC_USER: SettingsUpdateText(SET_MQTT_SWITCH_TOPIC, MQTT_SWITCH_TOPIC); break;
|
||||
case SC_USER: SettingsUpdateText(SET_MQTT_SWITCH_TOPIC, PSTR(MQTT_SWITCH_TOPIC)); break;
|
||||
default: SettingsUpdateText(SET_MQTT_SWITCH_TOPIC, XdrvMailbox.data);
|
||||
}
|
||||
}
|
||||
@ -1266,7 +1266,7 @@ void HandleMqttConfiguration(void)
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_MQTT));
|
||||
|
||||
if (Webserver->hasArg("save")) {
|
||||
if (Webserver->hasArg(F("save"))) {
|
||||
MqttSaveSettings();
|
||||
WebRestart(1);
|
||||
return;
|
||||
@ -1282,11 +1282,11 @@ void HandleMqttConfiguration(void)
|
||||
#ifdef USE_MQTT_TLS
|
||||
Mqtt.mqtt_tls ? PSTR(" checked") : "", // SetOption102 - Enable MQTT TLS
|
||||
#endif // USE_MQTT_TLS
|
||||
Format(str, MQTT_CLIENT_ID, sizeof(str)), MQTT_CLIENT_ID, SettingsText(SET_MQTT_CLIENT));
|
||||
Format(str, PSTR(MQTT_CLIENT_ID), sizeof(str)), PSTR(MQTT_CLIENT_ID), SettingsText(SET_MQTT_CLIENT));
|
||||
WSContentSend_P(HTTP_FORM_MQTT2,
|
||||
(!strlen(SettingsText(SET_MQTT_USER))) ? "0" : SettingsText(SET_MQTT_USER),
|
||||
Format(str, MQTT_TOPIC, sizeof(str)), MQTT_TOPIC, SettingsText(SET_MQTT_TOPIC),
|
||||
MQTT_FULLTOPIC, MQTT_FULLTOPIC, SettingsText(SET_MQTT_FULLTOPIC));
|
||||
Format(str, PSTR(MQTT_TOPIC), sizeof(str)), PSTR(MQTT_TOPIC), SettingsText(SET_MQTT_TOPIC),
|
||||
PSTR(MQTT_FULLTOPIC), PSTR(MQTT_FULLTOPIC), SettingsText(SET_MQTT_FULLTOPIC));
|
||||
WSContentSend_P(HTTP_FORM_END);
|
||||
WSContentSpaceButton(BUTTON_CONFIGURATION);
|
||||
WSContentStop();
|
||||
@ -1298,10 +1298,10 @@ void MqttSaveSettings(void)
|
||||
char stemp[TOPSZ];
|
||||
char stemp2[TOPSZ];
|
||||
|
||||
WebGetArg("mt", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("mt"), tmp, sizeof(tmp));
|
||||
strlcpy(stemp, (!strlen(tmp)) ? MQTT_TOPIC : tmp, sizeof(stemp));
|
||||
MakeValidMqtt(0, stemp);
|
||||
WebGetArg("mf", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("mf"), tmp, sizeof(tmp));
|
||||
strlcpy(stemp2, (!strlen(tmp)) ? MQTT_FULLTOPIC : tmp, sizeof(stemp2));
|
||||
MakeValidMqtt(1, stemp2);
|
||||
if ((strcmp(stemp, SettingsText(SET_MQTT_TOPIC))) || (strcmp(stemp2, SettingsText(SET_MQTT_FULLTOPIC)))) {
|
||||
@ -1310,18 +1310,18 @@ void MqttSaveSettings(void)
|
||||
}
|
||||
SettingsUpdateText(SET_MQTT_TOPIC, stemp);
|
||||
SettingsUpdateText(SET_MQTT_FULLTOPIC, stemp2);
|
||||
WebGetArg("mh", tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_MQTT_HOST, (!strlen(tmp)) ? MQTT_HOST : (!strcmp(tmp,"0")) ? "" : tmp);
|
||||
WebGetArg("ml", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("mh"), tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_MQTT_HOST, (!strlen(tmp)) ? PSTR(MQTT_HOST) : (!strcmp(tmp,"0")) ? "" : tmp);
|
||||
WebGetArg(PSTR("ml"), tmp, sizeof(tmp));
|
||||
Settings.mqtt_port = (!strlen(tmp)) ? MQTT_PORT : atoi(tmp);
|
||||
#ifdef USE_MQTT_TLS
|
||||
Settings.flag4.mqtt_tls = Webserver->hasArg("b3"); // SetOption102 - Enable MQTT TLS
|
||||
Settings.flag4.mqtt_tls = Webserver->hasArg(F("b3")); // SetOption102 - Enable MQTT TLS
|
||||
#endif
|
||||
WebGetArg("mc", tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_MQTT_CLIENT, (!strlen(tmp)) ? MQTT_CLIENT_ID : tmp);
|
||||
WebGetArg("mu", tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_MQTT_USER, (!strlen(tmp)) ? MQTT_USER : (!strcmp(tmp,"0")) ? "" : tmp);
|
||||
WebGetArg("mp", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("mc"), tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_MQTT_CLIENT, (!strlen(tmp)) ? PSTR(MQTT_CLIENT_ID) : tmp);
|
||||
WebGetArg(PSTR("mu"), tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_MQTT_USER, (!strlen(tmp)) ? PSTR(MQTT_USER) : (!strcmp(tmp,"0")) ? "" : tmp);
|
||||
WebGetArg(PSTR("mp"), tmp, sizeof(tmp));
|
||||
SettingsUpdateText(SET_MQTT_PWD, (!strlen(tmp)) ? "" : (!strcmp(tmp, D_ASTERISK_PWD)) ? SettingsText(SET_MQTT_PWD) : tmp);
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_CMND_MQTTHOST " %s, " D_CMND_MQTTPORT " %d, " D_CMND_MQTTCLIENT " %s, " D_CMND_MQTTUSER " %s, " D_CMND_TOPIC " %s, " D_CMND_FULLTOPIC " %s"),
|
||||
SettingsText(SET_MQTT_HOST), Settings.mqtt_port, SettingsText(SET_MQTT_CLIENT), SettingsText(SET_MQTT_USER), SettingsText(SET_MQTT_TOPIC), SettingsText(SET_MQTT_FULLTOPIC));
|
||||
|
@ -2625,7 +2625,7 @@ void CmndWakeup(void)
|
||||
Light.wakeup_active = 3;
|
||||
Settings.light_scheme = LS_WAKEUP;
|
||||
LightPowerOn();
|
||||
ResponseCmndChar(D_JSON_STARTED);
|
||||
ResponseCmndChar(PSTR(D_JSON_STARTED));
|
||||
}
|
||||
|
||||
void CmndColorTemperature(void)
|
||||
|
@ -546,7 +546,7 @@ void HandleDomoticzConfiguration(void) {
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_DOMOTICZ));
|
||||
|
||||
if (Webserver->hasArg("save")) {
|
||||
if (Webserver->hasArg(F("save"))) {
|
||||
DomoticzSaveSettings();
|
||||
WebRestart(1);
|
||||
return;
|
||||
@ -605,7 +605,7 @@ void DomoticzSaveSettings(void) {
|
||||
Settings.domoticz_sensor_idx[i] = (!strlen(tmp)) ? 0 : atoi(tmp);
|
||||
snprintf_P(ssensor_indices, sizeof(ssensor_indices), PSTR("%s%s%d"), ssensor_indices, (strlen(ssensor_indices)) ? "," : "", Settings.domoticz_sensor_idx[i]);
|
||||
}
|
||||
WebGetArg("ut", tmp, sizeof(tmp));
|
||||
WebGetArg(PSTR("ut"), tmp, sizeof(tmp));
|
||||
Settings.domoticz_update_timer = (!strlen(tmp)) ? DOMOTICZ_UPDATE_TIMER : atoi(tmp);
|
||||
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_DOMOTICZ D_CMND_IDX " %d,%d,%d,%d, " D_CMND_KEYIDX " %d,%d,%d,%d, " D_CMND_SWITCHIDX " %d,%d,%d,%d, " D_CMND_SENSORIDX " %s, " D_CMND_UPDATETIMER " %d"),
|
||||
|
@ -841,7 +841,7 @@ void HandleTimerConfiguration(void)
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_CONFIGURE_TIMER));
|
||||
|
||||
if (Webserver->hasArg("save")) {
|
||||
if (Webserver->hasArg(F("save"))) {
|
||||
TimerSaveSettings();
|
||||
HandleConfiguration();
|
||||
return;
|
||||
@ -883,8 +883,8 @@ void TimerSaveSettings(void)
|
||||
char message[32 + (MAX_TIMERS *11)]; // MQT: Timers 0,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000
|
||||
Timer timer;
|
||||
|
||||
Settings.flag3.timers_enable = Webserver->hasArg("e0"); // CMND_TIMERS
|
||||
WebGetArg("t0", tmp, sizeof(tmp));
|
||||
Settings.flag3.timers_enable = Webserver->hasArg(F("e0")); // CMND_TIMERS
|
||||
WebGetArg(PSTR("t0"), tmp, sizeof(tmp));
|
||||
char *p = tmp;
|
||||
snprintf_P(message, sizeof(message), PSTR(D_LOG_MQTT D_CMND_TIMERS " %d"), Settings.flag3.timers_enable); // CMND_TIMERS
|
||||
for (uint32_t i = 0; i < MAX_TIMERS; i++) {
|
||||
|
@ -416,7 +416,7 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all
|
||||
// Step1: Analyse rule
|
||||
String rule_expr = rule; // "TELE-INA219#CURRENT>0.100"
|
||||
if (Rules.teleperiod) {
|
||||
int ppos = rule_expr.indexOf("TELE-"); // "TELE-INA219#CURRENT>0.100" or "INA219#CURRENT>0.100"
|
||||
int ppos = rule_expr.indexOf(F("TELE-")); // "TELE-INA219#CURRENT>0.100" or "INA219#CURRENT>0.100"
|
||||
if (ppos == -1) { return false; } // No pre-amble in rule
|
||||
rule_expr = rule.substring(5); // "INA219#CURRENT>0.100" or "SYSTEM#BOOT"
|
||||
}
|
||||
@ -494,7 +494,7 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all
|
||||
// Step2: Search rule_name
|
||||
int pos;
|
||||
int rule_name_idx = 0;
|
||||
if ((pos = rule_name.indexOf("[")) > 0) { // "SUBTYPE1#CURRENT[1]"
|
||||
if ((pos = rule_name.indexOf(F("["))) > 0) { // "SUBTYPE1#CURRENT[1]"
|
||||
rule_name_idx = rule_name.substring(pos +1).toInt();
|
||||
if ((rule_name_idx < 1) || (rule_name_idx > 6)) { // Allow indexes 1 to 6
|
||||
rule_name_idx = 1;
|
||||
@ -515,7 +515,7 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule, bool stop_all
|
||||
}
|
||||
String subtype;
|
||||
uint32_t i = 0;
|
||||
while ((pos = rule_name.indexOf("#")) > 0) { // "SUBTYPE1#SUBTYPE2#CURRENT"
|
||||
while ((pos = rule_name.indexOf(F("#"))) > 0) { // "SUBTYPE1#SUBTYPE2#CURRENT"
|
||||
subtype = rule_name.substring(0, pos);
|
||||
obj = obj[subtype.c_str()].getObject();
|
||||
if (!obj) { return false; } // not found
|
||||
@ -686,14 +686,14 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
|
||||
|
||||
String rule = rules;
|
||||
rule.toUpperCase(); // "ON INA219#CURRENT>0.100 DO BACKLOG DIMMER 10;COLOR 100000 ENDON"
|
||||
if (!rule.startsWith("ON ")) { return serviced; } // Bad syntax - Nothing to start on
|
||||
if (!rule.startsWith(F("ON "))) { return serviced; } // Bad syntax - Nothing to start on
|
||||
|
||||
int pevt = rule.indexOf(" DO ");
|
||||
int pevt = rule.indexOf(F(" DO "));
|
||||
if (pevt == -1) { return serviced; } // Bad syntax - Nothing to do
|
||||
String event_trigger = rule.substring(3, pevt); // "INA219#CURRENT>0.100"
|
||||
|
||||
plen = rule.indexOf(" ENDON");
|
||||
plen2 = rule.indexOf(" BREAK");
|
||||
plen = rule.indexOf(F(" ENDON"));
|
||||
plen2 = rule.indexOf(F(" BREAK"));
|
||||
if ((plen == -1) && (plen2 == -1)) { return serviced; } // Bad syntax - No ENDON neither BREAK
|
||||
|
||||
if (plen == -1) { plen = 9999; }
|
||||
@ -717,10 +717,10 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
|
||||
|
||||
// if (!ucommand.startsWith("BACKLOG")) { commands = "backlog " + commands; } // Always use Backlog to prevent power race exception
|
||||
// Use Backlog with event to prevent rule event loop exception unless IF is used which uses an implicit backlog
|
||||
if ((ucommand.indexOf("IF ") == -1) &&
|
||||
(ucommand.indexOf("EVENT ") != -1) &&
|
||||
(ucommand.indexOf("BACKLOG ") == -1)) {
|
||||
commands = "backlog " + commands;
|
||||
if ((ucommand.indexOf(F("IF ")) == -1) &&
|
||||
(ucommand.indexOf(F("EVENT ")) != -1) &&
|
||||
(ucommand.indexOf(F("BACKLOG ")) == -1)) {
|
||||
commands = String(F("backlog ")) + commands;
|
||||
}
|
||||
|
||||
RulesVarReplace(commands, F("%VALUE%"), Rules.event_value);
|
||||
|
@ -294,7 +294,7 @@ void NewHAssDiscovery(void)
|
||||
for (uint32_t i = 0; i < MAX_FRIENDLYNAMES; i++) {
|
||||
char fname[TOPSZ];
|
||||
snprintf_P(fname, sizeof(fname), PSTR("\"%s\""), EscapeJSONString(SettingsText(SET_FRIENDLYNAME1 +i)).c_str());
|
||||
snprintf_P(stemp2, sizeof(stemp2), PSTR("%s%s%s"), stemp2, (i > 0 ? "," : ""), (i < maxfn) ? fname : "null");
|
||||
snprintf_P(stemp2, sizeof(stemp2), PSTR("%s%s%s"), stemp2, (i > 0 ? "," : ""), (i < maxfn) ? fname : PSTR("null"));
|
||||
}
|
||||
|
||||
stemp3[0] = '\0';
|
||||
@ -304,7 +304,7 @@ void NewHAssDiscovery(void)
|
||||
char sname[TOPSZ];
|
||||
snprintf_P(sname, sizeof(sname), PSTR("\"%s\""), GetSwitchText(i).c_str());
|
||||
snprintf_P(stemp3, sizeof(stemp3), PSTR("%s%s%d"), stemp3, (i > 0 ? "," : ""), (PinUsed(GPIO_SWT1, i) & Settings.flag5.mqtt_switches) ? Settings.switchmode[i] : -1);
|
||||
snprintf_P(stemp4, sizeof(stemp4), PSTR("%s%s%s"), stemp4, (i > 0 ? "," : ""), (PinUsed(GPIO_SWT1, i) & Settings.flag5.mqtt_switches) ? sname : "null");
|
||||
snprintf_P(stemp4, sizeof(stemp4), PSTR("%s%s%s"), stemp4, (i > 0 ? "," : ""), (PinUsed(GPIO_SWT1, i) & Settings.flag5.mqtt_switches) ? sname : PSTR("null"));
|
||||
}
|
||||
|
||||
stemp5[0] = '\0';
|
||||
@ -338,7 +338,7 @@ void NewHAssDiscovery(void)
|
||||
if (!Settings.flag.hass_discovery) { // HassDiscoveryRelays(relays)
|
||||
Response_P(HASS_DISCOVER_DEVICE, WiFi.localIP().toString().c_str(), SettingsText(SET_DEVICENAME),
|
||||
stemp2, TasmotaGlobal.hostname, unique_id, ModuleName().c_str(), TuyaMod, iFanMod, GetStateText(0), GetStateText(1), GetStateText(2), GetStateText(3),
|
||||
TasmotaGlobal.version, TasmotaGlobal.mqtt_topic, SettingsText(SET_MQTT_FULLTOPIC), SUB_PREFIX, PUB_PREFIX, PUB_PREFIX2, Hass.RelLst, stemp3, stemp4,
|
||||
TasmotaGlobal.version, TasmotaGlobal.mqtt_topic, SettingsText(SET_MQTT_FULLTOPIC), PSTR(SUB_PREFIX), PSTR(PUB_PREFIX), PSTR(PUB_PREFIX2), Hass.RelLst, stemp3, stemp4,
|
||||
stemp5, Settings.flag.mqtt_response, Settings.flag.button_swap, Settings.flag.button_single, Settings.flag.decimal_text, Settings.flag.not_power_linked,
|
||||
Settings.flag.hass_light, Settings.flag3.pwm_multi_channels, Settings.flag3.mqtt_buttons, Settings.flag4.alexa_ct_range, Settings.flag5.mqtt_switches,
|
||||
Settings.flag5.fade_fixed_duration, light_controller.isCTRGBLinked(), Light.subtype, stemp6);
|
||||
|
@ -1295,7 +1295,7 @@ void TuyaSensorsShow(bool json)
|
||||
|
||||
GetTextIndexed(sname, sizeof(sname), (sensor-71), kTuyaSensors);
|
||||
ResponseAppend_P(PSTR("\"%s\":%s"), sname,
|
||||
(Tuya.SensorsValid[sensor-71] ? dtostrfd(Tuya.Sensors[sensor-71], res, tempval) : "null"));
|
||||
(Tuya.SensorsValid[sensor-71] ? dtostrfd(Tuya.Sensors[sensor-71], res, tempval) : PSTR("null")));
|
||||
added = true;
|
||||
}
|
||||
#ifdef USE_WEBSERVER
|
||||
|
@ -429,9 +429,9 @@ void HandleUpnpSetupHue(void)
|
||||
{
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_HTTP D_HUE_BRIDGE_SETUP));
|
||||
String description_xml = Decompress(HUE_DESCRIPTION_XML_COMPRESSED,HUE_DESCRIPTION_XML_SIZE);
|
||||
description_xml.replace("{x1", WiFi.localIP().toString());
|
||||
description_xml.replace("{x2", HueUuid());
|
||||
description_xml.replace("{x3", HueSerialnumber());
|
||||
description_xml.replace(F("{x1"), WiFi.localIP().toString());
|
||||
description_xml.replace(F("{x2"), HueUuid());
|
||||
description_xml.replace(F("{x3"), HueSerialnumber());
|
||||
WSSend(200, CT_XML, description_xml);
|
||||
}
|
||||
|
||||
@ -439,19 +439,19 @@ void HueNotImplemented(String *path)
|
||||
{
|
||||
AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_API_NOT_IMPLEMENTED " (%s)"), path->c_str());
|
||||
|
||||
WSSend(200, CT_JSON, "{}");
|
||||
WSSend(200, CT_JSON, PSTR("{}"));
|
||||
}
|
||||
|
||||
void HueConfigResponse(String *response)
|
||||
{
|
||||
*response += Decompress(HueConfigResponse_JSON, HueConfigResponse_JSON_SIZE);
|
||||
response->replace("{ma", WiFi.macAddress());
|
||||
response->replace("{ip", WiFi.localIP().toString());
|
||||
response->replace("{ms", WiFi.subnetMask().toString());
|
||||
response->replace("{gw", WiFi.gatewayIP().toString());
|
||||
response->replace("{br", HueBridgeId());
|
||||
response->replace("{dt", GetDateAndTime(DT_UTC));
|
||||
response->replace("{id", GetHueUserId());
|
||||
response->replace(F("{ma"), WiFi.macAddress());
|
||||
response->replace(F("{ip"), WiFi.localIP().toString());
|
||||
response->replace(F("{ms"), WiFi.subnetMask().toString());
|
||||
response->replace(F("{gw"), WiFi.gatewayIP().toString());
|
||||
response->replace(F("{br"), HueBridgeId());
|
||||
response->replace(F("{dt"), GetDateAndTime(DT_UTC));
|
||||
response->replace(F("{id"), GetHueUserId());
|
||||
}
|
||||
|
||||
void HueConfig(String *path)
|
||||
@ -534,13 +534,13 @@ void HueLightStatus1(uint8_t device, String *response)
|
||||
char * buf = (char*) malloc(buf_size); // temp buffer for strings, avoid stack
|
||||
UnishoxStrings msg(HUE_LIGHTS);
|
||||
|
||||
snprintf_P(buf, buf_size, PSTR("{\"on\":%s,"), (TasmotaGlobal.power & (1 << (device-1))) ? "true" : "false");
|
||||
snprintf_P(buf, buf_size, PSTR("{\"on\":%s,"), (TasmotaGlobal.power & (1 << (device-1))) ? PSTR("true") : PSTR("false"));
|
||||
// Brightness for all devices with PWM
|
||||
if ((1 == echo_gen) || (LST_SINGLE <= local_light_subtype)) { // force dimmer for 1st gen Echo
|
||||
snprintf_P(buf, buf_size, PSTR("%s\"bri\":%d,"), buf, bri);
|
||||
}
|
||||
if (LST_COLDWARM <= local_light_subtype) {
|
||||
snprintf_P(buf, buf_size, PSTR("%s\"colormode\":\"%s\","), buf, g_gotct ? "ct" : "hs");
|
||||
snprintf_P(buf, buf_size, PSTR("%s\"colormode\":\"%s\","), buf, g_gotct ? PSTR("ct") : PSTR("hs"));
|
||||
}
|
||||
if (LST_RGB <= local_light_subtype) { // colors
|
||||
if (prev_x_str[0] && prev_y_str[0]) {
|
||||
@ -680,7 +680,7 @@ void HueGlobalConfig(String *path) {
|
||||
#endif // USE_ZIGBEE
|
||||
response += F("},\"groups\":{},\"schedules\":{},\"config\":");
|
||||
HueConfigResponse(&response);
|
||||
response += "}";
|
||||
response += F("}");
|
||||
WSSend(200, CT_JSON, response);
|
||||
}
|
||||
|
||||
@ -700,7 +700,7 @@ void CheckHue(String * response, bool &appending) {
|
||||
for (uint32_t i = 1; i <= maxhue; i++) {
|
||||
if (HueActive(i)) {
|
||||
if (appending) { *response += ","; }
|
||||
*response += "\"";
|
||||
*response += F("\"");
|
||||
*response += EncodeLightId(i);
|
||||
*response += F("\":{\"state\":");
|
||||
HueLightStatus1(i, response);
|
||||
@ -735,7 +735,7 @@ void HueLightsCommand(uint8_t device, uint32_t device_id, String &response) {
|
||||
on = hue_on.getBool();
|
||||
snprintf_P(buf, buf_size,
|
||||
msg[HUE_RESP_ON],
|
||||
device_id, on ? "true" : "false");
|
||||
device_id, on ? PSTR("true") : PSTR("false"));
|
||||
|
||||
#ifdef USE_SHUTTER
|
||||
if (ShutterState(device)) {
|
||||
@ -778,7 +778,7 @@ void HueLightsCommand(uint8_t device, uint32_t device_id, String &response) {
|
||||
if (resp) { response += ","; }
|
||||
snprintf_P(buf, buf_size,
|
||||
msg[HUE_RESP_NUM],
|
||||
device_id, "bri", bri);
|
||||
device_id, PSTR("bri"), bri);
|
||||
response += buf;
|
||||
if (LST_SINGLE <= Light.subtype) {
|
||||
// extend bri value if set to max
|
||||
@ -824,7 +824,7 @@ void HueLightsCommand(uint8_t device, uint32_t device_id, String &response) {
|
||||
if (resp) { response += ","; }
|
||||
snprintf_P(buf, buf_size,
|
||||
msg[HUE_RESP_NUM],
|
||||
device_id, "hue", hue);
|
||||
device_id, PSTR("hue"), hue);
|
||||
response += buf;
|
||||
if (LST_RGB <= Light.subtype) {
|
||||
// change range from 0..65535 to 0..360
|
||||
@ -843,7 +843,7 @@ void HueLightsCommand(uint8_t device, uint32_t device_id, String &response) {
|
||||
if (resp) { response += ","; }
|
||||
snprintf_P(buf, buf_size,
|
||||
msg[HUE_RESP_NUM],
|
||||
device_id, "sat", sat);
|
||||
device_id, PSTR("sat"), sat);
|
||||
response += buf;
|
||||
if (LST_RGB <= Light.subtype) {
|
||||
// extend sat value if set to max
|
||||
@ -862,7 +862,7 @@ void HueLightsCommand(uint8_t device, uint32_t device_id, String &response) {
|
||||
if (resp) { response += ","; }
|
||||
snprintf_P(buf, buf_size,
|
||||
msg[HUE_RESP_NUM],
|
||||
device_id, "ct", ct);
|
||||
device_id, PSTR("ct"), ct);
|
||||
response += buf;
|
||||
if ((LST_COLDWARM == Light.subtype) || (LST_RGBW <= Light.subtype)) {
|
||||
g_gotct = true;
|
||||
@ -923,7 +923,7 @@ void HueLights(String *path)
|
||||
|
||||
path->remove(0,path->indexOf(F("/lights"))); // Remove until /lights
|
||||
if (path->endsWith(F("/lights"))) { // Got /lights
|
||||
response = "{";
|
||||
response = F("{");
|
||||
bool appending = false;
|
||||
#ifdef USE_LIGHT
|
||||
CheckHue(&response, appending);
|
||||
@ -934,7 +934,7 @@ void HueLights(String *path)
|
||||
#ifdef USE_SCRIPT_HUE
|
||||
Script_Check_Hue(&response);
|
||||
#endif
|
||||
response += "}";
|
||||
response += F("}");
|
||||
}
|
||||
else if (path->endsWith(F("/state"))) { // Got ID/state
|
||||
path->remove(0,8); // Remove /lights/
|
||||
@ -992,7 +992,7 @@ void HueLights(String *path)
|
||||
#endif // USE_LIGHT
|
||||
}
|
||||
else {
|
||||
response = "{}";
|
||||
response = F("{}");
|
||||
code = 406;
|
||||
}
|
||||
exit:
|
||||
@ -1005,24 +1005,24 @@ void HueGroups(String *path)
|
||||
/*
|
||||
* http://tasmota/api/username/groups?1={"name":"Woonkamer","lights":[],"type":"Room","class":"Living room"})
|
||||
*/
|
||||
String response = "{}";
|
||||
String response(F("{}"));
|
||||
uint8_t maxhue = (TasmotaGlobal.devices_present > MAX_HUE_DEVICES) ? MAX_HUE_DEVICES : TasmotaGlobal.devices_present;
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE " HueGroups (%s)"), path->c_str());
|
||||
|
||||
if (path->endsWith("/0")) {
|
||||
if (path->endsWith(F("/0"))) {
|
||||
UnishoxStrings msg(HUE_LIGHTS);
|
||||
response = msg[HUE_GROUP0_STATUS_JSON];
|
||||
String lights = F("\"1\"");
|
||||
for (uint32_t i = 2; i <= maxhue; i++) {
|
||||
lights += ",\"";
|
||||
lights += F(",\"");
|
||||
lights += EncodeLightId(i);
|
||||
lights += "\"";
|
||||
lights += F("\"");
|
||||
}
|
||||
|
||||
#ifdef USE_ZIGBEE
|
||||
ZigbeeHueGroups(&response);
|
||||
#endif // USE_ZIGBEE
|
||||
response.replace("{l1", lights);
|
||||
response.replace(F("{l1"), lights);
|
||||
#ifdef USE_LIGHT
|
||||
HueLightStatus1(1, &response);
|
||||
#endif // USE_LIGHT
|
||||
|
@ -579,7 +579,7 @@ String Z_attribute::toString(bool prefix_comma) const {
|
||||
// value part
|
||||
switch (type) {
|
||||
case Za_type::Za_none:
|
||||
res += "null";
|
||||
res += F("null");
|
||||
break;
|
||||
case Za_type::Za_bool:
|
||||
res += val.uval32 ? F("true") : F("false");
|
||||
@ -638,7 +638,9 @@ String Z_attribute::toString(bool prefix_comma) const {
|
||||
if (val.arrval) {
|
||||
res += val.arrval->toString();
|
||||
} else {
|
||||
res += "[]";
|
||||
// res += '[';
|
||||
// res += ']';
|
||||
res += F("[]");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ void Z_Device::jsonPublishAttrList(const char * json_prefix, const Z_attribute_l
|
||||
if (Settings.flag5.zb_received_as_subtopic)
|
||||
GetTopic_P(stopic, TELE, subtopic, json_prefix);
|
||||
else
|
||||
GetTopic_P(stopic, TELE, subtopic, D_RSLT_SENSOR);
|
||||
GetTopic_P(stopic, TELE, subtopic, PSTR(D_RSLT_SENSOR));
|
||||
MqttPublish(stopic, Settings.flag.mqtt_sensor_retain);
|
||||
} else {
|
||||
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain);
|
||||
@ -767,7 +767,7 @@ String Z_Devices::dumpCoordinator(void) const {
|
||||
attr_list.addAttributePMEM(PSTR("IEEEAddr")).setHex64(localIEEEAddr);
|
||||
attr_list.addAttributePMEM(PSTR("TotalDevices")).setUInt(zigbee_devices.devicesSize());
|
||||
|
||||
return attr_list.toString();
|
||||
return attr_list.toString(true);
|
||||
}
|
||||
|
||||
// If &device == nullptr, then dump all
|
||||
|
@ -62,13 +62,13 @@ void HueLightStatus1Zigbee(uint16_t shortaddr, uint8_t local_light_subtype, Stri
|
||||
const size_t buf_size = 256;
|
||||
char * buf = (char*) malloc(buf_size); // temp buffer for strings, avoid stack
|
||||
|
||||
snprintf_P(buf, buf_size, PSTR("{\"on\":%s,"), power ? "true" : "false");
|
||||
snprintf_P(buf, buf_size, PSTR("{\"on\":%s,"), power ? PSTR("true") : PSTR("false"));
|
||||
// Brightness for all devices with PWM
|
||||
if ((1 == echo_gen) || (LST_SINGLE <= local_light_subtype)) { // force dimmer for 1st gen Echo
|
||||
snprintf_P(buf, buf_size, PSTR("%s\"bri\":%d,"), buf, bri);
|
||||
}
|
||||
if (LST_COLDWARM <= local_light_subtype) {
|
||||
snprintf_P(buf, buf_size, PSTR("%s\"colormode\":\"%s\","), buf, (0 == colormode) ? "hs" : (1 == colormode) ? "xy" : "ct");
|
||||
snprintf_P(buf, buf_size, PSTR("%s\"colormode\":\"%s\","), buf, (0 == colormode) ? PSTR("hs") : (1 == colormode) ? PSTR("xy") : PSTR("ct"));
|
||||
}
|
||||
if (LST_RGB <= local_light_subtype) { // colors
|
||||
if (prev_x_str[0] && prev_y_str[0]) {
|
||||
@ -83,7 +83,7 @@ void HueLightStatus1Zigbee(uint16_t shortaddr, uint8_t local_light_subtype, Stri
|
||||
if (LST_COLDWARM == local_light_subtype || LST_RGBW <= local_light_subtype) { // white temp
|
||||
snprintf_P(buf, buf_size, PSTR("%s\"ct\":%d,"), buf, ct > 0 ? ct : 284);
|
||||
}
|
||||
snprintf_P(buf, buf_size, HUE_LIGHTS_STATUS_JSON1_SUFFIX_ZIGBEE, buf, reachable ? "true" : "false");
|
||||
snprintf_P(buf, buf_size, HUE_LIGHTS_STATUS_JSON1_SUFFIX_ZIGBEE, buf, reachable ? PSTR("true") : PSTR("false"));
|
||||
|
||||
*response += buf;
|
||||
free(buf);
|
||||
@ -233,7 +233,7 @@ void ZigbeeHandleHue(uint16_t shortaddr, uint32_t device_id, String &response) {
|
||||
on = hue_on.getBool();
|
||||
snprintf_P(buf, buf_size,
|
||||
msg[HUE_RESP_ON],
|
||||
device_id, on ? "true" : "false");
|
||||
device_id, on ? PSTR("true") : PSTR("false"));
|
||||
|
||||
if (on) {
|
||||
ZigbeeHuePower(shortaddr, 0x01);
|
||||
@ -252,7 +252,7 @@ void ZigbeeHandleHue(uint16_t shortaddr, uint32_t device_id, String &response) {
|
||||
if (resp) { response += ","; }
|
||||
snprintf_P(buf, buf_size,
|
||||
msg[HUE_RESP_NUM],
|
||||
device_id, "bri", bri);
|
||||
device_id, PSTR("bri"), bri);
|
||||
response += buf;
|
||||
if (LST_SINGLE <= bulbtype) {
|
||||
// extend bri value if set to max
|
||||
@ -293,7 +293,7 @@ void ZigbeeHandleHue(uint16_t shortaddr, uint32_t device_id, String &response) {
|
||||
if (resp) { response += ","; }
|
||||
snprintf_P(buf, buf_size,
|
||||
msg[HUE_RESP_NUM],
|
||||
device_id, "hue", hue);
|
||||
device_id, PSTR("hue"), hue);
|
||||
response += buf;
|
||||
if (LST_RGB <= bulbtype) {
|
||||
// change range from 0..65535 to 0..360
|
||||
@ -311,7 +311,7 @@ void ZigbeeHandleHue(uint16_t shortaddr, uint32_t device_id, String &response) {
|
||||
if (resp) { response += ","; }
|
||||
snprintf_P(buf, buf_size,
|
||||
msg[HUE_RESP_NUM],
|
||||
device_id, "sat", sat);
|
||||
device_id, PSTR("sat"), sat);
|
||||
response += buf;
|
||||
if (LST_RGB <= bulbtype) {
|
||||
// extend sat value if set to max
|
||||
@ -332,7 +332,7 @@ void ZigbeeHandleHue(uint16_t shortaddr, uint32_t device_id, String &response) {
|
||||
if (resp) { response += ","; }
|
||||
snprintf_P(buf, buf_size,
|
||||
msg[HUE_RESP_NUM],
|
||||
device_id, "ct", ct);
|
||||
device_id, PSTR("ct"), ct);
|
||||
response += buf;
|
||||
if ((LST_COLDWARM == bulbtype) || (LST_RGBW <= bulbtype)) {
|
||||
ZigbeeHueCT(shortaddr, ct);
|
||||
|
@ -1673,6 +1673,27 @@ void ZCLFrame::parseClusterSpecificCommand(Z_attribute_list& attr_list) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Send Default Response to acknowledge the attribute reporting
|
||||
if (0 == _frame_control.b.disable_def_resp) {
|
||||
// the device expects a default response
|
||||
SBuffer buf(2);
|
||||
buf.add8(_cmd_id);
|
||||
buf.add8(0x00); // Status = OK
|
||||
|
||||
ZigbeeZCLSend_Raw(ZigbeeZCLSendMessage({
|
||||
_srcaddr,
|
||||
0x0000,
|
||||
_cluster_id,
|
||||
_srcendpoint,
|
||||
ZCL_DEFAULT_RESPONSE,
|
||||
_manuf_code,
|
||||
false /* not cluster specific */,
|
||||
false /* noresponse */,
|
||||
true /* direct no retry */,
|
||||
_transact_seq, /* zcl transaction id */
|
||||
buf.getBuffer(), buf.len()
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
// ======================================================================
|
||||
|
@ -789,38 +789,38 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = {
|
||||
|
||||
// configure EFR32
|
||||
ZI_MQTT_STATE(ZIGBEE_STATUS_STARTING, kConfiguredCoord)
|
||||
ZI_SEND(ZBS_SET_ADDR_TABLE) ZI_WAIT_RECV(500, ZBR_SET_OK) // Address table size
|
||||
ZI_SEND(ZBS_SET_MCAST_TABLE) ZI_WAIT_RECV(500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_STK_PROF) ZI_WAIT_RECV(500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_SEC_LEVEL) ZI_WAIT_RECV(500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_MAX_DEVICES) ZI_WAIT_RECV(500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_INDIRECT_TMO) ZI_WAIT_RECV(500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_TC_CACHE) ZI_WAIT_RECV(500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_ROUTE_TBL) ZI_WAIT_RECV(500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_KEY_TBL) ZI_WAIT_RECV(500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_PANID_CNFLCT) ZI_WAIT_RECV(500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_ZDO_REQ) ZI_WAIT_RECV(500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_NETWORKS) ZI_WAIT_RECV(500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_PACKET_BUF) ZI_WAIT_RECV(500, ZBR_SET_OK2)
|
||||
ZI_SEND(ZBS_SET_ADDR_TABLE) ZI_WAIT_RECV(2500, ZBR_SET_OK) // Address table size
|
||||
ZI_SEND(ZBS_SET_MCAST_TABLE) ZI_WAIT_RECV(2500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_STK_PROF) ZI_WAIT_RECV(2500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_SEC_LEVEL) ZI_WAIT_RECV(2500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_MAX_DEVICES) ZI_WAIT_RECV(2500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_INDIRECT_TMO) ZI_WAIT_RECV(2500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_TC_CACHE) ZI_WAIT_RECV(2500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_ROUTE_TBL) ZI_WAIT_RECV(2500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_KEY_TBL) ZI_WAIT_RECV(2500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_PANID_CNFLCT) ZI_WAIT_RECV(2500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_ZDO_REQ) ZI_WAIT_RECV(2500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_NETWORKS) ZI_WAIT_RECV(2500, ZBR_SET_OK)
|
||||
ZI_SEND(ZBS_SET_PACKET_BUF) ZI_WAIT_RECV(2500, ZBR_SET_OK2)
|
||||
|
||||
// read configuration
|
||||
// TODO - not sure it's useful
|
||||
//ZI_SEND(ZBS_GET_APS_UNI) ZI_WAIT_RECV_FUNC(500, ZBR_GET_OK, &EZ_ReadAPSUnicastMessage)
|
||||
//ZI_SEND(ZBS_GET_APS_UNI) ZI_WAIT_RECV_FUNC(2500, ZBR_GET_OK, &EZ_ReadAPSUnicastMessage)
|
||||
|
||||
// add endpoint 0x01 and 0x0B
|
||||
ZI_SEND(ZBS_ADD_ENDPOINT1) ZI_WAIT_RECV(500, ZBR_ADD_ENDPOINT)
|
||||
ZI_SEND(ZBS_ADD_ENDPOINTB) ZI_WAIT_RECV(500, ZBR_ADD_ENDPOINT)
|
||||
ZI_SEND(ZBS_ADD_ENDPOINT1) ZI_WAIT_RECV(2500, ZBR_ADD_ENDPOINT)
|
||||
ZI_SEND(ZBS_ADD_ENDPOINTB) ZI_WAIT_RECV(2500, ZBR_ADD_ENDPOINT)
|
||||
|
||||
// set Concentrator
|
||||
ZI_SEND(ZBS_SET_CONCENTRATOR) ZI_WAIT_RECV(500, ZBR_SET_CONCENTRATOR)
|
||||
ZI_SEND(ZBS_SET_CONCENTRATOR) ZI_WAIT_RECV(2500, ZBR_SET_CONCENTRATOR)
|
||||
|
||||
// setInitialSecurityState
|
||||
ZI_SEND(ZBS_SET_POLICY_00) ZI_WAIT_RECV(500, ZBR_SET_POLICY_XX)
|
||||
ZI_SEND(ZBS_SET_POLICY_02) ZI_WAIT_RECV(500, ZBR_SET_POLICY_XX)
|
||||
ZI_SEND(ZBS_SET_POLICY_03) ZI_WAIT_RECV(500, ZBR_SET_POLICY_XX)
|
||||
// ZI_SEND(ZBS_SET_POLICY_04) ZI_WAIT_RECV(500, ZBR_SET_POLICY_XX)
|
||||
ZI_SEND(ZBS_SET_POLICY_05) ZI_WAIT_RECV(500, ZBR_SET_POLICY_XX)
|
||||
ZI_SEND(ZBS_SET_POLICY_06) ZI_WAIT_RECV(500, ZBR_SET_POLICY_XX)
|
||||
ZI_SEND(ZBS_SET_POLICY_00) ZI_WAIT_RECV(2500, ZBR_SET_POLICY_XX)
|
||||
ZI_SEND(ZBS_SET_POLICY_02) ZI_WAIT_RECV(2500, ZBR_SET_POLICY_XX)
|
||||
ZI_SEND(ZBS_SET_POLICY_03) ZI_WAIT_RECV(2500, ZBR_SET_POLICY_XX)
|
||||
// ZI_SEND(ZBS_SET_POLICY_04) ZI_WAIT_RECV(2500, ZBR_SET_POLICY_XX)
|
||||
ZI_SEND(ZBS_SET_POLICY_05) ZI_WAIT_RECV(2500, ZBR_SET_POLICY_XX)
|
||||
ZI_SEND(ZBS_SET_POLICY_06) ZI_WAIT_RECV(2500, ZBR_SET_POLICY_XX)
|
||||
|
||||
// Decide whether we try 'networkInit()' to restore configuration, or create a new network
|
||||
ZI_CALL(&EZ_GotoIfResetConfig, ZIGBEE_LABEL_CONFIGURE_EZSP) // goto ZIGBEE_LABEL_CONFIGURE_EZSP if reset_config is set
|
||||
@ -830,12 +830,12 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = {
|
||||
// Try networkInit to restore settings, and check if network comes up
|
||||
ZI_ON_TIMEOUT_GOTO(ZIGBEE_LABEL_BAD_CONFIG) //
|
||||
ZI_ON_ERROR_GOTO(ZIGBEE_LABEL_BAD_CONFIG)
|
||||
ZI_SEND(ZBS_NETWORK_INIT) ZI_WAIT_RECV(500, ZBR_NETWORK_INIT)
|
||||
ZI_SEND(ZBS_NETWORK_INIT) ZI_WAIT_RECV(2500, ZBR_NETWORK_INIT)
|
||||
ZI_WAIT_RECV(1500, ZBR_NETWORK_UP) // wait for network to start
|
||||
// check if configuration is ok
|
||||
ZI_SEND(ZBS_GET_KEY_NWK) ZI_WAIT_RECV_FUNC(500, ZBR_GET_KEY_NWK, &EZ_CheckKeyNWK)
|
||||
ZI_SEND(ZBS_GET_EUI64) ZI_WAIT_RECV_FUNC(500, ZBR_GET_EUI64, &EZ_GetEUI64)
|
||||
ZI_SEND(ZBS_GET_NETW_PARM) ZI_WAIT_RECV_FUNC(500, ZBR_CHECK_NETW_PARM, &EZ_NetworkParameters)
|
||||
ZI_SEND(ZBS_GET_KEY_NWK) ZI_WAIT_RECV_FUNC(2500, ZBR_GET_KEY_NWK, &EZ_CheckKeyNWK)
|
||||
ZI_SEND(ZBS_GET_EUI64) ZI_WAIT_RECV_FUNC(2500, ZBR_GET_EUI64, &EZ_GetEUI64)
|
||||
ZI_SEND(ZBS_GET_NETW_PARM) ZI_WAIT_RECV_FUNC(2500, ZBR_CHECK_NETW_PARM, &EZ_NetworkParameters)
|
||||
|
||||
// all ok, proceed to next step
|
||||
ZI_GOTO(ZIGBEE_LABEL_NETWORK_CONFIGURED)
|
||||
@ -851,9 +851,9 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = {
|
||||
ZI_ON_TIMEOUT_GOTO(ZIGBEE_LABEL_ABORT)
|
||||
ZI_ON_ERROR_GOTO(ZIGBEE_LABEL_ABORT)
|
||||
// set encryption keys
|
||||
ZI_SEND(ZBS_SET_SECURITY) ZI_WAIT_RECV(500, ZBR_SET_SECURITY)
|
||||
ZI_SEND(ZBS_SET_SECURITY) ZI_WAIT_RECV(2500, ZBR_SET_SECURITY)
|
||||
// formNetwork
|
||||
ZI_SEND(ZBS_FORM_NETWORK) ZI_WAIT_RECV(500, ZBR_FORM_NETWORK)
|
||||
ZI_SEND(ZBS_FORM_NETWORK) ZI_WAIT_RECV(2500, ZBR_FORM_NETWORK)
|
||||
ZI_WAIT_RECV(5000, ZBR_NETWORK_UP) // wait for network to start
|
||||
|
||||
ZI_LABEL(ZIGBEE_LABEL_NETWORK_CONFIGURED)
|
||||
@ -861,11 +861,11 @@ static const Zigbee_Instruction zb_prog[] PROGMEM = {
|
||||
ZI_ON_TIMEOUT_GOTO(ZIGBEE_LABEL_ABORT)
|
||||
ZI_ON_ERROR_GOTO(ZIGBEE_LABEL_ABORT)
|
||||
// Query device information
|
||||
ZI_SEND(ZBS_GET_EUI64) ZI_WAIT_RECV_FUNC(500, ZBR_GET_EUI64, &EZ_GetEUI64)
|
||||
ZI_SEND(ZBS_GET_NODEID) ZI_WAIT_RECV_FUNC(500, ZBR_GET_NODEID, &EZ_GetNodeId)
|
||||
ZI_SEND(ZBS_GET_EUI64) ZI_WAIT_RECV_FUNC(2500, ZBR_GET_EUI64, &EZ_GetEUI64)
|
||||
ZI_SEND(ZBS_GET_NODEID) ZI_WAIT_RECV_FUNC(2500, ZBR_GET_NODEID, &EZ_GetNodeId)
|
||||
// auto-register multicast group 0x0000
|
||||
ZI_LOG(LOG_LEVEL_INFO, kZigbeeGroup0)
|
||||
ZI_SEND(ZBS_SET_MCAST_ENTRY) ZI_WAIT_RECV(500, ZBR_SET_MCAST_ENTRY)
|
||||
ZI_SEND(ZBS_SET_MCAST_ENTRY) ZI_WAIT_RECV(2500, ZBR_SET_MCAST_ENTRY)
|
||||
|
||||
// ZI_LABEL(ZIGBEE_LABEL_READY)
|
||||
ZI_MQTT_STATE(ZIGBEE_STATUS_OK, kStarted)
|
||||
|
@ -81,6 +81,13 @@ char ZigbeeUploadFlashRead(void) {
|
||||
ZbUpload.byte_counter++;
|
||||
|
||||
if (ZbUpload.byte_counter > ZbUpload.ota_size) {
|
||||
|
||||
// static bool padding = true;
|
||||
// if (padding) {
|
||||
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Start padding from %d"), ZbUpload.byte_counter);
|
||||
// padding = false;
|
||||
// }
|
||||
|
||||
// When the source device reaches the last XModem data block, it should be padded to 128 bytes
|
||||
// of data using SUB (ASCII 0x1A) characters.
|
||||
data = XM_SUB;
|
||||
@ -107,8 +114,8 @@ struct XMODEM {
|
||||
uint32_t delay = 0;
|
||||
uint32_t flush_delay = 0xFFFFFFFF;
|
||||
uint32_t filepos = 0;
|
||||
uint32_t packet_no = 1;
|
||||
int crcBuf = 0;
|
||||
uint8_t packetNo = 1;
|
||||
uint8_t checksumBuf = 0;
|
||||
bool oldChecksum;
|
||||
} XModem;
|
||||
@ -142,6 +149,11 @@ char XModemWaitACK(void)
|
||||
if (i > 200) { return -1; }
|
||||
}
|
||||
in_char = ZigbeeSerial->read();
|
||||
|
||||
// if (in_char != XM_ACK) {
|
||||
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("XMD: Rcvd3 0x%02X"), in_char);
|
||||
// }
|
||||
|
||||
if (XM_CAN == in_char) { return XM_CAN; }
|
||||
} while ((in_char != XM_NAK) && (in_char != XM_ACK) && (in_char != 'C'));
|
||||
return in_char;
|
||||
@ -162,10 +174,12 @@ bool XModemSendPacket(uint32_t packet_no) {
|
||||
XModem.checksumBuf = 0x00;
|
||||
XModem.crcBuf = 0x00;
|
||||
|
||||
uint8_t packet_num = packet_no;
|
||||
|
||||
// Try to send packet, so header first
|
||||
ZigbeeSerial->write(XM_SOH);
|
||||
ZigbeeSerial->write(packet_no);
|
||||
ZigbeeSerial->write(~packet_no);
|
||||
ZigbeeSerial->write(packet_num);
|
||||
ZigbeeSerial->write(~packet_num);
|
||||
for (uint32_t i = 0; i < XMODEM_PACKET_SIZE; i++) {
|
||||
in_char = ZigbeeUploadFlashRead();
|
||||
XModemOutputByte(in_char);
|
||||
@ -220,6 +234,13 @@ bool ZigbeeUploadBootloaderPrompt(void) {
|
||||
yield();
|
||||
char bootloader_byte = ZigbeeSerial->read();
|
||||
|
||||
// [cr][lf]
|
||||
// Gecko Bootloader v1.A.3 or Gecko Bootloader v1.9.1.04[cr][lf]
|
||||
// 1. upload gbl[cr][lf]
|
||||
// 2. run[cr][lf]
|
||||
// 3. ebl info[cr][lf]
|
||||
// BL >
|
||||
|
||||
if (((uint8_t)bootloader_byte >=0) && (buf_len < sizeof(serial_buffer) -2)) {
|
||||
serial_buffer[buf_len++] = bootloader_byte;
|
||||
}
|
||||
@ -332,17 +353,18 @@ bool ZigbeeUploadXmodem(void) {
|
||||
}
|
||||
} else {
|
||||
// After the bootloader receives a carriage return from the target device, it displays a menu
|
||||
// Gecko Bootloader v1.A.3
|
||||
// 1. upload gbl
|
||||
// 2. run
|
||||
// 3. ebl info
|
||||
// [cr][lf]
|
||||
// Gecko Bootloader v1.A.3 or Gecko Bootloader v1.9.1.04[cr][lf]
|
||||
// 1. upload gbl[cr][lf]
|
||||
// 2. run[cr][lf]
|
||||
// 3. ebl info[cr][lf]
|
||||
// BL >
|
||||
if (ZigbeeUploadBootloaderPrompt()) {
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Init sync"));
|
||||
ZigbeeSerial->flush();
|
||||
ZigbeeSerial->write('1'); // upload ebl
|
||||
if (TasmotaGlobal.sleep > 0) {
|
||||
TasmotaGlobal.sleep = 1; // Speed up loop used for xmodem upload
|
||||
TasmotaGlobal.sleep = 1; // Speed up loop used for xmodem upload
|
||||
}
|
||||
XModem.timeout = millis() + (XMODEM_SYNC_TIMEOUT * 1000);
|
||||
ZbUpload.ota_step = ZBU_SYNC;
|
||||
@ -358,11 +380,17 @@ bool ZigbeeUploadXmodem(void) {
|
||||
}
|
||||
// Wait for either C or NACK as a sync packet. Determines protocol details, checksum algorithm.
|
||||
if (ZigbeeSerial->available()) {
|
||||
// [cr][lf]
|
||||
// begin upload[cr][lf]
|
||||
// C
|
||||
char xmodem_sync = ZigbeeSerial->read();
|
||||
|
||||
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("XMD: Rcvd2 0x%02X"), xmodem_sync);
|
||||
|
||||
if (('C' == xmodem_sync) || (XM_NAK == xmodem_sync)) {
|
||||
// Determine which checksum algorithm to use
|
||||
XModem.oldChecksum = (xmodem_sync == XM_NAK);
|
||||
XModem.packetNo = 1;
|
||||
XModem.packet_no = 1;
|
||||
ZbUpload.byte_counter = 0;
|
||||
ZbUpload.ota_step = ZBU_UPLOAD;
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Init packet send"));
|
||||
@ -372,12 +400,15 @@ bool ZigbeeUploadXmodem(void) {
|
||||
}
|
||||
case ZBU_UPLOAD: { // *** Handle file upload using XModem - upload
|
||||
if (ZigbeeUploadAvailable()) {
|
||||
if (!XModemSendPacket(XModem.packetNo)) {
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Packet send failed"));
|
||||
if (ZbUpload.byte_counter && !(ZbUpload.byte_counter % 10240)) { // Show progress every 10kB
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Progress %d kB"), ZbUpload.byte_counter / 1024);
|
||||
}
|
||||
if (!XModemSendPacket(XModem.packet_no)) {
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Packet %d send failed"), XModem.packet_no);
|
||||
ZbUpload.ota_step = ZBU_ERROR;
|
||||
return true;
|
||||
}
|
||||
XModem.packetNo++;
|
||||
XModem.packet_no++;
|
||||
} else {
|
||||
// Once the last block is ACKed by the target, the transfer should be finalized by an
|
||||
// EOT (ASCII 0x04) packet from the source. Once this packet is confirmed via XModem ACK
|
||||
@ -385,6 +416,7 @@ bool ZigbeeUploadXmodem(void) {
|
||||
ZigbeeSerial->write(XM_EOT);
|
||||
XModem.timeout = millis() + (30 * 1000); // Allow 30 seconds to receive EOT ACK
|
||||
ZbUpload.ota_step = ZBU_EOT;
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Transferred %d bytes"), ZbUpload.ota_size);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -401,7 +433,12 @@ bool ZigbeeUploadXmodem(void) {
|
||||
}
|
||||
if (ZigbeeSerial->available()) {
|
||||
char xmodem_ack = XModemWaitACK();
|
||||
if (XM_ACK == xmodem_ack) {
|
||||
if (XM_CAN == xmodem_ack) {
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: Transfer invalid"));
|
||||
ZbUpload.ota_step = ZBU_ERROR;
|
||||
return true;
|
||||
}
|
||||
else if (XM_ACK == xmodem_ack) {
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: " D_SUCCESSFUL));
|
||||
XModem.timeout = millis() + (30 * 1000); // Allow 30 seconds to receive EBL prompt
|
||||
ZbUpload.byte_counter = 0;
|
||||
@ -418,28 +455,33 @@ bool ZigbeeUploadXmodem(void) {
|
||||
} else {
|
||||
// After an image successfully uploads, the XModem transaction completes and the bootloader displays
|
||||
// ‘Serial upload complete’ before redisplaying the menu
|
||||
// Serial upload complete
|
||||
// Gecko Bootloader v1.A.3
|
||||
// 1. upload gbl
|
||||
// 2. run
|
||||
// 3. ebl info
|
||||
//
|
||||
// [cr][lf]
|
||||
// Serial upload complete[cr][lf]
|
||||
// [cr][lf]
|
||||
// Gecko Bootloader v1.A.3 or Gecko Bootloader v1.9.1.04[cr][lf]
|
||||
// 1. upload gbl[cr][lf]
|
||||
// 2. run[cr][lf]
|
||||
// 3. ebl info[cr][lf]
|
||||
// BL >
|
||||
if (ZigbeeUploadBootloaderPrompt()) {
|
||||
ZbUpload.state = ZBU_COMPLETE;
|
||||
ZbUpload.ota_step = ZBU_DONE;
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: " D_RESTARTING));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ZBU_ERROR:
|
||||
ZbUpload.state = ZBU_ERROR;
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: " D_FAILED));
|
||||
case ZBU_DONE: { // *** Clean up and restart to disable bootloader and use new firmware
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("XMD: " D_RESTARTING));
|
||||
ZigbeeUploadSetBootloader(1); // Disable bootloader and reset MCU - should happen at restart
|
||||
if (1 == TasmotaGlobal.sleep) {
|
||||
TasmotaGlobal.sleep = Settings.sleep; // Restore loop sleep
|
||||
}
|
||||
// TasmotaGlobal.restart_flag = 2; // Restart to disable bootloader and use new firmware
|
||||
if (ZbUpload.buffer) { free(ZbUpload.buffer); }
|
||||
ZbUpload.ota_step = ZBU_FINISH; // Never return to zero without a restart to get a sane Zigbee environment
|
||||
break;
|
||||
}
|
||||
@ -472,10 +514,6 @@ void ZigbeeUploadStep1Done(uint32_t data, size_t size) {
|
||||
ZbUpload.state = ZBU_UPLOAD; // Signal upload done and ready for delayed upload to MCU EFR32
|
||||
}
|
||||
|
||||
bool ZigbeeUploadFinish(void) {
|
||||
return (ZBU_FINISH == ZbUpload.ota_step);
|
||||
}
|
||||
|
||||
#define WEB_HANDLE_ZIGBEE_XFER "zx"
|
||||
|
||||
const char HTTP_SCRIPT_XFER_STATE[] PROGMEM =
|
||||
@ -500,12 +538,12 @@ void HandleZigbeeXfer(void) {
|
||||
if (!HttpCheckPriviledgedAccess()) { return; }
|
||||
|
||||
if (Webserver->hasArg("z")) { // Status refresh requested
|
||||
WSContentBegin(200, CT_PLAIN);
|
||||
WSContentSend_P(PSTR("%d"), ZbUpload.state);
|
||||
WSContentEnd();
|
||||
if (ZBU_ERROR == ZbUpload.state) {
|
||||
Web.upload_error = 7; // Upload aborted (xmodem transfer failed)
|
||||
}
|
||||
WSContentBegin(200, CT_PLAIN);
|
||||
WSContentSend_P(PSTR("%d"), ZbUpload.state);
|
||||
WSContentEnd();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2092,7 +2092,7 @@ void ZigbeeMapRefresh(void) {
|
||||
if ((!zigbee.init_phase) && (!zigbee.mapping_in_progress)) {
|
||||
ZigbeeMapAllDevices();
|
||||
}
|
||||
Webserver->sendHeader("Location","/zbm"); // Add a header to respond with a new location for the browser to go to the home page again
|
||||
Webserver->sendHeader(F("Location"),F("/zbm")); // Add a header to respond with a new location for the browser to go to the home page again
|
||||
Webserver->send(302);
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ void PingResponsePoll(void) {
|
||||
",\"AvgTime\":%d"
|
||||
"}}}"),
|
||||
ping->hostname.c_str(),
|
||||
success ? "true" : "false",
|
||||
success ? PSTR("true") : PSTR("false"),
|
||||
ip & 0xFF, (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, ip >> 24,
|
||||
success,
|
||||
ping->timeout_count,
|
||||
|
@ -434,14 +434,14 @@ void CmndTmChatId(void) {
|
||||
|
||||
void CmndTmSend(void) {
|
||||
if (!Telegram.send_enable || !strlen(SettingsText(SET_TELEGRAM_CHATID))) {
|
||||
ResponseCmndChar(D_JSON_FAILED);
|
||||
ResponseCmndChar(PSTR(D_JSON_FAILED));
|
||||
return;
|
||||
}
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
String message = XdrvMailbox.data;
|
||||
String chat_id = SettingsText(SET_TELEGRAM_CHATID);
|
||||
if (!TelegramSendMessage(chat_id.toInt(), message)) {
|
||||
ResponseCmndChar(D_JSON_FAILED);
|
||||
ResponseCmndChar(PSTR(D_JSON_FAILED));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ void UFSDelete(void) {
|
||||
result = (ufs_type && ufsp->remove(XdrvMailbox.data));
|
||||
}
|
||||
if (!result) {
|
||||
ResponseCmndChar(D_JSON_FAILED);
|
||||
ResponseCmndChar(PSTR(D_JSON_FAILED));
|
||||
} else {
|
||||
ResponseCmndDone();
|
||||
}
|
||||
@ -454,8 +454,8 @@ void UfsDirectory(void) {
|
||||
|
||||
strcpy(ufs_path, "/");
|
||||
|
||||
if (Webserver->hasArg("download")) {
|
||||
String stmp = Webserver->arg("download");
|
||||
if (Webserver->hasArg(F("download"))) {
|
||||
String stmp = Webserver->arg(F("download"));
|
||||
char *cp = (char*)stmp.c_str();
|
||||
if (UfsDownloadFile(cp)) {
|
||||
// is directory
|
||||
@ -465,8 +465,8 @@ void UfsDirectory(void) {
|
||||
}
|
||||
}
|
||||
|
||||
if (Webserver->hasArg("dir")) {
|
||||
String stmp = Webserver->arg("dir");
|
||||
if (Webserver->hasArg(F("dir"))) {
|
||||
String stmp = Webserver->arg(F("dir"));
|
||||
ufs_dir = atoi(stmp.c_str());
|
||||
if (ufs_dir == 1) {
|
||||
dfsp = ufsp;
|
||||
@ -477,8 +477,8 @@ void UfsDirectory(void) {
|
||||
}
|
||||
}
|
||||
|
||||
if (Webserver->hasArg("delete")) {
|
||||
String stmp = Webserver->arg("delete");
|
||||
if (Webserver->hasArg(F("delete"))) {
|
||||
String stmp = Webserver->arg(F("delete"));
|
||||
char *cp = (char*)stmp.c_str();
|
||||
dfsp->remove(cp);
|
||||
}
|
||||
@ -498,7 +498,7 @@ void UfsDirectory(void) {
|
||||
}
|
||||
WSContentSend_P(UFS_FORM_FILE_UPGc2);
|
||||
|
||||
WSContentSend_P(UFS_FORM_FILE_UPG, D_SCRIPT_UPLOAD);
|
||||
WSContentSend_P(UFS_FORM_FILE_UPG, PSTR(D_SCRIPT_UPLOAD));
|
||||
|
||||
WSContentSend_P(UFS_FORM_SDC_DIRa);
|
||||
if (ufs_type) {
|
||||
@ -516,7 +516,7 @@ void UfsListDir(char *path, uint8_t depth) {
|
||||
char name[32];
|
||||
char npath[128];
|
||||
char format[12];
|
||||
sprintf(format, "%%-%ds", 24 - depth);
|
||||
sprintf(format, PSTR("%%-%ds"), 24 - depth);
|
||||
|
||||
File dir = dfsp->open(path, UFS_FILE_READ);
|
||||
if (dir) {
|
||||
@ -533,7 +533,7 @@ void UfsListDir(char *path, uint8_t depth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
WSContentSend_P(UFS_FORM_SDC_DIRd, npath, path, "..");
|
||||
WSContentSend_P(UFS_FORM_SDC_DIRd, npath, path, PSTR(".."));
|
||||
}
|
||||
char *ep;
|
||||
while (true) {
|
||||
@ -764,13 +764,13 @@ bool Xdrv50(uint8_t function) {
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_WEB_ADD_MANAGEMENT_BUTTON:
|
||||
if (ufs_type) {
|
||||
WSContentSend_PD(UFS_WEB_DIR, D_MANAGE_FILE_SYSTEM);
|
||||
WSContentSend_PD(UFS_WEB_DIR, PSTR(D_MANAGE_FILE_SYSTEM));
|
||||
}
|
||||
break;
|
||||
case FUNC_WEB_ADD_HANDLER:
|
||||
Webserver->on("/ufsd", UfsDirectory);
|
||||
Webserver->on("/ufsu", HTTP_GET, UfsDirectory);
|
||||
Webserver->on("/ufsu", HTTP_POST,[](){Webserver->sendHeader("Location","/ufsu");Webserver->send(303);}, HandleUploadLoop);
|
||||
Webserver->on(F("/ufsd"), UfsDirectory);
|
||||
Webserver->on(F("/ufsu"), HTTP_GET, UfsDirectory);
|
||||
Webserver->on(F("/ufsu"), HTTP_POST,[](){Webserver->sendHeader(F("Location"),F("/ufsu"));Webserver->send(303);}, HandleUploadLoop);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
}
|
||||
|
@ -599,7 +599,7 @@ int addSeenDevice(const uint8_t *mac, uint8_t addrtype, const char *name, int8_t
|
||||
int total = seenDevices.size();
|
||||
if (total < MAX_BLE_DEVICES_LOGGED){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("new seendev slot %d"), total);
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: New seendev slot %d"), total);
|
||||
#endif
|
||||
BLE_ESP32::BLE_simple_device_t* dev = new BLE_ESP32::BLE_simple_device_t;
|
||||
freeDevices.push_back(dev);
|
||||
@ -667,10 +667,10 @@ int deleteSeenDevices(int ageS = 0){
|
||||
dump(addr, 20, dev->mac, 6);
|
||||
const char *alias = getAlias(dev->mac);
|
||||
if (!filter){
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("delete device %s(%s) by age lastseen %u + maxage %u < now %u."),
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Delete device %s(%s) by age lastseen %u + maxage %u < now %u."),
|
||||
addr, alias, lastseenS, ageS, nowS);
|
||||
} else {
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("delete device %s(%s) by addrtype filter %d > %d."),
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Delete device %s(%s) by addrtype filter %d > %d."),
|
||||
addr, alias, dev->addrtype, BLEAddressFilter);
|
||||
}
|
||||
#endif
|
||||
@ -682,7 +682,7 @@ int deleteSeenDevices(int ageS = 0){
|
||||
}
|
||||
if (res){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE deleted %d devices"), res);
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Deleted %d devices"), res);
|
||||
#endif
|
||||
}
|
||||
return res;
|
||||
@ -820,7 +820,7 @@ int getSeenDevicesToJson(char *dest, int maxlen){
|
||||
}
|
||||
|
||||
// deliberate test of SafeAddLog_P from main thread...
|
||||
//AddLog_P(LOG_LEVEL_INFO,PSTR("getSeen %d"), seenDevices.size());
|
||||
//AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: getSeen %d"), seenDevices.size());
|
||||
|
||||
|
||||
int len;
|
||||
@ -1184,17 +1184,17 @@ void postAdvertismentDetails(){
|
||||
class BLESensorCallback : public NimBLEClientCallbacks {
|
||||
void onConnect(NimBLEClient* pClient) {
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("onConnect %s"), ((std::string)pClient->getPeerAddress()).c_str());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: onConnect %s"), ((std::string)pClient->getPeerAddress()).c_str());
|
||||
#endif
|
||||
}
|
||||
void onDisconnect(NimBLEClient* pClient) {
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("onDisconnect %s"), ((std::string)pClient->getPeerAddress()).c_str());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: onDisconnect %s"), ((std::string)pClient->getPeerAddress()).c_str());
|
||||
#endif
|
||||
}
|
||||
bool onConnParamsUpdateRequest(NimBLEClient* pClient, const ble_gap_upd_params* params) {
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("onConnParamsUpdateRequest %s"), ((std::string)pClient->getPeerAddress()).c_str());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: onConnParamsUpdateRequest %s"), ((std::string)pClient->getPeerAddress()).c_str());
|
||||
#endif
|
||||
|
||||
// if(params->itvl_min < 24) { /** 1.25ms units */
|
||||
@ -1315,7 +1315,7 @@ class BLEAdvCallbacks: public NimBLEAdvertisedDeviceCallbacks {
|
||||
}
|
||||
} catch(const std::exception& e){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("exception in advertismentCallbacks"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: exception in advertismentCallbacks"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -1334,18 +1334,18 @@ static BLESensorCallback BLESensorCB;
|
||||
static void BLEscanEndedCB(NimBLEScanResults results){
|
||||
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("Scan ended"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Scan ended"));
|
||||
#endif
|
||||
for (int i = 0; i < scancompleteCallbacks.size(); i++){
|
||||
try {
|
||||
SCANCOMPLETE_CALLBACK *pFn = scancompleteCallbacks[i];
|
||||
int callbackres = pFn(results);
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("scancompleteCallbacks %d %d"), i, callbackres);
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: scancompleteCallbacks %d %d"), i, callbackres);
|
||||
#endif
|
||||
} catch(const std::exception& e){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("exception in operationsCallbacks"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: exception in operationsCallbacks"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -1367,21 +1367,21 @@ static void BLEGenNotifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, ui
|
||||
|
||||
if (!pRemoteCharacteristic){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("Notify: no remote char!!??"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Notify: no remote char!!??"));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("Notified length: %u"),length);
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Notified length: %u"),length);
|
||||
#endif
|
||||
// find the operation this is associated with
|
||||
NimBLERemoteService *pSvc = pRemoteCharacteristic->getRemoteService();
|
||||
|
||||
if (!pSvc){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Notify: no remote service found"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Notify: no remote service found"));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -1389,7 +1389,7 @@ static void BLEGenNotifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, ui
|
||||
pRClient = pSvc->getClient();
|
||||
if (!pRClient){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Notify: no remote client!!??"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Notify: no remote client!!??"));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -1404,7 +1404,7 @@ static void BLEGenNotifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, ui
|
||||
generic_sensor_t *op = currentOperations[i];
|
||||
if (!op){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Notify: null op in currentOperations!!??"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Notify: null op in currentOperations!!??"));
|
||||
#endif
|
||||
} else {
|
||||
if (devaddr == op->addr){
|
||||
@ -1420,7 +1420,7 @@ static void BLEGenNotifyCB(NimBLERemoteCharacteristic* pRemoteCharacteristic, ui
|
||||
|
||||
if (!thisop){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("no op for notify"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: no op for notify"));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -1524,7 +1524,7 @@ static void BLEOperationTask(void *pvParameters);
|
||||
static void BLEStartOperationTask(){
|
||||
if (BLERunning == false){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: Start operations"),D_CMND_BLE);
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: %s: Start operations"),D_CMND_BLE);
|
||||
#endif
|
||||
BLERunning = true;
|
||||
|
||||
@ -1547,25 +1547,25 @@ static void BLEStartOperationTask(){
|
||||
static void BLETaskStopStartNimBLE(NimBLEClient **ppClient, bool start = true){
|
||||
|
||||
if (*ppClient){
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLETask:Stopping NimBLE"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Task:Stopping NimBLE"));
|
||||
|
||||
(*ppClient)->setClientCallbacks(nullptr, false);
|
||||
|
||||
try {
|
||||
if ((*ppClient)->isConnected()){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("disconnecting connected client"));
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: disconnecting connected client"));
|
||||
#endif
|
||||
(*ppClient)->disconnect();
|
||||
}
|
||||
NimBLEDevice::deleteClient((*ppClient));
|
||||
(*ppClient) = nullptr;
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("deleted client"));
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: deleted client"));
|
||||
#endif
|
||||
} catch(const std::exception& e){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Stopping NimBLE:exception in delete client"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Stopping NimBLE:exception in delete client"));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1582,7 +1582,7 @@ static void BLETaskStopStartNimBLE(NimBLEClient **ppClient, bool start = true){
|
||||
BLERunningScan = 0;
|
||||
|
||||
if (start){
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("BLETask:Starting NimBLE"));
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: BLETask:Starting NimBLE"));
|
||||
NimBLEDevice::init("BLE_ESP32");
|
||||
|
||||
*ppClient = NimBLEDevice::createClient();
|
||||
@ -1623,7 +1623,7 @@ int BLETaskStartScan(int time){
|
||||
}
|
||||
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLETask: Startscan"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: Startscan"));
|
||||
#endif
|
||||
//vTaskDelay(500/ portTICK_PERIOD_MS);
|
||||
ble32Scan->setActiveScan(BLEScanActiveMode ? 1: 0);
|
||||
@ -1652,7 +1652,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
*pCurrentOperation = nextOperation(&queuedOperations);
|
||||
if (*pCurrentOperation){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLETask: new currentOperation"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: new currentOperation"));
|
||||
#endif
|
||||
BLEOpCount++;
|
||||
generic_sensor_t* temp = *pCurrentOperation;
|
||||
@ -1673,7 +1673,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
diff = diff/1000;
|
||||
if (diff > 20000){ // 20s
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLETask: notify timeout"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: notify timeout"));
|
||||
#endif
|
||||
(*pCurrentOperation)->state = GEN_STATE_FAILED_NOTIFYTIMEOUT;
|
||||
(*pCurrentOperation)->notifytimer = 0;
|
||||
@ -1690,7 +1690,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
(*pCurrentOperation)->state = GEN_STATE_NOTIFIED;
|
||||
// just stay here until this is removed by the main thread
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLETask: notify operation complete"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: notify operation complete"));
|
||||
#endif
|
||||
BLE_ESP32::BLETaskRunTaskDoneOperation(pCurrentOperation, ppClient);
|
||||
pClient = *ppClient;
|
||||
@ -1701,7 +1701,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
case GEN_STATE_NOTIFIED: // - may have completed DURING our read/write to get here
|
||||
// just stay here until this is removed by the main thread
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLETask: operation complete"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: operation complete"));
|
||||
#endif
|
||||
BLE_ESP32::BLETaskRunTaskDoneOperation(pCurrentOperation, ppClient);
|
||||
pClient = *ppClient;
|
||||
@ -1721,7 +1721,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
|
||||
if ((*pCurrentOperation)->state <= GEN_STATE_FAILED){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLETask: op failed %d"), (*pCurrentOperation)->state);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: BLETask: op failed %d"), (*pCurrentOperation)->state);
|
||||
#endif
|
||||
BLE_ESP32::BLETaskRunTaskDoneOperation(pCurrentOperation, ppClient);
|
||||
pClient = *ppClient;
|
||||
@ -1735,7 +1735,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
if (pClient->isConnected()){
|
||||
// don't do anything if we are still connected
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLETask: still connected"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: still connected"));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -1755,7 +1755,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
op->state = GEN_STATE_STARTED;
|
||||
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLETask: attempt connect %s"), ((std::string)op->addr).c_str());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLETask: attempt connect %s"), ((std::string)op->addr).c_str());
|
||||
#endif
|
||||
|
||||
if (!op->serviceUUID.bitSize()){
|
||||
@ -1766,7 +1766,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
if (pClient->connect(op->addr, true)) {
|
||||
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("connected %s -> getservice"), ((std::string)op->addr).c_str());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: connected %s -> getservice"), ((std::string)op->addr).c_str());
|
||||
#endif
|
||||
NimBLERemoteService *pService = pClient->getService(op->serviceUUID);
|
||||
int waitNotify = false;
|
||||
@ -1775,7 +1775,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
|
||||
if (pService != nullptr) {
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("got service"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: got service"));
|
||||
#endif
|
||||
// pre-set to fail if no operations requested
|
||||
//newstate = GEN_STATE_FAILED_NOREADWRITE;
|
||||
@ -1792,13 +1792,13 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
pService->getCharacteristic(op->notificationCharacteristicUUID);
|
||||
if (pNCharacteristic != nullptr) {
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("got notify characteristic"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: got notify characteristic"));
|
||||
#endif
|
||||
op->notifylen = 0;
|
||||
if(pNCharacteristic->canNotify()) {
|
||||
if(pNCharacteristic->subscribe(true, BLE_ESP32::BLEGenNotifyCB)) {
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("subscribe for notify"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: subscribe for notify"));
|
||||
#endif
|
||||
uint64_t now = esp_timer_get_time();
|
||||
op->notifytimer = now;
|
||||
@ -1808,7 +1808,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
waitNotify = true;
|
||||
} else {
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("failed subscribe for notify"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: failed subscribe for notify"));
|
||||
#endif
|
||||
newstate = GEN_STATE_FAILED_NOTIFY;
|
||||
}
|
||||
@ -1816,7 +1816,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
if(pNCharacteristic->canIndicate()) {
|
||||
if(pNCharacteristic->subscribe(false, BLE_ESP32::BLEGenNotifyCB)) {
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("subscribe for indicate"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: subscribe for indicate"));
|
||||
#endif
|
||||
notifystate = GEN_STATE_WAITINDICATE;
|
||||
uint64_t now = esp_timer_get_time();
|
||||
@ -1824,21 +1824,21 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
waitNotify = true;
|
||||
} else {
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("failed subscribe for indicate"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: failed subscribe for indicate"));
|
||||
#endif
|
||||
newstate = GEN_STATE_FAILED_INDICATE;
|
||||
}
|
||||
} else {
|
||||
newstate = GEN_STATE_FAILED_CANTNOTIFYORINDICATE;
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("characteristic can't notify"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: characteristic can't notify"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newstate = GEN_STATE_FAILED_NONOTIFYCHAR;
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("notify characteristic not found"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: notify characteristic not found"));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1855,7 +1855,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
pCharacteristic = pService->getCharacteristic(op->characteristicUUID);
|
||||
if (pCharacteristic != nullptr) {
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("got read/write characteristic"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: got read/write characteristic"));
|
||||
#endif
|
||||
newstate = GEN_STATE_FAILED_NOREADWRITE; // overwritten on failure
|
||||
|
||||
@ -1875,12 +1875,12 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
if (op->readmodifywritecallback){
|
||||
READ_CALLBACK *pFn = (READ_CALLBACK *)op->readmodifywritecallback;
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("read characteristic with readmodifywritecallback"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: read characteristic with readmodifywritecallback"));
|
||||
#endif
|
||||
pFn(op);
|
||||
} else {
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("read characteristic"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: read characteristic"));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1896,12 +1896,12 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
if (!pCharacteristic->writeValue(op->dataToWrite, op->writelen, true)){
|
||||
newstate = GEN_STATE_FAILED_WRITE;
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("characteristic write fail"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: characteristic write fail"));
|
||||
#endif
|
||||
} else {
|
||||
if (!waitNotify) newstate = GEN_STATE_WRITEDONE;
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("write characteristic"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: write characteristic"));
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
@ -1913,7 +1913,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
} else {
|
||||
newstate = GEN_STATE_FAILED_NO_RW_CHAR;
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("r/w characteristic not found"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: r/w characteristic not found"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -1934,7 +1934,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
newstate = GEN_STATE_FAILED_NOSERVICE;
|
||||
// failed to get a service
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("failed - svc not on device?"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: failed - svc not on device?"));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1946,14 +1946,14 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
switch (rc){
|
||||
case (0x0200+BLE_ERR_CONN_LIMIT ):
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Hit connection limit? - restarting NimBLE"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Hit connection limit? - restarting NimBLE"));
|
||||
#endif
|
||||
BLERestartNimBLE = 1;
|
||||
BLERestartBLEReason = BLE_RESTART_BLE_REASON_CONN_LIMIT;
|
||||
break;
|
||||
case (0x0200+BLE_ERR_ACL_CONN_EXISTS):
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Connection exists? - restarting NimBLE"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Connection exists? - restarting NimBLE"));
|
||||
#endif
|
||||
BLERestartNimBLE = 1;
|
||||
BLERestartBLEReason = BLE_RESTART_BLE_REASON_CONN_EXISTS;
|
||||
@ -1963,7 +1963,7 @@ static void BLETaskRunCurrentOperation(BLE_ESP32::generic_sensor_t** pCurrentOpe
|
||||
|
||||
// failed to connect
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("failed to connect to device %d"), rc);
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: failed to connect to device %d"), rc);
|
||||
#endif
|
||||
}
|
||||
op->state = newstate;
|
||||
@ -1979,7 +1979,7 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE
|
||||
try {
|
||||
if ((*ppClient)->isConnected()){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("runTaskDoneOperation: disconnecting connected client"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: runTaskDoneOperation: disconnecting connected client"));
|
||||
#endif
|
||||
(*ppClient)->disconnect();
|
||||
// wait for 1/2 second after disconnect
|
||||
@ -1990,7 +1990,7 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE
|
||||
//(*ppClient)->disconnect();
|
||||
// we will stall here forever!!! - as testing
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE wait discon%d"), waits);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: wait discon%d"), waits);
|
||||
#endif
|
||||
vTaskDelay(500/ portTICK_PERIOD_MS);
|
||||
}
|
||||
@ -1999,11 +1999,11 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE
|
||||
int conn_id = (*ppClient)->getConnId();
|
||||
ble_gap_conn_broken(conn_id, -1);
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE wait discon%d - kill connection"), waits);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: wait discon%d - kill connection"), waits);
|
||||
#endif
|
||||
}
|
||||
if (waits == 60){
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR(">60s waiting -> BLE Failed, restart Tasmota %d"), waits);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: >60s waiting -> BLE Failed, restart Tasmota %d"), waits);
|
||||
BLEStop = 1;
|
||||
BLEStopAt = esp_timer_get_time();
|
||||
|
||||
@ -2015,7 +2015,7 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE
|
||||
}
|
||||
} catch(const std::exception& e){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("runTaskDoneOperation: exception in disconnect"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: runTaskDoneOperation: exception in disconnect"));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2035,7 +2035,7 @@ static void BLETaskRunTaskDoneOperation(BLE_ESP32::generic_sensor_t** op, NimBLE
|
||||
|
||||
// by adding it to this list, this will cause it to be sent to MQTT
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("runTaskDoneOperation: add to completedOperations"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: runTaskDoneOperation: add to completedOperations"));
|
||||
#endif
|
||||
addOperation(&completedOperations, op);
|
||||
return;
|
||||
@ -2096,7 +2096,7 @@ static void BLEOperationTask(void *pvParameters){
|
||||
BLERestartNimBLE = 0;
|
||||
BLERestartTasmota = 10;
|
||||
BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_RESTARTING_BLE_TIMEOUT;
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLETask: Restart NimBLE - restart Tasmota in 10 if not complt"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: BLETask: Restart NimBLE - restart Tasmota in 10 if not complt"));
|
||||
BLE_ESP32::BLETaskStopStartNimBLE(&pClient);
|
||||
BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_UNKNOWN;
|
||||
BLERestartTasmota = 0;
|
||||
@ -2110,7 +2110,7 @@ static void BLEOperationTask(void *pvParameters){
|
||||
vTaskDelay(100/ portTICK_PERIOD_MS);
|
||||
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLEOperationTask: Left task"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: BLEOperationTask: Left task"));
|
||||
#endif
|
||||
deleteSeenDevices();
|
||||
|
||||
@ -2192,11 +2192,11 @@ static void BLEEverySecond(bool restart){
|
||||
if (!BLERestartTasmotaReason) BLERestartTasmotaReason = BLE_RESTART_TEAMOTA_REASON_UNKNOWN;
|
||||
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("{\"reboot\":\"%s\"}"), BLERestartTasmotaReason);
|
||||
MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE Failure! Restarting Tasmota in %d seconds because %s"), BLERestartTasmota, BLERestartTasmotaReason);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting Tasmota in %d seconds because %s"), BLERestartTasmota, BLERestartTasmotaReason);
|
||||
}
|
||||
|
||||
if (!BLERestartTasmota){
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE Failure! Restarting Tasmota because %s"), BLERestartTasmotaReason);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting Tasmota because %s"), BLERestartTasmotaReason);
|
||||
// just a normal restart
|
||||
TasmotaGlobal.restart_flag = 1;
|
||||
}
|
||||
@ -2205,7 +2205,7 @@ static void BLEEverySecond(bool restart){
|
||||
if (BLERestartBLEReason){ // just use the ptr as the trigger to send MQTT
|
||||
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("{\"blerestart\":\"%s\"}"), BLERestartBLEReason);
|
||||
MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE Failure! Restarting BLE Stack because %s"), BLERestartBLEReason);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failure! Restarting BLE Stack because %s"), BLERestartBLEReason);
|
||||
BLERestartBLEReason = nullptr;
|
||||
}
|
||||
|
||||
@ -2250,9 +2250,9 @@ int addOperation(std::deque<generic_sensor_t*> *ops, generic_sensor_t** op){
|
||||
}
|
||||
}
|
||||
if (res){
|
||||
//AddLog_P(LOG_LEVEL_DEBUG,PSTR("added operation"));
|
||||
//AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: added operation"));
|
||||
} else {
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE op - no room"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: op - no room"));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -2260,7 +2260,7 @@ int addOperation(std::deque<generic_sensor_t*> *ops, generic_sensor_t** op){
|
||||
|
||||
int newOperation(BLE_ESP32::generic_sensor_t** op){
|
||||
if (!op) {
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE op inv in newOperation"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: op inv in newOperation"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2307,7 +2307,7 @@ int extQueueOperation(BLE_ESP32::generic_sensor_t** op){
|
||||
|
||||
int res = addOperation(&queuedOperations, op);
|
||||
if (!res){
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("extQueueOperation: op added id %d failed"), (lastopid-1));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: extQueueOperation: op added id %d failed"), (lastopid-1));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -2427,7 +2427,7 @@ static int StartBLE(void) {
|
||||
BLE_ESP32::BLEStartOperationTask();
|
||||
return 1;
|
||||
}
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("StartBLE - wait as BLEStop==1"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: StartBLE - wait as BLEStop==1"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2436,16 +2436,16 @@ static int StopBLE(void){
|
||||
if (BLERunning){
|
||||
if (BLEStop != 1){
|
||||
BLEStop = 1;
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("StopBLE - BLEStop->1"));
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: StopBLE - BLEStop->1"));
|
||||
BLEStopAt = esp_timer_get_time();
|
||||
// give a little time for it to stop.
|
||||
vTaskDelay(1000/ portTICK_PERIOD_MS);
|
||||
return 1;
|
||||
}
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("StopBLE - wait as BLEStop==1"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: StopBLE - wait as BLEStop==1"));
|
||||
return 0;
|
||||
} else {
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("StopBLE - was not running"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: StopBLE - was not running"));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -2686,7 +2686,7 @@ void CmndBLEDetails(void){
|
||||
void CmndBLEAlias(void){
|
||||
#ifdef BLE_ESP32_ALIASES
|
||||
int op = XdrvMailbox.index;
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("Alias %d %s"), op, XdrvMailbox.data);
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Alias %d %s"), op, XdrvMailbox.data);
|
||||
|
||||
int res = -1;
|
||||
switch(op){
|
||||
@ -2705,7 +2705,7 @@ void CmndBLEAlias(void){
|
||||
char *mac = p;
|
||||
int len = fromHex(addr, p, sizeof(addr));
|
||||
if (len != 6){
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Alias invalid mac %s"), p);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Alias invalid mac %s"), p);
|
||||
ResponseCmndChar("invalidmac");
|
||||
return;
|
||||
}
|
||||
@ -2726,7 +2726,7 @@ void CmndBLEAlias(void){
|
||||
return;
|
||||
}
|
||||
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Add Alias mac %s = name %s"), mac, p);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Add Alias mac %s = name %s"), mac, p);
|
||||
if (addAlias( addr, name )){
|
||||
added++;
|
||||
}
|
||||
@ -2734,7 +2734,7 @@ void CmndBLEAlias(void){
|
||||
} while (p);
|
||||
|
||||
if (added){
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("Added %d Aliases"), added);
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Added %d Aliases"), added);
|
||||
BLEAliasListResp();
|
||||
} else {
|
||||
BLEAliasListResp();
|
||||
@ -2742,7 +2742,7 @@ void CmndBLEAlias(void){
|
||||
return;
|
||||
} break;
|
||||
case 2:{ // clear
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLEAlias clearing %d"), aliases.size());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: Alias clearing %d"), aliases.size());
|
||||
for (int i = aliases.size()-1; i >= 0; i--){
|
||||
BLE_ESP32::ble_alias_t *alias = aliases[i];
|
||||
aliases.pop_back();
|
||||
@ -2773,14 +2773,14 @@ void CmndBLEName(void) {
|
||||
|
||||
if (addrres){
|
||||
if (addrres == 2){
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE addr used alias: %s"), p);
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: addr used alias: %s"), p);
|
||||
}
|
||||
|
||||
//#ifdef EQ3_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE cmd addr: %s -> %s"), p, addr.toString().c_str());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: cmd addr: %s -> %s"), p, addr.toString().c_str());
|
||||
//#endif
|
||||
} else {
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE addr invalid: %s"), p);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: addr invalid: %s"), p);
|
||||
ResponseCmndIdxChar(PSTR("invalidaddr"));
|
||||
return;
|
||||
}
|
||||
@ -2789,11 +2789,11 @@ void CmndBLEName(void) {
|
||||
// ALWAYS use this function to create a new one.
|
||||
int res = BLE_ESP32::newOperation(&op);
|
||||
if (!res){
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Can't get a newOperation"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Can't get a newOperation"));
|
||||
ResponseCmndChar(PSTR("FAIL"));
|
||||
return;
|
||||
} else {
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("got a newOperation from BLE"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: got a newOperation from BLE"));
|
||||
}
|
||||
|
||||
op->addr = addr;
|
||||
@ -2804,21 +2804,21 @@ void CmndBLEName(void) {
|
||||
char *name = strtok(nullptr, " ");
|
||||
bool write = false;
|
||||
if (name && *name){
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("write name %s"), name);
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: write name %s"), name);
|
||||
op->writelen = strlen(name);
|
||||
memcpy(op->dataToWrite, name, op->writelen);
|
||||
write = true;
|
||||
} else {
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("read name"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: read name"));
|
||||
op->readlen = 1;
|
||||
}
|
||||
|
||||
res = BLE_ESP32::extQueueOperation(&op);
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("queue res %d"), res);
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: queue res %d"), res);
|
||||
if (!res){
|
||||
// if it fails to add to the queue, do please delete it
|
||||
BLE_ESP32::freeOperation(&op);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Failed to queue new operation - deleted"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failed to queue new operation - deleted"));
|
||||
ResponseCmndChar(PSTR("QUEUEFAIL"));
|
||||
return;
|
||||
}
|
||||
@ -2856,7 +2856,7 @@ void CmndBLEOperation(void){
|
||||
|
||||
int op = XdrvMailbox.index;
|
||||
|
||||
//AddLog_P(LOG_LEVEL_INFO,PSTR("op %d"), op);
|
||||
//AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: op %d"), op);
|
||||
|
||||
int res = -1;
|
||||
|
||||
@ -2864,7 +2864,7 @@ void CmndBLEOperation(void){
|
||||
switch(op) {
|
||||
case 0:
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("preview"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: preview"));
|
||||
#endif
|
||||
BLEPostMQTTTrigger = 1;
|
||||
break;
|
||||
@ -2875,7 +2875,7 @@ void CmndBLEOperation(void){
|
||||
int opres = BLE_ESP32::newOperation(&prepOperation);
|
||||
if (!opres){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Could not create new operation"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Could not create new operation"));
|
||||
#endif
|
||||
ResponseCmndChar("FailCreate");
|
||||
return;
|
||||
@ -2933,14 +2933,14 @@ void CmndBLEOperation(void){
|
||||
// this means you could retry with another BLEOp10.
|
||||
// it WOULD be deleted if you sent another BELOP1 <MAC>
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Could not queue new operation"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Could not queue new operation"));
|
||||
#endif
|
||||
ResponseCmndChar("FailQueue");
|
||||
return;
|
||||
} else {
|
||||
// NOTE: prepOperation has been set to null if we queued sucessfully.
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("Operations queued:%d"), queuedOperations.size());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Operations queued:%d"), queuedOperations.size());
|
||||
#endif
|
||||
char temp[40];
|
||||
sprintf(temp, "{\"opid\":%d,\"u\":%d}", lastopid-1, u);
|
||||
@ -2969,13 +2969,13 @@ void CmndBLEOperation(void){
|
||||
// this means you could retry with another BLEOp10.
|
||||
// it WOULD be deleted if you sent another BELOP1 <MAC>
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Could not queue new operation"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Could not queue new operation"));
|
||||
#endif
|
||||
ResponseCmndChar("FailQueue");
|
||||
} else {
|
||||
// NOTE: prepOperation has been set to null if we queued sucessfully.
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("Operations queued:%d"), queuedOperations.size());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: Operations queued:%d"), queuedOperations.size());
|
||||
#endif
|
||||
char temp[40];
|
||||
sprintf(temp, "{\"opid\":%d,\"u\":%d}", lastopid-1, u);
|
||||
@ -3026,20 +3026,20 @@ static void BLEPostMQTT(bool onlycompleted) {
|
||||
|
||||
if (prepOperation || completedOperations.size() || queuedOperations.size() || currentOperations.size()){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("some to show"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: some to show"));
|
||||
#endif
|
||||
if (prepOperation && !onlycompleted){
|
||||
std::string out = BLETriggerResponse(prepOperation);
|
||||
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str());
|
||||
MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain);
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("prep sent %s"), out.c_str());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: prep sent %s"), out.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
if (queuedOperations.size() && !onlycompleted){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("queued %d"), queuedOperations.size());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: queued %d"), queuedOperations.size());
|
||||
#endif
|
||||
for (int i = 0; i < queuedOperations.size(); i++){
|
||||
TasAutoMutex localmutex(&BLEOperationsRecursiveMutex, "BLEPost1");
|
||||
@ -3053,7 +3053,7 @@ static void BLEPostMQTT(bool onlycompleted) {
|
||||
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str());
|
||||
MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain);
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("queued %d sent %s"), i, out.c_str());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: queued %d sent %s"), i, out.c_str());
|
||||
#endif
|
||||
//break;
|
||||
}
|
||||
@ -3062,7 +3062,7 @@ static void BLEPostMQTT(bool onlycompleted) {
|
||||
|
||||
if (currentOperations.size() && !onlycompleted){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("current %d"), currentOperations.size());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: current %d"), currentOperations.size());
|
||||
#endif
|
||||
for (int i = 0; i < currentOperations.size(); i++){
|
||||
TasAutoMutex localmutex(&BLEOperationsRecursiveMutex, "BLEPost2");
|
||||
@ -3075,7 +3075,7 @@ static void BLEPostMQTT(bool onlycompleted) {
|
||||
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str());
|
||||
MqttPublishPrefixTopic_P(TELE, PSTR("BLE"), Settings.flag.mqtt_sensor_retain);
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("curr %d sent %s"), i, out.c_str());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: curr %d sent %s"), i, out.c_str());
|
||||
#endif
|
||||
//break;
|
||||
}
|
||||
@ -3084,7 +3084,7 @@ static void BLEPostMQTT(bool onlycompleted) {
|
||||
|
||||
if (completedOperations.size()){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("completed %d"), completedOperations.size());
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: completed %d"), completedOperations.size());
|
||||
#endif
|
||||
do {
|
||||
generic_sensor_t *toSend = nextOperation(&completedOperations);
|
||||
@ -3092,7 +3092,7 @@ static void BLEPostMQTT(bool onlycompleted) {
|
||||
break; // break from while loop
|
||||
} else {
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE:completedOperation removed"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: completedOperation removed"));
|
||||
#endif
|
||||
std::string out = BLETriggerResponse(toSend);
|
||||
snprintf_P(TasmotaGlobal.mqtt_data, sizeof(TasmotaGlobal.mqtt_data), PSTR("%s"), out.c_str());
|
||||
@ -3154,7 +3154,7 @@ static void mainThreadBLETimeouts() {
|
||||
|
||||
static void mainThreadOpCallbacks() {
|
||||
if (completedOperations.size()){
|
||||
//AddLog_P(LOG_LEVEL_INFO,PSTR("completed %d"), completedOperations.size());
|
||||
//AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: completed %d"), completedOperations.size());
|
||||
TasAutoMutex localmutex(&BLEOperationsRecursiveMutex, "BLEMainCB");
|
||||
|
||||
// find this operation in currentOperations, and remove it.
|
||||
@ -3169,11 +3169,11 @@ static void mainThreadOpCallbacks() {
|
||||
OPCOMPLETE_CALLBACK *pFn = (OPCOMPLETE_CALLBACK *)(op->completecallback);
|
||||
callbackres = pFn(op);
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("op->completecallback %d"), callbackres);
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: op->completecallback %d"), callbackres);
|
||||
#endif
|
||||
} catch(const std::exception& e){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("exception in op->completecallback"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: exception in op->completecallback"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -3184,14 +3184,14 @@ static void mainThreadOpCallbacks() {
|
||||
OPCOMPLETE_CALLBACK *pFn = operationsCallbacks[i];
|
||||
callbackres = pFn(op);
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("operationsCallbacks %d %d"), i, callbackres);
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: operationsCallbacks %d %d"), i, callbackres);
|
||||
#endif
|
||||
if (callbackres){
|
||||
break; // this callback ate the op.
|
||||
}
|
||||
} catch(const std::exception& e){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("exception in operationsCallbacks"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: exception in operationsCallbacks"));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -3200,7 +3200,7 @@ static void mainThreadOpCallbacks() {
|
||||
// if some callback told us not to send on MQTT, then remove from completed and delete the data
|
||||
if (callbackres){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("callbackres true -> delete op"));
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("BLE: callbackres true -> delete op"));
|
||||
#endif
|
||||
completedOperations.erase(completedOperations.begin() + i);
|
||||
delete op;
|
||||
@ -3214,7 +3214,7 @@ static void BLEShow(bool json)
|
||||
{
|
||||
if (json){
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("show json %d"),json);
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: show json %d"),json);
|
||||
#endif
|
||||
uint32_t totalCount = BLEAdvertisment.totalCount;
|
||||
uint32_t deviceCount = seenDevices.size();
|
||||
@ -3262,7 +3262,7 @@ static void BLEDiag()
|
||||
uint32_t totalCount = BLEAdvertisment.totalCount;
|
||||
uint32_t deviceCount = seenDevices.size();
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE:scans:%u,advertisements:%u,devices:%u,resets:%u,BLEStop:%d,BLERunning:%d,BLERunningScan:%d,BLELoopCount:%u,BLEOpCount:%u"), BLEScanCount, totalCount, deviceCount, BLEResets, BLEStop, BLERunning, BLERunningScan, BLELoopCount, BLEOpCount);
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: scans:%u,advertisements:%u,devices:%u,resets:%u,BLEStop:%d,BLERunning:%d,BLERunningScan:%d,BLELoopCount:%u,BLEOpCount:%u"), BLEScanCount, totalCount, deviceCount, BLEResets, BLEStop, BLERunning, BLERunningScan, BLELoopCount, BLEOpCount);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -3372,12 +3372,12 @@ void HandleBleConfiguration(void)
|
||||
{
|
||||
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("HandleBleConfiguration"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: HandleBleConfiguration"));
|
||||
#endif
|
||||
|
||||
if (!HttpCheckPriviledgedAccess()) {
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("!HttpCheckPriviledgedAccess()"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: !HttpCheckPriviledgedAccess()"));
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@ -3390,12 +3390,12 @@ void HandleBleConfiguration(void)
|
||||
WebGetArg("en", tmp, sizeof(tmp));
|
||||
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("arg en is %s"), tmp);
|
||||
if (BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: arg en is %s"), tmp);
|
||||
#endif
|
||||
|
||||
if (Webserver->hasArg("save")) {
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE SETTINGS SAVE"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: SETTINGS SAVE"));
|
||||
#endif
|
||||
Settings.flag5.mi32_enable = Webserver->hasArg("e0"); //
|
||||
BLEScanActiveMode = (Webserver->hasArg("e1")?1:0); //
|
||||
@ -3405,7 +3405,7 @@ void HandleBleConfiguration(void)
|
||||
return;
|
||||
}
|
||||
#ifdef BLE_ESP32_DEBUG
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("!SAVE"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: !SAVE"));
|
||||
#endif
|
||||
char str[TOPSZ];
|
||||
|
||||
@ -3460,7 +3460,7 @@ void HandleBleConfiguration(void)
|
||||
\*********************************************************************************************/
|
||||
|
||||
int ExtStopBLE(){
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("Stopping BLE if active - upgrade starting?"));
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("BLE: Stopping if active"));
|
||||
BLE_ESP32::BLEMode = BLE_ESP32::BLEModeDisabled;
|
||||
BLE_ESP32::StopBLE();
|
||||
return 0;
|
||||
@ -3548,13 +3548,13 @@ int myAdvertCallback(BLE_ESP32::ble_advertisment_t *pStruct) {
|
||||
|
||||
// this one is used to demonstrate processing ALL operations
|
||||
int myOpCallback(BLE_ESP32::generic_sensor_t *pStruct){
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("myOpCallback"));
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: myOpCallback"));
|
||||
return 0; // return true to block MQTT broadcast
|
||||
}
|
||||
|
||||
// this one is used to demonstrate processing of ONE specific operation
|
||||
int myOpCallback2(BLE_ESP32::generic_sensor_t *pStruct){
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("myOpCallback2"));
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("BLE: myOpCallback2"));
|
||||
return 1; // return true to block MQTT broadcast
|
||||
}
|
||||
#endif
|
||||
@ -3577,7 +3577,7 @@ void sendExample(){
|
||||
BLE_ESP32::generic_sensor_t *op = nullptr;
|
||||
int res = BLE_ESP32::newOperation(&op);
|
||||
if (!res){
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Could not create new operation"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Could not create new operation"));
|
||||
return;
|
||||
}
|
||||
strncpy(op->MAC, "001A22092EE0", sizeof(op->MAC));
|
||||
@ -3592,7 +3592,7 @@ void sendExample(){
|
||||
if (!res){
|
||||
// if it fails to add to the queue, do please delete it
|
||||
BLE_ESP32::freeOperation(&op);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Failed to queue new operation - deleted"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("BLE: Failed to queue new operation - deleted"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -241,7 +241,7 @@ bool HxCommand(void)
|
||||
break;
|
||||
case 7: // WeightSave
|
||||
Settings.energy_frequency_calibration = Hx.weight;
|
||||
Response_P(S_JSON_SENSOR_INDEX_SVALUE, XSNS_34, D_JSON_DONE);
|
||||
Response_P(S_JSON_SENSOR_INDEX_SVALUE, XSNS_34, PSTR(D_JSON_DONE));
|
||||
break;
|
||||
case 8: // Json on weight change
|
||||
if (strchr(XdrvMailbox.data, ',') != nullptr) {
|
||||
|
@ -97,15 +97,15 @@ struct {
|
||||
struct {
|
||||
// the slot currently having it's battery read
|
||||
// set to 0 to start a battery read cycle
|
||||
uint8_t slot = 255;
|
||||
uint8_t active = 0;
|
||||
uint8_t slot = 255;
|
||||
uint8_t active = 0;
|
||||
} batteryreader;
|
||||
|
||||
struct {
|
||||
// the slot currently having it's battery read
|
||||
// set to 0 to start a battery read cycle
|
||||
uint8_t slot = 255;
|
||||
uint8_t active = 0;
|
||||
uint8_t slot = 255;
|
||||
uint8_t active = 0;
|
||||
} sensorreader;
|
||||
|
||||
struct {
|
||||
@ -246,7 +246,7 @@ struct PVVXPacket_t {
|
||||
uint16_t battery_mv; // mV
|
||||
uint8_t battery_level; // 0..100 %
|
||||
uint8_t counter; // measurement count
|
||||
uint8_t flags;
|
||||
uint8_t flags;
|
||||
};
|
||||
|
||||
#pragma pack(0)
|
||||
@ -362,7 +362,7 @@ void (*const MI32_Commands[])(void) PROGMEM = {
|
||||
|
||||
#define MI_MI32_TYPES 13 //count this manually
|
||||
|
||||
const uint16_t kMI32DeviceID[MI_MI32_TYPES]={
|
||||
const uint16_t kMI32DeviceID[MI_MI32_TYPES]={
|
||||
0x0000, // Unkown
|
||||
0x0098, // Flora
|
||||
0x01aa, // MJ_HT_V1
|
||||
@ -419,8 +419,8 @@ const char *MHOC303_TimeChar = LYWSD02_TimeChar;
|
||||
const char *MHOC401_Svc = LYWSD02_Svc;
|
||||
const char *MHOC401_BattNotifyChar = LYWSD02_BattNotifyChar;
|
||||
|
||||
const char CGD1_Svc[] PROGMEM = "180F";
|
||||
const char CGD1_BattChar[] PROGMEM = "2A19";
|
||||
const char CGD1_Svc[] PROGMEM = "180F";
|
||||
const char CGD1_BattChar[] PROGMEM = "2A19";
|
||||
|
||||
const char FLORA_Svc[] PROGMEM = "00001204-0000-1000-8000-00805F9B34FB";
|
||||
const char FLORA_BattChar[] PROGMEM = "00001A02-0000-1000-8000-00805F9B34FB";
|
||||
@ -443,7 +443,7 @@ enum MI32_MI_OP_TYPES {
|
||||
|
||||
|
||||
enum MI32_MI_KEY_REQ {
|
||||
KEY_REQUIREMENT_UNKNOWN = 0, // we don't know if a key is needed
|
||||
KEY_REQUIREMENT_UNKNOWN = 0, // we don't know if a key is needed
|
||||
KEY_NOT_REQUIRED = 1, // we got an unencrypted payload
|
||||
KEY_REQUIRED_BUT_NOT_FOUND = 2, // we got an encrypted packet, but had not key
|
||||
KEY_REQUIRED_AND_FOUND = 3, // we got an encrypted packet, and could decrypt
|
||||
@ -490,7 +490,7 @@ int toggleUnit(BLE_ESP32::generic_sensor_t *op){
|
||||
|
||||
bool MI32Operation(int slot, int optype, const char *svc, const char *charactistic, const char *notifychar = nullptr, const uint8_t *data = nullptr, int datalen = 0, uint8_t *addr = nullptr ) {
|
||||
if (!svc || !svc[0]){
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("MI32Op: inv svc"));
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: Op inv svc"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -499,17 +499,17 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist
|
||||
// ALWAYS use this function to create a new one.
|
||||
int res = BLE_ESP32::newOperation(&op);
|
||||
if (!res){
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Can't get a newOperation from BLE"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Can't get a newOperation"));
|
||||
return 0;
|
||||
} else {
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("got a newOperation from BLE"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Got a newOperation"));
|
||||
}
|
||||
|
||||
if (slot >= 0){
|
||||
op->addr = NimBLEAddress(MIBLEsensors[slot].MAC);
|
||||
} else {
|
||||
if (!addr){
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("no addr"));
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: No addr"));
|
||||
BLE_ESP32::freeOperation(&op);
|
||||
return 0;
|
||||
}
|
||||
@ -521,7 +521,7 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist
|
||||
|
||||
if (!op->serviceUUID.bitSize()){
|
||||
BLE_ESP32::freeOperation(&op);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("MI: Bad service string %s"), svc);
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: MI Bad service string %s"), svc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -531,7 +531,7 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist
|
||||
op->characteristicUUID = NimBLEUUID(charactistic);
|
||||
if (!op->characteristicUUID.bitSize()){
|
||||
BLE_ESP32::freeOperation(&op);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("MI: Bad characteristic string %s"), charactistic);
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: MI Bad characteristic string %s"), charactistic);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -539,10 +539,10 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist
|
||||
op->notificationCharacteristicUUID = NimBLEUUID(notifychar);
|
||||
if (!op->notificationCharacteristicUUID.bitSize()){
|
||||
BLE_ESP32::freeOperation(&op);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("MI: Bad notifycharacteristic string %s"), notifychar);
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: MI Bad notifycharacteristic string %s"), notifychar);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data && datalen) {
|
||||
op->writelen = datalen;
|
||||
@ -564,13 +564,13 @@ bool MI32Operation(int slot, int optype, const char *svc, const char *charactist
|
||||
uint32_t context = (optype << 24) | (MIBLEsensors[slot].type << 16) | slot;
|
||||
op->context = (void *)context;
|
||||
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI s:%d op:%s"), slot, BLE_ESP32::BLETriggerResponse(op).c_str());
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: MI s:%d op:%s"), slot, BLE_ESP32::BLETriggerResponse(op).c_str());
|
||||
|
||||
res = BLE_ESP32::extQueueOperation(&op);
|
||||
if (!res){
|
||||
// if it fails to add to the queue, do please delete it
|
||||
BLE_ESP32::freeOperation(&op);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Failed to queue new operation - deleted"));
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: Failed to queue new operation - deleted"));
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -591,10 +591,10 @@ int genericBatReadFn(int slot){
|
||||
break;
|
||||
|
||||
// these read a characteristic
|
||||
case MI_FLORA:
|
||||
case MI_FLORA:
|
||||
res = MI32Operation(slot, OP_BATT_READ, FLORA_Svc, FLORA_BattChar);
|
||||
break;
|
||||
case MI_LYWSD02:
|
||||
case MI_LYWSD02:
|
||||
res = MI32Operation(slot, OP_BATT_READ, LYWSD02_Svc, LYWSD02_BattChar);
|
||||
break;
|
||||
case MI_CGD1:
|
||||
@ -611,9 +611,9 @@ int genericBatReadFn(int slot){
|
||||
break;
|
||||
}
|
||||
if (res > 0){
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("Req batt read slot %d type %d queued"), slot, MIBLEsensors[slot].type);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Req batt read slot %d type %d queued"), slot, MIBLEsensors[slot].type);
|
||||
} else {
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("Req batt read slot %d type %d non-queued res %d"), slot, MIBLEsensors[slot].type, res);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Req batt read slot %d type %d non-queued res %d"), slot, MIBLEsensors[slot].type, res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@ -627,17 +627,17 @@ int genericSensorReadFn(int slot, int force){
|
||||
so although the characteristic seems to exist, it does not work?
|
||||
further dev required with sensor to hand.
|
||||
case MI_LYWSD02:
|
||||
// don't read if key present and we've decoded at least one advert
|
||||
// don't read if key present and we've decoded at least one advert
|
||||
if (MIBLEsensors[slot].needkey == KEY_REQUIRED_AND_FOUND) return -2;
|
||||
res = MI32Operation(slot, OP_READ_HT_LY, LYWSD02_Svc, nullptr, LYWSD02_BattNotifyChar);
|
||||
break;*/
|
||||
case MI_LYWSD03MMC:
|
||||
// don't read if key present and we've decoded at least one advert
|
||||
// don't read if key present and we've decoded at least one advert
|
||||
if (MIBLEsensors[slot].needkey == KEY_REQUIRED_AND_FOUND && !force) return -2;
|
||||
res = MI32Operation(slot, OP_READ_HT_LY, LYWSD03_Svc, nullptr, LYWSD03_BattNotifyChar);
|
||||
break;
|
||||
case MI_MHOC401:
|
||||
// don't read if key present and we've decoded at least one advert
|
||||
// don't read if key present and we've decoded at least one advert
|
||||
if (MIBLEsensors[slot].needkey == KEY_REQUIRED_AND_FOUND && !force) return -2;
|
||||
res = MI32Operation(slot, OP_READ_HT_LY, MHOC401_Svc, nullptr, MHOC401_BattNotifyChar);
|
||||
break;
|
||||
@ -653,22 +653,22 @@ int genericSensorReadFn(int slot, int force){
|
||||
// called once per second
|
||||
int readOneSensor(){
|
||||
if (MI32.sensorreader.active){
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("readOneSensor - already active reading %d"), MI32.sensorreader.slot-1);
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor - already active reading %d"), MI32.sensorreader.slot-1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// loop if the sensor at the slot does not need to be read
|
||||
// i.e. drop out of loop when we start a read, or hit the end
|
||||
int res = -1;
|
||||
int res = -1;
|
||||
do {
|
||||
// MI32.sensorreader.slot is reset to zero to trigger a read sequence
|
||||
if (MI32.sensorreader.slot >= MIBLEsensors.size()){
|
||||
//AddLog_P(LOG_LEVEL_DEBUG,PSTR("readOneSensor past end of slots - %d > %d"), MI32.sensorreader.slot, MIBLEsensors.size());
|
||||
//AddLog_P(LOG_LEVEL_DEBUG, PSTR("BLE: readOneSensor past end of slots - %d > %d"), MI32.sensorreader.slot, MIBLEsensors.size());
|
||||
return 0;
|
||||
}
|
||||
|
||||
res = genericSensorReadFn(MI32.sensorreader.slot, 0);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("genericSensorReadFn slot %d res %d"), MI32.sensorreader.slot, res);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: genericSensorReadFn slot %d res %d"), MI32.sensorreader.slot, res);
|
||||
|
||||
// if this sensor in this slot does not need to be read via notify, just move on top the next one
|
||||
if (res < 0){
|
||||
@ -680,7 +680,7 @@ int readOneSensor(){
|
||||
|
||||
if (res == 0){
|
||||
// can't read at the moment (no operations available?)
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("readOneSensor no ops available slot %d res %d"), MI32.sensorreader.slot, res);
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor no ops available slot %d res %d"), MI32.sensorreader.slot, res);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -689,7 +689,7 @@ int readOneSensor(){
|
||||
// and make it wait until the read/notify is complete
|
||||
// this is cleared in the response callback.
|
||||
MI32.sensorreader.active = 1;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("readOneSensor reading for slot %d res %d"), MI32.sensorreader.slot-1, res);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: readOneSensor reading for slot %d res %d"), MI32.sensorreader.slot-1, res);
|
||||
|
||||
// started one
|
||||
return 1;
|
||||
@ -714,7 +714,7 @@ int readOneBat(){
|
||||
if (res < 0){
|
||||
MI32.batteryreader.slot++;
|
||||
if (MI32.batteryreader.slot >= MIBLEsensors.size()){
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("Batt loop complete at %d"), MI32.batteryreader.slot);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Batt loop complete at %d"), MI32.batteryreader.slot);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -730,7 +730,7 @@ int readOneBat(){
|
||||
// this is cleared in the response callback.
|
||||
MI32.batteryreader.active = 1;
|
||||
if (MI32.batteryreader.slot >= MIBLEsensors.size()){
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO,PSTR("Batt loop will complete at %d"), MI32.batteryreader.slot);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Batt loop will complete at %d"), MI32.batteryreader.slot);
|
||||
}
|
||||
// started one
|
||||
return 1;
|
||||
@ -816,7 +816,7 @@ int genericTimeWriteFn(int slot){
|
||||
int genericOpCompleteFn(BLE_ESP32::generic_sensor_t *op){
|
||||
uint32_t context = (uint32_t) op->context;
|
||||
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI op complete context %x"), context);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: MI op complete context %x"), context);
|
||||
|
||||
int opType = context >> 24;
|
||||
int devType = (context >> 16) & 0xff;
|
||||
@ -832,12 +832,12 @@ int genericOpCompleteFn(BLE_ESP32::generic_sensor_t *op){
|
||||
bool fail = false;
|
||||
if (op->addr != addr){
|
||||
// slot changed during operation?
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Slot mac changed during an operation"));
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: Slot mac changed during an operation"));
|
||||
fail = true;
|
||||
}
|
||||
|
||||
if (op->state <= GEN_STATE_FAILED){
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("operation failed %d for %s"), op->state, slotMAC);
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: Operation failed %d for %s"), op->state, slotMAC);
|
||||
fail = true;
|
||||
}
|
||||
|
||||
@ -857,7 +857,7 @@ int genericOpCompleteFn(BLE_ESP32::generic_sensor_t *op){
|
||||
|
||||
switch(opType){
|
||||
case OP_TIME_WRITE:
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("Time write for %s complete"), slotMAC);
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Time write for %s complete"), slotMAC);
|
||||
return 0; // nothing to do
|
||||
case OP_BATT_READ:{
|
||||
uint8_t *data = nullptr;
|
||||
@ -876,33 +876,33 @@ int genericOpCompleteFn(BLE_ESP32::generic_sensor_t *op){
|
||||
|
||||
// allow another...
|
||||
MI32.batteryreader.active = 0;
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("batt read slot %d done state %x"), slot, op->state);
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("M32: Batt read slot %d done state %x"), slot, op->state);
|
||||
|
||||
} return 0;
|
||||
|
||||
case OP_UNIT_WRITE: // nothing more to do?
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("Unit write for %s complete"), slotMAC);
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Unit write for %s complete"), slotMAC);
|
||||
return 0;
|
||||
|
||||
case OP_UNIT_READ: {
|
||||
uint8_t currUnit = op->dataRead[0];
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("Unit read for %s complete %d"), slotMAC, currUnit);
|
||||
uint8_t currUnit = op->dataRead[0];
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Unit read for %s complete %d"), slotMAC, currUnit);
|
||||
} return 0;
|
||||
|
||||
case OP_UNIT_TOGGLE: {
|
||||
uint8_t currUnit = op->dataToWrite[0];
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("Unit toggle for %s complete %d->%d; datasize was %d"), slotMAC, op->dataRead[0], op->dataToWrite[0], op->readlen);
|
||||
uint8_t currUnit = op->dataToWrite[0];
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Unit toggle for %s complete %d->%d; datasize was %d"), slotMAC, op->dataRead[0], op->dataToWrite[0], op->readlen);
|
||||
} return 0;
|
||||
|
||||
case OP_READ_HT_LY: {
|
||||
// allow another...
|
||||
MI32.sensorreader.active = 0;
|
||||
MI32notifyHT_LY(slot, (char*)op->dataNotify, op->notifylen);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("HT_LY notify for %s complete"), slotMAC);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: HT_LY notify for %s complete"), slotMAC);
|
||||
} return 0;
|
||||
|
||||
default:
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("OpType %d not recognised?"), opType);
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: OpType %d not recognised?"), opType);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -914,7 +914,7 @@ int MI32advertismentCallback(BLE_ESP32::ble_advertisment_t *pStruct)
|
||||
// we will try not to use this...
|
||||
BLEAdvertisedDevice *advertisedDevice = pStruct->advertisedDevice;
|
||||
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Advertised Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length());
|
||||
// AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Advertised Device: %s Buffer: %u"),advertisedDevice->getAddress().toString().c_str(),advertisedDevice->getServiceData(0).length());
|
||||
int RSSI = pStruct->RSSI;
|
||||
const uint8_t *addr = pStruct->addr;
|
||||
if(MI32isInBlockList(addr) == true) return 0;
|
||||
@ -937,14 +937,14 @@ int MI32advertismentCallback(BLE_ESP32::ble_advertisment_t *pStruct)
|
||||
char temp[60];
|
||||
BLE_ESP32::dump(temp, 13, addr, 6);
|
||||
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("MI:%s svc[0] UUID (%x)"), temp, UUID);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("M32: MI:%s svc[0] UUID (%x)"), temp, UUID);
|
||||
std::string ServiceDataStr = advertisedDevice->getServiceData(0);
|
||||
|
||||
|
||||
uint32_t ServiceDataLength = ServiceDataStr.length();
|
||||
const uint8_t *ServiceData = (const uint8_t *)ServiceDataStr.data();
|
||||
BLE_ESP32::dump(temp, 60, ServiceData, ServiceDataLength);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("MI:%s"), temp);
|
||||
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("M32: MI:%s"), temp);
|
||||
|
||||
|
||||
if (UUID){
|
||||
// this will take and keep the mutex until the function is over
|
||||
@ -1041,14 +1041,14 @@ int MI32AddKey(char* payload, char* key = nullptr){
|
||||
bool unknownKey = true;
|
||||
for(uint32_t i=0; i<MIBLEbindKeys.size(); i++){
|
||||
if(memcmp(keyMAC.MAC,MIBLEbindKeys[i].MAC,sizeof(keyMAC.MAC))==0){
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("known key"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Known key"));
|
||||
memcpy(MIBLEbindKeys[i].key, keyMAC.key, 16);
|
||||
unknownKey=false;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if(unknownKey){
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("New key"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: New key"));
|
||||
MIBLEbindKeys.push_back(keyMAC);
|
||||
return 1;
|
||||
}
|
||||
@ -1066,17 +1066,17 @@ int MIDecryptPayload(const uint8_t *macin, const uint8_t *nonce, uint32_t tag, u
|
||||
uint8_t _bindkey[32] = {0x0};
|
||||
const unsigned char authData[16] = {0x11};
|
||||
bool foundNoKey = true;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: search key for MAC: %02x%02x%02x%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: Search key for MAC: %02x%02x%02x%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
for(uint32_t i=0; i<MIBLEbindKeys.size(); i++){
|
||||
if(memcmp(mac, MIBLEbindKeys[i].MAC, 6)==0){
|
||||
memcpy(_bindkey, MIBLEbindKeys[i].key, 16);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: decryption Key found"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Decryption Key found"));
|
||||
foundNoKey = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(foundNoKey){
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: no Key found !!"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: No Key found"));
|
||||
return -2; // indicates needs key
|
||||
}
|
||||
|
||||
@ -1098,7 +1098,7 @@ int MIDecryptPayload(const uint8_t *macin, const uint8_t *nonce, uint32_t tag, u
|
||||
// returns 1 if matched, else 0
|
||||
int ret = br_ccm_check_tag(&ctx, &tag);
|
||||
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: Err:%i, Decrypted : %02x %02x %02x %02x %02x"), ret, payload[1],payload[2],payload[3],payload[4],payload[5]);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Err:%i, Decrypted : %02x %02x %02x %02x %02x"), ret, payload[1],payload[2],payload[3],payload[4],payload[5]);
|
||||
return ret-1; // -> -1=fail, 0=success
|
||||
}
|
||||
|
||||
@ -1168,7 +1168,7 @@ int MIParsePacket(const uint8_t* slotmac, struct mi_beacon_data_t *parsed, const
|
||||
parsed->devicetype = *((uint16_t *)(data + byteindex));
|
||||
byteindex += 2;
|
||||
parsed->framecnt = data[byteindex];
|
||||
//if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI frame %d"), parsed->framecnt);
|
||||
//if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: MI frame %d"), parsed->framecnt);
|
||||
byteindex++;
|
||||
|
||||
|
||||
@ -1184,7 +1184,7 @@ int MIParsePacket(const uint8_t* slotmac, struct mi_beacon_data_t *parsed, const
|
||||
byteindex += 6;
|
||||
}
|
||||
|
||||
int decres = 1;
|
||||
int decres = 1;
|
||||
// everything after MAC is encrypted if specified?
|
||||
if (parsed->framedata.isencrypted){
|
||||
if (len < byteindex + 3+4+1){
|
||||
@ -1217,17 +1217,17 @@ int MIParsePacket(const uint8_t* slotmac, struct mi_beacon_data_t *parsed, const
|
||||
break;
|
||||
case 0: // suceeded
|
||||
parsed->needkey = KEY_REQUIRED_AND_FOUND;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI payload decrypted"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Payload decrypted"));
|
||||
break;
|
||||
case -1: // key failed to work
|
||||
parsed->needkey = KEY_REQUIRED_AND_INVALID;
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("MI payload decrypt failed"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Payload decrypt failed"));
|
||||
parsed->payloadpresent = 0;
|
||||
return 0;
|
||||
break;
|
||||
case -2: // key not present
|
||||
parsed->needkey = KEY_REQUIRED_BUT_NOT_FOUND;
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("MI payload encrypted but no key"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Payload encrypted but no key"));
|
||||
parsed->payloadpresent = 0;
|
||||
return 0;
|
||||
break;
|
||||
@ -1262,7 +1262,7 @@ int MIParsePacket(const uint8_t* slotmac, struct mi_beacon_data_t *parsed, const
|
||||
}
|
||||
|
||||
if ((len - byteindex) == 0){
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI no payload"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: No payload"));
|
||||
parsed->payload.size = 0;
|
||||
parsed->payloadpresent = 0;
|
||||
return 0;
|
||||
@ -1271,14 +1271,14 @@ int MIParsePacket(const uint8_t* slotmac, struct mi_beacon_data_t *parsed, const
|
||||
// we have payload which did not need decrypt.
|
||||
if (decres == 1){
|
||||
parsed->needkey = KEY_NOT_REQUIRED;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI payload unencrypted"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Payload unencrypted"));
|
||||
}
|
||||
|
||||
// already decrypted if required
|
||||
parsed->payloadpresent = 1;
|
||||
memcpy(&parsed->payload, (data + byteindex), (len - byteindex));
|
||||
if (parsed->payload.size != (len - byteindex) - 3){
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI payload length mismatch"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Payload length mismatch"));
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -1319,7 +1319,7 @@ void MI32nullifyEndOfMQTT_DATA(){
|
||||
*/
|
||||
uint32_t MIBLEgetSensorSlot(const uint8_t *mac, uint16_t _type, uint8_t counter){
|
||||
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("%s: will test ID-type: %x"),D_CMND_MI32, _type);
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: will test ID-type: %x"),D_CMND_MI32, _type);
|
||||
bool _success = false;
|
||||
for (uint32_t i=0; i < MI_MI32_TYPES; i++){ // i < sizeof(kMI32DeviceID) gives compiler warning
|
||||
if(_type == kMI32DeviceID[i]){
|
||||
@ -1328,40 +1328,40 @@ uint32_t MIBLEgetSensorSlot(const uint8_t *mac, uint16_t _type, uint8_t counter)
|
||||
break;
|
||||
}
|
||||
else {
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("%s: ID-type is not: %x"),D_CMND_MI32,kMI32DeviceID[i]);
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: ID-type is not: %x"),D_CMND_MI32,kMI32DeviceID[i]);
|
||||
}
|
||||
}
|
||||
if(!_success) {
|
||||
_type = 1; // unknown
|
||||
}
|
||||
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("%s: vector size %u"),D_CMND_MI32, MIBLEsensors.size());
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: vector size %u"),D_CMND_MI32, MIBLEsensors.size());
|
||||
for(uint32_t i=0; i<MIBLEsensors.size(); i++){
|
||||
if(memcmp(mac, MIBLEsensors[i].MAC, 6)==0){
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Counters: %x %x"),MIBLEsensors[i].lastCnt, counter);
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Counters: %x %x"),MIBLEsensors[i].lastCnt, counter);
|
||||
if(MIBLEsensors[i].lastCnt==counter) {
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Old packet"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("%s: slot: %u/%u - ign repeat"),D_CMND_MI32, i, MIBLEsensors.size());
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: slot: %u/%u - ign repeat"),D_CMND_MI32, i, MIBLEsensors.size());
|
||||
//return 0xff; // packet received before, stop here
|
||||
}
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI frame %d, last %d"), counter, MIBLEsensors[i].lastCnt);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Frame %d, last %d"), counter, MIBLEsensors[i].lastCnt);
|
||||
MIBLEsensors[i].lastCnt = counter;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("%s: slot: %u/%u"),D_CMND_MI32, i, MIBLEsensors.size());
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: slot: %u/%u"),D_CMND_MI32, i, MIBLEsensors.size());
|
||||
|
||||
if (MIBLEsensors[i].type != _type){
|
||||
// this happens on incorrectly configured pvvx ATC firmware
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("%s: slot: %u - device type 0x%04x(%s) -> 0x%04x(%s) - check device is only sending one type of advert."),D_CMND_MI32, i,
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: %s: slot: %u - device type 0x%04x(%s) -> 0x%04x(%s) - check device is only sending one type of advert."),D_CMND_MI32, i,
|
||||
kMI32DeviceID[MIBLEsensors[i].type-1], kMI32DeviceType[MIBLEsensors[i].type-1], kMI32DeviceID[_type-1], kMI32DeviceType[_type-1]);
|
||||
MIBLEsensors[i].type = _type;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("%s: i: %x %x %x %x %x %x"),D_CMND_MI32, MIBLEsensors[i].MAC[5], MIBLEsensors[i].MAC[4],MIBLEsensors[i].MAC[3],MIBLEsensors[i].MAC[2],MIBLEsensors[i].MAC[1],MIBLEsensors[i].MAC[0]);
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("%s: n: %x %x %x %x %x %x"),D_CMND_MI32, mac[5], mac[4], mac[3],mac[2],mac[1],mac[0]);
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: i: %x %x %x %x %x %x"),D_CMND_MI32, MIBLEsensors[i].MAC[5], MIBLEsensors[i].MAC[4],MIBLEsensors[i].MAC[3],MIBLEsensors[i].MAC[2],MIBLEsensors[i].MAC[1],MIBLEsensors[i].MAC[0]);
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: n: %x %x %x %x %x %x"),D_CMND_MI32, mac[5], mac[4], mac[3],mac[2],mac[1],mac[0]);
|
||||
}
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("%s: new sensor -> slot: %u"),D_CMND_MI32, MIBLEsensors.size());
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("%s: found new sensor"),D_CMND_MI32);
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: new sensor -> slot: %u"),D_CMND_MI32, MIBLEsensors.size());
|
||||
//AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: found new sensor"),D_CMND_MI32);
|
||||
mi_sensor_t _newSensor;
|
||||
memset(&_newSensor, 0 , sizeof(_newSensor));
|
||||
memcpy(_newSensor.MAC, mac, 6);
|
||||
@ -1411,7 +1411,7 @@ uint32_t MIBLEgetSensorSlot(const uint8_t *mac, uint16_t _type, uint8_t counter)
|
||||
break;
|
||||
}
|
||||
MIBLEsensors.push_back(_newSensor);
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: new %s at slot: %u"),D_CMND_MI32, kMI32DeviceType[_type-1],MIBLEsensors.size()-1);
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: new %s at slot: %u"),D_CMND_MI32, kMI32DeviceType[_type-1],MIBLEsensors.size()-1);
|
||||
MI32.mode.shallShowStatusInfo = 1;
|
||||
return MIBLEsensors.size()-1;
|
||||
};
|
||||
@ -1444,7 +1444,7 @@ void MI32StatusInfo() {
|
||||
|
||||
int MI32scanCompleteCallback(NimBLEScanResults results){
|
||||
// we actually don't need to do anything here....
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: scancomplete"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Scan complete"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1473,7 +1473,7 @@ void MI32Init(void) {
|
||||
// note: for operations, we will set individual callbacks in the operations we request
|
||||
//void registerForOpCallbacks(const char *tag, BLE_ESP32::OPCOMPLETE_CALLBACK* pFn);
|
||||
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: init: request callbacks"));
|
||||
AddLog_P(LOG_LEVEL_INFO,PSTR("M32: init: request callbacks"));
|
||||
MI32.period = Settings.tele_period;
|
||||
MI32.mode.init = 1;
|
||||
return;
|
||||
@ -1496,19 +1496,19 @@ int MIParseBatt(int slot, uint8_t *data, int len){
|
||||
MIBLEsensors[slot].bat = value;
|
||||
if(MIBLEsensors[slot].type==MI_FLORA){
|
||||
if (len < 7){
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("FLORA: not enough bytes read for firmware?"));
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: FLORA: not enough bytes read for firmware?"));
|
||||
} else {
|
||||
memcpy(MIBLEsensors[slot].firmware, data+2, 5);
|
||||
MIBLEsensors[slot].firmware[5] = '\0';
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: FLORA Firmware: %s"),D_CMND_MI32,MIBLEsensors[slot].firmware);
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: FLORA Firmware: %s"),D_CMND_MI32,MIBLEsensors[slot].firmware);
|
||||
}
|
||||
}
|
||||
MIBLEsensors[slot].eventType.bat = 1;
|
||||
MIBLEsensors[slot].shallSendMQTT = 1;
|
||||
MI32.mode.shallTriggerTele = 1;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("Batt read for %s complete %d"), slotMAC, value);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Batt read for %s complete %d"), slotMAC, value);
|
||||
} else {
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Batt read for %s complete but out of range 1-101 (%d)"), slotMAC, value);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Batt read for %s complete but out of range 1-101 (%d)"), slotMAC, value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1534,13 +1534,13 @@ void MI32ParseATCPacket(const uint8_t * _buf, uint32_t length, const uint8_t *ad
|
||||
//uint16_t battery_mv; // mV
|
||||
//uint8_t battery_level; // 0..100 %
|
||||
//uint8_t counter; // measurement count
|
||||
//uint8_t flags;
|
||||
//uint8_t flags;
|
||||
|
||||
uint32_t _slot = MIBLEgetSensorSlot(addr, 0x0a1c, ppv_packet->counter); // This must be a hard-coded fake ID
|
||||
if(_slot==0xff) return;
|
||||
|
||||
if ((_slot >= 0) && (_slot < MIBLEsensors.size())){
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s:pvvx at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s:pvvx at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot);
|
||||
MIBLEsensors[_slot].RSSI=RSSI;
|
||||
MIBLEsensors[_slot].needkey=KEY_NOT_REQUIRED;
|
||||
|
||||
@ -1557,7 +1557,7 @@ void MI32ParseATCPacket(const uint8_t * _buf, uint32_t length, const uint8_t *ad
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("PVVX packet mac mismatch - ignored?"));
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: PVVX packet mac mismatch - ignored?"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -1571,9 +1571,9 @@ void MI32ParseATCPacket(const uint8_t * _buf, uint32_t length, const uint8_t *ad
|
||||
if (memcmp(addrrev, _packet->MAC, 6)){
|
||||
MI32_ReverseMAC(_packet->MAC);
|
||||
if (!memcmp(addrrev, _packet->MAC, 6)){
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("ATC packet with reversed MAC addr?"));
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: ATC packet with reversed MAC addr?"));
|
||||
} else {
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("ATC packet with MAC addr mismatch - is this mesh?"));
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: ATC packet with MAC addr mismatch - is this mesh?"));
|
||||
memcpy(addrrev, _packet->MAC, 6);
|
||||
}
|
||||
addr = addrrev;
|
||||
@ -1584,7 +1584,7 @@ void MI32ParseATCPacket(const uint8_t * _buf, uint32_t length, const uint8_t *ad
|
||||
if(_slot==0xff) return;
|
||||
|
||||
if ((_slot >= 0) && (_slot < MIBLEsensors.size())){
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s at slot %u"), kMI32DeviceType[MIBLEsensors[_slot].type-1],_slot);
|
||||
MIBLEsensors[_slot].RSSI=RSSI;
|
||||
MIBLEsensors[_slot].needkey=KEY_NOT_REQUIRED;
|
||||
|
||||
@ -1606,17 +1606,17 @@ void MI32ParseATCPacket(const uint8_t * _buf, uint32_t length, const uint8_t *ad
|
||||
////////////////////////////////////////////////////////////
|
||||
// this SHOULD parse any MI payload.
|
||||
int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){
|
||||
struct mi_beacon_data_payload_data_t *pld =
|
||||
struct mi_beacon_data_payload_data_t *pld =
|
||||
(struct mi_beacon_data_payload_data_t *) &parsed->payload.data;
|
||||
int res = 1;
|
||||
|
||||
|
||||
if (!parsed->payloadpresent){
|
||||
return 0;
|
||||
}
|
||||
|
||||
char tmp[20];
|
||||
BLE_ESP32::dump(tmp, 20, (uint8_t*)&(parsed->payload), parsed->payload.size+3);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("MI%d payload %s"), _slot, tmp);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: MI%d payload %s"), _slot, tmp);
|
||||
|
||||
switch(parsed->payload.type){
|
||||
case 0x01: // button press
|
||||
@ -1624,7 +1624,7 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){
|
||||
MIBLEsensors[_slot].eventType.Btn = 1;
|
||||
MI32.mode.shallTriggerTele = 1;
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x02:
|
||||
res = 0;
|
||||
break;
|
||||
case 0x03: {// motion? 1 byte
|
||||
@ -1636,22 +1636,22 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){
|
||||
if(_tempFloat<60){
|
||||
MIBLEsensors[_slot].temp=_tempFloat;
|
||||
MIBLEsensors[_slot].eventType.temp = 1;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("Mode 4: temp updated"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 4: temp updated"));
|
||||
} else {
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("Mode 4: temp ignored > 60 (%f)"), _tempFloat);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 4: temp ignored > 60 (%f)"), _tempFloat);
|
||||
}
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 4: U16: %u Temp"), _beacon.temp );
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 4: U16: %u Temp"), _beacon.temp );
|
||||
} break;
|
||||
case 0x06: {
|
||||
float _tempFloat=(float)(pld->hum)/10.0f;
|
||||
if(_tempFloat<101){
|
||||
MIBLEsensors[_slot].hum=_tempFloat;
|
||||
MIBLEsensors[_slot].eventType.hum = 1;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("Mode 6: hum updated"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 6: hum updated"));
|
||||
} else {
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("Mode 6: hum ignored > 101 (%f)"), _tempFloat);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 6: hum ignored > 101 (%f)"), _tempFloat);
|
||||
}
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 6: U16: %u Hum"), _beacon.hum);
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 6: U16: %u Hum"), _beacon.hum);
|
||||
} break;
|
||||
case 0x07:
|
||||
MIBLEsensors[_slot].lux=pld->lux & 0x00ffffff;
|
||||
@ -1659,19 +1659,19 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){
|
||||
MIBLEsensors[_slot].eventType.noMotion = 1;
|
||||
}
|
||||
MIBLEsensors[_slot].eventType.lux = 1;
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 7: U24: %u Lux"), _beacon.lux & 0x00ffffff);
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 7: U24: %u Lux"), _beacon.lux & 0x00ffffff);
|
||||
break;
|
||||
case 0x08:
|
||||
MIBLEsensors[_slot].moisture=pld->moist;
|
||||
MIBLEsensors[_slot].eventType.moist = 1;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("Mode 8: moisture updated"));
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 8: U8: %u Moisture"), _beacon.moist);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 8: moisture updated"));
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 8: U8: %u Moisture"), _beacon.moist);
|
||||
break;
|
||||
case 0x09: // 'conductivity'
|
||||
MIBLEsensors[_slot].fertility=pld->fert;
|
||||
MIBLEsensors[_slot].eventType.fert = 1;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("Mode 9: fertility updated"));
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 9: U16: %u Fertility"), _beacon.fert);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode 9: fertility updated"));
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 9: U16: %u Fertility"), _beacon.fert);
|
||||
break;
|
||||
case 0x0a:
|
||||
if(MI32.option.ignoreBogusBattery){
|
||||
@ -1683,31 +1683,31 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){
|
||||
if(pld->bat<101){
|
||||
MIBLEsensors[_slot].bat = pld->bat;
|
||||
MIBLEsensors[_slot].eventType.bat = 1;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("Mode a: bat updated"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode a: bat updated"));
|
||||
} else {
|
||||
MIBLEsensors[_slot].bat = 100;
|
||||
MIBLEsensors[_slot].eventType.bat = 1;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("Mode a: bat > 100 (%d)"), pld->bat);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode a: bat > 100 (%d)"), pld->bat);
|
||||
}
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode a: U8: %u %%"), _beacon.bat);
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode a: U8: %u %%"), _beacon.bat);
|
||||
break;
|
||||
case 0x0d:{
|
||||
float _tempFloat=(float)(pld->HT.temp)/10.0f;
|
||||
if(_tempFloat < 60){
|
||||
MIBLEsensors[_slot].temp = _tempFloat;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("Mode d: temp updated"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: temp updated"));
|
||||
} else {
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("Mode d: temp ignored > 60 (%f)"), _tempFloat);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: temp ignored > 60 (%f)"), _tempFloat);
|
||||
}
|
||||
_tempFloat=(float)(pld->HT.hum)/10.0f;
|
||||
if(_tempFloat < 100){
|
||||
MIBLEsensors[_slot].hum = _tempFloat;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("Mode d: hum updated"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: hum updated"));
|
||||
} else {
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("Mode d: hum ignored > 100 (%f)"), _tempFloat);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: Mode d: hum ignored > 100 (%f)"), _tempFloat);
|
||||
}
|
||||
MIBLEsensors[_slot].eventType.tempHum = 1;
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode d: U16: %x Temp U16: %x Hum"), _beacon.HT.temp, _beacon.HT.hum);
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode d: U16: %x Temp U16: %x Hum"), _beacon.HT.temp, _beacon.HT.hum);
|
||||
} break;
|
||||
case 0x0f:
|
||||
if (parsed->payload.ten != 0) break;
|
||||
@ -1718,7 +1718,7 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){
|
||||
MIBLEsensors[_slot].eventType.lux = 1;
|
||||
MIBLEsensors[_slot].NMT = 0;
|
||||
MI32.mode.shallTriggerTele = 1;
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("PIR: primary"),MIBLEsensors[_slot].lux );
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: PIR: primary"),MIBLEsensors[_slot].lux );
|
||||
break;
|
||||
case 0x10:{ // 'formaldehide'
|
||||
const uint16_t f = uint16_t(parsed->payload.data[0]) | (uint16_t(parsed->payload.data[1]) << 8);
|
||||
@ -1742,11 +1742,11 @@ int MI32parseMiPayload(int _slot, struct mi_beacon_data_t *parsed){
|
||||
MIBLEsensors[_slot].NMT = pld->NMT;
|
||||
MIBLEsensors[_slot].eventType.NMT = 1;
|
||||
MI32.mode.shallTriggerTele = 1;
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("Mode 17: NMT: %u seconds"), _beacon.NMT);
|
||||
// AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Mode 17: NMT: %u seconds"), _beacon.NMT);
|
||||
} break;
|
||||
|
||||
default: {
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("Unknown MI pld"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Unknown MI pld"));
|
||||
res = 0;
|
||||
} break;
|
||||
}
|
||||
@ -1771,7 +1771,7 @@ void MI32ParseResponse(const uint8_t *buf, uint16_t bufsize, const uint8_t* addr
|
||||
MI32_ReverseMAC(addrrev);
|
||||
|
||||
if (memcmp(addrrev, parsed.macdata.mac, 6)){
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("MI packet with MAC addr mismatch - is this mesh?"));
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: MI packet with MAC addr mismatch - is this mesh?"));
|
||||
memcpy(addrrev, parsed.macdata.mac, 6);
|
||||
MI32_ReverseMAC(addrrev);
|
||||
addr = addrrev;
|
||||
@ -1781,11 +1781,11 @@ void MI32ParseResponse(const uint8_t *buf, uint16_t bufsize, const uint8_t* addr
|
||||
if(_slot==0xff) return;
|
||||
if ((_slot >= 0) && (_slot < MIBLEsensors.size())){
|
||||
if (parsed.needkey != KEY_REQUIREMENT_UNKNOWN){
|
||||
MIBLEsensors[_slot].needkey = parsed.needkey;
|
||||
MIBLEsensors[_slot].needkey = parsed.needkey;
|
||||
}
|
||||
MIBLEsensors[_slot].RSSI=RSSI;
|
||||
if (!res){ // - if the payload is not valid
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("MIParsePacket returned %d"), res);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: MIParsePacket returned %d"), res);
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
@ -1806,7 +1806,7 @@ void MI32removeMIBLEsensor(uint8_t* MAC){
|
||||
TasAutoMutex localmutex(&slotmutex, "Mi32Rem");
|
||||
|
||||
MIBLEsensors.erase( std::remove_if( MIBLEsensors.begin() , MIBLEsensors.end(), [MAC]( mi_sensor_t _sensor )->bool
|
||||
{ return (memcmp(_sensor.MAC,MAC,6) == 0); }
|
||||
{ return (memcmp(_sensor.MAC,MAC,6) == 0); }
|
||||
), end( MIBLEsensors ) );
|
||||
}
|
||||
/***********************************************************************\
|
||||
@ -1814,14 +1814,14 @@ void MI32removeMIBLEsensor(uint8_t* MAC){
|
||||
\***********************************************************************/
|
||||
|
||||
void MI32notifyHT_LY(int slot, char *_buf, int len){
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("%s: raw data: %x%x%x%x%x%x%x"),D_CMND_MI32,_buf[0],_buf[1],_buf[2],_buf[3],_buf[4],_buf[5],_buf[6]);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: %s: raw data: %x%x%x%x%x%x%x"),D_CMND_MI32,_buf[0],_buf[1],_buf[2],_buf[3],_buf[4],_buf[5],_buf[6]);
|
||||
// the value 0b00 is 28.16 C?
|
||||
if(_buf[0] != 0 || _buf[1] != 0){
|
||||
memcpy(&LYWSD0x_HT,(void *)_buf,sizeof(LYWSD0x_HT));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("%s: T * 100: %u, H: %u, V: %u"),D_CMND_MI32,LYWSD0x_HT.temp,LYWSD0x_HT.hum, LYWSD0x_HT.volt);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: %s: T * 100: %u, H: %u, V: %u"),D_CMND_MI32,LYWSD0x_HT.temp,LYWSD0x_HT.hum, LYWSD0x_HT.volt);
|
||||
uint32_t _slot = slot;
|
||||
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("MIBLE: Sensor slot: %u"), _slot);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: MIBLE: Sensor slot: %u"), _slot);
|
||||
static float _tempFloat;
|
||||
_tempFloat=(float)(LYWSD0x_HT.temp)/100.0f;
|
||||
if(_tempFloat<60){
|
||||
@ -1831,7 +1831,7 @@ void MI32notifyHT_LY(int slot, char *_buf, int len){
|
||||
_tempFloat=(float)LYWSD0x_HT.hum;
|
||||
if(_tempFloat<100){
|
||||
MIBLEsensors[_slot].hum = _tempFloat;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("LYWSD0x: hum updated"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG_MORE,PSTR("M32: LYWSD0x: hum updated"));
|
||||
}
|
||||
MIBLEsensors[_slot].eventType.tempHum = 1;
|
||||
if (MIBLEsensors[_slot].type == MI_LYWSD03MMC || MIBLEsensors[_slot].type == MI_MHOC401){
|
||||
@ -1875,17 +1875,17 @@ void MI32Every50mSecond(){
|
||||
|
||||
void MI32EverySecond(bool restart){
|
||||
|
||||
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("MI32: onesec"));
|
||||
// AddLog_P(LOG_LEVEL_DEBUG_MORE, PSTR("M32: onesec"));
|
||||
MI32TimeoutSensors();
|
||||
|
||||
MI32ShowSomeSensors();
|
||||
|
||||
// read a battery if
|
||||
// read a battery if
|
||||
// MI32.batteryreader.slot < filled and !MI32.batteryreader.active
|
||||
readOneBat();
|
||||
|
||||
|
||||
// read a sensor if
|
||||
// read a sensor if
|
||||
// MI32.sensorreader.slot < filled and !MI32.sensorreader.active
|
||||
// for sensors which need to get data through notify...
|
||||
readOneSensor();
|
||||
@ -1893,7 +1893,7 @@ void MI32EverySecond(bool restart){
|
||||
if (MI32.secondsCounter >= MI32.period){
|
||||
// only if we finished the last read
|
||||
if (MI32.sensorreader.slot >= MIBLEsensors.size()){
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("kick off readOneSensor"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Kick off readOneSensor"));
|
||||
// kick off notification sensor reading every period.
|
||||
MI32.sensorreader.slot = 0;
|
||||
MI32.secondsCounter = 0;
|
||||
@ -1903,11 +1903,11 @@ void MI32EverySecond(bool restart){
|
||||
|
||||
if (MI32.secondsCounter2 >= MI32.period){
|
||||
if (MI32.mqttCurrentSlot >= MIBLEsensors.size()){
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("kick off tele sending"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Kick off tele sending"));
|
||||
MI32.mqttCurrentSlot = 0;
|
||||
MI32.secondsCounter2 = 0;
|
||||
} else {
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("hit tele time, restarted but not finished last - lost from slot %d")+MI32.mqttCurrentSlot);
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Hit tele time, restarted but not finished last - lost from slot %d")+MI32.mqttCurrentSlot);
|
||||
MI32.mqttCurrentSlot = 0;
|
||||
MI32.secondsCounter2 = 0;
|
||||
}
|
||||
@ -1968,15 +1968,15 @@ void CmndMi32Time(void) {
|
||||
if (MIBLEsensors.size() > slot) {
|
||||
int res = genericTimeWriteFn(slot);
|
||||
if (res > 0){
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("MI32: will set Time"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: will set Time"));
|
||||
ResponseCmndNumber(slot);
|
||||
return;
|
||||
}
|
||||
if (res < 0) {
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("MI32: cannot set Time on sensor type"));
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: cannot set Time on sensor type"));
|
||||
}
|
||||
if (res == 0) {
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("MI32: cannot set Time right now"));
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: cannot set Time right now"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2009,15 +2009,15 @@ void CmndMi32Unit(void) {
|
||||
// TOGGLE unit?
|
||||
int res = genericUnitWriteFn(slot, -1);
|
||||
if (res > 0){
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("MI32: will toggle Unit"));
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: will toggle Unit"));
|
||||
ResponseCmndNumber(slot);
|
||||
return;
|
||||
}
|
||||
if (res < 0) {
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("MI32: cannot toggle Unit on sensor type"));
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: cannot toggle Unit on sensor type"));
|
||||
}
|
||||
if (res == 0) {
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("MI32: cannot toggle Unit right now"));
|
||||
AddLog_P(LOG_LEVEL_ERROR, PSTR("M32: cannot toggle Unit right now"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2058,7 +2058,7 @@ void CmndMi32Block(void){
|
||||
} break;
|
||||
default:
|
||||
case 1:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
MI32BlockListResp();
|
||||
return;
|
||||
@ -2076,7 +2076,7 @@ void CmndMi32Block(void){
|
||||
case 0: {
|
||||
//TasAutoMutex localmutex(&slotmutex, "Mi32Block2");
|
||||
MIBLEBlockList.erase( std::remove_if( begin( MIBLEBlockList ), end( MIBLEBlockList ), [_MACasBytes]( MAC_t& _entry )->bool
|
||||
{ return (memcmp(_entry.buf,_MACasBytes.buf,6) == 0); }
|
||||
{ return (memcmp(_entry.buf,_MACasBytes.buf,6) == 0); }
|
||||
), end( MIBLEBlockList ) );
|
||||
} break;
|
||||
case 1: {
|
||||
@ -2091,8 +2091,8 @@ void CmndMi32Block(void){
|
||||
MIBLEBlockList.push_back(_MACasBytes);
|
||||
MI32removeMIBLEsensor(_MACasBytes.buf);
|
||||
}
|
||||
// AddLog_P(LOG_LEVEL_INFO,PSTR("MI32: size of ilist: %u"), MIBLEBlockList.size());
|
||||
} break;
|
||||
// AddLog_P(LOG_LEVEL_INFO,PSTR("M32: size of ilist: %u"), MIBLEBlockList.size());
|
||||
} break;
|
||||
}
|
||||
MI32BlockListResp();
|
||||
}
|
||||
@ -2126,7 +2126,7 @@ void MI32KeyListResp(){
|
||||
ToHex_P(MIBLEbindKeys[i].MAC,6,tmp,20,0);
|
||||
char key[16*2+1];
|
||||
ToHex_P(MIBLEbindKeys[i].key,16,key,33,0);
|
||||
|
||||
|
||||
ResponseAppend_P(PSTR("\"%s\":\"%s\""), tmp, key);
|
||||
}
|
||||
ResponseAppend_P(PSTR("}}"));
|
||||
@ -2136,7 +2136,7 @@ void MI32KeyListResp(){
|
||||
void CmndMi32Keys(void){
|
||||
#ifdef BLE_ESP32_ALIASES
|
||||
int op = XdrvMailbox.index;
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("key %d %s"), op, XdrvMailbox.data);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Key %d %s"), op, XdrvMailbox.data);
|
||||
|
||||
int res = -1;
|
||||
switch(op){
|
||||
@ -2175,7 +2175,7 @@ void CmndMi32Keys(void){
|
||||
return;
|
||||
}
|
||||
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("Add key mac %s = key %s"), mac, key);
|
||||
AddLog_P(LOG_LEVEL_ERROR,PSTR("M32: Add key mac %s = key %s"), mac, key);
|
||||
char tmp[20];
|
||||
// convert mac back to string
|
||||
ToHex_P(addr,6,tmp,20,0);
|
||||
@ -2186,7 +2186,7 @@ void CmndMi32Keys(void){
|
||||
} while (p);
|
||||
|
||||
if (added){
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("Added %d Keys"), added);
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Added %d Keys"), added);
|
||||
MI32KeyListResp();
|
||||
} else {
|
||||
MI32KeyListResp();
|
||||
@ -2194,7 +2194,7 @@ void CmndMi32Keys(void){
|
||||
return;
|
||||
} break;
|
||||
case 2:{ // clear
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32Keys clearing %d"), MIBLEbindKeys.size());
|
||||
if (BLE_ESP32::BLEDebugMode > 0) AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Keys clearing %d"), MIBLEbindKeys.size());
|
||||
for (int i = MIBLEbindKeys.size()-1; i >= 0; i--){
|
||||
MIBLEbindKeys.pop_back();
|
||||
}
|
||||
@ -2232,7 +2232,7 @@ const char HTTP_MI32_HL[] PROGMEM = "{s}<hr>{m}<hr>{e}";
|
||||
const char HTTP_NEEDKEY[] PROGMEM = "{s}%s <a target=\"_blank\" href=\""
|
||||
"https://btsimonh.github.io/atc1441.github.io/TelinkFlasherTasmota.html?mac=%s&cb=http%%3A%%2F%%2F%s%%2Fmikey"
|
||||
"\">%s</a>{m} {e}";
|
||||
|
||||
|
||||
|
||||
const char HTTP_PAIRING[] PROGMEM = "{s}%s Pair Button Pressed{m} {e}";
|
||||
|
||||
@ -2246,10 +2246,10 @@ const char HTTP_MI_KEY_STYLE[] PROGMEM = "";
|
||||
#define D_MI32_KEY "MI32 Set Key"
|
||||
|
||||
void HandleMI32Key(){
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("HandleMI32Key hit"));
|
||||
if (!HttpCheckPriviledgedAccess()) {
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("!HttpCheckPriviledgedAccess()"));
|
||||
return;
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: HandleMI32Key hit"));
|
||||
if (!HttpCheckPriviledgedAccess()) {
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("M32: !HttpCheckPriviledgedAccess()"));
|
||||
return;
|
||||
}
|
||||
WSContentStart_P(PSTR(D_MI32_KEY));
|
||||
WSContentSendStyle_P(HTTP_MI_KEY_STYLE);
|
||||
@ -2286,13 +2286,13 @@ void MI32TimeoutSensors(){
|
||||
// so block for as long as it takes.
|
||||
|
||||
// PROBLEM: when we take this, it hangs the BLE loop.
|
||||
// BUT, devicePresent uses the
|
||||
// BUT, devicePresent uses the
|
||||
// remove devices for which the adverts have timed out
|
||||
for (int i = MIBLEsensors.size()-1; i >= 0 ; i--) {
|
||||
//if (MIBLEsensors[i].MAC[2] || MIBLEsensors[i].MAC[3] || MIBLEsensors[i].MAC[4] || MIBLEsensors[i].MAC[5]){
|
||||
if (!BLE_ESP32::devicePresent(MIBLEsensors[i].MAC)){
|
||||
uint8_t *mac = MIBLEsensors[i].MAC;
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("MI32: dev no longer present MAC: %02x%02x%02x%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: Dev no longer present MAC: %02x%02x%02x%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
TasAutoMutex localmutex(&slotmutex, "Mi32Timeout");
|
||||
MIBLEsensors.erase(MIBLEsensors.begin() + i);
|
||||
}
|
||||
@ -2313,7 +2313,7 @@ void MI32GetOneSensorJson(int slot){
|
||||
ResponseAppend_P(PSTR("\"MAC\":\"%02x%02x%02x%02x%02x%02x\""),
|
||||
p->MAC[0], p->MAC[1], p->MAC[2],
|
||||
p->MAC[3], p->MAC[4], p->MAC[5]);
|
||||
|
||||
|
||||
if((!MI32.mode.triggeredTele && !MI32.option.minimalSummary)||MI32.mode.triggeredTele){
|
||||
bool tempHumSended = false;
|
||||
if(p->feature.tempHum){
|
||||
@ -2497,7 +2497,7 @@ void MI32ShowSomeSensors(){
|
||||
}
|
||||
ResponseAppend_P(PSTR("}"));
|
||||
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain);
|
||||
//AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data);
|
||||
//AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: show some %d %s"),D_CMND_MI32, MI32.mqttCurrentSlot, TasmotaGlobal.mqtt_data);
|
||||
|
||||
#ifdef USE_RULES
|
||||
RulesTeleperiod(); // Allow rule based HA messages
|
||||
@ -2547,7 +2547,7 @@ void MI32ShowTriggeredSensors(){
|
||||
if (cnt){ // if we got one, then publish
|
||||
ResponseAppend_P(PSTR("}"));
|
||||
MqttPublishPrefixTopic_P(STAT, PSTR(D_RSLT_SENSOR), Settings.flag.mqtt_sensor_retain);
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("%s: triggered %d %s"),D_CMND_MI32, sensor, TasmotaGlobal.mqtt_data);
|
||||
AddLog_P(LOG_LEVEL_DEBUG,PSTR("M32: %s: triggered %d %s"),D_CMND_MI32, sensor, TasmotaGlobal.mqtt_data);
|
||||
|
||||
#ifdef USE_RULES
|
||||
RulesTeleperiod(); // Allow rule based HA messages
|
||||
@ -2565,7 +2565,7 @@ void MI32Show(bool json)
|
||||
// don't detect half-added ones here
|
||||
int numsensors = MIBLEsensors.size();
|
||||
|
||||
if (json) {
|
||||
if (json) {
|
||||
// TELE JSON messages now do nothing here, apart from set MI32.mqttCurrentSlot
|
||||
// which will trigger send next second of up to 4 sensors, then the next four in the next second, etc.
|
||||
//MI32.mqttCurrentSlot = 0;
|
||||
@ -2576,7 +2576,7 @@ void MI32Show(bool json)
|
||||
static uint16_t _counter = 0;
|
||||
int32_t i = _page * MI32.perPage;
|
||||
uint32_t j = i + MI32.perPage;
|
||||
|
||||
|
||||
if (j+1 > numsensors){
|
||||
j = numsensors;
|
||||
}
|
||||
|
BIN
tools/fw_SonoffZigbeeBridge_ezsp/ncp-uart-sw_6.7.8_115200.ota
Normal file
BIN
tools/fw_SonoffZigbeeBridge_ezsp/ncp-uart-sw_6.7.8_115200.ota
Normal file
Binary file not shown.
@ -3,8 +3,7 @@
|
||||
## EmberZNet NCP UART EZSP firmware signed for Sonoff ZBBridge
|
||||
|
||||
- `ncp-uart-sw_6.7.6_115200.ota` - recommended stable version for EZSP v6, EZSP v7, and EZSP v8 compatible hosts.
|
||||
- `ncp-uart-sw-6.8.0.1_115200.ota` - latest cutting-edge version. largely untested and only for experimentation with EZSP v8 compatible hosts.
|
||||
- `ncp-uart-sw_6.5.5_115200.ota` - legacy version for EZSP v4, EZSP v5, EZSP v6, or EZSP v7 compatible hosts.
|
||||
- `ncp-uart-sw_6.7.8_115200.ota` - release candidate, supposedly fixing IKEA battery drain issue.
|
||||
|
||||
## EmberZNet and EZSP Protocol Versions
|
||||
|
||||
@ -13,3 +12,7 @@ Silicon Labs do not currently have a consolidated list of changes by EmberZNet S
|
||||
The largest change was between EZSP v4 (first added in EmberZNet 4.7.2 SDK) and EZSP v5 that was added in EmberZNet 5.9.0 SDK which requires the Legacy Frame ID 0xFF. The change from EZSP v5 to EZSP v6 was done in EmberZNet 6.0.0 SDK. The change from EZSP v6 to EZSP v7 was in EmberZNet 6.4.0 SDK. EmberZNet 6.7.0 SDK added EZSP v8 (and Secure EZSP Protocol Version 2).
|
||||
|
||||
Perhaps more important to know is that EZSP v5, v6 and v7 (EmberZNet 6.6.x.x) use the same framing format, but EmberZNet 6.7.x.x/EZSP v8 introduced new framing format and expanded command id field from 8 bits to 16 bits.
|
||||
|
||||
## Archived Versions
|
||||
|
||||
- `ncp-uart-sw_6.5.5_115200.ota` - legacy version for EZSP v4, EZSP v5, EZSP v6, or EZSP v7 compatible hosts.
|
Loading…
x
Reference in New Issue
Block a user