Compare commits

..

452 Commits

Author SHA1 Message Date
Jiang Jiang Jian
d9f9b7d8ed Merge branch 'bugfix/fix_tbtt_timming_error_esp32' into 'release/v5.0'
bugfix: fix tbtt timing error esp32(v5.0)

See merge request espressif/esp-idf!38981
2025-05-12 17:53:11 +08:00
sibeibei
0687165375 Revert "fix(esp32): Fixed qa program may fail issue when cpu 240m (v5.0)"
This reverts commit 453f78e011.
2025-05-08 17:39:10 +08:00
Jiang Jiang Jian
84801979ff Merge branch 'feat/pawr_bugfix_v5.0' into 'release/v5.0'
fix(nimble): Fix sync handle assignment for pawr connection (v5.0)

See merge request espressif/esp-idf!38506
2025-05-07 14:12:11 +08:00
Jiang Jiang Jian
c91fa88602 Merge branch 'feat/spi_ble_log_improvement_v5.0' into 'release/v5.0'
feat(ble): Improved SPI BLE Log functionality (v5.0)

See merge request espressif/esp-idf!38737
2025-05-07 10:12:20 +08:00
Jiang Jiang Jian
6dcddbc94d Merge branch 'docs/update_ble_feature_support_status_v5.0' into 'release/v5.0'
Docs: update ble feature support status (v5.0)

See merge request espressif/esp-idf!37087
2025-05-07 10:11:02 +08:00
Jiang Jiang Jian
d1b2ad339d Merge branch 'fix/ble_mesh_trans_pending_fix_v5.0' into 'release/v5.0'
fix(ble_mesh): remove tx pending assert (v5.0)

See merge request espressif/esp-idf!38641
2025-05-07 10:10:26 +08:00
Jiang Jiang Jian
ae32f091fc Merge branch 'fix/multi_core_race_cond_in_panic_handler_v5.0' into 'release/v5.0'
fix(panic_handler): Prevent race condition in panic handler (v5.0)

See merge request espressif/esp-idf!38668
2025-05-07 10:09:57 +08:00
weiyuhan
8e363d1a0b docs(ble): Removed the Bluetooth SIG Qualification information for ESP32C6 and ESP32C5 on 5.0 2025-05-05 15:21:46 +08:00
Wei Yu Han
6fdad98ece Updated BLE feature status
(cherry picked from commit 6a584e9698)

Co-authored-by: weiyuhan <weiyuhan@espressif.com>
2025-05-05 15:21:46 +08:00
Island
54ec0a99f1 Merge branch 'bugfix/fix_cble50y25_207_v5.0' into 'release/v5.0'
Fixed MIC error disconnection when pairing with iOS devices on ESP32-C3 and ESP32-S3(7dcd455) (v5.0)

See merge request espressif/esp-idf!38760
2025-04-30 11:17:56 +08:00
chenjianhua
790859ef1a fix(bt): Update bt lib for ESP32-C3 and ESP32-S3(edf923e)
- Fixed ble lib linkage issue
2025-04-28 12:15:29 +08:00
chenjianhua
e79ae69a92 fix(bt): Update bt lib for ESP32-C3 and ESP32-S3(edf923e)
- Fixed MIC error disconnection when pairing with iOS devices
2025-04-28 12:14:46 +08:00
Zhou Xiao
80b64e21a7 feat(ble): Improved SPI BLE Log functionality
* Added checksum for every frame
* Added SPI slave transaction interval workaround
* Added SPI tx done isr issue workaround
* Turned buffer flush to a menuconfig and disabled by default
* Modified packet loss write operation and trigger condition
* Optimized buffer append efficiency for controller ISR
2025-04-25 16:03:08 +08:00
Sudeep Mohanty
a896bc5b7d fix(panic_handler): Prevent race condition in panic handler
This commit updates all RTC WDT contexts to be local instead of global
to avoid race conditions when both cores enter the panic handler
simultaneously.
2025-04-23 15:13:35 +02:00
luoxu
8493d2b42b fix(ble_mesh): remove tx pending assert 2025-04-23 14:20:15 +08:00
Jiang Jiang Jian
a7d6b07851 Merge branch 'bugfix/fix_not_update_country_in_beacon' into 'release/v5.0'
fix(wifi): fix not update country in beacon(backport v5.0)

See merge request espressif/esp-idf!38585
2025-04-22 10:19:07 +08:00
Jiang Jiang Jian
c58641e9d0 Merge branch 'fix/s2_adc_cali_loss_resolution_v5.0' into 'release/v5.0'
fix(adc): fix s2 cali loss resolution (v5.0)

See merge request espressif/esp-idf!38599
2025-04-22 10:12:34 +08:00
Jiang Jiang Jian
a5ecb8a5dc Merge branch 'bugfix/fix_some_ble_bugs_2503_v5.0' into 'release/v5.0'
Bugfix/fix some ble bugs 2503 (v5.0)

See merge request espressif/esp-idf!38287
2025-04-22 10:08:08 +08:00
Jiang Jiang Jian
1779887800 Merge branch 'bugfix/fix_some_ble_bugs_250331_esp32c3_v5.0' into 'release/v5.0'
Fixed some BLE bugs 250331 on esp32c3 (v5.0)

See merge request espressif/esp-idf!38576
2025-04-21 21:45:24 +08:00
gaoxu
aac8132912 fix(adc): fix s2 cali loss resolution 2025-04-21 19:48:05 +08:00
zhanghaipeng
287f45ad8b fix(ble/bluedroid): Fix potential uint32_t overflow in BLE btu_start_timer 2025-04-21 19:15:09 +08:00
Zhang Hai Peng
3a16029484 fix(ble/bluedrooid): Fixed memory leak issue when deinit the host
(cherry picked from commit 6becf74cbb)

Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
2025-04-21 16:28:50 +08:00
Zhang Hai Peng
1660aa1a84 fix(ble/bluedroid): Fix missing event reporting in esp_ble_create_sc_oob_data
(cherry picked from commit f291725936)

Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
2025-04-21 16:28:50 +08:00
Zhang Hai Peng
be5aa8712b fix(ble/bluedroid): Fixed BLE crash when disable bluedroid host
(cherry picked from commit 9dfa6ab0e9)

Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
2025-04-21 16:28:50 +08:00
yinqingzhao
8ab3480ea9 fix(wifi): fix not update country in beacon 2025-04-21 16:07:21 +08:00
Chen Jian Hua
f726c1d454 fix(bt): Update bt lib for ESP32-C3 and ESP32-S3(a684dd5)
- Fixed clear legacy adv error when adv not exist
- Disable anonymous extended adv reporting
- Fixed BLE assert lld_adv.c 2992
- Fixed heap assert due to adv data buffer double freeing
- Fixed BLE 0x08 disconnect when the win size is greater than half of the conn interval


(cherry picked from commit 4602665e5d)

Co-authored-by: chenjianhua <chenjianhua@espressif.com>
2025-04-21 14:33:18 +08:00
Jiang Jiang Jian
36a8ce4896 Merge branch 'fix/blemesh25-92_v5.0' into 'release/v5.0'
fix(ble_mesh): fixed issues with decrypt failed when resending messages (v5.0)

See merge request espressif/esp-idf!38556
2025-04-21 14:07:47 +08:00
Jiang Jiang Jian
77819073b7 Merge branch 'bugfix/tsens_read_abnormal_value_v5.0' into 'release/v5.0'
fix: tsens read abnormal value in esp32c2eco4(backport v5.0)

See merge request espressif/esp-idf!38553
2025-04-21 11:40:30 +08:00
Jiang Jiang Jian
26e70c3969 Merge branch 'bugfix/fix_phy_data_partition_restoring_default_fails_issue_v5.0' into 'release/v5.0'
fix(phy): fix phy data partition restoring default fails issue(Backport v5.0)

See merge request espressif/esp-idf!38552
2025-04-21 11:06:31 +08:00
Jiang Jiang Jian
0e567403ba Merge branch 'fix/revert_esp32s2_phy_lib_v50' into 'release/v5.0'
fix(phy): revert esp32s2 libphy txrx time change

See merge request espressif/esp-idf!38554
2025-04-19 15:04:36 +08:00
Jiang Jiang Jian
02f3948a84 Merge branch 'bugfix/pmkid_password_mismatch_regression_v5.0' into 'release/v5.0'
fix(wifi): Avoid writing to NVS if station configuration is not changed (Backport v5.0)

See merge request espressif/esp-idf!38466
2025-04-19 14:44:17 +08:00
Sarvesh Bodakhe
455df4ff02 fix(wifi): Avoid writing to NVS if station configuration is not changed
Fixes the regression introduced by e93ddfd739
2025-04-19 10:20:16 +05:30
Luo Xu
9e944c86a5 fix(ble_mesh): fixed issues with decrypt failed when resending messages
(cherry picked from commit 4803cea3cc)

Co-authored-by: luoxu <luoxu@espressif.com>
2025-04-18 20:23:26 +08:00
Jiang Jiang Jian
5082a268a6 Merge branch 'bugfix/crypto_reset_on_exit_v5.0' into 'release/v5.0'
fix(esp_system): reset crypto peripherals before device restart (v5.0)

See merge request espressif/esp-idf!38480
2025-04-18 19:27:10 +08:00
Jiang Jiang Jian
1303c62078 Merge branch 'bugfix/fix_bt_access_ext_mem_in_intr_v5.0' into 'release/v5.0'
fix(bt/controller): update libbtdm_app.a (backport v5.0)

See merge request espressif/esp-idf!38550
2025-04-18 19:21:40 +08:00
wangtao@espressif.com
ee271a44af fix(phy): revert esp32s2 libphy txrx time change 2025-04-18 19:16:13 +08:00
sibeibei
aeeccb7a7c fix: tsens read abnormal value in esp32c2eco4 2025-04-18 19:05:27 +08:00
muhaidong
26d9925393 fix(phy): fix phy data partition restoring default fails issue
Closes https://github.com/espressif/esp-idf/issues/14698
2025-04-18 17:49:16 +08:00
linruihao
1d6002c6c2 fix(bt/controller): Fixed access external memory in isr context 2025-04-18 15:56:48 +08:00
Jin Cheng
8bd0b2dcff fix(bt/controller): update libbtdm_app.a
- fixed errors in the coexistance of ACL and SCO
- fixed dynamic priority config error in dual mode
2025-04-18 15:56:31 +08:00
Jiang Jiang Jian
ef9dbc787b Merge branch 'fix/fix_wifi_connect_mem_leakage_v50' into 'release/v5.0'
fix(wifi): fix wifi connect mem leakage v50

See merge request espressif/esp-idf!38488
2025-04-18 14:43:32 +08:00
Island
5fe7b4c80f Merge branch 'change/ble_update_lib_20250414_v5.0' into 'release/v5.0'
change(ble): [AUTO_MR] 20250414 - Update ESP BLE Controller Lib (v5.0)

See merge request espressif/esp-idf!38490
2025-04-18 11:09:18 +08:00
Jiang Jiang Jian
2d8537a8f9 Merge branch 'bugfix/no_write_evt_report_v5.0' into 'release/v5.0'
fix(bt): fixed spp not reporting write event(v5.0)

See merge request espressif/esp-idf!38462
2025-04-17 15:38:55 +08:00
Abhinav Kudnar
18f69e8ef5 fix(nimble): Fix sync handle assignment for pawr connection 2025-04-17 14:33:15 +08:00
Zhou Xiao
3673c57cdd fix(ble): remove null pointer assert in npl event deinit
(cherry picked from commit ece108c0bf)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2025-04-17 14:05:22 +08:00
Zhou Xiao
fb1267a01a change(ble): bugs fixed on spi ble log
* removed spi master in iram select for flash only firmware
* fixed memory issue in transaction init function
* fixed memory issue in transaction deinit function
2025-04-17 14:05:22 +08:00
cjin
4124ce77aa feat(ble): use new section for ble sleep on ESP32-C2 2025-04-17 14:05:22 +08:00
Jiang Jiang Jian
43005566ac Merge branch 'fix/some_issues_in_bt_controller_v5.0' into 'release/v5.0'
fix(bt): fixed some issues in bt controller(backport v5.0)

See merge request espressif/esp-idf!38446
2025-04-17 12:50:17 +08:00
Jiang Jiang Jian
2122c077de Merge branch 'change/allow_keep_sar_poweron_in_light_sleep_v5.0' into 'release/v5.0'
change(esp_hw_support): allow sar power keep on during lightsleep (v5.0)

See merge request espressif/esp-idf!38427
2025-04-17 11:12:38 +08:00
Zhou Xiao
3adf9fd579 change(ble): [AUTO_MR] Update lib_esp32c2 to fca2b9ea
(cherry picked from commit 09467baed0)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2025-04-17 10:53:37 +08:00
wangtao@espressif.com
22bc32930c fix(wifi): fix wifi connect mem leakage 2025-04-17 10:45:46 +08:00
Jiang Jiang Jian
152eb37307 Merge branch 'fix/fix_incorrect_ota_address_assignment_v5.0' into 'release/v5.0'
fix(nimble): Fix incorrect OTA address type assignment (v5.0)

See merge request espressif/esp-idf!38352
2025-04-17 10:37:34 +08:00
Mahavir Jain
f22fd00f93 fix(esp_system): reset crypto peripherals before device restart
This change addresses a rare but critical issue observed on certain
ESP32-C3 and ESP32-S3 devices, where secure boot verification
intermittently fails due to improper cleanup of crypto peripherals
during a restart.

Background – Restart Behavior in IDF
------------------------------------
In ESP-IDF, when the device restarts (via `esp_restart()` or due to a
panic/exception), a partial peripheral reset is performed followed by a
CPU reset. However, until now, crypto-related peripherals were not
included in this selective reset sequence.

Problem Scenario
----------------
If a restart occurs while the application is in the middle of a bignum
operation (i.e., using the MPI/Bignum peripheral), the ROM code may
encounter an inconsistent peripheral state during the subsequent boot.
This leads to transient RSA-PSS secure boot verification failures.

Following such a failure, the ROM typically triggers a full-chip reset
via the watchdog timer (WDT). This full reset clears the crypto
peripheral state, allowing secure boot verification to succeed on the
next boot.

Risk with Aggressive Revocation
-------------------------------
If secure boot aggressive revocation is enabled (disabled by default in
IDF), this transient verification failure could mistakenly lead to
revocation of the secure boot digest.

If your product configuration has aggressive revocation enabled,
applying this fix is strongly recommended.

Frequency of Occurrence
-----------------------
The issue is rare and only occurs in corner cases involving
simultaneous use of the MPI peripheral and an immediate CPU reset.

Fix
---
This fix ensures that all crypto peripherals are explicitly reset prior
to any software-triggered restart (including panic scenarios),
guaranteeing a clean peripheral state for the next boot and preventing
incorrect secure boot behavior.
2025-04-16 20:45:18 +08:00
xiongweichao
5abe6e4c52 fix(bt): fixed spp not reporting write event 2025-04-16 17:14:23 +08:00
Jiang Jiang Jian
bb02c680fa Merge branch 'fix/fix_uart_console_broken_after_sleep' into 'release/v5.0'
fix(esp_hw_support): fixed gpio sleep switching filling junk data to the console UART FIFO (v5.0)

See merge request espressif/esp-idf!38426
2025-04-16 16:40:10 +08:00
Jiang Jiang Jian
f1af5bbd8e Merge branch 'fix/fix_current_leakage_after_ext_osc_detect_failed_v5.0' into 'release/v5.0'
fix(esp_hw_support): fix current leakage if ext32k slow clock source not exists (v5.0)

See merge request espressif/esp-idf!38428
2025-04-16 16:39:26 +08:00
gongyantao
90c4674d4f fix(bt): fixed some issues in bt controller
- add check for Wi-Fi channel
- fix the incorrect unit of duration_min in cpb tx
- recalculate the channel map when afh is enabled
- fix incorrect vendor event count causing an assertion failure
2025-04-16 15:24:54 +08:00
Shreeyash
04f9e94dea fix(nimble): Fix incorrect OTA address assignment 2025-04-16 11:54:18 +05:30
wuzhenghui
6af2629bcd fix(esp_hw_support): fix unused OSC source deinit breaks XTAL32K configuration 2025-04-15 22:07:23 +08:00
wuzhenghui
2d1501f25d fix(esp_hw_support): fix current leakage if ext32k slow clock source not exists 2025-04-15 22:06:05 +08:00
wuzhenghui
f421ec9443 change(esp_hw_support): allow sar power keep on during lightsleep 2025-04-15 22:00:24 +08:00
wuzhenghui
9dc0805ccb fix(esp_hw_support): fixed gpio sleep switching filling junk data to the console UART FIFO 2025-04-15 21:57:04 +08:00
Jiang Jiang Jian
cc29434655 Merge branch 'refactor/sae_pt_flag_v5.0' into 'release/v5.0'
refactor(wifi): Optimize wifi bin size for station mode (Backport v5.0)

See merge request espressif/esp-idf!38312
2025-04-15 14:37:06 +08:00
Jiang Jiang Jian
60d1381286 Merge branch 'bugfix/esp32s2_memprot_clear_v5.0' into 'release/v5.0'
fix(esp_hw_support): clear the memory protection interrupt status on boot (backport v5.0)

See merge request espressif/esp-idf!38056
2025-04-15 14:14:37 +08:00
Jiang Jiang Jian
f3e272a293 Merge branch 'bugfix/handle_missing_unlock_v5.0' into 'release/v5.0'
fix(nimble): Fixed one missing ble_hs_unlock() (v5.0)

See merge request espressif/esp-idf!38197
2025-04-15 10:44:33 +08:00
Omar Chebib
ffe8d09f17 fix(esp_hw_support): clear the memory protection interrupt status on boot
Fixes https://github.com/espressif/esp-idf/issues/15359
2025-04-14 19:05:36 +08:00
Sajia
3d0ceacd35 refactor(wifi): Optimize wifi bin size for station mode 2025-04-14 14:26:13 +05:30
Jiang Jiang Jian
4426dd5e8d Merge branch 'fix/sdmmc_write_sectors_dma_always_send_cmd13_v5.0' into 'release/v5.0'
fix(sdmmc): sdmmc_write_sectors_dma always check card status after write (v5.0)

See merge request espressif/esp-idf!34344
2025-04-14 15:04:17 +08:00
Jiang Jiang Jian
e8d1e3ced7 Merge branch 'fix/ssdmmc_send_cmd_set_relative_addr_rca_v5.0' into 'release/v5.0'
fix(sdmmc): Retry to get another RCA if the previous response was 0 (v5.0)

See merge request espressif/esp-idf!34348
2025-04-14 15:03:07 +08:00
Jiang Jiang Jian
0318fe86ba Merge branch 'refactor/improve_p4_psram_timing_tuning_point_selection_v5.0' into 'release/v5.0'
mspi: improve p4 psram timing tuning point selection (v5.0)

See merge request espressif/esp-idf!38192
2025-04-14 15:01:34 +08:00
Jiang Jiang Jian
e2aa03c18d Merge branch 'fix/update_os_time_struct_v5.0' into 'release/v5.0'
fix(esp_wifi): Modifying os_time_t datatype for platform and compiler independence

See merge request espressif/esp-idf!36710
2025-04-11 19:32:39 +08:00
tarun.kumar
04b73079b4 fix(esp_wifi): Modifying os_time_t datatype for platform and compiler independence 2025-04-10 13:05:55 +05:30
Rahul Tank
5321b3726e fix(nimble): Fixed one missing ble_hs_unlock() 2025-04-10 11:29:07 +05:30
Jiang Jiang Jian
8df0a41ec4 Merge branch 'fix/examples_python3.13_ssl_conn_failure_v5.0' into 'release/v5.0'
Change in Python3.13's default ssl context caused SSL connection failure (v5.0)

See merge request espressif/esp-idf!38203
2025-04-10 11:16:27 +08:00
Jiang Jiang Jian
e8d066f8d4 Merge branch 'fix/fix_sleep_reject_on_esp32_v5.0' into 'release/v5.0'
fix(esp_hw_support): fix short duration sleep requests rejected in pd_flash lightsleep (v5.0)

See merge request espressif/esp-idf!38225
2025-04-10 11:15:48 +08:00
Jiang Jiang Jian
5fa881ddb0 Merge branch 'ci/add_test_for_ecos_wifi_enterprise_v50' into 'release/v5.0'
ci(c2/c3): add major eco version tests(v5.0)

See merge request espressif/esp-idf!37796
2025-04-10 11:15:27 +08:00
armando
9a713f9b7d refactor(mspi): improved timing tuning max consecutive success points calculation 2025-04-10 10:49:02 +08:00
Jiang Jiang Jian
e5dc75ea6a Merge branch 'bugfix/handle_invalid_rd_rem_feat_v5.0' into 'release/v5.0'
fix(nimble): Handle connection posting condition (v5.0)

See merge request espressif/esp-idf!38231
2025-04-10 10:46:20 +08:00
Jiang Jiang Jian
c08af7bd46 Merge branch 'feat/optimize_cble50y24_111_v5.0' into 'release/v5.0'
feat(bt/bluedroid): Added BLE eddystone sender example (v5.0)

See merge request espressif/esp-idf!38154
2025-04-10 10:38:59 +08:00
Jiang Jiang Jian
a5b58094ec Merge branch 'bugfix/fix_sscanf_usage_v5.0' into 'release/v5.0'
fix(nimble): Updated sscanf usage in examples to work for all versions (v5.0)

See merge request espressif/esp-idf!38025
2025-04-10 10:37:01 +08:00
Jiang Jiang Jian
34240b11c6 Merge branch 'feat/update_mbedtls_3.6.3_v5.0' into 'release/v5.0'
feat(component/mbedtls): update to upstream v3.6.3 (v5.0)

See merge request espressif/esp-idf!38183
2025-04-10 10:34:35 +08:00
Jiang Jiang Jian
a8e0e0b1f7 Merge branch 'feat/eap_domain_check_v5.0' into 'release/v5.0'
esp_wifi: Add EAP domain validation support (v5.0)

See merge request espressif/esp-idf!38283
2025-04-10 10:33:59 +08:00
Rahul Tank
cd79294cfb fix(nimble): Updated sscanf usage in examples to work for all versions 2025-04-09 18:33:48 +05:30
Kapil Gupta
816e7bf914 fix(esp_wifi): Flush PMK when EAP configuration is changed 2025-04-09 14:43:46 +05:30
Kapil Gupta
8a57b738e9 fix(esp_wifi): Code cleanup for PR#15550 PR#15551
Closes https://github.com/espressif/esp-idf/pull/15550
Closes https://github.com/espressif/esp-idf/pull/15551
2025-04-08 18:08:36 +05:30
zhangbowen
7ec49b1c01 feat(bt/bluedroid): Added BLE eddystone sender example 2025-04-07 19:54:10 +08:00
Michael Stoll
ef0ab70bd2 fix: Force validate when using the default crt bundle 2025-04-07 14:53:03 +05:30
Michael Stoll
dbb1715325 feat: Add domain match to wifi_enterprise example 2025-04-07 14:53:02 +05:30
Michael Stoll
b004916c87 feat(esp_wifi): Implement esp_eap_client_set_domain_match 2025-04-07 14:53:02 +05:30
Island
8efb55e925 Merge branch 'bugfix/fixed_c2eco4_ble_crash_issue_5.0' into 'release/v5.0'
fix(ble): fixed a heap assertion issue when enabling BLE for esp32c2 v2.0

See merge request espressif/esp-idf!38218
2025-04-03 14:43:52 +08:00
Rahul Tank
4249e00820 fix(nimble): Handle connection posting condition 2025-04-03 11:11:41 +05:30
harshal.patil
8094b821c8 fix(examples): Example CA certs must contain the Key Usage parameter
- Example CA certificates that are used for self-signed client certificates
need to include the Key Usage parameter.
- Python3.13 changed the default context of the SSL context that is
generated using ssl.create_default_context() by enabling the VERIFY_X509_STRICT
flag by default
2025-04-03 11:06:18 +05:30
wuzhenghui
fc823576ac fix(esp_hw_support): fix min sleep time calculation missmatch in powerdown flash decision 2025-04-03 11:50:34 +08:00
Shen Weilong
a8f3e33fbe fix(ble): fixed a heap assertion issue when enabling BLE for esp32c2 v2.0 2025-04-03 09:00:03 +08:00
luaijun
302eb16a60 ci(c2/c3): add major eco version tests(v5.0) 2025-04-02 19:09:48 +08:00
Ashish Sharma
905f73a4ab feat(mbedtls): new config to allow weak cert verification 2025-04-02 10:21:44 +05:30
Ashish Sharma
ea79647066 feat(mbedtls): update to version 3.6.3 2025-04-02 10:12:17 +05:30
Jiang Jiang Jian
6cb14d5b2f Merge branch 'support/add_srp_salt_ver_gen_api_v5.0' into 'release/v5.0'
Generate Salt and verifier pair for given username and password (v5.0)

See merge request espressif/esp-idf!37914
2025-04-02 10:41:23 +08:00
Jiang Jiang Jian
dda08430cd Merge branch 'bugfix/pmkid_password_mismatch_v5.0' into 'release/v5.0'
fix(wifi): Fix wrong PMKSA cache entry being used when wifi password is changed (Backport v5.0)

See merge request espressif/esp-idf!38167
2025-04-02 10:40:32 +08:00
Sajia
a2bf35b1a5 fix(wifi): Fix crash when set config is called with changed password
Closes https://github.com/espressif/esp-idf/issues/15584
2025-04-01 19:38:36 +08:00
Sarvesh Bodakhe
e93ddfd739 fix(wifi): Fix wrong PMKSA cache entry being used when wifi password is changed 2025-04-01 19:38:36 +08:00
Jiang Jiang Jian
9842b1fac1 Merge branch 'feature/support_sco_coexist_v5.0' into 'release/v5.0'
feat(coex): Support BR/EDR (e)SCO and Wi-Fi coexistence

See merge request espressif/esp-idf!38137
2025-04-01 19:29:59 +08:00
Rahul Tank
d1deab0248 Merge branch 'bugfix/reattempt_sync_failed_unlock_v5.0' into 'release/v5.0'
fix(nimble): Added ble_hs_unlock for resync failed (v5.0)

See merge request espressif/esp-idf!38101
2025-04-01 14:42:19 +08:00
Vikram Dattu
f5a5db5057 feat(provisioning): Generate Salt and verifier pair for given username and password
This commit adds a new feature to generate a salt and verifier pair for a given username and
password during the provisioning process. This is useful in scenarios where the pairing pin is
randomly generated and shown via some interface such as a display or console.

- Uses the provided username and password to generate a salt and verifier pair
- Adds support for dev mode where the pin/password can still be read from flash
2025-04-01 10:56:21 +05:30
Vikram Dattu
6eb74a9f41 refactor(esp_srp): Expose esp_srp.h and add API docs
- Also added missing `protocomm_security2` reference in `protocomm.rst`
2025-04-01 10:56:17 +05:30
Island
be5933cc61 Merge branch 'feat/support_blecrt_359_v5.0' into 'release/v5.0'
Support BLE vendor hci set rx sensie and max gain on esp32c3 (v5.0)

See merge request espressif/esp-idf!38126
2025-04-01 11:04:25 +08:00
baohongde
f0023145c7 feat(coex): Support BR/EDR (e)SCO and Wi-Fi coexistence 2025-04-01 10:39:29 +08:00
Jiang Jiang Jian
68448cf7e1 Merge branch 'fix/__atomic_test_and_set_v5.0' into 'release/v5.0'
fix(newlib): fix __atomic_test_and_set to ensure atomicity (v5.0)

See merge request espressif/esp-idf!37454
2025-04-01 10:32:31 +08:00
Jiang Jiang Jian
3f94b6b77b Merge branch 'fix/fix_dhcp_server_recv_decline_issue_v50' into 'release/v5.0'
fix(dhcp): fix dhcp server recv decline issue v50

See merge request espressif/esp-idf!38131
2025-04-01 10:32:02 +08:00
wangtao@espressif.com
1e29e38919 fix(dhcp): fix dhcp server recv decline issue 2025-03-31 14:07:20 +08:00
Alexey Lapshin
742d7a9f37 fix(newlib): fix __atomic_test_and_set to ensure atomicity
Before the change described in
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631393.html it
appeared that inlining built-in GCC function __atomic_test_and_set() was
incorrect. It resulted in a non-atomic write.
For GCC toolchains which do not have such patch yet, this commit fixes
__atomic_test_and_set to be atomic in IDF's builds.
2025-03-31 11:58:17 +07:00
Chen Jian Hua
45670f7761 feat(bt): Update bt lib for ESP32-C3 and ESP32-S3(566c8e3)
- Support BLE vendor hci set RX sensitivity and AGC gain command


(cherry picked from commit 8742bbe553)

Co-authored-by: chenjianhua <chenjianhua@espressif.com>
2025-03-31 12:05:08 +08:00
Jiang Jiang Jian
02cead408e Merge branch 'fix/fix_esp32s2_recv_24m_ba_issue_v50' into 'release/v5.0'
fix(wifi): fix esp32s2 recv 24M BA issue v50

See merge request espressif/esp-idf!38116
2025-03-31 11:41:54 +08:00
Jiang Jiang Jian
c5436dd14f Merge branch 'ci/add_build_test_eco_versions_v5.0' into 'release/v5.0'
ci: add build test for eco versions (v5.0)

See merge request espressif/esp-idf!35822
2025-03-31 11:30:40 +08:00
Adam Múdry
91b891c259 fix(sdmmc): Send status (CMD13) even if write/read command fails 2025-03-31 11:09:44 +08:00
Adam Múdry
20e0788361 fix(sdmmc): Improve SD card state checking after write/read command 2025-03-31 11:09:44 +08:00
Adam Múdry
a908cf2aea fix(sdmmc): Retry to get another RCA if the previous response was 0 2025-03-31 10:54:48 +08:00
Jiang Jiang Jian
f7faec9bee Merge branch 'bugfix/fix_wep_shared_auth_association_timeout_issue_v5.0' into 'release/v5.0'
fix(wifi): fix association timeout timer issue for wep shared auth(Backport v5.0)

See merge request espressif/esp-idf!38111
2025-03-31 10:50:37 +08:00
Rahul Tank
3adb4edd92 Merge branch 'fix/periodic_adv_example_v5.0' into 'release/v5.0'
fix(nimble):Fix conversion for min-max itvl of periodic adv param (v5.0)

See merge request espressif/esp-idf!38095
2025-03-29 19:46:07 +08:00
wangtao@espressif.com
665fd1a895 fix(wifi): fix esp32s2 recv 24M BA issue 2025-03-29 15:18:51 +08:00
Michael (XIAO Xufeng)
6471d88303 Merge branch 'bugfix/cache2phys_xip_v5.0' into 'release/v5.0'
fix(mmap): fixed spi_flash_cache2phys return addr in PSRAM issue (v5.0)

See merge request espressif/esp-idf!38051
2025-03-28 18:13:42 +08:00
muhaidong
d377d94877 fix(wifi): fix association timeout timer issue for wep shared auth 2025-03-28 17:15:41 +08:00
Astha Verma
ed3f29442f fix(nimble): Added ble_hs_unlock for resync failed 2025-03-28 12:20:38 +05:30
Abhinav Kudnar
fbfc85feac fix(nimble): Fix conversion for min-max itvl of periodic adv param 2025-03-28 14:24:12 +08:00
Xiao Xufeng
b71af88f45 ci: increase UT_C2 parallel num 2025-03-28 13:34:49 +08:00
Xiao Xufeng
4e6af199f2 ci(spi_flash): add tests for cache2phys with XIP 2025-03-28 13:34:49 +08:00
Xiao Xufeng
0f1c8cc986 fix(mmap): fixed spi_flash_phys2cache return addr in PSRAM issue
When SPIRAM_FETCH_INSTRUCTIONS or SPIRAM_RODATA enabled
2025-03-28 13:34:48 +08:00
Xiao Xufeng
2e3c42e41f fix(mmap): fixed spi_flash_cache2phys return addr in PSRAM issue
When SPIRAM_FETCH_INSTRUCTIONS or SPIRAM_RODATA enabled
2025-03-28 13:34:48 +08:00
morris
5214c71dec Merge branch 'bugfix/ledc_fade_stop_race_condition_v5.0' into 'release/v5.0'
fix(ledc): fix race condition in ledc_fade_stop causing assert failure (v5.0)

See merge request espressif/esp-idf!38084
2025-03-28 11:49:08 +08:00
morris
89bcbca982 Merge branch 'fix/mmu_multicore_app_bl_v5.0' into 'release/v5.0'
fix(MMU): fixed mmap deadlock when using multicore app with unicore bootloader (v5.0)

See merge request espressif/esp-idf!32899
2025-03-28 10:59:42 +08:00
Jiang Jiang Jian
22789f45d6 Merge branch 'backport/backport_some_changes_to_v5.0' into 'release/v5.0'
fix(wifi): fix some wifi bugs(Backport v5.0)

See merge request espressif/esp-idf!38071
2025-03-28 10:02:22 +08:00
Wang Meng Yang
c0478d2ed7 Merge branch 'bugfix/sec_service_record_conn_fail_v5.0' into 'release/v5.0'
fix(bt/bluedroid): fix the issue of connection failure when initializing multiple profiles(v5.0)

See merge request espressif/esp-idf!38078
2025-03-28 09:14:34 +08:00
Song Ruo Jing
3e44f63640 fix(ledc): fix race condition in ledc_fade_stop causing assert failure
Closes https://github.com/espressif/esp-idf/issues/15580
2025-03-27 20:17:36 +08:00
xiongweichao
481022f028 fix(bt/bluedroid): fix the issue of connection failure when initializing multiple profiles
- Due to the number of service security records exceeding the maximum value, the connection failed
2025-03-27 20:05:57 +08:00
Roland Dobai
90712386fd Merge branch 'fix/check_python_dependencies_v5.0' into 'release/v5.0'
fix(tools): handle packages with dots in their names during dependency checks (v5.0)

See merge request espressif/esp-idf!38066
2025-03-27 19:37:46 +08:00
Xiao Xufeng
8532aab32b ci(mmu): add unicore test 2025-03-27 18:15:28 +08:00
yinqingzhao
fe923b3b4b fix(sniffer): fix channel in rx_ctrl is zero when using sniffer 2025-03-27 17:29:15 +08:00
Island
87a728c41d Merge branch 'feature/add_vendor_ble_cmd_definitions_5.0' into 'release/v5.0'
Feature/add vendor ble cmd definitions (v5.0)

See merge request espressif/esp-idf!37962
2025-03-27 17:14:49 +08:00
Frantisek Hrbata
fd3b6c61c7 fix(tools): handle packages with dots in their names during dependency checks
The `setuptools` package starting with `v70.1.0`[1] contains built-in
`bdist_wheel` command. Before this version `setuptools` relied on the
`bdist_wheel` command implementation from the `wheel` package. Starting with
`setuptools` `v75.8.1` the `PEP 491`[3] restrictions on the distribution name
of a wheel package are enforced[4], replacting also `.` with `_`.  Note that
`PEP 491` actually allows `.` in the distribution name, but for some reason the
latest packaging docs[10][11] does not, stating that `.` should be replaced
with `_`. This was discussion here[12].

Also the `wheel` package starting with `v0.45.0`[5] is using the `bdist_wheel`
command from `setuptools`.  This means that any package which has `.` in its
distribution name, like `ruamel.yaml.clib`, can have different wheel name,
depending on which version of the `bdist_wheel` command was used.

The `bdist_wheel` command from setuptools prior `v75.8.1` or `wheel` prior
`v0.45.0` will keep the dots in distribution name preserved.  For exaple the
`ruamel.yaml.clib` package will have distribution name
`ruamel.yaml.clib-0.2.12.dist-info. Newer versions will replace the dots with
`_` according to [10][11], creating distribution like
`ruamel_yaml_clib-0.2.12.dist-info`.

From packaging point of view `ruamel.yaml.clib-0.2.12.dist-info` and
`ruamel_yaml_clib-0.2.12.dist-info` are the same packages, but this is not
reflected in `importlib.metadata` prior python 3.10[9], which does not perform
name normalization prior the distribution search. This causes the `version`
from `importlib.metadata` to fail on python prior the 3.10 version if the
package with dots in distribution name was generated with normalized paths with
newer `setuptools`. Note that the distribution name normalization was
backported to some later 3.9 python version.

Let's demonstrate this behavior on a simple package with the
`my.minimal.package` name.

```
my_minimal_package/
├── pkg
│   └── __init__.py
└── setup.py

from setuptools import setup, find_packages

setup(
    name='my.minimal.package',
    version='0.1.0',
    packages=find_packages(),
    install_requires=[],
    entry_points={},
)
```

With python 3.9.0 search for `my.minimal.package` fails because
of the missing name normalization.
```
docker run --rm -it --platform linux/x86_64 python:3.9.0 bash
python -m venv venv
. venv/bin/activate
pip install setuptools==v75.8.1
python setup.py bdist_wheel
pip install dist/my_minimal_package-0.1.0-py3-none-any.whl
python
Python 3.9.0 (default, Nov 18 2020, 13:28:38)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib.metadata import version as get_version
>>> get_version('my.minimal.package')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/importlib/metadata.py", line 551, in version
    return distribution(distribution_name).version
  File "/usr/local/lib/python3.9/importlib/metadata.py", line 524, in distribution
    return Distribution.from_name(distribution_name)
  File "/usr/local/lib/python3.9/importlib/metadata.py", line 187, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: my.minimal.package
>>> get_version('my_minimal_package')
'0.1.0'
```

With python 3.10.0 search for both `my.minimal.package` and
`my_minimal_package` succeeds.
```
docker run --rm -it --platform linux/x86_64 python:3.10.0 bash
python
Python 3.10.0 (default, Dec  3 2021, 00:21:30) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from importlib.metadata import version as get_version
>>> get_version('my.minimal.package')
'0.1.0'
>>> get_version('my_minimal_package')
'0.1.0'
```

In our `tools/check_python_dependencies.py` we cannot relay on the default
distribution finder, used in the `version` function from `importlib.metadata`,
to do name normalization on older python versions.  To cope with this,
implement a fallback version search. If `version` fails with
`PackageNotFoundError`, do the name normalization according to [10][11] and try
again.

Note: There is also a `wheel`[6][7] `v0.43.0` package embeded in `setuptools`
along with the new implementation[8].  This one seems to be used if the
external `wheel` package is not available but imported. TBH this is all kinda
messy and I may have overlooked something.

* [1] https://setuptools.pypa.io/en/stable/history.html#v70-1-0
* [2] https://setuptools.pypa.io/en/stable/history.html#v75-8-1
* [3] https://peps.python.org/pep-0491/#escaping-and-unicode
* [4] https://github.com/pypa/setuptools/pull/4766/files
* [5] https://wheel.readthedocs.io/en/stable/news.html
* [6] https://github.com/pypa/setuptools/blob/main/setuptools/_vendor/wheel/__init__.py
* [7] https://github.com/pypa/setuptools/issues/1386
* [8] https://github.com/pypa/setuptools/blob/main/setuptools/command/bdist_wheel.py
* [9] c6ca368867
* [10] https://packaging.python.org/en/latest/specifications/name-normalization/#name-normalization
* [11] https://packaging.python.org/en/latest/specifications/binary-distribution-format/
       #escaping-and-unicode
* [12] https://github.com/pypa/setuptools/issues/3777

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-03-27 08:05:45 +01:00
Jiang Jiang Jian
b39b0cc47f Merge branch 'bugfix/fix_scan_info_error_in_lr_only_mode_v5.0' into 'release/v5.0'
fix(wifi): Fixed the scan information error in LR only mode (v5.0)

See merge request espressif/esp-idf!37904
2025-03-27 14:27:22 +08:00
morris
ac8137d181 Merge branch 'fix/i2s_iram_safe_issue_while_use_psram_v5.0' into 'release/v5.0'
fix(i2s): fixed failure when dma is iram_safe but i2s not (v5.0)

See merge request espressif/esp-idf!38007
2025-03-27 14:18:44 +08:00
morris
10130e92d7 Merge branch 'contrib/github_pr_15484_v5.0' into 'release/v5.0'
fix(twai): fixed twai assert fail during recover (GitHub PR) (v5.0)

See merge request espressif/esp-idf!37996
2025-03-27 13:45:35 +08:00
diplfranzhoepfinger
d1b03d36ba fix(twai): fixed twai assert fail when recover
driver try start new frame in ISR however already bus off

Closes https://github.com/espressif/esp-idf/issues/9697
2025-03-27 11:24:07 +08:00
zhangyanjiao
02cebb0975 fix(wifi): Added timer to send wake null after STA received assoc response 2025-03-27 10:48:02 +08:00
zhangyanjiao
f41ea3257d fix(wifi): Fixed the scan information error in LR only mode 2025-03-27 10:43:10 +08:00
zhangyanjiao
b7a612cd00 fix(wifi): Fixed the max log level not work when it exceeds the default log level 2025-03-27 10:43:10 +08:00
zhangyanjiao
7157645d65 docs(wifi): update the description for esp_mesh_send() return value
Closes https://github.com/espressif/esp-idf/issues/14440
2025-03-27 10:43:10 +08:00
zhangyanjiao
852feea9dd fix(wifi): Update the doc for espnow add peer 2025-03-27 10:43:10 +08:00
Xiao Xufeng
c1bd3d2925 fix(MMU): fixed mmap deadlock when using multicore app with unicore bootloader
Closes https://github.com/espressif/esp-idf/issues/11617
2025-03-27 00:23:49 +08:00
Jiang Jiang Jian
29797ad298 Merge branch 'bugfix/pmf_enabled_sae_query_v5.0' into 'release/v5.0'
fix(wifi): SA Query responses not transmitted (Backport v5.0)

See merge request espressif/esp-idf!38009
2025-03-26 21:28:24 +08:00
Shen Weilong
1e3a0daddf feat(bt): fixed some doc error and add ocf parameters description 2025-03-26 13:26:38 +08:00
Rahul Tank
ac367ac8b8 Merge branch 'feature/expose_ble_gap_wl_tx_add_v5.0' into 'release/v5.0'
fix(nimble): Exposed the ble_gap_wl_tx_add API to add a device in whitelist(v5.0)

See merge request espressif/esp-idf!37649
2025-03-25 19:09:04 +08:00
akshat
e458f633d7 fix(wifi): Fix occasional dropping of SA Query responses by SoftAP 2025-03-25 13:00:20 +05:30
laokaiyao
02799dbee2 fix(i2s): add check for i2s DMA buffer array allocation
Closes https://github.com/espressif/esp-idf/issues/15607
2025-03-25 15:28:55 +08:00
Shen Weilong
98acfd514b feat(bt): added definitions for bluetooth hci vendor commands and events 2025-03-25 15:24:21 +08:00
laokaiyao
1b7004fdeb fix(i2s): fixed mismatch of the i2s and gdma iram-safe config
Closes https://github.com/espressif/esp-idf/issues/15533
2025-03-25 15:21:53 +08:00
Shen Weilong
8c74230b77 feat(ble/controller): Added memory boundary check for ESP32-C2 2025-03-25 14:38:00 +08:00
zhiweijian
33e15accdd fix(bt): Update bt lib for ESP32-C3 and ESP32-S3 (03d0f8a6)
- Remove unused functions in the controller
2025-03-25 14:38:00 +08:00
baohongde
b03bac9a72 feat(bt): added definitions for BR/EDR hci vendor commands and events 2025-03-25 14:38:00 +08:00
chenjianhua
85a2c95aa7 fix(bt): Update bt lib for ESP32(dc1cd581)
- Remove unused functions in the controller
- Add an SDK config for the minimum size of encryption key
2025-03-25 14:38:00 +08:00
Abhinav Kudnar
c9b4a39dea fix(nimble): Exposed the ble_gap_wl_tx_add API to add a device in whitelist 2025-03-25 11:45:15 +05:30
Aditya Patwardhan
7ff465074f Merge branch 'bugfix/provisioning_sec2_aes_iv_usage_v5.0' into 'release/v5.0'
fix(provisioning): fix incorrect AES-GCM IV usage in security2 scheme (v5.0)

See merge request espressif/esp-idf!37666
2025-03-25 13:57:29 +08:00
Island
096fb7f96e Merge branch 'feat/optimize_hci_data_recv_process_v5.0' into 'release/v5.0'
Feat/optimize hci data recv process (v5.0)

See merge request espressif/esp-idf!37830
2025-03-25 11:04:51 +08:00
Zhao Wei Liang
72f23505ed feat(ble): optimize reconfig hci uart pin code 2025-03-24 17:28:41 +08:00
Zhao Wei Liang
9c64256462 feat(ble): change nimble whitelist max size to 31
(cherry picked from commit 93357e8613)

Co-authored-by: zwl <zhaoweiliang@espressif.com>
2025-03-24 17:28:41 +08:00
Zhao Wei Liang
a9d9e092d2 feat(ble): change whitelist max size to 31 on ESP32-C2
(cherry picked from commit 578f2358c6)

Co-authored-by: zwl <zhaoweiliang@espressif.com>
2025-03-24 17:28:41 +08:00
Zhao Wei Liang
ea3f6d7329 fix(ble): fixed hci driver stack protection fault issue on ESP32-C2
(cherry picked from commit afd44d14b9)

Co-authored-by: zwl <zhaoweiliang@espressif.com>
2025-03-24 17:28:41 +08:00
Zhao Wei Liang
922db69683 fix(ble): fixed hci assertion issue when uart interference occurs
(cherry picked from commit 84f0b39e4d)

Co-authored-by: zwl <zhaoweiliang@espressif.com>
2025-03-24 17:28:41 +08:00
morris
da555cce40 Merge branch 'bugfix/usj_wrong_return_value_v5.0' into 'release/v5.0'
fix(usb_serial_jtag): wrong return value in usb_serial_jtag_write_bytes (v5.0)

See merge request espressif/esp-idf!37973
2025-03-24 16:06:16 +08:00
Jiang Jiang Jian
1920192291 Merge branch 'bugfix/wps_reconnect_failure_v5.0' into 'release/v5.0'
fix(wpa_suppplicant): Fix for issue in wps reconnection (Backport v5.0)

See merge request espressif/esp-idf!37646
2025-03-24 15:01:27 +08:00
Wang Meng Yang
6683d50054 Merge branch 'bugfix/fix_esp32_bt_disable_crash_v5.0' into 'release/v5.0'
fix(bt): Fix controller disable cause iwdt timeout on esp32 (v5.0)

See merge request espressif/esp-idf!37776
2025-03-24 14:29:47 +08:00
Wang Meng Yang
63b16bcdda Merge branch 'bugfix/err_disc_state_changed_evt_v5.0' into 'release/v5.0'
fix(bt/bluedroid): fixed other events being reported when disconnected(v5.0)

See merge request espressif/esp-idf!37940
2025-03-24 14:10:16 +08:00
Island
e29cfa8952 Merge branch 'change/ble_update_lib_20250313_v5.0' into 'release/v5.0'
change(ble): [AUTO_MR] 20250313 - Update ESP BLE Controller Lib (v5.0)

See merge request espressif/esp-idf!37818
2025-03-24 12:53:40 +08:00
morris
1f86a3e289 fix(usb_serial_jtag): wrong return value in usb_serial_jtag_write_bytes
Closes https://github.com/espressif/esp-idf/issues/15620
2025-03-24 11:47:44 +08:00
Mahavir Jain
9d73231cf9 Merge branch 'refactor/protocomm_public_hdr_v5.0' into 'release/v5.0'
refactor(protocomm): Make the protocomm `proto-c` headers public (v5.0)

See merge request espressif/esp-idf!37786
2025-03-21 12:02:15 +08:00
xiongweichao
a227b6ad44 fix(bt/bluedroid): fixed other events being reported when disconnected
- Since no initial value is assigned, the variable evt is a random value,
causing the ESP_BT_GAP_DISC_STATE_CHANGED_EVT event to be reported when
the connection is disconnected.
2025-03-21 11:24:18 +08:00
morris
4d78c54a95 Merge branch 'feat/unilc_psram_s3_v5.0' into 'release/v5.0'
psram: supported UnilC octal psram on s3 (v5.0)

See merge request espressif/esp-idf!37858
2025-03-21 10:06:37 +08:00
Roland Dobai
83b9a4de2e Merge branch 'fix/extractall_deprecation_v5.0' into 'release/v5.0'
fix(idf_tools): Patch extractall() deprecation warning (v5.0)

See merge request espressif/esp-idf!37887
2025-03-21 02:03:06 +08:00
Roland Dobai
6bbaf8b88d Merge branch 'fix/install_input_validation_v5.0' into 'release/v5.0'
fix(idf_tools): Validate input features (v5.0)

See merge request espressif/esp-idf!37893
2025-03-21 01:58:40 +08:00
Rahul Tank
30ff8658a7 Merge branch 'bugfix/fix_smp_command_allocation_v5.0' into 'release/v5.0'
fix(nimble): Fix SMP command allocation (v5.0)

See merge request espressif/esp-idf!37850
2025-03-20 20:32:59 +08:00
Geng Yuchao
32e72c42e8 fix(ble): Add link requires esp_phy for ble. 2025-03-20 09:48:47 +08:00
Zhou Xiao
9ac3dcf07d feat(ble): support ble log simple output via SPI interface 2025-03-20 09:48:35 +08:00
Radim Karniš
52d60d161c fix(idf_tools): Patch extractall() deprecation warning 2025-03-19 22:07:57 +01:00
Radim Karniš
59ca6c93b4 fix(idf_tools): Validate input features 2025-03-19 22:04:17 +01:00
Rahul Tank
39e996bac0 fix(nimble): Fix SMP command allocation 2025-03-19 20:58:33 +05:30
Rahul Tank
0ba9ba4b78 Merge branch 'feat/implement_vendor_event_mask_vsc_v5.0' into 'release/v5.0'
feat(nimble): Add support for Vendor Event mask VSC(v5.0)

See merge request espressif/esp-idf!37733
2025-03-19 20:45:08 +08:00
Laukik Hase
2c0fcb7a1f refactor(protocomm): Make the protocomm proto-c headers public 2025-03-19 16:29:21 +05:30
armando
ed545ba844 feat(psram): supported new octal psram on s3 2025-03-19 10:26:47 +08:00
Zhou Xiao
a72a99dae5 fix(ble): fix ble log init failure mem leak for ESP32
(cherry picked from commit bb9dc5a927)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2025-03-18 12:53:43 +08:00
Zhou Xiao
f3b25c4b34 fix(ble): fix ble log init failure mem leak for ESP32-C3
(cherry picked from commit 9ff9fb0661)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2025-03-18 12:53:41 +08:00
Zhou Xiao
d21703765b feat(ble): add enhanced connect function on ESP32-C2
(cherry picked from commit 71cea01694)

Co-authored-by: zwl <zhaoweiliang@espressif.com>
2025-03-18 12:53:39 +08:00
Zhou Xiao
b424d7bcb6 feat(ble): support ble log simple output via SPI interface for ESP32-C2
(cherry picked from commit df829ac919)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2025-03-18 12:53:37 +08:00
Zhou Xiao
32c92aed88 change(ble): [AUTO_MR] Update lib_esp32c2 to 5d9a6661
(cherry picked from commit f198302067)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2025-03-18 12:53:34 +08:00
Mahavir Jain
4909d72f9e feat(protocomm): add (hidden) config option to indicate security patch feature 2025-03-17 13:37:22 +05:30
Shreeyash
c05421bd88 feat(nimble): support vendor event mask set and vendor HCI event on nimble host 2025-03-15 16:56:13 +05:30
Rahul Tank
e6c139e56f Merge branch 'bugfix/fix_event_deinit_sequence_v5.0' into 'release/v5.0'
fix(nimble): Fix incorrect event deinit in gatt caching discovery (v5.0)

See merge request espressif/esp-idf!37727
2025-03-15 19:18:26 +08:00
Rahul Tank
5676daedfb fix(nimble): Fix incorrect event deinit in gatt caching discovery 2025-03-14 19:18:24 +05:30
linruihao
af82753edd fix(bt): Fix controller disable cause iwdt timeout on esp32 2025-03-14 17:53:24 +08:00
Island
3d2ad66e4c Merge branch 'feature/move_tinycrypt_to_bt_common_v5.0' into 'release/v5.0'
Feature/move tinycrypt to bt common (v5.0)

See merge request espressif/esp-idf!37578
2025-03-14 15:41:56 +08:00
morris
7a59dfe095 Merge branch 'bugfix/sdmmc_high_prio_timeout_v5.0' into 'release/v5.0'
fix(sdmmc): move DMA descriptor refilling into the ISR (v5.0)

See merge request espressif/esp-idf!37691
2025-03-14 11:48:52 +08:00
Island
651fa8fd41 Merge branch 'bugfix/reduce_controller_bin_size_v5.0' into 'release/v5.0'
fix(ble/controller): reduce controller bin size (backport v5.0)

See merge request espressif/esp-idf!37745
2025-03-14 10:59:56 +08:00
Island
62e181e185 Merge branch 'fix/feed_wdts_during_ble_log_dump_c2_v5.0' into 'release/v5.0'
fix(ble): add feed wdts during ble log dump for ESP32-C2 (v5.0)

See merge request espressif/esp-idf!37716
2025-03-13 19:34:15 +08:00
zhiweijian
997d96157e fix(ble/controller): reduce controller bin size 2025-03-13 17:42:36 +08:00
Shen Weilong
32370b047e feat(bt): support hardware ecc acceleration for bt tinycrypt 2025-03-13 17:35:20 +08:00
Island
95cafb5a32 Merge branch 'bugfix/fix_some_ble_bugs_250220_esp32c3_v5.0' into 'release/v5.0'
Fixed some BLE bugs 250220 on esp32c3(b34b7d6) (v5.0)

See merge request espressif/esp-idf!37697
2025-03-13 17:34:20 +08:00
Island
b230faf2e1 Merge branch 'feature/update_controller_lib_20250310_v5.0' into 'release/v5.0'
Feature/update controller lib 20250310 (v5.0)

See merge request espressif/esp-idf!37678
2025-03-13 14:24:28 +08:00
Zhou Xiao
35f1090636 fix(ble): add feed wdts during ble log dump for ESP32-C2
(cherry picked from commit e2e8e7dce1)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2025-03-13 12:53:30 +08:00
Island
1f51604a5d Merge branch 'bugfix/disable_dbg_hci_cmd_on_esp32_v5.0' into 'release/v5.0'
Disable debug vendor hci command on ESP32 (v5.0)

See merge request espressif/esp-idf!37626
2025-03-13 10:55:46 +08:00
Jiang Jiang Jian
efd8975a65 Merge branch 'fix/add_sta_authmode_for_sta_connect_v5.0' into 'release/v5.0'
Modify authmode to sta for sta connect event(backport v5.0)

See merge request espressif/esp-idf!37653
2025-03-12 22:17:29 +08:00
Wang Meng Yang
36f41bfc45 Merge branch 'bugfix/spp_free_server_slot_err_v5.0' into 'release/v5.0'
fix(bt/bluedroid): Fixed freeing spp server memory when disconnected(v5.0)

See merge request espressif/esp-idf!37612
2025-03-12 17:26:33 +08:00
Wang Meng Yang
7de84062c9 Merge branch 'feat/update_phy_lib_250304_5.0' into 'release/v5.0'
feat(phy): update libphy to add rx sens set api

See merge request espressif/esp-idf!37665
2025-03-12 16:26:19 +08:00
Chen Jian Hua
aaa7cb9920 fix(bt): Update bt lib for ESP32-C3 and ESP32-S3(b34b7d6)
- Fixed enhanced TX power setting and getting for legacy adv
- Fixed BLE assert lld_con.c 2387
- Fixed compatibility issues during the encryption procedure
- Support BLE vendor hci enable CCA command


(cherry picked from commit d672f909f3)

Co-authored-by: chenjianhua <chenjianhua@espressif.com>
2025-03-12 15:33:18 +08:00
armando
304fc07c45 fix(sdmmc): move DMA descriptor refilling into the ISR 2025-03-12 11:32:13 +08:00
morris
2cec465293 Merge branch 'fix/pr_15513_psram_bss_noinit_calc_issue_v5.0' into 'release/v5.0'
psram: correct .bss and .noinit vaddr calculation (v5.0)

See merge request espressif/esp-idf!37662
2025-03-12 10:32:08 +08:00
Marius Vikhammer
be7ea1c1c2 Merge branch 'bug/xtensa_cpu1_sys_lockup_v5.0' into 'release/v5.0'
fix(panic_handler): Updated panic handler to use RTC WDT (v5.0)

See merge request espressif/esp-idf!37125
2025-03-12 10:01:25 +08:00
Shen Wei Long
dfaa34b9c6 feat(ble): tell controller if vhci is enabled for ESP32-C2
(cherry picked from commit 892b3a0b0e)

Co-authored-by: Shen Weilong <shenweilong@espressif.com>
2025-03-11 20:53:37 +08:00
shenmengjing
16bbfbff93 docs(provisioning): Sync CN translation and EN source 2025-03-11 15:57:11 +05:30
Mahavir Jain
76bd80a56b fix(esp_local_ctrl): update for changes in protocomm security2 scheme 2025-03-11 11:26:07 +05:30
Mahavir Jain
e708375782 fix(docs): update for changes in provisioning security2 scheme 2025-03-11 10:11:30 +05:30
Mahavir Jain
14bc1b4b07 fix(provisioning): fix incorrect AES-GCM IV usage in security2 scheme
Using same IV in AES-GCM across multiple invocation of
encryption/decryption operations can pose a security risk. It can help
to reveal co-relation between different plaintexts.

This commit introduces a change to use part of IV as a monotonic
counter, which must be incremented after every AES-GCM invocation
on both the client and the device side.

Concept of patch version for a security scheme has been introduced here
which can help to differentiate a protocol behavior for the provisioning
entity. The security patch version will be available in the JSON
response for `proto-ver` endpoint request with the field
`sec_patch_ver`.

Please refer to documentation for more details on the changes required
on the provisioning entity side (e.g., PhoneApps).
2025-03-11 10:11:02 +05:30
Mahavir Jain
d887709d45 fix(protocomm): memory leak issue for session command0 failure case 2025-03-11 10:09:52 +05:30
zwl
86b721cdd9 feat(phy): update libphy to add rx sens set api 2025-03-11 11:53:45 +08:00
armando
85e9d68324 refactor(psram): rename .bss .noinit segments to sections
Closes https://github.com/espressif/esp-idf/pull/15513
2025-03-11 11:49:04 +08:00
Erki Aring
93bdc2dd2d fix(psram): correct heap vaddr calculation
- fixes https://github.com/espressif/esp-idf/issues/15496

Signed-off-by: armando <douyiwen@espressif.com>
2025-03-11 11:48:58 +08:00
Island
cedd9a1db4 Merge branch 'feat/support_read_periodic_adv_size_v5.0' into 'release/v5.0'
feat(ble/bluedroid): Support read periodic advertiser list size command (v5.0)

See merge request espressif/esp-idf!37500
2025-03-11 10:52:41 +08:00
tarun.kumar
09f26ece10 fix(wifi): Modify authmode to sta for sta connect event 2025-03-10 22:52:27 +05:30
Sarvesh Bodakhe
88cce45a89 fix(wifi): Resolved WPS connectivity issue with pre-connected stations
This fixes the issue where station was not able connect using WPS if it was
already in connected state.

wifi_wps_scan_done() issues an esp_wifi_disconnect() before
calling esp_wifi_connect() to associate with the newly discovered AP. This
behavior incorrectly triggered a failure event (WIFI_EVENT_STA_WPS_ER_FAILED)
even though the disconnection was part of the normal WPS flow. This commit
prevents sending the false failure event, ensuring expected WPS behavior.
2025-03-10 15:22:22 +05:30
Aditi
51c0d400d8 fix(wpa_suppplicant): Add fix for issue in wps reconnection 2025-03-10 15:22:17 +05:30
chenjianhua
f5b012fe41 fix(bt): Update bt lib for ESP32(e250cf1)
- Disable debug vendor hci command
2025-03-10 15:39:41 +08:00
gongyantao
9e3859f666 fix(bt): fixed some issues in bt controller
- fixed the issue where the NULL pointer was deferenced in lc_free state
- avoid accessing released ACL resources in SCO logic
2025-03-10 15:39:32 +08:00
zhanghaipeng
135a1990af feat(ble/bluedroid): Support read periodic advertiser list size command 2025-03-10 14:37:24 +08:00
Jiang Jiang Jian
44c38da499 Merge branch 'fix/fix_esp32s3_reboot_cache_failure_v5.0' into 'release/v5.0'
fix(esp_system): fix possible cache_error by another core accessing flash in esp_restart (v5.0)

See merge request espressif/esp-idf!37589
2025-03-10 11:40:53 +08:00
xiongweichao
18e13f2868 fix(bt/bluedroid): Fixed freeing spp server memory when disconnected 2025-03-10 11:11:54 +08:00
Shen Weilong
8ab6cc3bf3 change(bt): moved porting/ext/tinycrypt into common 2025-03-10 09:21:58 +08:00
wuzhenghui
6f59a9ea51 fix(esp_system): fix possible cache_error by another core accessing flash in esp_restart 2025-03-07 20:31:32 +08:00
Roland Dobai
a1577d26bc Merge branch 'fix/remove-unnecessary-select_v5.0' into 'release/v5.0'
fix(esp_system): Remove unnecessary select from esp_system/Kconfig (v5.0)

See merge request espressif/esp-idf!37525
2025-03-07 02:22:45 +08:00
Alexey Gerenkov
f5fc6672ff Merge branch 'feature/update-openocd-to-v0.12.0-esp32-20250226_v5.0' into 'release/v5.0'
feat(tools): update openocd version to v0.12.0-esp32-20250226 (v5.0)

See merge request espressif/esp-idf!37531
2025-03-06 21:52:47 +08:00
Rahul Tank
c22e7ae6f3 Merge branch 'bugfix/fix_sc_only_pairing_v5.0' into 'release/v5.0'
fix(nimble): Fix SC only pairing failure (v5.0)

See merge request espressif/esp-idf!37536
2025-03-06 17:07:19 +08:00
Erhan Kurubas
b6af603098 feat(tools): update openocd version to v0.12.0-esp32-20250226 2025-03-05 15:56:04 +01:00
Rahul Tank
0118cb6f1b fix(nimble): Fix SC only pairing failure 2025-03-05 19:48:48 +05:30
Jan Beran
2fcd18fb5a fix(esp_system): Remove unnecessary select from esp_system/Kconfig 2025-03-05 15:17:26 +01:00
Island
df5d6cdd4e Merge branch 'feat/ble_read_long_value_v5.0' into 'release/v5.0'
feat(ble/bluedroid): Add Read Long Characteristic Values example (v5.0)

See merge request espressif/esp-idf!37485
2025-03-05 20:06:44 +08:00
Rahul Tank
16a07891d3 Merge branch 'feat/added_change_to_ble_spp_client_v5.0' into 'release/v5.0'
feat(nimble): Allow BLE SPP Client to subscribe to the server (v5.0)

See merge request espressif/esp-idf!37459
2025-03-05 16:17:29 +08:00
Island
3b60206f3b Merge branch 'bugfix/fix_ble_kconfig_v5.0' into 'release/v5.0'
fix(ble/controller): Fix BLE Kconfig on ESP32 to avoid unexpected behavior (v5.0)

See merge request espressif/esp-idf!37418
2025-03-05 15:08:05 +08:00
zhanghaipeng
5117099572 feat(ble/bluedroid): Add Read Long Characteristic Values example 2025-03-05 14:59:20 +08:00
Rahul Tank
f55e6c385b Merge branch 'bugfix/fix_link_estab_compile_failure_v5.0' into 'release/v5.0'
fix(nimble): Handle probable release breaking change (v5.0)

See merge request espressif/esp-idf!37438
2025-03-05 14:56:11 +08:00
Shreeyash
62ac09eb8f feat(nimble): Allow BLE SPP Client to subscribe to the server 2025-03-05 11:45:08 +05:30
morris
4ddfbf7941 Merge branch 'fix/build_when_rom_patch_disable_v5.0' into 'release/v5.0'
fix(spi_flash): Fix build fail when rom_patch config disabled (backport v5.0)

See merge request espressif/esp-idf!37111
2025-03-05 10:11:31 +08:00
Jiang Jiang Jian
638bb70758 Merge branch 'bugfix/fix_some_wifi_bugs_250303_v5.0' into 'release/v5.0'
fix(wifi): fix some wifi bugs 250303(Backport v5.0)

See merge request espressif/esp-idf!37444
2025-03-04 17:59:58 +08:00
Jiang Jiang Jian
0d92239a72 Merge branch 'bugfix/bt_ctrl_issues_v5.0' into 'release/v5.0'
fix(bt/controller): fixed some controller bugs on ESP32. (v5.0)

See merge request espressif/esp-idf!37400
2025-03-04 17:44:16 +08:00
C.S.M
64e169c86e refactor(spi_flash): remove redundent flash suspend check 2025-03-03 19:14:19 +08:00
Rahul Tank
99f0ecf35d fix(nimble): Handle probable release breaking change
link_estab event may be handled by customers in application and the previous would break it.
Revert few changes so as to not break the customer's code
2025-03-03 14:57:35 +05:30
muhaidong
a6a4cdf3b2 fix(wifi): fix some wifi bugs 250303
1. fix disable external coexist fail issue
2. fix the issue of failing to connect to a shared wep ap
2025-03-03 16:45:58 +08:00
muhaidong
085153fb82 feat(phy): update libphy for RXDC cal opt, no antenna current opt, add cca api 2025-03-03 15:58:23 +08:00
zhanghaipeng
d6f803079b fix(ble/controller): Fix BLE Kconfig on ESP32 to avoid unexpected behavior 2025-03-03 11:19:22 +08:00
Jiang Jiang Jian
c7ed859d8a Merge branch 'bugfix/fix_cache_count_flash_pages_patchs_return_wrong_value_v5.0' into 'release/v5.0'
fix(rom): Fix s2 and s3 Cache_Count_Flash_Pages rom function wrapper (v5.0)

See merge request espressif/esp-idf!37159
2025-03-03 10:39:19 +08:00
Jiang Jiang Jian
54e0f77af2 Merge branch 'bugfix/check_ssid_before_sa_query_v5.0' into 'release/v5.0'
fix(esp_wifi): Check SSID in Assoc Req before starting SA Query (Backport v5.0)

See merge request espressif/esp-idf!37213
2025-03-02 17:05:26 +08:00
Tomasz Kramkowski
bf5ce28592 fix(rom): Fix s2 and s3 Cache_Count_Flash_Pages rom function wrapper
The rom function on the s2 and s3 only counts one page for any pages
which are mapped to page 0 of flash as the Cache_Flash_To_SPIRAM_Copy
function attempts to map all flash page 0 mapped pages to one PSRAM
page.

As this function can be called for multiple regions, it needs to track
if a page mapped to page 0 has previously been accounted for by a
previous call. It does this using the page0_mapped in-out parameter.
This logic contains an error:

```
if (*page0_mapped == 0) {
    // BUG: If page0_count is 0, 1 is still added
    count = valid_flash_count + 1 - page0_count;
} else {
    count = valid_flash_count - page0_count;
}
*page0_mapped += page0_count;
return count;
```

The current Cache_Count_Flash_Pages wrapper in the idf attempts to
compensate for this bug by checking if the page0_mapped parameter was
changed by a call to the function and reducing the count if it has not.

This, however, will incorrectly over-compensate in situations where the
initial value of page0_mapped was not zero as the code above only
miscounts when it was zero.

This patch addresses the issue in this wrapper function by correctly
compensating for the bug only in cases where the final page0_mapped
value is 0.
2025-03-02 17:03:16 +08:00
Jiang Jiang Jian
8fbdf6c409 Merge branch 'bugfix/spp_mem_leak_v5.0' into 'release/v5.0'
fix(bt/bluedroid): fixed memory leaks in SPP callback mode (v5.0)

See merge request espressif/esp-idf!37389
2025-03-02 17:00:48 +08:00
Rahul Tank
e85dbe06b4 Merge branch 'bugfix/set_data_len_post_conn_v5.0' into 'release/v5.0'
fix(nimble): update data length after connection for all chips (v5.0)

See merge request espressif/esp-idf!37292
2025-03-01 16:29:37 +08:00
Sajia
4f427f63c4 fix(esp_wifi): Check SSID in Assoc Req before starting SA Query 2025-02-28 15:11:07 +05:30
Jin Cheng
01dec39ed2 fix(bt/controller): fixed some controller bugs on ESP32.
1. added a VSC to control whether to initiate lmp_auto_rate
        - Closes https://github.com/espressif/esp-idf/issues/15133
    2. fixed EA resource cleanup error after SNIFF negotiation failure
        - Closes https://github.com/espressif/esp-idf/issues/13605
    3. removed an assertion in SCO data TX handler after disconnection
        - Closes https://github.com/espressif/esp-idf/issues/15176
2025-02-28 17:36:44 +08:00
Jin Cheng
fab1b432fb fix(bt/bluedroid): fixed memory leaks in SPP callback mode 2025-02-28 16:18:50 +08:00
Island
e69a86629a Merge branch 'feat/support_ble_vendor_hci_event_report_v5.0' into 'release/v5.0'
feat(bt/bluedroid): Support BLE vendor hci event reporting (v5.0)

See merge request espressif/esp-idf!37350
2025-02-28 14:30:32 +08:00
Island
e831ba7722 Merge branch 'feat/add_ble_ctrl_log_module_on_esp32c3_v5.0' into 'release/v5.0'
feat(bt): Added BLE log module on ESP32-C3 and ESP32-S3(723439d) (v5.0)

See merge request espressif/esp-idf!37357
2025-02-28 14:30:20 +08:00
Jiang Jiang Jian
f2fd69cd67 Merge branch 'bugfix/reason_code_error_v50' into 'release/v5.0'
fix(esp_wifi): Fix disconnect reason code error

See merge request espressif/esp-idf!36530
2025-02-28 13:24:32 +08:00
Jiang Jiang Jian
cae81c6d0b Merge branch 'bugfix/ifdef_cplusplus_bracket_v5.0' into 'release/v5.0'
bugfix(wifi): Add missing brackets in the C++ guard (Backport v5.0)

See merge request espressif/esp-idf!36849
2025-02-28 11:50:17 +08:00
Jiang Jiang Jian
ad2af15233 Merge branch 'fix/fix_s2_s3_rtc_iomux_clock_management_v5.0' into 'release/v5.0'
fix(esp_hw_support): fix esp32s2/esp32s3 RTC IOMUX clock management (v5.0)

See merge request espressif/esp-idf!37172
2025-02-28 11:41:20 +08:00
Jiang Jiang Jian
386c346fa2 Merge branch 'fix/fix_bad_dslp_param_after_lightsleep_v5.0' into 'release/v5.0'
fix(esp_hw_support): Fixed the issue that light sleep destroyed the parameters of subsequent deep sleep (v5.0)

See merge request espressif/esp-idf!37306
2025-02-28 11:36:46 +08:00
Rahul Tank
14ff0f1836 fix(nimble): update data length after connection for all chips 2025-02-27 21:00:13 +05:30
Rahul Tank
57ed699feb Merge branch 'bugfix/deprecate_link_estab_v5.0' into 'release/v5.0'
fix(nimble): Deprecate link_estab event (v5.0)

See merge request espressif/esp-idf!37061
2025-02-27 23:22:27 +08:00
Island
66319fbcae Merge branch 'feat/add_ble_spi_log_v5.0' into 'release/v5.0'
fix(ble/bluedroid): Support SPI log output options for HCI (v5.0)

See merge request espressif/esp-idf!37337
2025-02-27 20:18:07 +08:00
wuzhenghui
fedda1cb23 fix(esp_hw_support): fix esp32s2/esp32s3 RTC IOMUX clock management 2025-02-27 17:31:14 +08:00
chenjianhua
1d489be168 feat(bt): Update bt lib for ESP32-C3 and ESP32-S3(723439d)
- Added BLE controller debug log trace
- Added BLE controller log module
2025-02-27 16:12:18 +08:00
Wang Meng Yang
45acdc00ba Merge branch 'feat/support_ble_debug_with_gpio_v5.0' into 'release/v5.0'
Support change HID task size by Kconfig in HID example (v5.0)

See merge request espressif/esp-idf!36995
2025-02-27 15:07:43 +08:00
chenjianhua
ee8fbde1a2 feat(bt/bluedroid): Support BLE vendor hci event reporting 2025-02-27 15:02:38 +08:00
chenjianhua
735daff1e5 feat(bt/bluedroid): Support BLE setting vendor event mask 2025-02-27 15:00:54 +08:00
Jiang Jiang Jian
cefc3e2b26 Merge branch 'esp32/run_panic_debug_v5.0' into 'release/v5.0'
fix(esp32): Fixed qa program may fail issue when cpu 240m (v5.0)

See merge request espressif/esp-idf!37236
2025-02-27 14:20:37 +08:00
akshat
d753986556 bugfix(wifi): Fix header file errors and remove esp_supplicant from check_public_headers_exceptions.txt 2025-02-27 13:56:17 +08:00
akshat
8cb861890a bugfix(wifi): Add missing brackets in the C++ guard
Closes https://github.com/espressif/esp-idf/issues/14991
2025-02-27 13:56:17 +08:00
Jiang Jiang Jian
a4f233eacf Merge branch 'docs/fix_some_coexist_doc_issue_v5.0' into 'release/v5.0'
docs(coex): update rf coexistence documents (v5.0)

See merge request espressif/esp-idf!37348
2025-02-27 13:48:10 +08:00
Zhou Xiao
02e415448e fix(ble): fix flushout and sync issues 2025-02-27 13:13:59 +08:00
zhanghaipeng
ae24c6e9b2 fix(ble/bluedroid): Added SPI output support for Bluedroid host log 2025-02-27 13:13:51 +08:00
zhanghaipeng
3cebdc731a fix(ble/bluedroid): Support SPI log output options for HCI 2025-02-27 13:13:43 +08:00
linruihao
06d58996fb docs(coex): update rf coexistence documents
- remove BLE connecting state in coexistence scenario
2025-02-27 11:40:00 +08:00
Martin Vychodil
331e9be3b4 Merge branch 'fix/esp_vfs_register_fd_range_warning_message_v5.0' into 'release/v5.0'
fix(storage/vfs): incorrect log level in esp_vfs_register_fd_range (v5.0)

See merge request espressif/esp-idf!36322
2025-02-27 04:27:40 +08:00
Tomáš Rohlínek
4b3d802ba5 fix(storage/vfs): incorrect log level in esp_vfs_register_fd_range
Closes https://github.com/espressif/esp-idf/issues/14327
2025-02-26 15:09:40 +01:00
Martin Vychodil
e59cc9822c Merge branch 'fix/incorrect_console_open_and_close_behaviour_v5.0' into 'release/v5.0'
fix(storage/vfs_console): stop new console opens from overwriting existing fds (v5.0)

See merge request espressif/esp-idf!35271
2025-02-26 21:39:44 +08:00
Aditi
babc6045f0 fix(esp_wifi): Fix disconnect reason code error 2025-02-26 18:15:38 +05:30
wuzhenghui
011d60e6ec fix(esp_hw_support): fix lightsleep destroys deepsleep rtc parameters 2025-02-26 17:03:36 +08:00
zhanghaipeng
162331877c fix(ble): Update bt lib for ESP32(2a2631f)
- Support ESP32 BLE GPIO DEBUG
2025-02-26 16:20:54 +08:00
Sudeep Mohanty
68277df469 fix(panic_handler): Updated panic handler to use RTC WDT
This commit updates the following:
- Updates the panic handler to use only the RTC WDT to reset the system.
- Refactors some of the panic handler code.
- Updates Bluetooth files where in they now feed the WDTs instead of
  reconfiguring them.
- Removes some unnecessary configuration of WDTs from various files.
- Added a unit test to verify that the system does not lock up when the
  panic handler is stuck.
- Updates the memprot unit tests to work with the refactored panic
  handler.

Closes https://github.com/espressif/esp-idf/issues/15166
Closes https://github.com/espressif/esp-idf/issues/15018
Closes https://github.com/espressif/esp-idf/issues/10110
2025-02-26 08:38:05 +01:00
Island
94adab5492 Merge branch 'bugfix/fix_ble_report_len_v5.0' into 'release/v5.0'
fix(ble/bluedroid): Fix adv data and scan rsp data not reported together in BLE active scan (v5.0)

See merge request espressif/esp-idf!37199
2025-02-26 14:11:51 +08:00
morris
16aba9936a Merge branch 'fix/hub_error_handling_v5.0' into 'release/v5.0'
fix(usb/host): Fix disconnection error handling (backport to v5.0)

See merge request espressif/esp-idf!37229
2025-02-26 10:00:41 +08:00
Island
90766acef1 Merge branch 'feat/add_ble_log_spi_out_printf_v5.0' into 'release/v5.0'
feat(ble): add printf interface for ble log spi out (v5.0)

See merge request espressif/esp-idf!37183
2025-02-25 10:35:19 +08:00
Roland Dobai
a5099fa00b Merge branch 'backport/fix/empty_int_handling' into 'release/v5.0'
fix(kconfgen): Improve error message for int/hex without default

See merge request espressif/esp-idf!37215
2025-02-24 21:30:09 +08:00
chaijie@espressif.com
453f78e011 fix(esp32): Fixed qa program may fail issue when cpu 240m (v5.0) 2025-02-24 19:27:22 +08:00
Tomas Rezucha
e3b21fb932 fix(usb/host): Fix disconnection error handling
In a very rare case of having 2 or more events of type
DISCONNECTION/ERROR/OVERCURRENT in a short time,
the driver has not yet recovered from
the 1st error but already got a 2nd error.

Closes https://github.com/espressif/esp-idf/issues/13364
Closes https://github.com/espressif/esp-idf/issues/15290
2025-02-24 10:29:20 +01:00
Zhang Hai Peng
2f9c756d74 feat(ble/bluedroid): Support change HID task size by Kconfig in HID example
(cherry picked from commit d4b3a7e99d)

Co-authored-by: Mitch Cairns <mitch.cairns@handheldlegend.com>
2025-02-23 17:49:07 +08:00
Zhang Hai Peng
fe57c1bfb9 docs(ble/bluedroid): Optimize doc for implementation of a characteristic with 128 bit UUID
(cherry picked from commit fa40d971a5)

Co-authored-by: Erast  <78802792+MatoiDev@users.noreply.github.com>
2025-02-23 17:48:57 +08:00
Zhang Hai Peng
358020ad8f fix(ble/bluedroid): Don't log error on 16/128-bit UUID mixed descriptors
(cherry picked from commit fed1d41aa7)

Co-authored-by: Nebojša Cvetković <nebkat@gmail.com>
2025-02-23 17:48:47 +08:00
Zhang Hai Peng
ae6d5f8c29 fix(ble/bluedroid): Allow 0 length indications
(cherry picked from commit 9b5a52e2f7)

Co-authored-by: Nebojsa Cvetkovic <nebkat@gmail.com>
2025-02-23 17:48:28 +08:00
Rahul Tank
5d95056424 fix(nimble): Keep only BLE_GAP_EVENT_CONNECT gap event 2025-02-23 15:16:31 +05:30
Jan Beran
2c501d5bac fix(kconfgen): Improve error message for int/hex without default
Non string values without (valid) default value will have their
str_value equal to "" (empty string). If this is detected, a warning is
printed and the value is set to None.
2025-02-21 13:11:31 +01:00
Zhang Hai Peng
e202883133 fix(ble/bluedroid): Fix adv data and scan rsp data not reported together in BLE active scan
(cherry picked from commit 7f2cedc048)

Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
2025-02-21 16:13:27 +08:00
wuzhenghui
0a89efed63 fix(esp_driver_gpio): manage lp_io module clock by driver 2025-02-21 14:00:52 +08:00
Zhou Xiao
91d8d8ed11 feat(ble): add printf and write with timestamp interface for ble log spi out
(cherry picked from commit f8efa4cd80)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2025-02-21 11:53:31 +08:00
Martin Vychodil
ae11fd5c92 Merge branch 'bugfix/memprot_s2_intr_peri1_v5.0' into 'release/v5.0'
fix(security): ESP32S2 memory protection check for Peri1 RTCSLOW interrupt (v5.0)

See merge request espressif/esp-idf!37122
2025-02-21 04:56:44 +08:00
Island
f0756ef7cd Merge branch 'feat/improve_bt_log_spi_output_interface_v5.0' into 'release/v5.0'
Feat/improve bt log spi output interface (v5.0)

See merge request espressif/esp-idf!37133
2025-02-20 19:51:30 +08:00
Jiang Jiang Jian
5949919086 Merge branch 'bugfix/fix_delete_queue_error_in_espnow_example_v5.0' into 'release/v5.0'
fix(wifi): fix the delete queue error in espnow exapmle (v5.0)

See merge request espressif/esp-idf!37018
2025-02-20 15:44:05 +08:00
Island
0364a68eee Merge branch 'change/ble_update_lib_20250114_v5.0' into 'release/v5.0'
change(ble): [AUTO_MR] 20250114 - Update ESP BLE Controller Lib (v5.0)

See merge request espressif/esp-idf!36476
2025-02-20 14:48:07 +08:00
Jiang Jiang Jian
f299f69d04 Merge branch 'bugfix/sdp_uuid16_match_err_v5.0' into 'release/v5.0'
fix(bt): Fix the incorrect record found using uuid16 search(v5.0)

See merge request espressif/esp-idf!36853
2025-02-20 10:58:35 +08:00
Zhou Xiao
09eef742ea feat(ble): improved ble log spi output interface to support multisource log 2025-02-20 10:34:27 +08:00
Martin Vychodil
889cfabc89 fix(security): Fixed ESP32S2 memory protection check for Peri1 RTCSLOW interrupt
- fixes the issue found in https://github.com/espressif/esp-idf/issues/15359
- extends debug printouts in the related tests
2025-02-19 19:40:23 +01:00
Zhou Xiao
06c6996a2c feat(ble): support ble log spi out for ESP32-C3 and ESP32-S3
(cherry picked from commit e41f619566)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2025-02-19 20:53:26 +08:00
Zhou Xiao
56e38729b1 feat(ble): support ble log spi out for ESP32
(cherry picked from commit e2fbec5d2e)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2025-02-19 20:53:23 +08:00
Zhou Xiao
6bd2ef0083 change(ble): update ble log spi out config for ESP32-C2
(cherry picked from commit e4b698fc32)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2025-02-19 20:53:21 +08:00
Jiang Jiang Jian
a2e76fa5aa Merge branch 'feat/add_inq_page_coex_schm_v5.0' into 'release/v5.0'
feat(coex): add coexist scheme for bt inquiry/page coexist with wifi

See merge request espressif/esp-idf!37009
2025-02-19 20:21:02 +08:00
C.S.M
d28197b74f fix(spi_flash): Fix build fail when rom_patch config disabled,
Closes https://github.com/espressif/esp-idf/issues/15229
2025-02-19 17:33:33 +08:00
Island
4d1964212c Merge branch 'change/ble_update_lib_20250212_v5.0' into 'release/v5.0'
change(ble): [AUTO_MR] 20250212 - Update ESP BLE Controller Lib (v5.0)

See merge request espressif/esp-idf!37040
2025-02-19 17:19:00 +08:00
xiongweichao
dc7b0241ae fix(bt): Fixed SDP record integrity check bug 2025-02-18 14:10:26 +08:00
xiongweichao
dd5155ea9c fix(bt/bluedroid): fixed the format error of passkey printing 2025-02-18 14:10:26 +08:00
xiongweichao
76da49327e fix(bt/bluedroid): Fixed incorrect types of some variables in SDP 2025-02-18 14:10:26 +08:00
xiongweichao
559bcf1ec9 fix(bt): Fix incorrect type returned when searching SAP record 2025-02-18 14:10:26 +08:00
xiongweichao
bf9f271ca7 fix(bt): Fix the incorrect record found using uuid16 search 2025-02-18 14:10:26 +08:00
morris
085bf84090 Merge branch 'bugfix/gpio_rom_patch_fix_v5.0' into 'release/v5.0'
fix(gpio): fix esp_rom_gpio_connect_out_signal for gpio num over 31 on esp32/s2 (v5.0)

See merge request espressif/esp-idf!36869
2025-02-18 10:24:53 +08:00
Zhou Xiao
3fcc64cc05 feat(ble): support enhanced controller log capabilities on ESP32-C2
(cherry picked from commit bbcb4a2e1f)

Co-authored-by: zwl <zhaoweiliang@espressif.com>
2025-02-18 10:22:43 +08:00
Rahul Tank
608d5a7626 Merge branch 'fix/wifi_provisioning_ble_v5.0' into 'release/v5.0'
fix(nimble): Handle nested locks when BT_NIMBLE_DEBUG enabled (v5.0)

See merge request espressif/esp-idf!36502
2025-02-17 18:59:52 +08:00
zhangyanjiao
d6b268361c fix(wifi): fix the delete queue error in espnow exapmle
Closes https://github.com/espressif/esp-idf/issues/15383
2025-02-17 14:59:56 +08:00
liuning
69ae8735c7 feat(coex): add coexist scheme for bt inquiry/page coexist with wifi 2025-02-17 14:23:03 +08:00
Astha Verma
8391e9a02b fix(nimble): Handle nested locks when BT_NIMBLE_DEBUG enabled 2025-02-17 10:34:48 +05:30
Rahul Tank
85109aff8f Merge branch 'fix/ble_issue_05022025_v5.0' into 'release/v5.0'
fix(nimble): Fix/ble issue 05022025 v5.0

See merge request espressif/esp-idf!36759
2025-02-17 12:58:35 +08:00
Island
10bebf8139 Merge branch 'feat/add_spi_output_v5.0' into 'release/v5.0'
Feat/add spi output (v5.0)

See merge request espressif/esp-idf!36952
2025-02-17 11:04:29 +08:00
Abhinav Kudnar
f7f91702b8 feat(nimble): Add offset in GATT server long read context 2025-02-15 20:28:36 +05:30
Rahul Tank
30116f0522 fix(nimble): Handle not sending disconnect event if connect was not sent 2025-02-15 20:27:56 +05:30
Astha Verma
698badd76a fix(nimble): Added sync reattempt for periodic adv 2025-02-15 20:26:35 +05:30
Astha Verma
bcb9511858 fix(nimble): Handle NVS corruption due to incorrect security record
deletion
2025-02-15 20:25:55 +05:30
Rahul Tank
9297010c2e fix(nimble): Fixed warnings with COMPILTER_WARN_WRITE_STRINGS set 2025-02-15 20:25:00 +05:30
Astha Verma
2b5d70b4cf fix(nimble): Enhanced error handling by adding to print core error definitions 2025-02-15 20:22:41 +05:30
Kapil Gupta
e2a2dcd808 Merge branch 'bugfix/skip_memory_reordering_wpa2_semaphr_v5.0' into 'release/v5.0'
fix(esp_wifi): fixed stack corruption in WiFi tasks (v5.0)

See merge request espressif/esp-idf!36940
2025-02-14 19:06:36 +08:00
zhouxiao
0563abdd5e change(ble): [AUTO_MR] Update lib_esp32c2 to 7b7ee440 2025-02-14 17:39:58 +08:00
Kapil Gupta
e7e15d954c fix(esp_wifi): Fix stack curruption in btm task (v5.2) 2025-02-14 13:03:32 +05:30
Zhou Xiao
e456978606 change(ble): update esp32c2 rom ld file
(cherry picked from commit e5feba6ed3)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2025-02-14 14:09:25 +08:00
Jiang Jiang Jian
5dbf151488 Merge branch 'change/ble_update_lib_20250103_v5.0' into 'release/v5.0'
change(ble): [AUTO_MR] 20250103 - Update ESP BLE Controller Lib (v5.0)

See merge request espressif/esp-idf!36369
2025-02-14 13:43:40 +08:00
Zhou Xiao
22bec7a569 feat(ble): add spi output interface for esp ble controller log 2025-02-14 12:18:31 +08:00
Zhou Xiao
11230d884a feat(ble): support esp ble controller spi output interface for ESP32-C2
(cherry picked from commit 0b57f8ae87)

Co-authored-by: Zhou Xiao <zhouxiao@espressif.com>
2025-02-14 11:53:23 +08:00
Kapil Gupta
cbe890bde6 fix(esp_wifi): fixed Stack corruption in DPP task 2025-02-13 15:57:48 +05:30
Kapil Gupta
968b8a215a fix(esp_wifi): fixed Stack corruption in WPS processing 2025-02-13 15:57:48 +05:30
Kapil Gupta
90b29be236 fix(esp_wifi): Fixed memory corruption in wifi enterprise
Closes https://github.com/espressif/esp-idf/issues/15370
2025-02-13 15:57:41 +05:30
Jiang Jiang Jian
9d8fc56139 Merge branch 'fix/stack_overuse_by_failure_retry_cnt_v5.0' into 'release/v5.0'
fix(wifi): Fix stack overflow when failure_retry_cnt is set in station configuration (Backport v5.0)

See merge request espressif/esp-idf!36856
2025-02-12 18:04:50 +08:00
Jiang Jiang Jian
dc58edb50d Merge branch 'bugfix/fix_i2s_reconfig_slot_issue_v5.0' into 'release/v5.0'
fix(i2s): fixed incorrect logic in slot reconfig (v5.0)

See merge request espressif/esp-idf!36645
2025-02-12 16:13:32 +08:00
Jiang Jiang Jian
92f710f8c8 Merge branch 'fix/ringbuf_receives_after_aq_wraparound_v5.0' into 'release/v5.0'
fix(esp_ringbuf): Fixed no-split ringbuf issue where acquire pointer  wraps around (v5.0)

See merge request espressif/esp-idf!35871
2025-02-12 16:12:49 +08:00
Jiang Jiang Jian
a3136838fa Merge branch 'bugfix/analyzer_issues_supplicant_v5.0' into 'release/v5.0'
fix(esp_wifi): fix some analyzer issues (v5.0)

See merge request espressif/esp-idf!36834
2025-02-12 16:11:16 +08:00
Jiang Jiang Jian
45ff2887e7 Merge branch 'bugfix/wps_scan_freq_v5.0' into 'release/v5.0'
fix(esp_wifi): Reduce scan frequency in WPS (v5.0)

See merge request espressif/esp-idf!36824
2025-02-12 16:10:45 +08:00
Island
9aea05c4cd Merge branch 'bugfix/fix_blufi_crash_v5.0' into 'release/v5.0'
fix(blufi): Fixed crash issue during memcpy in example (v5.0)

See merge request espressif/esp-idf!36548
2025-02-12 15:02:38 +08:00
Island
8dde4f9233 Merge branch 'fix/blufi_example_mem_access_v5.0' into 'release/v5.0'
fix(ble/blufi): Fixed blufi example security issue (v5.0)

See merge request espressif/esp-idf!36160
2025-02-12 15:02:33 +08:00
Jiang Jiang Jian
30eba26e51 Merge branch 'bugfix/remove_unused_sco_state_v5.0' into 'release/v5.0'
Bugfix/remove unused sco state (v5.0)

See merge request espressif/esp-idf!36733
2025-02-12 14:00:57 +08:00
Wang Meng Yang
a55d6bc08f Merge branch 'feat/add_vsc_to_support_test_v5.0' into 'release/v5.0'
feat(bt): add vendor hci command and event to support test (v5.0)

See merge request espressif/esp-idf!36567
2025-02-12 11:15:14 +08:00
Zhou Xiao
f73fdaa744 fix(ble): fixed ld file for c2eco0 and c2eco4
(cherry picked from commit 937fe2a6e3)

Co-authored-by: zhouxiao <zhouxiao@espressif.com>
2025-02-12 10:55:00 +08:00
Zhou Xiao
79627f0151 fix(ble): fixed esp_ble_tx_power_set api issue on ESP32-C2
(cherry picked from commit 6a752eeb89)

Co-authored-by: zwl <zhaoweiliang@espressif.com>
2025-02-12 10:55:00 +08:00
Zhou Xiao
14b81fd066 change(ble): Update lib_esp32c2 to 2a00fb0b
(cherry picked from commit 7cd3fe6953)

Co-authored-by: zhouxiao <zhouxiao@espressif.com>
2025-02-12 10:55:00 +08:00
Song Ruo Jing
834c9da833 fix(gpio): fix esp_rom_gpio_connect_out_signal for gpio num over 31 on esp32/s2
Closes https://github.com/espressif/esp-idf/issues/15209
2025-02-11 19:15:08 +08:00
zhanghaipeng
770f713e65 fix(ble): Update bt lib for ESP32(194dd63)
- Fix the issue where disconnection events were not reported as a slave.
- Enhance Access Address validation in compatibility mode.
2025-02-11 16:56:31 +08:00
gongyantao
bb039cc318 feat(bt): add vendor hci command and event to support test
- add afh related vendor hci command and event
- add vendor event mask command
2025-02-11 16:56:31 +08:00
linruihao
7db6f812af feat(bt): add coexist scheme status support for bt page 2025-02-11 16:56:31 +08:00
Jin Cheng
13d598d50f fix(bt/controller): fixed missing critical protections on linked-list structure of (e)SCO buffers 2025-02-11 16:56:31 +08:00
chenjianhua
01d9a716b9 fix(bt): Update bt lib for ESP32(ba6739f)
- Fixed assert in lld_evt.c at line 2353
- Fixed interrupt WDT when shutdown bt controller
- Added config for BLE vendor HCI QA command
- Added config for BLE channel assessment and ping procedure
2025-02-11 16:56:31 +08:00
zhanghaipeng
cc00e9f2fc fix(blufi): Enhance security in BLUFI example 2025-02-11 15:24:04 +08:00
Sarvesh Bodakhe
d2306adc5e fix(wifi): Fix stack overflow when failure_retry_cnt is set
Fix issue of increased stack usage when failure_retry_cnt is set
and wifi driver internally retries connection attempts
2025-02-11 12:25:37 +05:30
zhanghaipeng
b5b9f9559e docs(ble/bluedroid): Added BLE log when bond info was deleted 2025-02-11 14:17:03 +08:00
zhanghaipeng
d2d3ce7f0c docs(ble/bluedroid): Optimize doc for registering BLE callback functions 2025-02-11 14:16:53 +08:00
zhanghaipeng
a4c4601e59 fix(ble/blufi): Fixed blufi example security issue 2025-02-11 14:16:43 +08:00
Jiang Jiang Jian
9659bb2d03 Merge branch 'feat/esp32_set_get_bt_lpclk_src_v5.0' into 'release/v5.0'
feat(ble): Added API to get/set low power clock source(v5.0)

See merge request espressif/esp-idf!36575
2025-02-11 11:34:04 +08:00
Rahul Tank
f9358b74f0 Merge branch 'bugfix/fix_scan_rsp_evt' into 'release/v5.0'
fix(nimble): Add support for missing legacy event type in report parsing (v5.0)

See merge request espressif/esp-idf!36782
2025-02-11 00:23:56 +08:00
Kapil Gupta
b37f89bbce fix(esp_wifi): fix some analyzer issues
Closes https://github.com/espressif/esp-idf/issues/15097
Closes https://github.com/espressif/esp-idf/issues/15098
Closes https://github.com/espressif/esp-idf/issues/15099
2025-02-10 20:16:35 +05:30
Kapil Gupta
55c6945957 fix(esp_wifi): Reduce scan frequency in WPS 2025-02-10 15:45:39 +05:30
Jiang Jiang Jian
1443536abb Merge branch 'revert/use_wpa3_ent_authmode_naming_v5.0' into 'release/v5.0'
fix(wifi): Revert support for WPA3 Enterprise mode (v5.0)

See merge request espressif/esp-idf!36708
2025-02-10 14:42:39 +08:00
Wang Mengyang
01c34d4b62 change(bt): Remove unused state variable for (e)SCO disconnect reason in Bluedroid 2025-02-08 17:58:18 +08:00
xiongweichao
a1d6fc04a4 feat(bt): Added API to get/set low power clock source 2025-02-08 14:29:33 +08:00
Wang Meng Yang
90e98f1dbc Merge branch 'docs/refactor_ceva_bt_controller_api_v5.0' into 'release/v5.0'
docs(ble): Refactored the API reference for esp32/c3/s3 BT controller (v5.0)

See merge request espressif/esp-idf!35349
2025-02-08 11:05:55 +08:00
Wei Yu Han
11f791c6c6 docs(ble): Refactored the API reference for esp32/c3/s3 BT controller (v5.0) 2025-02-08 11:05:55 +08:00
morris
8f817ec1b4 Merge branch 'fix/spi_hd_seg_fix_iwdt_timeout_v5.0' into 'release/v5.0'
fix(spi_slave_hd): fix seg mode potential iwdt timeout when multi task call (v5.0)

See merge request espressif/esp-idf!31845
2025-02-08 10:11:26 +08:00
Rahul Tank
1f004ce6fe fix(nimble): Add support for missing legacy event type in report parsing 2025-02-06 18:02:51 +05:30
Martin Vychodil
c562688d32 Merge branch 'bugfix/storage_generic_pytests_v5.0' into 'release/v5.0'
fix(ci): Removed storage related entries in known generate test child pipeline warnings (v5.0)

See merge request espressif/esp-idf!36688
2025-02-05 23:57:27 +08:00
morris
1730e74921 Merge branch 'bugfix/uart_single_wire_mode_v5.0' into 'release/v5.0'
fix(uart): allow same pin for tx and rx in uart_set_pin; UART_SELECT_READ_NOTIF race conditon fix (v5.0)

See merge request espressif/esp-idf!36300
2025-02-05 14:53:30 +08:00
Marius Vikhammer
2260b66eb1 Merge branch 'bugfix/remove_wdt_both_cpus_test_v5.0' into 'release/v5.0'
test(panic): remove WDT both CPU test (v5.0)

See merge request espressif/esp-idf!36624
2025-02-05 11:50:24 +08:00
Sarvesh Bodakhe
19f29ca11b Revert "fix(wifi): Add support to recongize different WPA3 Authentication modes from specs"
This reverts commit fbc0c3e9fe.
2025-02-04 10:23:34 +05:30
Rocha Euripedes
9bc65542a4 Merge branch 'fix/test_app_certificate_v5.0' into 'release/v5.0'
Regenerate certificates for testing (v5.0)

See merge request espressif/esp-idf!36676
2025-01-31 16:00:24 +08:00
radek.tandler
3d6cf0f904 fix(storage/nvs): Fixed failing test cases in example folder 2025-01-30 12:05:39 +01:00
Euripedes Rocha
42351e8d15 fix(mqtt): Regenerate certificates for testing
- Previous fix ommited one of the client certificates by mistaque.
- This regenerates all certificates to clean that up.
2025-01-29 14:04:58 +01:00
Marius Vikhammer
6401cad494 test(panic): remove WDT both CPU test
Test never worked on S3/P4 and was flakey on ESP32. Hard to design a reliable test
case that triggers both WDT at the exact same time.
2025-01-27 11:20:39 +01:00
Mahavir Jain
0ce2167242 Merge branch 'feature/memprot_test_app_v5.0' into 'release/v5.0'
test_app: Split `panic` test app into separate source files (v5.0)

See merge request espressif/esp-idf!36625
2025-01-27 17:47:07 +08:00
Laukik Hase
87058b125e test_app: Split panic test app into separate source files
- Added minor improvements to  `panic` test app
  * Replaced existing API to disable flash cache which did not disabled cache always
    (`esp_flash_default_chip->os_func->start(esp_flash_default_chip->os_func_data)`)
    with `spi_flash_enable_interrupts_caches_and_other_cpu`
  * Included some required headers explicitly (`esp_memory_utils.h` and `esp_heap_caps.h`)
2025-01-27 08:33:00 +01:00
laokaiyao
1cef1b3e4d fix(i2s): fixed incorrect logic in slot reconfig
Closes https://github.com/espressif/esp-idf/issues/15256
2025-01-27 14:17:03 +08:00
Song Ruo Jing
1f69df2a37 fix(uart): allow same pin for tx and rx in uart_set_pin
Closes https://github.com/espressif/esp-idf/issues/14787
2025-01-24 22:06:53 +08:00
Song Ruo Jing
ac2ca7bdb4 fix(uart): fix race condition with the use of UART_SELECT_READ_NOTIF
UART_SELECT_READ_NOTIF needs to be sent after received data got processed
to avoid the potential race condition
2025-01-24 22:04:12 +08:00
wanlei
ace1578670 fix(spi_slave_hd): fix seg mode potential iwdt timeout when multi task call 2025-01-24 20:20:33 +08:00
Rahul Tank
d7e63ef591 Merge branch 'bugfix/rename_variable_name_v5.0' into 'release/v5.0'
fix(nimble): fix compilation issue due to incorrect variable name type (v5.0)

See merge request espressif/esp-idf!36606
2025-01-24 20:01:52 +08:00
morris
85443b12f5 Merge branch 'fix/twai_io_init_glitch_v5.0' into 'release/v5.0'
fix(driver_twai): fixed bus-off when twai_init due to wrong gpio config (v5.0)

See merge request espressif/esp-idf!34824
2025-01-24 17:09:25 +08:00
morris
db9e335093 Merge branch 'fix/spi_slave_no_dma_rx_overwrite_v5.0' into 'release/v5.0'
fix(driver_spi): fixed slave no dma rx overwrite when trans_len below or over (v5.0)

See merge request espressif/esp-idf!34177
2025-01-24 16:57:13 +08:00
Astha Verma
773c52b599 fix(nimble): Fix compilation issue in ble_enc_adv_data examples 2025-01-24 12:15:05 +05:30
morris
f3e576a727 Merge branch 'bugfix/modbus_serial_examples_fix_mode' into 'release/v5.0'
fix(modbus): Fix the mode setup in modbus slave (backport v5.0)

See merge request espressif/esp-idf!36114
2025-01-24 13:23:24 +08:00
Rahul Tank
7de5c22f44 Merge branch 'bugfix/fix_few_nimble_issues_v5.0' into 'release/v5.0'
fix(nimble): Fix few nimble issues 11012025 (v5.0)

See merge request espressif/esp-idf!36315
2025-01-24 12:37:30 +08:00
morris
a7b8aed433 Merge branch 'bugfix/esp_rom_gpio_connect_out_signal_patch_v5.0' into 'release/v5.0'
fix(gpio): patched esp_rom_gpio_connect_out_signal for esp32 and esp32s2 (v5.0)

See merge request espressif/esp-idf!35943
2025-01-24 11:16:51 +08:00
aleks
395ad7cd63 fix(modbus): Fix the mode setup in modbus slave
https://github.com/espressif/esp-idf/pull/14878
2025-01-24 11:01:42 +08:00
Kabir Waraich
32b86e8dcd Update slave.c to fix the mode
There is an issue in the lines that I have changed. I think it was copied over from the enum by mistake.
2025-01-24 11:01:42 +08:00
Island
245fb725f2 Merge branch 'bugfix/fixed_ble_issues_241220_v5.0' into 'release/v5.0'
Bugfix/fixed ble issues 241220 (v5.0)

See merge request espressif/esp-idf!35920
2025-01-24 10:53:40 +08:00
Island
743ed7b1d7 Merge branch 'feat/add_get_started_example_on_bluedroid_v5.0' into 'release/v5.0'
feat(bt/bluedroid): Added BLE get started examples for Bluedroid (v5.0)

See merge request espressif/esp-idf!35649
2025-01-24 10:53:13 +08:00
Island
a68962b30c Merge branch 'refactor/optimize_ble_gatt_api_doc_v5.0' into 'release/v5.0'
refactor(bt/bluedroid): Optimize BLE GATT related APIs reference (v5.0)

See merge request espressif/esp-idf!35915
2025-01-24 10:53:08 +08:00
Island
eb5c888782 Merge branch 'bugfix/fix_some_ble_bugs_241224_esp32c3_v5.0' into 'release/v5.0'
Fixed some BLE bugs 241224 on ESP32C3(fd62b31) (v5.0)

See merge request espressif/esp-idf!36192
2025-01-24 10:53:05 +08:00
morris
66745df896 Merge branch 'bugfix/fix_i2s_24b_buf_size_calc_v5.0' into 'release/v5.0'
fix(i2s): fixed some issues in I2S driver (v5.0)

See merge request espressif/esp-idf!35772
2025-01-24 10:29:31 +08:00
Rahul Tank
607a4efccf fix(nimble): Fixed encrypted advertisement menu option dependancy 2025-01-23 17:17:09 +05:30
morris
b3e2d38022 Merge branch 'feat/xmc_32d_support_v5.0' into 'release/v5.0'
feat(spi_flash): support 120M on xmc25q32d flash (backport v5.0)

See merge request espressif/esp-idf!36082
2025-01-23 16:10:59 +08:00
Jiang Jiang Jian
d452461f4c Merge branch 'bugfix/enable_eap_workarounds_v5.0' into 'release/v5.0'
fix(esp_wifi): Enable EAP workarounds by default (v5.0)

See merge request espressif/esp-idf!36156
2025-01-23 16:06:15 +08:00
morris
02e655706d Merge branch 'fix/fix_psram_mode_reg_wrong_timing_v5.0' into 'release/v5.0'
psram: fixed mode reg read bad timing on octal and hex psrams (v5.0)

See merge request espressif/esp-idf!35954
2025-01-23 15:39:18 +08:00
morris
c6de21b7ca Merge branch 'bugfix/channel_resolution_calculation_v5.0' into 'release/v5.0'
fix(rmt): channel resolution divider rounding issue (v5.0)

See merge request espressif/esp-idf!36036
2025-01-23 15:36:02 +08:00
Rahul Tank
62c2eb733b fix(nimble): Corrected storing method of csfc to nvs 2025-01-23 11:23:34 +05:30
shreeyash
437ccaa366 fix(nimble):Updated peer OTA address type 2025-01-23 11:23:34 +05:30
Shreeyash
87c61ee4c6 fix(nimble): Added a check for invalid offset 2025-01-23 11:23:34 +05:30
Rahul Tank
3db0f28c94 fix(nimble): Fix compilation issue for combination of Ext Adv and Reattempt conn flag 2025-01-23 11:23:34 +05:30
Abhinav Kudnar
967a727e24 fix(nimble): Save the gatt context in case of preemption 2025-01-23 11:23:34 +05:30
Astha Verma
f3de540bda fix(nimble): Added a function for printing HCI error definition 2025-01-23 11:23:34 +05:30
Astha Verma
fadd347a41 fix(nimble): fix memory leak issue in Blufi example 2025-01-23 11:23:34 +05:30
Abhinav Kudnar
dd6dfb798b feat(nimble): Additional changes in PAWR IDF Examples/support for ESP IP 2025-01-23 11:23:34 +05:30
Rahul Tank
d4f6071227 fix(nimble): Reset data length global variables 2025-01-23 11:23:34 +05:30
Rahul Tank
e9dde5b336 fix(nimble): Fixed a typo in Kconfig file 2025-01-23 11:23:34 +05:30
Astha Verma
ddfe0657e0 fix(nimble): Added HCI_Read_Remote_Version_Information command 2025-01-23 11:23:34 +05:30
Rahul Tank
c2874d469e fix(nimble): Clear our and peer security records during unpair 2025-01-23 11:23:34 +05:30
Sarvesh Bodakhe
c5e3bc98ee fix(wifi): Fix bug in authmode detection for wpa2/wpa3 enterprise
1. WPA3-Enterprise mandates the use of AKM suite selector
   00:0F:AC:5 (IEEE80211 802.1X with SHA-256)
2. Add placeholder enums in 'wifi_auth_mode_t' for maintaining
   forward compatibility with minor versions > v5.0
2025-01-23 11:23:34 +05:30
Zhang Hai Peng
9cb7206d4a fix(blufi): Fixed some security issue in blufi example
(cherry picked from commit abc18e93eb)

Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
2025-01-22 16:34:19 +08:00
wanckl
562111939e fix(driver_twai): fixed bus-off when twai_init due to wrong gpio config
Closes https://github.com/espressif/esp-idf/issues/14548
2025-01-14 15:58:58 +08:00
morris
21fb8b2a47 fix(rmt): channel resolution divider rounding issue
Closes https://github.com/espressif/esp-idf/issues/15092
2025-01-09 14:34:09 +08:00
Chen Jian Hua
01bcc85fd9 fix(bt): Update bt lib for ESP32-C3 and ESP32-S3(fd62b31)
- Fixed periodic adv enable params checking
- Fixed BLE assert lld_scan.c 1728 when receiving directed adv
- Support resolving RPA to identity address when creating connection
- Fixed BLE assert rwble.c 505 param 00400010
- Fixed peer address type error in HCI LE meta event
- Fixed setting random address failed when extended adv is enabled


(cherry picked from commit 326f391f9c)

Co-authored-by: chenjianhua <chenjianhua@espressif.com>
2025-01-07 14:33:16 +08:00
Sudeep Mohanty
089baafa5b fix(esp_ringbuf): Fixed no-split ringbuf issue where acquire pointer wraps around
This commit fixes an issue with no-split ring buffers where in the the
buffer did not receive items correctly if the acquire pointer wraps
around before items are sent to it.
2025-01-06 16:45:46 +08:00
Kapil Gupta
92f5736c21 fix(esp_wifi): Enable EAP workarounds by default
Enabling this will make sure our behavior is same as upstream
wpa_supplicant.
2025-01-03 17:46:33 +05:30
C.S.M
15e2b9f04b feat(spi_flash): support 120M on xmc25q32d flash 2024-12-31 11:45:44 +08:00
Armando
0bd7ee15f6 fix(psram): fixed mode reg read bad timing on octal and hex psrams 2024-12-27 11:35:57 +08:00
Song Ruo Jing
d555ea2b00 fix(gpio): patched esp_rom_gpio_connect_out_signal for esp32 and esp32s2
The original ROM function enabled output for the pad first, and then connected the signal
This could result in an undesired level change at the pad

Closes https://github.com/espressif/esp-idf/issues/12826
2024-12-25 13:56:46 +08:00
Song Ruo Jing
a1da3ac136 fix(uart): eliminated potential glitch on TX at setup if TX signal is inversed
Closes https://github.com/espressif/esp-idf/issues/14285
2024-12-25 13:56:18 +08:00
zwl
4ad39f320d feat(ble): add dtm configuration command in hci example 2024-12-25 10:02:01 +08:00
laokaiyao
133cbda732 fix(i2s): add check for the tdm frame bits num 2024-12-24 15:47:53 +08:00
laokaiyao
f8e363e307 fix(i2s): fixed the issue in PR 14879
Closes https://github.com/espressif/esp-idf/pull/14879

[Kevin: Update to only remove the limitation for PCM short format]
2024-12-24 15:47:53 +08:00
laokaiyao
45e3474568 fix(i2s): return error when mclk_div is smaller than 2 2024-12-24 15:47:53 +08:00
laokaiyao
ff937be091 fix(i2s): fixed incorrect buf size calculation 2024-12-24 15:47:53 +08:00
Zhao Wei Liang
85e299b939 feat(ble): Support get ble controller free heap size on ESP32-C2
(cherry picked from commit 2cb7d2437b)

Co-authored-by: zwl <zhaoweiliang@espressif.com>
2024-12-24 15:20:54 +08:00
Zhao Wei Liang
2cc6e7c173 feat(ble): fixed some ble issues on ESP32-C2
(cherry picked from commit 5f9a3cdd1a)

Co-authored-by: zwl <zhaoweiliang@espressif.com>
2024-12-24 15:20:51 +08:00
Zhao Wei Liang
f95343e4cd feat(ble): adjust bt default scheme position
(cherry picked from commit 446239251c)

Co-authored-by: zwl <zhaoweiliang@espressif.com>
2024-12-24 15:20:49 +08:00
Chen Jian Hua
67700a0688 Merge branch 'refactor/optimize_ble_gatt_api_doc' into 'master'
refactor(bt/bluedroid): Optimize BLE GATT related APIs reference

See merge request espressif/esp-idf!34650

(cherry picked from commit 19b5381c99)

7320c77d refactor(bt/bluedroid): Optimize BLE GATT related APIs reference
8a80617c refactor(bt/bluedroid): Optimize BLE GATT related APIs reference
0ac97e98 refactor(bt/bluedroid): Optimize BLE GATT related APIs reference
27b17c69 refactor(bt/bluedroid): Optimize BLE GATT related APIs reference
ea8d7686 docs: Update gattc & gatts api header files
f508772f Apply 3 suggestion(s) to 2 file(s)
03469b52 Apply 2 suggestion(s) to 1 file(s)
aa2cf7a5 docs: fix minor issue
46dc6e96 docs(ble): Replaced "closed" with "terminated" for physical connection.

Co-authored-by: Wei Yu Han <weiyuhan@espressif.com>
2024-12-24 15:19:41 +08:00
Chen Jian Hua
15d3576137 feat(bt/bluedroid): Added BLE get started examples for Bluedroid
(cherry picked from commit d051a2a39d)

Co-authored-by: xuzhekai <xuzhekai@espressif.com>
2024-12-21 18:40:36 +08:00
Chen Yudong
af2fe64500 ci: add build test for eco versions 2024-12-19 21:06:04 +08:00
wanckl
cd4b074267 fix(driver_spi): fixed slave no dma rx overwrite when trans_len below or over
Closes https://github.com/espressif/esp-idf/issues/14462
2024-12-19 13:54:10 +08:00
Tomáš Rohlínek
dae7bfa69b fix(storage/vfs_console): stop new console opens from overwriting existing fds 2024-12-05 12:39:59 +01:00
513 changed files with 14306 additions and 4247 deletions

View File

@@ -199,6 +199,22 @@ example_test_pytest_esp32_wifi_two_dut:
- build_pytest_examples_esp32
tags: [ esp32, wifi_two_dut ]
example_test_pytest_esp32c3eco7_wifi_two_dut:
extends:
- .pytest_examples_dir_template
- .rules:test:example_test-esp32c3-wifi
needs:
- build_pytest_examples_esp32c3
tags: [ esp32c3eco7, wifi_two_dut ]
example_test_pytest_esp32c2eco4_wifi_two_dut:
extends:
- .pytest_examples_dir_template
- .rules:test:example_test-esp32c2-wifi
needs:
- build_pytest_examples_esp32c2
tags: [ esp32c2eco4, wifi_two_dut, xtal_26mhz]
example_test_pytest_esp32c3_flash_encryption:
extends:
- .pytest_examples_dir_template
@@ -1012,7 +1028,7 @@ UT_S2_SDSPI:
UT_C2:
extends: .unit_test_esp32c2_template
parallel: 23
parallel: 24
tags:
- ESP32C2_IDF
- UT_T1_1

View File

@@ -6,6 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "esp_log.h"
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <freertos/semphr.h>
@@ -113,3 +114,11 @@ TEST_CASE("esp_ota_get_partition_description", "[ota]")
};
TEST_ESP_ERR(ESP_ERR_NOT_FOUND, bootloader_common_get_partition_description(&not_app_pos, &app_desc1));
}
TEST_CASE("esp_ota_get_running_partition points to correct address", "[spi_flash]")
{
const esp_partition_t *factory = esp_partition_find_first(ESP_PARTITION_TYPE_APP, ESP_PARTITION_SUBTYPE_ANY, "factory");
const esp_partition_t* part = esp_ota_get_running_partition();
ESP_LOGI("running bin", "0x%p", (void*)part->address);
TEST_ASSERT_EQUAL_HEX32(factory->address, part->address);
}

View File

@@ -129,7 +129,7 @@ static esp_err_t bootloader_check_rated_cpu_clock(void)
{
int rated_freq = bootloader_clock_get_rated_freq_mhz();
if (rated_freq < CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ) {
ESP_LOGE(TAG, "Chip CPU frequency rated for %dMHz, configured for %dMHz. Modify CPU frequency in menuconfig",
ESP_LOGE(TAG, "Chip CPU freq rated for %dMHz, configured for %dMHz. Modify CPU freq in menuconfig",
rated_freq, CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ);
return ESP_FAIL;
}

View File

@@ -27,7 +27,8 @@ if(CONFIG_BT_ENABLED)
list(APPEND ldscripts "linker_esp_ble_controller.lf")
elseif(CONFIG_IDF_TARGET_ESP32C2)
list(APPEND srcs "controller/esp32c2/bt.c")
list(APPEND srcs "controller/esp32c2/bt.c"
"controller/esp32c2/ble.c")
list(APPEND include_dirs include/esp32c2/include)
set(ldscripts "linker_esp32c2.lf")
@@ -50,6 +51,7 @@ if(CONFIG_BT_ENABLED)
common/btc/profile/esp/blufi/include
common/btc/profile/esp/include
common/hci_log/include
common/ble_log/include
)
@@ -76,6 +78,7 @@ if(CONFIG_BT_ENABLED)
"common/osi/osi.c"
"common/osi/semaphore.c"
"porting/mem/bt_osi_mem.c"
"common/ble_log/ble_log_spi_out.c"
)
# Host Bluedroid
@@ -514,23 +517,25 @@ if(CONFIG_BT_ENABLED)
if(NOT (CONFIG_BT_LE_CRYPTO_STACK_MBEDTLS OR CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS))
list(APPEND include_dirs
porting/ext/tinycrypt/include
common/tinycrypt/include
common/tinycrypt/port
)
list(APPEND srcs "porting/ext/tinycrypt/src/utils.c"
"porting/ext/tinycrypt/src/sha256.c"
"porting/ext/tinycrypt/src/ecc.c"
"porting/ext/tinycrypt/src/ctr_prng.c"
"porting/ext/tinycrypt/src/ctr_mode.c"
"porting/ext/tinycrypt/src/aes_decrypt.c"
"porting/ext/tinycrypt/src/aes_encrypt.c"
"porting/ext/tinycrypt/src/ccm_mode.c"
"porting/ext/tinycrypt/src/ecc_dsa.c"
"porting/ext/tinycrypt/src/cmac_mode.c"
"porting/ext/tinycrypt/src/ecc_dh.c"
"porting/ext/tinycrypt/src/hmac_prng.c"
"porting/ext/tinycrypt/src/ecc_platform_specific.c"
"porting/ext/tinycrypt/src/hmac.c"
"porting/ext/tinycrypt/src/cbc_mode.c")
list(APPEND srcs "common/tinycrypt/src/utils.c"
"common/tinycrypt/src/sha256.c"
"common/tinycrypt/src/ecc.c"
"common/tinycrypt/src/ctr_prng.c"
"common/tinycrypt/src/ctr_mode.c"
"common/tinycrypt/src/aes_decrypt.c"
"common/tinycrypt/src/aes_encrypt.c"
"common/tinycrypt/src/ccm_mode.c"
"common/tinycrypt/src/ecc_dsa.c"
"common/tinycrypt/src/cmac_mode.c"
"common/tinycrypt/src/ecc_dh.c"
"common/tinycrypt/src/hmac_prng.c"
"common/tinycrypt/src/ecc_platform_specific.c"
"common/tinycrypt/src/hmac.c"
"common/tinycrypt/src/cbc_mode.c"
"common/tinycrypt/port/esp_tinycrypt_port.c")
endif()
if(CONFIG_BT_NIMBLE_ENABLED)
@@ -741,16 +746,20 @@ if(CONFIG_BT_ENABLED)
endif()
elseif(CONFIG_IDF_TARGET_ESP32H2 AND CONFIG_BT_CONTROLLER_ENABLED)
if(CONFIG_IDF_TARGET_ESP32H2_BETA_VERSION_1)
add_prebuilt_library(nimblelib "controller/lib_esp32h2/esp32h2-bt-lib/beta1/libble_app.a")
add_prebuilt_library(nimblelib "controller/lib_esp32h2/esp32h2-bt-lib/beta1/libble_app.a"
REQUIRES esp_phy)
elseif(CONFIG_IDF_TARGET_ESP32H2_BETA_VERSION_2)
add_prebuilt_library(nimblelib "controller/lib_esp32h2/esp32h2-bt-lib/beta2/libble_app.a")
add_prebuilt_library(nimblelib "controller/lib_esp32h2/esp32h2-bt-lib/beta2/libble_app.a"
REQUIRES esp_phy)
endif()
target_link_libraries(${COMPONENT_LIB} PRIVATE nimblelib)
elseif(CONFIG_IDF_TARGET_ESP32C2 AND CONFIG_BT_CONTROLLER_ENABLED)
if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY)
add_prebuilt_library(nimblelib "controller/lib_esp32c2/esp32c2-bt-lib/libble_app_flash.a")
add_prebuilt_library(nimblelib "controller/lib_esp32c2/esp32c2-bt-lib/libble_app_flash.a"
REQUIRES esp_phy)
else()
add_prebuilt_library(nimblelib "controller/lib_esp32c2/esp32c2-bt-lib/libble_app.a")
add_prebuilt_library(nimblelib "controller/lib_esp32c2/esp32c2-bt-lib/libble_app.a"
REQUIRES esp_phy)
endif()
target_link_libraries(${COMPONENT_LIB} PRIVATE nimblelib)
endif()

View File

@@ -4,3 +4,106 @@ config BT_ALARM_MAX_NUM
help
This option decides the maximum number of alarms which
could be used by Bluetooth host.
config BT_BLE_LOG_SPI_OUT_ENABLED
bool "Output ble logs to SPI bus (Experimental)"
default n
help
Output ble logs to SPI bus
config BT_BLE_LOG_SPI_OUT_UL_TASK_BUF_SIZE
int "SPI transaction buffer size for upper layer task logs"
depends on BT_BLE_LOG_SPI_OUT_ENABLED
default 512
help
SPI transaction buffer size for upper layer task logs.
There will be 2 SPI DMA buffers with the same size.
config BT_BLE_LOG_SPI_OUT_HCI_ENABLED
bool "Enable HCI log output to SPI"
depends on BT_BLE_LOG_SPI_OUT_ENABLED
default n
help
Enable logging of HCI packets to the SPI bus when BLE SPI log output is enabled.
config BT_BLE_LOG_SPI_OUT_HOST_ENABLED
bool "Enable Host log output to SPI"
depends on BT_BLE_LOG_SPI_OUT_ENABLED
default n
help
This configuration applies to the logs of both Bluedroid Host and NimBLE Host.
When BLE SPI log output is enabled, this option allows host logs to be transmitted via SPI.
config BT_BLE_LOG_SPI_OUT_LL_ENABLED
bool "Enable Controller log output to SPI"
depends on BT_BLE_LOG_SPI_OUT_ENABLED
depends on BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
default n
help
Enable controller log output to SPI bus.
config BT_BLE_LOG_SPI_OUT_LL_TASK_BUF_SIZE
int "SPI transaction buffer size for lower layer task logs"
depends on BT_BLE_LOG_SPI_OUT_LL_ENABLED
default 1024
help
SPI transaction buffer size for upper layer task logs.
There will be 2 SPI DMA buffers with the same size.
config BT_BLE_LOG_SPI_OUT_LL_ISR_BUF_SIZE
int "SPI transaction buffer size for lower layer ISR logs"
depends on BT_BLE_LOG_SPI_OUT_LL_ENABLED
default 512
help
SPI transaction buffer size for upper layer ISR logs.
There will be 2 SPI DMA buffers with the same size.
config BT_BLE_LOG_SPI_OUT_MOSI_IO_NUM
int "GPIO number of SPI MOSI"
depends on BT_BLE_LOG_SPI_OUT_ENABLED
default 0
help
GPIO number of SPI MOSI
config BT_BLE_LOG_SPI_OUT_SCLK_IO_NUM
int "GPIO number of SPI SCLK"
depends on BT_BLE_LOG_SPI_OUT_ENABLED
default 1
help
GPIO number of SPI SCLK
config BT_BLE_LOG_SPI_OUT_CS_IO_NUM
int "GPIO number of SPI CS"
depends on BT_BLE_LOG_SPI_OUT_ENABLED
default 2
help
GPIO number of SPI CS
config BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
bool "Enable ble log & logic analyzer log time sync"
depends on BT_BLE_LOG_SPI_OUT_ENABLED
default y
help
Enable ble log & logic analyzer log time sync
config BT_BLE_LOG_SPI_OUT_SYNC_IO_NUM
int "GPIO number of SYNC IO"
depends on BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
default 3
help
GPIO number of SYNC IO
config BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
bool "Enable periodic buffer flush out"
depends on BT_BLE_LOG_SPI_OUT_ENABLED
default n
help
Enable periodic buffer flush out
Not recommended when SPI receiver is unavailable
config BT_BLE_LOG_SPI_OUT_FLUSH_TIMEOUT
int "Buffer flush out period in unit of ms"
depends on BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
default 1000
help
Buffer flush out period in unit of ms

View File

@@ -0,0 +1,983 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "ble_log/ble_log_spi_out.h"
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
// Private defines
#define BLE_LOG_TAG "BLE_LOG"
#define SPI_OUT_BUS SPI2_HOST
#define SPI_OUT_MAX_TRANSFER_SIZE 10240
#define SPI_OUT_FRAME_HEAD_LEN 4
#define SPI_OUT_FRAME_TAIL_LEN 4
#define SPI_OUT_FRAME_OVERHEAD (SPI_OUT_FRAME_HEAD_LEN + SPI_OUT_FRAME_TAIL_LEN)
#define SPI_OUT_RECYCLE_TIMEOUT_MS 10
#define SPI_OUT_TRANS_CB_FLAG_AVAILABLE 0
#define SPI_OUT_TRANS_CB_FLAG_NEED_QUEUE 1
#define SPI_OUT_TRANS_CB_FLAG_IN_QUEUE 2
#define SPI_OUT_FLUSHOUT_TIMEOUT (CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMEOUT * 1000)
#define SPI_OUT_PACKET_LOSS_UL 0
#define SPI_OUT_PACKET_LOSS_LL_TASK 1
#define SPI_OUT_PACKET_LOSS_LL_ISR 2
#define SPI_OUT_PACKET_LOSS_FRAME_SIZE 6
#define SPI_OUT_INTERFACE_FLAG_IN_ISR (1 << 3)
#define SPI_OUT_TRANS_ITVL_MIN_US 30
#define SPI_OUT_SPI_MASTER_QUEUE_SIZE 6
#if CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
#define SPI_OUT_TS_SYNC_TIMEOUT (1000 * 1000)
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
// Private typedefs
typedef struct {
// CRITICAL: 0 for available, 1 for need queue (ISR), 2 for in queue
// This flag is for multithreading, must be a word, do not modify
volatile uint32_t flag;
uint16_t buf_size;
uint16_t length;
spi_transaction_t trans;
} spi_out_trans_cb_t;
typedef struct {
spi_out_trans_cb_t *trans_cb[2];
uint8_t trans_cb_idx;
uint8_t frame_cnt;
uint32_t bytes_loss_cnt;
uint8_t trans_loss_cnt;
} spi_out_log_cb_t;
// Private variables
static bool spi_out_inited = false;
static spi_device_handle_t spi_handle = NULL;
static uint32_t last_tx_done_ts = 0;
static bool ul_log_inited = false;
static SemaphoreHandle_t ul_log_mutex = NULL;
static spi_out_log_cb_t *ul_log_cb = NULL;
#if CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
static esp_timer_handle_t ul_log_flushout_timer = NULL;
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
#if CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
static bool ll_log_inited = false;
static spi_out_log_cb_t *ll_task_log_cb = NULL;
static spi_out_log_cb_t *ll_isr_log_cb = NULL;
#if CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
static esp_timer_handle_t ll_log_flushout_timer = NULL;
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
#if CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
static bool ts_sync_inited = false;
static bool sync_io_level = false;
static esp_timer_handle_t ts_sync_timer = NULL;
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
// Extern function declarations
extern void esp_panic_handler_feed_wdts(void);
// Private function declarations
static int spi_out_init_trans(spi_out_trans_cb_t **trans_cb, uint16_t buf_size);
static void spi_out_deinit_trans(spi_out_trans_cb_t **trans_cb);
static void spi_out_tx_done_cb(spi_transaction_t *ret_trans);
static inline int spi_out_append_trans(spi_out_trans_cb_t *trans_cb);
static int spi_out_log_cb_init(spi_out_log_cb_t **log_cb, uint16_t buf_size);
static void spi_out_log_cb_deinit(spi_out_log_cb_t **log_cb);
static inline int spi_out_log_cb_check_trans(spi_out_log_cb_t *log_cb, uint16_t len);
static inline void spi_out_log_cb_append_trans(spi_out_log_cb_t *log_cb);
static inline void spi_out_log_cb_flush_trans(spi_out_log_cb_t *log_cb);
static void spi_out_log_cb_write(spi_out_log_cb_t *log_cb, const uint8_t *addr, uint16_t len, \
const uint8_t *addr_append, uint16_t len_append, uint8_t source);
static void spi_out_log_cb_write_packet_loss(spi_out_log_cb_t *log_cb, uint8_t flag);
static void spi_out_log_cb_dump(spi_out_log_cb_t *log_cb);
static int spi_out_ul_log_init(void);
static void spi_out_ul_log_deinit(void);
#if CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
static void esp_timer_cb_ul_log_flushout(void);
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
#if CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
static int spi_out_ll_log_init(void);
static void spi_out_ll_log_deinit(void);
static void spi_out_ll_log_ev_proc(void);
#if CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
static void esp_timer_cb_ll_log_flushout(void);
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
#if defined(CONFIG_IDF_TARGET_ESP32H2) || defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32C5) ||\
defined(CONFIG_IDF_TARGET_ESP32C61) || defined(CONFIG_IDF_TARGET_ESP32H21)
extern void r_ble_log_simple_put_ev(void);
#define BLE_LOG_LL_PUT_EV r_ble_log_simple_put_ev()
#elif defined(CONFIG_IDF_TARGET_ESP32C2)
extern void ble_log_simple_put_ev(void);
#define BLE_LOG_LL_PUT_EV ble_log_simple_put_ev()
#else
#define BLE_LOG_LL_PUT_EV
#endif
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
#if CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
static int spi_out_ts_sync_init(void);
static void spi_out_ts_sync_deinit(void);
static void esp_timer_cb_ts_sync(void);
#if defined(CONFIG_IDF_TARGET_ESP32H2) || defined(CONFIG_IDF_TARGET_ESP32C6) || defined(CONFIG_IDF_TARGET_ESP32C5) ||\
defined(CONFIG_IDF_TARGET_ESP32C61) || defined(CONFIG_IDF_TARGET_ESP32H21)
extern uint32_t r_ble_lll_timer_current_tick_get(void);
#define SPI_OUT_GET_LC_TIME r_ble_lll_timer_current_tick_get()
#elif defined(CONFIG_IDF_TARGET_ESP32C2)
extern uint32_t r_os_cputime_get32(void);
#define SPI_OUT_GET_LC_TIME r_os_cputime_get32()
#else
#define SPI_OUT_GET_LC_TIME 0
#endif
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
// Private functions
static int spi_out_init_trans(spi_out_trans_cb_t **trans_cb, uint16_t buf_size)
{
// Memory allocations
*trans_cb = (spi_out_trans_cb_t *)malloc(sizeof(spi_out_trans_cb_t));
if (!(*trans_cb)) {
return -1;
}
memset(*trans_cb, 0, sizeof(spi_out_trans_cb_t));
uint8_t *buf = (uint8_t *)heap_caps_malloc(buf_size, MALLOC_CAP_DMA);
if (!buf) {
free(*trans_cb);
*trans_cb = NULL;
return -1;
}
// Initialization
(*trans_cb)->buf_size = buf_size;
(*trans_cb)->trans.tx_buffer = buf;
return 0;
}
static void spi_out_deinit_trans(spi_out_trans_cb_t **trans_cb)
{
if (!(*trans_cb)) {
return;
}
if ((*trans_cb)->trans.tx_buffer) {
free((uint8_t *)(*trans_cb)->trans.tx_buffer);
(*trans_cb)->trans.tx_buffer = NULL;
}
free(*trans_cb);
*trans_cb = NULL;
return;
}
IRAM_ATTR static void spi_out_tx_done_cb(spi_transaction_t *ret_trans)
{
last_tx_done_ts = esp_timer_get_time();
spi_out_trans_cb_t *trans_cb = __containerof(ret_trans, spi_out_trans_cb_t, trans);
trans_cb->length = 0;
trans_cb->flag = SPI_OUT_TRANS_CB_FLAG_AVAILABLE;
}
IRAM_ATTR static void spi_out_pre_tx_cb(spi_transaction_t *ret_trans)
{
// SPI slave continuous transaction workaround
while (esp_timer_get_time() - last_tx_done_ts < SPI_OUT_TRANS_ITVL_MIN_US) {}
}
IRAM_ATTR static inline int spi_out_append_trans(spi_out_trans_cb_t *trans_cb)
{
if (trans_cb->flag != SPI_OUT_TRANS_CB_FLAG_NEED_QUEUE || !trans_cb->length) {
return -1;
}
// CRITICAL: Length unit conversion from bytes to bits
trans_cb->trans.length = trans_cb->length * 8;
trans_cb->trans.rxlength = 0;
if (spi_device_queue_trans(spi_handle, &(trans_cb->trans), 0) == ESP_OK) {
trans_cb->flag = SPI_OUT_TRANS_CB_FLAG_IN_QUEUE;
return 0;
} else {
trans_cb->length = 0;
trans_cb->flag = SPI_OUT_TRANS_CB_FLAG_AVAILABLE;
return -1;
}
}
static int spi_out_log_cb_init(spi_out_log_cb_t **log_cb, uint16_t buf_size)
{
// Initialize log control block
*log_cb = (spi_out_log_cb_t *)malloc(sizeof(spi_out_log_cb_t));
if (!(*log_cb)) {
ESP_LOGE(BLE_LOG_TAG, "Failed to initialize log control block!");
return -1;
}
memset(*log_cb, 0, sizeof(spi_out_log_cb_t));
// Initialize transactions
int ret = 0;
for (uint8_t i = 0; i < 2; i++) {
ret |= spi_out_init_trans(&((*log_cb)->trans_cb[i]), buf_size);
}
if (ret != 0) {
ESP_LOGE(BLE_LOG_TAG, "Failed to initialize SPI transactions!");
spi_out_log_cb_deinit(log_cb);
return -1;
}
return 0;
}
static void spi_out_log_cb_deinit(spi_out_log_cb_t **log_cb)
{
if (!(*log_cb)) {
return;
}
for (uint8_t i = 0; i < 2; i++) {
if ((*log_cb)->trans_cb[i]) {
spi_out_deinit_trans(&((*log_cb)->trans_cb[i]));
}
}
free(*log_cb);
*log_cb = NULL;
return;
}
IRAM_ATTR static inline int spi_out_log_cb_check_trans(spi_out_log_cb_t *log_cb, uint16_t len)
{
spi_out_trans_cb_t *trans_cb;
uint16_t frame_len = len + SPI_OUT_FRAME_OVERHEAD;
for (uint8_t i = 0; i < 2; i++) {
trans_cb = log_cb->trans_cb[log_cb->trans_cb_idx];
if (frame_len > trans_cb->buf_size) {
goto failed;
}
if (trans_cb->flag == SPI_OUT_TRANS_CB_FLAG_AVAILABLE) {
if ((trans_cb->buf_size - trans_cb->length) >= (len + SPI_OUT_FRAME_OVERHEAD)) {
return 0;
} else {
trans_cb->flag = SPI_OUT_TRANS_CB_FLAG_NEED_QUEUE;
}
}
log_cb->trans_cb_idx = !(log_cb->trans_cb_idx);
}
failed:
log_cb->bytes_loss_cnt += len + SPI_OUT_FRAME_OVERHEAD;
log_cb->frame_cnt++;
return -1;
}
// CRITICAL: Shall not be called from ISR!
IRAM_ATTR static inline void spi_out_log_cb_append_trans(spi_out_log_cb_t *log_cb)
{
spi_out_trans_cb_t *trans_cb;
uint8_t idx = !log_cb->trans_cb_idx;
for (uint8_t i = 0; i < 2; i++) {
trans_cb = log_cb->trans_cb[idx];
if (trans_cb->flag == SPI_OUT_TRANS_CB_FLAG_NEED_QUEUE) {
if (spi_out_append_trans(trans_cb) != 0) {
log_cb->trans_loss_cnt++;
}
}
idx = !idx;
}
}
IRAM_ATTR static inline void spi_out_log_cb_flush_trans(spi_out_log_cb_t *log_cb)
{
spi_out_trans_cb_t *trans_cb = log_cb->trans_cb[log_cb->trans_cb_idx];
if (trans_cb->length && (trans_cb->flag == SPI_OUT_TRANS_CB_FLAG_AVAILABLE)) {
trans_cb->flag = SPI_OUT_TRANS_CB_FLAG_NEED_QUEUE;
}
}
IRAM_ATTR static void spi_out_log_cb_write(spi_out_log_cb_t *log_cb, const uint8_t *addr, uint16_t len, \
const uint8_t *addr_append, uint16_t len_append, uint8_t source)
{
spi_out_trans_cb_t *trans_cb = log_cb->trans_cb[log_cb->trans_cb_idx];
uint8_t *buf = (uint8_t *)trans_cb->trans.tx_buffer + trans_cb->length;
uint16_t total_length = len + len_append;
const uint8_t head[4] = {total_length & 0xFF, (total_length >> 8) & 0xFF, source, log_cb->frame_cnt};
uint32_t checksum = 0;
for (int i = 0; i < len; i++) {
checksum += addr[i];
}
for (int i = 0; i < len_append; i++) {
checksum += addr_append[i];
}
memcpy(buf, head, SPI_OUT_FRAME_HEAD_LEN);
memcpy(buf + SPI_OUT_FRAME_HEAD_LEN, addr, len);
if (len_append) {
memcpy(buf + SPI_OUT_FRAME_HEAD_LEN + len, addr_append, len_append);
}
memcpy(buf + SPI_OUT_FRAME_HEAD_LEN + total_length, &checksum, SPI_OUT_FRAME_TAIL_LEN);
trans_cb->length += total_length + SPI_OUT_FRAME_OVERHEAD;
log_cb->frame_cnt++;
if ((trans_cb->buf_size - trans_cb->length) <= SPI_OUT_FRAME_OVERHEAD) {
trans_cb->flag = SPI_OUT_TRANS_CB_FLAG_NEED_QUEUE;
}
return;
}
IRAM_ATTR static void spi_out_log_cb_write_packet_loss(spi_out_log_cb_t *log_cb, uint8_t flag)
{
if (!log_cb->bytes_loss_cnt && !log_cb->trans_loss_cnt) {
return;
}
if (spi_out_log_cb_check_trans(log_cb, SPI_OUT_PACKET_LOSS_FRAME_SIZE) == 0) {
uint8_t packet_loss_frame[SPI_OUT_PACKET_LOSS_FRAME_SIZE];
packet_loss_frame[0] = flag;
memcpy(packet_loss_frame + 1, (uint8_t *)&log_cb->bytes_loss_cnt, 4);
packet_loss_frame[5] = log_cb->trans_loss_cnt;
spi_out_log_cb_write(log_cb, packet_loss_frame, SPI_OUT_PACKET_LOSS_FRAME_SIZE, NULL, 0, BLE_LOG_SPI_OUT_SOURCE_LOSS);
log_cb->bytes_loss_cnt = 0;
log_cb->trans_loss_cnt = 0;
}
}
static void spi_out_log_cb_dump(spi_out_log_cb_t *log_cb)
{
spi_out_trans_cb_t *trans_cb;
uint8_t *buf;
for (uint8_t i = 0; i < 2; i++) {
// Dump the last transaction before dumping the current transaction
log_cb->trans_cb_idx = !(log_cb->trans_cb_idx);
trans_cb = log_cb->trans_cb[log_cb->trans_cb_idx];
buf = (uint8_t *)trans_cb->trans.tx_buffer;
for (uint16_t j = 0; j < trans_cb->buf_size; j++) {
esp_rom_printf("%02x ", buf[j]);
// Feed watchdogs periodically to avoid wdts timeout
if ((j % 100) == 0) {
esp_panic_handler_feed_wdts();
}
}
}
}
static int spi_out_ul_log_init(void)
{
if (ul_log_inited) {
return 0;
}
// Initialize mutex
ul_log_mutex = xSemaphoreCreateMutex();
if (!ul_log_mutex) {
ESP_LOGE(BLE_LOG_TAG, "Failed to create mutex for upper layer task log!");
goto mutex_init_failed;
}
#if CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
// Initialize flushout timer
esp_timer_create_args_t timer_args = {
.callback = (esp_timer_cb_t)esp_timer_cb_ul_log_flushout,
.dispatch_method = ESP_TIMER_TASK
};
if (esp_timer_create(&timer_args, &ul_log_flushout_timer) != ESP_OK) {
ESP_LOGE(BLE_LOG_TAG, "Failed to initialize flushout timer upper layer task log!");
goto timer_init_failed;
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
// Initialize log control block
if (spi_out_log_cb_init(&ul_log_cb, CONFIG_BT_BLE_LOG_SPI_OUT_UL_TASK_BUF_SIZE) != 0) {
ESP_LOGE(BLE_LOG_TAG, "Failed to initialize log control blocks for upper layer task log!");
goto log_cb_init_failed;
}
// Initialization done
ESP_LOGI(BLE_LOG_TAG, "Succeeded to initialize upper layer task log!");
ul_log_inited = true;
return 0;
log_cb_init_failed:
#if CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
esp_timer_delete(ul_log_flushout_timer);
timer_init_failed:
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
vSemaphoreDelete(ul_log_mutex);
mutex_init_failed:
return -1;
}
static void spi_out_ul_log_deinit(void)
{
if (!ul_log_inited) {
return;
}
#if CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
esp_timer_stop(ul_log_flushout_timer);
esp_timer_delete(ul_log_flushout_timer);
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
xSemaphoreTake(ul_log_mutex, portMAX_DELAY);
spi_out_log_cb_deinit(&ul_log_cb);
xSemaphoreGive(ul_log_mutex);
vSemaphoreDelete(ul_log_mutex);
ul_log_mutex = NULL;
ESP_LOGI(BLE_LOG_TAG, "Succeeded to deinitialize upper layer log!");
ul_log_inited = false;
return;
}
#if CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
IRAM_ATTR static void esp_timer_cb_ul_log_flushout(void)
{
xSemaphoreTake(ul_log_mutex, portMAX_DELAY);
spi_out_log_cb_flush_trans(ul_log_cb);
spi_out_log_cb_append_trans(ul_log_cb);
xSemaphoreGive(ul_log_mutex);
esp_timer_start_once(ul_log_flushout_timer, SPI_OUT_FLUSHOUT_TIMEOUT);
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
#if CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
static int spi_out_ll_log_init(void)
{
if (ll_log_inited) {
return 0;
}
#if CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
// Initialize flushout timer
esp_timer_create_args_t timer_args = {
.callback = (esp_timer_cb_t)esp_timer_cb_ll_log_flushout,
.dispatch_method = ESP_TIMER_TASK
};
if (esp_timer_create(&timer_args, &ll_log_flushout_timer) != ESP_OK) {
ESP_LOGE(BLE_LOG_TAG, "Failed to initialize flushout timer for controller log!");
goto timer_init_failed;
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
// Initialize log control blocks for controller task & ISR logs
if (spi_out_log_cb_init(&ll_task_log_cb, CONFIG_BT_BLE_LOG_SPI_OUT_LL_TASK_BUF_SIZE) != 0) {
ESP_LOGE(BLE_LOG_TAG, "Failed to initialize log control blocks for controller task!");
goto task_log_cb_init_failed;
}
if (spi_out_log_cb_init(&ll_isr_log_cb, CONFIG_BT_BLE_LOG_SPI_OUT_LL_ISR_BUF_SIZE) != 0) {
ESP_LOGE(BLE_LOG_TAG, "Failed to initialize log control blocks for controller ISR!");
goto isr_log_cb_init_failed;
}
// Initialization done
ESP_LOGI(BLE_LOG_TAG, "Succeeded to initialize log control blocks for controller task & ISR!");
ll_log_inited = true;
return 0;
isr_log_cb_init_failed:
spi_out_log_cb_deinit(&ll_task_log_cb);
task_log_cb_init_failed:
#if CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
esp_timer_delete(ll_log_flushout_timer);
timer_init_failed:
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
return -1;
}
static void spi_out_ll_log_deinit(void)
{
if (!ll_log_inited) {
return;
}
#if CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
esp_timer_stop(ll_log_flushout_timer);
esp_timer_delete(ll_log_flushout_timer);
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
spi_out_log_cb_deinit(&ll_isr_log_cb);
spi_out_log_cb_deinit(&ll_task_log_cb);
// Deinitialization done
ESP_LOGI(BLE_LOG_TAG, "Succeeded to deinitialize controller log!");
ll_log_inited = false;
return;
}
IRAM_ATTR static void spi_out_ll_log_ev_proc(void)
{
#if CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
// Request from flushout timer
spi_out_log_cb_flush_trans(ll_isr_log_cb);
spi_out_log_cb_append_trans(ll_isr_log_cb);
spi_out_log_cb_flush_trans(ll_task_log_cb);
spi_out_log_cb_append_trans(ll_task_log_cb);
esp_timer_start_once(ll_log_flushout_timer, SPI_OUT_FLUSHOUT_TIMEOUT);
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
return;
}
#if CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
IRAM_ATTR static void esp_timer_cb_ll_log_flushout(void)
{
BLE_LOG_LL_PUT_EV;
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
#if CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
static int spi_out_ts_sync_init(void)
{
if (ts_sync_inited) {
return 0;
}
// Initialize sync timer
esp_timer_create_args_t timer_args = {
.callback = (esp_timer_cb_t)esp_timer_cb_ts_sync,
.dispatch_method = ESP_TIMER_TASK
};
if (esp_timer_create(&timer_args, &ts_sync_timer) != ESP_OK) {
ESP_LOGE(BLE_LOG_TAG, "Failed to initialize timestamp synchronizer timer!");
goto timer_init_failed;
}
// Initialize sync IO
gpio_config_t io_conf = {
.intr_type = GPIO_INTR_DISABLE,
.mode = GPIO_MODE_OUTPUT,
.pin_bit_mask = (1UL << CONFIG_BT_BLE_LOG_SPI_OUT_SYNC_IO_NUM),
.pull_down_en = 0,
.pull_up_en = 0
};
if (gpio_config(&io_conf) != ESP_OK) {
ESP_LOGE(BLE_LOG_TAG, "Failed to initialize timestamp synchronizer IO!");
goto gpio_init_failed;
}
// Initialization done
ESP_LOGI(BLE_LOG_TAG, "Succeeded to initialize timestamp synchronizer!");
sync_io_level = false;
gpio_set_level(CONFIG_BT_BLE_LOG_SPI_OUT_SYNC_IO_NUM, sync_io_level);
ts_sync_inited = true;
return 0;
gpio_init_failed:
esp_timer_delete(ts_sync_timer);
timer_init_failed:
return -1;
}
static void spi_out_ts_sync_deinit(void)
{
if (!ts_sync_inited) {
return;
}
// Deinitialize timestamp synchronizer
esp_timer_stop(ts_sync_timer);
esp_timer_delete(ts_sync_timer);
// Deinitialize sync IO
sync_io_level = false;
gpio_set_level(CONFIG_BT_BLE_LOG_SPI_OUT_SYNC_IO_NUM, sync_io_level);
gpio_reset_pin(CONFIG_BT_BLE_LOG_SPI_OUT_SYNC_IO_NUM);
// Deinitialization done
ESP_LOGI(BLE_LOG_TAG, "Succeeded to deinitialize timestamp synchronizer!");
ts_sync_inited = false;
return;
}
// CRITICAL: This function is called in ESP Timer task
static void esp_timer_cb_ts_sync(void)
{
// Initialize variables
uint32_t lc_ts = 0;
uint32_t esp_ts = 0;
// Toggle sync IO
sync_io_level = !sync_io_level;
// Enter critical
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL(&spinlock);
// Get LC timestamp
lc_ts = SPI_OUT_GET_LC_TIME;
// Set sync IO level
gpio_set_level(CONFIG_BT_BLE_LOG_SPI_OUT_SYNC_IO_NUM, (uint32_t)sync_io_level);
// Get ESP timestamp
esp_ts = esp_timer_get_time();
portEXIT_CRITICAL(&spinlock);
// Exit critical
// Write timestamp sync log
uint8_t sync_frame[9];
sync_frame[0] = ((uint8_t)sync_io_level & 0xFF);
memcpy(sync_frame + 1, &lc_ts, sizeof(lc_ts));
memcpy(sync_frame + 5, &esp_ts, sizeof(esp_ts));
ble_log_spi_out_write(BLE_LOG_SPI_OUT_SOURCE_SYNC, sync_frame, 9);
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
// Public functions
int ble_log_spi_out_init(void)
{
// Avoid double init
if (spi_out_inited) {
return 0;
}
// Initialize SPI
spi_bus_config_t bus_config = {
.miso_io_num = -1,
.mosi_io_num = CONFIG_BT_BLE_LOG_SPI_OUT_MOSI_IO_NUM,
.sclk_io_num = CONFIG_BT_BLE_LOG_SPI_OUT_SCLK_IO_NUM,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
.max_transfer_sz = SPI_OUT_MAX_TRANSFER_SIZE,
#if CONFIG_SPI_MASTER_ISR_IN_IRAM
.intr_flags = ESP_INTR_FLAG_IRAM
#endif // CONFIG_SPI_MASTER_ISR_IN_IRAM
};
spi_device_interface_config_t dev_config = {
.clock_speed_hz = SPI_MASTER_FREQ_20M,
.mode = 0,
.spics_io_num = CONFIG_BT_BLE_LOG_SPI_OUT_CS_IO_NUM,
.queue_size = SPI_OUT_SPI_MASTER_QUEUE_SIZE,
.post_cb = spi_out_tx_done_cb,
.pre_cb = spi_out_pre_tx_cb
};
if (spi_bus_initialize(SPI_OUT_BUS, &bus_config, SPI_DMA_CH_AUTO) != ESP_OK) {
ESP_LOGE(BLE_LOG_TAG, "Failed to initialize SPI bus!");
goto spi_bus_init_failed;
}
if (spi_bus_add_device(SPI_OUT_BUS, &dev_config, &spi_handle) != ESP_OK) {
ESP_LOGE(BLE_LOG_TAG, "Failed to add device to SPI bus!");
goto spi_device_add_failed;
}
if (spi_out_ul_log_init() != 0) {
goto ul_log_init_failed;
}
#if CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
if (spi_out_ll_log_init() != 0) {
goto ll_log_init_failed;
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
#if CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
if (spi_out_ts_sync_init() != 0) {
goto ts_sync_init_failed;
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
// Initialization done
ESP_LOGI(BLE_LOG_TAG, "Succeeded to initialize BLE log SPI output interface!");
spi_out_inited = true;
#if CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
// Start flushout timer
esp_timer_start_once(ul_log_flushout_timer, SPI_OUT_FLUSHOUT_TIMEOUT);
#if CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
esp_timer_start_once(ll_log_flushout_timer, SPI_OUT_FLUSHOUT_TIMEOUT);
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_FLUSH_TIMER_ENABLED
return 0;
#if CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
ts_sync_init_failed:
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
#if CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
spi_out_ll_log_deinit();
ll_log_init_failed:
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
spi_out_ul_log_deinit();
ul_log_init_failed:
spi_bus_remove_device(spi_handle);
spi_handle = NULL;
spi_device_add_failed:
spi_bus_free(SPI_OUT_BUS);
spi_bus_init_failed:
return -1;
}
void ble_log_spi_out_deinit(void)
{
// Avoid double deinit
if (!spi_out_inited) {
return;
}
// Drain all queued transactions
assert(spi_device_acquire_bus(spi_handle, portMAX_DELAY) == ESP_OK);
spi_device_release_bus(spi_handle);
// Remove SPI master
spi_bus_remove_device(spi_handle);
spi_handle = NULL;
spi_bus_free(SPI_OUT_BUS);
#if CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
spi_out_ts_sync_deinit();
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
#if CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
spi_out_ll_log_deinit();
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
spi_out_ul_log_deinit();
// Reset init flag
spi_out_inited = false;
}
#if CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
void ble_log_spi_out_ts_sync_start(void)
{
// Check if SPI out is initialized
if (!spi_out_inited) {
return;
}
// Start timestamp sync timer
if (ts_sync_timer) {
if (!esp_timer_is_active(ts_sync_timer)) {
esp_timer_start_periodic(ts_sync_timer, SPI_OUT_TS_SYNC_TIMEOUT);
}
}
}
void ble_log_spi_out_ts_sync_stop(void)
{
// Check if SPI out is initialized
if (!spi_out_inited) {
return;
}
// Stop timestamp sync timer
if (ts_sync_timer) {
if (esp_timer_is_active(ts_sync_timer)) {
esp_timer_stop(ts_sync_timer);
}
// Set sync IO to low level
sync_io_level = 0;
gpio_set_level(CONFIG_BT_BLE_LOG_SPI_OUT_SYNC_IO_NUM, (uint32_t)sync_io_level);
}
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_TS_SYNC_ENABLED
#if CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
// Only LL task has access to this API
IRAM_ATTR void ble_log_spi_out_ll_write(uint32_t len, const uint8_t *addr, uint32_t len_append,\
const uint8_t *addr_append, uint32_t flag)
{
if (!ll_log_inited) {
return;
}
bool in_isr = (bool)(flag & SPI_OUT_INTERFACE_FLAG_IN_ISR);
uint8_t source = in_isr ? BLE_LOG_SPI_OUT_SOURCE_ESP_ISR : BLE_LOG_SPI_OUT_SOURCE_ESP;
spi_out_log_cb_t *log_cb = in_isr ? ll_isr_log_cb : ll_task_log_cb;
uint16_t total_length = (uint16_t)(len + len_append);
if (spi_out_log_cb_check_trans(log_cb, total_length) == 0) {
spi_out_log_cb_write(log_cb, addr, (uint16_t)len, addr_append, (uint16_t)len_append, source);
if (in_isr) {
spi_out_log_cb_write_packet_loss(log_cb, SPI_OUT_PACKET_LOSS_LL_ISR);
} else {
spi_out_log_cb_append_trans(ll_isr_log_cb);
spi_out_log_cb_append_trans(ll_task_log_cb);
spi_out_log_cb_write_packet_loss(log_cb, SPI_OUT_PACKET_LOSS_LL_TASK);
}
}
return;
}
IRAM_ATTR void ble_log_spi_out_ll_log_ev_proc(void)
{
if (!ll_log_inited) {
return;
}
return spi_out_ll_log_ev_proc();
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
int ble_log_spi_out_write(uint8_t source, const uint8_t *addr, uint16_t len)
{
if (!ul_log_inited) {
return -1;
}
xSemaphoreTake(ul_log_mutex, portMAX_DELAY);
if (spi_out_log_cb_check_trans(ul_log_cb, len) == 0) {
spi_out_log_cb_write(ul_log_cb, addr, len, NULL, 0, source);
spi_out_log_cb_append_trans(ul_log_cb);
spi_out_log_cb_write_packet_loss(ul_log_cb, SPI_OUT_PACKET_LOSS_UL);
}
xSemaphoreGive(ul_log_mutex);
return 0;
}
int ble_log_spi_out_printf(uint8_t source, const char *format, ...)
{
if (!ul_log_inited) {
return -1;
}
// Get arguments
va_list args;
va_start(args, format);
// Get len as ref to allocate heap memory
va_list args_copy;
va_copy(args_copy, args);
int len = vsnprintf(NULL, 0, format, args_copy);
va_end(args_copy);
// Length validation
if ((len < 0) || (len > 0xFFFF)) {
va_end(args);
return -1;
}
// Allocate memory
uint8_t *buffer = malloc(len + 1);
if (!buffer) {
va_end(args);
return -1;
}
// Generate string
vsnprintf((char *)buffer, len + 1, format, args);
va_end(args);
uint32_t esp_ts = esp_timer_get_time();
xSemaphoreTake(ul_log_mutex, portMAX_DELAY);
if (spi_out_log_cb_check_trans(ul_log_cb, sizeof(uint32_t) + len) == 0) {
spi_out_log_cb_write(ul_log_cb, (const uint8_t *)&esp_ts, sizeof(uint32_t), (const uint8_t *)buffer, len, source);
spi_out_log_cb_append_trans(ul_log_cb);
spi_out_log_cb_write_packet_loss(ul_log_cb, SPI_OUT_PACKET_LOSS_UL);
}
xSemaphoreGive(ul_log_mutex);
// Release
free(buffer);
return 0;
}
int ble_log_spi_out_printf_enh(uint8_t source, uint8_t level, const char *tag, const char *format, ...)
{
if (!ul_log_inited) {
return -1;
}
// Create log prefix in the format: "[level][tag] "
char prefix[32];
int prefix_len = snprintf(prefix, sizeof(prefix), "[%d][%s] ", level, tag ? tag : "NULL");
// Compute the length of the formatted log message
va_list args;
va_start(args, format);
va_list args_copy;
va_copy(args_copy, args);
int log_len = vsnprintf(NULL, 0, format, args_copy);
va_end(args_copy);
// Validate length
if (log_len < 0 || log_len > 0xFFFF) {
va_end(args);
return -1;
}
// Compute total log length (prefix + formatted message)
int total_len = prefix_len + log_len;
// Allocate memory for the complete log message
uint8_t *buffer = malloc(total_len + 1);
if (!buffer) {
va_end(args);
return -1;
}
// Construct the final log message
memcpy(buffer, prefix, prefix_len); // Copy the prefix
vsnprintf((char *)(buffer + prefix_len), log_len + 1, format, args);
va_end(args);
uint32_t esp_ts = esp_timer_get_time();
xSemaphoreTake(ul_log_mutex, portMAX_DELAY);
if (spi_out_log_cb_check_trans(ul_log_cb, sizeof(uint32_t) + total_len) == 0) {
spi_out_log_cb_write(ul_log_cb, (const uint8_t *)&esp_ts, sizeof(uint32_t), (const uint8_t *)buffer, total_len, source);
spi_out_log_cb_append_trans(ul_log_cb);
spi_out_log_cb_write_packet_loss(ul_log_cb, SPI_OUT_PACKET_LOSS_UL);
}
xSemaphoreGive(ul_log_mutex);
free(buffer);
return 0;
}
int ble_log_spi_out_write_with_ts(uint8_t source, const uint8_t *addr, uint16_t len)
{
if (!ul_log_inited) {
return -1;
}
uint32_t esp_ts = esp_timer_get_time();
xSemaphoreTake(ul_log_mutex, portMAX_DELAY);
if (spi_out_log_cb_check_trans(ul_log_cb, sizeof(uint32_t) + len) == 0) {
spi_out_log_cb_write(ul_log_cb, (const uint8_t *)&esp_ts, sizeof(uint32_t), addr, len, source);
spi_out_log_cb_append_trans(ul_log_cb);
spi_out_log_cb_write_packet_loss(ul_log_cb, SPI_OUT_PACKET_LOSS_UL);
}
xSemaphoreGive(ul_log_mutex);
return 0;
}
void ble_log_spi_out_dump_all(void)
{
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL_SAFE(&spinlock);
#if CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
if (ll_log_inited) {
// Dump lower layer log buffer
esp_rom_printf("[LL_ISR_LOG_DUMP_START:\n");
spi_out_log_cb_dump(ll_isr_log_cb);
esp_rom_printf("\n:LL_ISR_LOG_DUMP_END]\n\n");
esp_rom_printf("[LL_TASK_LOG_DUMP_START:\n");
spi_out_log_cb_dump(ll_task_log_cb);
esp_rom_printf("\n:LL_TASK_LOG_DUMP_END]\n\n");
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_LL_ENABLED
if (ul_log_inited) {
// Dump upper layer log buffer
esp_rom_printf("[UL_LOG_DUMP_START:\n");
spi_out_log_cb_dump(ul_log_cb);
esp_rom_printf("\n:UL_LOG_DUMP_END]\n\n");
}
portEXIT_CRITICAL_SAFE(&spinlock);
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED

View File

@@ -0,0 +1,54 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef __BT_SPI_OUT_H__
#define __BT_SPI_OUT_H__
#include <stdarg.h>
#include <string.h>
#include "driver/spi_master.h"
#include "driver/gpio.h"
#include "esp_timer.h"
#include "esp_log.h"
#include "freertos/semphr.h"
// Public typedefs
#define BLE_LOG_SPI_OUT_SOURCE_ESP 0
#define BLE_LOG_SPI_OUT_SOURCE_ESP_LEGACY 1
#define BLE_LOG_SPI_OUT_SOURCE_BLUEDROID 2
#define BLE_LOG_SPI_OUT_SOURCE_NIMBLE 3
#define BLE_LOG_SPI_OUT_SOURCE_HCI_UPSTREAM 4
#define BLE_LOG_SPI_OUT_SOURCE_HCI_DOWNSTREAM 5
#define BLE_LOG_SPI_OUT_SOURCE_ESP_ISR 6
#define BLE_LOG_SPI_OUT_SOURCE_ESP_LEGACY_ISR 7
#define BLE_LOG_SPI_OUT_SOURCE_USER 0x10
#define BLE_LOG_SPI_OUT_SOURCE_SYNC 0xFE
#define BLE_LOG_SPI_OUT_SOURCE_LOSS 0xFF
// SPI Log Level Definitions
#define BLE_LOG_SPI_OUT_LEVEL_NONE 0 /*!< No log output */
#define BLE_LOG_SPI_OUT_LEVEL_ERROR 1 /*!< Critical errors that SPI driver cannot recover from */
#define BLE_LOG_SPI_OUT_LEVEL_WARN 2 /*!< Recoverable error conditions in SPI communication */
#define BLE_LOG_SPI_OUT_LEVEL_INFO 3 /*!< Informational messages about SPI transactions */
#define BLE_LOG_SPI_OUT_LEVEL_DEBUG 4 /*!< Detailed debug information, such as SPI register values */
#define BLE_LOG_SPI_OUT_LEVEL_VERBOSE 5 /*!< Very detailed debugging logs, potentially flooding output */
#define BLE_LOG_SPI_OUT_LEVEL_MAX 6 /*!< Number of SPI log levels supported */
// Public functions
int ble_log_spi_out_init(void);
void ble_log_spi_out_deinit(void);
void ble_log_spi_out_timer_control(bool enable);
int ble_log_spi_out_write(uint8_t source, const uint8_t *addr, uint16_t len);
void ble_log_spi_out_ll_write(uint32_t len, const uint8_t *addr, uint32_t len_append,\
const uint8_t *addr_append, uint32_t flag);
void ble_log_spi_out_ll_log_ev_proc(void);
void ble_log_spi_out_ts_sync_start(void);
void ble_log_spi_out_ts_sync_stop(void);
int ble_log_spi_out_printf(uint8_t source, const char *format, ...);
int ble_log_spi_out_printf_enh(uint8_t source, uint8_t level, const char *tag, const char *format, ...);
int ble_log_spi_out_write_with_ts(uint8_t source, const uint8_t *addr, uint16_t len);
void ble_log_spi_out_dump_all(void);
#endif // __BT_SPI_OUT_H__

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -16,6 +16,12 @@ void **btc_profile_cb_tab;
void esp_profile_cb_reset(void)
{
#if BTC_DYNAMIC_MEMORY == TRUE
if (btc_profile_cb_tab == NULL) {
return;
}
#endif
int i;
for (i = 0; i < BTC_PID_NUM; i++) {
@@ -25,6 +31,12 @@ void esp_profile_cb_reset(void)
int btc_profile_cb_set(btc_pid_t profile_id, void *cb)
{
#if BTC_DYNAMIC_MEMORY == TRUE
if (btc_profile_cb_tab == NULL) {
return -1;
}
#endif
if (profile_id < 0 || profile_id >= BTC_PID_NUM) {
return -1;
}
@@ -36,6 +48,12 @@ int btc_profile_cb_set(btc_pid_t profile_id, void *cb)
void *btc_profile_cb_get(btc_pid_t profile_id)
{
#if BTC_DYNAMIC_MEMORY == TRUE
if (btc_profile_cb_tab == NULL) {
return NULL;
}
#endif
if (profile_id < 0 || profile_id >= BTC_PID_NUM) {
return NULL;
}

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -95,7 +95,29 @@ void btc_blufi_report_error(esp_blufi_error_state_t state)
void btc_blufi_recv_handler(uint8_t *data, int len)
{
if (len < sizeof(struct blufi_hdr)) {
BTC_TRACE_ERROR("%s invalid data length: %d", __func__, len);
btc_blufi_report_error(ESP_BLUFI_DATA_FORMAT_ERROR);
return;
}
struct blufi_hdr *hdr = (struct blufi_hdr *)data;
// Verify if the received data length matches the expected length based on the BLUFI protocol
int target_data_len;
if (BLUFI_FC_IS_CHECK(hdr->fc)) {
target_data_len = hdr->data_len + 4 + 2; // Data + (Type + Frame Control + Sequence Number + Data Length) + Checksum
} else {
target_data_len = hdr->data_len + 4; // Data + (Type + Frame Control + Sequence Number + Data Length)
}
if (len != target_data_len) {
BTC_TRACE_ERROR("%s: Invalid data length: %d, expected: %d", __func__, len, target_data_len);
btc_blufi_report_error(ESP_BLUFI_DATA_FORMAT_ERROR);
return;
}
uint16_t checksum, checksum_pkt;
int ret;

View File

@@ -44,6 +44,7 @@ void esp_blufi_gatt_svr_register_cb(struct ble_gatt_register_ctxt *ctxt, void *a
/* Initialise gatt server */
int esp_blufi_gatt_svr_init(void);
int esp_blufi_gatt_svr_deinit(void);
void esp_blufi_btc_init(void);
void esp_blufi_btc_deinit(void);
#endif

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -240,6 +240,32 @@ static void init_gatt_values(void)
}
static void deinit_gatt_values(void)
{
int i = 0;
const struct ble_gatt_svc_def *svc;
const struct ble_gatt_chr_def *chr;
const struct ble_gatt_dsc_def *dsc;
for (svc = gatt_svr_svcs; svc && svc->uuid; svc++) {
for (chr = svc->characteristics; chr && chr->uuid; chr++) {
if (i < SERVER_MAX_VALUES && gatt_values[i].buf != NULL) {
os_mbuf_free(gatt_values[i].buf); /* Free the buffer */
gatt_values[i].buf = NULL; /* Nullify the pointer to avoid dangling references */
}
++i;
for (dsc = chr->descriptors; dsc && dsc->uuid; dsc++) {
if (i < SERVER_MAX_VALUES && gatt_values[i].buf != NULL) {
os_mbuf_free(gatt_values[i].buf); /* Free the buffer */
gatt_values[i].buf = NULL; /* Nullify the pointer to avoid dangling references */
}
++i;
}
}
}
}
int esp_blufi_gatt_svr_init(void)
{
int rc;
@@ -260,6 +286,18 @@ int esp_blufi_gatt_svr_init(void)
return 0;
}
int esp_blufi_gatt_svr_deinit(void)
{
deinit_gatt_values();
ble_gatts_free_svcs();
/* Deinitialize BLE GATT and GAP services */
ble_svc_gatt_deinit();
ble_svc_gap_deinit();
return 0;
}
static int
esp_blufi_gap_event(struct ble_gap_event *event, void *arg)
{

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -84,6 +84,20 @@
#define BT_HCI_LOG_INCLUDED FALSE
#endif
// HCI LOG TO SPI
#if UC_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
#define BT_BLE_LOG_SPI_OUT_HCI_ENABLED UC_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
#else
#define BT_BLE_LOG_SPI_OUT_HCI_ENABLED FALSE
#endif
// BLURDROID LOG TO SPI
#if UC_BT_BLE_LOG_SPI_OUT_HOST_ENABLED
#define BT_BLE_LOG_SPI_OUT_HOST_ENABLED UC_BT_BLE_LOG_SPI_OUT_HOST_ENABLED
#else
#define BT_BLE_LOG_SPI_OUT_HOST_ENABLED FALSE
#endif
#if UC_BT_HCI_LOG_DATA_BUFFER_SIZE
#define HCI_LOG_DATA_BUFFER_SIZE UC_BT_HCI_LOG_DATA_BUFFER_SIZE
#else

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -120,6 +120,20 @@
#define UC_BT_HCI_LOG_DEBUG_EN FALSE
#endif
//HCI LOG TO SPI
#ifdef CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
#define UC_BT_BLE_LOG_SPI_OUT_HCI_ENABLED TRUE
#else
#define UC_BT_BLE_LOG_SPI_OUT_HCI_ENABLED FALSE
#endif
//BLUEDROID LOG TO SPI
#ifdef CONFIG_BT_BLE_LOG_SPI_OUT_HOST_ENABLED
#define UC_BT_BLE_LOG_SPI_OUT_HOST_ENABLED TRUE
#else
#define UC_BT_BLE_LOG_SPI_OUT_HOST_ENABLED FALSE
#endif
#ifdef CONFIG_BT_HCI_LOG_DATA_BUFFER_SIZE
#define UC_BT_HCI_LOG_DATA_BUFFER_SIZE CONFIG_BT_HCI_LOG_DATA_BUFFER_SIZE
#else

View File

@@ -76,4 +76,8 @@ void fixed_pkt_queue_unregister_dequeue(fixed_pkt_queue_t *queue);
void fixed_pkt_queue_process(fixed_pkt_queue_t *queue);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -1,4 +1,8 @@
/* aes.h - TinyCrypt interface to an AES-128 implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@@ -1,4 +1,8 @@
/* cbc_mode.h - TinyCrypt interface to a CBC mode implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@@ -1,4 +1,8 @@
/* ccm_mode.h - TinyCrypt interface to a CCM mode implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@@ -1,4 +1,8 @@
/* cmac_mode.h -- interface to a CMAC implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved

View File

@@ -1,4 +1,8 @@
/* constants.h - TinyCrypt interface to constants */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@@ -1,4 +1,8 @@
/* ctr_mode.h - TinyCrypt interface to CTR mode */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* ctr_prng.h - TinyCrypt interface to a CTR-PRNG implementation */
/*

View File

@@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* ecc.h - TinyCrypt interface to common ECC functions */
/* Copyright (c) 2014, Kenneth MacKay

View File

@@ -1,4 +1,8 @@
/* ecc_dh.h - TinyCrypt interface to EC-DH implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (c) 2014, Kenneth MacKay

View File

@@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* ecc_dh.h - TinyCrypt interface to EC-DSA implementation */
/*

View File

@@ -1,4 +1,8 @@
/* uECC_platform_specific.h - Interface to platform specific functions*/
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* Copyright (c) 2014, Kenneth MacKay
* All rights reserved.

View File

@@ -1,4 +1,8 @@
/* hmac.h - TinyCrypt interface to an HMAC implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
@@ -124,7 +128,7 @@ int tc_hmac_update(TCHmacState_t ctx, const void *data,
* key == NULL or
* taglen != TC_SHA256_DIGEST_SIZE
* @note ctx is erased before exiting. This should never be changed/removed.
* @note Assumes the tag bufer is at least sizeof(hmac_tag_size(state)) bytes
* @note Assumes the tag buffer is at least sizeof(hmac_tag_size(state)) bytes
* state has been initialized by tc_hmac_init
* @param tag IN/OUT -- buffer to receive computed HMAC tag
* @param taglen IN -- size of tag in bytes

View File

@@ -1,4 +1,8 @@
/* hmac_prng.h - TinyCrypt interface to an HMAC-PRNG implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* sha256.h - TinyCrypt interface to a SHA-256 implementation */
/*

View File

@@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* utils.h - TinyCrypt interface to platform-dependent run-time operations */
/*

View File

@@ -0,0 +1,70 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "esp_tinycrypt_port.h"
#if SOC_ECC_SUPPORTED
#include "esp_crypto_lock.h"
#include "esp_private/periph_ctrl.h"
#include "hal/ecc_hal.h"
#include "hal/ecc_ll.h"
static void esp_tinycrypt_acquire_ecc_hardware(void)
{
esp_crypto_ecc_lock_acquire();
periph_module_enable(PERIPH_ECC_MODULE);
}
static void esp_tinycrypt_release_ecc_hardware(void)
{
periph_module_disable(PERIPH_ECC_MODULE);
esp_crypto_ecc_lock_release();
}
int esp_tinycrypt_verify_ecc_point(const uint8_t *pk_x, const uint8_t *pk_y, uint8_t length)
{
int result;
esp_tinycrypt_acquire_ecc_hardware();
ecc_hal_write_verify_param(pk_x, pk_y, length);
ecc_hal_set_mode(ECC_MODE_VERIFY);
ecc_hal_start_calc();
while (!ecc_hal_is_calc_finished());
result = ecc_hal_read_verify_result();
esp_tinycrypt_release_ecc_hardware();
if (result == 1) {
return 0;
} else {
return -1;
}
}
int esp_tinycrypt_calc_ecc_mult(const uint8_t *p_x, const uint8_t *p_y, const uint8_t *scalar,
uint8_t *r_x, uint8_t *r_y, uint8_t num_bytes, bool verify_first)
{
int ret = -1;
ecc_mode_t work_mode = verify_first ? ECC_MODE_VERIFY_THEN_POINT_MUL : ECC_MODE_POINT_MUL;
esp_tinycrypt_acquire_ecc_hardware();
ecc_hal_write_mul_param(scalar, p_x, p_y, num_bytes);
ecc_hal_set_mode(work_mode);
ecc_hal_start_calc();
while (!ecc_hal_is_calc_finished());
ret = ecc_hal_read_mul_result(r_x, r_y, num_bytes);
esp_tinycrypt_release_ecc_hardware();
return ret;
}
#endif /* SOC_ECC_SUPPORTED */

View File

@@ -0,0 +1,15 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdint.h>
#include <stdbool.h>
#include "soc/soc_caps.h"
#if SOC_ECC_SUPPORTED
int esp_tinycrypt_verify_ecc_point(const uint8_t *pk_x, const uint8_t *pk_y, uint8_t length);
int esp_tinycrypt_calc_ecc_mult(const uint8_t *p_x, const uint8_t *p_y, const uint8_t *scalar,
uint8_t *r_x, uint8_t *r_y, uint8_t num_bytes, bool verify_first);
#endif /* SOC_ECC_SUPPORTED */

View File

@@ -1,4 +1,8 @@
/* aes_decrypt.c - TinyCrypt implementation of AES decryption procedure */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
@@ -30,6 +34,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/* aes_decrypt.c - TinyCrypt implementation of AES decryption procedure */
#include <tinycrypt/aes.h>
#include <tinycrypt/constants.h>
#include <tinycrypt/utils.h>

View File

@@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* aes_encrypt.c - TinyCrypt implementation of AES encryption procedure */
/*

View File

@@ -1,4 +1,8 @@
/* cbc_mode.c - TinyCrypt implementation of CBC mode encryption & decryption */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@@ -1,4 +1,8 @@
/* ccm_mode.c - TinyCrypt implementation of CCM mode */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
@@ -30,6 +34,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/* ccm_mode.c - TinyCrypt implementation of CCM mode */
#include <tinycrypt/ccm_mode.h>
#include <tinycrypt/constants.h>
#include <tinycrypt/utils.h>

View File

@@ -1,4 +1,8 @@
/* cmac_mode.c - TinyCrypt CMAC mode implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* ctr_mode.c - TinyCrypt CTR mode implementation */
/*

View File

@@ -1,4 +1,8 @@
/* ctr_prng.c - TinyCrypt implementation of CTR-PRNG */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (c) 2016, Chris Morrison

View File

@@ -1,4 +1,8 @@
/* ecc.c - TinyCrypt implementation of common ECC functions */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (c) 2014, Kenneth MacKay
@@ -55,6 +59,9 @@
#include <tinycrypt/ecc.h>
#include <tinycrypt/ecc_platform_specific.h>
#include <string.h>
#include <stdio.h>
#include "esp_tinycrypt_port.h"
/* IMPORTANT: Make sure a cryptographically-secure PRNG is set and the platform
* has access to enough entropy in order to feed the PRNG regularly. */
@@ -635,6 +642,7 @@ void apply_z(uECC_word_t * X1, uECC_word_t * Y1, const uECC_word_t * const Z,
uECC_vli_modMult_fast(Y1, Y1, t1, curve); /* y1 * z^3 */
}
#if !SOC_ECC_SUPPORTED
/* P = (x1, y1) => 2P, (x2, y2) => P' */
static void XYcZ_initial_double(uECC_word_t * X1, uECC_word_t * Y1,
uECC_word_t * X2, uECC_word_t * Y2,
@@ -658,31 +666,6 @@ static void XYcZ_initial_double(uECC_word_t * X1, uECC_word_t * Y1,
apply_z(X2, Y2, z, curve);
}
void XYcZ_add(uECC_word_t * X1, uECC_word_t * Y1,
uECC_word_t * X2, uECC_word_t * Y2,
uECC_Curve curve)
{
/* t1 = X1, t2 = Y1, t3 = X2, t4 = Y2 */
uECC_word_t t5[NUM_ECC_WORDS];
wordcount_t num_words = curve->num_words;
uECC_vli_modSub(t5, X2, X1, curve->p, num_words); /* t5 = x2 - x1 */
uECC_vli_modSquare_fast(t5, t5, curve); /* t5 = (x2 - x1)^2 = A */
uECC_vli_modMult_fast(X1, X1, t5, curve); /* t1 = x1*A = B */
uECC_vli_modMult_fast(X2, X2, t5, curve); /* t3 = x2*A = C */
uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); /* t4 = y2 - y1 */
uECC_vli_modSquare_fast(t5, Y2, curve); /* t5 = (y2 - y1)^2 = D */
uECC_vli_modSub(t5, t5, X1, curve->p, num_words); /* t5 = D - B */
uECC_vli_modSub(t5, t5, X2, curve->p, num_words); /* t5 = D - B - C = x3 */
uECC_vli_modSub(X2, X2, X1, curve->p, num_words); /* t3 = C - B */
uECC_vli_modMult_fast(Y1, Y1, X2, curve); /* t2 = y1*(C - B) */
uECC_vli_modSub(X2, X1, t5, curve->p, num_words); /* t3 = B - x3 */
uECC_vli_modMult_fast(Y2, Y2, X2, curve); /* t4 = (y2 - y1)*(B - x3) */
uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); /* t4 = y3 */
uECC_vli_set(X2, t5, num_words);
}
/* Input P = (x1, y1, Z), Q = (x2, y2, Z)
Output P + Q = (x3, y3, Z3), P - Q = (x3', y3', Z3)
@@ -725,12 +708,49 @@ static void XYcZ_addC(uECC_word_t * X1, uECC_word_t * Y1,
uECC_vli_set(X1, t7, num_words);
}
#endif /* !SOC_ECC_SUPPORTED */
void XYcZ_add(uECC_word_t * X1, uECC_word_t * Y1,
uECC_word_t * X2, uECC_word_t * Y2,
uECC_Curve curve)
{
/* t1 = X1, t2 = Y1, t3 = X2, t4 = Y2 */
uECC_word_t t5[NUM_ECC_WORDS];
wordcount_t num_words = curve->num_words;
uECC_vli_modSub(t5, X2, X1, curve->p, num_words); /* t5 = x2 - x1 */
uECC_vli_modSquare_fast(t5, t5, curve); /* t5 = (x2 - x1)^2 = A */
uECC_vli_modMult_fast(X1, X1, t5, curve); /* t1 = x1*A = B */
uECC_vli_modMult_fast(X2, X2, t5, curve); /* t3 = x2*A = C */
uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); /* t4 = y2 - y1 */
uECC_vli_modSquare_fast(t5, Y2, curve); /* t5 = (y2 - y1)^2 = D */
uECC_vli_modSub(t5, t5, X1, curve->p, num_words); /* t5 = D - B */
uECC_vli_modSub(t5, t5, X2, curve->p, num_words); /* t5 = D - B - C = x3 */
uECC_vli_modSub(X2, X2, X1, curve->p, num_words); /* t3 = C - B */
uECC_vli_modMult_fast(Y1, Y1, X2, curve); /* t2 = y1*(C - B) */
uECC_vli_modSub(X2, X1, t5, curve->p, num_words); /* t3 = B - x3 */
uECC_vli_modMult_fast(Y2, Y2, X2, curve); /* t4 = (y2 - y1)*(B - x3) */
uECC_vli_modSub(Y2, Y2, Y1, curve->p, num_words); /* t4 = y3 */
uECC_vli_set(X2, t5, num_words);
}
void EccPoint_mult(uECC_word_t * result, const uECC_word_t * point,
const uECC_word_t * scalar,
const uECC_word_t * initial_Z,
bitcount_t num_bits, uECC_Curve curve)
{
#if SOC_ECC_SUPPORTED
wordcount_t num_words = curve->num_words;
/* Only p256r1 is supported currently. */
assert (curve == uECC_secp256r1());
esp_tinycrypt_calc_ecc_mult((const uint8_t *)&point[0], (const uint8_t *)&point[num_words],
(uint8_t *)scalar, (uint8_t *)&result[0], (uint8_t *)&result[num_words],
num_words * uECC_WORD_SIZE, false);
#else
/* R0 and R1 */
uECC_word_t Rx[2][NUM_ECC_WORDS];
uECC_word_t Ry[2][NUM_ECC_WORDS];
@@ -769,6 +789,7 @@ void EccPoint_mult(uECC_word_t * result, const uECC_word_t * point,
uECC_vli_set(result, Rx[0], num_words);
uECC_vli_set(result + num_words, Ry[0], num_words);
#endif /* SOC_ECC_SUPPORTED */
}
uECC_word_t regularize_k(const uECC_word_t * const k, uECC_word_t *k0,
@@ -862,8 +883,6 @@ int uECC_generate_random_int(uECC_word_t *random, const uECC_word_t *top,
int uECC_valid_point(const uECC_word_t *point, uECC_Curve curve)
{
uECC_word_t tmp1[NUM_ECC_WORDS];
uECC_word_t tmp2[NUM_ECC_WORDS];
wordcount_t num_words = curve->num_words;
/* The point at infinity is invalid. */
@@ -877,19 +896,34 @@ int uECC_valid_point(const uECC_word_t *point, uECC_Curve curve)
return -2;
}
#if SOC_ECC_SUPPORTED
/* Only p256r1 is supported currently. */
if (curve != uECC_secp256r1()) {
return -5;
}
if (esp_tinycrypt_verify_ecc_point((const uint8_t *)&point[0],
(const uint8_t *)&point[num_words],
num_words * uECC_WORD_SIZE)) {
return -3;
}
#else
uECC_word_t tmp1[NUM_ECC_WORDS];
uECC_word_t tmp2[NUM_ECC_WORDS];
uECC_vli_modSquare_fast(tmp1, point + num_words, curve);
curve->x_side(tmp2, point, curve); /* tmp2 = x^3 + ax + b */
/* Make sure that y^2 == x^3 + ax + b */
if (uECC_vli_equal(tmp1, tmp2, num_words) != 0)
return -3;
#endif /* SOC_ECC_SUPPORTED */
return 0;
}
int uECC_valid_public_key(const uint8_t *public_key, uECC_Curve curve)
{
uECC_word_t _public[NUM_ECC_WORDS * 2];
uECC_vli_bytesToNative(_public, public_key, curve->num_bytes);
@@ -908,7 +942,6 @@ int uECC_valid_public_key(const uint8_t *public_key, uECC_Curve curve)
int uECC_compute_public_key(const uint8_t *private_key, uint8_t *public_key,
uECC_Curve curve)
{
uECC_word_t _private[NUM_ECC_WORDS];
uECC_word_t _public[NUM_ECC_WORDS * 2];

View File

@@ -1,4 +1,8 @@
/* ec_dh.c - TinyCrypt implementation of EC-DH */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (c) 2014, Kenneth MacKay

View File

@@ -1,4 +1,8 @@
/* ec_dsa.c - TinyCrypt implementation of EC-DSA */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* Copyright (c) 2014, Kenneth MacKay
* All rights reserved.

View File

@@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/* uECC_platform_specific.c - Implementation of platform specific functions*/
/* Copyright (c) 2014, Kenneth MacKay

View File

@@ -1,4 +1,8 @@
/* hmac.c - TinyCrypt implementation of the HMAC algorithm */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@@ -1,4 +1,8 @@
/* hmac_prng.c - TinyCrypt implementation of HMAC-PRNG */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
@@ -30,6 +34,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/* hmac_prng.c - TinyCrypt implementation of HMAC-PRNG */
#include <tinycrypt/hmac_prng.h>
#include <tinycrypt/hmac.h>
#include <tinycrypt/constants.h>

View File

@@ -1,4 +1,8 @@
/* sha256.c - TinyCrypt SHA-256 crypto hash algorithm implementation */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.

View File

@@ -1,4 +1,8 @@
/* utils.c - TinyCrypt platform-dependent run-time operations */
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Copyright (C) 2017 by Intel Corporation, All Rights Reserved.
@@ -30,6 +34,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/* utils.c - TinyCrypt platform-dependent run-time operations */
#include <tinycrypt/utils.h>
#include <tinycrypt/constants.h>

View File

@@ -23,6 +23,14 @@ config BTDM_CTRL_BLE_MAX_CONN
BLE maximum connections of bluetooth controller.
Each connection uses 1KB static DRAM whenever the BT controller is enabled.
config BTDM_CTRL_BR_EDR_MIN_ENC_KEY_SZ_DFT
int "BR/EDR default minimum size of encryption key"
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default 7
range 7 16
help
BR/EDR default minimum size of encryption key when start encryption.
config BTDM_CTRL_BR_EDR_MAX_ACL_CONN
int "BR/EDR ACL Max Connections"
depends on BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
@@ -139,6 +147,11 @@ config BTDM_CTRL_BLE_MAX_CONN_EFF
default BTDM_CTRL_BLE_MAX_CONN if BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM
default 0
config BTDM_CTRL_BR_EDR_MIN_ENC_KEY_SZ_DFT_EFF
int
default BTDM_CTRL_BR_EDR_MIN_ENC_KEY_SZ_DFT if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
default 0
config BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF
int
default BTDM_CTRL_BR_EDR_MAX_ACL_CONN if BTDM_CTRL_MODE_BR_EDR_ONLY || BTDM_CTRL_MODE_BTDM
@@ -467,6 +480,31 @@ menu "BLE disconnect when instant passed"
when instant passed in channel map update procedure.
endmenu
config BTDM_BLE_CHAN_ASS_EN
bool "Enable channel assessment"
depends on (BTDM_CTRL_MODE_BLE_ONLY || BTDM_CTRL_MODE_BTDM)
default y
help
If this option is enabled, The Controller will records the communication quality
for each channel and then start a timer to check and update the channel map every 4 seconds.
config BTDM_BLE_PING_EN
bool "Enable LE Ping procedure"
depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY)
default y
help
If this option is disabled, The Controller will not start the LE authenticated payload timer.
This option is used for some compatibility problems related to LE ping procedure.
config BTDM_CTRL_CONTROLLER_DEBUG_MODE_1
bool "Enable Bluetooth controller debugging mode 1 (for internal use only)"
default n
depends on BT_ENABLED
help
Enables specific debugging features for the Bluetooth controller.
This option is strictly for internal debugging purposes and should not be enabled in production environments,
as it may impact performance and stability.
config BTDM_RESERVE_DRAM
hex
default 0xdb5c if BT_ENABLED

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -44,6 +44,10 @@
#include "esp_rom_sys.h"
#include "hli_api.h"
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#include "ble_log/ble_log_spi_out.h"
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#if CONFIG_BT_ENABLED
/* Macro definition
@@ -260,6 +264,16 @@ extern void config_bt_funcs_reset(void);
extern void config_ble_funcs_reset(void);
extern void config_btdm_funcs_reset(void);
#ifdef CONFIG_BT_BLUEDROID_ENABLED
extern void bt_stack_enableSecCtrlVsCmd(bool en);
#endif // CONFIG_BT_BLUEDROID_ENABLED
#if defined(CONFIG_BT_NIMBLE_ENABLED) || defined(CONFIG_BT_BLUEDROID_ENABLED)
extern void bt_stack_enableCoexVsCmd(bool en);
extern void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
extern void adv_stack_enableClearLegacyAdvVsCmd(bool en);
extern void advFilter_stack_enableDupExcListVsCmd(bool en);
#endif // (CONFIG_BT_NIMBLE_ENABLED) || (CONFIG_BT_BLUEDROID_ENABLED)
/* Local Function Declare
*********************************************************************
*/
@@ -460,7 +474,11 @@ static DRAM_ATTR uint8_t btdm_lpcycle_us_frac = 0; // number of fractional bit f
#if CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
// used low power clock
static DRAM_ATTR uint8_t btdm_lpclk_sel;
#if CONFIG_BTDM_CTRL_LPCLK_SEL_EXT_32K_XTAL
static DRAM_ATTR uint8_t btdm_lpclk_sel = ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL;
#else
static DRAM_ATTR uint8_t btdm_lpclk_sel = ESP_BT_SLEEP_CLOCK_MAIN_XTAL;
#endif /* CONFIG_BTDM_CTRL_LPCLK_SEL_EXT_32K_XTAL */
#endif /* #ifdef CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG */
static DRAM_ATTR QueueHandle_t s_wakeup_req_sem = NULL;
@@ -1083,9 +1101,8 @@ static bool async_wakeup_request(int event)
switch (event) {
case BTDM_ASYNC_WAKEUP_REQ_HCI:
btdm_in_wakeup_requesting_set(true);
// NO break
case BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA:
btdm_in_wakeup_requesting_set(true);
if (!btdm_power_state_active()) {
do_wakeup_request = true;
@@ -1118,10 +1135,10 @@ static void async_wakeup_request_end(int event)
bool request_lock = false;
switch (event) {
case BTDM_ASYNC_WAKEUP_REQ_HCI:
case BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA:
request_lock = true;
break;
case BTDM_ASYNC_WAKEUP_REQ_COEX:
case BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA:
request_lock = false;
break;
default:
@@ -1543,6 +1560,117 @@ static void hli_queue_setup_pinned_to_core(int core_id)
}
#endif /* CONFIG_BTDM_CTRL_HLI */
// init low-power control resources
static esp_err_t btdm_low_power_mode_init(void)
{
esp_err_t err = ESP_OK;
#ifdef CONFIG_PM_ENABLE
s_btdm_allow_light_sleep = false;
#endif
// set default sleep clock cycle and its fractional bits
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
#if CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
if (btdm_lpclk_sel == ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL) {
// check whether or not EXT_CRYS is working
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) {
#ifdef CONFIG_PM_ENABLE
s_btdm_allow_light_sleep = true;
#endif
} else {
ESP_LOGW(BTDM_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock\n"
"light sleep mode will not be able to apply when bluetooth is enabled");
btdm_lpclk_sel = ESP_BT_SLEEP_CLOCK_MAIN_XTAL; // set default value
}
} else if (btdm_lpclk_sel != ESP_BT_SLEEP_CLOCK_MAIN_XTAL) {
assert(0);
}
bool select_src_ret __attribute__((unused));
bool set_div_ret __attribute__((unused));
if (btdm_lpclk_sel == ESP_BT_SLEEP_CLOCK_MAIN_XTAL) {
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
set_div_ret = btdm_lpclk_set_div(esp_clk_xtal_freq() * 2 / MHZ - 1);
assert(select_src_ret && set_div_ret);
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
} else { // btdm_lpclk_sel == BTDM_LPCLK_SEL_XTAL32K
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K);
set_div_ret = btdm_lpclk_set_div(0);
assert(select_src_ret && set_div_ret);
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) :
(1000000 >> (15 - RTC_CLK_CAL_FRACT));
assert(btdm_lpcycle_us != 0);
}
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_ORIG);
#elif CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_EVED
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_EVED);
#else
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
#endif
#ifdef CONFIG_PM_ENABLE
if (!s_btdm_allow_light_sleep) {
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
return err;
}
}
if ((err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock)) != ESP_OK) {
return err;
}
esp_timer_create_args_t create_args = {
.callback = btdm_slp_tmr_callback,
.arg = NULL,
.name = "btSlp"
};
if ((err = esp_timer_create(&create_args, &s_btdm_slp_tmr)) != ESP_OK) {
return err;
}
s_pm_lock_acquired = true;
#endif
return err;
}
esp_bt_sleep_clock_t esp_bt_get_lpclk_src(void)
{
#if CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_INITED &&
btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {
return ESP_BT_SLEEP_CLOCK_NONE;
}
return btdm_lpclk_sel;
#else
return ESP_BT_SLEEP_CLOCK_NONE;
#endif
}
esp_err_t esp_bt_set_lpclk_src(esp_bt_sleep_clock_t lpclk)
{
#if CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
if (lpclk < ESP_BT_SLEEP_CLOCK_MAIN_XTAL || lpclk > ESP_BT_SLEEP_CLOCK_EXT_32K_XTAL) {
return ESP_ERR_INVALID_ARG;
}
if (btdm_controller_status == ESP_BT_CONTROLLER_STATUS_INITED ||
btdm_controller_status == ESP_BT_CONTROLLER_STATUS_ENABLED) {
ESP_LOGW(BTDM_LOG_TAG, "Please set the Bluetooth sleep clock source before Bluetooth initialization");
return ESP_ERR_INVALID_STATE;
}
btdm_lpclk_sel = lpclk;
return ESP_OK;
#else
return ESP_ERR_NOT_SUPPORTED;
#endif
}
esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
{
esp_err_t err;
@@ -1605,58 +1733,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
btdm_controller_mem_init();
periph_module_enable(PERIPH_BT_MODULE);
#ifdef CONFIG_PM_ENABLE
s_btdm_allow_light_sleep = false;
#endif
// set default sleep clock cycle and its fractional bits
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
#if CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
#if CONFIG_BTDM_CTRL_LPCLK_SEL_EXT_32K_XTAL
// check whether or not EXT_CRYS is working
if (rtc_clk_slow_src_get() == SOC_RTC_SLOW_CLK_SRC_XTAL32K) {
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL32K; // External 32kHz XTAL
#ifdef CONFIG_PM_ENABLE
s_btdm_allow_light_sleep = true;
#endif
} else {
ESP_LOGW(BTDM_LOG_TAG, "32.768kHz XTAL not detected, fall back to main XTAL as Bluetooth sleep clock\n"
"light sleep mode will not be able to apply when bluetooth is enabled");
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
}
#else
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
#endif
bool select_src_ret __attribute__((unused));
bool set_div_ret __attribute__((unused));
if (btdm_lpclk_sel == BTDM_LPCLK_SEL_XTAL) {
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
set_div_ret = btdm_lpclk_set_div(esp_clk_xtal_freq() * 2 / MHZ - 1);
assert(select_src_ret && set_div_ret);
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
} else { // btdm_lpclk_sel == BTDM_LPCLK_SEL_XTAL32K
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL32K);
set_div_ret = btdm_lpclk_set_div(0);
assert(select_src_ret && set_div_ret);
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
btdm_lpcycle_us = (RTC_CLK_CAL_FRACT > 15) ? (1000000 << (RTC_CLK_CAL_FRACT - 15)) :
(1000000 >> (15 - RTC_CLK_CAL_FRACT));
assert(btdm_lpcycle_us != 0);
}
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_ORIG);
#elif CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_EVED
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_EVED);
#else
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
#endif
periph_module_reset(PERIPH_BT_MODULE);
#if CONFIG_BTDM_CTRL_HCI_UART_FLOW_CTRL_EN
sdk_config_set_uart_flow_ctrl_enable(true);
@@ -1664,31 +1741,22 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
sdk_config_set_uart_flow_ctrl_enable(false);
#endif
#ifdef CONFIG_PM_ENABLE
if (!s_btdm_allow_light_sleep) {
if ((err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "btLS", &s_light_sleep_pm_lock)) != ESP_OK) {
goto error;
}
}
if ((err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "bt", &s_pm_lock)) != ESP_OK) {
if ((err = btdm_low_power_mode_init()) != ESP_OK) {
ESP_LOGE(BTDM_LOG_TAG, "Low power module initialization failed");
goto error;
}
esp_timer_create_args_t create_args = {
.callback = btdm_slp_tmr_callback,
.arg = NULL,
.name = "btSlp"
};
if ((err = esp_timer_create(&create_args, &s_btdm_slp_tmr)) != ESP_OK) {
goto error;
}
s_pm_lock_acquired = true;
#endif
#if CONFIG_SW_COEXIST_ENABLE
coex_init();
#endif
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
if (ble_log_spi_out_init() != 0) {
ESP_LOGE(BTDM_LOG_TAG, "BLE Log SPI output init failed");
goto error;
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
btdm_cfg_mask = btdm_config_mask_load();
err = btdm_controller_init(btdm_cfg_mask, cfg);
@@ -1699,12 +1767,26 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
goto error;
}
#ifdef CONFIG_BT_BLUEDROID_ENABLED
bt_stack_enableSecCtrlVsCmd(true);
#endif // CONFIG_BT_BLUEDROID_ENABLED
#if defined(CONFIG_BT_NIMBLE_ENABLED) || defined(CONFIG_BT_BLUEDROID_ENABLED)
bt_stack_enableCoexVsCmd(true);
scan_stack_enableAdvFlowCtrlVsCmd(true);
adv_stack_enableClearLegacyAdvVsCmd(true);
advFilter_stack_enableDupExcListVsCmd(true);
#endif // (CONFIG_BT_NIMBLE_ENABLED) || (CONFIG_BT_BLUEDROID_ENABLED)
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
return ESP_OK;
error:
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
ble_log_spi_out_deinit();
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
bt_controller_deinit_internal();
return err;
@@ -1716,17 +1798,30 @@ esp_err_t esp_bt_controller_deinit(void)
return ESP_ERR_INVALID_STATE;
}
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
ble_log_spi_out_deinit();
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
btdm_controller_deinit();
bt_controller_deinit_internal();
#ifdef CONFIG_BT_BLUEDROID_ENABLED
bt_stack_enableSecCtrlVsCmd(false);
#endif // CONFIG_BT_BLUEDROID_ENABLED
#if defined(CONFIG_BT_NIMBLE_ENABLED) || defined(CONFIG_BT_BLUEDROID_ENABLED)
bt_stack_enableCoexVsCmd(false);
scan_stack_enableAdvFlowCtrlVsCmd(false);
adv_stack_enableClearLegacyAdvVsCmd(false);
advFilter_stack_enableDupExcListVsCmd(false);
#endif // (CONFIG_BT_NIMBLE_ENABLED) || (CONFIG_BT_BLUEDROID_ENABLED)
return ESP_OK;
}
static void bt_controller_deinit_internal(void)
// deinit low power control resources
static void btdm_low_power_mode_deinit(void)
{
periph_module_disable(PERIPH_BT_MODULE);
#ifdef CONFIG_PM_ENABLE
if (!s_btdm_allow_light_sleep) {
esp_pm_lock_delete(s_light_sleep_pm_lock);
@@ -1747,6 +1842,16 @@ static void bt_controller_deinit_internal(void)
s_pm_lock_acquired = false;
#endif
btdm_lpcycle_us = 0;
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
}
static void bt_controller_deinit_internal(void)
{
periph_module_disable(PERIPH_BT_MODULE);
btdm_low_power_mode_deinit();
if (s_wakeup_req_sem) {
semphr_delete_wrapper(s_wakeup_req_sem);
s_wakeup_req_sem = NULL;
@@ -1759,9 +1864,6 @@ static void bt_controller_deinit_internal(void)
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
btdm_lpcycle_us = 0;
btdm_controller_set_sleep_mode(BTDM_MODEM_SLEEP_MODE_NONE);
esp_bt_power_domain_off();
esp_phy_modem_deinit();
@@ -1872,6 +1974,7 @@ esp_err_t esp_bt_controller_disable(void)
while (!btdm_power_state_active()) {
esp_rom_delay_us(1000);
}
async_wakeup_request_end(BTDM_ASYNC_WAKEUP_REQ_CTRL_DISA);
}
btdm_controller_disable();

View File

@@ -90,7 +90,7 @@ menu "HCI Config"
config BT_LE_HCI_TRANS_TASK_STACK_SIZE
int "HCI transport task stack size"
depends on !BT_LE_HCI_INTERFACE_USE_RAM
default 1024
default 2048
help
This configures stack size of hci transport task
endmenu
@@ -308,6 +308,15 @@ config BT_LE_CONTROLLER_LOG_DUMP_ONLY
help
Only operate in dump mode
config BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
bool "Output ble controller logs to SPI bus (Experimental)"
depends on BT_LE_CONTROLLER_LOG_ENABLED
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
select BT_BLE_LOG_SPI_OUT_ENABLED
default n
help
Output ble controller logs to SPI bus
config BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
bool "Store ble controller logs to flash(Experimental)"
depends on !BT_LE_CONTROLLER_LOG_DUMP_ONLY
@@ -347,6 +356,19 @@ config BT_LE_LOG_HCI_BUF_SIZE
help
Configure the size of the BLE HCI LOG buffer.
config BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
bool "Enable wrap panic handler"
depends on BT_LE_CONTROLLER_LOG_ENABLED
default n
help
Wrap esp_panic_handler to get controller logs when PC pointer exception crashes.
config BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
bool "Enable esp_task_wdt_isr_user_handler implementation"
depends on BT_LE_CONTROLLER_LOG_ENABLED
default n
help
Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered.
config BT_LE_LL_RESOLV_LIST_SIZE
int "BLE LL Resolving list size"
range 1 5
@@ -402,7 +424,7 @@ config BT_LE_CRYPTO_STACK_MBEDTLS
config BT_LE_WHITELIST_SIZE
int "BLE white list size"
range 1 15
range 1 31
default 12
depends on !BT_NIMBLE_ENABLED
@@ -659,6 +681,11 @@ config BT_LE_PLACE_CONN_RELATED_INTO_IRAM
depends on BT_CTRL_RUN_IN_FLASH_ONLY
default n
config BT_LE_PLACE_SLEEP_RELATED_INTO_IRAM
bool
depends on BT_CTRL_RUN_IN_FLASH_ONLY && BT_LE_SLEEP_ENABLE
default y
config BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
bool "Enable enhanced Access Address check in CONNECT_IND"
default n
@@ -666,3 +693,33 @@ config BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU.
This improves security by ensuring that only connection requests with valid Access Addresses are accepted.
If disabled, only basic checks are applied, improving compatibility.
menu "BLE disconnects when Instant Passed (0x28) occurs"
config BT_LE_CTRL_LLCP_CONN_UPDATE
bool "BLE ACL connection update procedure"
default n
help
If this option is enabled, Controller will terminate the connection
when Instant Passed (0x28) error occurs during connection update procedure.
config BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
bool "BLE ACL channel map update procedure"
default n
help
If this option is enabled, Controller will terminate the connection
when Instant Passed (0x28) error occurs in channel map update procedure.
config BT_LE_CTRL_LLCP_PHY_UPDATE
bool "BLE ACL PHY update procedure"
default n
help
If this option is enabled, Controller will terminate the connection
when Instant Passed (0x28) error occurs in PHY update procedure.
endmenu
config BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
int "The value of upperlimitmax during scan backoff procedure"
range 1 256
default 32
help
The value of upperlimitmax needs to be a power of 2.

View File

@@ -0,0 +1,71 @@
/*
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdlib.h>
#include "sdkconfig.h"
#include "esp_bt_cfg.h"
/* External functions or variables
************************************************************************
*/
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
void adv_stack_enableClearLegacyAdvVsCmd(bool en);
void chanSel_stack_enableSetCsaVsCmd(bool en);
void hci_stack_enableSetVsEvtMaskVsCmd(bool en);
void adv_stack_enableScanReqRxdVsEvent(bool en);
void conn_stack_enableChanMapUpdCompVsEvent(bool en);
void sleep_stack_enableWakeupVsEvent(bool en);
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
/* Local functions definition
***************************************************************************
*/
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
void ble_stack_enableVsCmds(bool en)
{
#if DEFAULT_BT_LE_ROLE_BROADCASTER
adv_stack_enableClearLegacyAdvVsCmd(en);
#endif // DEFAULT_BT_LE_ROLE_BROADCASTER
#if DEFAULT_BT_LE_ROLE_OBSERVER
scan_stack_enableAdvFlowCtrlVsCmd(en);
#endif // DEFAULT_BT_LE_ROLE_OBSERVER
chanSel_stack_enableSetCsaVsCmd(en);
hci_stack_enableSetVsEvtMaskVsCmd(en);
}
void ble_stack_enableVsEvents(bool en)
{
#if DEFAULT_BT_LE_ROLE_BROADCASTER
adv_stack_enableScanReqRxdVsEvent(en);
#endif // DEFAULT_BT_LE_ROLE_BROADCASTER
conn_stack_enableChanMapUpdCompVsEvent(en);
#if CONFIG_BT_LE_SLEEP_ENABLE
sleep_stack_enableWakeupVsEvent(en);
#endif // CONFIG_BT_LE_SLEEP_ENABLE
}
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
int ble_stack_enable(void)
{
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
ble_stack_enableVsCmds(true);
ble_stack_enableVsEvents(true);
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
return 0;
}
void ble_stack_disable(void)
{
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
ble_stack_enableVsEvents(false);
ble_stack_enableVsCmds(false);
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
}

View File

@@ -0,0 +1,13 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BLE_PRIV_H_
#define _BLE_PRIV_H_
int ble_stack_enable(void);
void ble_stack_disable(void);
#endif // _BLE_PRIV_H_

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -35,6 +35,7 @@
#include "os/endian.h"
#include "esp_bt.h"
#include "ble_priv.h"
#include "esp_intr_alloc.h"
#include "esp_sleep.h"
#include "esp_pm.h"
@@ -61,6 +62,10 @@
#include "hal/efuse_ll.h"
#include "soc/rtc.h"
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#include "ble_log/ble_log_spi_out.h"
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
/* Macro definition
************************************************************************
*/
@@ -109,7 +114,7 @@ struct ext_funcs_t {
};
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
typedef void (*interface_func_t) (uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
/* External functions or variables
@@ -119,10 +124,12 @@ extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs);
extern int coex_core_ble_conn_dyn_prio_get(bool *low, bool *high);
extern int ble_controller_init(esp_bt_controller_config_t *cfg);
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
extern int ble_log_init_async(interface_func_t interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
extern int ble_log_deinit_async(void);
extern int ble_log_init_simple(interface_func_t interface, void *handler);
extern void ble_log_deinit_simple(void);
extern void ble_log_async_output_dump_all(bool output);
extern void esp_panic_handler_reconfigure_wdts(void);
extern void esp_panic_handler_feed_wdts(void);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
extern int ble_controller_deinit(void);
extern int ble_controller_enable(uint8_t mode);
@@ -189,10 +196,12 @@ static int esp_ecc_gen_key_pair(uint8_t *pub, uint8_t *priv);
static int esp_ecc_gen_dh_key(const uint8_t *peer_pub_key_x, const uint8_t *peer_pub_key_y,
const uint8_t *our_priv_key, uint8_t *out_dhkey);
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end);
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag);
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
#endif // #if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
/* Local variable definition
***************************************************************************
@@ -202,47 +211,29 @@ void *g_ble_lll_rfmgmt_env_p;
#endif
/* Static variable declare */
static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE;
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
const static uint32_t log_bufs_size[] = {CONFIG_BT_LE_LOG_CTRL_BUF1_SIZE, CONFIG_BT_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_LE_LOG_CTRL_BUF2_SIZE};
enum log_out_mode {
LOG_DUMP_MEMORY,
LOG_ASYNC_OUT,
LOG_STORAGE_TO_FLASH,
};
static bool log_is_inited = false;
bool log_is_inited = false;
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
uint8_t log_output_mode = LOG_DUMP_MEMORY;
#else
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
uint8_t log_output_mode = LOG_STORAGE_TO_FLASH;
#else
uint8_t log_output_mode = LOG_ASYNC_OUT;
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
#endif // CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
void esp_bt_log_output_mode_set(uint8_t output_mode)
esp_err_t esp_bt_controller_log_init(void)
{
log_output_mode = output_mode;
}
uint8_t esp_bt_log_output_mode_get(void)
{
return log_output_mode;
}
esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
{
esp_err_t ret = ESP_OK;
interface_func_t bt_controller_log_interface;
bt_controller_log_interface = esp_bt_controller_log_interface;
bool task_create;
uint8_t buffers = 0;
if (log_is_inited) {
return ret;
return ESP_OK;
}
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
if (ble_log_spi_out_init() != 0) {
goto spi_out_init_failed;
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
if (ble_log_init_simple(ble_log_spi_out_ll_write, ble_log_spi_out_ll_log_ev_proc) != 0) {
goto log_init_failed;
}
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
uint8_t buffers = 0;
#if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
buffers |= ESP_BLE_LOG_BUF_CONTROLLER;
#endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED
@@ -250,34 +241,41 @@ esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
buffers |= ESP_BLE_LOG_BUF_HCI;
#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED
switch (log_output_mode) {
case LOG_DUMP_MEMORY:
task_create = false;
break;
case LOG_ASYNC_OUT:
case LOG_STORAGE_TO_FLASH:
task_create = true;
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
esp_bt_ctrl_log_partition_get_and_erase_first_block();
}
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
break;
default:
assert(0);
}
bool task_create = true;
#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY
task_create = false;
#elif CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
esp_bt_ctrl_log_partition_get_and_erase_first_block();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
ret = ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
if (ret == ESP_OK) {
log_is_inited = true;
if (ble_log_init_async(esp_bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size) != 0) {
goto log_init_failed;
}
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
return ret;
log_is_inited = true;
return ESP_OK;
log_init_failed:
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
ble_log_spi_out_deinit();
spi_out_init_failed:
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
return ESP_FAIL;
}
void esp_bt_ontroller_log_deinit(void)
void esp_bt_controller_log_deinit(void)
{
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
ble_log_spi_out_deinit();
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#if CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
ble_log_deinit_simple();
#else // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
ble_log_deinit_async();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
log_is_inited = false;
}
@@ -370,13 +368,13 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL_SAFE(&spinlock);
esp_panic_handler_reconfigure_wdts();
esp_panic_handler_feed_wdts();
ble_log_async_output_dump_all(true);
esp_bt_controller_log_deinit();
stop_write = true;
esp_bt_ontroller_log_deinit();
portEXIT_CRITICAL_SAFE(&spinlock);
buffer = (const uint8_t *)mapped_ptr;
esp_panic_handler_feed_wdts();
if (is_filled) {
read_index = next_erase_index;
} else {
@@ -388,7 +386,7 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
while (read_index != write_index) {
esp_rom_printf("%02x ", buffer[read_index]);
if (print_len > max_print_len) {
vTaskDelay(2);
esp_panic_handler_feed_wdts();
print_len = 0;
}
@@ -396,45 +394,70 @@ void esp_bt_read_ctrl_log_from_flash(bool output)
read_index = (read_index + 1) % MAX_STORAGE_SIZE;
}
esp_rom_printf(":DUMP_END]\r\n");
portEXIT_CRITICAL_SAFE(&spinlock);
esp_partition_munmap(mmap_handle);
err = esp_bt_controller_log_init(log_output_mode);
err = esp_bt_controller_log_init();
assert(err == ESP_OK);
}
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end)
{
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
esp_bt_controller_log_storage(len, addr, end);
#endif //CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
} else {
for (int i = 0; i < len; i++) {
esp_rom_printf("%02x ", addr[i]);
}
if (end) {
esp_rom_printf("\n");
}
#if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag)
{
bool end = flag ? true : false;
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
esp_bt_controller_log_storage(len, addr, end);
#else // !CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL_SAFE(&spinlock);
esp_panic_handler_feed_wdts();
for (int i = 0; i < len; i++) {
esp_rom_printf("%02x ", addr[i]);
}
if (end) {
esp_rom_printf("\n");
}
portEXIT_CRITICAL_SAFE(&spinlock);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
}
#endif // !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
void esp_ble_controller_log_dump_all(bool output)
{
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
ble_log_spi_out_dump_all();
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
esp_bt_read_ctrl_log_from_flash(output);
#endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE
} else {
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL_SAFE(&spinlock);
esp_panic_handler_reconfigure_wdts();
BT_ASSERT_PRINT("\r\n[DUMP_START:");
ble_log_async_output_dump_all(output);
BT_ASSERT_PRINT(":DUMP_END]\r\n");
portEXIT_CRITICAL_SAFE(&spinlock);
}
esp_bt_read_ctrl_log_from_flash(output);
#elif !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL_SAFE(&spinlock);
esp_panic_handler_feed_wdts();
BT_ASSERT_PRINT("\r\n[DUMP_START:");
ble_log_async_output_dump_all(output);
BT_ASSERT_PRINT(":DUMP_END]\r\n");
portEXIT_CRITICAL_SAFE(&spinlock);
#endif
}
#if CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
void esp_task_wdt_isr_user_handler(void)
{
esp_ble_controller_log_dump_all(true);
}
#endif // CONFIG_BT_LE_CONTROLLER_LOG_TASK_WDT_USER_HANDLER_ENABLE
#if CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
void __real_esp_panic_handler(void *info);
void __wrap_esp_panic_handler (void *info)
{
esp_ble_controller_log_dump_all(true);
__real_esp_panic_handler(info);
}
#endif // CONFIG_BT_LE_CONTROLLER_LOG_WRAP_PANIC_HANDLER_ENABLE
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
/* This variable tells if BLE is running */
@@ -447,6 +470,17 @@ static DRAM_ATTR ble_rtc_slow_clk_src_t s_bt_lpclk_src = BT_SLOW_CLK_SRC_INVALID
#define BLE_RTC_DELAY_US (1800)
#define BLE_CONTROLLER_MALLOC_CAPS (MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT|MALLOC_CAP_DMA)
void *malloc_ble_controller_mem(size_t size)
{
return heap_caps_malloc(size, BLE_CONTROLLER_MALLOC_CAPS);
}
uint32_t get_ble_controller_free_heap_size(void)
{
return heap_caps_get_free_size(BLE_CONTROLLER_MALLOC_CAPS);
}
static const struct osi_coex_funcs_t s_osi_coex_funcs_ro = {
._magic = OSI_COEX_MAGIC_VALUE,
._version = OSI_COEX_VERSION,
@@ -556,13 +590,6 @@ static int esp_intr_free_wrapper(void **ret_handle)
return rc;
}
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
void sleep_modem_light_sleep_overhead_set(uint32_t overhead)
{
esp_ble_set_wakeup_overhead(overhead);
}
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
ble_rtc_slow_clk_src_t esp_bt_get_lpclk_src(void)
{
return s_bt_lpclk_src;
@@ -577,7 +604,7 @@ void esp_bt_set_lpclk_src(ble_rtc_slow_clk_src_t clk_src)
s_bt_lpclk_src = clk_src;
}
IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg)
void controller_sleep_cb(uint32_t enable_tick, void *arg)
{
if (!s_ble_active) {
return;
@@ -591,7 +618,7 @@ IRAM_ATTR void controller_sleep_cb(uint32_t enable_tick, void *arg)
s_ble_active = false;
}
IRAM_ATTR void controller_wakeup_cb(void *arg)
void controller_wakeup_cb(void *arg)
{
if (s_ble_active) {
return;
@@ -631,7 +658,7 @@ esp_err_t controller_sleep_init(ble_rtc_slow_clk_src_t slow_clk_src)
esp_sleep_enable_bt_wakeup();
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer");
rc = esp_pm_register_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
rc = esp_pm_register_inform_out_light_sleep_overhead_callback(esp_ble_set_wakeup_overhead);
if (rc != ESP_OK) {
goto error;
}
@@ -641,7 +668,7 @@ esp_err_t controller_sleep_init(ble_rtc_slow_clk_src_t slow_clk_src)
error:
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
esp_sleep_disable_bt_wakeup();
esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
esp_pm_unregister_inform_out_light_sleep_overhead_callback(esp_ble_set_wakeup_overhead);
#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */
/*lock should release first and then delete*/
if (s_pm_lock != NULL) {
@@ -658,7 +685,7 @@ void controller_sleep_deinit(void)
r_ble_rtc_wake_up_state_clr();
esp_sleep_disable_bt_wakeup();
esp_sleep_pd_config(ESP_PD_DOMAIN_XTAL, ESP_PD_OPTION_AUTO);
esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set);
esp_pm_unregister_inform_out_light_sleep_overhead_callback(esp_ble_set_wakeup_overhead);
#endif // CONFIG_FREERTOS_USE_TICKLESS_IDLE
#ifdef CONFIG_PM_ENABLE
/*lock should release first and then delete*/
@@ -849,7 +876,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
ESP_LOGI(NIMBLE_PORT_LOG_TAG, "ble rom commit:[%s]", r_ble_controller_get_rom_compile_version());
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
ret = esp_bt_controller_log_init(log_output_mode);
ret = esp_bt_controller_log_init();
if (ret != ESP_OK) {
ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret);
goto controller_init_err;
@@ -898,7 +925,7 @@ free_controller:
controller_sleep_deinit();
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
controller_init_err:
esp_bt_ontroller_log_deinit();
esp_bt_controller_log_deinit();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
ble_controller_deinit();
modem_deint:
@@ -928,7 +955,7 @@ esp_err_t esp_bt_controller_deinit(void)
controller_sleep_deinit();
#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
esp_bt_ontroller_log_deinit();
esp_bt_controller_log_deinit();
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED
ble_controller_deinit();
@@ -982,6 +1009,12 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
#if CONFIG_SW_COEXIST_ENABLE
coex_enable();
#endif
if (ble_stack_enable() != 0) {
ret = ESP_FAIL;
goto error;
}
if (ble_controller_enable(mode) != 0) {
ret = ESP_FAIL;
goto error;
@@ -991,6 +1024,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
return ESP_OK;
error:
ble_stack_disable();
#if CONFIG_SW_COEXIST_ENABLE
coex_disable();
#endif
@@ -1013,7 +1047,7 @@ esp_err_t esp_bt_controller_disable(void)
if (ble_controller_disable() != 0) {
return ESP_FAIL;
}
ble_stack_disable();
if (s_ble_active) {
esp_phy_disable();
#if CONFIG_PM_ENABLE
@@ -1164,12 +1198,20 @@ esp_err_t esp_ble_tx_power_set(esp_ble_power_type_t power_type, esp_power_level_
switch (power_type) {
case ESP_BLE_PWR_TYPE_DEFAULT:
case ESP_BLE_PWR_TYPE_ADV:
case ESP_BLE_PWR_TYPE_SCAN:
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
stat = ESP_OK;
}
break;
case ESP_BLE_PWR_TYPE_ADV:
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_ADV, 0xFF, power_level) == 0) {
stat = ESP_OK;
}
break;
case ESP_BLE_PWR_TYPE_SCAN:
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0, power_level) == 0) {
stat = ESP_OK;
}
break;
case ESP_BLE_PWR_TYPE_CONN_HDL0:
case ESP_BLE_PWR_TYPE_CONN_HDL1:
case ESP_BLE_PWR_TYPE_CONN_HDL2:
@@ -1196,9 +1238,13 @@ esp_err_t esp_ble_tx_power_set_enhanced(esp_ble_enhanced_power_type_t power_type
esp_err_t stat = ESP_FAIL;
switch (power_type) {
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
stat = ESP_OK;
}
break;
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0, power_level) == 0) {
if (ble_txpwr_set(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0, power_level) == 0) {
stat = ESP_OK;
}
break;
@@ -1221,11 +1267,15 @@ esp_power_level_t esp_ble_tx_power_get(esp_ble_power_type_t power_type)
int tx_level = 0;
switch (power_type) {
case ESP_BLE_PWR_TYPE_ADV:
case ESP_BLE_PWR_TYPE_SCAN:
case ESP_BLE_PWR_TYPE_DEFAULT:
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
break;
case ESP_BLE_PWR_TYPE_ADV:
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_ADV, 0);
break;
case ESP_BLE_PWR_TYPE_SCAN:
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0);
break;
case ESP_BLE_PWR_TYPE_CONN_HDL0:
case ESP_BLE_PWR_TYPE_CONN_HDL1:
case ESP_BLE_PWR_TYPE_CONN_HDL2:
@@ -1254,9 +1304,11 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po
switch (power_type) {
case ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT:
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
break;
case ESP_BLE_ENHANCED_PWR_TYPE_SCAN:
case ESP_BLE_ENHANCED_PWR_TYPE_INIT:
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_DEFAULT, 0);
tx_level = ble_txpwr_get(ESP_BLE_ENHANCED_PWR_TYPE_SCAN, 0);
break;
case ESP_BLE_ENHANCED_PWR_TYPE_ADV:
case ESP_BLE_ENHANCED_PWR_TYPE_CONN:

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -226,12 +226,44 @@ extern "C" {
#define DEFAULT_BT_LE_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS (0)
#endif
#ifdef CONFIG_BT_LE_CTRL_LLCP_CONN_UPDATE
#define BT_CTRL_BLE_LLCP_CONN_UPDATE (1<<0)
#else
#define BT_CTRL_BLE_LLCP_CONN_UPDATE (0<<0)
#endif
#ifdef CONFIG_BT_LE_CTRL_LLCP_CHAN_MAP_UPDATE
#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (1<<1)
#else
#define BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE (0<<1)
#endif
#ifdef CONFIG_BT_LE_CTRL_LLCP_PHY_UPDATE
#define BT_CTRL_BLE_LLCP_PHY_UPDATE (1<<2)
#else
#define BT_CTRL_BLE_LLCP_PHY_UPDATE (0<<2)
#endif
#define BT_LE_CTRL_LLCP_DISC_FLAG (BT_CTRL_BLE_LLCP_CONN_UPDATE | BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE | BT_CTRL_BLE_LLCP_PHY_UPDATE)
#ifdef CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX (CONFIG_BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX)
#else
#define BT_CTRL_SCAN_BACKOFF_UPPERLIMITMAX (256)
#endif
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_UART
#define HCI_UART_EN CONFIG_BT_LE_HCI_INTERFACE_USE_UART
#else
#define HCI_UART_EN 0 // hci ram mode
#endif
#ifdef CONFIG_BT_LE_HCI_INTERFACE_USE_RAM
#define DEFAULT_BT_LE_VHCI_ENABLED (CONFIG_BT_LE_HCI_INTERFACE_USE_RAM)
#else
#define DEFAULT_BT_LE_VHCI_ENABLED (0)
#endif
#ifdef CONFIG_BT_LE_SLEEP_ENABLE
#define NIMBLE_SLEEP_ENABLE CONFIG_BT_LE_SLEEP_ENABLE
#else

View File

@@ -66,7 +66,7 @@ endchoice
config BT_CTRL_HCI_TL
int
default 0 if BT_CTRL_HCI_MODE_UART_H4
default 1 if BT_CTRL_HCI_M0DE_VHCI
default 1 if BT_CTRL_HCI_MODE_VHCI
default 1
help
HCI mode as VHCI or UART(H4)
@@ -83,13 +83,16 @@ choice BT_BLE_CCA_MODE
default BT_BLE_CCA_MODE_NONE
help
Define BT BLE CCA mode
Note that if CCA feature is enabled, the hardware may not transmit packets due to channel busy.
Therefore, it may potentially lead to an increase in the time taken for scanning advertising packet
and establishing connections, or a decrease in the throughput rate of the connection.
config BT_BLE_CCA_MODE_NONE
bool "NONE"
config BT_BLE_CCA_MODE_HW
bool "Hardware"
config BT_BLE_CCA_MODE_SW
bool "Software"
bool "Software (experimental)"
endchoice
config BT_BLE_CCA_MODE
@@ -445,7 +448,7 @@ config BT_CTRL_SLEEP_CLOCK_EFF
config BT_CTRL_HCI_TL_EFF
int
default 0 if BT_CTRL_HCI_MODE_UART_H4
default 1 if BT_CTRL_HCI_M0DE_VHCI
default 1 if BT_CTRL_HCI_MODE_VHCI
default 1
config BT_CTRL_AGC_RECORRECT_EN
@@ -550,3 +553,71 @@ config BT_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU.
This improves security by ensuring that only connection requests with valid Access Addresses are accepted.
If disabled, only basic checks are applied, improving compatibility.
menu "Controller debug log Options (Experimental)"
config BT_CTRL_LE_LOG_EN
depends on BT_CTRL_RUN_IN_FLASH_ONLY
bool "Enable BLE debug log"
default n
config BT_CTRL_LE_HCI_LOG_EN
depends on BT_CTRL_LE_LOG_EN
bool "Enable BLE HCI log"
default n
config BT_CTRL_LE_LOG_DUMP_ONLY
depends on BT_CTRL_LE_LOG_EN
bool "Enable BLE log dump only"
default n
config BT_CTRL_LE_LOG_STORAGE_EN
depends on BT_CTRL_LE_LOG_EN
bool "Enable BLE log storage to flash"
default n
config BT_CTRL_LE_LOG_PARTITION_SIZE
int "The size of ble controller log partition(Multiples of 4K)"
depends on BT_CTRL_LE_LOG_STORAGE_EN
default 65536
help
The size of ble controller log partition shall be a multiples of 4K.
The name of log partition shall be "bt_ctrl_log".
The partition type shall be ESP_PARTITION_TYPE_DATA.
The partition sub_type shall be ESP_PARTITION_SUBTYPE_ANY.
config BT_CTRL_LE_LOG_SPI_OUT_EN
bool "Output ble controller logs to SPI bus"
depends on BT_CTRL_LE_LOG_EN
depends on !BT_CTRL_LE_LOG_DUMP_ONLY
select BT_BLE_LOG_SPI_OUT_ENABLED
default n
help
Output ble controller logs to SPI bus
config BT_CTRL_LE_LOG_MODE_EN
depends on BT_CTRL_LE_LOG_EN
int "Enable log for specified BLE mode"
range 0 4095
default 4093
config BT_CTRL_LE_LOG_LEVEL
depends on BT_CTRL_LE_LOG_EN
int "The level of BLE log"
range 0 5
default 2
config BT_CTRL_LE_LOG_BUF1_SIZE
depends on BT_CTRL_LE_LOG_EN
int "The size of BLE log buffer1"
default 1024
config BT_CTRL_LE_LOG_HCI_BUF_SIZE
depends on BT_CTRL_LE_LOG_EN
int "The size of BLE log HCI buffer"
default 1024
config BT_CTRL_LE_LOG_BUF2_SIZE
depends on BT_CTRL_LE_LOG_EN
int "The size of BLE log buffer2"
default 1024
endmenu

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -46,6 +46,13 @@
#include "xtensa/core-macros.h"
#include "esp32s3/rom/rom_layout.h"
#endif
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#include "ble_log/ble_log_spi_out.h"
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
#include "esp_partition.h"
#include "hal/wdt_hal.h"
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
#if CONFIG_BT_ENABLED
/* Macro definition
@@ -112,12 +119,20 @@ do{\
} while(0)
#define OSI_FUNCS_TIME_BLOCKING 0xffffffff
#define OSI_VERSION 0x00010009
#define OSI_VERSION 0x0001000A
#define OSI_MAGIC_VALUE 0xFADEBEAD
#define BLE_PWR_HDL_INVL 0xFFFF
#define BLE_CONTROLLER_MALLOC_CAPS (MALLOC_CAP_INTERNAL|MALLOC_CAP_DMA)
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
#define MAX_STORAGE_SIZE (CONFIG_BT_CTRL_LE_LOG_PARTITION_SIZE)
#define BLOCK_SIZE (4096)
#define THRESHOLD (3072)
#define PARTITION_NAME "bt_ctrl_log"
#endif
/* Types definition
************************************************************************
*/
@@ -214,8 +229,13 @@ struct osi_funcs_t {
void (* _btdm_rom_table_ready)(void);
bool (* _coex_bt_wakeup_request)(void);
void (* _coex_bt_wakeup_request_end)(void);
int64_t (*_get_time_us)(void);
void (* _assert)(void);
};
#if CONFIG_BT_CTRL_LE_LOG_EN
typedef void (*interface_func_t) (uint32_t len, const uint8_t*addr, bool end);
#endif // CONFIG_BT_CTRL_LE_LOG_EN
/* External functions or values
************************************************************************
@@ -276,6 +296,21 @@ extern void ets_backup_dma_copy(uint32_t reg, uint32_t mem_addr, uint32_t num, b
extern void btdm_cca_feature_enable(void);
extern void btdm_aa_check_enhance_enable(void);
/* BLE Log module */
#if CONFIG_BT_CTRL_LE_LOG_EN
extern int r_ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size);
extern int r_ble_log_deinit_async(void);
extern void r_ble_log_async_select_dump_buffers(uint8_t buffers);
extern void r_ble_log_async_output_dump_all(bool output);
extern void esp_panic_handler_feed_wdts(void);
#endif // CONFIG_BT_CTRL_LE_LOG_EN
#if (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
extern void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
extern void adv_stack_enableClearLegacyAdvVsCmd(bool en);
extern void advFilter_stack_enableDupExcListVsCmd(bool en);
extern void chanSel_stack_enableSetCsaVsCmd(bool en);
#endif // (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
extern uint32_t _bt_bss_start;
extern uint32_t _bt_bss_end;
extern uint32_t _bt_controller_bss_start;
@@ -337,6 +372,8 @@ static void btdm_backup_dma_copy_wrapper(uint32_t reg, uint32_t mem_addr, uint32
static void btdm_funcs_table_ready_wrapper(void);
static bool coex_bt_wakeup_request(void);
static void coex_bt_wakeup_request_end(void);
static int64_t get_time_us_wrapper(void);
static void assert_wrapper(void);
static void btdm_slp_tmr_callback(void *arg);
@@ -344,6 +381,15 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end);
static void bt_controller_deinit_internal(void);
#if CONFIG_BT_CTRL_LE_LOG_EN
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end);
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
void esp_bt_read_ctrl_log_from_flash(bool output);
static int esp_bt_controller_log_storage(uint32_t len, const uint8_t *addr, bool end);
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void);
#endif // #if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
#endif // CONFIG_BT_CTRL_LE_LOG_EN
/* Local variable definition
***************************************************************************
*/
@@ -409,6 +455,8 @@ static const struct osi_funcs_t osi_funcs_ro = {
._btdm_rom_table_ready = btdm_funcs_table_ready_wrapper,
._coex_bt_wakeup_request = coex_bt_wakeup_request,
._coex_bt_wakeup_request_end = coex_bt_wakeup_request_end,
._get_time_us = get_time_us_wrapper,
._assert = assert_wrapper,
};
static DRAM_ATTR struct osi_funcs_t *osi_funcs_p;
@@ -437,6 +485,255 @@ static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock;
static DRAM_ATTR esp_pm_lock_handle_t s_light_sleep_pm_lock;
#endif
#if CONFIG_BT_CTRL_LE_LOG_EN
enum log_out_mode {
LOG_DUMP_MEMORY,
LOG_ASYNC_OUT,
LOG_STORAGE_TO_FLASH,
LOG_SPI_OUT,
};
const static uint32_t log_bufs_size[] = {CONFIG_BT_CTRL_LE_LOG_BUF1_SIZE, CONFIG_BT_CTRL_LE_LOG_HCI_BUF_SIZE, CONFIG_BT_CTRL_LE_LOG_BUF2_SIZE};
bool log_is_inited = false;
#if CONFIG_BT_CTRL_LE_LOG_DUMP_ONLY
uint8_t log_output_mode = LOG_DUMP_MEMORY;
#else
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
uint8_t log_output_mode = LOG_STORAGE_TO_FLASH;
#elif CONFIG_BT_CTRL_LE_LOG_SPI_OUT_EN
uint8_t log_output_mode = LOG_SPI_OUT;
#else
uint8_t log_output_mode = LOG_ASYNC_OUT;
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
#endif // CONFIG_BT_CTRL_LE_LOG_DUMP_ONLY
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
static const esp_partition_t *log_partition;
static uint32_t write_index = 0;
static uint32_t next_erase_index = BLOCK_SIZE;
static bool block_erased = false;
static bool stop_write = false;
static bool is_filled = false;
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, bool end)
{
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
esp_bt_controller_log_storage(len, addr, end);
#endif //CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
} else {
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL_SAFE(&spinlock);
esp_panic_handler_feed_wdts();
for (int i = 0; i < len; i++) {
esp_rom_printf("%02x ", addr[i]);
}
if (end) {
esp_rom_printf("\n");
}
portEXIT_CRITICAL_SAFE(&spinlock);
}
}
#if CONFIG_BT_CTRL_LE_LOG_SPI_OUT_EN
static IRAM_ATTR void esp_bt_controller_spi_log_interface(uint32_t len, const uint8_t *addr, bool end)
{
ble_log_spi_out_write(BLE_LOG_SPI_OUT_SOURCE_ESP_LEGACY, addr, len);
}
#endif // CONFIG_BT_CTRL_LE_LOG_SPI_OUT_EN
void esp_ble_controller_log_dump_all(bool output)
{
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
esp_bt_read_ctrl_log_from_flash(output);
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
} else {
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL_SAFE(&spinlock);
esp_panic_handler_feed_wdts();
esp_rom_printf("\r\n[DUMP_START:");
r_ble_log_async_output_dump_all(output);
esp_rom_printf(":DUMP_END]\r\n");
portEXIT_CRITICAL_SAFE(&spinlock);
}
}
void esp_bt_log_output_mode_set(uint8_t output_mode)
{
log_output_mode = output_mode;
}
uint8_t esp_bt_log_output_mode_get(void)
{
return log_output_mode;
}
esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
{
esp_err_t ret = ESP_OK;
interface_func_t bt_controller_log_interface;
bt_controller_log_interface = esp_bt_controller_log_interface;
bool task_create;
uint8_t buffers = 0;
if (log_is_inited) {
return ret;
}
#if CONFIG_BT_CTRL_LE_LOG_EN
buffers |= ESP_BLE_LOG_BUF_CONTROLLER;
#endif // CONFIG_BT_CTRL_LE_LOG_EN
#if CONFIG_BT_CTRL_LE_HCI_LOG_EN
buffers |= ESP_BLE_LOG_BUF_HCI;
#endif // CONFIG_BT_CTRL_LE_HCI_LOG_EN
switch (log_output_mode) {
case LOG_DUMP_MEMORY:
task_create = false;
break;
case LOG_ASYNC_OUT:
case LOG_STORAGE_TO_FLASH:
task_create = true;
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
if (log_output_mode == LOG_STORAGE_TO_FLASH) {
esp_bt_ctrl_log_partition_get_and_erase_first_block();
}
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
break;
case LOG_SPI_OUT:
task_create = true;
#if CONFIG_BT_CTRL_LE_LOG_SPI_OUT_EN
bt_controller_log_interface = esp_bt_controller_spi_log_interface;
#endif // CONFIG_BT_CTRL_LE_LOG_SPI_OUT_EN
break;
default:
assert(0);
}
ret = r_ble_log_init_async(bt_controller_log_interface, task_create, buffers, (uint32_t *)log_bufs_size);
if (ret == ESP_OK) {
log_is_inited = true;
}
return ret;
}
void esp_bt_ontroller_log_deinit(void)
{
r_ble_log_deinit_async();
log_is_inited = false;
}
#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
static void esp_bt_ctrl_log_partition_get_and_erase_first_block(void)
{
log_partition = NULL;
assert(MAX_STORAGE_SIZE % BLOCK_SIZE == 0);
// Find the partition map in the partition table
log_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, PARTITION_NAME);
assert(log_partition != NULL);
// Prepare data to be read later using the mapped address
ESP_ERROR_CHECK(esp_partition_erase_range(log_partition, 0, BLOCK_SIZE));
write_index = 0;
next_erase_index = BLOCK_SIZE;
block_erased = false;
is_filled = false;
stop_write = false;
}
static int esp_bt_controller_log_storage(uint32_t len, const uint8_t *addr, bool end)
{
if (len > MAX_STORAGE_SIZE) {
return -1;
}
if (stop_write) {
return 0;
}
if (((write_index) % BLOCK_SIZE) >= THRESHOLD && !block_erased) {
// esp_rom_printf("Ers nxt: %d,%d\n", next_erase_index, write_index);
esp_partition_erase_range(log_partition, next_erase_index, BLOCK_SIZE);
next_erase_index = (next_erase_index + BLOCK_SIZE) % MAX_STORAGE_SIZE;
block_erased = true;
}
if (((write_index + len) / BLOCK_SIZE) > (write_index / BLOCK_SIZE)) {
block_erased = false;
}
if (write_index + len <= MAX_STORAGE_SIZE) {
esp_partition_write(log_partition, write_index, addr, len);
write_index = (write_index + len) % MAX_STORAGE_SIZE;
} else {
uint32_t first_part_len = MAX_STORAGE_SIZE - write_index;
esp_partition_write(log_partition, write_index, addr, first_part_len);
esp_partition_write(log_partition, 0, addr + first_part_len, len - first_part_len);
write_index = len - first_part_len;
is_filled = true;
// esp_rom_printf("old idx: %d,%d\n",next_erase_index, write_index);
}
return 0;
}
void esp_bt_read_ctrl_log_from_flash(bool output)
{
esp_partition_mmap_handle_t mmap_handle;
uint32_t read_index;
const void *mapped_ptr;
const uint8_t *buffer;
uint32_t print_len;
uint32_t max_print_len;
esp_err_t err;
print_len = 0;
max_print_len = 4096;
err = esp_partition_mmap(log_partition, 0, MAX_STORAGE_SIZE, ESP_PARTITION_MMAP_DATA, &mapped_ptr, &mmap_handle);
if (err != ESP_OK) {
ESP_LOGE("FLASH", "Mmap failed: %s", esp_err_to_name(err));
return;
}
portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED;
portENTER_CRITICAL_SAFE(&spinlock);
esp_panic_handler_feed_wdts();
r_ble_log_async_output_dump_all(true);
esp_bt_ontroller_log_deinit();
stop_write = true;
buffer = (const uint8_t *)mapped_ptr;
esp_panic_handler_feed_wdts();
if (is_filled) {
read_index = next_erase_index;
} else {
read_index = 0;
}
esp_rom_printf("\r\nREAD_CHECK:%ld,%ld,%d\r\n",read_index, write_index, is_filled);
esp_rom_printf("\r\n[DUMP_START:");
while (read_index != write_index) {
esp_rom_printf("%02x ", buffer[read_index]);
if (print_len > max_print_len) {
esp_panic_handler_feed_wdts();
print_len = 0;
}
print_len++;
read_index = (read_index + 1) % MAX_STORAGE_SIZE;
}
esp_rom_printf(":DUMP_END]\r\n");
portEXIT_CRITICAL_SAFE(&spinlock);
esp_partition_munmap(mmap_handle);
err = esp_bt_controller_log_init(log_output_mode);
assert(err == ESP_OK);
}
#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
#endif // CONFIG_BT_CTRL_LE_LOG_EN
void IRAM_ATTR btdm_hw_mac_power_down_wrapper(void)
{
#if CONFIG_MAC_BB_PD
@@ -1017,6 +1314,18 @@ static void coex_bt_wakeup_request_end(void)
return;
}
static IRAM_ATTR int64_t get_time_us_wrapper(void)
{
return esp_timer_get_time();
}
static IRAM_ATTR void assert_wrapper(void)
{
#if CONFIG_BT_CTRL_LE_LOG_EN
esp_ble_controller_log_dump_all(true);
#endif // CONFIG_BT_CTRL_LE_LOG_EN
}
bool esp_vhci_host_check_send_available(void)
{
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_ENABLED) {
@@ -1472,9 +1781,24 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
coex_init();
#endif
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
if (ble_log_spi_out_init() != 0) {
ESP_LOGE(BT_LOG_TAG, "BLE Log SPI output init failed");
goto error;
}
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
periph_module_enable(PERIPH_BT_MODULE);
periph_module_reset(PERIPH_BT_MODULE);
#if CONFIG_BT_CTRL_LE_LOG_EN
err = esp_bt_controller_log_init(log_output_mode);
if (err != ESP_OK) {
ESP_LOGW(BT_LOG_TAG, "ble_controller_log_init failed %d", err);
goto error;
}
#endif // CONFIG_BT_CTRL_LE_LOG_EN
err = btdm_controller_init(cfg);
if (err != 0) {
@@ -1483,12 +1807,23 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
goto error;
}
#if (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
scan_stack_enableAdvFlowCtrlVsCmd(true);
adv_stack_enableClearLegacyAdvVsCmd(true);
advFilter_stack_enableDupExcListVsCmd(true);
chanSel_stack_enableSetCsaVsCmd(true);
#endif // (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
btdm_controller_status = ESP_BT_CONTROLLER_STATUS_INITED;
return ESP_OK;
error:
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
ble_log_spi_out_deinit();
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
bt_controller_deinit_internal();
return err;
@@ -1500,6 +1835,17 @@ esp_err_t esp_bt_controller_deinit(void)
return ESP_ERR_INVALID_STATE;
}
#if CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
ble_log_spi_out_deinit();
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_ENABLED
#if (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
scan_stack_enableAdvFlowCtrlVsCmd(false);
adv_stack_enableClearLegacyAdvVsCmd(false);
advFilter_stack_enableDupExcListVsCmd(false);
chanSel_stack_enableSetCsaVsCmd(false);
#endif // (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED)
btdm_controller_deinit();
bt_controller_deinit_internal();
@@ -1578,6 +1924,10 @@ static void bt_controller_deinit_internal(void)
#endif
esp_phy_modem_deinit();
#if CONFIG_BT_CTRL_LE_LOG_EN
esp_bt_ontroller_log_deinit();
#endif // CONFIG_BT_CTRL_LE_LOG_EN
if (osi_funcs_p != NULL) {
free(osi_funcs_p);
osi_funcs_p = NULL;

View File

@@ -2,7 +2,7 @@
/*
* SPDX-FileCopyrightText: 2017 Intel Corporation
* SPDX-FileContributor: 2018-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileContributor: 2018-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -322,6 +322,20 @@ static inline void seg_tx_complete(struct seg_tx *tx, int err)
static void schedule_retransmit(struct seg_tx *tx)
{
/* It's possible that a segment broadcast hasn't finished,
* but the tx are already released. Only the seg_pending
* of this segment remains unprocessed. So, here, we
* determine if the tx are released by checking if the
* destination (dst) is unassigned, and then process
* the seg_pending of this segment.
* See BLEMESH25-92 for details */
if (tx->dst == BLE_MESH_ADDR_UNASSIGNED) {
if (tx->seg_pending) {
tx->seg_pending--;
}
return;
}
if (--tx->seg_pending) {
return;
}
@@ -448,7 +462,15 @@ static int send_seg(struct bt_mesh_net_tx *net_tx, struct net_buf_simple *sdu,
}
for (tx = NULL, i = 0; i < ARRAY_SIZE(seg_tx); i++) {
if (!seg_tx[i].nack_count) {
if (!seg_tx[i].nack_count &&
/* In some critical conditions, the tx might be
* reset before a segment broadcast is finished.
* If this happens, the seg_pending of the segment
* hasn't been processed. To avoid assigning this
* uncleared tx to a new message, extra checks for
* seg_pending being 0 are added. See BLEMESH25-92
* for details.*/
!seg_tx[i].seg_pending) {
tx = &seg_tx[i];
break;
}

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -1620,6 +1620,18 @@ esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr,
}
esp_err_t esp_ble_gap_get_periodic_list_size(uint8_t *size)
{
if (size == NULL) {
return ESP_FAIL;
}
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
btc_get_periodic_list_size(size);
return ESP_OK;
}
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
@@ -1741,3 +1753,21 @@ esp_err_t esp_ble_gap_vendor_command_send(esp_ble_vendor_cmd_params_t *vendor_cm
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_set_vendor_event_mask(uint32_t event_mask)
{
btc_msg_t msg = {0};
btc_ble_gap_args_t arg;
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_ACT_SET_VENDOR_EVT_MASK;
arg.set_vendor_evt_mask.evt_mask = event_mask;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -20,6 +20,27 @@ static bool esp_sdp_record_integrity_check(esp_bluetooth_sdp_record_t *record)
bool ret = true;
if (record != NULL) {
if (record->hdr.type < ESP_SDP_TYPE_RAW || record->hdr.type > ESP_SDP_TYPE_SAP_SERVER) {
LOG_ERROR("Invalid type!\n");
return false;
}
switch (record->hdr.type) {
case ESP_SDP_TYPE_MAP_MAS:
if ((record->mas.mas_instance_id >> 8) || (record->mas.supported_message_types >> 8)) {
LOG_ERROR("mas_instance_id and supported_message_types are defined as uint8_t in the spec!\n");
ret = false;
}
break;
case ESP_SDP_TYPE_PBAP_PSE:
if (record->pse.supported_repositories >> 8) {
LOG_ERROR("supported_repositories is defined in the spec as uint8_t!\n");
ret = false;
}
break;
default:
break;
}
if (record->hdr.service_name_length > ESP_SDP_SERVER_NAME_MAX ||
strlen(record->hdr.service_name) + 1 != record->hdr.service_name_length) {
LOG_ERROR("Invalid server name!\n");

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -230,6 +230,8 @@ typedef enum {
ESP_GAP_BLE_VENDOR_CMD_COMPLETE_EVT, /*!< When vendor hci command complete, the event comes */
ESP_GAP_BLE_SET_PRIVACY_MODE_COMPLETE_EVT, /*!< When set privacy mode complete, the event comes */
ESP_GAP_BLE_SET_CSA_SUPPORT_COMPLETE_EVT, /*!< When set CSA support complete, the event comes */
ESP_GAP_BLE_SET_VENDOR_EVT_MASK_COMPLETE_EVT, /*!< When set vendor event mask complete, the event comes */
ESP_GAP_BLE_VENDOR_HCI_EVT, /*!< When BLE vendor HCI event received, the event comes */
ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */
} esp_gap_ble_cb_event_t;
@@ -1578,7 +1580,21 @@ typedef union {
*/
struct ble_set_csa_support_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate CSA support set operation success status */
} set_csa_support_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_CSA_SUPPORT_COMPLETE_EVT */
} set_csa_support_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_CSA_SUPPORT_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_SET_VENDOR_EVT_MASK_COMPLETE_EVT
*/
struct ble_set_vendor_evt_mask_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate set vendor event mask operation success status */
} set_vendor_evt_mask_cmpl; /*!< Event parameter of ESP_GAP_BLE_SET_VENDOR_EVT_MASK_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_VENDOR_HCI_EVT
*/
struct ble_vendor_hci_event_evt_param {
uint8_t subevt_code; /*!< Subevent code for vendor HCI event, the range is 0xC0 to 0xFF */
uint8_t param_len; /*!< The length of the event parameter buffer */
uint8_t *param_buf; /*!< The pointer of the event parameter buffer */
} vendor_hci_evt; /*!< Event parameter buffer of ESP_GAP_BLE_VENDOR_HCI_EVT */
} esp_ble_gap_cb_param_t;
/**
@@ -1593,6 +1609,8 @@ typedef void (* esp_gap_ble_cb_t)(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_p
*
* @param[in] callback: callback function
*
* @note Avoid performing time-consuming operations within the callback functions.
*
* @return
* - ESP_OK : success
* - other : failed
@@ -1643,7 +1661,8 @@ esp_err_t esp_ble_gap_set_scan_params(esp_ble_scan_params_t *scan_params);
/**
* @brief This procedure keep the device scanning the peer device which advertising on the air
*
* @param[in] duration: Keeping the scanning time, the unit is second.
* @param[in] duration: The scanning duration in seconds.
* Set to 0 for continuous scanning until explicitly stopped.
*
* @return
* - ESP_OK : success
@@ -2592,6 +2611,17 @@ esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr,
const esp_ble_gap_conn_params_t *phy_2m_conn_params,
const esp_ble_gap_conn_params_t *phy_coded_conn_params);
/**
* @brief Retrieve the capacity of the periodic advertiser list in the controller.
*
* @param[out] size: Pointer to a variable where the capacity of the periodic advertiser list will be stored.
*
* @return
* - ESP_OK : Success
* - Others : Failure
*/
esp_err_t esp_ble_gap_get_periodic_list_size(uint8_t *size);
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
@@ -2768,6 +2798,18 @@ esp_err_t esp_ble_gap_set_privacy_mode(esp_ble_addr_type_t addr_type, esp_bd_add
*/
esp_err_t esp_ble_gap_set_csa_support(uint8_t csa_select);
/**
* @brief This function is used to control which vendor events are generated by the HCI for the Host.
*
* @param[in] event_mask: Bit0: Legacy scan request received event
* Bit1: Vendor channel map update complete event
*
* @return
* - ESP_OK : success
* - other : failed
*/
esp_err_t esp_ble_gap_set_vendor_event_mask(uint32_t event_mask);
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -17,580 +17,606 @@ extern "C" {
/// GATT Server callback function events
typedef enum {
ESP_GATTS_REG_EVT = 0, /*!< When register application id, the event comes */
ESP_GATTS_READ_EVT = 1, /*!< When gatt client request read operation, the event comes */
ESP_GATTS_WRITE_EVT = 2, /*!< When gatt client request write operation, the event comes */
ESP_GATTS_EXEC_WRITE_EVT = 3, /*!< When gatt client request execute write, the event comes */
ESP_GATTS_MTU_EVT = 4, /*!< When set mtu complete, the event comes */
ESP_GATTS_CONF_EVT = 5, /*!< When receive confirm, the event comes */
ESP_GATTS_UNREG_EVT = 6, /*!< When unregister application id, the event comes */
ESP_GATTS_CREATE_EVT = 7, /*!< When create service complete, the event comes */
ESP_GATTS_ADD_INCL_SRVC_EVT = 8, /*!< When add included service complete, the event comes */
ESP_GATTS_ADD_CHAR_EVT = 9, /*!< When add characteristic complete, the event comes */
ESP_GATTS_ADD_CHAR_DESCR_EVT = 10, /*!< When add descriptor complete, the event comes */
ESP_GATTS_DELETE_EVT = 11, /*!< When delete service complete, the event comes */
ESP_GATTS_START_EVT = 12, /*!< When start service complete, the event comes */
ESP_GATTS_STOP_EVT = 13, /*!< When stop service complete, the event comes */
ESP_GATTS_CONNECT_EVT = 14, /*!< When gatt client connect, the event comes */
ESP_GATTS_DISCONNECT_EVT = 15, /*!< When gatt client disconnect, the event comes */
ESP_GATTS_OPEN_EVT = 16, /*!< When connect to peer, the event comes */
ESP_GATTS_CANCEL_OPEN_EVT = 17, /*!< When disconnect from peer, the event comes */
ESP_GATTS_CLOSE_EVT = 18, /*!< When gatt server close, the event comes */
ESP_GATTS_LISTEN_EVT = 19, /*!< When gatt listen to be connected the event comes */
ESP_GATTS_CONGEST_EVT = 20, /*!< When congest happen, the event comes */
ESP_GATTS_REG_EVT = 0, /*!< This event is triggered when a GATT Server application is registered using `esp_ble_gatts_app_register`. */
ESP_GATTS_READ_EVT = 1, /*!< This event is triggered when the read request from the Client is received. */
ESP_GATTS_WRITE_EVT = 2, /*!< This event is triggered when the write request from the Client is received. */
ESP_GATTS_EXEC_WRITE_EVT = 3, /*!< This event is triggered when the write execution request from the Client is received. */
ESP_GATTS_MTU_EVT = 4, /*!< This event is triggered when the MTU configuration request from the Client is received. */
ESP_GATTS_CONF_EVT = 5, /*!< This event is triggered when the confirmation from the Client is received. */
ESP_GATTS_UNREG_EVT = 6, /*!< This event is triggered when a GATT Server application is unregistered using `esp_ble_gatts_app_unregister`. */
ESP_GATTS_CREATE_EVT = 7, /*!< This event is triggered when a GATT Server service is created using `esp_ble_gatts_create_service`. */
ESP_GATTS_ADD_INCL_SRVC_EVT = 8, /*!< This event is triggered when an included service is added using `esp_ble_gatts_add_included_service`. */
ESP_GATTS_ADD_CHAR_EVT = 9, /*!< This event is triggered when a characteristic is added to the service using `esp_ble_gatts_add_char`. */
ESP_GATTS_ADD_CHAR_DESCR_EVT = 10, /*!< This event is triggered when a characteristic descriptor is added to the service using `esp_ble_gatts_add_char_descr`. */
ESP_GATTS_DELETE_EVT = 11, /*!< This event is triggered when the service is deleted using `esp_ble_gatts_delete_service`. */
ESP_GATTS_START_EVT = 12, /*!< This event is triggered when the service is started using `esp_ble_gatts_start_service`. */
ESP_GATTS_STOP_EVT = 13, /*!< This event is triggered when the service is stopped using `esp_ble_gatts_stop_service`. */
ESP_GATTS_CONNECT_EVT = 14, /*!< This event is triggered when a physical connection is set up. */
ESP_GATTS_DISCONNECT_EVT = 15, /*!< This event is triggered when a physical connection is terminated. */
ESP_GATTS_OPEN_EVT = 16, /*!< This event is triggered when a virtual connection is created using `esp_ble_gatts_open`. */
ESP_GATTS_CANCEL_OPEN_EVT = 17, /*!< Deprecated. */
ESP_GATTS_CLOSE_EVT = 18, /*!< This event is triggered when a virtual connection is closed using `esp_ble_gatts_close`. */
ESP_GATTS_LISTEN_EVT = 19, /*!< Deprecated. */
ESP_GATTS_CONGEST_EVT = 20, /*!< This event is triggered when the GATT connection is congested. */
/* following is extra event */
ESP_GATTS_RESPONSE_EVT = 21, /*!< When gatt send response complete, the event comes */
ESP_GATTS_CREAT_ATTR_TAB_EVT = 22, /*!< When gatt create table complete, the event comes */
ESP_GATTS_SET_ATTR_VAL_EVT = 23, /*!< When gatt set attr value complete, the event comes */
ESP_GATTS_SEND_SERVICE_CHANGE_EVT = 24, /*!< When gatt send service change indication complete, the event comes */
ESP_GATTS_RESPONSE_EVT = 21, /*!< This event is triggered when a response is sent to the request using `esp_ble_gatts_send_response`. */
ESP_GATTS_CREAT_ATTR_TAB_EVT = 22, /*!< This event is triggered when a service attribute table is created using `esp_ble_gatts_create_attr_tab`. */
ESP_GATTS_SET_ATTR_VAL_EVT = 23, /*!< This event is triggered when an attribute value is set using `esp_ble_gatts_set_attr_value`. */
ESP_GATTS_SEND_SERVICE_CHANGE_EVT = 24, /*!< This event is triggered when a service change indication is sent using `esp_ble_gatts_send_service_change_indication`. */
} esp_gatts_cb_event_t;
/**
* @brief Gatt server callback parameters union
* @brief GATT Server callback parameters
*/
typedef union {
/**
* @brief ESP_GATTS_REG_EVT
* @brief Callback parameter for the event `ESP_GATTS_REG_EVT`
*/
struct gatts_reg_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t app_id; /*!< Application id which input in register API */
} reg; /*!< Gatt server callback param of ESP_GATTS_REG_EVT */
uint16_t app_id; /*!< Application ID */
} reg; /*!< Callback parameter for the event `ESP_GATTS_REG_EVT` */
/**
* @brief ESP_GATTS_READ_EVT
* @brief Callback parameter for the event `ESP_GATTS_READ_EVT`
*/
struct gatts_read_evt_param {
uint16_t conn_id; /*!< Connection id */
uint32_t trans_id; /*!< Transfer id */
esp_bd_addr_t bda; /*!< The bluetooth device address which been read */
uint16_t conn_id; /*!< Connection ID */
uint32_t trans_id; /*!< Transfer ID */
esp_bd_addr_t bda; /*!< The device address to read */
uint16_t handle; /*!< The attribute handle */
uint16_t offset; /*!< Offset of the value, if the value is too long */
bool is_long; /*!< The value is too long or not */
bool need_rsp; /*!< The read operation need to do response */
} read; /*!< Gatt server callback param of ESP_GATTS_READ_EVT */
uint16_t offset; /*!< The position offset to read. If the length of value is less than or equal to the MTU size, this value is 0. */
bool is_long; /*!< True indicates that the length of value is greater than the MTU size; false otherwise. */
bool need_rsp; /*!< True indicates that the `esp_ble_gatts_send_response` is required in the following step; false otherwise. */
} read; /*!< Callback parameter for the event `ESP_GATTS_READ_EVT` */
/**
* @brief ESP_GATTS_WRITE_EVT
* @brief Callback parameter for the event `ESP_GATTS_WRITE_EVT`
*/
struct gatts_write_evt_param {
uint16_t conn_id; /*!< Connection id */
uint32_t trans_id; /*!< Transfer id */
esp_bd_addr_t bda; /*!< The bluetooth device address which been written */
uint16_t conn_id; /*!< Connection ID */
uint32_t trans_id; /*!< Transfer ID */
esp_bd_addr_t bda; /*!< The device address to write */
uint16_t handle; /*!< The attribute handle */
uint16_t offset; /*!< Offset of the value, if the value is too long */
bool need_rsp; /*!< The write operation need to do response */
bool is_prep; /*!< This write operation is prepare write */
uint16_t len; /*!< The write attribute value length */
uint16_t offset; /*!< The position offset to write. If the length of value is less than or equal to the MTU size, this value is 0.*/
bool need_rsp; /*!< True indicates that the `esp_ble_gatts_send_response` is required in the following step; false otherwise. */
bool is_prep; /*!< True indicates the write operation is a prepared write operation */
uint16_t len; /*!< The length of the write attribute value in bytes */
uint8_t *value; /*!< The write attribute value */
} write; /*!< Gatt server callback param of ESP_GATTS_WRITE_EVT */
} write; /*!< Callback parameter for the event `ESP_GATTS_WRITE_EVT` */
/**
* @brief ESP_GATTS_EXEC_WRITE_EVT
* @brief Callback parameter for the event `ESP_GATTS_EXEC_WRITE_EVT`
*/
struct gatts_exec_write_evt_param {
uint16_t conn_id; /*!< Connection id */
uint32_t trans_id; /*!< Transfer id */
esp_bd_addr_t bda; /*!< The bluetooth device address which been written */
#define ESP_GATT_PREP_WRITE_CANCEL 0x00 /*!< Prepare write flag to indicate cancel prepare write */
#define ESP_GATT_PREP_WRITE_EXEC 0x01 /*!< Prepare write flag to indicate execute prepare write */
uint8_t exec_write_flag; /*!< Execute write flag */
} exec_write; /*!< Gatt server callback param of ESP_GATTS_EXEC_WRITE_EVT */
uint16_t conn_id; /*!< Connection ID */
uint32_t trans_id; /*!< Transfer ID */
esp_bd_addr_t bda; /*!< The bluetooth device address to write */
#define ESP_GATT_PREP_WRITE_CANCEL 0x00 /*!< Flag to indicate the cancellation of a prepare write operation */
#define ESP_GATT_PREP_WRITE_EXEC 0x01 /*!< Flag to indicate the execution of a prepare write operation */
uint8_t exec_write_flag; /*!< Execute write flag: `ESP_GATT_PREP_WRITE_CANCEL` or `ESP_GATT_PREP_WRITE_EXEC` */
} exec_write; /*!< Callback parameter for the event `ESP_GATTS_EXEC_WRITE_EVT` */
/**
* @brief ESP_GATTS_MTU_EVT
* @brief Callback parameter for the event `ESP_GATTS_MTU_EVT`
*/
struct gatts_mtu_evt_param {
uint16_t conn_id; /*!< Connection id */
uint16_t conn_id; /*!< Connection ID */
uint16_t mtu; /*!< MTU size */
} mtu; /*!< Gatt server callback param of ESP_GATTS_MTU_EVT */
} mtu; /*!< Callback parameter for the event `ESP_GATTS_MTU_EVT` */
/**
* @brief ESP_GATTS_CONF_EVT
* @brief Callback parameter for the event `ESP_GATTS_CONF_EVT`
*/
struct gatts_conf_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
uint16_t handle; /*!< attribute handle */
uint16_t len; /*!< The indication or notification value length, len is valid when send notification or indication failed */
uint8_t *value; /*!< The indication or notification value , value is valid when send notification or indication failed */
} conf; /*!< Gatt server callback param of ESP_GATTS_CONF_EVT (confirm) */
uint16_t conn_id; /*!< Connection ID */
uint16_t handle; /*!< Attribute handle */
uint16_t len; /*!< The length of indication or notification value in bytes. The length is invalid if the notification or indication failed. */
uint8_t *value; /*!< The indication or notification value. The value is invalid if the notification or indication failed. */
} conf; /*!< Callback parameter for the event `ESP_GATTS_CONF_EVT` */
/**
* @brief ESP_GATTS_UNREG_EVT
*/
/**
* @brief ESP_GATTS_CREATE_EVT
* @brief Callback parameter for the event `ESP_GATTS_CREATE_EVT`
*/
struct gatts_create_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t service_handle; /*!< Service attribute handle */
esp_gatt_srvc_id_t service_id; /*!< Service id, include service uuid and other information */
} create; /*!< Gatt server callback param of ESP_GATTS_CREATE_EVT */
esp_gatt_srvc_id_t service_id; /*!< Service ID, including service UUID and other information */
} create; /*!< Callback parameter for the event `ESP_GATTS_CREATE_EVT` */
/**
* @brief ESP_GATTS_ADD_INCL_SRVC_EVT
* @brief Callback parameter for the event `ESP_GATTS_ADD_INCL_SRVC_EVT`
*/
struct gatts_add_incl_srvc_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t attr_handle; /*!< Included service attribute handle */
uint16_t service_handle; /*!< Service attribute handle */
} add_incl_srvc; /*!< Gatt server callback param of ESP_GATTS_ADD_INCL_SRVC_EVT */
} add_incl_srvc; /*!< Callback parameter for the event `ESP_GATTS_ADD_INCL_SRVC_EVT` */
/**
* @brief ESP_GATTS_ADD_CHAR_EVT
* @brief Callback parameter for the event `ESP_GATTS_ADD_CHAR_EVT`
*/
struct gatts_add_char_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t attr_handle; /*!< Characteristic attribute handle */
uint16_t service_handle; /*!< Service attribute handle */
esp_bt_uuid_t char_uuid; /*!< Characteristic uuid */
} add_char; /*!< Gatt server callback param of ESP_GATTS_ADD_CHAR_EVT */
esp_bt_uuid_t char_uuid; /*!< Characteristic UUID */
} add_char; /*!< Callback parameter for the event `ESP_GATTS_ADD_CHAR_EVT` */
/**
* @brief ESP_GATTS_ADD_CHAR_DESCR_EVT
* @brief Callback parameter for the event `ESP_GATTS_ADD_CHAR_DESCR_EVT`
*/
struct gatts_add_char_descr_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t attr_handle; /*!< Descriptor attribute handle */
uint16_t service_handle; /*!< Service attribute handle */
esp_bt_uuid_t descr_uuid; /*!< Characteristic descriptor uuid */
} add_char_descr; /*!< Gatt server callback param of ESP_GATTS_ADD_CHAR_DESCR_EVT */
esp_bt_uuid_t descr_uuid; /*!< Characteristic descriptor UUID */
} add_char_descr; /*!< Callback parameter for the event `ESP_GATTS_ADD_CHAR_DESCR_EVT` */
/**
* @brief ESP_GATTS_DELETE_EVT
* @brief Callback parameter for the event `ESP_GATTS_DELETE_EVT`
*/
struct gatts_delete_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t service_handle; /*!< Service attribute handle */
} del; /*!< Gatt server callback param of ESP_GATTS_DELETE_EVT */
} del; /*!< Callback parameter for the event `ESP_GATTS_DELETE_EVT` */
/**
* @brief ESP_GATTS_START_EVT
* @brief Callback parameter for the event `ESP_GATTS_START_EVT`
*/
struct gatts_start_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t service_handle; /*!< Service attribute handle */
} start; /*!< Gatt server callback param of ESP_GATTS_START_EVT */
} start; /*!< Callback parameter for the event `ESP_GATTS_START_EVT` */
/**
* @brief ESP_GATTS_STOP_EVT
* @brief Callback parameter for the event `ESP_GATTS_STOP_EVT`
*/
struct gatts_stop_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t service_handle; /*!< Service attribute handle */
} stop; /*!< Gatt server callback param of ESP_GATTS_STOP_EVT */
} stop; /*!< Callback parameter for the event `ESP_GATTS_STOP_EVT` */
/**
* @brief ESP_GATTS_CONNECT_EVT
* @brief Callback parameter for the event `ESP_GATTS_CONNECT_EVT`
*/
struct gatts_connect_evt_param {
uint16_t conn_id; /*!< Connection id */
uint8_t link_role; /*!< Link role : master role = 0 ; slave role = 1*/
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
esp_gatt_conn_params_t conn_params; /*!< current Connection parameters */
esp_ble_addr_type_t ble_addr_type; /*!< Remote BLE device address type */
uint16_t conn_handle; /*!< HCI connection handle */
} connect; /*!< Gatt server callback param of ESP_GATTS_CONNECT_EVT */
uint16_t conn_id; /*!< Connection ID */
uint8_t link_role; /*!< Link role: master role = 0; slave role = 1 */
esp_bd_addr_t remote_bda; /*!< Remote device address */
esp_gatt_conn_params_t conn_params; /*!< Current connection parameters */
esp_ble_addr_type_t ble_addr_type; /*!< Remote device address type */
uint16_t conn_handle; /*!< HCI connection handle */
} connect; /*!< Callback parameter for the event `ESP_GATTS_CONNECT_EVT` */
/**
* @brief ESP_GATTS_DISCONNECT_EVT
* @brief Callback parameter for the event `ESP_GATTS_DISCONNECT_EVT`
*/
struct gatts_disconnect_evt_param {
uint16_t conn_id; /*!< Connection id */
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
esp_gatt_conn_reason_t reason; /*!< Indicate the reason of disconnection */
} disconnect; /*!< Gatt server callback param of ESP_GATTS_DISCONNECT_EVT */
uint16_t conn_id; /*!< Connection ID */
esp_bd_addr_t remote_bda; /*!< Remote device address */
esp_gatt_conn_reason_t reason; /*!< The reason of disconnection */
} disconnect; /*!< Callback parameter for the event `ESP_GATTS_DISCONNECT_EVT` */
/**
* @brief ESP_GATTS_OPEN_EVT
* @brief Callback parameter for the event `ESP_GATTS_OPEN_EVT`
*/
struct gatts_open_evt_param {
esp_gatt_status_t status; /*!< Operation status */
} open; /*!< Gatt server callback param of ESP_GATTS_OPEN_EVT */
} open; /*!< Callback parameter for the event `ESP_GATTS_OPEN_EVT` */
/**
* @brief ESP_GATTS_CANCEL_OPEN_EVT
* @brief Callback parameter for the event `ESP_GATTS_CANCEL_OPEN_EVT`
*/
struct gatts_cancel_open_evt_param {
esp_gatt_status_t status; /*!< Operation status */
} cancel_open; /*!< Gatt server callback param of ESP_GATTS_CANCEL_OPEN_EVT */
} cancel_open; /*!< Callback parameter for the event `ESP_GATTS_CANCEL_OPEN_EVT` */
/**
* @brief ESP_GATTS_CLOSE_EVT
* @brief Callback parameter for the event `ESP_GATTS_CLOSE_EVT`
*/
struct gatts_close_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
} close; /*!< Gatt server callback param of ESP_GATTS_CLOSE_EVT */
uint16_t conn_id; /*!< Connection ID */
} close; /*!< Callback parameter for the event `ESP_GATTS_CLOSE_EVT` */
/**
* @brief ESP_GATTS_LISTEN_EVT
*/
/**
* @brief ESP_GATTS_CONGEST_EVT
* @brief Callback parameter for the event `ESP_GATTS_CONGEST_EVT`
*/
struct gatts_congest_evt_param {
uint16_t conn_id; /*!< Connection id */
bool congested; /*!< Congested or not */
} congest; /*!< Gatt server callback param of ESP_GATTS_CONGEST_EVT */
uint16_t conn_id; /*!< Connection ID */
bool congested; /*!< True indicates the connection is congested; false otherwise. */
} congest; /*!< Callback parameter for the event `ESP_GATTS_CONGEST_EVT` */
/**
* @brief ESP_GATTS_RESPONSE_EVT
* @brief Callback parameter for the event `ESP_GATTS_RESPONSE_EVT`
*/
struct gatts_rsp_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
uint16_t handle; /*!< Attribute handle which send response */
} rsp; /*!< Gatt server callback param of ESP_GATTS_RESPONSE_EVT */
uint16_t conn_id; /*!< Connection ID */
uint16_t handle; /*!< Attribute handle which sends the response */
} rsp; /*!< Callback parameter for the event `ESP_GATTS_RESPONSE_EVT` */
/**
* @brief ESP_GATTS_CREAT_ATTR_TAB_EVT
* @brief Callback parameter for the event `ESP_GATTS_CREAT_ATTR_TAB_EVT`
*/
struct gatts_add_attr_tab_evt_param{
esp_gatt_status_t status; /*!< Operation status */
esp_bt_uuid_t svc_uuid; /*!< Service uuid type */
uint8_t svc_inst_id; /*!< Service id */
uint16_t num_handle; /*!< The number of the attribute handle to be added to the gatts database */
uint16_t *handles; /*!< The number to the handles */
} add_attr_tab; /*!< Gatt server callback param of ESP_GATTS_CREAT_ATTR_TAB_EVT */
esp_bt_uuid_t svc_uuid; /*!< Service UUID type */
uint8_t svc_inst_id; /*!< Service ID */
uint16_t num_handle; /*!< The number of the attribute handles which have been added to the GATT Service table */
uint16_t *handles; /*!< The handles which have been added to the table */
} add_attr_tab; /*!< Callback parameter for the event `ESP_GATTS_CREAT_ATTR_TAB_EVT` */
/**
* @brief ESP_GATTS_SET_ATTR_VAL_EVT
* @brief Callback parameter for the event `ESP_GATTS_SET_ATTR_VAL_EVT`
*/
struct gatts_set_attr_val_evt_param{
uint16_t srvc_handle; /*!< The service handle */
uint16_t attr_handle; /*!< The attribute handle */
esp_gatt_status_t status; /*!< Operation status*/
} set_attr_val; /*!< Gatt server callback param of ESP_GATTS_SET_ATTR_VAL_EVT */
uint16_t attr_handle; /*!< The attribute handle */
esp_gatt_status_t status; /*!< Operation status */
} set_attr_val; /*!< Callback parameter for the event `ESP_GATTS_SET_ATTR_VAL_EVT` */
/**
* @brief ESP_GATTS_SEND_SERVICE_CHANGE_EVT
* @brief Callback parameter for the event `ESP_GATTS_SEND_SERVICE_CHANGE_EVT`
*/
struct gatts_send_service_change_evt_param{
esp_gatt_status_t status; /*!< Operation status*/
} service_change; /*!< Gatt server callback param of ESP_GATTS_SEND_SERVICE_CHANGE_EVT */
esp_gatt_status_t status; /*!< Operation status */
} service_change; /*!< Callback parameter for the event `ESP_GATTS_SEND_SERVICE_CHANGE_EVT` */
} esp_ble_gatts_cb_param_t;
/**
* @brief GATT Server callback function type
* @param event : Event type
* @param gatts_if : GATT server access interface, normally
* different gatts_if correspond to different profile
* @param param : Point to callback parameter, currently is union type
*
* @param[in] event Event type
* @param[in] gatts_if GATT Server access interface. Typically, different `gatts_if` values correspond to different profiles.
* @param[in] param The pointer to the callback parameter, which is of a union type.
*/
typedef void (* esp_gatts_cb_t)(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t *param);
/**
* @brief This function is called to register application callbacks
* with BTA GATTS module.
* @brief Register GATT Server application callbacks
*
* @param[in] callback The pointer to the application callback function
*
* @note Avoid performing time-consuming operations within the callback functions.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_FAIL: Failure
*/
esp_err_t esp_ble_gatts_register_callback(esp_gatts_cb_t callback);
/**
* @brief This function is called to get the current application callbacks
* with BTA GATTS module.
* @brief Get the current GATT Server application callback
*
* @return
* - esp_gatts_cb_t : current callback
*
* - esp_gatts_cb_t: Current callback
*/
esp_gatts_cb_t esp_ble_gatts_get_callback(void);
/**
* @brief This function is called to register application identifier
* @brief Register GATT Server application
*
* @param[in] app_id: The UUID for different application
*
* @note
* 1. This function triggers `ESP_GATTS_REG_EVT`.
* 2. The maximum number of applications is limited to 6.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_ERR_INVALID_ARG: The input `app_id` exceeds `ESP_APP_ID_MAX` (0x7fff) defined in esp_bt_defs.h.
* - ESP_FAIL: Failure due to other reasons
*/
esp_err_t esp_ble_gatts_app_register(uint16_t app_id);
/**
* @brief unregister with GATT Server.
* @brief Unregister an GATT Server application
*
* @param[in] gatts_if GATT Server access interface.
*
* @note
* 1. This function triggers `ESP_GATTS_UNREG_EVT`.
* 2. The maximum number of applications is limited to 6.
*
* @param[in] gatts_if: GATT server access interface
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_FAIL: Failure
*/
esp_err_t esp_ble_gatts_app_unregister(esp_gatt_if_t gatts_if);
/**
* @brief Create a service. When service creation is done, a callback
* event ESP_GATTS_CREATE_EVT is called to report status
* and service ID to the profile. The service ID obtained in
* the callback function needs to be used when adding included
* service and characteristics/descriptors into the service.
* @brief Create a GATT Server service
*
* @param[in] gatts_if: GATT server access interface
* @param[in] service_id: service ID.
* @param[in] num_handle: number of handle requested for this service.
* @param[in] gatts_if GATT Server access interface
* @param[in] service_id The pointer to the Service ID
* @param[in] num_handle The number of handles requested for this service.
*
* @note
* 1. This function triggers `ESP_GATTS_CREATE_EVT`.
* 2. `num_handle` should not be greater than CONFIG_BT_GATT_MAX_SR_ATTRIBUTES.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_FAIL: Failure
*/
esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatts_if,
esp_gatt_srvc_id_t *service_id, uint16_t num_handle);
/**
* @brief Create a service attribute tab.
* @param[in] gatts_attr_db: the pointer to the service attr tab
* @param[in] gatts_if: GATT server access interface
* @param[in] max_nb_attr: the number of attribute to be added to the service database.
* @param[in] srvc_inst_id: the instance id of the service
* @brief Create a service attribute table
*
* @param[in] gatts_attr_db The pointer to the service attribute table
* @param[in] gatts_if GATT Server access interface
* @param[in] max_nb_attr The number of attributes to be added to the service database
* @param[in] srvc_inst_id The instance ID of the service
*
* @note
* 1. This function triggers `ESP_GATTS_CREAT_ATTR_TAB_EVT`.
* 2. `max_nb_attr` should not be greater than CONFIG_BT_GATT_MAX_SR_ATTRIBUTES.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_ERR_INVALID_ARG: Invalid `max_nb_attr`
* - ESP_FAIL: Failure
*/
esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db,
esp_gatt_if_t gatts_if,
uint16_t max_nb_attr,
uint8_t srvc_inst_id);
/**
* @brief This function is called to add an included service. This function have to be called between
* 'esp_ble_gatts_create_service' and 'esp_ble_gatts_add_char'. After included
* service is included, a callback event ESP_GATTS_ADD_INCL_SRVC_EVT
* is reported the included service ID.
* @brief Add an included service
*
* @param[in] service_handle: service handle to which this included service is to
* be added.
* @param[in] included_service_handle: the service ID to be included.
* @param[in] service_handle Target service handle to add
* @param[in] included_service_handle The handle of included service to be added
*
* @note
* 1. This function triggers `ESP_GATTS_ADD_INCL_SRVC_EVT`.
* 2. This function has to be called between `esp_ble_gatts_create_service` and `esp_ble_gatts_add_char`.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_FAIL: Failure
*/
esp_err_t esp_ble_gatts_add_included_service(uint16_t service_handle, uint16_t included_service_handle);
/**
* @brief This function is called to add a characteristic into a service.
* @brief Add a characteristic into a service.
*
* @param[in] service_handle: service handle to which this included service is to
* be added.
* @param[in] char_uuid : Characteristic UUID.
* @param[in] perm : Characteristic value declaration attribute permission.
* @param[in] property : Characteristic Properties
* @param[in] char_val : Characteristic value
* @param[in] control : attribute response control byte
* @param[in] service_handle Target service handle to add the characteristic
* @param[in] char_uuid The pointer to the characteristic UUID
* @param[in] perm Characteristic value declaration attribute permission
* @param[in] property Characteristic Properties
* @param[in] char_val The pointer to the characteristic value
* @param[in] control The pointer to the attribute response control byte
*
* @note
* 1. This function triggers `ESP_GATTS_ADD_CHAR_EVT`.
* 2. `control->auto_rsp` should be set to `ESP_GATT_AUTO_RSP` or `ESP_GATT_RSP_BY_APP`.
* 3. For stack respond attribute (`ESP_GATT_AUTO_RSP`), `char_val` should not be NULL and `char_val->attr_max_len` must be greater than 0.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_ERR_INVALID_ARG: Invalid arguments
* - ESP_FAIL: Failure due to other reasons
*/
esp_err_t esp_ble_gatts_add_char(uint16_t service_handle, esp_bt_uuid_t *char_uuid,
esp_gatt_perm_t perm, esp_gatt_char_prop_t property, esp_attr_value_t *char_val,
esp_attr_control_t *control);
/**
* @brief This function is called to add characteristic descriptor. When
* it's done, a callback event ESP_GATTS_ADD_DESCR_EVT is called
* to report the status and an ID number for this descriptor.
* @brief Add a characteristic descriptor
*
* @param[in] service_handle Target service handle to add the characteristic descriptor
* @param[in] descr_uuid The pointer to the descriptor UUID
* @param[in] perm Descriptor access permission
* @param[in] char_descr_val The pointer to the characteristic descriptor value
* @param[in] control The pointer to the attribute response control byte
*
* @note
* 1. This function triggers `ESP_GATTS_ADD_CHAR_DESCR_EVT`.
* 2. `control->auto_rsp` should be set to `ESP_GATT_AUTO_RSP` or `ESP_GATT_RSP_BY_APP`.
* 3. For stack respond attribute (`ESP_GATT_AUTO_RSP`), `char_val` should not be NULL and `char_val->attr_max_len` must be greater than 0.
*
* @param[in] service_handle: service handle to which this characteristic descriptor is to
* be added.
* @param[in] perm: descriptor access permission.
* @param[in] descr_uuid: descriptor UUID.
* @param[in] char_descr_val : Characteristic descriptor value
* @param[in] control : attribute response control byte
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_ERR_INVALID_ARG: Invalid arguments
* - ESP_FAIL: Failure due to other reasons
*/
esp_err_t esp_ble_gatts_add_char_descr (uint16_t service_handle,
esp_bt_uuid_t *descr_uuid,
esp_gatt_perm_t perm, esp_attr_value_t *char_descr_val,
esp_attr_control_t *control);
/**
* @brief This function is called to delete a service. When this is done,
* a callback event ESP_GATTS_DELETE_EVT is report with the status.
* @brief Delete a service
*
* @param[in] service_handle: service_handle to be deleted.
* @param[in] service_handle Target service handle to delete
*
* @note This function triggers `ESP_GATTS_DELETE_EVT`.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_FAIL: Failure
*/
esp_err_t esp_ble_gatts_delete_service(uint16_t service_handle);
/**
* @brief This function is called to start a service.
* @brief Start a service
*
* @param[in] service_handle: the service handle to be started.
* @param[in] service_handle Target service handle to start
*
* @note This function triggers `ESP_GATTS_START_EVT`.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_FAIL: Failure
*/
esp_err_t esp_ble_gatts_start_service(uint16_t service_handle);
/**
* @brief This function is called to stop a service.
* @brief Stop a service.
*
* @param[in] service_handle - service to be topped.
* @param[in] service_handle Target service handle to stop
*
* @note This function triggers `ESP_GATTS_STOP_EVT`.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_FAIL: Failure
*/
esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle);
/**
* @brief Send indicate or notify to GATT client.
* Set param need_confirm as false will send notification, otherwise indication.
* Note: the size of indicate or notify data need less than MTU size,see "esp_ble_gattc_send_mtu_req".
* @brief Send indication or notification to a GATT Client
*
* @param[in] gatts_if: GATT server access interface
* @param[in] conn_id - connection id to indicate.
* @param[in] attr_handle - attribute handle to indicate.
* @param[in] value_len - indicate value length.
* @param[in] value: value to indicate.
* @param[in] need_confirm - Whether a confirmation is required.
* false sends a GATT notification, true sends a GATT indication.
* @param[in] gatts_if GATT Server access interface
* @param[in] conn_id Connection ID
* @param[in] attr_handle Attribute handle to indicate
* @param[in] value_len Indication value length in bytes
* @param[in] value Value to indicate
* @param[in] need_confirm True if a confirmation is required, which is a GATT indication; false if the confirmation is not required, which is a GATT notification.
*
* @note
* 1. This function triggers `ESP_GATTS_CONF_EVT`.
* 2. The size of indication or notification data must be less than or equal to MTU size, see `esp_ble_gattc_send_mtu_req`.
* 3. This function should be called only after the connection has been established.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_ERR_INVALID_STATE: The connection has not been established.
* - ESP_FAIL: Failure due to other reasons
*/
esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id, uint16_t attr_handle,
uint16_t value_len, uint8_t *value, bool need_confirm);
/**
* @brief This function is called to send a response to a request.
* @brief Send a response to a request
*
* @param[in] gatts_if: GATT server access interface
* @param[in] conn_id - connection identifier.
* @param[in] trans_id - transfer id
* @param[in] status - response status
* @param[in] rsp - response data.
* @param[in] gatts_if GATT Server access interface
* @param[in] conn_id Connection ID
* @param[in] trans_id Transfer ID
* @param[in] status Response status
* @param[in] rsp The pointer to the response data
*
* @note
* 1. This function triggers `ESP_GATTS_RESPONSE_EVT`.
* 2. This function should be called only after the connection has been established.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_ERR_INVALID_STATE: The connection has not been established.
* - ESP_FAIL: Failure due to other reasons
*/
esp_err_t esp_ble_gatts_send_response(esp_gatt_if_t gatts_if, uint16_t conn_id, uint32_t trans_id,
esp_gatt_status_t status, esp_gatt_rsp_t *rsp);
/**
* @brief This function is called to set the attribute value by the application
* @brief Set the attribute value
*
* @param[in] attr_handle: the attribute handle which to be set
* @param[in] length: the value length
* @param[in] value: the pointer to the attribute value
* @param[in] attr_handle Target attribute handle to set the value
* @param[in] length The value length in bytes
* @param[in] value The pointer to the attribute value
*
* @note This function triggers `ESP_GATTS_SET_ATTR_VAL_EVT`.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_FAIL: Failure
*/
esp_err_t esp_ble_gatts_set_attr_value(uint16_t attr_handle, uint16_t length, const uint8_t *value);
/**
* @brief Retrieve attribute value
* @brief Retrieve attribute value
*
* @param[in] attr_handle: Attribute handle.
* @param[out] length: pointer to the attribute value length
* @param[out] value: Pointer to attribute value payload, the value cannot be modified by user
* @param[in] attr_handle Attribute handle
* @param[out] length The pointer to the attribute value length in bytes
* @param[out] value The pointer to attribute value payload. This value cannot be modified by user.
*
* @note
* 1. This function does not trigger any event.
* 2. `attr_handle` must be greater than 0.
*
* @return
* - ESP_GATT_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_GATT_INVALID_HANDLE: Invalid `attr_handle`
* - ESP_FAIL: Failure due to other reasons
*/
esp_gatt_status_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *length, const uint8_t **value);
/**
* @brief Open a direct open connection or add a background auto connection
* @brief Create an ACL connection when `BT_BLE_42_FEATURES_SUPPORTED` is enabled in the menuconfig
*
* @param[in] gatts_if: GATT server access interface
* @param[in] remote_bda: remote device bluetooth device address.
* @param[in] is_direct: direct connection or background auto connection
* @param[in] gatts_if GATT Server access interface
* @param[in] remote_bda Remote device address
* @param[in] is_direct `True` indicates a direct connection, while `False` indicates a background auto connection. Currently, background auto connection is not supported, so please always set this parameter to True.
*
* @note
* 1. The function always triggers `ESP_GATTS_CONNECT_EVT` and `ESP_GATTS_OPEN_EVT`.
* 2. When the device acts as GATT Server, besides the above two events, this function triggers `ESP_GATTS_CONNECT_EVT` as well.
* 3. This function will establish an ACL connection as a Central and a virtual connection as a GATT Server. If the ACL connection already exists, it will create a virtual connection only.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_FAIL: Failure
*/
esp_err_t esp_ble_gatts_open(esp_gatt_if_t gatts_if, esp_bd_addr_t remote_bda, bool is_direct);
/**
* @brief Close a connection a remote device.
* @brief Close a connection with a remote device
*
* @param[in] gatts_if: GATT server access interface
* @param[in] conn_id: connection ID to be closed.
* @param[in] gatts_if GATT Server access interface
* @param[in] conn_id Connection ID to be closed
*
* @note
* 1. This function triggers `ESP_GATTS_CLOSE_EVT`.
* 2. There may be multiple virtual GATT server connections when multiple `app_id` got registered.
* 3. This API closes one virtual GATT server connection only, if there exist other virtual GATT server connections. It does not close the physical connection.
* 4. The API `esp_ble_gap_disconnect` can be used to disconnect the physical connection directly.
* 5. If there is only one virtual GATT connection left, this API will terminate the ACL connection in addition, and trigger `ESP_GATTS_DISCONNECT_EVT`. Then there is no need to call `esp_ble_gap_disconnect` anymore.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_FAIL: Failure
*/
esp_err_t esp_ble_gatts_close(esp_gatt_if_t gatts_if, uint16_t conn_id);
/**
* @brief Send service change indication
* @brief Send service change indication
*
* @param[in] gatts_if: GATT server access interface
* @param[in] remote_bda: remote device bluetooth device address.
* @param[in] gatts_if GATT Server access interface
* @param[in] remote_bda Remote device address.
* If remote_bda is NULL then it will send service change
* indication to all the connected devices and if not then
* to a specific device
* to a specific device.
*
* @note This function triggers `ESP_GATTS_SEND_SERVICE_CHANGE_EVT`.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_FAIL: Failure
*/
esp_err_t esp_ble_gatts_send_service_change_indication(esp_gatt_if_t gatts_if, esp_bd_addr_t remote_bda);
/**
* @brief Print local database (GATT service table)
* @brief Display the Server's local attribute database.
*
* This API prints the local attribute database of the BLE server, including details
* of all services, characteristics, and descriptors.
*
* @note
* 1. This function does not trigger any event.
* 2. It is primarily intended for debugging purposes to verify the server's current configuration.
*
* @return
* - ESP_OK : success
* - other : failed
*
* - ESP_OK: Success
* - ESP_FAIL: Failure
*/
esp_err_t esp_ble_gatts_show_local_database(void);

View File

@@ -4875,7 +4875,9 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
if (p_data->complt.reason != 0) {
sec_event.auth_cmpl.fail_reason = BTA_DM_AUTH_CONVERT_SMP_CODE(((UINT8)p_data->complt.reason));
/* delete this device entry from Sec Dev DB */
bta_dm_remove_sec_dev_entry (bda);
APPL_TRACE_WARNING("%s remove bond,rsn %d, BDA:0x%02X%02X%02X%02X%02X%02X", __func__, sec_event.auth_cmpl.fail_reason,
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
bta_dm_remove_sec_dev_entry(bda);
} else {
sec_event.auth_cmpl.success = TRUE;
if (!p_data->complt.smp_over_br) {
@@ -5768,6 +5770,12 @@ void bta_dm_ble_gap_set_csa_support(tBTA_DM_MSG *p_data)
BTM_BleSetCsaSupport(p_data->ble_set_csa_support.csa_select, p_data->ble_set_csa_support.p_cback);
}
void bta_dm_ble_gap_set_vendor_evt_mask(tBTA_DM_MSG *p_data)
{
APPL_TRACE_API("%s, evt_mask = %d", __func__, p_data->ble_set_vendor_evt_mask.evt_mask);
BTM_BleSetVendorEventMask(p_data->ble_set_vendor_evt_mask.evt_mask, p_data->ble_set_vendor_evt_mask.p_cback);
}
#if (BLE_50_FEATURE_SUPPORT == TRUE)
void bta_dm_ble_gap_dtm_enhance_tx_start(tBTA_DM_MSG *p_data)
{

View File

@@ -2943,6 +2943,19 @@ void BTA_DmBleGapSetCsaSupport(uint8_t csa_select, tBTA_SET_CSA_SUPPORT_CMPL_CBA
}
}
void BTA_DmBleGapSetVendorEventMask(uint32_t evt_mask, tBTA_SET_VENDOR_EVT_MASK_CBACK *p_callback)
{
tBTA_DM_API_BLE_SET_VENDOR_EVT_MASK *p_msg;
if ((p_msg = (tBTA_DM_API_BLE_SET_VENDOR_EVT_MASK *)osi_malloc(sizeof(tBTA_DM_API_BLE_SET_VENDOR_EVT_MASK)))
!= NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_SET_VENDOR_EVT_MASK_EVT;
p_msg->evt_mask = evt_mask;
p_msg->p_cback = p_callback;
bta_sys_sendmsg(p_msg);
}
}
/*******************************************************************************
**
** Function BTA_VendorInit

View File

@@ -223,6 +223,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_ble_gap_add_dev_to_resolving_list, /* BTA_DM_API_ADD_DEV_TO_RESOLVING_LIST_EVT */
bta_dm_ble_gap_set_privacy_mode, /* BTA_DM_API_SET_PRIVACY_MODE_EVT */
bta_dm_ble_gap_set_csa_support, /* BTA_DM_API_BLE_SET_CSA_SUPPORT_EVT */
bta_dm_ble_gap_set_vendor_evt_mask, /* BTA_DM_API_BLE_SET_VENDOR_EVT_MASK_EVT */
#endif
};

View File

@@ -219,6 +219,7 @@ enum {
BTA_DM_API_ADD_DEV_TO_RESOLVING_LIST_EVT,
BTA_DM_API_SET_PRIVACY_MODE_EVT,
BTA_DM_API_BLE_SET_CSA_SUPPORT_EVT,
BTA_DM_API_BLE_SET_VENDOR_EVT_MASK_EVT,
#endif
BTA_DM_MAX_EVT
};
@@ -925,6 +926,12 @@ typedef struct {
tBTA_SET_CSA_SUPPORT_CMPL_CBACK *p_cback;
} tBTA_DM_API_BLE_SET_CSA_SUPPORT;
typedef struct {
BT_HDR hdr;
UINT32 evt_mask;
tBTA_SET_VENDOR_EVT_MASK_CBACK *p_cback;
} tBTA_DM_API_BLE_SET_VENDOR_EVT_MASK;
#endif /* BLE_INCLUDED */
/* data type for BTA_DM_API_REMOVE_ACL_EVT */
@@ -1324,6 +1331,7 @@ typedef union {
tBTA_DM_API_CLEAR_ADV ble_clear_adv;
tBTA_DM_API_SET_PRIVACY_MODE ble_set_privacy_mode;
tBTA_DM_API_BLE_SET_CSA_SUPPORT ble_set_csa_support;
tBTA_DM_API_BLE_SET_VENDOR_EVT_MASK ble_set_vendor_evt_mask;
#endif
tBTA_DM_API_REMOVE_ACL remove_acl;
@@ -1769,6 +1777,7 @@ extern void bta_dm_ble_gap_set_rpa_timeout(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_add_dev_to_resolving_list(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_privacy_mode(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_csa_support(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_set_vendor_evt_mask(tBTA_DM_MSG *p_data);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
extern void bta_dm_ble_gap_dtm_enhance_tx_start(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_gap_dtm_enhance_rx_start(tBTA_DM_MSG *p_data);

View File

@@ -723,10 +723,6 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
} else {
APPL_TRACE_ERROR("%s, malloc failed", __func__);
}
} else {
if (p_msg->api_indicate.value) {
APPL_TRACE_ERROR("%s, incorrect length", __func__);
}
}
(*p_rcb->p_cback)(BTA_GATTS_CONF_EVT, &cb_data);
if (cb_data.req_data.value != NULL) {

View File

@@ -441,6 +441,8 @@ typedef tBTM_SET_PRIVACY_MODE_CMPL_CBACK tBTA_SET_PRIVACY_MODE_CMPL_CBACK;
typedef tBTM_SET_CSA_SUPPORT_CMPL_CBACK tBTA_SET_CSA_SUPPORT_CMPL_CBACK;
typedef tBTM_SET_VENDOR_EVT_MASK_CBACK tBTA_SET_VENDOR_EVT_MASK_CBACK;
typedef tBTM_CMPL_CB tBTA_CMPL_CB;
typedef tBTM_VSC_CMPL tBTA_VSC_CMPL;
@@ -2860,6 +2862,8 @@ extern void BTA_DmBleSetPrivacyMode(uint8_t addr_type, BD_ADDR addr, uint8_t pri
extern void BTA_DmBleGapSetCsaSupport(uint8_t csa_select, tBTM_SET_CSA_SUPPORT_CMPL_CBACK *p_callback);
extern void BTA_DmBleGapSetVendorEventMask(uint32_t evt_mask, tBTA_SET_VENDOR_EVT_MASK_CBACK *p_callback);
/*******************************************************************************
**
** Function BTA_DmBleSetStorageParams

View File

@@ -18,7 +18,7 @@
/******************************************************************************
*
* This is the public interface file for the simulatenous advanced
* This is the public interface file for the simultaneous advanced
* audio/video streaming (AV) source and sink of BTA, Broadcom's Bluetooth
* application layer for mobile phones.
*
@@ -35,6 +35,10 @@
#if (BTA_AR_INCLUDED == TRUE)
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
** Constants and data types
*****************************************************************************/

View File

@@ -1058,7 +1058,7 @@ void sdp_bqb_add_language_attr_ctrl(BOOLEAN enable)
/**
* @brief Adds a protocol list and service name (if provided) to an SDP record given by
* sdp_handle, and marks it as browseable. This is a shortcut for defining a
* sdp_handle, and marks it as browsable. This is a shortcut for defining a
* set of protocols that includes L2CAP, RFCOMM, and optionally OBEX.
*
* @param[in] sdp_handle: SDP handle
@@ -1133,9 +1133,9 @@ static bool create_base_record(const uint32_t sdp_handle, const char *name, cons
}
}
// Mark the service as browseable.
// Mark the service as browsable.
uint16_t list = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
stage = "browseable";
stage = "browsable";
if (!SDP_AddUuidSequence(sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, &list)){
APPL_TRACE_ERROR("create_base_record: failed to create base service "
"record, stage: %s, scn: %d, name: %s, with_obex: %d",
@@ -1754,6 +1754,7 @@ static void bta_jv_port_mgmt_cl_cback(UINT32 code, UINT16 port_handle, void* dat
evt_data.rfc_close.status = BTA_JV_FAILURE;
evt_data.rfc_close.port_status = code;
evt_data.rfc_close.async = TRUE;
evt_data.rfc_close.user_data = p_pcb->user_data;
if (p_pcb->state == BTA_JV_ST_CL_CLOSING) {
evt_data.rfc_close.async = FALSE;
evt_data.rfc_close.status = BTA_JV_SUCCESS;
@@ -2082,6 +2083,7 @@ static void bta_jv_port_mgmt_sr_cback(UINT32 code, UINT16 port_handle, void *dat
evt_data.rfc_close.status = BTA_JV_FAILURE;
evt_data.rfc_close.async = TRUE;
evt_data.rfc_close.port_status = code;
evt_data.rfc_close.user_data = user_data;
p_pcb->cong = FALSE;
tBTA_JV_RFCOMM_CBACK *p_cback = p_cb->p_cback;

View File

@@ -40,31 +40,6 @@
#if (SDP_INCLUDED == TRUE)
/*****************************************************************************
** Constants
*****************************************************************************/
static const uint8_t UUID_OBEX_OBJECT_PUSH[] = {0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
};
static const uint8_t UUID_PBAP_PSE[] = {0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
};
static const uint8_t UUID_PBAP_PCE[] = {0x00, 0x00, 0x11, 0x2E, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
};
static const uint8_t UUID_MAP_MAS[] = {0x00, 0x00, 0x11, 0x32, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
};
static const uint8_t UUID_MAP_MNS[] = {0x00, 0x00, 0x11, 0x33, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
};
static const uint8_t UUID_SPP[] = {0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
};
static const uint8_t UUID_SAP[] = {0x00, 0x00, 0x11, 0x2D, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
};
// TODO:
// Both the fact that the UUIDs are declared in multiple places, plus the fact
// that there is a mess of UUID comparison and shortening methods will have to
@@ -328,7 +303,7 @@ static void bta_create_sap_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE
tSDP_PROTOCOL_ELEM pe;
UINT16 pversion = -1;
record->sap.hdr.type = SDP_TYPE_MAP_MAS;
record->sap.hdr.type = SDP_TYPE_SAP_SERVER;
record->sap.hdr.service_name_length = 0;
record->sap.hdr.service_name = NULL;
record->sap.hdr.rfcomm_channel_number = 0;
@@ -379,6 +354,15 @@ static void bta_create_raw_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE
record->hdr.user1_ptr = p_bta_sdp_cfg->p_sdp_db->raw_data;
}
static bool check_if_uuid16_match(UINT16 uuid16, tBT_UUID *uuid)
{
// Because it is converted to a short UUID, only uuid16 needs to be checked.
if (uuid->len == 2 && uuid->uu.uuid16 == uuid16) {
return TRUE;
} else {
return FALSE;
}
}
/*******************************************************************************
**
@@ -415,22 +399,22 @@ static void bta_sdp_search_cback(UINT16 result, void *user_data)
/* generate the matching record data pointer */
if (p_rec != NULL) {
status = BTA_SDP_SUCCESS;
if (IS_UUID(UUID_MAP_MAS, uuid->uu.uuid128)) {
if (check_if_uuid16_match(UUID_SERVCLASS_MESSAGE_ACCESS, &su)) {
APPL_TRACE_DEBUG("%s() - found MAP (MAS) uuid\n", __func__);
bta_create_mas_sdp_record(&evt_data.records[count], p_rec);
} else if (IS_UUID(UUID_MAP_MNS, uuid->uu.uuid128)) {
} else if (check_if_uuid16_match(UUID_SERVCLASS_MESSAGE_NOTIFICATION, &su)) {
APPL_TRACE_DEBUG("%s() - found MAP (MNS) uuid\n", __func__);
bta_create_mns_sdp_record(&evt_data.records[count], p_rec);
} else if (IS_UUID(UUID_PBAP_PSE, uuid->uu.uuid128)) {
} else if (check_if_uuid16_match(UUID_SERVCLASS_PBAP_PSE, &su)) {
APPL_TRACE_DEBUG("%s() - found PBAP (PSE) uuid\n", __func__);
bta_create_pse_sdp_record(&evt_data.records[count], p_rec);
} else if (IS_UUID(UUID_PBAP_PCE, uuid->uu.uuid128)) {
} else if (check_if_uuid16_match(UUID_SERVCLASS_PBAP_PCE, &su)) {
APPL_TRACE_DEBUG("%s() - found PBAP (PCE) uuid\n", __func__);
bta_create_pce_sdp_record(&evt_data.records[count], p_rec);
} else if (IS_UUID(UUID_OBEX_OBJECT_PUSH, uuid->uu.uuid128)) {
} else if (check_if_uuid16_match(UUID_SERVCLASS_OBEX_OBJECT_PUSH, &su)) {
APPL_TRACE_DEBUG("%s() - found Object Push Server (OPS) uuid\n", __func__);
bta_create_ops_sdp_record(&evt_data.records[count], p_rec);
} else if (IS_UUID(UUID_SAP, uuid->uu.uuid128)) {
} else if (check_if_uuid16_match(UUID_SERVCLASS_SAP, &su)) {
APPL_TRACE_DEBUG("%s() - found SAP uuid\n", __func__);
bta_create_sap_sdp_record(&evt_data.records[count], p_rec);
} else {

View File

@@ -293,6 +293,9 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
status = BT_STATUS_AUTH_REJECTED;
break;
default:
BTC_TRACE_WARNING ("%s, remove bond in flash bd_addr: %08x%04x", __func__,
(p_auth_cmpl->bd_addr[0] << 24) + (p_auth_cmpl->bd_addr[1] << 16) + (p_auth_cmpl->bd_addr[2] << 8) + p_auth_cmpl->bd_addr[3],
(p_auth_cmpl->bd_addr[4] << 8) + p_auth_cmpl->bd_addr[5]);
btc_dm_remove_ble_bonding_keys();
status = BT_STATUS_FAIL;
break;

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -1375,6 +1375,45 @@ static void btc_ble_set_csa_support_callback(UINT8 status)
}
}
static void btc_ble_set_vendor_evt_mask_callback(UINT8 status)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg = {0};
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_SET_VENDOR_EVT_MASK_COMPLETE_EVT;
param.set_csa_support_cmpl.status = btc_btm_status_to_esp_status(status);
ret = btc_transfer_context(&msg, &param, sizeof(esp_ble_gap_cb_param_t), NULL, NULL);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
static void btc_ble_vendor_hci_event_callback(UINT8 subevt_code, UINT8 param_len, UINT8 *params)
{
esp_ble_gap_cb_param_t param = {0};
bt_status_t ret;
btc_msg_t msg = {0};
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_VENDOR_HCI_EVT;
param.vendor_hci_evt.subevt_code = subevt_code;
param.vendor_hci_evt.param_len = param_len;
param.vendor_hci_evt.param_buf = params;
ret = btc_transfer_context(&msg, &param, sizeof(esp_ble_gap_cb_param_t), btc_gap_ble_cb_deep_copy, btc_gap_ble_cb_deep_free);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
void btc_get_whitelist_size(uint16_t *length)
{
BTM_BleGetWhiteListSize(length);
@@ -1545,6 +1584,13 @@ static void btc_ble_dtm_enhance_rx_start(uint8_t rx_channel, uint8_t phy, uint8_
BTA_DmBleDtmEnhRxStart(rx_channel, phy, modulation_index, p_dtm_cmpl_cback);
}
void btc_get_periodic_list_size(uint8_t *size)
{
BTM_BleGetPeriodicAdvListSize(size);
return;
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
static void btc_ble_dtm_stop(tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback)
@@ -1774,6 +1820,18 @@ void btc_gap_ble_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
}
break;
}
case ESP_GAP_BLE_VENDOR_HCI_EVT: {
if (src->vendor_hci_evt.param_len) {
dst->vendor_hci_evt.param_buf = osi_malloc(src->vendor_hci_evt.param_len);
if (dst->vendor_hci_evt.param_buf) {
memcpy(dst->vendor_hci_evt.param_buf, src->vendor_hci_evt.param_buf,
src->vendor_hci_evt.param_len);
} else {
BTC_TRACE_ERROR("%s, malloc failed\n", __func__);
}
}
break;
}
default:
BTC_TRACE_ERROR("%s, Unhandled deep copy %d\n", __func__, msg->act);
break;
@@ -1902,6 +1960,13 @@ void btc_gap_ble_cb_deep_free(btc_msg_t *msg)
}
break;
}
case ESP_GAP_BLE_VENDOR_HCI_EVT: {
void *value = ((esp_ble_gap_cb_param_t *)msg->arg)->vendor_hci_evt.param_buf;
if (value) {
osi_free(value);
}
break;
}
default:
BTC_TRACE_DEBUG("Unhandled deep free %d", msg->act);
break;
@@ -2397,6 +2462,9 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
case BTC_GAP_BLE_SET_CSA_SUPPORT:
BTA_DmBleGapSetCsaSupport(arg->set_csa_support.csa_select, btc_ble_set_csa_support_callback);
break;
case BTC_GAP_BLE_ACT_SET_VENDOR_EVT_MASK:
BTA_DmBleGapSetVendorEventMask(arg->set_vendor_evt_mask.evt_mask, btc_ble_set_vendor_evt_mask_callback);
break;
default:
break;
}
@@ -2412,6 +2480,7 @@ void btc_gap_callback_init(void)
#if (BLE_50_FEATURE_SUPPORT == TRUE)
BTM_BleGapRegisterCallback(btc_ble_5_gap_callback);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
BTM_BleRegisterVendorHciEventCallback(btc_ble_vendor_hci_event_callback);
}
bool btc_gap_ble_init(void)

View File

@@ -23,6 +23,9 @@
#include "stack/a2d_sbc.h"
#if (BTC_AV_INCLUDED == TRUE)
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************
** Constants and data types
*****************************************************************************/

View File

@@ -109,6 +109,7 @@ typedef enum {
BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT,
BTC_GAP_BLE_SET_PRIVACY_MODE,
BTC_GAP_BLE_SET_CSA_SUPPORT,
BTC_GAP_BLE_ACT_SET_VENDOR_EVT_MASK,
} btc_gap_ble_act_t;
/* btc_ble_gap_args_t */
@@ -281,6 +282,10 @@ typedef union {
struct set_csa_support_args {
uint8_t csa_select;
} set_csa_support;
// BTC_GAP_BLE_ACT_SET_VENDOR_EVT_MASK
struct set_vendor_evt_mask_args {
uint32_t evt_mask;
} set_vendor_evt_mask;
} btc_ble_gap_args_t;
#if (BLE_50_FEATURE_SUPPORT == TRUE)
@@ -441,6 +446,9 @@ typedef union {
void btc_gap_ble_call_handler(btc_msg_t *msg);
void btc_gap_ble_cb_handler(btc_msg_t *msg);
void btc_get_whitelist_size(uint16_t *length);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
void btc_get_periodic_list_size(uint8_t *length);
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_gap_ble_arg_deep_free(btc_msg_t *msg);
void btc_gap_ble_cb_deep_free(btc_msg_t *msg);

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -909,6 +909,9 @@ static void btc_spp_write(btc_spp_args_t *arg)
} else {
if (fixed_queue_enqueue(slot->tx.queue, arg->write.p_data, 0)) {
BTA_JvRfcommWrite(arg->write.handle, slot->id, arg->write.len, arg->write.p_data);
// The TX queue of SPP will handle this memory properly.
// Set it to NULL here to prevent deep free handler from releasing it.
arg->write.p_data = NULL;
} else {
ret = ESP_SPP_NO_RESOURCE;
}
@@ -966,6 +969,13 @@ void btc_spp_arg_deep_free(btc_msg_t *msg)
case BTC_SPP_ACT_START_DISCOVERY:
if (arg->start_discovery.p_uuid_list) {
osi_free(arg->start_discovery.p_uuid_list);
arg->start_discovery.p_uuid_list = NULL;
}
break;
case BTC_SPP_ACT_WRITE:
if (arg->write.p_data) {
osi_free(arg->write.p_data);
arg->write.p_data = NULL;
}
break;
default:
@@ -1099,7 +1109,7 @@ void btc_spp_cb_handler(btc_msg_t *msg)
break;
case BTA_JV_RFCOMM_WRITE_EVT:
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
slot = spp_find_slot_by_handle(p_data->rfc_write.handle);
slot = spp_find_slot_by_id(p_data->rfc_write.req_id);
if (!slot) {
BTC_TRACE_ERROR("%s unable to find RFCOMM slot!, handle:%d", __func__, p_data->rfc_write.handle);
}
@@ -1165,7 +1175,7 @@ void btc_spp_cb_handler(btc_msg_t *msg)
param.close.async = p_data->rfc_close.async;
if (spp_local_param.spp_mode == ESP_SPP_MODE_CB) {
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
slot = spp_find_slot_by_handle(p_data->rfc_close.handle);
slot = spp_find_slot_by_id((uint32_t)p_data->rfc_close.user_data);
if (!slot) {
param.close.status = ESP_SPP_NO_CONNECTION;
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);
@@ -1179,7 +1189,7 @@ void btc_spp_cb_handler(btc_msg_t *msg)
bool need_call = true;
do {
osi_mutex_lock(&spp_local_param.spp_slot_mutex, OSI_MUTEX_MAX_TIMEOUT);
slot = spp_find_slot_by_handle(p_data->rfc_close.handle);
slot = spp_find_slot_by_id((uint32_t)p_data->rfc_close.user_data);
if (!slot) {
param.close.status = ESP_SPP_NO_CONNECTION;
osi_mutex_unlock(&spp_local_param.spp_slot_mutex);

View File

@@ -908,9 +908,82 @@
#define BTM_SEC_MAX_DEVICE_RECORDS UC_BT_SMP_MAX_BONDS
#endif
/* The number of security records for services. 32 AS Default*/
#if BTA_SDP_INCLUDED
#define BTM_SDP_SEC_SERVICE_RECORDS 1
#else
#define BTM_SDP_SEC_SERVICE_RECORDS 0
#endif
#if BTA_AG_INCLUDED
#define BTM_AG_SEC_SERVICE_RECORDS 1
#else
#define BTM_AG_SEC_SERVICE_RECORDS 0
#endif
#if BTA_HF_INCLUDED
#define BTM_HF_SEC_SERVICE_RECORDS 1
#else
#define BTM_HF_SEC_SERVICE_RECORDS 0
#endif
#if BTA_JV_INCLUDED
#define BTM_JV_SEC_SERVICE_RECORDS (MAX_RFC_PORTS - BTM_HF_SEC_SERVICE_RECORDS - BTM_AG_SEC_SERVICE_RECORDS)
#else
#define BTM_JV_SEC_SERVICE_RECORDS 0
#endif
#if AVCT_INCLUDED
#if AVCT_BROWSE_INCLUDED
#define BTM_AVCT_SEC_SERVICE_RECORDS 2
#else
#define BTM_AVCT_SEC_SERVICE_RECORDS 1
#endif // AVCT_BROWSE_INCLUDED
#else
#define BTM_AVCT_SEC_SERVICE_RECORDS 0
#endif
#if AVDT_INCLUDED
#if AVDT_REPORTING
#define BTM_AVDT_SEC_SERVICE_RECORDS 3
#else
#define BTM_AVDT_SEC_SERVICE_RECORDS 2
#endif // AVDT_INCLUDED
#else
#define BTM_AVDT_SEC_SERVICE_RECORDS 0
#endif
#if GAP_CONN_INCLUDED
#define BTM_GAP_SEC_SERVICE_RECORDS GAP_MAX_CONNECTIONS
#else
#define BTM_GAP_SEC_SERVICE_RECORDS 0
#endif
#if HID_DEV_INCLUDED
#define BTM_HIDD_SEC_SERVICE_RECORDS 3
#else
#define BTM_HIDD_SEC_SERVICE_RECORDS 0
#endif
#if HID_HOST_INCLUDED
#define BTM_HIDH_SEC_SERVICE_RECORDS 3
#else
#define BTM_HIDH_SEC_SERVICE_RECORDS 0
#endif
#if BLE_INCLUDED
#define BTM_GATT_SEC_SERVICE_RECORDS 1
#else
#define BTM_GATT_SEC_SERVICE_RECORDS 0
#endif
#define BTM_SEC_DEV_SERVICE_RECORDS 1
/* The number of security records for services. */
#ifndef BTM_SEC_MAX_SERVICE_RECORDS
#define BTM_SEC_MAX_SERVICE_RECORDS 8 // 32
#define BTM_SEC_MAX_SERVICE_RECORDS (BTM_SDP_SEC_SERVICE_RECORDS + BTM_AG_SEC_SERVICE_RECORDS \
+ BTM_AVCT_SEC_SERVICE_RECORDS + BTM_AVDT_SEC_SERVICE_RECORDS + BTM_GAP_SEC_SERVICE_RECORDS \
+ BTM_HIDD_SEC_SERVICE_RECORDS + BTM_GATT_SEC_SERVICE_RECORDS + BTM_JV_SEC_SERVICE_RECORDS \
+ BTM_HIDH_SEC_SERVICE_RECORDS + BTM_SEC_DEV_SERVICE_RECORDS + BTM_HF_SEC_SERVICE_RECORDS)
#endif
/* If True, force a retrieval of remote device name for each bond in case it's changed */

View File

@@ -25,6 +25,9 @@
#include "stack/bt_types.h"
#include "bt_common.h"
#if (BT_BLE_LOG_SPI_OUT_HOST_ENABLED && !CLASSIC_BT_INCLUDED)
#include "ble_log/ble_log_spi_out.h"
#endif // (BT_BLE_LOG_SPI_OUT_HOST_ENABLED && !CLASSIC_BT_INCLUDED)
static inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t len)
{
uint16_t i;
@@ -217,20 +220,83 @@ static inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t l
/* Define tracing for BTM
*/
#if (BT_BLE_LOG_SPI_OUT_HOST_ENABLED && !CLASSIC_BT_INCLUDED)
#define BTM_TRACE_ERROR(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_ERROR, "BT_BTM", fmt, ## args); \
if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(BTM, ERROR)) BT_PRINT_E("BT_BTM", fmt, ## args); \
}
#define BTM_TRACE_WARNING(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_WARN, "BT_BTM", fmt, ## args); \
if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(BTM, WARNING)) BT_PRINT_W("BT_BTM", fmt, ## args); \
}
#define BTM_TRACE_API(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_INFO, "BT_BTM", fmt, ## args); \
if (btm_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(BTM, API)) BT_PRINT_I("BT_BTM", fmt, ## args); \
}
#define BTM_TRACE_EVENT(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_DEBUG, "BT_BTM", fmt, ## args); \
if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(BTM, EVENT)) BT_PRINT_D("BT_BTM", fmt, ## args); \
}
#define BTM_TRACE_DEBUG(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_DEBUG, "BT_BTM", fmt, ## args); \
if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(BTM, DEBUG)) BT_PRINT_D("BT_BTM", fmt, ## args); \
}
#else
#define BTM_TRACE_ERROR(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(BTM, ERROR)) BT_PRINT_E("BT_BTM", fmt, ## args);}
#define BTM_TRACE_WARNING(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(BTM, WARNING)) BT_PRINT_W("BT_BTM", fmt, ## args);}
#define BTM_TRACE_API(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(BTM,API)) BT_PRINT_I("BT_BTM", fmt, ## args);}
#define BTM_TRACE_EVENT(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(BTM,EVENT)) BT_PRINT_D("BT_BTM", fmt, ## args);}
#define BTM_TRACE_DEBUG(fmt, args...) {if (btm_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(BTM,DEBUG)) BT_PRINT_D("BT_BTM", fmt, ## args);}
#endif // (BT_BLE_LOG_SPI_OUT_HOST_ENABLED && !CLASSIC_BT_INCLUDED)
/* Define tracing for the L2CAP unit
*/
#if (BT_BLE_LOG_SPI_OUT_HOST_ENABLED && !CLASSIC_BT_INCLUDED)
#define L2CAP_TRACE_ERROR(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_ERROR, "BT_L2CAP", fmt, ## args); \
if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(L2CAP, ERROR)) BT_PRINT_E("BT_L2CAP", fmt, ## args); \
}
#define L2CAP_TRACE_WARNING(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_WARN, "BT_L2CAP", fmt, ## args); \
if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(L2CAP, WARNING)) BT_PRINT_W("BT_L2CAP", fmt, ## args); \
}
#define L2CAP_TRACE_API(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_INFO, "BT_L2CAP", fmt, ## args); \
if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(L2CAP, API)) BT_PRINT_I("BT_L2CAP", fmt, ## args); \
}
#define L2CAP_TRACE_EVENT(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_DEBUG, "BT_L2CAP", fmt, ## args); \
if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(L2CAP, EVENT)) BT_PRINT_D("BT_L2CAP", fmt, ## args); \
}
#define L2CAP_TRACE_DEBUG(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_DEBUG, "BT_L2CAP", fmt, ## args); \
if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(L2CAP, DEBUG)) BT_PRINT_D("BT_L2CAP", fmt, ## args); \
}
#else
#define L2CAP_TRACE_ERROR(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(L2CAP, ERROR)) BT_PRINT_E("BT_L2CAP", fmt, ## args);}
#define L2CAP_TRACE_WARNING(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(L2CAP, WARNING)) BT_PRINT_W("BT_L2CAP", fmt, ## args);}
#define L2CAP_TRACE_API(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(L2CAP,API)) BT_PRINT_I("BT_L2CAP", fmt, ## args);}
#define L2CAP_TRACE_EVENT(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(L2CAP,EVENT)) BT_PRINT_D("BT_L2CAP", fmt, ## args);}
#define L2CAP_TRACE_DEBUG(fmt, args...) {if (l2cb.l2cap_trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(L2CAP,DEBUG)) BT_PRINT_D("BT_L2CAP", fmt, ## args);}
#endif // (BT_BLE_LOG_SPI_OUT_HOST_ENABLED && !CLASSIC_BT_INCLUDED)
/* Define tracing for the SDP unit
*/
#define SDP_TRACE_ERROR(fmt, args...) {if (sdp_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(SDP, ERROR)) BT_PRINT_E("BT_SDP", fmt, ## args);}
@@ -248,11 +314,38 @@ static inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t l
#define RFCOMM_TRACE_DEBUG(fmt, args...) {if (rfc_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(RFCOMM,DEBUG)) BT_PRINT_D("BT_RFCOMM", fmt, ## args);}
/* Generic Access Profile traces */
#if (BT_BLE_LOG_SPI_OUT_HOST_ENABLED && !CLASSIC_BT_INCLUDED)
#define GAP_TRACE_ERROR(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_ERROR, "BT_GAP", fmt, ## args); \
if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(GAP, ERROR)) BT_PRINT_E("BT_GAP", fmt, ## args); \
}
#define GAP_TRACE_WARNING(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_WARN, "BT_GAP", fmt, ## args); \
if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(GAP, WARNING)) BT_PRINT_W("BT_GAP", fmt, ## args); \
}
#define GAP_TRACE_API(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_INFO, "BT_GAP", fmt, ## args); \
if (gap_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(GAP, API)) BT_PRINT_I("BT_GAP", fmt, ## args); \
}
#define GAP_TRACE_EVENT(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_DEBUG, "BT_GAP", fmt, ## args); \
if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(GAP, EVENT)) BT_PRINT_D("BT_GAP", fmt, ## args); \
}
#else
#define GAP_TRACE_ERROR(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(GAP, ERROR)) BT_PRINT_E("BT_GAP", fmt, ## args);}
#define GAP_TRACE_API(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(GAP,API)) BT_PRINT_I("BT_GAP", fmt, ## args);}
#define GAP_TRACE_EVENT(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(GAP,EVENT)) BT_PRINT_D("BT_GAP", fmt, ## args);}
#define GAP_TRACE_WARNING(fmt, args...) {if (gap_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(GAP, WARNING)) BT_PRINT_W("BT_GAP", fmt, ## args);}
#endif // (BT_BLE_LOG_SPI_OUT_HOST_ENABLED && !CLASSIC_BT_INCLUDED)
/* define traces for HID Host */
#define HIDH_TRACE_ERROR(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(HIDH, ERROR)) BT_PRINT_E("BT_HIDH", fmt, ## args);}
#define HIDH_TRACE_WARNING(fmt, args...) {if (hh_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(HIDH, WARNING)) BT_PRINT_W("BT_HIDH", fmt, ## args);}
@@ -326,20 +419,81 @@ static inline void trc_dump_buffer(const char *prefix, uint8_t *data, uint16_t l
/* Define tracing for the ATT/GATT unit
*/
#if (BT_BLE_LOG_SPI_OUT_HOST_ENABLED && !CLASSIC_BT_INCLUDED)
#define GATT_TRACE_ERROR(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_ERROR, "BT_GATT", fmt, ## args); \
if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(GATT, ERROR)) BT_PRINT_E("BT_GATT", fmt, ## args); \
}
#define GATT_TRACE_WARNING(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_WARN, "BT_GATT", fmt, ## args); \
if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(GATT, WARNING)) BT_PRINT_W("BT_GATT", fmt, ## args); \
}
#define GATT_TRACE_API(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_INFO, "BT_GATT", fmt, ## args); \
if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(GATT, API)) BT_PRINT_I("BT_GATT", fmt, ## args); \
}
#define GATT_TRACE_EVENT(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_DEBUG, "BT_GATT", fmt, ## args); \
if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(GATT, EVENT)) BT_PRINT_D("BT_GATT", fmt, ## args); \
}
#define GATT_TRACE_DEBUG(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_DEBUG, "BT_GATT", fmt, ## args); \
if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(GATT, DEBUG)) BT_PRINT_D("BT_GATT", fmt, ## args); \
}
#else
#define GATT_TRACE_ERROR(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(GATT, ERROR)) BT_PRINT_E("BT_GATT", fmt, ## args);}
#define GATT_TRACE_WARNING(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(GATT, WARNING)) BT_PRINT_W("BT_GATT", fmt, ## args);}
#define GATT_TRACE_API(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(GATT,API)) BT_PRINT_I("BT_GATT", fmt, ## args);}
#define GATT_TRACE_EVENT(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(GATT,EVENT)) BT_PRINT_D("BT_GATT", fmt, ## args);}
#define GATT_TRACE_DEBUG(fmt, args...) {if (gatt_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(GATT,DEBUG)) BT_PRINT_D("BT_GATT", fmt, ## args);}
#endif // (BT_BLE_LOG_SPI_OUT_HOST_ENABLED && !CLASSIC_BT_INCLUDED)
/* Define tracing for the SMP unit
*/
#if (BT_BLE_LOG_SPI_OUT_HOST_ENABLED && !CLASSIC_BT_INCLUDED)
#define SMP_TRACE_ERROR(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_ERROR, "BT_SMP", fmt, ## args); \
if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(SMP, ERROR)) BT_PRINT_E("BT_SMP", fmt, ## args); \
}
#define SMP_TRACE_WARNING(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_WARN, "BT_SMP", fmt, ## args); \
if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(SMP, WARNING)) BT_PRINT_W("BT_SMP", fmt, ## args); \
}
#define SMP_TRACE_API(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_INFO, "BT_SMP", fmt, ## args); \
if (smp_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(SMP, API)) BT_PRINT_I("BT_SMP", fmt, ## args); \
}
#define SMP_TRACE_EVENT(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_DEBUG, "BT_SMP", fmt, ## args); \
if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(SMP, EVENT)) BT_PRINT_D("BT_SMP", fmt, ## args); \
}
#define SMP_TRACE_DEBUG(fmt, args...) { \
ble_log_spi_out_printf_enh(BLE_LOG_SPI_OUT_SOURCE_BLUEDROID, BLE_LOG_SPI_OUT_LEVEL_DEBUG, "BT_SMP", fmt, ## args); \
if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(SMP, DEBUG)) BT_PRINT_D("BT_SMP", fmt, ## args); \
}
#else
#define SMP_TRACE_ERROR(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_ERROR && BT_LOG_LEVEL_CHECK(SMP, ERROR)) BT_PRINT_E("BT_SMP", fmt, ## args);}
#define SMP_TRACE_WARNING(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_WARNING && BT_LOG_LEVEL_CHECK(SMP, WARNING)) BT_PRINT_W("BT_SMP", fmt, ## args);}
#define SMP_TRACE_API(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_API && BT_LOG_LEVEL_CHECK(SMP,API)) BT_PRINT_I("BT_SMP", fmt, ## args);}
#define SMP_TRACE_EVENT(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_EVENT && BT_LOG_LEVEL_CHECK(SMP,EVENT)) BT_PRINT_D("BT_SMP", fmt, ## args);}
#define SMP_TRACE_DEBUG(fmt, args...) {if (smp_cb.trace_level >= BT_TRACE_LEVEL_DEBUG && BT_LOG_LEVEL_CHECK(SMP,DEBUG)) BT_PRINT_D("BT_SMP", fmt, ## args);}
#endif // (BT_BLE_LOG_SPI_OUT_HOST_ENABLED && !CLASSIC_BT_INCLUDED)
extern UINT8 btif_trace_level;

View File

@@ -83,6 +83,7 @@ typedef struct {
bool secure_connections_supported;
#if (BLE_50_FEATURE_SUPPORT == TRUE)
uint16_t ble_ext_adv_data_max_len;
uint16_t get_ble_periodic_advertiser_list_size;
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
} controller_local_param_t;
@@ -95,6 +96,7 @@ static controller_local_param_t *controller_param_ptr;
#define AWAIT_COMMAND(command) future_await(controller_param.hci->transmit_command_futured(command))
static bool loaded = false;
// Module lifecycle functions
static void start_up(void)
@@ -277,6 +279,10 @@ static void start_up(void)
response,
&controller_param.ble_ext_adv_data_max_len);
}
response = AWAIT_COMMAND(controller_param.packet_factory->make_read_periodic_adv_list_size());
controller_param.packet_parser->parse_ble_read_periodic_adv_list_size_response(
response,
&controller_param.get_ble_periodic_advertiser_list_size);
#endif // (BLE_50_FEATURE_SUPPORT == TRUE && BLE_42_FEATURE_SUPPORT == FALSE)
if (HCI_LE_DATA_LEN_EXT_SUPPORTED(controller_param.features_ble.as_array)) {
@@ -317,6 +323,17 @@ static void shut_down(void)
controller_param.readable = false;
}
#if (BT_BLE_DYNAMIC_ENV_MEMORY == TRUE)
void free_controller_param(void)
{
if (controller_param_ptr) {
osi_free(controller_param_ptr);
controller_param_ptr = NULL;
loaded = false;
}
}
#endif
static bool get_is_ready(void)
{
return controller_param.readable;
@@ -517,6 +534,12 @@ static uint16_t ble_get_ext_adv_data_max_len(void)
return controller_param.ble_ext_adv_data_max_len;
}
static uint8_t get_ble_periodic_adv_list_size(void)
{
assert(controller_param.readable);
assert(controller_param.ble_supported);
return controller_param.get_ble_periodic_advertiser_list_size;
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BTM_SCO_HCI_INCLUDED == TRUE)
static uint8_t get_sco_data_size(void)
@@ -577,6 +600,7 @@ static const controller_t interface = {
set_ble_resolving_list_max_size,
#if (BLE_50_FEATURE_SUPPORT == TRUE)
ble_get_ext_adv_data_max_len,
get_ble_periodic_adv_list_size,
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BTM_SCO_HCI_INCLUDED == TRUE)
get_sco_data_size,
@@ -586,7 +610,6 @@ static const controller_t interface = {
const controller_t *controller_get_interface(void)
{
static bool loaded = false;
if (!loaded) {
loaded = true;
#if (BT_BLE_DYNAMIC_ENV_MEMORY == TRUE)

View File

@@ -82,6 +82,7 @@ typedef struct controller_t {
#if (BLE_50_FEATURE_SUPPORT == TRUE)
uint16_t (*ble_get_ext_adv_data_max_len)(void);
uint8_t (*get_ble_periodic_adv_list_size)(void);
#endif // BLE_50_FEATURE_SUPPORT
#if (BTM_SCO_HCI_INCLUDED == TRUE)

View File

@@ -41,6 +41,14 @@
#include "stack/hcimsgs.h"
#include "hci_log/bt_hci_log.h"
#if CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
#include "ble_log/ble_log_spi_out.h"
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
#if CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
#include "ble_log/ble_log_spi_out.h"
#endif // CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED
#define HCI_BLE_EVENT 0x3e
#define PACKET_TYPE_TO_INBOUND_INDEX(type) ((type) - 2)
#define PACKET_TYPE_TO_INDEX(type) ((type) - 1)
@@ -214,6 +222,9 @@ static uint16_t transmit_data(serial_data_type_t type,
#if (BT_HCI_LOG_INCLUDED == TRUE)
bt_hci_log_record_hci_data(data[0], &data[1], length - 1);
#endif
#if (CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED && !SOC_ESP_NIMBLE_CONTROLLER)
ble_log_spi_out_write_with_ts(BLE_LOG_SPI_OUT_SOURCE_NIMBLE, data, length);
#endif // (CONFIG_BT_BLE_LOG_SPI_OUT_HCI_ENABLED && !SOC_ESP_NIMBLE_CONTROLLER)
// TX Data to target
esp_vhci_host_send_packet(data, length);
@@ -561,6 +572,9 @@ void bt_record_hci_data(uint8_t *data, uint16_t len)
static int host_recv_pkt_cb(uint8_t *data, uint16_t len)
{
#if (BT_BLE_LOG_SPI_OUT_HCI_ENABLED && !SOC_ESP_NIMBLE_CONTROLLER)
ble_log_spi_out_write_with_ts(BLE_LOG_SPI_OUT_SOURCE_HCI_UPSTREAM, data, len);
#endif // (BT_BLE_LOG_SPI_OUT_HCI_ENABLED && !SOC_ESP_NIMBLE_CONTROLLER)
//Target has packet to host, malloc new buffer for packet
BT_HDR *pkt = NULL;
pkt_linked_item_t *linked_pkt = NULL;

View File

@@ -223,6 +223,12 @@ static BT_HDR *make_read_max_adv_data_len(void)
{
return make_command_no_params(HCI_BLE_RD_MAX_ADV_DATA_LEN);
}
static BT_HDR *make_read_periodic_adv_list_size(void)
{
return make_command_no_params(HCI_BLE_RD_PERIOD_ADV_LIST_SIZE);
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
// Internal functions
@@ -270,6 +276,7 @@ static const hci_packet_factory_t interface = {
make_ble_read_resolving_list_size,
#if (BLE_50_FEATURE_SUPPORT == TRUE)
make_read_max_adv_data_len,
make_read_periodic_adv_list_size,
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
make_ble_read_suggested_default_data_length,
make_ble_write_suggested_default_data_length,

View File

@@ -221,6 +221,19 @@ static void parse_ble_read_adv_max_len_response(
}
osi_free(response);
}
static void parse_ble_read_periodic_adv_list_size_response(
BT_HDR *response,
uint16_t *periodic_adv_list_size_ptr)
{
uint8_t *stream = read_command_complete_header(response, HCI_BLE_RD_PERIOD_ADV_LIST_SIZE, 1 /* bytes after */);
if (stream) {
// Size: 1 Octets ; Value: 0x01 to 0xFF ; Total number of Periodic Advertiser list entries that can be stored in the Controller
STREAM_TO_UINT8(*periodic_adv_list_size_ptr, stream);
}
osi_free(response);
}
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
@@ -283,6 +296,7 @@ static const hci_packet_parser_t interface = {
parse_ble_read_resolving_list_size_response,
#if (BLE_50_FEATURE_SUPPORT == TRUE)
parse_ble_read_adv_max_len_response,
parse_ble_read_periodic_adv_list_size_response,
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
parse_ble_read_suggested_default_data_length_response
};

View File

@@ -44,6 +44,7 @@ typedef struct {
BT_HDR *(*make_ble_read_resolving_list_size)(void);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
BT_HDR *(*make_read_max_adv_data_len)(void);
BT_HDR *(*make_read_periodic_adv_list_size)(void);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
BT_HDR *(*make_ble_read_suggested_default_data_length)(void);
BT_HDR *(*make_ble_write_suggested_default_data_length)(uint16_t SuggestedMaxTxOctets, uint16_t SuggestedMaxTxTime);

View File

@@ -96,9 +96,13 @@ typedef struct {
);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
void (*parse_ble_read_adv_max_len_response) (
BT_HDR *respone,
BT_HDR *response,
uint16_t *ble_ext_adv_data_max_len_ptr
);
void (*parse_ble_read_periodic_adv_list_size_response) (
BT_HDR *response,
uint16_t *periodic_advertiser_list_size
);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
void (*parse_ble_read_suggested_default_data_length_response)(
BT_HDR *response,

View File

@@ -64,6 +64,9 @@ static void bte_main_enable(void);
bluedroid_init_done_cb_t bluedroid_init_done_cb;
extern void osi_mem_dbg_init(void);
#if (BT_BLE_DYNAMIC_ENV_MEMORY == TRUE)
extern void free_controller_param(void);
#endif
/******************************************************************************
**
** Function bte_main_boot_entry
@@ -85,7 +88,7 @@ int bte_main_boot_entry(bluedroid_init_done_cb_t cb)
osi_init();
//Enbale HCI
//Enable HCI
bte_main_enable();
return 0;
@@ -105,6 +108,11 @@ void bte_main_shutdown(void)
#if (BLE_INCLUDED == TRUE)
BTA_VendorCleanup();
#endif
#if (BT_BLE_DYNAMIC_ENV_MEMORY == TRUE)
free_controller_param();
#endif
bte_main_disable();
osi_deinit();

View File

@@ -335,7 +335,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, UINT8 bdn[BTM_MAX_REM_BD_NAME_L
#if (CLASSIC_BT_INCLUDED == TRUE)
const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND);
#endif ///CLASSIC_BT_INCLUDED == TRUE
/* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */
/* Store the Peer Security Capabilities (in SM4 and rmt_sec_caps) */
#if (SMP_INCLUDED == TRUE)
btm_sec_set_peer_sec_caps(p, p_dev_rec);
#endif ///SMP_INCLUDED == TRUE
@@ -350,7 +350,7 @@ void btm_acl_created (BD_ADDR bda, DEV_CLASS dc, UINT8 bdn[BTM_MAX_REM_BD_NAME_L
return;
}
} else {
/* If remote features indicated secure connection (SC) mode, check the remote feautres again*/
/* If remote features indicated secure connection (SC) mode, check the remote features again*/
/* this is to prevent from BIAS attack where attacker can downgrade SC mode*/
btm_read_remote_features (p->hci_handle);
}
@@ -474,7 +474,7 @@ void btm_acl_removed (BD_ADDR bda, tBT_TRANSPORT transport)
BTM_TRACE_DEBUG("Bonded\n");
}
} else {
BTM_TRACE_DEBUG("Bletooth link down\n");
BTM_TRACE_DEBUG("Bluetooth link down\n");
p_dev_rec->sec_flags &= ~(BTM_SEC_AUTHORIZED | BTM_SEC_AUTHENTICATED
| BTM_SEC_ENCRYPTED | BTM_SEC_ROLE_SWITCHED);
}
@@ -531,10 +531,11 @@ void btm_acl_device_down (void)
*******************************************************************************/
void btm_acl_update_busy_level (tBTM_BLI_EVENT event)
{
tBTM_BL_UPDATE_DATA evt;
UINT8 busy_level;
BTM_TRACE_DEBUG ("btm_acl_update_busy_level\n");
UINT8 busy_level_flags = 0;
BOOLEAN old_inquiry_state = btm_cb.is_inquiry;
BTM_TRACE_DEBUG ("btm_acl_update_busy_level\n");
switch (event) {
case BTM_BLI_ACL_UP_EVT:
BTM_TRACE_DEBUG ("BTM_BLI_ACL_UP_EVT\n");
@@ -545,30 +546,31 @@ void btm_acl_update_busy_level (tBTM_BLI_EVENT event)
case BTM_BLI_PAGE_EVT:
BTM_TRACE_DEBUG ("BTM_BLI_PAGE_EVT\n");
btm_cb.is_paging = TRUE;
evt.busy_level_flags = BTM_BL_PAGING_STARTED;
busy_level_flags = BTM_BL_PAGING_STARTED;
break;
case BTM_BLI_PAGE_DONE_EVT:
BTM_TRACE_DEBUG ("BTM_BLI_PAGE_DONE_EVT\n");
btm_cb.is_paging = FALSE;
evt.busy_level_flags = BTM_BL_PAGING_COMPLETE;
busy_level_flags = BTM_BL_PAGING_COMPLETE;
break;
case BTM_BLI_INQ_EVT:
BTM_TRACE_DEBUG ("BTM_BLI_INQ_EVT\n");
btm_cb.is_inquiry = TRUE;
evt.busy_level_flags = BTM_BL_INQUIRY_STARTED;
busy_level_flags = BTM_BL_INQUIRY_STARTED;
break;
case BTM_BLI_INQ_CANCEL_EVT:
BTM_TRACE_DEBUG ("BTM_BLI_INQ_CANCEL_EVT\n");
btm_cb.is_inquiry = FALSE;
evt.busy_level_flags = BTM_BL_INQUIRY_CANCELLED;
busy_level_flags = BTM_BL_INQUIRY_CANCELLED;
break;
case BTM_BLI_INQ_DONE_EVT:
BTM_TRACE_DEBUG ("BTM_BLI_INQ_DONE_EVT\n");
btm_cb.is_inquiry = FALSE;
evt.busy_level_flags = BTM_BL_INQUIRY_COMPLETE;
busy_level_flags = BTM_BL_INQUIRY_COMPLETE;
break;
}
UINT8 busy_level;
if (btm_cb.is_paging || btm_cb.is_inquiry) {
busy_level = 10;
} else {
@@ -576,8 +578,11 @@ void btm_acl_update_busy_level (tBTM_BLI_EVENT event)
}
if ((busy_level != btm_cb.busy_level) || (old_inquiry_state != btm_cb.is_inquiry)) {
evt.event = BTM_BL_UPDATE_EVT;
evt.busy_level = busy_level;
tBTM_BL_UPDATE_DATA evt = {
.event = BTM_BL_UPDATE_EVT,
.busy_level = busy_level,
.busy_level_flags = busy_level_flags,
};
btm_cb.busy_level = busy_level;
if (btm_cb.p_bl_changed_cb && (btm_cb.bl_evt_mask & BTM_BL_UPDATE_MASK)) {
(*btm_cb.p_bl_changed_cb)((tBTM_BL_EVENT_DATA *)&evt);
@@ -1016,7 +1021,7 @@ void btm_process_remote_ext_features (tACL_CONN *p_acl_cb, UINT8 num_read_pages)
const UINT8 req_pend = (p_dev_rec->sm4 & BTM_SM4_REQ_PEND);
#if (SMP_INCLUDED == TRUE)
/* Store the Peer Security Capabilites (in SM4 and rmt_sec_caps) */
/* Store the Peer Security Capabilities (in SM4 and rmt_sec_caps) */
btm_sec_set_peer_sec_caps(p_acl_cb, p_dev_rec);
#endif ///SMP_INCLUDED == TRUE
BTM_TRACE_API("%s: pend:%d\n", __FUNCTION__, req_pend);
@@ -1455,7 +1460,7 @@ void btm_process_clk_off_comp_evt (UINT16 hci_handle, UINT16 clock_offset)
**
** Function btm_acl_role_changed
**
** Description This function is called whan a link's master/slave role change
** Description This function is called when a link's master/slave role change
** event or command status event (with error) is received.
** It updates the link control block, and calls
** the registered callback with status and role (if registered).
@@ -2218,6 +2223,18 @@ void BTM_BleGetWhiteListSize(uint16_t *length)
*length = p_cb->white_list_avail_size;
return;
}
#if (BLE_50_FEATURE_SUPPORT == TRUE)
void BTM_BleGetPeriodicAdvListSize(uint8_t *size)
{
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
if (p_cb->periodic_adv_list_size == 0) {
BTM_TRACE_WARNING("%s Periodic Adv list is full.", __func__);
}
*size = p_cb->periodic_adv_list_size;
}
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
#endif ///BLE_INCLUDED == TRUE
/*******************************************************************************
@@ -2705,7 +2722,7 @@ void btm_acl_connected(BD_ADDR bda, UINT16 handle, UINT8 link_type, UINT8 enc_mo
l2c_link_hci_conn_comp(status, handle, bda);
}
#if BTM_SCO_INCLUDED == TRUE
else {
else if (link_type == HCI_LINK_TYPE_SCO) {
memset(&esco_data, 0, sizeof(tBTM_ESCO_DATA));
esco_data.link_type = HCI_LINK_TYPE_SCO;
memcpy (esco_data.bd_addr, bda, BD_ADDR_LEN);

View File

@@ -2289,17 +2289,16 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data)
}
} else {
if (event == SMP_SC_LOC_OOB_DATA_UP_EVT) {
tBTM_LE_EVT_DATA evt_data;
memcpy(&evt_data.local_oob_data, &p_data->loc_oob_data, sizeof(tSMP_LOC_OOB_DATA));
if (btm_cb.api.p_le_callback) {
(*btm_cb.api.p_le_callback)(event, bd_addr, &evt_data);
}
} else {
BTM_TRACE_ERROR("btm_proc_smp_cback received for unknown device");
}
if (event == SMP_SC_LOC_OOB_DATA_UP_EVT) {
tBTM_LE_EVT_DATA evt_data;
memcpy(&evt_data.local_oob_data, &p_data->loc_oob_data, sizeof(tSMP_LOC_OOB_DATA));
if (btm_cb.api.p_le_callback) {
(*btm_cb.api.p_le_callback)(event, bd_addr, &evt_data);
}
}
return 0;
}
#endif ///SMP_INCLUDED == TRUE

View File

@@ -423,6 +423,23 @@ void btm_ble_white_list_init(UINT8 white_list_size)
btm_cb.ble_ctr_cb.white_list_avail_size = white_list_size;
}
#if (BLE_50_FEATURE_SUPPORT == TRUE)
/*******************************************************************************
**
** Function btm_ble_periodic_adv_list_init
**
** Description Initialize the periodic advertiser list size.
**
** Parameters periodic_adv_size: The size of the periodic advertiser list to be initialized.
**
*******************************************************************************/
void btm_ble_periodic_adv_list_init(UINT8 periodic_adv_size)
{
BTM_TRACE_DEBUG("%s white_list_size = %d", __func__, periodic_adv_size);
btm_cb.ble_ctr_cb.periodic_adv_list_size = periodic_adv_size;
}
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
/*******************************************************************************
**
** Function btm_ble_add_2_white_list_complete
@@ -724,7 +741,7 @@ void btm_resume_wl_activity(tBTM_BLE_WL_STATE wl_state)
static void btm_wl_update_to_controller(void)
{
/* whitelist will be added in the btm_ble_resume_bg_conn(), we do not
support background connection now, so we nedd to use btm_execute_wl_dev_operation
support background connection now, so we need to use btm_execute_wl_dev_operation
to add whitelist directly ,if we support background connection in the future,
please delete btm_execute_wl_dev_operation(). */
btm_execute_wl_dev_operation();

View File

@@ -71,6 +71,8 @@ static tBTM_BLE_CTRL_FEATURES_CBACK *p_ctrl_le_feature_rd_cmpl_cback = NULL;
#endif
tBTM_CallbackFunc conn_callback_func;
// BLE vendor HCI event callback
static tBTM_BLE_VENDOR_HCI_EVT_CBACK *ble_vs_evt_callback = NULL;
/*******************************************************************************
** Local functions
*******************************************************************************/
@@ -326,6 +328,11 @@ void BTM_BleRegiseterPktLengthChangeCallback(tBTM_SET_PKT_DATA_LENGTH_CBACK *ptk
conn_callback_func.set_pkt_data_length_cb = ptk_len_chane_cb;
}
void BTM_BleRegisterVendorHciEventCallback(tBTM_BLE_VENDOR_HCI_EVT_CBACK *vendor_hci_evt_cb)
{
ble_vs_evt_callback = vendor_hci_evt_cb;
}
/*******************************************************************************
**
** Function BTM_BleUpdateAdvWhitelist
@@ -4003,7 +4010,6 @@ static void btm_ble_stop_discover(void)
if (!BTM_BLE_IS_SCAN_ACTIVE(p_ble_cb->scan_activity)) {
/* Clear the inquiry callback if set */
btm_cb.ble_ctr_cb.inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE;
btm_cb.ble_ctr_cb.inq_var.state &= ~BTM_BLE_SCANNING;
/* stop discovery now */
if(btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_DISABLE, BTM_BLE_DUPLICATE_ENABLE)) {
@@ -4530,6 +4536,26 @@ BOOLEAN btm_ble_update_mode_operation(UINT8 link_role, BD_ADDR bd_addr, UINT8 st
return bg_con;
}
static void btm_ble_vs_evt_callback(UINT8 len, UINT8 *p)
{
UINT8 sub_event;
if (!len || !p) {
return;
}
STREAM_TO_UINT8(sub_event, p);
len--;
if (sub_event < HCI_VSE_LE_LEGACY_SCAN_REQ_RECEIVED_EVT) {
return;
}
if (ble_vs_evt_callback) {
ble_vs_evt_callback(sub_event, len, p);
}
}
/*******************************************************************************
**
** Function btm_ble_init
@@ -4586,6 +4612,8 @@ void btm_ble_init (void)
#if BLE_VND_INCLUDED == FALSE
btm_ble_adv_filter_init();
#endif
BTM_RegisterForVSEvents(btm_ble_vs_evt_callback, TRUE);
}
/*******************************************************************************
@@ -4779,6 +4807,17 @@ BOOLEAN BTM_BleSetCsaSupport(UINT8 csa_select, tBTM_SET_CSA_SUPPORT_CMPL_CBACK *
return TRUE;
}
BOOLEAN BTM_BleSetVendorEventMask(UINT32 evt_mask, tBTM_SET_VENDOR_EVT_MASK_CBACK *p_callback)
{
if (btsnd_hcic_ble_set_vendor_evt_mask(evt_mask) != TRUE) {
BTM_TRACE_ERROR("LE SetVendorEventMask evt_mask=%x: error", evt_mask);
return FALSE;
}
btm_cb.ble_ctr_cb.set_vendor_evt_mask_cmpl_cb = p_callback;
return TRUE;
}
bool btm_ble_adv_pkt_ready(void)
{
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;

View File

@@ -191,6 +191,9 @@ static void reset_complete(void)
if (controller->supports_ble()) {
btm_ble_white_list_init(controller->get_ble_white_list_size());
#if (BLE_50_FEATURE_SUPPORT == TRUE)
btm_ble_periodic_adv_list_init(controller->get_ble_periodic_adv_list_size());
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
l2c_link_processs_ble_num_bufs(controller->get_acl_buffer_count_ble());
}
#endif
@@ -730,6 +733,14 @@ void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len,
}
break;
}
case HCI_VENDOR_BLE_SET_EVT_MASK: {
uint8_t status;
STREAM_TO_UINT8(status, p);
if (ble_cb && ble_cb->set_vendor_evt_mask_cmpl_cb) {
ble_cb->set_vendor_evt_mask_cmpl_cb(status);
}
break;
}
default:
break;
}
@@ -820,7 +831,7 @@ void btm_vendor_specific_evt (UINT8 *p, UINT8 evt_len)
STREAM_TO_UINT8(sub_event, p_evt);
/* Check in subevent if authentication is through Legacy Authentication. */
if (sub_event == ESP_VS_REM_LEGACY_AUTH_CMP) {
if (sub_event == HCI_VENDOR_LEGACY_REM_AUTH_EVT_SUBCODE) {
UINT16 hci_handle;
STREAM_TO_UINT16(hci_handle, p_evt);
btm_sec_handle_remote_legacy_auth_cmp(hci_handle);

View File

@@ -117,8 +117,6 @@ void btm_sco_init (void)
}
#endif
/* Initialize nonzero defaults */
btm_cb.sco_cb.sco_disc_reason = BTM_INVALID_SCO_DISC_REASON;
btm_cb.sco_cb.def_esco_parms = btm_esco_defaults; /* Initialize with defaults */
btm_cb.sco_cb.desired_sco_mode = BTM_DEFAULT_SCO_MODE;
}
@@ -1048,7 +1046,6 @@ void btm_sco_connected (UINT8 hci_status, BD_ADDR bda, UINT16 hci_handle,
tBTM_CHG_ESCO_PARAMS parms;
#endif
btm_cb.sco_cb.sco_disc_reason = hci_status;
BTM_TRACE_API("%s, handle %x", __FUNCTION__, hci_handle);
#if (BTM_MAX_SCO_LINKS>0)
for (xx = 0; xx < BTM_MAX_SCO_LINKS; xx++, p++) {
@@ -1224,16 +1221,11 @@ void btm_sco_removed (UINT16 hci_handle, UINT8 reason)
#if (BTM_MAX_SCO_LINKS>0)
tSCO_CONN *p = &btm_cb.sco_cb.sco_db[0];
UINT16 xx;
#endif
btm_cb.sco_cb.sco_disc_reason = reason;
#if (BTM_MAX_SCO_LINKS>0)
p = &btm_cb.sco_cb.sco_db[0];
for (xx = 0; xx < BTM_MAX_SCO_LINKS; xx++, p++) {
if ((p->state != SCO_ST_UNUSED) && (p->state != SCO_ST_LISTENING) && (p->hci_handle == hci_handle)) {
btm_sco_flush_sco_data(xx);
p->state = SCO_ST_UNUSED;
#if BTM_SCO_HCI_INCLUDED == TRUE
btm_cb.sco_cb.xmit_window_size += p->sent_not_acked;
@@ -1375,24 +1367,6 @@ UINT16 BTM_ReadScoPacketTypes (UINT16 sco_inx)
#endif
}
/*******************************************************************************
**
** Function BTM_ReadScoDiscReason
**
** Description This function is returns the reason why an (e)SCO connection
** has been removed. It contains the value until read, or until
** another (e)SCO connection has disconnected.
**
** Returns HCI reason or BTM_INVALID_SCO_DISC_REASON if not set.
**
*******************************************************************************/
UINT16 BTM_ReadScoDiscReason (void)
{
UINT16 res = btm_cb.sco_cb.sco_disc_reason;
btm_cb.sco_cb.sco_disc_reason = BTM_INVALID_SCO_DISC_REASON;
return (res);
}
/*******************************************************************************
**
** Function BTM_ReadDeviceScoPacketTypes
@@ -1894,10 +1868,6 @@ UINT8 *BTM_ReadScoBdAddr(UINT16 sco_inx)
{
return ((UINT8 *) NULL);
}
UINT16 BTM_ReadScoDiscReason (void)
{
return (BTM_INVALID_SCO_DISC_REASON);
}
tBTM_STATUS BTM_SetEScoMode (tBTM_SCO_TYPE sco_mode, tBTM_ESCO_PARAMS *p_parms)
{
return (BTM_MODE_UNSUPPORTED);

View File

@@ -353,6 +353,10 @@ typedef struct {
tBTM_BLE_SEL_CBACK *p_select_cback;
/* white list information */
UINT8 white_list_avail_size;
#if (BLE_50_FEATURE_SUPPORT == TRUE)
/* periodic list information */
UINT8 periodic_adv_list_size;
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb;
tBTM_BLE_WL_STATE wl_state;
@@ -381,6 +385,7 @@ typedef struct {
UINT8 link_count[2]; /* total link count master and slave*/
tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK *update_exceptional_list_cmp_cb;
tBTM_SET_CSA_SUPPORT_CMPL_CBACK *set_csa_support_cmpl_cb;
tBTM_SET_VENDOR_EVT_MASK_CBACK *set_vendor_evt_mask_cmpl_cb;
} tBTM_BLE_CB;
#ifdef __cplusplus
@@ -540,6 +545,7 @@ void btm_ble_channel_select_algorithm_evt(tBTM_BLE_CHANNEL_SEL_ALG *params);
void btm_ble_periodic_adv_report_evt(tBTM_PERIOD_ADV_REPORT *params);
void btm_ble_periodic_adv_sync_lost_evt(tBTM_BLE_PERIOD_ADV_SYNC_LOST *params);
void btm_ble_periodic_adv_sync_establish_evt(tBTM_BLE_PERIOD_ADV_SYNC_ESTAB *params);
void btm_ble_periodic_adv_list_init(UINT8 periodic_adv_size);
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)

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