Merge branch 'arendst:development' into rm_dead_code

This commit is contained in:
Jason2866 2022-06-04 16:58:46 +02:00 committed by GitHub
commit d7305828d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
457 changed files with 12952 additions and 4400 deletions

View File

@ -32,13 +32,18 @@ jobs:
- tasmota-zbbridge - tasmota-zbbridge
- tasmota-zigbee - tasmota-zigbee
- tasmota32 - tasmota32
- tasmota32-zbbrdgpro
- tasmota32-webcam - tasmota32-webcam
- tasmota32-bluetooth - tasmota32-bluetooth
- tasmota32-nspanel
- tasmota32-display - tasmota32-display
- tasmota32-ir - tasmota32-ir
- tasmota32-lvgl - tasmota32-lvgl
- tasmota32c3 - tasmota32c3
- tasmota32c3usb - tasmota32c3usb
- tasmota32s2
- tasmota32s3
- tasmota32s3usb
- tasmota32solo1 - tasmota32solo1
- tasmota32solo1-safeboot - tasmota32solo1-safeboot
- tasmota32-safeboot - tasmota32-safeboot
@ -46,6 +51,7 @@ jobs:
- tasmota32c3usb-safeboot - tasmota32c3usb-safeboot
- tasmota32s2-safeboot - tasmota32s2-safeboot
- tasmota32s3-safeboot - tasmota32s3-safeboot
- tasmota32s3usb-safeboot
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
@ -121,9 +127,13 @@ jobs:
[ ! -f ./mv_firmware/firmware/tasmota32-lvgl.* ] || mv ./mv_firmware/firmware/tasmota32-lvgl.* ./firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32-lvgl.* ] || mv ./mv_firmware/firmware/tasmota32-lvgl.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-web*.* ] || mv ./mv_firmware/firmware/tasmota32-web*.* ./firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32-web*.* ] || mv ./mv_firmware/firmware/tasmota32-web*.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-odroidgo.* ] || mv ./mv_firmware/firmware/tasmota32-odroidgo.* ./firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32-odroidgo.* ] || mv ./mv_firmware/firmware/tasmota32-odroidgo.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-zbbrdgpro.* ] || mv ./mv_firmware/firmware/tasmota32-zbbrdgpro.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-nspanel.* ] || mv ./mv_firmware/firmware/tasmota32-nspanel.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-core2.* ] || mv ./mv_firmware/firmware/tasmota32-core2.* ./firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32-core2.* ] || mv ./mv_firmware/firmware/tasmota32-core2.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-bluetooth.* ] || mv ./mv_firmware/firmware/tasmota32-bluetooth.* ./firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32-bluetooth.* ] || mv ./mv_firmware/firmware/tasmota32-bluetooth.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32c3*.* ] || mv ./mv_firmware/firmware/tasmota32c3*.* ./firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32c3*.* ] || mv ./mv_firmware/firmware/tasmota32c3*.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32s2*.* ] || mv ./mv_firmware/firmware/tasmota32s2*.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32s3*.* ] || mv ./mv_firmware/firmware/tasmota32s3*.* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-safeboot* ] || mv ./mv_firmware/firmware/tasmota32-safeboot* ./firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32-safeboot* ] || mv ./mv_firmware/firmware/tasmota32-safeboot* ./firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-* ] || mv ./mv_firmware/firmware/tasmota32-* ./firmware/tasmota32/languages/ [ ! -f ./mv_firmware/firmware/tasmota32-* ] || mv ./mv_firmware/firmware/tasmota32-* ./firmware/tasmota32/languages/
[ ! -f ./mv_firmware/firmware/tasmota32* ] || mv ./mv_firmware/firmware/tasmota32* ./firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32* ] || mv ./mv_firmware/firmware/tasmota32* ./firmware/tasmota32/

View File

@ -31,20 +31,26 @@ jobs:
- tasmota-zbbridge - tasmota-zbbridge
- tasmota-zigbee - tasmota-zigbee
- tasmota32 - tasmota32
- tasmota32-zbbrdgpro
- tasmota32-webcam - tasmota32-webcam
- tasmota32-bluetooth - tasmota32-bluetooth
- tasmota32-nspanel
- tasmota32-display - tasmota32-display
- tasmota32-ir - tasmota32-ir
- tasmota32-lvgl - tasmota32-lvgl
- tasmota32c3 - tasmota32c3
- tasmota32c3usb - tasmota32c3usb
- tasmota32s2
- tasmota32s3
- tasmota32s3usb
- tasmota32solo1 - tasmota32solo1
- tasmota32solo1-safeboot - tasmota32solo1-safeboot
- tasmota32-safeboot - tasmota32-safeboot
- tasmota32c3-safeboot - tasmota32c3-safeboot
- tasmota32c3usb-safeboot
- tasmota32s2-safeboot - tasmota32s2-safeboot
- tasmota32s3-safeboot - tasmota32s3-safeboot
- tasmota32c3usb-safeboot - tasmota32s3usb-safeboot
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
@ -128,10 +134,14 @@ jobs:
[ ! -f ./mv_firmware/firmware/tasmota32-display.* ] || mv ./mv_firmware/firmware/tasmota32-display.* ./release-firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32-display.* ] || mv ./mv_firmware/firmware/tasmota32-display.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-lvgl.* ] || mv ./mv_firmware/firmware/tasmota32-lvgl.* ./release-firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32-lvgl.* ] || mv ./mv_firmware/firmware/tasmota32-lvgl.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-web*.* ] || mv ./mv_firmware/firmware/tasmota32-web*.* ./release-firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32-web*.* ] || mv ./mv_firmware/firmware/tasmota32-web*.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-zbbrdgpro.* ] || mv ./mv_firmware/firmware/tasmota32-zbbrdgpro.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-nspanel.* ] || mv ./mv_firmware/firmware/tasmota32-nspanel.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-odroidgo.* ] || mv ./mv_firmware/firmware/tasmota32-odroidgo.* ./release-firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32-odroidgo.* ] || mv ./mv_firmware/firmware/tasmota32-odroidgo.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-core2.* ] || mv ./mv_firmware/firmware/tasmota32-core2.* ./release-firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32-core2.* ] || mv ./mv_firmware/firmware/tasmota32-core2.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-bluetooth.* ] || mv ./mv_firmware/firmware/tasmota32-bluetooth.* ./release-firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32-bluetooth.* ] || mv ./mv_firmware/firmware/tasmota32-bluetooth.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32c3*.* ] || mv ./mv_firmware/firmware/tasmota32c3*.* ./release-firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32c3*.* ] || mv ./mv_firmware/firmware/tasmota32c3*.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32s2*.* ] || mv ./mv_firmware/firmware/tasmota32s2*.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32s3*.* ] || mv ./mv_firmware/firmware/tasmota32s3*.* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-safeboot* ] || mv ./mv_firmware/firmware/tasmota32-safeboot* ./release-firmware/tasmota32/ [ ! -f ./mv_firmware/firmware/tasmota32-safeboot* ] || mv ./mv_firmware/firmware/tasmota32-safeboot* ./release-firmware/tasmota32/
[ ! -f ./mv_firmware/firmware/tasmota32-* ] || mv ./mv_firmware/firmware/tasmota32-* ./release-firmware/tasmota32/languages/ [ ! -f ./mv_firmware/firmware/tasmota32-* ] || mv ./mv_firmware/firmware/tasmota32-* ./release-firmware/tasmota32/languages/
[ ! -f ./mv_firmware/firmware/tasmota32* ] || mv ./mv_firmware/firmware/tasmota32* ./release-firmware/tasmota32/languages/ [ ! -f ./mv_firmware/firmware/tasmota32* ] || mv ./mv_firmware/firmware/tasmota32* ./release-firmware/tasmota32/languages/

View File

@ -32,17 +32,21 @@ jobs:
- tasmota-minimal - tasmota-minimal
- tasmota-sensors - tasmota-sensors
- tasmota-zbbridge - tasmota-zbbridge
- tasmota32-zbbrdgpro
- tasmota-zigbee - tasmota-zigbee
- tasmota32 - tasmota32
- tasmota32-webcam - tasmota32-webcam
- tasmota32-bluetooth - tasmota32-bluetooth
- tasmota32-core2 - tasmota32-core2
- tasmota32-nspanel
- tasmota32-display - tasmota32-display
- tasmota32-ir - tasmota32-ir
- tasmota32-lvgl - tasmota32-lvgl
- tasmota32s2
- tasmota32c3 - tasmota32c3
- tasmota32c3usb - tasmota32c3usb
- tasmota32s2
- tasmota32s3
- tasmota32s3usb
- tasmota32solo1 - tasmota32solo1
- tasmota32solo1-safeboot - tasmota32solo1-safeboot
- tasmota32-safeboot - tasmota32-safeboot
@ -50,6 +54,7 @@ jobs:
- tasmota32c3usb-safeboot - tasmota32c3usb-safeboot
- tasmota32s2-safeboot - tasmota32s2-safeboot
- tasmota32s3-safeboot - tasmota32s3-safeboot
- tasmota32s3usb-safeboot
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Set up Python - name: Set up Python

View File

