mirror of https://github.com/arendst/Tasmota.git
Merge branch 'development' of https://github.com/arendst/Sonoff-Tasmota into development
This commit is contained in:
commit
6f26c1333a
|
@ -4,39 +4,61 @@ about: Create a report to help us improve
|
|||
|
||||
---
|
||||
|
||||
**IMPORTANT NOTICE**
|
||||
If you do not complete the template below it is likely that your issue will not be addressed. When providing information about your issue please be as extensive as possible so that it can be solved by as little as possible responses.
|
||||
<GUIDE>
|
||||
|
||||
**FAILURE TO COMPLETE THE REQUESTED INFORMATION WILL RESULT IN YOUR ISSUE BEING CLOSED**
|
||||
<This BUG issue template is meant to REPORT Tasmota software BUGS ONLY>
|
||||
|
||||
<Please DO NOT OPEN AN ISSUE:>
|
||||
<If your Tasmota version is not the latest, please update before posting. Your issue might be already solved. Latest precompiled bins of Tasmota can be downloaded from http://thehackbox.org/tasmota/>
|
||||
<If your issue is a flashing issue, please address that to the Tasmota Support Chat>
|
||||
<If your issue is compilation problem, please address that to the Tasmota Support Chat>
|
||||
<If your issue has been addresed before (duplicated issue), please ask in the original issue>
|
||||
<If your issue is wifi problem or mqtt problem, please try first the steps provided in troubleshooting of the wiki>
|
||||
|
||||
**Describe the bug**
|
||||
### BUG DESCRIPTION
|
||||
_A clear and concise description of what the bug is._
|
||||
|
||||
|
||||
_Also, make sure these boxes are checked [x] before submitting your issue - Thank you!_
|
||||
- [ ] _Searched the problem in issues and in the wiki_
|
||||
- [ ] _Hardware used_ :
|
||||
- [ ] _Development/Compiler/Upload tools used_ :
|
||||
- [ ] _If a pre-compiled release or development binary was used, which one?_ :
|
||||
- [ ] _You have tried latest release or development binaries?_ :
|
||||
- [ ] _Provide the output of command_``status 0`` :
|
||||
### REQUESTED INFORMATION
|
||||
_Make sure these boxes are checked before submitting your issue. Thank you_
|
||||
|
||||
**FAILURE TO COMPLETE THE REQUESTED INFORMATION WILL RESULT IN YOUR ISSUE BEING CLOSED**
|
||||
|
||||
- [ ] Read the [Contributing Guide and Policy](https://github.com/arendst/Sonoff-Tasmota/blob/development/CONTRIBUTING.md) and [the Code of Conduct](https://github.com/arendst/Sonoff-Tasmota/blob/development/CODE_OF_CONDUCT.md)
|
||||
- [ ] Searched the problem in issues (https://github.com/arendst/Sonoff-Tasmota/issues)
|
||||
- [ ] Searched the problem in the wiki (https://github.com/arendst/Sonoff-Tasmota/wiki/Troubleshooting)
|
||||
- [ ] Searched the problem in the forum (https://groups.google.com/d/forum/sonoffusers)
|
||||
- [ ] Searched the problem in the chat (https://discord.gg/Ks2Kzd4)
|
||||
- [ ] Device used (i.e. Sonoff Basic) : _____
|
||||
- [ ] Tasmota binary firmware version number used : ____ / (pre-compiled or self-compiled ?)
|
||||
- [ ] Development IDE - Compiler / Upload tools used : ____ / ____
|
||||
- [ ] Provide the output of command ``status 0`` :
|
||||
```
|
||||
STATUS 0 OUTPUT HERE - DO NOT DELETE THE MARKERS ABOVE AND BELOW THIS LINE
|
||||
STATUS 0 OUTPUT HERE:
|
||||
|
||||
|
||||
```
|
||||
- [ ] Provide the output of console when you experience your issue if apply :
|
||||
_(Please use_ ``weblog 4`` _for more debug information)_
|
||||
```
|
||||
CONSOLE OUTPUT HERE:
|
||||
|
||||
|
||||
```
|
||||
|
||||
**To Reproduce**
|
||||
### TO REPRODUCE
|
||||
_Steps to reproduce the behavior:_
|
||||
|
||||
|
||||
**Expected behavior**
|
||||
### EXPECTED BEHAVIOUR
|
||||
_A clear and concise description of what you expected to happen._
|
||||
|
||||
|
||||
**Screenshots**
|
||||
### SCREENSHOTS
|
||||
_If applicable, add screenshots to help explain your problem._
|
||||
|
||||
|
||||
**Additional context**
|
||||
### ADDITIONAL CONTEXT
|
||||
_Add any other context about the problem here._
|
||||
|
||||
|
||||
|
|
|
@ -4,24 +4,47 @@ about: Users Troubleshooting Help
|
|||
|
||||
---
|
||||
|
||||
**IMPORTANT NOTICE**
|
||||
If you do not complete the template below it is likely that your issue will not be addressed. When providing information about your issue please be as extensive as possible so that it can be solved by as little as possible responses.
|
||||
<GUIDE>
|
||||
|
||||
<This troubleshooting issue template is meant to help Tasmota users with difficult problems. It is aimed to be opened if using the wiki and the support chat could not solve the issue. The Github Issue tracker is NOT a general discussion forum>
|
||||
|
||||
<Please DO NOT OPEN AN ISSUE:>
|
||||
<If you have general questions or you need help on Tasmota usage, go to the Tasmota support chat>
|
||||
<If your Tasmota version is not the latest, please update before posting. Your issue might be already solved. Latest precompiled bins of Tasmota can be downloaded from http://thehackbox.org/tasmota/>
|
||||
<If your issue is a new device, please use the Tasmota Template Feature. See wiki for that>
|
||||
<If your issue is a flashing issue, please address that to the Tasmota Support Chat>
|
||||
<If your issue is compilation problem, please address that to the Tasmota Support Chat>
|
||||
<If your issue has been addresed before (duplicated issue), please ask in the original issue>
|
||||
<If your issue is wifi problem or mqtt problem, please try first the steps provided in troubleshooting of the wiki>
|
||||
|
||||
### ISSUE DESCRIPTION - TROUBLESHOOTING
|
||||
_A clear description of what the issue is and be as extensive as possible_
|
||||
|
||||
|
||||
### REQUESTED INFORMATION
|
||||
_Make sure these boxes are checked before submitting your issue. Thank you_
|
||||
|
||||
**FAILURE TO COMPLETE THE REQUESTED INFORMATION WILL RESULT IN YOUR ISSUE BEING CLOSED**
|
||||
|
||||
Make sure these boxes are checked [x] before submitting your issue - Thank you!
|
||||
|
||||
- [ ] Read the [Contributing Guide and Policy](https://github.com/arendst/Sonoff-Tasmota/blob/development/CONTRIBUTING.md) and [the Code of Conduct](https://github.com/arendst/Sonoff-Tasmota/blob/development/CODE_OF_CONDUCT.md)
|
||||
- [ ] Searched the problem in issues (https://github.com/arendst/Sonoff-Tasmota/issues)
|
||||
- [ ] Searched the problem in the wiki (https://github.com/arendst/Sonoff-Tasmota/wiki/Troubleshooting)
|
||||
- [ ] Searched the problem in the forum (https://groups.google.com/d/forum/sonoffusers)
|
||||
- [ ] Searched the problem in the chat (https://discord.gg/Ks2Kzd4)
|
||||
- [ ] Development/Compiler/Upload tools used :
|
||||
- [ ] Hardware used :
|
||||
- [ ] If a pre-compiled release or development binary was used, which one? :
|
||||
- [ ] You have tried latest release or development binaries? :
|
||||
- [ ] Device used (i.e. Sonoff Basic) : _____
|
||||
- [ ] Tasmota binary firmware version number used : ____ / (pre-compiled or self-compiled ?)
|
||||
- [ ] Development IDE - Compiler / Upload tools used : ____ / ____
|
||||
- [ ] Provide the output of command ``status 0`` :
|
||||
```
|
||||
STATUS 0 OUTPUT HERE
|
||||
```
|
||||
STATUS 0 OUTPUT HERE:
|
||||
|
||||
|
||||
```
|
||||
- [ ] Provide the output of console when you experience your issue if apply :
|
||||
_(Please use_ ``weblog 4`` _for more debug information)_
|
||||
```
|
||||
CONSOLE OUTPUT HERE:
|
||||
|
||||
|
||||
```
|
||||
**(Please, remember to close the issue when the problem has been addressed)**
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
## Description:
|
||||
|
||||
**Related issue (if applicable):** fixes #<Sonoff-Tasmota issue number goes here>
|
||||
|
||||
## Checklist:
|
||||
- [ ] The pull request is done against the dev branch
|
||||
- [ ] Only relevant files were touched (Also beware if your editor has auto-formatting feature enabled)
|
||||
- [ ] Only one feature/fix was added per PR.
|
||||
- [ ] The code change is tested and works.
|
||||
- [ ] The code change pass travis tests. **Your PR cannot be merged unless tests pass**
|
|
@ -1,9 +1,9 @@
|
|||
# Number of days of inactivity before an Issue or Pull Request becomes stale
|
||||
daysUntilStale: 45
|
||||
daysUntilStale: 25
|
||||
|
||||
# Number of days of inactivity before a stale Issue or Pull Request is closed.
|
||||
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
|
||||
daysUntilClose: 15
|
||||
daysUntilClose: 5
|
||||
|
||||
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
|
||||
exemptLabels:
|
||||
|
@ -37,4 +37,4 @@ closeComment: >
|
|||
limitPerRun: 30
|
||||
|
||||
# Limit to only `issues` or `pulls`
|
||||
only: issues
|
||||
#only: issues
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our project and
|
||||
our community a harassment-free experience for everyone, regardless of age, body
|
||||
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||
level of experience, education, socio-economic status, nationality, personal
|
||||
appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment
|
||||
include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||
advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic
|
||||
address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable
|
||||
behavior and are expected to take appropriate and fair corrective action in
|
||||
response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or
|
||||
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||
permanently any contributor for other behaviors that they deem inappropriate,
|
||||
threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces
|
||||
when an individual is representing the project or its community. Examples of
|
||||
representing a project or community include using an official project e-mail
|
||||
address, posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event. Representation of a project may be
|
||||
further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported by contacting the project team at https://sidweb.nl/cms3/en/contact. All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is deemed necessary and appropriate to the circumstances. The project team is
|
||||
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||
Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||
faith may face temporary or permanent repercussions as determined by other
|
||||
members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
|
||||
For answers to common questions about this code of conduct, see
|
||||
https://www.contributor-covenant.org/faq
|
|
@ -0,0 +1,63 @@
|
|||
# Contributing to Sonoff-Tasmota
|
||||
|
||||
**Any contribution helps our team and makes Tasmota better for the entire community!**
|
||||
|
||||
Everybody is welcome and invited to contribute to Sonoff-Tasmota Project by:
|
||||
|
||||
* Testing newly released features and reporting issues.
|
||||
* Providing Pull Requests (Features, Proof of Concepts, Language files or Fixes)
|
||||
* Contributing missing documentation for features and devices on our [Wiki](https://github.com/arendst/Sonoff-Tasmota/wiki/Contributing)
|
||||
|
||||
This document describes rules that are in effect for this repository, meant for handling issues by contributors in the issue tracker and PRs.
|
||||
|
||||
## Opening New Issues
|
||||
|
||||
**Issue tracker is NOT a general discussion forum!**
|
||||
1. Opening an issue means that a problem exists in the code and should be addressed by the project contributors.
|
||||
2. When opening an issue, it is required to fill out the presented template. The requested information is important! If the template is ignored or insufficient info about the issue is provided, the issue may be closed.
|
||||
3. Questions of type "How do I..." or "Can you please help me with..." or "Can Tasmota do..." WILL NOT be handled here. Such questions should be directed at a discussion forum or to the Tasmota Support Chat. All issues of this type will be closed with a simple reference to this contributing policy.
|
||||
4. Issues about topics already handled in the documentation will be closed in a similar manner.
|
||||
5. Issues for unmerged PRs will be closed. If there is an issue with a PR, the explanation should be added to the PR itself.
|
||||
6. Issues with accompanied investigation that shows the root of the problem should be given priority.
|
||||
7. Duplicate issues will be closed.
|
||||
|
||||
## Triaging of Issues/PR's
|
||||
|
||||
1. Any contributor to the project can participate in the triaging process, if he/she chooses to do so.
|
||||
2. An issue that needs to be closed, either due to not complying with this policy, or for other reasons, should be closed by a contributor.
|
||||
3. Issues that are accepted should be marked with appropriate labels.
|
||||
4. Issues that could impact functionality for many users should be considered severe.
|
||||
5. Issues caused by the SDK or chip should not be marked severe, as there usually isn’t much to be done. Common sense should be applied when deciding. Such issues should be documented in the Wiki, for reference by users.
|
||||
6. Issues with feature requests should be discussed for viability/desirability.
|
||||
7. Feature requests or changes that are meant to address a very specific/limited use case, especially if at the expense of increased code complexity, may be denied, or may be required to be redesigned, generalized, or simplified.
|
||||
8. Feature requests that are not accompanied by a PR:
|
||||
* could be closed immediately (denied).
|
||||
* could be closed after some predetermined period of time (left as candidate for somebody to pick up).
|
||||
9. In some cases, feedback may be requested from the issue reporter, either as additional info for clarification, additional testing, or other. If no feedback is provided, the issue may be closed by a contributor or after 30 days by the STALE bot.
|
||||
|
||||
## Pull requests
|
||||
|
||||
A Pull Request (PR) is the process where code modifications are managed in GitHub.
|
||||
|
||||
The process is straight-forward.
|
||||
|
||||
- Read [How to get faster PR reviews](https://github.com/kubernetes/community/blob/master/contributors/guide/pull-requests.md#best-practices-for-faster-reviews) by Kubernetes (but skip step 0)
|
||||
- Fork the Sonoff-Tasmota Repository [git repository](https://github.com/arendst/Sonoff-Tasmota).
|
||||
- Write/Change the code in your Fork for a new feature, bug fix, new sensor, optimization, etc.
|
||||
- Ensure tests work.
|
||||
- Create a Pull Request against the [**dev**](https://github.com/arendst/Sonoff-Tasmota/tree/dev) branch of Sonoff-Tasmota.
|
||||
|
||||
1. All pull requests must be done against the dev branch.
|
||||
2. Only relevant files should be touched (Also beware if your editor has auto-formatting feature enabled).
|
||||
3. Only one feature/fix should be added per PR.
|
||||
4. If adding a new functionality (new hardware, new library support) not related to an existing component move it to it's own modules (.ino file).
|
||||
5. PRs that don't compile (break Travis) or cause coding errors will not be merged. Please fix the issue. Same goes for PRs that are raised against older commit in dev - you might need to rebase and resolve conflicts.
|
||||
6. All pull requests should undergo peer review by at least one contributor other than the creator, excepts for the owner.
|
||||
7. All pull requests should consider updates to the documentation.
|
||||
8. Pull requests that address an outstanding issue, particularly an issue deemed to be severe, should be given priority.
|
||||
9. If a PR is accepted, then it should undergo review and updated based on the feedback provided, then merged.
|
||||
10. Pull requests that don't meet the above will be denied and closed.
|
||||
|
||||
<Other>
|
||||
<A table should be maintained for relating maintainers and components. When triaging, this is essential to figure out if someone in particular should be consulted about specific changes.>
|
||||
<A stable release cadence should be established, e.g.: every month.>
|
|
@ -0,0 +1,22 @@
|
|||
# Sonoff-Tasmota Support
|
||||
|
||||
If you're looking for support on **Sonoff-Tasmota** there are some options available:
|
||||
|
||||
### Documentation:
|
||||
|
||||
* [Wiki Pages](https://github.com/arendst/Sonoff-Tasmota/wiki): For information on how to Flash Tasmota, configure and use it.
|
||||
* [Troubleshooting Information](https://github.com/arendst/Sonoff-Tasmota/wiki/Troubleshooting): For information on common problems and solutions.
|
||||
* [Commands Information](https://github.com/arendst/Sonoff-Tasmota/wiki/Commands): For information on all the commands supported by Tasmota.
|
||||
|
||||
### Support's Community:
|
||||
|
||||
* [Tasmota Forum](https://groups.google.com/d/forum/sonoffusers): For usage and discussions.
|
||||
* [Tasmota Support Chat](https://discord.gg/Ks2Kzd4): For support, troubleshooting and general questions. You have better chances to get fast answers from members of the Tasmota Community.
|
||||
* [Search in Issues](https://github.com/arendst/Sonoff-Tasmota/issues): You might find an answer to your question by searching current or closed issues.
|
||||
|
||||
### Developers' Community:
|
||||
|
||||
* [Bug Report](https://github.com/arendst/Sonoff-Tasmota/issues/new?template=Bug_report.md): For reporting Bugs of Tasmota Software.
|
||||
* [Feature Request](https://github.com/arendst/Sonoff-Tasmota/issues/new?template=Feature_request.md): For requesting features/functions to Tasmota Software.
|
||||
* [Troubleshooting](https://github.com/arendst/Sonoff-Tasmota/issues/new?template=Custom.md): As a last resort, you can open new *Troubleshooting* issue on GitHub if the solution could not be found using the other channels. Just remember: the more info you provide the more chances you'll have to get an accurate answer.
|
||||
* [Issue a question](https://github.com/arendst/Sonoff-Tasmota/issues/new/choose): As a last resort, you can open new *Question* issue on GitHub if the answer could not be found using the other channels. Just remember: the more info you provide the more chances you'll have to get an accurate answer.
|
|
@ -1,8 +1,18 @@
|
|||
/* 6.4.1.19 20190222
|
||||
/* 6.4.1.21 20190309
|
||||
* Fix exception on GUI Configure Logging and Configure Other (#5424)
|
||||
*
|
||||
* 6.4.1.20 20190304
|
||||
* Changed webserver content handling from single String to small Chunks increasing RAM
|
||||
* Changed logging message handling
|
||||
* Fix additional characters in fallbacktopic, hostname and mqttclient on core 2.5.0 (#5359, #5417)
|
||||
* Add command Template 255 to copy module configuration over to current active template and store as user template named Merged (#5371)
|
||||
*
|
||||
* 6.4.1.19 20190222
|
||||
* Add command SetOption37 for RGBCW color mapping (#5326)
|
||||
* Add Korean language translations (#5344)
|
||||
* Fix Energy TotalStartTime when commands EnergyReset0 and/or EnergyReset3 used (#5373)
|
||||
* Fix DS18S20 temperature calculation (#5375)
|
||||
* Fix float calculations in range from 0 to -1 (#5386)
|
||||
*
|
||||
* 6.4.1.18 20190221
|
||||
* Fix some exceptions and watchdogs due to lack of stack space - part 1 (#5215)
|
||||
|
|
|
@ -280,8 +280,8 @@
|
|||
|
||||
// -- Rules ---------------------------------------
|
||||
#define USE_RULES // Add support for rules (+4k4 code)
|
||||
#define USE_EXPRESSION // Add support for expression evaluation in rules (+3k2 code, +64 bytes mem)
|
||||
#define SUPPORT_MQTT_EVENT // Support trigger event with MQTT subscriptions (+3k5 code)
|
||||
// #define USE_EXPRESSION // Add support for expression evaluation in rules (+3k2 code, +64 bytes mem)
|
||||
// #define SUPPORT_MQTT_EVENT // Support trigger event with MQTT subscriptions (+3k5 code)
|
||||
|
||||
// -- Internal Analog input -----------------------
|
||||
#define USE_ADC_VCC // Display Vcc in Power status. Disable for use as Analog input on selected devices
|
||||
|
@ -291,7 +291,7 @@
|
|||
//#define USE_DS18x20_LEGACY // Optional for more than one DS18x20 sensors with dynamic scan using library OneWire (+1k5 code)
|
||||
#define USE_DS18x20 // Optional for more than one DS18x20 sensors with id sort, single scan and read retry (+1k3 code)
|
||||
// #define W1_PARASITE_POWER // If using USE_DS18x20 then optimize for parasite powered sensors
|
||||
// #define DS18B20_INTERNAL_PULLUP // Use INPUT_PULLUP internal pullup resistors for single DS18B20
|
||||
// #define DS18B20_INTERNAL_PULLUP // Use INPUT_PULLUP internal pullup resistors for single DS18B20
|
||||
|
||||
// -- I2C sensors ---------------------------------
|
||||
#define USE_I2C // I2C using library wire (+10k code, 0k2 mem, 124 iram)
|
||||
|
|
|
@ -435,9 +435,8 @@ void SettingsSave(uint8_t rotate)
|
|||
delay(1);
|
||||
}
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_CONFIG D_SAVED_TO_FLASH_AT " %X, " D_COUNT " %d, " D_BYTES " %d"),
|
||||
settings_location, Settings.save_flag, sizeof(SYSCFG));
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG D_SAVED_TO_FLASH_AT " %X, " D_COUNT " %d, " D_BYTES " %d"), settings_location, Settings.save_flag, sizeof(SYSCFG));
|
||||
|
||||
settings_crc = Settings.cfg_crc;
|
||||
}
|
||||
|
@ -482,9 +481,7 @@ void SettingsLoad(void)
|
|||
}
|
||||
if (settings_location > 0) {
|
||||
ESP.flashRead(settings_location * SPI_FLASH_SEC_SIZE, (uint32*)&Settings, sizeof(SYSCFG));
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_CONFIG D_LOADED_FROM_FLASH_AT " %X, " D_COUNT " %d"),
|
||||
settings_location, Settings.save_flag);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_CONFIG D_LOADED_FROM_FLASH_AT " %X, " D_COUNT " %d"), settings_location, Settings.save_flag);
|
||||
}
|
||||
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
|
@ -516,8 +513,7 @@ void SettingsErase(uint8_t type)
|
|||
|
||||
bool _serialoutput = (LOG_LEVEL_DEBUG_MORE <= seriallog_level);
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_ERASE " %d " D_UNIT_SECTORS), _sectorEnd - _sectorStart);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_ERASE " %d " D_UNIT_SECTORS), _sectorEnd - _sectorStart);
|
||||
|
||||
for (uint32_t _sector = _sectorStart; _sector < _sectorEnd; _sector++) {
|
||||
result = ESP.flashEraseSector(_sector);
|
||||
|
|
|
@ -200,12 +200,13 @@ char* Format(char* output, const char* input, int size)
|
|||
if (token != NULL) {
|
||||
digits = atoi(token);
|
||||
if (digits) {
|
||||
char tmp[size];
|
||||
if (strchr(token, 'd')) {
|
||||
snprintf_P(output, size, PSTR("%s%c0%dd"), output, '%', digits);
|
||||
snprintf_P(output, size, output, ESP.getChipId() & 0x1fff); // %04d - short chip ID in dec, like in hostname
|
||||
snprintf_P(tmp, size, PSTR("%s%c0%dd"), output, '%', digits);
|
||||
snprintf_P(output, size, tmp, ESP.getChipId() & 0x1fff); // %04d - short chip ID in dec, like in hostname
|
||||
} else {
|
||||
snprintf_P(output, size, PSTR("%s%c0%dX"), output, '%', digits);
|
||||
snprintf_P(output, size, output, ESP.getChipId()); // %06X - full chip ID in hex
|
||||
snprintf_P(tmp, size, PSTR("%s%c0%dX"), output, '%', digits);
|
||||
snprintf_P(output, size, tmp, ESP.getChipId()); // %06X - full chip ID in hex
|
||||
}
|
||||
} else {
|
||||
if (strchr(token, 'd')) {
|
||||
|
@ -228,7 +229,7 @@ char* GetOtaUrl(char *otaurl, size_t otaurl_size)
|
|||
snprintf_P(otaurl, otaurl_size, Settings.ota_url, ESP.getChipId());
|
||||
}
|
||||
else {
|
||||
snprintf(otaurl, otaurl_size, Settings.ota_url);
|
||||
strlcpy(otaurl, Settings.ota_url, otaurl_size);
|
||||
}
|
||||
return otaurl;
|
||||
}
|
||||
|
@ -473,9 +474,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
|
|||
|
||||
if (topicBuf[0] != '/') { ShowSource(SRC_MQTT); }
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_RESULT D_RECEIVED_TOPIC " %s, " D_DATA_SIZE " %d, " D_DATA " %s"),
|
||||
topicBuf, data_len, dataBuf);
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_RESULT D_RECEIVED_TOPIC " %s, " D_DATA_SIZE " %d, " D_DATA " %s"), topicBuf, data_len, dataBuf);
|
||||
// if (LOG_LEVEL_DEBUG_MORE <= seriallog_level) { Serial.println(dataBuf); }
|
||||
|
||||
if (XdrvMqttData(topicBuf, sizeof(topicBuf), dataBuf, sizeof(dataBuf))) { return; }
|
||||
|
@ -503,9 +502,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
|
|||
type[i] = '\0';
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_RESULT D_GROUP " %d, " D_INDEX " %d, " D_COMMAND " %s, " D_DATA " %s"),
|
||||
grpflg, index, type, dataBuf);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_RESULT D_GROUP " %d, " D_INDEX " %d, " D_COMMAND " %s, " D_DATA " %s"), grpflg, index, type, dataBuf);
|
||||
|
||||
if (type != NULL) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_COMMAND "\":\"" D_JSON_ERROR "\"}"));
|
||||
|
@ -526,8 +523,7 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
|
|||
int temp_payload = GetStateNumber(dataBuf);
|
||||
if (temp_payload > -1) { payload = temp_payload; }
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("RSLT: Payload %d, Payload16 %d"), payload, payload16);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RSLT: Payload %d, Payload16 %d"), payload, payload16);
|
||||
|
||||
int command_code = GetCommandCode(command, sizeof(command), type, kTasmotaCommands);
|
||||
if (-1 == command_code) {
|
||||
|
@ -624,9 +620,9 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
|
|||
// We also need at least 3 chars to make a valid version number string.
|
||||
if (((1 == data_len) && (1 == payload)) || ((data_len >= 3) && NewerVersion(dataBuf))) {
|
||||
ota_state_flag = 3;
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), "{\"%s\":\"" D_JSON_VERSION " %s " D_JSON_FROM " %s\"}", command, my_version, GetOtaUrl(stemp1, sizeof(stemp1)));
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"%s\":\"" D_JSON_VERSION " %s " D_JSON_FROM " %s\"}"), command, my_version, GetOtaUrl(stemp1, sizeof(stemp1)));
|
||||
} else {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), "{\"%s\":\"" D_JSON_ONE_OR_GT "\"}", command, my_version);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"%s\":\"" D_JSON_ONE_OR_GT "\"}"), command, my_version);
|
||||
}
|
||||
}
|
||||
else if (CMND_OTAURL == command_code) {
|
||||
|
@ -962,11 +958,26 @@ void MqttDataHandler(char* topic, uint8_t* data, unsigned int data_len)
|
|||
ModuleDefault(payload -1); // Copy template module
|
||||
if (USER_MODULE == Settings.module) { restart_flag = 2; }
|
||||
}
|
||||
else if (0 == payload) { // Copy current module with user configured GPIO
|
||||
else if (0 == payload) { // Copy current template to user template
|
||||
if (Settings.module != USER_MODULE) {
|
||||
ModuleDefault(Settings.module);
|
||||
}
|
||||
}
|
||||
else if (255 == payload) { // Copy current module with user configured GPIO
|
||||
if (Settings.module != USER_MODULE) {
|
||||
ModuleDefault(Settings.module);
|
||||
}
|
||||
snprintf_P(Settings.user_template.name, sizeof(Settings.user_template.name), PSTR("Merged"));
|
||||
uint8_t j = 0;
|
||||
for (uint8_t i = 0; i < sizeof(mycfgio); i++) {
|
||||
if (6 == i) { j = 9; }
|
||||
if (8 == i) { j = 12; }
|
||||
if (my_module.io[j] > GPIO_NONE) {
|
||||
Settings.user_template.gp.io[i] = my_module.io[j];
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (data_len > 9) { // Workaround exception if empty JSON like {} - Needs checks
|
||||
if (JsonTemplate(dataBuf)) { // Free 336 bytes StaticJsonBuffer stack space by moving code to function
|
||||
|
@ -1793,8 +1804,7 @@ void PerformEverySecond(void)
|
|||
RtcRebootSave();
|
||||
|
||||
Settings.bootcount++; // Moved to here to stop flash writes during start-up
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BOOT_COUNT " %d"), Settings.bootcount);
|
||||
}
|
||||
|
||||
if ((4 == uptime) && (SONOFF_IFAN02 == my_module_type)) { // Microcontroller needs 3 seconds before accepting commands
|
||||
|
@ -2001,8 +2011,7 @@ void Every250mSeconds(void)
|
|||
}
|
||||
}
|
||||
#endif // FIRMWARE_MINIMAL
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "%s"), mqtt_data);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "%s"), mqtt_data);
|
||||
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1) || defined(ARDUINO_ESP8266_RELEASE_2_4_2)
|
||||
ota_result = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(mqtt_data));
|
||||
#else
|
||||
|
@ -2013,8 +2022,7 @@ void Every250mSeconds(void)
|
|||
if (!ota_result) {
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
int ota_error = ESPhttpUpdate.getLastError();
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "Ota error %d"), ota_error);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "Ota error %d"), ota_error);
|
||||
if ((HTTP_UE_TOO_LESS_SPACE == ota_error) || (HTTP_UE_BIN_FOR_WRONG_FLASH == ota_error)) {
|
||||
RtcSettings.ota_loader = 1; // Try minimal image next
|
||||
}
|
||||
|
@ -2145,8 +2153,7 @@ void ArduinoOTAInit(void)
|
|||
AriluxRfDisable(); // Prevent restart exception on Arilux Interrupt routine
|
||||
#endif // USE_ARILUX_RF
|
||||
if (Settings.flag.mqtt_enabled) { MqttDisconnect(); }
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "Arduino OTA " D_UPLOAD_STARTED));
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_UPLOAD_STARTED));
|
||||
arduino_ota_triggered = true;
|
||||
arduino_ota_progress_dot_count = 0;
|
||||
delay(100); // Allow time for message xfer
|
||||
|
@ -2177,22 +2184,19 @@ void ArduinoOTAInit(void)
|
|||
default:
|
||||
snprintf_P(error_str, sizeof(error_str), PSTR(D_UPLOAD_ERROR_CODE " %d"), error);
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "Arduino OTA %s. " D_RESTARTING), error_str);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA %s. " D_RESTARTING), error_str);
|
||||
EspRestart();
|
||||
});
|
||||
|
||||
ArduinoOTA.onEnd([]()
|
||||
{
|
||||
if ((LOG_LEVEL_DEBUG <= seriallog_level)) { Serial.println(); }
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "Arduino OTA " D_SUCCESSFUL ". " D_RESTARTING));
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_SUCCESSFUL ". " D_RESTARTING));
|
||||
EspRestart();
|
||||
});
|
||||
|
||||
ArduinoOTA.begin();
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPLOAD "Arduino OTA " D_ENABLED " " D_PORT " 8266"));
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD "Arduino OTA " D_ENABLED " " D_PORT " 8266"));
|
||||
}
|
||||
#endif // USE_ARDUINO_OTA
|
||||
|
||||
|
@ -2268,8 +2272,7 @@ void SerialInput(void)
|
|||
else if (!Settings.flag.mqtt_serial && (serial_in_byte == '\n')) {
|
||||
serial_in_buffer[serial_in_byte_counter] = 0; // Serial data completed
|
||||
seriallog_level = (Settings.seriallog_level < LOG_LEVEL_INFO) ? (uint8_t)LOG_LEVEL_INFO : Settings.seriallog_level;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_COMMAND "%s"), serial_in_buffer);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_COMMAND "%s"), serial_in_buffer);
|
||||
ExecuteCommand(serial_in_buffer, SRC_SERIAL);
|
||||
serial_in_byte_counter = 0;
|
||||
serial_polling_window = 0;
|
||||
|
@ -2338,8 +2341,7 @@ void GpioInit(void)
|
|||
for (uint8_t i = 0; i < sizeof(my_module.io); i++) {
|
||||
mpin = ValidPin(i, my_module.io[i]);
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("DBG: gpio pin %d, mpin %d"), i, mpin);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("DBG: gpio pin %d, mpin %d"), i, mpin);
|
||||
|
||||
if (mpin) {
|
||||
if ((mpin >= GPIO_SWT1_NP) && (mpin < (GPIO_SWT1_NP + MAX_SWITCHES))) {
|
||||
|
@ -2584,8 +2586,7 @@ void setup(void)
|
|||
Settings.module = SONOFF_BASIC; // Reset module to Sonoff Basic
|
||||
// Settings.last_module = SONOFF_BASIC;
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_LOG_SOME_SETTINGS_RESET " (%d)"), RtcReboot.fast_reboot_count);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_LOG_SOME_SETTINGS_RESET " (%d)"), RtcReboot.fast_reboot_count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2651,12 +2652,9 @@ void setup(void)
|
|||
}
|
||||
blink_powersave = power;
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_PROJECT " %s %s " D_VERSION " %s%s-" ARDUINO_ESP8266_RELEASE),
|
||||
PROJECT, Settings.friendlyname[0], my_version, my_image);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_PROJECT " %s %s " D_VERSION " %s%s-" ARDUINO_ESP8266_RELEASE), PROJECT, Settings.friendlyname[0], my_version, my_image);
|
||||
#ifdef FIRMWARE_MINIMAL
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_WARNING_MINIMAL_VERSION));
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_WARNING_MINIMAL_VERSION));
|
||||
#endif // FIRMWARE_MINIMAL
|
||||
|
||||
RtcInit();
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef _SONOFF_VERSION_H_
|
||||
#define _SONOFF_VERSION_H_
|
||||
|
||||
#define VERSION 0x06040113
|
||||
#define VERSION 0x06040115
|
||||
|
||||
#define D_PROGRAMNAME "Sonoff-Tasmota"
|
||||
#define D_AUTHOR "Theo Arends"
|
||||
|
|
|
@ -47,8 +47,7 @@ void OsWatchTicker(void)
|
|||
unsigned long last_run = abs(t - oswatch_last_loop_time);
|
||||
|
||||
#ifdef DEBUG_THEO
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_OSWATCH " FreeRam %d, rssi %d, last_run %d"), ESP.getFreeHeap(), WifiGetRssiAsQuality(WiFi.RSSI()), last_run);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_OSWATCH " FreeRam %d, rssi %d, last_run %d"), ESP.getFreeHeap(), WifiGetRssiAsQuality(WiFi.RSSI()), last_run);
|
||||
#endif // DEBUG_THEO
|
||||
if (last_run >= (OSWATCH_RESET_TIME * 1000)) {
|
||||
// AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_OSWATCH " " D_BLOCKED_LOOP ". " D_RESTARTING)); // Save iram space
|
||||
|
@ -160,28 +159,33 @@ double CharToDouble(const char *str)
|
|||
char strbuf[24];
|
||||
|
||||
strlcpy(strbuf, str, sizeof(strbuf));
|
||||
char *pt;
|
||||
double left = atoi(strbuf);
|
||||
char *pt = strbuf;
|
||||
while ((*pt != '\0') && isblank(*pt)) { pt++; } // Trim leading spaces
|
||||
|
||||
signed char sign = 1;
|
||||
if (*pt == '-') { sign = -1; }
|
||||
if (*pt == '-' || *pt=='+') { pt++; } // Skip any sign
|
||||
|
||||
double left = 0;
|
||||
if (*pt != '.') {
|
||||
left = atoi(pt); // Get left part
|
||||
while (isdigit(*pt)) { pt++; } // Skip number
|
||||
}
|
||||
|
||||
double right = 0;
|
||||
short len = 0;
|
||||
pt = strtok (strbuf, ".");
|
||||
if (pt) {
|
||||
pt = strtok (NULL, ".");
|
||||
if (pt) {
|
||||
right = atoi(pt);
|
||||
len = strlen(pt);
|
||||
double fac = 1;
|
||||
while (len) {
|
||||
fac /= 10.0;
|
||||
len--;
|
||||
}
|
||||
// pow is also very large
|
||||
//double fac=pow(10,-len);
|
||||
right *= fac;
|
||||
if (*pt == '.') {
|
||||
pt++;
|
||||
right = atoi(pt); // Decimal part
|
||||
while (isdigit(*pt)) {
|
||||
pt++;
|
||||
right /= 10.0;
|
||||
}
|
||||
}
|
||||
|
||||
double result = left + right;
|
||||
if (left < 0) { result = left - right; }
|
||||
if (sign < 0) {
|
||||
return -result; // Add negative sign
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -640,8 +644,7 @@ void SetSerialBaudrate(int baudrate)
|
|||
Settings.baudrate = baudrate / 1200;
|
||||
if (Serial.baudRate() != baudrate) {
|
||||
if (seriallog_level) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_SET_BAUDRATE_TO " %d"), baudrate);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SET_BAUDRATE_TO " %d"), baudrate);
|
||||
}
|
||||
delay(100);
|
||||
Serial.flush();
|
||||
|
@ -669,7 +672,7 @@ void SerialSendRaw(char *codes)
|
|||
int size = strlen(codes);
|
||||
|
||||
while (size > 0) {
|
||||
snprintf(stemp, sizeof(stemp), codes);
|
||||
strlcpy(stemp, codes, sizeof(stemp));
|
||||
code = strtol(stemp, &p, 16);
|
||||
Serial.write(code);
|
||||
size -= 2;
|
||||
|
@ -690,8 +693,7 @@ void ShowSource(int source)
|
|||
{
|
||||
if ((source > 0) && (source < SRC_MAX)) {
|
||||
char stemp1[20];
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("SRC: %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource));
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SRC: %s"), GetTextIndexed(stemp1, sizeof(stemp1), source, kCommandSource));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1166,8 +1168,7 @@ bool I2cDevice(uint8_t addr)
|
|||
* Syslog
|
||||
*
|
||||
* Example:
|
||||
* snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_LOG "Any value %d"), value);
|
||||
* AddLog(LOG_LEVEL_DEBUG);
|
||||
* AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_LOG "Any value %d"), value);
|
||||
*
|
||||
\*********************************************************************************************/
|
||||
|
||||
|
@ -1223,8 +1224,7 @@ void Syslog(void)
|
|||
} else {
|
||||
syslog_level = 0;
|
||||
syslog_timer = SYSLOG_TIMER;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_SYSLOG_HOST_NOT_FOUND ". " D_RETRY_IN " %d " D_UNIT_SECOND), SYSLOG_TIMER);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_SYSLOG_HOST_NOT_FOUND ". " D_RETRY_IN " %d " D_UNIT_SECOND), SYSLOG_TIMER);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1274,6 +1274,16 @@ void AddLog_P(uint8_t loglevel, const char *formatP, const char *formatP2)
|
|||
AddLog(loglevel);
|
||||
}
|
||||
|
||||
void AddLog_P2(uint8_t loglevel, PGM_P formatP, ...)
|
||||
{
|
||||
va_list arg;
|
||||
va_start(arg, formatP);
|
||||
int len = vsnprintf_P(log_data, sizeof(log_data), formatP, arg);
|
||||
va_end(arg);
|
||||
|
||||
AddLog(loglevel);
|
||||
}
|
||||
|
||||
void AddLogBuffer(uint8_t loglevel, uint8_t *buffer, int count)
|
||||
{
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("DMP:"));
|
||||
|
@ -1290,6 +1300,5 @@ void AddLogSerial(uint8_t loglevel)
|
|||
|
||||
void AddLogMissed(char *sensor, uint8_t misses)
|
||||
{
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("SNS: %s missed %d"), sensor, SENSOR_MAX_MISS - misses);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SNS: %s missed %d"), sensor, SENSOR_MAX_MISS - misses);
|
||||
}
|
||||
|
|
|
@ -103,8 +103,7 @@ void ButtonHandler(void)
|
|||
if (!button_index && ((SONOFF_DUAL == my_module_type) || (CH4 == my_module_type))) {
|
||||
button_present = 1;
|
||||
if (dual_button_code) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON " " D_CODE " %04X"), dual_button_code);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON " " D_CODE " %04X"), dual_button_code);
|
||||
button = PRESSED;
|
||||
if (0xF500 == dual_button_code) { // Button hold
|
||||
holdbutton[button_index] = (loops_per_second * Settings.param[P_HOLD_TIME] / 10) -1;
|
||||
|
@ -130,14 +129,12 @@ void ButtonHandler(void)
|
|||
|
||||
bool button_pressed = false;
|
||||
if ((PRESSED == button) && (NOT_PRESSED == lastbutton[button_index])) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_10), button_index +1);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_10), button_index +1);
|
||||
holdbutton[button_index] = loops_per_second;
|
||||
button_pressed = true;
|
||||
}
|
||||
if ((NOT_PRESSED == button) && (PRESSED == lastbutton[button_index])) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_01), button_index +1);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_LEVEL_01), button_index +1);
|
||||
if (!holdbutton[button_index]) { button_pressed = true; } // Do not allow within 1 second
|
||||
}
|
||||
if (button_pressed) {
|
||||
|
@ -149,15 +146,13 @@ void ButtonHandler(void)
|
|||
else {
|
||||
if ((PRESSED == button) && (NOT_PRESSED == lastbutton[button_index])) {
|
||||
if (Settings.flag.button_single) { // Allow only single button press for immediate action
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_IMMEDIATE), button_index +1);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_IMMEDIATE), button_index +1);
|
||||
if (!SendKey(0, button_index +1, POWER_TOGGLE)) { // Execute Toggle command via MQTT if ButtonTopic is set
|
||||
ExecuteCommandPower(button_index +1, POWER_TOGGLE, SRC_BUTTON); // Execute Toggle command internally
|
||||
}
|
||||
} else {
|
||||
multipress[button_index] = (multiwindow[button_index]) ? multipress[button_index] +1 : 1;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_MULTI_PRESS " %d"), button_index +1, multipress[button_index]);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_BUTTON "%d " D_MULTI_PRESS " %d"), button_index +1, multipress[button_index]);
|
||||
multiwindow[button_index] = loops_per_second / 2; // 0.5 second multi press window
|
||||
}
|
||||
blinks = 201;
|
||||
|
|
|
@ -115,8 +115,7 @@ void RotaryHandler(void)
|
|||
if (t > 500) {
|
||||
t = 500;
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_CMND_COLORTEMPERATURE " %d"), rotary_position - rotary_last_position);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_CMND_COLORTEMPERATURE " %d"), rotary_position - rotary_last_position);
|
||||
LightSetColorTemp((uint16_t)t);
|
||||
} else {
|
||||
int8_t d = Settings.light_dimmer;
|
||||
|
@ -127,8 +126,7 @@ void RotaryHandler(void)
|
|||
if (d > 100) {
|
||||
d = 100;
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION D_CMND_DIMMER " %d"), rotary_position - rotary_last_position);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION D_CMND_DIMMER " %d"), rotary_position - rotary_last_position);
|
||||
|
||||
LightSetDimmer((uint8_t)d);
|
||||
Settings.light_dimmer = d;
|
||||
|
|
|
@ -364,9 +364,7 @@ void RtcSecond(void)
|
|||
RtcTime.year = tmpTime.year + 1970;
|
||||
daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year);
|
||||
standard_time = RuleToTime(Settings.tflag[0], RtcTime.year);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "(" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
|
||||
GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "(" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"), GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
|
||||
if (local_time < 1451602800) { // 2016-01-01
|
||||
rules_flag.time_init = 1;
|
||||
} else {
|
||||
|
|
|
@ -107,8 +107,7 @@ void WifiWpsStatusCallback(wps_cb_status status)
|
|||
if (WPS_CB_ST_SUCCESS == wps_result) {
|
||||
wifi_wps_disable();
|
||||
} else {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_WPS_FAILED_WITH_STATUS " %d"), wps_result);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_WPS_FAILED_WITH_STATUS " %d"), wps_result);
|
||||
wifi_config_counter = 2;
|
||||
}
|
||||
}
|
||||
|
@ -247,9 +246,8 @@ void WifiBegin(uint8_t flag, uint8_t channel)
|
|||
} else {
|
||||
WiFi.begin(Settings.sta_ssid[Settings.sta_active], Settings.sta_pwd[Settings.sta_active]);
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_CONNECTING_TO_AP "%d %s " D_IN_MODE " 11%c " D_AS " %s..."),
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_CONNECTING_TO_AP "%d %s " D_IN_MODE " 11%c " D_AS " %s..."),
|
||||
Settings.sta_active +1, Settings.sta_ssid[Settings.sta_active], kWifiPhyMode[WiFi.getPhyMode() & 0x3], my_hostname);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
}
|
||||
|
||||
void WifiBeginAfterScan()
|
||||
|
@ -324,9 +322,8 @@ void WifiBeginAfterScan()
|
|||
break;
|
||||
}
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI "Network %d, AP%c, SSId %s, Channel %d, BSSId %02X:%02X:%02X:%02X:%02X:%02X, RSSI %d, Encryption %d"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI "Network %d, AP%c, SSId %s, Channel %d, BSSId %02X:%02X:%02X:%02X:%02X:%02X, RSSI %d, Encryption %d"),
|
||||
i, (known) ? (j) ? '2' : '1' : '-', ssid_scan.c_str(), chan_scan, bssid_scan[0], bssid_scan[1], bssid_scan[2], bssid_scan[3], bssid_scan[4], bssid_scan[5], rssi_scan, (sec_scan == ENC_TYPE_NONE) ? 0 : 1);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
delay(0);
|
||||
}
|
||||
WiFi.scanDelete(); // Clean up Ram
|
||||
|
@ -490,8 +487,7 @@ void WifiCheck(uint8_t param)
|
|||
strlcpy(Settings.sta_pwd[0], WiFi.psk().c_str(), sizeof(Settings.sta_pwd[0]));
|
||||
}
|
||||
Settings.sta_active = 0;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_WCFG_1_SMARTCONFIG D_CMND_SSID "1 %s"), Settings.sta_ssid[0]);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_1_SMARTCONFIG D_CMND_SSID "1 %s"), Settings.sta_ssid[0]);
|
||||
}
|
||||
}
|
||||
if (!wifi_config_counter) {
|
||||
|
@ -534,8 +530,7 @@ void WifiCheck(uint8_t param)
|
|||
// } else {
|
||||
// mdns_delayed_start = Settings.param[P_MDNS_DELAYED_START];
|
||||
mdns_begun = (uint8_t)MDNS.begin(my_hostname);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MDNS "%s"), (mdns_begun) ? D_INITIALIZED : D_FAILED);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS "%s"), (mdns_begun) ? D_INITIALIZED : D_FAILED);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -234,8 +234,7 @@ void MqttDiscoverServer(void)
|
|||
|
||||
int n = MDNS.queryService("mqtt", "tcp"); // Search for mqtt service
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MDNS D_QUERY_DONE " %d"), n);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_QUERY_DONE " %d"), n);
|
||||
|
||||
if (n > 0) {
|
||||
uint8_t i = 0; // If the hostname isn't set, use the first record found.
|
||||
|
@ -249,9 +248,7 @@ void MqttDiscoverServer(void)
|
|||
snprintf_P(Settings.mqtt_host, sizeof(Settings.mqtt_host), MDNS.IP(i).toString().c_str());
|
||||
Settings.mqtt_port = MDNS.port(i);
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MDNS D_MQTT_SERVICE_FOUND " %s, " D_IP_ADDRESS " %s, " D_PORT " %d"),
|
||||
MDNS.hostname(i).c_str(), Settings.mqtt_host, Settings.mqtt_port);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MDNS D_MQTT_SERVICE_FOUND " %s, " D_IP_ADDRESS " %s, " D_PORT " %d"), MDNS.hostname(i).c_str(), Settings.mqtt_host, Settings.mqtt_port);
|
||||
}
|
||||
}
|
||||
#endif // MQTT_HOST_DISCOVERY
|
||||
|
@ -269,15 +266,13 @@ void MqttRetryCounter(uint8_t value)
|
|||
|
||||
void MqttSubscribe(const char *topic)
|
||||
{
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_SUBSCRIBE_TO " %s"), topic);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT D_SUBSCRIBE_TO " %s"), topic);
|
||||
MqttSubscribeLib(topic);
|
||||
}
|
||||
|
||||
void MqttUnsubscribe(const char *topic)
|
||||
{
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_UNSUBSCRIBE_FROM " %s"), topic);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT D_UNSUBSCRIBE_FROM " %s"), topic);
|
||||
MqttUnsubscribeLib(topic);
|
||||
}
|
||||
|
||||
|
@ -308,8 +303,8 @@ void MqttPublishDirect(const char* topic, bool retained)
|
|||
snprintf_P(log_data, sizeof(log_data), PSTR("%s ..."), log_data);
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%s%s"), log_data, sretained);
|
||||
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
|
||||
if (Settings.ledstate &0x04) {
|
||||
blinks++;
|
||||
}
|
||||
|
@ -413,9 +408,7 @@ void MqttDisconnected(int state)
|
|||
mqtt_connected = false;
|
||||
mqtt_retry_counter = Settings.mqtt_retry;
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_CONNECT_FAILED_TO " %s:%d, rc %d. " D_RETRY_IN " %d " D_UNIT_SECOND),
|
||||
Settings.mqtt_host, Settings.mqtt_port, state, mqtt_retry_counter);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_MQTT D_CONNECT_FAILED_TO " %s:%d, rc %d. " D_RETRY_IN " %d " D_UNIT_SECOND), Settings.mqtt_host, Settings.mqtt_port, state, mqtt_retry_counter);
|
||||
rules_flag.mqtt_disconnected = 1;
|
||||
}
|
||||
|
||||
|
@ -500,9 +493,7 @@ bool MqttCheckTls(void)
|
|||
//#endif
|
||||
|
||||
if (!EspClient.connect(Settings.mqtt_host, Settings.mqtt_port)) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_TLS_CONNECT_FAILED_TO " %s:%d. " D_RETRY_IN " %d " D_UNIT_SECOND),
|
||||
Settings.mqtt_host, Settings.mqtt_port, mqtt_retry_counter);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_MQTT D_TLS_CONNECT_FAILED_TO " %s:%d. " D_RETRY_IN " %d " D_UNIT_SECOND), Settings.mqtt_host, Settings.mqtt_port, mqtt_retry_counter);
|
||||
} else {
|
||||
#ifdef USE_MQTT_TLS_CA_CERT
|
||||
unsigned char tls_ca_cert[] = MQTT_TLS_CA_CERT;
|
||||
|
@ -774,10 +765,10 @@ bool MqttCommand(void)
|
|||
if (data_len > 0) {
|
||||
char *mqtt_part = strtok(dataBuf, " ");
|
||||
if (mqtt_part) {
|
||||
snprintf(stemp1, sizeof(stemp1), mqtt_part);
|
||||
strlcpy(stemp1, mqtt_part, sizeof(stemp1));
|
||||
mqtt_part = strtok(NULL, " ");
|
||||
if (mqtt_part) {
|
||||
snprintf(mqtt_data, sizeof(mqtt_data), mqtt_part);
|
||||
strlcpy(mqtt_data, mqtt_part, sizeof(mqtt_data));
|
||||
} else {
|
||||
mqtt_data[0] = '\0';
|
||||
}
|
||||
|
@ -900,16 +891,17 @@ const char S_CONFIGURE_MQTT[] PROGMEM = D_CONFIGURE_MQTT;
|
|||
const char HTTP_BTN_MENU_MQTT[] PROGMEM =
|
||||
"<p><form action='" WEB_HANDLE_MQTT "' method='get'><button>" D_CONFIGURE_MQTT "</button></form></p>";
|
||||
|
||||
const char HTTP_FORM_MQTT[] PROGMEM =
|
||||
const char HTTP_FORM_MQTT1[] PROGMEM =
|
||||
"<fieldset><legend><b> " D_MQTT_PARAMETERS " </b></legend>"
|
||||
"<form method='get' action='" WEB_HANDLE_MQTT "'>"
|
||||
"<p><b>" D_HOST "</b> (" MQTT_HOST ")<br/><input id='mh' name='mh' placeholder='" MQTT_HOST" ' value='{m1'></p>"
|
||||
"<p><b>" D_PORT "</b> (" STR(MQTT_PORT) ")<br/><input id='ml' name='ml' placeholder='" STR(MQTT_PORT) "' value='{m2'></p>"
|
||||
"<p><b>" D_CLIENT "</b> ({m0)<br/><input id='mc' name='mc' placeholder='" MQTT_CLIENT_ID "' value='{m3'></p>"
|
||||
"<p><b>" D_USER "</b> (" MQTT_USER ")<br/><input id='mu' name='mu' placeholder='" MQTT_USER "' value='{m4'></p>"
|
||||
"<p><b>" D_HOST "</b> (" MQTT_HOST ")<br/><input id='mh' name='mh' placeholder='" MQTT_HOST" ' value='%s'></p>"
|
||||
"<p><b>" D_PORT "</b> (" STR(MQTT_PORT) ")<br/><input id='ml' name='ml' placeholder='" STR(MQTT_PORT) "' value='%d'></p>"
|
||||
"<p><b>" D_CLIENT "</b> (%s)<br/><input id='mc' name='mc' placeholder='%s' value='%s'></p>";
|
||||
const char HTTP_FORM_MQTT2[] PROGMEM =
|
||||
"<p><b>" D_USER "</b> (" MQTT_USER ")<br/><input id='mu' name='mu' placeholder='" MQTT_USER "' value='%s'></p>"
|
||||
"<p><b>" D_PASSWORD "</b><br/><input id='mp' name='mp' type='password' placeholder='" D_PASSWORD "' value='" D_ASTERISK_PWD "'></p>"
|
||||
"<p><b>" D_TOPIC "</b> = %topic% (" MQTT_TOPIC ")<br/><input id='mt' name='mt' placeholder='" MQTT_TOPIC" ' value='{m6'></p>"
|
||||
"<p><b>" D_FULL_TOPIC "</b> (" MQTT_FULLTOPIC ")<br/><input id='mf' name='mf' placeholder='" MQTT_FULLTOPIC" ' value='{m7'></p>";
|
||||
"<p><b>" D_TOPIC "</b> = %%topic%% (" MQTT_TOPIC ")<br/><input id='mt' name='mt' placeholder='" MQTT_TOPIC "' value='%s'></p>"
|
||||
"<p><b>" D_FULL_TOPIC "</b> (%s)<br/><input id='mf' name='mf' placeholder='%s' value='%s'></p>";
|
||||
|
||||
void HandleMqttConfiguration(void)
|
||||
{
|
||||
|
@ -923,23 +915,24 @@ void HandleMqttConfiguration(void)
|
|||
return;
|
||||
}
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
page.replace(F("{v}"), FPSTR(S_CONFIGURE_MQTT));
|
||||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
|
||||
page += FPSTR(HTTP_FORM_MQTT);
|
||||
char str[sizeof(Settings.mqtt_client)];
|
||||
page.replace(F("{m0"), Format(str, MQTT_CLIENT_ID, sizeof(Settings.mqtt_client)));
|
||||
page.replace(F("{m1"), Settings.mqtt_host);
|
||||
page.replace(F("{m2"), String(Settings.mqtt_port));
|
||||
page.replace(F("{m3"), Settings.mqtt_client);
|
||||
page.replace(F("{m4"), (Settings.mqtt_user[0] == '\0')?"0":Settings.mqtt_user);
|
||||
page.replace(F("{m6"), Settings.mqtt_topic);
|
||||
page.replace(F("{m7"), Settings.mqtt_fulltopic);
|
||||
|
||||
page += FPSTR(HTTP_FORM_END);
|
||||
page += FPSTR(HTTP_BTN_CONF);
|
||||
ShowPage(page);
|
||||
WSContentStart(FPSTR(S_CONFIGURE_MQTT));
|
||||
WSContentSendStyle();
|
||||
WSContentSend_P(HTTP_FORM_MQTT1,
|
||||
Settings.mqtt_host,
|
||||
Settings.mqtt_port,
|
||||
Format(str, MQTT_CLIENT_ID, sizeof(Settings.mqtt_client)),
|
||||
MQTT_CLIENT_ID,
|
||||
Settings.mqtt_client);
|
||||
WSContentSend_P(HTTP_FORM_MQTT2,
|
||||
(Settings.mqtt_user[0] == '\0') ? "0" : Settings.mqtt_user,
|
||||
Settings.mqtt_topic,
|
||||
MQTT_FULLTOPIC, MQTT_FULLTOPIC,
|
||||
Settings.mqtt_fulltopic);
|
||||
WSContentSend(FPSTR(HTTP_FORM_END));
|
||||
WSContentSend(FPSTR(HTTP_BTN_CONF));
|
||||
WSContentEnd();
|
||||
}
|
||||
|
||||
void MqttSaveSettings(void)
|
||||
|
@ -970,9 +963,8 @@ void MqttSaveSettings(void)
|
|||
strlcpy(Settings.mqtt_user, (!strlen(tmp)) ? MQTT_USER : (!strcmp(tmp,"0")) ? "" : tmp, sizeof(Settings.mqtt_user));
|
||||
WebGetArg("mp", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.mqtt_pwd, (!strlen(tmp)) ? "" : (!strcmp(tmp, D_ASTERISK_PWD)) ? Settings.mqtt_pwd : tmp, sizeof(Settings.mqtt_pwd));
|
||||
snprintf_P(log_data, sizeof(log_data), 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"),
|
||||
AddLog_P2(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"),
|
||||
Settings.mqtt_host, Settings.mqtt_port, Settings.mqtt_client, Settings.mqtt_user, Settings.mqtt_topic, Settings.mqtt_fulltopic);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
|
@ -988,7 +980,7 @@ bool Xdrv02(uint8_t function)
|
|||
switch (function) {
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_WEB_ADD_BUTTON:
|
||||
strncat_P(mqtt_data, HTTP_BTN_MENU_MQTT, sizeof(mqtt_data) - strlen(mqtt_data) -1);
|
||||
WSContentSend(FPSTR(HTTP_BTN_MENU_MQTT));
|
||||
break;
|
||||
case FUNC_WEB_ADD_HANDLER:
|
||||
WebServer->on("/" WEB_HANDLE_MQTT, HandleMqttConfiguration);
|
||||
|
|
|
@ -199,8 +199,7 @@ void EnergyMarginCheck(void)
|
|||
energy_voltage_u = (uint16_t)(energy_voltage);
|
||||
energy_current_u = (uint16_t)(energy_current * 1000);
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("NRG: W %d, U %d, I %d"), energy_power_u, energy_voltage_u, energy_current_u);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("NRG: W %d, U %d, I %d"), energy_power_u, energy_voltage_u, energy_current_u);
|
||||
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{"));
|
||||
jsonflg = false;
|
||||
|
|
|
@ -205,8 +205,7 @@ void AriluxRfHandler(void)
|
|||
}
|
||||
uint16_t stored_hostcode = Settings.rf_code[1][6] << 8 | Settings.rf_code[1][7];
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_RFR D_HOST D_CODE " 0x%04X, " D_RECEIVED " 0x%06X"), stored_hostcode, arilux_rf_received_value);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_RFR D_HOST D_CODE " 0x%04X, " D_RECEIVED " 0x%06X"), stored_hostcode, arilux_rf_received_value);
|
||||
|
||||
if (hostcode == stored_hostcode) {
|
||||
char command[33];
|
||||
|
@ -406,8 +405,7 @@ void SM16716_Update(uint8_t duty_r, uint8_t duty_g, uint8_t duty_b)
|
|||
uint8_t sm16716_should_enable = (duty_r | duty_g | duty_b);
|
||||
if (!sm16716_enabled && sm16716_should_enable) {
|
||||
#ifdef D_LOG_SM16716
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_SM16716 "turning color on"));
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_SM16716 "turning color on"));
|
||||
#endif // D_LOG_SM16716
|
||||
sm16716_enabled = 1;
|
||||
digitalWrite(sm16716_pin_sel, HIGH);
|
||||
|
@ -418,18 +416,14 @@ void SM16716_Update(uint8_t duty_r, uint8_t duty_g, uint8_t duty_b)
|
|||
}
|
||||
else if (sm16716_enabled && !sm16716_should_enable) {
|
||||
#ifdef D_LOG_SM16716
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_SM16716 "turning color off"));
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_SM16716 "turning color off"));
|
||||
#endif // D_LOG_SM16716
|
||||
sm16716_enabled = 0;
|
||||
digitalWrite(sm16716_pin_sel, LOW);
|
||||
}
|
||||
}
|
||||
#ifdef D_LOG_SM16716
|
||||
snprintf_P(log_data, sizeof(log_data),
|
||||
PSTR(D_LOG_SM16716 "Update; rgb=%02x%02x%02x"),
|
||||
duty_r, duty_g, duty_b);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_SM16716 "Update; rgb=%02x%02x%02x"), duty_r, duty_g, duty_b);
|
||||
#endif // D_LOG_SM16716
|
||||
|
||||
// send start bit
|
||||
|
@ -454,10 +448,7 @@ bool SM16716_ModuleSelected(void)
|
|||
sm16716_pin_dat = pin[GPIO_SM16716_DAT];
|
||||
sm16716_pin_sel = pin[GPIO_SM16716_SEL];
|
||||
#ifdef D_LOG_SM16716
|
||||
snprintf_P(log_data, sizeof(log_data),
|
||||
PSTR(D_LOG_SM16716 "ModuleSelected; clk_pin=%d, dat_pin=%d)"),
|
||||
sm16716_pin_clk, sm16716_pin_dat);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_SM16716 "ModuleSelected; clk_pin=%d, dat_pin=%d)"), sm16716_pin_clk, sm16716_pin_dat);
|
||||
#endif // D_LOG_SM16716
|
||||
return (sm16716_pin_clk < 99) && (sm16716_pin_dat < 99);
|
||||
}
|
||||
|
@ -598,8 +589,7 @@ void LightUpdateColorMapping(void)
|
|||
light_ct_rgb_linked = !(Settings.param[P_RGB_REMAP] & 128);
|
||||
|
||||
light_update = 1;
|
||||
//snprintf_P(log_data, sizeof(log_data), "%d colors: %d %d %d %d %d",Settings.param[P_RGB_REMAP], light_color_remap[0],light_color_remap[1],light_color_remap[2],light_color_remap[3],light_color_remap[4]);
|
||||
//AddLog(LOG_LEVEL_DEBUG);
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("%d colors: %d %d %d %d %d") ,Settings.param[P_RGB_REMAP], light_color_remap[0],light_color_remap[1],light_color_remap[2],light_color_remap[3],light_color_remap[4]);
|
||||
}
|
||||
|
||||
void LightSetColorTemp(uint16_t ct)
|
||||
|
@ -707,8 +697,7 @@ void LightSetSignal(uint16_t lo, uint16_t hi, uint16_t value)
|
|||
signal = 255;
|
||||
}
|
||||
}
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "Light signal %d"), signal);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Light signal %d"), signal);
|
||||
light_signal_color[0] = signal;
|
||||
light_signal_color[1] = 255 - signal;
|
||||
light_signal_color[2] = 0;
|
||||
|
@ -1015,8 +1004,7 @@ void LightAnimate(void)
|
|||
cur_col[i] = 0xFC; // Fix unwanted blinking and PWM watchdog errors for values close to pwm_range (H801, Arilux and BN-SZ01)
|
||||
}
|
||||
uint16_t curcol = cur_col[i] * (Settings.pwm_range / 255);
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "Cur_Col%d %d, CurCol %d"), i, cur_col[i], curcol);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Cur_Col%d %d, CurCol %d"), i, cur_col[i], curcol);
|
||||
analogWrite(pin[GPIO_PWM1 +i], bitRead(pwm_inverted, i) ? Settings.pwm_range - curcol : curcol);
|
||||
}
|
||||
}
|
||||
|
@ -1044,8 +1032,7 @@ void LightAnimate(void)
|
|||
cur_col[i] = 0xFC; // Fix unwanted blinking and PWM watchdog errors for values close to pwm_range (H801, Arilux and BN-SZ01)
|
||||
}
|
||||
uint16_t curcol = cur_col[i] * (Settings.pwm_range / 255);
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "Cur_Col%d %d, CurCol %d"), i, cur_col[i], curcol);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "Cur_Col%d %d, CurCol %d"), i, cur_col[i], curcol);
|
||||
analogWrite(pin[GPIO_PWM1 +i-3], bitRead(pwm_inverted, i-3) ? Settings.pwm_range - curcol : curcol);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,9 +114,8 @@ void IrReceiveCheck(void)
|
|||
|
||||
if (irrecv->decode(&results)) {
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_IRR "Echo %d, RawLen %d, Overflow %d, Bits %d, Value %08X, Decode %d"),
|
||||
irsend_active, results.rawlen, results.overflow, results.bits, results.value, results.decode_type);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_IRR "Echo %d, RawLen %d, Overflow %d, Bits %d, Value %08X, Decode %d"),
|
||||
irsend_active, results.rawlen, results.overflow, results.bits, results.value, results.decode_type);
|
||||
|
||||
unsigned long now = millis();
|
||||
// if ((now - ir_lasttime > IR_TIME_AVOID_DUPLICATE) && (UNKNOWN != results.decode_type) && (results.bits > 0)) {
|
||||
|
@ -314,9 +313,8 @@ bool IrHvacMitsubishi(const char *HVAC_Mode, const char *HVAC_FanMode, bool HVAC
|
|||
mitsubir->setVane(MITSUBISHI_AC_VANE_AUTO);
|
||||
mitsubir->send();
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("IRHVAC: Mitsubishi Power %d, Mode %d, FanSpeed %d, Temp %d, VaneMode %d"),
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRHVAC: Mitsubishi Power %d, Mode %d, FanSpeed %d, Temp %d, VaneMode %d"),
|
||||
// mitsubir->getPower(), mitsubir->getMode(), mitsubir->getFan(), mitsubir->getTemp(), mitsubir->getVane());
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -381,8 +379,7 @@ bool IrHvacLG(const char *HVAC_Mode, const char *HVAC_FanMode, bool HVAC_Power,
|
|||
hvacOn = true;
|
||||
}
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("IRHVAC: HvacMode %s, ModeVal %d, Code %d"), p, mode, data[3]);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRHVAC: HvacMode %s, ModeVal %d, Code %d"), p, mode, data[3]);
|
||||
|
||||
// Set code for HVAC temperature - data[4]
|
||||
if (HVAC_Temp > 30) {
|
||||
|
@ -414,8 +411,7 @@ bool IrHvacLG(const char *HVAC_Mode, const char *HVAC_FanMode, bool HVAC_Power,
|
|||
data[5] = (mode * 2) - 2; // Low = 0x00, Mid = 0x02, High = 0x04
|
||||
}
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("IRHVAC: FanMode %s, ModeVal %d, Code %d"), p, mode, data[5]);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRHVAC: FanMode %s, ModeVal %d, Code %d"), p, mode, data[5]);
|
||||
|
||||
// Set CRC code - data[6]
|
||||
data[6] = (data[3] + data[4] + data[5]) & 0x0f; // CRC
|
||||
|
@ -428,8 +424,7 @@ bool IrHvacLG(const char *HVAC_Mode, const char *HVAC_FanMode, bool HVAC_Power,
|
|||
}
|
||||
LG_Code = LG_Code + data[6];
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("IRHVAC: LG_Code %d"), LG_Code);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRHVAC: LG_Code %d"), LG_Code);
|
||||
|
||||
// Send LG IR Code
|
||||
// noInterrupts();
|
||||
|
@ -449,8 +444,7 @@ bool IrHvacFujitsu(const char *HVAC_Mode, const char *HVAC_FanMode, bool HVAC_Po
|
|||
{
|
||||
const char kFujitsuHvacModeOptions[] = "HDCAF";
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("FUJITSU: mode:%s, fan:%s, power:%u, temp:%u"), HVAC_Mode, HVAC_FanMode, HVAC_Power, HVAC_Temp);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("FUJITSU: mode:%s, fan:%s, power:%u, temp:%u"), HVAC_Mode, HVAC_FanMode, HVAC_Power, HVAC_Temp);
|
||||
|
||||
IRFujitsuAC ac(pin[GPIO_IRSEND]);
|
||||
|
||||
|
@ -541,9 +535,7 @@ bool IrSendCommand(void)
|
|||
raw_array[i++] = strtoul(str, NULL, 0); // Allow decimal (5246996) and hexadecimal (0x501014) input
|
||||
}
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("IRS: Count %d, Freq %d, Arr[0] %d, Arr[count -1] %d"),
|
||||
// count, freq, raw_array[0], raw_array[count -1]);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRS: Count %d, Freq %d, Arr[0] %d, Arr[count -1] %d"), count, freq, raw_array[0], raw_array[count -1]);
|
||||
|
||||
irsend_active = true;
|
||||
irsend->sendRaw(raw_array, count, freq);
|
||||
|
@ -573,9 +565,8 @@ bool IrSendCommand(void)
|
|||
char protocol_text[20];
|
||||
int protocol_code = GetCommandCode(protocol_text, sizeof(protocol_text), protocol, kIrRemoteProtocols);
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("IRS: protocol_text %s, protocol %s, bits %d, data %u (0x%lX), protocol_code %d"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRS: protocol_text %s, protocol %s, bits %d, data %u (0x%lX), protocol_code %d"),
|
||||
protocol_text, protocol, bits, data, data, protocol_code);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
|
||||
irsend_active = true;
|
||||
switch (protocol_code) {
|
||||
|
@ -637,9 +628,7 @@ bool IrSendCommand(void)
|
|||
HVAC_FanMode = root[D_JSON_IRHVAC_FANSPEED];
|
||||
HVAC_Temp = root[D_JSON_IRHVAC_TEMP];
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("IRHVAC: Received Vendor %s, Power %d, Mode %s, FanSpeed %s, Temp %d"),
|
||||
// HVAC_Vendor, HVAC_Power, HVAC_Mode, HVAC_FanMode, HVAC_Temp);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("IRHVAC: Received Vendor %s, Power %d, Mode %s, FanSpeed %s, Temp %d"), HVAC_Vendor, HVAC_Power, HVAC_Mode, HVAC_FanMode, HVAC_Temp);
|
||||
|
||||
char vendor[20];
|
||||
int vendor_code = GetCommandCode(vendor, sizeof(vendor), HVAC_Vendor, kIrHvacVendors);
|
||||
|
|
|
@ -206,8 +206,7 @@ bool DomoticzMqttData(void)
|
|||
nvalue = domoticz["nvalue"];
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DOMOTICZ "idx %d, nvalue %d"), idx, nvalue);
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ "idx %d, nvalue %d"), idx, nvalue);
|
||||
|
||||
if ((idx > 0) && (nvalue >= 0) && (nvalue <= 15)) {
|
||||
uint8_t maxdev = (devices_present > MAX_DOMOTICZ_IDX) ? MAX_DOMOTICZ_IDX : devices_present;
|
||||
|
@ -275,8 +274,7 @@ bool DomoticzMqttData(void)
|
|||
return 1;
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DOMOTICZ D_RECEIVED_TOPIC " %s, " D_DATA " %s"), XdrvMailbox.topic, XdrvMailbox.data);
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_DOMOTICZ D_RECEIVED_TOPIC " %s, " D_DATA " %s"), XdrvMailbox.topic, XdrvMailbox.data);
|
||||
|
||||
domoticz_update_flag = 0;
|
||||
}
|
||||
|
@ -439,14 +437,14 @@ const char HTTP_FORM_DOMOTICZ[] PROGMEM =
|
|||
"<br/>"
|
||||
"<table>";
|
||||
const char HTTP_FORM_DOMOTICZ_RELAY[] PROGMEM =
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_IDX " {1</b></td><td style='width:70px'><input id='r{1' name='r{1' placeholder='0' value='{2'></td></tr>"
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_KEY_IDX " {1</b></td><td style='width:70px'><input id='k{1' name='k{1' placeholder='0' value='{3'></td></tr>";
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_IDX " %d</b></td><td style='width:70px'><input id='r%d' name='r%d' placeholder='0' value='%d'></td></tr>"
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_KEY_IDX " %d</b></td><td style='width:70px'><input id='k%d' name='k%d' placeholder='0' value='%d'></td></tr>";
|
||||
const char HTTP_FORM_DOMOTICZ_SWITCH[] PROGMEM =
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_SWITCH_IDX " {1</b></td><td style='width:70px'><input id='s{1' name='s{1' placeholder='0' value='{4'></td></tr>";
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_SWITCH_IDX " %d</b></td><td style='width:70px'><input id='s%d' name='s%d' placeholder='0' value='%d'></td></tr>";
|
||||
const char HTTP_FORM_DOMOTICZ_SENSOR[] PROGMEM =
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_SENSOR_IDX " {1</b> {2</td><td style='width:70px'><input id='l{1' name='l{1' placeholder='0' value='{5'></td></tr>";
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_SENSOR_IDX " %d</b> %s</td><td style='width:70px'><input id='l%d' name='l%d' placeholder='0' value='%d'></td></tr>";
|
||||
const char HTTP_FORM_DOMOTICZ_TIMER[] PROGMEM =
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_UPDATE_TIMER "</b> (" STR(DOMOTICZ_UPDATE_TIMER) ")</td><td style='width:70px'><input id='ut' name='ut' placeholder='" STR(DOMOTICZ_UPDATE_TIMER) "' value='{6'</td></tr>";
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_UPDATE_TIMER "</b> (" STR(DOMOTICZ_UPDATE_TIMER) ")</td><td style='width:70px'><input id='ut' name='ut' placeholder='" STR(DOMOTICZ_UPDATE_TIMER) "' value='%d'</td></tr>";
|
||||
|
||||
void HandleDomoticzConfiguration(void)
|
||||
{
|
||||
|
@ -462,35 +460,30 @@ void HandleDomoticzConfiguration(void)
|
|||
|
||||
char stemp[32];
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
page.replace(F("{v}"), FPSTR(S_CONFIGURE_DOMOTICZ));
|
||||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
page += FPSTR(HTTP_FORM_DOMOTICZ);
|
||||
WSContentStart(FPSTR(S_CONFIGURE_DOMOTICZ));
|
||||
WSContentSendStyle();
|
||||
WSContentSend(FPSTR(HTTP_FORM_DOMOTICZ));
|
||||
for (int i = 0; i < MAX_DOMOTICZ_IDX; i++) {
|
||||
if (i < devices_present) {
|
||||
page += FPSTR(HTTP_FORM_DOMOTICZ_RELAY);
|
||||
page.replace("{2", String((int)Settings.domoticz_relay_idx[i]));
|
||||
page.replace("{3", String((int)Settings.domoticz_key_idx[i]));
|
||||
WSContentSend_P(HTTP_FORM_DOMOTICZ_RELAY,
|
||||
i +1, i, i, Settings.domoticz_relay_idx[i],
|
||||
i +1, i, i, Settings.domoticz_key_idx[i]);
|
||||
}
|
||||
if (pin[GPIO_SWT1 +i] < 99) {
|
||||
page += FPSTR(HTTP_FORM_DOMOTICZ_SWITCH);
|
||||
page.replace("{4", String((int)Settings.domoticz_switch_idx[i]));
|
||||
WSContentSend_P(HTTP_FORM_DOMOTICZ_SWITCH,
|
||||
i +1, i, i, Settings.domoticz_switch_idx[i]);
|
||||
}
|
||||
page.replace("{1", String(i +1));
|
||||
if ((SONOFF_IFAN02 == my_module_type) && (1 == i)) { break; }
|
||||
}
|
||||
for (int i = 0; i < DZ_MAX_SENSORS; i++) {
|
||||
page += FPSTR(HTTP_FORM_DOMOTICZ_SENSOR);
|
||||
page.replace("{1", String(i +1));
|
||||
page.replace("{2", GetTextIndexed(stemp, sizeof(stemp), i, kDomoticzSensors));
|
||||
page.replace("{5", String((int)Settings.domoticz_sensor_idx[i]));
|
||||
WSContentSend_P(HTTP_FORM_DOMOTICZ_SENSOR,
|
||||
i +1, GetTextIndexed(stemp, sizeof(stemp), i, kDomoticzSensors), i, i, Settings.domoticz_sensor_idx[i]);
|
||||
}
|
||||
page += FPSTR(HTTP_FORM_DOMOTICZ_TIMER);
|
||||
page.replace("{6", String((int)Settings.domoticz_update_timer));
|
||||
page += F("</table>");
|
||||
page += FPSTR(HTTP_FORM_END);
|
||||
page += FPSTR(HTTP_BTN_CONF);
|
||||
ShowPage(page);
|
||||
WSContentSend_P(HTTP_FORM_DOMOTICZ_TIMER, Settings.domoticz_update_timer);
|
||||
WSContentSend(F("</table>"));
|
||||
WSContentSend(FPSTR(HTTP_FORM_END));
|
||||
WSContentSend(FPSTR(HTTP_BTN_CONF));
|
||||
WSContentEnd();
|
||||
}
|
||||
|
||||
void DomoticzSaveSettings(void)
|
||||
|
@ -500,19 +493,19 @@ void DomoticzSaveSettings(void)
|
|||
char tmp[100];
|
||||
|
||||
for (uint8_t i = 0; i < MAX_DOMOTICZ_IDX; i++) {
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("r%d"), i +1);
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("r%d"), i);
|
||||
WebGetArg(stemp, tmp, sizeof(tmp));
|
||||
Settings.domoticz_relay_idx[i] = (!strlen(tmp)) ? 0 : atoi(tmp);
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("k%d"), i +1);
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("k%d"), i);
|
||||
WebGetArg(stemp, tmp, sizeof(tmp));
|
||||
Settings.domoticz_key_idx[i] = (!strlen(tmp)) ? 0 : atoi(tmp);
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("s%d"), i +1);
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("s%d"), i);
|
||||
WebGetArg(stemp, tmp, sizeof(tmp));
|
||||
Settings.domoticz_switch_idx[i] = (!strlen(tmp)) ? 0 : atoi(tmp);
|
||||
}
|
||||
ssensor_indices[0] = '\0';
|
||||
for (uint8_t i = 0; i < DZ_MAX_SENSORS; i++) {
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("l%d"), i +1);
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("l%d"), i);
|
||||
WebGetArg(stemp, tmp, sizeof(tmp));
|
||||
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]);
|
||||
|
@ -520,12 +513,11 @@ void DomoticzSaveSettings(void)
|
|||
WebGetArg("ut", tmp, sizeof(tmp));
|
||||
Settings.domoticz_update_timer = (!strlen(tmp)) ? DOMOTICZ_UPDATE_TIMER : atoi(tmp);
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), 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"),
|
||||
AddLog_P2(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"),
|
||||
Settings.domoticz_relay_idx[0], Settings.domoticz_relay_idx[1], Settings.domoticz_relay_idx[2], Settings.domoticz_relay_idx[3],
|
||||
Settings.domoticz_key_idx[0], Settings.domoticz_key_idx[1], Settings.domoticz_key_idx[2], Settings.domoticz_key_idx[3],
|
||||
Settings.domoticz_switch_idx[0], Settings.domoticz_switch_idx[1], Settings.domoticz_switch_idx[2], Settings.domoticz_switch_idx[3],
|
||||
ssensor_indices, Settings.domoticz_update_timer);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
|
@ -541,7 +533,7 @@ bool Xdrv07(uint8_t function)
|
|||
switch (function) {
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_WEB_ADD_BUTTON:
|
||||
strncat_P(mqtt_data, HTTP_BTN_MENU_DOMOTICZ, sizeof(mqtt_data) - strlen(mqtt_data) -1);
|
||||
WSContentSend(FPSTR(HTTP_BTN_MENU_DOMOTICZ));
|
||||
break;
|
||||
case FUNC_WEB_ADD_HANDLER:
|
||||
WebServer->on("/" WEB_HANDLE_DOMOTICZ, HandleDomoticzConfiguration);
|
||||
|
|
|
@ -137,7 +137,7 @@ bool SerialBridgeCommand(void)
|
|||
int size = strlen(XdrvMailbox.data);
|
||||
|
||||
while (size > 0) {
|
||||
snprintf(stemp, sizeof(stemp), codes);
|
||||
strlcpy(stemp, codes, sizeof(stemp));
|
||||
code = strtol(stemp, &p, 16);
|
||||
SerialBridgeSerial->write(code); // "AA004566" as hex values
|
||||
size -= 2;
|
||||
|
|
|
@ -385,7 +385,7 @@ bool TimerCommand(void)
|
|||
uint8_t sign = 0;
|
||||
char time_str[10];
|
||||
|
||||
snprintf(time_str, sizeof(time_str), root[parm_uc]);
|
||||
strlcpy(time_str, root[parm_uc], sizeof(time_str));
|
||||
const char *substr = strtok(time_str, ":");
|
||||
if (substr != NULL) {
|
||||
if (strchr(substr, '-')) {
|
||||
|
@ -519,7 +519,7 @@ const char S_CONFIGURE_TIMER[] PROGMEM = D_CONFIGURE_TIMER;
|
|||
const char HTTP_BTN_MENU_TIMER[] PROGMEM =
|
||||
"<p><form action='" WEB_HANDLE_TIMER "' method='get'><button>" D_CONFIGURE_TIMER "</button></form></p>";
|
||||
|
||||
const char HTTP_TIMER_SCRIPT[] PROGMEM =
|
||||
const char HTTP_TIMER_SCRIPT1[] PROGMEM =
|
||||
"var pt=[],ct=99;"
|
||||
"function qs(s){" // Alias to save code space
|
||||
"return document.querySelector(s);"
|
||||
|
@ -528,8 +528,9 @@ const char HTTP_TIMER_SCRIPT[] PROGMEM =
|
|||
"var o=document.createElement('option');"
|
||||
"o.textContent=i;"
|
||||
"q.appendChild(o);"
|
||||
"}"
|
||||
"}";
|
||||
#ifdef USE_SUNRISE
|
||||
const char HTTP_TIMER_SCRIPT2[] PROGMEM =
|
||||
"function gt(){" // Set hours and minutes according to mode
|
||||
"var m,p,q;"
|
||||
"m=qs('input[name=\"rd\"]:checked').value;" // Get mode
|
||||
|
@ -558,8 +559,9 @@ const char HTTP_TIMER_SCRIPT[] PROGMEM =
|
|||
"qs('#dr').disabled='disabled';"
|
||||
"if(e<23){for(i=12;i<=23;i++){ce(i,o);}}" // Create hours select options
|
||||
"}"
|
||||
"}"
|
||||
"}";
|
||||
#endif
|
||||
const char HTTP_TIMER_SCRIPT3[] PROGMEM =
|
||||
"function st(){" // Save parameters to hidden area
|
||||
"var i,l,m,n,p,s;"
|
||||
"m=0;s=0;"
|
||||
|
@ -570,7 +572,7 @@ const char HTTP_TIMER_SCRIPT[] PROGMEM =
|
|||
"m=qs('input[name=\"rd\"]:checked').value;" // Check mode
|
||||
"s|=(qs('input[name=\"rd\"]:checked').value<<29);" // Get mode
|
||||
#endif
|
||||
"if(}1>0){"
|
||||
"if(%d>0){"
|
||||
"i=qs('#d1').selectedIndex;if(i>=0){s|=(i<<23);}" // Get output
|
||||
"s|=(qs('#p1').selectedIndex<<27);" // Get action
|
||||
"}else{"
|
||||
|
@ -587,7 +589,8 @@ const char HTTP_TIMER_SCRIPT[] PROGMEM =
|
|||
"s|=((qs('#mw').selectedIndex)&0x0F)<<11;" // Get window minutes
|
||||
"pt[ct]=s;"
|
||||
"eb('t0').value=pt.join();" // Save parameters from array to hidden area
|
||||
"}"
|
||||
"}";
|
||||
const char HTTP_TIMER_SCRIPT4[] PROGMEM =
|
||||
"function ot(t,e){" // Select tab and update elements
|
||||
"var i,n,o,p,q,s;"
|
||||
"if(ct<99){st();}" // Save changes
|
||||
|
@ -602,23 +605,24 @@ const char HTTP_TIMER_SCRIPT[] PROGMEM =
|
|||
#else
|
||||
"p=s&0x7FF;" // Get time
|
||||
"q=Math.floor(p/60);if(q<10){q='0'+q;}qs('#ho').value=q;" // Set hours
|
||||
"q=p%60;if(q<10){q='0'+q;}qs('#mi').value=q;" // Set minutes
|
||||
"q=p%%60;if(q<10){q='0'+q;}qs('#mi').value=q;" // Set minutes
|
||||
#endif
|
||||
"q=(s>>11)&0xF;if(q<10){q='0'+q;}qs('#mw').value=q;" // Set window minutes
|
||||
"for(i=0;i<7;i++){p=(s>>(16+i))&1;eb('w'+i).checked=p;}" // Set weekdays
|
||||
"if(}1>0){"
|
||||
"if(%d>0){"
|
||||
"p=(s>>23)&0xF;qs('#d1').value=p+1;" // Set output
|
||||
"p=(s>>27)&3;qs('#p1').selectedIndex=p;" // Set action
|
||||
"}"
|
||||
"p=(s>>15)&1;eb('r0').checked=p;" // Set repeat
|
||||
"p=(s>>31)&1;eb('a0').checked=p;" // Set arm
|
||||
"}"
|
||||
"}";
|
||||
const char HTTP_TIMER_SCRIPT5[] PROGMEM =
|
||||
"function it(){" // Initialize elements and select first tab
|
||||
"var b,i,o,s;"
|
||||
"pt=eb('t0').value.split(',').map(Number);" // Get parameters from hidden area to array
|
||||
"s='';for(i=0;i<" STR(MAX_TIMERS) ";i++){b='';if(0==i){b=\" id='dP'\";}s+=\"<button type='button' class='tl' onclick='ot(\"+i+\",this)'\"+b+\">\"+(i+1)+\"</button>\"}"
|
||||
"eb('bt').innerHTML=s;" // Create tabs
|
||||
"if(}1>0){" // Create Output and Action drop down boxes
|
||||
"if(%d>0){" // Create Output and Action drop down boxes
|
||||
"eb('oa').innerHTML=\"<b>" D_TIMER_OUTPUT "</b> <span><select style='width:60px;' id='d1' name='d1'></select></span> <b>" D_TIMER_ACTION "</b> <select style='width:99px;' id='p1' name='p1'></select>\";"
|
||||
"o=qs('#p1');ce('" D_OFF "',o);ce('" D_ON "',o);ce('" D_TOGGLE "',o);" // Create offset direction select options
|
||||
#ifdef USE_RULES
|
||||
|
@ -628,48 +632,52 @@ const char HTTP_TIMER_SCRIPT[] PROGMEM =
|
|||
#endif
|
||||
"}else{"
|
||||
"eb('oa').innerHTML=\"<b>" D_TIMER_ACTION "</b> " D_RULE "\";" // No outputs but rule is allowed
|
||||
"}"
|
||||
"}";
|
||||
const char HTTP_TIMER_SCRIPT6[] PROGMEM =
|
||||
#ifdef USE_SUNRISE
|
||||
"o=qs('#dr');ce('+',o);ce('-',o);" // Create offset direction select options
|
||||
#endif
|
||||
"o=qs('#ho');for(i=0;i<=23;i++){ce((i<10)?('0'+i):i,o);}" // Create hours select options
|
||||
"o=qs('#mi');for(i=0;i<=59;i++){ce((i<10)?('0'+i):i,o);}" // Create minutes select options
|
||||
"o=qs('#mw');for(i=0;i<=15;i++){ce((i<10)?('0'+i):i,o);}" // Create window minutes select options
|
||||
"o=qs('#d1');for(i=0;i<}1;i++){ce(i+1,o);}" // Create outputs
|
||||
"o=qs('#d1');for(i=0;i<%d;i++){ce(i+1,o);}" // Create outputs
|
||||
"var a='" D_DAY3LIST "';"
|
||||
"s='';for(i=0;i<7;i++){s+=\"<input id='w\"+i+\"' name='w\"+i+\"' type='checkbox'><b>\"+a.substring(i*3,(i*3)+3)+\"</b> \"}"
|
||||
"eb('ds').innerHTML=s;" // Create weekdays
|
||||
"eb('dP').click();" // Get the element with id='dP' and click on it
|
||||
"}";
|
||||
"}"
|
||||
"window.onload=it;";
|
||||
const char HTTP_TIMER_STYLE[] PROGMEM =
|
||||
".tl{float:left;border-radius:0;border:1px solid #f2f2f2;padding:1px;width:6.25%;}" // Border color needs to be the same as Fieldset background color from HTTP_HEAD_STYLE (transparent won't work)
|
||||
"</style>";
|
||||
const char HTTP_FORM_TIMER[] PROGMEM =
|
||||
".tl{float:left;border-radius:0;border:1px solid #f2f2f2;padding:1px;width:6.25%;}"; // Border color needs to be the same as Fieldset background color from HTTP_HEAD_STYLE1 (transparent won't work)
|
||||
const char HTTP_FORM_TIMER1[] PROGMEM =
|
||||
"<fieldset style='min-width:470px;text-align:center;'>"
|
||||
"<legend style='text-align:left;'><b> " D_TIMER_PARAMETERS " </b></legend>"
|
||||
"<form method='post' action='" WEB_HANDLE_TIMER "' onsubmit='return st();'>"
|
||||
"<br/><input id='e0' name='e0' type='checkbox'{e0><b>" D_TIMER_ENABLE "</b><br/><br/><hr/>"
|
||||
"<br/><input id='e0' name='e0' type='checkbox'%s><b>" D_TIMER_ENABLE "</b><br/><br/><hr/>"
|
||||
"<input id='t0' name='t0' value='";
|
||||
const char HTTP_FORM_TIMER1[] PROGMEM =
|
||||
const char HTTP_FORM_TIMER2[] PROGMEM =
|
||||
"' hidden><div id='bt' name='bt'></div><br/><br/><br/>"
|
||||
"<div id='oa' name='oa'></div><br/>"
|
||||
"<div>"
|
||||
"<input id='a0' name='a0' type='checkbox'><b>" D_TIMER_ARM "</b> "
|
||||
"<input id='r0' name='r0' type='checkbox'><b>" D_TIMER_REPEAT "</b>"
|
||||
"</div><br/>"
|
||||
"<div>"
|
||||
"<div>";
|
||||
#ifdef USE_SUNRISE
|
||||
"<fieldset style='width:299px;margin:auto;text-align:left;border:0;'>" // 299 used in page.replace(F("299")
|
||||
const char HTTP_FORM_TIMER3[] PROGMEM =
|
||||
"<fieldset style='width:%dpx;margin:auto;text-align:left;border:0;'>"
|
||||
"<input id='b0' name='rd' type='radio' value='0' onclick='gt();'><b>" D_TIMER_TIME "</b><br/>"
|
||||
"<input id='b1' name='rd' type='radio' value='1' onclick='gt();'><b>" D_SUNRISE "</b> (}8)<br/>"
|
||||
"<input id='b2' name='rd' type='radio' value='2' onclick='gt();'><b>" D_SUNSET "</b> (}9)<br/>"
|
||||
"<input id='b1' name='rd' type='radio' value='1' onclick='gt();'><b>" D_SUNRISE "</b> (%s)<br/>"
|
||||
"<input id='b2' name='rd' type='radio' value='2' onclick='gt();'><b>" D_SUNSET "</b> (%s)<br/>"
|
||||
"</fieldset>"
|
||||
"<p></p>"
|
||||
"<span><select style='width:46px;' id='dr' name='dr'></select></span>"
|
||||
" "
|
||||
" ";
|
||||
#else
|
||||
"<b>" D_TIMER_TIME "</b> "
|
||||
const char HTTP_FORM_TIMER3[] PROGMEM =
|
||||
"<b>" D_TIMER_TIME "</b> ";
|
||||
#endif // USE_SUNRISE
|
||||
const char HTTP_FORM_TIMER4[] PROGMEM =
|
||||
"<span><select style='width:60px;' id='ho' name='ho'></select></span>"
|
||||
" " D_HOUR_MINUTE_SEPARATOR " "
|
||||
"<span><select style='width:60px;' id='mi' name='mi'></select></span>"
|
||||
|
@ -690,28 +698,30 @@ void HandleTimerConfiguration(void)
|
|||
return;
|
||||
}
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
page.replace(F("{v}"), FPSTR(S_CONFIGURE_TIMER));
|
||||
page += FPSTR(HTTP_TIMER_SCRIPT);
|
||||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
page.replace(F("</style>"), FPSTR(HTTP_TIMER_STYLE));
|
||||
page += FPSTR(HTTP_FORM_TIMER);
|
||||
page.replace(F("{e0"), (Settings.flag3.timers_enable) ? F(" checked") : F(""));
|
||||
for (uint8_t i = 0; i < MAX_TIMERS; i++) {
|
||||
if (i > 0) { page += F(","); }
|
||||
page += String(Settings.timer[i].data);
|
||||
}
|
||||
page += FPSTR(HTTP_FORM_TIMER1);
|
||||
page.replace(F("}1"), String(devices_present));
|
||||
WSContentStart(FPSTR(S_CONFIGURE_TIMER));
|
||||
WSContentSend(FPSTR(HTTP_TIMER_SCRIPT1));
|
||||
#ifdef USE_SUNRISE
|
||||
page.replace(F("}8"), GetSun(0)); // Add Sunrise
|
||||
page.replace(F("}9"), GetSun(1)); // Add Sunset
|
||||
page.replace(F("299"), String(100 + (strlen(D_SUNSET) *12))); // Fix string length to keep radios centered
|
||||
WSContentSend(FPSTR(HTTP_TIMER_SCRIPT2));
|
||||
#endif // USE_SUNRISE
|
||||
page += FPSTR(HTTP_FORM_END);
|
||||
page += F("<script>it();</script>"); // Init elements and select first tab/button
|
||||
page += FPSTR(HTTP_BTN_CONF);
|
||||
ShowPage(page);
|
||||
WSContentSend_P(HTTP_TIMER_SCRIPT3, devices_present);
|
||||
WSContentSend_P(HTTP_TIMER_SCRIPT4, devices_present);
|
||||
WSContentSend_P(HTTP_TIMER_SCRIPT5, devices_present);
|
||||
WSContentSend_P(HTTP_TIMER_SCRIPT6, devices_present);
|
||||
WSContentSendStyle(FPSTR(HTTP_TIMER_STYLE));
|
||||
WSContentSend_P(HTTP_FORM_TIMER1, (Settings.flag3.timers_enable) ? " checked" : "");
|
||||
for (uint8_t i = 0; i < MAX_TIMERS; i++) {
|
||||
WSContentSend_P(PSTR("%s%u"), (i > 0) ? "," : "", Settings.timer[i].data);
|
||||
}
|
||||
WSContentSend(FPSTR(HTTP_FORM_TIMER2));
|
||||
#ifdef USE_SUNRISE
|
||||
WSContentSend_P(HTTP_FORM_TIMER3, 100 + (strlen(D_SUNSET) *12), GetSun(0).c_str(), GetSun(1).c_str());
|
||||
#else
|
||||
WSContentSend(FPSTR(HTTP_FORM_TIMER3));
|
||||
#endif // USE_SUNRISE
|
||||
WSContentSend(FPSTR(HTTP_FORM_TIMER4));
|
||||
WSContentSend(FPSTR(HTTP_FORM_END));
|
||||
WSContentSend(FPSTR(HTTP_BTN_CONF));
|
||||
WSContentEnd();
|
||||
}
|
||||
|
||||
void TimerSaveSettings(void)
|
||||
|
@ -754,9 +764,9 @@ bool Xdrv09(uint8_t function)
|
|||
#ifdef USE_TIMERS_WEB
|
||||
case FUNC_WEB_ADD_BUTTON:
|
||||
#ifdef USE_RULES
|
||||
strncat_P(mqtt_data, HTTP_BTN_MENU_TIMER, sizeof(mqtt_data) - strlen(mqtt_data) -1);
|
||||
WSContentSend(FPSTR(HTTP_BTN_MENU_TIMER));
|
||||
#else
|
||||
if (devices_present) { strncat_P(mqtt_data, HTTP_BTN_MENU_TIMER, sizeof(mqtt_data) - strlen(mqtt_data) -1); }
|
||||
if (devices_present) { WSContentSend(FPSTR(HTTP_BTN_MENU_TIMER)); }
|
||||
#endif // USE_RULES
|
||||
break;
|
||||
case FUNC_WEB_ADD_HANDLER:
|
||||
|
|
|
@ -218,7 +218,7 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule)
|
|||
}
|
||||
#endif // USE_TIMERS and USE_SUNRISE
|
||||
rule_param.toUpperCase();
|
||||
snprintf(rule_svalue, sizeof(rule_svalue), rule_param.c_str());
|
||||
strlcpy(rule_svalue, rule_param.c_str(), sizeof(rule_svalue));
|
||||
|
||||
int temp_value = GetStateNumber(rule_svalue);
|
||||
if (temp_value > -1) {
|
||||
|
@ -237,9 +237,8 @@ bool RulesRuleMatch(uint8_t rule_set, String &event, String &rule)
|
|||
double value = 0;
|
||||
const char* str_value = root[rule_task][rule_name];
|
||||
|
||||
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: Task %s, Name %s, Value |%s|, TrigCnt %d, TrigSt %d, Source %s, Json %s"),
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Task %s, Name %s, Value |%s|, TrigCnt %d, TrigSt %d, Source %s, Json %s"),
|
||||
// rule_task.c_str(), rule_name.c_str(), rule_svalue, rules_trigger_count[rule_set], bitRead(rules_triggers[rule_set], rules_trigger_count[rule_set]), event.c_str(), (str_value) ? str_value : "none");
|
||||
//AddLog(LOG_LEVEL_DEBUG);
|
||||
|
||||
if (!root[rule_task][rule_name].success()) { return false; }
|
||||
// No value but rule_name is ok
|
||||
|
@ -305,8 +304,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
|
|||
|
||||
delay(0); // Prohibit possible loop software watchdog
|
||||
|
||||
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: Event = %s, Rule = %s"), event_saved.c_str(), Settings.rules[rule_set]);
|
||||
//AddLog(LOG_LEVEL_DEBUG);
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event = %s, Rule = %s"), event_saved.c_str(), Settings.rules[rule_set]);
|
||||
|
||||
String rules = Settings.rules[rule_set];
|
||||
|
||||
|
@ -341,8 +339,7 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
|
|||
rules_event_value = "";
|
||||
String event = event_saved;
|
||||
|
||||
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: Event |%s|, Rule |%s|, Command(s) |%s|"), event.c_str(), event_trigger.c_str(), commands.c_str());
|
||||
//AddLog(LOG_LEVEL_DEBUG);
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event |%s|, Rule |%s|, Command(s) |%s|"), event.c_str(), event_trigger.c_str(), commands.c_str());
|
||||
|
||||
if (RulesRuleMatch(rule_set, event, event_trigger)) {
|
||||
commands.trim();
|
||||
|
@ -368,10 +365,9 @@ bool RuleSetProcess(uint8_t rule_set, String &event_saved)
|
|||
#endif // USE_TIMERS and USE_SUNRISE
|
||||
|
||||
char command[commands.length() +1];
|
||||
snprintf(command, sizeof(command), commands.c_str());
|
||||
strlcpy(command, commands.c_str(), sizeof(command));
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("RUL: %s performs \"%s\""), event_trigger.c_str(), command);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("RUL: %s performs \"%s\""), event_trigger.c_str(), command);
|
||||
|
||||
// snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, D_CMND_RULE, D_JSON_INITIATED);
|
||||
// MqttPublishPrefixTopic_P(RESULT_OR_STAT, PSTR(D_CMND_RULE));
|
||||
|
@ -396,8 +392,7 @@ bool RulesProcessEvent(char *json_event)
|
|||
String event_saved = json_event;
|
||||
event_saved.toUpperCase();
|
||||
|
||||
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: Event %s"), event_saved.c_str());
|
||||
//AddLog(LOG_LEVEL_DEBUG);
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Event %s"), event_saved.c_str());
|
||||
|
||||
for (uint8_t i = 0; i < MAX_RULE_SETS; i++) {
|
||||
if (strlen(Settings.rules[i]) && bitRead(Settings.rule_enabled, i)) {
|
||||
|
@ -608,15 +603,13 @@ bool RulesMqttData(void)
|
|||
}
|
||||
String sTopic = XdrvMailbox.topic;
|
||||
String sData = XdrvMailbox.data;
|
||||
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: MQTT Topic %s, Event %s"), XdrvMailbox.topic, XdrvMailbox.data);
|
||||
//AddLog(LOG_LEVEL_DEBUG);
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: MQTT Topic %s, Event %s"), XdrvMailbox.topic, XdrvMailbox.data);
|
||||
MQTT_Subscription event_item;
|
||||
//Looking for matched topic
|
||||
for (int index = 0; index < subscriptions.size(); index++) {
|
||||
event_item = subscriptions.get(index);
|
||||
|
||||
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: Match MQTT message Topic %s with subscription topic %s"), sTopic.c_str(), event_item.Topic.c_str());
|
||||
//AddLog(LOG_LEVEL_DEBUG);
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Match MQTT message Topic %s with subscription topic %s"), sTopic.c_str(), event_item.Topic.c_str());
|
||||
if (sTopic.startsWith(event_item.Topic)) {
|
||||
//This topic is subscribed by us, so serve it
|
||||
serviced = true;
|
||||
|
@ -686,8 +679,7 @@ String RulesSubscribe(const char *data, int data_len)
|
|||
}
|
||||
}
|
||||
}
|
||||
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: Subscribe command with parameters: %s, %s, %s."), event_name.c_str(), topic.c_str(), key.c_str());
|
||||
//AddLog(LOG_LEVEL_DEBUG);
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: Subscribe command with parameters: %s, %s, %s."), event_name.c_str(), topic.c_str(), key.c_str());
|
||||
event_name.toUpperCase();
|
||||
if (event_name.length() > 0 && topic.length() > 0) {
|
||||
//Search all subscriptions
|
||||
|
@ -708,8 +700,7 @@ String RulesSubscribe(const char *data, int data_len)
|
|||
topic.concat("/#");
|
||||
}
|
||||
}
|
||||
//snprintf_P(log_data, sizeof(log_data), PSTR("RUL: New topic: %s."), topic.c_str());
|
||||
//AddLog(LOG_LEVEL_DEBUG);
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RUL: New topic: %s."), topic.c_str());
|
||||
//MQTT Subscribe
|
||||
subscription_item.Event = event_name;
|
||||
subscription_item.Topic = topic.substring(0, topic.length() - 2); //Remove "/#" so easy to match
|
||||
|
|
|
@ -247,11 +247,10 @@ void KNX_ADD_GA( uint8_t GAop, uint8_t GA_FNUM, uint8_t GA_AREA, uint8_t GA_FDEF
|
|||
|
||||
Settings.knx_GA_registered++;
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_ADD " GA #%d: %s " D_TO " %d/%d/%d"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ADD " GA #%d: %s " D_TO " %d/%d/%d"),
|
||||
Settings.knx_GA_registered,
|
||||
device_param_ga[GAop-1],
|
||||
GA_FNUM, GA_AREA, GA_FDEF );
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
|
||||
|
@ -297,9 +296,8 @@ void KNX_DEL_GA( uint8_t GAnum )
|
|||
|
||||
Settings.knx_GA_registered--;
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_DELETE " GA #%d"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " GA #%d"),
|
||||
GAnum );
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
|
||||
|
@ -330,11 +328,10 @@ void KNX_ADD_CB( uint8_t CBop, uint8_t CB_FNUM, uint8_t CB_AREA, uint8_t CB_FDEF
|
|||
|
||||
Settings.knx_CB_registered++;
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_ADD " CB #%d: %d/%d/%d " D_TO " %s"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ADD " CB #%d: %d/%d/%d " D_TO " %s"),
|
||||
Settings.knx_CB_registered,
|
||||
CB_FNUM, CB_AREA, CB_FDEF,
|
||||
device_param_cb[CBop-1] );
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
|
||||
|
@ -387,8 +384,7 @@ void KNX_DEL_CB( uint8_t CBnum )
|
|||
device_param[oldparam-1].CB_id = KNX_Empty;
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_DELETE " CB #%d"), CBnum );
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " CB #%d"), CBnum );
|
||||
}
|
||||
|
||||
|
||||
|
@ -445,8 +441,7 @@ bool KNX_CONFIG_NOT_MATCH(void)
|
|||
void KNXStart(void)
|
||||
{
|
||||
knx.start(nullptr);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_START));
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_START));
|
||||
}
|
||||
|
||||
|
||||
|
@ -522,8 +517,7 @@ void KNX_INIT(void)
|
|||
if (KNX_CONFIG_NOT_MATCH()) {
|
||||
Settings.knx_GA_registered = 0;
|
||||
Settings.knx_CB_registered = 0;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_DELETE " " D_KNX_PARAMETERS ));
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_DELETE " " D_KNX_PARAMETERS));
|
||||
}
|
||||
|
||||
// Register Group Addresses to listen to
|
||||
|
@ -555,22 +549,18 @@ void KNX_CB_Action(message_t const &msg, void *arg)
|
|||
|
||||
if (msg.data_len == 1) {
|
||||
// COMMAND
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_RECEIVED_FROM " %d.%d.%d " D_COMMAND " %s: %d " D_TO " %s"),
|
||||
msg.received_on.ga.area, msg.received_on.ga.line, msg.received_on.ga.member,
|
||||
(msg.ct == KNX_CT_WRITE) ? D_KNX_COMMAND_WRITE : (msg.ct == KNX_CT_READ) ? D_KNX_COMMAND_READ : D_KNX_COMMAND_OTHER,
|
||||
msg.data[0],
|
||||
device_param_cb[(chan->type)-1]);
|
||||
tempchar[0] = msg.data[0];
|
||||
tempchar[1] = '\0';
|
||||
} else {
|
||||
// VALUE
|
||||
float tempvar = knx.data_to_2byte_float(msg.data);
|
||||
dtostrfd(tempvar,2,tempchar);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_RECEIVED_FROM " %d.%d.%d " D_COMMAND " %s: %s " D_TO " %s"),
|
||||
msg.received_on.ga.area, msg.received_on.ga.line, msg.received_on.ga.member,
|
||||
(msg.ct == KNX_CT_WRITE) ? D_KNX_COMMAND_WRITE : (msg.ct == KNX_CT_READ) ? D_KNX_COMMAND_READ : D_KNX_COMMAND_OTHER,
|
||||
tempchar,
|
||||
device_param_cb[(chan->type)-1]);
|
||||
}
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_KNX D_RECEIVED_FROM " %d.%d.%d " D_COMMAND " %s: %s " D_TO " %s"),
|
||||
msg.received_on.ga.area, msg.received_on.ga.line, msg.received_on.ga.member,
|
||||
(msg.ct == KNX_CT_WRITE) ? D_KNX_COMMAND_WRITE : (msg.ct == KNX_CT_READ) ? D_KNX_COMMAND_READ : D_KNX_COMMAND_OTHER,
|
||||
tempchar,
|
||||
device_param_cb[(chan->type)-1]);
|
||||
|
||||
switch (msg.ct)
|
||||
{
|
||||
|
@ -668,10 +658,9 @@ void KnxUpdatePowerState(uint8_t device, power_t state)
|
|||
knx.write_1bit(KNX_addr, device_param[device -1].last_state);
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"),
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"),
|
||||
device_param_ga[device -1], device_param[device -1].last_state,
|
||||
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
|
||||
i = KNX_GA_Search(device, i + 1);
|
||||
}
|
||||
|
@ -701,10 +690,9 @@ void KnxSendButtonPower(uint8_t key, uint8_t device, uint8_t state)
|
|||
knx.write_1bit(KNX_addr, !(state == 0));
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"),
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"),
|
||||
device_param_ga[device + 7], !(state == 0),
|
||||
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
|
||||
i = KNX_GA_Search(device + 8, i + 1);
|
||||
}
|
||||
|
@ -733,10 +721,9 @@ void KnxSensor(uint8_t sensor_type, float value)
|
|||
knx.write_2byte_float(KNX_addr, value);
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "%s " D_SENT_TO " %d.%d.%d "),
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s " D_SENT_TO " %d.%d.%d "),
|
||||
device_param_ga[sensor_type -1],
|
||||
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
|
||||
i = KNX_GA_Search(sensor_type, i+1);
|
||||
}
|
||||
|
@ -755,13 +742,14 @@ const char HTTP_BTN_MENU_KNX[] PROGMEM =
|
|||
"<p><form action='kn' method='get'><button>" D_CONFIGURE_KNX "</button></form></p>";
|
||||
|
||||
const char HTTP_FORM_KNX[] PROGMEM =
|
||||
"<fieldset><legend style='text-align:left;'><b> " D_KNX_PARAMETERS " </b>"
|
||||
"</legend><form method='post' action='kn'>"
|
||||
"<fieldset style='min-width:530px;'>"
|
||||
"<legend style='text-align:left;'><b> " D_KNX_PARAMETERS " </b></legend>"
|
||||
"<form method='post' action='kn'>"
|
||||
"<br/><center>"
|
||||
"<b>" D_KNX_PHYSICAL_ADDRESS " </b>"
|
||||
"<input style='width:12%;' type='number' name='area' min='0' max='15' value='{kna'> . "
|
||||
"<input style='width:12%;' type='number' name='line' min='0' max='15' value='{knl'> . "
|
||||
"<input style='width:12%;' type='number' name='member' min='0' max='255' value='{knm'>"
|
||||
"<input style='width:12%%;' type='number' name='area' min='0' max='15' value='%d'> . "
|
||||
"<input style='width:12%%;' type='number' name='line' min='0' max='15' value='%d'> . "
|
||||
"<input style='width:12%%;' type='number' name='member' min='0' max='255' value='%d'>"
|
||||
"<br/><br/>" D_KNX_PHYSICAL_ADDRESS_NOTE "<br/><br/>"
|
||||
"<input id='b1' name='b1' type='checkbox'";
|
||||
|
||||
|
@ -777,20 +765,20 @@ const char HTTP_FORM_KNX2[] PROGMEM =
|
|||
"<select name='GAop' style='width:25%;'>";
|
||||
|
||||
const char HTTP_FORM_KNX_OPT[] PROGMEM =
|
||||
"<option value='{vop}'>{nop}</option>";
|
||||
"<option value='%d'>%s</option>";
|
||||
|
||||
const char HTTP_FORM_KNX_GA[] PROGMEM =
|
||||
"<input style='width:12%;' type='number' id='GAfnum' name='GAfnum' min='0' max='31' value='0'> / "
|
||||
"<input style='width:12%;' type='number' id='GAarea' name='GAarea' min='0' max='7' value='0'> / "
|
||||
"<input style='width:12%;' type='number' id='GAfdef' name='GAfdef' min='0' max='255' value='0'> ";
|
||||
"<input style='width:12%%;' type='number' id='%s' name='%s' min='0' max='31' value='0'> / "
|
||||
"<input style='width:12%%;' type='number' id='%s' name='%s' min='0' max='7' value='0'> / "
|
||||
"<input style='width:12%%;' type='number' id='%s' name='%s' min='0' max='255' value='0'> ";
|
||||
|
||||
const char HTTP_FORM_KNX_ADD_BTN[] PROGMEM =
|
||||
"<button type='submit' onclick='fncbtnadd()' btndis name='btn_add' value='{btnval}' style='width:18%;'>" D_ADD "</button><br/><br/>"
|
||||
"<table style='width:80%; font-size: 14px;'><col width='250'><col width='30'>";
|
||||
"<button type='submit' onclick='%s()' %s name='btn_add' value='%d' style='width:18%%;'>" D_ADD "</button><br/><br/>"
|
||||
"<table style='width:80%%; font-size: 14px;'><col width='250'><col width='30'>";
|
||||
|
||||
const char HTTP_FORM_KNX_ADD_TABLE_ROW[] PROGMEM =
|
||||
"<tr><td><b>{optex} -> GAfnum / GAarea / GAfdef </b></td>"
|
||||
"<td><button type='submit' name='btn_del_ga' value='{opval}' class='button bred'> " D_DELETE " </button></td></tr>";
|
||||
"<tr><td><b>%s -> %d / %d / %d </b></td>"
|
||||
"<td><button type='submit' name='btn_del_ga' value='%d' class='button bred'> " D_DELETE " </button></td></tr>";
|
||||
|
||||
const char HTTP_FORM_KNX3[] PROGMEM =
|
||||
"</table></center></fieldset><br/>"
|
||||
|
@ -801,8 +789,8 @@ const char HTTP_FORM_KNX4[] PROGMEM =
|
|||
"-> <select name='CBop' style='width:25%;'>";
|
||||
|
||||
const char HTTP_FORM_KNX_ADD_TABLE_ROW2[] PROGMEM =
|
||||
"<tr><td><b>GAfnum / GAarea / GAfdef -> {optex}</b></td>"
|
||||
"<td><button type='submit' name='btn_del_cb' value='{opval}' class='button bred'> " D_DELETE " </button></td></tr>";
|
||||
"<tr><td><b>%d / %d / %d -> %s</b></td>"
|
||||
"<td><button type='submit' name='btn_del_cb' value='%d' class='button bred'> " D_DELETE " </button></td></tr>";
|
||||
|
||||
void HandleKNXConfiguration(void)
|
||||
{
|
||||
|
@ -871,113 +859,8 @@ void HandleKNXConfiguration(void)
|
|||
|
||||
}
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
page.replace(F("{v}"), FPSTR(S_CONFIGURE_KNX));
|
||||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
page.replace(F("340px"), F("530px"));
|
||||
page += FPSTR(HTTP_FORM_KNX);
|
||||
KNX_physs_addr.value = Settings.knx_physsical_addr;
|
||||
page.replace(F("{kna"), String(KNX_physs_addr.pa.area));
|
||||
page.replace(F("{knl"), String(KNX_physs_addr.pa.line));
|
||||
page.replace(F("{knm"), String(KNX_physs_addr.pa.member));
|
||||
if ( Settings.flag.knx_enabled ) { page += F(" checked"); }
|
||||
page += FPSTR(HTTP_FORM_KNX1);
|
||||
if ( Settings.flag.knx_enable_enhancement ) { page += F(" checked"); }
|
||||
|
||||
page += FPSTR(HTTP_FORM_KNX2);
|
||||
for (uint8_t i = 0; i < KNX_MAX_device_param ; i++)
|
||||
{
|
||||
if ( device_param[i].show )
|
||||
{
|
||||
page += FPSTR(HTTP_FORM_KNX_OPT);
|
||||
page.replace(F("{vop}"), String(device_param[i].type));
|
||||
page.replace(F("{nop}"), String(device_param_ga[i]));
|
||||
}
|
||||
}
|
||||
page += F("</select> -> ");
|
||||
page += FPSTR(HTTP_FORM_KNX_GA);
|
||||
page.replace(F("GAfnum"), F("GA_FNUM"));
|
||||
page.replace(F("GAarea"), F("GA_AREA"));
|
||||
page.replace(F("GAfdef"), F("GA_FDEF"));
|
||||
page.replace(F("GAfnum"), F("GA_FNUM"));
|
||||
page.replace(F("GAarea"), F("GA_AREA"));
|
||||
page.replace(F("GAfdef"), F("GA_FDEF"));
|
||||
page += FPSTR(HTTP_FORM_KNX_ADD_BTN);
|
||||
page.replace(F("{btnval}"), String(1));
|
||||
if (Settings.knx_GA_registered < MAX_KNX_GA) {
|
||||
page.replace(F("btndis"), F(" "));
|
||||
}
|
||||
else
|
||||
{
|
||||
page.replace(F("btndis"), F("disabled"));
|
||||
}
|
||||
page.replace(F("fncbtnadd"), F("GAwarning"));
|
||||
for (uint8_t i = 0; i < Settings.knx_GA_registered ; ++i)
|
||||
{
|
||||
if ( Settings.knx_GA_param[i] )
|
||||
{
|
||||
page += FPSTR(HTTP_FORM_KNX_ADD_TABLE_ROW);
|
||||
page.replace(F("{opval}"), String(i+1));
|
||||
page.replace(F("{optex}"), String(device_param_ga[Settings.knx_GA_param[i]-1]));
|
||||
KNX_addr.value = Settings.knx_GA_addr[i];
|
||||
page.replace(F("GAfnum"), String(KNX_addr.ga.area));
|
||||
page.replace(F("GAarea"), String(KNX_addr.ga.line));
|
||||
page.replace(F("GAfdef"), String(KNX_addr.ga.member));
|
||||
}
|
||||
}
|
||||
|
||||
page += FPSTR(HTTP_FORM_KNX3);
|
||||
page += FPSTR(HTTP_FORM_KNX_GA);
|
||||
page.replace(F("GAfnum"), F("CB_FNUM"));
|
||||
page.replace(F("GAarea"), F("CB_AREA"));
|
||||
page.replace(F("GAfdef"), F("CB_FDEF"));
|
||||
page.replace(F("GAfnum"), F("CB_FNUM"));
|
||||
page.replace(F("GAarea"), F("CB_AREA"));
|
||||
page.replace(F("GAfdef"), F("CB_FDEF"));
|
||||
page += FPSTR(HTTP_FORM_KNX4);
|
||||
uint8_t j;
|
||||
for (uint8_t i = 0; i < KNX_MAX_device_param ; i++)
|
||||
{
|
||||
// Check How many Relays are available and add: RelayX and TogleRelayX
|
||||
if ( (i > 8) && (i < 16) ) { j=i-8; } else { j=i; }
|
||||
if ( i == 8 ) { j = 0; }
|
||||
if ( device_param[j].show )
|
||||
{
|
||||
page += FPSTR(HTTP_FORM_KNX_OPT);
|
||||
page.replace(F("{vop}"), String(device_param[i].type));
|
||||
page.replace(F("{nop}"), String(device_param_cb[i]));
|
||||
}
|
||||
}
|
||||
page += F("</select> ");
|
||||
page += FPSTR(HTTP_FORM_KNX_ADD_BTN);
|
||||
page.replace(F("{btnval}"), String(2));
|
||||
if (Settings.knx_CB_registered < MAX_KNX_CB) {
|
||||
page.replace(F("btndis"), F(" "));
|
||||
}
|
||||
else
|
||||
{
|
||||
page.replace(F("btndis"), F("disabled"));
|
||||
}
|
||||
page.replace(F("fncbtnadd"), F("CBwarning"));
|
||||
|
||||
for (uint8_t i = 0; i < Settings.knx_CB_registered ; ++i)
|
||||
{
|
||||
if ( Settings.knx_CB_param[i] )
|
||||
{
|
||||
page += FPSTR(HTTP_FORM_KNX_ADD_TABLE_ROW2);
|
||||
page.replace(F("{opval}"), String(i+1));
|
||||
page.replace(F("{optex}"), String(device_param_cb[Settings.knx_CB_param[i]-1]));
|
||||
KNX_addr.value = Settings.knx_CB_addr[i];
|
||||
page.replace(F("GAfnum"), String(KNX_addr.ga.area));
|
||||
page.replace(F("GAarea"), String(KNX_addr.ga.line));
|
||||
page.replace(F("GAfdef"), String(KNX_addr.ga.member));
|
||||
}
|
||||
}
|
||||
page += F("</table></center></fieldset>");
|
||||
page += F("<br/><button name='save' type='submit' class='button bgrn'>" D_SAVE "</button></form></fieldset>");
|
||||
page += FPSTR(HTTP_BTN_CONF);
|
||||
|
||||
page.replace( F("</script>"),
|
||||
WSContentStart(FPSTR(S_CONFIGURE_KNX));
|
||||
WSContentSend(
|
||||
F("function GAwarning()"
|
||||
"{"
|
||||
"var GA_FNUM = eb('GA_FNUM');"
|
||||
|
@ -995,9 +878,63 @@ void HandleKNXConfiguration(void)
|
|||
"if ( CB_FNUM != null && CB_FNUM.value == '0' && CB_AREA.value == '0' && CB_FDEF.value == '0' ) {"
|
||||
"alert('" D_KNX_WARNING "');"
|
||||
"}"
|
||||
"}"
|
||||
"</script>") );
|
||||
ShowPage(page);
|
||||
"}"));
|
||||
WSContentSendStyle();
|
||||
WSContentSend_P(HTTP_FORM_KNX, KNX_physs_addr.pa.area, KNX_physs_addr.pa.line, KNX_physs_addr.pa.member);
|
||||
if ( Settings.flag.knx_enabled ) { WSContentSend(F(" checked")); }
|
||||
WSContentSend(FPSTR(HTTP_FORM_KNX1));
|
||||
if ( Settings.flag.knx_enable_enhancement ) { WSContentSend(F(" checked")); }
|
||||
|
||||
WSContentSend(FPSTR(HTTP_FORM_KNX2));
|
||||
for (uint8_t i = 0; i < KNX_MAX_device_param ; i++)
|
||||
{
|
||||
if ( device_param[i].show )
|
||||
{
|
||||
WSContentSend_P(HTTP_FORM_KNX_OPT, device_param[i].type, device_param_ga[i]);
|
||||
}
|
||||
}
|
||||
WSContentSend(F("</select> -> "));
|
||||
WSContentSend_P(HTTP_FORM_KNX_GA, "GA_FNUM", "GA_FNUM", "GA_AREA", "GA_AREA", "GA_FDEF", "GA_FDEF");
|
||||
WSContentSend_P(HTTP_FORM_KNX_ADD_BTN, "GAwarning", (Settings.knx_GA_registered < MAX_KNX_GA) ? "" : "disabled", 1);
|
||||
for (uint8_t i = 0; i < Settings.knx_GA_registered ; ++i)
|
||||
{
|
||||
if ( Settings.knx_GA_param[i] )
|
||||
{
|
||||
KNX_addr.value = Settings.knx_GA_addr[i];
|
||||
WSContentSend_P(HTTP_FORM_KNX_ADD_TABLE_ROW, device_param_ga[Settings.knx_GA_param[i]-1], KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member, i +1);
|
||||
}
|
||||
}
|
||||
|
||||
WSContentSend(FPSTR(HTTP_FORM_KNX3));
|
||||
WSContentSend_P(HTTP_FORM_KNX_GA, "CB_FNUM", "CB_FNUM", "CB_AREA", "CB_AREA", "CB_FDEF", "CB_FDEF");
|
||||
WSContentSend(FPSTR(HTTP_FORM_KNX4));
|
||||
|
||||
uint8_t j;
|
||||
for (uint8_t i = 0; i < KNX_MAX_device_param ; i++)
|
||||
{
|
||||
// Check How many Relays are available and add: RelayX and TogleRelayX
|
||||
if ( (i > 8) && (i < 16) ) { j=i-8; } else { j=i; }
|
||||
if ( i == 8 ) { j = 0; }
|
||||
if ( device_param[j].show )
|
||||
{
|
||||
WSContentSend_P(HTTP_FORM_KNX_OPT, device_param[i].type, device_param_cb[i]);
|
||||
}
|
||||
}
|
||||
WSContentSend(F("</select> "));
|
||||
WSContentSend_P(HTTP_FORM_KNX_ADD_BTN, "CBwarning", (Settings.knx_CB_registered < MAX_KNX_CB) ? "" : "disabled", 2);
|
||||
|
||||
for (uint8_t i = 0; i < Settings.knx_CB_registered ; ++i)
|
||||
{
|
||||
if ( Settings.knx_CB_param[i] )
|
||||
{
|
||||
KNX_addr.value = Settings.knx_CB_addr[i];
|
||||
WSContentSend_P(HTTP_FORM_KNX_ADD_TABLE_ROW2, KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member, device_param_cb[Settings.knx_CB_param[i]-1], i +1);
|
||||
}
|
||||
}
|
||||
WSContentSend(F("</table></center></fieldset>"));
|
||||
WSContentSend(FPSTR(HTTP_FORM_END));
|
||||
WSContentSend(FPSTR(HTTP_BTN_CONF));
|
||||
WSContentEnd();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1010,9 +947,8 @@ void KNX_Save_Settings(void)
|
|||
|
||||
Settings.flag.knx_enabled = WebServer->hasArg("b1");
|
||||
Settings.flag.knx_enable_enhancement = WebServer->hasArg("b2");
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_ENABLED ": %d, " D_KNX_ENHANCEMENT ": %d"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_ENABLED ": %d, " D_KNX_ENHANCEMENT ": %d"),
|
||||
Settings.flag.knx_enabled, Settings.flag.knx_enable_enhancement );
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
|
||||
stmp = WebServer->arg("area");
|
||||
KNX_addr.pa.area = stmp.toInt();
|
||||
|
@ -1022,33 +958,29 @@ void KNX_Save_Settings(void)
|
|||
KNX_addr.pa.member = stmp.toInt();
|
||||
Settings.knx_physsical_addr = KNX_addr.value;
|
||||
knx.physical_address_set( KNX_addr ); // Set Physical KNX Address of the device
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX D_KNX_PHYSICAL_ADDRESS ": %d.%d.%d "),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX D_KNX_PHYSICAL_ADDRESS ": %d.%d.%d "),
|
||||
KNX_addr.pa.area, KNX_addr.pa.line, KNX_addr.pa.member );
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "GA: %d"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "GA: %d"),
|
||||
Settings.knx_GA_registered );
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
for (uint8_t i = 0; i < Settings.knx_GA_registered ; ++i)
|
||||
{
|
||||
KNX_addr.value = Settings.knx_GA_addr[i];
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "GA #%d: %s " D_TO " %d/%d/%d"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "GA #%d: %s " D_TO " %d/%d/%d"),
|
||||
i+1, device_param_ga[Settings.knx_GA_param[i]-1],
|
||||
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member );
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "CB: %d"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "CB: %d"),
|
||||
Settings.knx_CB_registered );
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
for (uint8_t i = 0; i < Settings.knx_CB_registered ; ++i)
|
||||
{
|
||||
KNX_addr.value = Settings.knx_CB_addr[i];
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "CB #%d: %d/%d/%d " D_TO " %s"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_KNX "CB #%d: %d/%d/%d " D_TO " %s"),
|
||||
i+1,
|
||||
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member,
|
||||
device_param_cb[Settings.knx_CB_param[i]-1] );
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1078,10 +1010,9 @@ bool KnxCommand(void)
|
|||
knx.write_1bit(KNX_addr, !(XdrvMailbox.payload == 0));
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"),
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %d " D_SENT_TO " %d.%d.%d"),
|
||||
device_param_ga[index + KNX_SLOT1 -2], !(XdrvMailbox.payload == 0),
|
||||
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
|
||||
i = KNX_GA_Search(index + KNX_SLOT1 -1, i + 1);
|
||||
}
|
||||
|
@ -1107,10 +1038,9 @@ bool KnxCommand(void)
|
|||
knx.write_2byte_float(KNX_addr, tempvar);
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_KNX "%s = %s " D_SENT_TO " %d.%d.%d"),
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_KNX "%s = %s " D_SENT_TO " %d.%d.%d"),
|
||||
device_param_ga[index + KNX_SLOT1 -2], XdrvMailbox.data,
|
||||
KNX_addr.ga.area, KNX_addr.ga.line, KNX_addr.ga.member);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
|
||||
i = KNX_GA_Search(index + KNX_SLOT1 -1, i + 1);
|
||||
}
|
||||
|
@ -1299,7 +1229,7 @@ bool Xdrv11(uint8_t function)
|
|||
#ifdef USE_WEBSERVER
|
||||
#ifdef USE_KNX_WEB_MENU
|
||||
case FUNC_WEB_ADD_BUTTON:
|
||||
strncat_P(mqtt_data, HTTP_BTN_MENU_KNX, sizeof(mqtt_data) - strlen(mqtt_data) -1);
|
||||
WSContentSend(FPSTR(HTTP_BTN_MENU_KNX));
|
||||
break;
|
||||
case FUNC_WEB_ADD_HANDLER:
|
||||
WebServer->on("/kn", HandleKNXConfiguration);
|
||||
|
|
|
@ -172,10 +172,8 @@ int try_snprintf_P(char *s, size_t n, const char *format, ... )
|
|||
va_start(args, format);
|
||||
int len = vsnprintf_P(NULL, 0, format, args);
|
||||
if (len >= n) {
|
||||
snprintf_P(log_data, sizeof(log_data),
|
||||
PSTR("ERROR: MQTT discovery failed due to too long topic or friendly name. "
|
||||
"Please shorten topic and friendly name. Failed to format(%u/%u):"), len, n);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR("ERROR: MQTT discovery failed due to too long topic or friendly name. "
|
||||
"Please shorten topic and friendly name. Failed to format(%u/%u):"), len, n);
|
||||
va_start(args, format);
|
||||
vsnprintf_P(log_data, sizeof(log_data), format, args);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
|
@ -202,7 +200,7 @@ void HAssAnnounceRelayLight(void)
|
|||
|
||||
mqtt_data[0] = '\0'; // Clear retained message
|
||||
|
||||
// Clear "other" topic first in case the device has been reconfigured from ligth to switch or vice versa
|
||||
// Clear "other" topic first in case the device has been reconfigured from light to switch or vice versa
|
||||
snprintf_P(unique_id, sizeof(unique_id), PSTR("%06X_%s_%d"), ESP.getChipId(), (is_topic_light) ? "RL" : "LI", i);
|
||||
snprintf_P(stopic, sizeof(stopic), PSTR(HOME_ASSISTANT_DISCOVERY_PREFIX "/%s/%s/config"),
|
||||
(is_topic_light) ? "switch" : "light", unique_id);
|
||||
|
@ -319,7 +317,7 @@ void HAssAnnounceButtonSwitch(uint8_t device, char* topic, uint8_t present, uint
|
|||
name, state_topic, Settings.state_text[toggle?2:1], availability_topic);
|
||||
try_snprintf_P(mqtt_data, sizeof(mqtt_data)-1, HASS_DISCOVER_DEVICE_INFO_SHORT, mqtt_data,
|
||||
unique_id, ESP.getChipId());
|
||||
if (strlen(prefix) > 0 ) try_snprintf_P(mqtt_data-1, sizeof(mqtt_data), HASS_DISCOVER_TOPIC_PREFIX, mqtt_data, prefix);
|
||||
if (strlen(prefix) > 0 ) try_snprintf_P(mqtt_data, sizeof(mqtt_data)-1, HASS_DISCOVER_TOPIC_PREFIX, mqtt_data, prefix);
|
||||
if (toggle) try_snprintf_P(mqtt_data, sizeof(mqtt_data)-1, HASS_DISCOVER_BUTTON_SWITCH_TOGGLE, mqtt_data);
|
||||
else try_snprintf_P(mqtt_data, sizeof(mqtt_data)-1, HASS_DISCOVER_BUTTON_SWITCH_ONOFF, mqtt_data, Settings.state_text[0]);
|
||||
|
||||
|
@ -479,16 +477,14 @@ void HAssAnnounceSensors(void)
|
|||
StaticJsonBuffer<500> jsonBuffer;
|
||||
JsonObject& root = jsonBuffer.parseObject(sensordata);
|
||||
if (!root.success()) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("HASS: failed to parse '%s'"), sensordata);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR("HASS: failed to parse '%s'"), sensordata);
|
||||
continue;
|
||||
}
|
||||
for (auto sensor : root) {
|
||||
const char* sensorname = sensor.key;
|
||||
JsonObject& sensors = sensor.value.as<JsonObject>();
|
||||
if (!sensors.success()) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("HASS: failed to parse '%s'"), sensordata);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR("HASS: failed to parse '%s'"), sensordata);
|
||||
continue;
|
||||
}
|
||||
for (auto subsensor : sensors) {
|
||||
|
@ -543,11 +539,16 @@ void HAssAnnounceStatusSensor(void)
|
|||
void HAssPublishStatus(void)
|
||||
{
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data),
|
||||
PSTR("{\"" D_JSON_VERSION "\":\"%s%s\",\"" D_CMND_MODULE "\":\"%s\",\"" D_JSON_RESTARTREASON "\":\"%s\",\""
|
||||
D_JSON_UPTIME "\":\"%s\",\"" D_JSON_BOOTCOUNT "\":%d,\"" D_JSON_SAVECOUNT "\":%d,\""
|
||||
D_CMND_IPADDRESS "\":\"%s\",\"" D_JSON_RSSI "\":\"%d\",\"LoadAvg\":%lu}"),
|
||||
my_version, my_image, ModuleName().c_str(), GetResetReason().c_str(), GetUptime().c_str(), Settings.bootcount,
|
||||
Settings.save_flag, WiFi.localIP().toString().c_str(), WifiGetRssiAsQuality(WiFi.RSSI()), loop_load_avg);
|
||||
PSTR("{\"" D_JSON_VERSION "\":\"%s%s\",\"" D_JSON_BUILDDATETIME "\":\"%s\","
|
||||
"\"" D_JSON_COREVERSION "\":\"" ARDUINO_ESP8266_RELEASE "\",\"" D_JSON_SDKVERSION "\":\"%s\","
|
||||
"\"" D_CMND_MODULE "\":\"%s\",\"" D_JSON_RESTARTREASON "\":\"%s\",\"" D_JSON_UPTIME "\":\"%s\","
|
||||
"\"WiFi " D_JSON_LINK_COUNT "\":%d,\"WiFi " D_JSON_DOWNTIME "\":\"%s\","
|
||||
"\"" D_JSON_BOOTCOUNT "\":%d,\"" D_JSON_SAVECOUNT "\":%d,\"" D_CMND_IPADDRESS "\":\"%s\","
|
||||
"\"" D_JSON_RSSI "\":\"%d\",\"LoadAvg\":%lu}"),
|
||||
my_version, my_image, GetBuildDateAndTime().c_str(), ESP.getSdkVersion(), ModuleName().c_str(),
|
||||
GetResetReason().c_str(), GetUptime().c_str(), WifiLinkCount(), WifiDowntime().c_str(),
|
||||
Settings.bootcount, Settings.save_flag, WiFi.localIP().toString().c_str(),
|
||||
WifiGetRssiAsQuality(WiFi.RSSI()), loop_load_avg);
|
||||
MqttPublishPrefixTopic_P(TELE, PSTR(D_RSLT_HASS_STATE));
|
||||
}
|
||||
|
||||
|
|
|
@ -746,8 +746,7 @@ void DisplayJsonValue(const char* topic, const char* device, const char* mkey, c
|
|||
}
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR("%s %s"), source, svalue);
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "mkey [%s], source [%s], value [%s], quantity_code %d, log_buffer [%s]"), mkey, source, value, quantity_code, buffer);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "mkey [%s], source [%s], value [%s], quantity_code %d, log_buffer [%s]"), mkey, source, value, quantity_code, buffer);
|
||||
|
||||
DisplayLogBufferAdd(buffer);
|
||||
}
|
||||
|
@ -777,8 +776,7 @@ void DisplayAnalyzeJson(char *topic, char *json)
|
|||
tempunit = root[D_JSON_TEMPERATURE_UNIT];
|
||||
if (tempunit) {
|
||||
snprintf_P(disp_temp, sizeof(disp_temp), PSTR("%s"), tempunit);
|
||||
// snprintf_P(log_data, sizeof(log_data), disp_temp);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, disp_temp);
|
||||
}
|
||||
|
||||
for (JsonObject::iterator it = root.begin(); it != root.end(); ++it) {
|
||||
|
@ -883,8 +881,7 @@ void DisplayInitDriver(void)
|
|||
{
|
||||
XdspCall(FUNC_DISPLAY_INIT_DRIVER);
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "Display model %d"), Settings.display_model);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Display model %d"), Settings.display_model);
|
||||
|
||||
if (Settings.display_model) {
|
||||
devices_present++;
|
||||
|
|
|
@ -45,8 +45,7 @@ void PCA9685_Detect(void)
|
|||
if (I2cValidRead8(&buffer, USE_PCA9685_ADDR, PCA9685_REG_MODE1)) {
|
||||
if (0x20 == buffer) {
|
||||
pca9685_detected = 1;
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "PCA9685", USE_PCA9685_ADDR);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "PCA9685", USE_PCA9685_ADDR);
|
||||
PCA9685_Reset(); // Reset the controller
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +100,7 @@ void PCA9685_SetPWM(uint8_t pin, uint16_t pwm, bool inverted) {
|
|||
pca9685_pin_pwm_value[pin] = pwm;
|
||||
}
|
||||
|
||||
bool PCA9685_Command(void)
|
||||
bool PCA9685_Command(void)
|
||||
{
|
||||
bool serviced = true;
|
||||
bool validpin = false;
|
||||
|
|
|
@ -123,8 +123,7 @@ bool TuyaSetPower(void)
|
|||
|
||||
if (source != SRC_SWITCH && TuyaSerial) { // ignore to prevent loop from pushing state from faceplate interaction
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: SetDevicePower.rpower=%d"), rpower);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: SetDevicePower.rpower=%d"), rpower);
|
||||
|
||||
TuyaSendBool(TUYA_POWER_ID, rpower);
|
||||
|
||||
|
@ -146,16 +145,14 @@ void LightSerialDuty(uint8_t duty)
|
|||
duty = 25; // dimming acts odd below 25(10%) - this mirrors the threshold set on the faceplate itself
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR( "TYA: Send Serial Packet Dim Value=%d (id=%d)"), duty, Settings.param[P_TUYA_DIMMER_ID]);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR( "TYA: Send Serial Packet Dim Value=%d (id=%d)"), duty, Settings.param[P_TUYA_DIMMER_ID]);
|
||||
|
||||
TuyaSendValue(Settings.param[P_TUYA_DIMMER_ID], duty);
|
||||
|
||||
} else {
|
||||
tuya_ignore_dim = false; // reset flag
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR( "TYA: Send Dim Level skipped due to 0 or already set. Value=%d"), duty);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR( "TYA: Send Dim Level skipped due to 0 or already set. Value=%d"), duty);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -164,8 +161,7 @@ void TuyaRequestState(void){
|
|||
if(TuyaSerial) {
|
||||
|
||||
// Get current status of MCU
|
||||
snprintf_P(log_data, sizeof(log_data), "TYA: Request MCU state");
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Request MCU state"));
|
||||
|
||||
TuyaSendCmd(TUYA_CMD_QUERY_STATE);
|
||||
}
|
||||
|
@ -197,8 +193,7 @@ void TuyaPacketProcess(void)
|
|||
case TUYA_CMD_STATE:
|
||||
if (tuya_buffer[5] == 5) { // on/off packet
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data),PSTR("TYA: RX - %s State"),tuya_buffer[10]?"On":"Off");
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX - %s State"),tuya_buffer[10]?"On":"Off");
|
||||
|
||||
if((power || Settings.light_dimmer > 0) && (power != tuya_buffer[10])) {
|
||||
ExecuteCommandPower(1, tuya_buffer[10], SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
|
||||
|
@ -206,12 +201,10 @@ void TuyaPacketProcess(void)
|
|||
}
|
||||
else if (tuya_buffer[5] == 8) { // dim packet
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: RX Dim State=%d"), tuya_buffer[13]);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: RX Dim State=%d"), tuya_buffer[13]);
|
||||
|
||||
if (!Settings.param[P_TUYA_DIMMER_ID]) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: Autoconfiguring Dimmer ID %d"), tuya_buffer[6]);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Autoconfiguring Dimmer ID %d"), tuya_buffer[6]);
|
||||
Settings.param[P_TUYA_DIMMER_ID] = tuya_buffer[6];
|
||||
}
|
||||
|
||||
|
@ -220,8 +213,7 @@ void TuyaPacketProcess(void)
|
|||
|
||||
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), tuya_new_dim );
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: Send CMND_DIMMER_STR=%s"), scmnd );
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Send CMND_DIMMER_STR=%s"), scmnd );
|
||||
|
||||
tuya_ignore_dim = true;
|
||||
ExecuteCommand(scmnd, SRC_SWITCH);
|
||||
|
@ -297,8 +289,7 @@ void TuyaInit(void)
|
|||
if (TuyaSerial->begin(9600)) {
|
||||
if (TuyaSerial->hardwareSerial()) { ClaimSerial(); }
|
||||
// Get MCU Configuration
|
||||
snprintf_P(log_data, sizeof(log_data), "TYA: Request MCU configuration");
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Request MCU configuration"));
|
||||
|
||||
TuyaSendCmd(TUYA_CMD_MCU_CONF);
|
||||
}
|
||||
|
@ -364,8 +355,7 @@ void TuyaSerialInput(void)
|
|||
bool TuyaButtonPressed(void)
|
||||
{
|
||||
if (!XdrvMailbox.index && ((PRESSED == XdrvMailbox.payload) && (NOT_PRESSED == lastbutton[XdrvMailbox.index]))) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("TYA: Reset GPIO triggered"));
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("TYA: Reset GPIO triggered"));
|
||||
TuyaResetWifi();
|
||||
return true; // Reset GPIO served here
|
||||
}
|
||||
|
@ -387,8 +377,7 @@ void TuyaSetWifiLed(void){
|
|||
break;
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), "TYA: Set WiFi LED to state %d (%d)", wifi_state, WifiState());
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("TYA: Set WiFi LED to state %d (%d)"), wifi_state, WifiState());
|
||||
|
||||
TuyaSendCmd(TUYA_CMD_WIFI_STATE, &wifi_state, 1);
|
||||
}
|
||||
|
|
|
@ -49,8 +49,7 @@ void RfReceiveCheck(void)
|
|||
int protocol = mySwitch.getReceivedProtocol();
|
||||
int delay = mySwitch.getReceivedDelay();
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("RFR: Data %lX (%u), Bits %d, Protocol %d, Delay %d"), data, data, bits, protocol, delay);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RFR: Data %lX (%u), Bits %d, Protocol %d, Delay %d"), data, data, bits, protocol, delay);
|
||||
|
||||
uint32_t now = millis();
|
||||
if ((now - rf_lasttime > RF_TIME_AVOID_DUPLICATE) && (data > 0)) {
|
||||
|
|
|
@ -58,13 +58,11 @@ void LightSerial2Duty(uint8_t duty1, uint8_t duty2)
|
|||
ArmtronixSerial->print("\nDimmer2:");
|
||||
ArmtronixSerial->println(duty2);
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR( "ARM: Send Serial Packet Dim Values=%d,%d"), armtronix_dimState[0],armtronix_dimState[1]);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ARM: Send Serial Packet Dim Values=%d,%d"), armtronix_dimState[0],armtronix_dimState[1]);
|
||||
|
||||
} else {
|
||||
armtronix_ignore_dim = false;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR( "ARM: Send Dim Level skipped due to already set. Value=%d,%d"), armtronix_dimState[0],armtronix_dimState[1]);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ARM: Send Dim Level skipped due to already set. Value=%d,%d"), armtronix_dimState[0],armtronix_dimState[1]);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -73,8 +71,7 @@ void ArmtronixRequestState(void)
|
|||
{
|
||||
if (ArmtronixSerial) {
|
||||
// Get current status of MCU
|
||||
snprintf_P(log_data, sizeof(log_data), "TYA: Request MCU state");
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("ARM: Request MCU state"));
|
||||
ArmtronixSerial->println("Status");
|
||||
|
||||
}
|
||||
|
@ -123,8 +120,7 @@ void ArmtronixSerialInput(void)
|
|||
armtronix_ignore_dim = true;
|
||||
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_CHANNEL "%d %d"),i+1, temp);
|
||||
ExecuteCommand(scmnd,SRC_SWITCH);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("ARM: Send CMND_CHANNEL=%s"), scmnd );
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ARM: Send CMND_CHANNEL=%s"), scmnd );
|
||||
}
|
||||
commaIndex = answer.indexOf(',',commaIndex+1);
|
||||
}
|
||||
|
@ -152,8 +148,7 @@ void ArmtronixSetWifiLed(void)
|
|||
break;
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), "ARM: Set WiFi LED to state %d (%d)", wifi_state, WifiState());
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("ARM: Set WiFi LED to state %d (%d)"), wifi_state, WifiState());
|
||||
|
||||
char state = '0' + ((wifi_state & 1) > 0);
|
||||
ArmtronixSerial->print("Setled:");
|
||||
|
|
|
@ -67,8 +67,7 @@ void PS16DZSendCommand(char type = 0, uint8_t value = 0)
|
|||
break;
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR( "PSZ: Send serial command: %s"), ps16dz_tx_buffer );
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: Send serial command: %s"), ps16dz_tx_buffer );
|
||||
|
||||
PS16DZSerial->print(ps16dz_tx_buffer);
|
||||
PS16DZSerial->write(0x1B);
|
||||
|
@ -109,8 +108,7 @@ void PS16DZSerialDuty(uint8_t duty)
|
|||
} else {
|
||||
ps16dz_ignore_dim = false; // reset flag
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR( "PSZ: Send Dim Level skipped due to 0 or already set. Value=%d"), duty);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: Send Dim Level skipped due to 0 or already set. Value=%d"), duty);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -165,8 +163,7 @@ void PS16DZSerialInput(void)
|
|||
}
|
||||
else {
|
||||
ps16dz_rx_buffer[ps16dz_byte_counter++] = 0x00;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("PSZ: command received: %s"), ps16dz_rx_buffer);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: command received: %s"), ps16dz_rx_buffer);
|
||||
if(!strncmp(ps16dz_rx_buffer+3, "UPDATE", 6) || !strncmp(ps16dz_rx_buffer+3, "RESULT", 6)) {
|
||||
char *end_str;
|
||||
char *string = ps16dz_rx_buffer+10;
|
||||
|
@ -177,22 +174,19 @@ void PS16DZSerialInput(void)
|
|||
char* token3 = strtok_r(NULL, ":", &end_token);
|
||||
if(!strncmp(token2, "\"switch\"", 8)){
|
||||
bool ps16dz_power = !strncmp(token3, "\"on\"", 4)?true:false;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("PSZ: power received: %s"), token3);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: power received: %s"), token3);
|
||||
if((power || Settings.light_dimmer > 0) && (power !=ps16dz_power)) {
|
||||
ExecuteCommandPower(1, ps16dz_power, SRC_SWITCH); // send SRC_SWITCH? to use as flag to prevent loop from inbound states from faceplate interaction
|
||||
}
|
||||
}
|
||||
else if(!strncmp(token2, "\"bright\"", 8)){
|
||||
uint8_t ps16dz_bright = atoi(token3);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("PSZ: brightness received: %d"), ps16dz_bright);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: brightness received: %d"), ps16dz_bright);
|
||||
if(power && ps16dz_bright > 0 && ps16dz_bright != Settings.light_dimmer) {
|
||||
|
||||
snprintf_P(scmnd, sizeof(scmnd), PSTR(D_CMND_DIMMER " %d"), ps16dz_bright );
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("PSZ: Send CMND_DIMMER_STR=%s"), scmnd );
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: Send CMND_DIMMER_STR=%s"), scmnd );
|
||||
|
||||
ps16dz_ignore_dim = true;
|
||||
ExecuteCommand(scmnd, SRC_SWITCH);
|
||||
|
@ -200,15 +194,13 @@ void PS16DZSerialInput(void)
|
|||
}
|
||||
else if(!strncmp(token2, "\"sequence\"", 10)){
|
||||
//ps16dz_seq = strtoull(token3+1, NULL, 10);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("PSZ: sequence received: %s"), token3);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PSZ: sequence received: %s"), token3);
|
||||
}
|
||||
token = strtok_r(NULL, ",", &end_str);
|
||||
}
|
||||
}
|
||||
else if(!strncmp(ps16dz_rx_buffer+3, "SETTING", 7)) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("PSZ: Reset"));
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("PSZ: Reset"));
|
||||
PS16DZResetWifi();
|
||||
}
|
||||
memset(ps16dz_rx_buffer, 0, PS16DZ_BUFFER_SIZE);
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#endif // USE_DEBUG_DRIVER
|
||||
#endif // DEBUG_THEO
|
||||
|
||||
//#define USE_DEBUG_SETTING_NAMES
|
||||
|
||||
#ifdef USE_DEBUG_DRIVER
|
||||
/*********************************************************************************************\
|
||||
* Virtual debugging support - Part1
|
||||
|
@ -148,13 +150,12 @@ void CpuLoadLoop(void)
|
|||
#if defined(F_CPU) && (F_CPU == 160000000L)
|
||||
int CPU_load = 100 - ( (CPU_loops*(1 + 30*sleep)) / (CPU_load_check *800) );
|
||||
CPU_loops = CPU_loops / CPU_load_check;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(160MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(160MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops);
|
||||
#else
|
||||
int CPU_load = 100 - ( (CPU_loops*(1 + 30*sleep)) / (CPU_load_check *400) );
|
||||
CPU_loops = CPU_loops / CPU_load_check;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(80MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, CPU %d%%(80MHz), Loops/sec %d"), ESP.getFreeHeap(), CPU_load, CPU_loops);
|
||||
#endif
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
CPU_last_millis = CPU_last_loop_time;
|
||||
CPU_loops = 0;
|
||||
}
|
||||
|
@ -176,12 +177,8 @@ void DebugFreeMem(void)
|
|||
{
|
||||
register uint32_t *sp asm("a1");
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d, UnmodifiedStack %d (%s)"),
|
||||
// ESP.getFreeHeap(), 4 * (sp - g_cont.stack), cont_get_free_stack(&g_cont), XdrvMailbox.data);
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"),
|
||||
ESP.getFreeHeap(), 4 * (sp - g_cont.stack), XdrvMailbox.data);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d, UnmodifiedStack %d (%s)"), ESP.getFreeHeap(), 4 * (sp - g_cont.stack), cont_get_free_stack(&g_cont), XdrvMailbox.data);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), ESP.getFreeHeap(), 4 * (sp - g_cont.stack), XdrvMailbox.data);
|
||||
}
|
||||
|
||||
#else
|
||||
|
@ -198,9 +195,7 @@ void DebugFreeMem(void)
|
|||
{
|
||||
register uint32_t *sp asm("a1");
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"),
|
||||
ESP.getFreeHeap(), 4 * (sp - g_pcont->stack), XdrvMailbox.data);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "FreeRam %d, FreeStack %d (%s)"), ESP.getFreeHeap(), 4 * (sp - g_pcont->stack), XdrvMailbox.data);
|
||||
}
|
||||
|
||||
#endif // ARDUINO_ESP8266_RELEASE_2_x_x
|
||||
|
@ -233,8 +228,7 @@ void DebugRtcDump(char* parms)
|
|||
uint16_t srow = strtol(parms, &p, 16) / CFG_COLS;
|
||||
uint16_t mrow = strtol(p, &p, 10);
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow);
|
||||
|
||||
if (0 == mrow) { // Default only 8 lines
|
||||
mrow = 8;
|
||||
|
@ -285,8 +279,7 @@ void DebugCfgDump(char* parms)
|
|||
uint16_t srow = strtol(parms, &p, 16) / CFG_COLS;
|
||||
uint16_t mrow = strtol(p, &p, 10);
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("Cnfg: Parms %s, Start row %d, rows %d"), parms, srow, mrow);
|
||||
|
||||
if (0 == mrow) { // Default only 8 lines
|
||||
mrow = 8;
|
||||
|
@ -363,56 +356,38 @@ void DebugCfgPoke(char* parms)
|
|||
|
||||
uint32_t ndata32 = (buffer[address +3] << 24) + (buffer[address +2] << 16) + (buffer[address +1] << 8) + buffer[address];
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: 0x%0LX (%lu) poked to 0x%0LX (%lu)"), address, data32, data32, ndata32, ndata32);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: 0x%0LX (%lu) poked to 0x%0LX (%lu)"), address, data32, data32, ndata32, ndata32);
|
||||
}
|
||||
|
||||
#ifdef USE_DEBUG_SETTING_NAMES
|
||||
void DebugCfgShow(uint8_t more)
|
||||
{
|
||||
uint8_t *SetAddr;
|
||||
SetAddr = (uint8_t *)&Settings;
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: Hostname (%d) [%s]"), (uint8_t *)&Settings.hostname - SetAddr, sizeof(Settings.hostname)-1, Settings.hostname);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: SSids (%d) [%s], [%s]"), (uint8_t *)&Settings.sta_ssid - SetAddr, sizeof(Settings.sta_ssid[0])-1, Settings.sta_ssid[0], Settings.sta_ssid[1]);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: Friendlynames (%d) [%s], [%s], [%s], [%s]"), (uint8_t *)&Settings.friendlyname - SetAddr, sizeof(Settings.friendlyname[0])-1, Settings.friendlyname[0], Settings.friendlyname[1], Settings.friendlyname[2], Settings.friendlyname[3]);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: OTA Url (%d) [%s]"), (uint8_t *)&Settings.ota_url - SetAddr, sizeof(Settings.ota_url)-1, Settings.ota_url);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: StateText (%d) [%s], [%s], [%s], [%s]"), (uint8_t *)&Settings.state_text - SetAddr, sizeof(Settings.state_text[0])-1, Settings.state_text[0], Settings.state_text[1], Settings.state_text[2], Settings.state_text[3]);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: Syslog Host (%d) [%s]"), (uint8_t *)&Settings.syslog_host - SetAddr, sizeof(Settings.syslog_host)-1, Settings.syslog_host);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: NTP Servers (%d) [%s], [%s], [%s]"), (uint8_t *)&Settings.ntp_server - SetAddr, sizeof(Settings.ntp_server[0])-1, Settings.ntp_server[0], Settings.ntp_server[1], Settings.ntp_server[2]);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: MQTT Host (%d) [%s]"), (uint8_t *)&Settings.mqtt_host - SetAddr, sizeof(Settings.mqtt_host)-1, Settings.mqtt_host);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: MQTT Client (%d) [%s]"), (uint8_t *)&Settings.mqtt_client - SetAddr, sizeof(Settings.mqtt_client)-1, Settings.mqtt_client);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: MQTT User (%d) [%s]"), (uint8_t *)&Settings.mqtt_user - SetAddr, sizeof(Settings.mqtt_user)-1, Settings.mqtt_user);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: MQTT FullTopic (%d) [%s]"), (uint8_t *)&Settings.mqtt_fulltopic - SetAddr, sizeof(Settings.mqtt_fulltopic)-1, Settings.mqtt_fulltopic);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: MQTT Topic (%d) [%s]"), (uint8_t *)&Settings.mqtt_topic - SetAddr, sizeof(Settings.mqtt_topic)-1, Settings.mqtt_topic);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: MQTT GroupTopic (%d) [%s]"), (uint8_t *)&Settings.mqtt_grptopic - SetAddr, sizeof(Settings.mqtt_grptopic)-1, Settings.mqtt_grptopic);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: MQTT ButtonTopic (%d) [%s]"), (uint8_t *)&Settings.button_topic - SetAddr, sizeof(Settings.button_topic)-1, Settings.button_topic);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: MQTT SwitchTopic (%d) [%s]"), (uint8_t *)&Settings.switch_topic - SetAddr, sizeof(Settings.switch_topic)-1, Settings.switch_topic);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: MQTT Prefixes (%d) [%s], [%s], [%s]"), (uint8_t *)&Settings.mqtt_prefix - SetAddr, sizeof(Settings.mqtt_prefix[0])-1, Settings.mqtt_prefix[0], Settings.mqtt_prefix[1], Settings.mqtt_prefix[2]);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: Hostname (%d) [%s]"), (uint8_t *)&Settings.hostname - SetAddr, sizeof(Settings.hostname)-1, Settings.hostname);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: SSids (%d) [%s], [%s]"), (uint8_t *)&Settings.sta_ssid - SetAddr, sizeof(Settings.sta_ssid[0])-1, Settings.sta_ssid[0], Settings.sta_ssid[1]);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: Friendlynames (%d) [%s], [%s], [%s], [%s]"), (uint8_t *)&Settings.friendlyname - SetAddr, sizeof(Settings.friendlyname[0])-1, Settings.friendlyname[0], Settings.friendlyname[1], Settings.friendlyname[2], Settings.friendlyname[3]);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: OTA Url (%d) [%s]"), (uint8_t *)&Settings.ota_url - SetAddr, sizeof(Settings.ota_url)-1, Settings.ota_url);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: StateText (%d) [%s], [%s], [%s], [%s]"), (uint8_t *)&Settings.state_text - SetAddr, sizeof(Settings.state_text[0])-1, Settings.state_text[0], Settings.state_text[1], Settings.state_text[2], Settings.state_text[3]);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: Syslog Host (%d) [%s]"), (uint8_t *)&Settings.syslog_host - SetAddr, sizeof(Settings.syslog_host)-1, Settings.syslog_host);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: NTP Servers (%d) [%s], [%s], [%s]"), (uint8_t *)&Settings.ntp_server - SetAddr, sizeof(Settings.ntp_server[0])-1, Settings.ntp_server[0], Settings.ntp_server[1], Settings.ntp_server[2]);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: MQTT Host (%d) [%s]"), (uint8_t *)&Settings.mqtt_host - SetAddr, sizeof(Settings.mqtt_host)-1, Settings.mqtt_host);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: MQTT Client (%d) [%s]"), (uint8_t *)&Settings.mqtt_client - SetAddr, sizeof(Settings.mqtt_client)-1, Settings.mqtt_client);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: MQTT User (%d) [%s]"), (uint8_t *)&Settings.mqtt_user - SetAddr, sizeof(Settings.mqtt_user)-1, Settings.mqtt_user);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: MQTT FullTopic (%d) [%s]"), (uint8_t *)&Settings.mqtt_fulltopic - SetAddr, sizeof(Settings.mqtt_fulltopic)-1, Settings.mqtt_fulltopic);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: MQTT Topic (%d) [%s]"), (uint8_t *)&Settings.mqtt_topic - SetAddr, sizeof(Settings.mqtt_topic)-1, Settings.mqtt_topic);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: MQTT GroupTopic (%d) [%s]"), (uint8_t *)&Settings.mqtt_grptopic - SetAddr, sizeof(Settings.mqtt_grptopic)-1, Settings.mqtt_grptopic);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: MQTT ButtonTopic (%d) [%s]"), (uint8_t *)&Settings.button_topic - SetAddr, sizeof(Settings.button_topic)-1, Settings.button_topic);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: MQTT SwitchTopic (%d) [%s]"), (uint8_t *)&Settings.switch_topic - SetAddr, sizeof(Settings.switch_topic)-1, Settings.switch_topic);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: MQTT Prefixes (%d) [%s], [%s], [%s]"), (uint8_t *)&Settings.mqtt_prefix - SetAddr, sizeof(Settings.mqtt_prefix[0])-1, Settings.mqtt_prefix[0], Settings.mqtt_prefix[1], Settings.mqtt_prefix[2]);
|
||||
if (17 == more) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: AP Passwords (%d) [%s], [%s]"), (uint8_t *)&Settings.sta_pwd - SetAddr, sizeof(Settings.sta_pwd[0])-1, Settings.sta_pwd[0], Settings.sta_pwd[1]);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: MQTT Password (%d) [%s]"), (uint8_t *)&Settings.mqtt_pwd - SetAddr, sizeof(Settings.mqtt_pwd)-1, Settings.mqtt_pwd);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%03X: Web Password (%d) [%s]"), (uint8_t *)&Settings.web_password - SetAddr, sizeof(Settings.web_password)-1, Settings.web_password);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: AP Passwords (%d) [%s], [%s]"), (uint8_t *)&Settings.sta_pwd - SetAddr, sizeof(Settings.sta_pwd[0])-1, Settings.sta_pwd[0], Settings.sta_pwd[1]);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: MQTT Password (%d) [%s]"), (uint8_t *)&Settings.mqtt_pwd - SetAddr, sizeof(Settings.mqtt_pwd)-1, Settings.mqtt_pwd);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("%03X: Web Password (%d) [%s]"), (uint8_t *)&Settings.web_password - SetAddr, sizeof(Settings.web_password)-1, Settings.web_password);
|
||||
}
|
||||
}
|
||||
#endif // USE_DEBUG_SETTING_NAMES
|
||||
|
||||
void SetFlashMode(uint8_t mode)
|
||||
{
|
||||
|
@ -443,8 +418,7 @@ bool DebugCommand(void)
|
|||
serviced = false; // Unknown command
|
||||
}
|
||||
else if (CMND_HELP == command_code) {
|
||||
snprintf_P(log_data, sizeof(log_data), kDebugCommands);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P(LOG_LEVEL_INFO, kDebugCommands);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_DONE);
|
||||
}
|
||||
else if (CMND_RTCDUMP == command_code) {
|
||||
|
@ -463,10 +437,12 @@ bool DebugCommand(void)
|
|||
DebugCfgPoke(XdrvMailbox.data);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_DONE);
|
||||
}
|
||||
#ifdef USE_DEBUG_SETTING_NAMES
|
||||
else if (CMND_CFGSHOW == command_code) {
|
||||
DebugCfgShow(XdrvMailbox.payload);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), S_JSON_COMMAND_SVALUE, command, D_JSON_DONE);
|
||||
}
|
||||
#endif // USE_DEBUG_SETTING_NAMES
|
||||
#ifdef USE_WEBSERVER
|
||||
else if (CMND_CFGXOR == command_code) {
|
||||
if (XdrvMailbox.data_len > 0) {
|
||||
|
|
|
@ -138,8 +138,7 @@ bool LcdPrintLog(void)
|
|||
strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols);
|
||||
DisplayFillScreen(last_row);
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
|
||||
|
||||
lcd->setCursor(0, last_row);
|
||||
lcd->print(disp_screen_buffer[last_row]);
|
||||
|
|
|
@ -154,8 +154,7 @@ void Ssd1306PrintLog(void)
|
|||
strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols);
|
||||
DisplayFillScreen(last_row);
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]);
|
||||
|
||||
oled->println(disp_screen_buffer[last_row]);
|
||||
oled->display();
|
||||
|
|
|
@ -94,8 +94,7 @@ void MatrixScrollLeft(char* txt, int loop)
|
|||
// Horiz. position of text -- starts off right edge
|
||||
mtx_x = 8 * mtx_matrices;
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "[%s]"), txt);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), txt);
|
||||
|
||||
disp_refresh = Settings.display_refresh;
|
||||
case 2:
|
||||
|
@ -227,7 +226,7 @@ void MatrixOnOff(void)
|
|||
|
||||
void MatrixDrawStringAt(uint16_t x, uint16_t y, char *str, uint16_t color, uint8_t flag)
|
||||
{
|
||||
snprintf(mtx_buffer, MTX_MAX_SCREEN_BUFFER, str);
|
||||
strlcpy(mtx_buffer, str, MTX_MAX_SCREEN_BUFFER);
|
||||
mtx_mode = x &1; // Use x for selecting scroll up (0) or scroll left (1)
|
||||
mtx_loop = y &1; // Use y for selecting no loop (0) or loop (1)
|
||||
if (!mtx_state) { mtx_state = 1; }
|
||||
|
@ -261,8 +260,7 @@ void MatrixPrintLog(uint8_t direction)
|
|||
i++;
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "[%s]"), mtx_buffer);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), mtx_buffer);
|
||||
|
||||
mtx_done = 1;
|
||||
}
|
||||
|
|
|
@ -178,8 +178,7 @@ void Ili9341PrintLog(void)
|
|||
DisplayFillScreen(last_row);
|
||||
tft->print(disp_screen_buffer[last_row]);
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "[%s]"), txt);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), txt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,16 +123,14 @@ void EpdInitDriver(void)
|
|||
epd.sclk_pin = pin[GPIO_SPI_CLK]; // 14
|
||||
epd.mosi_pin = pin[GPIO_SPI_MOSI]; // 13
|
||||
EpdInitMode();
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("EPD: HardSPI CS %d, CLK %d, MOSI %d"), epd.cs_pin, epd.sclk_pin, epd.mosi_pin);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("EPD: HardSPI CS %d, CLK %d, MOSI %d"), epd.cs_pin, epd.sclk_pin, epd.mosi_pin);
|
||||
}
|
||||
else if ((pin[GPIO_SSPI_CS] < 99) && (pin[GPIO_SSPI_SCLK] < 99) && (pin[GPIO_SSPI_MOSI] < 99)) {
|
||||
epd.cs_pin = pin[GPIO_SSPI_CS];
|
||||
epd.sclk_pin = pin[GPIO_SSPI_SCLK];
|
||||
epd.mosi_pin = pin[GPIO_SSPI_MOSI];
|
||||
EpdInitMode();
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("EPD: SoftSPI CS %d, CLK %d, MOSI %d"), epd.cs_pin, epd.sclk_pin, epd.mosi_pin);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("EPD: SoftSPI CS %d, CLK %d, MOSI %d"), epd.cs_pin, epd.sclk_pin, epd.mosi_pin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -221,8 +219,7 @@ void EpdPrintLog(void)
|
|||
EpdDrawStringAt(0, epd_scroll, disp_screen_buffer[last_row], COLORED, 0);
|
||||
// EpdDisplayFrame();
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_APPLICATION "[%s]"), txt);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_APPLICATION "[%s]"), txt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,9 +152,8 @@ void HlwEvery200ms(void)
|
|||
}
|
||||
}
|
||||
unsigned long median = hlw_debug[(hlw_cf1_pulse_counter +1) / 2];
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("NRG: power %d, ui %d, cnt %d, smpl%s, sum %d, mean %d, median %d"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("NRG: power %d, ui %d, cnt %d, smpl%s, sum %d, mean %d, median %d"),
|
||||
hlw_cf_power_pulse_length, hlw_select_ui_flag, hlw_cf1_pulse_counter, stemp, hlw_cf1_summed_pulse_length, cf1_pulse_length, median);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
#endif
|
||||
|
||||
if (hlw_select_ui_flag == hlw_ui_flag) {
|
||||
|
|
|
@ -49,8 +49,7 @@ void PzemAcEverySecond(void)
|
|||
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, (buffer[2]) ? buffer[2] +5 : sizeof(buffer));
|
||||
|
||||
if (error) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "PzemAc response error %d"), error);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "PzemAc response error %d"), error);
|
||||
} else {
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
||||
// 01 04 14 08 D1 00 6C 00 00 00 F4 00 00 00 26 00 00 01 F4 00 64 00 00 51 34
|
||||
|
|
|
@ -49,8 +49,7 @@ void PzemDcEverySecond(void)
|
|||
AddLogBuffer(LOG_LEVEL_DEBUG_MORE, buffer, (buffer[2]) ? buffer[2] +5 : sizeof(buffer));
|
||||
|
||||
if (error) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "PzemDc response error %d"), error);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "PzemDc response error %d"), error);
|
||||
} else {
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
||||
// 01 04 10 05 40 00 0A 00 0D 00 00 00 02 00 00 00 00 00 00 D6 29
|
||||
|
|
|
@ -95,9 +95,8 @@ void WemoRespondToMSearch(int echo_type)
|
|||
} else {
|
||||
snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE));
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPNP D_WEMO " " D_JSON_TYPE " %d, %s " D_TO " %s:%d"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_WEMO " " D_JSON_TYPE " %d, %s " D_TO " %s:%d"),
|
||||
echo_type, message, udp_remote_ip.toString().c_str(), udp_remote_port);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
|
||||
udp_response_mutex = false;
|
||||
}
|
||||
|
@ -186,9 +185,8 @@ void HueRespondToMSearch(void)
|
|||
} else {
|
||||
snprintf_P(message, sizeof(message), PSTR(D_FAILED_TO_SEND_RESPONSE));
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_UPNP D_HUE " %s " D_TO " %s:%d"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPNP D_HUE " %s " D_TO " %s:%d"),
|
||||
message, udp_remote_ip.toString().c_str(), udp_remote_port);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
|
||||
udp_response_mutex = false;
|
||||
}
|
||||
|
@ -537,8 +535,7 @@ void HandleUpnpSetupHue(void)
|
|||
|
||||
void HueNotImplemented(String *path)
|
||||
{
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP D_HUE_API_NOT_IMPLEMENTED " (%s)"), path->c_str());
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_API_NOT_IMPLEMENTED " (%s)"), path->c_str());
|
||||
|
||||
WSSend(200, CT_JSON, "{}");
|
||||
}
|
||||
|
@ -819,12 +816,10 @@ void HandleHueApi(String *path)
|
|||
|
||||
path->remove(0, 4); // remove /api
|
||||
uint16_t apilen = path->length();
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP D_HUE_API " (%s)"), path->c_str());
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE); // HTP: Hue API (//lights/1/state)
|
||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_API " (%s)"), path->c_str()); // HTP: Hue API (//lights/1/state
|
||||
for (args = 0; args < WebServer->args(); args++) {
|
||||
String json = WebServer->arg(args);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_HTTP D_HUE_POST_ARGS " (%s)"), json.c_str());
|
||||
AddLog(LOG_LEVEL_DEBUG_MORE); // HTP: Hue POST args ({"on":false})
|
||||
AddLog_P2(LOG_LEVEL_DEBUG_MORE, PSTR(D_LOG_HTTP D_HUE_POST_ARGS " (%s)"), json.c_str()); // HTP: Hue POST args ({"on":false})
|
||||
}
|
||||
|
||||
if (path->endsWith("/invalid/")) {} // Just ignore
|
||||
|
|
|
@ -36,8 +36,7 @@ void CounterUpdate(uint8_t index)
|
|||
RtcSettings.pulse_counter[index -1]++;
|
||||
}
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("CNTR: Interrupt %d"), index);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("CNTR: Interrupt %d"), index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,8 +61,7 @@ void SonoffScSend(const char *data)
|
|||
{
|
||||
Serial.write(data);
|
||||
Serial.write('\x1B');
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_SERIAL D_TRANSMIT " %s"), data);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_SERIAL D_TRANSMIT " %s"), data);
|
||||
}
|
||||
|
||||
void SonoffScInit(void)
|
||||
|
@ -78,8 +77,7 @@ void SonoffScSerialInput(char *rcvstat)
|
|||
char *str;
|
||||
uint16_t value[5] = { 0 };
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_SERIAL D_RECEIVED " %s"), rcvstat);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_SERIAL D_RECEIVED " %s"), rcvstat);
|
||||
|
||||
if (!strncasecmp_P(rcvstat, PSTR("AT+UPDATE="), 10)) {
|
||||
int8_t i = -1;
|
||||
|
|
|
@ -287,8 +287,7 @@ void Ds18x20Init(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DSB D_SENSORS_FOUND " %d"), ds18x20_sensors);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DSB D_SENSORS_FOUND " %d"), ds18x20_sensors);
|
||||
}
|
||||
|
||||
void Ds18x20Convert(void)
|
||||
|
|
|
@ -125,9 +125,8 @@ bool DhtRead(uint8_t sensor)
|
|||
|
||||
uint8_t checksum = (dht_data[0] + dht_data[1] + dht_data[2] + dht_data[3]) & 0xFF;
|
||||
if (dht_data[4] != checksum) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DHT D_CHECKSUM_FAILURE " %02X, %02X, %02X, %02X, %02X =? %02X"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DHT D_CHECKSUM_FAILURE " %02X, %02X, %02X, %02X, %02X =? %02X"),
|
||||
dht_data[0], dht_data[1], dht_data[2], dht_data[3], dht_data[4], checksum);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -224,8 +224,7 @@ void HtuDetect(void)
|
|||
htu_delay_humidity = 23;
|
||||
}
|
||||
GetTextIndexed(htu_types, sizeof(htu_types), index, kHtuTypes);
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, htu_types, htu_address);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, htu_types, htu_address);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -482,8 +482,7 @@ void BmpDetect(void)
|
|||
}
|
||||
if (success) {
|
||||
GetTextIndexed(bmp_sensors[bmp_count].bmp_name, sizeof(bmp_sensors[bmp_count].bmp_name), bmp_sensors[bmp_count].bmp_model, kBmpTypes);
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, bmp_sensors[bmp_count].bmp_name, bmp_sensors[bmp_count].bmp_address);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, bmp_sensors[bmp_count].bmp_name, bmp_sensors[bmp_count].bmp_address);
|
||||
bmp_count++;
|
||||
}
|
||||
}
|
||||
|
@ -540,7 +539,7 @@ void BmpShow(bool json)
|
|||
float bmp_pressure = ConvertPressure(bmp_sensors[bmp_idx].bmp_pressure);
|
||||
|
||||
char name[10];
|
||||
snprintf(name, sizeof(name), bmp_sensors[bmp_idx].bmp_name);
|
||||
strlcpy(name, bmp_sensors[bmp_idx].bmp_name, sizeof(name));
|
||||
if (bmp_count > 1) {
|
||||
snprintf_P(name, sizeof(name), PSTR("%s-%02X"), name, bmp_sensors[bmp_idx].bmp_address); // BMXXXX-XX
|
||||
}
|
||||
|
|
|
@ -65,8 +65,7 @@ void Bh1750Detect(void)
|
|||
Wire.write(BH1750_CONTINUOUS_HIGH_RES_MODE);
|
||||
if (!Wire.endTransmission()) {
|
||||
bh1750_type = 1;
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, bh1750_types, bh1750_address);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, bh1750_types, bh1750_address);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
Version Date Action Description
|
||||
--------------------------------------------------------------------------------------------
|
||||
|
||||
1.0.0.3 20181006 fixed - missing "" around the UV Index text
|
||||
1.0.0.3 20181006 fixed - missing "" around the UV Index text
|
||||
- thanks to Lisa she had tested it on here mqtt system.
|
||||
--
|
||||
1.0.0.2 20180928 tests - same as in version 1.0.0.1
|
||||
|
@ -140,8 +140,7 @@ void Veml6070Detect(void)
|
|||
veml6070_type = 1;
|
||||
uint8_t veml_model = 0;
|
||||
GetTextIndexed(veml6070_name, sizeof(veml6070_name), veml_model, kVemlTypes);
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "VEML6070", VEML6070_ADDR_L);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "VEML6070", VEML6070_ADDR_L);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,13 +155,11 @@ void Veml6070UvTableInit(void)
|
|||
uv_risk_map[i] = ( (USE_VEML6070_RSET / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1);
|
||||
} else {
|
||||
uv_risk_map[i] = ( (VEML6070_RSET_DEFAULT / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "VEML6070 resistor error %d"), USE_VEML6070_RSET);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 resistor error %d"), USE_VEML6070_RSET);
|
||||
}
|
||||
#else
|
||||
uv_risk_map[i] = ( (VEML6070_RSET_DEFAULT / VEML6070_TABLE_COEFFCIENT) / VEML6070_UV_MAX_DEFAULT ) * (i+1);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "VEML6070 resistor default used %d"), VEML6070_RSET_DEFAULT);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 resistor default used %d"), VEML6070_RSET_DEFAULT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -196,8 +193,7 @@ void Veml6070ModeCmd(bool mode_cmd)
|
|||
uint8_t status = Wire.endTransmission();
|
||||
// action on status
|
||||
if (!status) {
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "VEML6070 mode_cmd", VEML6070_ADDR_L);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "VEML6070 mode_cmd", VEML6070_ADDR_L);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -241,8 +237,7 @@ double Veml6070UvRiskLevel(uint16_t uv_level)
|
|||
// out of range and much to high - it must be outerspace or sensor damaged
|
||||
snprintf_P(str_uvrisk_text, sizeof(str_uvrisk_text), D_UV_INDEX_7);
|
||||
return ( risk = 99 );
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "VEML6070 out of range %d"), risk);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "VEML6070 out of range %d"), risk);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -164,13 +164,12 @@ void Ads1115Detect(void)
|
|||
for (uint8_t i = 0; i < sizeof(ads1115_addresses); i++) {
|
||||
if (!ads1115_found[i]) {
|
||||
ads1115_address = ads1115_addresses[i];
|
||||
if (I2cValidRead16(&buffer, ads1115_address, ADS1115_REG_POINTER_CONVERT) &&
|
||||
if (I2cValidRead16(&buffer, ads1115_address, ADS1115_REG_POINTER_CONVERT) &&
|
||||
I2cValidRead16(&buffer, ads1115_address, ADS1115_REG_POINTER_CONFIG)) {
|
||||
Ads1115StartComparator(i, ADS1115_REG_CONFIG_MODE_CONTIN);
|
||||
ads1115_type = 1;
|
||||
ads1115_found[i] = 1;
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "ADS1115", ads1115_address);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "ADS1115", ads1115_address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -182,8 +181,7 @@ void Ads1115GetValues(uint8_t address)
|
|||
ads1115_address = address;
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
ads1115_values[i] = Ads1115GetConversion(i);
|
||||
//snprintf_P(log_data, sizeof(log_data), "Logging ADS1115 %02x (%i) = %i", address, i, ads1115_values[i] );
|
||||
//AddLog(LOG_LEVEL_INFO);
|
||||
//AddLog_P2(LOG_LEVEL_INFO, "Logging ADS1115 %02x (%i) = %i", address, i, ads1115_values[i] );
|
||||
}
|
||||
ads1115_address = old_address;
|
||||
}
|
||||
|
@ -220,8 +218,7 @@ void Ads1115Show(bool json)
|
|||
char *comma = (char*)"";
|
||||
|
||||
for (uint8_t t = 0; t < sizeof(ads1115_addresses); t++) {
|
||||
//snprintf_P(log_data, sizeof(log_data), "Logging ADS1115 %02x", ads1115_addresses[t]);
|
||||
//AddLog(LOG_LEVEL_INFO);
|
||||
//AddLog_P2(LOG_LEVEL_INFO, "Logging ADS1115 %02x", ads1115_addresses[t]);
|
||||
if (ads1115_found[t]) {
|
||||
Ads1115GetValues(ads1115_addresses[t]);
|
||||
if (json) {
|
||||
|
|
|
@ -90,8 +90,7 @@ void Ads1115Detect(void)
|
|||
adc0.setRate(ADS1115_RATE_860);
|
||||
adc0.setMode(ADS1115_MODE_CONTINUOUS);
|
||||
ads1115_type = 1;
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "ADS1115", ads1115_address);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "ADS1115", ads1115_address);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -198,8 +198,7 @@ void Ina219Detect(void)
|
|||
ina219_address = ina219_addresses[i];
|
||||
if (Ina219SetCalibration(Settings.ina219_mode)) {
|
||||
ina219_type = 1;
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, ina219_types, ina219_address);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, ina219_types, ina219_address);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,8 +86,7 @@ void Sht3xDetect(void)
|
|||
if (Sht3xRead(t, h, sht3x_addresses[i])) {
|
||||
sht3x_sensors[sht3x_count].address = sht3x_addresses[i];
|
||||
GetTextIndexed(sht3x_sensors[sht3x_count].types, sizeof(sht3x_sensors[sht3x_count].types), i, kShtTypes);
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, sht3x_sensors[sht3x_count].types, sht3x_sensors[sht3x_count].address);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, sht3x_sensors[sht3x_count].types, sht3x_sensors[sht3x_count].address);
|
||||
sht3x_count++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,8 +123,7 @@ size_t MhzSendCmd(uint8_t command_id)
|
|||
memcpy_P(&mhz_send[6], kMhzCommands[command_id] + sizeof(uint16_t), sizeof(uint16_t));
|
||||
mhz_send[8] = MhzCalculateChecksum(mhz_send);
|
||||
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("Final MhzCommand: %x %x %x %x %x %x %x %x %x"),mhz_send[0],mhz_send[1],mhz_send[2],mhz_send[3],mhz_send[4],mhz_send[5],mhz_send[6],mhz_send[7],mhz_send[8]);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("Final MhzCommand: %x %x %x %x %x %x %x %x %x"),mhz_send[0],mhz_send[1],mhz_send[2],mhz_send[3],mhz_send[4],mhz_send[5],mhz_send[6],mhz_send[7],mhz_send[8]);
|
||||
|
||||
return MhzSerial->write(mhz_send, sizeof(mhz_send));
|
||||
}
|
||||
|
|
|
@ -71,8 +71,7 @@ void Tsl2561Detect(void)
|
|||
if (!Tsl.id(id)) return;
|
||||
if (Tsl.on()) {
|
||||
tsl2561_type = 1;
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, tsl2561_types, Tsl.address(), id);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, tsl2561_types, Tsl.address(), id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,19 +70,16 @@ void Senseair250ms(void) // Every 250 mSec
|
|||
if (data_ready) {
|
||||
uint8_t error = SenseairModbus->Receive16BitRegister(&value);
|
||||
if (error) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "SenseAir response error %d"), error);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir response error %d"), error);
|
||||
} else {
|
||||
switch(senseair_read_state) {
|
||||
case 0: // 0x1A (26) READ_TYPE_LOW - S8: fe 04 02 01 77 ec 92
|
||||
senseair_type = 2;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "SenseAir type id low %04X"), value);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir type id low %04X"), value);
|
||||
break;
|
||||
case 1: // 0x00 (0) READ_ERRORLOG - fe 04 02 00 00 ad 24
|
||||
if (value) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "SenseAir error %04X"), value);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir error %04X"), value);
|
||||
}
|
||||
break;
|
||||
case 2: // 0x03 (3) READ_CO2 - fe 04 02 06 2c af 59
|
||||
|
@ -98,13 +95,11 @@ void Senseair250ms(void) // Every 250 mSec
|
|||
case 5: // 0x1C (28) READ_RELAY_STATE - S8: fe 04 02 01 54 ad 4b - firmware version
|
||||
{
|
||||
bool relay_state = value >> 8 & 1;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "SenseAir relay state %d"), relay_state);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir relay state %d"), relay_state);
|
||||
break;
|
||||
}
|
||||
case 6: // 0x0A (10) READ_TEMP_ADJUSTMENT - S8: fe 84 02 f2 f1 - Illegal Data Address
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "SenseAir temp adjustment %d"), value);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SenseAir temp adjustment %d"), value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,8 +42,7 @@ bool MGSPrepare(void)
|
|||
{
|
||||
gas.begin(MGS_SENSOR_ADDR);
|
||||
if (!gas.isError()) {
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "MultiGasSensor", MGS_SENSOR_ADDR);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "MultiGasSensor", MGS_SENSOR_ADDR);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -82,10 +82,9 @@ bool NovaSdsCommand(uint8_t byte1, uint8_t byte2, uint8_t byte3, uint16_t sensor
|
|||
for (uint8_t i = 2; i < 17; i++) {
|
||||
novasds_cmnd[17] += novasds_cmnd[i];
|
||||
}
|
||||
//~ snprintf_P(log_data, sizeof(log_data), PSTR("SDS: Send %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X"),
|
||||
//~ AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SDS: Send %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X"),
|
||||
//~ novasds_cmnd[0],novasds_cmnd[1],novasds_cmnd[2],novasds_cmnd[3],novasds_cmnd[4],novasds_cmnd[5],novasds_cmnd[6],novasds_cmnd[7],novasds_cmnd[8],novasds_cmnd[9],
|
||||
//~ novasds_cmnd[10],novasds_cmnd[11],novasds_cmnd[12],novasds_cmnd[13],novasds_cmnd[14],novasds_cmnd[15],novasds_cmnd[16],novasds_cmnd[17],novasds_cmnd[18]);
|
||||
//~ AddLog(LOG_LEVEL_DEBUG);
|
||||
// send cmnd
|
||||
NovaSdsSerial->write(novasds_cmnd, sizeof(novasds_cmnd));
|
||||
NovaSdsSerial->flush();
|
||||
|
|
|
@ -44,10 +44,8 @@ void Sgp30Update(void) // Perform every second to ensure proper operation of th
|
|||
if (!sgp30_type) {
|
||||
if (sgp.begin()) {
|
||||
sgp30_type = 1;
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("SGP: Serialnumber 0x%04X-0x%04X-0x%04X"), sgp.serialnumber[0], sgp.serialnumber[1], sgp.serialnumber[2]);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "SGP30", 0x58);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SGP: Serialnumber 0x%04X-0x%04X-0x%04X"), sgp.serialnumber[0], sgp.serialnumber[1], sgp.serialnumber[2]);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "SGP30", 0x58);
|
||||
}
|
||||
} else {
|
||||
if (!sgp.IAQmeasure()) return; // Measurement failed
|
||||
|
@ -59,8 +57,7 @@ void Sgp30Update(void) // Perform every second to ensure proper operation of th
|
|||
uint16_t eCO2_base;
|
||||
|
||||
if (!sgp.getIAQBaseline(&eCO2_base, &TVOC_base)) return; // Failed to get baseline readings
|
||||
// snprintf_P(log_data, sizeof(log_data), PSTR("SGP: Baseline values eCO2 0x%04X, TVOC 0x%04X"), eCO2_base, TVOC_base);
|
||||
// AddLog(LOG_LEVEL_DEBUG);
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SGP: Baseline values eCO2 0x%04X, TVOC 0x%04X"), eCO2_base, TVOC_base);
|
||||
}
|
||||
sgp30_ready = 1;
|
||||
}
|
||||
|
|
|
@ -165,8 +165,7 @@ void SDM120250ms(void) // Every 250 mSec
|
|||
if (data_ready) {
|
||||
uint8_t error = SDM120_ModbusReceive(&value);
|
||||
if (error) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "SDM120 response error %d"), error);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SDM120 response error %d"), error);
|
||||
} else {
|
||||
switch(sdm120_read_state) {
|
||||
case 0:
|
||||
|
|
|
@ -310,8 +310,7 @@ void Si1145Update(void)
|
|||
if (!si1145_type) {
|
||||
if (Si1145Begin()) {
|
||||
si1145_type = 1;
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "SI1145", SI114X_ADDR);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "SI1145", SI114X_ADDR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,8 +155,7 @@ void SDM630250ms(void) // Every 250 mSec
|
|||
if (data_ready) {
|
||||
uint8_t error = SDM630_ModbusReceive(&value);
|
||||
if (error) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_DEBUG "SDM630 response error %d"), error);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "SDM630 response error %d"), error);
|
||||
} else {
|
||||
switch(sdm630_read_state) {
|
||||
case 0:
|
||||
|
|
|
@ -58,8 +58,7 @@ void LM75ADDetect(void)
|
|||
if (I2cValidRead16(&buffer, lm75ad_address, LM75_THYST_REGISTER)) {
|
||||
if (buffer == 0x4B00) {
|
||||
lm75ad_type = 1;
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "LM75AD", lm75ad_address);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "LM75AD", lm75ad_address);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1518,8 +1518,7 @@ int16_t readGesture(void)
|
|||
if (gesture_loop_counter == APDS9960_MAX_GESTURE_CYCLES){ // We will escape after a few loops
|
||||
disableGestureSensor(); // stop the sensor to prevent problems with power consumption/blocking and return to the main loop
|
||||
APDS9960_overload = true; // we report this as "long"-gesture
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("Sensor overload"));
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("Sensor overload"));
|
||||
}
|
||||
gesture_loop_counter += 1;
|
||||
/* Wait some time to collect next batch of FIFO data */
|
||||
|
@ -1794,33 +1793,32 @@ void handleGesture(void) {
|
|||
if (isGestureAvailable() ) {
|
||||
switch (readGesture()) {
|
||||
case DIR_UP:
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("UP"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("UP"));
|
||||
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Up"));
|
||||
break;
|
||||
case DIR_DOWN:
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("DOWN"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("DOWN"));
|
||||
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Down"));
|
||||
break;
|
||||
case DIR_LEFT:
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("LEFT"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("LEFT"));
|
||||
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Left"));
|
||||
break;
|
||||
case DIR_RIGHT:
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("RIGHT"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("RIGHT"));
|
||||
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Right"));
|
||||
break;
|
||||
default:
|
||||
if(APDS9960_overload)
|
||||
{
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("LONG"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("LONG"));
|
||||
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("Long"));
|
||||
}
|
||||
else{
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("NONE"));
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR("NONE"));
|
||||
snprintf_P(currentGesture, sizeof(currentGesture), PSTR("None"));
|
||||
}
|
||||
}
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
|
||||
mqtt_data[0] = '\0';
|
||||
if (MqttShowSensor()) {
|
||||
|
@ -1908,8 +1906,7 @@ bool APDS9960_detect(void)
|
|||
|
||||
if (APDS9960type == APDS9960_CHIPID_1 || APDS9960type == APDS9960_CHIPID_2) {
|
||||
strcpy_P(APDS9960stype, PSTR("APDS9960"));
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, APDS9960stype, APDS9960_I2C_ADDR);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, APDS9960stype, APDS9960_I2C_ADDR);
|
||||
if (APDS9960_init()) {
|
||||
success = true;
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "APDS9960 initialized"));
|
||||
|
@ -1919,12 +1916,10 @@ bool APDS9960_detect(void)
|
|||
}
|
||||
else {
|
||||
if (APDS9960type == APDS9930_CHIPID_1 || APDS9960type == APDS9930_CHIPID_2) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("APDS9930 found at address 0x%x, unsupported chip"), APDS9960_I2C_ADDR);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("APDS9930 found at address 0x%x, unsupported chip"), APDS9960_I2C_ADDR);
|
||||
}
|
||||
else{
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("APDS9960 not found at address 0x%x"), APDS9960_I2C_ADDR);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("APDS9960 not found at address 0x%x"), APDS9960_I2C_ADDR);
|
||||
}
|
||||
}
|
||||
currentGesture[0] = '\0';
|
||||
|
|
|
@ -81,7 +81,7 @@ void MCP230xx_CheckForIntCounter(void) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MCP230xx_CheckForIntRetainer(void) {
|
||||
uint8_t en = 0;
|
||||
for (uint8_t ca=0;ca<16;ca++) {
|
||||
|
@ -210,15 +210,13 @@ void MCP230xx_Detect(void)
|
|||
if (I2cValidRead8(&buffer, USE_MCP230xx_ADDR, MCP230xx_IOCON)) {
|
||||
if (0x00 == buffer) {
|
||||
mcp230xx_type = 1; // We have a MCP23008
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "MCP23008", USE_MCP230xx_ADDR);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "MCP23008", USE_MCP230xx_ADDR);
|
||||
mcp230xx_pincount = 8;
|
||||
MCP230xx_ApplySettings();
|
||||
} else {
|
||||
if (0x80 == buffer) {
|
||||
mcp230xx_type = 2; // We have a MCP23017
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "MCP23017", USE_MCP230xx_ADDR);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "MCP23017", USE_MCP230xx_ADDR);
|
||||
mcp230xx_pincount = 16;
|
||||
// Reset bank mode to 0
|
||||
I2cWrite8(USE_MCP230xx_ADDR, MCP230xx_IOCON, 0x00);
|
||||
|
@ -498,8 +496,7 @@ bool MCP230xx_Command(void) {
|
|||
if (Settings.mcp230xx_config[pin].int_count_en) {
|
||||
Settings.mcp230xx_config[pin].int_count_en=0;
|
||||
MCP230xx_CheckForIntCounter();
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("*** WARNING *** - Disabled INTCNT for pin D%i"),pin);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled INTCNT for pin D%i"),pin);
|
||||
}
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), MCP230XX_INTCFG_RESPONSE,"DEF",pin,Settings.mcp230xx_config[pin].int_report_defer); // "{\"MCP230xx_INT%s\":{\"D_%i\":%i}}";
|
||||
return serviced;
|
||||
|
@ -537,17 +534,14 @@ bool MCP230xx_Command(void) {
|
|||
Settings.mcp230xx_config[pin].int_count_en=intcnt;
|
||||
if (Settings.mcp230xx_config[pin].int_report_defer) {
|
||||
Settings.mcp230xx_config[pin].int_report_defer=0;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("*** WARNING *** - Disabled INTDEF for pin D%i"),pin);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled INTDEF for pin D%i"),pin);
|
||||
}
|
||||
if (Settings.mcp230xx_config[pin].int_report_mode < 3) {
|
||||
Settings.mcp230xx_config[pin].int_report_mode=3;
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("*** WARNING *** - Disabled immediate interrupt/telemetry reporting for pin D%i"),pin);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("*** WARNING *** - Disabled immediate interrupt/telemetry reporting for pin D%i"),pin);
|
||||
}
|
||||
if ((Settings.mcp230xx_config[pin].int_count_en) && (!Settings.mcp230xx_int_timer)) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("*** WARNING *** - INTCNT enabled for pin D%i but global INTTIMER is disabled!"),pin);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("*** WARNING *** - INTCNT enabled for pin D%i but global INTTIMER is disabled!"),pin);
|
||||
}
|
||||
MCP230xx_CheckForIntCounter(); // update register on whether or not we should be counting interrupts
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), MCP230XX_INTCFG_RESPONSE,"CNT",pin,Settings.mcp230xx_config[pin].int_count_en); // "{\"MCP230xx_INT%s\":{\"D_%i\":%i}}";
|
||||
|
@ -605,7 +599,7 @@ bool MCP230xx_Command(void) {
|
|||
}
|
||||
|
||||
uint8_t pin = atoi(subStr(sub_string, XdrvMailbox.data, ",", 1));
|
||||
|
||||
|
||||
if (pin < mcp230xx_pincount) {
|
||||
if (0 == pin) {
|
||||
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1), "0")) validpin=true;
|
||||
|
@ -767,7 +761,7 @@ void MCP230xx_Interrupt_Retain_Report(void) {
|
|||
uint16_t retainresult = 0;
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_TIME "\":\"%s\",\"MCP_INTRETAIN\": {"), GetDateAndTime(DT_LOCAL).c_str());
|
||||
for (uint8_t pinx = 0;pinx < mcp230xx_pincount;pinx++) {
|
||||
if (Settings.mcp230xx_config[pinx].int_retain_flag) {
|
||||
if (Settings.mcp230xx_config[pinx].int_retain_flag) {
|
||||
snprintf_P(mqtt_data,sizeof(mqtt_data), PSTR("%s\"D%i\":%i,"),mqtt_data,pinx,mcp230xx_int_retainer[pinx]);
|
||||
retainresult |= (((mcp230xx_int_retainer[pinx])&1) << pinx);
|
||||
mcp230xx_int_retainer[pinx]=0;
|
||||
|
|
|
@ -220,8 +220,7 @@ void Mpr121Init(struct mpr121 *pS)
|
|||
if (pS->connected[i]) {
|
||||
|
||||
// Log sensor found
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_I2C "MPR121(%c) " D_FOUND_AT " 0x%X"), pS->id[i], pS->i2c_addr[i]);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_I2C "MPR121(%c) " D_FOUND_AT " 0x%X"), pS->id[i], pS->i2c_addr[i]);
|
||||
|
||||
// Set thresholds for registers 0x41 - 0x5A (ExTTH and ExRTH)
|
||||
for (uint8_t j = 0; j < 13; j++) {
|
||||
|
@ -283,12 +282,9 @@ void Mpr121Init(struct mpr121 *pS)
|
|||
|
||||
// Check if sensor is running
|
||||
pS->running[i] = (0x00 != I2cRead8(pS->i2c_addr[i], MPR121_ECR_REG));
|
||||
if (pS->running[i]) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_I2C "MPR121%c: Running"), pS->id[i]);
|
||||
} else {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_I2C "MPR121%c: NOT Running"), pS->id[i]);
|
||||
}
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_I2C "MPR121%c: %sRunning"), pS->id[i], (pS->running[i]) ? "" : "NOT");
|
||||
|
||||
} else {
|
||||
|
||||
// Make sure running is false
|
||||
|
@ -299,8 +295,7 @@ void Mpr121Init(struct mpr121 *pS)
|
|||
// Display no sensor found message
|
||||
if (!(pS->connected[0] || pS->connected[1] || pS->connected[2]
|
||||
|| pS->connected[3])) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_I2C "MPR121: No sensors found"));
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P(LOG_LEVEL_DEBUG, PSTR(D_LOG_I2C "MPR121: No sensors found"));
|
||||
}
|
||||
} // void Mpr121Init(struct mpr121 *s)
|
||||
|
||||
|
@ -329,8 +324,7 @@ void Mpr121Show(struct mpr121 *pS, uint8_t function)
|
|||
|
||||
// Read data
|
||||
if (!I2cValidRead16LE(&pS->current[i], pS->i2c_addr[i], MPR121_ELEX_REG)) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_I2C "MPR121%c: ERROR: Cannot read data!"), pS->id[i]);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR(D_LOG_I2C "MPR121%c: ERROR: Cannot read data!"), pS->id[i]);
|
||||
Mpr121Init(pS);
|
||||
return;
|
||||
}
|
||||
|
@ -339,9 +333,7 @@ void Mpr121Show(struct mpr121 *pS, uint8_t function)
|
|||
|
||||
// Clear OVCF bit
|
||||
I2cWrite8(pS->i2c_addr[i], MPR121_ELEX_REG, 0x00);
|
||||
snprintf_P(log_data, sizeof(log_data),
|
||||
PSTR(D_LOG_I2C "MPR121%c: ERROR: Excess current detected! Fix circuits if it happens repeatedly! Soft-resetting MPR121 ..."), pS->id[i]);
|
||||
AddLog(LOG_LEVEL_ERROR);
|
||||
AddLog_P2(LOG_LEVEL_ERROR, PSTR(D_LOG_I2C "MPR121%c: ERROR: Excess current detected! Fix circuits if it happens repeatedly! Soft-resetting MPR121 ..."), pS->id[i]);
|
||||
Mpr121Init(pS);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -52,11 +52,9 @@ void CCS811Update(void) // Perform every n second
|
|||
sint8_t res = ccs.begin(CCS811_ADDRESS);
|
||||
if (!res) {
|
||||
CCS811_type = 1;
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "CCS811", 0x5A);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, "CCS811", 0x5A);
|
||||
} else {
|
||||
//snprintf_P(log_data, sizeof(log_data), "CCS811 init failed: %d",res);
|
||||
//AddLog(LOG_LEVEL_DEBUG);
|
||||
//AddLog_P2(LOG_LEVEL_DEBUG, "CCS811 init failed: %d",res);
|
||||
}
|
||||
} else {
|
||||
if (ccs.available()) {
|
||||
|
|
|
@ -134,12 +134,12 @@ void MPU_6050Detect(void)
|
|||
mpu6050.setXGyroOffset(220);
|
||||
mpu6050.setYGyroOffset(76);
|
||||
mpu6050.setZGyroOffset(-85);
|
||||
mpu6050.setZAccelOffset(1788);
|
||||
mpu6050.setZAccelOffset(1788);
|
||||
if (MPU6050_dmp.devStatus == 0) {
|
||||
mpu6050.setDMPEnabled(true);
|
||||
MPU6050_dmp.packetSize = mpu6050.dmpGetFIFOPacketSize();
|
||||
MPU_6050_found = true;
|
||||
}
|
||||
}
|
||||
#else
|
||||
mpu6050.initialize();
|
||||
MPU_6050_found = mpu6050.testConnection();
|
||||
|
@ -150,8 +150,7 @@ void MPU_6050Detect(void)
|
|||
|
||||
if (MPU_6050_found)
|
||||
{
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, D_SENSOR_MPU6050, MPU_6050_address);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, D_SENSOR_MPU6050, MPU_6050_address);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,12 +73,11 @@ void DS3231Detect(void)
|
|||
{
|
||||
DS3231chipDetected = false;
|
||||
if (I2cValidRead(USE_RTC_ADDR, RTC_STATUS, 1)) {
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, "DS3231", USE_RTC_ADDR);
|
||||
AddLog_P2(LOG_LEVEL_INFO, S_LOG_I2C_FOUND_AT, "DS3231", USE_RTC_ADDR);
|
||||
DS3231chipDetected = true;
|
||||
} else {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_I2C "%s *NOT* " D_FOUND_AT " 0x%x"), "DS3231", USE_RTC_ADDR);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_I2C "DS3231 NOT " D_FOUND_AT " 0x%x"), USE_RTC_ADDR);
|
||||
}
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*
|
||||
|
@ -155,9 +154,8 @@ bool Xsns33(uint8_t function)
|
|||
RtcTime.year = tmpTime.year + 1970;
|
||||
daylight_saving_time = RuleToTime(Settings.tflag[1], RtcTime.year);
|
||||
standard_time = RuleToTime(Settings.tflag[0], RtcTime.year);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("Set time from DS3231 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("Set time from DS3231 to RTC (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
|
||||
GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
if (local_time < 1451602800) { // 2016-01-01
|
||||
rules_flag.time_init = 1;
|
||||
} else {
|
||||
|
@ -165,9 +163,8 @@ bool Xsns33(uint8_t function)
|
|||
}
|
||||
}
|
||||
else if (!ds3231WriteStatus && DS3231chipDetected && utc_time > 1451602800 && abs(utc_time - ReadFromDS3231()) > 60) {//if time is valid and is drift from RTC in more that 60 second
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("Write Time TO DS3231 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("Write Time TO DS3231 from NTP (" D_UTC_TIME ") %s, (" D_DST_TIME ") %s, (" D_STD_TIME ") %s"),
|
||||
GetTime(0).c_str(), GetTime(2).c_str(), GetTime(3).c_str());
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
SetDS3231Time (utc_time); //update the DS3231 time
|
||||
ds3231WriteStatus = true;
|
||||
}
|
||||
|
|
|
@ -382,14 +382,14 @@ const char HTTP_BTN_MENU_HX711[] PROGMEM =
|
|||
const char HTTP_FORM_HX711[] PROGMEM =
|
||||
"<fieldset><legend><b> " D_CALIBRATION " </b></legend>"
|
||||
"<form method='post' action='" WEB_HANDLE_HX711 "'>"
|
||||
"<p><b>" D_REFERENCE_WEIGHT "</b> (" D_UNIT_KILOGRAM ")<br/><input type='number' step='0.001' id='p1' name='p1' placeholder='0' value='{1'></p>"
|
||||
"<p><b>" D_REFERENCE_WEIGHT "</b> (" D_UNIT_KILOGRAM ")<br/><input type='number' step='0.001' id='p1' name='p1' placeholder='0' value='%s'></p>"
|
||||
"<br/><button name='calibrate' type='submit'>" D_CALIBRATE "</button>"
|
||||
"</form>"
|
||||
"</fieldset><br/><br/>"
|
||||
|
||||
"<fieldset><legend><b> " D_HX711_PARAMETERS " </b></legend>"
|
||||
"<form method='post' action='" WEB_HANDLE_HX711 "'>"
|
||||
"<p><b>" D_ITEM_WEIGHT "</b> (" D_UNIT_KILOGRAM ")<br/><input type='number' max='6.5535' step='0.0001' id='p2' name='p2' placeholder='0.0' value='{2'></p>";
|
||||
"<p><b>" D_ITEM_WEIGHT "</b> (" D_UNIT_KILOGRAM ")<br/><input type='number' max='6.5535' step='0.0001' id='p2' name='p2' placeholder='0.0' value='%s'></p>";
|
||||
|
||||
void HandleHxAction(void)
|
||||
{
|
||||
|
@ -403,41 +403,38 @@ void HandleHxAction(void)
|
|||
return;
|
||||
}
|
||||
|
||||
char tmp[100];
|
||||
char stemp1[20];
|
||||
|
||||
if (WebServer->hasArg("reset")) {
|
||||
snprintf_P(tmp, sizeof(tmp), PSTR("Sensor34 1")); // Reset
|
||||
ExecuteWebCommand(tmp, SRC_WEBGUI);
|
||||
snprintf_P(stemp1, sizeof(stemp1), PSTR("Sensor34 1")); // Reset
|
||||
ExecuteWebCommand(stemp1, SRC_WEBGUI);
|
||||
|
||||
HandleRoot(); // Return to main screen
|
||||
return;
|
||||
}
|
||||
|
||||
if (WebServer->hasArg("calibrate")) {
|
||||
WebGetArg("p1", tmp, sizeof(tmp));
|
||||
Settings.weight_reference = (!strlen(tmp)) ? 0 : (unsigned long)(CharToDouble(tmp) * 1000);
|
||||
WebGetArg("p1", stemp1, sizeof(stemp1));
|
||||
Settings.weight_reference = (!strlen(stemp1)) ? 0 : (unsigned long)(CharToDouble(stemp1) * 1000);
|
||||
|
||||
HxLogUpdates();
|
||||
|
||||
snprintf_P(tmp, sizeof(tmp), PSTR("Sensor34 2")); // Start calibration
|
||||
ExecuteWebCommand(tmp, SRC_WEBGUI);
|
||||
snprintf_P(stemp1, sizeof(stemp1), PSTR("Sensor34 2")); // Start calibration
|
||||
ExecuteWebCommand(stemp1, SRC_WEBGUI);
|
||||
|
||||
HandleRoot(); // Return to main screen
|
||||
return;
|
||||
}
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
page.replace(F("{v}"), FPSTR(D_CONFIGURE_HX711));
|
||||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
page += FPSTR(HTTP_FORM_HX711);
|
||||
dtostrfd((float)Settings.weight_reference / 1000, 3, tmp);
|
||||
page.replace("{1", String(tmp));
|
||||
dtostrfd((float)Settings.weight_item / 10000, 4, tmp);
|
||||
page.replace("{2", String(tmp));
|
||||
|
||||
page += FPSTR(HTTP_FORM_END);
|
||||
page += FPSTR(HTTP_BTN_CONF);
|
||||
ShowPage(page);
|
||||
WSContentStart(FPSTR(D_CONFIGURE_HX711));
|
||||
WSContentSendStyle();
|
||||
dtostrfd((float)Settings.weight_reference / 1000, 3, stemp1);
|
||||
char stemp2[20];
|
||||
dtostrfd((float)Settings.weight_item / 10000, 4, stemp2);
|
||||
WSContentSend_P(HTTP_FORM_HX711, stemp1, stemp2);
|
||||
WSContentSend(FPSTR(HTTP_FORM_END));
|
||||
WSContentSend(FPSTR(HTTP_BTN_CONF));
|
||||
WSContentEnd();
|
||||
}
|
||||
|
||||
void HxSaveSettings(void)
|
||||
|
@ -457,9 +454,7 @@ void HxLogUpdates(void)
|
|||
char weigth_item_chr[33];
|
||||
dtostrfd((float)Settings.weight_item / 10000, 4, weigth_item_chr);
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_JSON_WEIGHT_REF " %s, " D_JSON_WEIGHT_ITEM " %s"),
|
||||
weigth_ref_chr, weigth_item_chr);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_JSON_WEIGHT_REF " %s, " D_JSON_WEIGHT_ITEM " %s"), weigth_ref_chr, weigth_item_chr);
|
||||
}
|
||||
|
||||
#endif // USE_HX711_GUI
|
||||
|
@ -495,10 +490,10 @@ bool Xsns34(uint8_t function)
|
|||
break;
|
||||
#ifdef USE_HX711_GUI
|
||||
case FUNC_WEB_ADD_MAIN_BUTTON:
|
||||
strncat_P(mqtt_data, HTTP_BTN_MENU_MAIN_HX711, sizeof(mqtt_data) - strlen(mqtt_data) -1);
|
||||
WSContentSend(FPSTR(HTTP_BTN_MENU_MAIN_HX711));
|
||||
break;
|
||||
case FUNC_WEB_ADD_BUTTON:
|
||||
strncat_P(mqtt_data, HTTP_BTN_MENU_HX711, sizeof(mqtt_data) - strlen(mqtt_data) -1);
|
||||
WSContentSend(FPSTR(HTTP_BTN_MENU_HX711));
|
||||
break;
|
||||
case FUNC_WEB_ADD_HANDLER:
|
||||
WebServer->on("/" WEB_HANDLE_HX711, HandleHxAction);
|
||||
|
|
|
@ -501,13 +501,11 @@ bool MGC3130_detect(void)
|
|||
success = MGC3130_receiveMessage(); // This should read the firmware info
|
||||
if (success) {
|
||||
strcpy_P(MGC3130stype, PSTR("MGC3130"));
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, MGC3130stype, MGC3130_I2C_ADDR);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, MGC3130stype, MGC3130_I2C_ADDR);
|
||||
MGC3130_currentGesture[0] = '\0';
|
||||
MGC3130_type = true;
|
||||
} else {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("MGC3130 did not respond at address 0x%x"), MGC3130_I2C_ADDR);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("MGC3130 did not respond at address 0x%x"), MGC3130_I2C_ADDR);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -251,9 +251,8 @@ void RfSnsAnalyzeTheov2(void)
|
|||
break;
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("RFS: TheoV2, ChkCalc %d, Chksum %d, id %d, Type %d, Ch %d, Volt %d, BattLo %d, Pld1 %d, Pld2 %d"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RFS: TheoV2, ChkCalc %d, Chksum %d, id %d, Type %d, Ch %d, Volt %d, BattLo %d, Pld1 %d, Pld2 %d"),
|
||||
chksum, Checksum, id, Type, Channel +1, Payload3, (Voltage & 0x80) >> 7, Payload1, Payload2);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
void RfSnsTheoV2Show(bool json)
|
||||
|
@ -507,9 +506,8 @@ void RfSnsAnalyzeAlectov2()
|
|||
rfsns_alecto_v2->wdir = data[8] & 0xf;
|
||||
}
|
||||
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("RFS: " D_ALECTOV2 ", ChkCalc %d, Chksum %d, rc %d, Temp %d, Hum %d, Rain %d, Wind %d, Gust %d, Dir %d, Factor %s"),
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RFS: " D_ALECTOV2 ", ChkCalc %d, Chksum %d, rc %d, Temp %d, Hum %d, Rain %d, Wind %d, Gust %d, Dir %d, Factor %s"),
|
||||
checksumcalc, checksum, rc, ((data[1] & 0x3) * 256 + data[2]) - 400, data[3], (data[6] * 256) + data[7], data[4], data[5], data[8] & 0xf, dtostrfd(factor, 3, buf1));
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
void RfSnsAlectoResetRain(void)
|
||||
|
@ -627,8 +625,7 @@ void RfSnsInit(void)
|
|||
|
||||
void RfSnsAnalyzeRawSignal(void)
|
||||
{
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("RFS: Pulses %d"), (int)rfsns_raw_signal->Number);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("RFS: Pulses %d"), (int)rfsns_raw_signal->Number);
|
||||
|
||||
#ifdef USE_THEO_V2
|
||||
RfSnsAnalyzeTheov2();
|
||||
|
|
|
@ -76,8 +76,7 @@ void PN532_Init(void)
|
|||
PN532_setPassiveActivationRetries(0xFF);
|
||||
PN532_SAMConfig();
|
||||
pn532_model = 1;
|
||||
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC Reader detected (V%u.%u)",(ver>>16) & 0xFF, (ver>>8) & 0xFF);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO,"NFC: PN532 NFC Reader detected (V%u.%u)",(ver>>16) & 0xFF, (ver>>8) & 0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -446,8 +445,7 @@ void PN532_ScanForTag(void)
|
|||
}
|
||||
if (mifareclassic_WriteDataBlock(1, card_data)) {
|
||||
erase_success = true;
|
||||
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Erase success");
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Erase success"));
|
||||
memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string
|
||||
}
|
||||
}
|
||||
|
@ -456,8 +454,7 @@ void PN532_ScanForTag(void)
|
|||
memcpy(&card_data,&pn532_newdata,sizeof(card_data));
|
||||
if (mifareclassic_WriteDataBlock(1, card_data)) {
|
||||
set_success = true;
|
||||
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Data write successful");
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data write successful"));
|
||||
memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string
|
||||
}
|
||||
#else
|
||||
|
@ -472,13 +469,11 @@ void PN532_ScanForTag(void)
|
|||
card_data[pn532_newdata_len] = '\0'; // Enforce null termination
|
||||
if (mifareclassic_WriteDataBlock(1, card_data)) {
|
||||
set_success = true;
|
||||
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Data write successful");
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data write successful"));
|
||||
memcpy(&card_datas,&card_data,sizeof(card_data)); // Cast block 1 to a string
|
||||
}
|
||||
} else {
|
||||
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Data must be alphanumeric");
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Data must be alphanumeric"));
|
||||
}
|
||||
#endif // USE_PN532_DATA_RAW
|
||||
}
|
||||
|
@ -489,14 +484,12 @@ void PN532_ScanForTag(void)
|
|||
switch (pn532_function) {
|
||||
case 0x01:
|
||||
if (!erase_success) {
|
||||
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Erase fail - exiting erase mode");
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Erase fail - exiting erase mode"));
|
||||
}
|
||||
break;
|
||||
case 0x02:
|
||||
if (!set_success) {
|
||||
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Write failed - exiting set mode");
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Write failed - exiting set mode"));
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
@ -550,8 +543,7 @@ bool PN532_Command(void)
|
|||
UpperCase(XdrvMailbox.data,XdrvMailbox.data);
|
||||
if (!strcmp(subStr(sub_string, XdrvMailbox.data, ",", 1),"E")) {
|
||||
pn532_function = 1; // Block 1 of next card/tag will be reset to 0x00...
|
||||
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Next scanned tag data block 1 will be erased");
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Next scanned tag data block 1 will be erased"));
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_TIME "\":\"%s\""), GetDateAndTime(DT_LOCAL).c_str());
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"PN532\":{\"COMMAND\":\"E\"\"}}"), mqtt_data);
|
||||
return serviced;
|
||||
|
@ -568,8 +560,7 @@ bool PN532_Command(void)
|
|||
memcpy(&pn532_newdata,&sub_string_tmp,pn532_newdata_len);
|
||||
pn532_newdata[pn532_newdata_len] = 0x00; // Null terminate the string
|
||||
pn532_function = 2;
|
||||
snprintf_P(log_data, sizeof(log_data),"NFC: PN532 NFC - Next scanned tag data block 1 will be set to '%s'",pn532_newdata);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
AddLog_P2(LOG_LEVEL_INFO, PSTR("NFC: PN532 NFC - Next scanned tag data block 1 will be set to '%s'"), pn532_newdata);
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("{\"" D_JSON_TIME "\":\"%s\""), GetDateAndTime(DT_LOCAL).c_str());
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), PSTR("%s,\"PN532\":{\"COMMAND\":\"S\"\"}}"), mqtt_data);
|
||||
return serviced;
|
||||
|
|
|
@ -94,8 +94,7 @@ void Max4409Detect(void)
|
|||
Wire.write(MAX44009_CONTINUOUS_AUTO_MODE);
|
||||
if (0 == Wire.endTransmission()) {
|
||||
max44009_found = 1;
|
||||
snprintf_P(log_data, sizeof(log_data), S_LOG_I2C_FOUND_AT, max44009_types, max44009_address);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, S_LOG_I2C_FOUND_AT, max44009_types, max44009_address);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -305,8 +305,7 @@ bool XsnsCall(uint8_t Function)
|
|||
uint32_t profile_millis = millis() - profile_start_millis;
|
||||
if (profile_millis) {
|
||||
if (FUNC_EVERY_SECOND == Function) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("PRF: At %08u XsnsCall %d to Sensor %d took %u mS"), uptime, Function, x, profile_millis);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PRF: At %08u XsnsCall %d to Sensor %d took %u mS"), uptime, Function, x, profile_millis);
|
||||
}
|
||||
}
|
||||
#endif // PROFILE_XSNS_SENSOR_EVERY_SECOND
|
||||
|
@ -323,8 +322,7 @@ bool XsnsCall(uint8_t Function)
|
|||
uint32_t profile_millis = millis() - profile_start_millis;
|
||||
if (profile_millis) {
|
||||
if (FUNC_EVERY_SECOND == Function) {
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("PRF: At %08u XsnsCall %d took %u mS"), uptime, Function, profile_millis);
|
||||
AddLog(LOG_LEVEL_DEBUG);
|
||||
AddLog_P2(LOG_LEVEL_DEBUG, PSTR("PRF: At %08u XsnsCall %d took %u mS"), uptime, Function, profile_millis);
|
||||
}
|
||||
}
|
||||
#endif // PROFILE_XSNS_EVERY_SECOND
|
||||
|
|
Loading…
Reference in New Issue