Compare commits

..

384 Commits

Author SHA1 Message Date
Theo Arends
afba1c8b9c Fix LoRaWan regression 2025-07-25 16:13:24 +02:00
Theo Arends
a273684902 Allow LoRaWanName as GUI name 2025-07-25 15:35:29 +02:00
Theo Arends
010de30400 Revert LwDecode device name change 2025-07-25 11:06:23 +02:00
Theo Arends
93c46dc3f9 Consolidate LoRaWan decoding Device, Node and RSSI into LwDecode
- Use LoRaWanName as JSON device name
- Use SetOption83 to control JSON LwDecoded field pair display
2025-07-24 10:55:42 +02:00
Theo Arends
4a632e9ef1 Build LwDecode topic once 2025-07-23 14:49:43 +02:00
Theo Arends
2fededdc57 Merge branch 'development' of https://github.com/arendst/Tasmota into development 2025-07-23 12:30:48 +02:00
Theo Arends
1495338f53 Fix Build MQTT topic string based on FullTopic 2025-07-23 12:30:35 +02:00
gemu
83ed4c3aec
add calls for shelly pro EM3 emulation (#23713) 2025-07-23 12:18:06 +02:00
Theo Arends
a4b05b88a5 Add RSSI to LoRaWan decoded messages 2025-07-23 12:05:44 +02:00
Theo Arends
86d5b3e727 Fix UFS Domoticz regression when no relays/devices are configured 2025-07-23 11:45:59 +02:00
Theo Arends
063ea6af3e Add CSS tab colors and unify LwDecode GUI 2025-07-22 18:14:41 +02:00
UBWH
4b74c71f19
Create D20.be (#23709) 2025-07-22 09:20:02 +02:00
Theo Arends
d7eebc174e Fix and Unify LoRaWan berry parameter GUI 2025-07-21 16:21:26 +02:00
Theo Arends
e11c874eda Fix power0 regression from yesterday 2025-07-21 09:26:30 +02:00
Theo Arends
8f973e3b3a Fix iFan response to command Power0 (#23595) 2025-07-20 16:18:26 +02:00
Theo Arends
37af8be39d Update changelogs 2025-07-20 15:49:34 +02:00
Alexey Pavlov
6080bdc472
Latest opentherm (#23704)
* Revert "Build firmware from Master branch"

* Updated workflows

* Added ENS160 (Air quality) and ENS210 (Temperature & Humidity) sensor

* Revert "Added ENS160 (Air quality) and ENS210 (Temperature & Humidity) sensor"

* pre-release 9.3.0

* Update README.md

* Update xsns_05_ds18x20.ino

Fix DS18x20 driver timing issue (#11270)

* Prep release 9.4.0

* Prep 9.4.0

* Update Spanish and Italian

* Update languages

* Push rebuild

* Update changelog

* Update tasmota_version.h

* Update CHANGELOG.md

* Update README.md

* Prep v10.1.0

* revert xlgt_01_ws2812

* Update xsns_69_opentherm.ino

Add variable overrides

* Revert "Update xsns_69_opentherm.ino"

* Prep release

* Prep release

* Prep release 11.1

* Prep release 12.0

* Fix resolving MQTT and NTP servers

- Fix resolving MQTT and NTP servers (#15816)
- Bump version to v12.0.1

* Update RELEASENOTES.md

* Update CHANGELOG.md

* Release 12.1

* Release 12.1

* Revert camera changes

* Prep v12.1.1

* Prep v12.1.1

* Prep v12.1.1

* OT bugfix

* Prep release v12.2.0

* Prep v12.3.0 release

* Revert Tuya change

* add safeboot to release (#17393)

* Update Tasmota_build_master.yml

* Fix ESP8266 zifbee exception 3

* Update RELEASENOTES.md

* fix needed depend. base32-images (#17406)

* Fix ESP32 uploads

* Create TASMOTA_FullLogo_Vector_White.svg

* Fix support for non-sequential buttons and switches

Fix support for non-sequential buttons and switches (#17967)

* Fix duplicate EnergyTotal update

* Update README.md

* New workflow for release (#18722)

* Update CHANGELOG.md

* Update CHANGELOG.md

* fix rs485 transmit

* fix modbus

* prep v13.1

* Prep v13.2.0

* Prep v13.3

* Update to v13.4.0

* Prep release v14.0.0

* Prep release v14.0.0

* Prep v14.1.0

* Prep v14.2.0

* Update CHANGELOG.md

* Prep 14.4

* Update changelog

* Prep v14.5.0

* remove abs from analog sensor

* Update CHANGELOG.md

* Prep release v14.6.0

* Update CHANGELOG.md

* Prep v15.0.0

* change opentherm library

* fixes for new open therm library

* remove changes

* remove changes

---------

Co-authored-by: Jason2866 <24528715+Jason2866@users.noreply.github.com>
Co-authored-by: Theo Arends <11044339+arendst@users.noreply.github.com>
Co-authored-by: chrfriese123 <christoph@frieseonline.de>
Co-authored-by: Alexey Pavlov <ap@profi.ru>
Co-authored-by: Serge <60098151+Xjeater@users.noreply.github.com>
2025-07-20 15:29:10 +02:00
md5sum-as
aa7d74dec0
Added encoder support in scripter (#23706)
Co-authored-by: a.spirenkov@vk.team <a.spirenkov@vk.team>
2025-07-20 15:28:13 +02:00
Theo Arends
fee8198e64 Unify HostedOTA with Upgrade experience 2025-07-20 12:51:50 +02:00
Theo Arends
d2f7af6572 Update changelogs 2025-07-20 11:39:27 +02:00
Jason2866
0adf865163
esp8266 Platform 2025.07.00 (#23700) 2025-07-18 11:49:05 +02:00
Pedro Ribeiro
f106eb3324
Fix misdetection of current generation TSL2591 (#23699)
* Update xsns_11_veml6070.ino

in Veml6070Detect check for the presence of both addresses in the bus to avoid misdetection of ATH20/21 (anyone with the device, please confirm this change still detect the device when present)

* Update xsns_16_tsl2561.ino

check the correct ID was returned to avoid misdetection of other sensors.

* Update xsns_57_tsl2591.ino - report channel values in JSON as in TSL2561

Add the raw infrared and broadband channels of the sensor to the JSON report like is done in the driver for TSL2561

* Update xsns_57_tsl2591.ino

Fix var name

* Update xsns_57_tsl2591.ino

Fix variable name

* Fix to correctly detect all known chip versions

Fix do deal with the current generation of the chip that returns 5 is ID
2025-07-17 19:46:22 +02:00
s-hadinger
60d59fde09
Adding detailed documentation to support_wifi (#23697)
* Adding detailed documentation to support_wifi

* fix compilation

* Another leftover
2025-07-17 16:54:01 +02:00
Theo Arends
79e76bddfb Add support for HostedOta based on OtaUrl 2025-07-17 14:28:09 +02:00
s-hadinger
d82fb0e07f
Berry fix missing coma (code actually not used in Tasmota) 2025-07-17 09:59:49 +02:00
s-hadinger
1fbe52df06
Remove bytes from Tasmota specific 2025-07-17 09:40:42 +02:00
s-hadinger
57c7033987
Fix TwoWire signature change (#23695) 2025-07-16 23:09:27 +02:00
s-hadinger
dd4c8e875c
Berry add CLI options to Berry Ref (#23693) 2025-07-16 19:21:49 +02:00
Jason2866
64d5045ccb
Simplify Pio script post_esp32.py (#23689)
* simplify post_esp32.py
* make sure path has correct "\" or "/" regarding OS
* add os specific path separators
* more path possible issues corrections
* add function to normpath cmd
* set board_build.variants_dir    = variants/tasmota correctly for OS
2025-07-16 18:23:33 +02:00
Theo Arends
035667327d Add support for P4 GUI Template config 2025-07-16 15:40:02 +02:00
Theo Arends
becd0a6ffc Update changelogs 2025-07-16 14:37:19 +02:00
Theo Arends
6e7e483a70 Fix repeated get hosted MCU fw version 2025-07-16 14:27:01 +02:00
Jason2866
3c0e71c290
Platform 2025.07.31 Tasmota Arduino Core 3.1.3.250712 based on IDF 5.3.3.250702 (#23685)
* use OBJCOPY for full esptool path
* Update PULL_REQUEST_TEMPLATE.md
* Platform 2025.07.31 Tasmota Arduino Core 3.1.3.250712 based on IDF 5.3.3.250702
2025-07-16 09:55:34 +02:00
s-hadinger
df4943bc19
Berry Leds fix minor inconsistencies in Leds_segment (#23688) 2025-07-15 22:49:18 +02:00
s-hadinger
722db4157d
Berry split tasmota-specific reference documentation (#23687) 2025-07-15 22:17:11 +02:00
Christian Baars
08f2826e97
MI32: fix server notifications/indications (#23686) 2025-07-15 20:25:41 +02:00
Jason2866
a38146cc95
Revert "Platform 2025.07.31 Tasmota Arduino Core 3.1.3.250712 based on IDF 5.…" (#23684)
This reverts commit 228588a6a3a005ef6cc88650225bb7c327f61f57.
2025-07-15 18:42:30 +02:00
Jason2866
228588a6a3
Platform 2025.07.31 Tasmota Arduino Core 3.1.3.250712 based on IDF 5.3.3.250702 (#23683)
* Platform 2025.07.31 Tasmota Arduino Core 3.1.3.250712 based on IDF 5.3.3.250702
2025-07-15 18:40:08 +02:00
Theo Arends
64c8719f70 Re-add domoticz erase settings on request 2025-07-15 17:39:07 +02:00
Theo Arends
c0f11f0373 Changed Domoticz supports persistent settings for all relays, keys and switches when filesystem #define USE_UFILESYS is enabled 2025-07-15 17:06:03 +02:00
Jason2866
a6124128a7
P4 Ethernet support in safeboot (#23681) 2025-07-14 20:46:43 +02:00
Jason2866
488225c787
add p4 to GH Actions (#23680) 2025-07-14 14:26:47 +02:00
bovirus
95fb60fd07
Italian language update (#23678) 2025-07-14 08:23:44 +02:00
Jason2866
cddcafbda3
Switch off not needed waiting for FS up and download (#23677) 2025-07-13 21:24:25 +02:00
Theo Arends
0738f0f916 Fix compilation 2025-07-13 17:36:37 +02:00
Theo Arends
231f342497 ESP32 reduce Domoticz memory and filesystem footprint. Redesign GUI 2025-07-13 15:37:33 +02:00
Theo Arends
4efc2d6ce6 Add ESP32 switch to safeboot on 10 fast_reboots 2025-07-12 23:20:09 +02:00
Theo Arends
46e6f7ea02 Update changelogs 2025-07-12 21:36:53 +02:00
realmicu
7e77086a2d
Add support for Hyundai WS Senzor 77(TH) (#23673) 2025-07-12 21:20:41 +02:00
FransOv
3b207db27c
Correct handling of passive response of Winsen ZH03X Particle sensor in xsns_18_pms5003.ino (#23651)
* Update xsns_18_pms5003.ino

* Update xsns_18_pms5003.ino
2025-07-12 21:20:16 +02:00
TheHexaMaster
d3e2bb6906
RV3028 RTC Chip support (#23672)
* Update xdrv_56_rtc_chips.ino

Added support for RV3028 RTC

* Update I2CDEVICES.md

RV3028 RTC Support

* Update my_user_config.h
2025-07-12 21:17:43 +02:00
Christian Baars
6c699e9b95
add hostedOTA and info messages (#23675) 2025-07-12 11:43:42 +02:00
Theo Arends
fc22688b5d Add ESP32P4 config_version 2025-07-11 09:01:22 +02:00
Theo Arends
b4796836b0 Update changelogs 2025-07-10 22:51:40 +02:00
Jason2866
9e25fc0f30
basic P4 support (#23663) 2025-07-10 16:47:30 +02:00
Theo Arends
c909e20fb1 Prep Settings for ESP32-P4 2025-07-10 14:56:39 +02:00
chefpro
a052ee00a2
Add more commands and error handling to pipsolar driver. (#23659)
Co-authored-by: Peter Rustler <peter@rustlerit.de>
2025-07-09 22:41:53 +02:00
Jason2866
bb53b42790
fix esptool call 2025-07-09 22:35:38 +02:00
Theo Arends
fca68c6b30 Change ESP32 Domoticz supports persistent settings for all relays, keys and switches using filesystem 2025-07-09 17:25:34 +02:00
Theo Arends
6751bd397c Change WSContentEnd to fix UDP 2025-07-09 14:29:46 +02:00
UBWH
c22cdd24b2
Update README.md (#23656)
Add LoRaWAN Configuration page instructions
2025-07-09 12:31:32 +02:00
UBWH
e0515a7d30
Update LwDecode.be (#23655)
Add LoRaWAN Config page
2025-07-09 12:26:16 +02:00
Jason2866
dc14f1c3bd
esptool v5.0.0 changes for post pio esp32 script (#23650) 2025-07-08 22:05:14 +02:00
s-hadinger
d8b40263e2
Add Tasmota specific Berry APIs to language reference (#23652) 2025-07-08 21:15:27 +02:00
Theo Arends
56eb8d98c0 Bump version 15.0.1.2 2025-07-08 15:16:37 +02:00
Christian Baars
ae3dbde4b1
i2spause (#23646) 2025-07-07 21:26:52 +02:00
s-hadinger
3dec15322f
Fix DisplayCalibrate regression caused by autoconf removed from global scope (#23648) 2025-07-07 21:24:17 +02:00
s-hadinger
19c212f261
Add Berry language reference in Markdown for AI (#23647) 2025-07-07 20:56:31 +02:00
Jason2866
850fd07d3a
Platform 2025.07.30 Tasmota Arduino Core 3.1.3.250707 based on IDF 5.3.3.250702 (#23642)
* Platform 2025.07.30 Tasmota Arduino Core 3.1.3.250707 based on IDF 5.3.3.250702
* Use esp_jpeg component for decoding
2025-07-07 19:04:29 +02:00
Theo Arends
59c80254cd Add internal function 'WSContentSendRaw_P' (#23641) 2025-07-07 14:27:45 +02:00
Theo Arends
9e7be254c2 Revert "Add internal function 'WSContentSendRaw_P' (#23641)"
This reverts commit 912cb15beb8015212a80d8369a98332d58b1f05e.
2025-07-06 15:13:52 +02:00
s-hadinger
912cb15beb
Add internal function 'WSContentSendRaw_P' (#23641)
* Add internal function 'add_WSContentSendRaw_P'

* Fix crash if PROGMEM

* Update xdrv_01_9_webserver.ino

Fix ESP8266 exception 3 when Unishox is disabled

---------

Co-authored-by: Theo Arends <11044339+arendst@users.noreply.github.com>
2025-07-06 14:38:15 +02:00
Theo Arends
5086863322 Add commands LoRaWanDecoder " and LoRaWanName " to clear name (#23394) 2025-07-05 15:57:51 +02:00
Theo Arends
0a80f45636 Add Universal display driver for ZJY169S0800TG01 ST7789 280x240 (#23638) 2025-07-05 15:44:10 +02:00
Theo Arends
fffda63f3c Update changelogs 2025-07-05 15:35:40 +02:00
然而并没有
07dcbcc53e
fix: AHT30 sensor start with null values (#23624) 2025-07-05 15:21:05 +02:00
Arnie97
39013e4f7b
Remove Keeloq 64/66 conversion code (#23615) 2025-07-05 15:20:31 +02:00
s-hadinger
99b73aaaf8
CSS uses named colors variables (#23597) 2025-07-05 15:19:45 +02:00
UBWH
c5aced3dd0
Create SE01-L.be (#23607)
LoRaWAN decoder for 
Dragino SE01-LB/LS -- LoRaWAN Soil Moisture & EC Sensor
2025-07-05 15:18:45 +02:00
Norbert Richter
ece26ccfaf
NeoPool add Redox tank alarm (#23582)
Co-authored-by: Theo Arends <11044339+arendst@users.noreply.github.com>
2025-07-05 15:16:57 +02:00
Pedro Ribeiro
407c274229
Update xsns_11_veml6070.ino (#23581)
* Update xsns_11_veml6070.ino

in Veml6070Detect check for the presence of both addresses in the bus to avoid misdetection of ATH20/21 (anyone with the device, please confirm this change still detect the device when present)

* Update xsns_16_tsl2561.ino

check the correct ID was returned to avoid misdetection of other sensors.

* Update xsns_57_tsl2591.ino - report channel values in JSON as in TSL2561

Add the raw infrared and broadband channels of the sensor to the JSON report like is done in the driver for TSL2561

* Update xsns_57_tsl2591.ino

Fix var name

* Update xsns_57_tsl2591.ino

Fix variable name
2025-07-05 15:15:27 +02:00
Theo Arends
ac51cd7340 Update changelogs 2025-07-05 14:56:57 +02:00
TID
638b3b5c1e
Update pl_PL.h (#23626)
Polish language update
2025-07-03 10:48:38 +02:00
Jason2866
2380c33ef0
CI: use uv instead of pip (#23631)
* use uv
* Windows 2019 is deprecated
2025-07-03 09:41:56 +02:00
Routmoute
4904a43b33
fix: teleinfo standard mode crash (#23628) 2025-07-02 08:44:03 +02:00
s-hadinger
143cfdd4f2
Berry Hue fix regression from #23429 (#23623) 2025-06-30 20:34:51 +02:00
Christian Baars
550b8c5307
use SDK config information about BLE capabilities (#23621) 2025-06-30 18:50:52 +02:00
Christian Baars
cc95aa5f0f
add i2s to some demo environments (#23620) 2025-06-30 16:36:58 +02:00
Christian Baars
aeb3005c3e
small fixes for i2s audio driver (#23619) 2025-06-30 15:22:06 +02:00
s-hadinger
45dd2a331e
Berry f-strings now support ':' in expression (#23618) 2025-06-29 22:46:18 +02:00
Moritz Stückler
99297d6dfc
fix: mention AHT30 temperature sensor config variable (#23617) 2025-06-29 20:55:02 +02:00
s-hadinger
942e419b0c
Summary of the docs repository to easily feed to Code AI (#23614) 2025-06-28 21:59:39 +02:00
s-hadinger
8158db7dad
Summary of the docs repository to easily feed to Code AI (#23610) 2025-06-28 15:15:57 +02:00
s-hadinger
ddf96fb58f
Add Claude 4 generated hierarhy of Matter classes (#23608) 2025-06-28 09:39:46 +02:00
s-hadinger
232db5ce77
Berry fix security issues in 'berry_mapping' and improve documentation (#23606) 2025-06-27 21:26:33 +02:00
s-hadinger
8de22ee4cc
Berry fix security issues in 'int64' and improve documentation (#23605) 2025-06-27 20:49:49 +02:00
s-hadinger
727756283d
Berry add internal documentation with Claude 4 (#23604) 2025-06-27 19:42:44 +02:00
s-hadinger
decdfc6b51
Berry vulnerability in JSON parsing for unicode (#23603) 2025-06-27 19:38:31 +02:00
s-hadinger
e9b62811c7
Berry minor fixes to tapp handling (#23590) 2025-06-22 15:06:22 +02:00
Jason2866
25c85a90ac
esptool v5 explicit exists (#23576)
fetch the exit to prevent leaving the running script
2025-06-19 20:19:37 +02:00
Theo Arends
91e5be450d Change ESP32 LoRaWan decoding won't duplicate non-decoded message if SO147 0 2025-06-19 17:32:07 +02:00
UBWH
07809eede5
Create PS-L-I5.be (#23573)
Codec file for Dragino PS-LB/LS -- LoRaWAN Air Water Pressure Sensor.

0-5m version
2025-06-19 09:32:14 +02:00
Theo Arends
fef5ee9a6f Update changelogs 2025-06-18 15:55:53 +02:00
s-hadinger
7d7a9ea6fb
LVGL restore lv_chart.set_range removed in LVGL 9.3.0 in favor of lv_chart.set_axis_range (#23567)
* LVGL restore `lv_chart.set_range` remove in LVGL 8.3.0 in favor of `lv_chart.set_axis_range`

* Fix typo in changelog

* Another typo
2025-06-17 23:12:55 +02:00
Theo Arends
67d428cd3d Update changelogs 2025-06-17 15:50:08 +02:00
Jason2866
384edd22a7
fix lib names (#23560) 2025-06-16 17:46:00 +02:00
Christian Baars
fb44d42426
BLE updates for esp-nimble-cpp v2.x (#23553) 2025-06-15 18:24:54 +02:00
Christian Baars
f378e68b3d
i2s additions (#23543) 2025-06-14 16:32:54 +02:00
s-hadinger
e30ad61e00
Berry report from upstream !BE_USE_PRECOMPILED_OBJECT (#23549) 2025-06-14 16:07:31 +02:00
Theo Arends
9392ac7d55 Bump version v15.0.1.1 2025-06-14 14:31:34 +02:00
Theo Arends
76d4651163 Update changelogs 2025-06-14 12:16:08 +02:00
UBWH
ea4e399b18
Create DDS75L.be (#23545)
LoRaWAN Decoder File for Dragino DDS75-LB/LS

An Ultrasonic distance sensor

https://www.dragino.com/products/distance-level-sensor/item/271-dds75-lb-ls.html
2025-06-14 11:10:46 +02:00
s-hadinger
d4d6a2c779
LVGL HASPmora fix regression introduced with LVGL 9.3.0 (#23547) 2025-06-14 11:03:55 +02:00
s-hadinger
390927c190
Berry fix realline (#23546) 2025-06-14 10:37:04 +02:00
s-hadinger
b5d6e95164
LVGL regression missing 'lv.ANIM_OFF' and 'lv.ANIM_ON' (#23544) 2025-06-13 22:31:12 +02:00
Theo Arends
79024cdd23 Bump version v15.0.0.1 2025-06-13 15:01:51 +02:00
Theo Arends
f7d4b0e726 Update changelogs 2025-06-13 12:33:53 +02:00
Jason2866
0687520c93
add CMakeLists.txt to gitignore 2025-06-13 11:13:31 +02:00
s-hadinger
64d6231111
LVGL Tasmota logo splash screen (#23538) 2025-06-12 07:53:41 +02:00
s-hadinger
ea99e4724f
Autoconf failing when last line has no trailing LF (#23537) 2025-06-11 23:10:20 +02:00
gemu
004f1ec36a
fix compile error when globvars not used (#23535) 2025-06-11 09:16:15 +02:00
Theo Arends
742b7338fd Update rsyslog msgid 2025-06-10 23:40:38 +02:00
s-hadinger
84059199d4
Berry 'tasmota.is_network_up()' (#23532) 2025-06-10 20:56:50 +02:00
Theo Arends
4002344227 Fix syslog message id 2025-06-10 16:23:42 +02:00
Theo Arends
bba5ba008e Format syslog messages according to RFC5424 adding local log time (#23509) 2025-06-09 17:42:58 +02:00
s-hadinger
7c2eabcd94
Zigbee improved message when coordinator failed to start (#23525)
* Zigbee improved message when coordinator failed to start

* Faster fail
2025-06-08 19:04:17 +02:00
Theo Arends
76a39f7597 LoRaWan berry fix initial last seen 2025-06-07 14:25:55 +02:00
Theo Arends
17cc37b889 Update changelogs 2025-06-07 13:52:45 +02:00
s-hadinger
8da8c97d4f
ESP32 LVGL library from v9.2.2 to v9.3.0 (#23518) 2025-06-06 23:54:17 +02:00
Theo Arends
5522f3f6ba LoRaWan berry decoders add last seen to interrupt sensor 2025-06-06 16:09:13 +02:00
Theo Arends
f3d4b5275d LoRaWan berry decoders fix invalid last seen 2025-06-05 15:08:21 +02:00
Theo Arends
26613aacb2 Add Berry mqtt publish rule processing 2025-06-05 14:04:03 +02:00
Theo Arends
4be87d41ef Fix LoRaWan decoder LHT52 battery calculation 2025-06-05 11:27:06 +02:00
Theo Arends
55c7dc0654 LoRaWan fix initial last_seen uninitialized 2025-06-04 18:38:23 +02:00
Theo Arends
93a22628e5 LoraWan change to confirmed command downlink 2025-06-04 18:13:43 +02:00
Theo Arends
263d84315f Add support for LoraWanSend and LoraWanNode 2025-06-03 17:58:35 +02:00
Theo Arends
81465a8506 Update changelogs 2025-06-03 11:15:00 +02:00
s-hadinger
bafcfcd227
Berry increase web hooks from 16 to 32 (#23507) 2025-06-02 23:12:55 +02:00
sfromis
e7f9f51e27
Update xsns_102_ld2402.ino, command table broken (#23504)
Command pointer table broken after refactoring 3a28938b91

The error with a comma before an entry instead of after, to match the other pointers, looks very obvious to me. Hence, I'm submitting this PR without having the hardware, and thus not able to do a runtime test.
2025-06-02 21:53:08 +02:00
s-hadinger
d94d7c8972
Berry change number parser for json to reuse same parser as lexer (#23505) 2025-06-02 21:42:44 +02:00
Theo Arends
de0d88514a Fix button size 2025-06-01 15:50:42 +02:00
Theo Arends
601ddc564d Update changelogs 2025-06-01 14:07:25 +02:00
s-hadinger
ea9a24e76d
Berry fix potential pointer underflow with string.endswith (#23496) 2025-05-31 20:02:40 +02:00
s-hadinger
1cd4e27123
Berry fix integer and real parser to handle overflows (#23495) 2025-05-31 15:03:54 +02:00
s-hadinger
fcf4706914
Berry avoid json parsing for unmatched commands (#23494) 2025-05-30 22:34:56 +02:00
Theo Arends
692cf547cb Add Support for AP33772S USB PD Sink Controller as used in CentyLab RotoPD 2025-05-30 15:51:50 +02:00
Theo Arends
04302414c8 Berryfy code 2025-05-30 11:13:57 +02:00
Theo Arends
b90ef3b400 Fix compilation 2025-05-29 17:53:55 +02:00
Theo Arends
2eb56b77a2 Change LoRaWan GUI sensor representation 2025-05-29 17:31:21 +02:00
gemu
2914554f5e
fix regression (#23483) 2025-05-28 08:13:08 +02:00
Theo Arends
b822a37a7c Add command trace code to be enabled with define DEBUG_COMMAND_HANG (#23481) 2025-05-27 11:31:15 +02:00
gemu
6aca98673d
fix upd[x] chg[x] (#23477) 2025-05-26 08:05:41 +02:00
Theo Arends
429537ce4c Fix Dragino LHT65 lorawan decoder 2025-05-25 17:20:47 +02:00
Theo Arends
fe596c680d Fix LoraWan config change detection 2025-05-25 16:39:30 +02:00
Jason2866
559209ee14
Update GH Actions (#23472) 2025-05-24 14:23:47 +02:00
s-hadinger
6a4f09c888
Berry fix vulnerability in solidify code
Found by Claude.ai
2025-05-24 09:48:42 +02:00
s-hadinger
d7f9142833
Berry fix POOL32 pointer comparison (#23468) 2025-05-23 22:45:04 +02:00
Fabrizio Amodio
553ee44b02
Berry: 'webserver.content_status_sticker' attribute parameter added (#23466)
* Berry: 'webserver.content_status_sticker' attribute parameter added

* fix optional parameter in comment
2025-05-23 22:42:59 +02:00
Theo Arends
6853e88116 Update i18n.h 2025-05-23 16:38:25 +02:00
Theo Arends
f6bf4351f5 Increase number of supported LoRaWan nodes from 4 to 16 2025-05-23 13:40:30 +02:00
sfromis
b684486570
Command lookup table in support_command.ino broken for ESP32 (#23461)
I observed that the definition of command names became mangled with commit 2bc5f682b0 due to vertical bar not being placed where it should. With no bar after `D_CMND_CPU_FREQUENCY`, the command name became concatenated with the next `D_CMND_SETSENSOR` with the "funny" effect that command name `CpuFrequencySetSensor` got matched with `&CmndSetSensor`

The reason for it not being matched with `&CmndCpuFrequency` is that there is a bar too many before the `Info` command name, as previous command name lines all finish with `"|"`. Hence an extra command table entry was created, meaning that the mismatch "only" affected command names `Info`, `TouchCal`, `TouchThres`, `CpuFrequency` and `SetSensor`.

Issue is only for ESP32, as both mishaps happened in a block conditional on `#ifdef ESP32`.

Arguably, it could make sense to have all the lines with command names start with `"|"` as a consistent way of formatting the lines without the special case of ending `"|"` to be omitted for the very last command name line, but I wanted to only make minimal changes
2025-05-22 22:13:52 +02:00
Theo Arends
4f4bf7c61b Add GUI support to LoRaWan decoders 2025-05-22 17:32:16 +02:00
Theo Arends
92f14dd0c0 Update changelogs 2025-05-22 10:47:30 +02:00
s-hadinger
67d223dc78
Fix Berry solidification regression introduced in #23451 2025-05-22 08:27:41 +02:00
s-hadinger
c10686e366
Berry 'compile' and 'tasmota.compile' option to compile in local context (#23457)
* Berry 'compile' and 'tasmota.compile' option to compile in local context

* remove unwanted changes
2025-05-21 23:46:36 +02:00
Jason2866
c8d6f723c1
Beautify console log output (#23456) 2025-05-21 22:15:23 +02:00
Theo Arends
36a2d253e5 Update changelogs 2025-05-21 10:01:25 +02:00
s-hadinger
40bc108ba1
Berry 'webserver.remove_route' to revert 'webserver.on' (#23452) 2025-05-20 23:07:05 +02:00
s-hadinger
7ce3ba376c
Berry 'introspect.module' option to not cache module entry (#23451) 2025-05-20 22:39:42 +02:00
Theo Arends
6a27899241 Update changelogs 2025-05-20 17:14:59 +02:00
Damian Wrobel
a6ab85f3cd
Fix version for IniFile-Tasmota (#23449)
Fixes the version string in lib/lib_ssl/IniFile-Tasmota/library.properties
file to be semver compliant to avoid build error:
  ValueError: Invalid version string: '0.0.0+modified by Tasmota, based on 1.3.0':

Signed-off-by: Damian Wrobel <dwrobel@ertelnet.rybnik.pl>
2025-05-19 23:44:18 +02:00
Jason2866
08e1ff548b
Platform 2025.05.00 esp8266 Arduino core 2.7.8 (#23448)
- no changes in Arduino Core to previous Platform!
- Platform don't use Platformio registry any more
2025-05-19 20:13:12 +02:00
s-hadinger
e2d30dd64d
Berry fix keys conflict (#23444) 2025-05-19 10:42:17 +02:00
Theo Arends
02ce050727 Update changelogs 2025-05-19 10:30:16 +02:00
s-hadinger
78787f693e
Berry support for 'sortedmap' (#23441)
* Berry support for 'sortedmap'

* Add keys()
2025-05-18 19:29:50 +02:00
NeuDLi
3327f4a5ca
Update IRac.cpp (#23438)
Fix the Coolix fan-only mode in IRac class.

(9785cb910d)
2025-05-18 17:52:16 +02:00
Jason2866
17210d1aca
port VSC: take care of WSL use (#23440) 2025-05-18 16:30:43 +02:00
Jason2866
54a9a117fc
make new VSC port pio script more failsafe (#23439)
* no crash when VSC database is not found
* don't stop when unknown OS is detected
2025-05-18 15:41:10 +02:00
Theo Arends
2b460aa112 Update changelogs 2025-05-18 14:42:47 +02:00
Jason2866
a088c8791f
provide serial upoload port from VSC to PIO (#23436) 2025-05-17 19:59:14 +02:00
s-hadinger
f5fe75c9b0 Solidified Code updated 2025-05-17 08:14:50 +00:00
s-hadinger
65b1c9668f
Berry remove global 'b' (#23433) 2025-05-17 10:13:15 +02:00
s-hadinger
1ee3d8c079
Fix solidification of float on macos (#23432) 2025-05-17 09:54:32 +02:00
s-hadinger
1306f7a8c7
Berry remove imports from globals (#23429) 2025-05-17 09:37:53 +02:00
s-hadinger
e86af24056
DNS setting with 'IPAddress4/5' not persisted (#23426) 2025-05-15 23:25:32 +02:00
s-hadinger
aff2157356
HASPmota auto-dimming when no touch (#23425) 2025-05-15 19:05:43 +02:00
Norbert
fc492bb6b2
Change the log level from INFO to Debug (#23423)
https://discord.com/channels/479389167382691863/790187952416358460/1372526416855437322
2025-05-15 15:30:12 +02:00
Theo Arends
c61462a8ea Add timestamp decode to LHTxx 2025-05-15 15:17:58 +02:00
Theo Arends
f90be50d2d Cleanup LoRaWan berry decoding 2025-05-15 14:27:56 +02:00
Theo Arends
0abe70816b Fix LoRaWan Decoding when SO147 is enabled 2025-05-15 13:38:19 +02:00
Theo Arends
28f4a07fd6 Add LoRaWan Decoder MerryIoT DW10 2025-05-15 11:13:55 +02:00
Theo Arends
7fb8654c6c Add Support for LoRaWan Rx1 and Rx2 profiles (#23394) 2025-05-13 16:53:02 +02:00
Rob
08e8f0b64d
LoRaWan Decode Files (#23412)
* Add LoraWanDecoders

Documentation to follow in separate PR.

See https://github.com/arendst/Tasmota/discussions/23394

* Create README.md

Quick Guide

* Update README.md

Typo

---------

Co-authored-by: UBWH <clark@ubwh.com.au>
2025-05-13 08:53:07 +02:00
Jason2866
ca9df09d6a
add sdkconfig.defaults to .gitignore 2025-05-12 15:25:55 +02:00
s-hadinger
9f764ac414
TCP bridge more logging (#23410) 2025-05-11 18:41:20 +02:00
Theo Arends
f660ba7e04 Add function SleepSkip(<millis> to handle imminent interrupt outside interrupt handler 2025-05-11 17:32:55 +02:00
Theo Arends
8471832b3a Update changelogs 2025-05-11 11:53:11 +02:00
Jason2866
eef115f2c5
Platform 20250530 Arduino core 3.1.3.250504 based on IDF 5.3.3.250501 (#23404)
* Platform 2025.05.30

* ESP32 CORE V.3.1.3.250504
2025-05-11 11:37:07 +02:00
s-hadinger
56ce7b3f93
Allow temporary change of DisplayDimmer (#23406) 2025-05-11 10:43:11 +02:00
s-hadinger
b29ef3dfbc
Fix 'haspmota.parse()' page parsing (#23403)
* Fix 'haspmota.parse()' page parsing

* take into account current page as default
2025-05-10 19:21:35 +02:00
Jason2866
8ea150328d
Solo1 safeboot size shrink 2025-05-10 15:35:30 +02:00
Theo Arends
3d11cc4fee Add command LoRaWanDecoder (#23394) 2025-05-10 14:44:18 +02:00
Theo Arends
42a1aee832 Bump version v14.6.0.2 2025-05-10 13:28:32 +02:00
Jason2866
98c6b0730f
Merge 54 (#487) (#23397)
* IDF 55

* Arduino based on IDF 55

* Update platformio_tasmota32.ini

* Update Tasmota_build_devel.yml

* Create platformio_override.ini

* Update platformio_tasmota32.ini

* Update Tasmota_build_devel.yml

* Update platformio_override.ini

* Update Tasmota_build_devel.yml

* Delete platformio_override.ini

* Update esp32c2.json

* Update esp32c2_2M.json

* Update platformio_tasmota32.ini

* Update PULL_REQUEST_TEMPLATE.md
2025-05-10 12:45:36 +02:00
s-hadinger
66013fcf04
HASPmota add 'antiburn()' (#23400) 2025-05-10 11:33:14 +02:00
Theo Arends
1e74d6fd4d Fix LoRa(Wan) response after config change 2025-05-08 15:48:55 +02:00
gemu
2d16798263
fixes (#23391) 2025-05-08 08:56:57 +02:00
Theo Arends
c25b9827e8 Add support for multi channel AU915-928 LoRaWanBridge by Rob Clark (#23372) 2025-05-07 16:36:41 +02:00
Theo Arends
5475fcc8f3 Fix setting illegal LoRaWan frequencies (#23388) 2025-05-07 12:26:45 +02:00
Theo Arends
502cdfb9ea Fix inconsistent LoRaConfig 42 results (#23387) 2025-05-07 10:32:32 +02:00
Christian Baars
75b109c893
use smaller poly1305-donna and remove other poly1305_auth code (#23386) 2025-05-06 22:01:22 +02:00
Theo Arends
b5ae6bc035 Add support for AU915 (#23372) 2025-05-06 18:30:24 +02:00
Theo Arends
5d8b90d83b Add Region to i18 2025-05-06 16:20:35 +02:00
Christian Baars
9329dbc52b
add SSH demo driver to berry examples (#23378) 2025-05-06 10:48:50 +02:00
SteWers
c148c8e84d
Set syslog severity level (#23377) 2025-05-06 10:37:20 +02:00
Theo Arends
38802ab5b7 Update changelogs 2025-05-06 10:23:48 +02:00
s-hadinger
f83b5a8c80
Berry introspect.module() failed to load modules in files (#23376) 2025-05-05 22:33:52 +02:00
Jason2866
2ab84dd3a4
piotool python scripts refactor (#23375) 2025-05-05 13:12:30 +02:00
Theo Arends
faf12234f6 Update changelogs 2025-05-04 12:30:27 +02:00
SteWers
7624016efb
Use Alias in MI32/TRV (#23368)
- Display Alias in MI32/TRV instead of type, when present
- Show device MAC in BLE log messages
2025-05-04 11:52:02 +02:00
s-hadinger
9ed833ec5f
Matter and mDNS can be enabled at the same time (#23373) 2025-05-04 10:15:07 +02:00
SteWers
d7073b3bdf
Add SSID to Wifi strength indicator (#23369)
Display SSID at Wifi strength indicator to see which is the connected access point
2025-05-03 23:45:49 +02:00
Theo Arends
195fd7c6a3 GPIOViewer from v1.6.2 to v1.6.3 (No functional change) 2025-05-03 18:09:49 +02:00
Theo Arends
ddf3e38ef8 Update changelogs 2025-05-02 15:16:01 +02:00
Christian Baars
e2eae10db6
Fix log_level definition conflict (#23366) 2025-05-02 15:10:02 +02:00
Theo Arends
a52f3450b8 Update changelogs 2025-05-01 14:52:26 +02:00
s-hadinger
a4ce9efd2c
Berry 'display.touch_update' wrongly applies resistive calibration (#23363) 2025-04-30 22:45:19 +02:00
s-hadinger
f72a989976
WebUI status line Berry tapp for Wifi and Free Heap (#23358) 2025-04-30 10:06:48 +02:00
s-hadinger
736d4d6576
WebUI heap status (#23356) 2025-04-30 10:01:59 +02:00
SteWers
060f47678d
Use language files for MQTT stickers (#23355) 2025-04-30 08:39:59 +02:00
Theo Arends
2e251468f9 Update RELEASENOTES.md 2025-04-29 14:48:25 +02:00
s-hadinger
ce5fae934b
Fix WG bug introduced in latest PR 2025-04-29 14:14:26 +02:00
s-hadinger
70bf5daff9
Update CHANGELOG.md 2025-04-29 14:05:30 +02:00
s-hadinger
6cd19c0e59
WebUI status line left and renamed events 'FUNC_WEB_STATUS_left' and 'FUNC_WEB_STATUS_RIGHT' (#23354) 2025-04-29 14:04:29 +02:00
s-hadinger
326fa9ca10
Optional Wifi strength indicator in WebUI status line (#23352) 2025-04-28 22:46:20 +02:00
s-hadinger
d95200939a
Unishox show compressed size (#23351) 2025-04-28 19:37:51 +02:00
s-hadinger
7e7f237292
Wireguard default values (#23349) 2025-04-27 23:12:18 +02:00
s-hadinger
2c2f7f1149
Group "MQTT TLS" in a single sticker (#23348) 2025-04-27 22:31:42 +02:00
s-hadinger
402c9e8e8d
Update CHANGELOG.md 2025-04-27 21:17:25 +02:00
s-hadinger
94652ad6ed
Added Wireguard VPN (#23347) 2025-04-27 20:54:01 +02:00
Christian Baars
723684bb06
Berry: add crypto modules ED25519 and Chacha20-Poly1305 (#23338)
* add crypto modules for Berry

* remove Berry examples from PR
2025-04-25 00:11:47 +02:00
Theo Arends
115cefc557 Fix XModem for SecureCRT telnet client 2025-04-24 15:48:19 +02:00
s-hadinger
0ad8696dfc
WebUI status line for MQTT and TLS, added 'FUNC_WEB_STATUS' event (#23326)
* WebUI status line for MQTT and TLS, added 'FUNC_WEB_STATUS' event

* add Berry support
2025-04-21 11:32:32 +02:00
Theo Arends
6344c46d08 Lower minimum WebRefresh from 1000 to 400 2025-04-20 14:43:20 +02:00
Theo Arends
ed6203e114 - Allow command WebRefresh minimum from 1000 to 400 mSec
- Fix command JsonPP <command> when showing log buffer data like in GUI console and ESP8266 Telnet.
2025-04-20 14:36:22 +02:00
Theo Arends
015fa1da89 Add command JsonPP <command>|backlog <command>;... to enable JSON PP only once 2025-04-19 16:56:15 +02:00
Theo Arends
a11e269ca0 Fix Xmodem send over serial 2025-04-19 12:54:53 +02:00
Theo Arends
2831bbfd18 Update changelogs 2025-04-18 10:36:42 +02:00
bovirus
92b3f7d37c
Italian language update (#23309) 2025-04-18 10:26:10 +02:00
s-hadinger
a2d1915692
Base64 split implementation in separate file (#23313) 2025-04-17 22:38:04 +02:00
s-hadinger
082170374c
Berry string literals containing NULL are truncated (#23312) 2025-04-17 22:12:35 +02:00
s-hadinger
c2628c95f3
Berry 'bytes().asstring()' now truncates a string if buffer contains NULL (#23311) 2025-04-17 21:51:03 +02:00
Theo Arends
2bc5f682b0 Add command JsonPP 0..7 to enable (>0) JSON Pretty Print on user interfaces and set number of indents 2025-04-17 15:55:05 +02:00
Theo Arends
cea46bb660 Bump version v14.6.0.1 2025-04-16 14:02:56 +02:00
Theo Arends
b67231483a Update TEMPLATES.md 2025-04-16 11:46:06 +02:00
Theo Arends
e6918d8b9c Fix ESP8266 IPv6 compilation 2025-04-16 11:35:06 +02:00
s-hadinger
7ea95ec6b2
Show network interface priority in 'Status 5' debug logging (#23302) 2025-04-15 13:21:14 +02:00
Theo Arends
8921a42f79 Add filesystem command `UfsList[2]` 2025-04-15 12:35:55 +02:00
Theo Arends
c8181e3290 Fix PZEM GUI address display 2025-04-14 16:13:59 +02:00
Theo Arends
117e503aaa Add PZEM_AC device address in JSON and GUI (#23268) 2025-04-14 15:24:02 +02:00
Theo Arends
3baa110f9d Add support for XMODEM over serial and telnet if enabled with #define USE_XYZMODEM 2025-04-14 13:54:05 +02:00
Theo Arends
a4096ab049 Update changelogs 2025-04-14 10:54:53 +02:00
Theo Arends
83118b9e05 Update changelogs 2025-04-14 10:52:54 +02:00
protectivedad
3a28938b91
HLK-LD2402 Update for firmware 3.3.5+ (#23281)
* Many changes for the newest firmware 3.3.5

added comments and debug lines
added new autogain function (fw 3.3.5+)
changed variables for consistency
ended configuration mode on error
fixed improper JSON response messages
changed timings for new firmware
consolidated post configuration processsing

* code size reduction
updated size extimates

* reworked to reduce code and memory usage

---------

Co-authored-by: Anthony Sepa <protectivedad@gmail.com>
2025-04-14 10:44:00 +02:00
s-hadinger
68f019cf43
HASPmota default theme is now Tasmota-style (#23288) 2025-04-13 23:23:51 +02:00
s-hadinger
4707cc068f
HASPmota added 'y2_min' and 'y2_max' to control the second series of 'chart' (#23287) 2025-04-13 21:54:43 +02:00
valentin richard
0604fac3bc
fix(zigbee): fix convertTuyaSpecificCluster datapoint parser -> support multiple data points in the same payload. (#23247)
Co-authored-by: valentin <email@example.com>
2025-04-12 19:12:32 +02:00
gemu
c12974366b
Sml update (#23267)
* rename nthll 64

* fix nthll 64
2025-04-11 15:16:05 +02:00
sfromis
cced48d824
Update uDisplay.h (#23273)
RGB565 value for pink was same as magenta. This is obviously wrong, hence correcting to the "pink" value from the docs.

While I'm far from certain about the "right" shading of color nuances, the correction does "reasonably pink" in my eyes (on a ST7789), and assuming that the value from the docs was sourced from something relevant to the small displays used with Tasmota, I consider the change to be at least a move in the right direction.

Still, the corrected value (FF80C0 in RGB888) does have the name "tea rose" when using HTML color codes as a reference, but "some people" may have more interest in long discussions like what pink "really" is.
2025-04-11 15:15:35 +02:00
Theo Arends
1a8903578f Update changelogs 2025-04-11 15:11:38 +02:00
Jason2866
230ce2c539
Platform 2025.04.30 Tasmota Arduino Core 3.1.3.250411 based on IDF 5.3.2.250403 (#23280) 2025-04-11 13:06:26 +02:00
Norbert
6b7606c958
Fix spelling (#23278) 2025-04-11 08:54:44 +02:00
jetpax
cfe1cee4d3
Replace brotli compressed file serving with gzip (#23274)
* Replace brotli compressed file serving with gzip as it is better supported

* Add HTTP_POST support
2025-04-10 23:12:37 +02:00
s-hadinger
2999eed8b9
Berry 'readline' when a line is exactly 98 characters (#23276) 2025-04-10 22:57:03 +02:00
Theo Arends
3f82228905 Fix MIEL_HVAC temperature saving 9k code size in addition (#23271) 2025-04-10 11:32:43 +02:00
s-hadinger
7ddf8abf90
Ensure AlpineJS is in PROGMEM (#23264) 2025-04-07 19:49:19 +02:00
Theo Arends
215b37bf69 Add Alpine.js 2.8.2 support (#23259) 2025-04-07 14:42:35 +02:00
Theo Arends
342bb2cb7b Update changelogs 2025-04-07 10:28:55 +02:00
s-hadinger
2096411be6
Fix esp_idf_http to make strings 'weak' (#23256) 2025-04-06 22:51:38 +02:00
jetpax
929582b1af
Expose esp_http_server to Berry (#23206)
* Expose esp_http_server to Berry

* Fix conditional build defines

* Fix Berry returns, dangling pointer

* Use correct Berry returns

* Remove debug code

* cleanup

* add BERRY to conditionals to avoid confusion
2025-04-06 22:27:48 +02:00
Thomas Büngener
4ed48feaa2
SML: CRC for binary SML (#23205)
* SML: CRC for binary SML parsing

* switch algos

* improve errormessage on buffer overflow

* move crc variable to their own struct

* Use Flag bit to disable CRC, auto-detect algorithm,
data in own struct
debug log

* configure and enable/disable via special option "=soC,bufsz,mode", mode 16 autodetect.

* fix 15 vs 0xF

* remove benchmark code

* fix typo in comment

* Byteflip for CRC
2025-04-05 11:22:22 +02:00
Theo Arends
c121dbcd4a Update changelogs 2025-04-05 11:21:03 +02:00
s-hadinger
e8baea464f
TLS increase timeout and fix crash (#23249) 2025-04-05 00:04:36 +02:00
Theo Arends
2bf67b96a6 Prep XYZModem support on Serial/USB and telnet 2025-04-01 23:15:28 +02:00
s-hadinger
0cb6a8ba24
Fix typo (#23232) 2025-04-01 23:10:30 +02:00
Theo Arends
39494f1287 Update changelogs 2025-04-01 23:10:08 +02:00
Qowy
90c690e67a
fix DIMMER ! to use correct dim value (#23196) 2025-04-01 22:57:58 +02:00
s-hadinger
08f20b9404
Smoothen light gamma curve when using Fade (#23230) 2025-04-01 22:51:56 +02:00
Theo Arends
dfabe8cc0f Update change logs 2025-03-31 11:49:57 +02:00
protectivedad
b43d360d37
fixes for ina226 driver (#23197)
adjust current/voltage timing to be consistent
fix missing comma in json

Co-authored-by: Anthony Sepa <protectivedad@gmail.com>
2025-03-31 11:45:59 +02:00
Theo Arends
2f7793ddcf Fix Zigbee XModem wait loop 2025-03-29 16:37:48 +01:00
Theo Arends
3c70b728ac Fix ESP32 compile without webserver 2025-03-28 13:58:22 +01:00
Theo Arends
289120ee92 Fix telnet buffer overrun detection 2025-03-28 12:16:32 +01:00
s-hadinger
b77b622fbe
Berry bytes add 3 (#23200)
* Berry bytes add with 3 bytes

* add changelog
2025-03-27 22:55:42 +01:00
s-hadinger
a47e6f1496
Berry avoid bootloop when Berry is disabled (#23199) 2025-03-27 21:08:32 +01:00
Theo Arends
74757ee7da Fix telnet response if seriallog is 0 2025-03-27 17:27:48 +01:00
Qowy
ea2baee3b8
fix fadeGammaReverse is applied to the time variable (#23194) 2025-03-27 10:17:43 +01:00
s-hadinger
f4bb9d98b6
HASPmota improve parsing (#23192) 2025-03-26 22:34:12 +01:00
Theo Arends
87b95f798a Extend command GPIO with different display options and allowing updating of module GPIO's in one go 2025-03-26 16:43:13 +01:00
Theo Arends
da4dc56b16 Bump version v14.5.0.3 2025-03-25 17:04:44 +01:00
Theo Arends
714ad233e0 Changed output of commands GPIO and GPIOs swapped 2025-03-25 16:53:26 +01:00
protectivedad
2da631e442
missing edits for last commit (#23185)
Co-authored-by: Anthony Sepa <protectivedad@gmail.com>
2025-03-25 15:22:27 +01:00
Theo Arends
6f47f23f7a Add terminate telnet session with command exit or quit 2025-03-25 13:47:41 +01:00
Theo Arends
69fca99ac1 Add telnet compile options 2025-03-25 11:19:53 +01:00
Theo Arends
a3b564f4f3 Keep telnet output while serial logging was disabled 2025-03-24 12:16:35 +01:00
Theo Arends
52f3306f15 Disable telnet output colors on command TelnetColor 0 2025-03-24 12:04:01 +01:00
Theo Arends
9d6640a42e Change command TelnetColor 0 to disable color codes from output 2025-03-24 10:57:48 +01:00
Theo Arends
307e1d9c29 Fix telnet line length regression 2025-03-23 22:36:42 +01:00
Theo Arends
f71ca3e0a2 Fix ESP32 telnet response 2025-03-23 17:34:44 +01:00
Theo Arends
a3d86eebf0 Telnet more functional bling bling 2025-03-23 13:23:03 +01:00
s-hadinger
f331a64ac3
HASPmota autostart when pages.jsonl exists (#23181) 2025-03-22 23:23:57 +01:00
Theo Arends
caac9f1257 Reduce telnet stack usage fixing ESP8266 exceptions 2025-03-22 17:33:27 +01:00
Theo Arends
b47a1bc1e2 Fix telnet async input 2025-03-22 12:04:02 +01:00
Qowy
9e3ad52356
fix wrong comment in xdrv_79_esp32_ble.ino (#23171) 2025-03-22 10:30:20 +01:00
protectivedad
38ceafe789
upgrades and fixes for HLK-LD2402 driver (#23164)
Co-authored-by: Anthony Sepa <protectivedad@gmail.com>
2025-03-22 10:28:15 +01:00
Theo Arends
ddc1439edf Fix webcam updatestats 2025-03-22 10:23:15 +01:00
DavidPletcher
3827bca3cc
remove malformed clutter from webcam status0 JSON response (#23177)
A regression was added in commit 01154e949, which prepends
clutter to the status0 JSON status message.

Example:
```
$ curl 'http://webcam/cm?cmnd=Status0' -u admin:password ; echo
{s}Webcam Frame rate{m}0 FPS{e}{"Status":{"Module":0,"DeviceName":"...
```

The response is not properly formatted JSON and breaks client software.

The problem occurs because a new case statement was added for the
purpose of injecting webcam stats into the JSON status message, but
a break statement is missing and execution falls through to the
following case, which prepends garbage to the output buffer.

With this one-line fix in place, the output is properly formatted:
```
$ curl 'http://tahoe-front-door-cam/cm?cmnd=Status0' -u admin:password ; echo
{"Status":{"Module":0,"DeviceName":"
```

Note that the prior case for FUNC_EVERY_SECOND is also missing a break
statement. That looks wrong to me but it's unrelated to fixing this
issue and I'm inclined to punt that concern to others who are more
familiar with this code.
2025-03-22 08:18:01 +01:00
Theo Arends
8183a9ed3b Add telnet bling bling 2025-03-21 23:41:01 +01:00
Theo Arends
00e2d1d430 Fix filelog and save some bytes 2025-03-21 17:29:04 +01:00
Theo Arends
863c6d1214 Fix telnet regression 2025-03-21 16:49:25 +01:00
Theo Arends
73cace5274 Add telnet graceful close 2025-03-21 16:38:26 +01:00
aronk
1ada6da6b8
[MI BLE] added support for alternative version of LYWSD02MMC (#23169)
* [MI BLE] added support for alternative version of LYWSD02MMC

* Bumped MI32_VERSION to 0.9.2.5
2025-03-21 14:30:17 +01:00
Theo Arends
fbb752d8c2 Add Telnet server using command Telnet <0|1|port>[,<IP filter>] 2025-03-20 23:11:30 +01:00
Theo Arends
fb6640b91f Fix ESP32 receive incomplete serial data over 128 bytes (#23156) 2025-03-18 15:12:30 +01:00
s-hadinger
c0d15de965
Berry 're.dump()' (#23162) 2025-03-17 21:34:59 +01:00
Theo Arends
3764e88ed2 Merge branch 'development' of https://github.com/arendst/Tasmota into development 2025-03-17 14:06:02 +01:00
Theo Arends
0ea1f8e632 Change RCSwitch RCSWITCH_SEPARATION_LIMIT from 4100 to 3600 2025-03-17 14:05:38 +01:00
Jason2866
234c5ea170
check fw size against partition (#23160) 2025-03-17 13:59:25 +01:00
s-hadinger
ce92723c41
Berry update from upstream (#23159) 2025-03-17 08:27:03 +01:00
s-hadinger
e1f7ee26fa
Matter prepare for ICD cluster (#23158) 2025-03-16 22:38:36 +01:00
s-hadinger
a97d306a16
Berry include changes in 're' to HASPmota (#23153) 2025-03-15 18:58:21 +01:00
Theo Arends
508992258f Update changelogs 2025-03-14 11:39:59 +01:00
s-hadinger
1b51aef911
Berry now accepts 'bytes()' as precompiled patterns, added 're.compilebytes()' (#23149) 2025-03-13 23:38:55 +01:00
s-hadinger
6486ba3b26
Fix typo of be_set_ctype_func_hanlder (#23147) 2025-03-13 17:49:28 +01:00
Bartosz Nitka
9b4eb64caa
Fix unused ret_code2 in xdrv_52_9_berry (#23146) 2025-03-13 17:22:21 +01:00
bovirus
6d376a079e
Italian language update (#23144) 2025-03-12 19:00:50 +01:00
protectivedad
69c3863b14
HLK-LD2402 fix for missing '|' (#23142)
Signed-off-by: Anthony Sepa <protectivedad@gmail.com>
Co-authored-by: Anthony Sepa <protectivedad@gmail.com>
2025-03-12 15:26:02 +01:00
Theo Arends
ac8236abe1 Update changelogs 2025-03-12 11:31:00 +01:00
s-hadinger
16e9d105ba
Update flasher for Sonoff ZBBridge Pro (#23136) 2025-03-11 23:04:51 +01:00
protectivedad
f3ae3bec4b
Added support for hlk-ld2402 tasmota_xsns_sensor (#23133)
This is based on the xsns_102_ld2410s.ino.

* Available commands:
* LD2402_Status 0|1|2 - showing parameters|sensor readings|firmware info
* LD2402_ReRead - reread common, motion and micro threshold parameters from device
* LD2402_SetCommon 7-100,0-65535 - set common: maximum distance, disappearance delay
* LD2402_SetMotion n,n1..n16 - set motion threshold values (16)
* LD2402_SetMicro n,n1..n16 - set micro threshold values (16)
* LD2402_Mode 0/1 - set device output mode 0-normal, 1-engineering
* LD2402_AutoUpdate 3.0,2.0,3.0 - start autoupdate trigger,keep,micro magnification factor
* LD2402_Follow 0/n - reports every n seconds

Signed-off-by: Anthony Sepa <protectivedad@gmail.com>
Co-authored-by: Anthony Sepa <protectivedad@gmail.com>
2025-03-11 17:03:54 +01:00
Theo Arends
cae4551762 Fix ESP32 compilation V9240 2025-03-11 15:12:02 +01:00
Theo Arends
007608914c Support Vango Technologies V924x ultralow power, single-phase, power measurement (#23127) 2025-03-11 14:57:11 +01:00
Ivan Chopa
758ba17dde
Added V9240 energy metering chip driver (#23127)
* Add V9240 driver

* Addendum to previous commit

* Add driver code similar to the prototype

* they are talking to each other

* Added implementation of calibration commands

* continued work of calibration

* Maybe it works.

* Post-merger control

* Change driver number 34 to 25

* Correction of other comments

* Removed  duplicate code

* Adjusting the calibration procedure according to the behavior stated here. To the extent possible.
https://tasmota.github.io/docs/Power-Monitoring-Calibration/#calibration-procedure

* Removed added trailing whitespaces

* Fixing several small issues.
2025-03-11 14:28:07 +01:00
Giuliano
08fae4bcd6
typo fix (#23122) 2025-03-11 11:32:00 +01:00
s-hadinger
f305113d6d
Removed USE_WEBCLIENT and default USE_WEBCLIENT_HTTPS (#23132) 2025-03-10 22:37:27 +01:00
Marius Bezuidenhout
7b8d2fe93d
BMS additional features (#23125)
* Added more data from BMS

* Updated mcp2515 code
2025-03-09 16:27:10 +01:00
Giuliano
714435be1c
Remove misleading comment (#23124) 2025-03-09 13:42:44 +01:00
Theo Arends
e3eb47078f Fix ESP32 intermittent exception on WiFi AP cannot be reached (#23115) 2025-03-08 15:19:45 +01:00
Jason2866
a0c8ac4f80
enable FTP for all esp8266 >= 4MB (not only for 4MB variant) (#23120) 2025-03-08 13:07:58 +01:00
Jason2866
c926b4b3a6
enable wifi sleep for c3 (#23117) 2025-03-07 14:43:31 +01:00
s-hadinger
3f93d2deee
Berry remove 'Leds.create_matrix' from the standard library waiting for reimplementation (#23114) 2025-03-06 23:11:16 +01:00
s-hadinger
06aa356bc3
Berry load files in '/.extensions/' then in '/' (#23113) 2025-03-06 21:15:59 +01:00
Theo Arends
58632d67db Update changelogs 2025-03-06 16:17:54 +01:00
s-hadinger
e26a2cdac9
Berry prevent 'import' from hiding a solidified class (#23112) 2025-03-06 14:45:34 +01:00
Jason2866
72535db185
prep Hybrid: add Hybrid compile examples (#22474) 2025-03-05 14:27:47 +01:00
Theo Arends
f2bf8b96e7 Increase rcswitch H/L changes to 64 bits 2025-03-05 12:32:07 +01:00
Theo Arends
549ca6e32f ESP32 enable webcam version 2 (#18732) 2025-03-04 10:16:13 +01:00
Theo Arends
72520e0743 Bump version v14.5.0.2 2025-03-02 16:17:07 +01:00
Jason2866
aed82dc8b2
Platform 20250330 (#23088)
* Platform 2025.03.30 Tasmota Arduino Core 3.1.3.250302 based on IDF 5.3.2.250228

* Arduino core 3.1.3.250302
2025-03-02 16:04:56 +01:00
gemu
2e35a2ab93
some fixes and formatting (#23084) 2025-03-01 15:11:35 +01:00
Jason2866
3c171c1ed8
Compile lib NeopixelBus only for esp8266 (#23077)
* force mode strict for pixels lib
* Use lib NeoPixelBus only for esp8266
2025-02-27 12:15:20 +01:00
Theo Arends
481f2cd8e1 Update changelogs 2025-02-26 17:22:13 +01:00
s-hadinger
9a98db9773
Berry 'global.undef()' to undefine a global variable (#23073) 2025-02-26 15:30:04 +01:00
s-hadinger
e92e411040
Berry minor fixes to remove warnings (#23071) 2025-02-25 22:28:13 +01:00
s-hadinger
aecba92da4
Update be_mapping_utils.c, add final newline to avoid compilation warning 2025-02-25 21:14:09 +01:00
zzdovydas
4ee4b5908f
Fix LT Language (#22971) (#23064) 2025-02-25 11:19:43 +01:00
Theo Arends
3f74bc83e5 Update changelogs / gpioviewer / wizmote 2025-02-24 15:23:59 +01:00
Theo Arends
fd0501035d Update changelogs 2025-02-24 14:51:29 +01:00
s-hadinger
670fab7ead
Berry 'introspect.solidified()' to know if a Berry object is solidified in Flash or in RAM (#23063)
* Berry 'introspect.isconst()' to know if a Berry object is solidified or in RAM

* change to solidified

* fix typo
2025-02-24 14:05:58 +01:00
s-hadinger
375864b23b
Berry 'tasmota.when_network_up()' and simplified Matter using it (#23057) 2025-02-23 19:19:42 +01:00
Jason2866
788ac574ac
remove tagging gemu2015 for every opened bug report 2025-02-23 14:27:42 +01:00
Theo Arends
5aa7d08c91 Fix too many zeros in RCSwitch received data regression from v14.4.1.4 (#23050) 2025-02-23 13:54:39 +01:00
Theo Arends
b4c61325cb Add optional WizMote commission 2025-02-22 18:12:36 +01:00
Theo Arends
d10eafc500 Update changelogs 2025-02-22 15:22:20 +01:00
Theo Arends
90ebff552d Update changelogs 2025-02-22 15:01:37 +01:00
s-hadinger
0c26698ba6
Leds Panel add checkbox to enable/disable the feature (#23048) 2025-02-22 12:33:34 +01:00
s-hadinger
1db796c40f
LVGL Mirroring add checkbox to enable/disable the feature (#23047) 2025-02-22 12:00:36 +01:00
s-hadinger
b8459eb685
LVGL Berry fix lvgl_berry_fix_lv_style_prop_arr (#23042) 2025-02-21 09:15:03 +01:00
Giuliano Zaro
b1f3d6268d
Allow acl in mqtt when client certificate is in use (#22998)
* Allow acl in mqtt

Acl in mqtt needs user name if 'use_identity_as_username' is not true. It also seems that login in mqtt don't accept an user with an empty password, then reenabled both

* Add new define for mosquitto

Keep compatibility with AWS_IOT

* Better approach to custom client certificate

Don't duplicate defined check. Let USE_MQTT_AWS_IOT automatically set USE_MQTT_CLIENT_CERT and use latter in all code

* with mosquitto user and password may be empty

When mosquitto 'use_identity_as_username' option is enabled password and user are not used
2025-02-20 22:51:52 +01:00
s-hadinger
7a4d8a5fb1
LVGL experimental mirroring of display on Web UI (#23041) 2025-02-20 21:45:45 +01:00
s-hadinger
0ab5548615
LVGL, prepare for HASPmota theme, change: no-grow when clicked, DPI set to 160 (#23040) 2025-02-20 21:13:35 +01:00
s-hadinger
1af1057e66
Berry experimental driver for AXP2101 for M5Core2v1.1 (#23039) 2025-02-20 20:40:53 +01:00
Jason2866
039960153a
typo C3 not C2 2025-02-20 15:01:37 +01:00
Theo Arends
b4c1cd654f Bump version v14.5.0.1 2025-02-18 16:14:27 +01:00
1421 changed files with 214438 additions and 45026 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,704 @@
# Berry for Tasmota
This document covers Tasmota-specific Berry features and extensions, complementing the general Berry language reference.
## Introduction
Berry is the next generation scripting language for Tasmota, embedded by default in all ESP32 based firmwares (NOT supported on ESP8266). It is used for advanced scripting, superseding Rules, and enables building drivers, automations, and UI extensions.
## Tasmota-Specific Modules
Beyond standard Berry modules, Tasmota provides additional modules:
| Module | Description | Import |
|--------|-------------|--------|
| `tasmota` | Core integration module | Automatically imported |
| `light` | Light control | Automatically imported |
| `mqtt` | MQTT operations | `import mqtt` |
| `webserver` | Web server extensions | `import webserver` |
| `gpio` | GPIO control | `import gpio` |
| `persist` | Data persistence | `import persist` |
| `path` | File system operations | `import path` |
| `energy` | Energy monitoring | Automatically imported |
| `display` | Display driver integration | `import display` |
| `crypto` | Cryptographic functions | `import crypto` |
| `re` | Regular expressions | `import re` |
| `mdns` | mDNS/Bonjour support | `import mdns` |
| `ULP` | Ultra Low Power coprocessor | `import ULP` |
| `uuid` | UUID generation | `import uuid` |
| `crc` | CRC calculations | `import crc` |
## Additional Resources
For Tasmota-specific Berry features and extensions, please refer to the companion document `BERRY_TASMOTA.md`.
### Tasmota Constants and Enums
```berry
# GPIO constants (gpio module)
gpio.INPUT, gpio.OUTPUT, gpio.PULLUP, gpio.PULLDOWN
gpio.HIGH, gpio.LOW
gpio.REL1, gpio.KEY1, gpio.LED1, gpio.I2C_SCL, gpio.I2C_SDA
# ... many more GPIO function constants
# Serial constants
serial.SERIAL_8N1, serial.SERIAL_7E1, etc.
# Webserver constants
webserver.HTTP_GET, webserver.HTTP_POST, webserver.HTTP_OPTIONS, webserver.HTTP_ANY
webserver.HTTP_OFF, webserver.HTTP_USER, webserver.HTTP_ADMIN, webserver.HTTP_MANAGER
webserver.HTTP_MANAGER_RESET_ONLY
webserver.BUTTON_MAIN, webserver.BUTTON_CONFIGURATION, webserver.BUTTON_INFORMATION
webserver.BUTTON_MANAGEMENT, webserver.BUTTON_MODULE
```
### Console and REPL
Access Berry console via *Configuration**Berry Scripting Console*. The console supports:
- Multi-line input (press Enter twice or click "Run")
- Command history (arrow keys)
- Colorful syntax highlighting
- Berry VM restart with `BrRestart` command
### File System and Loading
Berry files can be source (`.be`) or pre-compiled bytecode (`.bec`):
```berry
load("filename") # Loads .be or .bec file
tasmota.compile("file.be") # Compiles .be to .bec
```
**Autostart**: Place `autoexec.be` in filesystem to run Berry code at boot.
### Tasmota Integration Functions
#### Core Tasmota Functions
```berry
# System information
tasmota.get_free_heap() # Free heap bytes
tasmota.memory() # Memory stats map
tasmota.arch() # Architecture: "esp32", "esp32s2", etc.
tasmota.millis() # Milliseconds since boot
tasmota.yield() # Give time to low-level functions
tasmota.delay(ms) # Block execution for ms milliseconds
# Commands and responses
tasmota.cmd("command") # Execute Tasmota command
tasmota.resp_cmnd_done() # Respond "Done"
tasmota.resp_cmnd_error() # Respond "Error"
tasmota.resp_cmnd_str(msg) # Custom response string
tasmota.resp_cmnd(json) # Custom JSON response
# Configuration
tasmota.get_option(index) # Get SetOption value
tasmota.read_sensors() # Get sensor JSON string
tasmota.wifi() # WiFi connection info
tasmota.eth() # Ethernet connection info
```
#### Rules and Events
```berry
# Add rules (similar to Tasmota Rules but more powerful)
tasmota.add_rule("trigger", function)
tasmota.add_rule(["trigger1", "trigger2"], function) # AND logic
tasmota.remove_rule("trigger")
# Rule function signature
def rule_function(value, trigger, msg)
# value: trigger value (%value% equivalent)
# trigger: full trigger string
# msg: parsed JSON map or original string
end
# Examples
tasmota.add_rule("Dimmer>50", def() print("Bright!") end)
tasmota.add_rule("ANALOG#A1>300", def(val) print("ADC:", val) end)
```
#### Timers and Scheduling
```berry
# Timers (50ms resolution)
tasmota.set_timer(delay_ms, function)
tasmota.remove_timer(id)
tasmota.defer(function) # Run in next millisecond
# Cron scheduling
tasmota.add_cron("*/15 * * * * *", function, "id")
tasmota.remove_cron("id")
tasmota.next_cron("id") # Next execution timestamp
# Time functions
tasmota.rtc() # Current time info
tasmota.time_dump(timestamp) # Decompose timestamp
tasmota.time_str(timestamp) # ISO 8601 string
tasmota.strftime(format, timestamp)
tasmota.strptime(time_str, format)
```
#### Device Control
```berry
# Relays and Power
tasmota.get_power() # Array of relay states
tasmota.set_power(idx, state) # Set relay state
# Lights (use light module)
light.get() # Current light status
light.set({"power": true, "bri": 128, "hue": 120})
# Light attributes: power, bri (0-255), hue (0-360), sat (0-255),
# ct (153-500), rgb (hex string), channels (array)
```
#### Custom Commands
```berry
# Add custom Tasmota commands
def my_command(cmd, idx, payload, payload_json)
# cmd: command name, idx: command index
# payload: raw string, payload_json: parsed JSON
tasmota.resp_cmnd_done()
end
tasmota.add_cmd("MyCmd", my_command)
tasmota.remove_cmd("MyCmd")
```
### Tasmota Drivers
Create complete Tasmota drivers by implementing event methods:
```berry
class MyDriver
def every_second() # Called every second
end
def every_50ms() # Called every 50ms
end
def web_sensor() # Add to web UI
tasmota.web_send("{s}Sensor{m}Value{e}")
end
def json_append() # Add to JSON teleperiod
tasmota.response_append(',"MySensor":{"Value":123}')
end
def web_add_main_button() # Add button to main page
import webserver
webserver.content_send("<button onclick='la(\"&myaction=1\");'>My Button</button>")
end
def button_pressed() # Handle button press
end
def mqtt_data(topic, idx, data, databytes) # Handle MQTT
end
def save_before_restart() # Before restart
end
end
# Register driver
driver = MyDriver()
tasmota.add_driver(driver)
```
### Fast Loop
For near real-time events (200Hz, 5ms intervals):
```berry
def fast_function()
# High-frequency processing
end
tasmota.add_fast_loop(fast_function)
tasmota.remove_fast_loop(fast_function)
```
### GPIO Control
```berry
import gpio
# GPIO detection and control
gpio.pin_used(gpio.REL1) # Check if GPIO is used
gpio.pin(gpio.REL1) # Get physical GPIO number
gpio.digital_write(pin, gpio.HIGH) # Set GPIO state
gpio.digital_read(pin) # Read GPIO state
gpio.pin_mode(pin, gpio.OUTPUT) # Set GPIO mode
# PWM control
gpio.set_pwm(pin, duty, phase) # Set PWM value
gpio.set_pwm_freq(pin, freq) # Set PWM frequency
# DAC (ESP32 GPIO 25-26, ESP32-S2 GPIO 17-18)
gpio.dac_voltage(pin, voltage_mv) # Set DAC voltage
# Counters
gpio.counter_read(counter) # Read counter value
gpio.counter_set(counter, value) # Set counter value
```
### I²C Communication
```berry
# Use wire1 or wire2 for I²C buses
wire1.scan() # Scan for devices
wire1.detect(addr) # Check if device present
wire1.read(addr, reg, size) # Read from device
wire1.write(addr, reg, val, size) # Write to device
wire1.read_bytes(addr, reg, size) # Read as bytes
wire1.write_bytes(addr, reg, bytes) # Write bytes
# Find device on any bus
wire = tasmota.wire_scan(addr, i2c_index)
```
### MQTT Integration
```berry
import mqtt
# MQTT operations
mqtt.publish(topic, payload, retain)
mqtt.subscribe(topic, function) # Subscribe with callback
mqtt.unsubscribe(topic)
mqtt.connected() # Check connection status
# Callback function signature
def mqtt_callback(topic, idx, payload_s, payload_b)
# topic: full topic, payload_s: string, payload_b: bytes
return true # Return true if handled
end
```
### Web Server Extensions
```berry
import webserver
# In driver's web_add_handler() method
webserver.on("/my_page", def()
webserver.content_send("<html>My Page</html>")
end)
# Request handling
webserver.has_arg("param") # Check parameter exists
webserver.arg("param") # Get parameter value
webserver.arg_size() # Number of parameters
# Response functions
webserver.content_send(html) # Send HTML content
webserver.content_button() # Standard button
webserver.html_escape(str) # Escape HTML
```
### Persistence
```berry
import persist
# Automatic persistence to _persist.json
persist.my_value = 123
persist.save() # Force save to flash
persist.has("key") # Check if key exists
persist.remove("key") # Remove key
persist.find("key", default) # Get with default
```
### Network Clients
#### HTTP/HTTPS Client
```berry
cl = webclient()
cl.begin("https://example.com/api")
cl.set_auth("user", "pass")
cl.add_header("Content-Type", "application/json")
result = cl.GET() # or POST(payload)
if result == 200
response = cl.get_string()
# or cl.write_file("filename") for binary
end
cl.close()
```
#### TCP Client
```berry
tcp = tcpclient()
tcp.connect("192.168.1.100", 80)
tcp.write("GET / HTTP/1.0\r\n\r\n")
response = tcp.read()
tcp.close()
```
#### UDP Communication
```berry
u = udp()
u.begin("", 2000) # Listen on port 2000
u.send("192.168.1.10", 2000, bytes("Hello"))
# Receive (polling)
packet = u.read() # Returns bytes or nil
if packet
print("From:", u.remote_ip, u.remote_port)
end
```
### Serial Communication
```berry
ser = serial(rx_gpio, tx_gpio, baud, serial.SERIAL_8N1)
ser.write(bytes("Hello")) # Send data
data = ser.read() # Read available data
ser.available() # Check bytes available
ser.flush() # Flush buffers
ser.close() # Close port
```
### Cryptography
```berry
import crypto
# AES encryption
aes = crypto.AES_GCM(key_32_bytes, iv_12_bytes)
encrypted = aes.encrypt(plaintext)
tag = aes.tag()
# Hashing
crypto.SHA256().update(data).finish() # SHA256 hash
crypto.MD5().update(data).finish() # MD5 hash
# HMAC
crypto.HMAC_SHA256(key).update(data).finish()
```
### File System Operations
```berry
import path
path.exists("filename") # Check file exists
path.listdir("/") # List directory
path.remove("filename") # Delete file
path.mkdir("dirname") # Create directory
path.last_modified("file") # File timestamp
```
### Regular Expressions
```berry
import re
# Pattern matching
matches = re.search("a.*?b(z+)", "aaaabbbzzz") # Returns matches array
all_matches = re.searchall('<([a-zA-Z]+)>', html) # All matches
parts = re.split('/', "path/to/file") # Split string
# Compiled patterns (faster for reuse)
pattern = re.compilebytes("\\d+")
matches = re.search(pattern, "abc123def")
```
### Energy Monitoring
```berry
# Read energy values
energy.voltage # Main phase voltage
energy.current # Main phase current
energy.active_power # Active power (W)
energy.total # Total energy (kWh)
# Multi-phase access
energy.voltage_phases[0] # Phase 0 voltage
energy.current_phases[1] # Phase 1 current
# Berry energy driver (with OPTION_A 9 GPIO)
if energy.driver_enabled()
energy.voltage = 240
energy.current = 1.5
energy.active_power = 360 # This drives energy calculation
end
```
### Display Integration
```berry
import display
# Initialize display driver
display.start(display_ini_string)
display.started() # Check if initialized
display.dimmer(50) # Set brightness 0-100
display.driver_name() # Get driver name
# Touch screen updates
display.touch_update(touches, x, y, gesture)
```
### Advanced Features
#### ULP (Ultra Low Power) Coprocessor
```berry
import ULP
ULP.wake_period(0, 500000) # Configure wake timer
ULP.load(bytecode) # Load ULP program
ULP.run() # Execute ULP program
ULP.set_mem(addr, value) # Set RTC memory
ULP.get_mem(addr) # Get RTC memory
```
#### mDNS Support
```berry
import mdns
mdns.start("hostname") # Start mDNS
mdns.add_service("_http", "_tcp", 80, {"path": "/"})
mdns.stop() # Stop mDNS
```
### Error Handling Patterns
Many Tasmota functions return `nil` for errors rather than raising exceptions:
```berry
# Check return values
data = json.load(json_string)
if data == nil
print("Invalid JSON")
end
# Wire operations
result = wire1.read(addr, reg, 1)
if result == nil
print("I2C read failed")
end
```
### Best Practices for Tasmota
1. **Memory Management**: Use `tasmota.gc()` to monitor memory usage
2. **Non-blocking**: Use timers instead of `delay()` for long waits
3. **Error Handling**: Always check return values for `nil`
4. **Persistence**: Use `persist` module for settings that survive reboots
5. **Performance**: Use fast_loop sparingly, prefer regular driver events
6. **Debugging**: Enable `#define USE_BERRY_DEBUG` for development
## Common Tasmota Berry Patterns
### Simple Sensor Driver
```berry
class MySensor
var wire, addr
def init()
self.addr = 0x48
self.wire = tasmota.wire_scan(self.addr, 99) # I2C index 99
if self.wire
print("MySensor found on bus", self.wire.bus)
end
end
def every_second()
if !self.wire return end
var temp = self.wire.read(self.addr, 0x00, 2) # Read temperature
self.temperature = temp / 256.0 # Convert to Celsius
end
def web_sensor()
if !self.wire return end
import string
var msg = string.format("{s}MySensor Temp{m}%.1f °C{e}", self.temperature)
tasmota.web_send_decimal(msg)
end
def json_append()
if !self.wire return end
import string
var msg = string.format(',"MySensor":{"Temperature":%.1f}', self.temperature)
tasmota.response_append(msg)
end
end
sensor = MySensor()
tasmota.add_driver(sensor)
```
### Custom Command with JSON Response
```berry
def my_status_cmd(cmd, idx, payload, payload_json)
import string
var response = {
"Uptime": tasmota.millis(),
"FreeHeap": tasmota.get_free_heap(),
"WiFi": tasmota.wifi("rssi")
}
tasmota.resp_cmnd(json.dump(response))
end
tasmota.add_cmd("MyStatus", my_status_cmd)
```
### MQTT Automation
```berry
import mqtt
def handle_sensor_data(topic, idx, payload_s, payload_b)
var data = json.load(payload_s)
if data && data.find("temperature")
var temp = data["temperature"]
if temp > 25
tasmota.cmd("Power1 ON") # Turn on fan
elif temp < 20
tasmota.cmd("Power1 OFF") # Turn off fan
end
end
return true
end
mqtt.subscribe("sensors/+/temperature", handle_sensor_data)
```
### Web UI Button with Action
```berry
class WebButton
def web_add_main_button()
import webserver
webserver.content_send("<p><button onclick='la(\"&toggle_led=1\");'>Toggle LED</button></p>")
end
def web_sensor()
import webserver
if webserver.has_arg("toggle_led")
# Toggle GPIO2 (built-in LED on many ESP32 boards)
var pin = 2
var current = gpio.digital_read(pin)
gpio.digital_write(pin, !current)
print("LED toggled to", !current)
end
end
end
button = WebButton()
tasmota.add_driver(button)
```
### Scheduled Task with Persistence
```berry
import persist
class ScheduledTask
def init()
if !persist.has("task_count")
persist.task_count = 0
end
# Run every 5 minutes
tasmota.add_cron("0 */5 * * * *", /-> self.run_task(), "my_task")
end
def run_task()
persist.task_count += 1
print("Task executed", persist.task_count, "times")
# Do something useful
var sensors = tasmota.read_sensors()
print("Current sensors:", sensors)
persist.save() # Save counter to flash
end
end
task = ScheduledTask()
```
### HTTP API Client
```berry
class WeatherAPI
var api_key, city
def init(key, city_name)
self.api_key = key
self.city = city_name
tasmota.add_cron("0 0 * * * *", /-> self.fetch_weather(), "weather")
end
def fetch_weather()
var cl = webclient()
var url = f"http://api.openweathermap.org/data/2.5/weather?q={self.city}&appid={self.api_key}"
cl.begin(url)
var result = cl.GET()
if result == 200
var response = cl.get_string()
var data = json.load(response)
if data
var temp = data["main"]["temp"] - 273.15 # Kelvin to Celsius
print(f"Weather in {self.city}: {temp:.1f}°C")
# Store in global for other scripts to use
import global
global.weather_temp = temp
end
end
cl.close()
end
end
# weather = WeatherAPI("your_api_key", "London")
```
### Rule-based Automation
```berry
# Advanced rule that combines multiple conditions
tasmota.add_rule(["ANALOG#A0>500", "Switch1#State=1"],
def(values, triggers)
print("Both conditions met:")
print("ADC value:", values[0])
print("Switch state:", values[1])
tasmota.cmd("Power2 ON") # Activate something
end
)
# Time-based rule
tasmota.add_rule("Time#Minute=30",
def()
if tasmota.rtc()["hour"] == 18 # 6:30 PM
tasmota.cmd("Dimmer 20") # Dim lights for evening
end
end
)
```
## Best Practices and Tips
1. **Always check for nil returns** from Tasmota functions
2. **Use timers instead of delay()** to avoid blocking Tasmota
3. **Implement proper error handling** in I²C and network operations
4. **Use persist module** for settings that should survive reboots
5. **Test memory usage** with `tasmota.gc()` during development
6. **Use fast_loop sparingly** - it runs 200 times per second
7. **Prefer driver events** over polling when possible
8. **Use f-strings** for readable string formatting
9. **Import modules only when needed** to save memory
10. **Use `tasmota.wire_scan()`** instead of manual I²C bus detection

View File

@ -0,0 +1,175 @@
# Deep Analysis of Tasmota Documentation Repository
This file is a summary of the Tasmota Documentation for the "docs" repository. It is provided here for convenience for GenAI to read it easily.
## Overview
Tasmota is a comprehensive open-source firmware for ESP8266/ESP8285 and ESP32-based IoT devices that provides local control, MQTT integration, and extensive customization capabilities. The documentation repository contains over 250 markdown files covering every aspect of the firmware, from basic installation to advanced development topics.
## Repository Structure
The documentation is organized into several key categories:
### Core Documentation
- **Getting Started**: Complete setup guide from hardware preparation to initial configuration
- **Commands**: Comprehensive reference of 200+ commands for device control
- **MQTT**: Central communication protocol documentation
- **Rules**: Flexible automation system documentation
- **Templates**: Device configuration system
- **Components**: GPIO mapping and peripheral management
### Hardware Support
- **ESP Platforms**: ESP8266, ESP8285, ESP32 (all variants including S2, S3, C3)
- **Supported Devices**: 125+ device-specific configuration files
- **Peripherals**: 85+ sensor and peripheral drivers documented
- **Pinouts**: Detailed GPIO mappings for common modules
### Advanced Features
- **Berry Scripting**: Modern scripting language for ESP32 (163KB documentation)
- **Scripting Language**: Legacy scripting for ESP8266 (93KB documentation)
- **Matter Protocol**: Thread/Matter support for modern IoT ecosystems
- **Zigbee**: Zigbee2Tasmota gateway functionality (100KB documentation)
- **Bluetooth**: BLE sensor integration and device control
### Integration Ecosystem
- **Home Assistant**: Native integration with autodiscovery
- **OpenHAB**: Configuration examples and best practices
- **Domoticz**: Integration guide
- **KNX**: Building automation protocol support
- **AWS IoT**: Cloud integration with certificates
- **Azure IoT**: Microsoft cloud platform integration
## Key Technical Insights
### Architecture Philosophy
Tasmota follows a modular architecture where:
- Core firmware provides basic functionality (WiFi, MQTT, web interface)
- Features are conditionally compiled based on `#define` directives
- GPIO mapping is completely flexible through templates
- All functionality is controllable via commands (MQTT, HTTP, serial, web console)
### Memory Management
- ESP8266: 80KB RAM total, ~25-30KB available for applications
- ESP32: Much more generous memory, supports advanced features
- Code size optimization is critical for ESP8266 OTA updates
- Flash memory partitioned for dual-boot OTA capability
### Communication Protocols
1. **MQTT** (Primary): All device control and telemetry
2. **HTTP**: Web interface and REST API
3. **Serial**: Direct console access
4. **WebSocket**: Real-time web interface updates
### Extensibility Mechanisms
1. **Rules**: Event-driven automation (up to 1536 characters)
2. **Berry Scripts**: Full programming language (ESP32 only)
3. **Scripting**: Legacy scripting system (ESP8266)
4. **Templates**: Device configuration sharing
5. **Custom Drivers**: C++ sensor/peripheral drivers
## Development Ecosystem
### Build System
- PlatformIO-based compilation
- Multiple build environments for different ESP variants
- Conditional compilation for feature selection
- OTA update system with safety mechanisms
### Driver Development
- Standardized sensor API with callback system
- I2C/SPI/UART peripheral support
- Memory-conscious development practices
- Extensive debugging and profiling tools
### Scripting Capabilities
- **Berry**: Modern language with object-oriented features, garbage collection
- **Rules**: Simple trigger-action automation
- **Legacy Scripting**: Procedural language for complex automation
### Integration APIs
- **JSON Status Responses**: Standardized telemetry format
- **Command Interface**: Unified control mechanism
- **Sensor API**: Standardized peripheral integration
- **Web Interface Extensions**: Custom UI components
## Notable Features
### Advanced Networking
- IPv6 support
- Wireguard VPN client
- Range extender functionality (NAPT)
- Multiple WiFi network support
- Ethernet support (ESP32)
### Security Features
- TLS/SSL support (ESP32)
- Certificate-based authentication
- Secure boot options
- Network isolation capabilities
### Display and UI
- Universal Display Driver supporting 50+ display types
- LVGL graphics library integration
- HASPmota: Advanced touch interface system
- Web interface customization
### Industrial Features
- Modbus bridge functionality
- KNX building automation
- Smart meter interfaces (P1, Teleinfo)
- Industrial sensor support (4-20mA, etc.)
## Documentation Quality Assessment
### Strengths
- **Comprehensive Coverage**: Every feature documented with examples
- **Practical Focus**: Heavy emphasis on real-world usage scenarios
- **Community-Driven**: Active contribution from users and developers
- **Multi-Level**: From beginner tutorials to advanced development guides
- **Well-Structured**: Logical organization with cross-references
### Areas for Improvement
- **Fragmentation**: Some information scattered across multiple files
- **Version Consistency**: Some docs may lag behind rapid development
- **Advanced Topics**: Some complex features could use more examples
## Community and Ecosystem
### Support Channels
- Discord server for real-time help
- GitHub discussions for feature requests
- Telegram and Matrix communities
- Reddit community
### Device Database
- Templates repository with 1000+ device configurations
- Community-contributed device support
- Standardized template sharing format
### Integration Ecosystem
- Native Home Assistant integration
- Multiple home automation platform support
- Cloud service integrations (AWS, Azure)
- Third-party tool ecosystem
## Development Trends
### Modern Features
- Matter protocol support for interoperability
- Berry scripting for advanced automation
- LVGL for rich user interfaces
- Machine learning integration (TensorFlow Lite)
### Hardware Evolution
- ESP32 as primary platform for new features
- ESP8266 maintained for compatibility
- Support for latest ESP32 variants (S2, S3, C3)
- Increasing focus on low-power applications
## Conclusion
The Tasmota documentation represents one of the most comprehensive firmware documentation projects in the IoT space. It successfully bridges the gap between simple device control and advanced IoT development, providing pathways for users to grow from basic usage to sophisticated automation and custom development.
The documentation's strength lies in its practical approach, extensive hardware support coverage, and community-driven nature. It serves as both a user manual and a development reference, making Tasmota accessible to a wide range of users while providing the depth needed for serious IoT development.
The modular architecture, extensive command system, and multiple scripting options make Tasmota a powerful platform for IoT development, with documentation that adequately supports this complexity while remaining approachable for newcomers.

View File

@ -0,0 +1,977 @@
# Tasmota Developer Guide
This file is a summary of the Tasmota Documentation for the "docs" repository. It is provided here for convenience for GenAI to read it easily.
## How Tasmota Works
### Core Architecture
Tasmota is a modular firmware that transforms ESP8266/ESP8285 and ESP32 microcontrollers into intelligent IoT devices. The architecture follows these key principles:
#### 1. Event-Driven System
- Main loop processes events and callbacks
- Non-blocking operations to maintain responsiveness
- Callback system for sensors, drivers, and features
- Timer-based scheduling for periodic tasks
#### 2. Modular Design
- Core functionality always present (WiFi, MQTT, web interface)
- Optional features compiled conditionally using `#define` directives
- Plugin architecture for sensors and peripherals
- Template system for device configuration
#### 3. Communication Hub
- **MQTT**: Primary communication protocol for automation systems
- **HTTP**: Web interface and REST API
- **Serial**: Direct console access for debugging and configuration
- **WebSocket**: Real-time web interface updates
### Firmware Structure
```
tasmota/
├── tasmota.ino # Main firmware file
├── tasmota_xdrv_driver/ # Driver files directory (187 files)
│ ├── xdrv_01_9_webserver.ino # Web server driver
│ ├── xdrv_02_9_mqtt.ino # MQTT driver
│ ├── xdrv_04_light.ino # Light driver
│ └── xdrv_##_name.ino # Other drivers
├── tasmota_xsns_sensor/ # Sensor files directory (143 files)
│ ├── xsns_01_counter.ino # Counter sensor
│ ├── xsns_02_analog.ino # Analog sensor
│ └── xsns_##_name.ino # Other sensors
├── tasmota_xlgt_light/ # Light driver files directory
├── tasmota_xnrg_energy/ # Energy monitoring files directory
├── tasmota_support/ # Support functions directory (29 files)
│ ├── support.ino # Core support functions
│ ├── settings.ino # Settings management
│ └── support_*.ino # Other support modules
├── include/ # Header files directory (18 files)
│ ├── tasmota.h # Main header
│ ├── tasmota_types.h # Type definitions
│ ├── tasmota_globals.h # Global variables
│ └── *.h # Other headers
└── my_user_config.h # User configuration overrides
```
### Command System
All Tasmota functionality is accessible through a unified command system:
- Commands can be sent via MQTT, HTTP, serial, or web console
- Format: `Command [parameter]`
- Response format: JSON for structured data
- Backlog support for multiple commands: `Backlog cmd1; cmd2; cmd3`
### GPIO Management
Tasmota uses a flexible GPIO assignment system:
1. **Templates**: Pre-defined GPIO configurations for specific devices
2. **Components**: Logical functions assigned to physical pins
3. **Modules**: Base hardware configurations
4. **Runtime Configuration**: GPIO can be reassigned without recompilation
## Development Environment Setup
### Prerequisites
1. **PlatformIO**: Primary build system
2. **Git**: Version control
3. **Python**: For build scripts and tools
4. **Serial Programmer**: For initial flashing
### Build Configuration
Create `platformio_tasmota_cenv.ini` for custom environments:
```ini
[env:tasmota32-custom]
extends = env:tasmota32
build_flags = ${env:tasmota32.build_flags}
-DUSE_MY_CUSTOM_FEATURE
```
### User Configuration
Create `tasmota/user_config_override.h`:
```c
#ifndef _USER_CONFIG_OVERRIDE_H_
#define _USER_CONFIG_OVERRIDE_H_
// Enable custom features
#define USE_CUSTOM_SENSOR
#define USE_BERRY_DEBUG
// Disable unused features to save space
#undef USE_DOMOTICZ
#undef USE_KNX
#endif
```
## Driver Development
### Sensor Driver Structure
All sensor drivers follow a standardized pattern:
```c
#ifdef USE_MY_SENSOR
#define XSNS_XX XX // Unique sensor ID
bool MySensorDetected = false;
void MySensorInit(void) {
// Initialize sensor
if (sensor_detected) {
MySensorDetected = true;
}
}
void MySensorEverySecond(void) {
// Read sensor data
}
void MySensorShow(bool json) {
if (json) {
ResponseAppend_P(PSTR(",\"MySensor\":{\"Temperature\":%d}"), temperature);
}
#ifdef USE_WEBSERVER
else {
WSContentSend_PD(HTTP_SNS_TEMP, "MySensor", temperature);
}
#endif
}
bool Xsns_XX(byte function) {
bool result = false;
if (i2c_flg) { // Only for I2C sensors
switch (function) {
case FUNC_INIT:
MySensorInit();
break;
case FUNC_EVERY_SECOND:
MySensorEverySecond();
break;
case FUNC_JSON_APPEND:
MySensorShow(1);
break;
#ifdef USE_WEBSERVER
case FUNC_WEB_SENSOR:
MySensorShow(0);
break;
#endif
}
}
return result;
}
#endif // USE_MY_SENSOR
```
### Complete Driver Callback Functions Reference
**VERIFIED FROM SOURCE CODE**: `tasmota/include/tasmota.h` lines 433-454
#### Core System Callbacks (Functions WITHOUT return results)
| Function | Purpose | When Called | Parameters |
|----------|---------|-------------|-----------|
| `FUNC_SETTINGS_OVERRIDE` | Override default settings | Before settings load | None |
| `FUNC_SETUP_RING1` | Early setup phase 1 | System initialization | None |
| `FUNC_SETUP_RING2` | Early setup phase 2 | System initialization | None |
| `FUNC_PRE_INIT` | Pre-initialization | Before main init | None |
| `FUNC_INIT` | Initialize driver/sensor | Once at startup | None |
| `FUNC_ACTIVE` | Check if driver is active | Status queries | None |
| `FUNC_ABOUT_TO_RESTART` | Prepare for restart | Before system restart | None |
#### Loop and Timing Callbacks
| Function | Purpose | Frequency | Parameters |
|----------|---------|-----------|-----------|
| `FUNC_LOOP` | Main loop processing | Every loop cycle (~1ms) | None |
| `FUNC_SLEEP_LOOP` | Sleep mode processing | During sleep cycles | None |
| `FUNC_EVERY_50_MSECOND` | Fast polling operations | Every 50ms | None |
| `FUNC_EVERY_100_MSECOND` | Medium polling | Every 100ms | None |
| `FUNC_EVERY_200_MSECOND` | Slower polling | Every 200ms | None |
| `FUNC_EVERY_250_MSECOND` | Quarter second tasks | Every 250ms | None |
| `FUNC_EVERY_SECOND` | Regular updates | Every second | None |
#### Settings and Configuration Callbacks
| Function | Purpose | When Called | Parameters |
|----------|---------|-------------|-----------|
| `FUNC_RESET_SETTINGS` | Reset to defaults | Settings reset | None |
| `FUNC_RESTORE_SETTINGS` | Restore from backup | Settings restore | None |
| `FUNC_SAVE_SETTINGS` | Save current settings | Settings save | None |
| `FUNC_SAVE_AT_MIDNIGHT` | Midnight save operations | Daily at 00:00 | None |
| `FUNC_SAVE_BEFORE_RESTART` | Save critical data | Before restart | None |
#### Interrupt and System Control
| Function | Purpose | When Called | Parameters |
|----------|---------|-------------|-----------|
| `FUNC_INTERRUPT_STOP` | Stop interrupts | Before critical section | None |
| `FUNC_INTERRUPT_START` | Resume interrupts | After critical section | None |
| `FUNC_FREE_MEM` | Memory cleanup | Low memory conditions | None |
#### Telemetry and JSON Callbacks
| Function | Purpose | When Called | Parameters |
|----------|---------|-------------|-----------|
| `FUNC_AFTER_TELEPERIOD` | Post-telemetry cleanup | After TelePeriod | None |
| `FUNC_JSON_APPEND` | Add JSON telemetry | Every TelePeriod | None |
| `FUNC_TELEPERIOD_RULES_PROCESS` | Rules after telemetry | Post-TelePeriod | None |
#### Web Interface Callbacks
| Function | Purpose | When Called | Parameters |
|----------|---------|-------------|-----------|
| `FUNC_WEB_SENSOR` | Show sensor on web | Sensor page load | None |
| `FUNC_WEB_COL_SENSOR` | Column sensor display | Web page layout | None |
| `FUNC_WEB_ADD_BUTTON` | Add web buttons | Main page load | None |
| `FUNC_WEB_ADD_CONSOLE_BUTTON` | Add console button | Console page | None |
| `FUNC_WEB_ADD_MANAGEMENT_BUTTON` | Add config button | Config page | None |
| `FUNC_WEB_ADD_MAIN_BUTTON` | Add main menu button | Main page | None |
| `FUNC_WEB_GET_ARG` | Process web arguments | Form submission | None |
| `FUNC_WEB_ADD_HANDLER` | Add URL handlers | Web server init | None |
| `FUNC_WEB_STATUS_LEFT` | Left status column | Status page | None |
| `FUNC_WEB_STATUS_RIGHT` | Right status column | Status page | None |
#### MQTT and Communication Callbacks
| Function | Purpose | When Called | Parameters |
|----------|---------|-------------|-----------|
| `FUNC_MQTT_SUBSCRIBE` | Subscribe to MQTT topics | MQTT connect | None |
| `FUNC_MQTT_INIT` | Initialize MQTT | MQTT setup | None |
#### Power and Hardware Control
| Function | Purpose | When Called | Parameters |
|----------|---------|-------------|-----------|
| `FUNC_SET_POWER` | Handle power changes | Power state change | None |
| `FUNC_SHOW_SENSOR` | Display sensor data | Status request | None |
| `FUNC_ANY_KEY` | Handle any key press | Key event | None |
| `FUNC_LED_LINK` | Control link LED | Network state change | None |
| `FUNC_ENERGY_EVERY_SECOND` | Energy monitoring | Every second | None |
| `FUNC_ENERGY_RESET` | Reset energy counters | Reset command | None |
#### Advanced System Callbacks
| Function | Purpose | When Called | Parameters |
|----------|---------|-------------|-----------|
| `FUNC_SET_SCHEME` | Set color scheme | Theme change | None |
| `FUNC_HOTPLUG_SCAN` | Scan for hotplug devices | Device detection | None |
| `FUNC_TIME_SYNCED` | Time synchronization | NTP sync complete | None |
| `FUNC_DEVICE_GROUP_ITEM` | Device group processing | Group operations | None |
| `FUNC_NETWORK_UP` | Network connected | WiFi/Ethernet up | None |
| `FUNC_NETWORK_DOWN` | Network disconnected | WiFi/Ethernet down | None |
#### Callback Functions WITH Return Results (ID >= 200)
These functions are expected to return boolean results:
| Function | Purpose | When Called | Return Value |
|----------|---------|-------------|--------------|
| `FUNC_PIN_STATE` | GPIO state query | Pin state check | true if handled |
| `FUNC_MODULE_INIT` | Module initialization | Module setup | true if success |
| `FUNC_ADD_BUTTON` | Add button handler | Button config | true if added |
| `FUNC_ADD_SWITCH` | Add switch handler | Switch config | true if added |
| `FUNC_BUTTON_PRESSED` | Handle button press | Button event | true if handled |
| `FUNC_BUTTON_MULTI_PRESSED` | Multi-button press | Button combo | true if handled |
| `FUNC_SET_DEVICE_POWER` | Device power control | Power command | true if handled |
| `FUNC_MQTT_DATA` | Process MQTT data | MQTT message | true if handled |
| `FUNC_SERIAL` | Serial data processing | Serial input | true if handled |
| `FUNC_COMMAND` | Process commands | Command received | true if handled |
| `FUNC_COMMAND_SENSOR` | Sensor commands | Sensor command | true if handled |
| `FUNC_COMMAND_DRIVER` | Driver commands | Driver command | true if handled |
| `FUNC_RULES_PROCESS` | Process rules | Rule evaluation | true if handled |
| `FUNC_SET_CHANNELS` | Set PWM channels | Channel update | true if handled |
#### Callback Implementation Pattern
```c
bool Xdrv_XX(uint8_t function) {
bool result = false;
switch (function) {
case FUNC_INIT:
MyDriverInit();
break;
case FUNC_EVERY_SECOND:
MyDriverEverySecond();
break;
case FUNC_COMMAND:
result = MyDriverCommand();
break;
case FUNC_JSON_APPEND:
MyDriverJsonAppend();
break;
case FUNC_WEB_SENSOR:
MyDriverWebSensor();
break;
case FUNC_SAVE_BEFORE_RESTART:
MyDriverSaveSettings();
break;
}
return result;
}
### I2C Development
```c
// I2C Helper Functions
bool I2cValidRead8(uint8_t *data, uint8_t addr, uint8_t reg);
bool I2cValidRead16(uint16_t *data, uint8_t addr, uint8_t reg);
uint8_t I2cRead8(uint8_t addr, uint8_t reg);
uint16_t I2cRead16(uint8_t addr, uint8_t reg);
bool I2cWrite8(uint8_t addr, uint8_t reg, uint8_t val);
// Device Detection Pattern
void MySensorDetect(void) {
if (MySensorDetected) return;
for (uint8_t i = 0; i < SENSOR_MAX_ADDR; i++) {
uint8_t addr = SENSOR_BASE_ADDR + i;
if (I2cValidRead8(&sensor_id, addr, SENSOR_ID_REG)) {
if (sensor_id == EXPECTED_ID) {
MySensorDetected = true;
AddLog(LOG_LEVEL_INFO, PSTR("MySensor found at 0x%02X"), addr);
break;
}
}
}
}
```
## Scripting and Automation
### Rules System
Rules provide event-driven automation:
```
Rule1 ON Switch1#State DO Power1 %value% ENDON
ON Time#Minute=30 DO Publish stat/topic/alert {"time":"30min"} ENDON
```
### Berry Scripting (ESP32)
Berry is a modern scripting language for advanced automation:
```berry
# Simple sensor reading
import json
def read_sensor()
var temp = tasmota.read_sensors()
if temp.contains("Temperature")
print("Current temperature:", temp["Temperature"])
end
end
# Set up timer
tasmota.set_timer(5000, read_sensor)
# Web interface extension
def web_add_button()
webserver.content_send("<button onclick='la(\"&m_toggle=1\");'>Toggle</button>")
end
tasmota.add_driver(web_add_button)
```
### Command Extensions
Add custom commands through Berry or C++:
```berry
def my_command(cmd, idx, payload)
if cmd == "MYCMD"
print("Custom command received:", payload)
tasmota.resp_cmnd_done()
end
end
tasmota.add_cmd('MYCMD', my_command)
```
## Complete Settings Structure Reference
### Settings Memory Layout
Tasmota uses a structured settings system stored in flash memory. The main settings structure is defined in `settings.h`:
```c
typedef struct {
unsigned long cfg_holder; // 000 v6.0.0a
unsigned long save_flag; // 004
unsigned long version; // 008
unsigned short flag; // 00C
unsigned short save_data; // 00E
int8_t timezone; // 010
char ota_url[101]; // 011
char mqtt_prefix[3][11]; // 076
char serial_delimiter; // 09D
uint8_t seriallog_level; // 09E
uint8_t sta_config; // 09F
char sta_ssid[2][33]; // 0A0
char sta_pwd[2][65]; // 102
char hostname[33]; // 183
char syslog_host[33]; // 1A4
uint16_t syslog_port; // 1C5
uint8_t syslog_level; // 1C7
uint8_t webserver; // 1C8
uint8_t weblog_level; // 1C9
char mqtt_fingerprint[2][60]; // 1CA
char mqtt_host[33]; // 236
uint16_t mqtt_port; // 257
char mqtt_client[33]; // 259
char mqtt_user[33]; // 27A
char mqtt_pwd[33]; // 29B
char mqtt_topic[33]; // 2BC
char button_topic[33]; // 2DD
char mqtt_grptopic[33]; // 2FE
uint8_t display_model; // 31F
uint8_t display_mode; // 320
uint8_t display_refresh; // 321
uint8_t display_rows; // 322
uint8_t display_cols[2]; // 323
uint8_t display_address[8]; // 325
uint8_t display_dimmer; // 32D
uint8_t display_size; // 32E
uint16_t pwm_frequency; // 32F
power_t power; // 331
uint16_t pwm_value[MAX_PWMS]; // 335
int16_t altitude; // 345
uint16_t tele_period; // 347
uint8_t ledstate; // 349
uint8_t param[PARAM_MAX]; // 34A
int16_t toffset[2]; // 35A
uint8_t display_font; // 35E
} Settings;
### ESP8266 Constraints
- **Flash**: 1MB total, ~500KB available for firmware
- **RAM**: 80KB total, ~25-30KB available for application
- **Stack**: 4KB maximum
### Optimization Techniques
1. **Use PROGMEM for constants**:
```c
const char MyString[] PROGMEM = "Constant string";
```
2. **Minimize dynamic allocation**:
```c
// Avoid
String result = String(value1) + "," + String(value2);
// Prefer
char result[32];
snprintf(result, sizeof(result), "%d,%d", value1, value2);
```
3. **Use flash-efficient data types**:
```c
// Use uint32_t instead of uint8_t for local variables
// Use uint8_t only in structs to save memory
```
## Communication Protocols
### Command Context Structure
All command handlers receive context through the global XdrvMailbox structure:
```c
struct XDRVMAILBOX {
bool grpflg; // Group flag
bool usridx; // User index flag
uint16_t command_code; // Command code
uint32_t index; // Command index
uint32_t data_len; // Parameter length
int32_t payload; // Numeric parameter
char *topic; // MQTT topic
char *data; // Command parameters
char *command; // Command name
} XdrvMailbox;
```
**Key Fields:**
- `command`: The command name (e.g., "Power", "Status")
- `data`: Raw parameter string
- `payload`: Numeric value of first parameter
- `data_len`: Length of parameter string
- `index`: Command index for numbered commands (Power1, Power2, etc.)
### MQTT Integration
```c
// Publish sensor data
void PublishSensorData(void) {
Response_P(PSTR("{\"MySensor\":{\"Value\":%d}}"), sensor_value);
MqttPublishTeleSensor();
}
// Subscribe to commands
bool MyCommand(void) {
if (XdrvMailbox.data_len > 0) {
// Process command
ResponseCmndDone();
return true;
}
ResponseCmndNumber(current_value);
return true;
}
```
### Web Interface Extensions
```c
#ifdef USE_WEBSERVER
void MySensorWebShow(void) {
WSContentSend_PD(PSTR(
"{s}MySensor Temperature{m}%d°C{e}"
"{s}MySensor Humidity{m}%d%%{e}"),
temperature, humidity);
}
#endif
```
## Advanced Features
### Template System
Templates define device GPIO configurations:
```json
{
"NAME":"Custom Device",
"GPIO":[416,0,418,0,417,2720,0,0,2624,32,2656,224,0,0],
"FLAG":0,
"BASE":45
}
```
### Matter Protocol Support
For ESP32 devices, Matter provides standardized IoT communication:
```c
// Matter endpoint configuration
matter.add_endpoint(1, 0x0100); // On/Off Light
matter.add_endpoint(2, 0x0106); // Light with dimming
```
### Display Integration
Universal Display Driver supports 50+ display types:
```
DisplayModel 1 # Select display type
DisplayMode 1 # Text mode
DisplayText [s1l1]Hello World
```
## Testing and Debugging
### Debug Options
Enable debugging in `user_config_override.h`:
```c
#define DEBUG_TASMOTA_CORE
#define DEBUG_TASMOTA_DRIVER
#define USE_DEBUG_DRIVER
```
### Serial Debugging
```c
AddLog(LOG_LEVEL_INFO, PSTR("Debug: value=%d"), value);
AddLog(LOG_LEVEL_DEBUG, PSTR("Detailed info: %s"), info_string);
```
### Memory Monitoring
```c
// Check free heap
uint32_t free_heap = ESP.getFreeHeap();
AddLog(LOG_LEVEL_DEBUG, PSTR("Free heap: %d"), free_heap);
```
## Best Practices
### Code Organization
1. **Use consistent naming**: `MySensor` prefix for all functions
2. **Follow callback patterns**: Implement standard driver callbacks
3. **Handle errors gracefully**: Check return values and sensor presence
4. **Document thoroughly**: Include usage examples and pin assignments
### Performance Considerations
1. **Minimize blocking operations**: Use state machines for long operations
2. **Cache sensor readings**: Don't read sensors more often than necessary
3. **Use appropriate data types**: Consider memory usage vs. precision
4. **Optimize for common cases**: Fast path for normal operations
### Security Guidelines
1. **Validate all inputs**: Check command parameters and sensor data
2. **Use secure defaults**: Enable security features by default
3. **Minimize attack surface**: Disable unused network services
4. **Regular updates**: Keep firmware and dependencies current
## Integration Examples
### Home Assistant Discovery
```c
void PublishDiscovery(void) {
Response_P(PSTR("{"
"\"name\":\"%s MySensor\","
"\"stat_t\":\"%s\","
"\"unit_of_meas\":\"°C\","
"\"dev_cla\":\"temperature\""
"}"), SettingsText(SET_DEVICENAME), GetStateTopic());
MqttPublish(GetDiscoveryTopic("sensor", "temperature"), true);
}
```
### Custom Web Interface
```c
const char HTTP_MYSENSOR[] PROGMEM =
"{s}MySensor{m}"
"<input type='range' min='0' max='100' value='%d' "
"onchange='la(\"&mysensor_val=\"+this.value);'>"
"{e}";
void MySensorWebShow(void) {
WSContentSend_PD(HTTP_MYSENSOR, current_value);
}
```
This guide provides the foundation for understanding and extending Tasmota. The modular architecture, standardized APIs, and extensive documentation make it an excellent platform for IoT development, whether you're adding simple sensor support or implementing complex automation systems.
## Complete Command Reference
### Core System Commands
| Command | Parameters | Description | Example |
|---------|------------|-------------|---------|
| `Status` | 0-11 | System status information | `Status 0` |
| `Reset` | 1-6 | Reset device with options | `Reset 1` |
| `Restart` | 1 | Restart device | `Restart 1` |
| `Upgrade` | 1 | Start OTA upgrade | `Upgrade 1` |
| `Upload` | 1 | Start file upload | `Upload 1` |
| `Otaurl` | url | Set OTA URL | `Otaurl http://ota.server/firmware.bin` |
| `Seriallog` | 0-4 | Set serial log level | `Seriallog 2` |
| `Syslog` | 0-4 | Set syslog level | `Syslog 2` |
| `Loghost` | hostname | Set syslog host | `Loghost 192.168.1.100` |
| `Logport` | port | Set syslog port | `Logport 514` |
| `Ipaddress` | x.x.x.x | Set IP address | `Ipaddress 192.168.1.100` |
| `Gateway` | x.x.x.x | Set gateway | `Gateway 192.168.1.1` |
| `Subnetmask` | x.x.x.x | Set subnet mask | `Subnetmask 255.255.255.0` |
| `Dnsserver` | x.x.x.x | Set DNS server | `Dnsserver 8.8.8.8` |
| `Mac` | - | Show MAC address | `Mac` |
| `Hostname` | name | Set hostname | `Hostname tasmota-device` |
### WiFi Commands
| Command | Parameters | Description | Example |
|---------|------------|-------------|---------|
| `Ssid1` | ssid | Set WiFi SSID 1 | `Ssid1 MyNetwork` |
| `Ssid2` | ssid | Set WiFi SSID 2 | `Ssid2 BackupNetwork` |
| `Password1` | password | Set WiFi password 1 | `Password1 MyPassword` |
| `Password2` | password | Set WiFi password 2 | `Password2 BackupPassword` |
| `Ap` | 0-2 | Set AP mode | `Ap 1` |
| `WebServer` | 0-2 | Enable web server | `WebServer 1` |
| `WebPassword` | password | Set web password | `WebPassword admin` |
| `WifiConfig` | 0-7 | WiFi configuration mode | `WifiConfig 4` |
### MQTT Commands
| Command | Parameters | Description | Example |
|---------|------------|-------------|---------|
| `MqttHost` | hostname | Set MQTT broker | `MqttHost 192.168.1.100` |
| `MqttPort` | port | Set MQTT port | `MqttPort 1883` |
| `MqttUser` | username | Set MQTT username | `MqttUser myuser` |
| `MqttPassword` | password | Set MQTT password | `MqttPassword mypass` |
| `MqttClient` | clientid | Set MQTT client ID | `MqttClient tasmota-device` |
| `Topic` | topic | Set MQTT topic | `Topic tasmota` |
| `GroupTopic` | topic | Set group topic | `GroupTopic tasmotas` |
| `FullTopic` | template | Set full topic template | `FullTopic %prefix%/%topic%/` |
| `Prefix1` | prefix | Set command prefix | `Prefix1 cmnd` |
| `Prefix2` | prefix | Set status prefix | `Prefix2 stat` |
| `Prefix3` | prefix | Set telemetry prefix | `Prefix3 tele` |
| `Publish` | topic payload | Publish MQTT message | `Publish stat/topic/test Hello` |
| `MqttRetry` | seconds | Set MQTT retry time | `MqttRetry 10` |
| `StateText1` | text | Set OFF state text | `StateText1 OFF` |
| `StateText2` | text | Set ON state text | `StateText2 ON` |
| `StateText3` | text | Set TOGGLE state text | `StateText3 TOGGLE` |
| `StateText4` | text | Set HOLD state text | `StateText4 HOLD` |
### Power and Relay Commands
| Command | Parameters | Description | Example |
|---------|------------|-------------|---------|
| `Power` | 0/1/2 | Control main power | `Power 1` |
| `Power1` | 0/1/2 | Control power 1 | `Power1 ON` |
| `Power2` | 0/1/2 | Control power 2 | `Power2 OFF` |
| `Power3` | 0/1/2 | Control power 3 | `Power3 TOGGLE` |
| `Power4` | 0/1/2 | Control power 4 | `Power4 1` |
| `PowerOnState` | 0-4 | Set power on state | `PowerOnState 1` |
| `PulseTime` | 1-111 | Set pulse time | `PulseTime1 10` |
| `BlinkTime` | 2-3600 | Set blink time | `BlinkTime 10` |
| `BlinkCount` | 0-32000 | Set blink count | `BlinkCount 5` |
| `Interlock` | 0/1 | Enable interlock | `Interlock 1` |
| `Ledstate` | 0-8 | Set LED state | `Ledstate 1` |
| `LedPower` | 0-2 | Control LED power | `LedPower 1` |
| `LedMask` | hex | Set LED mask | `LedMask 0xFF00` |
### Sensor Commands
| Command | Parameters | Description | Example |
|---------|------------|-------------|---------|
| `TelePeriod` | 10-3600 | Set telemetry period | `TelePeriod 300` |
| `Resolution` | 0-3 | Set sensor resolution | `Resolution 2` |
| `HumRes` | 0-3 | Set humidity resolution | `HumRes 1` |
| `TempRes` | 0-3 | Set temperature resolution | `TempRes 2` |
| `PressRes` | 0-3 | Set pressure resolution | `PressRes 1` |
| `EnergyRes` | 0-5 | Set energy resolution | `EnergyRes 3` |
| `SpeedUnit` | 1-4 | Set speed unit | `SpeedUnit 1` |
| `WeightRes` | 0-3 | Set weight resolution | `WeightRes 2` |
| `FreqRes` | 0-3 | Set frequency resolution | `FreqRes 2` |
### Timer Commands
| Command | Parameters | Description | Example |
|---------|------------|-------------|---------|
| `Timer1` | parameters | Configure timer 1 | `Timer1 {"Enable":1,"Time":"06:00","Days":"1111100","Repeat":1,"Action":1}` |
| `Timer2` | parameters | Configure timer 2 | `Timer2 {"Enable":1,"Time":"22:00","Action":0}` |
| `Timers` | 0/1 | Enable/disable timers | `Timers 1` |
| `Latitude` | degrees | Set latitude | `Latitude 52.520008` |
| `Longitude` | degrees | Set longitude | `Longitude 13.404954` |
| `Sunrise` | - | Show sunrise time | `Sunrise` |
| `Sunset` | - | Show sunset time | `Sunset` |
### GPIO and Template Commands
| Command | Parameters | Description | Example |
|---------|------------|-------------|---------|
| `Gpio` | pin,function | Set GPIO function | `Gpio 14,21` |
| `Gpios` | - | Show GPIO configuration | `Gpios` |
| `Template` | json | Set device template | `Template {"NAME":"Generic","GPIO":[255,255,255,255,255,255,255,255,255,255,255,255,255],"FLAG":1,"BASE":18}` |
| `Module` | 0-255 | Set device module | `Module 1` |
| `Modules` | - | Show available modules | `Modules` |
| `I2CScan` | - | Scan I2C bus | `I2CScan` |
| `I2CDriver` | driver | Enable I2C driver | `I2CDriver10 1` |
### Display Commands
| Command | Parameters | Description | Example |
|---------|------------|-------------|---------|
| `Display` | - | Show display info | `Display` |
| `DisplayModel` | 1-16 | Set display model | `DisplayModel 2` |
| `DisplayMode` | 0-5 | Set display mode | `DisplayMode 1` |
| `DisplayDimmer` | 0-100 | Set display brightness | `DisplayDimmer 50` |
| `DisplaySize` | 1-4 | Set display size | `DisplaySize 2` |
| `DisplayRotate` | 0-3 | Set display rotation | `DisplayRotate 2` |
| `DisplayText` | text | Display text | `DisplayText [s1l1]Hello World` |
| `DisplayClear` | - | Clear display | `DisplayClear` |
### Rule Commands
| Command | Parameters | Description | Example |
|---------|------------|-------------|---------|
| `Rule1` | rule | Set rule 1 | `Rule1 ON Switch1#State DO Power1 %value% ENDON` |
| `Rule2` | rule | Set rule 2 | `Rule2 ON Time#Minute=30 DO Publish stat/alert 30min ENDON` |
| `Rule3` | rule | Set rule 3 | `Rule3 ON Button1#State DO Backlog Power1 TOGGLE; Delay 10; Power2 TOGGLE ENDON` |
| `RuleTimer1` | 0-3600 | Set rule timer 1 | `RuleTimer1 60` |
| `RuleTimer2` | 0-3600 | Set rule timer 2 | `RuleTimer2 120` |
| `Mem1` | value | Set memory 1 | `Mem1 Hello` |
| `Mem2` | value | Set memory 2 | `Mem2 World` |
| `Var1` | value | Set variable 1 | `Var1 42` |
| `Var2` | value | Set variable 2 | `Var2 3.14` |
| `CalcRes` | 0-7 | Set calculation resolution | `CalcRes 2` |
### Berry Script Commands (ESP32)
| Command | Parameters | Description | Example |
|---------|------------|-------------|---------|
| `Br` | code | Execute Berry code | `Br print("Hello")` |
| `BrLoad` | filename | Load Berry file | `BrLoad autoexec.be` |
| `BrRun` | filename | Run Berry file | `BrRun script.be` |
| `BrRestart` | - | Restart Berry VM | `BrRestart` |
### Energy Monitoring Commands
| Command | Parameters | Description | Example |
|---------|------------|-------------|---------|
| `PowerCal` | value | Calibrate power | `PowerCal 12530` |
| `VoltageCal` | value | Calibrate voltage | `VoltageCal 1950` |
| `CurrentCal` | value | Calibrate current | `CurrentCal 3500` |
| `PowerSet` | watts | Set power reading | `PowerSet 100` |
| `VoltageSet` | volts | Set voltage reading | `VoltageSet 230` |
| `CurrentSet` | amps | Set current reading | `CurrentSet 0.43` |
| `FrequencySet` | hz | Set frequency reading | `FrequencySet 50` |
| `EnergyReset1` | kWh | Reset energy total | `EnergyReset1 0` |
| `EnergyReset2` | kWh | Reset energy yesterday | `EnergyReset2 0` |
| `EnergyReset3` | kWh | Reset energy today | `EnergyReset3 0` |
| `MaxPower` | watts | Set max power | `MaxPower 3500` |
| `MaxPowerHold` | seconds | Set max power hold | `MaxPowerHold 10` |
| `MaxPowerWindow` | seconds | Set max power window | `MaxPowerWindow 30` |
| `SafePower` | watts | Set safe power | `SafePower 3000` |
| `SafePowerHold` | seconds | Set safe power hold | `SafePowerHold 10` |
| `SafePowerWindow` | seconds | Set safe power window | `SafePowerWindow 30` |
## Complete Logging and Debug Reference
### Log Levels
```c
#define LOG_LEVEL_NONE 0 // No logging
#define LOG_LEVEL_ERROR 1 // Critical errors only
#define LOG_LEVEL_INFO 2 // Errors and info
#define LOG_LEVEL_DEBUG 3 // Errors, info and debug
#define LOG_LEVEL_DEBUG_MORE 4 // All logging
```
### Logging Functions
```c
// Main logging function
void AddLog(uint32_t loglevel, const char* formatP, ...);
// Convenience macros
#define AddLog_P(loglevel, formatP, ...) AddLog(loglevel, PSTR(formatP), ##__VA_ARGS__)
#define AddLog_P2(loglevel, formatP, ...) AddLog(loglevel, formatP, ##__VA_ARGS__)
// Debug logging (only in debug builds)
#ifdef DEBUG_TASMOTA_CORE
#define DEBUG_CORE_LOG(...) AddLog(__VA_ARGS__)
#else
#define DEBUG_CORE_LOG(...)
#endif
#ifdef DEBUG_TASMOTA_DRIVER
#define DEBUG_DRIVER_LOG(...) AddLog(__VA_ARGS__)
#else
#define DEBUG_DRIVER_LOG(...)
#endif
#ifdef DEBUG_TASMOTA_SENSOR
#define DEBUG_SENSOR_LOG(...) AddLog(__VA_ARGS__)
#else
#define DEBUG_SENSOR_LOG(...)
#endif
```
### Debug Build Options
```c
// Enable in user_config_override.h for debugging
#define DEBUG_TASMOTA_CORE // Core system debugging
#define DEBUG_TASMOTA_DRIVER // Driver debugging
#define DEBUG_TASMOTA_SENSOR // Sensor debugging
#define USE_DEBUG_DRIVER // Enable debug driver
#define DEBUG_TASMOTA_PORT Serial // Debug output port
```
### Memory Debugging
```c
// Memory monitoring functions
uint32_t ESP_getFreeHeap(void);
uint32_t ESP_getMaxAllocHeap(void);
uint8_t ESP_getHeapFragmentation(void);
uint32_t ESP_getFreeContStack(void);
// Memory debugging macros
#define SHOW_FREE_MEM(x) AddLog(LOG_LEVEL_DEBUG, PSTR(x " free mem: %d"), ESP_getFreeHeap())
#define CHECK_OOM() if (ESP_getFreeHeap() < 1000) AddLog(LOG_LEVEL_ERROR, PSTR("Low memory: %d"), ESP_getFreeHeap())
```
## Complete I2C Reference
### I2C Configuration
```c
// I2C pins (can be changed via GPIO configuration)
#define I2C_SDA_PIN 4 // Default SDA pin
#define I2C_SCL_PIN 5 // Default SCL pin
// I2C speeds
#define I2C_SPEED_SLOW 50000 // 50kHz
#define I2C_SPEED_STANDARD 100000 // 100kHz
#define I2C_SPEED_FAST 400000 // 400kHz
#define I2C_SPEED_FAST_PLUS 1000000 // 1MHz
```
### I2C Helper Functions
```c
// Basic I2C operations
bool I2cValidRead(uint8_t addr, uint8_t reg, uint8_t size);
bool I2cValidRead8(uint8_t *data, uint8_t addr, uint8_t reg);
bool I2cValidRead16(uint16_t *data, uint8_t addr, uint8_t reg);
bool I2cValidRead16LE(uint16_t *data, uint8_t addr, uint8_t reg);
bool I2cValidRead24(int32_t *data, uint8_t addr, uint8_t reg);
bool I2cValidReadS32(int32_t *data, uint8_t addr, uint8_t reg);
bool I2cValidReadS32_LE(int32_t *data, uint8_t addr, uint8_t reg);
uint8_t I2cRead8(uint8_t addr, uint8_t reg);
uint16_t I2cRead16(uint8_t addr, uint8_t reg);
uint16_t I2cRead16LE(uint8_t addr, uint8_t reg);
int32_t I2cRead24(uint8_t addr, uint8_t reg);
int32_t I2cReadS32(uint8_t addr, uint8_t reg);
int32_t I2cReadS32_LE(uint8_t addr, uint8_t reg);
bool I2cWrite8(uint8_t addr, uint8_t reg, uint8_t val);
bool I2cWrite16(uint8_t addr, uint8_t reg, uint16_t val);
bool I2cWrite16LE(uint8_t addr, uint8_t reg, uint16_t val);
// Buffer operations
uint8_t I2cReadBuffer(uint8_t addr, uint8_t reg, uint8_t *data, uint16_t len);
uint8_t I2cWriteBuffer(uint8_t addr, uint8_t reg, uint8_t *data, uint16_t len);
// Device detection
bool I2cActive(uint8_t addr);
void I2cScan(char *devs, unsigned int devs_len);
void I2cResetActive(uint8_t addr, uint8_t count = 1);
void I2cSetActive(uint8_t addr, uint8_t count = 1);
void I2cSetActiveFound(uint8_t addr, const char *types);
```
### I2C Device Detection Pattern
```c
void MySensorDetect(void) {
if (MySensorDetected) return;
for (uint32_t i = 0; i < SENSOR_MAX_ADDR; i++) {
uint8_t addr = SENSOR_BASE_ADDR + i;
if (I2cActive(addr)) continue; // Address already in use
if (I2cValidRead8(&sensor_id, addr, SENSOR_ID_REG)) {
if (sensor_id == EXPECTED_SENSOR_ID) {
I2cSetActiveFound(addr, "MySensor");
MySensorDetected = true;
MySensorAddress = addr;
AddLog(LOG_LEVEL_INFO, PSTR("MySensor found at address 0x%02X"), addr);
break;
}
}
}
}
```
This comprehensive developer reference provides all the essential information needed to understand, extend, and debug Tasmota firmware. The detailed callback system, complete command reference, GPIO configuration options, and debugging tools give developers everything needed to create robust IoT solutions.

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@ _Make sure your have performed every step and checked the applicable boxes befor
- [ ] Searched the problem in [discussions](https://github.com/arendst/Tasmota/discussions) - [ ] Searched the problem in [discussions](https://github.com/arendst/Tasmota/discussions)
- [ ] Searched the problem in the [docs](https://tasmota.github.io/docs/FAQ) - [ ] Searched the problem in the [docs](https://tasmota.github.io/docs/FAQ)
- [ ] Searched the problem in the [chat](https://discord.gg/Ks2Kzd4) - [ ] Searched the problem in the [chat](https://discord.gg/Ks2Kzd4)
- [ ] Problem is not scripter related, in this case open a discussion and tag @gemu2015 - [ ] Problem is not scripter related, in this case open a discussion and tag gemu2015
- [ ] Device used (e.g., Sonoff Basic): _____ - [ ] Device used (e.g., Sonoff Basic): _____
- [ ] Tasmota binary firmware version number used: _____ - [ ] Tasmota binary firmware version number used: _____
- [ ] Pre-compiled - [ ] Pre-compiled

View File

@ -7,7 +7,7 @@
- [ ] Only relevant files were touched - [ ] Only relevant files were touched
- [ ] Only one feature/fix was added per PR and the code change compiles without warnings - [ ] Only one feature/fix was added per PR and the code change compiles without warnings
- [ ] The code change is tested and works with Tasmota core ESP8266 V.2.7.8 - [ ] The code change is tested and works with Tasmota core ESP8266 V.2.7.8
- [ ] The code change is tested and works with Tasmota core ESP32 V.3.1.1.250203 - [ ] The code change is tested and works with Tasmota core ESP32 V.3.1.3.250712
- [ ] I accept the [CLA](https://github.com/arendst/Tasmota/blob/development/CONTRIBUTING.md#contributor-license-agreement-cla). - [ ] I accept the [CLA](https://github.com/arendst/Tasmota/blob/development/CONTRIBUTING.md#contributor-license-agreement-cla).
_NOTE: The code change must pass CI tests. **Your PR cannot be merged unless tests pass**_ _NOTE: The code change must pass CI tests. **Your PR cannot be merged unless tests pass**_

View File

@ -24,7 +24,7 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.x' python-version: '3.13'
- name: Make Berry and Solidify code - name: Make Berry and Solidify code
run: | run: |
@ -61,7 +61,7 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.x' python-version: '3.13'
- uses: actions/download-artifact@v4 - uses: actions/download-artifact@v4
with: with:
pattern: berry pattern: berry
@ -98,6 +98,8 @@ jobs:
- tasmota32s3ser-safeboot - tasmota32s3ser-safeboot
- tasmota32c6-safeboot - tasmota32c6-safeboot
- tasmota32c6ser-safeboot - tasmota32c6ser-safeboot
- tasmota32p4-safeboot
- tasmota32p4ser-safeboot
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
@ -105,11 +107,11 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.x' python-version: '3.13'
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install wheel pip install uv
pip install -U platformio uv pip install --system platformio
cp ./platformio_override_sample.ini ./platformio_override.ini cp ./platformio_override_sample.ini ./platformio_override.ini
- name: Add SHA to footer - name: Add SHA to footer
run: | run: |
@ -117,6 +119,9 @@ jobs:
SHA=${COMMIT_SHA_LONG::7} SHA=${COMMIT_SHA_LONG::7}
sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT $SHA-/g" ./tasmota/include/tasmota_version.h sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT $SHA-/g" ./tasmota/include/tasmota_version.h
- name: Run PlatformIO - name: Run PlatformIO
env:
PYTHONIOENCODING: utf-8
PYTHONUTF8: '1'
run: platformio run -e ${{ matrix.variant }} run: platformio run -e ${{ matrix.variant }}
#- name: Use esp32-solo1 safeboot for esp32 too #- name: Use esp32-solo1 safeboot for esp32 too
#run: | #run: |
@ -152,17 +157,20 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.x' python-version: '3.13'
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install wheel pip install uv
pip install -U platformio uv pip install --system platformio
- name: Add SHA to footer - name: Add SHA to footer
run: | run: |
COMMIT_SHA_LONG=$(git rev-parse --short HEAD || echo "") COMMIT_SHA_LONG=$(git rev-parse --short HEAD || echo "")
SHA=${COMMIT_SHA_LONG::7} SHA=${COMMIT_SHA_LONG::7}
sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT $SHA-/g" ./tasmota/include/tasmota_version.h sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT $SHA-/g" ./tasmota/include/tasmota_version.h
- name: Run PlatformIO - name: Run PlatformIO
env:
PYTHONIOENCODING: utf-8
PYTHONUTF8: '1'
run: platformio run -e ${{ matrix.variant }} run: platformio run -e ${{ matrix.variant }}
- name: Upload firmware artifacts - name: Upload firmware artifacts
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@ -189,6 +197,7 @@ jobs:
- tasmota32c2 - tasmota32c2
- tasmota32c3 - tasmota32c3
- tasmota32c6 - tasmota32c6
- tasmota32p4
- tasmota32s2 - tasmota32s2
- tasmota32s2cdc - tasmota32s2cdc
- tasmota32s3 - tasmota32s3
@ -200,11 +209,11 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.x' python-version: '3.13'
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install wheel pip install uv
pip install -U platformio uv pip install --system platformio
cp ./platformio_override_sample.ini ./platformio_override.ini cp ./platformio_override_sample.ini ./platformio_override.ini
- name: Download safeboot firmwares - name: Download safeboot firmwares
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
@ -221,6 +230,9 @@ jobs:
SHA=${COMMIT_SHA_LONG::7} SHA=${COMMIT_SHA_LONG::7}
sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT $SHA-/g" ./tasmota/include/tasmota_version.h sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT $SHA-/g" ./tasmota/include/tasmota_version.h
- name: Run PlatformIO - name: Run PlatformIO
env:
PYTHONIOENCODING: utf-8
PYTHONUTF8: '1'
run: platformio run -e ${{ matrix.variant }} run: platformio run -e ${{ matrix.variant }}
- name: Upload firmware artifacts - name: Upload firmware artifacts
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
@ -244,11 +256,11 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.x' python-version: '3.13'
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install wheel pip install uv
pip install -U platformio uv pip install --system platformio
cp ./platformio_override_sample.ini ./platformio_override.ini cp ./platformio_override_sample.ini ./platformio_override.ini
- name: Download safeboot firmwares - name: Download safeboot firmwares
uses: actions/download-artifact@v4 uses: actions/download-artifact@v4
@ -265,6 +277,9 @@ jobs:
SHA=${COMMIT_SHA_LONG::7} SHA=${COMMIT_SHA_LONG::7}
sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT $SHA-/g" ./tasmota/include/tasmota_version.h sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT $SHA-/g" ./tasmota/include/tasmota_version.h
- name: Run PlatformIO - name: Run PlatformIO
env:
PYTHONIOENCODING: utf-8
PYTHONUTF8: '1'
run: platformio run -e ${{ matrix.variant }}-${{ matrix.language }} run: platformio run -e ${{ matrix.variant }}-${{ matrix.language }}
- name: Upload language firmware artifacts - name: Upload language firmware artifacts
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4

View File

@ -1,234 +1,249 @@
name: Build_firmware_master name: Build_firmware_master
on: on:
workflow_dispatch: # Start a workflow workflow_dispatch: # Start a workflow
push: push:
branches: master branches: master
paths-ignore: paths-ignore:
- '.github/**' # Ignore changes towards the .github directory - '.github/**' # Ignore changes towards the .github directory
- '**.md' # Do no build if *.md files changes - '**.md' # Do no build if *.md files changes
# Ensures that only one deploy task per branch/environment will run at a time. # Ensures that only one deploy task per branch/environment will run at a time.
concurrency: concurrency:
group: environment-${{ github.ref }} group: environment-${{ github.ref }}
cancel-in-progress: true cancel-in-progress: true
jobs: jobs:
safeboot-images: safeboot-images:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.repository == 'arendst/Tasmota' if: github.repository == 'arendst/Tasmota'
continue-on-error: true continue-on-error: true
strategy: strategy:
matrix: matrix:
variant: variant:
- tasmota32-safeboot - tasmota32-safeboot
- tasmota32solo1-safeboot - tasmota32solo1-safeboot
- tasmota32c2-safeboot - tasmota32c2-safeboot
- tasmota32c3-safeboot - tasmota32c3-safeboot
- tasmota32c3ser-safeboot - tasmota32c3ser-safeboot
- tasmota32s2-safeboot - tasmota32s2-safeboot
- tasmota32s2cdc-safeboot - tasmota32s2cdc-safeboot
- tasmota32s3-safeboot - tasmota32s3-safeboot
- tasmota32s3ser-safeboot - tasmota32s3ser-safeboot
- tasmota32c6-safeboot - tasmota32c6-safeboot
- tasmota32c6ser-safeboot - tasmota32c6ser-safeboot
steps: - tasmota32p4-safeboot
- uses: actions/checkout@v4 - tasmota32p4ser-safeboot
with: steps:
ref: master - uses: actions/checkout@v4
- name: Set up Python with:
uses: actions/setup-python@v5 ref: master
with: - name: Set up Python
python-version: '3.x' uses: actions/setup-python@v5
- name: Install dependencies with:
run: | python-version: '3.13'
pip install wheel - name: Install dependencies
pip install -U platformio run: |
cp ./platformio_override_sample.ini ./platformio_override.ini pip install uv
- name: Add "release" to footer uv pip install --system platformio
run: | cp ./platformio_override_sample.ini ./platformio_override.ini
sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT release-/g" ./tasmota/include/tasmota_version.h - name: Add "release" to footer
- name: Run PlatformIO run: |
run: platformio run -e ${{ matrix.variant }} sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT release-/g" ./tasmota/include/tasmota_version.h
- name: Upload safeboot firmware artifacts - name: Run PlatformIO
uses: actions/upload-artifact@v4 env:
with: PYTHONIOENCODING: utf-8
name: ${{ matrix.variant }} PYTHONUTF8: '1'
path: ./build_output run: platformio run -e ${{ matrix.variant }}
- name: Upload safeboot firmware artifacts
base-images: uses: actions/upload-artifact@v4
runs-on: ubuntu-latest with:
if: github.repository == 'arendst/Tasmota' name: ${{ matrix.variant }}
continue-on-error: true path: ./build_output
strategy:
matrix: base-images:
variant: runs-on: ubuntu-latest
- tasmota if: github.repository == 'arendst/Tasmota'
- tasmota-4M continue-on-error: true
- tasmota-minimal strategy:
- tasmota-display matrix:
- tasmota-ir variant:
- tasmota-knx - tasmota
- tasmota-lite - tasmota-4M
- tasmota-sensors - tasmota-minimal
- tasmota-zbbridge - tasmota-display
- tasmota-zigbee - tasmota-ir
steps: - tasmota-knx
- uses: actions/checkout@v4 - tasmota-lite
with: - tasmota-sensors
ref: master - tasmota-zbbridge
- name: Set up Python - tasmota-zigbee
uses: actions/setup-python@v5 steps:
with: - uses: actions/checkout@v4
python-version: '3.x' with:
- name: Install dependencies ref: master
run: | - name: Set up Python
pip install wheel uses: actions/setup-python@v5
pip install -U platformio with:
cp ./platformio_override_sample.ini ./platformio_override.ini python-version: '3.13'
- name: Add "release" to footer - name: Install dependencies
run: | run: |
sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT release-/g" ./tasmota/include/tasmota_version.h pip install uv
- name: Run PlatformIO uv pip install --system platformio
run: platformio run -e ${{ matrix.variant }} cp ./platformio_override_sample.ini ./platformio_override.ini
- name: Upload firmware artifacts - name: Add "release" to footer
uses: actions/upload-artifact@v4 run: |
with: sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT release-/g" ./tasmota/include/tasmota_version.h
name: ${{ matrix.variant }} - name: Run PlatformIO
path: ./build_output env:
PYTHONIOENCODING: utf-8
base32-images: PYTHONUTF8: '1'
needs: safeboot-images run: platformio run -e ${{ matrix.variant }}
runs-on: ubuntu-latest - name: Upload firmware artifacts
if: github.repository == 'arendst/Tasmota' uses: actions/upload-artifact@v4
continue-on-error: true with:
strategy: name: ${{ matrix.variant }}
matrix: path: ./build_output
variant:
- tasmota32 base32-images:
- tasmota32-zbbrdgpro needs: safeboot-images
- tasmota32-webcam runs-on: ubuntu-latest
- tasmota32-bluetooth if: github.repository == 'arendst/Tasmota'
- tasmota32-nspanel continue-on-error: true
- tasmota32-display strategy:
- tasmota32-ir matrix:
- tasmota32-lvgl variant:
- tasmota32c2 - tasmota32
- tasmota32c3 - tasmota32-zbbrdgpro
- tasmota32c6 - tasmota32-webcam
- tasmota32s2 - tasmota32-bluetooth
- tasmota32s2cdc - tasmota32-nspanel
- tasmota32s3 - tasmota32-display
- tasmota32solo1 - tasmota32-ir
steps: - tasmota32-lvgl
- uses: actions/checkout@v4 - tasmota32c2
with: - tasmota32c3
ref: master - tasmota32c6
- name: Set up Python - tasmota32p4
uses: actions/setup-python@v5 - tasmota32s2
with: - tasmota32s2cdc
python-version: '3.x' - tasmota32s3
- name: Install dependencies - tasmota32solo1
run: | steps:
pip install wheel - uses: actions/checkout@v4
pip install -U platformio with:
cp ./platformio_override_sample.ini ./platformio_override.ini ref: master
- name: Download safeboot firmwares - name: Set up Python
uses: actions/download-artifact@v4 uses: actions/setup-python@v5
with: with:
pattern: tasmota32* python-version: '3.13'
path: ./temp - name: Install dependencies
- name: Move safeboot files run: |
run: | pip install uv
mkdir -p ./firmware/firmware uv pip install --system platformio
find ./temp -type f -exec cp -t ./firmware/firmware {} + cp ./platformio_override_sample.ini ./platformio_override.ini
- name: Add "release" to footer - name: Download safeboot firmwares
run: | uses: actions/download-artifact@v4
sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT release-/g" ./tasmota/include/tasmota_version.h with:
- name: Run PlatformIO pattern: tasmota32*
run: platformio run -e ${{ matrix.variant }} path: ./temp
- name: Upload firmware artifacts - name: Move safeboot files
uses: actions/upload-artifact@v4 run: |
with: mkdir -p ./firmware/firmware
name: ${{ matrix.variant }} find ./temp -type f -exec cp -t ./firmware/firmware {} +
path: ./build_output - name: Add "release" to footer
run: |
language-images: sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT release-/g" ./tasmota/include/tasmota_version.h
needs: safeboot-images - name: Run PlatformIO
runs-on: ubuntu-latest env:
if: github.repository == 'arendst/Tasmota' PYTHONIOENCODING: utf-8
continue-on-error: true PYTHONUTF8: '1'
strategy: run: platformio run -e ${{ matrix.variant }}
matrix: - name: Upload firmware artifacts
variant: [ tasmota, tasmota32 ] uses: actions/upload-artifact@v4
language: [ AD, AF, BG, BR, CN, CZ, DE, ES, FR, FY, GR, HE, HU, IT, KO, LT, NL, PL, PT, RO, RU, SE, SK, TR, TW, UK, VN ] with:
steps: name: ${{ matrix.variant }}
- uses: actions/checkout@v4 path: ./build_output
with:
ref: master language-images:
- name: Set up Python needs: safeboot-images
uses: actions/setup-python@v5 runs-on: ubuntu-latest
with: if: github.repository == 'arendst/Tasmota'
python-version: '3.x' continue-on-error: true
- name: Install dependencies strategy:
run: | matrix:
pip install wheel variant: [ tasmota, tasmota32 ]
pip install -U platformio language: [ AD, AF, BG, BR, CN, CZ, DE, ES, FR, FY, GR, HE, HU, IT, KO, LT, NL, PL, PT, RO, RU, SE, SK, TR, TW, UK, VN ]
cp ./platformio_override_sample.ini ./platformio_override.ini steps:
- name: Download safeboot firmwares - uses: actions/checkout@v4
uses: actions/download-artifact@v4 with:
with: ref: master
pattern: tasmota32* - name: Set up Python
path: ./temp uses: actions/setup-python@v5
- name: Move safeboot files with:
run: | python-version: '3.13'
mkdir -p ./firmware/firmware - name: Install dependencies
find ./temp -type f -exec cp -t ./firmware/firmware {} + run: |
- name: Add "release" to footer pip install uv
run: | uv pip install --system platformio
sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT release-/g" ./tasmota/include/tasmota_version.h cp ./platformio_override_sample.ini ./platformio_override.ini
- name: Run PlatformIO - name: Download safeboot firmwares
run: platformio run -e ${{ matrix.variant }}-${{ matrix.language }} uses: actions/download-artifact@v4
- name: Upload language firmware artifacts with:
uses: actions/upload-artifact@v4 pattern: tasmota32*
with: path: ./temp
name: ${{ matrix.variant }}-${{ matrix.language }} - name: Move safeboot files
path: ./build_output run: |
mkdir -p ./firmware/firmware
Release: find ./temp -type f -exec cp -t ./firmware/firmware {} +
needs: [base-images, base32-images, language-images] - name: Add "release" to footer
runs-on: ubuntu-latest run: |
continue-on-error: true sed -i -e "s/TASMOTA_SHA_SHORT/TASMOTA_SHA_SHORT release-/g" ./tasmota/include/tasmota_version.h
steps: - name: Run PlatformIO
- uses: actions/checkout@v4 env:
- name: Download all Tasmota artifacts PYTHONIOENCODING: utf-8
uses: actions/download-artifact@v4 PYTHONUTF8: '1'
with: run: platformio run -e ${{ matrix.variant }}-${{ matrix.language }}
pattern: tasmota* - name: Upload language firmware artifacts
path: ./temp uses: actions/upload-artifact@v4
- name: Move files with:
run: | name: ${{ matrix.variant }}-${{ matrix.language }}
mkdir -p ./release path: ./build_output
find ./temp -type f -exec cp -t ./release {} +
- name: Display structure of downloaded files Release:
run: ls -R ./release/ needs: [base-images, base32-images, language-images]
- name: Release runs-on: ubuntu-latest
uses: jason2866/action-gh-release@v1.2 continue-on-error: true
#if: startsWith(github.ref, 'refs/tags/') steps:
with: - uses: actions/checkout@v4
tag_name: ${{ github.run_number }} - name: Download all Tasmota artifacts
files: | uses: actions/download-artifact@v4
./release/tasmota* with:
env: pattern: tasmota*
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} path: ./temp
- name: Move files
Start_final_copy: run: |
needs: Release mkdir -p ./release
runs-on: ubuntu-latest find ./temp -type f -exec cp -t ./release {} +
steps: - name: Display structure of downloaded files
- name: Dispatch workflow in arendst/Tasmota-firmware run: ls -R ./release/
run: | - name: Release
curl -X POST https://api.github.com/repos/arendst/Tasmota-firmware/actions/workflows/fetch_deploy.yml/dispatches \ uses: jason2866/action-gh-release@v1.2
-H 'Accept: application/vnd.github.everest-preview+json' \ #if: startsWith(github.ref, 'refs/tags/')
-u ${{ secrets.API_TOKEN_GITHUB }} \ with:
--data '{"ref": "gh_actions"}' tag_name: ${{ github.run_number }}
files: |
./release/tasmota*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Start_final_copy:
needs: Release
runs-on: ubuntu-latest
steps:
- name: Dispatch workflow in arendst/Tasmota-firmware
run: |
curl -X POST https://api.github.com/repos/arendst/Tasmota-firmware/actions/workflows/fetch_deploy.yml/dispatches \
-H 'Accept: application/vnd.github.everest-preview+json' \
-u ${{ secrets.API_TOKEN_GITHUB }} \
--data '{"ref": "gh_actions"}'

View File

@ -19,7 +19,7 @@ on:
jobs: jobs:
os-check-win: os-check-win:
runs-on: windows-2019 runs-on: windows-latest
if: github.repository == 'arendst/Tasmota' if: github.repository == 'arendst/Tasmota'
strategy: strategy:
fail-fast: true fail-fast: true
@ -31,15 +31,15 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.x' python-version: '3.13'
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install wheel pip install uv
#python -m pip install --upgrade pip uv pip install --system platformio
pip install -U platformio
#platformio upgrade --dev
#platformio update
- name: Run PlatformIO - name: Run PlatformIO
env:
PYTHONIOENCODING: utf-8
PYTHONUTF8: '1'
run: platformio run -e ${{ matrix.variant }} run: platformio run -e ${{ matrix.variant }}
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
@ -59,15 +59,15 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.12' python-version: '3.13'
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install wheel pip install uv
#python -m pip install --upgrade pip uv pip install --system platformio
pip install -U platformio
#platformio upgrade --dev
#platformio update
- name: Run PlatformIO - name: Run PlatformIO
env:
PYTHONIOENCODING: utf-8
PYTHONUTF8: '1'
run: platformio run -e ${{ matrix.variant }} run: platformio run -e ${{ matrix.variant }}
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
@ -95,6 +95,7 @@ jobs:
- tasmota32c2 - tasmota32c2
- tasmota32c3 - tasmota32c3
- tasmota32c6 - tasmota32c6
- tasmota32p4
- tasmota32s2 - tasmota32s2
- tasmota32s2cdc - tasmota32s2cdc
- tasmota32s3 - tasmota32s3
@ -112,21 +113,22 @@ jobs:
- tasmota32c2-safeboot - tasmota32c2-safeboot
- tasmota32c3-safeboot - tasmota32c3-safeboot
- tasmota32c6-safeboot - tasmota32c6-safeboot
- tasmota32p4-safeboot
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.x' python-version: '3.13'
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install wheel pip install uv
#python -m pip install --upgrade pip uv pip install --system platformio
pip install -U platformio
#platformio upgrade --dev
#platformio update
cp ./platformio_override_sample.ini ./platformio_override.ini cp ./platformio_override_sample.ini ./platformio_override.ini
- name: Run PlatformIO - name: Run PlatformIO
env:
PYTHONIOENCODING: utf-8
PYTHONUTF8: '1'
run: platformio run -e ${{ matrix.variant }} run: platformio run -e ${{ matrix.variant }}
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:
@ -146,15 +148,15 @@ jobs:
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v5 uses: actions/setup-python@v5
with: with:
python-version: '3.x' python-version: '3.13'
- name: Install dependencies - name: Install dependencies
run: | run: |
pip install wheel pip install uv
#python -m pip install --upgrade pip uv pip install --system platformio
pip install -U platformio
#platformio upgrade --dev
#platformio update
- name: Run PlatformIO - name: Run PlatformIO
env:
PYTHONIOENCODING: utf-8
PYTHONUTF8: '1'
run: platformio run -e ${{ matrix.variant }}-${{ matrix.language }} run: platformio run -e ${{ matrix.variant }}-${{ matrix.language }}
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
with: with:

5
.gitignore vendored
View File

@ -19,6 +19,8 @@ managed_components
.cache .cache
.dummy .dummy
sdkconfig.* sdkconfig.*
sdkconfig.defaults
CMakeLists.txt
data data
unpacked_fs unpacked_fs
unpacked_boards unpacked_boards
@ -49,6 +51,9 @@ lib/libesp32/berry/berry
*.bak *.bak
*.code-workspace *.code-workspace
## IntelliJ ######
.idea
## Python virtual environments for Platformio ## ## Python virtual environments for Platformio ##
venv venv
.venv .venv

View File

@ -14,10 +14,13 @@ Note: the `minimal` variant is not listed as it shouldn't be used outside of the
| USE_HOME_ASSISTANT | - | - / - | - | - | - | - | | USE_HOME_ASSISTANT | - | - / - | - | - | - | - |
| USE_TASMOTA_DISCOVERY | x | x / x | x | x | x | x | | USE_TASMOTA_DISCOVERY | x | x / x | x | x | x | x |
| USE_MQTT_TLS\* | - | - / x | - | - | - | - | | USE_MQTT_TLS\* | - | - / x | - | - | - | - |
| USE_MQTT_CLIENT_CERT | - | - / - | - | - | - | - |
| USE_MQTT_AWS_IOT | - | - / - | - | - | - | - | | USE_MQTT_AWS_IOT | - | - / - | - | - | - | - |
| USE_4K_RSA | - | - / - | - | - | - | - | | USE_4K_RSA | - | - / - | - | - | - | - |
| USE_TELEGRAM | - | - / - | - | - | - | - | | USE_TELEGRAM | - | - / - | - | - | - | - |
| USE_KNX | - | - / x | x | - | - | - | | USE_KNX | - | - / x | x | - | - | - |
| USE_TELNET | - | - / - | - | - | - | - |
| USE_XYZMODEM | - | - / - | - | - | - | - |
| USE_WEBSERVER | x | x / x | x | x | x | x | | USE_WEBSERVER | x | x / x | x | x | x | x |
| USE_WEBSEND_RESPONSE | - | - / - | - | - | - | - | | USE_WEBSEND_RESPONSE | - | - / - | - | - | - | - |
| USE_EMULATION_HUE | x | x / x | - | x | - | - | | USE_EMULATION_HUE | x | x / x | - | x | - | - |
@ -228,7 +231,9 @@ Note: the `minimal` variant is not listed as it shouldn't be used outside of the
| USE_MIEL_HVAC | - | - / - | - | - | - | - | | USE_MIEL_HVAC | - | - / - | - | - | - | - |
| USE_PROJECTOR_CTRL | - | - / - | - | - | - | - | | USE_PROJECTOR_CTRL | - | - / - | - | - | - | - |
| USE_AS608 | - | - / - | - | - | - | - | | USE_AS608 | - | - / - | - | - | - | - |
| USE_LD2402 | - | - / - | - | - | - | - |
| USE_LD2410 | - | - / - | - | - | - | - | | USE_LD2410 | - | - / - | - | - | - | - |
| USE_LD2410S | - | - / - | - | - | - | - |
| USE_GM861 | - | - / - | - | - | - | - | | USE_GM861 | - | - / - | - | - | - | - |
| USE_TCP_BRIDGE | - | - / - | - | - | - | - | zbbridge / zbbrdgpro | | USE_TCP_BRIDGE | - | - / - | - | - | - | - | zbbridge / zbbrdgpro |
| USE_HC8 | - | - / - | - | - | - | - | | USE_HC8 | - | - / - | - | - | - | - |

View File

@ -1,8 +1,201 @@
# Changelog # Changelog
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
## [Unreleased] - Development
## [15.0.1.2]
### Added
- Command `I2sPause` (#23646)
- Basic support for ESP32-P4 (#23663)
- ESP32-P4 command `HostedOta` (#23675)
- Support for RV3028 RTC (#23672)
### Breaking Changed
### Changed
- ESP32 Platform from 2025.05.30 to 2025.07.30, Framework (Arduino Core) from v3.1.3.250504 to v3.1.3.250707 and IDF from v5.3.3.250501 to v5.3.3.250707 (#23642)
- Domoticz supports persistent settings for all relays, keys and switches when filesystem `#define USE_UFILESYS` is enabled
- ESP32 Platform from 2025.07.30 to 2025.07.31, Framework (Arduino Core) from v3.1.3.250707 to v3.1.3.250712 and IDF from v5.3.3.250707 to v5.3.3.250707 (#23685)
- ESP8266 platform update from 2025.05.00 to 2025.07.00 (#23700)
- OpenTherm library from v0.9.0 to v1.1.5 (#23704)
### Fixed
### Removed
## [15.0.1.1] 20250708
### Added
- I2S additions (#23543)
- NeoPool add Redox tank alarm (#19811)
- Berry f-strings now support ':' in expression (#23618)
- Universal display driver for ZJY169S0800TG01 ST7789 280x240 (#23638)
- Commands `LoRaWanDecoder "` and `LoRaWanName "` to clear name (#23394)
- Internal function 'WSContentSendRaw_P' (#23641)
### Changed
- BLE updates for esp-nimble-cpp v2.x (#23553)
- Library names (#23560)
- ESP32 LoRaWan decoding won't duplicate non-decoded message if `SO147 0`
- VEML6070 and AHT2x device detection (#23581)
- CSS uses named colors variables (#23597)
### Fixed
- LVGL restore `lv_chart.set_range` removed in LVGL 9.3.0 in favor of `lv_chart.set_axis_range` (#23567)
- Berry vulnerability in JSON parsing for unicode (#23603)
- Berry security issues in `int64` and improve documentation (#23605)
- Berry security issues in `berry_mapping` and improve documentation (#23606)
- Berry Hue regression from #23429 (#23623)
- AHT30 sensor start with null values after deep sleep (#23624)
## [Released] ## [Released]
## [15.0.1] 20250614
- Release Sharon
## [15.0.0.1] 20250614
### Fixed
- LVGL regression missing `lv.ANIM_OFF` and `lv.ANIM_ON` (#23544)
- Berry fix `realline` (#23546)
- LVGL HASPmota fix regression introduced with LVGL 9.3.0 (#23547)
## [15.0.0] 20250613
- Release Sharon
## [14.6.0.2] 20250613
### Added
- Allow temporary change of DisplayDimmer (#23406)
- Support for LoRaWan Rx1 and Rx2 profiles (#23394)
- HASPmota auto-dimming when no touch (#23425)
- Provide serial upload port from VSC to PIO (#23436)
- Berry support for `sortedmap` (#23441)
- Berry `introspect.module` option to not cache module entry (#23451)
- Berry `webserver.remove_route` to revert `webserver.on` (#23452)
- Berry `compile` and `tasmota.compile` option to compile in local context (#23457)
- Support for AP33772S USB PD Sink Controller as used in CentyLab RotoPD
- Berry mqtt publish rule processing
- Berry `tasmota.is_network_up()` (#23532)
### Changed
- ESP32 Platform from 2025.04.30 to 2025.05.40, Framework (Arduino Core) from v3.1.3.250411 to v3.2.0.250504 and IDF from v5.3.2.250403 to v5.4.1.250501 (#23397)
- ESP32 Platform from 2025.05.40 to 2025.05.30, Framework (Arduino Core) from v3.2.0.250504 to v3.1.3.250504 and IDF from v5.4.1.250501 to v5.3.3.250501 (#23404)
- ESP8266 platform update from 2024.09.00 to 2025.05.00 (#23448)
- Increase number of supported LoRaWan nodes from 4 to 16
- Berry change number parser for json to reuse same parser as lexer (#23505)
- Berry increase web hooks from 16 to 32 (#23507)
- ESP32 LVGL library from v9.2.2 to v9.3.0 (#23518)
- Zigbee improved message when coordinator failed to start (#23525)
- Format syslog messages according to RFC5424 adding local log time (#23509)
### Fixed
- Haspmota `haspmota.parse()` page parsing (#23403)
- ESP32-S3 display stability regression from #23397 (#23404)
- DNS setting with `IPAddress4/5` not persisted (#23426)
- Berry avoid json parsing for unmatched commands (#23494)
- Berry integer and real parser to handle overflows (#23495)
- Berry potential pointer underflow with `string.endswith` (#23496)
- Autoconf failing when last line has no trailing LF (#23537)
- LVGL Tasmota logo splash screen (#23538)
## [14.6.0.1] 20250510
### Added
- Command `JsonPP 0..7` to enable (>0) JSON Pretty Print on user interfaces and set number of indents
- Command `JsonPP <command>|backlog <command>;...` to enable JSON PP only once
- WebUI status line for MQTT and TLS, added `FUNC_WEB_STATUS` event (#23326)
- Wireguard VPN (#23347)
- Optional Wifi strength indicator in WebUI status line (#23352)
- WebUI status line left and renamed events `FUNC_WEB_STATUS_LEFT` and `FUNC_WEB_STATUS_RIGHT` (#23354)
- WebUI heap status (#23356)
- Support for multi channel AU915-928 LoRaWanBridge by Rob Clark (#23372)
- HASPmota `antiburn()` (#23400)
### Changed
- Allow command `WebRefresh` minimum from 1000 to 400 mSec
- GPIOViewer from v1.6.2 to v1.6.3 (No functional change)
### Fixed
- Berry `bytes().asstring()` now truncates a string if buffer contains NULL (#23311)
- Berry string literals containing NULL are truncated (#23312)
- Berry `display.touch_update` wrongly applies resistive calibration (#23363)
- NimBLE log_level definition conflict (#23366)
- Matter and mDNS can be enabled at the same time (#23373)
- Berry `introspect.module()` failed to load modules in files (#23376)
## [14.6.0] 20250416
- Release Ryan
## [14.5.0.3] 20250416
### Added
- Extend command `GPIO` with different display options and allowing updating of module GPIO's in one go
- Berry `bytes.add()` now accepts 3-bytes values (#23200)
- Berry expose `esp_http_server` for websockets (#23206)
- AlpineJS 2.8.2 - optional for now (#23259)
- Support for XMODEM over serial and telnet if enabled with `#define USE_XYZMODEM`
- PZEM_AC device address in JSON and GUI (#23268)
- Filesystem command ``UfsList[2]``
- ESP32 show network interface priority in `Status 5` debug logging (#23302)
### Breaking Changed
- HASPmota added `y2_min` and `y2_max` to control the second series of `chart` (#23287)
- HASPmota default theme is now Tasmota-style (#23288)
### Changed
- Output of commands `GPIO` and `GPIOs` swapped
- Smoothen light gamma curve when using `Fade` (#23230)
- ESP32 Platform from 2025.03.30 to 2025.04.30, Framework (Arduino Core) from v3.1.3.250302 to v3.1.3.250411 and IDF from v5.3.2.250228 to 5.3.2.250403 (#23280)
- HLK-LD2402 updates for firmware 3.3.5+ (#23281)
### Fixed
- INA226 driver fixes (#23197)
- TLS increase timeout and fix crash (#23249)
- Berry `readline` when a line is exactly 98 characters (#23276)
## [14.5.0.2] 20250325
### Added
- Berry load `.tapp` files in `/.extensions/` then in `/` (#23113)
- Support Vango Technologies V924x ultralow power, single-phase, power measurement (#23127)
- Support for HLK-LD2402 24GHz smart wave motion sensor (#23133)
- Matter prepare for ICD cluster (#23158)
- Berry `re.dump()` (#23162)
- Support for Telnet server using command `Telnet <0|1|port>[,<IP filter>]` if enabled with `#define USE_TELNET`
- HASPmota autostart when `pages.jsonl` exists (#23181)
### Breaking Changed
- Berry remove `Leds.create_matrix` from the standard library waiting for reimplementation (#23114)
### Changed
- ESP32 Platform from 2025.02.30 to 2025.03.30, Framework (Arduino Core) from v3.1.1.250203 to v3.1.3.250302 and IDF from v5.3.2.250120 to 5.3.2.250228 (#23088)
- ESP32 enable webcam version 2 (#18732)
- ESP8266 enable FTP for >= 4MB variants (#23120)
- Berry update flasher for Sonoff ZBBridge Pro (#23136)
- Berry `re` now accepts `bytes()` as precompiled patterns, added `re.compilebytes()` (#23149)
- RCSwitch `RCSWITCH_SEPARATION_LIMIT` from 4100 to 3600
### Fixed
- Berry prevent `import` from hiding a solidified class (#23112)
- ESP32-C3 WiFi sleep (#23096)
- ESP32 intermittent exception on WiFi AP cannot be reached (#23115)
- ESP32 receive incomplete serial data over 128 bytes (#23156)
## [14.5.0.1] 20250302
### Added
- Berry experimental driver for AXP2101 for M5Core2v1.1 (#23039)
- LVGL experimental mirroring of display on Web UI (#23041)
- Allow acl in mqtt when client certificate is in use with `#define USE_MQTT_CLIENT_CERT` (#22998)
- Berry `tasmota.when_network_up()` and simplified Matter using it (#23057)
- Berry `introspect.solidified()` to know if a Berry object is solidified or in RAM (#23063)
- Berry `global.undef()` to undefine a global variable (#23073)
### Changed
- LVGL, prepare for HASPmota theme, change: no-grow when clicked, DPI set to 160 (#23040)
- LVGL Mirroring add checkbox to enable/disable the feature (in the iterim for a better solution) (#23047)
- Leds Panel add checkbox to enable/disable the feature (in the iterim for a better solution) (#23048)
- GPIOViewer from v1.6.1 to v1.6.2 (No functional change)
### Fixed
- Too many zeros in RCSwitch received data regression from v14.4.1.4 (#23050)
## [14.5.0] 20250219 ## [14.5.0] 20250219
- Release Ruth - Release Ruth

View File

@ -89,8 +89,9 @@ In addition to @arendst the following code is mainly owned by:
| xdrv_75_dali | @eeak, @arendst | xdrv_75_dali | @eeak, @arendst
| xdrv_76_serial_i2c | @s-hadinger | xdrv_76_serial_i2c | @s-hadinger
| xdrv_77_wizmote | @arendst | xdrv_77_wizmote | @arendst
| xdrv_78 | | xdrv_78_telnet | @arendst
| xdrv_79_esp32_ble | @staars, @btsimonh | xdrv_79_esp32_ble | @staars, @btsimonh
| xdrv_80_wireguard_client | @s-hadinger
| xdrv_81_esp32_webcam | @gemu, @philrich | xdrv_81_esp32_webcam | @gemu, @philrich
| xdrv_82_esp32_ethernet | @arendst | xdrv_82_esp32_ethernet | @arendst
| xdrv_83_esp32_watch | @gemu | xdrv_83_esp32_watch | @gemu
@ -100,11 +101,13 @@ In addition to @arendst the following code is mainly owned by:
| xdrv_88_esp32_shelly_pro | @arendst | xdrv_88_esp32_shelly_pro | @arendst
| xdrv_89_ | | xdrv_89_ |
| xdrv_90_esp32_dingtian_relay | @barbudor | xdrv_90_esp32_dingtian_relay | @barbudor
| xdrv_91_ | | xdrv_91_esp32_twai | @arendst
| xdrv_92_ | | xdrv_92_ |
| xdrv_93_ | | xdrv_93_ |
| xdrv_94_ | | xdrv_94_ |
| | | |
| xdrv_119_i2c_ap33772s | @arendst
| xdrv_120_xyzmodem | @arendst
| xdrv_121_gpioviewer | @arendst | xdrv_121_gpioviewer | @arendst
| xdrv_122_file_settings_demo | @arendst | xdrv_122_file_settings_demo | @arendst
| xdrv_122_file_json_settings_demo | @arendst | xdrv_122_file_json_settings_demo | @arendst

View File

@ -18,7 +18,7 @@ See [CHANGELOG.md](https://github.com/arendst/Tasmota/blob/development/CHANGELOG
## Development ## Development
[![Dev Version](https://img.shields.io/badge/development%20version-v14.5.x.x-blue.svg)](https://github.com/arendst/Tasmota) [![Dev Version](https://img.shields.io/badge/development%20version-v15.0.x.x-blue.svg)](https://github.com/arendst/Tasmota)
[![Download Dev](https://img.shields.io/badge/download-development-yellow.svg)](http://ota.tasmota.com/tasmota/) [![Download Dev](https://img.shields.io/badge/download-development-yellow.svg)](http://ota.tasmota.com/tasmota/)
[![Tasmota CI](https://github.com/arendst/Tasmota/workflows/Tasmota%20CI/badge.svg)](https://github.com/arendst/Tasmota/actions?query=workflow%3A%22Tasmota+CI%22) [![Tasmota CI](https://github.com/arendst/Tasmota/workflows/Tasmota%20CI/badge.svg)](https://github.com/arendst/Tasmota/actions?query=workflow%3A%22Tasmota+CI%22)
[![Tasmota ESP32 CI](https://github.com/arendst/Tasmota/workflows/Tasmota%20ESP32%20CI/badge.svg)](https://github.com/arendst/Tasmota/actions?query=workflow%3A%22Tasmota+ESP32+CI%22) [![Tasmota ESP32 CI](https://github.com/arendst/Tasmota/workflows/Tasmota%20ESP32%20CI/badge.svg)](https://github.com/arendst/Tasmota/actions?query=workflow%3A%22Tasmota+ESP32+CI%22)

View File

@ -130,5 +130,7 @@ Index | Define | Driver | Device | Address(es) | Bus2 | Descrip
90 | USE_RX8010 | xdrv_56 | RX8010 | 0x32 | Yes | RX8010 RTC from IOTTIMER 90 | USE_RX8010 | xdrv_56 | RX8010 | 0x32 | Yes | RX8010 RTC from IOTTIMER
91 | USE_MS5837 | xsns_116 | MS5837 | 0x76 | | Pressure and temperature sensor 91 | USE_MS5837 | xsns_116 | MS5837 | 0x76 | | Pressure and temperature sensor
92 | USE_PCF85063 | xdrv_56 | PCF85063 | 0x51 | | PCF85063 Real time clock 92 | USE_PCF85063 | xdrv_56 | PCF85063 | 0x51 | | PCF85063 Real time clock
93 | USE_AS33772S | xdrv_119 | AS33772S | 0x52 | Yes | AS33772S USB PD Sink Controller
94 | USE_RV3028 | xdrv_56 | RV3028 | 0x52 | Yes | RV-3028-C7 RTC Controller
NOTE: Bus2 supported on ESP32 only. NOTE: Bus2 supported on ESP32 only.

View File

@ -31,7 +31,7 @@ Firmware binaries can be downloaded from http://ota.tasmota.com/tasmota/release/
## Development ## Development
[![Dev Version](https://img.shields.io/badge/development%20version-v14.5.x.x-blue.svg)](https://github.com/arendst/Tasmota) [![Dev Version](https://img.shields.io/badge/development%20version-v15.0.x.x-blue.svg)](https://github.com/arendst/Tasmota)
[![Download Dev](https://img.shields.io/badge/download-development-yellow.svg)](http://ota.tasmota.com/tasmota/) [![Download Dev](https://img.shields.io/badge/download-development-yellow.svg)](http://ota.tasmota.com/tasmota/)
[![Tasmota CI](https://github.com/arendst/Tasmota/actions/workflows/build_all_the_things.yml/badge.svg)](https://github.com/arendst/Tasmota/actions/workflows/build_all_the_things.yml) [![Tasmota CI](https://github.com/arendst/Tasmota/actions/workflows/build_all_the_things.yml/badge.svg)](https://github.com/arendst/Tasmota/actions/workflows/build_all_the_things.yml)
[![Build_development](https://github.com/arendst/Tasmota/actions/workflows/Tasmota_build_devel.yml/badge.svg)](https://github.com/arendst/Tasmota/actions/workflows/Tasmota_build_devel.yml) [![Build_development](https://github.com/arendst/Tasmota/actions/workflows/Tasmota_build_devel.yml/badge.svg)](https://github.com/arendst/Tasmota/actions/workflows/Tasmota_build_devel.yml)

View File

@ -36,9 +36,9 @@ While fallback or downgrading is common practice it was never supported due to S
This release will be supported from ESP8266/Arduino library Core version **2.7.8** due to reported security and stability issues on previous Core version. This will also support gzipped binaries. This release will be supported from ESP8266/Arduino library Core version **2.7.8** due to reported security and stability issues on previous Core version. This will also support gzipped binaries.
This release will be supported from ESP32/Arduino library Core version **v3.1.1.250203**. This release will be supported from ESP32/Arduino library Core version **v3.1.3.250504**.
Support of ESP8266 Core versions before 2.7.8 and ESP32 Core versions before v3.1.1.250203 have been removed. Support of ESP8266 Core versions before 2.7.8 and ESP32 Core versions before v3.1.3.250504 have been removed.
## Support of TLS ## Support of TLS
@ -75,12 +75,12 @@ Latest released binaries can be downloaded from
- http://ota.tasmota.com/tasmota/release - http://ota.tasmota.com/tasmota/release
Historical binaries can be downloaded from Historical binaries can be downloaded from
- http://ota.tasmota.com/tasmota/release-14.5.0 - http://ota.tasmota.com/tasmota/release-15.0.1
The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmota.com/tasmota/release/tasmota.bin.gz`` The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmota.com/tasmota/release/tasmota.bin.gz``
### ESP32, ESP32-C2, ESP32-C3, ESP32-C6, ESP32-S2 and ESP32-S3 based ### ESP32, ESP32-C2, ESP32-C3, ESP32-C6, ESP32-S2 and ESP32-S3 based
The following binary downloads have been compiled with ESP32/Arduino library core version **v3.1.1.250203**. The following binary downloads have been compiled with ESP32/Arduino library core version **v3.1.3.250504**.
- **tasmota32.bin** = The Tasmota version with most drivers including additional sensors and KNX for 4M+ flash. **RECOMMENDED RELEASE BINARY** - **tasmota32.bin** = The Tasmota version with most drivers including additional sensors and KNX for 4M+ flash. **RECOMMENDED RELEASE BINARY**
- **tasmota32solo1.bin** = The Tasmota version with most drivers including additional sensors and KNX for single core ESP32 and 4M+ flash. - **tasmota32solo1.bin** = The Tasmota version with most drivers including additional sensors and KNX for single core ESP32 and 4M+ flash.
@ -88,7 +88,7 @@ The following binary downloads have been compiled with ESP32/Arduino library cor
- **tasmota32s2cdc.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-S2 with serial over embedded USB CDC only and 4M+ flash. - **tasmota32s2cdc.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-S2 with serial over embedded USB CDC only and 4M+ flash.
- **tasmota32s3.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-S3 with USB HWCDC and fallback to serial and 4M+ flash. - **tasmota32s3.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-S3 with USB HWCDC and fallback to serial and 4M+ flash.
- **tasmota32c2.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-C2 with serial and 4M+ flash. - **tasmota32c2.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-C2 with serial and 4M+ flash.
- **tasmota32c3.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-C2 with USB HWCDC and fallback to serial and 4M+ flash. - **tasmota32c3.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-C3 with USB HWCDC and fallback to serial and 4M+ flash.
- **tasmota32c6.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-C6 with USB HWCDC and fallback to serial and 4M+ flash. - **tasmota32c6.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-C6 with USB HWCDC and fallback to serial and 4M+ flash.
- **tasmota32-AD.bin** to **tasmota32-VN.bin** = The Tasmota version in different languages for 4M+ flash. - **tasmota32-AD.bin** to **tasmota32-VN.bin** = The Tasmota version in different languages for 4M+ flash.
- **tasmota32-bluetooth.bin** = The Bluetooth version adds BLE support for 4M+ flash. - **tasmota32-bluetooth.bin** = The Bluetooth version adds BLE support for 4M+ flash.
@ -104,7 +104,7 @@ Latest released binaries can be downloaded from
- https://ota.tasmota.com/tasmota32/release - https://ota.tasmota.com/tasmota32/release
Historical binaries can be downloaded from Historical binaries can be downloaded from
- https://ota.tasmota.com/tasmota32/release-14.5.0 - https://ota.tasmota.com/tasmota32/release-15.0.1
The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasmota.com/tasmota32/release/tasmota32.bin`` The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasmota.com/tasmota32/release/tasmota32.bin``
@ -114,76 +114,38 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
[Complete list](BUILDS.md) of available feature and sensors. [Complete list](BUILDS.md) of available feature and sensors.
## Changelog v14.5.0 Ruth ## Changelog v15.0.1.2
### Added ### Added
- Command `SetOption163 1` to disable display of Device name in GUI header - Commands `LoRaWanDecoder "` and `LoRaWanName "` to clear name [#23394](https://github.com/arendst/Tasmota/issues/23394)
- Command `FileLog 0..4` to enable logging to filesystem using up to 16 rotating log files of 100kB (`#define FILE_LOG_SIZE 100`) - Command `I2sPause` [#23646](https://github.com/arendst/Tasmota/issues/23646)
- Command `FileLog 10..14` to enable logging to filesystem using up to 16 log files of 100kB (`#define FILE_LOG_SIZE 100`) - Support for RV3028 RTC [#23672](https://github.com/arendst/Tasmota/issues/23672)
- Command I2sLoop [#22807](https://github.com/arendst/Tasmota/issues/22807) - Internal function 'WSContentSendRaw_P' [#23641](https://github.com/arendst/Tasmota/issues/23641)
- Support for Lithuanian language translations by zzdovydas [#22971](https://github.com/arendst/Tasmota/issues/22971) - Universal display driver for ZJY169S0800TG01 ST7789 280x240 [#23638](https://github.com/arendst/Tasmota/issues/23638)
- Support for PCF85063 RTC [#22727](https://github.com/arendst/Tasmota/issues/22727) - NeoPool add Redox tank alarm [#19811](https://github.com/arendst/Tasmota/issues/19811)
- Support for Senseair S88 CO2 sensor [#22733](https://github.com/arendst/Tasmota/issues/22733) - I2S additions [#23543](https://github.com/arendst/Tasmota/issues/23543)
- Support for C8-CO2-5K CO2 sensor [#22905](https://github.com/arendst/Tasmota/issues/22905) - Basic support for ESP32-P4 [#23663](https://github.com/arendst/Tasmota/issues/23663)
- Support for ESP32 Two-Wire Automotive Interface (TWAI) or Controller Area Network (CAN) busses - ESP32-P4 command `HostedOta` [#23675](https://github.com/arendst/Tasmota/issues/23675)
- `#define FIX_JSON_HEXADECIMAL` to change JSON hexadecimal value "FF5F78" into "0xFF5F78" [#22919](https://github.com/arendst/Tasmota/issues/22919) - Berry f-strings now support ':' in expression [#23618](https://github.com/arendst/Tasmota/issues/23618)
- Support for RC-switch decoding of 64-bit received data
- Support for WiZ Smart Remote using `#define USE_WIZMOTE` and command `SetOption164 1` ### Breaking Changed
- `MqttTLS` field in `Status 6` to indicate if the MQTT connection is encrypted [#22995](https://github.com/arendst/Tasmota/issues/22995)
- Formatter `%_U` for `ext_snprintf_P()` to print uint64_t variable as decimal equivalent to `%llu`
- GPS driver select baudrate using GPIO GPS_RX1 (9600bps), GPS_RX2 (19200bps) or GPS_RX3 (38400bps) [#22869](https://github.com/arendst/Tasmota/issues/22869)
- I2S AAC support for web radio [#22787](https://github.com/arendst/Tasmota/issues/22787)
- I2S Opus stream and file support for opus/aac [#22795](https://github.com/arendst/Tasmota/issues/22795)
- ESP32 command `PixelType` to change the WS2812 color order and channel number [#22876](https://github.com/arendst/Tasmota/issues/22876)
- ESP32 TasmotaLED change dynamically the number of pixels [#22754](https://github.com/arendst/Tasmota/issues/22754)
- ESP32 expand `Pixels` with reverse, height and alternate [#22755](https://github.com/arendst/Tasmota/issues/22755)
- Display template for Waveshare ESP32-C6 LCD 1.47 [#22863](https://github.com/arendst/Tasmota/issues/22863)
- Berry `animate.crenel` primitive [#22673](https://github.com/arendst/Tasmota/issues/22673)
- Berry `tasmota.int(v, min, max)` function [#22723](https://github.com/arendst/Tasmota/issues/22723)
- Berry `bytes().appendhex()` [#22767](https://github.com/arendst/Tasmota/issues/22767)
- Berry `serial.read()` read only `n` bytes [#22835](https://github.com/arendst/Tasmota/issues/22835)
- Berry `tasmota.global.tele_period` and `tasmota.settings.tele_period` [#22865](https://github.com/arendst/Tasmota/issues/22865)
- Berry `tasmota.settings` entries for PixelType [#22912](https://github.com/arendst/Tasmota/issues/22912)
- Berry `tasmota.add_rule_once` and auto-remove rules with same pattern and id [#22900](https://github.com/arendst/Tasmota/issues/22900)
- Berry driver for M5Stack 8encoder [#22724](https://github.com/arendst/Tasmota/issues/22724)
- Berry driver for AXP2102 and M5CoreS3 [#22878](https://github.com/arendst/Tasmota/issues/22878)
- Berry driver for PN532 NFC/Mifare reader [#22899](https://github.com/arendst/Tasmota/issues/22899)
- Berry example for HeatFan WiFi Controller
- Berry WS2812 real-time Leds panel as app [#22788](https://github.com/arendst/Tasmota/issues/22788)
- Berry scroll to Leds_matrix [#22693](https://github.com/arendst/Tasmota/issues/22693)
- Berry unicode encoding to string parsing [#22713](https://github.com/arendst/Tasmota/issues/22713)
- Berry light_pixels values to `tasmota.settings` [#22762](https://github.com/arendst/Tasmota/issues/22762)
- Berry `tasmota.defer()` [#22976](https://github.com/arendst/Tasmota/issues/22976)
- Berry `bytes().appendb64()` [#22767](https://github.com/arendst/Tasmota/issues/22767)
- LVLG/HASPmota add color names from OpenHASP [#22879](https://github.com/arendst/Tasmota/issues/22879)
- LVGL `lv.set_paint_cb()` to register a callback when screen is refreshed [#22909](https://github.com/arendst/Tasmota/issues/22909)
- HASPmota support for `buttonmatrix` events [#22898](https://github.com/arendst/Tasmota/issues/22898)
### Changed ### Changed
- ESP32 Platform from 2024.12.30 to 2025.02.30, Framework (Arduino Core) from v3.1.0.241206 to v3.1.1.250203 and IDF to 5.3.2 [#22943](https://github.com/arendst/Tasmota/issues/22943) - ESP32 Platform from 2025.05.30 to 2025.07.31, Framework (Arduino Core) from v3.1.3.250504 to v3.1.3.250712 and IDF from v5.3.3.250501 to v5.3.3.250707 [#23685](https://github.com/arendst/Tasmota/issues/23685)
- GPIOViewer from v1.5.6 to v1.6.1 (No functional change) - ESP8266 platform update from 2025.05.00 to 2025.07.00 [#23700](https://github.com/arendst/Tasmota/issues/23700)
- Postpone save_data during light animation when fade is Off - OpenTherm library from v0.9.0 to v1.1.5 [#23704](https://github.com/arendst/Tasmota/issues/23704)
- Allow negative values for AdcParam/AdcGpio INPUT, TEMP and RANGE parameters [#22809](https://github.com/arendst/Tasmota/issues/22809) - Library names [#23560](https://github.com/arendst/Tasmota/issues/23560)
- Command `Pixels` has backwards compatible arguments fixing #22755 [#22791](https://github.com/arendst/Tasmota/issues/22791) - CSS uses named colors variables [#23597](https://github.com/arendst/Tasmota/issues/23597)
- ESP32 disable PSRAM check (and on restart some relay toggles) with `#define DISABLE_PSRAMCHECK true` [#21266](https://github.com/arendst/Tasmota/issues/21266) - VEML6070 and AHT2x device detection [#23581](https://github.com/arendst/Tasmota/issues/23581)
- ESP32 Webcam resolution changes since v14.4.0 [#22901](https://github.com/arendst/Tasmota/issues/22901) - Domoticz supports persistent settings for all relays, keys and switches when filesystem `#define USE_UFILESYS` is enabled
- Berry `gpio.pin_mode` frees PWM on pin - ESP32 LoRaWan decoding won't duplicate non-decoded message if `SO147 0`
- Berry bit-shift operators to `int64` [#22709](https://github.com/arendst/Tasmota/issues/22709) - BLE updates for esp-nimble-cpp v2.x [#23553](https://github.com/arendst/Tasmota/issues/23553)
- Berry callback now passes 5 arguments instead of 4 (in line with documentation) [#22908](https://github.com/arendst/Tasmota/issues/22908)
- HASPmota use 'roboto.ttf' for automatic sizing of default font [#22697](https://github.com/arendst/Tasmota/issues/22697)
- HASPmota add 'tag' attribute for free-form JSON [#22698](https://github.com/arendst/Tasmota/issues/22698)
- HASPmota support for `tabview` [#22707](https://github.com/arendst/Tasmota/issues/22707)
### Fixed ### Fixed
- Shutter discovery message regression from v14.4.1 [#22730](https://github.com/arendst/Tasmota/issues/22730) - AHT30 sensor start with null values after deep sleep [#23624](https://github.com/arendst/Tasmota/issues/23624)
- LoraWan decoding of Dragino LDS02 and MerryIoT DW10 [#22880](https://github.com/arendst/Tasmota/issues/22880) - Berry vulnerability in JSON parsing for unicode [#23603](https://github.com/arendst/Tasmota/issues/23603)
- ESP32 TasMesh broker MAC address all zeros [#23005](https://github.com/arendst/Tasmota/issues/23005) - Berry security issues in `int64` and improve documentation [#23605](https://github.com/arendst/Tasmota/issues/23605)
- ESP32-Cx compilation fails on Windows [#22832](https://github.com/arendst/Tasmota/issues/22832) - Berry security issues in `berry_mapping` and improve documentation [#23606](https://github.com/arendst/Tasmota/issues/23606)
- Wrong RMT channels for ESP32S3, now depends on `soc_caps.h` [#23021](https://github.com/arendst/Tasmota/issues/23021) - Berry Hue regression from #23429 [#23623](https://github.com/arendst/Tasmota/issues/23623)
- Sonoff SPM `PowerOnState` overrules `SSPMPowerOnState` in mixed 4Relay setup with 4Relay version 1.0.0 - LVGL restore `lv_chart.set_range` removed in LVGL 9.3.0 in favor of `lv_chart.set_axis_range` [#23567](https://github.com/arendst/Tasmota/issues/23567)
- Webcam compilation with `define USE_WEBCAM` but without `define ENABLE_RTSPSERVER` [#22686](https://github.com/arendst/Tasmota/issues/22686)
- Berry Zigbee fix wrong attributes [#22684](https://github.com/arendst/Tasmota/issues/22684) ### Removed
- Berry walrus operator [#22685](https://github.com/arendst/Tasmota/issues/22685)
- Berry parser error in rare case [#22997](https://github.com/arendst/Tasmota/issues/22997)
- LVGL updated `Antiburn.tapp` [#22699](https://github.com/arendst/Tasmota/issues/22699)
- HASPmota exception when clicking on a checkbox [#23022](https://github.com/arendst/Tasmota/issues/23022)
- Matter Air Quality sensor [#22708](https://github.com/arendst/Tasmota/issues/22708)

View File

@ -5,7 +5,7 @@
# Templates # Templates
Find below the available templates as of February 2025. More template information can be found in the [Tasmota Device Templates Repository](http://blakadder.github.io/templates) Find below the available templates as of June 2025. More template information can be found in the [Tasmota Device Templates Repository](http://blakadder.github.io/templates)
## Adapter Board ## Adapter Board
``` ```
@ -403,7 +403,6 @@ Shelly Vintage 4W 260lm 2700k {"NAME":"Shelly Vintage","GPIO":[0,0,0,0,416,0,0,
Shelly Vintage 7W 750lm 2700k {"NAME":"Shelly Vintage","GPIO":[0,0,0,0,416,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18} Shelly Vintage 7W 750lm 2700k {"NAME":"Shelly Vintage","GPIO":[0,0,0,0,416,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}
Shelly Vintage 7W 750lm 2700k {"NAME":"Shelly Vintage","GPIO":[0,0,0,0,416,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18} Shelly Vintage 7W 750lm 2700k {"NAME":"Shelly Vintage","GPIO":[0,0,0,0,416,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}
SmartDGM 9W 806lm {"NAME":"L-WB9W1","GPIO":[0,0,0,0,0,416,0,0,160,0,0,0,0,0],"FLAG":0,"BASE":18} SmartDGM 9W 806lm {"NAME":"L-WB9W1","GPIO":[0,0,0,0,0,416,0,0,160,0,0,0,0,0],"FLAG":0,"BASE":18}
Smitch 10W 6500K {"NAME":"Smitch Ambience SB-0110","GPIO":[0,0,0,0,416,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}
Smitch 10W 6500K {"NAME":"Smitch 10W 6500K Dimmable Bulb (SB0110 - E27)","GPIO":[0,0,0,0,0,416,0,0,0,417,0,0,0,0],"FLAG":0,"BASE":1} Smitch 10W 6500K {"NAME":"Smitch 10W 6500K Dimmable Bulb (SB0110 - E27)","GPIO":[0,0,0,0,0,416,0,0,0,417,0,0,0,0],"FLAG":0,"BASE":1}
TCP Smart 806lm Warm White {"NAME":"TCP Smart Clas","GPIO":[0,0,0,0,0,0,0,0,0,416,0,0,0,0],"FLAG":0,"BASE":1} TCP Smart 806lm Warm White {"NAME":"TCP Smart Clas","GPIO":[0,0,0,0,0,0,0,0,0,416,0,0,0,0],"FLAG":0,"BASE":1}
TCP Smart 810lm Filament {"NAME":"TCP Filament","GPIO":[0,0,0,0,0,0,0,0,0,0,448,0,0,0],"FLAG":0,"BASE":18} TCP Smart 810lm Filament {"NAME":"TCP Filament","GPIO":[0,0,0,0,0,0,0,0,0,0,448,0,0,0],"FLAG":0,"BASE":18}
@ -464,7 +463,7 @@ QS-WiFi-D01-TRIAC 150W {"NAME":"QS-WiFi-D01-TRIAC","GPIO":[0,3200,0,3232,0
RJWF-02A {"NAME":"RJWF-02A","GPIO":[32,2272,0,2304,0,0,0,0,0,0,288,0,0,0],"FLAG":0,"BASE":54} RJWF-02A {"NAME":"RJWF-02A","GPIO":[32,2272,0,2304,0,0,0,0,0,0,288,0,0,0],"FLAG":0,"BASE":54}
Shelly Dimmer {"NAME":"Shelly Dimmer 1","GPIO":[0,3200,0,3232,5568,5600,0,0,192,0,193,288,0,4736],"FLAG":0,"BASE":18} Shelly Dimmer {"NAME":"Shelly Dimmer 1","GPIO":[0,3200,0,3232,5568,5600,0,0,192,0,193,288,0,4736],"FLAG":0,"BASE":18}
Shelly Dimmer 2 {"NAME":"Shelly Dimmer 2","GPIO":[0,3200,0,3232,5568,5600,0,0,193,0,192,0,320,4736],"FLAG":0,"BASE":18} Shelly Dimmer 2 {"NAME":"Shelly Dimmer 2","GPIO":[0,3200,0,3232,5568,5600,0,0,193,0,192,0,320,4736],"FLAG":0,"BASE":18}
Shelly Plus 0-10V Dimmer {"NAME":"Shelly Plus 0-10V Dimmer","GPIO":[288,0,0,0,192,0,0,0,0,0,0,0,0,0,193,1,0,0,0,0,0,32,416,0,0,0,0,0,4736,0,0,0,0,0,0,0],"FLAG":0,"BASE":1} Shelly Plus 0-10V Dimmer {"NAME":"Shelly Plus 0-10V Dimmer","GPIO":[288,0,0,0,192,0,0,0,0,0,0,0,0,0,193,1,0,0,0,0,0,32,448,0,0,0,0,0,4736,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}
Sonoff D1 {"NAME":"Sonoff D1","GPIO":[1,3200,0,3232,0,0,0,0,0,320,0,0,0,0],"FLAG":0,"BASE":74} Sonoff D1 {"NAME":"Sonoff D1","GPIO":[1,3200,0,3232,0,0,0,0,0,320,0,0,0,0],"FLAG":0,"BASE":74}
``` ```
@ -2280,6 +2279,7 @@ Athom 8Ch Inching/Self-locking 10A {"NAME":"Athom 8CH Relay Board","GPIO":[0,0,
Claudy 5V {"NAME":"CLAUDY","GPIO":[0,0,225,0,0,0,0,0,0,0,0,224,0,0],"FLAG":0,"BASE":18} Claudy 5V {"NAME":"CLAUDY","GPIO":[0,0,225,0,0,0,0,0,0,0,0,224,0,0],"FLAG":0,"BASE":18}
Devantech 8x16A {"NAME":"ESP32LR88","GPIO":[0,0,231,0,32,35,0,0,229,230,228,0,33,34,36,37,0,38,39,544,0,225,226,227,0,0,0,0,0,224,3232,3200,0,0,0,0],"FLAG":0,"BASE":1} Devantech 8x16A {"NAME":"ESP32LR88","GPIO":[0,0,231,0,32,35,0,0,229,230,228,0,33,34,36,37,0,38,39,544,0,225,226,227,0,0,0,0,0,224,3232,3200,0,0,0,0],"FLAG":0,"BASE":1}
Dingtian 16 Channel {"NAME":"Dingtian DT-R008","GPIO":[1,9408,1,9440,1,1,1,1,1,9760,9729,9856,9792,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,9824,9952,1,1,1,0,0,1],"FLAG":0,"BASE":1} Dingtian 16 Channel {"NAME":"Dingtian DT-R008","GPIO":[1,9408,1,9440,1,1,1,1,1,9760,9729,9856,9792,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,9824,9952,1,1,1,0,0,1],"FLAG":0,"BASE":1}
Dingtian 2 Channel {"NAME":"Dingtian DT-R002","GPIO":[5536,9408,225,9440,0,0,0,0,0,9952,0,0,224,0,5600,0,0,0,0,5568,0,0,0,0,0,0,0,0,576,0,0,0,160,0,0,161],"FLAG":0,"BASE":1}
Dingtian 32 Channel {"NAME":"Dingtian DT-R008","GPIO":[1,9408,1,9440,1,1,1,1,1,9760,9731,9856,9792,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,9824,9952,1,1,1,0,0,1],"FLAG":0,"BASE":1} Dingtian 32 Channel {"NAME":"Dingtian DT-R008","GPIO":[1,9408,1,9440,1,1,1,1,1,9760,9731,9856,9792,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,9824,9952,1,1,1,0,0,1],"FLAG":0,"BASE":1}
Dingtian 4 Channel {"NAME":"Dingtian DT-R004","GPIO":[0,9408,225,9440,0,0,0,0,227,9952,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,226,162,0,163,160,0,0,161],"FLAG":0,"BASE":1} Dingtian 4 Channel {"NAME":"Dingtian DT-R004","GPIO":[0,9408,225,9440,0,0,0,0,227,9952,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,226,162,0,163,160,0,0,161],"FLAG":0,"BASE":1}
Dingtian 8 Channel {"NAME":"Dingtian DT-R008","GPIO":[1,9408,1,9440,1,1,1,1,1,9760,9728,9856,9792,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,9824,9952,1,1,1,0,0,1],"FLAG":0,"BASE":1} Dingtian 8 Channel {"NAME":"Dingtian DT-R008","GPIO":[1,9408,1,9440,1,1,1,1,1,9760,9728,9856,9792,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,9824,9952,1,1,1,0,0,1],"FLAG":0,"BASE":1}
@ -2455,7 +2455,6 @@ Connect SmartHome 3 Gang Wall Switch () {"NAME":"CSH-SWTCH3","GPIO":[0,0,288,0,
Csmart US-B2 {"NAME":"Csmart US-B2","GPIO":[0,544,0,33,32,0,0,0,0,225,224,0,0,0],"FLAG":0,"BASE":18} Csmart US-B2 {"NAME":"Csmart US-B2","GPIO":[0,544,0,33,32,0,0,0,0,225,224,0,0,0],"FLAG":0,"BASE":18}
Delock WLAN EASY-USB {"NAME":"Delock 11828","GPIO":[0,0,0,32,0,0,0,0,0,576,224,0,0,0],"FLAG":0,"BASE":53} Delock WLAN EASY-USB {"NAME":"Delock 11828","GPIO":[0,0,0,32,0,0,0,0,0,576,224,0,0,0],"FLAG":0,"BASE":53}
Deta 1 Gang {"NAME":"Deta 1G Switch","GPIO":[0,0,0,0,544,0,0,0,0,224,0,0,64,0],"FLAG":0,"BASE":18} Deta 1 Gang {"NAME":"Deta 1G Switch","GPIO":[0,0,0,0,544,0,0,0,0,224,0,0,64,0],"FLAG":0,"BASE":18}
Deta 2 Gang {"NAME":"DETA 2G Switch","GPIO":[0,0,0,0,544,0,0,0,65,224,225,0,64,0],"FLAG":0,"BASE":18}
Deta 3 Gang {"NAME":"DETA 3G Switch","GPIO":[544,0,0,66,65,224,0,0,226,0,225,0,64,0],"FLAG":0,"BASE":18} Deta 3 Gang {"NAME":"DETA 3G Switch","GPIO":[544,0,0,66,65,224,0,0,226,0,225,0,64,0],"FLAG":0,"BASE":18}
Deta 4 Gang {"NAME":"Deta 4G Switch","GPIO":[576,0,0,34,33,224,0,0,226,35,225,227,32,0],"FLAG":0,"BASE":18} Deta 4 Gang {"NAME":"Deta 4G Switch","GPIO":[576,0,0,34,33,224,0,0,226,35,225,227,32,0],"FLAG":0,"BASE":18}
DETA Mechanism {"NAME":"Deta 6014HA","GPIO":[0,0,0,0,0,0,0,0,320,0,32,0,224,0],"FLAG":0,"BASE":18} DETA Mechanism {"NAME":"Deta 6014HA","GPIO":[0,0,0,0,0,0,0,0,320,0,32,0,224,0],"FLAG":0,"BASE":18}

View File

@ -41,6 +41,11 @@
"download": { "download": {
"speed": 230400 "speed": 230400
}, },
"espidf": {
"custom_sdkconfig": [
"CONFIG_FREERTOS_UNICORE=y"
]
},
"url": "https://www.espressif.com/sites/default/files/documentation/esp32-solo-1_datasheet_en.pdf", "url": "https://www.espressif.com/sites/default/files/documentation/esp32-solo-1_datasheet_en.pdf",
"vendor": "Espressif" "vendor": "Espressif"
} }

View File

@ -39,6 +39,6 @@
"download": { "download": {
"speed": 230400 "speed": 230400
}, },
"url": "https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c6/esp32-c6-devkitc-1/index.html", "url": "https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp8684/esp8684-devkitm-1/user_guide.html",
"vendor": "Espressif" "vendor": "Espressif"
} }

View File

@ -39,6 +39,6 @@
"download": { "download": {
"speed": 230400 "speed": 230400
}, },
"url": "https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32c6/esp32-c6-devkitc-1/index.html", "url": "https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp8684/esp8684-devkitm-1/user_guide.html",
"vendor": "Espressif" "vendor": "Espressif"
} }

45
boards/esp32p4.json Normal file
View File

@ -0,0 +1,45 @@
{
"build": {
"core": "esp32",
"extra_flags": [
"-DARDUINO_TASMOTA -DESP32P4 -DBOARD_HAS_PSRAM -DARDUINO_USB_MODE=1 -DUSE_USB_CDC_CONSOLE"
],
"f_cpu": "360000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"mcu": "esp32p4",
"variant": "esp32p4",
"partitions": "partitions/esp32_partition_app2880k_fs320k.csv"
},
"connectivity": [
"wifi",
"bluetooth",
"openthread",
"ethernet"
],
"debug": {
"openocd_target": "esp32p4.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "Espressif Generic ESP32-P4 >= 4M Flash, Tasmota 2880k Code/OTA, >= 320k FS",
"upload": {
"arduino": {
"flash_extra_images": [
[
"0x10000",
"tasmota32p4-safeboot.bin"
]
]
},
"flash_size": "4MB",
"maximum_ram_size": 768000,
"maximum_size": 4194304,
"require_upload_port": true,
"speed": 1500000
},
"url": "https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/index.html",
"vendor": "Espressif"
}

46
boards/esp32p4_ev.json Normal file
View File

@ -0,0 +1,46 @@
{
"build": {
"core": "esp32",
"extra_flags": [
"-DARDUINO_TASMOTA -DESP32P4 -DBOARD_HAS_PSRAM -DARDUINO_USB_MODE=1 -DUSE_USB_CDC_CONSOLE"
],
"f_cpu": "360000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"mcu": "esp32p4",
"variant": "esp32p4",
"partitions": "partitions/esp32_partition_app3904k_fs3392k.csv"
},
"connectivity": [
"wifi",
"bluetooth",
"openthread",
"ethernet"
],
"debug": {
"openocd_target": "esp32p4.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "Espressif ESP32-P4 Function EV Board",
"upload": {
"arduino": {
"flash_extra_images": [
[
"0x10000",
"tasmota32p4-safeboot.bin"
]
]
},
"flash_size": "16MB",
"maximum_ram_size": 768000,
"maximum_size": 16777216,
"require_upload_port": true,
"speed": 1500000
},
"url": "https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/index.html",
"vendor": "Espressif"
}

45
boards/esp32p4ser.json Normal file
View File

@ -0,0 +1,45 @@
{
"build": {
"core": "esp32",
"extra_flags": [
"-DARDUINO_TASMOTA -DESP32P4 -DBOARD_HAS_PSRAM"
],
"f_cpu": "360000000L",
"f_flash": "80000000L",
"flash_mode": "qio",
"mcu": "esp32p4",
"variant": "esp32p4",
"partitions": "partitions/esp32_partition_app2880k_fs320k.csv"
},
"connectivity": [
"wifi",
"bluetooth",
"openthread",
"ethernet"
],
"debug": {
"openocd_target": "esp32p4.cfg"
},
"frameworks": [
"arduino",
"espidf"
],
"name": "Espressif Generic ESP32-P4 >= 4M Flash, Tasmota 2880k Code/OTA, >= 320k FS",
"upload": {
"arduino": {
"flash_extra_images": [
[
"0x10000",
"tasmota32p4-safeboot.bin"
]
]
},
"flash_size": "4MB",
"maximum_ram_size": 768000,
"maximum_size": 4194304,
"require_upload_port": true,
"speed": 1500000
},
"url": "https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/index.html",
"vendor": "Espressif"
}

View File

@ -61,7 +61,7 @@
// SPI_MOSI_DLEN_REG is not defined anymore in esp32s3 // SPI_MOSI_DLEN_REG is not defined anymore in esp32s3
#define SPI_MOSI_DLEN_REG(x) SPI_MS_DLEN_REG(x) #define SPI_MOSI_DLEN_REG(x) SPI_MS_DLEN_REG(x)
#elif CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 #elif CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32P4
#define SPI_HOST SPI1_HOST #define SPI_HOST SPI1_HOST
#define HSPI_HOST SPI2_HOST #define HSPI_HOST SPI2_HOST
#define VSPI_HOST SPI2_HOST /* No SPI3_host on C2/C6 */ #define VSPI_HOST SPI2_HOST /* No SPI3_host on C2/C6 */

View File

@ -168,6 +168,12 @@ void TasmotaSerial::Esp32Begin(void) {
if (m_speed <= 9600) { if (m_speed <= 9600) {
// At 9600, 10 chars are ~10ms // At 9600, 10 chars are ~10ms
uart_set_rx_full_threshold(m_uart, 10); uart_set_rx_full_threshold(m_uart, 10);
} else {
// At 19200, 120 chars are ~60ms
// At 76800, 120 chars are ~15ms
uart_set_rx_full_threshold(m_uart, 120);
}
/*
} else if (m_speed < 115200) { } else if (m_speed < 115200) {
// At 19200, 120 chars are ~60ms // At 19200, 120 chars are ~60ms
// At 76800, 120 chars are ~15ms // At 76800, 120 chars are ~15ms
@ -180,6 +186,7 @@ void TasmotaSerial::Esp32Begin(void) {
// At even higher speeds set 75% of the buffer // At even higher speeds set 75% of the buffer
uart_set_rx_full_threshold(m_uart, serial_buffer_size * 3 / 4); uart_set_rx_full_threshold(m_uart, serial_buffer_size * 3 / 4);
} }
*/
// For bitrate below 115200, set the Rx time out to 6 chars instead of the default 10 // For bitrate below 115200, set the Rx time out to 6 chars instead of the default 10
if (m_speed < 115200) { if (m_speed < 115200) {
// At 76800 the timeout is ~1ms // At 76800 the timeout is ~1ms

View File

@ -1,8 +1,8 @@
name=Unishox Compressor Decompressor highly customized and optimized for ESP8266 and Tasmota name=Unishox (De)Compressor
version=1.0 version=1.0
author=Arundale Ramanathan, Stephan Hadinger author=Arundale Ramanathan, Stephan Hadinger
maintainer=Arun <arun@siara.cc>, Stephan <stephan.hadinger@gmail.com> maintainer=Arun <arun@siara.cc>, Stephan <stephan.hadinger@gmail.com>
sentence=Unishox compression for Tasmota Rules sentence=Unishox compression for Tasmota Rules
paragraph=It is based on Unishox hybrid encoding technique. This version has specific Unicode code removed for size. paragraph=It is based on Unishox hybrid encoding technique. This Tasmota version has specific Unicode code removed for size.
url=https://github.com/siara-cc/Unishox url=https://github.com/siara-cc/Unishox
architectures=esp8266,esp32 architectures=esp8266,esp32

View File

@ -27,8 +27,8 @@ enum LoggingLevels {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_D
#ifdef USE_IPV6 #ifdef USE_IPV6
ip_addr_t dns_save4[DNS_MAX_SERVERS] = {}; // IPv4 DNS servers ip_addr_t dns_save4[2] = {}; // IPv4 DNS servers
ip_addr_t dns_save6[DNS_MAX_SERVERS] = {}; // IPv6 DNS servers ip_addr_t dns_save6[2] = {}; // IPv6 DNS servers
#endif // USE_IPV6 #endif // USE_IPV6
#include "tasmota_options.h" #include "tasmota_options.h"
@ -76,48 +76,72 @@ extern bool WifiHasIPv6(void);
extern bool EthernetHasIPv6(void); extern bool EthernetHasIPv6(void);
void WiFiHelper::scrubDNS(void) { void WiFiHelper::scrubDNS(void) {
// AddLog(LOG_LEVEL_DEBUG, "IP>1: dns_save4 %s %s dns_save6 %s %s",
// IPAddress(&dns_save4[0]).toString().c_str(),IPAddress(&dns_save4[1]).toString().c_str(),
// IPAddress(&dns_save6[0]).toString().c_str(),IPAddress(&dns_save6[1]).toString().c_str());
// String dns_entry0 = IPAddress(dns_getserver(0)).toString(); // String dns_entry0 = IPAddress(dns_getserver(0)).toString();
// String dns_entry1 = IPAddress(dns_getserver(1)).toString(); // String dns_entry1 = IPAddress(dns_getserver(1)).toString();
// scan DNS entries // scan DNS entries
bool has_v4 = WifiHasIPv4() || EthernetHasIPv4(); bool has_v4 = WifiHasIPv4() || EthernetHasIPv4();
bool has_v6 = false; bool has_v6 = false;
#ifdef USE_IPV6 #ifdef USE_IPV6
has_v6 = WifiHasIPv6() || EthernetHasIPv6(); has_v6 = WifiHasIPv6() || EthernetHasIPv6();
#endif #endif
// AddLog(LOG_LEVEL_DEBUG, "IP>1: DNS: (%s %s) has4/6:%i-%i", dns_entry0.c_str(), dns_entry1.c_str(), has_v4, has_v6);
// First pass, save values
for (uint32_t i=0; i<DNS_MAX_SERVERS; i++) {
#ifdef USE_IPV6 #ifdef USE_IPV6
// First pass, save values
for (uint32_t i=0; i<2; i++) {
const IPAddress ip_dns = IPAddress(dns_getserver(i)); const IPAddress ip_dns = IPAddress(dns_getserver(i));
// Step 1. save valid values from DNS // Step 1. save valid values from DNS
if (!ip_addr_isany_val((const ip_addr_t &)ip_dns)) { if (!ip_addr_isany_val((const ip_addr_t &)ip_dns)) {
if (ip_dns.type() == IPv4 && has_v4) { if (ip_dns.type() == IPv4 && (has_v4 || !has_v6)) {
ip_dns.to_ip_addr_t(&dns_save4[i]); ip_dns.to_ip_addr_t(&dns_save4[i]); // dns entry is populated, save it in v4 slot
// dns_save4[i] = (ip_addr_t) ip_dns; // dns entry is populated, save it in v4 slot
} else if (has_v6) { } else if (has_v6) {
ip_dns.to_ip_addr_t(&dns_save6[i]); ip_dns.to_ip_addr_t(&dns_save6[i]); // dns entry is populated, save it in v6 slot
// dns_save6[i] = (ip_addr_t) ip_dns; // dns entry is populated, save it in v6 slot
} }
} }
// Step 2. scrub addresses not supported
if (!has_v4) { dns_save4[i] = *IP4_ADDR_ANY; }
if (!has_v6) { dns_save6[i] = *IP_ADDR_ANY; }
// Step 3. restore saved value
if (has_v4 && has_v6) { // if both IPv4 and IPv6 are active, prefer IPv4
if (!ip_addr_isany_val(dns_save4[i])) { dns_setserver(i, &dns_save4[i]); }
else { dns_setserver(i, &dns_save6[i]); }
} else if (has_v4) {
dns_setserver(i, &dns_save4[i]);
} else if (has_v6) {
dns_setserver(i, &dns_save6[i]);
} else {
dns_setserver(i, IP4_ADDR_ANY);
}
#endif // USE_IPV6
} }
// AddLog(LOG_LEVEL_DEBUG, "IP>: DNS: from(%s %s) to (%s %s) has4/6:%i-%i", dns_entry0.c_str(), dns_entry1.c_str(), IPAddress(dns_getserver(0)).toString().c_str(), IPAddress(dns_getserver(1)).toString().c_str(), has_v4, has_v6);
// Step 2. scrub addresses not supported
if (!has_v4 && has_v6) { // v6 only
dns_save4[0] = *IP4_ADDR_ANY;
dns_save4[1] = *IP4_ADDR_ANY;
}
if (!has_v6) {
dns_save6[0] = *IP_ADDR_ANY;
dns_save6[1] = *IP_ADDR_ANY;
}
// Step 3. restore saved value
if (has_v4 && has_v6) { // if both IPv4 and IPv6 are active, prefer IPv4 for first and IPv6 for second
if (!ip_addr_isany_val(dns_save4[0])) {
// First DNS IPv4
dns_setserver(0, &dns_save4[0]);
if (!ip_addr_isany_val(dns_save6[0])) {
dns_setserver(1, &dns_save6[0]); // take first IPv6 as second DNS
} else {
dns_setserver(1, &dns_save4[1]); // or revert to second IPv4
}
} else {
// If no DNS IPv4, use IPv6
dns_setserver(0, &dns_save6[0]);
dns_setserver(1, &dns_save6[1]);
}
} else if (has_v6) { // v6 and no v4
dns_setserver(0, &dns_save6[0]);
dns_setserver(1, &dns_save6[1]);
} else { // no v6, we use v4 even if not connected
dns_setserver(0, &dns_save4[0]);
dns_setserver(1, &dns_save4[1]);
}
#endif // USE_IPV6
// AddLog(LOG_LEVEL_DEBUG, "IP>2: DNS: from(%s %s) to (%s %s) has4/6:%i-%i", dns_entry0.c_str(), dns_entry1.c_str(), IPAddress(dns_getserver(0)).toString().c_str(), IPAddress(dns_getserver(1)).toString().c_str(), has_v4, has_v6);
// AddLog(LOG_LEVEL_DEBUG, "IP>2: dns_save4 %s %s dns_save6 %s %s",
// IPAddress(&dns_save4[0]).toString().c_str(),IPAddress(&dns_save4[1]).toString().c_str(),
// IPAddress(&dns_save6[0]).toString().c_str(),IPAddress(&dns_save6[1]).toString().c_str());
} }
@ -142,6 +166,10 @@ int WiFiHelper::getPhyMode() {
WIFI_PHY_MODE_HE20, // PHY mode for Bandwidth HE20 (11ax) WIFI_PHY_MODE_HE20, // PHY mode for Bandwidth HE20 (11ax)
} wifi_phy_mode_t; } wifi_phy_mode_t;
*/ */
#ifndef SOC_WIFI_SUPPORTED
// ESP32-P4 does not support PHY modes, return 0
return 0;
#else
int phy_mode = 0; // "low rate|11b|11g|HT20|HT40|HE20" int phy_mode = 0; // "low rate|11b|11g|HT20|HT40|HE20"
wifi_phy_mode_t WiFiMode; wifi_phy_mode_t WiFiMode;
if (esp_wifi_sta_get_negotiated_phymode(&WiFiMode) == ESP_OK) { if (esp_wifi_sta_get_negotiated_phymode(&WiFiMode) == ESP_OK) {
@ -151,9 +179,13 @@ int WiFiHelper::getPhyMode() {
} }
} }
return phy_mode; return phy_mode;
# endif
} }
bool WiFiHelper::setPhyMode(WiFiPhyMode_t mode) { bool WiFiHelper::setPhyMode(WiFiPhyMode_t mode) {
# ifndef SOC_WIFI_SUPPORTED
return false; // ESP32-P4 does not support PHY modes
# else
uint8_t protocol_bitmap = WIFI_PROTOCOL_11B; // 1 uint8_t protocol_bitmap = WIFI_PROTOCOL_11B; // 1
switch (mode) { switch (mode) {
#if ESP_IDF_VERSION_MAJOR >= 5 #if ESP_IDF_VERSION_MAJOR >= 5
@ -163,6 +195,7 @@ bool WiFiHelper::setPhyMode(WiFiPhyMode_t mode) {
case 2: protocol_bitmap |= WIFI_PROTOCOL_11G; // 2 case 2: protocol_bitmap |= WIFI_PROTOCOL_11G; // 2
} }
return (ESP_OK == esp_wifi_set_protocol(WIFI_IF_STA, protocol_bitmap)); return (ESP_OK == esp_wifi_set_protocol(WIFI_IF_STA, protocol_bitmap));
#endif // CONFIG_IDF_TARGET_ESP32P4
} }
void WiFiHelper::setOutputPower(int n) { void WiFiHelper::setOutputPower(int n) {
@ -346,8 +379,11 @@ String WiFiHelper::macAddress(void) {
#else #else
uint8_t mac[6] = {0,0,0,0,0,0}; uint8_t mac[6] = {0,0,0,0,0,0};
char macStr[18] = { 0 }; char macStr[18] = { 0 };
#ifdef CONFIG_SOC_HAS_WIFI
esp_read_mac(mac, ESP_MAC_WIFI_STA); esp_read_mac(mac, ESP_MAC_WIFI_STA);
#else
esp_read_mac(mac, ESP_MAC_BASE);
#endif // CONFIG_SOC_HAS_WIFI
snprintf(macStr, sizeof(macStr), "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); snprintf(macStr, sizeof(macStr), "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
return String(macStr); return String(macStr);
#endif #endif

View File

@ -0,0 +1,128 @@
/**
* Base64 encoding and decoding of strings. Uses '+' for 62, '/' for 63, '=' for padding
*/
#include "base64.hpp"
unsigned char binary_to_base64(unsigned char v) {
// Capital letters - 'A' is ascii 65 and base64 0
if(v < 26) return v + 'A';
// Lowercase letters - 'a' is ascii 97 and base64 26
if(v < 52) return v + 71;
// Digits - '0' is ascii 48 and base64 52
if(v < 62) return v - 4;
// '+' is ascii 43 and base64 62
if(v == 62) return '+';
// '/' is ascii 47 and base64 63
if(v == 63) return '/';
return 64;
}
unsigned char base64_to_binary(unsigned char c) {
// Capital letters - 'A' is ascii 65 and base64 0
if('A' <= c && c <= 'Z') return c - 'A';
// Lowercase letters - 'a' is ascii 97 and base64 26
if('a' <= c && c <= 'z') return c - 71;
// Digits - '0' is ascii 48 and base64 52
if('0' <= c && c <= '9') return c + 4;
// '+' is ascii 43 and base64 62
if(c == '+') return 62;
// '/' is ascii 47 and base64 63
if(c == '/') return 63;
return 255;
}
unsigned int encode_base64_length(unsigned int input_length) {
return (input_length + 2)/3*4;
}
unsigned int decode_base64_length(unsigned char input[]) {
unsigned char *start = input;
while(base64_to_binary(input[0]) < 64) {
++input;
}
unsigned int input_length = input - start;
unsigned int output_length = input_length/4*3;
switch(input_length % 4) {
default: return output_length;
case 2: return output_length + 1;
case 3: return output_length + 2;
}
}
unsigned int encode_base64(unsigned char input[], unsigned int input_length, unsigned char output[]) {
unsigned int full_sets = input_length/3;
// While there are still full sets of 24 bits...
for(unsigned int i = 0; i < full_sets; ++i) {
output[0] = binary_to_base64( input[0] >> 2);
output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4);
output[2] = binary_to_base64((input[1] & 0x0F) << 2 | input[2] >> 6);
output[3] = binary_to_base64( input[2] & 0x3F);
input += 3;
output += 4;
}
switch(input_length % 3) {
case 0:
output[0] = '\0';
break;
case 1:
output[0] = binary_to_base64( input[0] >> 2);
output[1] = binary_to_base64((input[0] & 0x03) << 4);
output[2] = '=';
output[3] = '=';
output[4] = '\0';
break;
case 2:
output[0] = binary_to_base64( input[0] >> 2);
output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4);
output[2] = binary_to_base64((input[1] & 0x0F) << 2);
output[3] = '=';
output[4] = '\0';
break;
}
return encode_base64_length(input_length);
}
unsigned int decode_base64(unsigned char input[], unsigned char output[]) {
unsigned int output_length = decode_base64_length(input);
// While there are still full sets of 24 bits...
for(unsigned int i = 2; i < output_length; i += 3) {
output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2;
output[2] = base64_to_binary(input[2]) << 6 | base64_to_binary(input[3]);
input += 4;
output += 3;
}
switch(output_length % 3) {
case 1:
output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
break;
case 2:
output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2;
break;
}
return output_length;
}

View File

@ -69,127 +69,4 @@ unsigned int encode_base64(unsigned char input[], unsigned int input_length, uns
*/ */
unsigned int decode_base64(unsigned char input[], unsigned char output[]); unsigned int decode_base64(unsigned char input[], unsigned char output[]);
unsigned char binary_to_base64(unsigned char v) {
// Capital letters - 'A' is ascii 65 and base64 0
if(v < 26) return v + 'A';
// Lowercase letters - 'a' is ascii 97 and base64 26
if(v < 52) return v + 71;
// Digits - '0' is ascii 48 and base64 52
if(v < 62) return v - 4;
// '+' is ascii 43 and base64 62
if(v == 62) return '+';
// '/' is ascii 47 and base64 63
if(v == 63) return '/';
return 64;
}
unsigned char base64_to_binary(unsigned char c) {
// Capital letters - 'A' is ascii 65 and base64 0
if('A' <= c && c <= 'Z') return c - 'A';
// Lowercase letters - 'a' is ascii 97 and base64 26
if('a' <= c && c <= 'z') return c - 71;
// Digits - '0' is ascii 48 and base64 52
if('0' <= c && c <= '9') return c + 4;
// '+' is ascii 43 and base64 62
if(c == '+') return 62;
// '/' is ascii 47 and base64 63
if(c == '/') return 63;
return 255;
}
unsigned int encode_base64_length(unsigned int input_length) {
return (input_length + 2)/3*4;
}
unsigned int decode_base64_length(unsigned char input[]) {
unsigned char *start = input;
while(base64_to_binary(input[0]) < 64) {
++input;
}
unsigned int input_length = input - start;
unsigned int output_length = input_length/4*3;
switch(input_length % 4) {
default: return output_length;
case 2: return output_length + 1;
case 3: return output_length + 2;
}
}
unsigned int encode_base64(unsigned char input[], unsigned int input_length, unsigned char output[]) {
unsigned int full_sets = input_length/3;
// While there are still full sets of 24 bits...
for(unsigned int i = 0; i < full_sets; ++i) {
output[0] = binary_to_base64( input[0] >> 2);
output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4);
output[2] = binary_to_base64((input[1] & 0x0F) << 2 | input[2] >> 6);
output[3] = binary_to_base64( input[2] & 0x3F);
input += 3;
output += 4;
}
switch(input_length % 3) {
case 0:
output[0] = '\0';
break;
case 1:
output[0] = binary_to_base64( input[0] >> 2);
output[1] = binary_to_base64((input[0] & 0x03) << 4);
output[2] = '=';
output[3] = '=';
output[4] = '\0';
break;
case 2:
output[0] = binary_to_base64( input[0] >> 2);
output[1] = binary_to_base64((input[0] & 0x03) << 4 | input[1] >> 4);
output[2] = binary_to_base64((input[1] & 0x0F) << 2);
output[3] = '=';
output[4] = '\0';
break;
}
return encode_base64_length(input_length);
}
unsigned int decode_base64(unsigned char input[], unsigned char output[]) {
unsigned int output_length = decode_base64_length(input);
// While there are still full sets of 24 bits...
for(unsigned int i = 2; i < output_length; i += 3) {
output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2;
output[2] = base64_to_binary(input[2]) << 6 | base64_to_binary(input[3]);
input += 4;
output += 3;
}
switch(output_length % 3) {
case 1:
output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
break;
case 2:
output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
output[1] = base64_to_binary(input[1]) << 4 | base64_to_binary(input[2]) >> 2;
break;
}
return output_length;
}
#endif // ifndef #endif // ifndef

View File

@ -25,9 +25,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <Arduino.h> #include <Arduino.h>
// #define strcmp_P(x, y) strcmp(x,y)
// #define strcasecmp_P(x,y) strcasecmp(x,y)
// #define pgm_read_byte(x) (*(uint8_t*)(x))
#ifndef ARRAY_SIZE #ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif #endif

View File

@ -402,8 +402,10 @@ void IRac::airton(IRAirtonAc *ac,
const int16_t sleep) { const int16_t sleep) {
ac->begin(); ac->begin();
ac->setPower(on); ac->setPower(on);
ac->setMode(ac->convertMode(mode));
ac->setTemp(degrees); ac->setTemp(degrees);
// Mode needs to be set after temp as Fan-only uses a special temp.
ac->setMode(ac->convertMode(mode));
// Fan needs to be set after mode, as setMode can change the fan speed.
ac->setFan(ac->convertFan(fan)); ac->setFan(ac->convertFan(fan));
ac->setSwingV(swingv != stdAc::swingv_t::kOff); ac->setSwingV(swingv != stdAc::swingv_t::kOff);
// No Quiet setting available. // No Quiet setting available.

View File

@ -9,11 +9,7 @@
}, },
"version": "2.6.7", "version": "2.6.7",
"frameworks": "arduino", "frameworks": "arduino",
"platforms": "*", "libCompatMode": "strict",
"dependencies": [ "platforms": ["espressif8266"]
{
"name": "SPI"
}
]
} }

View File

@ -11,6 +11,7 @@
"url": "https://github.com/arendst/Tasmota/lib/lib_basic/TasmotaLED" "url": "https://github.com/arendst/Tasmota/lib/lib_basic/TasmotaLED"
}, },
"frameworks": "arduino", "frameworks": "arduino",
"libCompatMode": "strict",
"platforms": [ "platforms": [
"espressif32" "espressif32"
] ]

View File

@ -235,7 +235,7 @@ bool directRead(IO_REG_TYPE mask)
static inline __attribute__((always_inline)) static inline __attribute__((always_inline))
IO_REG_TYPE directRead(IO_REG_TYPE pin) IO_REG_TYPE directRead(IO_REG_TYPE pin)
{ {
#if SOC_GPIO_PIN_COUNT <= 32 #if SOC_GPIO_PIN_COUNT <= 32 || CONFIG_IDF_TARGET_ESP32P4
return (GPIO.in.val >> pin) & 0x1; return (GPIO.in.val >> pin) & 0x1;
#else // ESP32 with over 32 gpios #else // ESP32 with over 32 gpios
if ( pin < 32 ) if ( pin < 32 )
@ -250,7 +250,7 @@ IO_REG_TYPE directRead(IO_REG_TYPE pin)
static inline __attribute__((always_inline)) static inline __attribute__((always_inline))
void directWriteLow(IO_REG_TYPE pin) void directWriteLow(IO_REG_TYPE pin)
{ {
#if SOC_GPIO_PIN_COUNT <= 32 #if SOC_GPIO_PIN_COUNT <= 32 || CONFIG_IDF_TARGET_ESP32P4
GPIO.out_w1tc.val = ((uint32_t)1 << pin); GPIO.out_w1tc.val = ((uint32_t)1 << pin);
#else // ESP32 with over 32 gpios #else // ESP32 with over 32 gpios
if ( pin < 32 ) if ( pin < 32 )
@ -263,7 +263,7 @@ void directWriteLow(IO_REG_TYPE pin)
static inline __attribute__((always_inline)) static inline __attribute__((always_inline))
void directWriteHigh(IO_REG_TYPE pin) void directWriteHigh(IO_REG_TYPE pin)
{ {
#if SOC_GPIO_PIN_COUNT <= 32 #if SOC_GPIO_PIN_COUNT <= 32 || CONFIG_IDF_TARGET_ESP32P4
GPIO.out_w1ts.val = ((uint32_t)1 << pin); GPIO.out_w1ts.val = ((uint32_t)1 << pin);
#else // ESP32 with over 32 gpios #else // ESP32 with over 32 gpios
if ( pin < 32 ) if ( pin < 32 )
@ -280,7 +280,7 @@ void directModeInput(IO_REG_TYPE pin)
if ( digitalPinIsValid(pin) ) if ( digitalPinIsValid(pin) )
{ {
// Input // Input
#if SOC_GPIO_PIN_COUNT <= 32 #if SOC_GPIO_PIN_COUNT <= 32 || CONFIG_IDF_TARGET_ESP32P4
GPIO.enable_w1tc.val = ((uint32_t)1 << (pin)); GPIO.enable_w1tc.val = ((uint32_t)1 << (pin));
#else // ESP32 with over 32 gpios #else // ESP32 with over 32 gpios
if ( pin < 32 ) if ( pin < 32 )
@ -298,7 +298,7 @@ void directModeOutput(IO_REG_TYPE pin)
if ( digitalPinCanOutput(pin) ) if ( digitalPinCanOutput(pin) )
{ {
// Output // Output
#if SOC_GPIO_PIN_COUNT <= 32 #if SOC_GPIO_PIN_COUNT <= 32 || CONFIG_IDF_TARGET_ESP32P4
GPIO.enable_w1ts.val = ((uint32_t)1 << (pin)); GPIO.enable_w1ts.val = ((uint32_t)1 << (pin));
#else // ESP32 with over 32 gpios #else // ESP32 with over 32 gpios
if ( pin < 32 ) if ( pin < 32 )

View File

@ -97,7 +97,7 @@ enum uColorType { uCOLOR_BW, uCOLOR_COLOR };
#define UDISP_WHITE 0xFFFF /* 255, 255, 255 */ #define UDISP_WHITE 0xFFFF /* 255, 255, 255 */
#define UDISP_ORANGE 0xFD20 /* 255, 165, 0 */ #define UDISP_ORANGE 0xFD20 /* 255, 165, 0 */
#define UDISP_GREENYELLOW 0xAFE5 /* 173, 255, 47 */ #define UDISP_GREENYELLOW 0xAFE5 /* 173, 255, 47 */
#define UDISP_PINK 0xF81F #define UDISP_PINK 0xFc18 /* 255, 128, 192 */
#ifdef ESP8266 #ifdef ESP8266
#define PIN_OUT_SET 0x60000304 #define PIN_OUT_SET 0x60000304
@ -112,7 +112,7 @@ enum uColorType { uCOLOR_BW, uCOLOR_COLOR };
#undef GPIO_SET_SLOW #undef GPIO_SET_SLOW
#undef GPIO_CLR_SLOW #undef GPIO_CLR_SLOW
#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 #if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32P4
#define GPIO_CLR(A) GPIO.out_w1tc.val = (1 << A) #define GPIO_CLR(A) GPIO.out_w1tc.val = (1 << A)
#define GPIO_SET(A) GPIO.out_w1ts.val = (1 << A) #define GPIO_SET(A) GPIO.out_w1ts.val = (1 << A)
#else // plain ESP32 #else // plain ESP32

View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Frank
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -0,0 +1,56 @@
FastCRC
=======
Fast CRC Arduino library
Up to 30 times faster than crc16.h (_avr_libc)
- uses the on-chip hardware for Teensy 3.0 / 3.1 / 3.2 / 3.5 / 3.6
- uses fast table-algorithms for other chips
List of supported CRC calculations:
-
7 BIT:
CRC7
(poly=0x09 init=0x00 refin=false refout=false xorout=0x00 check=0x75)
MultiMediaCard interface
8 BIT:
SMBUS
(poly=0x07 init=0x00 refin=false refout=false xorout=0x00 check=0xf4)
MAXIM
(poly=0x31 init=0x00 refin=true refout=true xorout=0x00 check=0xa1)
16 BIT:
KERMIT (Alias CRC-16/CCITT, CRC-16/CCITT-TRUE, CRC-CCITT)
(poly=0x1021 init=0x0000 refin=true refout=true xorout=0x0000 check=0x2189
Attention: sometimes you'll find byteswapped presentation of result in other implementations)
CCITT-FALSE
(poly=0x1021 init=0xffff refin=false refout=false xorout=0x0000 check=0x29b1)
MCRF4XX
(poly=0x1021 init=0xffff refin=true refout=true xorout=0x0000 check=0x6f91)
MODBUS
(poly=0x8005 init=0xffff refin=true refout=true xorout=0x0000 check=0x4b37)
XMODEM (Alias ZMODEM, CRC-16/ACORN)
(poly=0x1021 init=0x0000 refin=false refout=false xorout=0x0000 check=0x31c3)
X25 (Alias CRC-16/IBM-SDLC, CRC-16/ISO-HDLC, CRC-B)
(poly=0x1021 init=0xffff refin=true refout=true xorout=0xffff check=0x906e)
32 BIT:
CRC32, CRC-32/ADCCP, PKZIP, ETHERNET, 802.3
(poly=0x04c11db7 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0xcbf43926)
CKSUM, CRC-32/POSIX
(poly=0x04c11db7 init=0x00000000 refin=false refout=false xorout=0xffffffff check=0x765e7680)

View File

@ -0,0 +1,59 @@
#######################################
# Syntax Coloring Map For FastCRC
#######################################
#######################################
# Datatypes (KEYWORD1)
#######################################
FastCRC7 KEYWORD1
FastCRC8 KEYWORD1
FastCRC14 KEYWORD1
FastCRC16 KEYWORD1
FastCRC32 KEYWORD1
CRC7 KEYWORD1
CRC8 KEYWORD1
CRC14 KEYWORD1
CRC16 KEYWORD1
CRC32 KEYWORD1
#######################################
# Methods and Functions (KEYWORD2)
#######################################
crc7 KEYWORD2
crc7_upd KEYWORD2
ccitt KEYWORD2
ccitt_upd KEYWORD2
kermit KEYWORD2
kermit_upd KEYWORD2
mcrf4xx KEYWORD2
mcrf4xx_upd KEYWORD2
modbus KEYWORD2
modbus_upd KEYWORD2
xmodem KEYWORD2
xmodem_upd KEYWORD2
x25 KEYWORD2
x25_upd KEYWORD2
update KEYWORD2
update_upd KEYWORD2
generic KEYWORD2
crc32 KEYWORD2
crc32_upd KEYWORD2
cksum KEYWORD2
cksum_upd KEYWORD2
darc KEYWORD2
darc_upd KEYWORD2
gsm KEYWORD2
gsm_upd KEYWORD2
eloran KEYWORD2
eloran_upd KEYWORD2
#######################################
# Constants (LITERAL1)
#######################################
CRC_FLAG_NOREFLECT LITERAL1
CRC_FLAG_REFLECT LITERAL1
CRC_FLAG_XOR LITERAL1
CRC_FLAG_NOREFLECT_8 LITERAL1
CRC_FLAG_REFLECT_SWAP LITERAL1

View File

@ -0,0 +1,26 @@
{
"name": "FastCRC",
"keywords": "CRC7, CRC8, CRC16, CRC32",
"description": "Fast CRC routines for Arduino and PC (Teensy 3.x: CRC in hardware)",
"exclude": [
"examples",
"examples_PC"
],
"repository":
{
"type": "git",
"url": "https://github.com/FrankBoesing/FastCRC"
},
"authors":
[
{
"name": "Frank Bösing",
"email": "f.boesing@gmx.de",
"url": "https://github.com/FrankBoesing/FastCRC",
"maintainer": true
}
],
"version": "1.44",
"frameworks": "arduino",
"platforms": "*"
}

View File

@ -0,0 +1,10 @@
name=FastCRC
version=1.44
author=Frank Bösing
maintainer=Frank Boesing<f.boesing@gmx.de>
sentence=Fast CRC routines
paragraph=
category=Data Processing
url=https://github.com/FrankBoesing/FastCRC
architectures=*
#dot_a_linkage=true

View File

@ -0,0 +1,189 @@
/* FastCRC library code is placed under the MIT license
* Copyright (c) 2014 - 2021 Frank Bösing
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Teensy 3.0, Teensy 3.1:
// See K20P64M72SF1RM.pdf (Kinetis), Pages 638 - 641 for documentation of CRC Device
// See KINETIS_4N30D.pdf for Errata (Errata ID 2776)
//
// So, ALL HW-calculations are done as 32 bit.
//
//
//
// Thanks to:
// - Catalogue of parametrised CRC algorithms, CRC RevEng
// http://reveng.sourceforge.net/crc-catalogue/
//
// - Danjel McGougan (CRC-Table-Generator)
//
// Set this to 0 for smaller 32BIT-CRC-Tables:
#if !defined(CRC_BIGTABLES)
#define CRC_BIGTABLES 1
#endif
#if !defined(FastCRC_h)
#define FastCRC_h
#if defined(ARDUINO)
#include <Arduino.h>
#endif
#include <inttypes.h>
// ================= DEFINES ===================
#if defined(KINETISK)
#define CRC_SW 0
#define CRC_FLAG_NOREFLECT (((1<<31) | (1<<30)) | ((0<<29) | (0<<28))) //refin=false refout=false
#define CRC_FLAG_REFLECT (((1<<31) | (0<<30)) | ((1<<29) | (0<<28))) //Reflect in- and outgoing bytes (refin=true refout=true)
#define CRC_FLAG_XOR (1<<26) //Perform XOR on result
#define CRC_FLAG_NOREFLECT_8 (0) //For 8-Bit CRC
#define CRC_FLAG_REFLECT_SWAP (((1<<31) | (0<<30)) | ((0<<29) | (1<<28))) //For 16-Bit CRC (byteswap)
#else
#define CRC_SW 1
#endif
// ================= 7-BIT CRC ===================
class FastCRC7
{
public:
FastCRC7();
uint8_t crc7(const uint8_t *data, const size_t datalen); // (MultiMediaCard interface)
uint8_t crc7_upd(const uint8_t *data, const size_t datalen); // Call for subsequent calculations with previous seed.
#if !CRC_SW
uint8_t generic(const uint8_t polyom, const uint8_t seed, const uint32_t flags, const uint8_t *data, const size_t datalen); //Not available in non-hw-variant (not T3.x)
#endif
private:
#if CRC_SW
uint8_t seed;
#else
uint8_t update(const uint8_t *data, const size_t datalen);
#endif
};
// ================= 8-BIT CRC ===================
class FastCRC8
{
public:
FastCRC8();
uint8_t smbus(const uint8_t *data, const size_t datalen); // Alias CRC-8
uint8_t maxim(const uint8_t *data, const size_t datalen); // Equivalent to _crc_ibutton_update() in crc16.h from avr_libc
uint8_t smbus_upd(const uint8_t *data, size_t datalen); // Call for subsequent calculations with previous seed.
uint8_t maxim_upd(const uint8_t *data, size_t datalen); // Call for subsequent calculations with previous seed.
#if !CRC_SW
uint8_t generic(const uint8_t polyom, const uint8_t seed, const uint32_t flags, const uint8_t *data, const size_t datalen); //Not available in non-hw-variant (not T3.x)
#endif
private:
#if CRC_SW
uint8_t seed;
#else
uint8_t update(const uint8_t *data, const size_t datalen);
#endif
};
// ================= 14-BIT CRC ===================
class FastCRC14
{
public:
#if !CRC_SW //NO Software-implemenation so far
FastCRC14();
uint16_t darc(const uint8_t *data, const size_t datalen);
uint16_t gsm(const uint8_t *data, const size_t datalen);
uint16_t eloran(const uint8_t *data, const size_t datalen);
uint16_t ft4(const uint8_t *data, const size_t datalen);
uint16_t darc_upd(const uint8_t *data, size_t len);
uint16_t gsm_upd(const uint8_t *data, size_t len);
uint16_t eloran_upd(const uint8_t *data, size_t len);
uint16_t ft4_upd(const uint8_t *data, size_t len);
#endif
#if !CRC_SW
uint16_t generic(const uint16_t polyom, const uint16_t seed, const uint32_t flags, const uint8_t *data, const size_t datalen); //Not available in non-hw-variant (not T3.x)
#endif
private:
#if CRC_SW
uint16_t seed;
#else
uint16_t update(const uint8_t *data, const size_t datalen);
#endif
};
// ================= 16-BIT CRC ===================
class FastCRC16
{
public:
FastCRC16();
uint16_t ccitt(const uint8_t *data, const size_t datalen); // Alias "false CCITT"
uint16_t mcrf4xx(const uint8_t *data,const size_t datalen); // Equivalent to _crc_ccitt_update() in crc16.h from avr_libc
uint16_t kermit(const uint8_t *data, const size_t datalen); // Alias CRC-16/CCITT, CRC-16/CCITT-TRUE, CRC-CCITT
uint16_t modbus(const uint8_t *data, const size_t datalen); // Equivalent to _crc_16_update() in crc16.h from avr_libc
uint16_t xmodem(const uint8_t *data, const size_t datalen); // Alias ZMODEM, CRC-16/ACORN
uint16_t x25(const uint8_t *data, const size_t datalen); // Alias CRC-16/IBM-SDLC, CRC-16/ISO-HDLC, CRC-B
uint16_t ccitt_upd(const uint8_t *data, size_t len); // Call for subsequent calculations with previous seed
uint16_t mcrf4xx_upd(const uint8_t *data, size_t len); // Call for subsequent calculations with previous seed
uint16_t kermit_upd(const uint8_t *data, size_t len); // Call for subsequent calculations with previous seed
uint16_t modbus_upd(const uint8_t *data, size_t len); // Call for subsequent calculations with previous seed
uint16_t xmodem_upd(const uint8_t *data, size_t len); // Call for subsequent calculations with previous seed
uint16_t x25_upd(const uint8_t *data, size_t len); // Call for subsequent calculations with previous seed
#if !CRC_SW
uint16_t generic(const uint16_t polyom, const uint16_t seed, const uint32_t flags, const uint8_t *data, const size_t datalen); //Not available in non-hw-variant (not T3.x)
#endif
private:
#if CRC_SW
uint16_t seed;
#else
uint16_t update(const uint8_t *data, const size_t datalen);
#endif
};
// ================= 32-BIT CRC ===================
class FastCRC32
{
public:
FastCRC32();
uint32_t crc32(const uint8_t *data, const size_t datalen); // Alias CRC-32/ADCCP, PKZIP, Ethernet, 802.3
uint32_t cksum(const uint8_t *data, const size_t datalen); // Alias CRC-32/POSIX
uint32_t crc32_upd(const uint8_t *data, size_t len); // Call for subsequent calculations with previous seed
uint32_t cksum_upd(const uint8_t *data, size_t len); // Call for subsequent calculations with previous seed
#if !CRC_SW
uint32_t generic(const uint32_t polyom, const uint32_t seed, const uint32_t flags, const uint8_t *data, const size_t datalen); //Not available in non-hw-variant (not T3.x)
#endif
private:
#if CRC_SW
uint32_t seed;
#else
uint32_t update(const uint8_t *data, const size_t datalen);
#endif
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,567 @@
/* FastCRC library code is placed under the MIT license
* Copyright (c) 2014 - 2021 Frank Bösing
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
//
// HW-calculations are 32BIT
//
// Thanks to:
// - Catalogue of parametrised CRC algorithms, CRC RevEng
// http://reveng.sourceforge.net/crc-catalogue/
//
// - Danjel McGougan (CRC-Table-Generator)
//
#if defined(ARDUINO)
#include <Arduino.h>
#endif
#if defined(KINETISK)
#include "mk20dx128.h"
#include "FastCRC.h"
// ===============================================
typedef struct {
union {
uint32_t CRC; //CRC Data register
struct {
uint16_t CRC16;
uint16_t CRC16_1;
};
struct {
uint8_t CRC8;
uint8_t CRC8_1;
uint8_t CRC8_2;
uint8_t CRC8_3;
};
};
uint32_t GPOLY; //CRC Polynomial register
uint32_t CTRL; //CRC Control register
} CRC_T;
static volatile CRC_T * const rCRC = (CRC_T *)0x40032000;
#define CRC_CTRL_WAS 25 // Write CRC Data Register As Seed(1) / Data(0)
#define CRC_CTRL_TCRC 24 // Width of CRC protocol (0=16 BIT, 1=32 BIT)
#define CRC_CTRL_TOTR1 29 // TOTR[1]
// ================= 7-BIT CRC ===================
/** Constructor
* Enables CRC-clock
*/
FastCRC7::FastCRC7(){
SIM_SCGC6 |= SIM_SCGC6_CRC;
}
/** CRC 7
* MultiMediaCard interface
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint8_t FastCRC7::crc7(const uint8_t *data, const size_t datalen)
{
// poly=0x09 init=0x00 refin=false refout=false xorout=0x00 check=0x75
return (generic(0x09, 0, CRC_FLAG_NOREFLECT, data, datalen));
}
/** Update
* Call for subsequent calculations with previous seed
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint8_t FastCRC7::update(const uint8_t *data, const size_t datalen)
{
const uint8_t *src = data;
const uint8_t *target = src + datalen;
while (((uintptr_t)src & 0x03) != 0 && (src < target)) {
rCRC->CRC8_3 = *src++; //Write 8 BIT
}
while (src <= target-4) {
rCRC->CRC = *( uint32_t *)src; //Write 32 BIT
src += 4;
}
while (src < target) {
rCRC->CRC8_3 = *src++; //Write 8 Bit
}
//TODO: Check handling of CRC_CTRL_TOTR1 for other CRC7s
/*
if (rCRC->CTRL & (1<<CRC_CTRL_TOTR1))
return rCRC->CRC8 >> 1;
else
*/
return rCRC->CRC8_3 >> 1;
}
/** generic function for all 7-Bit CRCs
* @param polynom Polynom
* @param seed Seed
* @param flags Flags
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint8_t FastCRC7::generic(const uint8_t polynom, const uint8_t seed, const uint32_t flags, const uint8_t *data,const size_t datalen)
{
rCRC->CTRL = flags | (1<<CRC_CTRL_TCRC) | (1<<CRC_CTRL_WAS); // 32Bit Mode, Prepare to write seed(25)
rCRC->GPOLY = ((uint32_t)polynom)<<(24 + 1); // Set polynom
rCRC->CRC = ((uint32_t)seed<<(24 + 1)); // Write seed
rCRC->CTRL = flags | (1<<CRC_CTRL_TCRC); // Clear WAS Bit - prepare to write data
return update(data, datalen);
}
uint8_t FastCRC7::crc7_upd(const uint8_t *data, size_t datalen){return update(data, datalen);}
// ================= 8-BIT CRC ===================
/** Constructor
* Enables CRC-clock
*/
FastCRC8::FastCRC8(){
SIM_SCGC6 |= SIM_SCGC6_CRC;
}
/** SMBUS CRC
* aka CRC-8
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint8_t FastCRC8::smbus(const uint8_t *data, const size_t datalen)
{
// poly=0x07 init=0x00 refin=false refout=false xorout=0x00 check=0xf4
return generic(0x07, 0, CRC_FLAG_NOREFLECT, data, datalen);
}
/** MAXIM 8-Bit CRC
* equivalent to _crc_ibutton_update() in crc16.h from avr_libc
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint8_t FastCRC8::maxim(const uint8_t *data, const size_t datalen)
{
// poly=0x31 init=0x00 refin=true refout=true xorout=0x00 check=0xa1
return generic(0x31, 0, CRC_FLAG_REFLECT, data, datalen);
}
/** Update
* Call for subsequent calculations with previous seed
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint8_t FastCRC8::update(const uint8_t *data, const size_t datalen)
{
const uint8_t *src = data;
const uint8_t *target = src + datalen;
while (((uintptr_t)src & 0x03) != 0 && (src < target)) {
rCRC->CRC8_3 = *src++; //Write 8 BIT
}
while (src <= target-4) {
rCRC->CRC = *( uint32_t *)src; //Write 32 BIT
src += 4;
}
while (src < target) {
rCRC->CRC8_3 = *src++; //Write 8 Bit
}
if (rCRC->CTRL & (1<<CRC_CTRL_TOTR1))
return rCRC->CRC8;
else
return rCRC->CRC8_3;
}
/** generic function for all 8-Bit CRCs
* @param polynom Polynom
* @param seed Seed
* @param flags Flags
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint8_t FastCRC8::generic(const uint8_t polynom, const uint8_t seed, const uint32_t flags, const uint8_t *data,const size_t datalen)
{
rCRC->CTRL = flags | (1<<CRC_CTRL_TCRC) | (1<<CRC_CTRL_WAS); // 32Bit Mode, Prepare to write seed(25)
rCRC->GPOLY = ((uint32_t)polynom)<<24; // Set polynom
rCRC->CRC = ((uint32_t)seed<<24); // Write seed
rCRC->CTRL = flags | (1<<CRC_CTRL_TCRC); // Clear WAS Bit - prepare to write data
return update(data, datalen);
}
uint8_t FastCRC8::smbus_upd(const uint8_t *data, size_t datalen){return update(data, datalen);}
uint8_t FastCRC8::maxim_upd(const uint8_t *data, size_t datalen){return update(data, datalen);}
// ================= 14-BIT CRC ===================
/** Constructor
* Enables CRC-clock
*/
FastCRC14::FastCRC14(){
SIM_SCGC6 |= SIM_SCGC6_CRC;
}
/** CRC-14/DARC
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC14::darc(const uint8_t *data,const size_t datalen)
{
// poly=0x0805 init=0x0000 refin=true refout=true xorout=0x0000 check=0x082d residue=0x0000
return generic(0x0805, 0x0000, CRC_FLAG_REFLECT, data, datalen);
}
/** CRC-14/GSM
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC14::gsm(const uint8_t *data,const size_t datalen)
{
// poly=0x202d init=0x0000 refin=false refout=false xorout=0x3fff check=0x30ae residue=0x031e
return generic(0x202d, 0x0000, CRC_FLAG_NOREFLECT | CRC_FLAG_XOR, data, datalen);
}
/** CRC-14/ELORAN
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC14::eloran(const uint8_t *data,const size_t datalen)
{
// poly=0x60b1 init=0x0000 refin=false refout=false xorout=0x0000 check=0x38d1
return generic(0x60b1, 0x0, CRC_FLAG_NOREFLECT , data, datalen);
}
/** CRC-14/ft4 : TODO
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
/*
uint16_t FastCRC14::ft4(const uint8_t *data,const size_t datalen)
{
return generic(, , , data, datalen);
}
*/
/** Update
* Call for subsequent calculations with previous seed
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC14::update(const uint8_t *data, const size_t datalen)
{
const uint8_t *src = data;
const uint8_t *target = src + datalen;
while (((uintptr_t)src & 0x03) !=0 && (src < target)) {
rCRC->CRC8_3 = *src++; //Write 8 BIT
}
while (src <= target-4) {
rCRC->CRC = *( uint32_t *)src; //Write 32 BIT
src += 4;
}
while (src < target) {
rCRC->CRC8_3 = *src++; //Write 8 Bit
}
if (rCRC->CTRL & (1<<CRC_CTRL_TOTR1))
return rCRC->CRC16;
else
return rCRC->CRC >> (32 - 14);
}
/** generic function for all 14-Bit CRCs
* @param polynom Polynom
* @param seed Seed
* @param flags Flags
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC14::generic(const uint16_t polynom, const uint16_t seed, const uint32_t flags, const uint8_t *data, const size_t datalen)
{
rCRC->CTRL = flags | (1<<CRC_CTRL_TCRC) | (1<<CRC_CTRL_WAS);// 32-Bit Mode, prepare to write seed(25)
rCRC->GPOLY = ((uint32_t)polynom) << (32 - 14); // set polynom
rCRC->CRC = ((uint32_t)seed << (32 - 14) ); // this is the seed
rCRC->CTRL = flags | (1<<CRC_CTRL_TCRC); // Clear WAS Bit - prepare to write data
return update(data, datalen);
}
uint16_t FastCRC14::darc_upd(const uint8_t *data, size_t len) {return update(data, len);}
uint16_t FastCRC14::gsm_upd(const uint8_t *data, size_t len) {return update(data, len);}
uint16_t FastCRC14::eloran_upd(const uint8_t *data, size_t len) {return update(data, len);}
//uint16_t FastCRC14::ft4(const uint8_t *data, size_t len) {return update(data, len);}
// ================= 16-BIT CRC ===================
/** Constructor
* Enables CRC-clock
*/
FastCRC16::FastCRC16(){
SIM_SCGC6 |= SIM_SCGC6_CRC;
}
/** CCITT
* Alias "false CCITT"
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC16::ccitt(const uint8_t *data,const size_t datalen)
{
// poly=0x1021 init=0xffff refin=false refout=false xorout=0x0000 check=0x29b1
return generic(0x1021, 0XFFFF, CRC_FLAG_NOREFLECT, data, datalen);
}
/** MCRF4XX
* equivalent to _crc_ccitt_update() in crc16.h from avr_libc
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC16::mcrf4xx(const uint8_t *data,const size_t datalen)
{
// poly=0x1021 init=0xffff refin=true refout=true xorout=0x0000 check=0x6f91
return generic(0x1021, 0XFFFF, CRC_FLAG_REFLECT , data, datalen);
}
/** MODBUS
* equivalent to _crc_16_update() in crc16.h from avr_libc
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC16::modbus(const uint8_t *data, const size_t datalen)
{
// poly=0x8005 init=0xffff refin=true refout=true xorout=0x0000 check=0x4b37
return generic(0x8005, 0XFFFF, CRC_FLAG_REFLECT, data, datalen);
}
/** KERMIT
* Alias CRC-16/CCITT, CRC-16/CCITT-TRUE, CRC-CCITT
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC16::kermit(const uint8_t *data, const size_t datalen)
{
// poly=0x1021 init=0x0000 refin=true refout=true xorout=0x0000 check=0x2189
// sometimes byteswapped presentation of result
return generic(0x1021, 0x00, CRC_FLAG_REFLECT, data, datalen);
}
/** XMODEM
* Alias ZMODEM, CRC-16/ACORN
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC16::xmodem(const uint8_t *data, const size_t datalen)
{
//width=16 poly=0x1021 init=0x0000 refin=false refout=false xorout=0x0000 check=0x31c3
return generic(0x1021, 0, CRC_FLAG_NOREFLECT, data, datalen);
}
/** X25
* Alias CRC-16/IBM-SDLC, CRC-16/ISO-HDLC, CRC-B
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC16::x25(const uint8_t *data, const size_t datalen)
{
// poly=0x1021 init=0xffff refin=true refout=true xorout=0xffff check=0x906e
return generic(0x1021, 0XFFFF, CRC_FLAG_REFLECT | CRC_FLAG_XOR, data, datalen);
}
/** Update
* Call for subsequent calculations with previous seed
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC16::update(const uint8_t *data, const size_t datalen)
{
const uint8_t *src = data;
const uint8_t *target = src + datalen;
while (((uintptr_t)src & 0x03) !=0 && (src < target)) {
rCRC->CRC8_3 = *src++; //Write 8 BIT
}
while (src <= target-4) {
rCRC->CRC = *( uint32_t *)src; //Write 32 BIT
src += 4;
}
while (src < target) {
rCRC->CRC8_3 = *src++; //Write 8 Bit
}
if (rCRC->CTRL & (1<<CRC_CTRL_TOTR1))
return rCRC->CRC16;
else
return rCRC->CRC16_1;
}
/** generic function for all 16-Bit CRCs
* @param polynom Polynom
* @param seed Seed
* @param flags Flags
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC16::generic(const uint16_t polynom, const uint16_t seed, const uint32_t flags, const uint8_t *data, const size_t datalen)
{
rCRC->CTRL = flags | (1<<CRC_CTRL_TCRC) | (1<<CRC_CTRL_WAS);// 32-Bit Mode, prepare to write seed(25)
rCRC->GPOLY = ((uint32_t)polynom)<<16; // set polynom
rCRC->CRC = ((uint32_t)seed<<16); // this is the seed
rCRC->CTRL = flags | (1<<CRC_CTRL_TCRC); // Clear WAS Bit - prepare to write data
return update(data, datalen);
}
uint16_t FastCRC16::ccitt_upd(const uint8_t *data, size_t len) {return update(data, len);}
uint16_t FastCRC16::mcrf4xx_upd(const uint8_t *data, size_t len){return update(data, len);}
uint16_t FastCRC16::kermit_upd(const uint8_t *data, size_t len) {return update(data, len);}
uint16_t FastCRC16::modbus_upd(const uint8_t *data, size_t len) {return update(data, len);}
uint16_t FastCRC16::xmodem_upd(const uint8_t *data, size_t len) {return update(data, len);}
uint16_t FastCRC16::x25_upd(const uint8_t *data, size_t len) {return update(data, len);}
// ================= 32-BIT CRC ===================
/** Constructor
* Enables CRC-clock
*/
FastCRC32::FastCRC32(){
SIM_SCGC6 |= SIM_SCGC6_CRC;
}
/** CRC32
* Alias CRC-32/ADCCP, PKZIP, Ethernet, 802.3
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint32_t FastCRC32::crc32(const uint8_t *data, const size_t datalen)
{
// poly=0x04c11db7 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0xcbf43926
return generic(0x04C11DB7L, 0XFFFFFFFFL, CRC_FLAG_REFLECT | CRC_FLAG_XOR, data, datalen);
}
/** CKSUM
* Alias CRC-32/POSIX
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint32_t FastCRC32::cksum(const uint8_t *data, const size_t datalen)
{
// width=32 poly=0x04c11db7 init=0x00000000 refin=false refout=false xorout=0xffffffff check=0x765e7680
return generic(0x04C11DB7L, 0, CRC_FLAG_NOREFLECT | CRC_FLAG_XOR, data, datalen);
}
/** Update
* Call for subsequent calculations with previous seed
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
//#pragma GCC diagnostic ignored "-Wpointer-arith"
uint32_t FastCRC32::update(const uint8_t *data, const size_t datalen)
{
const uint8_t *src = data;
const uint8_t *target = src + datalen;
while (((uintptr_t)src & 0x03) != 0 && (src < target)) {
rCRC->CRC8_3 = *src++; //Write 8 BIT
}
while (src <= target-4) {
rCRC->CRC = *( uint32_t *)src; //Write 32 BIT
src += 4;
}
while (src < target) {
rCRC->CRC8_3 = *src++; //Write 8 Bit
}
return rCRC->CRC;
}
/** generic function for all 32-Bit CRCs
* @param polynom Polynom
* @param seed Seed
* @param flags Flags
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint32_t FastCRC32::generic(const uint32_t polynom, const uint32_t seed, const uint32_t flags, const uint8_t *data, const size_t datalen)
{
rCRC->CTRL = flags | (1<<CRC_CTRL_TCRC) | (1<<CRC_CTRL_WAS); // 32Bit Mode, prepare to write seed(25)
rCRC->GPOLY = polynom; // Set polynom
rCRC->CRC = seed; // This is the seed
rCRC->CTRL = flags | (1<<CRC_CTRL_TCRC); // Clear WAS Bit - prepare to write data
return update(data, datalen);
}
uint32_t FastCRC32::crc32_upd(const uint8_t *data, size_t len){return update(data, len);}
uint32_t FastCRC32::cksum_upd(const uint8_t *data, size_t len){return update(data, len);}
#endif // #if defined(KINETISK)

View File

@ -0,0 +1,541 @@
/* FastCRC library code is placed under the MIT license
* Copyright (c) 2014 - 2021 Frank Bösing
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
//
// Thanks to:
// - Catalogue of parametrised CRC algorithms, CRC RevEng
// http://reveng.sourceforge.net/crc-catalogue/
//
// - Danjel McGougan (CRC-Table-Generator)
//
#if defined(ARDUINO)
#include <Arduino.h>
#endif
#if !defined(KINETISK)
#if !defined(ARDUINO)
#define PROGMEM
#define pgm_read_byte(addr) (*(const unsigned char *)(addr))
#define pgm_read_word(addr) ({ \
typeof(addr) _addr = (addr); \
*(const unsigned short *)(_addr); \
})
#define pgm_read_dword(addr) ({ \
typeof(addr) _addr = (addr); \
*(const unsigned long *)(_addr); \
})
#endif
#include "FastCRC.h"
#include "FastCRC_tables.h"
static inline
uint32_t REV16( uint32_t value)
{
return (value >> 8) | ((value & 0xff) << 8);
}
static inline
uint32_t REV32( uint32_t value)
{
value = (value >> 16) | ((value & 0xffff) << 16);
return ((value >> 8) & 0xff00ff) | ((value & 0xff00ff) << 8);
}
// ================= 7-BIT CRC ===================
/** Constructor
*/
FastCRC7::FastCRC7(){}
/** SMBUS CRC
* aka CRC-8
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint8_t FastCRC7::crc7_upd(const uint8_t *data, size_t datalen)
{
uint8_t crc = seed;
if (datalen) do {
crc = pgm_read_byte(&crc_table_crc7[crc ^ *data]);
data++;
} while (--datalen);
seed = crc;
return crc >> 1;
}
uint8_t FastCRC7::crc7(const uint8_t *data, const size_t datalen)
{
// poly=0x09 init=0x00 refin=false refout=false xorout=0x00 check=0x75
seed = 0x00;
return crc7_upd(data, datalen);
}
// ================= 8-BIT CRC ===================
/** Constructor
*/
FastCRC8::FastCRC8(){}
/** SMBUS CRC
* aka CRC-8
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint8_t FastCRC8::smbus_upd(const uint8_t *data, size_t datalen)
{
uint8_t crc = seed;
if (datalen) do {
crc = pgm_read_byte(&crc_table_smbus[crc ^ *data]);
data++;
} while (--datalen);
seed = crc;
return crc;
}
uint8_t FastCRC8::smbus(const uint8_t *data, const size_t datalen)
{
// poly=0x07 init=0x00 refin=false refout=false xorout=0x00 check=0xf4
seed = 0x00;
return smbus_upd(data, datalen);
}
/** MAXIM 8-Bit CRC
* equivalent to _crc_ibutton_update() in crc16.h from avr_libc
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint8_t FastCRC8::maxim_upd(const uint8_t *data, size_t datalen)
{
uint8_t crc = seed;
if (datalen) do {
crc = pgm_read_byte(&crc_table_maxim[crc ^ *data]);
data++;
} while (--datalen);
seed = crc;
return crc;
}
uint8_t FastCRC8::maxim(const uint8_t *data, const size_t datalen)
{
// poly=0x31 init=0x00 refin=true refout=true xorout=0x00 check=0xa1
seed = 0x00;
return maxim_upd(data, datalen);
}
// ================= 16-BIT CRC ===================
/** Constructor
*/
FastCRC16::FastCRC16(){}
#define crc_n4(crc, data, table) crc ^= data; \
crc = pgm_read_word(&table[(crc & 0xff) + 0x300]) ^ \
pgm_read_word(&table[((crc >> 8) & 0xff) + 0x200]) ^ \
pgm_read_word(&table[((data >> 16) & 0xff) + 0x100]) ^ \
pgm_read_word(&table[data >> 24]);
/** CCITT
* Alias "false CCITT"
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC16::ccitt_upd(const uint8_t *data, size_t len)
{
uint16_t crc = seed;
while (((uintptr_t)data & 3) && len) {
crc = (crc >> 8) ^ pgm_read_word(&crc_table_ccitt[(crc & 0xff) ^ *data++]);
len--;
}
while (len >= 16) {
len -= 16;
crc_n4(crc, ((uint32_t *)data)[0], crc_table_ccitt);
crc_n4(crc, ((uint32_t *)data)[1], crc_table_ccitt);
crc_n4(crc, ((uint32_t *)data)[2], crc_table_ccitt);
crc_n4(crc, ((uint32_t *)data)[3], crc_table_ccitt);
data += 16;
}
while (len--) {
crc = (crc >> 8) ^ pgm_read_word(&crc_table_ccitt[(crc & 0xff) ^ *data++]);
}
seed = crc;
crc = REV16(crc);
return crc;
}
uint16_t FastCRC16::ccitt(const uint8_t *data,const size_t datalen)
{
// poly=0x1021 init=0xffff refin=false refout=false xorout=0x0000 check=0x29b1
seed = 0xffff;
return ccitt_upd(data, datalen);
}
/** MCRF4XX
* equivalent to _crc_ccitt_update() in crc16.h from avr_libc
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC16::mcrf4xx_upd(const uint8_t *data, size_t len)
{
uint16_t crc = seed;
while (((uintptr_t)data & 3) && len) {
crc = (crc >> 8) ^ pgm_read_word(&crc_table_mcrf4xx[(crc & 0xff) ^ *data++]);
len--;
}
while (len >= 16) {
len -= 16;
crc_n4(crc, ((uint32_t *)data)[0], crc_table_mcrf4xx);
crc_n4(crc, ((uint32_t *)data)[1], crc_table_mcrf4xx);
crc_n4(crc, ((uint32_t *)data)[2], crc_table_mcrf4xx);
crc_n4(crc, ((uint32_t *)data)[3], crc_table_mcrf4xx);
data += 16;
}
while (len--) {
crc = (crc >> 8) ^ pgm_read_word(&crc_table_mcrf4xx[(crc & 0xff) ^ *data++]);
}
seed = crc;
return crc;
}
uint16_t FastCRC16::mcrf4xx(const uint8_t *data,const size_t datalen)
{
// poly=0x1021 init=0xffff refin=true refout=true xorout=0x0000 check=0x6f91
seed = 0xffff;
return mcrf4xx_upd(data, datalen);
}
/** MODBUS
* equivalent to _crc_16_update() in crc16.h from avr_libc
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC16::modbus_upd(const uint8_t *data, size_t len)
{
uint16_t crc = seed;
while (((uintptr_t)data & 3) && len) {
crc = (crc >> 8) ^ pgm_read_word(&crc_table_modbus[(crc & 0xff) ^ *data++]);
len--;
}
while (len >= 16) {
len -= 16;
crc_n4(crc, ((uint32_t *)data)[0], crc_table_modbus);
crc_n4(crc, ((uint32_t *)data)[1], crc_table_modbus);
crc_n4(crc, ((uint32_t *)data)[2], crc_table_modbus);
crc_n4(crc, ((uint32_t *)data)[3], crc_table_modbus);
data += 16;
}
while (len--) {
crc = (crc >> 8) ^ pgm_read_word(&crc_table_modbus[(crc & 0xff) ^ *data++]);
}
seed = crc;
return crc;
}
uint16_t FastCRC16::modbus(const uint8_t *data, const size_t datalen)
{
// poly=0x8005 init=0xffff refin=true refout=true xorout=0x0000 check=0x4b37
seed = 0xffff;
return modbus_upd(data, datalen);
}
/** KERMIT
* Alias CRC-16/CCITT, CRC-16/CCITT-TRUE, CRC-CCITT
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC16::kermit_upd(const uint8_t *data, size_t len)
{
uint16_t crc = seed;
while (((uintptr_t)data & 3) && len) {
crc = (crc >> 8) ^ pgm_read_word(&crc_table_kermit[(crc & 0xff) ^ *data++]);
len--;
}
while (len >= 16) {
len -= 16;
crc_n4(crc, ((uint32_t *)data)[0], crc_table_kermit);
crc_n4(crc, ((uint32_t *)data)[1], crc_table_kermit);
crc_n4(crc, ((uint32_t *)data)[2], crc_table_kermit);
crc_n4(crc, ((uint32_t *)data)[3], crc_table_kermit);
data += 16;
}
while (len--) {
crc = (crc >> 8) ^ pgm_read_word(&crc_table_kermit[(crc & 0xff) ^ *data++]);
}
seed = crc;
return crc;
}
uint16_t FastCRC16::kermit(const uint8_t *data, const size_t datalen)
{
// poly=0x1021 init=0x0000 refin=true refout=true xorout=0x0000 check=0x2189
// sometimes byteswapped presentation of result
seed = 0x0000;
return kermit_upd(data, datalen);
}
/** XMODEM
* Alias ZMODEM, CRC-16/ACORN
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC16::xmodem_upd(const uint8_t *data, size_t len)
{
uint16_t crc = seed;
while (((uintptr_t)data & 3) && len) {
crc = (crc >> 8) ^ pgm_read_word(&crc_table_xmodem[(crc & 0xff) ^ *data++]);
len--;
}
while (len >= 16) {
len -= 16;
crc_n4(crc, ((uint32_t *)data)[0], crc_table_xmodem);
crc_n4(crc, ((uint32_t *)data)[1], crc_table_xmodem);
crc_n4(crc, ((uint32_t *)data)[2], crc_table_xmodem);
crc_n4(crc, ((uint32_t *)data)[3], crc_table_xmodem);
data += 16;
}
while (len--) {
crc = (crc >> 8) ^ pgm_read_word(&crc_table_xmodem[(crc & 0xff) ^ *data++]);
}
seed = crc;
crc = REV16(crc);
return crc;
}
uint16_t FastCRC16::xmodem(const uint8_t *data, const size_t datalen)
{
//width=16 poly=0x1021 init=0x0000 refin=false refout=false xorout=0x0000 check=0x31c3
seed = 0x0000;
return xmodem_upd(data, datalen);
}
/** X25
* Alias CRC-16/IBM-SDLC, CRC-16/ISO-HDLC, CRC-B
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
uint16_t FastCRC16::x25_upd(const uint8_t *data, size_t len)
{
uint16_t crc = seed;
while (((uintptr_t)data & 3) && len) {
crc = (crc >> 8) ^ pgm_read_word(&crc_table_x25[(crc & 0xff) ^ *data++]);
len--;
}
while (len >= 16) {
len -= 16;
crc_n4(crc, ((uint32_t *)data)[0], crc_table_x25);
crc_n4(crc, ((uint32_t *)data)[1], crc_table_x25);
crc_n4(crc, ((uint32_t *)data)[2], crc_table_x25);
crc_n4(crc, ((uint32_t *)data)[3], crc_table_x25);
data += 16;
}
while (len--) {
crc = (crc >> 8) ^ pgm_read_word(&crc_table_x25[(crc & 0xff) ^ *data++]);
}
seed = crc;
crc = ~crc;
return crc;
}
uint16_t FastCRC16::x25(const uint8_t *data, const size_t datalen)
{
// poly=0x1021 init=0xffff refin=true refout=true xorout=0xffff check=0x906e
seed = 0xffff;
return x25_upd(data, datalen);
}
// ================= 32-BIT CRC ===================
/** Constructor
*/
FastCRC32::FastCRC32(){}
#define crc_n4d(crc, data, table) crc ^= data; \
crc = pgm_read_dword(&table[(crc & 0xff) + 0x300]) ^ \
pgm_read_dword(&table[((crc >> 8) & 0xff) + 0x200]) ^ \
pgm_read_dword(&table[((crc >> 16) & 0xff) + 0x100]) ^ \
pgm_read_dword(&table[(crc >> 24) & 0xff]);
#define crcsm_n4d(crc, data, table) crc ^= data; \
crc = (crc >> 8) ^ pgm_read_dword(&table[crc & 0xff]); \
crc = (crc >> 8) ^ pgm_read_dword(&table[crc & 0xff]); \
crc = (crc >> 8) ^ pgm_read_dword(&table[crc & 0xff]); \
crc = (crc >> 8) ^ pgm_read_dword(&table[crc & 0xff]);
/** CRC32
* Alias CRC-32/ADCCP, PKZIP, Ethernet, 802.3
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
#if CRC_BIGTABLES
#define CRC_TABLE_CRC32 crc_table_crc32_big
#else
#define CRC_TABLE_CRC32 crc_table_crc32
#endif
uint32_t FastCRC32::crc32_upd(const uint8_t *data, size_t len)
{
uint32_t crc = seed;
while (((uintptr_t)data & 3) && len) {
crc = (crc >> 8) ^ pgm_read_dword(&CRC_TABLE_CRC32[(crc & 0xff) ^ *data++]);
len--;
}
while (len >= 16) {
len -= 16;
#if CRC_BIGTABLES
crc_n4d(crc, ((uint32_t *)data)[0], CRC_TABLE_CRC32);
crc_n4d(crc, ((uint32_t *)data)[1], CRC_TABLE_CRC32);
crc_n4d(crc, ((uint32_t *)data)[2], CRC_TABLE_CRC32);
crc_n4d(crc, ((uint32_t *)data)[3], CRC_TABLE_CRC32);
#else
crcsm_n4d(crc, ((uint32_t *)data)[0], CRC_TABLE_CRC32);
crcsm_n4d(crc, ((uint32_t *)data)[1], CRC_TABLE_CRC32);
crcsm_n4d(crc, ((uint32_t *)data)[2], CRC_TABLE_CRC32);
crcsm_n4d(crc, ((uint32_t *)data)[3], CRC_TABLE_CRC32);
#endif
data += 16;
}
while (len--) {
crc = (crc >> 8) ^ pgm_read_dword(&CRC_TABLE_CRC32[(crc & 0xff) ^ *data++]);
}
seed = crc;
crc = ~crc;
return crc;
}
uint32_t FastCRC32::crc32(const uint8_t *data, const size_t datalen)
{
// poly=0x04c11db7 init=0xffffffff refin=true refout=true xorout=0xffffffff check=0xcbf43926
seed = 0xffffffff;
return crc32_upd(data, datalen);
}
/** CKSUM
* Alias CRC-32/POSIX
* @param data Pointer to Data
* @param datalen Length of Data
* @return CRC value
*/
#if CRC_BIGTABLES
#define CRC_TABLE_CKSUM crc_table_cksum_big
#else
#define CRC_TABLE_CKSUM crc_table_cksum
#endif
uint32_t FastCRC32::cksum_upd(const uint8_t *data, size_t len)
{
uint32_t crc = seed;
while (((uintptr_t)data & 3) && len) {
crc = (crc >> 8) ^ pgm_read_dword(&CRC_TABLE_CKSUM[(crc & 0xff) ^ *data++]);
len--;
}
while (len >= 16) {
len -= 16;
#if CRC_BIGTABLES
crc_n4d(crc, ((uint32_t *)data)[0], CRC_TABLE_CKSUM);
crc_n4d(crc, ((uint32_t *)data)[1], CRC_TABLE_CKSUM);
crc_n4d(crc, ((uint32_t *)data)[2], CRC_TABLE_CKSUM);
crc_n4d(crc, ((uint32_t *)data)[3], CRC_TABLE_CKSUM);
#else
crcsm_n4d(crc, ((uint32_t *)data)[0], CRC_TABLE_CKSUM);
crcsm_n4d(crc, ((uint32_t *)data)[1], CRC_TABLE_CKSUM);
crcsm_n4d(crc, ((uint32_t *)data)[2], CRC_TABLE_CKSUM);
crcsm_n4d(crc, ((uint32_t *)data)[3], CRC_TABLE_CKSUM);
#endif
data += 16;
}
while (len--) {
crc = (crc >> 8) ^ pgm_read_dword(&CRC_TABLE_CKSUM[(crc & 0xff) ^ *data++]);
}
seed = crc;
crc = ~REV32(crc);
return crc;
}
uint32_t FastCRC32::cksum(const uint8_t *data, const size_t datalen)
{
// width=32 poly=0x04c11db7 init=0x00000000 refin=false refout=false xorout=0xffffffff check=0x765e7680
seed = 0x00;
return cksum_upd(data, datalen);
}
#endif // #if !defined(KINETISK)

View File

@ -1,410 +0,0 @@
/*
OpenTherm.cpp - OpenTherm Communication Library For Arduino, ESP8266
Copyright 2018, Ihor Melnyk
*/
#include "OpenTherm.h"
OpenTherm::OpenTherm(int inPin, int outPin, bool isSlave):
status(OpenThermStatus::OPTH_NOT_INITIALIZED),
inPin(inPin),
outPin(outPin),
isSlave(isSlave),
response(0),
responseStatus(OpenThermResponseStatus::OPTH_NONE),
responseTimestamp(0),
handleInterruptCallback(NULL),
processResponseCallback(NULL)
{
}
void OpenTherm::begin(void(*handleInterruptCallback)(void), void(*processResponseCallback)(unsigned long, int))
{
pinMode(inPin, INPUT);
pinMode(outPin, OUTPUT);
if (handleInterruptCallback != NULL) {
this->handleInterruptCallback = handleInterruptCallback;
attachInterrupt(digitalPinToInterrupt(inPin), handleInterruptCallback, CHANGE);
}
activateBoiler();
status = OpenThermStatus::OPTH_READY;
this->processResponseCallback = processResponseCallback;
}
void OpenTherm::begin(void(*handleInterruptCallback)(void))
{
begin(handleInterruptCallback, NULL);
}
bool ICACHE_RAM_ATTR OpenTherm::isReady()
{
return status == OpenThermStatus::OPTH_READY;
}
int ICACHE_RAM_ATTR OpenTherm::readState() {
return digitalRead(inPin);
}
void OpenTherm::setActiveState() {
digitalWrite(outPin, LOW);
}
void OpenTherm::setIdleState() {
digitalWrite(outPin, HIGH);
}
void OpenTherm::activateBoiler() {
setIdleState();
delay(1000);
}
void OpenTherm::sendBit(bool high) {
if (high) setActiveState(); else setIdleState();
delayMicroseconds(500);
if (high) setIdleState(); else setActiveState();
delayMicroseconds(500);
}
bool OpenTherm::sendRequestAync(unsigned long request)
{
//Serial.println("Request: " + String(request, HEX));
noInterrupts();
const bool ready = isReady();
interrupts();
if (!ready)
return false;
status = OpenThermStatus::OPTH_REQUEST_SENDING;
response = 0;
responseStatus = OpenThermResponseStatus::OPTH_NONE;
sendBit(HIGH); //start bit
for (int i = 31; i >= 0; i--) {
sendBit(bitRead(request, i));
}
sendBit(HIGH); //stop bit
setIdleState();
status = OpenThermStatus::OPTH_RESPONSE_WAITING;
responseTimestamp = micros();
return true;
}
unsigned long OpenTherm::sendRequest(unsigned long request)
{
if (!sendRequestAync(request)) return 0;
while (!isReady()) {
process();
yield();
}
return response;
}
bool OpenTherm::sendResponse(unsigned long request)
{
status = OpenThermStatus::OPTH_REQUEST_SENDING;
response = 0;
responseStatus = OpenThermResponseStatus::OPTH_NONE;
sendBit(HIGH); //start bit
for (int i = 31; i >= 0; i--) {
sendBit(bitRead(request, i));
}
sendBit(HIGH); //stop bit
setIdleState();
status = OpenThermStatus::OPTH_READY;
return true;
}
OpenThermResponseStatus OpenTherm::getLastResponseStatus()
{
return responseStatus;
}
void ICACHE_RAM_ATTR OpenTherm::handleInterrupt()
{
if (isReady())
{
if (isSlave && readState() == HIGH) {
status = OpenThermStatus::OPTH_RESPONSE_WAITING;
}
else {
return;
}
}
unsigned long newTs = micros();
if (status == OpenThermStatus::OPTH_RESPONSE_WAITING) {
if (readState() == HIGH) {
status = OpenThermStatus::OPTH_RESPONSE_START_BIT;
responseTimestamp = newTs;
}
else {
status = OpenThermStatus::OPTH_RESPONSE_INVALID;
responseTimestamp = newTs;
}
}
else if (status == OpenThermStatus::OPTH_RESPONSE_START_BIT) {
if ((newTs - responseTimestamp < 750) && readState() == LOW) {
status = OpenThermStatus::OPTH_RESPONSE_RECEIVING;
responseTimestamp = newTs;
responseBitIndex = 0;
}
else {
status = OpenThermStatus::OPTH_RESPONSE_INVALID;
responseTimestamp = newTs;
}
}
else if (status == OpenThermStatus::OPTH_RESPONSE_RECEIVING) {
if ((newTs - responseTimestamp) > 750) {
if (responseBitIndex < 32) {
response = (response << 1) | !readState();
responseTimestamp = newTs;
responseBitIndex++;
}
else { //stop bit
status = OpenThermStatus::OPTH_RESPONSE_READY;
responseTimestamp = newTs;
}
}
}
}
void OpenTherm::process()
{
noInterrupts();
OpenThermStatus st = status;
unsigned long ts = responseTimestamp;
interrupts();
if (st == OpenThermStatus::OPTH_READY) return;
unsigned long newTs = micros();
if (st != OpenThermStatus::OPTH_NOT_INITIALIZED && (newTs - ts) > 1000000) {
status = OpenThermStatus::OPTH_READY;
responseStatus = OpenThermResponseStatus::OPTH_TIMEOUT;
if (processResponseCallback != NULL) {
processResponseCallback(response, responseStatus);
}
}
else if (st == OpenThermStatus::OPTH_RESPONSE_INVALID) {
status = OpenThermStatus::OPTH_DELAY;
responseStatus = OpenThermResponseStatus::OPTH_INVALID;
if (processResponseCallback != NULL) {
processResponseCallback(response, responseStatus);
}
}
else if (st == OpenThermStatus::OPTH_RESPONSE_READY) {
status = OpenThermStatus::OPTH_DELAY;
responseStatus = (isSlave ? isValidRequest(response) : isValidResponse(response)) ? OpenThermResponseStatus::OPTH_SUCCESS : OpenThermResponseStatus::OPTH_INVALID;
if (processResponseCallback != NULL) {
processResponseCallback(response, responseStatus);
}
}
else if (st == OpenThermStatus::OPTH_DELAY) {
if ((newTs - ts) > 100000) {
status = OpenThermStatus::OPTH_READY;
}
}
}
bool OpenTherm::parity(unsigned long frame) //odd parity
{
byte p = 0;
while (frame > 0)
{
if (frame & 1) p++;
frame = frame >> 1;
}
return (p & 1);
}
OpenThermMessageType OpenTherm::getMessageType(unsigned long message)
{
OpenThermMessageType msg_type = static_cast<OpenThermMessageType>((message >> 28) & 7);
return msg_type;
}
OpenThermMessageID OpenTherm::getDataID(unsigned long frame)
{
return (OpenThermMessageID)((frame >> 16) & 0xFF);
}
unsigned long OpenTherm::buildRequest(OpenThermMessageType type, OpenThermMessageID id, unsigned int data)
{
unsigned long request = data;
if (type == OpenThermMessageType::OPTH_WRITE_DATA) {
request |= 1ul << 28;
}
request |= ((unsigned long)id) << 16;
if (OpenTherm::parity(request)) request |= (1ul << 31);
return request;
}
unsigned long OpenTherm::buildResponse(OpenThermMessageType type, OpenThermMessageID id, unsigned int data)
{
unsigned long response = data;
response |= type << 28;
response |= ((unsigned long)id) << 16;
if (OpenTherm::parity(response)) response |= (1ul << 31);
return response;
}
bool OpenTherm::isValidResponse(unsigned long response)
{
if (OpenTherm::parity(response)) return false;
byte msgType = (response << 1) >> 29;
return msgType == OPTH_READ_ACK || msgType == OPTH_WRITE_ACK;
}
bool OpenTherm::isValidRequest(unsigned long request)
{
if (OpenTherm::parity(request)) return false;
byte msgType = (request << 1) >> 29;
return msgType == OPTH_READ_DATA || msgType == OPTH_WRITE_DATA;
}
void OpenTherm::end() {
if (this->handleInterruptCallback != NULL) {
detachInterrupt(digitalPinToInterrupt(inPin));
}
}
const char *OpenTherm::statusToString(OpenThermResponseStatus status)
{
switch (status) {
case OPTH_NONE: return "NONE";
case OPTH_SUCCESS: return "SUCCESS";
case OPTH_INVALID: return "INVALID";
case OPTH_TIMEOUT: return "TIMEOUT";
default: return "UNKNOWN";
}
}
const char *OpenTherm::messageTypeToString(OpenThermMessageType message_type)
{
switch (message_type) {
case OPTH_READ_DATA: return "READ_DATA";
case OPTH_WRITE_DATA: return "WRITE_DATA";
case OPTH_INVALID_DATA: return "INVALID_DATA";
case OPTH_RESERVED: return "RESERVED";
case OPTH_READ_ACK: return "READ_ACK";
case OPTH_WRITE_ACK: return "WRITE_ACK";
case OPTH_DATA_INVALID: return "DATA_INVALID";
case OPTH_UNKNOWN_DATA_ID: return "UNKNOWN_DATA_ID";
default: return "UNKNOWN";
}
}
//building requests
unsigned long OpenTherm::buildSetBoilerStatusRequest(bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, bool enableCentralHeating2) {
unsigned int data = enableCentralHeating | (enableHotWater << 1) | (enableCooling << 2) | (enableOutsideTemperatureCompensation << 3) | (enableCentralHeating2 << 4);
data <<= 8;
return buildRequest(OpenThermMessageType::OPTH_READ_DATA, OpenThermMessageID::Status, data);
}
unsigned long OpenTherm::buildSetBoilerTemperatureRequest(float temperature) {
unsigned int data = temperatureToData(temperature);
return buildRequest(OpenThermMessageType::OPTH_WRITE_DATA, OpenThermMessageID::TSet, data);
}
unsigned long OpenTherm::buildSetHotWaterTemperatureRequest(float temperature) {
unsigned int data = temperatureToData(temperature);
return buildRequest(OpenThermMessageType::OPTH_WRITE_DATA, OpenThermMessageID::TdhwSet, data);
}
unsigned long OpenTherm::buildGetBoilerTemperatureRequest() {
return buildRequest(OpenThermMessageType::OPTH_READ_DATA, OpenThermMessageID::Tboiler, 0);
}
unsigned long OpenTherm::buildSlaveConfigurationRequest() {
return buildRequest(OpenThermMessageType::OPTH_READ_DATA, OpenThermMessageID::SConfigSMemberIDcode, 0);
}
//parsing responses
bool OpenTherm::isFault(unsigned long response) {
return response & 0x1;
}
bool OpenTherm::isCentralHeatingActive(unsigned long response) {
return response & 0x2;
}
bool OpenTherm::isHotWaterActive(unsigned long response) {
return response & 0x4;
}
bool OpenTherm::isFlameOn(unsigned long response) {
return response & 0x8;
}
bool OpenTherm::isCoolingActive(unsigned long response) {
return response & 0x10;
}
bool OpenTherm::isDiagnostic(unsigned long response) {
return response & 0x40;
}
uint16_t OpenTherm::getUInt(const unsigned long response) {
const uint16_t u88 = response & 0xffff;
return u88;
}
float OpenTherm::getFloat(const unsigned long response) {
const uint16_t u88 = getUInt(response);
const float f = (u88 & 0x8000) ? -(0x10000L - u88) / 256.0f : u88 / 256.0f;
return f;
}
unsigned int OpenTherm::temperatureToData(float temperature) {
if (temperature < 0) temperature = 0;
if (temperature > 100) temperature = 100;
unsigned int data = (unsigned int)(temperature * 256);
return data;
}
//basic requests
unsigned long OpenTherm::setBoilerStatus(bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, bool enableCentralHeating2) {
return sendRequest(buildSetBoilerStatusRequest(enableCentralHeating, enableHotWater, enableCooling, enableOutsideTemperatureCompensation, enableCentralHeating2));
}
bool OpenTherm::setBoilerTemperature(float temperature) {
unsigned long response = sendRequest(buildSetBoilerTemperatureRequest(temperature));
return isValidResponse(response);
}
bool OpenTherm::setHotWaterTemperature(float temperature) {
unsigned long response = sendRequest(buildSetHotWaterTemperatureRequest(temperature));
return isValidResponse(response);
}
float OpenTherm::getBoilerTemperature() {
unsigned long response = sendRequest(buildGetBoilerTemperatureRequest());
return isValidResponse(response) ? getFloat(response) : 0;
}
float OpenTherm::getReturnTemperature() {
unsigned long response = sendRequest(buildRequest(OpenThermRequestType::OPTH_READ, OpenThermMessageID::Tret, 0));
return isValidResponse(response) ? getFloat(response) : 0;
}
float OpenTherm::getModulation() {
unsigned long response = sendRequest(buildRequest(OpenThermRequestType::OPTH_READ, OpenThermMessageID::RelModLevel, 0));
return isValidResponse(response) ? getFloat(response) : 0;
}
float OpenTherm::getPressure() {
unsigned long response = sendRequest(buildRequest(OpenThermRequestType::OPTH_READ, OpenThermMessageID::CHPressure, 0));
return isValidResponse(response) ? getFloat(response) : 0;
}
unsigned char OpenTherm::getFault() {
return ((sendRequest(buildRequest(OpenThermRequestType::OPTH_READ, OpenThermMessageID::ASFflags, 0)) >> 8) & 0xff);
}
unsigned long OpenTherm::getSlaveConfiguration() {
return sendRequest(buildSlaveConfigurationRequest());
}

View File

@ -1,193 +0,0 @@
/*
OpenTherm.h - OpenTherm Library for the ESP8266/Arduino platform
https://github.com/ihormelnyk/OpenTherm
http://ihormelnyk.com/pages/OpenTherm
Licensed under MIT license
Copyright 2018, Ihor Melnyk
Frame Structure:
P MGS-TYPE SPARE DATA-ID DATA-VALUE
0 000 0000 00000000 00000000 00000000
*/
#ifndef OpenTherm_h
#define OpenTherm_h
#include <stdint.h>
#include <Arduino.h>
enum OpenThermResponseStatus {
OPTH_NONE,
OPTH_SUCCESS,
OPTH_INVALID,
OPTH_TIMEOUT
};
enum OpenThermMessageType {
/* Master to Slave */
OPTH_READ_DATA = B000,
OPTH_READ = OPTH_READ_DATA, // for backwared compatibility
OPTH_WRITE_DATA = B001,
OPTH_WRITE = OPTH_WRITE_DATA, // for backwared compatibility
OPTH_INVALID_DATA = B010,
OPTH_RESERVED = B011,
/* Slave to Master */
OPTH_READ_ACK = B100,
OPTH_WRITE_ACK = B101,
OPTH_DATA_INVALID = B110,
OPTH_UNKNOWN_DATA_ID = B111
};
typedef OpenThermMessageType OpenThermRequestType; // for backwared compatibility
enum OpenThermMessageID {
Status, // flag8 / flag8 Master and Slave Status flags.
TSet, // f8.8 Control setpoint ie CH water temperature setpoint (°C)
MConfigMMemberIDcode, // flag8 / u8 Master Configuration Flags / Master MemberID Code
SConfigSMemberIDcode, // flag8 / u8 Slave Configuration Flags / Slave MemberID Code
Command, // u8 / u8 Remote Command
ASFflags, // / OEM-fault-code flag8 / u8 Application-specific fault flags and OEM fault code
RBPflags, // flag8 / flag8 Remote boiler parameter transfer-enable & read/write flags
CoolingControl, // f8.8 Cooling control signal (%)
TsetCH2, // f8.8 Control setpoint for 2e CH circuit (°C)
TrOverride, // f8.8 Remote override room setpoint
TSP, // u8 / u8 Number of Transparent-Slave-Parameters supported by slave
TSPindexTSPvalue, // u8 / u8 Index number / Value of referred-to transparent slave parameter.
FHBsize, // u8 / u8 Size of Fault-History-Buffer supported by slave
FHBindexFHBvalue, // u8 / u8 Index number / Value of referred-to fault-history buffer entry.
MaxRelModLevelSetting, // f8.8 Maximum relative modulation level setting (%)
MaxCapacityMinModLevel, // u8 / u8 Maximum boiler capacity (kW) / Minimum boiler modulation level(%)
TrSet, // f8.8 Room Setpoint (°C)
RelModLevel, // f8.8 Relative Modulation Level (%)
CHPressure, // f8.8 Water pressure in CH circuit (bar)
DHWFlowRate, // f8.8 Water flow rate in DHW circuit. (litres/minute)
DayTime, // special / u8 Day of Week and Time of Day
Date, // u8 / u8 Calendar date
Year, // u16 Calendar year
TrSetCH2, // f8.8 Room Setpoint for 2nd CH circuit (°C)
Tr, // f8.8 Room temperature (°C)
Tboiler, // f8.8 Boiler flow water temperature (°C)
Tdhw, // f8.8 DHW temperature (°C)
Toutside, // f8.8 Outside temperature (°C)
Tret, // f8.8 Return water temperature (°C)
Tstorage, // f8.8 Solar storage temperature (°C)
Tcollector, // f8.8 Solar collector temperature (°C)
TflowCH2, // f8.8 Flow water temperature CH2 circuit (°C)
Tdhw2, // f8.8 Domestic hot water temperature 2 (°C)
Texhaust, // s16 Boiler exhaust temperature (°C)
TdhwSetUBTdhwSetLB = 48, // s8 / s8 DHW setpoint upper & lower bounds for adjustment (°C)
MaxTSetUBMaxTSetLB, // s8 / s8 Max CH water setpoint upper & lower bounds for adjustment (°C)
HcratioUBHcratioLB, // s8 / s8 OTC heat curve ratio upper & lower bounds for adjustment
TdhwSet = 56, // f8.8 DHW setpoint (°C) (Remote parameter 1)
MaxTSet, // f8.8 Max CH water setpoint (°C) (Remote parameters 2)
Hcratio, // f8.8 OTC heat curve ratio (°C) (Remote parameter 3)
RemoteOverrideFunction = 100, // flag8 / - Function of manual and program changes in master and remote room setpoint.
OEMDiagnosticCode = 115, // u16 OEM-specific diagnostic/service code
BurnerStarts, // u16 Number of starts burner
CHPumpStarts, // u16 Number of starts CH pump
DHWPumpValveStarts, // u16 Number of starts DHW pump/valve
DHWBurnerStarts, // u16 Number of starts burner during DHW mode
BurnerOperationHours, // u16 Number of hours that burner is in operation (i.e. flame on)
CHPumpOperationHours, // u16 Number of hours that CH pump has been running
DHWPumpValveOperationHours, // u16 Number of hours that DHW pump has been running or DHW valve has been opened
DHWBurnerOperationHours, // u16 Number of hours that burner is in operation during DHW mode
OpenThermVersionMaster, // f8.8 The implemented version of the OpenTherm Protocol Specification in the master.
OpenThermVersionSlave, // f8.8 The implemented version of the OpenTherm Protocol Specification in the slave.
MasterVersion, // u8 / u8 Master product version number and type
SlaveVersion, // u8 / u8 Slave product version number and type
};
enum OpenThermStatus {
OPTH_NOT_INITIALIZED,
OPTH_READY,
OPTH_DELAY,
OPTH_REQUEST_SENDING,
OPTH_RESPONSE_WAITING,
OPTH_RESPONSE_START_BIT,
OPTH_RESPONSE_RECEIVING,
OPTH_RESPONSE_READY,
OPTH_RESPONSE_INVALID
};
class OpenTherm
{
public:
OpenTherm(int inPin = 4, int outPin = 5, bool isSlave = false);
volatile OpenThermStatus status;
void begin(void(*handleInterruptCallback)(void));
void begin(void(*handleInterruptCallback)(void), void(*processResponseCallback)(unsigned long, int));
bool isReady();
unsigned long sendRequest(unsigned long request);
bool sendResponse(unsigned long request);
bool sendRequestAync(unsigned long request);
static unsigned long buildRequest(OpenThermMessageType type, OpenThermMessageID id, unsigned int data);
static unsigned long buildResponse(OpenThermMessageType type, OpenThermMessageID id, unsigned int data);
OpenThermResponseStatus getLastResponseStatus();
const char *statusToString(OpenThermResponseStatus status);
void handleInterrupt();
void process();
void end();
static bool parity(unsigned long frame);
OpenThermMessageType getMessageType(unsigned long message);
OpenThermMessageID getDataID(unsigned long frame);
const char *messageTypeToString(OpenThermMessageType message_type);
bool isValidRequest(unsigned long request);
bool isValidResponse(unsigned long response);
//requests
unsigned long buildSetBoilerStatusRequest(bool enableCentralHeating, bool enableHotWater = false, bool enableCooling = false, bool enableOutsideTemperatureCompensation = false, bool enableCentralHeating2 = false);
unsigned long buildSetBoilerTemperatureRequest(float temperature);
unsigned long buildGetBoilerTemperatureRequest();
unsigned long buildSetHotWaterTemperatureRequest(float temperature);
unsigned long buildSlaveConfigurationRequest();
//responses
static bool isFault(unsigned long response);
static bool isCentralHeatingActive(unsigned long response);
static bool isHotWaterActive(unsigned long response);
static bool isFlameOn(unsigned long response);
static bool isCoolingActive(unsigned long response);
static bool isDiagnostic(unsigned long response);
static uint16_t getUInt(const unsigned long response);
static float getFloat(const unsigned long response);
static unsigned int temperatureToData(float temperature);
//basic requests
unsigned long setBoilerStatus(bool enableCentralHeating, bool enableHotWater = false, bool enableCooling = false, bool enableOutsideTemperatureCompensation = false, bool enableCentralHeating2 = false);
bool setBoilerTemperature(float temperature);
bool setHotWaterTemperature(float temperature);
float getBoilerTemperature();
float getReturnTemperature();
float getModulation();
float getPressure();
unsigned char getFault();
unsigned long getSlaveConfiguration();
private:
const int inPin;
const int outPin;
const bool isSlave;
volatile unsigned long response;
volatile OpenThermResponseStatus responseStatus;
volatile unsigned long responseTimestamp;
volatile byte responseBitIndex;
int readState();
void setActiveState();
void setIdleState();
void activateBoiler();
void sendBit(bool high);
void(*handleInterruptCallback)();
void(*processResponseCallback)(unsigned long, int);
};
#ifndef ICACHE_RAM_ATTR
#define ICACHE_RAM_ATTR
#endif
#endif // OpenTherm_h

View File

@ -1,29 +0,0 @@
Attention when updating library. Changes in lib needed!!
All OpenTherm constants shall be prepended with `OPTH_` to avoid conflicts with other libs.
See commit https://github.com/arendst/Tasmota/commit/960291729ccc7cb4da50108e5299d44a79cb06de
As of OpenTherm-0.9.0, hte list is:
OPTH_NONE
OPTH_SUCCESS
OPTH_INVALID
OPTH_TIMEOUT
OPTH_READ_DATA
OPTH_READ
OPTH_WRITE_DATA
OPTH_WRITE
OPTH_INVALID_DATA
OPTH_RESERVED
OPTH_READ_ACK
OPTH_WRITE_ACK
OPTH_DATA_INVALID
OPTH_UNKNOWN_DATA_ID
OPTH_NOT_INITIALIZED
OPTH_READY
OPTH_DELAY
OPTH_REQUEST_SENDING
OPTH_RESPONSE_WAITING
OPTH_RESPONSE_START_BIT
OPTH_RESPONSE_RECEIVING
OPTH_RESPONSE_READY
OPTH_RESPONSE_INVALID

View File

@ -1,8 +1,8 @@
# OpenTherm Arduino/ESP8266 Library # OpenTherm Arduino/ESP8266/ESP32 Library
This library provides implementation of OpenTherm protocol. This library provides implementation of OpenTherm protocol.
OpenTherm Library is based on OpenTherm protocol specification v2.2 and works with all OpenTherm compatible boilers. Library can be easily installed into Arduino IDE and compiled for Arduino, ESP8266 and other similar controllers. OpenTherm Library is based on OpenTherm protocol specification v2.2 and works with all OpenTherm compatible boilers. Library can be easily installed into Arduino IDE and compiled for Arduino, ESP8266/ESP32 and other similar controllers.
OpenTherm protocol requires simple low voltage twowire connection to boiler, but voltage levels (7..15V) still much higher than Arduino/ESP8266 levels, which requires [OpenTherm Adapter](http://ihormelnyk.com/opentherm_adapter). OpenTherm protocol requires simple low voltage twowire connection to boiler, but voltage levels (7..15V) still much higher than Arduino/ESP8266 levels, which requires [OpenTherm Adapter](http://ihormelnyk.com/opentherm_adapter).

View File

@ -30,6 +30,8 @@ doSomething KEYWORD2
setBoilerStatus KEYWORD2 setBoilerStatus KEYWORD2
setBoilerTemperature KEYWORD2 setBoilerTemperature KEYWORD2
getBoilerTemperature KEYWORD2 getBoilerTemperature KEYWORD2
setDHWSetpoint KEYWORD2
getDHWTemperature KEYWORD2
####################################### #######################################
# Instances (KEYWORD2) # Instances (KEYWORD2)

View File

@ -1,8 +1,8 @@
name=OpenTherm Library name=OpenTherm Library
version=0.9.0 version=1.1.5
author=Ihor Melnyk <ihor.melnyk@gmail.com> author=Ihor Melnyk <ihor.melnyk@gmail.com>
maintainer=Ihor Melnyk <ihor.melnyk@gmail.com> maintainer=Ihor Melnyk <ihor.melnyk@gmail.com>
sentence=OpenTherm Library for HVAC system control communication using Arduino and ESP8266 hardware. sentence=OpenTherm Library for HVAC system control communication using Arduino and ESP8266/ESP32 hardware.
paragraph=OpenTherm Library is based on OpenTherm protocol specification v2.2 and works with all OpenTherm compatible boilers. paragraph=OpenTherm Library is based on OpenTherm protocol specification v2.2 and works with all OpenTherm compatible boilers.
category=Communication category=Communication
url=https://github.com/ihormelnyk/opentherm_library url=https://github.com/ihormelnyk/opentherm_library

View File

@ -0,0 +1,578 @@
/*
OpenTherm.cpp - OpenTherm Communication Library For Arduino, ESP8266, ESP32
Copyright 2023, Ihor Melnyk
*/
#include "OpenTherm.h"
#if !defined(__AVR__)
#include "FunctionalInterrupt.h"
#endif
OpenTherm::OpenTherm(int inPin, int outPin, bool isSlave) :
status(OpenThermStatus::NOT_INITIALIZED),
inPin(inPin),
outPin(outPin),
isSlave(isSlave),
response(0),
responseStatus(OpenThermResponseStatus::NONE),
responseTimestamp(0),
processResponseCallback(NULL)
{
}
void OpenTherm::begin(void (*handleInterruptCallback)(void))
{
pinMode(inPin, INPUT);
pinMode(outPin, OUTPUT);
if (handleInterruptCallback != NULL)
{
attachInterrupt(digitalPinToInterrupt(inPin), handleInterruptCallback, CHANGE);
}
else
{
#if !defined(__AVR__)
attachInterruptArg(
digitalPinToInterrupt(inPin),
OpenTherm::handleInterruptHelper,
this,
CHANGE
);
#endif
}
activateBoiler();
status = OpenThermStatus::READY;
}
void OpenTherm::begin(void (*handleInterruptCallback)(void), void (*processResponseCallback)(unsigned long, int))
{
begin(handleInterruptCallback);
this->processResponseCallback = processResponseCallback;
}
#if !defined(__AVR__)
void OpenTherm::begin()
{
begin(NULL);
}
void OpenTherm::begin(std::function<void(unsigned long, OpenThermResponseStatus)> processResponseFunction)
{
begin();
this->processResponseFunction = processResponseFunction;
}
#endif
bool IRAM_ATTR OpenTherm::isReady()
{
return status == OpenThermStatus::READY;
}
int IRAM_ATTR OpenTherm::readState()
{
return digitalRead(inPin);
}
void OpenTherm::setActiveState()
{
digitalWrite(outPin, LOW);
}
void OpenTherm::setIdleState()
{
digitalWrite(outPin, HIGH);
}
void OpenTherm::activateBoiler()
{
setIdleState();
delay(1000);
}
void OpenTherm::sendBit(bool high)
{
if (high)
setActiveState();
else
setIdleState();
delayMicroseconds(500);
if (high)
setIdleState();
else
setActiveState();
delayMicroseconds(500);
}
bool OpenTherm::sendRequestAsync(unsigned long request)
{
noInterrupts();
const bool ready = isReady();
if (!ready)
{
interrupts();
return false;
}
status = OpenThermStatus::REQUEST_SENDING;
response = 0;
responseStatus = OpenThermResponseStatus::NONE;
#ifdef INC_FREERTOS_H
BaseType_t schedulerState = xTaskGetSchedulerState();
if (schedulerState == taskSCHEDULER_RUNNING)
{
vTaskSuspendAll();
}
#endif
interrupts();
sendBit(HIGH); // start bit
for (int i = 31; i >= 0; i--)
{
sendBit(bitRead(request, i));
}
sendBit(HIGH); // stop bit
setIdleState();
responseTimestamp = micros();
status = OpenThermStatus::RESPONSE_WAITING;
#ifdef INC_FREERTOS_H
if (schedulerState == taskSCHEDULER_RUNNING) {
xTaskResumeAll();
}
#endif
return true;
}
unsigned long OpenTherm::sendRequest(unsigned long request)
{
if (!sendRequestAsync(request))
{
return 0;
}
while (!isReady())
{
process();
yield();
}
return response;
}
bool OpenTherm::sendResponse(unsigned long request)
{
noInterrupts();
const bool ready = isReady();
if (!ready)
{
interrupts();
return false;
}
status = OpenThermStatus::REQUEST_SENDING;
response = 0;
responseStatus = OpenThermResponseStatus::NONE;
#ifdef INC_FREERTOS_H
BaseType_t schedulerState = xTaskGetSchedulerState();
if (schedulerState == taskSCHEDULER_RUNNING)
{
vTaskSuspendAll();
}
#endif
interrupts();
sendBit(HIGH); // start bit
for (int i = 31; i >= 0; i--)
{
sendBit(bitRead(request, i));
}
sendBit(HIGH); // stop bit
setIdleState();
status = OpenThermStatus::READY;
#ifdef INC_FREERTOS_H
if (schedulerState == taskSCHEDULER_RUNNING) {
xTaskResumeAll();
}
#endif
return true;
}
unsigned long OpenTherm::getLastResponse()
{
return response;
}
OpenThermResponseStatus OpenTherm::getLastResponseStatus()
{
return responseStatus;
}
void IRAM_ATTR OpenTherm::handleInterrupt()
{
if (isReady())
{
if (isSlave && readState() == HIGH)
{
status = OpenThermStatus::RESPONSE_WAITING;
}
else
{
return;
}
}
unsigned long newTs = micros();
if (status == OpenThermStatus::RESPONSE_WAITING)
{
if (readState() == HIGH)
{
status = OpenThermStatus::RESPONSE_START_BIT;
responseTimestamp = newTs;
}
else
{
status = OpenThermStatus::RESPONSE_INVALID;
responseTimestamp = newTs;
}
}
else if (status == OpenThermStatus::RESPONSE_START_BIT)
{
if ((newTs - responseTimestamp < 750) && readState() == LOW)
{
status = OpenThermStatus::RESPONSE_RECEIVING;
responseTimestamp = newTs;
responseBitIndex = 0;
}
else
{
status = OpenThermStatus::RESPONSE_INVALID;
responseTimestamp = newTs;
}
}
else if (status == OpenThermStatus::RESPONSE_RECEIVING)
{
if ((newTs - responseTimestamp) > 750)
{
if (responseBitIndex < 32)
{
response = (response << 1) | !readState();
responseTimestamp = newTs;
responseBitIndex = responseBitIndex + 1;
}
else
{ // stop bit
status = OpenThermStatus::RESPONSE_READY;
responseTimestamp = newTs;
}
}
}
}
#if !defined(__AVR__)
void IRAM_ATTR OpenTherm::handleInterruptHelper(void* ptr)
{
static_cast<OpenTherm*>(ptr)->handleInterrupt();
}
#endif
void OpenTherm::processResponse()
{
if (processResponseCallback != NULL)
{
processResponseCallback(response, (int)responseStatus);
}
#if !defined(__AVR__)
if (this->processResponseFunction != NULL)
{
processResponseFunction(response, responseStatus);
}
#endif
}
void OpenTherm::process()
{
noInterrupts();
OpenThermStatus st = status;
unsigned long ts = responseTimestamp;
interrupts();
if (st == OpenThermStatus::READY)
return;
unsigned long newTs = micros();
if (st != OpenThermStatus::NOT_INITIALIZED && st != OpenThermStatus::DELAY && (newTs - ts) > 1000000)
{
status = OpenThermStatus::READY;
responseStatus = OpenThermResponseStatus::TIMEOUT;
processResponse();
}
else if (st == OpenThermStatus::RESPONSE_INVALID)
{
status = OpenThermStatus::DELAY;
responseStatus = OpenThermResponseStatus::INVALID;
processResponse();
}
else if (st == OpenThermStatus::RESPONSE_READY)
{
status = OpenThermStatus::DELAY;
responseStatus = (isSlave ? isValidRequest(response) : isValidResponse(response)) ? OpenThermResponseStatus::SUCCESS : OpenThermResponseStatus::INVALID;
processResponse();
}
else if (st == OpenThermStatus::DELAY)
{
if ((newTs - ts) > (isSlave ? 20000 : 100000))
{
status = OpenThermStatus::READY;
}
}
}
bool OpenTherm::parity(unsigned long frame) // odd parity
{
byte p = 0;
while (frame > 0)
{
if (frame & 1)
p++;
frame = frame >> 1;
}
return (p & 1);
}
OpenThermMessageType OpenTherm::getMessageType(unsigned long message)
{
OpenThermMessageType msg_type = static_cast<OpenThermMessageType>((message >> 28) & 7);
return msg_type;
}
OpenThermMessageID OpenTherm::getDataID(unsigned long frame)
{
return (OpenThermMessageID)((frame >> 16) & 0xFF);
}
unsigned long OpenTherm::buildRequest(OpenThermMessageType type, OpenThermMessageID id, unsigned int data)
{
unsigned long request = data;
if (type == OpenThermMessageType::WRITE_DATA)
{
request |= 1ul << 28;
}
request |= ((unsigned long)id) << 16;
if (parity(request))
request |= (1ul << 31);
return request;
}
unsigned long OpenTherm::buildResponse(OpenThermMessageType type, OpenThermMessageID id, unsigned int data)
{
unsigned long response = data;
response |= ((unsigned long)type) << 28;
response |= ((unsigned long)id) << 16;
if (parity(response))
response |= (1ul << 31);
return response;
}
bool OpenTherm::isValidResponse(unsigned long response)
{
if (parity(response))
return false;
byte msgType = (response << 1) >> 29;
return msgType == (byte)OpenThermMessageType::READ_ACK || msgType == (byte)OpenThermMessageType::WRITE_ACK;
}
bool OpenTherm::isValidRequest(unsigned long request)
{
if (parity(request))
return false;
byte msgType = (request << 1) >> 29;
return msgType == (byte)OpenThermMessageType::READ_DATA || msgType == (byte)OpenThermMessageType::WRITE_DATA;
}
void OpenTherm::end()
{
detachInterrupt(digitalPinToInterrupt(inPin));
}
OpenTherm::~OpenTherm()
{
end();
}
const char *OpenTherm::statusToString(OpenThermResponseStatus status)
{
switch (status)
{
case OpenThermResponseStatus::NONE:
return "NONE";
case OpenThermResponseStatus::SUCCESS:
return "SUCCESS";
case OpenThermResponseStatus::INVALID:
return "INVALID";
case OpenThermResponseStatus::TIMEOUT:
return "TIMEOUT";
default:
return "UNKNOWN";
}
}
const char *OpenTherm::messageTypeToString(OpenThermMessageType message_type)
{
switch (message_type)
{
case OpenThermMessageType::READ_DATA:
return "READ_DATA";
case OpenThermMessageType::WRITE_DATA:
return "WRITE_DATA";
case OpenThermMessageType::INVALID_DATA:
return "INVALID_DATA";
case OpenThermMessageType::RESERVED:
return "RESERVED";
case OpenThermMessageType::READ_ACK:
return "READ_ACK";
case OpenThermMessageType::WRITE_ACK:
return "WRITE_ACK";
case OpenThermMessageType::DATA_INVALID:
return "DATA_INVALID";
case OpenThermMessageType::UNKNOWN_DATA_ID:
return "UNKNOWN_DATA_ID";
default:
return "UNKNOWN";
}
}
// building requests
unsigned long OpenTherm::buildSetBoilerStatusRequest(bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, bool enableCentralHeating2)
{
unsigned int data = enableCentralHeating | (enableHotWater << 1) | (enableCooling << 2) | (enableOutsideTemperatureCompensation << 3) | (enableCentralHeating2 << 4);
data <<= 8;
return buildRequest(OpenThermMessageType::READ_DATA, OpenThermMessageID::Status, data);
}
unsigned long OpenTherm::buildSetBoilerTemperatureRequest(float temperature)
{
unsigned int data = temperatureToData(temperature);
return buildRequest(OpenThermMessageType::WRITE_DATA, OpenThermMessageID::TSet, data);
}
unsigned long OpenTherm::buildGetBoilerTemperatureRequest()
{
return buildRequest(OpenThermMessageType::READ_DATA, OpenThermMessageID::Tboiler, 0);
}
// parsing responses
bool OpenTherm::isFault(unsigned long response)
{
return response & 0x1;
}
bool OpenTherm::isCentralHeatingActive(unsigned long response)
{
return response & 0x2;
}
bool OpenTherm::isHotWaterActive(unsigned long response)
{
return response & 0x4;
}
bool OpenTherm::isFlameOn(unsigned long response)
{
return response & 0x8;
}
bool OpenTherm::isCoolingActive(unsigned long response)
{
return response & 0x10;
}
bool OpenTherm::isDiagnostic(unsigned long response)
{
return response & 0x40;
}
uint16_t OpenTherm::getUInt(const unsigned long response)
{
const uint16_t u88 = response & 0xffff;
return u88;
}
float OpenTherm::getFloat(const unsigned long response)
{
const uint16_t u88 = getUInt(response);
const float f = (u88 & 0x8000) ? -(0x10000L - u88) / 256.0f : u88 / 256.0f;
return f;
}
unsigned int OpenTherm::temperatureToData(float temperature)
{
if (temperature < 0)
temperature = 0;
if (temperature > 100)
temperature = 100;
unsigned int data = (unsigned int)(temperature * 256);
return data;
}
// basic requests
unsigned long OpenTherm::setBoilerStatus(bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, bool enableCentralHeating2)
{
return sendRequest(buildSetBoilerStatusRequest(enableCentralHeating, enableHotWater, enableCooling, enableOutsideTemperatureCompensation, enableCentralHeating2));
}
bool OpenTherm::setBoilerTemperature(float temperature)
{
unsigned long response = sendRequest(buildSetBoilerTemperatureRequest(temperature));
return isValidResponse(response);
}
float OpenTherm::getBoilerTemperature()
{
unsigned long response = sendRequest(buildGetBoilerTemperatureRequest());
return isValidResponse(response) ? getFloat(response) : 0;
}
float OpenTherm::getReturnTemperature()
{
unsigned long response = sendRequest(buildRequest(OpenThermRequestType::READ, OpenThermMessageID::Tret, 0));
return isValidResponse(response) ? getFloat(response) : 0;
}
bool OpenTherm::setDHWSetpoint(float temperature)
{
unsigned int data = temperatureToData(temperature);
unsigned long response = sendRequest(buildRequest(OpenThermMessageType::WRITE_DATA, OpenThermMessageID::TdhwSet, data));
return isValidResponse(response);
}
float OpenTherm::getDHWTemperature()
{
unsigned long response = sendRequest(buildRequest(OpenThermMessageType::READ_DATA, OpenThermMessageID::Tdhw, 0));
return isValidResponse(response) ? getFloat(response) : 0;
}
float OpenTherm::getModulation()
{
unsigned long response = sendRequest(buildRequest(OpenThermRequestType::READ, OpenThermMessageID::RelModLevel, 0));
return isValidResponse(response) ? getFloat(response) : 0;
}
float OpenTherm::getPressure()
{
unsigned long response = sendRequest(buildRequest(OpenThermRequestType::READ, OpenThermMessageID::CHPressure, 0));
return isValidResponse(response) ? getFloat(response) : 0;
}
unsigned char OpenTherm::getFault()
{
return ((sendRequest(buildRequest(OpenThermRequestType::READ, OpenThermMessageID::ASFflags, 0)) >> 8) & 0xff);
}

View File

@ -0,0 +1,256 @@
/*
OpenTherm.h - OpenTherm Library for the ESP8266/ESP32/Arduino platform
https://github.com/ihormelnyk/OpenTherm
http://ihormelnyk.com/pages/OpenTherm
Licensed under MIT license
Copyright 2023, Ihor Melnyk
Frame Structure:
P MGS-TYPE SPARE DATA-ID DATA-VALUE
0 000 0000 00000000 00000000 00000000
*/
#ifndef OpenTherm_h
#define OpenTherm_h
#include <stdint.h>
#include <Arduino.h>
enum class OpenThermResponseStatus : byte
{
NONE,
SUCCESS,
INVALID,
TIMEOUT
};
enum class OpenThermMessageType : byte
{
/* Master to Slave */
READ_DATA = 0b000,
READ = READ_DATA, // for backwared compatibility
WRITE_DATA = 0b001,
WRITE = WRITE_DATA, // for backwared compatibility
INVALID_DATA = 0b010,
RESERVED = 0b011,
/* Slave to Master */
READ_ACK = 0b100,
WRITE_ACK = 0b101,
DATA_INVALID = 0b110,
UNKNOWN_DATA_ID = 0b111
};
typedef OpenThermMessageType OpenThermRequestType; // for backwared compatibility
enum class OpenThermMessageID : byte
{
Status = 0, // flag8/flag8 Master and Slave Status flags.
TSet = 1, // f8.8 Control Setpoint i.e.CH water temperature Setpoint(°C)
MConfigMMemberIDcode = 2, // flag8/u8 Master Configuration Flags / Master MemberID Code
SConfigSMemberIDcode = 3, // flag8/u8 Slave Configuration Flags / Slave MemberID Code
RemoteRequest = 4, // u8/u8 Remote Request
ASFflags = 5, // flag8/u8 Application - specific fault flags and OEM fault code
RBPflags = 6, // flag8/flag8 Remote boiler parameter transfer - enable & read / write flags
CoolingControl = 7, // f8.8 Cooling control signal(%)
TsetCH2 = 8, // f8.8 Control Setpoint for 2e CH circuit(°C)
TrOverride = 9, // f8.8 Remote override room Setpoint
TSP = 10, // u8/u8 Number of Transparent - Slave - Parameters supported by slave
TSPindexTSPvalue = 11, // u8/u8 Index number / Value of referred - to transparent slave parameter.
FHBsize = 12, // u8/u8 Size of Fault - History - Buffer supported by slave
FHBindexFHBvalue = 13, // u8/u8 Index number / Value of referred - to fault - history buffer entry.
MaxRelModLevelSetting = 14, // f8.8 Maximum relative modulation level setting(%)
MaxCapacityMinModLevel = 15, // u8/u8 Maximum boiler capacity(kW) / Minimum boiler modulation level(%)
TrSet = 16, // f8.8 Room Setpoint(°C)
RelModLevel = 17, // f8.8 Relative Modulation Level(%)
CHPressure = 18, // f8.8 Water pressure in CH circuit(bar)
DHWFlowRate = 19, // f8.8 Water flow rate in DHW circuit. (litres / minute)
DayTime = 20, // special/u8 Day of Week and Time of Day
Date = 21, // u8/u8 Calendar date
Year = 22, // u16 Calendar year
TrSetCH2 = 23, // f8.8 Room Setpoint for 2nd CH circuit(°C)
Tr = 24, // f8.8 Room temperature(°C)
Tboiler = 25, // f8.8 Boiler flow water temperature(°C)
Tdhw = 26, // f8.8 DHW temperature(°C)
Toutside = 27, // f8.8 Outside temperature(°C)
Tret = 28, // f8.8 Return water temperature(°C)
Tstorage = 29, // f8.8 Solar storage temperature(°C)
Tcollector = 30, // f8.8 Solar collector temperature(°C)
TflowCH2 = 31, // f8.8 Flow water temperature CH2 circuit(°C)
Tdhw2 = 32, // f8.8 Domestic hot water temperature 2 (°C)
Texhaust = 33, // s16 Boiler exhaust temperature(°C)
TboilerHeatExchanger = 34, // f8.8 Boiler heat exchanger temperature(°C)
BoilerFanSpeedSetpointAndActual = 35, // u8/u8 Boiler fan speed Setpoint and actual value
FlameCurrent = 36, // f8.8 Electrical current through burner flame[μA]
TrCH2 = 37, // f8.8 Room temperature for 2nd CH circuit(°C)
RelativeHumidity = 38, // f8.8 Actual relative humidity as a percentage
TrOverride2 = 39, // f8.8 Remote Override Room Setpoint 2
TdhwSetUBTdhwSetLB = 48, // s8/s8 DHW Setpoint upper & lower bounds for adjustment(°C)
MaxTSetUBMaxTSetLB = 49, // s8/s8 Max CH water Setpoint upper & lower bounds for adjustment(°C)
TdhwSet = 56, // f8.8 DHW Setpoint(°C) (Remote parameter 1)
MaxTSet = 57, // f8.8 Max CH water Setpoint(°C) (Remote parameters 2)
StatusVentilationHeatRecovery = 70, // flag8/flag8 Master and Slave Status flags ventilation / heat - recovery
Vset = 71, // -/u8 Relative ventilation position (0-100%). 0% is the minimum set ventilation and 100% is the maximum set ventilation.
ASFflagsOEMfaultCodeVentilationHeatRecovery = 72, // flag8/u8 Application-specific fault flags and OEM fault code ventilation / heat-recovery
OEMDiagnosticCodeVentilationHeatRecovery = 73, // u16 An OEM-specific diagnostic/service code for ventilation / heat-recovery system
SConfigSMemberIDCodeVentilationHeatRecovery = 74, // flag8/u8 Slave Configuration Flags / Slave MemberID Code ventilation / heat-recovery
OpenThermVersionVentilationHeatRecovery = 75, // f8.8 The implemented version of the OpenTherm Protocol Specification in the ventilation / heat-recovery system.
VentilationHeatRecoveryVersion = 76, // u8/u8 Ventilation / heat-recovery product version number and type
RelVentLevel = 77, // -/u8 Relative ventilation (0-100%)
RHexhaust = 78, // -/u8 Relative humidity exhaust air (0-100%)
CO2exhaust = 79, // u16 CO2 level exhaust air (0-2000 ppm)
Tsi = 80, // f8.8 Supply inlet temperature (°C)
Tso = 81, // f8.8 Supply outlet temperature (°C)
Tei = 82, // f8.8 Exhaust inlet temperature (°C)
Teo = 83, // f8.8 Exhaust outlet temperature (°C)
RPMexhaust = 84, // u16 Exhaust fan speed in rpm
RPMsupply = 85, // u16 Supply fan speed in rpm
RBPflagsVentilationHeatRecovery = 86, // flag8/flag8 Remote ventilation / heat-recovery parameter transfer-enable & read/write flags
NominalVentilationValue = 87, // u8/- Nominal relative value for ventilation (0-100 %)
TSPventilationHeatRecovery = 88, // u8/u8 Number of Transparent-Slave-Parameters supported by TSPs ventilation / heat-recovery
TSPindexTSPvalueVentilationHeatRecovery = 89, // u8/u8 Index number / Value of referred-to transparent TSPs ventilation / heat-recovery parameter.
FHBsizeVentilationHeatRecovery = 90, // u8/u8 Size of Fault-History-Buffer supported by ventilation / heat-recovery
FHBindexFHBvalueVentilationHeatRecovery = 91, // u8/u8 Index number / Value of referred-to fault-history buffer entry ventilation / heat-recovery
Brand = 93, // u8/u8 Index number of the character in the text string ASCII character referenced by the above index number
BrandVersion = 94, // u8/u8 Index number of the character in the text string ASCII character referenced by the above index number
BrandSerialNumber = 95, // u8/u8 Index number of the character in the text string ASCII character referenced by the above index number
CoolingOperationHours = 96, // u16 Number of hours that the slave is in Cooling Mode. Reset by zero is optional for slave
PowerCycles = 97, // u16 Number of Power Cycles of a slave (wake-up after Reset), Reset by zero is optional for slave
RFsensorStatusInformation = 98, // special/special For a specific RF sensor the RF strength and battery level is written
RemoteOverrideOperatingModeHeatingDHW = 99, // special/special Operating Mode HC1, HC2/ Operating Mode DHW
RemoteOverrideFunction = 100, // flag8/- Function of manual and program changes in master and remote room Setpoint
StatusSolarStorage = 101, // flag8/flag8 Master and Slave Status flags Solar Storage
ASFflagsOEMfaultCodeSolarStorage = 102, // flag8/u8 Application-specific fault flags and OEM fault code Solar Storage
SConfigSMemberIDcodeSolarStorage = 103, // flag8/u8 Slave Configuration Flags / Slave MemberID Code Solar Storage
SolarStorageVersion = 104, // u8/u8 Solar Storage product version number and type
TSPSolarStorage = 105, // u8/u8 Number of Transparent - Slave - Parameters supported by TSPs Solar Storage
TSPindexTSPvalueSolarStorage = 106, // u8/u8 Index number / Value of referred - to transparent TSPs Solar Storage parameter.
FHBsizeSolarStorage = 107, // u8/u8 Size of Fault - History - Buffer supported by Solar Storage
FHBindexFHBvalueSolarStorage = 108, // u8/u8 Index number / Value of referred - to fault - history buffer entry Solar Storage
ElectricityProducerStarts = 109, // U16 Number of start of the electricity producer.
ElectricityProducerHours = 110, // U16 Number of hours the electricity produces is in operation
ElectricityProduction = 111, // U16 Current electricity production in Watt.
CumulativElectricityProduction = 112, // U16 Cumulative electricity production in KWh.
UnsuccessfulBurnerStarts = 113, // u16 Number of un - successful burner starts
FlameSignalTooLowNumber = 114, // u16 Number of times flame signal was too low
OEMDiagnosticCode = 115, // u16 OEM - specific diagnostic / service code
SuccessfulBurnerStarts = 116, // u16 Number of succesful starts burner
CHPumpStarts = 117, // u16 Number of starts CH pump
DHWPumpValveStarts = 118, // u16 Number of starts DHW pump / valve
DHWBurnerStarts = 119, // u16 Number of starts burner during DHW mode
BurnerOperationHours = 120, // u16 Number of hours that burner is in operation(i.e.flame on)
CHPumpOperationHours = 121, // u16 Number of hours that CH pump has been running
DHWPumpValveOperationHours = 122, // u16 Number of hours that DHW pump has been running or DHW valve has been opened
DHWBurnerOperationHours = 123, // u16 Number of hours that burner is in operation during DHW mode
OpenThermVersionMaster = 124, // f8.8 The implemented version of the OpenTherm Protocol Specification in the master.
OpenThermVersionSlave = 125, // f8.8 The implemented version of the OpenTherm Protocol Specification in the slave.
MasterVersion = 126, // u8/u8 Master product version number and type
SlaveVersion = 127, // u8/u8 Slave product version number and type
};
enum class OpenThermStatus : byte
{
NOT_INITIALIZED,
READY,
DELAY,
REQUEST_SENDING,
RESPONSE_WAITING,
RESPONSE_START_BIT,
RESPONSE_RECEIVING,
RESPONSE_READY,
RESPONSE_INVALID
};
class OpenTherm
{
public:
OpenTherm(int inPin = 4, int outPin = 5, bool isSlave = false);
~OpenTherm();
volatile OpenThermStatus status;
void begin(void (*handleInterruptCallback)(void));
void begin(void (*handleInterruptCallback)(void), void (*processResponseCallback)(unsigned long, int));
#if !defined(__AVR__)
void begin();
void begin(std::function<void(unsigned long, OpenThermResponseStatus)> processResponseFunction);
#endif
bool isReady();
unsigned long sendRequest(unsigned long request);
bool sendResponse(unsigned long request);
bool sendRequestAsync(unsigned long request);
static unsigned long buildRequest(OpenThermMessageType type, OpenThermMessageID id, unsigned int data);
static unsigned long buildResponse(OpenThermMessageType type, OpenThermMessageID id, unsigned int data);
unsigned long getLastResponse();
OpenThermResponseStatus getLastResponseStatus();
static const char *statusToString(OpenThermResponseStatus status);
void handleInterrupt();
#if !defined(__AVR__)
static void handleInterruptHelper(void* ptr);
#endif
void process();
void end();
static bool parity(unsigned long frame);
static OpenThermMessageType getMessageType(unsigned long message);
static OpenThermMessageID getDataID(unsigned long frame);
static const char *messageTypeToString(OpenThermMessageType message_type);
static bool isValidRequest(unsigned long request);
static bool isValidResponse(unsigned long response);
// requests
static unsigned long buildSetBoilerStatusRequest(bool enableCentralHeating, bool enableHotWater = false, bool enableCooling = false, bool enableOutsideTemperatureCompensation = false, bool enableCentralHeating2 = false);
static unsigned long buildSetBoilerTemperatureRequest(float temperature);
static unsigned long buildGetBoilerTemperatureRequest();
// responses
static bool isFault(unsigned long response);
static bool isCentralHeatingActive(unsigned long response);
static bool isHotWaterActive(unsigned long response);
static bool isFlameOn(unsigned long response);
static bool isCoolingActive(unsigned long response);
static bool isDiagnostic(unsigned long response);
static uint16_t getUInt(const unsigned long response);
static float getFloat(const unsigned long response);
static unsigned int temperatureToData(float temperature);
// basic requests
unsigned long setBoilerStatus(bool enableCentralHeating, bool enableHotWater = false, bool enableCooling = false, bool enableOutsideTemperatureCompensation = false, bool enableCentralHeating2 = false);
bool setBoilerTemperature(float temperature);
float getBoilerTemperature();
float getReturnTemperature();
bool setDHWSetpoint(float temperature);
float getDHWTemperature();
float getModulation();
float getPressure();
unsigned char getFault();
private:
const int inPin;
const int outPin;
const bool isSlave;
volatile unsigned long response;
volatile OpenThermResponseStatus responseStatus;
volatile unsigned long responseTimestamp;
volatile byte responseBitIndex;
int readState();
void setActiveState();
void setIdleState();
void activateBoiler();
void sendBit(bool high);
void processResponse();
void (*processResponseCallback)(unsigned long, int);
#if !defined(__AVR__)
std::function<void(unsigned long, OpenThermResponseStatus)> processResponseFunction;
#endif
};
#ifndef ICACHE_RAM_ATTR
#define ICACHE_RAM_ATTR
#endif
#ifndef IRAM_ATTR
#define IRAM_ATTR ICACHE_RAM_ATTR
#endif
#endif // OpenTherm_h

View File

@ -6,7 +6,7 @@
#include "DataParsers.h" #include "DataParsers.h"
#include "DataParser.h" #include "DataParser.h"
#include "Cosem.h" #include "Cosem.h"
#include "ntohll.h" #include "ntohll_ams.h"
#define BUF_SIZE_HAN (1280) #define BUF_SIZE_HAN (1280)

View File

@ -1,5 +1,5 @@
#include "ntohll.h" #include "ntohll_ams.h"
uint64_t ntohll(uint64_t x) { uint64_t ntohll_ams(uint64_t x) {
return (((uint64_t)ntohl((uint32_t)x)) << 32) + ntohl(x >> 32); return (((uint64_t)ntohl((uint32_t)x)) << 32) + ntohl(x >> 32);
} }

View File

@ -3,6 +3,6 @@
#include "lwip/def.h" #include "lwip/def.h"
uint64_t ntohll(uint64_t x); uint64_t ntohll_ams(uint64_t x);
#endif #endif

Some files were not shown because too many files have changed in this diff Show More