Compare commits

...

703 Commits

Author SHA1 Message Date
ed1304146b Merge branch 'bugfix/timer_delete_dispatch_race_v3.1' into 'release/v3.1'
esp_timer: do not allow deleting timers while callbacks are dispatched (backport v3.1)

See merge request idf/esp-idf!3993
2019-01-02 20:42:45 +08:00
1937bc2bd7 esp_timer: do not allow deleting timers while callbacks are dispatched
timer_process_alarm function of esp_timer holds a spinlock for the
entire duration of its operation, except for the time when timer
callback function is called. It is possible that when
timer_process_alarm releases the spinlock, a higher priority task may
run and delete the timer. Then the execution will return to
timer_process_alarm, and this will either cause a crash, or undesired
execution of callback after the timer has been stopped or deleted.

To solve this problem, add a mutex which will prevent deletion of timers
while callbacks are being dispatched.
2019-01-02 20:01:26 +11:00
a18f92b09b Merge branch 'bugfix/tw27963_fix_wifi_stop_bug_v3.1' into 'release/v3.1'
esp32: fix WiFi stop bug in WiFi/BT coexist mode (backport v3.1)

See merge request idf/esp-idf!3981
2018-12-18 11:40:42 +08:00
6a418013a3 esp32: fix WiFi stop bug in WiFi/BT coexist mode
This fix includes following changes:
1. Fix the bug that esp_restart()/esp_wifi_stop() sometimes fails in WiFi/BT coexist mode.
2. Add a timer for WiFi stop and stop WiFi forcibly once the timer expires.
2018-12-17 20:39:54 +08:00
ad9bce3203 Merge branch 'bugfix/btdm_assert_ble_65536_v3.1' into 'release/v3.1'
fix bug that there's very low ratio to cause BLE assert(65536, 0) in rwble.c at line 222

See merge request idf/esp-idf!3967
2018-12-14 20:34:33 +08:00
129f1df461 fix bug that there's very low ratio to cause BLE assert(65536, 0) in rwble.c at line 222 2018-12-14 17:52:31 +08:00
07e8b35ead Merge branch 'bugfix/xts_compile_err_3.1' into 'release/v3.1'
Bugfix/xts compile err 3.1

See merge request idf/esp-idf!3747
2018-12-10 17:41:29 +08:00
76f98a4b36 mbedtls: Fix compilation errors when CONFIG_MBEDTLS_HARDWARE_AES is disabled 2018-12-07 09:41:59 +00:00
0b3fdf420f Merge branch 'bugfix/fat_lock_log_v3.1' into 'release/v3.1'
fatfs: Do not log from critical sections (backport v3.1)

See merge request idf/esp-idf!3720
2018-12-07 14:07:16 +08:00
a7d37b303d Merge branch 'bugfix/btdm_assert_ble_32768_v3.1' into 'release/v3.1'
fix bug that there's very low ratio to cause BLE assert(32768, 0) in rwble.c at line 222

See merge request idf/esp-idf!3918
2018-12-07 13:54:18 +08:00
a7b5496770 Merge branch 'fix/spi_callback_in_iram_v3.1' into 'release/v3.1'
spi: fix the crash when callbacks are not in the IRAM (Backports v3.1)

See merge request idf/esp-idf!3886
2018-12-07 09:11:47 +08:00
ce5b2709ab fix bug that there's very low ratio to cause BLE assert(32768, 0) in rwble.c at line 222 2018-12-06 21:17:49 +08:00
4070d095d0 Merge branch 'bugfix/btdm_bugs_caused_by_coex_v3.1' into 'release/v3.1'
component/bt and esp32:  fix two bluetooth bugs that caused by coexist module

See merge request idf/esp-idf!3871
2018-12-05 14:17:33 +08:00
3387d751d9 spi: fix the crash when callbacks are not in the IRAM
Introduced in 9c23b8e5 and 4f87a62f. To get higher speed, menuconfig
options are added to put ISR and other functions into the IRAM.  The
interrupt flag ESP_INTR_FLAG_IRAM is also mistakenly set when the ISR is
put into the IRAM. However callbacks, which are wrote by the user, are
called in the master and slave ISR. The user may not be aware of that
these callbacks are not disabled during flash operations. Any cache miss
during flash operation will cause panic.

Essentially IRAM functions and intrrupt flag ESP_INTR_FLAG_IRAM are
different, the latter means not disabling the ISR during flash
operations.  New bus_config flag intr_flags is offered to help set the
interrupt attribute, including priority level, SHARED, IRAM (not
disabled during flash operations).  It introduced a small BREAK to
IDFv3.1 (but the same as IDFv3.0) that the user has to manually set IRAM
flag now (therefore he's aware of the IRAM thing) to void the ISR being
disabled during flash operations.
2018-12-05 10:25:57 +08:00
155e48bbde component/bt and esp32: fix two bluetooth bugs that caused by coexist module
1. Fix interrupt watchdog timeout in bluetooth "btdm_bb_isr"
    2. Fix BLE assert(512) or assert(1536)  in rwble.c at line 222
    3. Update librtc.a to fix BLE assert(512) in rwble.c at line 222

    The #1 and #2 occurs random.
    The #3 bug occurs in certain scenario:
    	1. If Wifi start softap and BLE is working
    	2. If wifi start station, but do not use normal station operation, such
    		as just use espnow, while BLE is working
    	3. Any other scenario, that wifi works without use software coexist
    		operation, while BLE is working(such as do advertising and ...)

    4. update libcoexist.a version to v1.1.2
2018-12-03 22:09:04 +08:00
13155223f3 Merge branch 'ci/combine_unit_test_and_integration_test_v3.1' into 'release/v3.1'
ci: combine unit_test and integration_test stage (backport v3.1)

See merge request idf/esp-idf!3844
2018-12-03 11:28:49 +08:00
61ecee012e ci: combine unit_test and integration_test stage:
The number of runners of integration test is not bottleneck to CI
pipeline performance now. Combine these 2 stages will make integration
test executed even unit test fails. This could help us to collect more
info about test history.
2018-11-30 13:45:53 +08:00
ab8e4069b5 Merge branch 'test/enhanced_junit_test_result_v3.1' into 'release/v3.1'
test: enhanced junit test result (backport v3.1)

See merge request idf/esp-idf!3793
2018-11-30 11:38:26 +08:00
93fcc418fe Merge branch 'bugfix/i2c_hardware_filter_default_enable_v3.1' into 'release/v3.1'
driver(i2c): enable I2C master hardware filter by default for release/v3.1

See merge request idf/esp-idf!3816
2018-11-29 19:29:04 +08:00
f00c6d1e84 Merge branch 'bugfix/freertos_idle_tick_count_v3.1' into 'release/v3.1'
freertos: use xTaskQueueMutex to protect tick count (backport v3.1)

See merge request idf/esp-idf!3728
2018-11-29 12:01:56 +08:00
2aea6e5e9c driver(i2c): enable I2C master hardware filter by default for release/v3.1 2018-11-28 17:38:50 +08:00
a27e0357b8 ci: use artifacts:reports feature of Gitlab CI 2018-11-26 17:22:04 +08:00
c229de0564 ci: assign unit test cases in sequence of config and name 2018-11-26 17:22:04 +08:00
f298897fb5 test: generate junit test report according to executed cases 2018-11-26 17:10:39 +08:00
ab2062aa45 tiny-test-fw: support capture raw data in DUT:
test cases might want to use `expect` and get raw data from DUT at the same time. New added capture method provides a way to do that.
2018-11-26 17:08:27 +08:00
3892fd2c09 tiny-test-fw: enhanced junit test report support:
1. replace xunitgen with junit_xml, which can log more info
2. allow test cases to handle junit test report by them own
3. allow test cases to log some info into report via `sysout` tag
2018-11-26 17:08:27 +08:00
87f810dca1 Merge branch 'bugfix/aes_sha_mpi_shared_regs_v3.1' into 'release/v3.1'
aes/sha/mpi: Bugfix a use of shared registers.  (backport v3.1)

See merge request idf/esp-idf!3637
2018-11-26 16:23:41 +08:00
868da0741c aes/sha/mpi: Bugfix a use of shared registers.
This commit resolves a blocking in esp_aes_block function.

Introduce:
The problem was in the fact that AES is switched off at the moment when he should give out the processed data. But because of the disabled, the operation can not be completed successfully, there is an infinite hang. The reason for this behavior is that the registers for controlling the inclusion of AES, SHA, MPI have shared registers and they were not protected from sharing.

Fix some related issue with shared using of AES SHA RSA accelerators.

Closes: https://github.com/espressif/esp-idf/issues/2295#issuecomment-432898137
2018-11-26 02:42:37 +00:00
09b2cd7d26 Merge branch 'bugfix/btdm_add_check_peer_addr_type_in_set_adv_params_v3.1' into 'release/v3.1'
Component/bt: add check peer addr type in set adv params (backport v3.1)

See merge request idf/esp-idf!3735
2018-11-23 20:14:15 +08:00
f3cf5711bf Merge branch 'bugfix/fix_some_wifi_bugs_1121_v3.1' into 'release/v3.1'
esp32: fix some wifi bugs (backport v3.1)

See merge request idf/esp-idf!3761
2018-11-23 17:08:49 +08:00
ddbb535080 esp32: fix some wifi bugs
Fix some wifi bugs
1. Enable RX BAR
2. Fix the bug that ESP32 AP negotiates with iphone to 11g
3. Fix the bug that ESP32 STA has ap_loss because CMCC AP contains two SSID
2018-11-21 15:24:30 +08:00
195f7274c4 Merge branch 'bugfix/btdm_controller_disable_v3.1' into 'release/v3.1'
Fix two bugs when disable bluetooth controller(backport v3.1)

See merge request idf/esp-idf!3693
2018-11-20 17:00:38 +08:00
cdd3131f8a Merge branch 'bugfix/btdm_errors_in_comment_v3.1' into 'release/v3.1'
components/bt: Some errors in comment(backport 3.1)

See merge request idf/esp-idf!3714
2018-11-20 14:26:19 +08:00
37c9b4056a Merge branch 'bugfix/wifi_sta_sniffer_phy_config_bug_v3.1' into 'release/v3.1'
wifi: fix wifi sta and sniffer phy config bug (backport v3.1)

See merge request idf/esp-idf!3723
2018-11-20 14:20:34 +08:00
dfd46965ae Component/bt: add check peer addr type in set adv params 2018-11-19 17:21:28 +08:00
845bbc293a freertos: use xTaskQueueMutex to protect tick count
Having two different spinlocks is problematic due to possibly
different order in which the locks will be taken. Changing the order
would require significant restructuring of kernel code which is
undesirable.

An additional place where taking xTickCountMutex was needed was in
vApplicationSleep function. Not taking xTickCountMutex resulted in
other CPU sometimes possibly advancing tick count while light sleep
entry/exit was happening. Taking xTickCountMutex in addition to
xTaskQueueMutex has shown a problem that in different code paths,
these two spinlocks could be taken in different order, leading to
(unlikely, but possible) deadlocks.
2018-11-19 11:09:37 +08:00
50f8b7b783 wifi: fix the bug that if station (sleep is enabled) and sniffer are enabled at the same time,
when disable sniffer, station will never enable phy and rf againi. (backport v3.1)
2018-11-16 20:19:21 +08:00
c4193d5ec1 fatfs: Do not log from critical sections
Logging in the critical section can result in a deadlock when the logger
is redirected to FATFS.

Closes https://github.com/espressif/esp-idf/issues/1693
2018-11-16 12:59:38 +01:00
8e0bb3ec81 components/bt: Some errors in comment 2018-11-16 15:38:22 +08:00
41caedd0da Merge branch 'bugfix/app_template_build_v3.1' into 'release/v3.1'
esp-idf-template app: some fixes for the updated template app (backport v3.1)

See merge request idf/esp-idf!3701
2018-11-15 20:14:45 +08:00
13d4e43888 Merge branch 'bugfix/tw27096_fix_lwip_mbox_free_crash_v3.1' into 'release/v3.1'
fix the crash caused by sys_mbox_free (backport v3.1)

See merge request idf/esp-idf!3620
2018-11-15 10:32:06 +08:00
b837e64640 tools: fix cmake build script for sdkconfig test 2018-11-15 01:13:02 +08:00
26e7d01d42 cmake: fix the creation dummy main to avoid rebuilding 2018-11-15 01:12:50 +08:00
bbd0696992 ci: If there is no sdkconfig, we have to generate one 2018-11-15 01:12:42 +08:00
d4eab2602f Merge branch 'bugfix/ethernetif_memory_leak_v3.1' into 'release/v3.1'
fix potential ethernet memory leak(backport v3.1)

See merge request idf/esp-idf!3688
2018-11-14 14:23:43 +08:00
dbd225c673 Fix two bugs when disable bluetooth controller
1. Fix the bug that disable controller suddenly cause crash when ble is working
2. Fix the bug that when disable controller, it will cause wifi cannot RX, TX timeout, buffer lack and etc.
2018-11-13 17:49:06 +08:00
da8835aa0b ethernetif: fix potential memory leak
1. If L2_TO_L3_RX_BUF_MODE is not selected, we must assign l2_owner explictly before we call pbuf_free.
2018-11-13 11:41:17 +08:00
8e703b14ee Merge branch 'test/fix_bug_of_scan_interval_and_windows_for_v3.1' into 'release/v3.1'
test: fix bug of scan interval and window (backport v3.1)

See merge request idf/esp-idf!3668
2018-11-12 17:34:55 +08:00
79da87def9 Merge branch 'bugfix/wifi_do_not_load_phy_data_if_fail_to_open_nvs_v3.1' into 'release/v3.1'
esp32: do not try to load PHY data if fail to open NVS (backport v3.1)

See merge request idf/esp-idf!3649
2018-11-12 17:00:14 +08:00
0ffe9f0c4e Merge branch 'bugfix/mdns_crash_on_network_change_backport3.1' into 'release/v3.1'
Fixed mdns crashes on network changes (backport v3.1)

See merge request idf/esp-idf!3579
2018-11-12 15:30:44 +08:00
46fd333167 Merge branch 'bugfix/iperf_bt_error_when_wifi_connect_v3.1' into 'release/v3.1'
components/bt: Point ACL RX buffer ptr to ACL RX buffer if ACL RX buffer ptr is null(backport 3.1)

See merge request idf/esp-idf!3643
2018-11-12 15:29:30 +08:00
8b50419f55 esp32: do not try to load PHY data if fail to open NVS 2018-11-12 03:17:11 +00:00
65691de9bc Merge branch 'test/change_iperf_test_env_v3.1' into 'release/v3.1'
test: use simplified env to test iperf cases (backport v3.1)

See merge request idf/esp-idf!3568
2018-11-12 11:16:51 +08:00
3514effcd0 lwip: fix crash caused by sys_mbox_free
Fix lwip crashed bug caused by sys_mbox_free()
2018-11-11 11:51:10 +08:00
f7b9ea8cb5 test: fix bug of scan interval and window 2018-11-09 11:28:16 +08:00
ac124ee89c components/bt: Point ACL RX buffer ptr to ACL RX buffer if ACL RX buffer ptr is null(backprot 3.1)
1. When WIFI task or other high priority task blocks the Bluetooth task, ACL RX buffer will use up, ACL RX buffer ptr will point to null and will never point to a valid adress. Causing errors in Bluetooth.
2. hcimsgs.h used whether flow control is on or off
2018-11-09 03:26:36 +00:00
01cfb0d6bd Merge branch 'test/fixbug_create_service_check_message_change_v3.1' into 'release/v3.1'
test: bugfix create service check message change for v3.1

See merge request idf/esp-idf!3664
2018-11-09 11:22:05 +08:00
69b6eabef0 Merge branch 'bugfix/btdm_add_profile_descriptor_list_for_spp_v3.1' into 'release/v3.1'
component/bt: Add profile descriptor list for SPP(backport 3.1)

See merge request idf/esp-idf!3602
2018-11-08 17:27:21 +08:00
8c16be1edc Merge branch 'bugfix/btdm_name_buffer_allocation_size_differs_v3.1' into 'release/v3.1'
components/bt: Fix the different size of name buffer allocation size(backport 3.1)

See merge request idf/esp-idf!3588
2018-11-08 17:24:53 +08:00
a015072a7e test: bugfix create service check message change for v3.1 2018-11-08 11:23:59 +08:00
7cc2445b9a Merge branch 'bugfix/btdm_sniff_anchor_point_calculation_error_for_v3.1' into 'release/v3.1'
bugfix/btdm_sniff_anchor_point_calculation_error_for_v3.1(backport v3.1)

See merge request idf/esp-idf!3614
2018-11-06 17:12:39 +08:00
cfef8291bb component/bt: bugfix of two issues of sniff mode in classic bluetooth
1. resolve the error in calculating sniff anchor point that result in connection supervision timeout
2. resolve the issue of user case that requires sniff attempt is larger than 0xff
2018-11-06 12:02:18 +08:00
725978b817 Merge branch 'bugfix/btdm_allow_a2dp_codec_dynamic_alloc_for_v3.1' into 'release/v3.1'
bugfix/btdm_allow_a2dp_codec_dynamic_alloc_for_v3.1(backport v3.1)

See merge request idf/esp-idf!3600
2018-11-06 11:57:04 +08:00
1e598fc6db Merge branch 'bugfix/btdm_add_static_passkey_and_accept_specified_sec_aut' into 'release/v3.1'
component/bt:  add static passkey and accept specified sec auth (backport v3.1)

See merge request idf/esp-idf!3559
2018-11-05 11:02:18 +08:00
08c14389f6 Merge branch 'bugfix/fix_some_wifi_bugs_1022_v3.1' into 'release/v3.1'
esp32: fix some wifi bugs (backport v3.1)

See merge request idf/esp-idf!3540
2018-11-02 15:36:46 +08:00
35769b6c50 Merge branch 'docs/wifi_correct_mistake_in_csi_doc_v3.1' into 'release/v3.1'
esp32: correct a mistake about secondary channel of CSI in wifi.rst (backport v3.1)

See merge request idf/esp-idf!3406
2018-11-02 15:36:12 +08:00
2aa9a21180 Merge branch 'bugfix/fix_psram_eid_v3.1' into 'release/v3.1'
psram: fix psram eid (backport v3.1)

See merge request idf/esp-idf!3467
2018-11-01 22:15:04 +08:00
acdc7b0511 Merge branch 'bugfix/workaround_free_peripherals_isr_when_using_dual_core_v3.1' into 'release/v3.1'
driver(interrupt): fix the issue that interrupt might be allocated and freed on different core for release/v3.1

See merge request idf/esp-idf!3436
2018-11-01 22:14:52 +08:00
3b92e85b30 Merge branch 'bugfix/bootloader_iram_overlap_check_v3.1' into 'release/v3.1'
bootloader: verify that loaded image does not overlap bootloader code (backport v3.1)

See merge request idf/esp-idf!3526
2018-11-01 16:40:26 +08:00
7d6b82673f bootloader: Fix crash enabling flash encryption
Regression in 9c715d7946
2018-11-01 14:14:18 +08:00
12e5f25a1c bootloader: keep bootloader_common code to retention region
It is possible to utilize some of the routines related to otadata
partition validation, after firmware image is downloaded to RAM. Hence
these routines should be part of app cpu cache, so that they do not
get overwritten by firmware.

Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2018-11-01 14:14:00 +08:00
539064b93c component/bt: Add profile descriptor list for SPP(backport 3.1)
A cherry-pick of MR !2691
2018-11-01 10:36:11 +08:00
82e69475ca component/bt: allow dynamic allocation of SBC encoder/decoder buffer used in A2DP to save internal DRAM 2018-10-31 17:54:51 +08:00
d09342957d Merge branch 'bugfix/ci_cmake_examples_v31' into 'release/v3.1'
Fix cmake example build failures, gcov (backport 3.1)

See merge request idf/esp-idf!3326
2018-10-31 13:21:42 +08:00
7a05ef2002 components/bt: Fix the different size of name buffer allocation size(backport 3.1)
A cherry-pick of MR !3587
Close https://github.com/espressif/esp-idf/issues/2615
2018-10-31 10:56:16 +08:00
6a6fccc191 mdns: fixed crashes on network change (not properly locked sending packets to queue from timer task), backport 3.1 2018-10-30 07:37:02 +01:00
9c41962e68 examples: Copy ca_cert.pem into both example project dirs
Keeps projects all-in-one under a single directory.
2018-10-30 10:59:39 +11:00
a7372d5828 cmake: Fix some failing example builds, fix gcov 2018-10-30 10:59:39 +11:00
3850f82259 ci: Split build_examples jobs into make & cmake
Fix problem where failures in make were being ignored.
2018-10-30 10:59:39 +11:00
3f64b39ad5 Merge branch 'doc/nvs_encr_doc_v3.1' into 'release/v3.1'
nvs_flash: Update documentation at different places to indicate NVS encryotion is supported

See merge request idf/esp-idf!3479
2018-10-29 17:21:50 +08:00
536549253d nvs_flash: Update documentation at different places to indicate NVS encryption is supported 2018-10-29 06:57:28 +00:00
d1d2ce8c28 Merge branch 'ci/only_create_required_jobs_in_pipeline_v3.1' into 'release/v3.1'
CI: only create required jobs in pipeline (backport v3.1)

See merge request idf/esp-idf!3565
2018-10-28 21:58:06 +08:00
7ad26f30f0 test: use simplified env to test iperf cases 2018-10-27 11:25:43 +08:00
97610cfccf CI: only create required jobs when use bot to trigger test:
Gitlab CI now allow us to define if a job need to be created by
varialbes. This commit add label to CI jobs, so we can make some jobs
not created in certain scenarios when we trigger pipeline with @bot.
2018-10-26 19:45:24 +08:00
143c0bdaf9 Component/bt: add ble disconnect when ACCEPT_SPECIFIED_SEC_AUTH failed 2018-10-26 14:10:32 +08:00
9ec43e1721 bootloader: verify that loaded image does not overlap bootloader code
Fixes CVE-2018-18558
2018-10-26 12:44:58 +08:00
e5f2f1ba78 Component/bt: add only accept sepecified Authentication 2018-10-26 11:58:25 +08:00
89ee65e1c6 Component/bt: add set default passkey function 2018-10-26 11:55:18 +08:00
4eb20f4d99 Merge branch 'feature/34_coding_scheme_v3.1' into 'release/v3.1'
Secure Boot & Flash encryption: Support 3/4 Coding Scheme

See merge request idf/esp-idf!3510
2018-10-26 08:40:51 +08:00
55d7900079 Merge branch 'bugfix/btdm_fix_remove_bond_list_failed_v3.1' into 'release/v3.1'
component/bt: fix remove bond list failed (backport v3.1)

See merge request idf/esp-idf!3516
2018-10-25 18:50:44 +08:00
zwj
4b5cf90a95 component/bt: fix remove bond list failed 2018-10-25 05:32:01 +00:00
9edde5e8af esp32: fix some wifi bugs
Fix following WiFi bugs:
1. Fix the bug that MIC verification fails on soft-AP mode
2. Modify mesh root to have same behavior as normal WiFi STA in state change
3. Fix the bug that sniffer can't catch control packets
4. Fix crash bug in soft-AP mode
5. Fix ACM(Admission Control Management) bug
2018-10-25 12:05:27 +08:00
67ad5852f6 Secure Boot & Flash encryption: Support 3/4 Coding Scheme
Includes esptool update to v2.6-beta1
2018-10-24 23:21:17 +00:00
5641ff1b42 Merge branch 'feature/ci_multi_python_v3.1' into 'release/v3.1'
CI: Support switching between various versions of Python (backport v3.1)

See merge request idf/esp-idf!3534
2018-10-25 07:20:12 +08:00
7778b9d83a Merge branch 'bugfix/tw26711_fix_wifi_memory_v3.1' into 'release/v3.1'
esp32: fix wifi memory leak (backport v3.1)

See merge request idf/esp-idf!3524
2018-10-22 21:20:20 +08:00
afeaf64624 CI: Support switching between various versions of Python 2018-10-22 12:56:07 +02:00
6159788b97 esp32: fix wifi memory leak
Fix a WiFi memory leak bug
2018-10-21 20:43:48 +08:00
695b25775e esp32: correct a mistake about secondary channel of CSI in wifi.rst 2018-10-19 12:25:30 +00:00
ccddd3bc01 Merge branch 'bugfix/coex_hw_blocking_2nd_v3.1' into 'release/v3.1'
coexist : fix coexist bugs related to coex hw blocking

See merge request idf/esp-idf!3415
2018-10-18 21:25:33 +08:00
e982c25b40 coexist : fix coexist bugs related to coex hw blocking
1. fix some bugs by previous coex hw blocking bugfix,
   such like, rwble.c (64, 0) line 222
2. fix bug that ble scan performance is very low when software coexist
   is working.
3. update libcoexist version to v1.1.0
2018-10-17 18:30:39 +08:00
7707b9fc91 Merge branch 'bugfix/tw26696_fix_wifi_timer_v3.1' into 'release/v3.1'
Bugfix/tw26696 fix wifi timer v3.1 (backport v3.1)

See merge request idf/esp-idf!3494
2018-10-17 17:30:46 +08:00
f97e2d3bde Bugfix/tw26696 fix wifi timer v3.1 (backport v3.1) 2018-10-17 17:30:46 +08:00
93f04b87b2 Merge branch 'bugfix/fix_random_failure_with_ota_updates_v3.1' into 'release/v3.1'
app_update: fix intermittent failure with firmware updates (backport v3.1)

See merge request idf/esp-idf!3419
2018-10-16 10:58:24 +08:00
d444469cae heap: Fix heap metadata test to account for background memory allocations 2018-10-12 18:22:07 +11:00
64b41b5602 bugfix(psram): fix psram driver
1. remove use EID to distinguish psram voltage
2. 1V8 64Mbit psram and 3V3 64Mbit psram use the same psram driver(standard spi interface)
3. set cs hold time register as 1
2018-10-11 12:22:34 +08:00
b26b1389de feature(psram): add support for 64MBit psram of 1.8v and 3.3v.
1. Add reading psram EID.
2. Configure different clock mode for different EID.
3. add API to get psram size and voltage.
4. Remove unnecessary VSPI claim.

For 32MBit@1.8V and 64MBit@3.3V psram, there should be 2 extra clock cycles after CS get high level.
For 64MBit@1.8 psram, we can just use standard SPI protocol to drive the psram. We also need to increase the HOLD time for CS in this case.

EID for psram:
32MBit 1.8v: 0x20
64MBit 1.8v: 0x26
64MBit 3.3v: 0x46
2018-10-11 12:21:31 +08:00
3cf2f09469 Merge branch 'bugfix/several_bugfix_about_ba_session_setup_v3.1' into 'release/v3.1'
esp32: several fixes about BA session setup (backport v3.1)

See merge request idf/esp-idf!3456
2018-10-11 11:42:15 +08:00
fb30315d01 driver(interrupt): fix the issue that interrupt might be allocated and freed on different cores for release/v3.1 2018-10-10 19:22:34 +08:00
027e081622 Merge branch 'bugfix/misc_v3_1_backports' into 'release/v3.1'
Multiple v3.1 backports

See merge request idf/esp-idf!3378
2018-10-10 15:01:13 +08:00
84b4916fb8 esp32: several fixes about BA session setup
1. Fix the bug that ESP32 will reject the retry AddBA request frame
   if AddBA response frame is failed to sent by WiFi LMAC
2. Fix the bug that AddBA request retrys too frequently
3. Forbid BA session setup for VO queue related TID
2018-10-10 14:04:29 +08:00
27023a77e7 Merge branch 'fix/spi_master_cmd_addr_lsbfirst_v3.1' into 'release/v3.1'
spi_master: fix the command and address field when LSB_FIRST enabled (Backport v3.1)

See merge request idf/esp-idf!3446
2018-10-09 11:46:41 +08:00
1a3db605c2 Merge branch 'bugfix/no_disconnect_event_report_if_no_correct_status_code_report_v3.1' into 'release/v3.1'
Bugfix of no disconnect event report if no correct status code report( Backport v3.1)

See merge request idf/esp-idf!3386
2018-10-08 21:35:02 +08:00
712b9374af test: modify the command/address test a bit to test the LSBFIRST feature 2018-10-08 19:19:47 +08:00
06321a5241 spi: move gpio direction config to common func for coinsistence
(MINOR CHANGE)
2018-10-08 19:19:47 +08:00
b9f10a71ea spi_master: fix the command and address field when LSB_FIRST enabled
Resolves https://github.com/espressif/esp-idf/issues/2444.
2018-10-08 19:19:31 +08:00
97219eeb31 Merge branch 'feature/nvs_encr_v3.1' into 'release/v3.1'
nvs_flash: Add support for nvs encryption

See merge request idf/esp-idf!3434
2018-10-08 16:20:28 +08:00
a2f2cd3b41 app_update: remove unrequired static attribute from mmap handle 2018-10-08 03:18:37 +00:00
bbad487deb app_update: fix intermittent failure with firmware updates
Routine `spi_flash_cache2phys` sometimes return incorrect value,
resulting in failure in getting currently running ota partition.
This in turn aborts firmware update process.This issue was more
prominent with SPIRAM enabled cases.

Fix ensures proper cache guards during `spi_flash_cache2phys`, and
also for few other similar APIs.

In addition, `esp_ota_get_running_partition` has also been optimized
to save currently running partition for subsequent invocations.

Fixes https://github.com/espressif/esp-idf/issues/2451
2018-10-08 03:18:37 +00:00
7930cfdba9 Merge branch 'bugfix/disable_coding_scheme_security_features_v3.1' into 'release/v3.1'
bootloader: Don't enable secure boot or flash encryption for 3/4 Coding Scheme (v3.1)

See merge request idf/esp-idf!3421
2018-10-08 07:06:40 +08:00
68a9d1168f nvs_flash: Add support for nvs encryption 2018-10-04 19:25:12 +05:30
1755fba8dc esptool: Update to v2.5.1
Release notes: https://github.com/espressif/esptool/releases/tag/v2.5.1

Needed to no longer burn keys if 3/4 Coding Scheme is enabled.
2018-10-04 16:51:30 +10:00
d7615df616 bootloader: Don't enable secure boot or flash encryption for 3/4 Coding Scheme 2018-10-04 16:51:30 +10:00
541e02a7e3 Merge branch 'bugfix/bootloader_gen_secure_boot_digest_v3.1' into 'release/v3.1'
bootloader: Fix secure boot digest generation for image length where (len%128 < 32) (backport v3.1)

See merge request idf/esp-idf!3411
2018-10-03 11:38:00 +08:00
d899bf029d Merge branch 'fix/sdio_slave_reset_ret_queue_v3.1' into 'release/v3.1'
sdio_slave: fix the ret_queue crash issue when being reset by the master (Backport v3.1)

See merge request idf/esp-idf!3394
2018-10-03 09:24:08 +08:00
f11ac037c4 Merge branch 'bugfix/btdm_watchdog_timeout_after_pair_with_iphone_v3.1' into 'release/v3.1'
component/bt: Fix BTU task watchdog timeout after pair with iphone (backport 3.1)

See merge request idf/esp-idf!3396
2018-09-30 14:39:09 +08:00
0846615e98 Merge branch 'bugfix/btdm_controller_stuck_on_waking_up_for_v3.1' into 'release/v3.1'
bugfix/btdm_controller_stuck_on_waking_up_for_v3.1(backport v3.1)

See merge request idf/esp-idf!3397
2018-09-30 14:26:04 +08:00
f16b3754fb bootloader: Fix secure boot digest generation for image length where (len%128 < 32) 2018-09-30 00:45:07 +10:00
862b7b22b5 Bugfix of no disconnect event report if no correct status code report
Problem Description
The reporduce steps are as follows:

1.This issue can be reproduced with 4 ESP32 devices, 2 for stations (STA1, STA2) and 2 for soft-AP (AP1, AP2)
2.Configure AP1/AP2 to the same SSID (ssid_xxx)
3.The max allowed WiFi connections of AP1 is configured to 1 and STA1 connects to AP1
4.The AP1 is close to STA2 while AP2 is far away from STA2 (but the STA2 can find the AP2 via scan)
5.STA2 connects ssid_xxx with all scan method
6.The problem will happen on STA2 because it fails to connec AP1 and never connects AP2

Phenmenon
STA fail to connect after send auth or assoc with a wrong status code, but no disconnect event report and can not connect the next one in the envrionment
Root Cause
Because there are some same ssid APs in the evnrionment, when do all channel scan, it will collect all the matched AP in rc list, because rc list is not empty, so it would send disconnect event, however, we didn't do other step such as connect to other one
VNC MR 575
closes https://github.com/espressif/esp-idf/issues/2323
2018-09-29 16:18:26 +08:00
e353d09630 component/bt: bugfix that hci down stream datapath is unblocked too early on waking up from sleep
This issue can cause the controller to stuck after sleep interrupt happens and clock interrupt enabled
2018-09-28 14:31:49 +08:00
5205b31186 Merge branch 'bugfix/btdm_coex_hw_blocking_v3.1' into 'release/v3.1'
component/bt : fix coexist hardware blocking bug

See merge request idf/esp-idf!3363
2018-09-28 11:57:26 +08:00
de0a323bef component/bt: Fix BTU task watchdog timeout after pair with iphone (backport 3.1)
A cherry-pick of MR !3366

Create a new pending queue, then re-submit pending requests in old pending queue,preventing new events being inserted into it.

Closes https://github.com/espressif/esp-idf/issues/2191
2018-09-28 11:04:44 +08:00
39f97ee0d0 sdio_slave: fix the ret_queue crash issue when being reset by the master 2018-09-27 21:33:45 +08:00
ebdc82d3d2 component/bt : fix coexist hardware blocking bug
fix the bug following:
1. after disable bluetooth controller, wifi cannot TX/RX any packets.
2. when software coexist working, there's a little ratio cause wifi task
watchdog timeout
3. when software coexist working, there's a little ratio cause bluetooth
cannot receive anything.

feature:
1. add libbtdm_app.a git commit local and remote checking

Known issues:
1. there's still a bug occurs with a very very low ratio cause bluetooth
   cannot receive anything. The reproduce interval may great than 3days
   ~ 1week via 7x24 hours heavy testing.
2018-09-27 20:56:46 +08:00
773d282d71 Merge branch 'feature/backport_mp_support' into 'release/v3.1'
nvs-flash: Support for blobs larger than half of SPI Flash sector size

See merge request idf/esp-idf!3350
2018-09-27 17:19:32 +08:00
fc7ff2a59c Merge branch 'bugfix/btdm_fix_get_bond_list_error_sometimes_v3.1' into 'release/v3.1'
Component/bt: fix get bond list error sometimes(backport v3.1)

See merge request idf/esp-idf!3365
2018-09-27 17:16:41 +08:00
c4ce84bba5 cmake: add app_trace as FreeRTOS dependency
This is needed because FreeRTOSConfig.h includes header file provided
by app_trace when CONFIG_SYSVIEW_ENABLE=y.
2018-09-27 13:35:11 +08:00
315f18766c cmake: pass repository path to git when doing git describe
Fixes getting IDF version in out-of-tree builds
2018-09-27 13:35:11 +08:00
9ad19e8122 wpa_supplicant: more wpa2_enterprise fixes
Merges https://github.com/espressif/esp-idf/pull/2386

Closes https://github.com/espressif/esp-idf/issues/2383

Closes https://github.com/espressif/esp-idf/issues/2381
2018-09-27 13:35:11 +08:00
75fcd062e8 esp32: abort when running on single core chip in dual core mode
Ref. https://esp32.com/viewtopic.php?f=2&t=7307
2018-09-27 13:35:11 +08:00
b7fde00aed sleep: keep RTC_SLOW_MEM powered on if RTC_NOINIT is used
Fixes a bug that if application uses RTC_NOINIT variables but doesn’t
use RTC_DATA variables, then RTC_NOINIT variables loose their values
after deep sleep.

Reported in https://esp32.com/viewtopic.php?f=2&t=7045&p=30301#p30299
2018-09-27 11:31:28 +08:00
d6547595d7 bt: build unit tests only when CONFIG_BT_ENABLED=1 2018-09-27 11:31:10 +08:00
5bb12070d9 Component/bt: fix get bond list error sometimes 2018-09-27 02:33:33 +00:00
83b8f38484 Merge branch 'bugfix/cmake_lambda_v3.1' into 'release/v3.1'
idf.py: Make the lambda function Python 2 & 3 compatible (backport v3.1)

See merge request idf/esp-idf!3249
2018-09-27 10:22:00 +08:00
bdb65ed066 Merge branch 'bugfix/btdm_bt_remove_device_fail_when_ble_connected_v3.1' into 'release/v3.1'
component/bt: Fix bug of remove bond device fail when BLE and BT are connectd at…

See merge request idf/esp-idf!3368
2018-09-26 18:57:36 +08:00
cbb5b6f50b Merge branch 'mesh/bugfix_v3.1' into 'release/v3.1'
Mesh/bugfix v3.1 (backport3.1)

See merge request idf/esp-idf!3358
2018-09-26 16:14:40 +08:00
cc0a73c156 component/bt: Fix bug of remove bond device fail when BLE and BT are connectd at the same time (backport 3.1)
A cherry-pick of MR !2767
2018-09-26 14:23:05 +08:00
1d4ae1e9ad mesh: bugfix
1. suppport mesh type, mesh ID, router and IE crypt func&key at any time after mesh is initalized.
2. support modify parent at any time after mesh is configured.
3. modify manual networking example.
4. update header file.
5. fix issues in root conflicts handling.
6. add max length of beacon to menuconfig.
7. fix issue when received a beacon without DSSS.
2018-09-25 13:43:55 +08:00
e14b836fcc nvs-flash: Support for blobs larger than half of SPI Flash sector size
This change removes the earlier limitation of 1984 bytes for storing data-blobs.
Blobs larger than the sector size are split and stored on multiple sectors.
For this purpose, two new datatypes (multi-page index and multi-page data) are
added for entries stored in the sectors. The underlying read, write, erase and find
operations are modified to support these large blobs. The change is transparent
to users of the library and no special APIs need to be used to store these large
blobs.
2018-09-24 18:50:35 +05:30
fbcfc869e2 Merge branch 'bugfix/fix_the_bug_create_socket_fail_v3.1' into 'release/v3.1'
lwip: fix the bug that failed to create socket (backport v3.1)

See merge request idf/esp-idf!3311
2018-09-20 18:44:18 +08:00
4107361a3a Merge branch 'bugfix/btdm_fix_crash_when_test_multi_connect_v3.1' into 'release/v3.1'
Component/bt: fix crash when test multi_connect(backport v3.1)

See merge request idf/esp-idf!3313
2018-09-20 14:02:12 +08:00
e8aa442305 Merge branch 'bugfix/btdm_fix_save_error_key_in_smp_when_reconnect_v3.1' into 'release/v3.1'
Component/bt: fix save error key in smp when reconnect(backport v3.1)

See merge request idf/esp-idf!3289
2018-09-20 10:58:01 +08:00
82ee078d9a Merge branch 'bugfix/btdm_fix_iphoneX_error_when_get_wifi_list_v3.1' into 'release/v3.1'
Component/bt: fix iPhoneX error when getting wifi list (backport v3.1)

See merge request idf/esp-idf!3314
2018-09-20 10:55:08 +08:00
f90512ba39 Merge branch 'bugfix/mdns_memory_leak_backport_v3.1' into 'release/v3.1'
feat(mdns): fix bug when clean action memory (backport v3.1)

See merge request idf/esp-idf!3305
2018-09-19 18:05:51 +08:00
bb48077a81 lwip: fix the bug that failed to create socket
Fix the bug that failed to create nonblocking TCP or UDP socket after several times socket create/close
2018-09-19 16:43:25 +08:00
72f9d15a57 Component/bt: fix iPhoneX error when getting wifi list 2018-09-19 15:21:57 +08:00
78dca32a28 Component/bt: fix crash when test multi_connect 2018-09-19 14:26:55 +08:00
52a70b3418 feat(mdns): fix bug when clean action memory 2018-09-18 23:39:10 +05:30
889c80ec1c Merge branch 'bugfix/backport_several_wifi_bugfix_v3.1' into 'release/v3.1'
esp32: backport several WiFi bug fixes to v3.1 (backport v3.1)

See merge request idf/esp-idf!3280
2018-09-18 20:03:32 +08:00
922bae0be3 Merge branch 'bugfix/cmake_make_flash_target_v3.1' into 'release/v3.1'
cmake: Fix "make flash" & "ninja flash" targets

See merge request idf/esp-idf!3295
2018-09-18 10:49:52 +08:00
982a7fa499 Merge branch 'fix/spi_slave_free_cs_v3.1' into 'release/v3.1'
spi_slave: fix the issue rx dma get broken by master unexpected transaction (backport v3.1)

See merge request idf/esp-idf!3294
2018-09-18 08:08:41 +08:00
52413e9925 Merge branch 'feature/signature_verify_updates_v3.1' into 'release/v3.1'
secure boot: Support signed app verification without hardware secure boot  (backport v3.1)

See merge request idf/esp-idf!3184
2018-09-18 07:56:12 +08:00
cfb96e67f9 cmake: Fix "make flash" & "ninja flash" targets
As reported on forum.

Requires a small CMake wrapper script to pick
up environment variables at flashing time.
2018-09-18 09:32:54 +10:00
a7c67c1681 spi_slave: fix the issue rx dma get broken by master unexpected transaction 2018-09-17 22:36:49 +08:00
53d75901a9 Component/bt: fix save error key in smp when reconnect 2018-09-17 20:13:30 +08:00
8f665c3393 Merge branch 'bugfix/btdm_enable_modem_sleep_by_default_for_v3.1' into 'release/v3.1'
bugfix/btdm_enable_modem_sleep_by_default_for_v3.1(backport v3.1)

See merge request idf/esp-idf!3275
2018-09-17 16:17:46 +08:00
b5365c19f7 Merge branch 'bugfix/btdm_unreserve_scn1_for_hfp_v3.1' into 'release/v3.1'
component/bt: Unlock reserve of SCN 1 for HFP (backport v3.1)

See merge request idf/esp-idf!3285
2018-09-17 16:17:08 +08:00
738afe2de3 esp32: backport several WiFi bug fixes to v3.1
Backport following WiFi fixes to v3.1:
1. Fix AMPDU RX sequence compitability bug
2. Optimize scan capability in all channel scan
3. Fix some modem sleep bugs
4. Update API to set CSI channel filter and HT_LTF data generating
2018-09-17 14:40:24 +08:00
ea3b2716fd component/bt: Unlock reserve of SCN 1 for HFP (backport v3.1)
A cherry-pick of MR !3269
2018-09-17 11:01:58 +08:00
bfcb673c8e Merge branch 'bugfix/tw24694_dns_request_no_reply_v3.1' into 'release/v3.1'
lwip: add code for sending gratuitous ARP periodically (backport v3.1)

See merge request idf/esp-idf!3195
2018-09-16 15:18:39 +08:00
e5d8a68d96 Merge branch 'bugfix/mdns_service_txt_set_backportv3.1' into 'release/v3.1'
bugfix: mdns_service_txt_set() wasn't allocating memory for TXT records (backport v3.1)

See merge request idf/esp-idf!3254
2018-09-16 15:12:03 +08:00
760772ec4b Merge branch 'bugfix/ble_adv_data_tx_power_v3.1' into 'release/v3.1'
fix TX power value in ble adv data is incorrect

See merge request idf/esp-idf!3187
2018-09-16 14:54:59 +08:00
1a9d40ca3d Merge branch 'bugfix/btdm_controller_enable_failed_in_examples_for_v3.1' into 'release/v3.1'
Bugfix/btdm controller enable failed in examples for v3.1(backport v3.1)

See merge request idf/esp-idf!3266
2018-09-14 19:41:10 +08:00
9773c019d8 Merge branch 'doc/btdm_a2dp_source_example_improvement_for_v3.1' into 'release/v3.1'
Doc/btdm a2dp source example improvement for v3.1(backport v3.1)

See merge request idf/esp-idf!3233
2018-09-14 19:39:16 +08:00
67ef1865a6 Merge branch 'doc/btdm_a2dp_sink_example_improvement_for_v3.1' into 'release/v3.1'
doc/btdm_sink_example_improvement_for_v3.1(backport v3.1)

See merge request idf/esp-idf!3234
2018-09-14 19:38:57 +08:00
3db38f8281 Merge branch 'bugfix/btdm_a2dp_role_mixed_up_for_v3.1' into 'release/v3.1'
Bugfix/btdm a2dp role mixed up for v3.1(backport v3.1)

See merge request idf/esp-idf!3267
2018-09-14 19:32:53 +08:00
c6d2fc6807 component/bt: enable bluetooth modem sleep as default setting 2018-09-14 17:01:45 +08:00
9237110c5c bugfix: mdns_service_txt_set() wasn't allocating memory for TXT records
Allocation was happening later, causing possible use of stack variables
of caller function, which could be invalid.

Signed-off-by: Piyush Shah <piyush@espressif.com>
2018-09-14 11:17:53 +05:30
4c240064ab component/bt: stop to inititate AVRC connection when A2DP connection fails to set up
AVRCP connection binds to A2DP in current implementation, despite the two profiles are\
independent according to specification. AVRCP connection is not necessary to set-up \
if A2DP connection fails to establish
2018-09-13 17:58:00 +08:00
da4108dd1e component/bt: stop to initiate AVDTP connection on failure of A2DP service discovery
In opening state of AVDTP connection, if SDP client fails to get valid A2DP service record\
from peer SDP server, then do not initiate AVDTP connection request
2018-09-13 17:58:00 +08:00
01994059e2 component/bt: bugfix that A2DP sink device can be connected by another A2DP sink device
In pevious implementation, A2DP sink will register an A2DP source Stream End Point(SEP) although the SEP is not\
supposed to be used. Now remove the unused SEP for source so that only one role of A2DP can be supported at one
time. Service record in local SDP server only includes at most one service for A2DP sink role or source
2018-09-13 17:58:00 +08:00
763fa9b0fa component/bt: release some controller memory according to the configuration of bluetooth examples 2018-09-13 17:46:01 +08:00
a55c7a62ad component/bt: bugfix for mismatch of controller mode in sdkconfig.defaults and source code in some examples 2018-09-13 17:46:00 +08:00
0e1f561a32 test: fix incorrect tx power value in adv 2018-09-13 15:48:52 +08:00
cea4d31325 Merge branch 'feature/cmake_make_main_component_again_v3.1_bp' into 'release/v3.1'
cmake: make main a component again (backport v3.1)

See merge request idf/esp-idf!3247
2018-09-13 15:37:25 +08:00
af86b9cbce Merge branch 'doc/eclipse_parallel_build_v31' into 'release/v3.1'
docs: Add parallel builds to Eclipse setup (backport v3.1)

See merge request idf/esp-idf!3219
2018-09-13 15:36:35 +08:00
f16e78f72c Merge branch 'bugfix/ci_github_deploy_v31' into 'release/v3.1'
ci: Fix spurious pipeline failure when deploying a tag to GitHub (backport v3.1)

See merge request idf/esp-idf!3220
2018-09-13 15:36:28 +08:00
bc8540fec1 cmake: fix source list issues 2018-09-13 11:13:27 +08:00
533c5e98e8 cmake: don't add main component Kconfig twice 2018-09-13 11:13:27 +08:00
d04718bbe3 cmake: use built-in file function to create dummy main 2018-09-13 11:13:27 +08:00
7edf2bf66c cmake: make main a component again 2018-09-13 11:13:27 +08:00
a05868f0a8 fix TX power value in ble adv data is incorrect
refence to https://github.com/espressif/esp-idf/issues/2284
Before fixing, the tx power in adv data is always 0xeb(-21dbm).

restriction:
    If change BLE advertising TX power, please call esp_ble_gap_config_adv_data()
    after BLE adv TX power changed.

    Later, will implement set BLE advertising TX power via HCI, then the
    TX power value in adv data can be update automatically after BLE adv
    TX power changed.
2018-09-12 10:19:08 +00:00
5b1d8d64f2 idf.py: Make the lambda function Python 2 & 3 compatible 2018-09-12 11:45:01 +02:00
031ec7af93 component/bt: fix the format and add more content to A2DP source example document and source code 2018-09-12 10:48:15 +08:00
2a5802241f component/bt: fix the format and add more content to A2DP sink example document and source code 2018-09-12 10:44:58 +08:00
f6f4d7b410 add code for sending gratuitous ARP periodically 2018-09-11 15:20:24 +08:00
8e20c13348 Merge branch 'bugfix/fix_the_bug_when_gateway_zero_v3.1' into 'release/v3.1'
esp32: fix the bug that SYSTEM_EVENT_STA_GOT_IP is forbidden when gateway is 0.0.0.0 (backport v3.1)

See merge request idf/esp-idf!3238
2018-09-11 12:07:28 +08:00
f617a33b8d esp32: fix the bug that SYSTEM_EVENT_STA_GOT_IP is forbidden when gateway is 0.0.0.0 2018-09-11 10:57:17 +08:00
782ab8d872 Merge branch 'fix/sdio_slave_recv_isr_load_v3.1' into 'release/v3.1'
sdio_slave: fix the recv crash when trans finish and load at the same time (backport v3.1)

See merge request idf/esp-idf!3232
2018-09-11 09:44:49 +08:00
b3697e7741 sdio_slave: fix the recv crash when trans finish and load at the same time 2018-09-10 15:17:07 +08:00
da3c1be049 ci: Fix spurious pipeline failure when deploying a tag to GitHub
Everything succeeds, but because [ -z ${CI_COMMIT_TAG} ] on the last line returns non-zero, it
fails the job.
2018-09-07 15:21:51 +08:00
35785d08fd Merge branch 'feature/btdm_legacy_paring_v3.1' into 'release/v3.1'
component/bt: Add Legacy Pairing (backport 3.1)

See merge request idf/esp-idf!3193
2018-09-07 14:44:19 +08:00
05fbfe21b9 doc: translate parallel build in Eclipse 2018-09-07 14:40:29 +08:00
4fc1587f6c doc: Add parallel builds to the Eclipse setup guide 2018-09-07 14:40:29 +08:00
297945c32e Merge branch 'test/split_test_env_for_integration_test_v3.1' into 'release/v3.1'
test: split CI test environment (backport v3.1)

See merge request idf/esp-idf!3211
2018-09-07 11:06:51 +08:00
d193895ec6 Merge branch 'bugfix/btdm_hfp_invalid_hci_sync_pkt_len_for_v3.1' into 'release/v3.1'
bugfix/btdm_hfp_invalid_hci_sync_pkt_len_for_v3.1(backport v3.1)

See merge request idf/esp-idf!3188
2018-09-06 19:52:05 +08:00
f1bf446410 test: split CI test environment:
Currently CI test environment is complicated, usually includes NIC, AP.
These devices are not used for a lot test cases. Therefore we split the
test environment, remove unnecessary devices. Then it will be easier to
create CI runners.
2018-09-06 16:35:34 +08:00
e6a0eb74c8 Merge branch 'bugfix/btdm_discovery_ble_v3.1' into 'release/v3.1'
component/bt : fix bug that set discovery mode will stop ble adv

See merge request idf/esp-idf!3189
2018-09-06 14:19:31 +08:00
b3189bae38 Merge branch 'bugfix/tw25969_esp_derive_local_mac_missing_v3.1' into 'release/v3.1'
defination: fix the bug that esp_derive_local_mac() defination missing (backport v3.1)

See merge request idf/esp-idf!3199
2018-09-05 17:21:20 +08:00
c27c381ba2 defination: fix the bug that esp_derive_local_mac() defination missing 2018-09-05 14:42:23 +08:00
95c5805088 component/bt: Add Legacy Pairing (backport 3.1)
A cherry-pick of MR !3057
2018-09-04 20:59:03 +08:00
196793dccb component/bt : fix bug that set discovery mode will stop ble adv
As the bluedroid original implmentation of BR/EDR and BLE dual mode about discovery mode,
when set discovery mode for BR/EDR, it will stop ble advertising.

Reference to https://github.com/espressif/esp-idf/issues/2306
2018-09-04 20:29:36 +08:00
7c6d447938 component/bt: bugfix for incorrect length of HCI SCO packet size in HFP resulted from uninitialized data buffer length 2018-09-04 20:24:00 +08:00
7d847e60ec docs/en/security: Add documentation for signed apps without hardware secure boot feature 2018-09-04 19:10:32 +08:00
b069b31a2c secure boot: Support secure boot signatures without hardware secure boot
Allows OTA updates to be secured via signature checks, without requiring the overhead or complexity
of a full secure boot implementation.

Uses same signing mechanisms (build system and/or espsecure.py as Secure Boot).

Requires:
* [ ] More testing
* [ ] Documentation
2018-09-04 19:10:02 +08:00
969161183a Merge branch 'bugfix/esp_wifi_disconnect_fail_v3.1' into 'release/v3.1'
update wifi lib to fix two bugs (backport v3.1)

See merge request idf/esp-idf!3158
2018-09-04 15:06:49 +08:00
45e29a817c Merge branch 'bugfix/btdm_update_private_address_v3.1' into 'release/v3.1'
component/bt: Update BLE private address after it's private address interval (backport 3.1)

See merge request idf/esp-idf!3170
2018-09-04 14:10:47 +08:00
dabebbf639 Merge branch 'bugfix/btdm_rfcomm_test_command_cause_crash_v3.1' into 'release/v3.1'
component/bt: Fix bug rfcomm test command cause crash (backport 3.1)

See merge request idf/esp-idf!3169
2018-09-04 14:10:05 +08:00
cd78dc632a Merge branch 'bugfix/btdm_find_remote_service_by_uuid_always_return_success_v3.1' into 'release/v3.1'
component/bt: Fix bug of SDP find services by uuid always return success (backport 3.1)

See merge request idf/esp-idf!3164
2018-09-04 14:09:36 +08:00
33b3418b4e Merge branch 'mesh/rewrite_docs_backport_v3.1' into 'release/v3.1'
docs/rewrite_mesh_docs (backport v3.1)

See merge request idf/esp-idf!3168
2018-09-03 18:12:12 +08:00
6a2f492832 component/bt: Update BLE private address after it's private address interval (backport 3.1)
A cherry-pick of MR !2987
2018-09-03 14:27:15 +08:00
24a03a8d3f component/bt: Fix bug rfcomm test command cause crash (backport 3.1)
A cherry-pick of MR !3080
2018-09-03 14:17:56 +08:00
27ffeacf07 docs/rewrite_mesh_docs
The following commit rewrites the ESP-MESH docs. This commit includes
new diagrams and a structure approach to the mesh docs. Some mesh api references
have also been modified.
2018-09-03 13:03:32 +08:00
b1da63d645 component/bt: Fix bug of SDP find services by uuid always return success (backport 3.1)
A cherry-pick of MR !3036
2018-09-03 11:52:19 +08:00
ec3a1318dc update wifi lib to fix two bugs
1. fix the esp_wifi_disconnect() err when wifi is not started or inited

2. make g_intr_lock_mux and g_osi_funs_p in DRAM
2018-08-31 20:10:20 +08:00
22da5f6de9 Merge branch 'bugfix/btdm_security_vulnerability_v3.1' into 'release/v3.1'
fix bluetooth security vulnerability of ECDH public key checking

See merge request idf/esp-idf!3139
2018-08-31 02:11:55 +08:00
0ec9d3ec7d Merge branch 'bugfix/wifi_reorder_mpdu_as_ampdu_v3.1' into 'release/v3.1'
esp32: reorder MPDU as AMPDU (backport v3.1)

See merge request idf/esp-idf!3140
2018-08-31 01:59:55 +08:00
70764a4cf9 Merge branch 'bugfix/ci_use_mirror_for_public_v3.1' into 'release/v3.1'
ci: Use local mirrors on the public branches (master, release-) too

See merge request idf/esp-idf!3126
2018-08-30 14:22:42 +08:00
2ad5686937 esp32: reorder MPDU as AMPDU
Some APs transmit AMPDU and MPDU by turns. Moreover, the sequence
    numbers of AMPDU and MPDU are out of order, e.g. MPDU(1253) -
    AMPDU(1251, 1252) - MPDU(1254) - AMPDU(1255, 1256). In order to
    receive both AMPDU and MPDU in order, MPDU must be reordered with
    AMPDU.
2018-08-30 11:46:16 +08:00
84d10d8dad Merge branch 'test/fix_test_summary_duplicate_v3.1' into 'release/v3.1'
test: fix duplicated summary of BTSTK_GAP_14007,BTSTK_GAP_14008,BTSTK_GAP_14009

See merge request idf/esp-idf!3086
2018-08-30 11:20:58 +08:00
7f8de47631 fix bluetooth security vulnerability of ECDH publick key checking 2018-08-30 11:09:02 +08:00
16add00668 Merge branch 'bugfix/btdm_fix_memory_leak_in_security_server_v3.1' into 'release/v3.1'
Component/bt: fix memory leak in security server(backport v3.1)

See merge request idf/esp-idf!3081
2018-08-30 02:20:58 +08:00
a83c918946 Component/bt: fix memory leak in security server 2018-08-29 17:56:14 +00:00
9f791e06f6 Merge branch 'bugfix/mesh_fix_hard_to_find_parent_v3.1' into 'release/v3.1'
mesh: bugfix and add two APIs (backport3.1)

See merge request idf/esp-idf!3134
2018-08-30 01:54:08 +08:00
c3ba237846 Merge branch 'bugfix/btdm_fix_crash_when_BLE_do_SMP_con_discon_stress_test_v3.1' into 'release/v3.1'
Component/bt: fix crash when BLE do connect and disconnect stress test(backport v3.1)

See merge request idf/esp-idf!3119
2018-08-30 01:51:33 +08:00
17c4a76395 component/bt: fix crash when BLE do con and duscon stress test 2018-08-30 00:36:57 +08:00
114b16f0d5 Merge branch 'bugfix/btdm_fix_get_error_adv_sometimes_v3.1' into 'release/v3.1'
Component/bt: fix get error adv packet sometimes(backport v3.1)

See merge request idf/esp-idf!3082
2018-08-29 23:54:36 +08:00
e1fc259600 Merge branch 'bugfix/btdm_a2dp_sink_pcm_buf_size_for_v3.1' into 'release/v3.1'
bugfix/btdm_a2dp_sink_pcm_buffer_size_for_v3.1(backport v3.1)

See merge request idf/esp-idf!3116
2018-08-29 22:54:58 +08:00
1d537d29d5 Merge branch 'feature/cmake_v3.1' into release/v3.1 2018-08-29 19:30:06 +08:00
09f5854c9a mesh: bugfix and add two APIs
1. new APIs: esp_mesh_get_subnet_nodes_num() and esp_mesh_get_subnet_nodes_list().
2. fix hard to find the parent during connect.
3. disable Wi-Fi channel switch function.
4. fix a typo of MESH_EVENT_NO_PARENT_FOUND.
2018-08-29 17:28:17 +08:00
200d8d235b fix bug BTSTK_GAP_14007,BTSTK_GAP_14008,BTSTK_GAP_14009 duplicate summary 2018-08-29 12:27:59 +08:00
84a32f3288 ci: Use local mirrors on the public branches (master, release-) too
Use DONT_USE_MIRROR=1 to force using the original repositories if you need
2018-08-28 23:43:30 +08:00
bfc8142c99 Component/bt: fix get error adv packet sometimes 2018-08-28 14:13:10 +08:00
bcebf3e6f1 Merge branch 'bugfix/btdm_check_slave_feature_before_set_afh_for_v3.1' into 'release/v3.1'
bugfix/btdm_check_slave_feature_before_set_afh(backport v3.1)

See merge request idf/esp-idf!3103
2018-08-28 13:40:56 +08:00
4577270fc3 Merge branch 'bugfix/tw23404_dhcp_NAK_issue_v3.1' into 'release/v3.1'
lwip: optimize LWIP timer (backport v3.1)

See merge request idf/esp-idf!3060
2018-08-28 13:39:46 +08:00
2d22fbd4ff cmake: Add missing example CMakeLists.txt files, CI check all examples have both 2018-08-28 11:11:57 +08:00
9f6af0ad4b component/bt: bugfix for incorrect computation of PCM data buffer size in A2DP sink 2018-08-28 10:59:22 +08:00
c060853f70 Merge branch 'bugfix/fix_probable_mem_leak_v3.1' into 'release/v3.1'
components/bt: Fix a probable memory leak for BTA_GATTS_CONF_EVT event (backport v3.1)

See merge request idf/esp-idf!3106
2018-08-28 10:41:42 +08:00
501d81ce32 lwip: optimize LWIP timer
Port LWIP timer implementation in LWIP v2.0.3 to IDF v3.0
2018-08-27 21:59:36 +08:00
f9a770134b Merge branch 'bugfix/timer_oneshot_timeout_twice_v3.1' into 'release/v3.1'
component/bt: Some timer oneshot will timeout twice (backport v3.1)

See merge request idf/esp-idf!3063
2018-08-27 20:42:44 +08:00
b4fc5b0e8f Merge branch 'bugfix/fix_several_wifi_bugs_v3.1' into 'release/v3.1'
esp32: update wifi lib to fix several WiFi bugs (backport v3.1)

See merge request idf/esp-idf!3098
2018-08-27 20:38:35 +08:00
a821805ddc cmake: partition_table: Use PYTHON interpreter when running parttool.py (fixes flasher args on Windows) 2018-08-27 18:02:30 +08:00
cb9fa1f295 kconfig: Merge Kconfig.compiler back into Kconfig
Reverts 5e0a3d99e8 (no longer needed but also not supported by
mconf-idf built from kconfig-frontends repo.)
2018-08-27 17:24:31 +08:00
7ffd68cac2 components/bt: Fix a probable memory leak for BTA_GATTS_CONF_EVT event (backport v3.1)
Multiple modules register their callback BTA_GATTS_AppRegister().

If any of the callbacks do not free the allocated pointer in
BTA_GATTS_CONF_EVT event, then this can result in memory leak.

So, free the pointer after the callback function is called and remove
the calls to free in the callback functions as it is now not required

Signed-off-by: Hrishikesh Dhayagude <hrishi@espressif.com>
2018-08-27 12:03:20 +05:30
dd77a4c65d cmake: Account for missing partition CSV file at cmake runtime
Avoid either breaking menuconfig (if cmake fails), or producing bad build output (if cmake succeeds
but no flashing offsets, etc. were generated.)
2018-08-27 11:56:48 +08:00
a47cc3dd46 component/bt: check support of AFH in remote slave device's LM feature then determine whether to send LMP_set_AFH 2018-08-27 11:20:34 +08:00
7cd75f30f2 Merge branch 'fix/spi_dma_config_in_iram_v3.1' into 'release/v3.1'
spi: fix the issue that spi cannot be used when flash is disabled (backport v3.1)

See merge request idf/esp-idf!3075
2018-08-27 08:14:31 +08:00
3d2cd911f0 esp32: update wifi lib to fix several WiFi bugs
Fix following WiFi bugs:
1. Shouldn't scan when connect
2. Check beacon length in modem sleep
3. Fix the bug that AP may deauth wrong station when inactivity timer expires
4. Fix the bug that WiFi assert the system when receiving empty MCS in association response frame
2018-08-26 13:15:53 +08:00
da94560ec5 component/bt: Some timer oneshot will timeout twice (backport v3.1)
A cherry-pick of MR !2979
2018-08-25 15:50:46 +00:00
21ef7ed82c Merge branch 'test/disable_mesh_re_establish_network_case_v3.1' into 'release/v3.1'
test: disable mesh recreate network test (backport v3.1)

See merge request idf/esp-idf!3068
2018-08-25 10:38:02 +08:00
125da7a1c2 spi: fix the issue that spi cannot be used when flash is disabled
The dma configuration function called in the ISR should be put into the IRAM.

Fixes https://github.com/espressif/esp-idf/issues/2307.
2018-08-24 05:56:17 +00:00
ceca7b741c test: disable mesh recreate network test:
We have fixed a bug in test script. Before that, we didn't do strict check when generate the mesh tree, which makes the test pass.

Temp disable these cases, to let CI pass before bug fixed.
2018-08-23 19:15:12 +08:00
ab95d5cdd7 Place embedded data on flash 2018-08-23 11:15:23 +10:00
bc6a193130 cmake idf.py: Fix bug in JSON parsing when printing flash commands 2018-08-23 11:15:23 +10:00
7cc5888583 cmake/partitions: Apply offset to partition table metadata correctly
Also warn if the parttool.py has an error
2018-08-23 11:15:23 +10:00
0743361da3 kconfiglib: Allow CONFIG_xxx= to disable booleans
But replace all sdkconfig.defaults to use the explicit =n (more correct)
2018-08-20 17:18:05 +10:00
c16fbbf614 partition table: Remove hard-coded offsets from default partition tables
Makes them compatible with moving the partition table offset
2018-08-20 16:58:00 +10:00
b64815be4c cmake: Fix bt component dependencies 2018-08-20 10:47:55 +10:00
885df4c90f cmake: Fix flasher argument generation 2018-08-20 10:47:42 +10:00
d376105e8e doc: Update new documentation config output
Make output similar to previous implementation.
2018-08-17 20:21:59 +10:00
7f50bb7e7f Merge branch 'release/v3.1' into feature/cmake_v3.1 2018-08-17 14:14:10 +10:00
53509c7bfd Merge branch 'bugfix/mdns_any_type_share_v3.1' into 'release/v3.1'
mdns: Fix a portion of the queries are issued with the wildcard query type (backport v3.1)

See merge request idf/esp-idf!3008
2018-08-15 06:40:24 +08:00
1bbe9538ef mdns: Fix a portion of the queries are issued with the wildcard query type 2018-08-14 18:34:40 +10:00
39dd71d958 Merge branch 'bugfix/btdm_ecdh_public_key_not_check_v3.1' into 'release/v3.1'
Bugfix/btdm ecdh public key not check v3.1 (backport v3.1)

See merge request idf/esp-idf!2991
2018-08-14 13:20:22 +08:00
2dfe58e1b3 Merge branch 'bugfix/tw24252_fix_nonblocking_tcp_close_issue_v3.1' into 'release/v3.1'
lwip: fix nonblocking tcp close issue (backport v3.1)

See merge request idf/esp-idf!2938
2018-08-14 13:20:08 +08:00
2e60a4b751 Merge branch 'bugfix/gpio_reset_bitmask_v3.1' into 'release/v3.1'
gpio: Bitmask overflow fix in gpio_reset_pin (backport v3.1)

See merge request idf/esp-idf!3005
2018-08-14 11:29:15 +08:00
fc18d2cea5 Merge branch 'bugfix/ulp_fixes_v3.1' into 'release/v3.1'
ULP fixes (backport v3.1)

See merge request idf/esp-idf!3001
2018-08-14 11:25:14 +08:00
8b6060e24e gpio: Bitmask overflow fix in gpio_reset_pin
For pins 32 and up the BIT(nr) macro used here overflowed,
causing undetermined GPIO pins to be reset.
Example: freeing SPI device/bus where CS is on pin 33
caused debug UART to cease communication, TXD0 was
disabled.

Fixed as BIT64(nr) macro, to be used elsewhere as needed.
For example in definitions like GPIO_SEL_32..GPIO_SEL_39.
2018-08-14 04:23:56 +03:00
640f690def docs: update esp32ulp-binutils download link 2018-08-13 23:23:55 +03:00
cce9fa970e ulp: add documentation for JUMPS instruction conditions
Hardware implements conditions LE, LT, GE, and conditions EQ and GT
are implemented in the assembler by emitting two JUMPS instructions
with other conditions.
2018-08-13 23:23:55 +03:00
f63ab0792b ulp: add tests for jumps instruction 2018-08-13 23:23:55 +03:00
f4c8df2635 ulp: fix ULP binary format documentation
Fix incorrect offset value (4+2+2+2+2=12) of arbitrary data in ULP
binary format.

Closes https://github.com/espressif/esp-idf/issues/1705.
2018-08-13 23:23:55 +03:00
db5c542e96 ulp: use += instead of := when setting component vars
Component which includes component_ulp_common.mk may also need to set
some of the same COMPONENT_XXX variables. Logically, we should combine
the lists of files to embed, ldflags, extra include dirs, etc.

Fixes https://github.com/espressif/esp-idf/issues/2157.
2018-08-13 23:23:55 +03:00
bb8ecf8a7b ulp: fix missing include in esp32/ulp.h header
ulp.h uses some register base addresses, so needs to include soc.h
2018-08-13 23:23:55 +03:00
c2e424e7af ulp: fix calculation or ulp_run argument
The argument to ulp_run should be expressed in 32-bit words. Both the
address of ulp_entry and RTC_SLOW_MEM already are uint32_t*, so their
difference is the difference in addresses divided by sizeof(uint32_t).
Therefore the extra division by sizeof(uint32_t) is not needed.
2018-08-13 23:23:54 +03:00
a0191b28b2 docs: fix line endings of ULP docs 2018-08-13 23:23:29 +03:00
fa8dc32800 component/bt: Fixed the vulnerability released by Bluetooth org when using public key not check in the process of ECDH encryption.
1. Add the 100 times test when the private key is generated by the random number;
2. Add the bt components to the unit-test-app/config directory.
3. Added the bt unit test case to CI.
2018-08-13 19:47:02 +08:00
cf3e89c1b2 Merge branch 'bugfix/doc_generated_sections_v3.1' into 'release/v3.1'
docs: Move version-related includes to run in sphinx-build not make (backport v3.1)

See merge request idf/esp-idf!2989
2018-08-13 15:48:59 +08:00
08b9551494 docs: Add gen-version-specific-includes.py to executables list 2018-08-13 16:01:20 +10:00
92b29923cb docs: Move version-related includes to run in sphinx-build not make
Means they show up on ReadTheDocs(!)
2018-08-13 16:01:20 +10:00
695d95c983 Merge branch 'bugfix/http_client_null_auth_header_v3.1' into 'release/v3.1'
esp_http_client: Fixed exception on 401 without Www-Authenticate header (backport v3.1)

See merge request idf/esp-idf!2978
2018-08-13 11:48:26 +08:00
d91c425178 Merge branch 'bugfix/unit-test-build-fix_v3.1' into 'release/v3.1'
unit-test-app: don’t include project.mk for ut- targets (backport v3.1)

See merge request idf/esp-idf!2850
2018-08-13 11:42:43 +08:00
0da8e99580 Merge branch 'bugfix/btdm_fix_get_bond_list_error_when_connection_with_no_bond_v3.1' into 'release/v3.1'
Component/bt: fix get bond list error when connection with no bond (backport v3.1)

See merge request idf/esp-idf!2981
2018-08-13 10:20:12 +08:00
c6b4fa5a9a Merge branch 'doc/versions_v3.1' into 'release/v3.1'
docs: Add version-specific include files, version documentation (backport v3.1)

See merge request idf/esp-idf!2974
2018-08-13 09:54:13 +08:00
281877ada5 Component/bt: fix get bond list error when connection with no bond 2018-08-10 21:00:56 +08:00
9a273863ba esp_http_client: Fixed exception on 401 without Www-Authenticate header
Closes https://github.com/espressif/esp-idf/issues/2246
2018-08-10 14:23:19 +07:00
abbc13af62 freertos: Remove either one or two assertions from "fast path" of vPortCPUReleaseMutex()
Saves a few cycles by only testing the count validity once, and never for the common case where the
mutex was not recursively locked.
2018-08-10 16:53:17 +10:00
9fb746824a lwip: fix nonblocking tcp close issue
Fix assert issue causes by closing nonblocking tcp socket.
2018-08-10 06:21:56 +00:00
8a1adb0d50 Merge branch 'bugfix/spi_flash_mmap_malloc_internal_v3.1' into 'release/v3.1'
spi_flash: allocate mmap pages array in internal memory (backport v3.1)

See merge request idf/esp-idf!2961
2018-08-10 13:43:55 +08:00
ddb2570849 Merge branch 'mesh/bugfix_parent_switch_backport_v3.1' into 'release/v3.1'
mesh: modify parent switch mechanism (backport3.1)

See merge request idf/esp-idf!2977
2018-08-10 13:42:32 +08:00
7f4b77ca5b Merge branch 'bugfix/add_mutex_for_some_touchpad_apis_v3.1' into 'release/v3.1'
fix(touch): add_mutex_for_some_touchpad_apis (backport v3.1)

See merge request idf/esp-idf!2963
2018-08-10 12:18:33 +08:00
d421663d3f mesh: modify parent switch mechanism
1. modify parent switch mechanism.
2. fix non-root doesn't clear the layer value in nvs.
3. fix retransmit the remove announcement packets.
4. add API esp_mesh_flush_upstream_packets().
5. automatically adjust passsive scan time based on the change of beacon interval.
2018-08-10 11:45:11 +08:00
c455d6f2a0 Merge branch 'feature/nvs_version_check_v3.1' into 'release/v3.1'
nvs_flash: Version compatibility check for nvs storage (backport 3.1)

See merge request idf/esp-idf!2958
2018-08-10 11:36:39 +08:00
b3eee7d58f Merge branch 'bugfix/btdm_hfp_invalid_sco_param_v3.1' into 'release/v3.1'
component/bt: modify the invalid retransmission setting for SCO link in HFP(backport v3.1)

See merge request idf/esp-idf!2956
2018-08-10 11:10:55 +08:00
271e2f9419 Merge branch 'bugfix/backport_several_bugfix_to_v3.1' into 'release/v3.1'
esp32: backport several WiFi bug fixes to v3.1

See merge request idf/esp-idf!2955
2018-08-10 11:09:35 +08:00
70f15bd28e docs: Combine the common en/zh_CN Makefiles to one common file 2018-08-10 00:28:13 +00:00
607a1abefd docs: translate the version include script to Chinese 2018-08-10 00:28:13 +00:00
8122f7162c README: Add version-specific links
Make it clearer how the README fits in with the docs.
2018-08-10 00:28:13 +00:00
cd31a5e3c6 docs: Add version-specific include files, version documentation
* "git clone" command and a small version header are generated
  depending on git properties.
* Add Versions page with details about each version
* Make it clear using master branch is living on the "bleeding
  edge"
2018-08-10 00:28:13 +00:00
8a6c1df041 esp32: backport several WiFi bug fixes to v3.1
Backport following bug fixes to v3.1:

1. Bug fix of may connect to wrong AP in all channel scan

2. Station state machine change and fix ap loss

3. Add compatible to ccmp encryption

4. Update libphy.a to v3960:
   4.1 Decrease  phy_init time from 900us to 347us in sleep wakeup
   4.2 Fix RX STBC initialization
   4.3 Modify set_chan function to fix interrupt watchdog issue

5. Fix several wpa2 enterprise issues
   5.1 Fix heap corrupted bug
   5.2 Fix memory leak bug
   5.3 Make wpa2 enterprise thread-safe
   Closes https://github.com/espressif/esp-idf/issues/1569

6. Bugfix of coex wifi pm
2018-08-09 13:24:16 +00:00
7e02cd3498 Merge branch 'bugfix/remove_check_for_reason_assoc_expire_backport_v3.1' into 'release/v3.1'
test: remove check for REASON_ASSOC_EXPIRE (backport v3.1)

See merge request idf/esp-idf!2953
2018-08-09 21:23:21 +08:00
ef30229e52 Merge branch 'feature/http_firmware_upgrade_v3.1' into 'release/v3.1'
esp_https_ota: Add esp_https_ota component (Backport v3.1)

See merge request idf/esp-idf!2954
2018-08-09 08:20:33 +08:00
6ee884c861 fix(touch): add_mutex_for_some_touchpad_apis 2018-08-08 20:06:54 +08:00
002189cd1a esp_http_client: Add support for getting transport type 2018-08-08 14:55:35 +05:30
fbe792f33f esp_https_ota: Add support for HTTPS based ota feature 2018-08-08 14:55:22 +05:30
b88ae6c39f spi_flash: allocate mmap pages array in internal memory
* spi_flash_mmap_pages needs pages array to be in internal memory.
  Document and check this.

* Fix a bug that spi_flash_mmap did not allocate pages array in
  internal memory.

* Minor style fixes: const-ify pages argument of spi_flash_mmap, add
  spaces around operators, mark output arguments with [out].

Closes https://github.com/espressif/esp-idf/issues/2229.
2018-08-08 11:30:31 +03:00
45d7039623 Merge branch 'feature/support_for_XM25QU64A_v3.1' into 'release/v3.1'
feature(flash): set QIO mode for XM25QU64A(1V8_8MB_flash) (backport v3.1)

See merge request idf/esp-idf!2950
2018-08-08 16:30:09 +08:00
d9a1b5faae Merge branch 'bugfix/http_chunked_read_v3.1' into 'release/v3.1'
esp_http_client: fixed http chunked encoding packet loss & add check data before read for ssl transport (backport v3.1)

See merge request idf/esp-idf!2952
2018-08-08 16:24:04 +08:00
b2901d7e2f esp_http_client: fixed http chunked encoding packet loss & add check data before read for ssl transport (backport v3.1) 2018-08-08 16:24:04 +08:00
a3b5a23b87 nvs_flash: Version compatibility check for nvs storage
This change adds a check for compatibility between the nvs version
found on nvs flash and the one assumed by running code during nvs
initialization. Any mismatch is reported to the user using new error
code ESP_ERR_NVS_NEW_VERSION_FOUND.
2018-08-08 12:43:50 +05:30
eaa48f380a Merge branch 'bugfix/add_queueset_critical_sections_v3.1' into 'release/v3.1'
freertos: Add critical sections to queue sets (backport v3.1)

See merge request idf/esp-idf!2789
2018-08-08 14:46:25 +08:00
78c083325f component/bt: modify the invalid retransmission setting for SCO link in HFP 2018-08-08 14:40:22 +08:00
a8d34b8e20 Merge branch 'bugfix/btdm_spp_crash_on_reset_v3.1' into 'release/v3.1'
component/bt: Fix bug of SPP crash on reset (backport v3.1)

See merge request idf/esp-idf!2951
2018-08-08 14:36:21 +08:00
66e7027e7a test: update Wi-Fi test cases:
1. The test step for error code REASON_ASSOC_EXPIRE is not reliable. SoftAP
could also send error code WIFI_REASON_NOT_AUTHED
2. STA will be disconnected now if softAP restart DHCP server
2018-08-08 13:04:16 +08:00
6210272bfd component/bt: Fix bug of SPP crash on reset
In response to: https://github.com/espressif/esp-idf/issues/1998
2018-08-08 12:03:32 +08:00
57ed12a019 feature(flash): support for QIO mode of XM25QU64A 2018-08-08 10:58:13 +08:00
a4270573e7 Merge branch 'bugfix/ci_github_deploy_v31' into 'release/v3.1'
ci: Simplify github deployment (backport v3.1)

See merge request idf/esp-idf!2874
2018-08-08 07:26:01 +08:00
ae5cb25f11 Merge branch 'bugfix/fix_crash_for_http2_request_v3.1' into 'release/v3.1'
fix the crash when http2_request example send/recv fail

See merge request idf/esp-idf!2941
2018-08-07 18:36:41 +08:00
bf76c1bc1a fix the crash when http2_request example send/recv fail 2018-08-07 09:52:31 +08:00
cb05e152b9 Merge branch 'fix/sdio_speed_4bit_v3.1' into 'release/v3.1'
backport v3.1: fix(sdio): update sdio to better run in 4bit HS mode

See merge request idf/esp-idf!2759
2018-08-06 15:17:26 +08:00
f999688f2c Merge branch 'bugfix/coex_pause_v3.1' into 'release/v3.1'
fix coex pause cause bluetooth performance decrease (backport v3.1)

See merge request idf/esp-idf!2864
2018-08-06 15:05:19 +08:00
762c5fe996 ci: Simplify github deployment
CI_COMMIT_REF_NAME lets us use a single line to git push
2018-08-06 16:32:41 +10:00
ac19aef689 Merge branch 'feature/mbedtls_2_12_0_v3.1' into 'release/v3.1'
mbedtls: update to 2.12.0 (backport v3.1)

See merge request idf/esp-idf!2932
2018-08-06 14:23:10 +08:00
d88b705562 Merge branch 'bugfix/fix_uart_tx_bug_when_using_ringbuffer_for_v3.1' into 'release/v3.1'
driver(uart): Fixed uart tx_empty interrupt wdt timeout bug for release/v3.1

See merge request idf/esp-idf!2934
2018-08-06 14:22:29 +08:00
7d9d4d16e5 fix coex pause cause bluetooth performance decrease
1. it may cause BLE connection unstable
2. it may cause Classic BT connection unstable
3. it may cause BLE/BREDR scan performance decrease
2018-08-06 11:19:17 +08:00
1e92ad77c4 Merge branch 'bugfix/btdm_fix_sc_mitm_bond_failed_in_smp_for_iphones_v3.1' into 'release/v3.1'
Component/bt:  fix SC_MITM_BOND failed in smp for iphones for v3.1

See merge request idf/esp-idf!2923
2018-08-05 23:48:29 +08:00
e136fb7e18 mbedtls: update to 2.12.0 2018-08-05 09:17:40 +03:00
4225b9794f Merge branch 'bugfix/ampdu_duplicate_v3.1' into 'release/v3.1'
Wifi: fix ampdu duplicate issue (backport v3.1)

See merge request idf/esp-idf!2797
2018-08-05 07:17:25 +08:00
76b9e36f2b Merge branch 'bugfix/btdm_a2dp_disconnect_reason_for_v3.1' into 'release/v3.1'
bugfix/btdm_a2dp_disconnect_reason(backport v3.1)

See merge request idf/esp-idf!2927
2018-08-04 23:48:42 +08:00
b490f05b95 wifi: fix ampdu duplicate issue
fix ampdu duplicate issue
2018-08-04 15:33:55 +00:00
c7ca7872cb Merge branch 'bugfix/btdm_fix_ble_HIDD_demo_error_for_v3.1' into 'release/v3.1'
Component/bt: fix ble HID demo error for v3.1

See merge request idf/esp-idf!2922
2018-08-04 23:26:18 +08:00
97655e05b5 Merge branch 'bugfix/btdm_lmp_trans_coll_state_uncleared_for_v3.1' into 'release/v3.1'
bugfix/btdm_lmp_trans_coll_state_uncleared(backport v3.1)

See merge request idf/esp-idf!2929
2018-08-04 23:25:33 +08:00
512e4d5836 Component/bt: fix SC_MITM_BOND failed in smp for iphones 2018-08-04 17:02:13 +08:00
9d8a85e2ab component/bt: bugfix for uncleared LMP transaction collision state after rejecting sniff request from slave 2018-08-03 15:55:23 +08:00
8a940ccd65 component/bt: retrieve disconnection reason in AVDT when ACL-U link is disconnected 2018-08-03 15:36:44 +08:00
c983bc4d12 Merge branch 'bugfix/btdm_controller_deinit_v3.1' into 'release/v3.1'
bt : fix bug that bluetooth controller init/disable/enable/disable may cause exception(backport v3.1)

See merge request idf/esp-idf!2865
2018-08-03 15:09:58 +08:00
b8582d977d Component/bt: fix ble HID demo error 2018-08-03 11:35:32 +08:00
c4ffb39ccc fix(sdmmc): disable all pulldowns used by sdmmc host 2018-08-03 11:03:25 +08:00
485ed4cc22 Merge branch 'bugfix/btdm_fix_queue_block_when_scanning_for_v3.1' into 'release/v3.1'
Component/bt: fix queue blocking when scanning for v3.1

See merge request idf/esp-idf!2893
2018-08-03 07:28:07 +08:00
d4e38152ef driver(uart): Fixed uart tx_empty interrupt wdt timeout bug for release/v3.1 2018-08-02 12:45:53 +08:00
e5abec310d bt : fix bug that bluetooth controller init/disable/enable/disable may cause exception
1. when one task do deinit/init/disable/enable, especially different cpu
core, it may cause controller crash in ISR handler
2. fix while BLE is scanning, bluetooth controller is disabled cause BLE
scan is not abort.
2018-08-01 20:08:40 +08:00
2c483a6b52 Merge branch 'bugfix/spiffs_readdir_recursion_v3.1' into 'release/v3.1'
SPIFFS: fix stack overflow in readdir_r due to recursion (backport v3.1)

See merge request idf/esp-idf!2876
2018-08-01 18:05:47 +08:00
bf281b31ec Merge branch 'bugfix/remove_bt_dependency_on_lwip_header_v3.1' into 'release/v3.1'
Bugfix/remove bt dependency on lwip header (backport v3.1)

See merge request idf/esp-idf!2907
2018-08-01 17:40:37 +08:00
3c359763da heap: move get_all_caps to IRAM, used in unit test 2018-08-01 08:59:02 +00:00
f81e71f622 freertos: bump limit for spinlock performance test to 300 cycles 2018-08-01 08:59:02 +00:00
a1dadda7d6 newlib: fix unit test for psram config 2018-08-01 08:59:02 +00:00
cfde037f9a heap: fix unit test for the case when less than 10k of IRAM is available 2018-08-01 08:59:02 +00:00
3fcc3689ce spi_master, ulp: fix aliasing errors in unit tests 2018-08-01 08:59:02 +00:00
497b123958 unit-test-app: don’t include project.mk for ut- targets
If project.mk is included twice in recursive invocation of Make, some
variables defined on the first pass will not be redefined on the
second pass. Rather than cleaning up these variables before calling
Make recursively, don’t include IDF project.mk at all, if one of the
ut- targets is requested.
2018-08-01 08:59:02 +00:00
7995ba6433 fix(sdio_slave): improve sdio slave for high speed and 4 bit mode 2018-08-01 15:23:24 +08:00
5019ff3345 fix(sdio_slave): fix minor issues like return value of send function, output arg, etc. 2018-08-01 15:23:23 +08:00
b270638868 Component/bt: fix hci_hal_env.rx_q and xHciH4Queue blocking when scanning 2018-08-01 15:10:28 +08:00
3576a634c7 freertos: Add critical sections to queue sets.
Queue sets are not SMP safe. This commit adds
critical sections to queue sets. Unit tests for
queue sets have also been added.
2018-08-01 07:07:32 +00:00
d8a1080bdf Merge branch 'bugfix/btdm_fix_gattc_count_invalid_for_v3.1' into 'release/v3.1'
Component/bt: fix gattc get count invalid and discover included service error for v3.1

See merge request idf/esp-idf!2894
2018-08-01 14:51:08 +08:00
c209efa4e2 Merge branch 'doc/wifi_update_channel_state_information_document_v3.1' into 'release/v3.1'
docs: update channel state information document (backport v3.1)

See merge request idf/esp-idf!2796
2018-08-01 14:49:45 +08:00
d78452ed29 wpa_supplicant: removed unrequired header dir include from component.mk
- Also fixed license header in rtc driver

Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2018-08-01 12:02:13 +05:30
acb3b6fee2 bluedroid: remove dependency on arpa/inet.h include
Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2018-08-01 12:02:11 +05:30
c237beff1d Merge branch 'bugfix/ulp_example_fix_v3.1' into 'release/v3.1'
ULP example fixes (backport v3.1)

See merge request idf/esp-idf!2818
2018-08-01 14:29:29 +08:00
34a4a96ded Merge branch 'bugfix/sdmmc_auto_stop_cmd_v3.1' into 'release/v3.1'
sdmmc: enable host auto_stop only for certain commands (backport for v3.1)

See merge request idf/esp-idf!2817
2018-08-01 14:29:03 +08:00
2ef6bcaedd Merge branch 'bugfix/btdm_sco_end_crash_on_supv_to_for_v3.1' into 'release/v3.1'
bugfix/btdm_sco_end_crash_on_supv_to_for_v3.1(backport v3.1)

See merge request idf/esp-idf!2896
2018-08-01 14:28:08 +08:00
1928a4a638 Merge branch 'feat/sdio_pullup_v3.1' into 'release/v3.1'
backport v3.1: fix(sdio_slave): fix the intr_recv issue that trigger receiving too fast cause assertion failed.

See merge request idf/esp-idf!2795
2018-08-01 14:15:35 +08:00
d85b1fb091 fix(sdio_slave): fix the intr_recv issue that trigger receiving too fast cause assertion failed.
also fix a race risk issue when recycle receiving buffers.
2018-07-31 17:57:15 +08:00
970502f904 Component/bt: fix gattc get count invalid 2018-07-31 15:38:00 +08:00
d3cb687936 component/bt: bugfix on the crash during end of sco link resulted from link supervision timeout 2018-07-31 15:35:58 +08:00
b28db50786 Merge branch 'bugfix/unit_test_thread_local_storage_v3_1' into 'release/v3.1'
ci/esp32: Fix race in "TLS Test" where s_task can go out of scope before cleanup finishes (v3.1 backport)

See merge request idf/esp-idf!2844
2018-07-31 07:24:38 +08:00
7999c06f68 spiffs: add test case for readdir_r with large number of files
Ref. https://esp32.com/viewtopic.php?f=13&t=6486
2018-07-30 08:07:34 +03:00
490d7cbba9 Fix stackoverflow due to recursion in vfs_spiffs_readdir_r 2018-07-30 08:07:31 +03:00
a8b92d560b Merge branch 'test/backport_ci_changes_to_v3.1' into 'release/v3.1'
test: backport ci changes (backport v3.1)

See merge request idf/esp-idf!2869
2018-07-30 09:58:31 +08:00
1884151ca8 CI: support test one case multiple times by @bot 2018-07-28 15:06:18 +08:00
b86c8b3260 ci: temp disable http client tests:
connection is not stable. need to replace with local test servers.
2018-07-28 15:04:28 +08:00
2d31597fa9 tiny-test-fw: support ignore test cases in CI assign test stage 2018-07-28 15:04:14 +08:00
715dfac07e tiny-test-fw: fix exception during print debug info:
DUT log is unicode, might not be able to encode
2018-07-28 15:03:58 +08:00
bf72ed92a9 CI: erase nvs partition before test:
Latest NVS partition bin can't be parsed by old IDF revision. Need to erase before test.
2018-07-28 15:03:30 +08:00
146a959706 esp32/test: set 60s timeout for one deep sleep case 2018-07-28 15:00:57 +08:00
fa9c836f02 tiny-test-fw: save DUT log in different thread:
We found some SD card on Raspberry Pi could have very bad performance.
It could take seconds to save small amount of data.
If the DUT receives data and save it as log, then it stops receiving data until log is saved.
This could lead to expect timeout. As an workaround to this issue,
``BaseDUT`` class will create a thread to save logs.
Then data will be passed to ``expect`` as soon as received.
2018-07-28 15:00:41 +08:00
609e39a620 tiny-test-fw: fix incorrect wait timeout in expect 2018-07-28 15:00:28 +08:00
3956fe30c0 tiny-test-fw: filter examples with test level 2018-07-28 15:00:16 +08:00
831e8d653f tiny-test-fw: print expect failure when test fails 2018-07-28 15:00:01 +08:00
35a3ef6892 CI: add stage host_test:
1. Add `host_test` stage for test jobs running on host.
2. Rename stage `test` to `integration_test`.
2018-07-28 14:57:59 +08:00
5637424aff CI: minor optimize of CI config file:
1. set shorter expire time for artifacts
2. set dependency for example test jobs, to limit the artifacts it downloads
2018-07-28 14:57:42 +08:00
0fc888cf78 CI: remove test report stage:
Test report is not used as expected:

1. we rarely download and use test report
2. current test report method doesn't handle large amount data well,
   need to be replaced by other methods

Test report also make test jobs allow to fail. It breaks the
original flow of Gitlab CI and make user confused.
2018-07-28 14:57:32 +08:00
b37f08f961 test: add mesh basic function test cases 2018-07-28 14:56:53 +08:00
62682a681a Merge branch 'feature/wifi_check_wifi_lib_git_commit_id_v3.1' into 'release/v3.1'
check WiFi library git commit id in unit test (backport v3.1)

See merge request idf/esp-idf!2785
2018-07-26 14:24:52 +08:00
3e2d5f6292 Merge branch 'bugfix/fix_pcnt_isr_service_register_bug_for_v3.1' into 'release/v3.1'
driver(pcnt):  Add some comments in pcnt.h for v3.1

See merge request idf/esp-idf!2845
2018-07-26 08:35:18 +08:00
e9112a9489 Merge branch 'bugfix/fix_touchpad_wakeup_status_v3.1' into 'release/v3.1'
fix(sleep): swap touchpad num in wakeup status v3.1

See merge request idf/esp-idf!2848
2018-07-26 08:34:55 +08:00
e00d9425da Merge branch 'bugfix/ledc_duty_and_freq_for_v3.1' into 'release/v3.1'
driver(ledc):  fix bugs reported from unit-test and github for v3.1

See merge request idf/esp-idf!2843
2018-07-26 08:08:12 +08:00
3eaf8f1a84 Merge branch 'bugfix/secure_boot_padding_v3_1' into 'release/v3.1'
secure boot: Fix padding issue (backport v3.1)

See merge request idf/esp-idf!2833
2018-07-25 08:59:31 +08:00
ef38eb0323 Merge branch 'bugfix/bootloader_dev_zero_app_count_v3.1' into 'release/v3.1'
bootloader: Fix issue - bs->app_count is zero but ota_data have valid entry (backport  v3.1)

See merge request idf/esp-idf!2847
2018-07-25 00:14:43 +08:00
c6be772242 fix(sleep): swap touchpad num in wakeup status 2018-07-24 18:08:29 +08:00
c892c96f9a Merge branch 'bugfix/fix_uart_timeout_bug_when_enable_reftick_v3.1' into 'release/v3.1'
driver(uart): Fix uart time_out bug when using ref_tick for releasev3.1

See merge request idf/esp-idf!2810
2018-07-24 17:55:55 +08:00
7f2edf8528 bootloader: Fix issue - bs->app_count is zero but ota_data have valid entry
If we have the partition table without any ota_apps but in ota_data have
valide entry, in this case we get an error(hang). This commit fix this
case. If bs->app_count is zero when selecting the factory app.

Closes https://github.com/espressif/esp-idf/issues/2218
2018-07-24 15:41:49 +08:00
9b6769411a Merge branch 'bugfix/deep_sleep_flush_uart_v3.1' into 'release/v3.1'
sleep: fix flushing UARTs when entering deep sleep (backport v3.1)

See merge request idf/esp-idf!2816
2018-07-24 14:06:59 +08:00
e55f55531c esp32 tests: TLS test: use same size stack for static & non-static task
Use constant instead of magic number of task priorities.
2018-07-24 15:44:12 +10:00
0f665dfb0d esp32: Fix race in "TLS Test" where s_task can go out of scope before cleanup finishes
Probable cause for CI failures of "LoadStoreError" after this task finishes running.
2018-07-24 15:44:12 +10:00
b2f1dd6a16 bugfix(ledc): fix bugs reported from unit-test and github.
1. In ledc_set_duty_and_update, return if duty updated. Close https://github.com/espressif/esp-idf/issues/2082
2. fix ledc_set_freq function for low speed mode.
2018-07-24 13:22:50 +08:00
989396ef27 Add some comments in pcnt.h. 2018-07-24 10:46:50 +08:00
b3a2f85c70 driver(uart): Fix uart time_out bug when using ref_tick for releasev3.1 2018-07-24 09:57:55 +08:00
bd768edca2 check WiFi library git commit id in unit test 2018-07-23 20:03:43 +08:00
fdf61f7c45 Merge branch 'bugfix/beacon_info_do_not_update_after_user_scan_v3.1' into 'release/v3.1'
Wifi: bugfix of beacon info don't update after user scan (backport v3.1)

See merge request idf/esp-idf!2780
2018-07-23 20:02:24 +08:00
ccd431c7ed Merge branch 'feature/nvs_part_gen_improvements_backportv3.1' into 'release/v3.1'
Feature/nvs part gen improvements (backport v3.1)

See merge request idf/esp-idf!2799
2018-07-23 13:30:19 +08:00
e1e4e08fa8 app_update: Don't double-verify secure boot signature during OTA
esp_image_load() already verifies the signature
2018-07-23 13:45:55 +10:00
f8b191cfae secure boot: Pad to avoid data after the signature mapping into the address space
Because address space is mapped in 64KB pages, it was possible for unauthenticated data after the
app .bin to become mapped into the flash cache address space.

This problem is solved by 2 changes:

* "esptool elf2image --secure-pad" will pad the image so that the signature block ends close to the
  64KB boundary. Due to alignment constraints it will be 12 bytes too short after signing (but
  with flash encryption, these 12 bytes are still encrypted as part of the last block and can't be
  arbitrarily changed).
* By default, secure boot now requires all app partitions to be a multiple of 64KB in size.
2018-07-23 13:45:55 +10:00
487ae78235 Wifi: bugfix of beacon info don't update after user scan 2018-07-21 10:39:43 +00:00
4314b00289 Merge branch 'bugfix/clear_intr_status_when_enable_intr_v3.1' into 'release/v3.1'
driver(gpio): fix the gpio interrupt false triggering issue(backport v3.1)

See merge request idf/esp-idf!2806
2018-07-21 14:36:37 +08:00
650e1f79d1 Merge branch 'bugfix/rmt_mem_num_maximum_limit_is_not_accurate_v3.1' into 'release/v3.1'
bugfix(rmt): Modify the rmt_mem_num maximum limit value from 15 to 8.(backport v3.1)

See merge request idf/esp-idf!2808
2018-07-21 14:25:38 +08:00
b87c822d59 Merge branch 'bugfix/secure_boot_regression_partitions_v3_1' into 'release/v3.1'
Fix secure boot & flash encryption regression, don't verify partitions as part of secure boot (backport)

See merge request idf/esp-idf!2779
2018-07-20 09:12:20 +08:00
90c6ea59a6 Fix errors in rtc_gpio_desc values 2018-07-19 10:27:31 +03:00
7fbfb0fc9b ulp example: fix for RTC IOs
- call rtc_gpio_init for pins which aren't configured as RTC by default
- for RTC IOs 16 and 17, read higher part of the input register
- automatically convert GPIO number into RTC IO number
- use ulp_set_wakeup_period instead of writing to register
2018-07-19 10:27:00 +03:00
447890247a sdmmc: enable host auto_stop only for certain commands
Perviously host send_auto_stop flag would be set for every data
transfer over 1 block long. This caused stop commands to be sent
after CMD53, which shouldn't be done. Fix by adding an explicit list
of commands for which send_auto_stop should be set.
2018-07-19 10:23:58 +03:00
d360f6d95d sleep: fix flushing UARTs when entering deep sleep
Since 94250e42a0, UART output is suspended when entering sleep mode
(deep or light sleep). This makes sense for light sleep, where sleep
normally takes small amount of time, and flushing the UART would add
a lot of latency. But this breaks existing behaviour for deep sleep,
where UART output was previously sent out before entering sleep mode.

Closes https://github.com/espressif/esp-idf/issues/2145
2018-07-19 10:21:23 +03:00
7edc392d7c Modify the rmt_mem_num maximum limit value from 15 to 8. 2018-07-18 16:33:45 +08:00
071f7cdb49 driver(gpio) : Fixed the gpio related bug for release v3.1. 2018-07-18 15:36:57 +08:00
89b423658a nvs_partition_generator: Add support for base64 representation of Binary data 2018-07-17 19:24:04 +05:30
6d0a9fe95e nvs_partition_generator: Modifications to enable using the utility as a Python library
And also use directly as an executable
2018-07-17 19:24:04 +05:30
afdc73c8ab Merge branch 'bugfix/mdns_remove_backport' into 'release/v3.1'
mdns: Minor fix for mdns_service_remove (backport v3.1)

See merge request idf/esp-idf!2784
2018-07-17 20:50:34 +08:00
1dc9be01c4 Merge branch 'bugfix/autoip_compilation_backportv3.1' into 'release/v3.1'
LWIP AutoIP Compilation Fixed by defining IP_IS_V4_VAL(backport v3.1)

See merge request idf/esp-idf!2787
2018-07-17 20:49:31 +08:00
cffd28ad83 Merge branch 'bugfix/bt_os_abstraction_layer_v3.1' into 'release/v3.1'
bt: fix OS abstraction layer for correct critical section API usage (backport v3.1)

See merge request idf/esp-idf!2713
2018-07-17 18:53:01 +08:00
f4c57eb764 docs: update channel state information document
1. Move channel to the first row of the table.

    2. Remove the condition of HT20/HT40 for they are determined by
    secondary channel.

    3. Clean up the CSI table.
2018-07-17 15:01:12 +08:00
346d6b0eaa Merge branch 'bugfix/gcc8_complation_errors_v3.1' into 'release/v3.1'
gcc8_newlib3: Compilation warnings and errors not specific to newlib v3 (backport v3.1)

See merge request idf/esp-idf!2777
2018-07-17 14:13:28 +08:00
0a357a4838 Merge branch 'bugfix/minor_fix_about_ip_route' into 'release/v3.1'
lwip: minor fix about ip route

See merge request idf/esp-idf!2782
2018-07-17 14:12:22 +08:00
76a46a0f68 LWIP AutoIP Compilation Fixed by defining IP_IS_V4_VAL() 2018-07-16 15:12:18 +05:30
8dbf96a471 mdns: Minor fix for mdns_service_remove()
Send the Goodbye packet while removing an mDNS service as an "Authoritative" packet so
that the listeners remove the service from their records immediately.
2018-07-16 15:07:44 +05:30
60080d4893 lwip: minor fix about ip route
Minor fix about ip4_route_src_hook()
2018-07-16 17:21:46 +08:00
3716e3e8c4 Merge branch 'bugfix/tw23835_add_source_ip_route_for_unicast_v3.1' into 'release/v3.1'
lwip: add source ip based route for unicast packet (backport v3.1)

See merge request idf/esp-idf!2773
2018-07-16 17:01:31 +08:00
0b1c461e63 bootloader: Fix warning building reflashable Secure Boot image 2018-07-16 16:59:36 +10:00
ec73cebb59 bootloader: Don't verify Partition Table as part of Secure Boot
Partition Tables are still signed for backwards compatibility, but signature is no longer checked as
part of bootloader.

Closes https://github.com/espressif/esp-idf/issues/1641
2018-07-16 16:59:36 +10:00
ce634ef221 bootloader: Fix secure boot & flash encryption functionality
Fixes regression in 3e0ac4db79.
2018-07-16 16:59:36 +10:00
af2a6ee826 gcc8_newlib3: Compilation warnings and errors not specific to newlib v3 2018-07-16 14:19:57 +08:00
2a581e3fab lwip: add source ip based route for unicast packet
Add source IP based route for unicast packets forwarding.
2018-07-14 10:01:55 +08:00
7b0a926574 Merge branch 'bugfix/btdm_err_data_report_for_v3.1' into 'release/v3.1'
bugfix/btdm_err_data_report_for_v3.1(backport v3.1)

See merge request idf/esp-idf!2751
2018-07-13 19:16:42 +08:00
f2c543785b bt: fix OS abstraction layer for correct critical section API usage
Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2018-07-13 11:29:40 +08:00
ed27e75f50 Merge branch 'bugfix/xthal_get_interrupt_volatile_v3.1' into 'release/v3.1'
xtensa: make XTHAL_GET_INTERRUPT, XTHAL_GET_CCOUNT volatile (backport v3.1)

See merge request idf/esp-idf!2712
2018-07-12 17:18:06 +08:00
ea30c54cda component/bt: bugfix for erroneous data reporting always enabled 2018-07-11 20:08:36 +08:00
c71c8aea55 Merge branch 'bugfix/btdm_invalid_sco_handle_for_v3.1' into 'release/v3.1'
bugfix/btdm_invalid_sco_handle_for_v3.1(backport v3.1)

See merge request idf/esp-idf!2727
2018-07-11 18:23:47 +08:00
46001bf6d4 Merge branch 'bugfix/rom_libgcc_functions_v3.1' into 'release/v3.1'
Fix linking of libgcc math functions to ROM (backport v3.1)

See merge request idf/esp-idf!2711
2018-07-11 16:45:39 +08:00
3e5053b778 Merge branch 'doc/eclipse_setup_v3.1' into 'release/v3.1'
doc: eclipse setup (v3.1 backport)

See merge request idf/esp-idf!2679
2018-07-11 14:31:31 +08:00
0db9b87d66 Merge branch 'bugfix/disable_lwip_trust_ip_by_default_v3.1' into 'release/v3.1'
lwip: disable ETHARP_TRUST_IP_MAC by default (backport v3.1)

See merge request idf/esp-idf!2720
2018-07-10 14:42:54 +08:00
a9aaabae21 Merge branch 'bugfix/tw23667_tcp_pcb_purge_assert_v3.1' into 'release/v3.1'
lwip: fix the assertion in tcp_pcb_purge() (backport v3.1)

See merge request idf/esp-idf!2722
2018-07-10 14:42:47 +08:00
f43dd79e11 Merge branch 'bugfix/wifi_channel_state_information_data_type_v3.1' into 'release/v3.1'
esp32: Change channel state information(CSI) data type from unsigned char to singed char (backport v3.1)

See merge request idf/esp-idf!2697
2018-07-10 10:02:58 +08:00
dff911da69 component/bt: bugfix of invalid SCO handle in HCI number_of_completed_packets event 2018-07-09 12:14:27 +08:00
31ca811240 lwip: fix the assertion in tcp_pcb_purge()
Fix the assertion in tcp_pcb_purge().
2018-07-09 10:33:13 +08:00
febb0cb3da lwip: disable ETHARP_TRUST_IP_MAC by default
Disable ETHARP_TRUST_IP_MAC by default because:
1. The LAN peer may not be trustful
2. The LAN peer may has problem to update its ARP entry
2018-07-09 10:26:05 +08:00
d128ff3ecd xtensa: make XTHAL_GET_INTERRUPT, XTHAL_GET_CCOUNT volatile
INTERRUPT and CCOUNT registers will change outside of program control.
Making the inline assembly used to read these registers volatile
indicates this fact to the compiler.

Fixes https://github.com/espressif/esp-idf/issues/2127
2018-07-05 17:21:55 +08:00
debe83c3b5 esp32: force pure math functions from libgcc to be linked from ROM 2018-07-05 17:19:01 +08:00
5752e4d588 esp32: fix addresses of some libgcc functions in ROM ld script 2018-07-05 17:18:54 +08:00
66dad0c506 Merge branch 'bugfix/console_performance' into 'release/v3.1'
idf_monitor: Fix console performance

See merge request idf/esp-idf!2687
2018-07-05 11:42:00 +08:00
fffbcbb78b esp32: Change channel state information(CSI) data type from unsigned char to singed char 2018-07-04 11:47:57 +08:00
b8937e5522 idf_monitor: Fix console performance
51e42d8e92
introduced filtering options which handles the last (unterminated) line
with a delay. This introduced poor performance for console applications
when the user interacts with the ESP32 device in the same line because
there is an artificial delay for each key-press.

bb152030a0
decreased the delay but there are still delays for each key-presses.

The current fix makes only one delay per line instead of each
key-presses. When an unterminated line is detected then no more
"delayed" print is used for the given line.

Fixes https://github.com/espressif/esp-idf/issues/2054
2018-07-03 09:15:46 +02:00
0a2e4967ef doc: Clarify some Eclipse setup steps 2018-07-02 11:42:29 +10:00
cbc5ef4bc6 Merge branch 'docs/eclipse_regex' into 'master'
Docs: Fix bugs in Eclipse setup in CN

See merge request idf/esp-idf!2620
2018-07-02 11:41:12 +10:00
aec8dfdc8e Merge branch 'bugfix/coex_bug_v3.1' into 'release/v3.1'
esp32: fix coex bug(Backport v3.1)

See merge request idf/esp-idf!2675
2018-07-02 09:40:45 +08:00
3ad712ba86 esp32: fix coex bug
1. fix BLE connection missing in coex mode
    2. modify other parameters to make coex priority more reasonable
    3. fix modem sleep procedure trap cause Wifi disable RF when BT is
    working. Such cause that BR/EDR is difficult to be connected, BLE
    connection stability decrease and so on.
    4. modify BR/EDR coexist duration to imrove BR/EDR connect success
    ratio.
    5. Due to the hardware coexist bug, BLE scan interval/window should
    be less than 0x100(about 160ms). Therefore, it will cause BLE cannot
    scan any advertising packet while WiFi have higher priority
    behaviour(such like RX beacon, scan, TX/RX VO packets and etc.).
2018-06-30 22:40:09 +08:00
b31e16039e Merge branch 'bugfix/btdm_fix_gattc_register_multi_srvc_chg_v3.1' into 'release/v3.1'
Component/bt: fix register multi service change when register multi gattc for v3.1

See merge request idf/esp-idf!2668
2018-06-30 11:30:59 +08:00
16bb663c74 Merge branch 'bugfix/btdm_bad_pointer_of_bt_gap_v3.1' into 'release/v3.1'
component/bt: Fix some bad point calculations of BT GAP of v3.1

See merge request idf/esp-idf!2669
2018-06-29 22:16:15 +08:00
4bd6486b41 Merge branch 'bugfix/btdm_bt_remove_device_disconnect_v3.1' into 'release/v3.1'
component/bt: Fix bug of BT and BLE remove bond device of v3.1

See merge request idf/esp-idf!2670
2018-06-29 22:15:53 +08:00
1340de576e component/bt: Fix bug of BT and BLE remove bond device of v3.1
1. esp_ble_remove_bond_device will only remove BLE bond key and disconnect BLE device.
2. esp_bt_gap_remove_bond_device  will only remove BT bond key and disconnect BT device.

A cherry-pick of MR !2562
2018-06-29 20:09:19 +08:00
92ea676c38 component/bt: Fix some bad point calculations of BT GAP of v3.1
Closes https://github.com/espressif/esp-idf/issues/2103

A cherry-pick of MR !2655
2018-06-29 20:01:51 +08:00
8335933cdf Component/bt: fix register multi service change when register multi gattc 2018-06-29 19:54:22 +08:00
f198339ec0 Merge branch 'bugfix/esp_err_name_idf_path_v3.1' into 'release/v3.1'
docs: fix error code reference build issue (v3.1)

See merge request idf/esp-idf!2607
2018-06-29 19:23:49 +08:00
f4f563bc7b Merge branch 'bugfix/btdm_fix_stop_adv_error_in_dual_core_v3.1' into 'release/v3.1'
component/bt: fix stop adv error in dual core for v3.1

See merge request idf/esp-idf!2661
2018-06-29 19:22:28 +08:00
a95678bfcd Merge branch 'bugfix/assert_v3.1' into 'release/v3.1'
assert: Fix. Move useful functions from wrapped assert functions (v3.1)

See merge request idf/esp-idf!2605
2018-06-29 19:20:35 +08:00
dadfcc35b3 Merge branch 'bugfix/read_rssi_v3.1' into 'release/v3.1'
bt : fix read rssi conflict when in dual mode

See merge request idf/esp-idf!2618
2018-06-29 19:18:15 +08:00
7535226679 Merge branch 'bugfix/btdm_respond_error_when_receives_unsupported_request_v3.1' into 'release/v3.1'
component/bt: Fix bug: Respond with the Error Response when receiving a request…

See merge request idf/esp-idf!2662
2018-06-29 19:15:03 +08:00
35364c365f Merge branch 'bugfix/btdm_some_ble_hid_bugs_v3.1' into 'release/v3.1'
component/bt: Fix some hid bugs of v3.1

See merge request idf/esp-idf!2663
2018-06-29 19:14:41 +08:00
2d7798e091 Merge branch 'bugfix/btdm_modem_sleep_prevent_dfs_for_v3.1' into 'release/v3.1'
bugfix/btdm_modem_sleep_prevent_dfs_for_v3.1(backport v3.1)

See merge request idf/esp-idf!2660
2018-06-29 18:45:47 +08:00
d945191e08 Merge branch 'bugfix/btdm_rm_assert_in_isr_for_v3.1' into 'release/v3.1'
bugfix/btdm_rm_assert_in_isr_for_v3.1(backport v3.1)

See merge request idf/esp-idf!2659
2018-06-29 18:45:30 +08:00
a0014d91b9 Merge branch 'bugfix/btdm_singular_sleep_time_corr_for_v3.1' into 'release/v3.1'
bugfix/btdm_singular_sleep_time_correction_for_v3.1(backport v3.1)

See merge request idf/esp-idf!2658
2018-06-29 18:44:20 +08:00
ebc3df0038 component/bt: Fix some hid bugs of v3.1
1. Property of HID Information is Read
2. Property of HID Control Point is WriteWithoutResponse

A cherry-pick of MR !2628
2018-06-29 15:42:46 +08:00
85127bcbbd component/bt: Fix bug: Respond with the Error Response when receiving a request that it does not support into v3.1
A cherry-pick of MR !2591
2018-06-29 15:19:19 +08:00
364e587b46 Merge branch 'feature/optimize_wifi_memory_v3.1' into 'release/v3.1'
Optimize WiFi memory (backport v3.1)

See merge request idf/esp-idf!2651
2018-06-29 15:13:00 +08:00
zwj
6752163800 component/bt: fix stop adv error in dual core 2018-06-29 15:09:11 +08:00
ddb05d0719 Merge branch 'bugfix/btdm_fix_no_adv_packet_v3.1' into 'release/v3.1'
component/bt: fix no adv packets for v3.1

See merge request idf/esp-idf!2653
2018-06-29 14:59:10 +08:00
125828edaf prevent Dynamic Frequency Scaling when using bluetooth modem sleep
This constraint will be elimiated after the issue is fixed
2018-06-29 14:49:23 +08:00
d7f5c3e55f component/bt: remove the call of assert in time conversion functions which can be caused in ISR 2018-06-29 14:40:54 +08:00
eebbe2d008 component/bt: fix the cornered case caused by singular finetime correction value upon waking up from sleep
1. revert previous changes that adds 1-slot margin for first master Tx event, since this bugfix can handle that case
2018-06-29 14:29:53 +08:00
zwj
9ca4dc0626 component/bt: fix no adv packets 2018-06-29 10:23:46 +08:00
dd73e2a453 Optimize WiFi memory
Optimize wifi memory (b987c01d)
1. Decrease WiFi task stack size by 512 Bytes
2. Modify WiFi NVS configuration array from static to dynamic
3. Move interrupt/RX relating variables from .bss segment to .data segment
4. Modify WiFi management short buffer from static to dynamic
5. Remove some useless WiFi buffer space
2018-06-28 21:27:24 +08:00
07b1e2053c Merge branch 'mesh/update_libs_v3.1' into 'release/v3.1'
mesh: update libs(backport3.1)

See merge request idf/esp-idf!2630
2018-06-28 16:09:29 +08:00
999f86320e Merge branch 'bugfix/btdm_conn_stress_test_assert_for_v3.1' into 'release/v3.1'
bugfix/btdm_conn_stress_test_assert_for_v3.1(backport v3.1)

See merge request idf/esp-idf!2632
2018-06-28 14:23:39 +08:00
3c188abdd7 component/bt: add 1 slot margin to program the 1st master Tx event during BLE connection
this will resolve the issue of failure of BLE connection stress test with sleep enabled
2018-06-27 18:13:17 +08:00
698d3bafa5 Merge branch 'bugfix/btdm_slave_can_not_receive_long_packets_in_smp_v3.1' into 'release/v3.1'
Component/bt: fix slave can not receive long packets in smp for v3.1

See merge request idf/esp-idf!2626
2018-06-27 18:10:24 +08:00
fcf0324a66 Merge branch 'feature/move_to_soc_rtc_gpio_desc_v3.1' into 'release/v3.1'
soc: Fix check_long_hold_gpio and move def to soc (v3.1 backport)

See merge request idf/esp-idf!2622
2018-06-27 15:55:46 +08:00
3c4c838c2b mesh: update libs
1. add APIs to set/get announce interval values.
2. add API to enable/disable the min rate to 6Mbps for data packages.
3. add APIs to set/get RSSI threshold values.
4. fix ap_loss.
2018-06-26 21:49:23 +08:00
36adefc8a8 Merge branch 'feature/btdm_controller_to_host_flow_control_v3.1' into 'release/v3.1'
component/bt: Add Controller to Host Flow Control into v3.1

See merge request idf/esp-idf!2613
2018-06-26 17:07:18 +08:00
e8ff79d6b4 Component/bt: fix slave can not receive long packets in smp 2018-06-26 16:44:04 +08:00
baa6c19700 soc: Fix check_long_hold_gpio and move def to soc
Fix factory_reset_pin init as input
Move definition a structure rtc_gpio_desc to soc

Closes https://github.com/espressif/esp-idf/issues/2030
2018-06-26 12:47:55 +05:00
e3dedb74c5 bt : fix read rssi conflict when in dual mode 2018-06-26 11:54:39 +08:00
f406174be5 component/bt: Add Controller to Host Flow Control into v3.1
A cherry-pick of MR !2493
2018-06-25 20:38:21 +08:00
5ebb70ecc5 Merge branch 'bugfix/app_partition_fallback_v31' into 'release/v3.1'
partition_table: Support same fallback logic as bootloader for default boot partition (v3.1 backport)

See merge request idf/esp-idf!2597
2018-06-25 14:59:03 +08:00
8437b63845 Merge branch 'bugfix/wifi_support_null_mode_again_v3.1' into 'release/v3.1'
support WiFi null mode again

See merge request idf/esp-idf!2578
2018-06-25 14:54:40 +08:00
b17defd6cb docs: conf.py: check return code when calling os.system
Several calls were made but results were not checked, obfuscating the
errors.
2018-06-25 13:43:43 +08:00
26e1136fc5 esp_err_to_name.py: guess IDF_PATH if not set in environement
Fixes the issue that esp_err_to_name.py would fail when called in
documentation build process, when there was no IDF_PATH set.
2018-06-25 13:43:32 +08:00
6b5a15e3da partition_table: Support same fallback logic as bootloader for default boot partition
Generates correct "make flash" command even when partition table has no factory partition.

Also adds unit tests for parttool.py

Closes https://github.com/espressif/esp-idf/issues/2086
2018-06-25 05:36:55 +00:00
f9affb9fb8 assert: Fix. Move useful functions from wrapped assert functions
Moved useful functions from wrapped assert functions, because option `CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED=y` will remove this functions.

Closes https://github.com/espressif/esp-idf/issues/2068
2018-06-25 11:05:54 +08:00
21fd581265 Merge branch 'bugfix/btdm_modify_throught_demo_default_config_v3.1' into 'release/v3.1'
Component/bt: modify throughput demo default config for v3.1

See merge request idf/esp-idf!2600
2018-06-24 10:52:44 +08:00
6c87d104c0 Component/bt: modify throughput demo default config 2018-06-22 19:44:20 +08:00
7634d9a991 support WiFi null mode again 2018-06-21 21:45:57 +08:00
c59f7687ca Merge branch 'bugfix/btdm_k_mem_assert_bug_v3.1' into 'release/v3.1'
component/bt: Fix the bug of when operating the list on interrupt function,…

See merge request idf/esp-idf!2584
2018-06-21 15:23:24 +08:00
0f0833e350 component/bt: Fix the bug of when operating the list on interrupt function, there is no lock protection. 2018-06-21 11:14:07 +08:00
c1fdd45001 Merge branch 'bugfix/fix_touch_pad_can_not_wake_up' into 'master'
bugfix(touch pad): modify deep-sleep example and add note for sleep api

See merge request idf/esp-idf!2553
2018-06-20 11:51:46 +08:00
9a0d57b90b bugfix(touch pad): modify deep-sleep example and add note for sleep api.
Closes https://github.com/espressif/esp-idf/issues/2052
2018-06-20 10:57:26 +08:00
e3a31302ef Merge branch 'doc/use_docs_espressif_com' into 'master'
docs: Switch base URL from esp-idf.readthedocs.io to docs.espressif.com

See merge request idf/esp-idf!2569
2018-06-20 07:32:11 +08:00
d0b8f2865f docs: Switch base URL from esp-idf.readthedocs.io to docs.espressif.com 2018-06-19 11:23:33 +00:00
7933b75416 Merge branch 'bugfix/ESP_PARTITION_TABLE_OFFSET' into 'master'
spi_flash: Fix error unit tests on host

See merge request idf/esp-idf!2573
2018-06-19 19:13:30 +08:00
17dac0d273 spi_flash: Fix error unit tests on host
IDF had two defines ESP_PARTITION_TABLE_OFFSET and ESP_PARTITION_TABLE_ADDR. They were the same and equal by 0x8000.
A define ESP_PARTITION_TABLE_ADDR was removed from IDF.
A define ESP_PARTITION_TABLE_OFFSET depends on option CONFIG_PARTITION_TABLE_OFFSET in Kconfig.

Now using only #define ESP_PARTITION_TABLE_OFFSET CONFIG_PARTITION_TABLE_OFFSET
2018-06-19 14:30:25 +05:00
8956f35be5 Merge branch 'test/driver_ledc' into 'master'
test: add ledc test cases

See merge request idf/esp-idf!1782
2018-06-19 15:14:16 +08:00
73f6fb9fe7 Merge branch 'feature/spi_functions_in_iram' into 'master'
feature(spi_master): allow to place functions into IRAM to get higher efficiency

See merge request idf/esp-idf!2538
2018-06-19 07:25:12 +08:00
339d381019 test: components/driver: ledc case 2018-06-19 02:00:42 +08:00
43b6c76bba Merge branch 'feature/expansion_space_for_bootloader' into 'master'
partition_table: Moving to custom offset

See merge request idf/esp-idf!2263
2018-06-18 12:34:53 +08:00
86148a740b Merge branch 'feature/fatfs_without_wl' into 'master'
FATFS support without wear levelling

See merge request idf/esp-idf!2526
2018-06-18 12:26:02 +08:00
1325dff821 Merge branch 'docs/spi_timing_wavedrom' into 'master'
docs(spi_master): fix wavedrom image and comment mistake

See merge request idf/esp-idf!2563
2018-06-18 12:13:31 +08:00
0e71cdc097 Merge branch 'mesh/bugfix_osi' into 'master'
mesh: update mesh libs

See merge request idf/esp-idf!2524
2018-06-17 18:56:52 +08:00
fd7b794e81 FATFS support without wear levelling
This change allows readonly FATFS to be mounted without wear levelling
support. This will provide the customers a simple way to mount FATFS images
generated on host and flashed onto the chip during factory provisioning.
Since NVS encryption is not supported yet and NVS entry size is limited,
the change will provide an easy alternative for securing the provisioning data
by just marking FATFS parition as encrypted.
2018-06-16 16:02:35 +08:00
0dd750af1a mesh: update mesh libs
1. rename example internal_transceiver to internal_communication
2. bugfix
3. Closes https://github.com/espressif/esp-idf/issues/2014
2018-06-15 20:34:49 +08:00
9377575415 docs(spi_master): fix wavedrom image and comment mistake 2018-06-15 17:38:27 +08:00
ac8bd0d637 Merge branch 'bugfix/https_redirect_example_test' into 'master'
esp_http_client example test: Increase timeout when redirecting to HTTPS

See merge request idf/esp-idf!2558
2018-06-15 17:18:26 +08:00
4e243fb1c1 Merge branch 'doc/error_handling' into 'master'
docs: add information on error handling

See merge request idf/esp-idf!2539
2018-06-15 16:55:33 +08:00
efd16673bc docs: add pages about error handling 2018-06-15 15:53:23 +08:00
d9f8311b9d docs: add error codes reference 2018-06-15 15:49:24 +08:00
5e0a3d99e8 Kconfig: split out compiler options, add them to reference 2018-06-15 15:49:23 +08:00
2f7d327978 panic: remove extra newline 2018-06-15 15:49:23 +08:00
6f40b528fa esp32: esp_err_to_name_r: print error code as hex and decimal 2018-06-15 15:49:23 +08:00
6d6cff03fb esp_http_client example test: Increase timeout when redirecting to HTTPS 2018-06-15 16:33:37 +10:00
41095f8466 Merge branch 'bugfix/ulp_doc_insn_time' into 'master'
docs/ulp: fix instruction fetch and execution times

See merge request idf/esp-idf!1979
2018-06-15 11:50:14 +08:00
4056d1e2bf Merge branch 'bugfix/tw23325_replace_WLOGE_to_printf_when_wifi_not_init' into 'master'
WLOGE/WLOGW/WLOGI/WLOGD do anything when wifi is not initialized

See merge request idf/esp-idf!2554
2018-06-15 11:31:02 +08:00
9a55b42f08 Merge branch 'bugfix/tw22828_fix_tcp_bug_when_wifi_disconnect' into 'master'
fix the bug that TCP connections don't abort when IP changed

See merge request idf/esp-idf!2521
2018-06-15 08:03:06 +08:00
9c23b8e596 feature(spi_master): allow to place functions into IRAM to get higher efficiency 2018-06-14 20:22:40 +08:00
b1b1257476 docs/ulp: fix instruction fetch and execution times 2018-06-14 19:42:31 +08:00
bf78d3c4b1 WLOGE, WLOGW, WLOGI, WLOGD do anything when wifi is not initialized 2018-06-14 19:30:04 +08:00
589e8db4dd Merge branch 'bugfix/spi_gpio_deinit' into 'master'
fix(spi): Fix several init/deinit issues of spi pins

See merge request idf/esp-idf!2522
2018-06-14 19:21:34 +08:00
8674a34fd6 Merge branch 'bugfix/ext_wakeup_input_enable' into 'master'
sleep: make sure input enable is set for EXT0/EXT1 wakeup

See merge request idf/esp-idf!2542
2018-06-14 19:03:01 +08:00
b5f4bf922f fix the bug that TCP connections don't abort when IP changed 2018-06-14 16:56:39 +08:00
768f880b04 Merge branch 'bugfix/wifi_correct_modem_sleep_api_description' into 'master'
correct modem sleep API description

See merge request idf/esp-idf!2548
2018-06-14 15:50:08 +08:00
54d882101c Merge branch 'bugfix/fix_two_times_full_calibration' into 'master'
esp32: fix the bug that the first two reboots do full calibration

See merge request idf/esp-idf!2540
2018-06-14 15:49:03 +08:00
0b16ed644e Merge branch 'bugfix/fix_console_performance' into 'master'
idf_monitor: Fix the console performance issue

See merge request idf/esp-idf!2547
2018-06-14 15:09:20 +08:00
c77f84e788 Merge branch 'feature/fs_truncate_support' into 'master'
FATFS truncate support

See merge request idf/esp-idf!2541
2018-06-14 13:56:39 +08:00
59ab2136e8 Merge branch 'doc/kconfig_item' into 'master'
doc: fix the level inconsistent issue in Kconfig document

See merge request idf/esp-idf!2460
2018-06-14 12:51:50 +08:00
45d1c9207c bugfix(spi): resolve the glitch that happens during initialization 2018-06-14 11:29:16 +08:00
77077196fd fix(spi): reset gpios that used by spi when deinited 2018-06-14 11:29:15 +08:00
ebfda40b7c refactor(spi): move pin information into soc folder 2018-06-14 11:29:15 +08:00
ea711f2ee9 vfs, fatfs: Add file truncate for fatfs 2018-06-14 06:37:21 +08:00
e1a6e71486 Merge branch 'test/driver_rmt' into 'master'
test: add rmt test cases

See merge request idf/esp-idf!1797
2018-06-13 22:31:11 +08:00
a4581ff404 Merge branch 'test/driver_timer' into 'master'
test: add driver timer test cases

See merge request idf/esp-idf!1785
2018-06-13 22:28:17 +08:00
5c6473245f test: add driver/rmt test case 2018-06-13 18:10:09 +08:00
6e9070b6d9 correct modem sleep API description 2018-06-13 15:44:59 +08:00
17200f484e Merge branch 'test/driver_sigmadelta' into 'master'
test: add sigmadelta test

See merge request idf/esp-idf!1780
2018-06-13 15:19:35 +08:00
5a33f5150c Merge branch 'test/driver_gpio' into 'master'
test: add gpio test cases

See merge request idf/esp-idf!1778
2018-06-13 15:02:43 +08:00
bb152030a0 Fix the console performance issue
The IDF monitor waits for one second before printing the last
unterminated line. This is necessary for the correct filtering.
However, this causes poor performance, for example, in the case of the
system/console example.

This fix reduces the waiting time which improves the response time of
the console example and doesn't seem to influence the monitor filter.

Closes https://github.com/espressif/esp-idf/issues/2054
2018-06-13 08:05:31 +02:00
8e7dfb230f Merge branch 'bugfix/crosscore_handle_yield_iram' into 'master'
esp32: Move esp_crosscore_isr_handle_yield() to IRAM

See merge request idf/esp-idf!2544
2018-06-13 11:54:04 +08:00
de848a5150 test: driver/sigmadelta test case 2018-06-13 10:15:06 +08:00
0837eb4c2e test: components/driver: timer case 2018-06-13 01:39:07 +00:00
f6442abdeb esp32: Move esp_crosscore_isr_handle_yield() to IRAM
Also adds a hint to inline, as this is only called in one place
it seems like a natural candidate...

Closes https://github.com/espressif/esp-idf/issues/2055
2018-06-13 11:36:15 +10:00
0e501e5edd Merge branch 'bugfix/bt_rfcomm_pr1923' into 'master'
bt: PORT_WriteDataCO: fixed a bug, reduced heap memory allocation

See merge request idf/esp-idf!2511
2018-06-13 08:41:16 +08:00
3a71ae8595 bt: PORT_WriteDataCO: fixed a bug, reduced heap memory allocation
* a missing pointer increment caused error, if available was > 0 after the first iteration of while(available) loop.
* changed memory allocation strategy from large fixed size (RFCOMM_DATA_BUF_SIZE) to just the needed
  size, which will be below MTU

Cherry-picked from https://github.com/espressif/esp-idf/pull/1923/
2018-06-13 09:52:02 +10:00
e33ec5ccf4 Merge branch 'bugfix/btdm_tx_power_value' into 'master'
fix bluetooth(dual-mode) tx power value

See merge request idf/esp-idf!2503
2018-06-13 07:43:13 +08:00
785e9eeb36 Merge branch 'bugfix/esp_timer_set_alarm' into 'master'
esp_timer: remove busy loop in esp_timer_impl_set_alarm

See merge request idf/esp-idf!2436
2018-06-13 07:39:34 +08:00
4359d5985e sleep: make sure input enable is set for EXT0/EXT1 wakeup
Since commit 94250e4, EXT0 wakeup mechanism, when wakeup level was set
to 0, started waking up chip immediately after entering deep sleep.
This failure was triggered in that commit by a change of
RTC_CNTL_MIN_SLP_VAL (i.e. minimum time in sleep mode until wakeup
can happen) from 128 cycles to 2 cycles.

The reason for this behaviour is related to the way input enable (IE)
signal going into an RTC pad is obtained:

    PAD_IE = (SLP_SEL) ? SLP_IE & CHIP_SLEEP : IE,

where SLP_IE, SLP_SEL, and IE are bits of an RTC_IO register related
to the given pad. CHIP_SLEEP is the signal indicating that chip has
entered sleep mode.

The code in prepare_ext{0,1}_wakeup did not enable IE, but did enable
SLP_SEL and SLP_IE. This meant that until CHIP_SLEEP went high, PAD_IE
was 0, hence the input from the pad read 0 even if external signal
was 1. CHIP_SLEEP went high on the 2nd cycle of sleep. So when
RTC_CNTL_MIN_SLP_VAL was set to 2, the input signal from the pad was
latched as 0 at the moment when CHIP_SLEEP went high, causing EXT0
wakeup with level 0 to trigger.

This commit changes the way PAD_IE is enabled: SLP_SEL and SLP_IE are
no longer used, and IE is set to 1. If EXT0 wakeup is used, RTC_IO is
not powered down, so IE signal stays 1 both before CHIP_SLEEP goes
high and after. If EXT1 wakeup is used, RTC_IO may be powered down.
However prepare_ext1_wakeup enables Hold on the pad, locking states
of all the control signals, including IE.

Closes https://github.com/espressif/esp-idf/issues/1931
Closes https://github.com/espressif/esp-idf/issues/2043
2018-06-12 20:25:15 +08:00
294a4bd1f4 fix bluetootm(dual-mode) tx power value 2018-06-12 19:18:47 +08:00
e5717e365f test: add driver/gpio test case 2018-06-12 19:04:30 +08:00
7aa7b35a95 Merge branch 'bugfix/tw22485_dhcp_offer_mtu' into 'master'
modify dhcp offer MTU to 1500

See merge request idf/esp-idf!2461
2018-06-12 16:32:26 +08:00
fc72d53c71 esp32: fix the bug that the first two reboots do full calibration
If the NVS is erased, the first two reboots will do full calibration.
This commit is to fix this issue and only need to do full calibration once.
2018-06-12 15:51:51 +08:00
4eda1b7a25 Merge branch 'bugfix/fixes_for_building_with_amazon_freertos' into 'master'
Fixes for building with amazon freertos

See merge request idf/esp-idf!2523
2018-06-12 14:47:34 +08:00
4e43c920d8 freertos: make task{ENTER/EXIT} macros deprecated for external use
Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2018-06-12 11:19:39 +05:30
eef8d0f7ed Resolve required include header dependencies in component itself
Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2018-06-12 11:19:39 +05:30
636485db8e vfs: change task{ENTER/EXIT}_CRITICAL with port{ENTER/EXIT}_CRITICAL
Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2018-06-12 11:19:39 +05:30
f4d09506ad Merge branch 'feature/unit_test_config_components' into 'master'
unit-test-app: allow building subset of tests for a configuration

See merge request idf/esp-idf!2331
2018-06-12 10:01:42 +08:00
7cc7c8a94c Merge branch 'feature/microecc_1_0' into 'master'
micro-ecc: update to v1.0

See merge request idf/esp-idf!2534
2018-06-11 23:32:32 +08:00
7663782e8d unity: allow test task stack size to be configured 2018-06-11 23:26:56 +08:00
b2f498f7da build: allow EXCLUDE_COMPONENTS to contain quotes
'dequote' macro can’t be used at this point yet, use subst directly.
Also prevent EXCLUDE_COMPONENTS from being passed to bootloader build.
2018-06-11 23:26:56 +08:00
9b1876a458 unit-test-app: allow specifying subset of tests for configuration
For some test configurations, not all tests need to be run. This
change allows adding a comment in the configuration file of the
following form:

unit-test-app makefile will use it to determine which components to
build. If the comment is not present, all components will be built
(TESTS_ALL=1).

Also add test configuration for libsodium. It is a separate test
configuration due to the large binary size generated when building
libsodium tests.
2018-06-11 23:26:55 +08:00
3e64318364 Merge branch 'bugfix/performance_tests' into 'master'
test: Tweaks to reduce variation in CI unit tests

See merge request idf/esp-idf!2529
2018-06-11 23:20:45 +08:00
70eed4c284 Merge branch 'docs/update_eclipse-setup' into 'master'
Docs/update_eclipse-setup

See merge request idf/esp-idf!2528
2018-06-11 23:20:24 +08:00
c0ab42a62a Merge branch 'bugfix/ci_remove_stale_submodules' into 'master'
ci: remove stale submodules after checkout

See merge request idf/esp-idf!2533
2018-06-11 12:26:47 +08:00
84f78110dd Merge branch 'feature/esp_timer_example' into 'master'
examples: add esp_timer example

See merge request idf/esp-idf!2494
2018-06-11 11:44:45 +08:00
9ea947cd8a Merge branch 'bugfix/tw23171_fix_espnow_bug_when_add_node_in_AP_STA_mode' into 'master'
fix espnow bug when add node in AP+STA mode

See merge request idf/esp-idf!2518
2018-06-11 11:39:01 +08:00
b4e836eb97 esp_timer: test for monotonic values of esp_timer_get_timer in CI
Reduce test time by increasing overflow rate, make test more robust.
2018-06-11 02:37:19 +00:00
49d200aaa7 esp_timer: add test for esp_timer_impl_set_alarm
Ref https://github.com/espressif/esp-idf/issues/1891
2018-06-11 02:37:19 +00:00
141e51b468 esp_timer: reduce overflow value in unit tests
This allows testing for race conditions which occur near timer
overflow point more effectively.
2018-06-11 02:37:19 +00:00
125bbf0882 esp_timer: don’t busy loop in esp_timer_impl_set_alarm
Previously the loop in esp_timer_impl_set_alarm was necessary to catch
the case when timer count wraps around (goes from 2^32 - 1 to 0).
Since ALARM_OVERFLOW_VAL was reduced from 2^32 - 1 to 0xefffffff,
this is no longer necessary.

Fixes https://github.com/espressif/esp-idf/issues/1891
2018-06-11 02:37:19 +00:00
03c2678aa6 Merge branch 'bugfix/btdm_fix_include_service_start_handle_error' into 'master'
Component/bt: fix include service start handle error

See merge request idf/esp-idf!2525
2018-06-11 10:36:36 +08:00
7111cdb934 ci: remove stale submodules after checkout
When ‘fetch’ strategy is used, Gitlab removes untracked files before
checking out new revision. However if the new revision doesn’t
include some of the submodules which were present in the old
revision, such submodule directories would not be removed by the
checkout. This extra step ensures that these stale submodules are
removed.
2018-06-10 22:22:26 +08:00
43c779e519 micro-ecc: update to v1.0 2018-06-10 21:20:55 +08:00
3e0ac4db79 partition_table: Expanding the space under the bootloader
Allows you to move the partition table, it gives more space for the bootloader.
Added a new utility - parttool.py. This utility can search for the offset and/or size of the partitions by name and type/subtype. Use for getting APP_OFFSET and PHY_DATA_OFFSET.
The linker(esp32.bootloader.ld) made changes that allow you to write a custom bootloader code more.

TW14125
2018-06-08 18:47:29 +05:00
03d78e7afb Merge branch 'feature/Add_noinit_rtc_noinit_sections' into 'master'
esp32: Add .noinit and .rtc_noinit sections to the linker script

See merge request idf/esp-idf!1996
2018-06-08 16:01:30 +08:00
85e88cd0eb Component/bt: fix include service start handle error 2018-06-08 16:00:34 +08:00
bcd4fb9944 Merge branch 'doc/jtag_startup_command_fix' into 'master'
docs/jtag: use 'flushregs' instead of 'x $a1=0' in gdbinit

See merge request idf/esp-idf!2520
2018-06-08 15:15:29 +08:00
87077a5478 test: Tweaks to reduce variation in CI unit tests
spi test: Prime the flash cache before each test to minimise flash cache misses.

VFS performance test: Increase the number of runs to minimise influence of an isolated bad run.
2018-06-08 14:42:44 +10:00
f47af6185d docs/jtag: use ‘flushregs’ instead of ‘x $a1=0” in gdbinit
The old command caused was incorrect (x is “examine”, not “execute”)
and caused GDB register update only by chance. This replaces it with
“flushregs” command which purpose is exactly that — force GDB to
fetch registers from the remote.
2018-06-08 11:45:46 +08:00
40596fa55a Merge branch 'feature/host_side_storage_components' into 'master'
Runnable FS components on host

See merge request idf/esp-idf!2431
2018-06-08 11:42:37 +08:00
f5f200ee30 Update eclipse-setup.rst
Ref https://github.com/espressif/esp-idf/pull/1990
2018-06-08 11:01:25 +08:00
f9a3368f28 Update eclipse-setup.rst 2018-06-08 11:00:29 +08:00
c99a30a167 Merge branch 'bugfix/wakeup_from_deep_sleep' into 'master'
esp32: Fix not the right time spent in a deep sleep

See merge request idf/esp-idf!2501
2018-06-08 10:40:47 +08:00
c8d3c6a494 Merge branch 'feature/monitor_filter_output' into 'master'
idf_monitor: add support for filtering options

See merge request idf/esp-idf!2486
2018-06-08 08:09:40 +08:00
705d42dd18 Merge branch 'bugfix/get_power_down_flags' into 'master'
sleep_mode/esp32: Fix a condition to keep power domain enabled during sleep mode

See merge request idf/esp-idf!2515
2018-06-07 20:20:13 +08:00
ab538bb9f3 Merge branch 'feat/spi_master_timing' into 'master'
feature(spi_master): fine tune the timing of spi master

See merge request idf/esp-idf!2301
2018-06-07 20:19:06 +08:00
2f5cd89833 examples: add esp_timer example 2018-06-07 11:59:36 +08:00
34401afe39 Merge branch 'feature/ci_host_test_tag' into 'master'
ci: Use new common host_test tag for host-side testing

See merge request idf/esp-idf!2514
2018-06-07 11:59:25 +08:00
1bab62a6d6 modify dhcp offer MTU to 1500 2018-06-07 10:03:26 +08:00
d7d559a489 Merge branch 'doc/api-guides_blufi' into 'master'
Doc/api guides blufi

See merge request idf/esp-idf!2376
2018-06-07 08:54:27 +08:00
4b18a50f89 Merge branch 'bugfix/adjtime_attr' into 'master'
newlib: Remove RTC_DATA_ATTR for adjtime

See merge request idf/esp-idf!2504
2018-06-07 08:25:05 +08:00
70c6f8a803 Merge branch 'bugfix/few_typos_in_docs' into 'master'
Fix few typos in documentation

See merge request idf/esp-idf!2519
2018-06-07 08:24:23 +08:00
dff1a52722 Merge branch 'bugfix/docs_ascii_art_2_blockdiag' into 'master'
Replaced ASCII art drawings with blockdiag drawings

See merge request idf/esp-idf!2243
2018-06-07 08:23:01 +08:00
713141e631 Replaced ASCII art drawings with blockdiag drawings 2018-06-06 23:27:05 +02:00
8caab13faa spi_flash: Enable flash emulation down to ROM function calls 2018-06-06 17:35:30 +00:00
c409666d4e ci: Add spiffs, fatfs host runs to CI
Adds running the fatfs, spiffs sanity check to CI.
2018-06-06 17:35:30 +00:00
e542b7a920 spiffs: Make spiffs runnable on host
Makes spiffs component runnable on host. Depends on the host library build
of flash emulator. Includes a basic sanity test of
mounting a volume, opening a file, writing to the file, reading the file,
closing the file and unmounting volume.
2018-06-06 17:35:30 +00:00
af629b3547 fatfs: Make fatfs runnable on host
Makes fatfs component runnable on host. Depends on the host library build
of wear levelling and flash emulator. Includes a basic sanity test of
mounting a volume, opening a file, writing to the file, reading the file,
closing the file and unmounting volume.
2018-06-06 17:35:30 +00:00
893003357a wl, spi_flash: Make wl API runnable on host
Makes the entirety of the wl API runnable on host. Flash emulator
is separated into spi_flash component directory to be reused by
other storage components.
2018-06-06 17:35:30 +00:00
7e2a3da643 esp32: Fix not the right time spent in a deep sleep
Before entering the deep sleep, the RTC and FRC counters are synchronized. Updating the boot_time.
Added a unit test for this case.
Fixed warnings for MULTIPLE_STAGES

Closes https://github.com/espressif/esp-idf/issues/1840
2018-06-06 18:59:30 +05:00
5a9fc19f38 bt: fix typo in documentation
Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2018-06-06 18:22:32 +05:30
6e48e52478 docs: fix flash_encryption key generation command
Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2018-06-06 18:21:00 +05:30
5fec589c38 fix espnow bug when add node in AP+STA mode 2018-06-06 20:44:19 +08:00
28507920c8 sleep_mode/esp32: Fix a condition to keep power domain enabled during sleep mode 2018-06-06 17:35:21 +05:00
8955db6d29 Merge branch 'bugfix/btdm_fix_no_gatt_server_req_callback_warning' into 'master'
component/bt: fix the issue where no gatt server request callback warning caused…

See merge request idf/esp-idf!2502
2018-06-06 16:29:59 +08:00
a7d62fff18 Merge branch 'bugfix/btdm_fix_memory_leak' into 'master'
Component/bt: add config for gattc cache and fix memory leak

See merge request idf/esp-idf!2429
2018-06-06 16:28:15 +08:00
2ae5b41f56 ci: Use new common host_test tag for host-side testing 2018-06-06 17:20:44 +10:00
939e5693a5 chore(spi): fix the terms of native to iomux 2018-06-06 06:08:39 +00:00
75cdbcefc7 test(spi): add test for SPI timing 2018-06-06 06:08:39 +00:00
208d993de1 test(spi_master): slightly modify the test 2018-06-06 06:08:39 +00:00
5cf7d3768d feat(spi_master): fine tune the timing of SPI 2018-06-06 06:08:39 +00:00
d441dd32ea Merge branch 'bugfix/tw20393_tcp_pcb_purge_assert_v3.1' into 'master'
lwip: fix tcp_pcb_purge assert

See merge request idf/esp-idf!2512
2018-06-06 14:02:35 +08:00
b889305c1b Update blufi.rst 2018-06-06 12:11:57 +08:00
4a25f18f21 Update blufi.rst 2018-06-06 12:05:27 +08:00
ad48c2689f Update blufi.rst 2018-06-06 11:58:46 +08:00
3a15efd3c3 Delete api-guides_blufi.png 2018-06-06 11:46:13 +08:00
6cc95809fb lwip: fix tcp_pcb_purge assert
Remove the assert in tcp_pcb_purge()
2018-06-06 10:25:01 +08:00
0b447f0003 test/fix bug refresh cache after connect 2018-06-06 02:17:06 +00:00
822dac5659 Component/bt: fix memory leak 2018-06-06 02:17:06 +00:00
3ba8461928 doc: fix the level inconsistent issue in Kconfig document 2018-06-05 10:36:18 +00:00
51e42d8e92 idf_monitor: add support for filtering options 2018-06-05 12:23:27 +02:00
b2ff235bd0 Merge branch 'bugfix/github_prs' into 'master'
Merge some small fixes from Github

See merge request idf/esp-idf!2500
2018-06-05 11:51:35 +08:00
f30410113b component/bt: fix the issue where no gatt server request callback warning caused while acting as a GATTC 2018-06-05 02:41:34 +00:00
a8504b9628 docs: eclipse: Reword sentence, copy to Windows Eclipse guide also
Ref https://github.com/espressif/esp-idf/pull/1990
2018-06-05 09:53:59 +10:00
b1189f4f6a newlib: Remove RTC_DATA_ATTR for adjtime
Using RTC_DATA_ATTR in newlib leads to increased power consumption in sleep mode. (RTC SLOW MEM)
2018-06-04 15:59:22 +05:00
8a4c9d7dfb Merge branch 'doc/wifi_channel_state_information' into 'master'
add document of channel state information

See merge request idf/esp-idf!2468
2018-06-04 17:59:05 +08:00
d2d43cd52c Merge branch 'bugfix/btdm_close_sleep_default' into 'master'
Component/btdm: close BT sleep in default config

See merge request idf/esp-idf!2499
2018-06-04 17:51:42 +08:00
736e10749f correct eclipse build command
Merges https://github.com/espressif/esp-idf/pull/2024
2018-06-04 17:19:28 +10:00
5bc1bf4add Fix PartitionDefinition comparison in Python 3
Merges https://github.com/espressif/esp-idf/pull/2018
2018-06-04 17:18:41 +10:00
2a6c35c9af Update eclipse-setup.rst
This is workaround for eclipse indexer problems. When I disable that option, my problems with eclipse and header files are gone.

Merges https://github.com/espressif/esp-idf/pull/1990
2018-06-04 16:47:03 +10:00
18533346b8 Fix compile error using asm
In function 'xPortGetCoreID':
error: expected ')' before ':' token
         :"=r"(id));

Merges https://github.com/espressif/esp-idf/pull/1965
2018-06-04 16:44:35 +10:00
c83c3b64cd Add declarations of private nvs functions (nvs_*) in nvs_flash component to fix C++ -Wmissing-declarations warning
Merges https://github.com/espressif/esp-idf/pull/1956
2018-06-04 16:36:44 +10:00
e5ac96f49a Add declarations of private cxx_guard functions (__cxa_guard_*) in cxx component to fix C++ -Wmissing-declarations warning
Merges https://github.com/espressif/esp-idf/pull/1956
2018-06-04 16:36:44 +10:00
d3b0e0e3fd Unset COMPONENT_ADD_INCLUDEDIRS in cxx component to fix C++ -Wmissing-include-dirs warning
Merges https://github.com/espressif/esp-idf/pull/1956
2018-06-04 16:36:44 +10:00
27d1a5d51e Update index.rst 2018-06-04 14:24:40 +08:00
bf29c7ca57 Update index.rst 2018-06-04 14:24:10 +08:00
4232f69f98 Update blufi.rst 2018-06-04 14:22:04 +08:00
aff4696cc4 Update blufi.rst 2018-06-04 14:21:12 +08:00
0796099c29 test: filter duplicated ble adv events in test 2018-06-04 14:14:40 +08:00
ae6b47a60a Component/bt: close BT sleep in default config 2018-06-04 11:17:27 +08:00
5ed2d79572 Merge branch 'bugfix/mdns_remove_service' into 'master'
fix(mdns): fix the exception when remove one of multiple service

See merge request idf/esp-idf!2497
2018-06-04 08:39:38 +08:00
696d733eb0 fix(mdns): fix the exception when remove one of multiple service 2018-06-03 17:29:49 +08:00
f85be9f909 Merge branch 'bugfix/systemview_menu' into 'master'
fix the dependency of systemview config menu.

See merge request idf/esp-idf!2457
2018-06-01 21:52:16 +08:00
40da291d5d Merge branch 'bugfix/wifi_fix_a_few_bugs' into 'master'
Fix a few WiFi bugs

See merge request idf/esp-idf!2491
2018-06-01 18:37:50 +08:00
cd3ce46b8f Merge branch 'bugfix/a2dp_sink_fluent' into 'master'
component/bt : enlarge the A2DP SINK FRAME QUEUE SIZE to make A2DP more fluent

See merge request idf/esp-idf!2492
2018-06-01 18:34:20 +08:00
21cb7226a2 component/bt : enlarge the A2DP SINK FRAME QUEUE SIZE to make A2DP more fluent 2018-06-01 16:51:23 +08:00
28877e7868 Merge branch 'feature/esp_error_check_prints_error_text' into 'master'
ESP_ERROR_CHECK converts error code to text

See merge request idf/esp-idf!2488
2018-06-01 16:43:37 +08:00
cb9483e844 Merge branch 'bugfix/btdm_a2dp_assert_warn_after_connected' into 'master'
component/bt: Fix bug a2dp assert warn after connected

See merge request idf/esp-idf!2470
2018-06-01 15:54:05 +08:00
7d5ef3c765 add document of channel state information 2018-06-01 15:45:00 +08:00
5081714c53 Fix a few WiFi bugs
1. fix rx state parse if CSI is enabled.

2. make smartconfig channel timer thread safe.

3. fix sniffer filter mask to keep the same as IDF.
2018-06-01 14:25:43 +08:00
c04a4a8527 component/bt: Fix bug a2dp assert warn after connected 2018-06-01 10:57:22 +08:00
50252ca794 Merge branch 'bugfix/btdm_malloc_fail_lead_to_exception' into 'master'
component/bt: Fix malloc fail lead to crash

See merge request idf/esp-idf!2485
2018-06-01 10:36:36 +08:00
5ff8732950 Merge branch 'bugfix/tw22958_fix_some_bugs_introduced_by_wifi_os_adapter' into 'master'
esp32/wpa_supplicant: fix some bugs introduced by wifi os adapter

See merge request idf/esp-idf!2475
2018-06-01 10:34:04 +08:00
07acbb5664 ESP_ERROR_CHECK converts error code to text
If CONFIG_ESP_ERR_TO_NAME_LOOKUP is enabled, ESP_ERROR_CHECK
prints error message in addition to the error code.
2018-05-31 12:53:37 +02:00
a3a0b01c1b Merge branch 'bugfix/btdm_fix_ble_throughput_demo_fail' into 'master'
Component/bt: fix throughput_demo_fail

See merge request idf/esp-idf!2467
2018-05-31 18:53:01 +08:00
4afa5d0d29 esp32/wpa_supplicant: fix some bugs introduced by wifi os adapter
1. Fix the WiFi/BT coexist bug
2. Fix WPA2 enterprise example crash bug
3. Add size and version check for crypto type struct
4. Add MD5 check for crypto type header file
2018-05-31 17:09:40 +08:00
eeff0ca1fa Merge branch 'feature/xtensa_cleanup' into 'master'
xtensa: remove unused header files

See merge request idf/esp-idf!2471
2018-05-31 14:59:11 +08:00
4467b34da2 component/bt: Fix malloc fail lead to crash 2018-05-31 13:31:27 +08:00
834c056234 xtensa: remove unused header files 2018-05-31 02:21:36 +00:00
e764a3e671 Merge branch 'bugfix/btdm_add_makefile_for_coex_demo' into 'master'
Component/bt: add makefile for coex demo

See merge request idf/esp-idf!2477
2018-05-31 09:00:18 +08:00
212b786119 Component/bt: fix throughput_demo_fail 2018-05-30 19:58:31 +08:00
9eade73539 Merge branch 'bugfix/tw19630_fix_espnow_watchdog' into 'master'
fix espnow watchdog when modify it's config parameter

See merge request idf/esp-idf!2480
2018-05-30 19:53:52 +08:00
fbbf4b0c03 Merge branch 'bugfix/btdm_fix_start_adv' into 'master'
Component/bt: fix start adv complete event state error in dual core

See merge request idf/esp-idf!2432
2018-05-30 19:41:39 +08:00
26db749257 Component/bt: add makefile for coex demo 2018-05-30 19:33:52 +08:00
9bd38c0d86 fix espnow watchdog when modify 2018-05-30 17:19:46 +08:00
c8e848b0ff Component/bt: fix start adv 2018-05-30 17:10:51 +08:00
1b1a179f20 Merge branch 'bugfix/tw20805_fix_wpa2_enterprise_issue' into 'master'
wpa_supplicant: fix wpa2 enterprise PEAP connection issue

See merge request idf/esp-idf!2474
2018-05-30 15:51:48 +08:00
6c89ab9839 wpa_supplicant: fix wpa2 enterprise PEAP connection issue
Closes https://github.com/espressif/esp-idf/issues/1887
2018-05-30 13:48:29 +08:00
2ee00cc3a6 fix the dependency of systemview config menu. 2018-05-28 12:51:01 +08:00
8b884c4deb Update blufi.rst 2018-05-25 15:09:34 +08:00
1001083b1b Update blufi.rst 2018-05-25 15:09:34 +08:00
ad3af2cfc1 Update blufi.rst 2018-05-25 15:09:34 +08:00
02d4168d68 Update blufi.rst 2018-05-25 15:09:34 +08:00
27e4bea699 Update blufi.rst 2018-05-25 15:09:34 +08:00
d0bf4a0e23 Update blufi.rst 2018-05-25 15:09:33 +08:00
5a3f351207 Update blufi.rst 2018-05-25 15:09:33 +08:00
27d22a7574 Update index.rst 2018-05-25 15:09:33 +08:00
0ea39a72b0 Update blufi.rst 2018-05-25 15:09:33 +08:00
b443075133 Update index.rst 2018-05-25 15:09:33 +08:00
7db69b4da3 Update blufi.rst 2018-05-25 15:09:33 +08:00
241048c9f9 Update blufi.rst 2018-05-25 15:09:33 +08:00
75021e376a Upload api-guides_blufi.png 2018-05-25 15:09:33 +08:00
dd0bbebd4a Upload blufi.rst 2018-05-25 15:09:33 +08:00
799771b3fa Upload blufi.rst 2018-05-25 15:09:33 +08:00
44b1bc0ab9 esp32: Add .noinit and .rtc_noinit sections to the linker script
Added .rtc_noinit and .noinit section definitions into linker file /esp32/ld/esp32.common.ld.
The macro __NOINIT_ATTR, RTC_NOINIT_ATTR declared in esp32/esp_attr.h file.
Added unit test file to test added behavior for noinit variables and its attributes.
Added documentation changes for new added attributes.
Make some corrections after code review:
The linker file has been corrected to place noinit section before bss_start to make it safer.
Documentation file has been modified to clarify reset behavior of allocated data .
Corrected typos in test_noinit.c and removed assertion of noinit variable to avoid possible issues with ROM boot loader memory allocation.
The linker file has been corrected to place noinit section before bss_start to make it safer.
Documentation file has been modified to clarify reset behavior of allocated data .
Corrected typos in test_noinit.c and removed assertion of noinit variable to avoid possible issues with ROM boot loader memory allocation.
Update test_noinit.c file to address RTCWDT_RTC_RESET reset reason instead of POWERON_RESET.
Test optimized to pass automated unit testing.
esp32: Add .noinit and .rtc_noinit sections to the linker script
Update of general-notes.rst documentation to fomat examples as code and attributes as identifiers.
Test test_noinit.c corrected to pass automated testing (support ofTEST_CASE_MULTIPLE_STAGES())

https://ezredmine.espressif.cn:8765/issues/15878
2018-05-16 17:33:37 +05:00
1082 changed files with 31376 additions and 23152 deletions

File diff suppressed because it is too large Load Diff

28
Kconfig
View File

@ -71,6 +71,7 @@ choice OPTIMIZATION_ASSERTION_LEVEL
default OPTIMIZATION_ASSERTIONS_ENABLED
help
Assertions can be:
- Enabled. Failure will print verbose assertion details. This is the default.
- Set to "silent" to save code size (failed assertions will abort() but user
@ -129,17 +130,20 @@ choice STACK_CHECK_MODE
The guards are initialized when a function is entered and then checked when the function exits.
If a guard check fails, program is halted. Protection has the following modes:
- In NORMAL mode (GCC flag: -fstack-protector) only functions that call
alloca, and functions with buffers larger than 8 bytes are protected.
- STRONG mode (GCC flag: -fstack-protector-strong) is like NORMAL, but
includes additional functions to be protected -- those that have
local array definitions, or have references to local frame addresses.
- In OVERALL mode (GCC flag: -fstack-protector-all) all functions are
protected.
- In NORMAL mode (GCC flag: -fstack-protector) only functions that call alloca,
and functions with buffers larger than 8 bytes are protected.
- STRONG mode (GCC flag: -fstack-protector-strong) is like NORMAL, but includes
additional functions to be protected -- those that have local array definitions,
or have references to local frame addresses.
- In OVERALL mode (GCC flag: -fstack-protector-all) all functions are protected.
Modes have the following impact on code performance and coverage:
- performance: NORMAL > STRONG > OVERALL
- coverage: NORMAL < STRONG < OVERALL
- performance: NORMAL > STRONG > OVERALL
- coverage: NORMAL < STRONG < OVERALL
config STACK_CHECK_NONE
@ -164,13 +168,13 @@ config WARN_WRITE_STRINGS
help
Adds -Wwrite-strings flag for the C/C++ compilers.
For C, this gives string constants the type "const char[]" so that
copying the address of one into a non-"const" "char *" pointer
For C, this gives string constants the type ``const char[]`` so that
copying the address of one into a non-const ``char *`` pointer
produces a warning. This warning helps to find at compile time code
that tries to write into a string constant.
For C++, this warns about the deprecated conversion from string
literals to "char *".
literals to ``char *``.
endmenu # Compiler Options

View File

@ -1,28 +1,33 @@
# Espressif IoT Development Framework
[![alt text](https://readthedocs.org/projects/docs/badge/?version=latest "Documentation Status")](https://esp-idf.readthedocs.io/en/latest/?badge=latest)
[![alt text](https://readthedocs.org/projects/docs/badge/?version=latest "Documentation Status")](https://docs.espressif.com/projects/esp-idf/en/latest/?badge=latest)
ESP-IDF is the official development framework for the [ESP32](https://espressif.com/en/products/hardware/esp32/overview) chip.
# Developing With the ESP-IDF
# Developing With ESP-IDF
## Setting Up ESP-IDF
See setup guides for detailed instructions to set up the ESP-IDF:
* [Windows Setup Guide](https://esp-idf.readthedocs.io/en/latest/get-started/windows-setup.html)
* [Mac OS Setup Guide](https://esp-idf.readthedocs.io/en/latest/get-started/macos-setup.html)
* [Linux Setup Guide](https://esp-idf.readthedocs.io/en/latest/get-started/linux-setup.html)
* [Getting Started Guide for the stable ESP-IDF version](https://docs.espressif.com/projects/esp-idf/en/stable/get-started/)
* [Getting Started Guide for the latest (master branch) ESP-IDF version](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/)
## Finding a Project
As well as the [esp-idf-template](https://github.com/espressif/esp-idf-template) project mentioned in the setup guide, ESP-IDF comes with some example projects in the [examples](examples) directory.
As well as the [esp-idf-template](https://github.com/espressif/esp-idf-template) project mentioned in Getting Started, ESP-IDF comes with some example projects in the [examples](examples) directory.
Once you've found the project you want to work with, change to its directory and you can configure and build it.
To start your own project based on an example, copy the example project directory outside of the ESP-IDF directory.
# Quick Reference
See the Getting Started guide links above for a detailed setup guide. This is a quick reference for common commands when working with ESP-IDF projects:
## Configuring the Project
`idf.py menuconfig`
`make menuconfig`
* Opens a text-based configuration menu for the project.
* Use up & down arrow keys to navigate the menu.
@ -36,41 +41,54 @@ Once done configuring, press Escape multiple times to exit and say "Yes" to save
## Compiling the Project
`idf.py build`
`make -j4 all`
... will compile app, bootloader and generate a partition table based on the config.
NOTE: The `-j4` option causes `make` to run 4 parallel jobs. This is much faster than the default single job. The recommended number to pass to this option is `-j(number of CPUs + 1)`.
## Flashing the Project
When the build finishes, it will print a command line to use esptool.py to flash the chip. However you can also do this automatically by running:
`idf.py flash`
`make -j4 flash`
This will flash the entire project (app, bootloader and partition table) to a new chip. The settings for serial port flashing can be configured with `idf.py menuconfig`.
This will flash the entire project (app, bootloader and partition table) to a new chip. The settings for serial port flashing can be configured with `make menuconfig`.
You don't need to run `idf.py build` before running `idf.py flash`, `idf.py flash` will automatically rebuild anything which needs it.
You don't need to run `make all` before running `make flash`, `make flash` will automatically rebuild anything which needs it.
## Viewing Serial Output
The `idf.py monitor` target uses the [idf_monitor tool](https://esp-idf.readthedocs.io/en/latest/get-started/idf-monitor.html) to display serial output from the ESP32. idf_monitor also has a range of features to decode crash output and interact with the device. [Check the documentation page for details](https://esp-idf.readthedocs.io/en/latest/get-started/idf-monitor.html).
The `make monitor` target uses the [idf_monitor tool](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/idf-monitor.html) to display serial output from the ESP32. idf_monitor also has a range of features to decode crash output and interact with the device. [Check the documentation page for details](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/idf-monitor.html).
Exit the monitor by typing Ctrl-].
To flash and monitor output in one pass, you can run:
To build, flash and monitor output in one pass, you can run:
`idf.py flash monitor`
`make -j4 flash monitor`
## Compiling & Flashing Just the App
## Compiling & Flashing Only the App
After the initial flash, you may just want to build and flash just your app, not the bootloader and partition table:
* `idf.py app` - build just the app.
* `idf.py app-flash` - flash just the app.
* `make app` - build just the app.
* `make app-flash` - flash just the app.
`idf.py app-flash` will automatically rebuild the app if it needs it.
`make app-flash` will automatically rebuild the app if any source files have changed.
(In normal development there's no downside to reflashing the bootloader and partition table each time, if they haven't changed.)
## Parallel Builds
ESP-IDF supports compiling multiple files in parallel, so all of the above commands can be run as `make -jN` where `N` is the number of parallel make processes to run (generally N should be equal to the number of CPU cores in your system, plus one.)
Multiple make functions can be combined into one. For example: to build the app & bootloader using 5 jobs in parallel, then flash everything, and then display serial output from the ESP32 run:
```
make -j5 flash monitor
```
## The Partition Table
Once you've compiled your project, the "build" directory will contain a binary file with a name like "my_app.bin". This is an ESP32 image binary that can be loaded by the bootloader.
@ -79,29 +97,29 @@ A single ESP32's flash can contain multiple apps, as well as many different kind
Each entry in the partition table has a name (label), type (app, data, or something else), subtype and the offset in flash where the partition is loaded.
The simplest way to use the partition table is to `idf.py menuconfig` and choose one of the simple predefined partition tables:
The simplest way to use the partition table is to `make menuconfig` and choose one of the simple predefined partition tables:
* "Single factory app, no OTA"
* "Factory app, two OTA definitions"
In both cases the factory app is flashed at offset 0x10000. If you `idf.py partition_table` then it will print a summary of the partition table.
In both cases the factory app is flashed at offset 0x10000. If you `make partition_table` then it will print a summary of the partition table.
For more details about partition tables and how to create custom variations, view the [`docs/en/api-guides/partition-tables.rst`](docs/en/api-guides/partition-tables.rst) file.
## Erasing Flash
The `idf.py flash` target does not erase the entire flash contents. However it is sometimes useful to set the device back to a totally erased state, particularly when making partition table changes or OTA app updates. To erase the entire flash, run `idf.py erase_flash`.
The `make flash` target does not erase the entire flash contents. However it is sometimes useful to set the device back to a totally erased state, particularly when making partition table changes or OTA app updates. To erase the entire flash, run `make erase_flash`.
This can be combined with other targets, ie `idf.py erase_flash flash` will erase everything and then re-flash the new app, bootloader and partition table.
This can be combined with other targets, ie `make erase_flash flash` will erase everything and then re-flash the new app, bootloader and partition table.
# Resources
* Documentation for the latest version: https://esp-idf.readthedocs.io/. This documentation is built from the [docs directory](docs) of this repository.
* Documentation for the latest version: https://docs.espressif.com/projects/esp-idf/. This documentation is built from the [docs directory](docs) of this repository.
* The [esp32.com forum](https://esp32.com/) is a place to ask questions and find community resources.
* [Check the Issues section on github](https://github.com/espressif/esp-idf/issues) if you find a bug or have a feature request. Please check existing Issues before opening a new one.
* If you're interested in contributing to ESP-IDF, please check the [Contributions Guide](https://esp-idf.readthedocs.io/en/latest/contribute/index.html).
* If you're interested in contributing to ESP-IDF, please check the [Contributions Guide](https://docs.espressif.com/projects/esp-idf/en/latest/contribute/index.html).

View File

@ -1,4 +1,7 @@
set(COMPONENT_SRCDIRS "." "gcov")
set(COMPONENT_SRCS "app_trace.c"
"app_trace_util.c"
"host_file_io.c"
"gcov/gcov_rtio.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")
if(CONFIG_SYSVIEW_ENABLE)
@ -7,11 +10,10 @@ if(CONFIG_SYSVIEW_ENABLE)
sys_view/SEGGER
sys_view/Sample/OS)
list(APPEND COMPONENT_SRCDIRS
"sys_view/SEGGER"
"sys_view/Sample/OS"
"sys_view/Sample/Config"
"sys_view/esp32")
list(APPEND COMPONENT_SRCS "sys_view/SEGGER/SEGGER_SYSVIEW.c"
"sys_view/Sample/Config/SEGGER_SYSVIEW_Config_FreeRTOS.c"
"sys_view/Sample/OS/SEGGER_SYSVIEW_FreeRTOS.c"
"sys_view/esp32/SEGGER_RTT_esp32.c")
endif()
set(COMPONENT_REQUIRES)
@ -22,3 +24,5 @@ register_component()
# disable --coverage for this component, as it is used as transport
# for gcov
component_compile_options("-fno-profile-arcs" "-fno-test-coverage")
target_link_libraries(app_trace gcov)

View File

@ -56,6 +56,7 @@ config ESP32_APPTRACE_PENDING_DATA_SIZE_MAX
events will be discarded when main HW buffer is full.
menu "FreeRTOS SystemView Tracing"
depends on ESP32_APPTRACE_ENABLE
config SYSVIEW_ENABLE
bool "SystemView Tracing Enable"
depends on ESP32_APPTRACE_ENABLE

View File

@ -20,7 +20,6 @@
#include "rom/ets_sys.h"
#include "esp_app_trace.h"
#define LOG_LOCAL_LEVEL ESP_LOG_ERROR
#include "esp_log.h"
const static char *TAG = "segger_rtt";
@ -125,7 +124,7 @@ unsigned SEGGER_RTT_WriteSkipNoLock(unsigned BufferIndex, const void* pBuffer, u
uint8_t event_id = *pbuf;
if (NumBytes > SYSVIEW_EVENTS_BUF_SZ) {
ESP_LOGE(TAG, "Too large event %d bytes!", NumBytes);
ESP_LOGE(TAG, "Too large event %u bytes!", NumBytes);
return 0;
}
if (xPortGetCoreID()) { // dual core specific code

View File

@ -1,4 +1,4 @@
set(COMPONENT_SRCDIRS ".")
set(COMPONENT_SRCS "esp_ota_ops.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_REQUIRES spi_flash)

View File

@ -241,14 +241,6 @@ esp_err_t esp_ota_end(esp_ota_handle_t handle)
goto cleanup;
}
#ifdef CONFIG_SECURE_BOOT_ENABLED
ret = esp_secure_boot_verify_signature(it->part->address, data.image_len);
if (ret != ESP_OK) {
ret = ESP_ERR_OTA_VALIDATE_FAILED;
goto cleanup;
}
#endif
cleanup:
LIST_REMOVE(it, entries);
free(it);
@ -300,7 +292,7 @@ static esp_err_t esp_rewrite_ota_data(esp_partition_subtype_t subtype)
uint16_t ota_app_count = 0;
uint32_t i = 0;
uint32_t seq;
static spi_flash_mmap_memory_t ota_data_map;
spi_flash_mmap_handle_t ota_data_map;
const void *result = NULL;
find_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_OTA, NULL);
@ -385,7 +377,7 @@ esp_err_t esp_ota_set_boot_partition(const esp_partition_t *partition)
return ESP_ERR_OTA_VALIDATE_FAILED;
}
#ifdef CONFIG_SECURE_BOOT_ENABLED
#ifdef CONFIG_SECURE_SIGNED_ON_UPDATE
esp_err_t ret = esp_secure_boot_verify_signature(partition->address, data.image_len);
if (ret != ESP_OK) {
return ESP_ERR_OTA_VALIDATE_FAILED;
@ -446,7 +438,7 @@ const esp_partition_t *esp_ota_get_boot_partition(void)
{
esp_err_t ret;
const esp_partition_t *find_partition = NULL;
static spi_flash_mmap_memory_t ota_data_map;
spi_flash_mmap_handle_t ota_data_map;
const void *result = NULL;
uint16_t ota_app_count = 0;
find_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_OTA, NULL);
@ -502,9 +494,18 @@ const esp_partition_t *esp_ota_get_boot_partition(void)
const esp_partition_t* esp_ota_get_running_partition(void)
{
static const esp_partition_t *curr_partition = NULL;
/*
* Currently running partition is unlikely to change across reset cycle,
* so it can be cached here, and avoid lookup on every flash write operation.
*/
if (curr_partition != NULL) {
return curr_partition;
}
/* Find the flash address of this exact function. By definition that is part
of the currently running firmware. Then find the enclosing partition. */
size_t phys_offs = spi_flash_cache2phys(esp_ota_get_running_partition);
assert (phys_offs != SPI_FLASH_CACHE2PHYS_FAIL); /* indicates cache2phys lookup is buggy */
@ -518,6 +519,7 @@ const esp_partition_t* esp_ota_get_running_partition(void)
const esp_partition_t *p = esp_partition_get(it);
if (p->address <= phys_offs && p->address + p->size > phys_offs) {
esp_partition_iterator_release(it);
curr_partition = p;
return p;
}
it = esp_partition_next(it);

View File

@ -1,6 +1,21 @@
if(CONFIG_AWS_IOT_SDK)
set(COMPONENT_ADD_INCLUDEDIRS "include aws-iot-device-sdk-embedded-C/include")
set(COMPONENT_SRCDIRS "aws-iot-device-sdk-embedded-C/src port")
set(aws_sdk_src aws-iot-device-sdk-embedded-C/src)
set(COMPONENT_SRCS "${aws_sdk_src}/aws_iot_json_utils.c"
"${aws_sdk_src}/aws_iot_mqtt_client.c"
"${aws_sdk_src}/aws_iot_mqtt_client_common_internal.c"
"${aws_sdk_src}/aws_iot_mqtt_client_connect.c"
"${aws_sdk_src}/aws_iot_mqtt_client_publish.c"
"${aws_sdk_src}/aws_iot_mqtt_client_subscribe.c"
"${aws_sdk_src}/aws_iot_mqtt_client_unsubscribe.c"
"${aws_sdk_src}/aws_iot_mqtt_client_yield.c"
"${aws_sdk_src}/aws_iot_shadow.c"
"${aws_sdk_src}/aws_iot_shadow_actions.c"
"${aws_sdk_src}/aws_iot_shadow_json.c"
"${aws_sdk_src}/aws_iot_shadow_records.c"
"port/network_mbedtls_wrapper.c"
"port/threads_freertos.c"
"port/timer.c")
else()
message(STATUS "Building empty aws_iot component due to configuration")
endif()

View File

@ -132,9 +132,59 @@ endmenu # Bootloader
menu "Security features"
# These three are the actual options to check in code,
# selected by the displayed options
config SECURE_SIGNED_ON_BOOT
bool
default y
depends on SECURE_BOOT_ENABLED || SECURE_SIGNED_ON_BOOT_NO_SECURE_BOOT
config SECURE_SIGNED_ON_UPDATE
bool
default y
depends on SECURE_BOOT_ENABLED || SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
config SECURE_SIGNED_APPS
bool
default y
depends on SECURE_SIGNED_ON_BOOT || SECURE_SIGNED_ON_UPDATE
config SECURE_SIGNED_APPS_NO_SECURE_BOOT
bool "Require signed app images"
default n
depends on !SECURE_BOOT_ENABLED
help
Require apps to be signed to verify their integrity.
This option uses the same app signature scheme as hardware secure boot, but unlike hardware secure boot it does not prevent the bootloader from being physically updated. This means that the device can be secured against remote network access, but not physical access. Compared to using hardware Secure Boot this option is much simpler to implement.
config SECURE_SIGNED_ON_BOOT_NO_SECURE_BOOT
bool "Bootloader verifies app signatures"
default n
depends on SECURE_SIGNED_APPS_NO_SECURE_BOOT
help
If this option is set, the bootloader will be compiled with code to verify that an app is signed before booting it.
If hardware secure boot is enabled, this option is always enabled and cannot be disabled.
If hardware secure boot is not enabled, this option doesn't add significant security by itself so most users will want to leave it disabled.
config SECURE_SIGNED_ON_UPDATE_NO_SECURE_BOOT
bool "Verify app signature on update"
default y
depends on SECURE_SIGNED_APPS_NO_SECURE_BOOT
help
If this option is set, any OTA updated apps will have the signature verified before being considered valid.
When enabled, the signature is automatically checked whenever the esp_ota_ops.h APIs are used for OTA updates,
or esp_image_format.h APIs are used to verify apps.
If hardware secure boot is enabled, this option is always enabled and cannot be disabled.
If hardware secure boot is not enabled, this option still adds significant security against network-based attackers by preventing spoofing of OTA updates.
config SECURE_BOOT_ENABLED
bool "Enable secure boot in bootloader (READ DOCS FIRST)"
default N
bool "Enable hardware secure boot in bootloader (READ DOCS FIRST)"
default n
help
Build a bootloader which enables secure boot on first boot.
@ -142,7 +192,7 @@ config SECURE_BOOT_ENABLED
When enabling secure boot, JTAG and ROM BASIC Interpreter are permanently disabled by default.
Refer to https://esp-idf.readthedocs.io/en/latest/security/secure-boot.html before enabling.
Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
choice SECURE_BOOTLOADER_MODE
bool "Secure bootloader mode"
@ -169,12 +219,12 @@ endchoice
config SECURE_BOOT_BUILD_SIGNED_BINARIES
bool "Sign binaries during build"
depends on SECURE_BOOT_ENABLED
depends on SECURE_SIGNED_APPS
default y
help
Once secure boot is enabled, bootloader will only boot if partition table and app image are signed.
Once secure boot or signed app requirement is enabled, app images are required to be signed.
If enabled, these binary files are signed as part of the build process. The file named in "Secure boot private signing key" will be used to sign the image.
If enabled (default), these binary files are signed as part of the build process. The file named in "Secure boot private signing key" will be used to sign the image.
If disabled, unsigned app/partition data will be built. They must be signed manually using espsecure.py (for example, on a remote signing server.)
@ -183,7 +233,7 @@ config SECURE_BOOT_SIGNING_KEY
depends on SECURE_BOOT_BUILD_SIGNED_BINARIES
default secure_boot_signing_key.pem
help
Path to the key file used to sign partition tables and app images for secure boot. Once secure boot is enabled, bootloader will only boot if partition table and app image are signed.
Path to the key file used to sign app images.
Key file is an ECDSA private key (NIST256p curve) in PEM format.
@ -196,17 +246,38 @@ config SECURE_BOOT_SIGNING_KEY
config SECURE_BOOT_VERIFICATION_KEY
string "Secure boot public signature verification key"
depends on SECURE_BOOT_ENABLED && !SECURE_BOOT_BUILD_SIGNED_BINARIES
depends on SECURE_SIGNED_APPS && !SECURE_BOOT_BUILD_SIGNED_BINARIES
default signature_verification_key.bin
help
Path to a public key file used to verify signed images. This key is compiled into the bootloader,
and may also be used to verify signatures on OTA images after download.
Path to a public key file used to verify signed images. This key is compiled into the bootloader and/or app,
to verify app images.
Key file is in raw binary format, and can be extracted from a
PEM formatted private key using the espsecure.py
extract_public_key command.
Refer to https://esp-idf.readthedocs.io/en/latest/security/secure-boot.html before enabling.
Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
choice SECURE_BOOTLOADER_KEY_ENCODING
bool "Hardware Key Encoding"
depends on SECURE_BOOTLOADER_REFLASHABLE
default SECURE_BOOTLOADER_NO_ENCODING
help
In reflashable secure bootloader mode, a hardware key is derived from the signing key (with SHA-256) and can be written to efuse
with espefuse.py.
Normally this is a 256-bit key, but if 3/4 Coding Scheme is used on the device then the efuse key is truncated to 192 bits.
This configuration item doesn't change any firmware code, it only changes the size of key binary which is generated at build time.
config SECURE_BOOTLOADER_KEY_ENCODING_256BIT
bool "No encoding (256 bit key)"
config SECURE_BOOTLOADER_KEY_ENCODING_192BIT
bool "3/4 encoding (192 bit key)"
endchoice
config SECURE_BOOT_INSECURE
bool "Allow potentially insecure options"
@ -217,7 +288,7 @@ config SECURE_BOOT_INSECURE
Only enable these options if you are very sure.
Refer to https://esp-idf.readthedocs.io/en/latest/security/secure-boot.html before enabling.
Refer to https://docs.espressif.com/projects/esp-idf/en/latest/security/secure-boot.html before enabling.
config FLASH_ENCRYPTION_ENABLED
bool "Enable flash encryption on boot (READ DOCS FIRST)"
@ -228,7 +299,7 @@ config FLASH_ENCRYPTION_ENABLED
Note: After first boot, the system will be permanently encrypted. Re-flashing an encrypted
system is complicated and not always possible.
Read https://esp-idf.readthedocs.io/en/latest/security/flash-encryption.html before enabling.
Read https://docs.espressif.com/projects/esp-idf/en/latest/security/flash-encryption.html before enabling.
config FLASH_ENCRYPTION_INSECURE
bool "Allow potentially insecure options"
@ -275,6 +346,13 @@ config SECURE_BOOT_ALLOW_JTAG
Only set this option in testing environments.
config SECURE_BOOT_ALLOW_SHORT_APP_PARTITION
bool "Allow app partition length not 64KB aligned"
depends on SECURE_BOOT_INSECURE
help
If not set (default), app partition size must be a multiple of 64KB. App images are padded to 64KB length, and the bootloader checks any trailing bytes after the signature (before the next 64KB boundary) have not been written. This is because flash cache maps entire 64KB pages into the address space. This prevents an attacker from appending unverified data after the app image in the flash, causing it to be mapped into the address space.
Setting this option allows the app partition length to be unaligned, and disables padding of the app image to this length. It is generally not recommended to set this option, unless you have a legacy partitioning scheme which doesn't support 64KB aligned partition lengths.
config FLASH_ENCRYPTION_UART_BOOTLOADER_ALLOW_ENCRYPT
bool "Leave UART bootloader encryption enabled"

View File

@ -32,7 +32,8 @@ BOOTLOADER_MAKE= +\
V=$(V) \
BUILD_DIR_BASE=$(BOOTLOADER_BUILD_DIR) \
TEST_COMPONENTS= \
TESTS_ALL=
TESTS_ALL= \
EXCLUDE_COMPONENTS=
.PHONY: bootloader-clean bootloader-flash bootloader-list-components bootloader $(BOOTLOADER_BIN)
@ -77,12 +78,18 @@ else ifdef CONFIG_SECURE_BOOTLOADER_REFLASHABLE
# Reflashable secure bootloader
# generates a digest binary (bootloader + digest)
ifdef CONFIG_SECURE_BOOTLOADER_KEY_ENCODING_192BIT
KEY_DIGEST_LEN=192
else
KEY_DIGEST_LEN=256
endif
BOOTLOADER_DIGEST_BIN := $(BOOTLOADER_BUILD_DIR)/bootloader-reflash-digest.bin
SECURE_BOOTLOADER_KEY := $(BOOTLOADER_BUILD_DIR)/secure-bootloader-key.bin
SECURE_BOOTLOADER_KEY := $(BOOTLOADER_BUILD_DIR)/secure-bootloader-key-$(KEY_DIGEST_LEN).bin
ifdef CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES
$(SECURE_BOOTLOADER_KEY): $(SECURE_BOOT_SIGNING_KEY)
$(ESPSECUREPY) digest_private_key -k $< $@
$(ESPSECUREPY) digest_private_key --keylen $(KEY_DIGEST_LEN) -k $< $@
else
$(SECURE_BOOTLOADER_KEY):
@echo "No pre-generated key for a reflashable secure bootloader is available, due to signing configuration."
@ -106,7 +113,7 @@ bootloader: $(BOOTLOADER_DIGEST_BIN)
$(BOOTLOADER_DIGEST_BIN): $(BOOTLOADER_BIN) $(SECURE_BOOTLOADER_KEY)
@echo "DIGEST $(notdir $@)"
$(Q) $(ESPSECUREPY) digest_secure_bootloader -k $(SECURE_BOOTLOADER_KEY) -o $@ $<
$(ESPSECUREPY) digest_secure_bootloader -k $(SECURE_BOOTLOADER_KEY) -o $@ $<
else # CONFIG_SECURE_BOOT_ENABLED && !CONFIG_SECURE_BOOTLOADER_REFLASHABLE && !CONFIG_SECURE_BOOTLOADER_ONE_TIME_FLASH
bootloader:

View File

@ -10,14 +10,12 @@ if(NOT IDF_PATH)
"in by the parent build process.")
endif()
set(COMPONENTS bootloader esptool_py esp32 soc bootloader_support log spi_flash micro-ecc soc)
set(COMPONENTS bootloader esptool_py esp32 partition_table soc bootloader_support log spi_flash micro-ecc soc main)
set(BOOTLOADER_BUILD 1)
add_definitions(-DBOOTLOADER_BUILD=1)
set(COMPONENT_REQUIRES_COMMON log esp32 soc)
set(MAIN_SRCS main/bootloader_start.c)
include("${IDF_PATH}/tools/cmake/project.cmake")
project(bootloader)

View File

@ -0,0 +1,4 @@
set(COMPONENT_SRCS "bootloader_start.c")
set(COMPONENT_ADD_INCLUDEDIRS "")
set(COMPONENT_REQUIRES "bootloader bootloader_support")
register_component()

View File

@ -27,7 +27,7 @@
static const char* TAG = "boot";
static esp_err_t select_image (esp_image_metadata_t *image_data);
static int select_partition_number (bootloader_state_t *bs);
static int selected_boot_partition(const bootloader_state_t *bs);
/*
* We arrive here after the ROM bootloader finished loading this second stage bootloader from flash.
@ -37,41 +37,32 @@ static int selected_boot_partition(const bootloader_state_t *bs);
void call_start_cpu0()
{
// 1. Hardware initialization
if(bootloader_init() != ESP_OK){
if (bootloader_init() != ESP_OK) {
return;
}
// 2. Select image to boot
esp_image_metadata_t image_data;
if(select_image(&image_data) != ESP_OK){
return;
}
// 3. Loading the selected image
bootloader_utility_load_image(&image_data);
}
// Selects image to boot
static esp_err_t select_image (esp_image_metadata_t *image_data)
{
// 1. Load partition table
// 2. Select the number of boot partition
bootloader_state_t bs = { 0 };
if (!bootloader_utility_load_partition_table(&bs)) {
ESP_LOGE(TAG, "load partition table error!");
return ESP_FAIL;
}
// 2. Select boot partition
int boot_index = selected_boot_partition(&bs);
if(boot_index == INVALID_INDEX) {
return ESP_FAIL; // Unrecoverable failure (not due to corrupt ota data or bad partition contents)
int boot_index = select_partition_number(&bs);
if (boot_index == INVALID_INDEX) {
return;
}
// 3. Load the app image for booting
if (!bootloader_utility_load_boot_image(&bs, boot_index, image_data)) {
return ESP_FAIL;
bootloader_utility_load_boot_image(&bs, boot_index);
}
// Select the number of boot partition
static int select_partition_number (bootloader_state_t *bs)
{
// 1. Load partition table
if (!bootloader_utility_load_partition_table(bs)) {
ESP_LOGE(TAG, "load partition table error!");
return INVALID_INDEX;
}
return ESP_OK;
// 2. Select the number of boot partition
return selected_boot_partition(bs);
}
/*

View File

@ -8,12 +8,14 @@ Linker file used to link the bootloader.
The main purpose is to make sure the bootloader can load into main memory
without overwriting itself.
*/
MEMORY
{
/* I/O */
dport0_seg (RW) : org = 0x3FF00000, len = 0x10
/* IRAM POOL1, used for APP CPU cache. We can abuse it in bootloader because APP CPU is still held in reset, the main app enables APP CPU cache */
iram_seg (RWX) : org = 0x40078000, len = 0x8000
/* IRAM POOL1, used for APP CPU cache. Bootloader runs from here during the final stage of loading the app because APP CPU is still held in reset, the main app enables APP CPU cache */
iram_loader_seg (RWX) : org = 0x40078000, len = 0x8000 /* 32KB, APP CPU cache */
iram_seg (RWX) : org = 0x40080000, len = 0x10000 /* 64KB, IRAM */
/* 64k at the end of DRAM, after ROM bootloader stack */
dram_seg (RW) : org = 0x3FFF0000, len = 0x10000
}
@ -24,7 +26,36 @@ ENTRY(call_start_cpu0);
SECTIONS
{
.iram1.text :
.iram_loader.text :
{
. = ALIGN (16);
_loader_text_start = ABSOLUTE(.);
*(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
*(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
*liblog.a:(.literal .text .literal.* .text.*)
*libgcc.a:(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_common.o(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:efuse.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:secure_boot.*(.literal .text .literal.* .text.*)
*libbootloader_support.a:secure_boot_signatures.*(.literal .text .literal.* .text.*)
*libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
*libspi_flash.a:*.*(.literal .text .literal.* .text.*)
*libsoc.a:rtc_wdt.*(.literal .text .literal.* .text.*)
*(.fini.literal)
*(.fini)
*(.gnu.version)
_loader_text_end = ABSOLUTE(.);
} > iram_loader_seg
.iram.text :
{
. = ALIGN (16);
*(.entry.text)
@ -88,13 +119,13 @@ SECTIONS
. = (. + 3) & ~ 3;
/* C++ constructor and destructor tables, properly ordered: */
__init_array_start = ABSOLUTE(.);
KEEP (*crtbegin.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP (*crtbegin.*(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend.*) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
__init_array_end = ABSOLUTE(.);
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors))
KEEP (*crtbegin.*(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
/* C++ exception handlers table: */
@ -121,7 +152,7 @@ SECTIONS
_stext = .;
_text_start = ABSOLUTE(.);
*(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
*(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
*(.iram .iram.*) /* catch stray IRAM_ATTR */
*(.fini.literal)
*(.fini)
*(.gnu.version)

View File

@ -1,4 +1,17 @@
set(COMPONENT_SRCDIRS "src")
set(COMPONENT_SRCS "src/bootloader_clock.c"
"src/bootloader_common.c"
"src/bootloader_flash.c"
"src/bootloader_init.c"
"src/bootloader_random.c"
"src/bootloader_sha.c"
"src/bootloader_utility.c"
"src/efuse.c"
"src/esp_image_format.c"
"src/flash_encrypt.c"
"src/flash_partitions.c"
"src/flash_qio_mode.c"
"src/secure_boot.c"
"src/secure_boot_signatures.c")
if(${BOOTLOADER_BUILD})
set(COMPONENT_ADD_INCLUDEDIRS "include include_priv")

View File

@ -12,7 +12,7 @@ COMPONENT_SRCDIRS := src
#
# Secure boot signing key support
#
ifdef CONFIG_SECURE_BOOT_ENABLED
ifdef CONFIG_SECURE_SIGNED_APPS
# this path is created relative to the component build directory
SECURE_BOOT_VERIFICATION_KEY := $(abspath signature_verification_key.bin)

View File

@ -0,0 +1,34 @@
// Copyright 2018 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once
#include <stddef.h>
/**
* @brief Check if half-open intervals overlap
*
* @param start1 interval 1 start
* @param end1 interval 1 end
* @param start2 interval 2 start
* @param end2 interval 2 end
* @return true iff [start1; end1) overlaps [start2; end2)
*/
static inline bool bootloader_util_regions_overlap(
const intptr_t start1, const intptr_t end1,
const intptr_t start2, const intptr_t end2)
{
return (end1 > start2 && end2 > start1) ||
!(end1 <= start2 || end2 <= start1);
}

View File

@ -15,6 +15,7 @@
#define _ESP_EFUSE_H
#include "soc/efuse_reg.h"
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
@ -58,6 +59,38 @@ void esp_efuse_reset(void);
*/
void esp_efuse_disable_basic_rom_console(void);
/* @brief Encode one or more sets of 6 byte sequences into
* 8 bytes suitable for 3/4 Coding Scheme.
*
* This function is only useful if the CODING_SCHEME efuse
* is set to value 1 for 3/4 Coding Scheme.
*
* @param[in] in_bytes Pointer to a sequence of bytes to encode for 3/4 Coding Scheme. Must have length in_bytes_len. After being written to hardware, these bytes will read back as little-endian words.
* @param[out] out_words Pointer to array of words suitable for writing to efuse write registers. Array must contain 2 words (8 bytes) for every 6 bytes in in_bytes_len. Can be a pointer to efuse write registers.
* @param in_bytes_len. Length of array pointed to by in_bytes, in bytes. Must be a multiple of 6.
*
* @return ESP_ERR_INVALID_ARG if either pointer is null or in_bytes_len is not a multiple of 6. ESP_OK otherwise.
*/
esp_err_t esp_efuse_apply_34_encoding(const uint8_t *in_bytes, uint32_t *out_words, size_t in_bytes_len);
/* @brief Write random data to efuse key block write registers
*
* @note Caller is responsible for ensuring efuse
* block is empty and not write protected, before calling.
*
* @note Behaviour depends on coding scheme: a 256-bit key is
* generated and written for Coding Scheme "None", a 192-bit key
* is generated, extended to 256-bits by the Coding Scheme,
* and then writtten for 3/4 Coding Scheme.
*
* @note This function does not burn the new values, caller should
* call esp_efuse_burn_new_values() when ready to do this.
*
* @param blk_wdata0_reg Address of the first data write register
* in the block
*/
void esp_efuse_write_random_key(uint32_t blk_wdata0_reg);
#ifdef __cplusplus
}
#endif

View File

@ -17,17 +17,17 @@
#include "esp_err.h"
#include "esp_flash_data_types.h"
#include <stdbool.h>
#include "sdkconfig.h"
/* Pre-partition table fixed flash offsets */
#define ESP_BOOTLOADER_DIGEST_OFFSET 0x0
#define ESP_BOOTLOADER_OFFSET 0x1000 /* Offset of bootloader image. Has matching value in bootloader KConfig.projbuild file. */
#define ESP_BOOTLOADER_SIZE (ESP_PARTITION_TABLE_OFFSET - ESP_BOOTLOADER_OFFSET)
#define ESP_PARTITION_TABLE_OFFSET 0x8000 /* Offset of partition table. Has matching value in partition_table Kconfig.projbuild file. */
#define ESP_PARTITION_TABLE_OFFSET CONFIG_PARTITION_TABLE_OFFSET /* Offset of partition table. Backwards-compatible name.*/
#define ESP_PARTITION_TABLE_MAX_LEN 0xC00 /* Maximum length of partition table data */
#define ESP_PARTITION_TABLE_MAX_ENTRIES (ESP_PARTITION_TABLE_MAX_LEN / sizeof(esp_partition_info_t)) /* Maximum length of partition table data, including terminating entry */
/* @brief Verify the partition table (does not include verifying secure boot cryptographic signature)
/* @brief Verify the partition table
*
* @param partition_table Pointer to at least ESP_PARTITION_TABLE_MAX_ENTRIES of potential partition table data. (ESP_PARTITION_TABLE_MAX_LEN bytes.)
* @param log_errors Log errors if the partition table is invalid.
@ -35,6 +35,13 @@
*
* @return ESP_OK on success, ESP_ERR_INVALID_STATE if partition table is not valid.
*/
esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions);
esp_err_t esp_partition_table_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions);
/* This function is included for compatibility with the ESP-IDF v3.x API */
inline static __attribute__((deprecated)) esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions)
{
return esp_partition_table_verify(partition_table, log_errors, num_partitions);
}
#endif

View File

@ -81,6 +81,8 @@ typedef struct {
_Static_assert(sizeof(esp_image_header_t) == 24, "binary image header should be 24 bytes");
#define ESP_IMAGE_HASH_LEN 32 /* Length of the appended SHA-256 digest */
/* Header of binary image segment */
typedef struct {
uint32_t load_addr;
@ -142,6 +144,16 @@ esp_err_t esp_image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *
*/
esp_err_t esp_image_verify_bootloader(uint32_t *length);
/**
* @brief Verify the bootloader image.
*
* @param[out] Metadata for the image. Only valid if result is ESP_OK.
*
* @return As per esp_image_load_metadata().
*/
esp_err_t esp_image_verify_bootloader_data(esp_image_metadata_t *data);
typedef struct {
uint32_t drom_addr;
uint32_t drom_load_addr;

View File

@ -17,6 +17,14 @@
#include <esp_err.h>
#include "soc/efuse_reg.h"
#include "sdkconfig.h"
#ifdef CONFIG_SECURE_BOOT_ENABLED
#if !defined(CONFIG_SECURE_SIGNED_ON_BOOT) || !defined(CONFIG_SECURE_SIGNED_ON_UPDATE) || !defined(CONFIG_SECURE_SIGNED_APPS)
#error "internal sdkconfig error, secure boot should always enable all signature options"
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -40,25 +40,15 @@ bool bootloader_utility_load_partition_table(bootloader_state_t* bs);
int bootloader_utility_get_selected_boot_partition(const bootloader_state_t *bs);
/**
* @brief Load the app image for booting.
* @brief Load the selected partition and start application.
*
* Start from partition 'start_index', if not bootable then work backwards to FACTORY_INDEX
* (ie try any OTA slots in descending order and then the factory partition).
* If still nothing, start from 'start_index + 1' and work up to highest numbered OTA partition.
* If still nothing, try TEST_APP_INDEX.
* Everything this function calls must be located in the iram_loader_seg segment.
*
* @param[in] bs Bootloader state structure.
* @param[in] start_index The index from which the search for images begins.
* @param[out] result The image found.
* @return Returns true on success, false if there's no bootable app in the partition table.
*/
bool bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_index, esp_image_metadata_t *result);
/**
* @brief Loading the selected image.
*
* Copy loaded segments to RAM, set up caches for mapped segments, and start application.
*
* @param[in] data Structure to hold on-flash image metadata.
*/
void bootloader_utility_load_image(const esp_image_metadata_t* image_data);
__attribute__((noreturn)) void bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_index);

View File

@ -26,6 +26,7 @@
#include "esp_flash_partitions.h"
#include "bootloader_flash.h"
#include "bootloader_common.h"
#include "soc/gpio_periph.h"
static const char* TAG = "boot_comm";
@ -42,6 +43,9 @@ bool bootloader_common_ota_select_valid(const esp_ota_select_entry_t *s)
esp_comm_gpio_hold_t bootloader_common_check_long_hold_gpio(uint32_t num_pin, uint32_t delay_sec)
{
gpio_pad_select_gpio(num_pin);
if (GPIO_PIN_MUX_REG[num_pin]) {
PIN_INPUT_ENABLE(GPIO_PIN_MUX_REG[num_pin]);
}
gpio_pad_pullup(num_pin);
uint32_t tm_start = esp_log_early_timestamp();
if (GPIO_INPUT_GET(num_pin) == 1) {
@ -96,26 +100,14 @@ bool bootloader_common_erase_part_type_data(const char *list_erase, bool ota_dat
int num_partitions;
bool ret = true;
#ifdef CONFIG_SECURE_BOOT_ENABLED
if (esp_secure_boot_enabled()) {
ESP_LOGI(TAG, "Verifying partition table signature...");
err = esp_secure_boot_verify_signature(ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_MAX_LEN);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to verify partition table signature.");
return false;
}
ESP_LOGD(TAG, "Partition table signature verified");
}
#endif
partitions = bootloader_mmap(ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_MAX_LEN);
partitions = bootloader_mmap(ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
if (!partitions) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_MAX_LEN);
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
return false;
}
ESP_LOGD(TAG, "mapped partition table 0x%x at 0x%x", ESP_PARTITION_TABLE_ADDR, (intptr_t)partitions);
ESP_LOGD(TAG, "mapped partition table 0x%x at 0x%x", ESP_PARTITION_TABLE_OFFSET, (intptr_t)partitions);
err = esp_partition_table_basic_verify(partitions, true, &num_partitions);
err = esp_partition_table_verify(partitions, true, &num_partitions);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to verify partition table");
ret = false;

View File

@ -28,7 +28,10 @@ bootloader_sha256_handle_t bootloader_sha256_start()
return NULL;
}
mbedtls_sha256_init(ctx);
assert(mbedtls_sha256_starts_ret(ctx, false) == 0);
int ret = mbedtls_sha256_starts_ret(ctx, false);
if (ret != 0) {
return NULL;
}
return ctx;
}
@ -36,7 +39,8 @@ void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data,
{
assert(handle != NULL);
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)handle;
assert(mbedtls_sha256_update_ret(ctx, data, data_len) == 0);
int ret = mbedtls_sha256_update_ret(ctx, data, data_len);
assert(ret == 0);
}
void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest)
@ -44,7 +48,8 @@ void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest
assert(handle != NULL);
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)handle;
if (digest != NULL) {
assert(mbedtls_sha256_finish_ret(ctx, digest) == 0);
int ret = mbedtls_sha256_finish_ret(ctx, digest);
assert(ret == 0);
}
mbedtls_sha256_free(ctx);
free(handle);

View File

@ -55,6 +55,7 @@ static const char* TAG = "boot";
/* Reduce literal size for some generic string literals */
#define MAP_ERR_MSG "Image contains multiple %s segments. Only the last one will be mapped."
static void load_image(const esp_image_metadata_t* image_data);
static void unpack_load_app(const esp_image_metadata_t *data);
static void set_cache_and_start_app(uint32_t drom_addr,
uint32_t drom_load_addr,
@ -71,26 +72,14 @@ bool bootloader_utility_load_partition_table(bootloader_state_t* bs)
esp_err_t err;
int num_partitions;
#ifdef CONFIG_SECURE_BOOT_ENABLED
if(esp_secure_boot_enabled()) {
ESP_LOGI(TAG, "Verifying partition table signature...");
err = esp_secure_boot_verify_signature(ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_MAX_LEN);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to verify partition table signature.");
return false;
}
ESP_LOGD(TAG, "Partition table signature verified");
}
#endif
partitions = bootloader_mmap(ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_MAX_LEN);
partitions = bootloader_mmap(ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
if (!partitions) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", ESP_PARTITION_TABLE_ADDR, ESP_PARTITION_TABLE_MAX_LEN);
return false;
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", ESP_PARTITION_TABLE_OFFSET, ESP_PARTITION_TABLE_MAX_LEN);
return false;
}
ESP_LOGD(TAG, "mapped partition table 0x%x at 0x%x", ESP_PARTITION_TABLE_ADDR, (intptr_t)partitions);
ESP_LOGD(TAG, "mapped partition table 0x%x at 0x%x", ESP_PARTITION_TABLE_OFFSET, (intptr_t)partitions);
err = esp_partition_table_basic_verify(partitions, true, &num_partitions);
err = esp_partition_table_verify(partitions, true, &num_partitions);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to verify partition table");
return false;
@ -142,6 +131,9 @@ bool bootloader_utility_load_partition_table(bootloader_state_t* bs)
case PART_SUBTYPE_DATA_WIFI:
partition_usage = "WiFi data";
break;
case PART_SUBTYPE_DATA_NVS_KEYS:
partition_usage = "NVS keys";
break;
default:
partition_usage = "Unknown data";
break;
@ -221,8 +213,8 @@ int bootloader_utility_get_selected_boot_partition(const bootloader_state_t *bs)
bootloader_munmap(ota_select_map);
ESP_LOGD(TAG, "OTA sequence values A 0x%08x B 0x%08x", sa.ota_seq, sb.ota_seq);
if(sa.ota_seq == UINT32_MAX && sb.ota_seq == UINT32_MAX) {
ESP_LOGD(TAG, "OTA sequence numbers both empty (all-0xFF)");
if ((sa.ota_seq == UINT32_MAX && sb.ota_seq == UINT32_MAX) || (bs->app_count == 0)) {
ESP_LOGD(TAG, "OTA sequence numbers both empty (all-0xFF) or partition table does not have bootable ota_apps (app_count=%d)", bs->app_count);
if (bs->factory.offset != 0) {
ESP_LOGI(TAG, "Defaulting to factory image");
return FACTORY_INDEX;
@ -287,18 +279,21 @@ static bool try_load_partition(const esp_partition_pos_t *partition, esp_image_m
#define TRY_LOG_FORMAT "Trying partition index %d offs 0x%x size 0x%x"
bool bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_index, esp_image_metadata_t *result)
void bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_index)
{
int index = start_index;
esp_partition_pos_t part;
esp_image_metadata_t image_data;
if(start_index == TEST_APP_INDEX) {
if (try_load_partition(&bs->test, result)) {
return true;
if (try_load_partition(&bs->test, &image_data)) {
load_image(&image_data);
} else {
ESP_LOGE(TAG, "No bootable test partition in the partition table");
return false;
return;
}
}
/* work backwards from start_index, down to the factory app */
for(index = start_index; index >= FACTORY_INDEX; index--) {
part = index_to_partition(bs, index);
@ -306,8 +301,8 @@ bool bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_
continue;
}
ESP_LOGD(TAG, TRY_LOG_FORMAT, index, part.offset, part.size);
if (try_load_partition(&part, result)) {
return true;
if (try_load_partition(&part, &image_data)) {
load_image(&image_data);
}
log_invalid_app_partition(index);
}
@ -319,23 +314,23 @@ bool bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_
continue;
}
ESP_LOGD(TAG, TRY_LOG_FORMAT, index, part.offset, part.size);
if (try_load_partition(&part, result)) {
return true;
if (try_load_partition(&part, &image_data)) {
load_image(&image_data);
}
log_invalid_app_partition(index);
}
if (try_load_partition(&bs->test, result)) {
if (try_load_partition(&bs->test, &image_data)) {
ESP_LOGW(TAG, "Falling back to test app as only bootable partition");
return true;
load_image(&image_data);
}
ESP_LOGE(TAG, "No bootable app partitions in the partition table");
bzero(result, sizeof(esp_image_metadata_t));
return false;
bzero(&image_data, sizeof(esp_image_metadata_t));
}
void bootloader_utility_load_image(const esp_image_metadata_t* image_data)
// Copy loaded segments to RAM, set up caches for mapped segments, and start application.
static void load_image(const esp_image_metadata_t* image_data)
{
#if defined(CONFIG_SECURE_BOOT_ENABLED) || defined(CONFIG_FLASH_ENCRYPTION_ENABLED)
esp_err_t err;
@ -463,7 +458,7 @@ static void set_cache_and_start_app(
// Application will need to do Cache_Flush(1) and Cache_Read_Enable(1)
ESP_LOGD(TAG, "start: 0x%08x", entry_addr);
typedef void (*entry_t)(void);
typedef void (*entry_t)(void) __attribute__((noreturn));
entry_t entry = ((entry_t) entry_addr);
// TODO: we have used quite a bit of stack at this point.

View File

@ -13,6 +13,8 @@
// limitations under the License.
#include "esp_efuse.h"
#include "esp_log.h"
#include <string.h>
#include "bootloader_random.h"
#define EFUSE_CONF_WRITE 0x5A5A /* efuse_pgm_op_ena, force no rd/wr disable */
#define EFUSE_CONF_READ 0x5AA5 /* efuse_read_op_ena, release force */
@ -58,3 +60,55 @@ void esp_efuse_disable_basic_rom_console(void)
esp_efuse_burn_new_values();
}
}
esp_err_t esp_efuse_apply_34_encoding(const uint8_t *in_bytes, uint32_t *out_words, size_t in_bytes_len)
{
if (in_bytes == NULL || out_words == NULL || in_bytes_len % 6 != 0) {
return ESP_ERR_INVALID_ARG;
}
while (in_bytes_len > 0) {
uint8_t out[8];
uint8_t xor = 0;
uint8_t mul = 0;
for (int i = 0; i < 6; i++) {
xor ^= in_bytes[i];
mul += (i + 1) * __builtin_popcount(in_bytes[i]);
}
memcpy(out, in_bytes, 6); // Data bytes
out[6] = xor;
out[7] = mul;
memcpy(out_words, out, 8);
in_bytes_len -= 6;
in_bytes += 6;
out_words += 2;
}
return ESP_OK;
}
void esp_efuse_write_random_key(uint32_t blk_wdata0_reg)
{
uint32_t buf[8];
uint8_t raw[24];
uint32_t coding_scheme = REG_READ(EFUSE_BLK0_RDATA6_REG) & EFUSE_CODING_SCHEME_M;
if (coding_scheme == EFUSE_CODING_SCHEME_VAL_NONE) {
bootloader_fill_random(buf, sizeof(buf));
} else { // 3/4 Coding Scheme
bootloader_fill_random(raw, sizeof(raw));
esp_err_t r = esp_efuse_apply_34_encoding(raw, buf, sizeof(raw));
assert(r == ESP_OK);
}
ESP_LOGV(TAG, "Writing random values to address 0x%08x", blk_wdata0_reg);
for (int i = 0; i < 8; i++) {
ESP_LOGV(TAG, "EFUSE_BLKx_WDATA%d_REG = 0x%08x", i, buf[i]);
REG_WRITE(blk_wdata0_reg + 4*i, buf[i]);
}
bzero(buf, sizeof(buf));
bzero(raw, sizeof(raw));
}

View File

@ -23,10 +23,25 @@
#include <bootloader_flash.h>
#include <bootloader_random.h>
#include <bootloader_sha.h>
#include "bootloader_util.h"
/* Checking signatures as part of verifying images is necessary:
- Always if secure boot is enabled
- Differently in bootloader and/or app, depending on kconfig
*/
#ifdef BOOTLOADER_BUILD
#ifdef CONFIG_SECURE_SIGNED_ON_BOOT
#define SECURE_BOOT_CHECK_SIGNATURE
#endif
#else /* !BOOTLOADER_BUILD */
#ifdef CONFIG_SECURE_SIGNED_ON_UPDATE
#define SECURE_BOOT_CHECK_SIGNATURE
#endif
#endif
static const char *TAG = "esp_image";
#define HASH_LEN 32 /* SHA-256 digest length */
#define HASH_LEN ESP_IMAGE_HASH_LEN
#define SIXTEEN_MB 0x1000000
#define ESP_ROM_CHECKSUM_INITIAL 0xEF
@ -42,6 +57,10 @@ static const char *TAG = "esp_image";
(Means loaded code isn't executable until after the secure boot check.)
*/
static uint32_t ram_obfs_value[2];
/* Range of IRAM used by the loader, defined in ld script */
extern int _loader_text_start;
extern int _loader_text_end;
#endif
/* Return true if load_addr is an address the bootloader should load into */
@ -107,7 +126,7 @@ esp_err_t esp_image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *
}
// Calculate SHA-256 of image if secure boot is on, or if image has a hash appended
#ifdef CONFIG_SECURE_BOOT_ENABLED
#ifdef SECURE_BOOT_CHECK_SIGNATURE
if (1) {
#else
if (data->image.hash_appended) {
@ -174,7 +193,7 @@ goto err;
rewritten the header - rely on esptool.py having verified the bootloader at flashing time, instead.
*/
if (!is_bootloader) {
#ifdef CONFIG_SECURE_BOOT_ENABLED
#ifdef SECURE_BOOT_CHECK_SIGNATURE
// secure boot images have a signature appended
err = verify_secure_boot_signature(sha_handle, data);
#else
@ -182,7 +201,7 @@ goto err;
if (sha_handle != NULL && !esp_cpu_in_ocd_debug_mode()) {
err = verify_simple_hash(sha_handle, data);
}
#endif // CONFIG_SECURE_BOOT_ENABLED
#endif // SECURE_BOOT_CHECK_SIGNATURE
} else { // is_bootloader
// bootloader may still have a sha256 digest handle open
if (sha_handle != NULL) {
@ -287,18 +306,41 @@ static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segme
(do_load)?"load":(is_mapping)?"map":"");
}
#ifdef BOOTLOADER_BUILD
/* Before loading segment, check it doesn't clobber bootloader RAM. */
if (do_load) {
/* Before loading segment, check it doesn't clobber bootloader RAM... */
uint32_t end_addr = load_addr + data_len;
if (end_addr < 0x40000000) {
const intptr_t load_end = load_addr + data_len;
if (load_end <= (intptr_t) SOC_DIRAM_DRAM_HIGH) {
/* Writing to DRAM */
intptr_t sp = (intptr_t)get_sp();
if (end_addr > sp - STACK_LOAD_HEADROOM) {
ESP_LOGE(TAG, "Segment %d end address 0x%08x too high (bootloader stack 0x%08x liimit 0x%08x)",
index, end_addr, sp, sp - STACK_LOAD_HEADROOM);
if (load_end > sp - STACK_LOAD_HEADROOM) {
/* Bootloader .data/.rodata/.bss is above the stack, so this
* also checks that we aren't overwriting these segments.
*
* TODO: This assumes specific arrangement of sections we have
* in the ESP32. Rewrite this in a generic way to support other
* layouts.
*/
ESP_LOGE(TAG, "Segment %d end address 0x%08x too high (bootloader stack 0x%08x limit 0x%08x)",
index, load_end, sp, sp - STACK_LOAD_HEADROOM);
return ESP_ERR_IMAGE_INVALID;
}
} else {
/* Writing to IRAM */
const intptr_t loader_iram_start = (intptr_t) &_loader_text_start;
const intptr_t loader_iram_end = (intptr_t) &_loader_text_end;
if (bootloader_util_regions_overlap(loader_iram_start, loader_iram_end,
load_addr, load_end)) {
ESP_LOGE(TAG, "Segment %d (0x%08x-0x%08x) overlaps bootloader IRAM (0x%08x-0x%08x)",
index, load_addr, load_end, loader_iram_start, loader_iram_end);
return ESP_ERR_IMAGE_INVALID;
}
}
}
#endif // BOOTLOADER_BUILD
#ifndef BOOTLOADER_BUILD
uint32_t free_page_count = spi_flash_mmap_get_free_pages(SPI_FLASH_MMAP_DATA);
ESP_LOGD(TAG, "free data page_count 0x%08x",free_page_count);
@ -442,19 +484,28 @@ static bool should_load(uint32_t load_addr)
esp_err_t esp_image_verify_bootloader(uint32_t *length)
{
esp_image_metadata_t data;
const esp_partition_pos_t bootloader_part = {
.offset = ESP_BOOTLOADER_OFFSET,
.size = ESP_PARTITION_TABLE_OFFSET - ESP_BOOTLOADER_OFFSET,
};
esp_err_t err = esp_image_load(ESP_IMAGE_VERIFY,
&bootloader_part,
&data);
esp_err_t err = esp_image_verify_bootloader_data(&data);
if (length != NULL) {
*length = (err == ESP_OK) ? data.image_len : 0;
}
return err;
}
esp_err_t esp_image_verify_bootloader_data(esp_image_metadata_t *data)
{
if (data == NULL) {
return ESP_ERR_INVALID_ARG;
}
const esp_partition_pos_t bootloader_part = {
.offset = ESP_BOOTLOADER_OFFSET,
.size = ESP_PARTITION_TABLE_OFFSET - ESP_BOOTLOADER_OFFSET,
};
return esp_image_load(ESP_IMAGE_VERIFY,
&bootloader_part,
data);
}
static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t checksum_word, esp_image_metadata_t *data)
{
uint32_t unpadded_length = data->image_len;
@ -492,6 +543,8 @@ static esp_err_t verify_secure_boot_signature(bootloader_sha256_handle_t sha_han
{
uint8_t image_hash[HASH_LEN] = { 0 };
ESP_LOGI(TAG, "Verifying image signature...");
// For secure boot, we calculate the signature hash over the whole file, which includes any "simple" hash
// appended to the image for corruption detection
if (data->image.hash_appended) {

View File

@ -15,7 +15,6 @@
#include <strings.h>
#include "bootloader_flash.h"
#include "bootloader_random.h"
#include "esp_image_format.h"
#include "esp_flash_encrypt.h"
#include "esp_flash_partitions.h"
@ -62,6 +61,12 @@ esp_err_t esp_flash_encrypt_check_and_update(void)
static esp_err_t initialise_flash_encryption(void)
{
uint32_t coding_scheme = REG_GET_FIELD(EFUSE_BLK0_RDATA6_REG, EFUSE_CODING_SCHEME);
if (coding_scheme != EFUSE_CODING_SCHEME_VAL_NONE && coding_scheme != EFUSE_CODING_SCHEME_VAL_34) {
ESP_LOGE(TAG, "Unknown/unsupported CODING_SCHEME value 0x%x", coding_scheme);
return ESP_ERR_NOT_SUPPORTED;
}
/* Before first flash encryption pass, need to initialise key & crypto config */
/* Generate key */
@ -79,13 +84,7 @@ static esp_err_t initialise_flash_encryption(void)
&& REG_READ(EFUSE_BLK1_RDATA6_REG) == 0
&& REG_READ(EFUSE_BLK1_RDATA7_REG) == 0) {
ESP_LOGI(TAG, "Generating new flash encryption key...");
uint32_t buf[8];
bootloader_fill_random(buf, sizeof(buf));
for (int i = 0; i < 8; i++) {
ESP_LOGV(TAG, "EFUSE_BLK1_WDATA%d_REG = 0x%08x", i, buf[i]);
REG_WRITE(EFUSE_BLK1_WDATA0_REG + 4*i, buf[i]);
}
bzero(buf, sizeof(buf));
esp_efuse_write_random_key(EFUSE_BLK1_WDATA0_REG);
esp_efuse_burn_new_values();
ESP_LOGI(TAG, "Read & write protecting new key...");
@ -254,7 +253,7 @@ static esp_err_t encrypt_and_load_partition_table(esp_partition_info_t *partitio
ESP_LOGE(TAG, "Failed to read partition table data");
return err;
}
if (esp_partition_table_basic_verify(partition_table, false, num_partitions) == ESP_OK) {
if (esp_partition_table_verify(partition_table, false, num_partitions) == ESP_OK) {
ESP_LOGD(TAG, "partition table is plaintext. Encrypting...");
esp_err_t err = esp_flash_encrypt_region(ESP_PARTITION_TABLE_OFFSET,
FLASH_SECTOR_SIZE);
@ -285,7 +284,8 @@ static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partit
&partition->pos,
&data_ignored);
should_encrypt = (err == ESP_OK);
} else if (partition->type == PART_TYPE_DATA && partition->subtype == PART_SUBTYPE_DATA_OTA) {
} else if ((partition->type == PART_TYPE_DATA && partition->subtype == PART_SUBTYPE_DATA_OTA)
|| (partition->type == PART_TYPE_DATA && partition->subtype == PART_SUBTYPE_DATA_NVS_KEYS)) {
/* check if we have ota data partition and the partition should be encrypted unconditionally */
should_encrypt = true;
}

View File

@ -20,7 +20,7 @@
static const char *TAG = "flash_parts";
esp_err_t esp_partition_table_basic_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions)
esp_err_t esp_partition_table_verify(const esp_partition_info_t *partition_table, bool log_errors, int *num_partitions)
{
int md5_found = 0;
int num_parts;

View File

@ -35,6 +35,7 @@
#define CMD_WRDI 0x04
#define CMD_RDSR 0x05
#define CMD_RDSR2 0x35 /* Not all SPI flash uses this command */
#define CMD_OTPEN 0x3A /* Enable OTP mode, not all SPI flash uses this command */
static const char *TAG = "qio_mode";
@ -65,6 +66,11 @@ static void write_status_8b_wrsr2(unsigned new_status);
/* Write 16 bit status using WRSR */
static void write_status_16b_wrsr(unsigned new_status);
/* Read 8 bit status of XM25QU64A */
static unsigned read_status_8b_xmc25qu64a();
/* Write 8 bit status of XM25QU64A */
static void write_status_8b_xmc25qu64a(unsigned new_status);
#define ESP32_D2WD_WP_GPIO 7 /* ESP32-D2WD has this GPIO wired to WP pin of flash */
#ifndef CONFIG_BOOTLOADER_SPI_WP_PIN // Set in menuconfig if SPI flasher config is set to a quad mode
@ -84,11 +90,12 @@ static void write_status_16b_wrsr(unsigned new_status);
Searching of this table stops when the first match is found.
*/
const static qio_info_t chip_data[] = {
/* Manufacturer, mfg_id, flash_id, id mask, Read Status, Write Status, QIE Bit */
{ "MXIC", 0xC2, 0x2000, 0xFF00, read_status_8b_rdsr, write_status_8b_wrsr, 6 },
{ "ISSI", 0x9D, 0x4000, 0xCF00, read_status_8b_rdsr, write_status_8b_wrsr, 6 }, /* IDs 0x40xx, 0x70xx */
{ "WinBond", 0xEF, 0x4000, 0xFF00, read_status_16b_rdsr_rdsr2, write_status_16b_wrsr, 9 },
{ "GD", 0xC8, 0x6000, 0xFF00, read_status_16b_rdsr_rdsr2, write_status_16b_wrsr, 9 },
/* Manufacturer, mfg_id, flash_id, id mask, Read Status, Write Status, QIE Bit */
{ "MXIC", 0xC2, 0x2000, 0xFF00, read_status_8b_rdsr, write_status_8b_wrsr, 6 },
{ "ISSI", 0x9D, 0x4000, 0xCF00, read_status_8b_rdsr, write_status_8b_wrsr, 6 }, /* IDs 0x40xx, 0x70xx */
{ "WinBond", 0xEF, 0x4000, 0xFF00, read_status_16b_rdsr_rdsr2, write_status_16b_wrsr, 9 },
{ "GD", 0xC8, 0x6000, 0xFF00, read_status_16b_rdsr_rdsr2, write_status_16b_wrsr, 9 },
{ "XM25QU64A", 0x20, 0x3817, 0xFFFF, read_status_8b_xmc25qu64a, write_status_8b_xmc25qu64a, 6 },
/* Final entry is default entry, if no other IDs have matched.
@ -96,7 +103,7 @@ const static qio_info_t chip_data[] = {
GigaDevice (mfg ID 0xC8, flash IDs including 4016),
FM25Q32 (QOUT mode only, mfg ID 0xA1, flash IDs including 4016)
*/
{ NULL, 0xFF, 0xFFFF, 0xFFFF, read_status_8b_rdsr2, write_status_8b_wrsr2, 1 },
{ NULL, 0xFF, 0xFFFF, 0xFFFF, read_status_8b_rdsr2, write_status_8b_wrsr2, 1 },
};
#define NUM_CHIPS (sizeof(chip_data) / sizeof(qio_info_t))
@ -246,6 +253,24 @@ static void write_status_16b_wrsr(unsigned new_status)
execute_flash_command(CMD_WRSR, new_status, 16, 0);
}
static unsigned read_status_8b_xmc25qu64a()
{
execute_flash_command(CMD_OTPEN, 0, 0, 0); /* Enter OTP mode */
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
uint32_t read_status = execute_flash_command(CMD_RDSR, 0, 0, 8);
execute_flash_command(CMD_WRDI, 0, 0, 0); /* Exit OTP mode */
return read_status;
}
static void write_status_8b_xmc25qu64a(unsigned new_status)
{
execute_flash_command(CMD_OTPEN, 0, 0, 0); /* Enter OTP mode */
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
execute_flash_command(CMD_WRSR, new_status, 8, 0);
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
execute_flash_command(CMD_WRDI, 0, 0, 0); /* Exit OTP mode */
}
static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8_t mosi_len, uint8_t miso_len)
{
uint32_t old_ctrl_reg = SPIFLASH.ctrl.val;

View File

@ -50,7 +50,7 @@ static bool secure_boot_generate(uint32_t image_len){
const uint32_t *image;
/* hardware secure boot engine only takes full blocks, so round up the
image length. The additional data should all be 0xFF.
image length. The additional data should all be 0xFF (or the appended SHA, if it falls in the same block).
*/
if (image_len % sizeof(digest.iv) != 0) {
image_len = (image_len / sizeof(digest.iv) + 1) * sizeof(digest.iv);
@ -104,14 +104,21 @@ static inline void burn_efuses()
esp_err_t esp_secure_boot_permanently_enable(void) {
esp_err_t err;
uint32_t image_len = 0;
if (esp_secure_boot_enabled())
{
ESP_LOGI(TAG, "bootloader secure boot is already enabled, continuing..");
return ESP_OK;
}
err = esp_image_verify_bootloader(&image_len);
uint32_t coding_scheme = REG_GET_FIELD(EFUSE_BLK0_RDATA6_REG, EFUSE_CODING_SCHEME);
if (coding_scheme != EFUSE_CODING_SCHEME_VAL_NONE && coding_scheme != EFUSE_CODING_SCHEME_VAL_34) {
ESP_LOGE(TAG, "Unknown/unsupported CODING_SCHEME value 0x%x", coding_scheme);
return ESP_ERR_NOT_SUPPORTED;
}
/* Verify the bootloader */
esp_image_metadata_t bootloader_data = { 0 };
err = esp_image_verify_bootloader_data(&bootloader_data);
if (err != ESP_OK) {
ESP_LOGE(TAG, "bootloader image appears invalid! error %d", err);
return err;
@ -131,13 +138,7 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
&& REG_READ(EFUSE_BLK2_RDATA6_REG) == 0
&& REG_READ(EFUSE_BLK2_RDATA7_REG) == 0) {
ESP_LOGI(TAG, "Generating new secure boot key...");
uint32_t buf[8];
bootloader_fill_random(buf, sizeof(buf));
for (int i = 0; i < 8; i++) {
ESP_LOGV(TAG, "EFUSE_BLK2_WDATA%d_REG = 0x%08x", i, buf[i]);
REG_WRITE(EFUSE_BLK2_WDATA0_REG + 4*i, buf[i]);
}
bzero(buf, sizeof(buf));
esp_efuse_write_random_key(EFUSE_BLK2_WDATA0_REG);
burn_efuses();
ESP_LOGI(TAG, "Read & write protecting new key...");
REG_WRITE(EFUSE_BLK0_WDATA0_REG, EFUSE_WR_DIS_BLK2 | EFUSE_RD_DIS_BLK2);
@ -150,6 +151,11 @@ esp_err_t esp_secure_boot_permanently_enable(void) {
}
ESP_LOGI(TAG, "Generating secure boot digest...");
uint32_t image_len = bootloader_data.image_len;
if(bootloader_data.image.hash_appended) {
/* Secure boot digest doesn't cover the hash */
image_len -= ESP_IMAGE_HASH_LEN;
}
if (false == secure_boot_generate(image_len)){
ESP_LOGE(TAG, "secure boot generation failed");
return ESP_FAIL;

View File

@ -84,10 +84,13 @@ esp_err_t esp_secure_boot_verify_signature_block(const esp_secure_boot_sig_block
return ESP_FAIL;
}
ESP_LOGD(TAG, "Verifying secure boot signature");
is_valid = uECC_verify(signature_verification_key_start,
image_digest,
DIGEST_LEN,
sig_block->signature,
uECC_secp256r1());
ESP_LOGD(TAG, "Verification result %d", is_valid);
return is_valid ? ESP_OK : ESP_ERR_IMAGE_INVALID;
}

View File

@ -0,0 +1,94 @@
#include <stdint.h>
#include <strings.h>
#include "esp_efuse.h"
#include "unity.h"
typedef struct {
uint8_t unencoded[24];
uint32_t encoded[8];
} coding_scheme_test_t;
/* Randomly generated byte strings, encoded and written to ESP32
using espefuse algorithm, then verified to have no encoding errors
and correct readback.
*/
static const coding_scheme_test_t coding_scheme_data[] = {
{
.unencoded = { 0x96, 0xa9, 0xab, 0xb2, 0xda, 0xdd, 0x21, 0xd2, 0x35, 0x22, 0xd3, 0x30, 0x3b, 0xf8, 0xcb, 0x77, 0x8d, 0x8d, 0xf4, 0x96, 0x25, 0xc4, 0xb9, 0x94 },
.encoded = { 0xb2aba996, 0x6821ddda, 0x2235d221, 0x430730d3, 0x77cbf83b, 0x627f8d8d, 0xc42596f4, 0x4dae94b9 },
},
{
.unencoded = { 0x0e, 0x6b, 0x1a, 0x1d, 0xa5, 0x9f, 0x24, 0xcf, 0x91, 0x5b, 0xe7, 0xe1, 0x7c, 0x0a, 0x6e, 0xdc, 0x5e, 0x8e, 0xb1, 0xec, 0xd1, 0xf3, 0x75, 0x48 },
.encoded = { 0x1d1a6b0e, 0x5e589fa5, 0x5b91cf24, 0x6127e1e7, 0xdc6e0a7c, 0x5d148e5e, 0xf3d1ecb1, 0x57424875 },
},
{
.unencoded = { 0x0a, 0x79, 0x5a, 0x1c, 0xb1, 0x45, 0x71, 0x2c, 0xb3, 0xda, 0x9e, 0xdc, 0x76, 0x27, 0xf5, 0xca, 0xe7, 0x00, 0x39, 0x95, 0x6c, 0x53, 0xc2, 0x07 },
.encoded = { 0x1c5a790a, 0x4ac145b1, 0xdab32c71, 0x6476dc9e, 0xcaf52776, 0x4d8900e7, 0x536c9539, 0x495607c2 },
},
{
.unencoded = { 0x76, 0x46, 0x88, 0x2d, 0x4c, 0xe1, 0x50, 0x5d, 0xd6, 0x7c, 0x41, 0x15, 0xc6, 0x1f, 0xd4, 0x60, 0x10, 0x15, 0x2a, 0x72, 0x2d, 0x89, 0x93, 0x13 },
.encoded = { 0x2d884676, 0x4838e14c, 0x7cd65d50, 0x4bf31541, 0x60d41fc6, 0x39681510, 0x892d722a, 0x497c1393 },
},
{
.unencoded = { 0x32, 0xbc, 0x40, 0x92, 0x13, 0x37, 0x1a, 0xae, 0xb6, 0x00, 0xed, 0x30, 0xb8, 0x82, 0xee, 0xfc, 0xcf, 0x6d, 0x7f, 0xc5, 0xfa, 0x0e, 0xdd, 0x84 },
.encoded = { 0x9240bc32, 0x49783713, 0x00b6ae1a, 0x46df30ed, 0xfcee82b8, 0x6e8a6dcf, 0x0efac57f, 0x571784dd },
},
{
.unencoded = { 0x29, 0xb3, 0x04, 0x95, 0xf2, 0x3c, 0x81, 0xe6, 0x5a, 0xf3, 0x42, 0x82, 0xd1, 0x79, 0xe2, 0x12, 0xbe, 0xc3, 0xd4, 0x10, 0x63, 0x66, 0x9f, 0xe3 },
.encoded = { 0x9504b329, 0x51c53cf2, 0xf35ae681, 0x460e8242, 0x12e279d1, 0x5825c3be, 0x666310d4, 0x5ebde39f },
},
{
.unencoded = { 0xda, 0xda, 0x71, 0x4a, 0x62, 0x33, 0xdd, 0x31, 0x87, 0xf3, 0x70, 0x12, 0x33, 0x3b, 0x3b, 0xe9, 0xed, 0xc4, 0x6e, 0x6a, 0xc7, 0xd5, 0x85, 0xfc },
.encoded = { 0x4a71dada, 0x4e6a3362, 0xf38731dd, 0x4bfa1270, 0xe93b3b33, 0x61f3c4ed, 0xd5c76a6e, 0x636ffc85 },
},
{
.unencoded = { 0x45, 0x64, 0x51, 0x34, 0x1c, 0x82, 0x81, 0x77, 0xf8, 0x89, 0xb1, 0x15, 0x82, 0x94, 0xdd, 0x64, 0xa2, 0x46, 0x0e, 0xfb, 0x1a, 0x70, 0x4b, 0x9f },
.encoded = { 0x34516445, 0x39da821c, 0x89f87781, 0x4f2315b1, 0x64dd9482, 0x474b46a2, 0x701afb0e, 0x5e4b9f4b },
},
{
.unencoded = { 0x89, 0x87, 0x15, 0xb6, 0x66, 0x34, 0x49, 0x18, 0x8b, 0x7b, 0xb2, 0xf6, 0x96, 0x1e, 0x2e, 0xf1, 0x03, 0x9d, 0x4e, 0x16, 0x32, 0xd6, 0x23, 0x22 },
.encoded = { 0xb6158789, 0x4eff3466, 0x7b8b1849, 0x63e5f6b2, 0xf12e1e96, 0x54c99d03, 0xd632164e, 0x42bd2223 },
},
{
.unencoded = { 0xa7, 0xa0, 0xb5, 0x21, 0xd2, 0xa3, 0x9f, 0x65, 0xa9, 0xeb, 0x72, 0xa2, 0x2e, 0xa6, 0xfb, 0x9c, 0x48, 0x7e, 0x68, 0x08, 0x7a, 0xb1, 0x4f, 0xbc },
.encoded = { 0x21b5a0a7, 0x4ce2a3d2, 0xeba9659f, 0x5868a272, 0x9cfba62e, 0x5fd97e48, 0xb17a0868, 0x5b58bc4f },
},
{
.unencoded = { 0xf7, 0x05, 0xe3, 0x6c, 0xb1, 0x55, 0xcb, 0x2f, 0x8d, 0x3e, 0x0b, 0x2e, 0x3e, 0xb7, 0x02, 0xf5, 0x91, 0xb1, 0xfe, 0x8b, 0x58, 0x50, 0xb2, 0x40 },
.encoded = { 0x6ce305f7, 0x569955b1, 0x3e8d2fcb, 0x56722e0b, 0xf502b73e, 0x535eb191, 0x50588bfe, 0x3a8f40b2 },
},
{
.unencoded = { 0x0f, 0x93, 0xb0, 0xd5, 0x60, 0xba, 0x40, 0x2a, 0x62, 0xa6, 0x92, 0x82, 0xb8, 0x91, 0x2c, 0xd7, 0x23, 0xdc, 0x6f, 0x7f, 0x2f, 0xbe, 0x41, 0xf5 },
.encoded = { 0xd5b0930f, 0x5123ba60, 0xa6622a40, 0x3bbe8292, 0xd72c91b8, 0x582ddc23, 0xbe2f7f6f, 0x6935f541 },
},
{
.unencoded = { 0x7f, 0x0c, 0x99, 0xde, 0xff, 0x2e, 0xd2, 0x1c, 0x48, 0x98, 0x70, 0x85, 0x15, 0x01, 0x2a, 0xfb, 0xcd, 0xf2, 0xa0, 0xf9, 0x0e, 0xbc, 0x9f, 0x0c },
.encoded = { 0xde990c7f, 0x6fe52eff, 0x98481cd2, 0x3deb8570, 0xfb2a0115, 0x61faf2cd, 0xbc0ef9a0, 0x55780c9f },
},
{
.unencoded = { 0x9a, 0x10, 0x92, 0x03, 0x81, 0xfe, 0x41, 0x57, 0x77, 0x02, 0xcb, 0x20, 0x67, 0xa4, 0x97, 0xf3, 0xf8, 0xc7, 0x0d, 0x65, 0xcd, 0xfc, 0x15, 0xef },
.encoded = { 0x0392109a, 0x4b64fe81, 0x02775741, 0x418820cb, 0xf397a467, 0x6998c7f8, 0xfccd650d, 0x6ba3ef15 },
},
};
TEST_CASE("Test 3/4 Coding Scheme Algorithm", "[bootloader_support]")
{
const int num_tests = sizeof(coding_scheme_data)/sizeof(coding_scheme_test_t);
for (int i = 0; i < num_tests; i++) {
uint32_t result[8];
const coding_scheme_test_t *t = &coding_scheme_data[i];
printf("Test case %d...\n", i);
esp_err_t r = esp_efuse_apply_34_encoding(t->unencoded, result, sizeof(t->unencoded));
TEST_ASSERT_EQUAL_HEX(ESP_OK, r);
TEST_ASSERT_EQUAL_HEX32_ARRAY(t->encoded, result, 8);
// Do the same, 6 bytes at a time
for (int offs = 0; offs < sizeof(t->unencoded); offs += 6) {
bzero(result, sizeof(result));
r = esp_efuse_apply_34_encoding(t->unencoded + offs, result, 6);
TEST_ASSERT_EQUAL_HEX(ESP_OK, r);
TEST_ASSERT_EQUAL_HEX32_ARRAY(t->encoded + (offs / 6 * 2), result, 2);
}
}
}

View File

@ -14,6 +14,7 @@
#include "freertos/xtensa_api.h"
#include "unity.h"
#include "bootloader_common.h"
#include "bootloader_util.h"
#include "esp_partition.h"
#include "esp_ota_ops.h"
#include "esp_image_format.h"
@ -92,3 +93,23 @@ TEST_CASE("Test label_search", "[bootloader_support]")
check_label_search(25, "phy, 1234567890123456, nvs1", "12345678901234567", true);
}
TEST_CASE("Test regions_overlap", "[bootloader_support]")
{
TEST_ASSERT( bootloader_util_regions_overlap(1, 2, 1, 2) );
TEST_ASSERT( bootloader_util_regions_overlap(1, 2, 0, 2) );
TEST_ASSERT( bootloader_util_regions_overlap(1, 2, 1, 3) );
TEST_ASSERT( bootloader_util_regions_overlap(1, 2, 0, 3) );
TEST_ASSERT( bootloader_util_regions_overlap(0, 2, 1, 2) );
TEST_ASSERT( bootloader_util_regions_overlap(1, 3, 1, 2) );
TEST_ASSERT( bootloader_util_regions_overlap(0, 3, 1, 2) );
TEST_ASSERT( !bootloader_util_regions_overlap(2, 3, 1, 2) );
TEST_ASSERT( !bootloader_util_regions_overlap(1, 2, 2, 3) );
TEST_ASSERT( !bootloader_util_regions_overlap(3, 4, 1, 2) );
TEST_ASSERT( !bootloader_util_regions_overlap(1, 2, 3, 4) );
}

View File

@ -1,6 +1,6 @@
if(CONFIG_BT_ENABLED)
set(COMPONENT_SRCDIRS .)
set(COMPONENT_SRCS "bt.c")
set(COMPONENT_ADD_INCLUDEDIRS include)
if(CONFIG_BLUEDROID_ENABLED)
@ -41,51 +41,239 @@ if(CONFIG_BT_ENABLED)
list(APPEND COMPONENT_ADD_INCLUDEDIRS bluedroid/api/include/api)
list(APPEND COMPONENT_SRCDIRS
bluedroid/bta/dm
bluedroid/bta/gatt
bluedroid/bta/hh
bluedroid/bta/sdp
bluedroid/bta/av
bluedroid/bta/ar
bluedroid/bta/sys
bluedroid/bta/jv
bluedroid/device
bluedroid/hci
bluedroid/main
bluedroid/osi
bluedroid/external/sbc/decoder/srce
bluedroid/external/sbc/encoder/srce
bluedroid/btc/core
bluedroid/btc/profile/esp/blufi
bluedroid/btc/profile/std/gap
bluedroid/btc/profile/std/gatt
bluedroid/btc/profile/std/a2dp
bluedroid/btc/profile/std/avrc
bluedroid/btc/profile/std/spp
bluedroid/stack/btm
bluedroid/stack/btu
bluedroid/stack/gap
bluedroid/stack/gatt
bluedroid/stack/hcic
bluedroid/stack/l2cap
bluedroid/stack/sdp
bluedroid/stack/smp
bluedroid/stack/avct
bluedroid/stack/avrc
bluedroid/stack/avdt
bluedroid/stack/a2dp
bluedroid/stack/rfcomm
bluedroid/api
)
list(APPEND COMPONENT_SRCS "bluedroid/api/esp_a2dp_api.c"
"bluedroid/api/esp_avrc_api.c"
"bluedroid/api/esp_blufi_api.c"
"bluedroid/api/esp_bt_device.c"
"bluedroid/api/esp_bt_main.c"
"bluedroid/api/esp_gap_ble_api.c"
"bluedroid/api/esp_gap_bt_api.c"
"bluedroid/api/esp_gatt_common_api.c"
"bluedroid/api/esp_gattc_api.c"
"bluedroid/api/esp_gatts_api.c"
"bluedroid/api/esp_hf_client_api.c"
"bluedroid/api/esp_spp_api.c"
"bluedroid/bta/ar/bta_ar.c"
"bluedroid/bta/av/bta_av_aact.c"
"bluedroid/bta/av/bta_av_act.c"
"bluedroid/bta/av/bta_av_api.c"
"bluedroid/bta/av/bta_av_cfg.c"
"bluedroid/bta/av/bta_av_ci.c"
"bluedroid/bta/av/bta_av_main.c"
"bluedroid/bta/av/bta_av_sbc.c"
"bluedroid/bta/av/bta_av_ssm.c"
"bluedroid/bta/dm/bta_dm_act.c"
"bluedroid/bta/dm/bta_dm_api.c"
"bluedroid/bta/dm/bta_dm_cfg.c"
"bluedroid/bta/dm/bta_dm_ci.c"
"bluedroid/bta/dm/bta_dm_co.c"
"bluedroid/bta/dm/bta_dm_main.c"
"bluedroid/bta/dm/bta_dm_pm.c"
"bluedroid/bta/dm/bta_dm_sco.c"
"bluedroid/bta/gatt/bta_gatt_common.c"
"bluedroid/bta/gatt/bta_gattc_act.c"
"bluedroid/bta/gatt/bta_gattc_api.c"
"bluedroid/bta/gatt/bta_gattc_cache.c"
"bluedroid/bta/gatt/bta_gattc_ci.c"
"bluedroid/bta/gatt/bta_gattc_co.c"
"bluedroid/bta/gatt/bta_gattc_main.c"
"bluedroid/bta/gatt/bta_gattc_utils.c"
"bluedroid/bta/gatt/bta_gatts_act.c"
"bluedroid/bta/gatt/bta_gatts_api.c"
"bluedroid/bta/gatt/bta_gatts_co.c"
"bluedroid/bta/gatt/bta_gatts_main.c"
"bluedroid/bta/gatt/bta_gatts_utils.c"
"bluedroid/bta/hh/bta_hh_act.c"
"bluedroid/bta/hh/bta_hh_api.c"
"bluedroid/bta/hh/bta_hh_cfg.c"
"bluedroid/bta/hh/bta_hh_le.c"
"bluedroid/bta/hh/bta_hh_main.c"
"bluedroid/bta/hh/bta_hh_utils.c"
"bluedroid/bta/jv/bta_jv_act.c"
"bluedroid/bta/jv/bta_jv_api.c"
"bluedroid/bta/jv/bta_jv_cfg.c"
"bluedroid/bta/jv/bta_jv_main.c"
"bluedroid/bta/sdp/bta_sdp.c"
"bluedroid/bta/sdp/bta_sdp_act.c"
"bluedroid/bta/sdp/bta_sdp_api.c"
"bluedroid/bta/sdp/bta_sdp_cfg.c"
"bluedroid/bta/sys/bta_sys_conn.c"
"bluedroid/bta/sys/bta_sys_main.c"
"bluedroid/bta/sys/utl.c"
"bluedroid/btc/core/btc_alarm.c"
"bluedroid/btc/core/btc_ble_storage.c"
"bluedroid/btc/core/btc_config.c"
"bluedroid/btc/core/btc_dev.c"
"bluedroid/btc/core/btc_dm.c"
"bluedroid/btc/core/btc_main.c"
"bluedroid/btc/core/btc_manage.c"
"bluedroid/btc/core/btc_profile_queue.c"
"bluedroid/btc/core/btc_sec.c"
"bluedroid/btc/core/btc_sm.c"
"bluedroid/btc/core/btc_storage.c"
"bluedroid/btc/core/btc_task.c"
"bluedroid/btc/core/btc_util.c"
"bluedroid/btc/profile/esp/blufi/blufi_prf.c"
"bluedroid/btc/profile/esp/blufi/blufi_protocol.c"
"bluedroid/btc/profile/std/a2dp/bta_av_co.c"
"bluedroid/btc/profile/std/a2dp/btc_a2dp.c"
"bluedroid/btc/profile/std/a2dp/btc_a2dp_control.c"
"bluedroid/btc/profile/std/a2dp/btc_a2dp_sink.c"
"bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c"
"bluedroid/btc/profile/std/a2dp/btc_av.c"
"bluedroid/btc/profile/std/avrc/btc_avrc.c"
"bluedroid/btc/profile/std/gap/btc_gap_ble.c"
"bluedroid/btc/profile/std/gap/btc_gap_bt.c"
"bluedroid/btc/profile/std/gatt/btc_gatt_common.c"
"bluedroid/btc/profile/std/gatt/btc_gatt_util.c"
"bluedroid/btc/profile/std/gatt/btc_gattc.c"
"bluedroid/btc/profile/std/gatt/btc_gatts.c"
"bluedroid/btc/profile/std/spp/btc_spp.c"
"bluedroid/device/bdaddr.c"
"bluedroid/device/controller.c"
"bluedroid/device/interop.c"
"bluedroid/external/sbc/decoder/srce/alloc.c"
"bluedroid/external/sbc/decoder/srce/bitalloc-sbc.c"
"bluedroid/external/sbc/decoder/srce/bitalloc.c"
"bluedroid/external/sbc/decoder/srce/bitstream-decode.c"
"bluedroid/external/sbc/decoder/srce/decoder-oina.c"
"bluedroid/external/sbc/decoder/srce/decoder-private.c"
"bluedroid/external/sbc/decoder/srce/decoder-sbc.c"
"bluedroid/external/sbc/decoder/srce/dequant.c"
"bluedroid/external/sbc/decoder/srce/framing-sbc.c"
"bluedroid/external/sbc/decoder/srce/framing.c"
"bluedroid/external/sbc/decoder/srce/oi_codec_version.c"
"bluedroid/external/sbc/decoder/srce/synthesis-8-generated.c"
"bluedroid/external/sbc/decoder/srce/synthesis-dct8.c"
"bluedroid/external/sbc/decoder/srce/synthesis-sbc.c"
"bluedroid/external/sbc/encoder/srce/sbc_analysis.c"
"bluedroid/external/sbc/encoder/srce/sbc_dct.c"
"bluedroid/external/sbc/encoder/srce/sbc_dct_coeffs.c"
"bluedroid/external/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c"
"bluedroid/external/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c"
"bluedroid/external/sbc/encoder/srce/sbc_enc_coeffs.c"
"bluedroid/external/sbc/encoder/srce/sbc_encoder.c"
"bluedroid/external/sbc/encoder/srce/sbc_packing.c"
"bluedroid/hci/buffer_allocator.c"
"bluedroid/hci/hci_audio.c"
"bluedroid/hci/hci_hal_h4.c"
"bluedroid/hci/hci_layer.c"
"bluedroid/hci/hci_packet_factory.c"
"bluedroid/hci/hci_packet_parser.c"
"bluedroid/hci/packet_fragmenter.c"
"bluedroid/main/bte_init.c"
"bluedroid/main/bte_main.c"
"bluedroid/osi/alarm.c"
"bluedroid/osi/allocator.c"
"bluedroid/osi/buffer.c"
"bluedroid/osi/config.c"
"bluedroid/osi/fixed_queue.c"
"bluedroid/osi/future.c"
"bluedroid/osi/hash_functions.c"
"bluedroid/osi/hash_map.c"
"bluedroid/osi/list.c"
"bluedroid/osi/mutex.c"
"bluedroid/osi/osi.c"
"bluedroid/osi/semaphore.c"
"bluedroid/stack/a2dp/a2d_api.c"
"bluedroid/stack/a2dp/a2d_sbc.c"
"bluedroid/stack/avct/avct_api.c"
"bluedroid/stack/avct/avct_ccb.c"
"bluedroid/stack/avct/avct_l2c.c"
"bluedroid/stack/avct/avct_lcb.c"
"bluedroid/stack/avct/avct_lcb_act.c"
"bluedroid/stack/avdt/avdt_ad.c"
"bluedroid/stack/avdt/avdt_api.c"
"bluedroid/stack/avdt/avdt_ccb.c"
"bluedroid/stack/avdt/avdt_ccb_act.c"
"bluedroid/stack/avdt/avdt_l2c.c"
"bluedroid/stack/avdt/avdt_msg.c"
"bluedroid/stack/avdt/avdt_scb.c"
"bluedroid/stack/avdt/avdt_scb_act.c"
"bluedroid/stack/avrc/avrc_api.c"
"bluedroid/stack/avrc/avrc_bld_ct.c"
"bluedroid/stack/avrc/avrc_bld_tg.c"
"bluedroid/stack/avrc/avrc_opt.c"
"bluedroid/stack/avrc/avrc_pars_ct.c"
"bluedroid/stack/avrc/avrc_pars_tg.c"
"bluedroid/stack/avrc/avrc_sdp.c"
"bluedroid/stack/avrc/avrc_utils.c"
"bluedroid/stack/btm/btm_acl.c"
"bluedroid/stack/btm/btm_ble.c"
"bluedroid/stack/btm/btm_ble_addr.c"
"bluedroid/stack/btm/btm_ble_adv_filter.c"
"bluedroid/stack/btm/btm_ble_batchscan.c"
"bluedroid/stack/btm/btm_ble_bgconn.c"
"bluedroid/stack/btm/btm_ble_cont_energy.c"
"bluedroid/stack/btm/btm_ble_gap.c"
"bluedroid/stack/btm/btm_ble_multi_adv.c"
"bluedroid/stack/btm/btm_ble_privacy.c"
"bluedroid/stack/btm/btm_dev.c"
"bluedroid/stack/btm/btm_devctl.c"
"bluedroid/stack/btm/btm_inq.c"
"bluedroid/stack/btm/btm_main.c"
"bluedroid/stack/btm/btm_pm.c"
"bluedroid/stack/btm/btm_sco.c"
"bluedroid/stack/btm/btm_sec.c"
"bluedroid/stack/btu/btu_hcif.c"
"bluedroid/stack/btu/btu_init.c"
"bluedroid/stack/btu/btu_task.c"
"bluedroid/stack/gap/gap_api.c"
"bluedroid/stack/gap/gap_ble.c"
"bluedroid/stack/gap/gap_conn.c"
"bluedroid/stack/gap/gap_utils.c"
"bluedroid/stack/gatt/att_protocol.c"
"bluedroid/stack/gatt/gatt_api.c"
"bluedroid/stack/gatt/gatt_attr.c"
"bluedroid/stack/gatt/gatt_auth.c"
"bluedroid/stack/gatt/gatt_cl.c"
"bluedroid/stack/gatt/gatt_db.c"
"bluedroid/stack/gatt/gatt_main.c"
"bluedroid/stack/gatt/gatt_sr.c"
"bluedroid/stack/gatt/gatt_utils.c"
"bluedroid/stack/hcic/hciblecmds.c"
"bluedroid/stack/hcic/hcicmds.c"
"bluedroid/stack/l2cap/l2c_api.c"
"bluedroid/stack/l2cap/l2c_ble.c"
"bluedroid/stack/l2cap/l2c_csm.c"
"bluedroid/stack/l2cap/l2c_fcr.c"
"bluedroid/stack/l2cap/l2c_link.c"
"bluedroid/stack/l2cap/l2c_main.c"
"bluedroid/stack/l2cap/l2c_ucd.c"
"bluedroid/stack/l2cap/l2c_utils.c"
"bluedroid/stack/l2cap/l2cap_client.c"
"bluedroid/stack/rfcomm/port_api.c"
"bluedroid/stack/rfcomm/port_rfc.c"
"bluedroid/stack/rfcomm/port_utils.c"
"bluedroid/stack/rfcomm/rfc_l2cap_if.c"
"bluedroid/stack/rfcomm/rfc_mx_fsm.c"
"bluedroid/stack/rfcomm/rfc_port_fsm.c"
"bluedroid/stack/rfcomm/rfc_port_if.c"
"bluedroid/stack/rfcomm/rfc_ts_frames.c"
"bluedroid/stack/rfcomm/rfc_utils.c"
"bluedroid/stack/sdp/sdp_api.c"
"bluedroid/stack/sdp/sdp_db.c"
"bluedroid/stack/sdp/sdp_discovery.c"
"bluedroid/stack/sdp/sdp_main.c"
"bluedroid/stack/sdp/sdp_server.c"
"bluedroid/stack/sdp/sdp_utils.c"
"bluedroid/stack/smp/aes.c"
"bluedroid/stack/smp/p_256_curvepara.c"
"bluedroid/stack/smp/p_256_ecc_pp.c"
"bluedroid/stack/smp/p_256_multprecision.c"
"bluedroid/stack/smp/smp_act.c"
"bluedroid/stack/smp/smp_api.c"
"bluedroid/stack/smp/smp_br_main.c"
"bluedroid/stack/smp/smp_cmac.c"
"bluedroid/stack/smp/smp_keys.c"
"bluedroid/stack/smp/smp_l2c.c"
"bluedroid/stack/smp/smp_main.c"
"bluedroid/stack/smp/smp_utils.c")
endif()
endif()
# requirements can't depend on config
set(COMPONENT_PRIV_REQUIRES lwip nvs_flash)
# currently uses libcoap's hash table in hashkey.h
set(COMPONENT_REQUIRES coap)
set(COMPONENT_PRIV_REQUIRES nvs_flash)
register_component()

View File

@ -220,6 +220,13 @@ config GATTC_ENABLE
help
This option can be close when the app work only on gatt server mode
config GATTC_CACHE_NVS_FLASH
bool "Save gattc cache data to nvs flash"
depends on GATTC_ENABLE
default n
help
This select can save gattc cache data to nvs flash
config BLE_SMP_ENABLE
bool "Include BLE security module(SMP)"
depends on BLUEDROID_ENABLED
@ -997,6 +1004,15 @@ config BT_BLE_DYNAMIC_ENV_MEMORY
help
This select can make the allocation of memory will become more flexible
config BLE_HOST_QUEUE_CONGESTION_CHECK
bool "BLE queue congestion check"
depends on BLUEDROID_ENABLED
default n
help
When scanning and scan duplicate is not enabled, if there are a lot of adv packets around or application layer
handling adv packets is slow, it will cause the controller memory to run out. if enabled, adv packets will be
lost when host queue is congested.
config BLE_SCAN_DUPLICATE
bool "BLE Scan Duplicate Options"
depends on BLUEDROID_ENABLED
@ -1007,8 +1023,8 @@ config BLE_SCAN_DUPLICATE
config DUPLICATE_SCAN_CACHE_SIZE
int "Maximum number of devices in scan duplicate filter"
depends on BLE_SCAN_DUPLICATE
range 10 200
default 20
range 10 1000
default 50
help
Maximum number of devices which can be recorded in scan duplicate filter.
When the maximum amount of device in the filter is reached, the cache will be refreshed.
@ -1023,8 +1039,8 @@ config BLE_MESH_SCAN_DUPLICATE_EN
config MESH_DUPLICATE_SCAN_CACHE_SIZE
int "Maximum number of Mesh adv packets in scan duplicate filter"
depends on BLE_MESH_SCAN_DUPLICATE_EN
range 10 200
default 50
range 10 1000
default 100
help
Maximum number of adv packets which can be recorded in duplicate scan cache for BLE Mesh.
When the maximum amount of device in the filter is reached, the cache will be refreshed.

View File

@ -441,6 +441,23 @@ esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_d
esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type,
void *value, uint8_t len)
{
if(param_type >= ESP_BLE_SM_MAX_PARAM) {
return ESP_ERR_INVALID_ARG;
}
if((param_type != ESP_BLE_SM_CLEAR_STATIC_PASSKEY) && ( value == NULL || len < sizeof(uint8_t) || len > sizeof(uint32_t))) {
return ESP_ERR_INVALID_ARG;
}
if((param_type == ESP_BLE_SM_SET_STATIC_PASSKEY)) {
uint32_t passkey = 0;
for(uint8_t i = 0; i < len; i++)
{
passkey += (((uint8_t *)value)[i]<<(8*i));
}
if(passkey > 999999) {
return ESP_ERR_INVALID_ARG;
}
}
btc_msg_t msg;
btc_ble_gap_args_t arg;

View File

@ -240,4 +240,50 @@ esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list)
return (ret == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_bt_gap_set_pin(esp_bt_pin_type_t pin_type, uint8_t pin_code_len, esp_bt_pin_code_t pin_code)
{
btc_msg_t msg;
btc_gap_bt_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_BT;
msg.act = BTC_GAP_BT_ACT_SET_PIN_TYPE;
arg.set_pin_type.pin_type = pin_type;
if (pin_type == ESP_BT_PIN_TYPE_FIXED){
arg.set_pin_type.pin_code_len = pin_code_len;
memcpy(arg.set_pin_type.pin_code, pin_code, pin_code_len);
} else {
arg.set_pin_type.pin_code_len = 0;
memset(arg.set_pin_type.pin_code, 0, ESP_BT_PIN_CODE_LEN);
}
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_bt_gap_pin_reply(esp_bd_addr_t bd_addr, bool accept, uint8_t pin_code_len, esp_bt_pin_code_t pin_code)
{
btc_msg_t msg;
btc_gap_bt_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_BT;
msg.act = BTC_GAP_BT_ACT_PIN_REPLY;
arg.pin_reply.accept = accept;
arg.pin_reply.pin_code_len = pin_code_len;
memcpy(arg.pin_reply.bda.address, bd_addr, sizeof(esp_bd_addr_t));
memcpy(arg.pin_reply.pin_code, pin_code, pin_code_len);
return (btc_transfer_context(&msg, &arg, sizeof(btc_gap_bt_args_t), NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#endif /* #if BTC_GAP_BT_INCLUDED == TRUE */

View File

@ -164,6 +164,7 @@ esp_gatt_status_t esp_ble_gattc_get_all_char(esp_gatt_if_t gattc_if,
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if ((start_handle == 0) && (end_handle == 0)) {
*count = 0;
return ESP_GATT_INVALID_HANDLE;
}
@ -206,6 +207,7 @@ esp_gatt_status_t esp_ble_gattc_get_char_by_uuid(esp_gatt_if_t gattc_if,
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (start_handle == 0 && end_handle == 0) {
*count = 0;
return ESP_GATT_INVALID_HANDLE;
}
@ -247,6 +249,7 @@ esp_gatt_status_t esp_ble_gattc_get_descr_by_char_handle(esp_gatt_if_t gattc_if,
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (char_handle == 0) {
*count = 0;
return ESP_GATT_INVALID_HANDLE;
}
@ -269,6 +272,7 @@ esp_gatt_status_t esp_ble_gattc_get_include_service(esp_gatt_if_t gattc_if,
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (start_handle == 0 && end_handle == 0) {
*count = 0;
return ESP_GATT_INVALID_HANDLE;
}
@ -291,6 +295,7 @@ esp_gatt_status_t esp_ble_gattc_get_attr_count(esp_gatt_if_t gattc_if,
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if ((start_handle == 0 && end_handle == 0) && (type != ESP_GATT_DB_DESCRIPTOR)) {
*count = 0;
return ESP_GATT_INVALID_HANDLE;
}
@ -308,6 +313,7 @@ esp_gatt_status_t esp_ble_gattc_get_db(esp_gatt_if_t gattc_if, uint16_t conn_id,
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (start_handle == 0 && end_handle == 0) {
*count = 0;
return ESP_GATT_INVALID_HANDLE;
}

View File

@ -261,7 +261,7 @@ esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id,
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) {
LOG_ERROR("%s, the l2cap chanel is congest.", __func__);
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
return ESP_FAIL;
}

View File

@ -54,12 +54,16 @@ typedef uint8_t esp_ble_key_type_t;
#define ESP_LE_AUTH_NO_BOND 0x00 /*!< 0*/ /* relate to BTM_LE_AUTH_NO_BOND in stack/btm_api.h */
#define ESP_LE_AUTH_BOND 0x01 /*!< 1 << 0 */ /* relate to BTM_LE_AUTH_BOND in stack/btm_api.h */
#define ESP_LE_AUTH_REQ_MITM (1 << 2) /*!< 1 << 2 */ /* relate to BTM_LE_AUTH_REQ_MITM in stack/btm_api.h */
#define ESP_LE_AUTH_REQ_BOND_MITM (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_MITM)/*!< 0101*/
#define ESP_LE_AUTH_REQ_SC_ONLY (1 << 3) /*!< 1 << 3 */ /* relate to BTM_LE_AUTH_REQ_SC_ONLY in stack/btm_api.h */
#define ESP_LE_AUTH_REQ_SC_BOND (ESP_LE_AUTH_BOND | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1001 */ /* relate to BTM_LE_AUTH_REQ_SC_BOND in stack/btm_api.h */
#define ESP_LE_AUTH_REQ_SC_MITM (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY) /*!< 1100 */ /* relate to BTM_LE_AUTH_REQ_SC_MITM in stack/btm_api.h */
#define ESP_LE_AUTH_REQ_SC_MITM_BOND (ESP_LE_AUTH_REQ_MITM | ESP_LE_AUTH_REQ_SC_ONLY | ESP_LE_AUTH_BOND) /*!< 1101 */ /* relate to BTM_LE_AUTH_REQ_SC_MITM_BOND in stack/btm_api.h */
typedef uint8_t esp_ble_auth_req_t; /*!< combination of the above bit pattern */
#define ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_DISABLE 0
#define ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_ENABLE 1
/* relate to BTM_IO_CAP_xxx in stack/btm_api.h */
#define ESP_IO_CAP_OUT 0 /*!< DisplayOnly */ /* relate to BTM_IO_CAP_OUT in stack/btm_api.h */
#define ESP_IO_CAP_IO 1 /*!< DisplayYesNo */ /* relate to BTM_IO_CAP_IO in stack/btm_api.h */
@ -264,6 +268,10 @@ typedef enum {
ESP_BLE_SM_SET_INIT_KEY,
ESP_BLE_SM_SET_RSP_KEY,
ESP_BLE_SM_MAX_KEY_SIZE,
ESP_BLE_SM_SET_STATIC_PASSKEY,
ESP_BLE_SM_CLEAR_STATIC_PASSKEY,
ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH,
ESP_BLE_SM_MAX_PARAM,
} esp_ble_sm_param_t;
/// Advertising parameters
@ -279,7 +287,7 @@ typedef struct {
esp_ble_adv_type_t adv_type; /*!< Advertising type */
esp_ble_addr_type_t own_addr_type; /*!< Owner bluetooth device address type */
esp_bd_addr_t peer_addr; /*!< Peer device bluetooth device address */
esp_ble_addr_type_t peer_addr_type; /*!< Peer device bluetooth device address type */
esp_ble_addr_type_t peer_addr_type; /*!< Peer device bluetooth device address type, only support public address type and random address type */
esp_ble_adv_channel_t channel_map; /*!< Advertising channel map */
esp_ble_adv_filter_t adv_filter_policy; /*!< Advertising filter policy */
} esp_ble_adv_params_t;
@ -346,8 +354,8 @@ typedef struct {
Range: 0x0004 to 0x4000 Default: 0x0010 (10 ms)
Time = N * 0.625 msec
Time Range: 2.5 msec to 10240 msec */
esp_ble_scan_duplicate_t scan_duplicate; /*!< The Scan_Duplicates parameter controls whether the Link Layer should filter out
duplicate advertising reports (BLE_SCAN_DUPLICATE_ENABLE) to the Host, or if the Link Layer should generate
esp_ble_scan_duplicate_t scan_duplicate; /*!< The Scan_Duplicates parameter controls whether the Link Layer should filter out
duplicate advertising reports (BLE_SCAN_DUPLICATE_ENABLE) to the Host, or if the Link Layer should generate
advertising reports for each packet received */
} esp_ble_scan_params_t;
@ -508,7 +516,8 @@ typedef struct
uint8_t fail_reason; /*!< The HCI reason/error code for when success=FALSE */
esp_ble_addr_type_t addr_type; /*!< Peer device address type */
esp_bt_dev_type_t dev_type; /*!< Device type */
} esp_ble_auth_cmpl_t; /*!< The ble authentication complite cb type */
esp_ble_auth_req_t auth_mode; /*!< authentication mode */
} esp_ble_auth_cmpl_t; /*!< The ble authentication complete cb type */
/**
* @brief union associated with ble security
@ -933,8 +942,7 @@ esp_err_t esp_ble_gap_get_local_used_addr(esp_bd_addr_t local_used_addr, uint8_t
* @param[in] type - finding ADV data type
* @param[out] length - return the length of ADV data not including type
*
* @return - ESP_OK : success
* - other : failed
* @return pointer of ADV data
*
*/
uint8_t *esp_ble_resolve_adv_data(uint8_t *adv_data, uint8_t type, uint8_t *length);

View File

@ -102,6 +102,14 @@ typedef enum {
ESP_BT_COD_SRVC_INFORMATION = 0x400, /*!< Information, e.g., WEB-server, WAP-server */
} esp_bt_cod_srvc_t;
typedef enum{
ESP_BT_PIN_TYPE_VARIABLE = 0, /*!< Refer to BTM_PIN_TYPE_VARIABLE */
ESP_BT_PIN_TYPE_FIXED = 1, /*!< Refer to BTM_PIN_TYPE_FIXED */
} esp_bt_pin_type_t;
#define ESP_BT_PIN_CODE_LEN 16 /*!< Max pin code length */
typedef uint8_t esp_bt_pin_code_t[ESP_BT_PIN_CODE_LEN]; /*!< Pin Code (upto 128 bits) MSB is 0 */
/// Bits of major service class field
#define ESP_BT_COD_SRVC_BIT_MASK (0xffe000) /*!< Major service bit mask */
#define ESP_BT_COD_SRVC_BIT_OFFSET (13) /*!< Major service bit offset */
@ -149,6 +157,7 @@ typedef enum {
ESP_BT_GAP_RMT_SRVCS_EVT, /*!< get remote services event */
ESP_BT_GAP_RMT_SRVC_REC_EVT, /*!< get remote service record event */
ESP_BT_GAP_AUTH_CMPL_EVT, /*!< AUTH complete event */
ESP_BT_GAP_PIN_REQ_EVT, /*!< Legacy Pairing Pin code request */
ESP_BT_GAP_READ_RSSI_DELTA_EVT, /*!< read rssi event */
ESP_BT_GAP_EVT_MAX,
} esp_bt_gap_cb_event_t;
@ -216,6 +225,15 @@ typedef union {
esp_bt_status_t stat; /*!< authentication complete status */
uint8_t device_name[ESP_BT_GAP_MAX_BDNAME_LEN + 1]; /*!< device name */
} auth_cmpl; /*!< authentication complete parameter struct */
/**
* @brief ESP_BT_GAP_PIN_REQ_EVT
*/
struct pin_req_param {
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
bool min_16_digit; /*!< TRUE if the pin returned must be at least 16 digits */
} pin_req; /*!< pin request parameter struct */
} esp_bt_gap_cb_param_t;
/**
@ -447,6 +465,38 @@ int esp_bt_gap_get_bond_device_num(void);
*/
esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list);
/**
* @brief Set pin type and default pin code for legacy pairing.
*
* @param[in] pin_type: Use variable or fixed pin.
* If pin_type is ESP_BT_PIN_TYPE_VARIABLE, pin_code and pin_code_len
* will be ignored, and ESP_BT_GAP_PIN_REQ_EVT will come when control
* requests for pin code.
* Else, will use fixed pin code and not callback to users.
* @param[in] pin_code_len: Length of pin_code
* @param[in] pin_code: Pin_code
*
* @return - ESP_OK : success
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
* - other : failed
*/
esp_err_t esp_bt_gap_set_pin(esp_bt_pin_type_t pin_type, uint8_t pin_code_len, esp_bt_pin_code_t pin_code);
/**
* @brief Reply the pin_code to the peer device for legacy pairing
* when ESP_BT_GAP_PIN_REQ_EVT is coming.
*
* @param[in] bd_addr: BD address of the peer
* @param[in] accept: Pin_code reply successful or declined.
* @param[in] pin_code_len: Length of pin_code
* @param[in] pin_code: Pin_code
*
* @return - ESP_OK : success
* - ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled
* - other : failed
*/
esp_err_t esp_bt_gap_pin_reply(esp_bd_addr_t bd_addr, bool accept, uint8_t pin_code_len, esp_bt_pin_code_t pin_code);
#ifdef __cplusplus
}
#endif

View File

@ -350,7 +350,8 @@ esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db
uint8_t max_nb_attr,
uint8_t srvc_inst_id);
/**
* @brief This function is called to add an included service. After included
* @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 BTA_GATTS_ADD_INCL_SRVC_EVT
* is reported the included service ID.
*

View File

@ -251,9 +251,9 @@ typedef union {
} esp_hf_client_cb_param_t;
/**
* @brief HFP client incoming data callback function, the callback is useful in case of
* @brief HFP client incoming data callback function, the callback is useful in case of
* Voice Over HCI.
* @param[in] buf : pointer to incoming data(payload of HCI synchronous data packet), the
* @param[in] buf : pointer to incoming data(payload of HCI synchronous data packet), the
* buffer is allocated inside bluetooth protocol stack and will be released after
* invoke of the callback is finished.
* @param[in] len : size(in bytes) in buf
@ -261,13 +261,13 @@ typedef union {
typedef void (* esp_hf_client_incoming_data_cb_t)(const uint8_t *buf, uint32_t len);
/**
* @brief HFP client outgoing data callback function, the callback is useful in case of
* Voice Over HCI. Once audio connection is set up and the application layer has
* prepared data to send, the lower layer will call this function to read data
* @brief HFP client outgoing data callback function, the callback is useful in case of
* Voice Over HCI. Once audio connection is set up and the application layer has
* prepared data to send, the lower layer will call this function to read data
* and then send. This callback is supposed to be implemented as non-blocking,
* and if data is not enough, return value 0 is supposed.
*
* @param[in] buf : pointer to incoming data(payload of HCI synchronous data packet), the
*
* @param[in] buf : pointer to incoming data(payload of HCI synchronous data packet), the
* buffer is allocated inside bluetooth protocol stack and will be released after
* invoke of the callback is finished.
* @param[in] len : size(in bytes) in buf
@ -326,7 +326,7 @@ esp_err_t esp_hf_client_deinit(void);
/**
*
* @brief Connect to remote bluetooth HFP audio gateway(AG) device, must after esp_a2d_hf_client_init()
* @brief Connect to remote bluetooth HFP audio gateway(AG) device, must after esp_hf_client_init()
*
* @param[in] remote_bda: remote bluetooth device address
*
@ -606,7 +606,7 @@ void esp_hf_client_outgoing_data_ready(void);
/**
* @brief Initialize the down sampling converter. This is a utility function that can
* only be used in the case that Voice Over HCI is enabled.
* only be used in the case that Voice Over HCI is enabled.
*
* @param[in] src_sps: original samples per second(source audio data, i.e. 48000, 32000,
* 16000, 44100, 22050, 11025)

View File

@ -190,8 +190,7 @@ esp_err_t esp_spp_register_callback(esp_spp_cb_t callback);
/**
* @brief This function is called to init SPP.
*
* @param[in] mode: Choose the mode of SPP, ESP_SPP_MODE_CB or ESP_SPP_MODE_CB.
* Now only supports ESP_SPP_MODE_CB mode, we will continue to update.
* @param[in] mode: Choose the mode of SPP, ESP_SPP_MODE_CB or ESP_SPP_MODE_VFS.
*
* @return
* - ESP_OK: success

View File

@ -143,6 +143,7 @@ const tBTA_AV_SACT bta_av_a2d_action[] = {
bta_av_role_res, /* BTA_AV_ROLE_RES */
bta_av_delay_co, /* BTA_AV_DELAY_CO */
bta_av_open_at_inc, /* BTA_AV_OPEN_AT_INC */
bta_av_open_fail_sdp, /* BTA_AV_OPEN_FAIL_SDP */
NULL
};
@ -815,7 +816,7 @@ void bta_av_role_res (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
p_scb->wait &= ~BTA_AV_WAIT_ROLE_SW_BITS;
if (p_data->role_res.hci_status != HCI_SUCCESS) {
p_scb->role &= ~BTA_AV_ROLE_START_INT;
bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->peer_addr);
bta_sys_idle(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), bta_av_cb.audio_open_cnt, p_scb->peer_addr);
/* start failed because of role switch. */
start.chnl = p_scb->chnl;
start.status = BTA_AV_FAIL_ROLE;
@ -956,7 +957,7 @@ void bta_av_do_disc_a2d (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
p_scb->sec_mask = p_data->api_open.sec_mask;
p_scb->use_rc = p_data->api_open.use_rc;
bta_sys_app_open(BTA_ID_AV, p_scb->app_id, p_scb->peer_addr);
bta_sys_app_open(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), p_scb->app_id, p_scb->peer_addr);
/* allocate discovery database */
if (p_scb->p_disc_db == NULL) {
@ -1060,6 +1061,35 @@ void bta_av_free_sdb(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
utl_freebuf((void **) &p_scb->p_disc_db);
}
/*******************************************************************************
**
** Function bta_av_open_fail_sdp
**
** Description report BTA_AV_OPEN_EVT with service discovery failed status
**
** Returns void
**
*******************************************************************************/
void bta_av_open_fail_sdp(tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
{
tBTA_AV_OPEN open;
bdcpy(open.bd_addr, p_scb->peer_addr);
open.chnl = p_scb->chnl;
open.hndl = p_scb->hndl;
open.status = BTA_AV_FAIL_SDP;
if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SRC ) {
open.sep = AVDT_TSEP_SNK;
} else if (p_scb->seps[p_scb->sep_idx].tsep == AVDT_TSEP_SNK ) {
open.sep = AVDT_TSEP_SRC;
}
(*bta_av_cb.p_cback)(BTA_AV_OPEN_EVT, (tBTA_AV *) &open);
UNUSED(p_data);
}
/*******************************************************************************
**
** Function bta_av_config_ind
@ -1330,7 +1360,7 @@ void bta_av_str_opened (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
L2CA_SetTxPriority(p_scb->l2c_cid, L2CAP_CHNL_PRIORITY_MEDIUM);
L2CA_SetChnlFlushability (p_scb->l2c_cid, TRUE);
bta_sys_conn_open(BTA_ID_AV, p_scb->app_id, p_scb->peer_addr);
bta_sys_conn_open(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), p_scb->app_id, p_scb->peer_addr);
memset(&p_scb->q_info, 0, sizeof(tBTA_AV_Q_INFO));
p_scb->l2c_bufs = 0;
@ -1544,6 +1574,17 @@ void bta_av_disc_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
/* store number of stream endpoints returned */
p_scb->num_seps = p_data->str_msg.msg.discover_cfm.num_seps;
UINT8 num_seps = (p_scb->num_seps < BTA_AV_NUM_SEPS) ? p_scb->num_seps : BTA_AV_NUM_SEPS;
memcpy(p_scb->sep_info, p_data->str_msg.msg.discover_cfm.p_sep_info, sizeof(tAVDT_SEP_INFO) * num_seps);
for (i = 0; i < p_data->str_msg.msg.discover_cfm.num_seps; i++) {
APPL_TRACE_DEBUG("peer sep %d, in use %d, seid %d, media type %d, tsep %d",
i,
p_data->str_msg.msg.discover_cfm.p_sep_info[i].in_use,
p_data->str_msg.msg.discover_cfm.p_sep_info[i].seid,
p_data->str_msg.msg.discover_cfm.p_sep_info[i].media_type,
p_data->str_msg.msg.discover_cfm.p_sep_info[i].tsep
);
}
for (i = 0; i < p_scb->num_seps; i++) {
/* steam not in use, is a sink, and is audio */
if ((p_scb->sep_info[i].in_use == FALSE) &&
@ -1557,7 +1598,7 @@ void bta_av_disc_results (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
(uuid_int == UUID_SERVCLASS_AUDIO_SINK)) {
num_srcs++;
}
APPL_TRACE_DEBUG("num srcs: %d, num_snks: %d\n", num_snks, num_srcs);
}
}
@ -1933,8 +1974,7 @@ void bta_av_do_start (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
if ((p_scb->started == FALSE) && ((p_scb->role & BTA_AV_ROLE_START_INT) == 0)) {
p_scb->role |= BTA_AV_ROLE_START_INT;
bta_sys_busy(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->peer_addr);
bta_sys_busy(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), bta_av_cb.audio_open_cnt, p_scb->peer_addr);
AVDT_StartReq(&p_scb->avdt_handle, 1);
} else if (p_scb->started) {
p_scb->role |= BTA_AV_ROLE_START_INT;
@ -1969,7 +2009,7 @@ void bta_av_str_stopped (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
APPL_TRACE_ERROR("bta_av_str_stopped:audio_open_cnt=%d, p_data %p",
bta_av_cb.audio_open_cnt, p_data);
bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->peer_addr);
bta_sys_idle(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), bta_av_cb.audio_open_cnt, p_scb->peer_addr);
if ((bta_av_cb.features & BTA_AV_FEAT_MASTER) == 0 || bta_av_cb.audio_open_cnt == 1) {
policy |= HCI_ENABLE_MASTER_SLAVE_SWITCH;
}
@ -2239,7 +2279,7 @@ void bta_av_start_ok (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
if (p_data && (p_data->hdr.offset != BTA_AV_RS_NONE)) {
p_scb->wait &= ~BTA_AV_WAIT_ROLE_SW_BITS;
if (p_data->hdr.offset == BTA_AV_RS_FAIL) {
bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->peer_addr);
bta_sys_idle(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), bta_av_cb.audio_open_cnt, p_scb->peer_addr);
start.chnl = p_scb->chnl;
start.status = BTA_AV_FAIL_ROLE;
start.hndl = p_scb->hndl;
@ -2275,9 +2315,9 @@ void bta_av_start_ok (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
}
/* tell role manager to check M/S role */
bta_sys_conn_open(BTA_ID_AV, p_scb->app_id, p_scb->peer_addr);
bta_sys_conn_open(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), p_scb->app_id, p_scb->peer_addr);
bta_sys_busy(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->peer_addr);
bta_sys_busy(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), bta_av_cb.audio_open_cnt, p_scb->peer_addr);
if (p_scb->media_type == AVDT_MEDIA_AUDIO) {
/* in normal logic, conns should be bta_av_cb.audio_count - 1,
@ -2364,7 +2404,7 @@ void bta_av_start_failed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
UNUSED(p_data);
if (p_scb->started == FALSE && p_scb->co_started == FALSE) {
bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->peer_addr);
bta_sys_idle(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), bta_av_cb.audio_open_cnt, p_scb->peer_addr);
notify_start_failed(p_scb);
}
@ -2413,7 +2453,8 @@ void bta_av_str_closed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
event = BTA_AV_OPEN_EVT;
p_scb->open_status = BTA_AV_SUCCESS;
bta_sys_conn_close(BTA_ID_AV, p_scb->app_id, p_scb->peer_addr);
bta_sys_conn_close(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), p_scb->app_id, p_scb->peer_addr);
bta_av_cleanup(p_scb, p_data);
(*bta_av_cb.p_cback)(event, &data);
} else {
@ -2432,7 +2473,8 @@ void bta_av_str_closed (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
data.close.disc_rsn = p_scb->disc_rsn;
event = BTA_AV_CLOSE_EVT;
bta_sys_conn_close(BTA_ID_AV, p_scb->app_id, p_scb->peer_addr);
bta_sys_conn_close(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), p_scb->app_id, p_scb->peer_addr);
bta_av_cleanup(p_scb, p_data);
(*bta_av_cb.p_cback)(event, &data);
}
@ -2506,7 +2548,7 @@ void bta_av_suspend_cfm (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data)
p_scb->cong = FALSE;
}
bta_sys_idle(BTA_ID_AV, bta_av_cb.audio_open_cnt, p_scb->peer_addr);
bta_sys_idle(TSEP_TO_SYS_ID(p_scb->seps[p_scb->sep_idx].tsep), bta_av_cb.audio_open_cnt, p_scb->peer_addr);
if ((bta_av_cb.features & BTA_AV_FEAT_MASTER) == 0 || bta_av_cb.audio_open_cnt == 1) {
policy |= HCI_ENABLE_MASTER_SLAVE_SWITCH;
}

View File

@ -105,7 +105,7 @@ void BTA_AvDisable(void)
** Returns void
**
*******************************************************************************/
void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos)
void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos, UINT8 tsep)
{
tBTA_AV_API_REG *p_buf;
@ -122,6 +122,7 @@ void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id,
p_buf->app_id = app_id;
p_buf->p_app_data_cback = p_data_cback;
p_buf->bta_av_cos = bta_av_cos;
p_buf->tsep = tsep;
bta_sys_sendmsg(p_buf);
}
}

View File

@ -578,18 +578,20 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
}
/* Set the Capturing service class bit */
if (p_data->api_reg.tsep == AVDT_TSEP_SRC) {
cod.service = BTM_COD_SERVICE_CAPTURING;
} else {
#if (BTA_AV_SINK_INCLUDED == TRUE)
cod.service = BTM_COD_SERVICE_CAPTURING | BTM_COD_SERVICE_RENDERING;
#else
cod.service = BTM_COD_SERVICE_CAPTURING;
cod.service = BTM_COD_SERVICE_RENDERING;
#endif
}
utl_set_device_class(&cod, BTA_UTL_SET_COD_SERVICE_CLASS);
} /* if 1st channel */
/* get stream configuration and create stream */
/* memset(&cs.cfg,0,sizeof(tAVDT_CFG)); */
cs.cfg.num_codec = 1;
cs.tsep = AVDT_TSEP_SRC;
cs.tsep = p_data->api_reg.tsep;
/*
* memset of cs takes care setting call back pointers to null.
@ -637,11 +639,10 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
memcpy(&p_scb->cfg, &cs.cfg, sizeof(tAVDT_CFG));
while (index < BTA_AV_MAX_SEPS &&
(p_scb->p_cos->init)(&codec_type, cs.cfg.codec_info,
&cs.cfg.num_protect, cs.cfg.protect_info, index) == TRUE) {
&cs.cfg.num_protect, cs.cfg.protect_info, p_data->api_reg.tsep) == TRUE) {
#if (BTA_AV_SINK_INCLUDED == TRUE)
if (index == 1) {
cs.tsep = AVDT_TSEP_SNK;
if (p_data->api_reg.tsep == AVDT_TSEP_SNK) {
cs.p_data_cback = bta_av_stream_data_cback;
}
APPL_TRACE_DEBUG(" SEP Type = %d\n", cs.tsep);
@ -667,18 +668,20 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
}
if (!bta_av_cb.reg_audio) {
/* create the SDP records on the 1st audio channel */
bta_av_cb.sdp_a2d_handle = SDP_CreateRecord();
A2D_AddRecord(UUID_SERVCLASS_AUDIO_SOURCE, p_service_name, NULL,
A2D_SUPF_PLAYER, bta_av_cb.sdp_a2d_handle);
bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SOURCE);
if (p_data->api_reg.tsep == AVDT_TSEP_SRC) {
/* create the SDP records on the 1st audio channel */
bta_av_cb.sdp_a2d_handle = SDP_CreateRecord();
A2D_AddRecord(UUID_SERVCLASS_AUDIO_SOURCE, p_service_name, NULL,
A2D_SUPF_PLAYER, bta_av_cb.sdp_a2d_handle);
bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SOURCE);
} else {
#if (BTA_AV_SINK_INCLUDED == TRUE)
bta_av_cb.sdp_a2d_snk_handle = SDP_CreateRecord();
A2D_AddRecord(UUID_SERVCLASS_AUDIO_SINK, p_avk_service_name, NULL,
A2D_SUPF_PLAYER, bta_av_cb.sdp_a2d_snk_handle);
bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SINK);
bta_av_cb.sdp_a2d_snk_handle = SDP_CreateRecord();
A2D_AddRecord(UUID_SERVCLASS_AUDIO_SINK, p_avk_service_name, NULL,
A2D_SUPF_PLAYER, bta_av_cb.sdp_a2d_snk_handle);
bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SINK);
#endif
}
/* start listening when A2DP is registered */
if (bta_av_cb.features & BTA_AV_FEAT_RCTG) {
bta_av_rc_create(&bta_av_cb, AVCT_ACP, 0, BTA_AV_NUM_LINKS + 1);

View File

@ -94,6 +94,7 @@ enum {
BTA_AV_ROLE_RES,
BTA_AV_DELAY_CO,
BTA_AV_OPEN_AT_INC,
BTA_AV_OPEN_FAIL_SDP,
BTA_AV_NUM_SACTIONS
};
@ -199,7 +200,7 @@ static const UINT8 bta_av_sst_opening[][BTA_AV_NUM_COLS] = {
/* CI_SETCONFIG_OK_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
/* CI_SETCONFIG_FAIL_EVT */ {BTA_AV_SIGNORE, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
/* SDP_DISC_OK_EVT */ {BTA_AV_CONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
/* SDP_DISC_FAIL_EVT */ {BTA_AV_CONNECT_REQ, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
/* SDP_DISC_FAIL_EVT */ {BTA_AV_FREE_SDB, BTA_AV_OPEN_FAIL_SDP, BTA_AV_INIT_SST },
/* STR_DISC_OK_EVT */ {BTA_AV_DISC_RESULTS, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },
/* STR_DISC_FAIL_EVT */ {BTA_AV_OPEN_FAILED, BTA_AV_SIGNORE, BTA_AV_CLOSING_SST },
/* STR_GETCAP_OK_EVT */ {BTA_AV_GETCAP_RESULTS, BTA_AV_SIGNORE, BTA_AV_OPENING_SST },

View File

@ -153,48 +153,11 @@ enum {
#define BTA_AV_MULTI_AV_SUPPORTED 0x01
#define BTA_AV_MULTI_AV_IN_USE 0x02
#define TSEP_TO_SYS_ID(x) ((x) == AVDT_TSEP_SRC ? BTA_ID_AV : BTA_ID_AVK)
/*****************************************************************************
** Data types
*****************************************************************************/
#if 0
/* function types for call-out functions */
typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info,
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
typedef void (*tBTA_AV_CO_DISC_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps,
UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local);
typedef UINT8 (*tBTA_AV_CO_GETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
UINT8 *p_codec_info, UINT8 *p_sep_info_idx, UINT8 seid,
UINT8 *p_num_protect, UINT8 *p_protect_info);
typedef void (*tBTA_AV_CO_SETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
UINT8 *p_codec_info, UINT8 seid, BD_ADDR addr,
UINT8 num_protect, UINT8 *p_protect_info,
UINT8 t_local_sep, UINT8 avdt_handle);
typedef void (*tBTA_AV_CO_OPEN) (tBTA_AV_HNDL hndl,
tBTA_AV_CODEC codec_type, UINT8 *p_codec_info,
UINT16 mtu);
typedef void (*tBTA_AV_CO_CLOSE) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT16 mtu);
typedef void (*tBTA_AV_CO_START) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, UINT8 *p_codec_info, BOOLEAN *p_no_rtp_hdr);
typedef void (*tBTA_AV_CO_STOP) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type);
typedef void *(*tBTA_AV_CO_DATAPATH) (tBTA_AV_CODEC codec_type,
UINT32 *p_len, UINT32 *p_timestamp);
typedef void (*tBTA_AV_CO_DELAY) (tBTA_AV_HNDL hndl, UINT16 delay);
/* the call-out functions for one stream */
typedef struct {
tBTA_AV_CO_INIT init;
tBTA_AV_CO_DISC_RES disc_res;
tBTA_AV_CO_GETCFG getcfg;
tBTA_AV_CO_SETCFG setcfg;
tBTA_AV_CO_OPEN open;
tBTA_AV_CO_CLOSE close;
tBTA_AV_CO_START start;
tBTA_AV_CO_STOP stop;
tBTA_AV_CO_DATAPATH data;
tBTA_AV_CO_DELAY delay;
} tBTA_AV_CO_FUNCTS;
#endif
/* data type for BTA_AV_API_ENABLE_EVT */
typedef struct {
BT_HDR hdr;
@ -208,7 +171,8 @@ typedef struct {
BT_HDR hdr;
char p_service_name[BTA_SERVICE_NAME_LEN + 1];
UINT8 app_id;
tBTA_AV_DATA_CBACK *p_app_data_cback;
UINT8 tsep; // local SEP type
tBTA_AV_DATA_CBACK *p_app_data_cback;
tBTA_AV_CO_FUNCTS *bta_av_cos;
} tBTA_AV_API_REG;
@ -697,6 +661,7 @@ extern void bta_av_switch_role (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
extern void bta_av_role_res (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
extern void bta_av_delay_co (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
extern void bta_av_open_at_inc (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
extern void bta_av_open_fail_sdp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);
/* ssm action functions - vdp specific */
extern void bta_av_do_disc_vdp (tBTA_AV_SCB *p_scb, tBTA_AV_DATA *p_data);

View File

@ -374,6 +374,12 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
bta_sys_hw_unregister( BTA_SYS_HW_BLUETOOTH );
/* notify BTA DM is now unactive */
bta_dm_cb.is_bta_dm_active = FALSE;
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
#if (GATTC_INCLUDED == TRUE && GATTC_CACHE_NVS == TRUE)
/* clear the gattc cache address list */
bta_gattc_co_cache_addr_deinit();
#endif
#endif
} else if ( status == BTA_SYS_HW_ON_EVT ) {
/* FIXME: We should not unregister as the SYS shall invoke this callback on a H/W error.
* We need to revisit when this platform has more than one BLuetooth H/W chip */
@ -403,7 +409,7 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
BTM_SetDeviceClass (dev_class);
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
#if (GATTC_INCLUDED == TRUE)
#if (GATTC_INCLUDED == TRUE && GATTC_CACHE_NVS == TRUE)
// load the gattc cache address list
bta_gattc_co_cache_addr_init();
#endif /* #if (GATTC_INCLUDED = TRUE) */
@ -596,16 +602,16 @@ void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data)
if (p_data->read_tx_power.read_tx_power_cb != NULL) {
BTM_BleReadAdvTxPower(p_data->read_tx_power.read_tx_power_cb);
} else {
APPL_TRACE_ERROR("%s(), the callback function cann't be NULL.", __func__);
APPL_TRACE_ERROR("%s(), the callback function can't be NULL.", __func__);
}
}
void bta_dm_ble_read_rssi(tBTA_DM_MSG *p_data)
{
if (p_data->rssi.read_rssi_cb != NULL) {
BTM_ReadRSSI(p_data->rssi.remote_addr, p_data->rssi.read_rssi_cb);
BTM_ReadRSSI(p_data->rssi.remote_addr, p_data->rssi.transport, p_data->rssi.read_rssi_cb);
} else {
APPL_TRACE_ERROR("%s(), the callback function cann't be NULL.", __func__);
APPL_TRACE_ERROR("%s(), the callback function can't be NULL.", __func__);
}
}
@ -692,25 +698,29 @@ void bta_dm_set_visibility(tBTA_DM_MSG *p_data)
** Description Removes device, Disconnects ACL link if required.
****
*******************************************************************************/
void bta_dm_process_remove_device(BD_ADDR bd_addr)
static void bta_dm_process_remove_device(BD_ADDR bd_addr, tBT_TRANSPORT transport)
{
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
/* need to remove all pending background connection before unpair */
BTA_GATTC_CancelOpen(0, bd_addr, FALSE);
#endif
BTM_SecDeleteDevice(bd_addr);
BTM_SecDeleteDevice(bd_addr, transport);
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
/* remove all cached GATT information */
BTA_GATTC_Refresh(bd_addr);
BTA_GATTC_Refresh(bd_addr, false);
#endif
if (bta_dm_cb.p_sec_cback) {
tBTA_DM_SEC sec_event;
bdcpy(sec_event.link_down.bd_addr, bd_addr);
sec_event.link_down.status = HCI_SUCCESS;
bta_dm_cb.p_sec_cback(BTA_DM_DEV_UNPAIRED_EVT, &sec_event);
if (transport == BT_TRANSPORT_LE){
bta_dm_cb.p_sec_cback(BTA_DM_BLE_DEV_UNPAIRED_EVT, &sec_event);
} else {
bta_dm_cb.p_sec_cback(BTA_DM_DEV_UNPAIRED_EVT, &sec_event);
}
}
}
@ -728,32 +738,22 @@ void bta_dm_remove_device(tBTA_DM_MSG *p_data)
return;
}
BD_ADDR other_address;
bdcpy(other_address, p_dev->bd_addr);
/* If ACL exists for the device in the remove_bond message*/
BOOLEAN continue_delete_dev = FALSE;
UINT8 other_transport = BT_TRANSPORT_INVALID;
UINT8 transport = p_dev->transport;
if (BTM_IsAclConnectionUp(p_dev->bd_addr, BT_TRANSPORT_LE) ||
BTM_IsAclConnectionUp(p_dev->bd_addr, BT_TRANSPORT_BR_EDR)) {
if (BTM_IsAclConnectionUp(p_dev->bd_addr, transport)) {
APPL_TRACE_DEBUG("%s: ACL Up count %d", __func__, bta_dm_cb.device_list.count);
continue_delete_dev = FALSE;
/* Take the link down first, and mark the device for removal when disconnected */
for (int i = 0; i < bta_dm_cb.device_list.count; i++) {
if (!bdcmp(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, p_dev->bd_addr)) {
if (!bdcmp(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, p_dev->bd_addr)
&& bta_dm_cb.device_list.peer_device[i].transport == transport) {
bta_dm_cb.device_list.peer_device[i].conn_state = BTA_DM_UNPAIRING;
btm_remove_acl( p_dev->bd_addr, bta_dm_cb.device_list.peer_device[i].transport);
APPL_TRACE_DEBUG("%s:transport = %d", __func__,
bta_dm_cb.device_list.peer_device[i].transport);
/* save the other transport to check if device is connected on other_transport */
if (bta_dm_cb.device_list.peer_device[i].transport == BT_TRANSPORT_LE) {
other_transport = BT_TRANSPORT_BR_EDR;
} else {
other_transport = BT_TRANSPORT_LE;
}
break;
}
}
@ -761,35 +761,9 @@ void bta_dm_remove_device(tBTA_DM_MSG *p_data)
continue_delete_dev = TRUE;
}
// If it is DUMO device and device is paired as different address, unpair that device
// if different address
BOOLEAN continue_delete_other_dev = FALSE;
if ((other_transport && (BTM_ReadConnectedTransportAddress(other_address, other_transport))) ||
(!other_transport && (BTM_ReadConnectedTransportAddress(other_address, BT_TRANSPORT_BR_EDR) ||
BTM_ReadConnectedTransportAddress(other_address, BT_TRANSPORT_LE)))) {
continue_delete_other_dev = FALSE;
/* Take the link down first, and mark the device for removal when disconnected */
for (int i = 0; i < bta_dm_cb.device_list.count; i++) {
if (!bdcmp(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, other_address)) {
bta_dm_cb.device_list.peer_device[i].conn_state = BTA_DM_UNPAIRING;
btm_remove_acl(other_address, bta_dm_cb.device_list.peer_device[i].transport);
break;
}
}
} else {
APPL_TRACE_DEBUG("%s: continue to delete the other dev ", __func__);
continue_delete_other_dev = TRUE;
}
/* Delete the device mentioned in the msg */
if (continue_delete_dev) {
bta_dm_process_remove_device(p_dev->bd_addr);
}
/* Delete the other paired device too */
BD_ADDR dummy_bda = {0};
if (continue_delete_other_dev && (bdcmp(other_address, dummy_bda) != 0)) {
bta_dm_process_remove_device(other_address);
bta_dm_process_remove_device(p_dev->bd_addr, transport);
}
}
@ -880,14 +854,14 @@ void bta_dm_close_acl(tBTA_DM_MSG *p_data)
}
/* if to remove the device from security database ? do it now */
else if (p_remove_acl->remove_dev) {
if (!BTM_SecDeleteDevice(p_remove_acl->bd_addr)) {
if (!BTM_SecDeleteDevice(p_remove_acl->bd_addr, p_remove_acl->transport)) {
APPL_TRACE_ERROR("delete device from security database failed.");
}
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
/* need to remove all pending background connection if any */
BTA_GATTC_CancelOpen(0, p_remove_acl->bd_addr, FALSE);
/* remove all cached GATT information */
BTA_GATTC_Refresh(p_remove_acl->bd_addr);
BTA_GATTC_Refresh(p_remove_acl->bd_addr, false);
#endif
}
/* otherwise, no action needed */
@ -1000,6 +974,21 @@ void bta_dm_bond_cancel (tBTA_DM_MSG *p_data)
}
/*******************************************************************************
**
** Function bta_dm_set_pin_type
**
** Description Set the pin type and fixed pin
**
**
** Returns void
**
*******************************************************************************/
void bta_dm_set_pin_type (tBTA_DM_MSG *p_data)
{
BTM_SetPinType (p_data->set_pin_type.pin_type, p_data->set_pin_type.p_pin, p_data->set_pin_type.pin_len);
}
/*******************************************************************************
**
** Function bta_dm_pin_reply
@ -3283,7 +3272,7 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data)
}
if ( bta_dm_cb.device_list.peer_device[i].conn_state == BTA_DM_UNPAIRING ) {
if (BTM_SecDeleteDevice(bta_dm_cb.device_list.peer_device[i].peer_bdaddr)) {
if (BTM_SecDeleteDevice(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, bta_dm_cb.device_list.peer_device[i].transport)) {
issue_unpair_cb = TRUE;
}
@ -3331,12 +3320,12 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data)
}
}
if (conn.link_down.is_removed) {
BTM_SecDeleteDevice(p_bda);
BTM_SecDeleteDevice(p_bda, p_data->acl_change.transport);
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
/* need to remove all pending background connection */
BTA_GATTC_CancelOpen(0, p_bda, FALSE);
/* remove all cached GATT information */
BTA_GATTC_Refresh(p_bda);
BTA_GATTC_Refresh(p_bda, false);
#endif
}
@ -3345,7 +3334,11 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data)
if ( bta_dm_cb.p_sec_cback ) {
bta_dm_cb.p_sec_cback(BTA_DM_LINK_DOWN_EVT, &conn);
if ( issue_unpair_cb ) {
bta_dm_cb.p_sec_cback(BTA_DM_DEV_UNPAIRED_EVT, &conn);
if (p_data->acl_change.transport == BT_TRANSPORT_LE) {
bta_dm_cb.p_sec_cback(BTA_DM_BLE_DEV_UNPAIRED_EVT, &conn);
} else {
bta_dm_cb.p_sec_cback(BTA_DM_DEV_UNPAIRED_EVT, &conn);
}
}
}
}
@ -3505,12 +3498,12 @@ static void bta_dm_remove_sec_dev_entry(BD_ADDR remote_bd_addr)
APPL_TRACE_ERROR(" %s Device does not exist in DB", __FUNCTION__);
}
} else {
BTM_SecDeleteDevice (remote_bd_addr);
BTM_SecDeleteDevice (remote_bd_addr, bta_dm_cb.device_list.peer_device[index].transport);
#if (BLE_INCLUDED == TRUE && GATTC_INCLUDED == TRUE)
/* need to remove all pending background connection */
BTA_GATTC_CancelOpen(0, remote_bd_addr, FALSE);
/* remove all cached GATT information */
BTA_GATTC_Refresh(remote_bd_addr);
BTA_GATTC_Refresh(remote_bd_addr, false);
#endif
}
}
@ -4256,9 +4249,8 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
memset(&sec_event, 0, sizeof(tBTA_DM_SEC));
switch (event) {
case BTM_LE_IO_REQ_EVT:
// #if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE)
case BTM_LE_IO_REQ_EVT: {
// #if (BT_SSP_INCLUDED == TRUE)
bta_dm_co_ble_io_req(bda,
&p_data->io_req.io_cap,
&p_data->io_req.oob_data,
@ -4273,6 +4265,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
APPL_TRACE_EVENT("io mitm: %d oob_data:%d\n", p_data->io_req.auth_req, p_data->io_req.oob_data);
break;
}
case BTM_LE_SEC_REQUEST_EVT:
bdcpy(sec_event.ble_req.bd_addr, bda);
@ -4348,7 +4341,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
}
}
sec_event.auth_cmpl.auth_mode = p_data->complt.auth_mode;
if (bta_dm_cb.p_sec_cback) {
//bta_dm_cb.p_sec_cback(BTA_DM_AUTH_CMPL_EVT, &sec_event);
bta_dm_cb.p_sec_cback(BTA_DM_BLE_AUTH_CMPL_EVT, &sec_event);
@ -4466,6 +4459,10 @@ void bta_dm_ble_passkey_reply (tBTA_DM_MSG *p_data)
}
void bta_dm_ble_set_static_passkey(tBTA_DM_MSG *p_data)
{
BTM_BleSetStaticPasskey(p_data->ble_set_static_passkey.add, p_data->ble_set_static_passkey.static_passkey);
}
/*******************************************************************************
**
** Function bta_dm_ble_confirm_reply
@ -4659,7 +4656,7 @@ void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data)
void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data)
{
if (p_data->hdr.event != BTA_DM_API_BLE_STOP_ADV_EVT) {
APPL_TRACE_ERROR("Invalid BTA event,cann't stop the BLE adverting\n");
APPL_TRACE_ERROR("Invalid BTA event,can't stop the BLE adverting\n");
}
btm_ble_stop_adv();

View File

@ -206,12 +206,13 @@ void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb)
}
}
void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_CMPL_CB *cmpl_cb)
void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb)
{
tBTA_DM_API_READ_RSSI *p_msg;
if ((p_msg = (tBTA_DM_API_READ_RSSI *)osi_malloc(sizeof(tBTA_DM_API_READ_RSSI))) != NULL) {
p_msg->hdr.event = BTA_DM_API_BLE_READ_RSSI_EVT;
memcpy(p_msg->remote_addr, remote_addr, sizeof(BD_ADDR));
p_msg->transport = transport;
p_msg->read_rssi_cb = cmpl_cb;
bta_sys_sendmsg(p_msg);
}
@ -435,6 +436,29 @@ void BTA_DmBondCancel(BD_ADDR bd_addr)
}
/*******************************************************************************
**
** Function BTA_DMSetPinType
**
** Description This function set pin type as BTM_PIN_TYPE_FIXED or BTM_PIN_TYPE_VARIABLE
**
**
** Returns void
**
*******************************************************************************/
void BTA_DMSetPinType (UINT8 pin_type, UINT8 *pin_code, UINT8 pin_code_len)
{
tBTA_DM_API_SET_PIN_TYPE *p_msg;
if ((p_msg = (tBTA_DM_API_SET_PIN_TYPE *) osi_malloc(sizeof(tBTA_DM_API_SET_PIN_TYPE))) != NULL) {
p_msg->hdr.event = BTA_DM_API_SET_PIN_TYPE_EVT;
p_msg->pin_type = pin_type;
p_msg->pin_len = pin_code_len;
memcpy(p_msg->p_pin, pin_code, pin_code_len);
bta_sys_sendmsg(p_msg);
}
}
/*******************************************************************************
**
** Function BTA_DmPinReply
@ -447,7 +471,6 @@ void BTA_DmBondCancel(BD_ADDR bd_addr)
**
*******************************************************************************/
void BTA_DmPinReply(BD_ADDR bd_addr, BOOLEAN accept, UINT8 pin_len, UINT8 *p_pin)
{
tBTA_DM_API_PIN_REPLY *p_msg;
@ -569,7 +592,7 @@ void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class, LINK_KEY link_key,
** Returns void
**
*******************************************************************************/
tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr)
tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr, tBT_TRANSPORT transport)
{
tBTA_DM_API_REMOVE_DEVICE *p_msg;
@ -578,6 +601,7 @@ tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr)
p_msg->hdr.event = BTA_DM_API_REMOVE_DEVICE_EVT;
bdcpy(p_msg->bd_addr, bd_addr);
p_msg->transport = transport;
bta_sys_sendmsg(p_msg);
} else {
return BTA_FAILURE;
@ -801,6 +825,21 @@ void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey)
bta_sys_sendmsg(p_msg);
}
}
void BTA_DmBleSetStaticPasskey(bool add, uint32_t passkey)
{
tBTA_DM_API_SET_DEFAULT_PASSKEY *p_msg;
if ((p_msg = (tBTA_DM_API_SET_DEFAULT_PASSKEY *) osi_malloc(sizeof(tBTA_DM_API_SET_DEFAULT_PASSKEY))) != NULL) {
memset(p_msg, 0, sizeof(tBTA_DM_API_SET_DEFAULT_PASSKEY));
p_msg->hdr.event = BTA_DM_API_BLE_SET_STATIC_PASSKEY_EVT;
p_msg->add = add;
p_msg->static_passkey = passkey;
bta_sys_sendmsg(p_msg);
}
}
/*******************************************************************************
**
** Function BTA_DmBleConfirmReply

View File

@ -31,6 +31,10 @@
#endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
#include "common/bte_appl.h"
#define BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_DISABLE 0
#define BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_ENABLE 1
tBTE_APPL_CFG bte_appl_cfg = {
#if SMP_INCLUDED == TRUE
BTA_LE_AUTH_REQ_SC_MITM_BOND, // Authentication requirements
@ -40,7 +44,8 @@ tBTE_APPL_CFG bte_appl_cfg = {
BTM_LOCAL_IO_CAPS_BLE,
BTM_BLE_INITIATOR_KEY_SIZE,
BTM_BLE_RESPONDER_KEY_SIZE,
BTM_BLE_MAX_KEY_SIZE
BTM_BLE_MAX_KEY_SIZE,
BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_DISABLE
};
#endif
@ -319,7 +324,7 @@ void bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
#endif ///SMP_INCLUDED == TRUE
}
void bta_dm_co_ble_set_io_cap(UINT8 ble_io_cap)
void bta_dm_co_ble_set_io_cap(UINT8 ble_io_cap)
{
#if (SMP_INCLUDED == TRUE)
if(ble_io_cap < BTM_IO_CAP_MAX ) {
@ -330,7 +335,7 @@ void bta_dm_co_ble_set_io_cap(UINT8 ble_io_cap)
#endif ///SMP_INCLUDED == TRUE
}
void bta_dm_co_ble_set_auth_req(UINT8 ble_auth_req)
void bta_dm_co_ble_set_auth_req(UINT8 ble_auth_req)
{
#if (SMP_INCLUDED == TRUE)
bte_appl_cfg.ble_auth_req = ble_auth_req;
@ -363,5 +368,32 @@ void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size)
}
#endif ///SMP_INCLUDED == TRUE
}
void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable)
{
#if (SMP_INCLUDED == TRUE)
if (enable) {
enable = BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_ENABLE;
}
bte_appl_cfg.ble_accept_auth_enable = enable;
#endif ///SMP_INCLUDED == TRUE
}
UINT8 bta_dm_co_ble_get_accept_auth_enable(void)
{
#if (SMP_INCLUDED == TRUE)
return bte_appl_cfg.ble_accept_auth_enable;
#endif ///SMP_INCLUDED == TRUE
return 0;
}
UINT8 bta_dm_co_ble_get_auth_req(void)
{
#if (SMP_INCLUDED == TRUE)
return bte_appl_cfg.ble_auth_req;
#endif ///SMP_INCLUDED == TRUE
return 0;
}
#endif

View File

@ -53,33 +53,34 @@ typedef void (*tBTA_DM_ACTION)(tBTA_DM_MSG *p_data);
const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
/* device manager local device API events */
bta_dm_enable, /* 0 BTA_DM_API_ENABLE_EVT */
bta_dm_disable, /* 1 BTA_DM_API_DISABLE_EVT */
bta_dm_set_dev_name, /* 2 BTA_DM_API_SET_NAME_EVT */
bta_dm_set_visibility, /* 3 BTA_DM_API_SET_VISIBILITY_EVT */
bta_dm_acl_change, /* 8 BTA_DM_ACL_CHANGE_EVT */
bta_dm_add_device, /* 9 BTA_DM_API_ADD_DEVICE_EVT */
bta_dm_close_acl, /* 10 BTA_DM_API_REMOVE_ACL_EVT */
bta_dm_enable, /* BTA_DM_API_ENABLE_EVT */
bta_dm_disable, /* BTA_DM_API_DISABLE_EVT */
bta_dm_set_dev_name, /* BTA_DM_API_SET_NAME_EVT */
bta_dm_set_visibility, /* BTA_DM_API_SET_VISIBILITY_EVT */
bta_dm_acl_change, /* BTA_DM_ACL_CHANGE_EVT */
bta_dm_add_device, /* BTA_DM_API_ADD_DEVICE_EVT */
bta_dm_close_acl, /* BTA_DM_API_REMOVE_ACL_EVT */
#if (SMP_INCLUDED == TRUE)
/* security API events */
bta_dm_bond, /* 11 BTA_DM_API_BOND_EVT */
bta_dm_bond_cancel, /* 12 BTA_DM_API_BOND_CANCEL_EVT */
bta_dm_pin_reply, /* 13 BTA_DM_API_PIN_REPLY_EVT */
bta_dm_bond, /* BTA_DM_API_BOND_EVT */
bta_dm_bond_cancel, /* BTA_DM_API_BOND_CANCEL_EVT */
bta_dm_set_pin_type, /* BTA_DM_API_SET_PIN_TYPE_EVT */
bta_dm_pin_reply, /* BTA_DM_API_PIN_REPLY_EVT */
#endif ///SMP_INCLUDED == TRUE
#if (BTA_DM_PM_INCLUDED == TRUE)
/* power manger events */
bta_dm_pm_btm_status, /* 16 BTA_DM_PM_BTM_STATUS_EVT */
bta_dm_pm_timer, /* 17 BTA_DM_PM_TIMER_EVT*/
bta_dm_pm_btm_status, /* BTA_DM_PM_BTM_STATUS_EVT */
bta_dm_pm_timer, /* BTA_DM_PM_TIMER_EVT */
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
/* simple pairing events */
#if (SMP_INCLUDED == TRUE)
bta_dm_confirm, /* 18 BTA_DM_API_CONFIRM_EVT */
bta_dm_confirm, /* BTA_DM_API_CONFIRM_EVT */
bta_dm_set_encryption, /* BTA_DM_API_SET_ENCRYPTION_EVT */
#endif ///SMP_INCLUDED == TRUE
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
bta_dm_loc_oob, /* 20 BTA_DM_API_LOC_OOB_EVT */
bta_dm_ci_io_req_act, /* 21 BTA_DM_CI_IO_REQ_EVT */
bta_dm_ci_rmt_oob_act, /* 22 BTA_DM_CI_RMT_OOB_EVT */
bta_dm_loc_oob, /* BTA_DM_API_LOC_OOB_EVT */
bta_dm_ci_io_req_act, /* BTA_DM_CI_IO_REQ_EVT */
bta_dm_ci_rmt_oob_act, /* BTA_DM_CI_RMT_OOB_EVT */
#endif /* BTM_OOB_INCLUDED */
@ -88,6 +89,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_add_blekey, /* BTA_DM_API_ADD_BLEKEY_EVT */
bta_dm_add_ble_device, /* BTA_DM_API_ADD_BLEDEVICE_EVT */
bta_dm_ble_passkey_reply, /* BTA_DM_API_BLE_PASSKEY_REPLY_EVT */
bta_dm_ble_set_static_passkey, /* BTA_DM_API_BLE_SET_STATIC_PASSKEY_EVT */
bta_dm_ble_confirm_reply, /* BTA_DM_API_BLE_CONFIRM_REPLY_EVT */
bta_dm_security_grant,
#endif ///SMP_INCLUDED == TRUE
@ -96,18 +98,18 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_ble_set_conn_scan_params, /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */
bta_dm_ble_set_scan_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */
bta_dm_ble_set_scan_fil_params, /* BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT */
bta_dm_ble_observe, /* BTA_DM_API_BLE_OBSERVE_EVT*/
bta_dm_ble_observe, /* BTA_DM_API_BLE_OBSERVE_EVT */
bta_dm_ble_scan, /* BTA_DM_API_BLE_SCAN_EVT */
bta_dm_ble_update_conn_params, /* BTA_DM_API_UPDATE_CONN_PARAM_EVT */
/* This handler function added by
Yulong at 2016/9/9 to support the
random address setting for the APP */
bta_dm_ble_set_rand_address, /* BTA_DM_API_SET_RAND_ADDR_EVT*/
bta_dm_ble_set_rand_address, /* BTA_DM_API_SET_RAND_ADDR_EVT */
/* This handler function added by
Yulong at 2016/10/19 to support
stop the ble advertising setting
by the APP */
bta_dm_ble_stop_advertising, /* BTA_DM_API_BLE_STOP_ADV_EVT*/
bta_dm_ble_stop_advertising, /* BTA_DM_API_BLE_STOP_ADV_EVT */
#if BLE_PRIVACY_SPT == TRUE
bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */
#endif
@ -119,7 +121,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
data to HCI */
bta_dm_ble_set_adv_config_raw, /* BTA_DM_API_BLE_SET_ADV_CONFIG_RAW_EVT */
bta_dm_ble_set_scan_rsp, /* BTA_DM_API_BLE_SET_SCAN_RSP_EVT */
/* New function to allow set raw scan
/* New function to allow set raw scan
response data to HCI */
bta_dm_ble_set_scan_rsp_raw, /* BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT */
bta_dm_ble_broadcast, /* BTA_DM_API_BLE_BROADCAST_EVT */
@ -129,10 +131,10 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_scan_filter_param_setup, /* BTA_DM_API_SCAN_FILTER_SETUP_EVT */
bta_dm_enable_scan_filter, /* BTA_DM_API_SCAN_FILTER_ENABLE_EVT */
#endif
bta_dm_ble_multi_adv_enb, /* BTA_DM_API_BLE_MULTI_ADV_ENB_EVT*/
bta_dm_ble_multi_adv_upd_param, /* BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT */
bta_dm_ble_multi_adv_data, /* BTA_DM_API_BLE_MULTI_ADV_DATA_EVT */
btm_dm_ble_multi_adv_disable, /* BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT */
bta_dm_ble_multi_adv_enb, /* BTA_DM_API_BLE_MULTI_ADV_ENB_EVT */
bta_dm_ble_multi_adv_upd_param, /* BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT */
bta_dm_ble_multi_adv_data, /* BTA_DM_API_BLE_MULTI_ADV_DATA_EVT */
btm_dm_ble_multi_adv_disable, /* BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT */
bta_dm_ble_setup_storage, /* BTA_DM_API_BLE_SETUP_STORAGE_EVT */
bta_dm_ble_enable_batch_scan, /* BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT */
bta_dm_ble_disable_batch_scan, /* BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT */
@ -142,9 +144,9 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
bta_dm_ble_disconnect, /* BTA_DM_API_BLE_DISCONNECT_EVT */
#endif
bta_dm_enable_test_mode, /* BTA_DM_API_ENABLE_TEST_MODE_EVT */
bta_dm_disable_test_mode, /* BTA_DM_API_DISABLE_TEST_MODE_EVT */
bta_dm_execute_callback, /* BTA_DM_API_EXECUTE_CBACK_EVT */
bta_dm_enable_test_mode, /* BTA_DM_API_ENABLE_TEST_MODE_EVT */
bta_dm_disable_test_mode, /* BTA_DM_API_DISABLE_TEST_MODE_EVT */
bta_dm_execute_callback, /* BTA_DM_API_EXECUTE_CBACK_EVT */
bta_dm_remove_all_acl, /* BTA_DM_API_REMOVE_ALL_ACL_EVT */
bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */

View File

@ -61,6 +61,7 @@ enum {
/* security API events */
BTA_DM_API_BOND_EVT,
BTA_DM_API_BOND_CANCEL_EVT,
BTA_DM_API_SET_PIN_TYPE_EVT,
BTA_DM_API_PIN_REPLY_EVT,
#endif ///SMP_INCLUDED == TRUE
#if (BTA_DM_PM_INCLUDED == TRUE)
@ -86,6 +87,7 @@ enum {
BTA_DM_API_ADD_BLEKEY_EVT,
BTA_DM_API_ADD_BLEDEVICE_EVT,
BTA_DM_API_BLE_PASSKEY_REPLY_EVT,
BTA_DM_API_BLE_SET_STATIC_PASSKEY_EVT,
BTA_DM_API_BLE_CONFIRM_REPLY_EVT,
BTA_DM_API_BLE_SEC_GRANT_EVT,
#endif ///SMP_INCLUDED == TRUE
@ -196,6 +198,7 @@ typedef struct {
typedef struct {
BT_HDR hdr;
BD_ADDR remote_addr;
tBTA_TRANSPORT transport;
tBTA_CMPL_CB *read_rssi_cb;
}tBTA_DM_API_READ_RSSI;
@ -270,6 +273,14 @@ typedef struct {
tBTA_TRANSPORT transport;
} tBTA_DM_API_BOND_CANCEL;
/* data type for BTA_DM_API_SET_PIN_TYPE_EVT */
typedef struct {
BT_HDR hdr;
UINT8 pin_type;
UINT8 pin_len;
UINT8 p_pin[PIN_CODE_LEN];
} tBTA_DM_API_SET_PIN_TYPE;
/* data type for BTA_DM_API_PIN_REPLY_EVT */
typedef struct {
BT_HDR hdr;
@ -391,6 +402,7 @@ typedef struct {
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
UINT8 transport;
} tBTA_DM_API_REMOVE_DEVICE;
/* data type for BTA_DM_API_EXECUTE_CBACK_EVT */
@ -433,6 +445,12 @@ typedef struct {
UINT32 passkey;
} tBTA_DM_API_PASSKEY_REPLY;
typedef struct {
BT_HDR hdr;
BOOLEAN add;
UINT32 static_passkey;
} tBTA_DM_API_SET_DEFAULT_PASSKEY;
typedef struct {
BT_HDR hdr;
BD_ADDR bd_addr;
@ -742,6 +760,7 @@ typedef union {
tBTA_DM_API_BOND_CANCEL bond_cancel;
tBTA_DM_API_SET_PIN_TYPE set_pin_type;
tBTA_DM_API_PIN_REPLY pin_reply;
tBTA_DM_API_LOC_OOB loc_oob;
@ -775,6 +794,7 @@ typedef union {
tBTA_DM_API_ADD_BLEKEY add_ble_key;
tBTA_DM_API_ADD_BLE_DEVICE add_ble_device;
tBTA_DM_API_PASSKEY_REPLY ble_passkey_reply;
tBTA_DM_API_SET_DEFAULT_PASSKEY ble_set_static_passkey;
tBTA_DM_API_BLE_SEC_GRANT ble_sec_grant;
tBTA_DM_API_BLE_SET_BG_CONN_TYPE ble_set_bd_conn_type;
tBTA_DM_API_BLE_CONN_PARAMS ble_set_conn_params;
@ -1164,6 +1184,7 @@ extern void bta_dm_set_scan_config(tBTA_DM_MSG *p_data);
extern void bta_dm_vendor_spec_command(tBTA_DM_MSG *p_data);
extern void bta_dm_bond (tBTA_DM_MSG *p_data);
extern void bta_dm_bond_cancel (tBTA_DM_MSG *p_data);
extern void bta_dm_set_pin_type (tBTA_DM_MSG *p_data);
extern void bta_dm_pin_reply (tBTA_DM_MSG *p_data);
extern void bta_dm_acl_change(tBTA_DM_MSG *p_data);
extern void bta_dm_add_device (tBTA_DM_MSG *p_data);
@ -1176,6 +1197,7 @@ extern void bta_dm_add_ampkey (tBTA_DM_MSG *p_data);
extern void bta_dm_add_blekey (tBTA_DM_MSG *p_data);
extern void bta_dm_add_ble_device (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_passkey_reply (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_static_passkey(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_confirm_reply (tBTA_DM_MSG *p_data);
extern void bta_dm_security_grant (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_bg_conn_type (tBTA_DM_MSG *p_data);

View File

@ -65,6 +65,7 @@ static void bta_gattc_pop_command_to_send(tBTA_GATTC_CLCB *p_clcb);
static void bta_gattc_deregister_cmpl(tBTA_GATTC_RCB *p_clreg);
static void bta_gattc_enc_cmpl_cback(tGATT_IF gattc_if, BD_ADDR bda);
static void bta_gattc_cong_cback (UINT16 conn_id, BOOLEAN congested);
static void bta_gattc_req_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type, tGATTS_DATA *p_data);
static tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_id, BD_ADDR remote_bda);
static tGATT_CBACK bta_gattc_cl_cback = {
@ -72,7 +73,7 @@ static tGATT_CBACK bta_gattc_cl_cback = {
bta_gattc_cmpl_cback,
bta_gattc_disc_res_cback,
bta_gattc_disc_cmpl_cback,
NULL,
bta_gattc_req_cback,
bta_gattc_enc_cmpl_cback,
bta_gattc_cong_cback
};
@ -666,11 +667,16 @@ void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
if (p_clcb->p_srcb->p_srvc_cache == NULL ||
p_clcb->p_srcb->state != BTA_GATTC_SERV_IDLE) {
if (p_clcb->p_srcb->state == BTA_GATTC_SERV_IDLE) {
#if (GATTC_CACHE_NVS == TRUE)
p_clcb->p_srcb->state = BTA_GATTC_SERV_LOAD;
if (bta_gattc_cache_load(p_clcb)) {
p_clcb->p_srcb->state = BTA_GATTC_SERV_IDLE;
bta_gattc_reset_discover_st(p_clcb->p_srcb, BTA_GATT_OK);
} else { /* cache is building */
//register service change
bta_gattc_register_service_change_notify(p_clcb->bta_conn_id, p_clcb->bda);
} else
#endif
{ /* cache is building */
p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC;
/* cache load failure, start discovery */
bta_gattc_start_discover(p_clcb, NULL);
@ -1016,9 +1022,10 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
list_free(p_clcb->p_srcb->p_srvc_cache);
p_clcb->p_srcb->p_srvc_cache = NULL;
}
#if(GATTC_CACHE_NVS == TRUE)
/* used to reset cache in application */
bta_gattc_cache_reset(p_clcb->p_srcb->server_bda);
#endif
}
if (p_clcb->p_srcb && p_clcb->p_srcb->p_srvc_list) {
/* release pending attribute list buffer */
@ -1291,6 +1298,7 @@ void bta_gattc_write_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
cb_data.write.conn_id = p_clcb->bta_conn_id;
if (p_conn && p_conn->svc_change_descr_handle == cb_data.write.handle) {
if(cb_data.write.status != BTA_GATT_OK) {
p_conn->write_remote_svc_change_ccc_done = FALSE;
APPL_TRACE_ERROR("service change write ccc failed");
}
return;
@ -1716,7 +1724,6 @@ void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
}
if (found) {
bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
bta_gattc_cache_reset(p_msg->api_conn.remote_bda);
return;
}
}
@ -1726,8 +1733,6 @@ void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
p_srvc_cb->p_srvc_cache = NULL;
}
}
/* used to reset cache in application */
bta_gattc_cache_reset(p_msg->api_conn.remote_bda);
}
void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
@ -1873,6 +1878,10 @@ BOOLEAN bta_gattc_process_srvc_chg_ind(UINT16 conn_id,
/* if connection available, refresh cache by doing discovery now */
if (p_clcb != NULL) {
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find(p_clcb->bda);
if(p_conn) {
p_conn->write_remote_svc_change_ccc_done = FALSE;
}
bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_DISCOVER_EVT, NULL);
}
}
@ -2085,6 +2094,27 @@ static void bta_gattc_cong_cback (UINT16 conn_id, BOOLEAN congested)
}
}
/*******************************************************************************
**
** Function bta_gattc_req_cback
**
** Description GATT request command callback for BTA GATT client.
**
** Returns void
**
********************************************************************************/
static void bta_gattc_req_cback (UINT16 conn_id, UINT32 trans_id, tGATTS_REQ_TYPE type, tGATTS_DATA *p_data)
{
/* GATTC doesn't need to process the GATT request commands.
* Add this callback here to avoid the warning "Call back not found for application"
* printed in the function gatt_sr_send_req_callback
* */
UNUSED (conn_id);
UNUSED (trans_id) ;
UNUSED (type);
UNUSED (p_data);
}
#if BLE_INCLUDED == TRUE
/*******************************************************************************
**
@ -2257,6 +2287,10 @@ tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_
tBT_UUID gatt_service_uuid = {LEN_UUID_16, {UUID_SERVCLASS_GATT_SERVER}};
tBT_UUID gatt_service_change_uuid = {LEN_UUID_16, {GATT_UUID_GATT_SRV_CHGD}};
tBT_UUID gatt_ccc_uuid = {LEN_UUID_16, {GATT_UUID_CHAR_CLIENT_CONFIG}};
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find_alloc(remote_bda);
if(p_conn && p_conn->write_remote_svc_change_ccc_done) {
return SERVICE_CHANGE_CCC_WRITTEN_SUCCESS;
}
p_srcb = bta_gattc_find_srcb(remote_bda);
if ((p_srcb != NULL) && (p_srcb->p_srvc_cache != NULL)) {
@ -2321,9 +2355,9 @@ tBTA_GATTC_FIND_SERVICE_CB bta_gattc_register_service_change_notify(UINT16 conn_
}
if (gatt_ccc_found == TRUE){
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find_alloc(remote_bda);
if (p_conn) {
p_conn->svc_change_descr_handle = p_desc->handle;
p_conn->write_remote_svc_change_ccc_done = TRUE;
}
result = SERVICE_CHANGE_CCC_WRITTEN_SUCCESS;
uint16_t indicate_value = GATT_CLT_CONFIG_INDICATION;

View File

@ -912,12 +912,20 @@ tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF client_if,
** Description Refresh the server cache of the remote device
**
** Parameters remote_bda: remote device BD address.
** erase_flash: delete cache from nvs flash
**
** Returns void
**
*******************************************************************************/
void BTA_GATTC_Refresh(BD_ADDR remote_bda)
void BTA_GATTC_Refresh(BD_ADDR remote_bda, bool erase_flash)
{
#if(GATTC_CACHE_NVS == TRUE)
if(erase_flash) {
/* used to reset cache in application */
bta_gattc_cache_reset(remote_bda);
}
#endif
tBTA_GATTC_API_OPEN *p_buf;
if ((p_buf = (tBTA_GATTC_API_OPEN *) osi_malloc(sizeof(tBTA_GATTC_API_OPEN))) != NULL) {

View File

@ -346,6 +346,7 @@ static tBTA_GATT_STATUS bta_gattc_add_attr_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
tBT_UUID *p_uuid,
UINT8 property,
UINT16 incl_srvc_s_handle,
UINT16 incl_srvc_e_handle,
tBTA_GATTC_ATTR_TYPE type)
{
#if (defined BTA_GATT_DEBUG && BTA_GATT_DEBUG == TRUE)
@ -370,18 +371,13 @@ static tBTA_GATT_STATUS bta_gattc_add_attr_to_cache(tBTA_GATTC_SERV *p_srvc_cb,
isvc->handle = handle;
memcpy(&isvc->uuid, p_uuid, sizeof(tBT_UUID));
isvc->incl_srvc_s_handle = incl_srvc_s_handle;
isvc->incl_srvc_e_handle = incl_srvc_e_handle;
isvc->owning_service = service;
isvc->included_service = bta_gattc_find_matching_service(
p_srvc_cb->p_srvc_cache, incl_srvc_s_handle);
if (!isvc->included_service) {
// if it is a secondary service, wait to update later
if(property == 0){
p_srvc_cb->update_sec_sev = true;
} else {
APPL_TRACE_ERROR("%s: Illegal action to add non-existing included service!", __func__);
osi_free(isvc);
return GATT_WRONG_STATE;
}
// if can't find included service, wait to update later
p_srvc_cb->update_incl_srvc = true;
}
list_append(service->included_svc, isvc);
@ -604,10 +600,10 @@ static void bta_gattc_explore_srvc(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
return;
}
}
//update include service when have secondary service
if(p_srvc_cb->update_sec_sev) {
// if update_incl_srvc is true, update include service
if(p_srvc_cb->update_incl_srvc) {
bta_gattc_update_include_service(p_srvc_cb->p_srvc_cache);
p_srvc_cb->update_sec_sev = false;
p_srvc_cb->update_incl_srvc = false;
}
/* no service found at all, the end of server discovery*/
APPL_TRACE_DEBUG("%s no more services found", __func__);
@ -622,10 +618,11 @@ static void bta_gattc_explore_srvc(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb)
L2CA_EnableUpdateBleConnParams(p_clcb->p_srcb->server_bda, TRUE);
}
#endif
#if(GATTC_CACHE_NVS == TRUE)
/* save cache to NV */
p_clcb->p_srcb->state = BTA_GATTC_SERV_SAVE;
bta_gattc_cache_save(p_clcb->p_srcb, p_clcb->bta_conn_id);
#endif
bta_gattc_reset_discover_st(p_clcb->p_srcb, BTA_GATT_OK);
}
/*******************************************************************************
@ -995,6 +992,7 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
&p_data->value.incl_service.service_type,
pri_srvc,
p_data->value.incl_service.s_handle,
p_data->value.incl_service.e_handle,
BTA_GATTC_ATTR_TYPE_INCL_SRVC);
break;
@ -1008,10 +1006,14 @@ void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_
break;
case GATT_DISC_CHAR_DSCPT:
bta_gattc_add_attr_to_cache(p_srvc_cb, p_data->handle, &p_data->type, 0,
0 /* incl_srvc_handle */,
bta_gattc_add_attr_to_cache(p_srvc_cb,
p_data->handle,
&p_data->type,
0,
0 /* incl_srvc_s_handle */,
0 /* incl_srvc_e_handle */,
BTA_GATTC_ATTR_TYPE_CHAR_DESCR);
break;
break;
}
}
}
@ -1352,7 +1354,7 @@ void bta_gattc_get_db_with_opration(UINT16 conn_id,
BTGATT_DB_INCLUDED_SERVICE,
p_isvc->handle,
p_isvc->incl_srvc_s_handle /* s_handle */,
0 /* e_handle */,
p_isvc->incl_srvc_e_handle /* e_handle */,
p_isvc->handle,
p_isvc->uuid,
0 /* property */);
@ -1650,7 +1652,8 @@ void bta_gattc_get_db_size_handle(UINT16 conn_id, UINT16 start_handle, UINT16 en
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
if (p_clcb == NULL) {
return NULL;
*count = 0;
return;
}
tBTA_GATTC_SERV *p_srcb = p_clcb->p_srcb;
@ -1919,12 +1922,21 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr,
break;
case BTA_GATTC_ATTR_TYPE_CHAR_DESCR:
bta_gattc_add_attr_to_cache(p_srvc_cb,
p_attr->s_handle,
&p_attr->uuid,
p_attr->prop,
p_attr->incl_srvc_s_handle,
p_attr->incl_srvc_e_handle,
p_attr->attr_type);
break;
case BTA_GATTC_ATTR_TYPE_INCL_SRVC:
bta_gattc_add_attr_to_cache(p_srvc_cb,
p_attr->s_handle,
&p_attr->uuid,
p_attr->prop,
p_attr->incl_srvc_handle,
p_attr->incl_srvc_s_handle,
p_attr->incl_srvc_e_handle,
p_attr->attr_type);
break;
}
@ -1943,8 +1955,8 @@ void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srvc_cb, UINT16 num_attr,
**
*******************************************************************************/
void bta_gattc_fill_nv_attr(tBTA_GATTC_NV_ATTR *p_attr, UINT8 type, UINT16 s_handle,
UINT16 e_handle, tBT_UUID uuid, UINT8 prop, UINT16 incl_srvc_handle,
BOOLEAN is_primary)
UINT16 e_handle, tBT_UUID uuid, UINT8 prop, UINT16 incl_srvc_s_handle,
UINT16 incl_srvc_e_handle, BOOLEAN is_primary)
{
p_attr->s_handle = s_handle;
p_attr->e_handle = e_handle;
@ -1952,7 +1964,8 @@ void bta_gattc_fill_nv_attr(tBTA_GATTC_NV_ATTR *p_attr, UINT8 type, UINT16 s_han
p_attr->is_primary = is_primary;
p_attr->id = 0;
p_attr->prop = prop;
p_attr->incl_srvc_handle = incl_srvc_handle;
p_attr->incl_srvc_s_handle = incl_srvc_s_handle;
p_attr->incl_srvc_e_handle = incl_srvc_e_handle;
memcpy(&p_attr->uuid, &uuid, sizeof(tBT_UUID));
}
@ -1992,7 +2005,8 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
p_cur_srvc->e_handle,
p_cur_srvc->uuid,
0 /* properties */,
0 /* incl_srvc_handle */,
0 /* incl_srvc_s_handle */,
0 /* incl_srvc_e_handle */,
p_cur_srvc->is_primary);
}
@ -2013,7 +2027,8 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
0,
p_char->uuid,
p_char->properties,
0 /* incl_srvc_handle */,
0 /* incl_srvc_s_handle */,
0 /* incl_srvc_e_handle */,
FALSE);
if (!p_char->descriptors || list_is_empty(p_char->descriptors))
@ -2029,7 +2044,8 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
0,
p_desc->uuid,
0 /* properties */,
0 /* incl_srvc_handle */,
0 /* incl_srvc_s_handle */,
0 /* incl_srvc_e_handle */,
FALSE);
}
}
@ -2048,6 +2064,7 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
p_isvc->uuid,
0 /* properties */,
p_isvc->included_service->s_handle,
p_isvc->included_service->e_handle,
FALSE);
}
}

View File

@ -75,7 +75,7 @@ static void cacheReset(BD_ADDR bda)
#else
static const char *cache_key = "gattc_cahe_key";
static const char *cache_key = "gattc_cache_key";
static const char *cache_addr = "cache_addr_tab";
nvs_handle nvs_fp;
@ -144,7 +144,7 @@ static void cacheReset(BD_ADDR bda)
char fname[255] = {0};
getFilename(fname, bda);
UINT8 index = 0;
//cache_env.cache_addr
//cache_env.cache_addr
if ((index = bta_gattc_co_find_addr_in_cache(bda)) != INVALID_ADDR_NUM) {
//clear the association address pending in the source address.
bta_gattc_co_cache_clear_assoc_addr(bda);
@ -152,7 +152,22 @@ static void cacheReset(BD_ADDR bda)
nvs_erase_all(cache_env.cache_addr[index].cache_fp);
nvs_close(cache_env.cache_addr[index].cache_fp);
cache_env.cache_addr[index].is_open = FALSE;
} else {
cacheOpen(bda, false, &index);
if (cache_env.cache_addr[index].is_open) {
nvs_erase_all(cache_env.cache_addr[index].cache_fp);
nvs_close(cache_env.cache_addr[index].cache_fp);
cache_env.cache_addr[index].is_open = FALSE;
} else {
APPL_TRACE_ERROR("%s cacheOpen failed", __func__);
return;
}
}
if(cache_env.num_addr == 0) {
APPL_TRACE_ERROR("%s cache addr list error", __func__);
return;
}
UINT8 num = cache_env.num_addr;
//delete the server_bda in the addr_info list.
for(UINT8 i = index; i < (num - 1); i++) {
@ -160,6 +175,40 @@ static void cacheReset(BD_ADDR bda)
}
//reduced the number address counter also
cache_env.num_addr--;
//update addr list to nvs flash
if(cache_env.num_addr > 0) {
//update
UINT8 *p_buf = osi_malloc(MAX_ADDR_LIST_CACHE_BUF);
if(!p_buf) {
APPL_TRACE_ERROR("%s malloc error", __func__);
return;
}
UINT16 length = cache_env.num_addr*(sizeof(BD_ADDR) + sizeof(hash_key_t));
for (UINT8 i = 0; i < cache_env.num_addr; i++) {
//copy the address to the buffer.
memcpy(p_buf + i*(sizeof(BD_ADDR) + sizeof(hash_key_t)), cache_env.cache_addr[i].addr, sizeof(BD_ADDR));
//copy the hash key to the buffer.
memcpy(p_buf + i*(sizeof(BD_ADDR) + sizeof(hash_key_t)) + sizeof(BD_ADDR),
cache_env.cache_addr[i].hash_key, sizeof(hash_key_t));
}
if (cache_env.is_open) {
if (nvs_set_blob(cache_env.addr_fp, cache_key, p_buf, length) != ESP_OK) {
APPL_TRACE_WARNING("%s, nvs set blob failed", __func__);
}
}
osi_free(p_buf);
} else {
//erase
if (cache_env.is_open) {
nvs_erase_all(cache_env.addr_fp);
nvs_close(cache_env.addr_fp);
cache_env.is_open = FALSE;
} else {
APPL_TRACE_WARNING("cache_env status is error");
}
}
}
}
@ -325,10 +374,11 @@ void bta_gattc_co_cache_addr_init(void)
esp_err_t err_code;
UINT8 num_addr;
UINT8 *p_buf = osi_malloc(MAX_ADDR_LIST_CACHE_BUF);
size_t length = 0;
size_t length = MAX_ADDR_LIST_CACHE_BUF;
if ((err_code = nvs_open(cache_addr, NVS_READWRITE, &fp)) == ESP_OK) {
cache_env.addr_fp = fp;
cache_env.is_open = TRUE;
// Read previously saved blob if available
if ((err_code = nvs_get_blob(fp, cache_key, p_buf, &length)) != ESP_OK) {
if(err_code != ESP_ERR_NVS_NOT_FOUND) {
@ -361,6 +411,26 @@ void bta_gattc_co_cache_addr_init(void)
return;
}
void bta_gattc_co_cache_addr_deinit(void)
{
if(!cache_env.is_open) {
return;
}
nvs_close(cache_env.addr_fp);
cache_env.is_open = false;
for(UINT8 i = 0; i< cache_env.num_addr; i++) {
cache_addr_info_t *addr_info = &cache_env.cache_addr[i];
if(addr_info) {
nvs_close(addr_info->cache_fp);
addr_info->is_open = false;
if(addr_info->assoc_addr) {
list_free(addr_info->assoc_addr);
}
}
}
}
BOOLEAN bta_gattc_co_addr_in_cache(BD_ADDR bda)
{
UINT8 addr_index = 0;

View File

@ -702,6 +702,10 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
APPL_TRACE_ERROR("%s, malloc failed", __func__);
}
(*p_rcb->p_cback)(BTA_GATTS_CONF_EVT, &cb_data);
if (cb_data.req_data.value != NULL) {
osi_free(cb_data.req_data.value);
cb_data.req_data.value = NULL;
}
}
} else {
APPL_TRACE_ERROR("Not an registered servce attribute ID: 0x%04x",

View File

@ -300,7 +300,7 @@ typedef struct {
UINT16 attr_index; /* cahce NV saving/loading attribute index */
UINT16 mtu;
bool update_sec_sev;
bool update_incl_srvc;
} tBTA_GATTC_SERV;
#ifndef BTA_GATTC_NOTIF_REG_MAX
@ -365,7 +365,8 @@ typedef struct {
typedef struct {
BOOLEAN in_use;
BD_ADDR remote_bda;
UINT16 svc_change_descr_handle;
UINT16 svc_change_descr_handle;
BOOLEAN write_remote_svc_change_ccc_done;
} tBTA_GATTC_CONN;
enum {

View File

@ -46,7 +46,7 @@ static const tBTM_ESCO_PARAMS bta_hf_client_esco_params[] = {
BTM_SCO_PKT_TYPES_MASK_NO_3_EV3 |
BTM_SCO_PKT_TYPES_MASK_NO_2_EV5 |
BTM_SCO_PKT_TYPES_MASK_NO_3_EV5),
.retrans_effort = BTM_ESCO_RETRANS_POWER,
.retrans_effort = BTM_ESCO_RETRANS_OFF,
},
/* ESCO CVSD */
{
@ -429,7 +429,6 @@ static void bta_hf_client_sco_event(UINT8 event)
if (event == BTA_HF_CLIENT_SCO_CI_DATA_E) {
uint16_t pkt_offset = 1 + HCI_SCO_PREAMBLE_SIZE;
uint16_t len_to_send = 0;
uint8_t *p;
while (true)
{
p_buf = osi_malloc(sizeof(BT_HDR) + pkt_offset + BTM_SCO_DATA_SIZE_MAX);
@ -439,13 +438,13 @@ static void bta_hf_client_sco_event(UINT8 event)
}
p_buf->offset = pkt_offset;
p_buf->len = BTM_SCO_DATA_SIZE_MAX;
len_to_send = bta_hf_client_sco_co_out_data(p_buf->data + pkt_offset, BTM_SCO_DATA_SIZE_MAX);
if (len_to_send) {
if (len_to_send == BTM_SCO_DATA_SIZE_MAX) {
// expect to get the exact size of data from upper layer
if (bta_hf_client_cb.scb.sco_state == BTA_HF_CLIENT_SCO_OPEN_ST) {
p = (UINT8 *)(p_buf->data + pkt_offset -1);
*p = len_to_send; // set SCO packet length;
tBTM_STATUS write_stat = BTM_WriteScoData(p_scb->sco_idx, p_buf);
if (write_stat != BTM_SUCCESS && write_stat != BTM_SCO_BAD_LENGTH) {
if (write_stat != BTM_SUCCESS) {
break;
}
} else {

View File

@ -631,10 +631,11 @@ typedef UINT8 tBTA_SIG_STRENGTH_MASK;
#define BTA_DM_SP_RMT_OOB_EXT_EVT 23 /* Simple Pairing Remote OOB Extended Data request. */
#define BTA_DM_BLE_AUTH_CMPL_EVT 24 /* BLE Auth complete */
// btla-specific --
#define BTA_DM_DEV_UNPAIRED_EVT 25
#define BTA_DM_DEV_UNPAIRED_EVT 25 /* BT unpair event */
#define BTA_DM_HW_ERROR_EVT 26 /* BT Chip H/W error */
#define BTA_DM_LE_FEATURES_READ 27 /* Cotroller specific LE features are read */
#define BTA_DM_ENER_INFO_READ 28 /* Energy info read */
#define BTA_DM_BLE_DEV_UNPAIRED_EVT 29 /* BLE unpair event */
typedef UINT8 tBTA_DM_SEC_EVT;
/* Structure associated with BTA_DM_ENABLE_EVT */
@ -762,6 +763,7 @@ typedef struct {
UINT8 fail_reason; /* The HCI reason/error code for when success=FALSE */
tBLE_ADDR_TYPE addr_type; /* Peer device address type */
tBT_DEVICE_TYPE dev_type;
UINT8 auth_mode;
} tBTA_DM_AUTH_CMPL;
@ -1428,7 +1430,7 @@ extern void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBTA
extern void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb);
extern void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_CMPL_CB *cmpl_cb);
extern void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb);
/*******************************************************************************
**
@ -1559,6 +1561,18 @@ extern void BTA_DmBondByTransport(BD_ADDR bd_addr, tBTA_TRANSPORT transport);
*******************************************************************************/
extern void BTA_DmBondCancel(BD_ADDR bd_addr);
/*******************************************************************************
**
** Function BTA_DMSetPinType
**
** Description This function sets pin type as BTM_PIN_TYPE_FIXED or BTM_PIN_TYPE_VARIABLE
**
**
** Returns void
**
*******************************************************************************/
extern void BTA_DMSetPinType (UINT8 pin_type, UINT8 *pin_code, UINT8 pin_code_len);
/*******************************************************************************
**
** Function BTA_DmPinReply
@ -1632,7 +1646,7 @@ extern void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class,
** BTA_FAIL if operation failed.
**
*******************************************************************************/
extern tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr);
extern tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr, tBT_TRANSPORT transport);
/*******************************************************************************
**
@ -1789,6 +1803,22 @@ extern void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_B
*******************************************************************************/
extern void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey);
/*******************************************************************************
**
** Function BTA_DmBleSetStaticPasskey
**
** Description Set BLE SMP static passkey.
**
** Parameters: add - add static passkey when add is true
** clear static passkey when add is false
** passkey - static passkey value
**
**
** Returns void
**
*******************************************************************************/
extern void BTA_DmBleSetStaticPasskey(bool add, uint32_t passkey);
/*******************************************************************************
**
** Function BTA_DmBleConfirmReply

View File

@ -98,7 +98,7 @@ typedef UINT8 tBTA_AV_HNDL;
#endif
#ifndef BTA_AV_MAX_SEPS
#define BTA_AV_MAX_SEPS 2
#define BTA_AV_MAX_SEPS 1
#endif
#ifndef BTA_AV_MAX_A2DP_MTU
@ -259,7 +259,7 @@ typedef UINT8 tBTA_AV_ERR;
/* function types for call-out functions */
typedef BOOLEAN (*tBTA_AV_CO_INIT) (UINT8 *p_codec_type, UINT8 *p_codec_info,
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 tsep);
typedef void (*tBTA_AV_CO_DISC_RES) (tBTA_AV_HNDL hndl, UINT8 num_seps,
UINT8 num_snk, UINT8 num_src, BD_ADDR addr, UINT16 uuid_local);
typedef UINT8 (*tBTA_AV_CO_GETCFG) (tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type,
@ -580,7 +580,7 @@ void BTA_AvDisable(void);
**
*******************************************************************************/
void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name,
UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos);
UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos, UINT8 tsep);
/*******************************************************************************
**

View File

@ -85,7 +85,7 @@ typedef struct {
**
*******************************************************************************/
extern BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info,
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 index);
UINT8 *p_num_protect, UINT8 *p_protect_info, UINT8 tsep);
/*******************************************************************************
**

View File

@ -190,4 +190,10 @@ extern void bta_dm_co_ble_set_init_key_req(UINT8 init_key);
extern void bta_dm_co_ble_set_rsp_key_req(UINT8 rsp_key);
extern void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size);
extern void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable);
extern UINT8 bta_dm_co_ble_get_accept_auth_enable(void);
extern UINT8 bta_dm_co_ble_get_auth_req(void);
#endif

View File

@ -282,7 +282,8 @@ typedef struct {
UINT8 id;
UINT8 prop; /* used when attribute type is characteristic */
BOOLEAN is_primary; /* used when attribute type is service */
UINT16 incl_srvc_handle; /* used when attribute type is included service */
UINT16 incl_srvc_s_handle; /* used when attribute type is included service */
UINT16 incl_srvc_e_handle; /* used when attribute type is included service */
}tBTA_GATTC_NV_ATTR;
/* callback data structure */
@ -691,6 +692,7 @@ typedef struct
tBT_UUID uuid;
UINT16 handle;
UINT16 incl_srvc_s_handle;
UINT16 incl_srvc_e_handle;
tBTA_GATTC_SERVICE *owning_service; /* owning service*/
tBTA_GATTC_SERVICE *included_service;
} __attribute__((packed)) tBTA_GATTC_INCLUDED_SVC;
@ -1096,11 +1098,12 @@ extern void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_mult
** Description Refresh the server cache of the remote device
**
** Parameters remote_bda: remote device BD address.
** erase_flash: delete cache from nvs flash
**
** Returns void
**
*******************************************************************************/
extern void BTA_GATTC_Refresh(BD_ADDR remote_bda);
extern void BTA_GATTC_Refresh(BD_ADDR remote_bda, bool erase_flash);
extern void BTA_GATTC_CacheAssoc(tBTA_GATTC_IF client_if, BD_ADDR src_addr, BD_ADDR assoc_addr, BOOLEAN is_assoc);

View File

@ -113,6 +113,8 @@ extern size_t bta_gattc_get_cache_attr_length(UINT8 index);
extern void bta_gattc_co_cache_addr_init(void);
extern void bta_gattc_co_cache_addr_deinit(void);
extern BOOLEAN bta_gattc_co_addr_in_cache(BD_ADDR bda);
extern uint8_t bta_gattc_co_find_addr_in_cache(BD_ADDR bda);

View File

@ -22,7 +22,6 @@
*
******************************************************************************/
#include <arpa/inet.h>
#include <pthread.h>
#include <stdlib.h>
@ -959,6 +958,14 @@ static bool create_base_record(const uint32_t sdp_handle, const char *name, cons
return FALSE;
}
stage = "profile_descriptor_list";
if (!SDP_AddProfileDescriptorList(sdp_handle, UUID_SERVCLASS_SERIAL_PORT, SPP_VERSION)){
APPL_TRACE_ERROR("create_base_record: failed to create base service "
"record, stage: %s, scn: %d, name: %s, with_obex: %d",
stage, channel, name, with_obex);
return FALSE;
}
// Add the name to the SDP record.
if (name[0] != '\0') {
stage = "service_name";

View File

@ -37,6 +37,8 @@
** Constants
*****************************************************************************/
#define SPP_VERSION 0x0102
enum {
/* these events are handled by the state machine */
BTA_JV_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_JV),

View File

@ -29,6 +29,8 @@
static void _btc_storage_save(void)
{
uint16_t addr_section_count = 0;
bt_bdaddr_t bd_addr;
uint32_t device_type = 0;
const btc_config_section_iter_t *need_remove_iter = NULL;
const btc_config_section_iter_t *iter = btc_config_section_begin();
@ -36,12 +38,9 @@ static void _btc_storage_save(void)
//store the next iter, if remove section, then will not loss the point
const char *section = btc_config_section_name(iter);
if (!string_is_bdaddr(section)) {
iter = btc_config_section_next(iter);
continue;
}
if (!btc_config_exist(section, BTC_BLE_STORAGE_DEV_TYPE_STR) &&
if (string_is_bdaddr(section) &&
!btc_config_exist(section, BTC_BLE_STORAGE_DEV_TYPE_STR) &&
!btc_config_exist(section, BTC_BLE_STORAGE_ADDR_TYPE_STR) &&
!btc_config_exist(section, BTC_BLE_STORAGE_LINK_KEY_STR) &&
!btc_config_exist(section, BTC_BLE_STORAGE_LE_KEY_PENC_STR) &&
@ -53,6 +52,14 @@ static void _btc_storage_save(void)
btc_config_remove_section(section);
continue;
}
if (!string_is_bdaddr(section) ||
!btc_config_get_int(section, BTC_BLE_STORAGE_DEV_TYPE_STR, (int *)&device_type) ||
((device_type & BT_DEVICE_TYPE_BLE) != BT_DEVICE_TYPE_BLE)) {
iter = btc_config_section_next(iter);
continue;
}
if(addr_section_count == BONED_DEVICES_MAX_COUNT) {
need_remove_iter = iter;
}
@ -63,13 +70,20 @@ static void _btc_storage_save(void)
if (need_remove_iter) {
while(need_remove_iter != btc_config_section_end()) {
const char *need_remove_section = btc_config_section_name(need_remove_iter);
if (!string_is_bdaddr(need_remove_section)) {
if (!string_is_bdaddr(need_remove_section) ||
!btc_config_get_int(need_remove_section, BTC_BLE_STORAGE_DEV_TYPE_STR, (int *)&device_type) ||
((device_type & BT_DEVICE_TYPE_BLE) != BT_DEVICE_TYPE_BLE)) {
need_remove_iter = btc_config_section_next(need_remove_iter);
continue;
}
need_remove_iter = btc_config_section_next(need_remove_iter);
BTIF_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the last device info : %s", need_remove_section);
btc_config_remove_section(need_remove_section);
//delete device info
string_to_bdaddr(need_remove_section, &bd_addr);
BTM_SecDeleteDevice(bd_addr.address, BT_TRANSPORT_LE);
//delet config info
if(btc_config_remove_section(need_remove_section)) {
BTIF_TRACE_WARNING("exceeded the maximum nubmer of bonded devices, delete the last device info : %s", need_remove_section);
}
}
}
btc_config_flush();
@ -228,6 +242,9 @@ static bt_status_t _btc_storage_remove_ble_bonding_keys(bt_bdaddr_t *remote_bd_a
if (btc_config_exist(bdstr, BTC_BLE_STORAGE_LE_KEY_LCSRK_STR)) {
ret |= btc_config_remove(bdstr, BTC_BLE_STORAGE_LE_KEY_LCSRK_STR);
}
if (btc_config_exist(bdstr, BTC_BLE_STORAGE_LE_KEY_LID_STR)) {
ret |= btc_config_remove(bdstr, BTC_BLE_STORAGE_LE_KEY_LID_STR);
}
//here don't remove section, because config_save will check it
_btc_storage_save();
return ret ? BT_STATUS_SUCCESS : BT_STATUS_FAIL;
@ -750,7 +767,6 @@ bt_status_t btc_storage_load_bonded_ble_devices(void)
bt_status_t btc_storage_get_bonded_ble_devices_list(esp_ble_bond_dev_t *bond_dev, int dev_num)
{
bt_bdaddr_t bd_addr;
uint32_t device_type = 0;
char buffer[sizeof(tBTM_LE_KEY_VALUE)] = {0};
btc_config_lock();
@ -760,12 +776,13 @@ bt_status_t btc_storage_get_bonded_ble_devices_list(esp_ble_bond_dev_t *bond_dev
if (dev_num-- <= 0) {
break;
}
uint32_t device_type = 0;
const char *name = btc_config_section_name(iter);
if (!string_is_bdaddr(name) ||
!btc_config_get_int(name, BTC_BLE_STORAGE_DEV_TYPE_STR, (int *)&device_type) ||
!(device_type & BT_DEVICE_TYPE_BLE)) {
dev_num ++;
continue;
}

View File

@ -54,7 +54,7 @@ static btc_dm_local_key_cb_t ble_local_key_cb;
** Externs
******************************************************************************/
#if BTC_AV_INCLUDED
extern bt_status_t btc_av_execute_service(BOOLEAN b_enable);
extern bt_status_t btc_av_source_execute_service(BOOLEAN b_enable);
extern bt_status_t btc_av_sink_execute_service(BOOLEAN b_enable);
#endif
#if BTC_HF_CLIENT_INCLUDED
@ -182,6 +182,10 @@ static void btc_dm_remove_ble_bonding_keys(void)
static void btc_dm_save_ble_bonding_keys(void)
{
if (!(pairing_cb.ble.is_penc_key_rcvd || pairing_cb.ble.is_pid_key_rcvd || pairing_cb.ble.is_pcsrk_key_rcvd ||
pairing_cb.ble.is_lenc_key_rcvd || pairing_cb.ble.is_lcsrk_key_rcvd || pairing_cb.ble.is_lidk_key_rcvd)) {
return ;
}
bt_bdaddr_t bd_addr;
bdcpy(bd_addr.address, pairing_cb.bd_addr);
@ -193,6 +197,7 @@ static void btc_dm_save_ble_bonding_keys(void)
(char *) &pairing_cb.ble.penc_key,
BTM_LE_KEY_PENC,
sizeof(tBTM_LE_PENC_KEYS));
pairing_cb.ble.is_penc_key_rcvd = false;
}
if (pairing_cb.ble.is_pid_key_rcvd) {
@ -200,6 +205,7 @@ static void btc_dm_save_ble_bonding_keys(void)
(char *) &pairing_cb.ble.pid_key,
BTM_LE_KEY_PID,
sizeof(tBTM_LE_PID_KEYS));
pairing_cb.ble.is_pid_key_rcvd = false;
}
@ -208,6 +214,7 @@ static void btc_dm_save_ble_bonding_keys(void)
(char *) &pairing_cb.ble.pcsrk_key,
BTM_LE_KEY_PCSRK,
sizeof(tBTM_LE_PCSRK_KEYS));
pairing_cb.ble.is_pcsrk_key_rcvd = false;
}
@ -216,6 +223,7 @@ static void btc_dm_save_ble_bonding_keys(void)
(char *) &pairing_cb.ble.lenc_key,
BTM_LE_KEY_LENC,
sizeof(tBTM_LE_LENC_KEYS));
pairing_cb.ble.is_lenc_key_rcvd = false;
}
if (pairing_cb.ble.is_lcsrk_key_rcvd) {
@ -223,6 +231,7 @@ static void btc_dm_save_ble_bonding_keys(void)
(char *) &pairing_cb.ble.lcsrk_key,
BTM_LE_KEY_LCSRK,
sizeof(tBTM_LE_LCSRK_KEYS));
pairing_cb.ble.is_lcsrk_key_rcvd = false;
}
if (pairing_cb.ble.is_lidk_key_rcvd) {
@ -230,6 +239,7 @@ static void btc_dm_save_ble_bonding_keys(void)
NULL,
BTM_LE_KEY_LID,
0);
pairing_cb.ble.is_lidk_key_rcvd = false;
}
}
@ -375,6 +385,27 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
(void) status;
}
static void btc_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req)
{
#if (BTC_GAP_BT_INCLUDED == TRUE)
esp_bt_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BT;
msg.act = BTC_GAP_BT_PIN_REQ_EVT;
param.pin_req.min_16_digit = p_pin_req->min_16_digit;
memcpy(param.pin_req.bda, p_pin_req->bd_addr, ESP_BD_ADDR_LEN);
ret = btc_transfer_context(&msg, &param,
sizeof(esp_bt_gap_cb_param_t), NULL);
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
}
#endif /// BTC_GAP_BT_INCLUDED == TRUE
}
tBTA_SERVICE_MASK btc_get_enabled_services_mask(void)
{
return btc_enabled_services;
@ -393,7 +424,7 @@ static bt_status_t btc_in_execute_service_request(tBTA_SERVICE_ID service_id,
switch (service_id) {
#if BTC_AV_INCLUDED
case BTA_A2DP_SOURCE_SERVICE_ID:
btc_av_execute_service(b_enable);
btc_av_source_execute_service(b_enable);
break;
case BTA_A2DP_SINK_SERVICE_ID:
btc_av_sink_execute_service(b_enable);
@ -484,6 +515,8 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
break;
}
case BTA_DM_PIN_REQ_EVT:
BTC_TRACE_DEBUG("BTA_DM_PIN_REQ_EVT");
btc_dm_pin_req_evt(&p_data->pin_req);
break;
case BTA_DM_AUTH_CMPL_EVT:
btc_dm_auth_cmpl_evt(&p_data->auth_cmpl);
@ -495,10 +528,23 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
case BTA_DM_DEV_UNPAIRED_EVT: {
#if (SMP_INCLUDED == TRUE)
bt_bdaddr_t bd_addr;
rsp_app = true;
BTC_TRACE_DEBUG("BTA_DM_DEV_UNPAIRED_EVT");
memcpy(bd_addr.address, p_data->link_down.bd_addr, sizeof(BD_ADDR));
btm_set_bond_type_dev(p_data->link_down.bd_addr, BOND_TYPE_UNKNOWN);
if (p_data->link_down.status == HCI_SUCCESS) {
//remove the bonded key in the config and nvs flash.
btc_storage_remove_bonded_device(&bd_addr);
}
#endif /* #if (SMP_INCLUDED == TRUE) */
break;
}
case BTA_DM_BLE_DEV_UNPAIRED_EVT: {
#if (SMP_INCLUDED == TRUE)
bt_bdaddr_t bd_addr;
rsp_app = true;
BTC_TRACE_DEBUG("BTA_DM_BLE_DEV_UNPAIRED_EVT");
memcpy(bd_addr.address, p_data->link_down.bd_addr, sizeof(BD_ADDR));
btm_set_bond_type_dev(p_data->link_down.bd_addr, BOND_TYPE_UNKNOWN);
param.remove_bond_dev_cmpl.status = ESP_BT_STATUS_FAIL;
if (p_data->link_down.status == HCI_SUCCESS) {
@ -538,6 +584,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
param.ble_security.auth_cmpl.key_present = p_data->auth_cmpl.key_present;
memcpy(param.ble_security.auth_cmpl.bd_addr, p_data->auth_cmpl.bd_addr, sizeof(BD_ADDR));
memcpy(param.ble_security.auth_cmpl.key, p_data->auth_cmpl.key, sizeof(LINK_KEY));
param.ble_security.auth_cmpl.auth_mode = p_data->auth_cmpl.auth_mode;
btc_dm_ble_auth_cmpl_evt(&p_data->auth_cmpl);
break;
}

View File

@ -64,7 +64,7 @@ static void btc_init_bluetooth(void)
bte_main_boot_entry(btc_init_callback);
#if (SMP_INCLUDED)
btc_config_init();
//load the ble local key whitch has been store in the flash
//load the ble local key which has been stored in the flash
btc_dm_load_ble_local_keys();
#endif /* #if (SMP_INCLUDED) */
}

View File

@ -170,6 +170,9 @@ int btc_init(void)
return BT_STATUS_NOMEM;
}
btc_gap_callback_init();
#if SCAN_QUEUE_CONGEST_CHECK
btc_adv_list_init();
#endif
/* TODO: initial the profile_tab */
return BT_STATUS_SUCCESS;
}
@ -178,7 +181,18 @@ void btc_deinit(void)
{
vTaskDelete(xBtcTaskHandle);
vQueueDelete(xBtcQueue);
#if SCAN_QUEUE_CONGEST_CHECK
btc_adv_list_deinit();
#endif
xBtcTaskHandle = NULL;
xBtcQueue = 0;
}
bool btc_check_queue_is_congest(void)
{
UBaseType_t wait_size = uxQueueMessagesWaiting(xBtcQueue);
if(wait_size >= QUEUE_CONGEST_SIZE) {
return true;
}
return false;
}

View File

@ -28,6 +28,11 @@ typedef struct btc_msg {
void *arg; //param for btc function or function param
} btc_msg_t;
typedef struct btc_adv_packet {
uint8_t addr[6];
uint8_t addr_type;
} btc_adv_packet_t;
typedef enum {
BTC_SIG_API_CALL = 0, // APP TO STACK
BTC_SIG_API_CB, // STACK TO APP
@ -72,5 +77,6 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
int btc_init(void);
void btc_deinit(void);
bool btc_check_queue_is_congest(void);
#endif /* __BTC_TASK_H__ */

View File

@ -206,13 +206,10 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
break;
case BTA_GATTS_MTU_EVT:
BLUFI_TRACE_DEBUG("MTU size %d\n", p_data->req_data.p_data->mtu);
blufi_env.frag_size = p_data->req_data.p_data->mtu - BLUFI_MTU_RESERVED_SIZE;
blufi_env.frag_size = (p_data->req_data.p_data->mtu < BLUFI_MAX_DATA_LEN ? p_data->req_data.p_data->mtu : BLUFI_MAX_DATA_LEN) - BLUFI_MTU_RESERVED_SIZE;
break;
case BTA_GATTS_CONF_EVT:
BLUFI_TRACE_DEBUG("CONIRM EVT\n");
if (p_data && p_data->req_data.value){
osi_free(p_data->req_data.value);
}
BLUFI_TRACE_DEBUG("CONFIRM EVT\n");
/* Nothing */
break;
case BTA_GATTS_CREATE_EVT:

View File

@ -72,6 +72,7 @@ typedef struct blufi_frag_hdr blufi_frag_hdr_t;
#define BLUFI_DATA_SEC_MODE_ENC_MASK 0x02
#define BLUFI_CTRL_SEC_MODE_CHECK_MASK 0x10
#define BLUFI_CTRL_SEC_MODE_ENC_MASK 0x20
#define BLUFI_MAX_DATA_LEN 255
// packet type
#define BLUFI_TYPE_MASK 0x03

View File

@ -267,11 +267,11 @@ static tBTA_AV_CO_PEER *bta_av_co_get_peer(tBTA_AV_HNDL hndl)
**
*******************************************************************************/
BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info, UINT8 *p_num_protect,
UINT8 *p_protect_info, UINT8 index)
UINT8 *p_protect_info, UINT8 tsep)
{
FUNC_TRACE();
APPL_TRACE_DEBUG("bta_av_co_audio_init: %d", index);
APPL_TRACE_DEBUG("bta_av_co_audio_init: %d", tsep);
/* By default - no content protection info */
*p_num_protect = 0;
@ -280,29 +280,24 @@ BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info, UINT8 *p_
/* reset remote preference through setconfig */
bta_av_co_cb.codec_cfg_setconfig.id = BTC_AV_CODEC_NONE;
switch (index) {
case BTC_SV_AV_AA_SBC_INDEX:
if (tsep == AVDT_TSEP_SRC) {
#if defined(BTA_AV_CO_CP_SCMS_T) && (BTA_AV_CO_CP_SCMS_T == TRUE)
{
UINT8 *p = p_protect_info;
do {
UINT8 *p = p_protect_info;
/* Content protection info - support SCMS-T */
*p_num_protect = 1;
*p++ = BTA_AV_CP_LOSC;
UINT16_TO_STREAM(p, BTA_AV_CP_SCMS_T_ID);
}
/* Content protection info - support SCMS-T */
*p_num_protect = 1;
*p++ = BTA_AV_CP_LOSC;
UINT16_TO_STREAM(p, BTA_AV_CP_SCMS_T_ID);
} while (0);
#endif
/* Set up for SBC codec for SRC*/
*p_codec_type = BTA_AV_CODEC_SBC;
*p_codec_type = BTA_AV_CODEC_SBC;
/* This should not fail because we are using constants for parameters */
A2D_BldSbcInfo(AVDT_MEDIA_AUDIO, (tA2D_SBC_CIE *) &bta_av_co_sbc_caps, p_codec_info);
/* Codec is valid */
return TRUE;
#if (BTA_AV_SINK_INCLUDED == TRUE)
case BTC_SV_AV_AA_SBC_SINK_INDEX:
A2D_BldSbcInfo(AVDT_MEDIA_AUDIO, (tA2D_SBC_CIE *) &bta_av_co_sbc_caps, p_codec_info);
return TRUE;
} else if (tsep == AVDT_TSEP_SNK) {
*p_codec_type = BTA_AV_CODEC_SBC;
/* This should not fail because we are using constants for parameters */
@ -310,9 +305,8 @@ BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info, UINT8 *p_
/* Codec is valid */
return TRUE;
#endif
default:
/* Not valid */
} else {
APPL_TRACE_WARNING("invalid SEP type %d", tsep);
return FALSE;
}
}

View File

@ -87,8 +87,8 @@ enum {
but due to link flow control or thread preemption in lower
layers we might need to temporarily buffer up data */
/* 5 frames is equivalent to 6.89*5*2.9 ~= 100 ms @ 44.1 khz, 20 ms mediatick */
#define MAX_OUTPUT_A2DP_SNK_FRAME_QUEUE_SZ (5)
/* 18 frames is equivalent to 6.89*18*2.9 ~= 360 ms @ 44.1 khz, 20 ms mediatick */
#define MAX_OUTPUT_A2DP_SNK_FRAME_QUEUE_SZ (18)
typedef struct {
UINT16 num_frames_to_be_processed;
@ -143,9 +143,21 @@ static inline void btc_a2d_data_cb_to_app(const uint8_t *data, uint32_t len)
}
}
OI_CODEC_SBC_DECODER_CONTEXT context;
OI_UINT32 contextData[CODEC_DATA_WORDS(2, SBC_CODEC_FAST_FILTER_BUFFERS)];
OI_INT16 pcmData[15 * SBC_MAX_SAMPLES_PER_FRAME * SBC_MAX_CHANNELS];
#define BTC_SBC_DEC_CONTEXT_DATA_LEN (CODEC_DATA_WORDS(2, SBC_CODEC_FAST_FILTER_BUFFERS))
#define BTC_SBC_DEC_PCM_DATA_LEN (15 * SBC_MAX_SAMPLES_PER_FRAME * SBC_MAX_CHANNELS)
#if BTC_SBC_DEC_DYNAMIC_MEMORY == FALSE
static OI_CODEC_SBC_DECODER_CONTEXT btc_sbc_decoder_context;
static OI_UINT32 btc_sbc_decoder_context_data[BTC_SBC_DEC_CONTEXT_DATA_LEN];
static OI_INT16 btc_sbc_pcm_data[BTC_SBC_DEC_PCM_DATA_LEN];
#else
static OI_CODEC_SBC_DECODER_CONTEXT *btc_sbc_decoder_context_ptr;
static OI_UINT32 *btc_sbc_decoder_context_data;
static OI_INT16 *btc_sbc_pcm_data;
#define btc_sbc_decoder_context (*btc_sbc_decoder_context_ptr)
#endif /* BTC_SBC_DEC_DYNAMIC_MEMORY == FALSE */
/*****************************************************************************
** Misc helper functions
@ -235,6 +247,16 @@ bool btc_a2dp_sink_startup(void)
APPL_TRACE_EVENT("## A2DP SINK START MEDIA THREAD ##");
#if (BTC_SBC_DEC_DYNAMIC_MEMORY == TRUE)
btc_sbc_decoder_context_ptr = osi_calloc(sizeof(OI_CODEC_SBC_DECODER_CONTEXT));
btc_sbc_decoder_context_data = osi_calloc(BTC_SBC_DEC_CONTEXT_DATA_LEN * sizeof(OI_UINT32));
btc_sbc_pcm_data = osi_calloc(BTC_SBC_DEC_PCM_DATA_LEN * sizeof(OI_INT16));
if (!btc_sbc_decoder_context_ptr || !btc_sbc_decoder_context_data || !btc_sbc_pcm_data) {
APPL_TRACE_ERROR("failed to allocate SBC decoder");
goto error_exit;
}
#endif /* BTC_SBC_DEC_DYNAMIC_MEMORY == TRUE */
btc_aa_snk_queue_set = xQueueCreateSet(BTC_A2DP_SINK_TASK_QUEUE_SET_LEN);
configASSERT(btc_aa_snk_queue_set);
btc_aa_snk_data_queue = xQueueCreate(BTC_A2DP_SINK_DATA_QUEUE_LEN, sizeof(int32_t));
@ -280,6 +302,21 @@ error_exit:;
vQueueDelete(btc_aa_snk_queue_set);
btc_aa_snk_queue_set = NULL;
}
#if (BTC_SBC_DEC_DYNAMIC_MEMORY == TRUE)
if (btc_sbc_decoder_context_ptr) {
osi_free(btc_sbc_decoder_context_ptr);
btc_sbc_decoder_context_ptr = NULL;
}
if (btc_sbc_decoder_context_data) {
osi_free(btc_sbc_decoder_context_data);
btc_sbc_decoder_context_data = NULL;
}
if (btc_sbc_pcm_data) {
osi_free(btc_sbc_pcm_data);
btc_sbc_pcm_data = NULL;
}
#endif /* BTC_SBC_DEC_DYNAMIC_MEMORY == TRUE */
return false;
}
@ -306,6 +343,17 @@ void btc_a2dp_sink_shutdown(void)
vQueueDelete(btc_aa_snk_queue_set);
btc_aa_snk_queue_set = NULL;
#if (BTC_SBC_DEC_DYNAMIC_MEMORY == TRUE)
osi_free(btc_sbc_decoder_context_ptr);
btc_sbc_decoder_context_ptr = NULL;
osi_free(btc_sbc_decoder_context_data);
btc_sbc_decoder_context_data = NULL;
osi_free(btc_sbc_pcm_data);
btc_sbc_pcm_data = NULL;
#endif /* BTC_SBC_DEC_DYNAMIC_MEMORY == TRUE */
}
/*****************************************************************************
@ -467,7 +515,8 @@ static void btc_a2dp_sink_handle_decoder_reset(tBTC_MEDIA_SINK_CFG_UPDATE *p_msg
btc_aa_snk_cb.rx_flush = FALSE;
APPL_TRACE_EVENT("Reset to sink role");
status = OI_CODEC_SBC_DecoderReset(&context, contextData, sizeof(contextData), 2, 2, FALSE);
status = OI_CODEC_SBC_DecoderReset(&btc_sbc_decoder_context, btc_sbc_decoder_context_data,
BTC_SBC_DEC_CONTEXT_DATA_LEN * sizeof(OI_UINT32), 2, 2, FALSE);
if (!OI_SUCCESS(status)) {
APPL_TRACE_ERROR("OI_CODEC_SBC_DecoderReset failed with error code %d\n", status);
}
@ -582,11 +631,11 @@ static void btc_a2dp_sink_handle_inc_media(tBT_SBC_HDR *p_msg)
UINT8 *sbc_start_frame = ((UINT8 *)(p_msg + 1) + p_msg->offset + 1);
int count;
UINT32 pcmBytes, availPcmBytes;
OI_INT16 *pcmDataPointer = pcmData; /*Will be overwritten on next packet receipt*/
OI_INT16 *pcmDataPointer = btc_sbc_pcm_data; /*Will be overwritten on next packet receipt*/
OI_STATUS status;
int num_sbc_frames = p_msg->num_frames_to_be_processed;
UINT32 sbc_frame_len = p_msg->len - 1;
availPcmBytes = 2 * sizeof(pcmData);
availPcmBytes = BTC_SBC_DEC_PCM_DATA_LEN * sizeof(OI_INT16);
/* XXX: Check if the below check is correct, we are checking for peer to be sink when we are sink */
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK || (btc_aa_snk_cb.rx_flush)) {
@ -603,7 +652,7 @@ static void btc_a2dp_sink_handle_inc_media(tBT_SBC_HDR *p_msg)
for (count = 0; count < num_sbc_frames && sbc_frame_len != 0; count ++) {
pcmBytes = availPcmBytes;
status = OI_CODEC_SBC_DecodeFrame(&context, (const OI_BYTE **)&sbc_start_frame,
status = OI_CODEC_SBC_DecodeFrame(&btc_sbc_decoder_context, (const OI_BYTE **)&sbc_start_frame,
(OI_UINT32 *)&sbc_frame_len,
(OI_INT16 *)pcmDataPointer,
(OI_UINT32 *)&pcmBytes);
@ -617,7 +666,7 @@ static void btc_a2dp_sink_handle_inc_media(tBT_SBC_HDR *p_msg)
p_msg->len = sbc_frame_len + 1;
}
btc_a2d_data_cb_to_app((uint8_t *)pcmData, (2 * sizeof(pcmData) - availPcmBytes));
btc_a2d_data_cb_to_app((uint8_t *)btc_sbc_pcm_data, (BTC_SBC_DEC_PCM_DATA_LEN * sizeof(OI_INT16) - availPcmBytes));
}
/*******************************************************************************
@ -763,7 +812,7 @@ static void btc_a2dp_sink_thread_init(UNUSED_ATTR void *context)
btc_a2dp_sink_state = BTC_A2DP_SINK_STATE_ON;
btc_aa_snk_cb.RxSbcQ = fixed_queue_new(SIZE_MAX);
btc_aa_snk_cb.RxSbcQ = fixed_queue_new(QUEUE_SIZE_MAX);
btc_a2dp_control_init();
}

View File

@ -156,7 +156,6 @@ typedef struct {
tBTC_AV_FEEDING_MODE feeding_mode;
tBTC_AV_MEDIA_FEEDINGS_STATE media_feeding_state;
tBTC_AV_MEDIA_FEEDINGS media_feeding;
SBC_ENC_PARAMS encoder;
osi_alarm_t *media_alarm;
} tBTC_A2DP_SOURCE_CB;
@ -187,6 +186,13 @@ static QueueSetHandle_t btc_aa_src_queue_set;
static esp_a2d_source_data_cb_t btc_aa_src_data_cb = NULL;
static UINT64 last_frame_us = 0;
#if BTC_SBC_ENC_DYNAMIC_MEMORY == FALSE
static SBC_ENC_PARAMS btc_sbc_encoder;
#else
static SBC_ENC_PARAMS *btc_sbc_encoder_ptr;
#define btc_sbc_encoder (*btc_sbc_encoder_ptr)
#endif /* BTC_SBC_ENC_DYNAMIC_MEMORY == FALSE */
void btc_a2dp_src_reg_data_cb(esp_a2d_source_data_cb_t callback)
{
// todo: critical section protection
@ -310,6 +316,14 @@ bool btc_a2dp_source_startup(void)
APPL_TRACE_EVENT("## A2DP SOURCE START MEDIA THREAD ##");
#if BTC_SBC_ENC_DYNAMIC_MEMORY == TRUE
btc_sbc_encoder_ptr = osi_calloc(sizeof(SBC_ENC_PARAMS));
if (!btc_sbc_encoder_ptr) {
APPL_TRACE_ERROR("failed to allocate SBC encoder");
goto error_exit;
}
#endif /* #if BTC_SBC_ENC_DYNAMIC_MEMORY == TRUE */
btc_aa_src_queue_set = xQueueCreateSet(BTC_A2DP_SOURCE_TASK_QUEUE_SET_LEN);
configASSERT(btc_aa_src_queue_set);
btc_aa_src_data_queue = xQueueCreate(BTC_A2DP_SOURCE_DATA_QUEUE_LEN, sizeof(void *));
@ -355,6 +369,12 @@ error_exit:;
vQueueDelete(btc_aa_src_queue_set);
btc_aa_src_queue_set = NULL;
}
#if (BTC_SBC_ENC_DYNAMIC_MEMORY == TRUE)
if (btc_sbc_encoder_ptr) {
osi_free(btc_sbc_encoder_ptr);
btc_sbc_encoder_ptr = NULL;
}
#endif /* #if BTC_SBC_ENC_DYNAMIC_MEMORY == TRUE */
return false;
}
@ -381,6 +401,11 @@ void btc_a2dp_source_shutdown(void)
vQueueDelete(btc_aa_src_queue_set);
btc_aa_src_queue_set = NULL;
#if (BTC_SBC_ENC_DYNAMIC_MEMORY == TRUE)
osi_free(btc_sbc_encoder_ptr);
btc_sbc_encoder_ptr = NULL;
#endif /* #if BTC_SBC_ENC_DYNAMIC_MEMORY == TRUE */
}
/*****************************************************************************
@ -794,13 +819,14 @@ static void btc_a2dp_source_enc_init(BT_HDR *p_msg)
btc_aa_src_cb.timestamp = 0;
/* SBC encoder config (enforced even if not used) */
btc_aa_src_cb.encoder.s16ChannelMode = pInitAudio->ChannelMode;
btc_aa_src_cb.encoder.s16NumOfSubBands = pInitAudio->NumOfSubBands;
btc_aa_src_cb.encoder.s16NumOfBlocks = pInitAudio->NumOfBlocks;
btc_aa_src_cb.encoder.s16AllocationMethod = pInitAudio->AllocationMethod;
btc_aa_src_cb.encoder.s16SamplingFreq = pInitAudio->SamplingFreq;
btc_aa_src_cb.encoder.u16BitRate = btc_a2dp_source_get_sbc_rate();
btc_sbc_encoder.s16ChannelMode = pInitAudio->ChannelMode;
btc_sbc_encoder.s16NumOfSubBands = pInitAudio->NumOfSubBands;
btc_sbc_encoder.s16NumOfBlocks = pInitAudio->NumOfBlocks;
btc_sbc_encoder.s16AllocationMethod = pInitAudio->AllocationMethod;
btc_sbc_encoder.s16SamplingFreq = pInitAudio->SamplingFreq;
btc_sbc_encoder.u16BitRate = btc_a2dp_source_get_sbc_rate();
/* Default transcoding is PCM to SBC, modified by feeding configuration */
btc_aa_src_cb.TxTranscoding = BTC_MEDIA_TRSCD_PCM_2_SBC;
@ -811,14 +837,14 @@ static void btc_a2dp_source_enc_init(BT_HDR *p_msg)
APPL_TRACE_EVENT("btc_a2dp_source_enc_init mtu %d, peer mtu %d",
btc_aa_src_cb.TxAaMtuSize, pInitAudio->MtuSize);
APPL_TRACE_EVENT(" ch mode %d, subnd %d, nb blk %d, alloc %d, rate %d, freq %d",
btc_aa_src_cb.encoder.s16ChannelMode, btc_aa_src_cb.encoder.s16NumOfSubBands,
btc_aa_src_cb.encoder.s16NumOfBlocks,
btc_aa_src_cb.encoder.s16AllocationMethod, btc_aa_src_cb.encoder.u16BitRate,
btc_aa_src_cb.encoder.s16SamplingFreq);
btc_sbc_encoder.s16ChannelMode, btc_sbc_encoder.s16NumOfSubBands,
btc_sbc_encoder.s16NumOfBlocks,
btc_sbc_encoder.s16AllocationMethod, btc_sbc_encoder.u16BitRate,
btc_sbc_encoder.s16SamplingFreq);
/* Reset entirely the SBC encoder */
SBC_Encoder_Init(&(btc_aa_src_cb.encoder));
APPL_TRACE_DEBUG("btc_a2dp_source_enc_init bit pool %d", btc_aa_src_cb.encoder.s16BitPool);
SBC_Encoder_Init(&(btc_sbc_encoder));
APPL_TRACE_DEBUG("btc_a2dp_source_enc_init bit pool %d", btc_sbc_encoder.s16BitPool);
}
@ -835,7 +861,7 @@ static void btc_a2dp_source_enc_init(BT_HDR *p_msg)
static void btc_a2dp_source_enc_update(BT_HDR *p_msg)
{
tBTC_MEDIA_UPDATE_AUDIO *pUpdateAudio = (tBTC_MEDIA_UPDATE_AUDIO *) p_msg;
SBC_ENC_PARAMS *pstrEncParams = &btc_aa_src_cb.encoder;
SBC_ENC_PARAMS *pstrEncParams = &btc_sbc_encoder;
UINT16 s16SamplingFreq;
SINT16 s16BitPool = 0;
SINT16 s16BitRate;
@ -928,19 +954,19 @@ static void btc_a2dp_source_enc_update(BT_HDR *p_msg)
if (s16BitPool > pUpdateAudio->MaxBitPool) {
APPL_TRACE_DEBUG("%s computed bitpool too large (%d)", __FUNCTION__, s16BitPool);
/* Decrease bitrate */
btc_aa_src_cb.encoder.u16BitRate -= BTC_MEDIA_BITRATE_STEP;
btc_sbc_encoder.u16BitRate -= BTC_MEDIA_BITRATE_STEP;
/* Record that we have decreased the bitrate */
protect |= 1;
} else if (s16BitPool < pUpdateAudio->MinBitPool) {
APPL_TRACE_WARNING("%s computed bitpool too small (%d)", __FUNCTION__, s16BitPool);
/* Increase bitrate */
UINT16 previous_u16BitRate = btc_aa_src_cb.encoder.u16BitRate;
btc_aa_src_cb.encoder.u16BitRate += BTC_MEDIA_BITRATE_STEP;
UINT16 previous_u16BitRate = btc_sbc_encoder.u16BitRate;
btc_sbc_encoder.u16BitRate += BTC_MEDIA_BITRATE_STEP;
/* Record that we have increased the bitrate */
protect |= 2;
/* Check over-flow */
if (btc_aa_src_cb.encoder.u16BitRate < previous_u16BitRate) {
if (btc_sbc_encoder.u16BitRate < previous_u16BitRate) {
protect |= 3;
}
} else {
@ -957,10 +983,10 @@ static void btc_a2dp_source_enc_update(BT_HDR *p_msg)
pstrEncParams->s16BitPool = s16BitPool;
APPL_TRACE_DEBUG("%s final bit rate %d, final bit pool %d", __FUNCTION__,
btc_aa_src_cb.encoder.u16BitRate, btc_aa_src_cb.encoder.s16BitPool);
btc_sbc_encoder.u16BitRate, btc_sbc_encoder.s16BitPool);
/* make sure we reinitialize encoder with new settings */
SBC_Encoder_Init(&(btc_aa_src_cb.encoder));
SBC_Encoder_Init(&(btc_sbc_encoder));
}
}
@ -991,10 +1017,10 @@ static void btc_a2dp_source_pcm2sbc_init(tBTC_MEDIA_INIT_AUDIO_FEEDING *p_feedin
case 32000:
case 48000:
/* For these sampling_freq the AV connection must be 48000 */
if (btc_aa_src_cb.encoder.s16SamplingFreq != SBC_sf48000) {
if (btc_sbc_encoder.s16SamplingFreq != SBC_sf48000) {
/* Reconfiguration needed at 48000 */
APPL_TRACE_DEBUG("SBC Reconfiguration needed at 48000");
btc_aa_src_cb.encoder.s16SamplingFreq = SBC_sf48000;
btc_sbc_encoder.s16SamplingFreq = SBC_sf48000;
reconfig_needed = TRUE;
}
break;
@ -1003,10 +1029,10 @@ static void btc_a2dp_source_pcm2sbc_init(tBTC_MEDIA_INIT_AUDIO_FEEDING *p_feedin
case 22050:
case 44100:
/* For these sampling_freq the AV connection must be 44100 */
if (btc_aa_src_cb.encoder.s16SamplingFreq != SBC_sf44100) {
if (btc_sbc_encoder.s16SamplingFreq != SBC_sf44100) {
/* Reconfiguration needed at 44100 */
APPL_TRACE_DEBUG("SBC Reconfiguration needed at 44100");
btc_aa_src_cb.encoder.s16SamplingFreq = SBC_sf44100;
btc_sbc_encoder.s16SamplingFreq = SBC_sf44100;
reconfig_needed = TRUE;
}
break;
@ -1016,21 +1042,21 @@ static void btc_a2dp_source_pcm2sbc_init(tBTC_MEDIA_INIT_AUDIO_FEEDING *p_feedin
}
/* Some AV Headsets do not support Mono => always ask for Stereo */
if (btc_aa_src_cb.encoder.s16ChannelMode == SBC_MONO) {
if (btc_sbc_encoder.s16ChannelMode == SBC_MONO) {
APPL_TRACE_DEBUG("SBC Reconfiguration needed in Stereo");
btc_aa_src_cb.encoder.s16ChannelMode = SBC_JOINT_STEREO;
btc_sbc_encoder.s16ChannelMode = SBC_JOINT_STEREO;
reconfig_needed = TRUE;
}
if (reconfig_needed != FALSE) {
APPL_TRACE_DEBUG("%s :: mtu %d", __FUNCTION__, btc_aa_src_cb.TxAaMtuSize);
APPL_TRACE_DEBUG("ch mode %d, nbsubd %d, nb %d, alloc %d, rate %d, freq %d",
btc_aa_src_cb.encoder.s16ChannelMode,
btc_aa_src_cb.encoder.s16NumOfSubBands, btc_aa_src_cb.encoder.s16NumOfBlocks,
btc_aa_src_cb.encoder.s16AllocationMethod, btc_aa_src_cb.encoder.u16BitRate,
btc_aa_src_cb.encoder.s16SamplingFreq);
btc_sbc_encoder.s16ChannelMode,
btc_sbc_encoder.s16NumOfSubBands, btc_sbc_encoder.s16NumOfBlocks,
btc_sbc_encoder.s16AllocationMethod, btc_sbc_encoder.u16BitRate,
btc_sbc_encoder.s16SamplingFreq);
SBC_Encoder_Init(&(btc_aa_src_cb.encoder));
SBC_Encoder_Init(&(btc_sbc_encoder));
} else {
APPL_TRACE_DEBUG("%s no SBC reconfig needed", __FUNCTION__);
}
@ -1105,8 +1131,8 @@ static UINT8 btc_get_num_aa_frame(void)
switch (btc_aa_src_cb.TxTranscoding) {
case BTC_MEDIA_TRSCD_PCM_2_SBC: {
UINT32 pcm_bytes_per_frame = btc_aa_src_cb.encoder.s16NumOfSubBands *
btc_aa_src_cb.encoder.s16NumOfBlocks *
UINT32 pcm_bytes_per_frame = btc_sbc_encoder.s16NumOfSubBands *
btc_sbc_encoder.s16NumOfBlocks *
btc_aa_src_cb.media_feeding.cfg.pcm.num_channel *
btc_aa_src_cb.media_feeding.cfg.pcm.bit_per_sample / 8;
@ -1162,12 +1188,12 @@ static UINT8 btc_get_num_aa_frame(void)
BOOLEAN btc_media_aa_read_feeding(void)
{
UINT16 blocm_x_subband = btc_aa_src_cb.encoder.s16NumOfSubBands * \
btc_aa_src_cb.encoder.s16NumOfBlocks;
UINT16 blocm_x_subband = btc_sbc_encoder.s16NumOfSubBands * \
btc_sbc_encoder.s16NumOfBlocks;
UINT32 read_size;
UINT16 sbc_sampling = 48000;
UINT32 src_samples;
UINT16 bytes_needed = blocm_x_subband * btc_aa_src_cb.encoder.s16NumOfChannels * \
UINT16 bytes_needed = blocm_x_subband * btc_sbc_encoder.s16NumOfChannels * \
btc_aa_src_cb.media_feeding.cfg.pcm.bit_per_sample / 8;
static UINT16 up_sampled_buffer[SBC_MAX_NUM_FRAME * SBC_MAX_NUM_OF_BLOCKS
* SBC_MAX_NUM_OF_CHANNELS * SBC_MAX_NUM_OF_SUBBANDS * 2];
@ -1181,7 +1207,7 @@ BOOLEAN btc_media_aa_read_feeding(void)
UINT32 nb_byte_read = 0;
/* Get the SBC sampling rate */
switch (btc_aa_src_cb.encoder.s16SamplingFreq) {
switch (btc_sbc_encoder.s16SamplingFreq) {
case SBC_sf48000:
sbc_sampling = 48000;
break;
@ -1199,7 +1225,7 @@ BOOLEAN btc_media_aa_read_feeding(void)
if (sbc_sampling == btc_aa_src_cb.media_feeding.cfg.pcm.sampling_freq) {
read_size = bytes_needed - btc_aa_src_cb.media_feeding_state.pcm.aa_feed_residue;
nb_byte_read = btc_aa_src_data_read(
((uint8_t *)btc_aa_src_cb.encoder.as16PcmBuffer) +
((uint8_t *)btc_sbc_encoder.as16PcmBuffer) +
btc_aa_src_cb.media_feeding_state.pcm.aa_feed_residue,
read_size);
if (nb_byte_read == read_size) {
@ -1293,7 +1319,7 @@ BOOLEAN btc_media_aa_read_feeding(void)
/* only copy the pcm sample when we have up-sampled enough PCM */
if (btc_aa_src_cb.media_feeding_state.pcm.aa_feed_residue >= bytes_needed) {
/* Copy the output pcm samples in SBC encoding buffer */
memcpy((UINT8 *)btc_aa_src_cb.encoder.as16PcmBuffer,
memcpy((UINT8 *)btc_sbc_encoder.as16PcmBuffer,
(UINT8 *)up_sampled_buffer,
bytes_needed);
/* update the residue */
@ -1322,8 +1348,8 @@ BOOLEAN btc_media_aa_read_feeding(void)
static void btc_media_aa_prep_sbc_2_send(UINT8 nb_frame)
{
BT_HDR *p_buf;
UINT16 blocm_x_subband = btc_aa_src_cb.encoder.s16NumOfSubBands *
btc_aa_src_cb.encoder.s16NumOfBlocks;
UINT16 blocm_x_subband = btc_sbc_encoder.s16NumOfSubBands *
btc_sbc_encoder.s16NumOfBlocks;
while (nb_frame) {
if (NULL == (p_buf = osi_malloc(BTC_MEDIA_AA_BUF_SIZE))) {
@ -1339,27 +1365,27 @@ static void btc_media_aa_prep_sbc_2_send(UINT8 nb_frame)
do {
/* Write @ of allocated buffer in encoder.pu8Packet */
btc_aa_src_cb.encoder.pu8Packet = (UINT8 *) (p_buf + 1) + p_buf->offset + p_buf->len;
btc_sbc_encoder.pu8Packet = (UINT8 *) (p_buf + 1) + p_buf->offset + p_buf->len;
/* Fill allocated buffer with 0 */
memset(btc_aa_src_cb.encoder.as16PcmBuffer, 0, blocm_x_subband
* btc_aa_src_cb.encoder.s16NumOfChannels);
memset(btc_sbc_encoder.as16PcmBuffer, 0, blocm_x_subband
* btc_sbc_encoder.s16NumOfChannels);
/* Read PCM data and upsample them if needed */
if (btc_media_aa_read_feeding()) {
/* SBC encode and descramble frame */
SBC_Encoder(&(btc_aa_src_cb.encoder));
A2D_SbcChkFrInit(btc_aa_src_cb.encoder.pu8Packet);
A2D_SbcDescramble(btc_aa_src_cb.encoder.pu8Packet, btc_aa_src_cb.encoder.u16PacketLength);
SBC_Encoder(&(btc_sbc_encoder));
A2D_SbcChkFrInit(btc_sbc_encoder.pu8Packet);
A2D_SbcDescramble(btc_sbc_encoder.pu8Packet, btc_sbc_encoder.u16PacketLength);
/* Update SBC frame length */
p_buf->len += btc_aa_src_cb.encoder.u16PacketLength;
p_buf->len += btc_sbc_encoder.u16PacketLength;
nb_frame--;
p_buf->layer_specific++;
} else {
APPL_TRACE_WARNING("btc_media_aa_prep_sbc_2_send underflow %d, %d",
nb_frame, btc_aa_src_cb.media_feeding_state.pcm.aa_feed_residue);
btc_aa_src_cb.media_feeding_state.pcm.counter += nb_frame *
btc_aa_src_cb.encoder.s16NumOfSubBands *
btc_aa_src_cb.encoder.s16NumOfBlocks *
btc_sbc_encoder.s16NumOfSubBands *
btc_sbc_encoder.s16NumOfBlocks *
btc_aa_src_cb.media_feeding.cfg.pcm.num_channel *
btc_aa_src_cb.media_feeding.cfg.pcm.bit_per_sample / 8;
/* no more pcm to read */
@ -1372,7 +1398,7 @@ static void btc_media_aa_prep_sbc_2_send(UINT8 nb_frame)
}
}
} while (((p_buf->len + btc_aa_src_cb.encoder.u16PacketLength) < btc_aa_src_cb.TxAaMtuSize)
} while (((p_buf->len + btc_sbc_encoder.u16PacketLength) < btc_aa_src_cb.TxAaMtuSize)
&& (p_buf->layer_specific < 0x0F) && nb_frame);
if (p_buf->len) {
@ -1616,7 +1642,7 @@ static void btc_a2dp_source_thread_init(UNUSED_ATTR void *context)
btc_a2dp_source_state = BTC_A2DP_SOURCE_STATE_ON;
btc_aa_src_cb.TxAaQ = fixed_queue_new(SIZE_MAX);
btc_aa_src_cb.TxAaQ = fixed_queue_new(QUEUE_SIZE_MAX);
btc_a2dp_control_init();
}

View File

@ -315,8 +315,10 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
TRUE, BTA_SEC_AUTHENTICATE, ((btc_av_connect_req_t *)p_data)->uuid);
} else if (event == BTA_AV_PENDING_EVT) {
bdcpy(btc_av_cb.peer_bda.address, ((tBTA_AV *)p_data)->pend.bd_addr);
UINT16 uuid = (btc_av_cb.service_id == BTA_A2DP_SOURCE_SERVICE_ID) ? UUID_SERVCLASS_AUDIO_SOURCE :
UUID_SERVCLASS_AUDIO_SINK;
BTA_AvOpen(btc_av_cb.peer_bda.address, btc_av_cb.bta_handle,
TRUE, BTA_SEC_AUTHENTICATE, UUID_SERVCLASS_AUDIO_SOURCE);
TRUE, BTA_SEC_AUTHENTICATE, uuid);
}
btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_OPENING);
} break;
@ -402,8 +404,8 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
tBTA_AV *p_bta_data = (tBTA_AV *)p_data;
esp_a2d_connection_state_t state;
btc_sm_state_t av_state;
BTC_TRACE_DEBUG("status:%d, edr 0x%x\n", p_bta_data->open.status,
p_bta_data->open.edr);
BTC_TRACE_DEBUG("status:%d, edr 0x%x, peer sep %d\n", p_bta_data->open.status,
p_bta_data->open.edr, p_bta_data->open.sep);
if (p_bta_data->open.status == BTA_AV_SUCCESS) {
state = ESP_A2D_CONNECTION_STATE_CONNECTED;
@ -428,7 +430,8 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
btc_rc_check_handle_pending_play(p_bta_data->open.bd_addr,
(p_bta_data->open.status == BTA_AV_SUCCESS));
*/
} else if (btc_av_cb.peer_sep == AVDT_TSEP_SRC) {
} else if (btc_av_cb.peer_sep == AVDT_TSEP_SRC &&
(p_bta_data->open.status == BTA_AV_SUCCESS)) {
/* Bring up AVRCP connection too */
BTA_AvOpenRc(btc_av_cb.bta_handle);
}
@ -978,10 +981,10 @@ static bt_status_t btc_av_init(int service_id)
btc_av_cb.sm_handle =
btc_sm_init((const btc_sm_handler_t *)btc_av_state_handlers, BTC_AV_STATE_IDLE);
btc_dm_enable_service(BTA_A2DP_SOURCE_SERVICE_ID);
if (service_id == BTA_A2DP_SINK_SERVICE_ID) {
btc_dm_enable_service(BTA_A2DP_SINK_SERVICE_ID);
} else {
btc_dm_enable_service(BTA_A2DP_SOURCE_SERVICE_ID);
}
btc_a2dp_on_init();
@ -1213,7 +1216,7 @@ static void bte_av_media_callback(tBTA_AV_EVT event, tBTA_AV_MEDIA *p_data)
** Returns BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise
**
*******************************************************************************/
bt_status_t btc_av_execute_service(BOOLEAN b_enable)
bt_status_t btc_av_execute_service(BOOLEAN b_enable, UINT8 tsep)
{
if (b_enable) {
/* TODO: Removed BTA_SEC_AUTHORIZE since the Java/App does not
@ -1227,7 +1230,7 @@ bt_status_t btc_av_execute_service(BOOLEAN b_enable)
| BTA_AV_FEAT_RCTG | BTA_AV_FEAT_METADATA | BTA_AV_FEAT_VENDOR
| BTA_AV_FEAT_RCCT | BTA_AV_FEAT_ADV_CTRL,
bte_av_callback);
BTA_AvRegister(BTA_AV_CHNL_AUDIO, BTC_AV_SERVICE_NAME, 0, bte_av_media_callback, &bta_av_a2d_cos);
BTA_AvRegister(BTA_AV_CHNL_AUDIO, BTC_AV_SERVICE_NAME, 0, bte_av_media_callback, &bta_av_a2d_cos, tsep);
} else {
BTA_AvDeregister(btc_av_cb.bta_handle);
BTA_AvDisable();
@ -1235,6 +1238,20 @@ bt_status_t btc_av_execute_service(BOOLEAN b_enable)
return BT_STATUS_SUCCESS;
}
/*******************************************************************************
**
** Function btc_av_source_execute_service
**
** Description Initializes/Shuts down the A2DP source service
**
** Returns BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise
**
*******************************************************************************/
bt_status_t btc_av_source_execute_service(BOOLEAN b_enable)
{
return btc_av_execute_service(b_enable, AVDT_TSEP_SRC);
}
/*******************************************************************************
**
** Function btc_av_sink_execute_service
@ -1246,6 +1263,10 @@ bt_status_t btc_av_execute_service(BOOLEAN b_enable)
*******************************************************************************/
bt_status_t btc_av_sink_execute_service(BOOLEAN b_enable)
{
bt_status_t ret = btc_av_execute_service(b_enable, AVDT_TSEP_SNK);
if (ret != BT_STATUS_SUCCESS) {
return ret;
}
#if (BTA_AV_SINK_INCLUDED == TRUE)
BTA_AvEnable_Sink(b_enable);
#endif

View File

@ -28,9 +28,24 @@
#include "btc/btc_ble_storage.h"
#include "btc/btc_dm.h"
#include "btc/btc_util.h"
#include "osi/mutex.h"
#include "esp_bt.h"
static tBTA_BLE_ADV_DATA gl_bta_adv_data;
static tBTA_BLE_ADV_DATA gl_bta_scan_rsp_data;
#if SCAN_QUEUE_CONGEST_CHECK
static list_t *adv_filter_list;
static osi_mutex_t adv_list_lock;
bool btc_check_adv_list(uint8_t * addr, uint8_t addr_type);
uint32_t btc_get_adv_list_length(void);
void btc_adv_list_refresh(void);
void btc_adv_list_lock(void);
void btc_adv_list_unlock(void);
static uint16_t btc_adv_list_count = 0;
#define BTC_ADV_LIST_MAX_LENGTH 50
#define BTC_ADV_LIST_MAX_COUNT 200
#endif
static inline void btc_gap_ble_cb_to_app(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)
{
@ -128,6 +143,7 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT
if (p_adv_data->include_txpower) {
mask |= BTM_BLE_AD_BIT_TX_PWR;
bta_adv_data->tx_power = esp_ble_tx_power_get(ESP_BLE_PWR_TYPE_ADV);
}
if (p_adv_data->min_interval > 0 && p_adv_data->max_interval > 0 &&
@ -436,6 +452,10 @@ static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params, tBT
status = ESP_BT_STATUS_PARM_INVALID;
BTC_TRACE_ERROR("Invalid advertisting channel map parameters.\n");
}
if (!BLE_ISVALID_PARAM(ble_adv_params->peer_addr_type, BLE_ADDR_TYPE_PUBLIC, BLE_ADDR_TYPE_RANDOM)) {
status = ESP_BT_STATUS_PARM_INVALID;
BTC_TRACE_ERROR("Invalid advertisting peer address type parameters.\n");
}
if(status != ESP_BT_STATUS_SUCCESS) {
if(start_adv_cback) {
start_adv_cback(status);
@ -510,6 +530,19 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data
param.scan_rst.search_evt = event;
switch (event) {
case BTA_DM_INQ_RES_EVT: {
#if SCAN_QUEUE_CONGEST_CHECK
if(btc_check_queue_is_congest()) {
BTC_TRACE_DEBUG("BtcQueue is congested");
if(btc_get_adv_list_length() > BTC_ADV_LIST_MAX_LENGTH || btc_adv_list_count > BTC_ADV_LIST_MAX_COUNT) {
btc_adv_list_refresh();
btc_adv_list_count = 0;
}
if(btc_check_adv_list(p_data->inq_res.bd_addr, p_data->inq_res.ble_addr_type)) {
return;
}
}
btc_adv_list_count ++;
#endif
bdcpy(param.scan_rst.bda, p_data->inq_res.bd_addr);
param.scan_rst.dev_type = p_data->inq_res.device_type;
param.scan_rst.rssi = p_data->inq_res.rssi;
@ -585,6 +618,9 @@ static void btc_stop_scan_callback(tBTA_STATUS status)
if (ret != BT_STATUS_SUCCESS) {
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
}
#if SCAN_QUEUE_CONGEST_CHECK
btc_adv_list_refresh();
#endif
}
void btc_update_conn_param_callback (UINT8 status, BD_ADDR bd_addr, tBTM_LE_UPDATE_CONN_PRAMS *update_conn_params)
@ -725,6 +761,9 @@ static void btc_ble_start_scanning(uint32_t duration,
tBTA_START_STOP_SCAN_CMPL_CBACK *start_scan_cb)
{
if ((results_cb != NULL) && (start_scan_cb != NULL)) {
#if SCAN_QUEUE_CONGEST_CHECK
btc_adv_list_refresh();
#endif
//Start scan the device
BTA_DmBleScan(true, duration, results_cb, start_scan_cb);
} else {
@ -796,7 +835,7 @@ static void btc_ble_set_rand_addr (BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *
BTA_DmSetRandAddress(rand_addr, btc_set_rand_addr_callback);
} else {
btc_set_rand_addr_callback(BTM_INVALID_STATIC_RAND_ADDR);
BTC_TRACE_ERROR("Invalid random address, the high bit should be 0b11, all bits of the random part shall not be to 1 or 0");
BTC_TRACE_ERROR("Invalid random address, the high bit should be 0b11, bits of the random part shall not be all 1 or 0");
}
} else {
btc_set_rand_addr_callback(BTM_INVALID_STATIC_RAND_ADDR);
@ -1018,7 +1057,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
BTA_DmUpdateWhiteList(arg->update_white_list.add_remove, arg->update_white_list.remote_bda, btc_add_whitelist_complete_callback);
break;
case BTC_GAP_BLE_ACT_READ_RSSI:
BTA_DmBleReadRSSI(arg->read_rssi.remote_addr, btc_read_ble_rssi_cmpl_callback);
BTA_DmBleReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback);
break;
case BTC_GAP_BLE_ACT_SET_CONN_PARAMS:
BTA_DmSetBlePrefConnParams(arg->set_conn_params.bd_addr, arg->set_conn_params.min_conn_int,
@ -1081,6 +1120,25 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
bta_dm_co_ble_set_max_key_size(key_size);
break;
}
case ESP_BLE_SM_SET_STATIC_PASSKEY: {
uint32_t passkey = 0;
for(uint8_t i = 0; i < arg->set_security_param.len; i++)
{
passkey += (((uint8_t *)value)[i]<<(8*i));
}
BTA_DmBleSetStaticPasskey(true, passkey);
break;
}
case ESP_BLE_SM_CLEAR_STATIC_PASSKEY: {
BTA_DmBleSetStaticPasskey(false, 0);
break;
}
case ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH: {
uint8_t enable = 0;
STREAM_TO_UINT8(enable, value);
bta_dm_co_ble_set_accept_auth_enable(enable);
break;
}
default:
break;
}
@ -1108,7 +1166,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
case BTC_GAP_BLE_REMOVE_BOND_DEV_EVT: {
BD_ADDR bd_addr;
memcpy(bd_addr, arg->remove_bond_device.bd_addr, sizeof(BD_ADDR));
BTA_DmRemoveDevice(bd_addr);
BTA_DmRemoveDevice(bd_addr, BT_TRANSPORT_LE);
break;
}
#endif ///SMP_INCLUDED == TRUE
@ -1134,3 +1192,99 @@ void btc_gap_ble_deinit(void)
btc_cleanup_adv_data(&gl_bta_adv_data);
btc_cleanup_adv_data(&gl_bta_scan_rsp_data);
}
#if SCAN_QUEUE_CONGEST_CHECK
void btc_adv_list_free(void *data)
{
osi_free(data);
}
void btc_adv_list_init(void)
{
osi_mutex_new(&adv_list_lock);
adv_filter_list = list_new(btc_adv_list_free);
}
void btc_adv_list_deinit(void)
{
osi_mutex_free(&adv_list_lock);
if(adv_filter_list) {
list_free(adv_filter_list);
adv_filter_list = NULL;
}
}
void btc_adv_list_add_packet(void * data)
{
if(!data) {
BTC_TRACE_ERROR("%s data is NULL", __func__);
return;
}
btc_adv_list_lock();
list_prepend(adv_filter_list, data);
btc_adv_list_unlock();
}
uint32_t btc_get_adv_list_length(void)
{
if(!adv_filter_list) {
BTC_TRACE_ERROR("%s adv_filter_list is NULL", __func__);
return 0;
}
btc_adv_list_lock();
size_t length = list_length(adv_filter_list);
btc_adv_list_unlock();
return length;
}
void btc_adv_list_refresh(void)
{
if(!adv_filter_list) {
BTC_TRACE_ERROR("%s adv_filter_list is NULL", __func__);
return ;
}
btc_adv_list_lock();
list_clear(adv_filter_list);
btc_adv_list_unlock();
}
bool btc_check_adv_list(uint8_t * addr, uint8_t addr_type)
{
bool found = false;
if(!adv_filter_list || !addr) {
BTC_TRACE_ERROR("%s adv_filter_list is NULL", __func__);
return found;
}
btc_adv_list_lock();
for (const list_node_t *node = list_begin(adv_filter_list); node != list_end(adv_filter_list); node = list_next(node)) {
btc_adv_packet_t *packet = (btc_adv_packet_t *)list_node(node);
if(!bdcmp(addr, packet->addr) && packet->addr_type == addr_type) {
found = true;
break;
}
}
btc_adv_list_unlock();
if(!found) {
btc_adv_packet_t *adv_packet = osi_malloc(sizeof(btc_adv_packet_t));
if(adv_packet) {
adv_packet->addr_type = addr_type;
bdcpy(adv_packet->addr, addr);
btc_adv_list_add_packet(adv_packet);
} else {
BTC_TRACE_ERROR("%s adv_packet malloc failed", __func__);
}
}
return found;
}
void btc_adv_list_lock(void)
{
osi_mutex_lock(&adv_list_lock, OSI_MUTEX_MAX_TIMEOUT);
}
void btc_adv_list_unlock(void)
{
osi_mutex_unlock(&adv_list_lock);
}
#endif

View File

@ -151,7 +151,7 @@ static void search_devices_copy_cb(btc_msg_t *msg, void *p_dest, void *p_src)
switch (p_dest_data->event) {
case BTA_DM_INQ_RES_EVT: {
if (p_src_data->p_data->inq_res.p_eir) {
p_dest_data->p_data->inq_res.p_eir = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
p_dest_data->p_data->inq_res.p_eir = (UINT8 *)(p_dest_data->p_data) + sizeof(tBTA_DM_SEARCH);
memcpy(p_dest_data->p_data->inq_res.p_eir, p_src_data->p_data->inq_res.p_eir, HCI_EXT_INQ_RESPONSE_LEN);
}
}
@ -159,7 +159,7 @@ static void search_devices_copy_cb(btc_msg_t *msg, void *p_dest, void *p_src)
case BTA_DM_DISC_RES_EVT: {
if (p_src_data->p_data->disc_res.raw_data_size && p_src_data->p_data->disc_res.p_raw_data) {
p_dest_data->p_data->disc_res.p_raw_data = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
p_dest_data->p_data->disc_res.p_raw_data = (UINT8 *)(p_dest_data->p_data) + sizeof(tBTA_DM_SEARCH);
memcpy(p_dest_data->p_data->disc_res.p_raw_data,
p_src_data->p_data->disc_res.p_raw_data,
p_src_data->p_data->disc_res.raw_data_size);
@ -194,7 +194,7 @@ static void search_service_record_copy_cb(btc_msg_t *msg, void *p_dest, void *p_
switch (p_dest_data->event) {
case BTA_DM_DISC_RES_EVT: {
if (p_src_data->p_data->disc_res.p_raw_data && p_src_data->p_data->disc_res.raw_data_size > 0) {
p_dest_data->p_data->disc_res.p_raw_data = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
p_dest_data->p_data->disc_res.p_raw_data = (UINT8 *)(p_dest_data->p_data) + sizeof(tBTA_DM_SEARCH);
memcpy(p_dest_data->p_data->disc_res.p_raw_data,
p_src_data->p_data->disc_res.p_raw_data,
p_src_data->p_data->disc_res.raw_data_size);
@ -566,7 +566,7 @@ static void search_services_copy_cb(btc_msg_t *msg, void *p_dest, void *p_src)
case BTA_DM_DISC_RES_EVT: {
if (p_src_data->p_data->disc_res.result == BTA_SUCCESS) {
if (p_src_data->p_data->disc_res.num_uuids > 0) {
p_dest_data->p_data->disc_res.p_uuid_list = (UINT8 *)(p_dest_data->p_data + sizeof(tBTA_DM_SEARCH));
p_dest_data->p_data->disc_res.p_uuid_list = (UINT8 *)(p_dest_data->p_data) + sizeof(tBTA_DM_SEARCH);
memcpy(p_dest_data->p_data->disc_res.p_uuid_list, p_src_data->p_data->disc_res.p_uuid_list,
p_src_data->p_data->disc_res.num_uuids * MAX_UUID_SIZE);
osi_free(p_src_data->p_data->disc_res.p_uuid_list);
@ -632,20 +632,27 @@ static void btc_gap_bt_read_rssi_delta_cmpl_callback(void *p_data)
static void btc_gap_bt_read_rssi_delta(btc_gap_bt_args_t *arg)
{
BTA_DmBleReadRSSI(arg->read_rssi_delta.bda.address, btc_gap_bt_read_rssi_delta_cmpl_callback);
BTA_DmBleReadRSSI(arg->read_rssi_delta.bda.address, BTA_TRANSPORT_BR_EDR, btc_gap_bt_read_rssi_delta_cmpl_callback);
}
esp_err_t btc_gap_bt_remove_bond_device(btc_gap_bt_args_t *arg)
{
BD_ADDR bd_addr;
memcpy(bd_addr, arg->rm_bond_device.bda.address, sizeof(BD_ADDR));
if(BTA_DmRemoveDevice(bd_addr) == BTA_SUCCESS){
btc_storage_remove_bonded_device(&(arg->rm_bond_device.bda));
if(BTA_DmRemoveDevice(bd_addr, BT_TRANSPORT_BR_EDR) == BTA_SUCCESS){
return ESP_BT_STATUS_SUCCESS;
}
return ESP_BT_STATUS_FAIL;
}
static void btc_gap_bt_set_pin_type(btc_gap_bt_args_t *arg){
BTA_DMSetPinType (arg->set_pin_type.pin_type, arg->set_pin_type.pin_code, arg->set_pin_type.pin_code_len);
}
static void btc_gap_bt_pin_reply(btc_gap_bt_args_t *arg){
BTA_DmPinReply(arg->pin_reply.bda.address, arg->pin_reply.accept, arg->pin_reply.pin_code_len, arg->pin_reply.pin_code);
}
void btc_gap_bt_call_handler(btc_msg_t *msg)
{
btc_gap_bt_args_t *arg = (btc_gap_bt_args_t *)msg->arg;
@ -683,6 +690,14 @@ void btc_gap_bt_call_handler(btc_msg_t *msg)
btc_gap_bt_remove_bond_device(msg->arg);
break;
}
case BTC_GAP_BT_ACT_SET_PIN_TYPE:{
btc_gap_bt_set_pin_type(arg);
break;
}
case BTC_GAP_BT_ACT_PIN_REPLY: {
btc_gap_bt_pin_reply(arg);
break;
}
default:
break;
}
@ -716,6 +731,7 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
break;
case BTC_GAP_BT_READ_RSSI_DELTA_EVT:
case BTC_GAP_BT_AUTH_CMPL_EVT:
case BTC_GAP_BT_PIN_REQ_EVT:
break;
default:
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
@ -746,6 +762,10 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
btc_gap_bt_cb_to_app(ESP_BT_GAP_AUTH_CMPL_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
break;
}
case BTC_GAP_BT_PIN_REQ_EVT:{
btc_gap_bt_cb_to_app(ESP_BT_GAP_PIN_REQ_EVT, (esp_bt_gap_cb_param_t *)msg->arg);
break;
}
default:
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
break;

View File

@ -331,6 +331,7 @@ esp_gatt_status_t btc_ble_gattc_get_service(uint16_t conn_id, esp_bt_uuid_t *svc
if (bta_uuid) {
osi_free(bta_uuid);
}
*count = 0;
return status;
} else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)svc_num, ESP_GATT_DB_PRIMARY_SERVICE, offset, (void *)result, db);
@ -362,6 +363,7 @@ esp_gatt_status_t btc_ble_gattc_get_all_char(uint16_t conn_id,
if (db) {
osi_free(db);
}
*count = 0;
return status;
} else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)char_num, ESP_GATT_DB_CHARACTERISTIC, offset, (void *)result, db);
@ -389,6 +391,7 @@ esp_gatt_status_t btc_ble_gattc_get_all_descr(uint16_t conn_id,
if (db) {
osi_free(db);
}
*count = 0;
return status;
} else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)descr_num, ESP_GATT_DB_DESCRIPTOR, offset, (void *)result, db);
@ -420,6 +423,7 @@ esp_gatt_status_t btc_ble_gattc_get_char_by_uuid(uint16_t conn_id,
if (db) {
osi_free(db);
}
*count = 0;
return status;
} else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)char_num, ESP_GATT_DB_CHARACTERISTIC, 0, (void *)result, db);
@ -456,6 +460,7 @@ esp_gatt_status_t btc_ble_gattc_get_descr_by_uuid(uint16_t conn_id,
if (db) {
osi_free(db);
}
*count = 0;
return status;
} else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)descr_num, ESP_GATT_DB_DESCRIPTOR, 0, (void *)result, db);
@ -487,6 +492,7 @@ esp_gatt_status_t btc_ble_gattc_get_descr_by_char_handle(uint16_t conn_id,
if (db) {
osi_free(db);
}
*count = 0;
return status;
} else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)descr_num, ESP_GATT_DB_DESCRIPTOR, 0, (void *)result, db);
@ -524,6 +530,7 @@ esp_gatt_status_t btc_ble_gattc_get_include_service(uint16_t conn_id,
if (db) {
osi_free(db);
}
*count = 0;
return status;
}else {
btc_gattc_fill_gatt_db_conversion(*count, (uint16_t)incl_num, ESP_GATT_DB_INCLUDED_SERVICE, 0, (void *)result, db);
@ -566,6 +573,7 @@ esp_gatt_status_t btc_ble_gattc_get_db(uint16_t conn_id, uint16_t start_handle,
if (get_db) {
osi_free(get_db);
}
*count = 0;
return ESP_GATT_NOT_FOUND;
}
@ -579,7 +587,7 @@ esp_gatt_status_t btc_ble_gattc_get_db(uint16_t conn_id, uint16_t start_handle,
btc128_to_bta_uuid(&bta_uuid, get_db[i].uuid.uu);
bta_to_btc_uuid(&db[i].uuid, &bta_uuid);
}
*count = num;
*count = db_size;
//don't forget to free the db buffer after used.
if (get_db) {
osi_free(get_db);
@ -738,7 +746,7 @@ void btc_gattc_call_handler(btc_msg_t *msg)
btc_gattc_unreg_for_notify(arg);
break;
case BTC_GATTC_ACT_CACHE_REFRESH:
BTA_GATTC_Refresh(arg->cache_refresh.remote_bda);
BTA_GATTC_Refresh(arg->cache_refresh.remote_bda, true);
break;
case BTC_GATTC_ACT_CACHE_ASSOC:
BTA_GATTC_CacheAssoc(arg->cache_assoc.gattc_if,

View File

@ -506,6 +506,8 @@ static void btc_gatts_cb_param_copy_req(btc_msg_t *msg, void *p_dest, void *p_sr
if (p_dest_data->req_data.p_data != NULL) {
memcpy(p_dest_data->req_data.p_data, p_src_data->req_data.p_data,
sizeof(tBTA_GATTS_REQ_DATA));
} else {
BTC_TRACE_ERROR("%s %d no mem\n", __func__, msg->act);
}
break;
@ -528,9 +530,6 @@ static void btc_gatts_cb_param_copy_free(btc_msg_t *msg, tBTA_GATTS *p_data)
}
break;
case BTA_GATTS_CONF_EVT:
if (p_data && p_data->req_data.value){
osi_free(p_data->req_data.value);
}
break;
default:
break;
@ -759,6 +758,9 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
param.write.conn_id = BTC_GATT_GET_CONN_ID(p_data->req_data.conn_id);
param.write.trans_id = p_data->req_data.trans_id;
memcpy(param.write.bda, p_data->req_data.remote_bda, ESP_BD_ADDR_LEN);
if (p_data->req_data.p_data == NULL) {
break;
}
param.write.handle = p_data->req_data.p_data->write_req.handle;
param.write.offset = p_data->req_data.p_data->write_req.offset;
param.write.need_rsp = p_data->req_data.p_data->write_req.need_rsp;
@ -775,6 +777,9 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
param.exec_write.conn_id = BTC_GATT_GET_CONN_ID(p_data->req_data.conn_id);
param.exec_write.trans_id = p_data->req_data.trans_id;
memcpy(param.exec_write.bda, p_data->req_data.remote_bda, ESP_BD_ADDR_LEN);
if (p_data->req_data.p_data == NULL) {
break;
}
param.exec_write.exec_write_flag = p_data->req_data.p_data->exec_write;
btc_gatts_cb_to_app(ESP_GATTS_EXEC_WRITE_EVT, gatts_if, &param);

View File

@ -166,5 +166,7 @@ void btc_gap_ble_cb_deep_free(btc_msg_t *msg);
void btc_gap_ble_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
void btc_gap_callback_init(void);
void btc_gap_ble_deinit(void);
void btc_adv_list_init(void);
void btc_adv_list_deinit(void);
#endif /* __BTC_GAP_BLE_H__ */

View File

@ -28,6 +28,7 @@ typedef enum {
BTC_GAP_BT_SEARCH_SERVICE_RECORD_EVT,
BTC_GAP_BT_READ_RSSI_DELTA_EVT,
BTC_GAP_BT_AUTH_CMPL_EVT,
BTC_GAP_BT_PIN_REQ_EVT,
}btc_gap_bt_evt_t;
typedef enum {
@ -39,6 +40,8 @@ typedef enum {
BTC_GAP_BT_ACT_SET_COD,
BTC_GAP_BT_ACT_READ_RSSI_DELTA,
BTC_GAP_BT_ACT_REMOVE_BOND_DEVICE,
BTC_GAP_BT_ACT_SET_PIN_TYPE,
BTC_GAP_BT_ACT_PIN_REPLY,
} btc_gap_bt_act_t;
/* btc_bt_gap_args_t */
@ -79,6 +82,22 @@ typedef union {
struct rm_bond_device_args {
bt_bdaddr_t bda;
} rm_bond_device;
// BTC_GAP_BT_ACT_SET_PIN_TYPE
struct set_pin_type_args {
esp_bt_pin_type_t pin_type;
uint8_t pin_code_len;
esp_bt_pin_code_t pin_code;
} set_pin_type;
// BTC_GAP_BT_ACT_PIN_REPLY
struct pin_reply_args {
bt_bdaddr_t bda;
bool accept;
uint8_t pin_code_len;
esp_bt_pin_code_t pin_code;
} pin_reply;
} btc_gap_bt_args_t;
void btc_gap_bt_call_handler(btc_msg_t *msg);

View File

@ -52,7 +52,7 @@ typedef struct {
list_t *list;
list_t *incoming_list;
uint8_t service_uuid[16];
char service_name[ESP_SPP_SERVER_NAME_MAX];
char service_name[ESP_SPP_SERVER_NAME_MAX + 1];
} spp_slot_t;
static struct spp_local_param_t {

View File

@ -26,9 +26,6 @@
#define UNUSED(x) (void)(x)
#ifndef SIZE_MAX
#define SIZE_MAX 254
#endif
/*Timer Related Defination*/
//by Snake.T

View File

@ -94,6 +94,10 @@
#define CLASSIC_BT_INCLUDED FALSE
#endif /* CLASSIC_BT_INCLUDED */
#ifndef CONFIG_GATTC_CACHE_NVS_FLASH
#define CONFIG_GATTC_CACHE_NVS_FLASH FALSE
#endif /* CONFIG_GATTC_CACHE_NVS_FLASH */
/******************************************************************************
**
** BLE features
@ -111,13 +115,19 @@
#define GATTC_INCLUDED FALSE
#endif /* CONFIG_GATTC_ENABLE */
#if (CONFIG_GATTC_ENABLE && CONFIG_GATTC_CACHE_NVS_FLASH)
#define GATTC_CACHE_NVS TRUE
#else
#define GATTC_CACHE_NVS FALSE
#endif /* CONFIG_GATTC_CACHE_NVS_FLASH */
#if (CONFIG_SMP_ENABLE)
#define SMP_INCLUDED TRUE
#define BLE_PRIVACY_SPT TRUE
#else
#define SMP_INCLUDED FALSE
#define BLE_PRIVACY_SPT FALSE
#endif /* CONFIG_GATTC_ENABLE */
#endif /* CONFIG_SMP_ENABLE */
#if (CONFIG_BT_ACL_CONNECTIONS)
#define MAX_ACL_CONNECTIONS CONFIG_BT_ACL_CONNECTIONS
@ -297,6 +307,16 @@
#define BTA_AV_CO_CP_SCMS_T FALSE//FALSE
#endif
#ifndef QUEUE_CONGEST_SIZE
#define QUEUE_CONGEST_SIZE 40
#endif
#ifndef CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK
#define SCAN_QUEUE_CONGEST_CHECK FALSE
#else
#define SCAN_QUEUE_CONGEST_CHECK CONFIG_BLE_HOST_QUEUE_CONGESTION_CHECK
#endif
/* This feature is used to eanble interleaved scan*/
#ifndef BTA_HOST_INTERLEAVE_SEARCH
#define BTA_HOST_INTERLEAVE_SEARCH FALSE//FALSE
@ -571,7 +591,7 @@
#define BTM_DEFAULT_DISC_INTERVAL 0x0800
#endif
/*
/*
* {SERVICE_CLASS, MAJOR_CLASS, MINOR_CLASS}
*
* SERVICE_CLASS:0x5A (Bit17 -Networking,Bit19 - Capturing,Bit20 -Object Transfer,Bit22 -Telephony)
@ -744,6 +764,14 @@
#define BTM_BLE_CONFORMANCE_TESTING FALSE
#endif
/******************************************************************************
**
** CONTROLLER TO HOST FLOW CONTROL
**
******************************************************************************/
#define C2H_FLOW_CONTROL_INCLUDED TRUE
/******************************************************************************
**
** L2CAP
@ -963,7 +991,7 @@
#endif
#ifndef BTM_BLE_ADV_TX_POWER
#define BTM_BLE_ADV_TX_POWER {-21, -15, -7, 1, 9}
#define BTM_BLE_ADV_TX_POWER {-12, -9, -6, -3, 0, 3, 6, 9}
#endif

View File

@ -31,6 +31,7 @@ typedef struct {
UINT8 ble_init_key;
UINT8 ble_resp_key;
UINT8 ble_max_key_size;
UINT8 ble_accept_auth_enable;
#endif
} tBTE_APPL_CFG;

View File

@ -95,6 +95,12 @@ static void start_up(void)
response, &acl_data_size_classic, &acl_buffer_count_classic,
&sco_data_size, &sco_buffer_count);
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
// Enable controller to host flow control
response = AWAIT_COMMAND(packet_factory->make_set_c2h_flow_control(HCI_HOST_FLOW_CTRL_ACL_ON));
packet_parser->parse_generic_command_complete(response);
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
// Tell the controller about our buffer sizes and buffer counts next
// TODO(zachoverflow): factor this out. eww l2cap contamination. And why just a hardcoded 10?
response = AWAIT_COMMAND(
@ -252,6 +258,9 @@ static void start_up(void)
#if (BTM_SCO_HCI_INCLUDED == TRUE)
response = AWAIT_COMMAND(packet_factory->make_write_sync_flow_control_enable(1));
packet_parser->parse_generic_command_complete(response);
response = AWAIT_COMMAND(packet_factory->make_write_default_erroneous_data_report(1));
packet_parser->parse_generic_command_complete(response);
#endif
readable = true;
// return future_new_immediate(FUTURE_SUCCESS);

View File

@ -26,11 +26,17 @@
#include "hci/hci_layer.h"
#include "osi/thread.h"
#include "esp_bt.h"
#include "stack/hcimsgs.h"
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
#include "l2c_int.h"
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
#define HCI_HAL_SERIAL_BUFFER_SIZE 1026
#define HCI_BLE_EVENT 0x3e
#define PACKET_TYPE_TO_INBOUND_INDEX(type) ((type) - 2)
#define PACKET_TYPE_TO_INDEX(type) ((type) - 1)
extern bool BTU_check_queue_is_congest(void);
static const uint8_t preamble_sizes[] = {
@ -92,6 +98,7 @@ static void hci_hal_env_init(
static void hci_hal_env_deinit(void)
{
fixed_queue_free(hci_hal_env.rx_q, hci_hal_env.allocator->free);
hci_hal_env.rx_q = NULL;
}
static bool hal_open(const hci_hal_callbacks_t *upper_callbacks)
@ -99,7 +106,7 @@ static bool hal_open(const hci_hal_callbacks_t *upper_callbacks)
assert(upper_callbacks != NULL);
callbacks = upper_callbacks;
hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, SIZE_MAX);
hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, QUEUE_SIZE_MAX);
xHciH4Queue = xQueueCreate(HCI_H4_QUEUE_LEN, sizeof(BtTaskEvt_t));
xTaskCreatePinnedToCore(hci_hal_h4_rx_handler, HCI_H4_TASK_NAME, HCI_H4_TASK_STACK_SIZE, NULL, HCI_H4_TASK_PRIO, &xHciH4TaskHandle, HCI_H4_TASK_PINNED_TO_CORE);
@ -165,6 +172,7 @@ static void hci_hal_h4_rx_handler(void *arg)
if (pdTRUE == xQueueReceive(xHciH4Queue, &e, (portTickType)portMAX_DELAY)) {
if (e.sig == SIG_HCI_HAL_RECV_PACKET) {
fixed_queue_process(hci_hal_env.rx_q);
}
}
}
@ -178,13 +186,51 @@ task_post_status_t hci_hal_h4_task_post(task_post_t timeout)
evt.par = 0;
if (xQueueSend(xHciH4Queue, &evt, timeout) != pdTRUE) {
HCI_TRACE_ERROR("xHciH4Queue failed\n");
return TASK_POST_SUCCESS;
}
return TASK_POST_FAIL;
}
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
static void hci_packet_complete(BT_HDR *packet){
uint8_t type, num_handle;
uint16_t handle;
uint16_t handles[MAX_L2CAP_LINKS + 4];
uint16_t num_packets[MAX_L2CAP_LINKS + 4];
uint8_t *stream = packet->data + packet->offset;
tL2C_LCB *p_lcb = NULL;
STREAM_TO_UINT8(type, stream);
if (type == DATA_TYPE_ACL/* || type == DATA_TYPE_SCO*/) {
STREAM_TO_UINT16(handle, stream);
handle = handle & HCI_DATA_HANDLE_MASK;
p_lcb = l2cu_find_lcb_by_handle(handle);
if (p_lcb) {
p_lcb->completed_packets++;
}
if (esp_vhci_host_check_send_available()){
num_handle = l2cu_find_completed_packets(handles, num_packets);
if (num_handle > 0){
btsnd_hcic_host_num_xmitted_pkts (num_handle, handles, num_packets);
}
} else {
//Send HCI_Host_Number_of_Completed_Packets next time.
}
}
}
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
bool host_recv_adv_packet(BT_HDR *packet)
{
assert(packet);
if(packet->data[0] == DATA_TYPE_EVENT && packet->data[1] == HCI_BLE_EVENT && packet->data[3] == HCI_BLE_ADV_PKT_RPT_EVT) {
return true;
}
return false;
}
static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
{
uint8_t type, hdr_size;
@ -194,6 +240,11 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
if (!packet) {
return;
}
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
hci_packet_complete(packet);
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
STREAM_TO_UINT8(type, stream);
packet->offset++;
packet->len--;
@ -233,6 +284,13 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
hci_hal_env.allocator->free(packet);
return;
}
#if SCAN_QUEUE_CONGEST_CHECK
if(BTU_check_queue_is_congest() && host_recv_adv_packet(packet)) {
HCI_TRACE_ERROR("BtuQueue is congested");
hci_hal_env.allocator->free(packet);
return;
}
#endif
packet->event = outbound_event_types[PACKET_TYPE_TO_INDEX(type)];
callbacks->packet_ready(packet);
@ -260,6 +318,10 @@ static int host_recv_pkt_cb(uint8_t *data, uint16_t len)
BT_HDR *pkt;
size_t pkt_size;
if (hci_hal_env.rx_q == NULL) {
return 0;
}
pkt_size = BT_HDR_SIZE + len;
pkt = (BT_HDR *)hci_hal_env.allocator->alloc(pkt_size);
if (!pkt) {
@ -271,7 +333,7 @@ static int host_recv_pkt_cb(uint8_t *data, uint16_t len)
pkt->layer_specific = 0;
memcpy(pkt->data, data, len);
fixed_queue_enqueue(hci_hal_env.rx_q, pkt);
hci_hal_h4_task_post(TASK_POST_BLOCKING);
hci_hal_h4_task_post(100 / portTICK_PERIOD_MS);
BTTRC_DUMP_BUFFER("Recv Pkt", pkt->data, len);

View File

@ -158,7 +158,7 @@ static int hci_layer_init_env(void)
// as per the Bluetooth spec, Volume 2, Part E, 4.4 (Command Flow Control)
// This value can change when you get a command complete or command status event.
hci_host_env.command_credits = 1;
hci_host_env.command_queue = fixed_queue_new(SIZE_MAX);
hci_host_env.command_queue = fixed_queue_new(QUEUE_SIZE_MAX);
if (hci_host_env.command_queue) {
fixed_queue_register_dequeue(hci_host_env.command_queue, event_command_ready);
} else {
@ -166,7 +166,7 @@ static int hci_layer_init_env(void)
return -1;
}
hci_host_env.packet_queue = fixed_queue_new(SIZE_MAX);
hci_host_env.packet_queue = fixed_queue_new(QUEUE_SIZE_MAX);
if (hci_host_env.packet_queue) {
fixed_queue_register_dequeue(hci_host_env.packet_queue, event_packet_ready);
} else {
@ -274,6 +274,7 @@ static void transmit_command(
fixed_queue_enqueue(hci_host_env.command_queue, wait_entry);
hci_host_task_post(TASK_POST_BLOCKING);
}
static future_t *transmit_command_futured(BT_HDR *command)
@ -317,8 +318,14 @@ static void event_command_ready(fixed_queue_t *queue)
command_waiting_response_t *cmd_wait_q = &hci_host_env.cmd_waiting_q;
wait_entry = fixed_queue_dequeue(queue);
hci_host_env.command_credits--;
if(wait_entry->opcode == HCI_HOST_NUM_PACKETS_DONE){
packet_fragmenter->fragment_and_dispatch(wait_entry->command);
buffer_allocator->free(wait_entry->command);
osi_free(wait_entry);
return;
}
hci_host_env.command_credits--;
// Move it to the list of commands awaiting response
osi_mutex_lock(&cmd_wait_q->commands_pending_response_lock, OSI_MUTEX_MAX_TIMEOUT);
list_append(cmd_wait_q->commands_pending_response, wait_entry);
@ -435,7 +442,6 @@ static bool filter_incoming_event(BT_HDR *packet)
if (event_code == HCI_COMMAND_COMPLETE_EVT) {
STREAM_TO_UINT8(hci_host_env.command_credits, stream);
STREAM_TO_UINT16(opcode, stream);
wait_entry = get_waiting_command(opcode);
if (!wait_entry) {
HCI_TRACE_WARNING("%s command complete event with no matching command. opcode: 0x%x.", __func__, opcode);

View File

@ -45,6 +45,16 @@ static BT_HDR *make_read_buffer_size(void)
return make_command_no_params(HCI_READ_BUFFER_SIZE);
}
static BT_HDR *make_set_c2h_flow_control(uint8_t enable)
{
uint8_t *stream;
const uint8_t parameter_size = 1;
BT_HDR *packet = make_command(HCI_SET_HC_TO_HOST_FLOW_CTRL, parameter_size, &stream);
UINT8_TO_STREAM(stream, enable);
return packet;
}
static BT_HDR *make_host_buffer_size(uint16_t acl_size, uint8_t sco_size, uint16_t acl_count, uint16_t sco_count)
{
uint8_t *stream;
@ -184,6 +194,16 @@ static BT_HDR *make_write_sync_flow_control_enable(uint8_t enable)
UINT8_TO_STREAM(stream, enable);
return packet;
}
static BT_HDR *make_write_default_erroneous_data_report(uint8_t enable)
{
uint8_t *stream;
const uint8_t parameter_size = 1;
BT_HDR *packet = make_command(HCI_WRITE_ERRONEOUS_DATA_RPT, parameter_size, &stream);
UINT8_TO_STREAM(stream, enable);
return packet;
}
// Internal functions
static BT_HDR *make_command_no_params(uint16_t opcode)
@ -220,6 +240,7 @@ static BT_HDR *make_packet(size_t data_size)
static const hci_packet_factory_t interface = {
make_reset,
make_read_buffer_size,
make_set_c2h_flow_control,
make_host_buffer_size,
make_read_local_version_info,
make_read_bd_addr,
@ -237,7 +258,8 @@ static const hci_packet_factory_t interface = {
make_ble_read_suggested_default_data_length,
make_ble_write_suggested_default_data_length,
make_ble_set_event_mask,
make_write_sync_flow_control_enable
make_write_sync_flow_control_enable,
make_write_default_erroneous_data_report,
};
const hci_packet_factory_t *hci_packet_factory_get_interface()

View File

@ -25,6 +25,7 @@
typedef struct {
BT_HDR *(*make_reset)(void);
BT_HDR *(*make_read_buffer_size)(void);
BT_HDR *(*make_set_c2h_flow_control)(uint8_t enable);
BT_HDR *(*make_host_buffer_size)(uint16_t acl_size, uint8_t sco_size, uint16_t acl_count, uint16_t sco_count);
BT_HDR *(*make_read_local_version_info)(void);
BT_HDR *(*make_read_bd_addr)(void);
@ -43,6 +44,7 @@ typedef struct {
BT_HDR *(*make_ble_write_suggested_default_data_length)(uint16_t SuggestedMaxTxOctets, uint16_t SuggestedMaxTxTime);
BT_HDR *(*make_ble_set_event_mask)(const bt_event_mask_t *event_mask);
BT_HDR *(*make_write_sync_flow_control_enable)(uint8_t enable);
BT_HDR *(*make_write_default_erroneous_data_report)(uint8_t enable);
} hci_packet_factory_t;
const hci_packet_factory_t *hci_packet_factory_get_interface();

View File

@ -22,6 +22,10 @@
#include <stdbool.h>
#include "osi/list.h"
#ifndef QUEUE_SIZE_MAX
#define QUEUE_SIZE_MAX 254
#endif
struct fixed_queue_t;
typedef struct fixed_queue_t fixed_queue_t;

View File

@ -69,7 +69,7 @@ typedef enum {
#define HCI_H4_TASK_STACK_SIZE (2048 + BT_TASK_EXTRA_STACK_SIZE)
#define HCI_H4_TASK_PRIO (configMAX_PRIORITIES - 4)
#define HCI_H4_TASK_NAME "hciH4T"
#define HCI_H4_QUEUE_LEN 60
#define HCI_H4_QUEUE_LEN 1
#define BTU_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE)
#define BTU_TASK_STACK_SIZE (4096 + BT_TASK_EXTRA_STACK_SIZE)

View File

@ -313,7 +313,7 @@ tAVCT_LCB *avct_lcb_alloc(BD_ADDR bd_addr)
p_lcb->allocated = (UINT8)(i + 1);
memcpy(p_lcb->peer_addr, bd_addr, BD_ADDR_LEN);
AVCT_TRACE_DEBUG("avct_lcb_alloc %d", p_lcb->allocated);
p_lcb->tx_q = fixed_queue_new(SIZE_MAX);
p_lcb->tx_q = fixed_queue_new(QUEUE_SIZE_MAX);
break;
}
}

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