@ -1,47 +0,0 @@
language: python
python:
- '3.7'
sudo: false
install:
- pip install -U platformio
- platformio upgrade --dev
- platformio update
cache: false
env:
- ENV=tasmota
- ENV=tasmota-minimal
- ENV=tasmota-lite
- ENV=tasmota-knx
- ENV=tasmota-sensors
- ENV=tasmota-display
- ENV=tasmota-ir
- ENV=tasmota-BG
- ENV=tasmota-BR
- ENV=tasmota-CN
- ENV=tasmota-CZ
- ENV=tasmota-DE
- ENV=tasmota-ES
- ENV=tasmota-FR
- ENV=tasmota-GR
- ENV=tasmota-HE
- ENV=tasmota-HU
- ENV=tasmota-IT
- ENV=tasmota-KO
- ENV=tasmota-NL
- ENV=tasmota-PL
- ENV=tasmota-PT
- ENV=tasmota-RO
- ENV=tasmota-RU
- ENV=tasmota-SE
- ENV=tasmota-SK
- ENV=tasmota-TR
- ENV=tasmota-TW
- ENV=tasmota-UK
- ENV=tasmota-VN
script:
- platformio run -e $ENV
before_deploy:
- for file in .pioenvs/*/firmware.bin; do cp $file ${file%/*}.bin; done

View File

@ -65,6 +65,7 @@ Note: `minimal` variant is not listed as it shouldn't be used outside of the [up
| USE_MY92X1 | - | x / - | x | x | - | x | | USE_MY92X1 | - | x / - | x | x | - | x |
| USE_SM16716 | - | x / - | x | x | - | x | | USE_SM16716 | - | x / - | x | x | - | x |
| USE_SM2135 | - | x / - | x | x | - | x | | USE_SM2135 | - | x / - | x | x | - | x |
| USE_BP5758D | - | x / - | x | x | - | x |
| USE_SONOFF_L1 | - | x / - | x | x | - | x | | USE_SONOFF_L1 | - | x / - | x | x | - | x |
| USE_ELECTRIQ_MOODL | - | x / - | x | x | - | x | | USE_ELECTRIQ_MOODL | - | x / - | x | x | - | x |
| | | | | | | | | | | | | | | |
@ -170,6 +171,7 @@ Note: `minimal` variant is not listed as it shouldn't be used outside of the [up
| USE_HDC2010 | - | - / - | - | - | - | - | | USE_HDC2010 | - | - / - | - | - | - | - |
| USE_PCF85363 | - | - / - | - | - | - | - | | USE_PCF85363 | - | - / - | - | - | - | - |
| USE_DS3502 | - | - / - | - | - | - | - | | USE_DS3502 | - | - / - | - | - | - | - |
| USE_HYT | - | - / - | - | - | - | - |
| | | | | | | | | | | | | | | |
| Feature or Sensor | l | t | k | s | i | d | Remarks | Feature or Sensor | l | t | k | s | i | d | Remarks
| USE_SPI | - | - / - | - | - | - | x | | USE_SPI | - | - / - | - | - | - | x |
@ -241,6 +243,7 @@ Note: `minimal` variant is not listed as it shouldn't be used outside of the [up
| USE_MI_ESP32 | | / x | | | | | See SetOption115 | USE_MI_ESP32 | | / x | | | | | See SetOption115
| USE_IBEACON_ESP32 | | / - | | | | | | USE_IBEACON_ESP32 | | / - | | | | |
| USE_WEBCAM | | / - | | | | | | USE_WEBCAM | | / - | | | | |
| USE_ETHERNET | | / - | | | | | | USE_ETHERNET | | / x | | | | |
| USE_I2S_AUDIO | | / - | | | | | | USE_I2S_AUDIO | | / - | | | | |
| USE_TTGO_WATCH | | / - | | | | | | USE_TTGO_WATCH | | / - | | | | |
| USE_SONOFF_SPM | | / x | | | | |

View File

@ -3,19 +3,30 @@ All notable changes to this project will be documented in this file.
## [Unreleased] - Development ## [Unreleased] - Development
## [11.1.0.3] ## [11.1.0.4]
### Added ### Added
- Support for Sonoff SPM v1.2.0 - Support for HYTxxx temperature and humidity sensor (#15715)
- Support for Sensirion SHT4X using define USE_SHT3X (#15349)
### Changed ### Changed
- Restructured tasmota source directories taking benefit from PlatformIO Core v6.0.2
### Fixed ### Fixed
### Removed ### Removed
## [11.1.0.3] 20220602
### Added
- Support for Sonoff SPM v1.2.0
- Support for Sonoff Zigbee Bridge Pro by Stephan Hadinger (#15701)
- Command ``SspmDisplay 2`` to display Sonoff SPM energy data in GUI for user tab-selected relay modules (#13447)
- Command ``SetOption141 1`` to disable display of module name in GUI header
- Support for 5-channel light dimmer driver BP5758D used in Tuya bulbs (#15713)
### Fixed
- Possible pin output toggle after power on (#15630)
## [11.1.0.2] 20220514 ## [11.1.0.2] 20220514
### Added ### Added
- ESP32 Command ``Restart 3`` to switch between SafeBoot and Production - ESP32 Command ``Restart 3`` to switch between SafeBoot and Production

View File

@ -31,7 +31,8 @@ Index | Define | Driver | Device | Address(es) | Description
13 | USE_ADS1115 | xsns_12 | ADS1115 | 0x48 - 0x4B | 4-channel 16-bit A/D converter 13 | USE_ADS1115 | xsns_12 | ADS1115 | 0x48 - 0x4B | 4-channel 16-bit A/D converter
14 | USE_INA219 | xsns_13 | INA219 | 0x40 - 0x41, 0x44 - 0x45 | Low voltage current sensor 14 | USE_INA219 | xsns_13 | INA219 | 0x40 - 0x41, 0x44 - 0x45 | Low voltage current sensor
15 | USE_SHT3X | xsns_14 | SHT3X | 0x44 - 0x45 | Temperature and Humidity sensor 15 | USE_SHT3X | xsns_14 | SHT3X | 0x44 - 0x45 | Temperature and Humidity sensor
15 | USE_SHT3X | xsns_14 | SHTC3 | 0x70 | Temperature and Humidity sensor 15 | USE_SHT3X | xsns_14 | SHT4X | 0x44 - 0x45 | Temperature and Humidity sensor
15 | USE_SHT3X | xsns_14 | SHTCX | 0x70 | Temperature and Humidity sensor
16 | USE_TSL2561 | xsns_16 | TSL2561 | 0x29, 0x39, 0x49 | Light intensity sensor 16 | USE_TSL2561 | xsns_16 | TSL2561 | 0x29, 0x39, 0x49 | Light intensity sensor
17 | USE_MGS | xsns_19 | Grove | 0x04 | Multichannel gas sensor 17 | USE_MGS | xsns_19 | Grove | 0x04 | Multichannel gas sensor
18 | USE_SGP30 | xsns_21 | SGP30 | 0x58 | Gas (TVOC) and air quality sensor 18 | USE_SGP30 | xsns_21 | SGP30 | 0x58 | Gas (TVOC) and air quality sensor
@ -101,3 +102,4 @@ Index | Define | Driver | Device | Address(es) | Description
65 | USE_ADE7880 | xnrg_23 | ADE7880 | 0x38 | Energy monitor 65 | USE_ADE7880 | xnrg_23 | ADE7880 | 0x38 | Energy monitor
66 | USE_PCF85363 | xsns_99 | PCF85363 | 0x51 | Real time clock 66 | USE_PCF85363 | xsns_99 | PCF85363 | 0x51 | Real time clock
67 | USE_DS3502 | xdrv_61 | DS3502 | 0x28 - 0x2B | Digital potentiometer 67 | USE_DS3502 | xdrv_61 | DS3502 | 0x28 - 0x2B | Digital potentiometer
68 | USE_HYT | xsns_97 | HYTxxx | 0x28 | Temperature and Humidity sensor

View File

@ -104,22 +104,29 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
[Complete list](BUILDS.md) of available feature and sensors. [Complete list](BUILDS.md) of available feature and sensors.
## Changelog v11.1.0.3 ## Changelog v11.1.0.4
### Added ### Added
- Command ``SetOption139 0/1`` to switch between pressure unit "mmHg" (0) or "inHg" (1) when ``SO24 1`` [#15350](https://github.com/arendst/Tasmota/issues/15350) - Command ``SetOption139 0/1`` to switch between pressure unit "mmHg" (0) or "inHg" (1) when ``SO24 1`` [#15350](https://github.com/arendst/Tasmota/issues/15350)
- Command ``SetOption140 0/1`` to switch between MQTT Clean Session (0) or Persistent Session (1) [#15530](https://github.com/arendst/Tasmota/issues/15530) - Command ``SetOption140 0/1`` to switch between MQTT Clean Session (0) or Persistent Session (1) [#15530](https://github.com/arendst/Tasmota/issues/15530)
- Command ``SetOption141 1`` to disable display of module name in GUI header
- Command ``EnergyExportActive<phase>`` to (p)reset energy export active for supported devices. Currently ADE7880 only [#13515](https://github.com/arendst/Tasmota/issues/13515) - Command ``EnergyExportActive<phase>`` to (p)reset energy export active for supported devices. Currently ADE7880 only [#13515](https://github.com/arendst/Tasmota/issues/13515)
- Command ``IfxRp ""|<policy>`` adds optional InfluxDb Retention Policy [#15513](https://github.com/arendst/Tasmota/issues/15513) - Command ``IfxRp ""|<policy>`` adds optional InfluxDb Retention Policy [#15513](https://github.com/arendst/Tasmota/issues/15513)
- Command ``SspmDisplay 2`` to display Sonoff SPM energy data in GUI for user tab-selected relay modules [#13447](https://github.com/arendst/Tasmota/issues/13447)
- Support for Sonoff MS01 soil moisture sensor [#15335](https://github.com/arendst/Tasmota/issues/15335) - Support for Sonoff MS01 soil moisture sensor [#15335](https://github.com/arendst/Tasmota/issues/15335)
- Support for daisy chaining MAX7219 displays [#15345](https://github.com/arendst/Tasmota/issues/15345) - Support for daisy chaining MAX7219 displays [#15345](https://github.com/arendst/Tasmota/issues/15345)
- Support for Sensirion SHT4X using define USE_SHT3X [#15349](https://github.com/arendst/Tasmota/issues/15349)
- Sonoff SPM delayed SetPowerOnState [#13447](https://github.com/arendst/Tasmota/issues/13447) - Sonoff SPM delayed SetPowerOnState [#13447](https://github.com/arendst/Tasmota/issues/13447)
- Support for Sonoff SPM v1.2.0 - Support for Sonoff SPM v1.2.0
- Support for Sonoff Zigbee Bridge Pro by Stephan Hadinger [#15701](https://github.com/arendst/Tasmota/issues/15701)
- Support for flowrate meters like YF-DN50 and similary [#15474](https://github.com/arendst/Tasmota/issues/15474) - Support for flowrate meters like YF-DN50 and similary [#15474](https://github.com/arendst/Tasmota/issues/15474)
- Support for 5-channel light dimmer driver BP5758D used in Tuya bulbs [#15713](https://github.com/arendst/Tasmota/issues/15713)
- Support for HYTxxx temperature and humidity sensor [#15715](https://github.com/arendst/Tasmota/issues/15715)
- ESP32 Command ``Restart 3`` to switch between SafeBoot and Production - ESP32 Command ``Restart 3`` to switch between SafeBoot and Production
### Breaking Changed ### Breaking Changed
### Changed ### Changed
- Restructured tasmota source directories taking benefit from PlatformIO Core v6.0.2
- Prepare to remove dedicated Home Assistant discovery in favour of Tasmota Discovery and hatasmota - Prepare to remove dedicated Home Assistant discovery in favour of Tasmota Discovery and hatasmota
- ESP32 Tasmota SafeBoot with changed partition scheme allowing larger binaries - ESP32 Tasmota SafeBoot with changed partition scheme allowing larger binaries
@ -127,6 +134,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmo
- Improv initial or erase device installation failing to provide Configure WiFi option - Improv initial or erase device installation failing to provide Configure WiFi option
- SCD40 start low power command [#15361](https://github.com/arendst/Tasmota/issues/15361) - SCD40 start low power command [#15361](https://github.com/arendst/Tasmota/issues/15361)
- BL09xx negative power presentation [#15374](https://github.com/arendst/Tasmota/issues/15374) - BL09xx negative power presentation [#15374](https://github.com/arendst/Tasmota/issues/15374)
- Possible pin output toggle after power on [#15630](https://github.com/arendst/Tasmota/issues/15630)
### Removed ### Removed
- Arduino IDE support - Arduino IDE support

46
boards/esp32s3usb.json Normal file
View File

@ -0,0 +1,46 @@
{
"build": {
"arduino":{
"ldscript": "esp32s3_out.ld",
"memory_type": "qspi_qspi"
},
"core": "esp32",
"extra_flags": "-DBOARD_HAS_PSRAM -DARDUINO_USB_MODE=1 -DARDUINO_USB_CDC_ON_BOOT=0 -DARDUINO_USB_MSC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=0 -DUSE_USB_SERIAL_CONSOLE -DESP32_4M -DESP32S3",
"f_cpu": "240000000L",
"f_flash": "80000000L",
"flash_mode": "dio",
"mcu": "esp32s3",
"variant": "esp32s3",
"partitions": "partitions/esp32_partition_app2880k_fs320k.csv"
},
"connectivity": [
"wifi",
"bluetooth",
"ethernet"
],
"debug": {
"openocd_target": "esp32s3.cfg"
},
"frameworks": [
"espidf",
"arduino"
],
"name": "Espressif Generic ESP32-S3 4M Flash, Tasmota 2880k Code/OTA, 320k FS",
"upload": {
"arduino": {
"flash_extra_images": [
[
"0x10000",
"variants/tasmota/tasmota32s3usb-safeboot.bin"
]
]
},
"flash_size": "4MB",
"maximum_ram_size": 327680,
"maximum_size": 4194304,
"require_upload_port": true,
"speed": 460800
},
"url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/",
"vendor": "Espressif"
}

View File

@ -21,6 +21,6 @@
#define __TASMOTA_INCLUDE__ #define __TASMOTA_INCLUDE__
#include "../tasmota/my_user_config.h" #include "../tasmota/my_user_config.h"
#include "../tasmota/tasmota_configurations.h" #include "../tasmota/include/tasmota_configurations.h"
#endif // __TASMOTA_INCLUDE__ #endif // __TASMOTA_INCLUDE__

View File

@ -48,7 +48,7 @@ public:
inline uint8_t *buf(size_t i = 0) const { return &_buf->buf[i]; } inline uint8_t *buf(size_t i = 0) const { return &_buf->buf[i]; }
inline char *charptr(size_t i = 0) const { return (char*) &_buf->buf[i]; } inline char *charptr(size_t i = 0) const { return (char*) &_buf->buf[i]; }
virtual ~SBuffer(void) { ~SBuffer(void) {
delete[] _buf; delete[] _buf;
} }
@ -258,6 +258,12 @@ public:
return buf2; return buf2;
} }
static SBuffer SBufferFromBytes(const uint8_t *bytes, size_t len2) {
SBuffer buf2(len2);
buf2.addBuffer(bytes, len2);
return buf2;
}
// nullptr accepted // nullptr accepted
static bool equalsSBuffer(const class SBuffer * buf1, const class SBuffer * buf2) { static bool equalsSBuffer(const class SBuffer * buf1, const class SBuffer * buf2) {
if (buf1 == buf2) { return true; } if (buf1 == buf2) { return true; }
@ -290,18 +296,3 @@ protected:
SBuffer_impl * _buf; SBuffer_impl * _buf;
} SBuffer; } SBuffer;
typedef class PreAllocatedSBuffer : public SBuffer {
public:
PreAllocatedSBuffer(const size_t size, void * buffer) {
_buf = (SBuffer_impl*) buffer;
_buf->size = size - 4;
_buf->len = 0;
}
~PreAllocatedSBuffer(void) {
// don't deallocate
_buf = nullptr;
}
} PreAllocatedSBuffer;

View File

@ -252,7 +252,6 @@ int32_t Unishox::unishox_compress(const char *p_in, size_t p_len, char *p_out, s
out = p_out; out = p_out;
len_out = p_len_out; len_out = p_len_out;
char *ptr;
byte bits; byte bits;
int ll; int ll;

View File

@ -391,7 +391,7 @@ static uint32_t json_encode_utf8(char* str, uint32_t val) {
void json_unescape(char* string) { void json_unescape(char* string) {
size_t outlength = 0; size_t outlength = 0;
uint32_t hexval, numbytes; uint32_t numbytes;
char c; char c;
for (uint32_t i = 0; (c = string[i]) != 0; i++) { for (uint32_t i = 0; (c = string[i]) != 0; i++) {

View File

@ -48,13 +48,16 @@ be_extern_native_module(uuid);
be_extern_native_module(animate); be_extern_native_module(animate);
be_extern_native_module(partition_core); be_extern_native_module(partition_core);
be_extern_native_module(crc); be_extern_native_module(crc);
#ifdef USE_ZIGBEE
be_extern_native_module(zigbee);
#endif // USE_ZIGBEE
#ifdef USE_LVGL #ifdef USE_LVGL
be_extern_native_module(lv); be_extern_native_module(lv);
be_extern_native_module(lv_extra); be_extern_native_module(lv_extra);
be_extern_native_module(lv_tasmota); be_extern_native_module(lv_tasmota);
#ifdef USE_LVGL_OPENHASP #ifdef USE_LVGL_HASPMOTA
be_extern_native_module(openhasp); be_extern_native_module(haspmota);
#endif // USE_LVGL_OPENHASP #endif // USE_LVGL_HASPMOTA
#endif // USE_LVGL #endif // USE_LVGL
/* user-defined modules declare start */ /* user-defined modules declare start */
@ -137,9 +140,9 @@ BERRY_LOCAL const bntvmodule* const be_module_table[] = {
&be_native_module(lv), &be_native_module(lv),
&be_native_module(lv_extra), &be_native_module(lv_extra),
&be_native_module(lv_tasmota), &be_native_module(lv_tasmota),
#ifdef USE_LVGL_OPENHASP #ifdef USE_LVGL_HASPMOTA
&be_native_module(openhasp), &be_native_module(haspmota),
#endif // USE_LVGL_OPENHASP #endif // USE_LVGL_HASPMOTA
#endif // USE_LVGL #endif // USE_LVGL
#ifdef USE_ENERGY_SENSOR #ifdef USE_ENERGY_SENSOR
&be_native_module(energy), &be_native_module(energy),
@ -147,6 +150,9 @@ BERRY_LOCAL const bntvmodule* const be_module_table[] = {
#ifdef USE_WEBSERVER #ifdef USE_WEBSERVER
&be_native_module(webserver), &be_native_module(webserver),
#endif // USE_WEBSERVER #endif // USE_WEBSERVER
#ifdef USE_ZIGBEE
&be_native_module(zigbee),
#endif // USE_ZIGBEE
&be_native_module(flash), &be_native_module(flash),
&be_native_module(partition_core), &be_native_module(partition_core),
&be_native_module(crc), &be_native_module(crc),

View File

@ -12,7 +12,7 @@
#ifdef COMPILE_BERRY_LIB #ifdef COMPILE_BERRY_LIB
#include "my_user_config.h" #include "my_user_config.h"
#include "tasmota_configurations.h" #include "include/tasmota_configurations.h"
#endif #endif
/* Macro: BE_DEBUG /* Macro: BE_DEBUG

View File

@ -1,2 +1,8 @@
#!/bin/bash #!/bin/bash
#
# generate all precompiled Berry structures from multiple modules
#
# Should be eventually included in the build process
#
rm generate/be_*.h
python3 tools/pycoc/main.py -o generate src default ../berry_tasmota/src ../berry_mapping/src ../berry_int64/src ../../libesp32_lvgl/lv_binding_berry/src ../../libesp32_lvgl/lv_binding_berry/generate -c default/berry_conf.h python3 tools/pycoc/main.py -o generate src default ../berry_tasmota/src ../berry_mapping/src ../berry_int64/src ../../libesp32_lvgl/lv_binding_berry/src ../../libesp32_lvgl/lv_binding_berry/generate -c default/berry_conf.h

View File

@ -1,5 +1,6 @@
extern const bcstring be_const_str_; extern const bcstring be_const_str_;
extern const bcstring be_const_str_00; extern const bcstring be_const_str_00;
extern const bcstring be_const_str_0x_X2502X;
extern const bcstring be_const_str_AA50; extern const bcstring be_const_str_AA50;
extern const bcstring be_const_str_AES_GCM; extern const bcstring be_const_str_AES_GCM;
extern const bcstring be_const_str_ALIGN_BOTTOM_MID; extern const bcstring be_const_str_ALIGN_BOTTOM_MID;
@ -245,6 +246,7 @@ extern const bcstring be_const_str__energy;
extern const bcstring be_const_str__error; extern const bcstring be_const_str__error;
extern const bcstring be_const_str__filename; extern const bcstring be_const_str__filename;
extern const bcstring be_const_str__fl; extern const bcstring be_const_str__fl;
extern const bcstring be_const_str__get_bytes;
extern const bcstring be_const_str__global_addr; extern const bcstring be_const_str__global_addr;
extern const bcstring be_const_str__global_def; extern const bcstring be_const_str__global_def;
extern const bcstring be_const_str__lvgl; extern const bcstring be_const_str__lvgl;
@ -255,6 +257,7 @@ extern const bcstring be_const_str__read;
extern const bcstring be_const_str__request_from; extern const bcstring be_const_str__request_from;
extern const bcstring be_const_str__rmt; extern const bcstring be_const_str__rmt;
extern const bcstring be_const_str__rules; extern const bcstring be_const_str__rules;
extern const bcstring be_const_str__set_bytes;
extern const bcstring be_const_str__settings_def; extern const bcstring be_const_str__settings_def;
extern const bcstring be_const_str__settings_ptr; extern const bcstring be_const_str__settings_ptr;
extern const bcstring be_const_str__splash; extern const bcstring be_const_str__splash;
@ -264,6 +267,7 @@ extern const bcstring be_const_str__timers;
extern const bcstring be_const_str__validate; extern const bcstring be_const_str__validate;
extern const bcstring be_const_str__write; extern const bcstring be_const_str__write;
extern const bcstring be_const_str_a; extern const bcstring be_const_str_a;
extern const bcstring be_const_str_abort;
extern const bcstring be_const_str_abs; extern const bcstring be_const_str_abs;
extern const bcstring be_const_str_acos; extern const bcstring be_const_str_acos;
extern const bcstring be_const_str_active_otadata; extern const bcstring be_const_str_active_otadata;
@ -486,6 +490,7 @@ extern const bcstring be_const_str_format;
extern const bcstring be_const_str_from_to; extern const bcstring be_const_str_from_to;
extern const bcstring be_const_str_fromb64; extern const bcstring be_const_str_fromb64;
extern const bcstring be_const_str_frombytes; extern const bcstring be_const_str_frombytes;
extern const bcstring be_const_str_fromhex;
extern const bcstring be_const_str_fromptr; extern const bcstring be_const_str_fromptr;
extern const bcstring be_const_str_fromstring; extern const bcstring be_const_str_fromstring;
extern const bcstring be_const_str_full_state; extern const bcstring be_const_str_full_state;
@ -567,6 +572,7 @@ extern const bcstring be_const_str_imax;
extern const bcstring be_const_str_img; extern const bcstring be_const_str_img;
extern const bcstring be_const_str_imin; extern const bcstring be_const_str_imin;
extern const bcstring be_const_str_import; extern const bcstring be_const_str_import;
extern const bcstring be_const_str_info;
extern const bcstring be_const_str_init; extern const bcstring be_const_str_init;
extern const bcstring be_const_str_init_draw_arc_dsc; extern const bcstring be_const_str_init_draw_arc_dsc;
extern const bcstring be_const_str_init_draw_line_dsc; extern const bcstring be_const_str_init_draw_line_dsc;
@ -917,6 +923,7 @@ extern const bcstring be_const_str_subscribe;
extern const bcstring be_const_str_subtype; extern const bcstring be_const_str_subtype;
extern const bcstring be_const_str_subtype_to_string; extern const bcstring be_const_str_subtype_to_string;
extern const bcstring be_const_str_success; extern const bcstring be_const_str_success;
extern const bcstring be_const_str_sum;
extern const bcstring be_const_str_super; extern const bcstring be_const_str_super;
extern const bcstring be_const_str_switch_factory; extern const bcstring be_const_str_switch_factory;
extern const bcstring be_const_str_sys; extern const bcstring be_const_str_sys;
@ -940,6 +947,7 @@ extern const bcstring be_const_str_timer_cb;
extern const bcstring be_const_str_to_gamma; extern const bcstring be_const_str_to_gamma;
extern const bcstring be_const_str_tob64; extern const bcstring be_const_str_tob64;
extern const bcstring be_const_str_tobytes; extern const bcstring be_const_str_tobytes;
extern const bcstring be_const_str_tohex;
extern const bcstring be_const_str_toint; extern const bcstring be_const_str_toint;
extern const bcstring be_const_str_tolower; extern const bcstring be_const_str_tolower;
extern const bcstring be_const_str_tomap; extern const bcstring be_const_str_tomap;
@ -1029,5 +1037,9 @@ extern const bcstring be_const_str_y;
extern const bcstring be_const_str_y1; extern const bcstring be_const_str_y1;
extern const bcstring be_const_str_year; extern const bcstring be_const_str_year;
extern const bcstring be_const_str_yield; extern const bcstring be_const_str_yield;
extern const bcstring be_const_str_zb_coord_ntv;
extern const bcstring be_const_str_zb_device;
extern const bcstring be_const_str_zcl_frame;
extern const bcstring be_const_str_zcl_frame_ntv;
extern const bcstring be_const_str_zero; extern const bcstring be_const_str_zero;
extern const bcstring be_const_str_zip; extern const bcstring be_const_str_zip;

File diff suppressed because it is too large Load Diff

View File

@ -1,42 +1,44 @@
#include "be_constobj.h" #include "be_constobj.h"
static be_define_const_map_slots(be_class_bytes_map) { static be_define_const_map_slots(be_class_bytes_map) {
{ be_const_key(deinit, -1), be_const_func(m_deinit) },
{ be_const_key(get, 5), be_const_func(m_getu) },
{ be_const_key(fromb64, 18), be_const_func(m_fromb64) },
{ be_const_key(copy, -1), be_const_func(m_copy) },
{ be_const_key(_buffer, -1), be_const_func(m_buffer) },
{ be_const_key(getfloat, -1), be_const_func(m_getfloat) },
{ be_const_key(getbits, -1), be_const_closure(getbits_closure) },
{ be_const_key(tob64, -1), be_const_func(m_tob64) },
{ be_const_key(item, -1), be_const_func(m_item) },
{ be_const_key(_X21_X3D, -1), be_const_func(m_nequal) },
{ be_const_key(clear, 28), be_const_func(m_clear) },
{ be_const_key(size, 4), be_const_func(m_size) },
{ be_const_key(fromstring, -1), be_const_func(m_fromstring) },
{ be_const_key(_X2Elen, 21), be_const_var(0) },
{ be_const_key(seti, -1), be_const_func(m_set) },
{ be_const_key(_X2B, 9), be_const_func(m_merge) },
{ be_const_key(_X2Esize, 13), be_const_var(1) },
{ be_const_key(setfloat, 6), be_const_func(m_setfloat) },
{ be_const_key(_X2Ep, -1), be_const_var(2) },
{ be_const_key(set, -1), be_const_func(m_set) }, { be_const_key(set, -1), be_const_func(m_set) },
{ be_const_key(asstring, 0), be_const_func(m_asstring) }, { be_const_key(_X2Elen, 0), be_const_var(0) },
{ be_const_key(add, 24), be_const_func(m_add) }, { be_const_key(tob64, 4), be_const_func(m_tob64) },
{ be_const_key(setitem, -1), be_const_func(m_setitem) },
{ be_const_key(_change_buffer, -1), be_const_func(m_change_buffer) },
{ be_const_key(_X3D_X3D, 15), be_const_func(m_equal) },
{ be_const_key(resize, 2), be_const_func(m_resize) },
{ be_const_key(tostring, -1), be_const_func(m_tostring) },
{ be_const_key(setbits, -1), be_const_closure(setbits_closure) },
{ be_const_key(_X2E_X2E, -1), be_const_func(m_connect) }, { be_const_key(_X2E_X2E, -1), be_const_func(m_connect) },
{ be_const_key(setfloat, -1), be_const_func(m_setfloat) },
{ be_const_key(get, 2), be_const_func(m_getu) },
{ be_const_key(asstring, -1), be_const_func(m_asstring) },
{ be_const_key(getfloat, 24), be_const_func(m_getfloat) },
{ be_const_key(_buffer, -1), be_const_func(m_buffer) },
{ be_const_key(init, -1), be_const_func(m_init) }, { be_const_key(init, -1), be_const_func(m_init) },
{ be_const_key(_X2Esize, 23), be_const_var(1) },
{ be_const_key(tohex, 16), be_const_func(m_tohex) },
{ be_const_key(fromhex, -1), be_const_func(m_fromhex) },
{ be_const_key(setbits, 7), be_const_closure(setbits_closure) },
{ be_const_key(copy, 31), be_const_func(m_copy) },
{ be_const_key(size, 17), be_const_func(m_size) },
{ be_const_key(getbits, -1), be_const_closure(getbits_closure) },
{ be_const_key(fromb64, -1), be_const_func(m_fromb64) },
{ be_const_key(_change_buffer, -1), be_const_func(m_change_buffer) },
{ be_const_key(_X21_X3D, 30), be_const_func(m_nequal) },
{ be_const_key(clear, -1), be_const_func(m_clear) },
{ be_const_key(seti, 18), be_const_func(m_set) },
{ be_const_key(_X2B, -1), be_const_func(m_merge) },
{ be_const_key(add, 26), be_const_func(m_add) },
{ be_const_key(deinit, -1), be_const_func(m_deinit) },
{ be_const_key(tostring, -1), be_const_func(m_tostring) },
{ be_const_key(item, -1), be_const_func(m_item) },
{ be_const_key(geti, -1), be_const_func(m_geti) }, { be_const_key(geti, -1), be_const_func(m_geti) },
{ be_const_key(resize, -1), be_const_func(m_resize) },
{ be_const_key(setitem, -1), be_const_func(m_setitem) },
{ be_const_key(_X2Ep, -1), be_const_var(2) },
{ be_const_key(fromstring, -1), be_const_func(m_fromstring) },
{ be_const_key(_X3D_X3D, -1), be_const_func(m_equal) },
}; };
static be_define_const_map( static be_define_const_map(
be_class_bytes_map, be_class_bytes_map,
31 33
); );
BE_EXPORT_VARIABLE be_define_const_class( BE_EXPORT_VARIABLE be_define_const_class(

View File

@ -0,0 +1,23 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_zb_coord_ntv_map) {
{ be_const_key(iter, -1), be_const_func(zc_iter) },
{ be_const_key(zcl_frame, -1), be_const_class(be_class_zcl_frame) },
{ be_const_key(zb_device, 3), be_const_class(be_class_zb_device) },
{ be_const_key(info, -1), be_const_func(zc_info) },
{ be_const_key(size, 1), be_const_ctype_func(zc_size) },
{ be_const_key(item, -1), be_const_func(zc_item) },
{ be_const_key(abort, 4), be_const_ctype_func(zc_abort) },
};
static be_define_const_map(
be_class_zb_coord_ntv_map,
7
);
BE_EXPORT_VARIABLE be_define_const_class(
be_class_zb_coord_ntv,
0,
NULL,
zb_coord_ntv
);

View File

@ -0,0 +1,20 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_zb_device_map) {
{ be_const_key(init, -1), be_const_ctype_func(zd_init) },
{ be_const_key(tostring, -1), be_const_closure(zb_device_tostring_closure) },
{ be_const_key(_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(zd_member) },
};
static be_define_const_map(
be_class_zb_device_map,
4
);
BE_EXPORT_VARIABLE be_define_const_class(
be_class_zb_device,
1,
NULL,
zb_device
);

View File

@ -0,0 +1,19 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_zcl_frame_ntv_map) {
{ be_const_key(_set_bytes, -1), be_const_ctype_func(zfn_set_bytes) },
{ be_const_key(_def, 2), be_const_comptr(&be_zigbee_zcl_frame_struct) },
{ be_const_key(_get_bytes, -1), be_const_ctype_func(zfn_get_bytes) },
};
static be_define_const_map(
be_class_zcl_frame_ntv_map,
3
);
BE_EXPORT_VARIABLE be_define_const_class(
be_class_zcl_frame_ntv,
0,
(bclass *)&be_class_ctypes_bytes,
zcl_frame_ntv
);

View File

@ -2,13 +2,14 @@
static be_define_const_map_slots(m_libcrc_map) { static be_define_const_map_slots(m_libcrc_map) {
{ be_const_key(crc32, 1), be_const_ctype_func(c_crc32) }, { be_const_key(crc32, 1), be_const_ctype_func(c_crc32) },
{ be_const_key(crc8, 2), be_const_ctype_func(c_crc8) }, { be_const_key(sum, -1), be_const_ctype_func(c_sum) },
{ be_const_key(crc16, -1), be_const_ctype_func(c_crc16) }, { be_const_key(crc16, -1), be_const_ctype_func(c_crc16) },
{ be_const_key(crc8, -1), be_const_ctype_func(c_crc8) },
}; };
static be_define_const_map( static be_define_const_map(
m_libcrc_map, m_libcrc_map,
3 4
); );
static be_define_const_module( static be_define_const_module(

View File

@ -0,0 +1,17 @@
#include "be_constobj.h"
static be_define_const_map_slots(m_libzigbee_map) {
{ be_const_key(init, -1), be_const_func(zigbee_init) },
};
static be_define_const_map(
m_libzigbee_map,
1
);
static be_define_const_module(
m_libzigbee,
"zigbee"
);
BE_EXPORT_VARIABLE be_define_const_native_module(zigbee);

View File

@ -715,6 +715,24 @@ static int m_tostring(bvm *vm)
be_return(vm); be_return(vm);
} }
static int m_tohex(bvm *vm)
{
buf_impl attr = m_read_attributes(vm, 1);
if (attr.bufptr) { /* pointer looks valid */
int32_t len = attr.len;
size_t hex_len = len * 2 + 1;
char * hex_out = be_pushbuffer(vm, hex_len);
size_t l = tohex(hex_out, hex_len, attr.bufptr, len);
be_pushnstring(vm, hex_out, l); /* make escape string from buffer */
be_remove(vm, -2); /* remove buffer */
} else { /* pointer is null, don't try to dereference it as it would crash */
be_pushstring(vm, "");
}
be_return(vm);
}
/* /*
* Copy the buffer into a string without any changes * Copy the buffer into a string without any changes
*/ */
@ -1184,6 +1202,45 @@ static int m_fromb64(bvm *vm)
be_return_nil(vm); be_return_nil(vm);
} }
/*
* Converts hex to bytes()
*
* `bytes().fromhexx() -> bytes()`
*/
static int m_fromhex(bvm *vm)
{
int argc = be_top(vm);
if (argc >= 2 && be_isstring(vm, 2)) {
int32_t from = 0; // skip x chars
if (argc >= 3 && be_isint(vm, 3)) {
from = be_toint(vm, 3);
}
const char *s = be_tostring(vm, 2);
size_t s_len = strlen(s);
if (from < 0) { from = 0; }
if (from > s_len) { from = s_len; }
int32_t bin_len = (s_len - from) / 2;
buf_impl attr = m_read_attributes(vm, 1);
check_ptr(vm, &attr);
if (attr.fixed && attr.len != bin_len) {
be_raise(vm, BYTES_RESIZE_ERROR, BYTES_RESIZE_MESSAGE);
}
bytes_resize(vm, &attr, bin_len); /* resize if needed */
if (bin_len > attr.size) { /* avoid overflow */
be_raise(vm, "memory_error", "cannot allocate buffer");
}
attr.len = 0;
buf_add_hex(&attr, s + from, s_len - from);
be_pop(vm, 1); /* remove arg to leave instance */
m_write_attributes(vm, 1, &attr); /* update instance */
be_pop(vm, be_top(vm) - 1); /* leave instance on stack */
be_return(vm);
}
be_raise(vm, "type_error", "operand must be a string");
be_return_nil(vm);
}
/* /*
* Advanced API * Advanced API
@ -1497,6 +1554,8 @@ void be_load_byteslib(bvm *vm)
{ "fromstring", m_fromstring }, { "fromstring", m_fromstring },
{ "tob64", m_tob64 }, { "tob64", m_tob64 },
{ "fromb64", m_fromb64 }, { "fromb64", m_fromb64 },
{ "fromhex", m_fromhex },
{ "tohex", m_tohex },
{ "add", m_add }, { "add", m_add },
{ "get", m_getu }, { "get", m_getu },
{ "geti", m_geti }, { "geti", m_geti },
@ -1538,6 +1597,8 @@ class be_class_bytes (scope: global, name: bytes) {
fromstring, func(m_fromstring) fromstring, func(m_fromstring)
tob64, func(m_tob64) tob64, func(m_tob64)
fromb64, func(m_fromb64) fromb64, func(m_fromb64)
fromhex, func(m_fromhex)
tohex, func(m_tohex)
add, func(m_add) add, func(m_add)
get, func(m_getu) get, func(m_getu)
geti, func(m_geti) geti, func(m_geti)

View File

@ -168,21 +168,9 @@ static int check_next(blexer *lexer, int c)
return 0; return 0;
} }
static int char2hex(int c)
{
if (c >= '0' && c <= '9') {
return c - '0';
} else if (c >= 'a' && c <= 'f') {
return c - 'a' + 0x0A;
} else if (c >= 'A' && c <= 'F') {
return c - 'A' + 0x0A;
}
return -1;
}
static int check2hex(blexer *lexer, int c) static int check2hex(blexer *lexer, int c)
{ {
c = char2hex(c); c = be_char2hex(c);
if (c < 0) { if (c < 0) {
be_lexerror(lexer, "invalid hexadecimal number"); be_lexerror(lexer, "invalid hexadecimal number");
} }
@ -333,7 +321,7 @@ static bint scan_hexadecimal(blexer *lexer)
{ {
bint res = 0; bint res = 0;
int dig, num = 0; int dig, num = 0;
while ((dig = char2hex(lgetc(lexer))) >= 0) { while ((dig = be_char2hex(lgetc(lexer))) >= 0) {
res = ((bint)res << 4) + dig; res = ((bint)res << 4) + dig;
next(lexer); next(lexer);
++num; ++num;

View File

@ -231,17 +231,41 @@ const char* be_pushvfstr(bvm *vm, const char *format, va_list arg)
return concat2(vm); return concat2(vm);
} }
int be_char2hex(int c)
{
if (c >= '0' && c <= '9') {
return c - '0';
} else if (c >= 'a' && c <= 'f') {
return c - 'a' + 0x0A;
} else if (c >= 'A' && c <= 'F') {
return c - 'A' + 0x0A;
}
return -1;
}
/******************************************************************* /*******************************************************************
* the function be_str2int(): * the function be_str2int():
* >>-+------------+--+-----+----digits---->< * >>-+------------+--+--+-----+----digits-------+----------------><
* '-whitespace-' +- + -+ * '-whitespace-' | +- + -+ |
* '- - -' * | '- - -' |
* | |
* +- 0x or 0X ---hex_digits--+
*
*******************************************************************/ *******************************************************************/
BERRY_API bint be_str2int(const char *str, const char **endstr) BERRY_API bint be_str2int(const char *str, const char **endstr)
{ {
int c, sign; int c, sign;
bint sum = 0; bint sum = 0;
skip_space(str); skip_space(str);
if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) {
/* hex literal */
str += 2; /* skip 0x or 0X */
while ((c = be_char2hex(*str++)) >= 0) {
sum = sum * 16 + c;
}
return sum;
} else {
/* decimal literal */
sign = c = *str++; sign = c = *str++;
if (c == '+' || c == '-') { if (c == '+' || c == '-') {
c = *str++; c = *str++;
@ -254,6 +278,7 @@ BERRY_API bint be_str2int(const char *str, const char **endstr)
*endstr = str - 1; *endstr = str - 1;
} }
return sign == '-' ? -sum : sum; return sign == '-' ? -sum : sum;
}
} }
/******************************************************************* /*******************************************************************

View File

@ -19,6 +19,7 @@ bstring* be_strcat(bvm *vm, bstring *s1, bstring *s2);
int be_strcmp(bstring *s1, bstring *s2); int be_strcmp(bstring *s1, bstring *s2);
bstring* be_num2str(bvm *vm, bvalue *v); bstring* be_num2str(bvm *vm, bvalue *v);
void be_val2str(bvm *vm, int index); void be_val2str(bvm *vm, int index);
int be_char2hex(int c);
size_t be_strlcpy(char *dst, const char *src, size_t size); size_t be_strlcpy(char *dst, const char *src, size_t size);
const char* be_splitpath(const char *path); const char* be_splitpath(const char *path);
const char* be_splitname(const char *path); const char* be_splitname(const char *path);

View File

@ -6,3 +6,9 @@ class Test_int
end end
t=Test_int() t=Test_int()
assert(int(t) == 42) assert(int(t) == 42)
#- int can parse hex strings -#
assert(int("0x00") == 0)
assert(int("0X1") == 1)
assert(int("0x000000F") == 15)
assert(int("0x1000") == 0x1000)

View File

@ -3,7 +3,6 @@
"displayName": "Berry Script Language", "displayName": "Berry Script Language",
"description": "A small embedded script language.", "description": "A small embedded script language.",
"version": "0.1.0", "version": "0.1.0",
"icon": "berry-icon.png",
"publisher": "skiars", "publisher": "skiars",
"engines": { "engines": {
"vscode": "^1.15.1" "vscode": "^1.15.1"

View File

@ -153,7 +153,6 @@ static int32_t be_cb_make_cb(bvm *vm) {
int32_t argc = be_top(vm); int32_t argc = be_top(vm);
if (argc >= 1 && be_isfunction(vm, 1)) { if (argc >= 1 && be_isfunction(vm, 1)) {
bvalue *v = be_indexof(vm, 1);
for (be_callback_handler_list_t *elt = be_callback_handler_list_head; elt != NULL; elt = elt->next) { for (be_callback_handler_list_t *elt = be_callback_handler_list_head; elt != NULL; elt = elt->next) {
if (elt->vm == vm || elt->vm == NULL) { // if elt->vm is NULL then we accept any VM if (elt->vm == vm || elt->vm == NULL) { // if elt->vm is NULL then we accept any VM
// call the handler and check result // call the handler and check result
@ -215,7 +214,6 @@ static int32_t be_cb_gen_cb(bvm *vm) {
\*********************************************************************************************/ \*********************************************************************************************/
static int32_t be_cb_get_cb_list(bvm *vm) { static int32_t be_cb_get_cb_list(bvm *vm) {
be_newobject(vm, "list"); be_newobject(vm, "list");
int32_t i;
for (uint32_t i=0; i < BE_MAX_CB; i++) { for (uint32_t i=0; i < BE_MAX_CB; i++) {
if (be_cb_hooks[i].vm) { if (be_cb_hooks[i].vm) {
if (vm == be_cb_hooks[i].vm) { // make sure it corresponds to this vm if (vm == be_cb_hooks[i].vm) { // make sure it corresponds to this vm

View File

@ -76,6 +76,7 @@ static bbool be_const_member_dual(bvm *vm, const be_const_member_t * definitions
case '>': // call to a ctype function case '>': // call to a ctype function
{ {
be_ctype_var_args_t* args = (be_ctype_var_args_t*) definitions[idx].value; be_ctype_var_args_t* args = (be_ctype_var_args_t*) definitions[idx].value;
be_pop(vm, be_top(vm) - 1); // make sure we have only the instance left on the stack
int ret = be_call_c_func(vm, args->func, args->return_type, NULL); int ret = be_call_c_func(vm, args->func, args->return_type, NULL);
if ((ret == BE_OK) && !be_isnil(vm, -1)) { if ((ret == BE_OK) && !be_isnil(vm, -1)) {
return btrue; return btrue;

View File

@ -10,21 +10,30 @@
#include "rom/crc.h" #include "rom/crc.h"
uint32_t c_crc32(uint32_t crc, const uint8_t* buf, size_t size) { static uint32_t c_crc32(uint32_t crc, const uint8_t* buf, size_t size) {
return crc32_le(crc, buf, size); return crc32_le(crc, buf, size);
} }
BE_FUNC_CTYPE_DECLARE(c_crc32, "i", "i(bytes)~") BE_FUNC_CTYPE_DECLARE(c_crc32, "i", "i(bytes)~")
uint32_t c_crc16(uint32_t crc, const uint8_t* buf, size_t size) { static uint32_t c_crc16(uint32_t crc, const uint8_t* buf, size_t size) {
return crc16_le(crc, buf, size); return crc16_le(crc, buf, size);
} }
BE_FUNC_CTYPE_DECLARE(c_crc16, "i", "i(bytes)~") BE_FUNC_CTYPE_DECLARE(c_crc16, "i", "i(bytes)~")
uint32_t c_crc8(uint32_t crc, const uint8_t* buf, size_t size) { static uint32_t c_crc8(uint32_t crc, const uint8_t* buf, size_t size) {
return crc8_le(crc, buf, size); return crc8_le(crc, buf, size);
} }
BE_FUNC_CTYPE_DECLARE(c_crc8, "i", "i(bytes)~") BE_FUNC_CTYPE_DECLARE(c_crc8, "i", "i(bytes)~")
static uint32_t c_sum(const uint8_t* buf, size_t size) {
uint32_t sum = 0;
for (uint32_t i = 0; i < size; i++) {
sum = (sum + buf[i]) & 0xFF;
}
return sum;
}
BE_FUNC_CTYPE_DECLARE(c_sum, "i", "(bytes)~")
// const uint32_t crc32_tab[] = { // const uint32_t crc32_tab[] = {
// 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, // 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
// 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, // 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
@ -83,6 +92,7 @@ module crc (scope: global) {
crc32, ctype_func(c_crc32) crc32, ctype_func(c_crc32)
crc16, ctype_func(c_crc16) crc16, ctype_func(c_crc16)
crc8, ctype_func(c_crc8) crc8, ctype_func(c_crc8)
sum, ctype_func(c_sum)
} }
@const_object_info_end */ @const_object_info_end */
#include "be_fixed_crc.h" #include "be_fixed_crc.h"

View File

@ -144,8 +144,6 @@ int be_ctypes_init(bvm *vm) {
// copy ctypes_bytes, with same class and same content // copy ctypes_bytes, with same class and same content
// //
int be_ctypes_copy(bvm *vm) { int be_ctypes_copy(bvm *vm) {
size_t len;
const void * src = be_tobytes(vm, 1, &len);
be_classof(vm, 1); be_classof(vm, 1);
// stack: 1/self + class_object // stack: 1/self + class_object
be_call(vm, 0); // call empty constructor to build empty resizable copy be_call(vm, 0); // call empty constructor to build empty resizable copy
@ -184,7 +182,6 @@ int be_ctypes_copy(bvm *vm) {
// arg2: name of the argument // arg2: name of the argument
// The class has a `_def` static class attribute with the C low-level mapping definition // The class has a `_def` static class attribute with the C low-level mapping definition
int be_ctypes_member(bvm *vm) { int be_ctypes_member(bvm *vm) {
int argc = be_top(vm);
be_getmember(vm, 1, "_def"); be_getmember(vm, 1, "_def");
const be_ctypes_structure_t *definitions; const be_ctypes_structure_t *definitions;
definitions = (const be_ctypes_structure_t *) be_tocomptr(vm, -1); definitions = (const be_ctypes_structure_t *) be_tocomptr(vm, -1);
@ -276,8 +273,6 @@ int be_ctypes_member(bvm *vm) {
// 2: name of member // 2: name of member
// 3: value // 3: value
int be_ctypes_setmember(bvm *vm) { int be_ctypes_setmember(bvm *vm) {
int argc = be_top(vm);
// If the value is an instance, we call 'toint()' and replace the value // If the value is an instance, we call 'toint()' and replace the value
if (be_isinstance(vm, 3)) { if (be_isinstance(vm, 3)) {

View File

@ -1,10 +1,10 @@
/******************************************************************** /********************************************************************
* Tasmota OpenHASP solidified * Tasmota HASPmota solidified
*******************************************************************/ *******************************************************************/
#include "be_constobj.h" #include "be_constobj.h"
#ifdef USE_LVGL #ifdef USE_LVGL
#ifdef USE_LVGL_OPENHASP #ifdef USE_LVGL_HASPMOTA
extern const bclass be_class_lv_anim; extern const bclass be_class_lv_anim;
extern const bclass be_class_lv_arc; extern const bclass be_class_lv_arc;
@ -5847,39 +5847,10 @@ void be_load_lvh_qrcode_class(bvm *vm) {
be_pop(vm, 1); be_pop(vm, 1);
} }
/********************************************************************
** Solidified function: _anonymous_
********************************************************************/
be_local_closure(openhasp__anonymous_, /* name */
be_nested_proto(
3, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str_literal("OpenHASP"),
}),
be_str_literal("_anonymous_"),
&be_const_str_solidified,
( &(const binstruction[ 4]) { /* code */
0x88040100, // 0000 GETMBR R1 R0 K0
0x5C080200, // 0001 MOVE R2 R1
0x7C080000, // 0002 CALL R2 0
0x80040400, // 0003 RET 1 R2
})
)
);
/*******************************************************************/
/******************************************************************** /********************************************************************
** Solidified function: do_action ** Solidified function: do_action
********************************************************************/ ********************************************************************/
be_local_closure(OpenHASP_do_action, /* name */ be_local_closure(HASPmota_do_action, /* name */
be_nested_proto( be_nested_proto(
10, /* nstack */ 10, /* nstack */
3, /* argc */ 3, /* argc */
@ -5991,7 +5962,7 @@ be_local_closure(OpenHASP_do_action, /* name */
/******************************************************************** /********************************************************************
** Solidified function: pages_list_sorted ** Solidified function: pages_list_sorted
********************************************************************/ ********************************************************************/
be_local_closure(OpenHASP_pages_list_sorted, /* name */ be_local_closure(HASPmota_pages_list_sorted, /* name */
be_nested_proto( be_nested_proto(
8, /* nstack */ 8, /* nstack */
2, /* argc */ 2, /* argc */
@ -6071,7 +6042,7 @@ be_local_closure(OpenHASP_pages_list_sorted, /* name */
/******************************************************************** /********************************************************************
** Solidified function: get_page_cur ** Solidified function: get_page_cur
********************************************************************/ ********************************************************************/
be_local_closure(OpenHASP_get_page_cur, /* name */ be_local_closure(HASPmota_get_page_cur, /* name */
be_nested_proto( be_nested_proto(
3, /* nstack */ 3, /* nstack */
1, /* argc */ 1, /* argc */
@ -6101,7 +6072,7 @@ be_local_closure(OpenHASP_get_page_cur, /* name */
/******************************************************************** /********************************************************************
** Solidified function: start ** Solidified function: start
********************************************************************/ ********************************************************************/
be_local_closure(OpenHASP_start, /* name */ be_local_closure(HASPmota_start, /* name */
be_nested_proto( be_nested_proto(
11, /* nstack */ 11, /* nstack */
3, /* argc */ 3, /* argc */
@ -6131,7 +6102,7 @@ be_local_closure(OpenHASP_start, /* name */
/* K16 */ be_nested_str_literal("font_embedded"), /* K16 */ be_nested_str_literal("font_embedded"),
/* K17 */ be_nested_str_literal("robotocondensed"), /* K17 */ be_nested_str_literal("robotocondensed"),
/* K18 */ be_nested_str_literal("montserrat"), /* K18 */ be_nested_str_literal("montserrat"),
/* K19 */ be_nested_str_literal("theme_openhasp_init"), /* K19 */ be_nested_str_literal("theme_haspmota_init"),
/* K20 */ be_const_int(0), /* K20 */ be_const_int(0),
/* K21 */ be_nested_str_literal("color"), /* K21 */ be_nested_str_literal("color"),
/* K22 */ be_const_int(16711935), /* K22 */ be_const_int(16711935),
@ -6263,7 +6234,7 @@ be_local_closure(OpenHASP_start, /* name */
/******************************************************************** /********************************************************************
** Solidified function: init ** Solidified function: init
********************************************************************/ ********************************************************************/
be_local_closure(OpenHASP_init, /* name */ be_local_closure(HASPmota_init, /* name */
be_nested_proto( be_nested_proto(
5, /* nstack */ 5, /* nstack */
1, /* argc */ 1, /* argc */
@ -6297,7 +6268,7 @@ be_local_closure(OpenHASP_init, /* name */
/******************************************************************** /********************************************************************
** Solidified function: register_event ** Solidified function: register_event
********************************************************************/ ********************************************************************/
be_local_closure(OpenHASP_register_event, /* name */ be_local_closure(HASPmota_register_event, /* name */
be_nested_proto( be_nested_proto(
13, /* nstack */ 13, /* nstack */
3, /* argc */ 3, /* argc */
@ -6373,7 +6344,7 @@ be_local_closure(OpenHASP_register_event, /* name */
/******************************************************************** /********************************************************************
** Solidified function: parse_page ** Solidified function: parse_page
********************************************************************/ ********************************************************************/
be_local_closure(OpenHASP_parse_page, /* name */ be_local_closure(HASPmota_parse_page, /* name */
be_nested_proto( be_nested_proto(
9, /* nstack */ 9, /* nstack */
2, /* argc */ 2, /* argc */
@ -6465,7 +6436,7 @@ be_local_closure(OpenHASP_parse_page, /* name */
/******************************************************************** /********************************************************************
** Solidified function: deinit ** Solidified function: deinit
********************************************************************/ ********************************************************************/
be_local_closure(OpenHASP_deinit, /* name */ be_local_closure(HASPmota_deinit, /* name */
be_nested_proto( be_nested_proto(
5, /* nstack */ 5, /* nstack */
1, /* argc */ 1, /* argc */
@ -6512,7 +6483,7 @@ be_local_closure(OpenHASP_deinit, /* name */
/******************************************************************** /********************************************************************
** Solidified function: page_dir_to ** Solidified function: page_dir_to
********************************************************************/ ********************************************************************/
be_local_closure(OpenHASP_page_dir_to, /* name */ be_local_closure(HASPmota_page_dir_to, /* name */
be_nested_proto( be_nested_proto(
7, /* nstack */ 7, /* nstack */
2, /* argc */ 2, /* argc */
@ -6573,7 +6544,7 @@ be_local_closure(OpenHASP_page_dir_to, /* name */
/******************************************************************** /********************************************************************
** Solidified function: _load ** Solidified function: _load
********************************************************************/ ********************************************************************/
be_local_closure(OpenHASP__load, /* name */ be_local_closure(HASPmota__load, /* name */
be_nested_proto( be_nested_proto(
14, /* nstack */ 14, /* nstack */
2, /* argc */ 2, /* argc */
@ -6668,7 +6639,7 @@ be_local_closure(OpenHASP__load, /* name */
/******************************************************************** /********************************************************************
** Solidified function: parse ** Solidified function: parse
********************************************************************/ ********************************************************************/
be_local_closure(OpenHASP_parse, /* name */ be_local_closure(HASPmota_parse, /* name */
be_nested_proto( be_nested_proto(
9, /* nstack */ 9, /* nstack */
2, /* argc */ 2, /* argc */
@ -6722,7 +6693,7 @@ be_local_closure(OpenHASP_parse, /* name */
/******************************************************************** /********************************************************************
** Solidified function: sort ** Solidified function: sort
********************************************************************/ ********************************************************************/
be_local_closure(OpenHASP_sort, /* name */ be_local_closure(HASPmota_sort, /* name */
be_nested_proto( be_nested_proto(
6, /* nstack */ 6, /* nstack */
1, /* argc */ 1, /* argc */
@ -6778,7 +6749,7 @@ be_local_closure(OpenHASP_sort, /* name */
/******************************************************************** /********************************************************************
** Solidified function: parse_obj ** Solidified function: parse_obj
********************************************************************/ ********************************************************************/
be_local_closure(OpenHASP_parse_obj, /* name */ be_local_closure(HASPmota_parse_obj, /* name */
be_nested_proto( be_nested_proto(
20, /* nstack */ 20, /* nstack */
3, /* argc */ 3, /* argc */
@ -7022,7 +6993,7 @@ be_local_closure(OpenHASP_parse_obj, /* name */
/******************************************************************** /********************************************************************
** Solidified function: event_dispatch ** Solidified function: event_dispatch
********************************************************************/ ********************************************************************/
be_local_closure(OpenHASP_event_dispatch, /* name */ be_local_closure(HASPmota_event_dispatch, /* name */
be_nested_proto( be_nested_proto(
9, /* nstack */ 9, /* nstack */
2, /* argc */ 2, /* argc */
@ -7090,27 +7061,27 @@ be_local_closure(OpenHASP_event_dispatch, /* name */
/******************************************************************** /********************************************************************
** Solidified class: OpenHASP ** Solidified class: HASPmota
********************************************************************/ ********************************************************************/
be_local_class(OpenHASP, be_local_class(HASPmota,
10, 10,
NULL, NULL,
be_nested_map(43, be_nested_map(43,
( (struct bmapnode*) &(const bmapnode[]) { ( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_literal("lvh_textarea", 41), be_const_class(be_class_lvh_textarea) }, { be_const_key_literal("lvh_textarea", 41), be_const_class(be_class_lvh_textarea) },
{ be_const_key_literal("scr", -1), be_const_var(3) }, { be_const_key_literal("scr", -1), be_const_var(3) },
{ be_const_key_literal("event_dispatch", 16), be_const_closure(OpenHASP_event_dispatch_closure) }, { be_const_key_literal("event_dispatch", 16), be_const_closure(HASPmota_event_dispatch_closure) },
{ be_const_key_literal("lvh_bar", -1), be_const_class(be_class_lvh_bar) }, { be_const_key_literal("lvh_bar", -1), be_const_class(be_class_lvh_bar) },
{ be_const_key_literal("lvh_img", -1), be_const_class(be_class_lvh_img) }, { be_const_key_literal("lvh_img", -1), be_const_class(be_class_lvh_img) },
{ be_const_key_literal("event", -1), be_const_var(8) }, { be_const_key_literal("event", -1), be_const_var(8) },
{ be_const_key_literal("do_action", 33), be_const_closure(OpenHASP_do_action_closure) }, { be_const_key_literal("do_action", 33), be_const_closure(HASPmota_do_action_closure) },
{ be_const_key_literal("pages_list_sorted", -1), be_const_closure(OpenHASP_pages_list_sorted_closure) }, { be_const_key_literal("pages_list_sorted", -1), be_const_closure(HASPmota_pages_list_sorted_closure) },
{ be_const_key_literal("lvh_btnmatrix", 42), be_const_class(be_class_lvh_btnmatrix) }, { be_const_key_literal("lvh_btnmatrix", 42), be_const_class(be_class_lvh_btnmatrix) },
{ be_const_key_literal("start", -1), be_const_closure(OpenHASP_start_closure) }, { be_const_key_literal("start", -1), be_const_closure(HASPmota_start_closure) },
{ be_const_key_literal("init", 5), be_const_closure(OpenHASP_init_closure) }, { be_const_key_literal("init", 5), be_const_closure(HASPmota_init_closure) },
{ be_const_key_literal("lvh_scr", -1), be_const_class(be_class_lvh_scr) }, { be_const_key_literal("lvh_scr", -1), be_const_class(be_class_lvh_scr) },
{ be_const_key_literal("parse_page", -1), be_const_closure(OpenHASP_parse_page_closure) }, { be_const_key_literal("parse_page", -1), be_const_closure(HASPmota_parse_page_closure) },
{ be_const_key_literal("register_event", 24), be_const_closure(OpenHASP_register_event_closure) }, { be_const_key_literal("register_event", 24), be_const_closure(HASPmota_register_event_closure) },
{ be_const_key_literal("lvh_roller", 34), be_const_class(be_class_lvh_roller) }, { be_const_key_literal("lvh_roller", 34), be_const_class(be_class_lvh_roller) },
{ be_const_key_literal("lvh_page", 11), be_const_class(be_class_lvh_page) }, { be_const_key_literal("lvh_page", 11), be_const_class(be_class_lvh_page) },
{ be_const_key_literal("lvh_page_cur_idx", -1), be_const_var(6) }, { be_const_key_literal("lvh_page_cur_idx", -1), be_const_var(6) },
@ -7118,13 +7089,13 @@ be_local_class(OpenHASP,
{ be_const_key_literal("hres", 38), be_const_var(1) }, { be_const_key_literal("hres", 38), be_const_var(1) },
{ be_const_key_literal("dark", -1), be_const_var(0) }, { be_const_key_literal("dark", -1), be_const_var(0) },
{ be_const_key_literal("lvh_label", 37), be_const_class(be_class_lvh_label) }, { be_const_key_literal("lvh_label", 37), be_const_class(be_class_lvh_label) },
{ be_const_key_literal("deinit", 14), be_const_closure(OpenHASP_deinit_closure) }, { be_const_key_literal("deinit", 14), be_const_closure(HASPmota_deinit_closure) },
{ be_const_key_literal("page_dir_to", -1), be_const_closure(OpenHASP_page_dir_to_closure) }, { be_const_key_literal("page_dir_to", -1), be_const_closure(HASPmota_page_dir_to_closure) },
{ be_const_key_literal("parse_obj", -1), be_const_closure(OpenHASP_parse_obj_closure) }, { be_const_key_literal("parse_obj", -1), be_const_closure(HASPmota_parse_obj_closure) },
{ be_const_key_literal("lvh_spinner", -1), be_const_class(be_class_lvh_spinner) }, { be_const_key_literal("lvh_spinner", -1), be_const_class(be_class_lvh_spinner) },
{ be_const_key_literal("_load", -1), be_const_closure(OpenHASP__load_closure) }, { be_const_key_literal("_load", -1), be_const_closure(HASPmota__load_closure) },
{ be_const_key_literal("lvh_qrcode", -1), be_const_class(be_class_lvh_qrcode) }, { be_const_key_literal("lvh_qrcode", -1), be_const_class(be_class_lvh_qrcode) },
{ be_const_key_literal("parse", -1), be_const_closure(OpenHASP_parse_closure) }, { be_const_key_literal("parse", -1), be_const_closure(HASPmota_parse_closure) },
{ be_const_key_literal("lvh_pages", 2), be_const_var(5) }, { be_const_key_literal("lvh_pages", 2), be_const_var(5) },
{ be_const_key_literal("lvh_line", -1), be_const_class(be_class_lvh_line) }, { be_const_key_literal("lvh_line", -1), be_const_class(be_class_lvh_line) },
{ be_const_key_literal("lvh_switch", -1), be_const_class(be_class_lvh_switch) }, { be_const_key_literal("lvh_switch", -1), be_const_class(be_class_lvh_switch) },
@ -7132,32 +7103,61 @@ be_local_class(OpenHASP,
{ be_const_key_literal("r16", -1), be_const_var(4) }, { be_const_key_literal("r16", -1), be_const_var(4) },
{ be_const_key_literal("def_templ_name", -1), be_nested_str_literal("pages.jsonl") }, { be_const_key_literal("def_templ_name", -1), be_nested_str_literal("pages.jsonl") },
{ be_const_key_literal("lvh_obj", 19), be_const_class(be_class_lvh_obj) }, { be_const_key_literal("lvh_obj", 19), be_const_class(be_class_lvh_obj) },
{ be_const_key_literal("sort", 23), be_const_static_closure(OpenHASP_sort_closure) }, { be_const_key_literal("sort", 23), be_const_static_closure(HASPmota_sort_closure) },
{ be_const_key_literal("lvh_dropdown", -1), be_const_class(be_class_lvh_dropdown) }, { be_const_key_literal("lvh_dropdown", -1), be_const_class(be_class_lvh_dropdown) },
{ be_const_key_literal("lvh_checkbox", -1), be_const_class(be_class_lvh_checkbox) }, { be_const_key_literal("lvh_checkbox", -1), be_const_class(be_class_lvh_checkbox) },
{ be_const_key_literal("lvh_slider", -1), be_const_class(be_class_lvh_slider) }, { be_const_key_literal("lvh_slider", -1), be_const_class(be_class_lvh_slider) },
{ be_const_key_literal("vres", -1), be_const_var(2) }, { be_const_key_literal("vres", -1), be_const_var(2) },
{ be_const_key_literal("lvh_btn", -1), be_const_class(be_class_lvh_btn) }, { be_const_key_literal("lvh_btn", -1), be_const_class(be_class_lvh_btn) },
{ be_const_key_literal("event_cb", -1), be_const_var(9) }, { be_const_key_literal("event_cb", -1), be_const_var(9) },
{ be_const_key_literal("get_page_cur", -1), be_const_closure(OpenHASP_get_page_cur_closure) }, { be_const_key_literal("get_page_cur", -1), be_const_closure(HASPmota_get_page_cur_closure) },
})), })),
be_str_literal("OpenHASP") be_str_literal("HASPmota")
); );
/******************************************************************** /********************************************************************
** Solidified module: openhasp ** Solidified function: _anonymous_
********************************************************************/ ********************************************************************/
be_local_module(openhasp, be_local_closure(haspmota__anonymous_, /* name */
"openhasp", be_nested_proto(
3, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str_literal("HASPmota"),
}),
be_str_literal("_anonymous_"),
&be_const_str_solidified,
( &(const binstruction[ 4]) { /* code */
0x88040100, // 0000 GETMBR R1 R0 K0
0x5C080200, // 0001 MOVE R2 R1
0x7C080000, // 0002 CALL R2 0
0x80040400, // 0003 RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified module: haspmota
********************************************************************/
be_local_module(haspmota,
"haspmota",
be_nested_map(2, be_nested_map(2,
( (struct bmapnode*) &(const bmapnode[]) { ( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_literal("OpenHASP", -1), be_const_class(be_class_OpenHASP) }, { be_const_key_literal("HASPmota", -1), be_const_class(be_class_HASPmota) },
{ be_const_key_literal("init", 0), be_const_closure(openhasp__anonymous__closure) }, { be_const_key_literal("init", -1), be_const_closure(haspmota__anonymous__closure) },
})) }))
); );
BE_EXPORT_VARIABLE be_define_const_native_module(openhasp); BE_EXPORT_VARIABLE be_define_const_native_module(haspmota);
/********************************************************************/ /********************************************************************/
#endif // USE_LVGL_OPENHASP #endif // USE_LVGL_HASPMOTA
#endif // USE_LVGL #endif // USE_LVGL

View File

@ -1311,7 +1311,7 @@ be_local_closure(Partition_info_is_factory, /* name */
********************************************************************/ ********************************************************************/
be_local_closure(Partition_info_type_to_string, /* name */ be_local_closure(Partition_info_type_to_string, /* name */
be_nested_proto( be_nested_proto(
2, /* nstack */ 6, /* nstack */
1, /* argc */ 1, /* argc */
2, /* varg */ 2, /* varg */
0, /* has upvals */ 0, /* has upvals */
@ -1319,16 +1319,19 @@ be_local_closure(Partition_info_type_to_string, /* name */
0, /* has sup protos */ 0, /* has sup protos */
NULL, /* no sub protos */ NULL, /* no sub protos */
1, /* has constants */ 1, /* has constants */
( &(const bvalue[ 5]) { /* constants */ ( &(const bvalue[ 8]) { /* constants */
/* K0 */ be_nested_str(type), /* K0 */ be_nested_str(type),
/* K1 */ be_const_int(0), /* K1 */ be_const_int(0),
/* K2 */ be_nested_str(app), /* K2 */ be_nested_str(app),
/* K3 */ be_const_int(1), /* K3 */ be_const_int(1),
/* K4 */ be_nested_str(data), /* K4 */ be_nested_str(data),
/* K5 */ be_nested_str(string),
/* K6 */ be_nested_str(format),
/* K7 */ be_nested_str(0x_X2502X),
}), }),
&be_const_str_type_to_string, &be_const_str_type_to_string,
&be_const_str_solidified, &be_const_str_solidified,
( &(const binstruction[10]) { /* code */ ( &(const binstruction[15]) { /* code */
0x88040100, // 0000 GETMBR R1 R0 K0 0x88040100, // 0000 GETMBR R1 R0 K0
0x1C040301, // 0001 EQ R1 R1 K1 0x1C040301, // 0001 EQ R1 R1 K1
0x78060001, // 0002 JMPF R1 #0005 0x78060001, // 0002 JMPF R1 #0005
@ -1338,7 +1341,12 @@ be_local_closure(Partition_info_type_to_string, /* name */
0x1C040303, // 0006 EQ R1 R1 K3 0x1C040303, // 0006 EQ R1 R1 K3
0x78060000, // 0007 JMPF R1 #0009 0x78060000, // 0007 JMPF R1 #0009
0x80060800, // 0008 RET 1 K4 0x80060800, // 0008 RET 1 K4
0x80000000, // 0009 RET 0 0xA4060A00, // 0009 IMPORT R1 K5
0x8C080306, // 000A GETMET R2 R1 K6
0x58100007, // 000B LDCONST R4 K7
0x88140100, // 000C GETMBR R5 R0 K0
0x7C080600, // 000D CALL R2 3
0x80040400, // 000E RET 1 R2
}) })
) )
); );
@ -1453,7 +1461,7 @@ be_local_closure(Partition_info_init, /* name */
********************************************************************/ ********************************************************************/
be_local_closure(Partition_info_subtype_to_string, /* name */ be_local_closure(Partition_info_subtype_to_string, /* name */
be_nested_proto( be_nested_proto(
4, /* nstack */ 6, /* nstack */
1, /* argc */ 1, /* argc */
2, /* varg */ 2, /* varg */
0, /* has upvals */ 0, /* has upvals */
@ -1461,7 +1469,7 @@ be_local_closure(Partition_info_subtype_to_string, /* name */
0, /* has sup protos */ 0, /* has sup protos */
NULL, /* no sub protos */ NULL, /* no sub protos */
1, /* has constants */ 1, /* has constants */
( &(const bvalue[18]) { /* constants */ ( &(const bvalue[21]) { /* constants */
/* K0 */ be_nested_str(type), /* K0 */ be_nested_str(type),
/* K1 */ be_const_int(0), /* K1 */ be_const_int(0),
/* K2 */ be_nested_str(subtype), /* K2 */ be_nested_str(subtype),
@ -1480,10 +1488,13 @@ be_local_closure(Partition_info_subtype_to_string, /* name */
/* K15 */ be_nested_str(esphttpd), /* K15 */ be_nested_str(esphttpd),
/* K16 */ be_nested_str(fat), /* K16 */ be_nested_str(fat),
/* K17 */ be_nested_str(spiffs), /* K17 */ be_nested_str(spiffs),
/* K18 */ be_nested_str(string),
/* K19 */ be_nested_str(format),
/* K20 */ be_nested_str(0x_X2502X),
}), }),
&be_const_str_subtype_to_string, &be_const_str_subtype_to_string,
&be_const_str_solidified, &be_const_str_solidified,
( &(const binstruction[83]) { /* code */ ( &(const binstruction[88]) { /* code */
0x88040100, // 0000 GETMBR R1 R0 K0 0x88040100, // 0000 GETMBR R1 R0 K0
0x1C040301, // 0001 EQ R1 R1 K1 0x1C040301, // 0001 EQ R1 R1 K1
0x7806001A, // 0002 JMPF R1 #001E 0x7806001A, // 0002 JMPF R1 #001E
@ -1566,7 +1577,12 @@ be_local_closure(Partition_info_subtype_to_string, /* name */
0x1C040202, // 004F EQ R1 R1 R2 0x1C040202, // 004F EQ R1 R1 R2
0x78060000, // 0050 JMPF R1 #0052 0x78060000, // 0050 JMPF R1 #0052
0x80062200, // 0051 RET 1 K17 0x80062200, // 0051 RET 1 K17
0x80000000, // 0052 RET 0 0xA4062400, // 0052 IMPORT R1 K18
0x8C080313, // 0053 GETMET R2 R1 K19
0x58100014, // 0054 LDCONST R4 K20
0x88140102, // 0055 GETMBR R5 R0 K2
0x7C080600, // 0056 CALL R2 3
0x80040400, // 0057 RET 1 R2
}) })
) )
); );

View File

@ -62,7 +62,6 @@ static int m_path_remove(bvm *vm)
extern int be_format_fs(void); extern int be_format_fs(void);
static int m_path_format(bvm *vm) static int m_path_format(bvm *vm)
{ {
const char *path = NULL;
if (be_top(vm) >= 1 && be_isbool(vm, 1)) { if (be_top(vm) >= 1 && be_isbool(vm, 1)) {
if (be_tobool(vm, 1)) { if (be_tobool(vm, 1)) {
be_pushbool(vm, be_format_fs()); be_pushbool(vm, be_format_fs());

View File

@ -6,7 +6,7 @@
#include "be_mapping.h" #include "be_mapping.h"
extern uint32_t* tlr_init(void); BE_FUNC_CTYPE_DECLARE(tlr_init, "+_p", "") extern uint32_t* tlr_init(void); BE_FUNC_CTYPE_DECLARE(tlr_init, "+_p", "")
extern char* tlr_get_log(uint32_t* idx, int32_t log_level); BE_FUNC_CTYPE_DECLARE(tlr_get_log, "s", ".i") extern char* tlr_get_log(uint32_t* idx, int32_t log_level); BE_FUNC_CTYPE_DECLARE(tlr_get_log, "$", ".i")
#include "be_fixed_be_class_tasmota_log_reader.h" #include "be_fixed_be_class_tasmota_log_reader.h"

View File

@ -39,7 +39,7 @@ extern "C" {
// udp.begin(address:string, port:int) -> nil // udp.begin(address:string, port:int) -> nil
int32_t be_udp_begin_ntv(WiFiUDP *udp, const char *host, int32_t port) { int32_t be_udp_begin_ntv(WiFiUDP *udp, const char *host, int32_t port) {
IPAddress addr(INADDR_ANY); IPAddress addr((uint32_t)0);
// if no host or host is "" then we defult to INADDR_ANY (0.0.0.0) // if no host or host is "" then we defult to INADDR_ANY (0.0.0.0)
if(host && (*host != 0) && !WiFiGenericClass::hostByName(host, addr)){ if(host && (*host != 0) && !WiFiGenericClass::hostByName(host, addr)){
return 0; return 0;

View File

@ -0,0 +1,186 @@
/********************************************************************
* Zigbee
*
*******************************************************************/
#ifdef USE_ZIGBEE
#include "be_constobj.h"
#include "be_mapping.h"
#include "be_ctypes.h"
#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
extern const void * zd_init(void* d); BE_FUNC_CTYPE_DECLARE(zd_init, "+_p", "c")
extern int32_t zd_shortaddr(void* d); BE_VAR_CTYPE_DECLARE(zd_shortaddr, "i");
extern const void* zd_longaddr(void* d, size_t *size, void* p2); BE_VAR_CTYPE_DECLARE(zd_longaddr, "&");
extern const char* zd_manufacturer(void* d); BE_VAR_CTYPE_DECLARE(zd_manufacturer, "s");
extern const char* zd_model(void* d); BE_VAR_CTYPE_DECLARE(zd_model, "s");
extern const char* zd_name(void* d); BE_VAR_CTYPE_DECLARE(zd_name, "s");
extern bbool zd_router(void* d); BE_VAR_CTYPE_DECLARE(zd_router, "b");
extern bbool zd_hidden(void* d); BE_VAR_CTYPE_DECLARE(zd_hidden, "b");
extern bbool zd_reachable(void* d); BE_VAR_CTYPE_DECLARE(zd_reachable, "b");
extern int32_t zd_lastseen(void* d); BE_VAR_CTYPE_DECLARE(zd_lastseen, "i");
extern int32_t zd_lqi(void* d); BE_VAR_CTYPE_DECLARE(zd_lqi, "i");
extern int32_t zd_battery(void* d); BE_VAR_CTYPE_DECLARE(zd_battery, "i");
extern int32_t zd_battery_lastseen(void* d); BE_VAR_CTYPE_DECLARE(zd_battery_lastseen, "i");
// moved to constants array
// MUST BE STORED IN SORTED LIST
const be_const_member_t zd_members[] = {
{ ">battery", be_ctype(zd_battery) },
{ ">battery_lastseen", be_ctype(zd_battery_lastseen) },
{ ">hidden", be_ctype(zd_hidden) },
{ ">lastseen", be_ctype(zd_lastseen) },
{ ">longaddr", be_ctype(zd_longaddr) },
{ ">lqi", be_ctype(zd_lqi) },
{ ">manufacturer", be_ctype(zd_manufacturer) },
{ ">model", be_ctype(zd_model) },
{ ">name", be_ctype(zd_name) },
{ ">reachable", be_ctype(zd_reachable) },
{ ">router", be_ctype(zd_router) },
{ ">shortaddr", be_ctype(zd_shortaddr) },
};
static int zd_member(bvm *vm) {
if (be_const_class_member(vm, zd_members, ARRAY_SIZE(zd_members))) {
be_return(vm);
} else {
be_return_nil(vm);
}
}
extern int zc_info(struct bvm *vm);
extern int zc_item(struct bvm *vm);
extern int32_t zc_size(void* d); BE_FUNC_CTYPE_DECLARE(zc_size, "i", ".");
extern int zc_iter(bvm *vm);
extern void zc_abort(void); BE_FUNC_CTYPE_DECLARE(zc_abort, "", ".");
extern const bclass be_class_ctypes_bytes;
extern const be_ctypes_structure_t be_zigbee_zcl_frame_struct;
extern const bclass be_class_zcl_frame;
/********************************************************************
** Solidified function: tostring
********************************************************************/
be_local_closure(zb_device_tostring, /* name */
be_nested_proto(
14, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[11]) { /* constants */
/* K0 */ be_nested_str_literal("json"),
/* K1 */ be_nested_str_literal("string"),
/* K2 */ be_nested_str_literal("longaddr"),
/* K3 */ be_nested_str_literal("format"),
/* K4 */ be_nested_str_literal("<instance: %s(0x%04X, 0x%08X%08X, name:'%s', model:'%s', manufacturer:'%s')>"),
/* K5 */ be_nested_str_literal("shortaddr"),
/* K6 */ be_nested_str_literal("get"),
/* K7 */ be_const_int(0),
/* K8 */ be_nested_str_literal("name"),
/* K9 */ be_nested_str_literal("model"),
/* K10 */ be_nested_str_literal("manufacturer"),
}),
be_str_literal("tostring"),
&be_const_str_solidified,
( &(const binstruction[22]) { /* code */
0xA4060000, // 0000 IMPORT R1 K0
0xA40A0200, // 0001 IMPORT R2 K1
0x880C0102, // 0002 GETMBR R3 R0 K2
0x8C100503, // 0003 GETMET R4 R2 K3
0x58180004, // 0004 LDCONST R6 K4
0x601C0005, // 0005 GETGBL R7 G5
0x5C200000, // 0006 MOVE R8 R0
0x7C1C0200, // 0007 CALL R7 1
0x88200105, // 0008 GETMBR R8 R0 K5
0x8C240706, // 0009 GETMET R9 R3 K6
0x542E0003, // 000A LDINT R11 4
0x54320003, // 000B LDINT R12 4
0x7C240600, // 000C CALL R9 3
0x8C280706, // 000D GETMET R10 R3 K6
0x58300007, // 000E LDCONST R12 K7
0x54360003, // 000F LDINT R13 4
0x7C280600, // 0010 CALL R10 3
0x882C0108, // 0011 GETMBR R11 R0 K8
0x88300109, // 0012 GETMBR R12 R0 K9
0x8834010A, // 0013 GETMBR R13 R0 K10
0x7C101200, // 0014 CALL R4 9
0x80040800, // 0015 RET 1 R4
})
)
);
/*******************************************************************/
// Module Zigbee
extern const bclass be_class_zb_coord;
static int zigbee_init(bvm *vm) {
be_pushntvclass(vm, &be_class_zb_coord);
be_call(vm, 0);
be_return(vm);
}
/*******************************************************************/
extern void* zfn_get_bytes(void* sbuf_ptr, size_t *len_bytes);
BE_FUNC_CTYPE_DECLARE(zfn_get_bytes, "&", "-c");
extern void zfn_set_bytes(void* sbuf_ptr, const uint8_t* bytes, size_t len_bytes);
BE_FUNC_CTYPE_DECLARE(zfn_set_bytes, "", "-c(bytes)~");
/*******************************************************************/
#include "be_fixed_be_class_zb_device.h"
#include "be_fixed_be_class_zb_coord_ntv.h"
#include "be_fixed_be_class_zcl_frame_ntv.h"
#include "be_fixed_zigbee.h"
/* @const_object_info_begin
class be_class_zb_device (scope: global, name: zb_device) {
_p, var
init, ctype_func(zd_init)
member, func(zd_member)
tostring, closure(zb_device_tostring_closure)
}
@const_object_info_end */
/* @const_object_info_begin
class be_class_zb_coord_ntv (scope: global, name: zb_coord_ntv) {
zcl_frame, class(be_class_zcl_frame)
zb_device, class(be_class_zb_device)
info, func(zc_info)
item, func(zc_item)
size, ctype_func(zc_size)
iter, func(zc_iter)
abort, ctype_func(zc_abort)
}
@const_object_info_end */
/* @const_object_info_begin
class be_class_zcl_frame_ntv (scope: global, name: zcl_frame_ntv, super: be_class_ctypes_bytes) {
_def, comptr(&be_zigbee_zcl_frame_struct)
_get_bytes, ctype_func(zfn_get_bytes)
_set_bytes, ctype_func(zfn_set_bytes)
}
@const_object_info_end */
/* @const_object_info_begin
module zigbee (scope: global) {
init, func(zigbee_init)
}
@const_object_info_end */
#endif // USE_LIGHT

View File

@ -0,0 +1,214 @@
/********************************************************************
* Zigbee
*
*******************************************************************/
#ifdef USE_ZIGBEE
#include "be_constobj.h"
extern const bclass be_class_zb_coord_ntv;
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(zb_coord_init, /* name */
be_nested_proto(
3, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str_literal("init"),
}),
be_str_literal("init"),
&be_const_str_solidified,
( &(const binstruction[ 6]) { /* code */
0x60040003, // 0000 GETGBL R1 G3
0x5C080000, // 0001 MOVE R2 R0
0x7C040200, // 0002 CALL R1 1
0x8C040300, // 0003 GETMET R1 R1 K0
0x7C040200, // 0004 CALL R1 1
0x80000000, // 0005 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: add_handler
********************************************************************/
be_local_closure(zb_coord_add_handler, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 5]) { /* constants */
/* K0 */ be_nested_str_literal("instance"),
/* K1 */ be_nested_str_literal("value_error"),
/* K2 */ be_nested_str_literal("instance required"),
/* K3 */ be_nested_str_literal("_handlers"),
/* K4 */ be_nested_str_literal("push"),
}),
be_str_literal("add_handler"),
&be_const_str_solidified,
( &(const binstruction[18]) { /* code */
0x60080004, // 0000 GETGBL R2 G4
0x5C0C0200, // 0001 MOVE R3 R1
0x7C080200, // 0002 CALL R2 1
0x20080500, // 0003 NE R2 R2 K0
0x780A0000, // 0004 JMPF R2 #0006
0xB0060302, // 0005 RAISE 1 K1 K2
0x88080103, // 0006 GETMBR R2 R0 K3
0x780A0004, // 0007 JMPF R2 #000D
0x88080103, // 0008 GETMBR R2 R0 K3
0x8C080504, // 0009 GETMET R2 R2 K4
0x5C100200, // 000A MOVE R4 R1
0x7C080400, // 000B CALL R2 2
0x70020003, // 000C JMP #0011
0x60080012, // 000D GETGBL R2 G18
0x7C080000, // 000E CALL R2 0
0x400C0401, // 000F CONNECT R3 R2 R1
0x90020602, // 0010 SETMBR R0 K3 R2
0x80000000, // 0011 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: dispatch
********************************************************************/
be_local_closure(zb_coord_dispatch, /* name */
be_nested_proto(
19, /* nstack */
5, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[14]) { /* constants */
/* K0 */ be_nested_str_literal("_handlers"),
/* K1 */ be_nested_str_literal("introspect"),
/* K2 */ be_nested_str_literal("string"),
/* K3 */ be_nested_str_literal("zcl_frame"),
/* K4 */ be_const_int(0),
/* K5 */ be_nested_str_literal("get"),
/* K6 */ be_nested_str_literal("function"),
/* K7 */ be_nested_str_literal("format"),
/* K8 */ be_nested_str_literal("BRY: Exception> '%s' - %s"),
/* K9 */ be_nested_str_literal("tasmota"),
/* K10 */ be_nested_str_literal("_debug_present"),
/* K11 */ be_nested_str_literal("debug"),
/* K12 */ be_nested_str_literal("traceback"),
/* K13 */ be_const_int(1),
}),
be_str_literal("dispatch"),
&be_const_str_solidified,
( &(const binstruction[61]) { /* code */
0x88140100, // 0000 GETMBR R5 R0 K0
0x4C180000, // 0001 LDNIL R6
0x1C140A06, // 0002 EQ R5 R5 R6
0x78160000, // 0003 JMPF R5 #0005
0x80000A00, // 0004 RET 0
0xA4160200, // 0005 IMPORT R5 K1
0xA41A0400, // 0006 IMPORT R6 K2
0x5C1C0600, // 0007 MOVE R7 R3
0x1C200503, // 0008 EQ R8 R2 K3
0x78220003, // 0009 JMPF R8 #000E
0x8C200103, // 000A GETMET R8 R0 K3
0x5C280600, // 000B MOVE R10 R3
0x7C200400, // 000C CALL R8 2
0x5C1C1000, // 000D MOVE R7 R8
0x58200004, // 000E LDCONST R8 K4
0x6024000C, // 000F GETGBL R9 G12
0x88280100, // 0010 GETMBR R10 R0 K0
0x7C240200, // 0011 CALL R9 1
0x14241009, // 0012 LT R9 R8 R9
0x78260027, // 0013 JMPF R9 #003C
0x88240100, // 0014 GETMBR R9 R0 K0
0x94241208, // 0015 GETIDX R9 R9 R8
0x8C280B05, // 0016 GETMET R10 R5 K5
0x5C301200, // 0017 MOVE R12 R9
0x5C340200, // 0018 MOVE R13 R1
0x7C280600, // 0019 CALL R10 3
0x602C0004, // 001A GETGBL R11 G4
0x5C301400, // 001B MOVE R12 R10
0x7C2C0200, // 001C CALL R11 1
0x1C2C1706, // 001D EQ R11 R11 K6
0x782E001A, // 001E JMPF R11 #003A
0xA8020008, // 001F EXBLK 0 #0029
0x5C2C1400, // 0020 MOVE R11 R10
0x5C301200, // 0021 MOVE R12 R9
0x5C340200, // 0022 MOVE R13 R1
0x5C380400, // 0023 MOVE R14 R2
0x5C3C0E00, // 0024 MOVE R15 R7
0x5C400800, // 0025 MOVE R16 R4
0x7C2C0A00, // 0026 CALL R11 5
0xA8040001, // 0027 EXBLK 1 1
0x70020010, // 0028 JMP #003A
0xAC2C0002, // 0029 CATCH R11 0 2
0x7002000D, // 002A JMP #0039
0x60340001, // 002B GETGBL R13 G1
0x8C380D07, // 002C GETMET R14 R6 K7
0x58400008, // 002D LDCONST R16 K8
0x5C441600, // 002E MOVE R17 R11
0x5C481800, // 002F MOVE R18 R12
0x7C380800, // 0030 CALL R14 4
0x7C340200, // 0031 CALL R13 1
0xB8361200, // 0032 GETNGBL R13 K9
0x88341B0A, // 0033 GETMBR R13 R13 K10
0x78360002, // 0034 JMPF R13 #0038
0xA4361600, // 0035 IMPORT R13 K11
0x8C381B0C, // 0036 GETMET R14 R13 K12
0x7C380200, // 0037 CALL R14 1
0x70020000, // 0038 JMP #003A
0xB0080000, // 0039 RAISE 2 R0 R0
0x0020110D, // 003A ADD R8 R8 K13
0x7001FFD2, // 003B JMP #000F
0x80000000, // 003C RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: zb_coord
********************************************************************/
extern const bclass be_class_zb_coord_ntv;
be_local_class(zb_coord,
1,
&be_class_zb_coord_ntv,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_literal("dispatch", 1), be_const_closure(zb_coord_dispatch_closure) },
{ be_const_key_literal("add_handler", 2), be_const_closure(zb_coord_add_handler_closure) },
{ be_const_key_literal("_handlers", -1), be_const_var(0) },
{ be_const_key_literal("init", 0), be_const_closure(zb_coord_init_closure) },
})),
be_str_literal("zb_coord")
);
/*******************************************************************/
void be_load_zb_coord_class(bvm *vm) {
be_pushntvclass(vm, &be_class_zb_coord);
be_setglobal(vm, "zb_coord");
be_pop(vm, 1);
}
#endif // USE_LIGHT

View File

@ -0,0 +1,239 @@
/********************************************************************
* Zigbee
*
*******************************************************************/
#ifdef USE_ZIGBEE
#include "be_constobj.h"
extern const bclass be_class_zcl_frame_ntv;
/********************************************************************
** Solidified function: member
********************************************************************/
be_local_closure(zcl_frame_member, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 4]) { /* constants */
/* K0 */ be_nested_str_literal("payload"),
/* K1 */ be_nested_str_literal("_get_bytes"),
/* K2 */ be_nested_str_literal("payload_ptr"),
/* K3 */ be_nested_str_literal("member"),
}),
be_str_literal("member"),
&be_const_str_solidified,
( &(const binstruction[15]) { /* code */
0x1C080300, // 0000 EQ R2 R1 K0
0x780A0004, // 0001 JMPF R2 #0007
0x8C080101, // 0002 GETMET R2 R0 K1
0x88100102, // 0003 GETMBR R4 R0 K2
0x7C080400, // 0004 CALL R2 2
0x80040400, // 0005 RET 1 R2
0x70020006, // 0006 JMP #000E
0x60080003, // 0007 GETGBL R2 G3
0x5C0C0000, // 0008 MOVE R3 R0
0x7C080200, // 0009 CALL R2 1
0x8C080503, // 000A GETMET R2 R2 K3
0x5C100200, // 000B MOVE R4 R1
0x7C080400, // 000C CALL R2 2
0x80040400, // 000D RET 1 R2
0x80000000, // 000E RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: setmember
********************************************************************/
be_local_closure(zcl_frame_setmember, /* name */
be_nested_proto(
7, /* nstack */
3, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 4]) { /* constants */
/* K0 */ be_nested_str_literal("payload"),
/* K1 */ be_nested_str_literal("_set_bytes"),
/* K2 */ be_nested_str_literal("payload_ptr"),
/* K3 */ be_nested_str_literal("setmember"),
}),
be_str_literal("setmember"),
&be_const_str_solidified,
( &(const binstruction[17]) { /* code */
0x1C0C0300, // 0000 EQ R3 R1 K0
0x780E0005, // 0001 JMPF R3 #0008
0x8C0C0101, // 0002 GETMET R3 R0 K1
0x88140102, // 0003 GETMBR R5 R0 K2
0x5C180400, // 0004 MOVE R6 R2
0x7C0C0600, // 0005 CALL R3 3
0x80040600, // 0006 RET 1 R3
0x70020007, // 0007 JMP #0010
0x600C0003, // 0008 GETGBL R3 G3
0x5C100000, // 0009 MOVE R4 R0
0x7C0C0200, // 000A CALL R3 1
0x8C0C0703, // 000B GETMET R3 R3 K3
0x5C140200, // 000C MOVE R5 R1
0x5C180400, // 000D MOVE R6 R2
0x7C0C0600, // 000E CALL R3 3
0x80040600, // 000F RET 1 R3
0x80000000, // 0010 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(zcl_frame_init, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_str_literal("init"),
/* K1 */ be_nested_str_literal("no_bytes"),
}),
be_str_literal("init"),
&be_const_str_solidified,
( &(const binstruction[10]) { /* code */
0x60080003, // 0000 GETGBL R2 G3
0x5C0C0000, // 0001 MOVE R3 R0
0x7C080200, // 0002 CALL R2 1
0x8C080500, // 0003 GETMET R2 R2 K0
0x5C100200, // 0004 MOVE R4 R1
0x7C080400, // 0005 CALL R2 2
0x60080015, // 0006 GETGBL R2 G21
0x7C080000, // 0007 CALL R2 0
0x90020202, // 0008 SETMBR R0 K1 R2
0x80000000, // 0009 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: tomap
********************************************************************/
be_local_closure(zcl_frame_tomap, /* name */
be_nested_proto(
7, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 7]) { /* constants */
/* K0 */ be_nested_str_literal("string"),
/* K1 */ be_nested_str_literal("tomap"),
/* K2 */ be_nested_str_literal("shortaddr_hex"),
/* K3 */ be_nested_str_literal("format"),
/* K4 */ be_nested_str_literal("0x%04X"),
/* K5 */ be_nested_str_literal("shortaddr"),
/* K6 */ be_nested_str_literal("payload"),
}),
be_str_literal("tomap"),
&be_const_str_solidified,
( &(const binstruction[14]) { /* code */
0xA4060000, // 0000 IMPORT R1 K0
0x60080003, // 0001 GETGBL R2 G3
0x5C0C0000, // 0002 MOVE R3 R0
0x7C080200, // 0003 CALL R2 1
0x8C080501, // 0004 GETMET R2 R2 K1
0x7C080200, // 0005 CALL R2 1
0x8C0C0303, // 0006 GETMET R3 R1 K3
0x58140004, // 0007 LDCONST R5 K4
0x88180105, // 0008 GETMBR R6 R0 K5
0x7C0C0600, // 0009 CALL R3 3
0x980A0403, // 000A SETIDX R2 K2 R3
0x880C0106, // 000B GETMBR R3 R0 K6
0x980A0C03, // 000C SETIDX R2 K6 R3
0x80040400, // 000D RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: tostring
********************************************************************/
be_local_closure(zcl_frame_tostring, /* name */
be_nested_proto(
4, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str_literal("tomap"),
}),
be_str_literal("tostring"),
&be_const_str_solidified,
( &(const binstruction[ 6]) { /* code */
0x8C040100, // 0000 GETMET R1 R0 K0
0x7C040200, // 0001 CALL R1 1
0x60080008, // 0002 GETGBL R2 G8
0x5C0C0200, // 0003 MOVE R3 R1
0x7C080200, // 0004 CALL R2 1
0x80040400, // 0005 RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: zcl_frame
********************************************************************/
extern const bclass be_class_zcl_frame_ntv;
be_local_class(zcl_frame,
1,
&be_class_zcl_frame_ntv,
be_nested_map(6,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key_literal("no_bytes", -1), be_const_var(0) },
{ be_const_key_literal("member", 2), be_const_closure(zcl_frame_member_closure) },
{ be_const_key_literal("tostring", 5), be_const_closure(zcl_frame_tostring_closure) },
{ be_const_key_literal("init", -1), be_const_closure(zcl_frame_init_closure) },
{ be_const_key_literal("tomap", -1), be_const_closure(zcl_frame_tomap_closure) },
{ be_const_key_literal("setmember", -1), be_const_closure(zcl_frame_setmember_closure) },
})),
be_str_literal("zcl_frame")
);
/*******************************************************************/
void be_load_zcl_frame_class(bvm *vm) {
be_pushntvclass(vm, &be_class_zcl_frame);
be_setglobal(vm, "zcl_frame");
be_pop(vm, 1);
}
#endif // USE_LIGHT

View File

@ -146,6 +146,8 @@ class Partition_info
if self.type == 0 return "app" if self.type == 0 return "app"
elif self.type == 1 return "data" elif self.type == 1 return "data"
end end
import string
return string.format("0x%02X", self.type)
end end
def subtype_to_string() def subtype_to_string()
@ -166,6 +168,8 @@ class Partition_info
elif self.subtype == 0x82 return "spiffs" elif self.subtype == 0x82 return "spiffs"
end end
end end
import string
return string.format("0x%02X", self.subtype)
end end
# Human readable version of Partition information # Human readable version of Partition information

View File

@ -0,0 +1,17 @@
# zigbee code
class zb_device
def tostring()
import json
import string
var la = self.longaddr # bytes() of size 8, little-endian
return string.format("<instance: %s(0x%04X, 0x%08X%08X, name:'%s', model:'%s', manufacturer:'%s')>",
classname(self), self.shortaddr,
la.get(4,4), la.get(0,4),
self.name, self.model, self.manufacturer)
return
end
end

View File

@ -0,0 +1,59 @@
# zigbee zcl_frame class
# solidify.dump(zb_coord,true)
class zb_coord_ntv end # fake class replaced with native one
#zb_coord_ntv = classof(super(zigbee))
class zb_coord : zb_coord_ntv
var _handlers
def init()
super(self).init()
end
def add_handler(h)
if type(h) != 'instance'
raise "value_error", "instance required"
end
if self._handlers
self._handlers.push(h)
else
self._handlers = [h]
end
end
def dispatch(event_type, data_type, data_ptr, idx)
if self._handlers == nil return end
import introspect
import string
var data = data_ptr
if data_type == "zcl_frame"
data = self.zcl_frame(data_ptr)
end
#print(string.format(">ZIG: cmd=%s data_type=%s data=%s idx=%i", event_type, data_type, str(data), idx))
var i = 0
while i < size(self._handlers)
var h = self._handlers[i]
var f = introspect.get(h, event_type) # try to match a function or method with the same name
if type(f) == 'function'
try
f(h, event_type, data_type, data, idx)
except .. as e,m
print(string.format("BRY: Exception> '%s' - %s", e, m))
if tasmota._debug_present
import debug
debug.traceback()
end
end
end
i += 1
end
end
end

View File

@ -0,0 +1,44 @@
# zigbee zcl_frame class
#
# solidify.dump(zcl_frame,true)
class zcl_frame_ntv end
class zcl_frame : zcl_frame_ntv
var no_bytes
def init(p)
super(self).init(p)
self.no_bytes = bytes()
end
def member(name)
if name == "payload"
return self._get_bytes(self.payload_ptr)
else
return super(self).member(name)
end
end
def setmember(name, val)
if name == "payload"
return self._set_bytes(self.payload_ptr, val)
else
return super(self).setmember(name, val)
end
end
def tomap()
import string
var m = super(self).tomap()
m["shortaddr_hex"] = string.format("0x%04X", self.shortaddr)
m["payload"] = self.payload # add payload object which is a synthetic attribute not included in tomap()
return m
end
def tostring()
var m = self.tomap()
return str(m)
end
end

View File

@ -8,7 +8,7 @@
*********************/ *********************/
#include "../lvgl.h" /*To see all the widgets*/ #include "../lvgl.h" /*To see all the widgets*/
#include "lv_theme_openhasp.h" #include "lv_theme_haspmota.h"
#include "misc/lv_gc.h" #include "misc/lv_gc.h"
/********************* /*********************
@ -625,7 +625,7 @@ static void style_init(void)
* GLOBAL FUNCTIONS * GLOBAL FUNCTIONS
**********************/ **********************/
lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font) lv_theme_t * lv_theme_haspmota_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)
{ {
/*This trick is required only to avoid the garbage collection of /*This trick is required only to avoid the garbage collection of
@ -658,7 +658,7 @@ lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary,
return (lv_theme_t *)&theme; return (lv_theme_t *)&theme;
} }
bool lv_theme_openhasp_is_inited(void) bool lv_theme_haspmota_is_inited(void)
{ {
return inited; return inited;
} }

View File

@ -1,5 +1,5 @@
/** /**
* @file lv_theme_openhasp.h * @file lv_theme_haspmota.h
* *
*/ */
@ -40,9 +40,9 @@ typedef enum {
* @param font pointer to a font to use. * @param font pointer to a font to use.
* @return a pointer to reference this theme later * @return a pointer to reference this theme later
*/ */
lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font); lv_theme_t * lv_theme_haspmota_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font);
bool lv_theme_openhasp_is_inited(void); bool lv_theme_haspmota_is_inited(void);
/********************** /**********************
* MACROS * MACROS

View File

@ -9,7 +9,7 @@
#include "lvgl.h" #include "lvgl.h"
#include "be_mapping.h" #include "be_mapping.h"
#include "lv_berry.h" #include "lv_berry.h"
#include "lv_theme_openhasp.h" #include "lv_theme_haspmota.h"
extern int lv0_member(bvm *vm); // resolve virtual members extern int lv0_member(bvm *vm); // resolve virtual members
extern int lv0_load_font(bvm *vm); extern int lv0_load_font(bvm *vm);
@ -163,9 +163,9 @@ const be_ntv_func_def_t lv_func[] = {
{ "theme_get_font_normal", { (const void*) &lv_theme_get_font_normal, "lv.lv_font", "(lv.lv_obj)" } }, { "theme_get_font_normal", { (const void*) &lv_theme_get_font_normal, "lv.lv_font", "(lv.lv_obj)" } },
{ "theme_get_font_small", { (const void*) &lv_theme_get_font_small, "lv.lv_font", "(lv.lv_obj)" } }, { "theme_get_font_small", { (const void*) &lv_theme_get_font_small, "lv.lv_font", "(lv.lv_obj)" } },
{ "theme_get_from_obj", { (const void*) &lv_theme_get_from_obj, "lv.lv_theme", "(lv.lv_obj)" } }, { "theme_get_from_obj", { (const void*) &lv_theme_get_from_obj, "lv.lv_theme", "(lv.lv_obj)" } },
{ "theme_haspmota_init", { (const void*) &lv_theme_haspmota_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" } },
{ "theme_haspmota_is_inited", { (const void*) &lv_theme_haspmota_is_inited, "b", "" } },
{ "theme_mono_init", { (const void*) &lv_theme_mono_init, "lv.lv_theme", "(lv.lv_disp)b(lv.lv_font)" } }, { "theme_mono_init", { (const void*) &lv_theme_mono_init, "lv.lv_theme", "(lv.lv_disp)b(lv.lv_font)" } },
{ "theme_openhasp_init", { (const void*) &lv_theme_openhasp_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" } },
{ "theme_openhasp_is_inited", { (const void*) &lv_theme_openhasp_is_inited, "b", "" } },
{ "theme_set_apply_cb", { (const void*) &lv_theme_set_apply_cb, "", "(lv.lv_theme)^lv_theme_apply_cb^" } }, { "theme_set_apply_cb", { (const void*) &lv_theme_set_apply_cb, "", "(lv.lv_theme)^lv_theme_apply_cb^" } },
{ "theme_set_parent", { (const void*) &lv_theme_set_parent, "", "(lv.lv_theme)(lv.lv_theme)" } }, { "theme_set_parent", { (const void*) &lv_theme_set_parent, "", "(lv.lv_theme)(lv.lv_theme)" } },
{ "timer_create", { (const void*) &lv_timer_create, "lv.lv_timer", "^lv_timer_cb^i." } }, { "timer_create", { (const void*) &lv_timer_create, "lv.lv_timer", "^lv_timer_cb^i." } },

View File

@ -1151,7 +1151,7 @@ void lv_textarea_cursor_left(lv_obj_t * obj)
void lv_textarea_cursor_down(lv_obj_t * obj) void lv_textarea_cursor_down(lv_obj_t * obj)
void lv_textarea_cursor_up(lv_obj_t * obj) void lv_textarea_cursor_up(lv_obj_t * obj)
// ../../LVGL_assets/src/lv_theme_openhasp.h // ../../LVGL_assets/src/lv_theme_haspmota.h
lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font) lv_theme_t * lv_theme_haspmota_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)
bool lv_theme_openhasp_is_inited(void) bool lv_theme_haspmota_is_inited(void)

View File

@ -181,8 +181,6 @@ int lco_init(bvm *vm) {
int argc = be_top(vm); int argc = be_top(vm);
lv_color_t lv_color = {}; // default value is all zeroes (black) lv_color_t lv_color = {}; // default value is all zeroes (black)
uint32_t color32 = 0x000000; // default to black
if (argc > 1) { if (argc > 1) {
if (be_isint(vm, 2)) { // color is RGB 24 bits if (be_isint(vm, 2)) { // color is RGB 24 bits
lv_color = lv_color_hex(be_toint(vm, 2)); lv_color = lv_color_hex(be_toint(vm, 2));
@ -209,7 +207,6 @@ int lco_tostring(bvm *vm) {
} }
int lco_toint(bvm *vm) { int lco_toint(bvm *vm) {
lv_color_t lv_color = {};
be_getmember(vm, 1, "_p"); be_getmember(vm, 1, "_p");
uint32_t ntv_color = be_toint(vm, -1); uint32_t ntv_color = be_toint(vm, -1);
be_pushint(vm, ntv_color); be_pushint(vm, ntv_color);

View File

@ -741,7 +741,7 @@ print("""/********************************************************************
#include "lvgl.h" #include "lvgl.h"
#include "be_mapping.h" #include "be_mapping.h"
#include "lv_berry.h" #include "lv_berry.h"
#include "lv_theme_openhasp.h" #include "lv_theme_haspmota.h"
extern int lv0_member(bvm *vm); // resolve virtual members extern int lv0_member(bvm *vm); // resolve virtual members
extern int lv0_load_font(bvm *vm); extern int lv0_load_font(bvm *vm);

View File

@ -78,7 +78,7 @@ lv_fun_globs = [
#"**/*.h", #"**/*.h",
] ]
headers_names = list_files(lv_src_prefix, lv_fun_globs) headers_names = list_files(lv_src_prefix, lv_fun_globs)
headers_names += list_files("../../LVGL_assets/src/", ["lv_theme_openhasp.h"]) headers_names += list_files("../../LVGL_assets/src/", ["lv_theme_haspmota.h"])
# headers_names += ["lv_pre_style.h"] # for LVGL v7, add pre-generated style functions from C preprocessor # headers_names += ["lv_pre_style.h"] # for LVGL v7, add pre-generated style functions from C preprocessor
# unit test # unit test

View File

@ -39,7 +39,7 @@ FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32")
variants_dir = join(FRAMEWORK_DIR, "variants", "tasmota") variants_dir = join(FRAMEWORK_DIR, "variants", "tasmota")
def esp32_create_chip_string(chip): def esp32_create_chip_string(chip):
tasmota_platform = env.subst("$BUILD_DIR").split('/')[-1] tasmota_platform = env.subst("$BUILD_DIR").split(os.path.sep)[-1]
tasmota_platform = tasmota_platform.split('-')[0] tasmota_platform = tasmota_platform.split('-')[0]
if 'tasmota' and chip[3:] not in tasmota_platform: # quick check for a valid name like 'tasmota' + '32c3' if 'tasmota' and chip[3:] not in tasmota_platform: # quick check for a valid name like 'tasmota' + '32c3'
print('Unexpected naming conventions in this build environment -> Undefined behavior for further build process!!') print('Unexpected naming conventions in this build environment -> Undefined behavior for further build process!!')
@ -54,6 +54,14 @@ def esp32_build_filesystem(fs_size):
for file in files: for file in files:
if "no_files" in file: if "no_files" in file:
continue continue
if "http" and "://" in file:
response = requests.get(file)
if response.ok:
target = join(filesystem_dir,file.split(os.path.sep)[-1])
open(target, "wb").write(response.content)
else:
print("Failed to download: ",file)
continue
shutil.copy(file, filesystem_dir) shutil.copy(file, filesystem_dir)
if not os.listdir(filesystem_dir): if not os.listdir(filesystem_dir):
print("No files added -> will NOT create littlefs.bin and NOT overwrite fs partition!") print("No files added -> will NOT create littlefs.bin and NOT overwrite fs partition!")

View File

@ -0,0 +1,12 @@
import glob
import os
Import("env")
def FindInoNodes(env):
src_dir = glob.escape(env.subst("$PROJECT_SRC_DIR"))
return env.Glob(os.path.join(src_dir, "*.ino")) + env.Glob(
os.path.join(src_dir, "tasmota_*", "*.ino")
)
env.AddMethod(FindInoNodes)

View File

@ -64,7 +64,8 @@ lib_extra_dirs =
;bin_dir = /tmp/bin_files/ ;bin_dir = /tmp/bin_files/
[scripts_defaults] [scripts_defaults]
extra_scripts = pio-tools/strip-floats.py extra_scripts = pre:pio-tools/pre_source_dir.py
pio-tools/strip-floats.py
pio-tools/name-firmware.py pio-tools/name-firmware.py
pio-tools/gzip-firmware.py pio-tools/gzip-firmware.py
pio-tools/override_copy.py pio-tools/override_copy.py

View File

@ -27,18 +27,22 @@ default_envs =
; tasmota-zbbridge ; tasmota-zbbridge
; tasmota-ir ; tasmota-ir
; tasmota32 ; tasmota32
; tasmota32-zbbrdgpro
; tasmota32-bluetooth ; tasmota32-bluetooth
; tasmota32-webcam ; tasmota32-webcam
; tasmota32-knx ; tasmota32-knx
; tasmota32-sensors ; tasmota32-sensors
; tasmota32-display ; tasmota32-lvgl
; tasmota32-ir ; tasmota32-ir
; tasmota32solo1 ; tasmota32solo1
; tasmota32c3 ; tasmota32c3
; tasmota32c3usb
; tasmota32s2 ; tasmota32s2
; tasmota32s3 ; tasmota32s3
; tasmota32s3usb
; tasmota32-odroidgo ; tasmota32-odroidgo
; tasmota32-core2 ; tasmota32-core2
; tasmota32-nspanel
[env] [env]
@ -46,7 +50,7 @@ default_envs =
;platform = https://github.com/platformio/platform-espressif8266.git ;platform = https://github.com/platformio/platform-espressif8266.git
;platform_packages = framework-arduinoespressif8266 @ https://github.com/esp8266/Arduino.git ;platform_packages = framework-arduinoespressif8266 @ https://github.com/esp8266/Arduino.git
; mcspr/toolchain-xtensa @ ~5.100300.211127 ; mcspr/toolchain-xtensa @ ~5.100300.211127
; platformio/tool-esptoolpy @ ~1.30100 ; platformio/tool-esptoolpy @ ~1.30300
;build_unflags = ${common.build_unflags} ;build_unflags = ${common.build_unflags}
; -Wswitch-unreachable ; -Wswitch-unreachable
;build_flags = ${common.build_flags} ;build_flags = ${common.build_flags}
@ -92,11 +96,11 @@ lib_extra_dirs = ${library.lib_extra_dirs}
[env:tasmota32_base] [env:tasmota32_base]
; *** Uncomment next lines ";" to enable development Tasmota Arduino version ESP32 ; *** Uncomment next lines ";" to enable development Tasmota Arduino version ESP32
;platform = https://github.com/tasmota/platform-espressif32/releases/download/v.2.0.3/platform-espressif32-v.2.0.3.zip ;platform = https://github.com/tasmota/platform-espressif32/releases/download/v.2.0.3/platform-espressif32-v.2.0.3.zip
;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/837/framework-arduinoespressif32-v4.4_dev-6fa4526c0d.tar.gz ;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/847/framework-arduinoespressif32-v4.4_dev-d327997163.tar.gz
build_unflags = ${esp32_defaults.build_unflags} build_unflags = ${esp32_defaults.build_unflags}
build_flags = ${esp32_defaults.build_flags} build_flags = ${esp32_defaults.build_flags}
; Build variant ESP32 4M Flash, Tasmota 1856k Code/OTA, 320k LITTLEFS (default) ; Build variant ESP32 4M Flash, Tasmota 1856k Code/OTA, 1344k LITTLEFS (default)
;board = esp32_4M ;board = esp32_4M
; Build variant ESP32 8M Flash, Tasmota 2944k Code/OTA, 2112k LITTLEFS ; Build variant ESP32 8M Flash, Tasmota 2944k Code/OTA, 2112k LITTLEFS
;board = esp32_8M ;board = esp32_8M

View File

@ -49,3 +49,9 @@ platform = https://github.com/tasmota/platform-espressif32/re
platform_packages = platform_packages =
build_unflags = ${esp32_defaults.build_unflags} build_unflags = ${esp32_defaults.build_unflags}
build_flags = ${esp32_defaults.build_flags} build_flags = ${esp32_defaults.build_flags}
[core32itead]
platform = https://github.com/tasmota/platform-espressif32/releases/download/v.2.0.3/platform-espressif32-solo1-v.2.0.3.zip
platform_packages = framework-arduinoespressif32 @ https://github.com/tasmota/esp32-arduino-lib-builder/releases/download/v2.0.3/framework-arduinoespressif32-itead.tar.gz
build_unflags = ${esp32_defaults.build_unflags}
build_flags = ${esp32_defaults.build_flags}

View File

@ -12,13 +12,14 @@ build_flags = ${env:tasmota32_base.build_flags}
-D USE_WIFI_RANGE_EXTENDER -D USE_WIFI_RANGE_EXTENDER
-D USE_WIFI_RANGE_EXTENDER_NAPT -D USE_WIFI_RANGE_EXTENDER_NAPT
[env:tasmota32s3] [env:tasmota32s3-file]
extends = env:tasmota32_base extends = env:tasmota32_base
board = esp32s3 board = esp32s3
build_flags = ${env:tasmota32_base.build_flags} -D FIRMWARE_TASMOTA32 build_flags = ${env:tasmota32_base.build_flags} -D FIRMWARE_TASMOTA32
; example for custom file upload in Tasmota Filesystem ; example for custom file upload in Tasmota Filesystem
; custom_files_upload = ${env:tasmota32_base.custom_files_upload} ; custom_files_upload = ${env:tasmota32_base.custom_files_upload}
; tasmota/berry/modules/Partition_wizard.tapp ; tasmota/berry/modules/Partition_wizard.tapp
; https://github.com/tasmota/autoconf/raw/main/esp32s3/DevKitC-1.autoconf
; *** Debug version used for PlatformIO Home Project Inspection ; *** Debug version used for PlatformIO Home Project Inspection
[env:tasmota-debug] [env:tasmota-debug]

View File

@ -40,6 +40,16 @@ lib_ignore =
; tasmota/berry/modules/Partition_Manager.tapp ; tasmota/berry/modules/Partition_Manager.tapp
custom_files_upload = no_files custom_files_upload = no_files
[env:tasmota32-safeboot]
extends = env:tasmota32_base
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT
lib_extra_dirs = lib/lib_ssl, lib/libesp32
lib_ignore =
TTGO TWatch Library
NimBLE-Arduino
Micro-RTSP
epdiy
[env:tasmota32] [env:tasmota32]
extends = env:tasmota32_base extends = env:tasmota32_base
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32 build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32
@ -54,13 +64,6 @@ extends = env:tasmota32_base
board = esp32_16M board = esp32_16M
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32 build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32
[env:tasmota32solo1]
extends = env:tasmota32_base
board = esp32_solo1_4M
platform = ${core32solo1.platform}
platform_packages = ${core32solo1.platform_packages}
build_flags = ${core32solo1.build_flags} -DFIRMWARE_TASMOTA32
[env:tasmota32-webcam] [env:tasmota32-webcam]
extends = env:tasmota32_base extends = env:tasmota32_base
board = esp32-cam board = esp32-cam
@ -98,41 +101,12 @@ extends = env:tasmota32_base
build_flags = ${env:tasmota32_base.build_flags} -DUSE_IR_REMOTE_FULL -DFIRMWARE_IR build_flags = ${env:tasmota32_base.build_flags} -DUSE_IR_REMOTE_FULL -DFIRMWARE_IR
lib_extra_dirs = lib/libesp32, lib/lib_basic, lib/lib_ssl lib_extra_dirs = lib/libesp32, lib/lib_basic, lib/lib_ssl
[env:tasmota32c3] [env:tasmota32solo1]
extends = env:tasmota32_base extends = env:tasmota32_base
board = esp32c3 board = esp32_solo1_4M
build_unflags = ${env:tasmota32_base.build_unflags} platform = ${core32solo1.platform}
-flto platform_packages = ${core32solo1.platform_packages}
-mtarget-align build_flags = ${core32solo1.build_flags} -DFIRMWARE_TASMOTA32
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32
-fno-lto
lib_ignore =
TTGO TWatch Library
Micro-RTSP
epdiy
[env:tasmota32c3usb]
extends = env:tasmota32c3
board = esp32c3usb
[env:tasmota32s2]
extends = env:tasmota32_base
board = esp32s2
build_flags = ${env:tasmota32_base.build_flags} -D FIRMWARE_TASMOTA32
lib_ignore =
TTGO TWatch Library
NimBLE-Arduino
Micro-RTSP
epdiy
[env:tasmota32-safeboot]
extends = env:tasmota32_base
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT
lib_extra_dirs = lib/lib_ssl, lib/libesp32
lib_ignore =
TTGO TWatch Library
NimBLE-Arduino
Micro-RTSP
epdiy
[env:tasmota32solo1-safeboot] [env:tasmota32solo1-safeboot]
extends = env:tasmota32_base extends = env:tasmota32_base
@ -147,6 +121,64 @@ lib_ignore =
Micro-RTSP Micro-RTSP
epdiy epdiy
[env:tasmota32-zbbrdgpro]
extends = env:tasmota32_base
board = esp32_4M_FS
platform = ${core32itead.platform}
platform_packages = ${core32itead.platform_packages}
build_flags = ${env:tasmota32_base.build_flags}
-DFIRMWARE_ZBBRDGPRO
custom_files_upload = ${env:tasmota32_base.custom_files_upload}
tools/fw_SonoffZigbeeBridgePro_cc2652/Sonoff_ZBPro.autoconf
tasmota/berry/zigbee/cc2652_flasher.be
tasmota/berry/zigbee/intelhex.be
tasmota/berry/zigbee/sonoff_zb_pro_flasher.be
tools/fw_SonoffZigbeeBridgePro_cc2652/SonoffZBPro_coord_20220219.hex
lib_extra_dirs = lib/lib_basic, lib/lib_ssl, lib/libesp32
[env:tasmota32-nspanel]
extends = env:tasmota32_base
platform = ${core32itead.platform}
platform_packages = ${core32itead.platform_packages}
build_flags = ${env:tasmota32_base.build_flags}
-DFIRMWARE_NSPANEL
[env:tasmota32c3-safeboot]
extends = env:tasmota32_base
board = esp32c3
build_unflags = ${env:tasmota32_base.build_unflags}
-flto
-mtarget-align
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT
-fno-lto
lib_extra_dirs = lib/lib_ssl, lib/libesp32
lib_ignore =
TTGO TWatch Library
NimBLE-Arduino
Micro-RTSP
epdiy
[env:tasmota32c3]
extends = env:tasmota32_base
board = esp32c3
build_unflags = ${env:tasmota32_base.build_unflags}
-flto
-mtarget-align
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32
-fno-lto
lib_ignore =
TTGO TWatch Library
Micro-RTSP
epdiy
[env:tasmota32c3usb-safeboot]
extends = env:tasmota32c3-safeboot
board = esp32c3usb
[env:tasmota32c3usb]
extends = env:tasmota32c3
board = esp32c3usb
[env:tasmota32s2-safeboot] [env:tasmota32s2-safeboot]
extends = env:tasmota32_base extends = env:tasmota32_base
board = esp32s2 board = esp32s2
@ -158,6 +190,16 @@ lib_ignore =
Micro-RTSP Micro-RTSP
epdiy epdiy
[env:tasmota32s2]
extends = env:tasmota32_base
board = esp32s2
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32
lib_ignore =
TTGO TWatch Library
NimBLE-Arduino
Micro-RTSP
epdiy
[env:tasmota32s3-safeboot] [env:tasmota32s3-safeboot]
extends = env:tasmota32_base extends = env:tasmota32_base
board = esp32s3 board = esp32s3
@ -169,35 +211,22 @@ lib_ignore =
Micro-RTSP Micro-RTSP
epdiy epdiy
[env:tasmota32c3-safeboot] [env:tasmota32s3]
extends = env:tasmota32_base extends = env:tasmota32_base
board = esp32c3 board = esp32s3
build_unflags = ${env:tasmota32_base.build_unflags} build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32
-flto
-mtarget-align
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT
-fno-lto
lib_extra_dirs = lib/lib_ssl, lib/libesp32
lib_ignore = lib_ignore =
TTGO TWatch Library TTGO TWatch Library
NimBLE-Arduino
Micro-RTSP Micro-RTSP
epdiy epdiy
[env:tasmota32c3usb-safeboot] [env:tasmota32s3usb-safeboot]
extends = env:tasmota32_base extends = env:tasmota32s3-safeboot
board = esp32c3usb board = esp32s3usb
build_unflags = ${env:tasmota32_base.build_unflags}
-flto [env:tasmota32s3usb]
-mtarget-align extends = env:tasmota32s3
build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_SAFEBOOT board = esp32s3usb
-fno-lto
lib_extra_dirs = lib/lib_ssl, lib/libesp32
lib_ignore =
TTGO TWatch Library
NimBLE-Arduino
Micro-RTSP
epdiy
[env:tasmota32-AF] [env:tasmota32-AF]
extends = env:tasmota32_base extends = env:tasmota32_base

View File

@ -1,4 +1,4 @@
// Configuration // Configuration
#include "my_user_config.h" #include "my_user_config.h"
#include "tasmota_configurations.h" #include "include/tasmota_configurations.h"

View File

@ -0,0 +1,5 @@
# generate all haspmota tapp files
rm haspmota.tapp; zip -j -0 haspmota.tapp haspmota_core/*
rm haspmota_demo.tapp ; zip -j -0 haspmota_demo.tapp haspmota_demo/* haspmota_core/haspmota.be
cp haspmota.tapp ../haspmota
cp haspmota_demo.tapp ../haspmota

View File

@ -0,0 +1,7 @@
# start haspmota
# package with
# rm haspmota.tapp; zip -j -0 haspmota.tapp haspmota_core/*
import haspmota
# defer start to make sure all modules and tapp applications were loaded first
tasmota.set_timer(1000, /-> haspmota.start())

View File

@ -1,19 +1,19 @@
# OpenHASP compatibility module # HASPMota - OpenHASP compatibility module
# #
# use `import openhasp` and set the JSONL definitions in `pages.jsonl` # use `import haspmota` and set the JSONL definitions in `pages.jsonl`
# #
# As an optimization `0 #- lv.PART_MAIN | lv.STATE_DEFAULT -#` is replaced with `0` # As an optimization `0 #- lv.PART_MAIN | lv.STATE_DEFAULT -#` is replaced with `0`
# #
# rm openhasp.tapp; zip -j -0 openhasp.tapp openhasp_core/* # rm haspmota.tapp; zip -j -0 haspmota.tapp haspmota_core/*
################################################################################# #################################################################################
# How to solidify (needs an ESP32 with PSRAM) # How to solidify (needs an ESP32 with PSRAM)
#- #-
import path import path
path.remove("openhasp.bec") path.remove("haspmota.bec")
import solidify import solidify
var openhasp var haspmota
load('openhasp.be') load('haspmota.be')
var classes = [ var classes = [
"page", "obj", "scr", "page", "obj", "scr",
@ -23,12 +23,12 @@ var classes = [
"qrcode" "qrcode"
] ]
for c:classes for c:classes
solidify.dump(openhasp.OpenHASP.("lvh_"+c), true) solidify.dump(haspmota.HASPmota.("lvh_"+c), true)
end end
solidify.dump(openhasp, true) solidify.dump(haspmota, true)
-# -#
var openhasp = module("openhasp") var haspmota = module("haspmota")
################################################################################# #################################################################################
################################################################################# #################################################################################
@ -37,7 +37,7 @@ var openhasp = module("openhasp")
# Provide a mapping for virtual members # Provide a mapping for virtual members
# Stores the associated page and object id # Stores the associated page and object id
# #
# Adds specific virtual members used by OpenHASP # Adds specific virtual members used by HASPmota
################################################################################# #################################################################################
################################################################################# #################################################################################
class lvh_obj class lvh_obj
@ -62,7 +62,7 @@ class lvh_obj
# and the Berry or LVGL attribute to set # and the Berry or LVGL attribute to set
# #
# We try to map directly an attribute to the LVGL # We try to map directly an attribute to the LVGL
# Ex: OpenHASP attribute `w` is mapped to LVGL `width` # Ex: HASPmota attribute `w` is mapped to LVGL `width`
# #
# If mapping is null, we use set_X and get_X from our own class # If mapping is null, we use set_X and get_X from our own class
static _attr_map = { static _attr_map = {
@ -150,7 +150,7 @@ class lvh_obj
var _lv_obj # native lvgl object var _lv_obj # native lvgl object
var _lv_label # sub-label if exists var _lv_label # sub-label if exists
var _page # parent page object var _page # parent page object
var _action # value of the OpenHASP `action` attribute, shouldn't be called `self.action` since we want to trigger the set/member functions var _action # value of the HASPmota `action` attribute, shouldn't be called `self.action` since we want to trigger the set/member functions
#==================================================================== #====================================================================
# Rule engine to map value and text to rules # Rule engine to map value and text to rules
@ -242,10 +242,10 @@ class lvh_obj
end end
#==================================================================== #====================================================================
# init OpenHASP object from its jsonl definition # init HASPmota object from its jsonl definition
# #
# arg1: LVGL parent object (used to create a sub-object) # arg1: LVGL parent object (used to create a sub-object)
# arg2: `jline` JSONL definition of the object from OpenHASP template (used in sub-classes) # arg2: `jline` JSONL definition of the object from HASPmota template (used in sub-classes)
# arg3: (opt) LVGL object if it already exists and was created prior to init() # arg3: (opt) LVGL object if it already exists and was created prior to init()
#==================================================================== #====================================================================
def init(parent, page, jline, obj) def init(parent, page, jline, obj)
@ -323,7 +323,7 @@ class lvh_obj
# the callback avoids doing anything sophisticated in the cb # the callback avoids doing anything sophisticated in the cb
# defer the actual action to the Tasmota event loop # defer the actual action to the Tasmota event loop
# print("-> CB fired","self",self,"obj",obj,"event",event.tomap(),"code",event.code) # print("-> CB fired","self",self,"obj",obj,"event",event.tomap(),"code",event.code)
var oh = self._page._oh # openhasp global object var oh = self._page._oh # haspmota global object
var code = event.code # materialize to a local variable, otherwise the value can change (and don't capture event object) var code = event.code # materialize to a local variable, otherwise the value can change (and don't capture event object)
if self.action != "" && code == lv.EVENT_CLICKED if self.action != "" && code == lv.EVENT_CLICKED
# if clicked and action is declared, do the page change event # if clicked and action is declared, do the page change event
@ -507,7 +507,7 @@ class lvh_obj
#==================================================================== #====================================================================
# `text_font` # `text_font`
# #
# For OpenHASP compatiblity, default to "robotocondensed-latin1" # For HASPmota compatiblity, default to "robotocondensed-latin1"
# However we propose an extension to allow for other font names # However we propose an extension to allow for other font names
# #
# Arg1: (int) font size for `robotocondensed-latin1` # Arg1: (int) font size for `robotocondensed-latin1`
@ -1104,7 +1104,7 @@ class lvh_dropdown : lvh_obj
end end
end end
# direction needs a conversion from OpenHASP numbers and LVGL's # direction needs a conversion from HASPmota numbers and LVGL's
def set_direction(t) def set_direction(t)
# 0 = down, 1 = up, 2 = left, 3 = right # 0 = down, 1 = up, 2 = left, 3 = right
self._lv_obj.set_dir(self._dir[int(t)]) self._lv_obj.set_dir(self._dir[int(t)])
@ -1119,7 +1119,7 @@ class lvh_dropdown : lvh_obj
return -1 return -1
end end
# show_selected (bool) is a OpenHASP addition # show_selected (bool) is a HASPmota addition
# only meaningful if set to `true`, setting to false requires a call to `set_text` # only meaningful if set to `true`, setting to false requires a call to `set_text`
def set_show_selected(t) def set_show_selected(t)
if t if t
@ -1159,22 +1159,22 @@ class lvh_page
var _obj_id # (map) of `lvh_obj` objects by id numbers var _obj_id # (map) of `lvh_obj` objects by id numbers
var _page_id # (int) id number of this page var _page_id # (int) id number of this page
var _lv_scr # (lv_obj) lvgl screen object var _lv_scr # (lv_obj) lvgl screen object
var _oh # OpenHASP global object var _oh # HASPmota global object
# openhasp attributes for page are on item `#0` # haspmota attributes for page are on item `#0`
var prev, next, back # (int) id values for `prev`, `next`, `back` buttons var prev, next, back # (int) id values for `prev`, `next`, `back` buttons
#==================================================================== #====================================================================
# `init` # `init`
# #
# arg1: `page_number` (int) OpenHASP page id # arg1: `page_number` (int) HASPmota page id
# defaults to `1` if not specified # defaults to `1` if not specified
# page 0 is special, visible on all pages. Internally uses `layer_top` # page 0 is special, visible on all pages. Internally uses `layer_top`
# arg2: `oh` global OpenHASP monad object # arg2: `oh` global HASPmota monad object
# page_number: openhasp page number, defaults to `1` if not specified # page_number: haspmota page number, defaults to `1` if not specified
#==================================================================== #====================================================================
def init(page_number, oh) def init(page_number, oh)
import global import global
self._oh = oh # memorize OpenHASP parent object self._oh = oh # memorize HASPmota parent object
# if no parameter, default to page #1 # if no parameter, default to page #1
page_number = int(page_number) page_number = int(page_number)
@ -1283,17 +1283,17 @@ end
################################################################################# #################################################################################
# #
# class `OpenHASP` to initialize the OpenHASP parsing # class `HASPmota` to initialize the HASPmota parsing
# #
################################################################################# #################################################################################
# main class controller, meant to be a singleton and the only externally used class # main class controller, meant to be a singleton and the only externally used class
class OpenHASP class HASPmota
var dark # (bool) use dark theme? var dark # (bool) use dark theme?
var hres, vres # (int) resolution var hres, vres # (int) resolution
var scr # (lv_obj) default LVGL screen var scr # (lv_obj) default LVGL screen
var r16 # (lv_font) robotocondensed fonts size 16 var r16 # (lv_font) robotocondensed fonts size 16
# openhasp objects # haspmota objects
var lvh_pages # (list of lvg_page) list of pages var lvh_pages # (list of lvg_page) list of pages
var lvh_page_cur_idx # (int) current page index number var lvh_page_cur_idx # (int) current page index number
# regex patterns # regex patterns
@ -1376,8 +1376,8 @@ class OpenHASP
self.r16 = lv.font_embedded("montserrat", 14) # TODO what if does not exist self.r16 = lv.font_embedded("montserrat", 14) # TODO what if does not exist
end end
# set the theme for OpenHASP # set the theme for HASPmota
var th2 = lv.theme_openhasp_init(0, lv.color(0xFF00FF), lv.color(0x303030), self.dark, self.r16) var th2 = lv.theme_haspmota_init(0, lv.color(0xFF00FF), lv.color(0x303030), self.dark, self.r16)
self.scr.get_disp().set_theme(th2) self.scr.get_disp().set_theme(th2)
self.scr.set_style_bg_color(self.dark ? lv.color(0x000000) : lv.color(0xFFFFFF),0) # set background to white self.scr.set_style_bg_color(self.dark ? lv.color(0x000000) : lv.color(0xFFFFFF),0) # set background to white
# apply theme to layer_top, but keep it transparent # apply theme to layer_top, but keep it transparent
@ -1675,7 +1675,7 @@ class OpenHASP
return return
end end
# extract openhasp class, prefix with `lvh_`. Ex: `btn` becomes `lvh_btn` # extract haspmota class, prefix with `lvh_`. Ex: `btn` becomes `lvh_btn`
# extract parent # extract parent
var parent_lvgl var parent_lvgl
var parent_id = int(jline.find("parentid")) var parent_id = int(jline.find("parentid"))
@ -1746,20 +1746,20 @@ class OpenHASP
end end
end end
end end
openhasp.OpenHASP = OpenHASP haspmota.HASPmota = HASPmota
################################################################################# #################################################################################
# General module initilization # General module initilization
################################################################################# #################################################################################
# automatically instanciate the OpenHASP() monad # automatically instanciate the HASPmota() monad
# note: value is cached in the module cache # note: value is cached in the module cache
# and is returned whenever you call `import openhasp` again # and is returned whenever you call `import haspmota` again
# This means that the object is never garbage collected # This means that the object is never garbage collected
# #
openhasp.init = def (m) # `init(m)` is called during first `import openhasp` haspmota.init = def (m) # `init(m)` is called during first `import haspmota`
var oh = m.OpenHASP var oh = m.HASPmota
return oh() return oh()
end end
return openhasp return haspmota

View File

@ -1,5 +1,5 @@
# OpenHASP demo # OpenHASP demo
# rm openhasp_demo.tapp ; zip -j -0 openhasp_demo.tapp openhasp_demo/* openhasp_core/openhasp.be # rm haspmota_demo.tapp ; zip -j -0 haspmota_demo.tapp haspmota_demo/* haspmota_core/haspmota.be
if !tasmota.memory().contains("psram") if !tasmota.memory().contains("psram")
print("HSP: Error: OpenHASP demo requires PSRAM") print("HSP: Error: OpenHASP demo requires PSRAM")
@ -10,8 +10,8 @@ import lv_tasmota_log
import lv_tasmota_info import lv_tasmota_info
import lv_wifi_graph import lv_wifi_graph
import openhasp import haspmota
openhasp.start(false, "openhasp_demo.tapp#pages.jsonl") haspmota.start(false, "haspmota_demo.tapp#pages.jsonl")
var prev_day = -1 var prev_day = -1
def set_watch() def set_watch()

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -36,16 +36,16 @@
{"page":4,"comment":"---------- Page 4 - fan animation ----------"} {"page":4,"comment":"---------- Page 4 - fan animation ----------"}
{"id":0,"bg_color":"#0000A0","bg_grad_color":"#000000","bg_grad_dir":1,"text_color":"#FFFFFF"} {"id":0,"bg_color":"#0000A0","bg_grad_color":"#000000","bg_grad_dir":1,"text_color":"#FFFFFF"}
{"id":11,"obj":"img","src":"A:/openhasp_demo.tapp#noun_Fan_35097_140.png","auto_size":1,"w":140,"h":140,"x":50,"y":50,"image_recolor":"#0080FF","image_recolor_opa":150} {"id":11,"obj":"img","src":"A:/haspmota_demo.tapp#noun_Fan_35097_140.png","auto_size":1,"w":140,"h":140,"x":50,"y":50,"image_recolor":"#0080FF","image_recolor_opa":150}
{"id":12,"obj":"spinner","parentid":11,"x":7,"y":6,"w":126,"h":126,"bg_opa":0,"border_width":0,"line_width":7,"line_width1":7,"type":2,"angle":120,"speed":1000,"value_str":3,"value_font":24} {"id":12,"obj":"spinner","parentid":11,"x":7,"y":6,"w":126,"h":126,"bg_opa":0,"border_width":0,"line_width":7,"line_width1":7,"type":2,"angle":120,"speed":1000,"value_str":3,"value_font":24}
{"page":5,"comment":"---------- Page 5 - fancy watch ----------"} {"page":5,"comment":"---------- Page 5 - fancy watch ----------"}
{"id":0,"bg_color":"#000000","bg_grad_color":"#000000","bg_grad_dir":1,"text_color":"#000000"} {"id":0,"bg_color":"#000000","bg_grad_color":"#000000","bg_grad_dir":1,"text_color":"#000000"}
{"id":10,"obj":"img","src":"A:/openhasp_demo.tapp#watch_ren_back_240.png","x":40,"y":0,"w":240,"h":240} {"id":10,"obj":"img","src":"A:/haspmota_demo.tapp#watch_ren_back_240.png","x":40,"y":0,"w":240,"h":240}
{"id":11,"obj":"img","parentid":10,"src":"A:/openhasp_demo.tapp#watch_ren_hour_240.png","auto_size":1,"x":110,"y":45} {"id":11,"obj":"img","parentid":10,"src":"A:/haspmota_demo.tapp#watch_ren_hour_240.png","auto_size":1,"x":110,"y":45}
{"id":12,"obj":"img","parentid":10,"src":"A:/openhasp_demo.tapp#watch_ren_min_240.png","auto_size":1} {"id":12,"obj":"img","parentid":10,"src":"A:/haspmota_demo.tapp#watch_ren_min_240.png","auto_size":1}
{"id":13,"obj":"img","parentid":10,"src":"A:/openhasp_demo.tapp#watch_ren_sec_240.png","auto_size":1,"x":110,"y":10} {"id":13,"obj":"img","parentid":10,"src":"A:/haspmota_demo.tapp#watch_ren_sec_240.png","auto_size":1,"x":110,"y":10}
{"id":15,"obj":"label","parentid":10,"x":184,"y":112,"w":18,"h":16,"text":"","align":1,"text_font":"montserrat-14"} {"id":15,"obj":"label","parentid":10,"x":184,"y":112,"w":18,"h":16,"text":"","align":1,"text_font":"montserrat-14"}

View File

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 95 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -1,6 +1,6 @@
# pre-load widgets so future `import` will be already in memory # pre-load widgets so future `import` will be already in memory
# create tapp file with: # create tapp file with:
# rm rm openhasp_widgets.tapp; zip -j -0 openhasp_widgets.tapp openhasp_widgets/* # rm rm haspmota_widgets.tapp; zip -j -0 haspmota_widgets.tapp haspmota_widgets/*
import lv_tasmota_log import lv_tasmota_log
import lv_tasmota_info import lv_tasmota_info
import lv_wifi_graph import lv_wifi_graph

View File

@ -1,5 +0,0 @@
# generate all openhasp tapp files
rm openhasp.tapp; zip -j -0 openhasp.tapp openhasp_core/*
rm openhasp_demo.tapp ; zip -j -0 openhasp_demo.tapp openhasp_demo/* openhasp_core/openhasp.be
cp openhasp.tapp ../openhasp
cp openhasp_demo.tapp ../openhasp

View File

@ -1,7 +0,0 @@
# start openhasp
# package with
# rm openhasp.tapp; zip -j -0 openhasp.tapp openhasp_core/*
import openhasp
# defer start to make sure all modules and tapp applications were loaded first
tasmota.set_timer(1000, /-> openhasp.start())

View File

@ -0,0 +1,385 @@
#################################################################################
#
# class `cc2652_flasher`
#
# Flash libraries for CC2652: read, write, verify...
#
# The serial protocol requires the CC2652 to boot in BSL (bootloader) mode.
# On Sonoff Zigbee Bridge Pro, it requires to reset the MCU with DIO_8 low.
#
# When starting the flasher, normal zigbee operations are aborterd. Restarting
# normal zigbee functions requires a Tasmota restart.
#
# Required condiguration:
# - Zigbee Rx: must be configured as `Zigbee Rx` or `TCP Rx`
# - Zigbee Tx: must be configured as `Zigbee Tx` or `TCP Tx`
# - Zigbee Reset: must be configured as `Zigbee Rst - 1``
# - Zigbee BSL mode (low): must be configured as `Zigbee Rts - 2`
# For Sonoff Zibeee Bridge Pro: Rx=23 Tx=19 Rst-1=15 Rst-2=22
#
# How to use:
# - `import cc2652_flasher as cc`
# aborts all zigbee operations and configures the serial port
# Output: `FLH: cc2652_flasher rx=23 tx=19 rst=15 bsl=22`
#
# - `cc.start()` to start the flasher`
# restarts the CC2652 in BSL mode, and establishes connection
# Use `cc.start(true)` to enable debug verbose mode
#
# - `cc.ping()` sends a ping command and waits for ACK (does nothing)
#
# - `cc.cmd_get_chip_id()` returns the chip ID
#
# - `cc.flash_read(addr, len)` reads `len` bytes from address `addr``
# len must be a multiple of 4 and less or equal than 128 bytes
# Returns a bytes() object
#
# - `cc.flash_crc32(addr, len)` returns the CRC32 of a flash region
#
# - `cc.flash_write(addr, data)` writes bytes to the flash
# `data` is a bytes() buffer, its len must be a multiple of 4 and less or equal than 128
# This call does not erase the flash, so it must have been erased before.
# The bootloader checks that the bytes were correctly written, i.e. that
# the appropriate bits were changed from `1` to `0`.
# Chaning bits from `0` to `1` requires a flash erase.
#
# - `cc.flash_erase()` erase the entire flash.
# Use with caution. After the flash is erased, there is no valid application
# in flash so the MCU always starts in BSL bootloader mode until a valid
# app is flashed.
#
# - `cc.flash_dump_to_file(filename, addr, len)` dumps the CC2652 flash into a file
# `filename` is the output file in binary format, make sure there are 360KB free in filesystem.
# Dumping the complete file is done as follows (it takes 3 minutes during which Tasmota is unresponsive):
# `cc.dump_to_file("cc2652_dump.bin", 0x00000, 0x58000)`
#
#################################################################################
#- Example
import string
import cc2652_flasher as cc
cc.start()
cc.ping()
print(string.format("0x%08X", cc.cmd_get_chip_id()))
# output: 0x3202F000
# Dumping CC2652 flash into filesystem
# This takes 3 minutes during which Tasmota is unresponsive
#
import cc2652_flasher as cc
cc.start()
cc.flash_dump_to_file("cc2652_dump.bin", 0x00000, 0x58000)
-#
class cc2652_flasher
var ser # serial object
var debug # verbose logs?
var rx, tx, rst, bsl # GPIO numbers
# init - abort zigbee operations and starts the serial driver
# args are optional
def init(rx, tx, rst, bsl)
import string
self.debug = false
self.rx = (rx == nil) ? -1 : rx
self.tx = (tx == nil) ? -1 : tx
self.rst = (rst == nil) ? -1 : rst
self.bsl = (bsl == nil) ? -1 : bsl
#
if self.rx < 0 self.rx = gpio.pin(gpio.ZIGBEE_RX) end
if self.rx < 0 self.rx = gpio.pin(gpio.TCP_RX) end
if self.tx < 0 self.tx = gpio.pin(gpio.ZIGBEE_TX) end
if self.tx < 0 self.tx = gpio.pin(gpio.TCP_TX) end
if self.rst < 0 self.rst = gpio.pin(gpio.ZIGBEE_RST, 0) end
if self.bsl < 0 self.bsl = gpio.pin(gpio.ZIGBEE_RST, 1) end
print(string.format("FLH: cc2652_flasher rx=%i tx=%i rst=%i bsl=%i", self.rx, self.tx, self.rst, self.bsl))
# tasmota.log(string.format("FLH: cc2652_flasher rx=%i tx=%i rst=%i bsl=%i", self.rx, self.tx, self.rst, self.bsl), 3)
if self.rx < 0 || self.tx < 0 || self.rst < 0 || self.bsl < 0
raise "value_error", "cc2652_flasher unspecified GPIOs"
end
# stop all zigbee activity
import zigbee
zigbee.abort()
# good to go
self.ser = serial(self.rx, self.tx, 115200) # initialize UART serial port
end
# restart the MCU in BSL mode and establish communication
def start(debug)
if debug == nil debug = false end
self.debug = bool(debug)
self.reset_bsl()
#
# print("FLH: cc2652_flasher started")
end
#################################################################################
# Low level methods
#################################################################################
# restart MCU and enter BSL
#
# arg:
# ser: serial object
def reset_bsl()
self.ser.flush()
gpio.digital_write(self.bsl, 0) # trigger BSL
gpio.digital_write(self.rst, 0)
tasmota.delay(10) # wait 10ms
gpio.digital_write(self.rst, 1)
tasmota.delay(100) # wait 100ms
self.ser.write(bytes("5555")) # trigger auto baudrate detector
var ret = self.recv_raw(100)
if self.debug print("ret=", ret) end
if ret != bytes('CC')
raise "protocol_error"
end
end
# received buffer and give up if timeout
def recv_raw(timeout)
var due = tasmota.millis() + timeout
while !tasmota.time_reached(due)
if self.ser.available()
var b = self.ser.read()
if self.debug print("b:",b) end
while size(b) > 0 && b[0] == 0
b = b[1..]
end
return b
end
tasmota.delay(5) # check every 5ms
end
raise "timeout_error", "serial timeout"
end
# send simple ACK
def send_ack()
if self.debug print("send ACK") end
self.ser.write(bytes("00CC"))
end
# encode payload
static def encode_payload(b)
var checksum = 0
for i:0..size(b)-1
checksum = (checksum + b[i]) & 0xFF
end
var payload = bytes("0000")
payload[0] = size(b) + 2
payload[1] = checksum
payload += b
payload += bytes("00")
return payload
end
static def decode_ack(b)
# skip any 00 or CC bytes
while size(b) > 0 && b[0] == 0
b = b[1..]
end
if size(b) == 0 || b[0] != 0xCC
raise "serial_error", "missing ACK"
end
end
static def decode_payload(b)
# skip any 00 or CC bytes
while size(b) > 0 && (b[0] == 0 || b[0] == 0xCC)
b = b[1..]
end
# check buffer
var sz = b[0]
if size(b) < sz || sz < 2 raise "serial_error", "buffer too small" end
#
var payload = b[2..sz-1]
var checksum = 0
for i:0..size(payload)-1
checksum = (checksum + payload[i]) & 0xFF
end
if checksum != b[1] raise "serial_error", "invalid checksum received" end
return payload
end
# send
# args:
# b: logical bytes() to send
# no_response: true if ignore any response, or ignore to get a response
def send(b, no_response)
# compute
var payload = self.encode_payload(b)
if self.debug print("sending:", payload) end
self.ser.write(payload)
var ret = self.recv_raw(500)
if self.debug print("ret=", ret) end
if no_response == true
#ignore
self.decode_ack(ret)
return nil
else
payload = self.decode_payload(ret)
self.send_ack()
return payload
end
end
# Higher level functions
# 64 - COMMAND_RET_SUCCESS
# 65 - COMMAND_RET_UNKNOWN_CMD
# 66 - COMMAND_RET_INVALID_CMD
# 67 - COMMAND_RET_INVALID_ADR
# 68 - COMMAND_RET_FLASH_FAIL
def cmd_get_status()
var payload = self.send(bytes("23"))
return payload[0]
end
# Get the value of the 32-bit user ID from the AON_PMCTL JTAGUSERCODE register
def cmd_get_chip_id()
var payload = self.send(bytes("28"))
return payload.get(0, -4)
end
def cmd_memory_read(addr, len)
if (len % 4 != 0) raise "value_error", "len must be a multiple of 4" end
if len > 128 raise "value_error", "len is bigger than 128" end
var b = bytes("2A")
b.add(addr, -4)
b.add(1)
b.add(len/4)
return self.send(b)
end
# does not look to be implemented
# def cmd_memory_write(addr, data)
# var sz = size(data)
# if (sz % 4 != 0) raise "value_error", "len must be a multiple of 4" end
# if sz > 128 raise "value_error", "len is bigger than 128" end
# var b = bytes("2B")
# b.add(addr, -4)
# b.add(1)
# b += data
# print("cmd_memory_write",b)
# return self.send(b)
# end
def cmd_download(addr, sz)
if (sz % 4 != 0) raise "value_error", "len must be a multiple of 4" end
if sz > 128 raise "value_error", "len is bigger than 128" end
var b = bytes("21")
b.add(addr, -4)
b.add(sz, -4)
if self.debug print("cmd_download",b) end
return self.send(b, true)
end
def cmd_send_data(data)
var sz = size(data)
if (sz % 4 != 0) raise "value_error", "len must be a multiple of 4" end
if sz > 128 raise "value_error", "len is bigger than 128" end
var b = bytes("24")
b += data
if self.debug print("cmd_send_data",b) end
return self.send(b, true)
end
# WARNING: this command erases all of the customer-accessible flash sectors
# After this operation, since CCFG is not configured, the device will always reboot in BSL (bootloader) mode
# until CCFG is actually re-written
#
def cmd_bank_erase()
self.send(bytes("2C"), true)
end
# compute crc32 for a memory range
# repeat count if forced to 0x00000000 to read each location only once
def cmd_crc32(addr, len)
var b = bytes("27")
b.add(addr, -4)
b.add(len, -4)
b.add(0, -4) # repeat count = 0
return self.send(b)
end
#################################################################################
# High level methods
#################################################################################
def flash_read(addr, len)
return self.cmd_memory_read(addr, len)
end
def flash_crc32(addr, len)
return self.cmd_crc32(addr, len)
end
def flash_erase()
self.cmd_bank_erase()
end
# send ping
def ping()
self.send(bytes("20"), true)
end
# higher level
def flash_write(addr, data)
import string
var sz = size(data)
if (sz % 4 != 0) raise "value_error", "len must be a multiple of 4" end
if sz > 128 raise "value_error", "len is bigger than 128" end
var ret
ret = self.cmd_download(addr, size(data))
#print(">cmd_download", r)
var ack
ack = self.cmd_get_status()
if ack != 0x40 raise "serial_error", string.format("command failed: 0x%02X - 0x%06X (%i)", ack, addr, sz) end
ret = self.cmd_send_data(data)
ack = self.cmd_get_status()
if ack != 0x40 raise "serial_error", string.format("command failed: 0x%02X - 0x%06X (%i)", ack, addr, sz) end
end
# dump the flash into a bin file
def flash_dump_to_file(filename, addr, len)
var offset = addr
var f
try
f = open(filename,"w")
while len > 0
var b = self.cmd_memory_read(offset, 32)
f.write(b)
offset += 32
len -= 32
tasmota.yield()
end
except .. as e, m
if f != nil f.close() end
raise e, m
end
f.close()
end
end
return cc2652_flasher()

View File

@ -0,0 +1,5 @@
import cc2652_flasher as fl
fl.start(true)
print("CCFG=",fl.cmd_memory_read(0x57FD8,4))
print("crc32=",fl.cmd_crc32(0x0,0x30000)) # bytes('1598929A')

View File

@ -0,0 +1,133 @@
# parse intelhex file
#
# use: `import intelhex`
#
# This class allows to open and parse an Intel HEX format file.
# Basic checks are done to make sure that the format is valid.
#
# If anything goes wrong, an exception is raised.
#
# You provide 3 callbacks:
# - pre: method called when file was opened, but content not parsed - no arg, no return (raise an exception if error)
# this is a good place to erase flash before writing
# - cb: method called for each line containing data to be flashed. args(address:int, len_in_bytes:int, data:bytes, offset:int)
# address: full address in Flash (high and low are automatically combined)
# len_in_bytes: length of the data line, generally max 32 bytes
# data: bytes() object containing raw bytes
# offset: offset in bytes() object, skipping first bytes without needing to reallocate buffer
# - post: method called when all data was parsed, and before the file is closed - no arg, no return (raise an exception if error)
# this is a good place to check CRC32 or any checksum
#
class intelhex
var filename # filename of hex file
var f # file object
var file_parsed # was the file already parsed. It cannot be flashed if not previously parsed and validated
var file_validated # was the file already validated. It cannot be flashed if not previously parsed and validated
def init(filename)
self.filename = str(filename)
self.file_parsed = false
self.file_validated = true
end
def close()
if self.f != nil
self.f.close()
self.f = nil
end
end
# open the intelhex file and parse from start to end
#
# Args:
# - pre: method called when file was opened, but content not parsed - no arg, no return (raise an exception if error)
# this is a good place to erase flash before writing
# - cb: method called for each line containing data to be flashed. args(address:int, len_in_bytes:int, data:bytes, offset:int)
# address: full address in Flash (high and low are automatically combined)
# len_in_bytes: length of the data line, generally max 32 bytes
# data: bytes() object containing raw bytes
# offset: offset in bytes() object, skipping first bytes without needing to reallocate buffer
# - post: method called when all data was parsed, and before the file is closed - no arg, no return (raise an exception if error)
# this is a good place to check CRC32 or any checksum
#
def parse(pre, parse_cb, post)
try
self.f = open(self.filename, "rb")
self.file_parsed = true # we tried to parse
pre()
self.munch_line(parse_cb)
post() # validated is computed internally
except .. as e, m
self.close()
self.file_validated = false
raise e, m # re-raise
end
self.close()
end
# internally used, verify each line
def munch_line(parse_cb)
import crc
var crc_sum = crc.sum
var tas = tasmota
var yield = tasmota.yield
var offset_high = 0
var offset_low = 0
var b = bytes()
var b_get = b.get
var b_fromhex = b.fromhex
var self_f = self.f
var readline = self_f.readline
while true
yield(tas) # tasmota.yield() -- faster version
var line = readline(self_f) # self.f.readline()
# print(line)
if line == "" raise "value_error", "unexpected end of file" end
if line[0] != ":" continue end # ignore empty line or not starting with ':'
b = b_fromhex(b, line, 1) # b.fromhex(line, 1) # convert to bytes, avoid allocating a new object
var sz = b[0]
# check size
if size(b) != sz+5 raise "value_error", "invalid size for line: "+line end
var record_type = b[3]
# 00: low address + data
# 01: end of file
# 04: high address
if record_type != 0 && record_type != 1 && record_type != 4
raise "value_error", "unsupported record_type: "+str(record_type)
end
offset_low = b_get(b, 1, -2) # b.get(1,-2)
var checksum = crc_sum(b)
if checksum != 0 raise "value_error", "invalid checksum" end
if record_type == 1 break end # end of file
if record_type == 0
# data
var address = offset_high << 16 | offset_low # full address
#var data = b[4..-2] # actual payload
parse_cb(address, sz, b, 4)
# OK
# do whatever needed
import string
# print(string.format("addr=0x%06X len=0x%02X", address, sz))
elif record_type == 4
if offset_low != 0 raise "value_error", "offset_low not null for cmd 04" end
offset_high = b_get(b, 4, -2) # b.get(4,-2)
end
end
end
end
return intelhex

View File

@ -0,0 +1,176 @@
#################################################################################
#
# class `sonoff_zb_pro_flasher`
#
#################################################################################
class sonoff_zb_pro_flasher
static CCFG_address = 0x057FD8
static CCFG_reference = 0xC5FE08C5
#################################################################################
# Flashing from Intel HEX files
#################################################################################
var filename # filename of hex file
var f # file object
var file_checked # was the file already parsed. It cannot be flashed if not previously parsed and validated
var file_validated # was the file already validated. It cannot be flashed if not previously parsed and validated
var file_hex # intelhex object
var flasher # low-level flasher object (cc2652_flasher instance)
def init()
self.file_checked = false
self.file_validated = false
end
def load(filename)
import intelhex
if type(filename) != 'string' raise "value_error", "invalid file name" end
self.filename = filename
self.file_hex = intelhex(filename) # prepare the parser object
self.file_checked = false
self.file_validated = false
end
#################################################################################
# check that the HEX file is valid
# parse it completely once, and verify some values
#################################################################################
def check()
self.file_hex.parse(/ -> self._check_pre(),
/ address, len, data, offset -> self._check_cb(address, len, data, offset),
/ -> self._check_post()
)
end
#################################################################################
# Flash the firmware to the device
#
#################################################################################
def flash()
if !self.file_checked
print("FLH: firmware not checked, use `cc.check()`")
raise "flash_error", "firmware not checked"
end
if !self.file_validated
print("FLH: firmware not validated, use `cc.check()`")
raise "flash_error", "firmware not validated"
end
import cc2652_flasher # this stops zigbee and configures serial
self.flasher = cc2652_flasher
try
self.file_hex.parse(/ -> self._flash_pre(),
/ address, len, data, offset -> self._flash_cb(address, len, data, offset),
/ -> self._flash_post()
)
except .. as e, m
self.file_checked = false
self.file_validated = false
raise e, m
end
end
#################################################################################
# Dump firmware to local file
#
#################################################################################
def dump_to_file(filename)
import cc2652_flasher # this stops zigbee and configures serial
self.flasher = cc2652_flasher
print("FLH: Dump started (takes 3 minutes during which Tasmota is unresponsive)")
self.flasher.start()
self.flasher.ping()
self.flasher.flash_dump_to_file(filename, 0x000000, 0x58000)
print("FLH: Dump completed")
end
#################################################################################
# low-level
#################################################################################
def _flash_pre()
print("FLH: Flashing started (takes 5 minutes during which Tasmota is unresponsive)")
self.flasher.start()
self.flasher.ping()
# erase flash
self.flasher.flash_erase()
end
def _flash_post()
print("FLH: Flashing completed: OK")
var flash_crc = self.flasher.cmd_crc32(0x0,0x30000)
print("FLH: Flash crc32 0x000000 - 0x2FFFF = " + str(flash_crc));
# tasmota.log("FLH: Verification of HEX file OK", 2)
end
def _flash_cb(addr, sz, data, offset)
var payload = data[offset .. offset + sz - 1]
# final check
if size(payload) != sz raise "flash_error", "incomplete payload" end
self.flasher.flash_write(addr, payload)
end
# start verification (log only)
def _check_pre()
print("FLH: Starting verification of HEX file")
# tasmota.log("FLH: Starting verification of HEX file", 2)
end
# don't flash so ignore data
# check CCFG at location 0x57FD8 (4 bytes)
def _check_cb(addr, sz, data, offset)
# import string
# check than sz is a multiple of 4
if (sz % 4 != 0)
import string
raise "value_error", string.format("size of payload is not a mutliple of 4: 0x%06X", addr)
end
# print(string.format("> addr=0x%06X sz=0x%02X data=%s", addr, sz, data[offset..offset+sz-1]))
var CCFG = self.CCFG_address
if addr <= CCFG && addr+sz > CCFG+4
# we have CCFG in the buffer
var ccfg_bytes = data.get(4 + CCFG - addr, 4)
if ccfg_bytes != self.CCFG_reference
import string
raise "value_error", string.format("incorrect CCFG, BSL is not set to DIO_8 LOW (0x%08X expected 0x%08X)", ccfg_bytes, self.CCFG_reference) end
self.file_validated = true # if we are here, it means that the file looks correct
end
end
def _check_post()
print("FLH: Verification of HEX file OK")
# tasmota.log("FLH: Verification of HEX file OK", 2)
self.file_checked = true
end
end
return sonoff_zb_pro_flasher()
#-
# Flash local firmware
import sonoff_zb_pro_flasher as cc
cc.load("SonoffZBPro_coord_20220219.hex")
cc.check()
cc.flash()
-#
#-
# Dump local firmware
import sonoff_zb_pro_flasher as cc
cc.dump_to_file("SonoffZBPro_dump.bin")
-#

View File

@ -25,7 +25,7 @@ is located.
./brssl ta pki/ca.crt | sed -e '/br_x509/,+999 d' >local_ca_data.h ./brssl ta pki/ca.crt | sed -e '/br_x509/,+999 d' >local_ca_data.h
Then copy local_ca_data.h into the same directory as user_config_override. Then copy local_ca_data.h into directory include.
Add this line to user_config_override.h: Add this line to user_config_override.h:

View File

@ -25,7 +25,7 @@ is located.
./brssl ta pki/ca.crt | sed -e '1,/br_x509/ d' -e '/};/,+999 d' >local_ca_descriptor.h ./brssl ta pki/ca.crt | sed -e '1,/br_x509/ d' -e '/};/,+999 d' >local_ca_descriptor.h
Then copy local_ca_descriptor.h into the same directory as user_config_override. Then copy local_ca_descriptor.h into directory include.
Add this line to user_config_override.h: Add this line to user_config_override.h:

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