Commit Graph

52 Commits

Author SHA1 Message Date
Kuba Szczodrzyński
6bf549b104 [misc] Update .clang-format style 2025-05-28 15:50:18 +02:00
Hajo Noerenberg
2ea0066536 [common] Make Serial RX buffer size configurable, increase default to 256 bytes (#313)
* Make Serial RX buffer configurable and set default to 256 bytes

* Replace RingBuffer by SerialRingBuffer
2025-01-13 12:14:41 +01:00
Kuba Szczodrzyński
a9009a8cee [misc] Update .clang-format style 2024-09-05 16:36:55 +02:00
Luca Olivetti
41819f2fd6 [beken-72xx] Fix CHANGE interrupt logic (#290)
* fix CHANGE interrupt for beken-72xx

* Update cores/beken-72xx/arduino/src/wiring_irq.c

---------

Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
2024-09-05 14:46:42 +02:00
David Woodhouse
17043f634f [beken-72xx] Add IPv6 and lwIP 2.2.0 support (#292)
* mDNS: Fix build against LwIP 2.2.0

* Stop defining ip_addr_t when !CONFIG_IPV6

The only reason we had to do this is because we forgot to define LWIP_IPV4,
which is fixed in our LwIP port now, but keep it around for !CONFIG_IPV6
for now for builds against older LwIP.

* Allow returning IPv6 results from WiFiClass::hostByName()

* Add ipv6 and extra mDNS files for LwIP 2.2.0

* Add IPv6 support to BK72xx WifiSTA

Add an allLocalIPv6() method to return a *vector* of addresses, rather
than just one. It's not clear where the enableIpV6() and localIPv6()
methods came from; they don't seem to be part of the standard Arduino
class.

Eventually at least for ESPHome, I'd like to stop using these classes
and just let the ESPHome wifi component talk directly to LwIP. Or maybe
LibreTiny should offer an API compatible with the esp-idf one which is
a light wrapper around LwIP.

But short of a major refactor, this seems like a reasonable option.

* Update LwIP default to 2.2.0

* Apply suggestions from code review

---------

Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
2024-09-05 14:46:13 +02:00
devgs
e1c5761df9 [beken-72xx] Allow setting deep sleep wake-up pins as floating (#275)
According to guide `gpio_stay_*_map` are specifically there to prevent
pulling pins to a specific level and let them float during deep sleep.

https://docs.bekencorp.com/sdk_3.0.x/bk7238/build/en/latest/developer-guide/power_save/sleep_test.html

This allows any external low-power circuitry to change a pin level, as
required, to trigger the wake up

This requires changes in BDK and was implemented via fixup. Also, exposed
`gpio_stay_lo_map` parameter via `lt_deep_sleep_keep_floating_gpio` to
manage this configuration for pins in range P0-P31.
2024-09-05 14:45:48 +02:00
devgs
b255402659 [beken-72xx] Fix race condition when checking Wi-Fi SSID (#274)
* Fix for a race condition in WiFi connection loop

There seems to be the race between the event RW_EVT_STA_CONNECTED
and an actual valid SSID value returned by BDK. If even a small delay
is injected immediately after the event reception the valid value
becomes available. Without this fix, due to a polling nature of ESPHome
WiFiComponent::check_connecting_finished function may observe the
WiFiSTAConnectStatus::CONNECTED status but with an empty SSID value,
leading to `Incomplete connection.` warning and immediate attempt to
start another connection, while the current one was actually established.

* Fixed clang format conformance

* Apply suggestions from code review

* Update cores/beken-72xx/arduino/libraries/WiFi/WiFiEvents.cpp

Co-authored-by: Cossid <83468485+Cossid@users.noreply.github.com>

---------

Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
Co-authored-by: Cossid <83468485+Cossid@users.noreply.github.com>
2024-05-31 14:54:41 +02:00
Kuba Szczodrzyński
dfabfbb921 [beken-72xx] Increase MBEDTLS_ENTROPY_MAX_SOURCES 2024-05-18 13:50:25 +02:00
cap9qd
cf52021d38 [core] Split reboot reasons due to wakeup (#254)
* Updates to break out wakeup reasons.

Per https://github.com/libretiny-eu/libretiny/issues/234

* Update cores/common/base/api/lt_device.h

Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>

* fix clang-format

* Fix formatting of python files.

* Update lt_device.h

---------

Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
2024-02-25 18:45:22 +01:00
cap9qd
b78c9387a6 [beken-72xx] Fix duration rollover in deep sleep (#253) 2024-02-22 20:24:40 +01:00
Piotr Szulc
1d80b5fff7 [beken-72xx] Free list returned by wlan_sta_scan_result() (#226)
* Free list returned by wlan_sta_scan_result()

* scanAlloc improvements

There were a few things I didn't like about this function:
1) realloc() was called a bit too often.
2) if realloc() failed, the previous memory was not freed.
3) scanAlloc returned previous count or 255 on error. But there was no real check for error and 255 could've been used as index to null. I think it's better to simple return boolean.
4) scanAlloc was clearing memory only up to (and excluding) the new entries.

* Corrected clearing new entries in scanAlloc

* scanAlloc() now returns number of allocated items

* Fixed compilation issues related to goto.
2024-01-06 19:41:01 +01:00
Piotr Szulc
1e3a82f439 [beken-72xx] Improve ddev ADC support (#220) 2024-01-06 19:40:33 +01:00
Cossid
c90794e9f5 [beken-72xx] Allow connecting to specific BSSID if provided (#209)
* Switch to bk_wlan_start_sta_adv for specific bssid control.

* Allow split sta/adv_sta configs.

* Add wifi_mode back for regular STA mode.

* Fix apparent bug of setting null/empty wifi key.
Reset STA_ADV_CFG.dhcp_mode in reconnect, as it seems to not survive for some reason.
Do les _CFG setting in reconnect()

* Move all _CFG setting to begin()

* Fix dhcp_mode in STA_ADV_CFG.

* Remove no longer necessary dhcp_mode re-set.

* Formatting cleanups.

* Formatting.

* Update cores/beken-72xx/arduino/libraries/WiFi/WiFiSTA.cpp

* Apply suggestions from code review

---------

Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
2024-01-06 19:40:08 +01:00
Piotr Szulc
eed39c9cfb [beken-72xx] Pause PWM instead of stopping, track PWM state (#222)
* Pause PWM instead of stopping on duty cycle 0.

* Merged paused and stopped conditions
2023-12-16 13:57:47 +01:00
Piotr Szulc
7bd6d1d815 [beken-72xx] Fix stopping PWM, use pin-scoped PWM struct (#215)
* Fixed stopping PWM

* Clang-formatted as required

* Use separate memory block for each pwm pin
2023-12-08 19:20:41 +01:00
Kuba Szczodrzyński
27393e47c3 [beken-72xx] Initialize UART to fix deep sleep 2023-08-23 16:08:03 +02:00
Péter Sárközi
bd47772c04 [beken-72xx] Fix GPIO deep sleep wakeup edge (#159)
Manufacturer docs: https://docs-bekencorp-com.translate.goog/sdk_3.0.x/bk7238/html/developer-guide/power_save/sleep_test.html?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=hu&_x_tr_pto=wapp

Discussion: https://github.com/libretiny-eu/libretiny-esphome/pull/11
2023-08-23 16:06:55 +02:00
Péter Sárközi
93e0a5d066 [beken-72xx] Implement deep sleep (#140)
* Initial support code for Deep Sleep

* Global functions

* Remove unnecessary override

* clang-format

* Support for multiple pins

* Fix math

* Add a way to unset GPIOs

* Clang format

* Update brief

---------

Co-authored-by: Kuba Szczodrzyński <kuba@szczodrzynski.pl>
2023-07-13 18:00:14 +02:00
Kuba Szczodrzyński
e38e53bac0 [core] Split lt_api.c into separate units 2023-06-22 18:30:14 +02:00
Kuba Szczodrzyński
b38a4d5d46 [core] Add hardware peripheral availability defines 2023-06-21 17:02:48 +02:00
Kuba Szczodrzyński
73ede2838c Merge branch 'master' into family/ambz2 2023-06-20 18:53:46 +02:00
Kuba Szczodrzyński
273a86532b [beken-72xx] Add initial BK7231Q support, add WA2 board 2023-06-20 17:22:12 +02:00
Kuba Szczodrzyński
e7f35c584b [realtek-ambz2] Reuse Log UART for Serial 2023-05-31 12:37:34 +02:00
Kuba Szczodrzyński
4532c88873 [core] Add lt_set_debug_mode() function, update core types 2023-05-27 16:03:46 +02:00
Kuba Szczodrzyński
4dae304f51 [core] Add lt_get_device_mac() function 2023-05-25 20:43:00 +02:00
Kuba Szczodrzyński
c0cc602c9a [core] Add configure() for SerialClass 2023-05-25 14:29:35 +02:00
Kuba Szczodrzyński
e5f98ff41f [core] Refactor Wiring, use PinData for parameters 2023-05-24 22:01:05 +02:00
Kuba Szczodrzyński
3836ad20b7 [core] Refactor SerialClass as API library 2023-05-24 11:55:07 +02:00
Kuba Szczodrzyński
b073290989 [realtek-ambz2] Implement base C API 2023-05-23 19:54:00 +02:00
Stroe Andrei Catalin
219415174e [libs] Fix mDNS after a wifi disconnect / reconnect event (#112)
* [libs] Fix mDNS not responding when device disconnects / reconnects to wifi

* Minor bugfix

* Reworked mDNS fix

* Update LwIPmDNS.cpp
2023-05-01 21:44:03 +02:00
Kuba Szczodrzyński
d332315e7a [beken-72xx] Fix WiFi compilation issue 2023-04-28 21:24:41 +02:00
Péter Sárközi
882f58bae4 [beken-72xx] Implement WiFi powersave (#111)
* Rebase

* Clang-format
2023-04-28 17:21:49 +02:00
Kuba Szczodrzyński
461e4c6df0 [core] Prepare for project name change 2023-04-24 11:35:39 +02:00
Kuba Szczodrzyński
c5361a4738 [beken-72xx] Use realloc() based on malloc() 2023-04-22 18:29:52 +02:00
Kuba Szczodrzyński
070f2afd66 [core] Generate linker scripts based on flash layout 2023-03-25 20:44:19 +01:00
Kuba Szczodrzyński
c51bf0b7db [core] Migrate to GPIO-based pin numbering 2023-03-20 21:28:50 +01:00
Kuba Szczodrzyński
2e30d34021 [core] Update Arduino compatibility, fix MD5 library 2023-03-17 17:33:43 +01:00
Kuba Szczodrzyński
f69b4bea4f Merge branch 'master' into structure-refactor 2023-03-13 17:46:13 +01:00
Kuba Szczodrzyński
c3f12ab247 [core] Rename CPU and memory APIs 2023-03-12 14:11:16 +01:00
Kuba Szczodrzyński
fd1afea1bc [core] Refactor LT class into C methods 2023-03-10 19:08:55 +01:00
Kuba Szczodrzyński
6b92aac1da [core] Organize GCC compilation flags 2023-03-04 17:19:24 +01:00
Kuba Szczodrzyński
3113b387c3 [boards] Move docs generation to GitHub Actions 2023-03-04 16:56:49 +01:00
Kuba Szczodrzyński
e8c18f4e66 [core] Add common malloc() implementation 2023-03-04 11:12:55 +01:00
Kuba Szczodrzyński
8be5aeab59 [core] Update Arduino compatibility 2023-03-04 11:12:36 +01:00
Kuba Szczodrzyński
7f62f1e965 [beken-72xx] Make WiFiData private 2023-03-04 11:10:25 +01:00
Kuba Szczodrzyński
b51501fb21 [beken-72xx] Update Arduino core to new structure 2023-03-04 11:10:18 +01:00
Kuba Szczodrzyński
72ab64461c [builder] Add library queue to manage cloned environments 2023-03-04 11:10:05 +01:00
Kuba Szczodrzyński
26b393e059 [core] Replace usages of PIN_SERIAL_TX with HAS_SERIAL 2023-03-04 11:09:38 +01:00
Kuba Szczodrzyński
bc328657aa [beken-72xx] Update base core to new structure 2023-03-04 11:09:27 +01:00
Kuba Szczodrzyński
3413d70210 [core] Update PIO builders to new structure 2023-03-04 11:05:56 +01:00