Commit Graph

4052 Commits

Author SHA1 Message Date
45ff821a2f tuyamcu calib if non zero 1.18.126 2025-06-26 10:24:25 +02:00
b6e9862563 autoexecExamples.md: Use C++ higlighting (#1687)
* Run getcommands.js through a linter

* Use C++ higlighting for autoexec.bat examples
1.18.125
2025-06-24 17:08:35 +02:00
af37e093d0 bk7231u/bk7231s/bk7252/bk7252n/bk7231t alt. (#1680)
* bk7231u/bk7231t/bk7252 new sdk

* 7252n
2025-06-24 13:16:27 +02:00
e4791701c0 update readme - additional ESP32 info + platforms in development (#1685)
* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md
1.18.124
2025-06-23 16:12:31 +02:00
25e406a875 Test mqtt auth commands for https://github.com/openshwprojects/OpenBK7231T_App/issues/1657 2025-06-21 08:09:37 +02:00
1a22a074e0 self test for https://github.com/openshwprojects/OpenBK7231T_App/issues/1646 , but it passes on my side 2025-06-21 08:00:12 +02:00
841c8d86e4 update sdks 1.18.123 2025-06-20 10:16:48 +02:00
fac2cf081c w800 + berry (#1629)
* w800 + berry

* fix w600

* Update XR and makefile

* Berry cmake

* BL602 lfs test

* Update w800

* Fix

* W600 heap

* sensors & bl602

* bl602 delay_us
1.18.122
2025-06-20 09:35:00 +02:00
10e20f9a9b allow tuyamcu 0x04 (paired) state if no mqtt configured at all 1.18.121 2025-06-20 00:29:04 +02:00
d8acf9b735 force-update SDKs to latest verisons 1.18.120 2025-06-19 01:01:44 +02:00
25ed1bd135 merge old Max31855 driver (#1403)
* MAX31855

* tabl

* fx

* fx

* test

* try

* fx

* statics

* defines

* aa

* dd

* fx

* fixces

* Update obk_config.h
2025-06-19 00:55:08 +02:00
67b463458c Revert "Enable SHTX on BEKEN in obk_config.h (#1601)" (#1679)
This reverts commit 22a5667c30.
2025-06-19 00:47:02 +02:00
22a5667c30 Enable SHTX on BEKEN in obk_config.h (#1601) 2025-06-19 00:46:29 +02:00
5f9c0618b6 Update obk_config_sensors.h 1.18.119 2025-06-19 00:28:35 +02:00
b2ed2df150 sensors 2025-06-19 00:19:03 +02:00
f0ae60197c readd windows sleep for simulator 1.18.118 2025-06-19 00:08:15 +02:00
64df1f9d4c clearAllHandlers self testr 1.18.117 2025-06-19 00:04:10 +02:00
470acb4061 Merge branch 'main' of https://github.com/openshwprojects/OpenBK7231T_App 2025-06-18 23:58:02 +02:00
c849575a01 doc typo fix 2025-06-18 23:37:32 +02:00
468211422e readme typo 2025-06-18 23:36:57 +02:00
716cd7b87c Backlogdelay (#1677)
* backlog

* fx

* fx

* Update selftest_tasmota.c

* Update cmd_tasmota.c

* fxes

* delay_s

* PLATFORM_W800
1.18.116
2025-06-18 23:25:01 +02:00
273549950e tuyaMCU: introduce battery-powered device ack-delay (#1497)
This introduces a delay for sending the ACKs on battery powered TuyaMCU
sensors.

Rationale is to allow users to delay the return to sleep state. This is
useful when e.g. changing settings on the device.

Currently the device is sent back to sleep after the status has been
read and commited to MQTT. This can be less than 5 seconds of uptime.

Set this value to a sane default, which allows the device to retain
online for enough time for a user to change configuration.

Signed-off-by: David Bauer <mail@david-bauer.net>
1.18.115
2025-06-18 22:54:36 +02:00
0ae3f861af Run linux tests with UBSAN (#1664)
Undefined Behavior Sanitizer (UBSAN) [1] is a similar tool to ASAN,
useful for catching bugs related to undefined behavior.

All the problems it detects seem related to the bitshifts related to
flags. Here's a sample:

```
src/new_pins.c:2437:8: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
	#0 0x55a1b51011c1 in PIN_get_Relay_PWM_Count src/new_pins.c:2437
	#1 0x55a1b500389b in NewLED_InitCommands src/cmnds/cmd_newLEDDriver.c:1627
	#2 0x55a1b5150208 in Main_Init_BeforeDelay_Unsafe src/user_main.c:1151
	#3 0x55a1b51506e7 in Main_Init_Before_Delay src/user_main.c:1290
	#4 0x55a1b5150a05 in Main_Init src/user_main.c:1428
	#5 0x55a1b515902c in SIM_ClearOBK src/win_main.c:166
	#6 0x55a1b515a0fd in main src/win_main.c:534
	#7 0x7f1acfdabd8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
	#8 0x7f1acfdabe3f in __libc_start_main_impl ../csu/libc-start.c:392
	#9 0x55a1b4fd8eb4 in _start (/home/niteria/tmp/broken-realloc/OpenBK7231T_App/build/win_main+0x10ceb4)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior src/new_pins.c:2437:8 in
```

```
src/new_cfg.c:591:9: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
	#0 0x5629450eb803 in CFG_HasFlag src/new_cfg.c:591
	#1 0x562944ffdb53 in CMD_Init_Early src/cmnds/cmd_main.c:1007
	#2 0x562945153230 in Main_Init_BeforeDelay_Unsafe src/user_main.c:1162
	#3 0x5629451536e7 in Main_Init_Before_Delay src/user_main.c:1290
	#4 0x562945153a05 in Main_Init src/user_main.c:1428
	#5 0x56294515c02c in SIM_ClearOBK src/win_main.c:166
	#6 0x56294515d0fd in main src/win_main.c:534
	#7 0x7f9f5e12bd8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
	#8 0x7f9f5e12be3f in __libc_start_main_impl ../csu/libc-start.c:392
	#9 0x562944fdbeb4 in _start (/home/niteria/tmp/broken-realloc/OpenBK7231T_App/build/win_main+0x10ceb4)
```

```
src/httpserver/http_fns.c:369:8: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
	#0 0x560135601d44 in http_fn_index src/httpserver/http_fns.c:369
	#1 0x5601356185cb in HTTP_ProcessPacket src/httpserver/new_http.c:826
	#2 0x5601356a1e93 in Test_FakeHTTPClientPacket_Generic src/selftest/selftest_http.c:86
	#3 0x5601356a2002 in Test_FakeHTTPClientPacket_GET src/selftest/selftest_http.c:102
	#4 0x5601356b773f in Test_PIR src/selftest/selftest_pir.c:27
	#5 0x5601356d204b in Win_DoUnitTests src/win_main.c:171
	#6 0x5601356d3116 in main src/win_main.c:538
	#7 0x7f6911b2ad8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
	#8 0x7f6911b2ae3f in __libc_start_main_impl ../csu/libc-start.c:392
	#9 0x560135551eb4 in _start (/home/niteria/tmp/broken-realloc/OpenBK7231T_App/build/win_main+0x10ceb4)
```

Preexisting problems are suppressed in `platforms/linux/ubsan.suppressions`

[1] https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
2025-06-18 22:52:22 +02:00
b02068e485 docs refresh 1.18.114 2025-06-17 18:01:35 +02:00
901a43ceaf sefl test for tuyamcu calibration 1.18.113 2025-06-17 17:45:20 +02:00
e663cf5d30 allow TuyaMCU VCP calibration 1.18.112 2025-06-17 17:20:30 +02:00
6a027eb204 self test for click event with backlog and repeating event 1.18.111 2025-06-15 12:24:12 +02:00
2d27d1d7ed fix syntax 1.18.110 2025-06-04 12:26:07 +02:00
59f6d3549f RAW_V2C3P3 2025-06-04 12:25:07 +02:00
1e201d6be4 fix mem leaks in sim (#1665)
* Update drv_spiLED.c

* Update drv_spiLED.c

* Update drv_spiLED.c

* Update asan.suppressions

* Update drv_spiLED.c

* try

* mcu clear

* return cmd

* free alias leak
1.18.109
2025-06-01 10:06:09 +02:00
92ea9cd8ab Ability to run linux tests with AddressSanitizer (#1651)
* Ability to run linux tests with AddressSanitizer

This makes it possible to compile and run the tests with Address
Sanitizer (ASAN) [1].

The command is:
```
make -f custom.mk clean; ASAN=1 make -f custom.mk && ./build/win_main -runUnitTests 2
```

Building without ASAN works without change.

Address Sanitizer saves a lot of time debugging memory issues, for
example for a bug where we index in an array with negative index it
gives this nice error message:
```
=================================================================
==2532658==ERROR: AddressSanitizer: global-buffer-overflow on address 0x5642389c5e37 at pc 0x564237e67492 bp 0x7fff17726e50 sp 0x7fff17726e40
READ of size 1 at 0x5642389c5e37 thread T0
    #0 0x564237e67491 in CHANNEL_GetType src/new_cfg.c:427
    #1 0x564237dfc933 in TuyaMCU_ApplyMapping src/driver/drv_tuyaMCU.c:1126
    #2 0x564237dff92f in TuyaMCU_ParseStateMessage src/driver/drv_tuyaMCU.c:1632
    #3 0x564237e019fa in TuyaMCU_ProcessIncoming src/driver/drv_tuyaMCU.c:1977
    #4 0x564237e027ee in TuyaMCU_RunReceive src/driver/drv_tuyaMCU.c:2178
    #5 0x564237e02dc2 in TuyaMCU_RunFrame src/driver/drv_tuyaMCU.c:2335
    #6 0x564237dd2ce6 in DRV_RunQuickTick src/driver/drv_main.c:536
    #7 0x564237ec4037 in QuickTick src/user_main.c:946
    #8 0x564237eca8a5 in Sim_RunFrame src/win_main.c:106
    #9 0x564237eca993 in Sim_RunFrames src/win_main.c:134
    #10 0x564237ebce4a in Test_TuyaMCU_Basic src/selftest/selftest_tuyaMCU.c:369
    #11 0x564237ecab1f in Win_DoUnitTests src/win_main.c:194
    #12 0x564237ecba57 in main src/win_main.c:535
    #13 0x7fb55312ed8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #14 0x7fb55312ee3f in __libc_start_main_impl ../csu/libc-start.c:392
    #15 0x564237cb16b4 in _start (/home/niteria/tmp/broken-realloc/OpenBK7231T_App/build/win_main+0xcf6b4)

0x5642389c5e37 is located 51 bytes to the right of global variable 'stat_deduper_culled_tooFast' defined in 'src/mqtt/new_mqtt_deduper.c:40:12' (0x5642389c5e00) of size 4
0x5642389c5e37 is located 9 bytes to the left of global variable 'g_mutex' defined in 'src/mqtt/new_mqtt_deduper.c:42:26' (0x5642389c5e40) of size 4
SUMMARY: AddressSanitizer: global-buffer-overflow src/new_cfg.c:427 in CHANNEL_GetType
Shadow bytes around the buggy address:
  0x0ac8c7130b70: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0ac8c7130b80: 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0ac8c7130b90: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0ac8c7130ba0: 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9
  0x0ac8c7130bb0: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
=>0x0ac8c7130bc0: 04 f9 f9 f9 f9 f9[f9]f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0ac8c7130bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac8c7130be0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac8c7130bf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac8c7130c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac8c7130c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==2532658==ABORTING
```

[1] https://github.com/google/sanitizers/wiki/addresssanitizer

* disable tests broken on linux

* add a suppression file for known leaks

* attempt at adding an ASAN workflow

* fix autogen

* Update workflow.yaml

---------

Co-authored-by: openshwprojects <85486843+openshwprojects@users.noreply.github.com>
2025-05-31 14:27:02 +02:00
b1b41f4a66 channel type - Percent 1.18.108 2025-05-31 01:18:37 +02:00
d6f7678dc6 TCL AC driver progress + LowMidHigh etc channels HA discovery
* Buzzer

* Update obk_config.h

* Display

* uart test stub

* unfinished TCL_DoDiscovery

* ha

* Update drv_tclAC.c

* ha mode send

* unfinished not working

* Update drv_tclAC.c

* Update hass.h

* better discovery

* Update obk_config.h
1.18.107
2025-05-30 16:10:36 +02:00
a2c9d19147 Fix a memory leak in http_fns.c (#1653) 1.18.106 2025-05-26 17:35:45 +02:00
cbf0d459fd Fix tests on linux (#1640)
The tests were segfaulting on linux, I don't know how they work on
Windows, perhaps casting `void*` to `int` happens to work there.
Generally it's not portable.

Berry has a dedicated `comptr` type, so let's use that and be portable.

Also makes `run_closure` handle arbitrary number of arguments, see
https://berry.readthedocs.io/en/latest/source/en/Chapter-5.html#function-with-variable-number-of-arguments-vararg
for docs.

Test Plan:
* CI
* make -f custom.mk, ./build/win_main -runUnitTests 2
2025-05-25 18:12:56 +02:00
e1456181e8 berry workaround for broken realloc on OpenBK7231N (#1649)
* berry workaround for broken realloc on OpenBK7231N

I ran `addRepeatingEvent 1 -1 testRealloc 100` on a OpenBK7231N device
and it failed. This is the same problem as #1563.

This might be related to mysterious crashes I was getting while
importing big modules like this:
`addRepeatingEvent 1 1 berry import modulename`.

* fix
1.18.105
2025-05-25 17:44:06 +02:00
46fe6736ca Fix out-of-bounds access on g_cfg.pins.channelTypes (#1652)
This place expected -1 for "unmapped", but -999 can come from this line:
fe51ee8f47/src/driver/drv_tuyaMCU.c (L883)

This was detected with ASAN (#1651), the error message:
```
=================================================================
==2532658==ERROR: AddressSanitizer: global-buffer-overflow on address 0x5642389c5e37 at pc 0x564237e67492 bp 0x7fff17726e50 sp 0x7fff17726e40
READ of size 1 at 0x5642389c5e37 thread T0
    #0 0x564237e67491 in CHANNEL_GetType src/new_cfg.c:427
    #1 0x564237dfc933 in TuyaMCU_ApplyMapping src/driver/drv_tuyaMCU.c:1126
    #2 0x564237dff92f in TuyaMCU_ParseStateMessage src/driver/drv_tuyaMCU.c:1632
    #3 0x564237e019fa in TuyaMCU_ProcessIncoming src/driver/drv_tuyaMCU.c:1977
    #4 0x564237e027ee in TuyaMCU_RunReceive src/driver/drv_tuyaMCU.c:2178
    #5 0x564237e02dc2 in TuyaMCU_RunFrame src/driver/drv_tuyaMCU.c:2335
    #6 0x564237dd2ce6 in DRV_RunQuickTick src/driver/drv_main.c:536
    #7 0x564237ec4037 in QuickTick src/user_main.c:946
    #8 0x564237eca8a5 in Sim_RunFrame src/win_main.c:106
    #9 0x564237eca993 in Sim_RunFrames src/win_main.c:134
    #10 0x564237ebce4a in Test_TuyaMCU_Basic src/selftest/selftest_tuyaMCU.c:369
    #11 0x564237ecab1f in Win_DoUnitTests src/win_main.c:194
    #12 0x564237ecba57 in main src/win_main.c:535
    #13 0x7fb55312ed8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #14 0x7fb55312ee3f in __libc_start_main_impl ../csu/libc-start.c:392
    #15 0x564237cb16b4 in _start (/home/niteria/tmp/broken-realloc/OpenBK7231T_App/build/win_main+0xcf6b4)

0x5642389c5e37 is located 51 bytes to the right of global variable 'stat_deduper_culled_tooFast' defined in 'src/mqtt/new_mqtt_deduper.c:40:12' (0x5642389c5e00) of size 4
0x5642389c5e37 is located 9 bytes to the left of global variable 'g_mutex' defined in 'src/mqtt/new_mqtt_deduper.c:42:26' (0x5642389c5e40) of size 4
SUMMARY: AddressSanitizer: global-buffer-overflow src/new_cfg.c:427 in CHANNEL_GetType
Shadow bytes around the buggy address:
  0x0ac8c7130b70: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0ac8c7130b80: 00 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0ac8c7130b90: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0ac8c7130ba0: 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9 f9 f9
  0x0ac8c7130bb0: 04 f9 f9 f9 f9 f9 f9 f9 04 f9 f9 f9 f9 f9 f9 f9
=>0x0ac8c7130bc0: 04 f9 f9 f9 f9 f9[f9]f9 04 f9 f9 f9 f9 f9 f9 f9
  0x0ac8c7130bd0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac8c7130be0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac8c7130bf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac8c7130c00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0ac8c7130c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==2532658==ABORTING
```
2025-05-25 17:42:08 +02:00
5899b0c7e5 CSE stub (unfinished)
* test1

* Update CMakeLists.txt

* Update drv_cse7761.c

* tr

* dbg

* Update hal_uart_espidf.c

* Update hal_uart_espidf.c

* Update hal_uart_espidf.c

* cmnt
1.18.104
2025-05-23 10:23:01 +02:00
529bf00170 cse test stub 1.18.103 2025-05-22 12:33:13 +02:00
d07c72a0ca AC TCL driver - part 1
* ac t1

* test

* fx

* fx

* p

* build_set_cmd

* try enable

* makefile

* make

* header

* self test

* parsing - not tested

* rename for easier testing

* add src

* print len

* parity

* FIX PARITY - 2

* SwingH and SwingV

* w

* files

* Update drv_tclAC.c

* display vals

* few berry tests

* disable
1.18.102
2025-05-18 18:24:21 +02:00
acd46ad682 add PIR driver
* tt

* Update selftest_berry.c

* Update obk_config.h

* some more fixes

* fixes

* IOR_PWM_ScriptOnly_n

* fx

* Update OpenBeken.mk

* disable
1.18.101
2025-05-16 10:07:38 +02:00
5ea78582e0 fix header 1.18.100 2025-05-15 23:55:04 +02:00
4196afda4d unfinished PIR code 2025-05-15 18:08:53 +02:00
fe51ee8f47 Update hal_flashConfig_xr809.c 1.18.99 2025-05-06 09:50:27 +02:00
754aca5c01 BL602 powersave workaround (#1630) 1.18.98 2025-05-04 09:54:59 +02:00
3597eec24d Remove powersave for BL602 (#1628)
Apparently breaks connecting to wifi. Maybe something like ln882 should be done
1.18.97
2025-05-03 12:32:21 +02:00
4cc458f014 update OpenBL602 and XR872 SDKs to latest commits 1.18.96 2025-05-02 15:31:39 +02:00
5916fbd8a7 Update BL602 code to work with latest sdk. (#1487)
* Support new BL602 SDK

* Update .gitmodules

---------

Co-authored-by: openshwprojects <85486843+openshwprojects@users.noreply.github.com>
1.18.95
2025-05-02 14:42:14 +02:00
0274993d7f Update OpenXR872 1.18.94 2025-04-25 17:26:25 +02:00
162e4df354 Update workflow.yaml 1.18.93 2025-04-23 00:28:35 +02:00