Compare commits

...

548 Commits
fixes ... v3.0

Author SHA1 Message Date
94ec3c8e53 Merge branch 'bugfix/i2s_param_comments' into 'release/v3.0'
modify i2s param and comments

See merge request idf/esp-idf!2266
2018-04-24 10:47:56 +08:00
7535dbc454 fix zero dma buffer bug: must be 4-bytes aligned 2018-04-23 19:33:11 +08:00
aeb4d8e3c2 modify i2s param and comments 2018-04-23 14:30:55 +08:00
ba13d282dd Merge branch 'bugfix/mbedtls_patches_3.0' into 'release/v3.0'
Bugfix/mbedtls patches 3.0

See merge request idf/esp-idf!2261
2018-04-19 17:30:16 +08:00
806d23b17b Merge branch 'cherry-pick-595ddfd8' into 'release/v3.0'
CI: build_ssc_in_multiple_ci_jobs

See merge request idf/esp-idf!2183
2018-04-19 15:00:01 +08:00
e410f4268e Merge branch 'feature/uart_add_api_get_cmd_position_v3.0' into 'release/v3.0'
driver(uart):  Provide an API to get the position of the cmd char from queue

See merge request idf/esp-idf!2254
2018-04-19 14:58:28 +08:00
8de29499ce mbedtls: Add bounds check before length read
This is part of the patch for CVE-2018-9989.
Cherry-picked from 740b218386
Ref. https://github.com/espressif/esp-idf/issues/1860
2018-04-19 12:58:48 +08:00
ffab6084f0 mbedtls: Prevent arithmetic overflow on bounds check
Part of the patch for CVE-2018-9989.
Cherry-picked from 5224a7544c.
Ref. https://github.com/espressif/esp-idf/issues/1860
2018-04-19 12:58:48 +08:00
f58c664e2b mbedtls: Add bounds check before signature length read
Part of the patch for CVE-2018-9988.
Cherry-picked from a1098f81c2
Ref. https://github.com/espressif/esp-idf/issues/1860
2018-04-19 12:58:47 +08:00
b42ba1b0a5 mbedtls: Prevent arithmetic overflow on bounds check
Part of the patch for CVE-2018-9988.
Cherry-pick of 027f84c69f
Ref. https://github.com/espressif/esp-idf/issues/1860
2018-04-19 12:58:47 +08:00
67ba85650d mbedtls: Prevent bounds check bypass through overflow in PSK identity parsing
This is a patch for CVE-2017-18187.
Cherry-picked from 83c9f495ff
Ref. https://github.com/espressif/esp-idf/issues/1730
2018-04-19 12:58:47 +08:00
0a97cb62ef mbedtls: disable support for RSASSA-PSS signatures
This is a workaround for CVE-2018-0487.
Ref. https://tls.mbed.org/tech-updates/security-advisories/mbedtls-security-advisory-2018-01
Ref. https://github.com/espressif/esp-idf/issues/1730
2018-04-19 12:58:47 +08:00
594e1b5e44 mbedtls: disable truncated HMAC
This is a workaround for CVE-2018-0488.
Ref. https://tls.mbed.org/tech-updates/security-advisories/mbedtls-security-advisory-2018-01
Ref. https://github.com/espressif/esp-idf/issues/1730
2018-04-19 12:26:41 +08:00
10a5cfc900 Merge branch 'bugfix/deep_sleep_wake_dbias_3.0' into 'release/v3.0'
soc/rtc, sleep: don’t lower the bias for wakeup state

See merge request idf/esp-idf!2258
2018-04-18 20:23:50 +08:00
e4a840d8cf soc/rtc, sleep: don’t lower the bias for wakeup state
This fixes watchdog resets occurring during wakeup from light sleep.
2018-04-18 18:22:49 +08:00
7a32ae363e driver(uart):Provide an API to get the position of the cmd char from queue without modify the queue. 2018-04-18 10:11:02 +08:00
fddc905fa3 Merge branch 'bugfix/tw19728_support_static_allocation_of_freertos_queue_used_by_isr' into 'release/v3.0'
esp32/driver/bt: support static allocation of FreeRTOS queues used by ISR routine

See merge request idf/esp-idf!2171
2018-04-12 23:07:51 +08:00
574dd08085 Merge branch 'bugfix/i2s_mix_result_with_error_code' into 'release/v3.0'
fix i2s mix result and error code

See merge request idf/esp-idf!2187
2018-04-11 18:30:45 +08:00
7705126287 Merge branch 'bugfix/pm_init_1core' into 'release/v3.0'
pm: fix initialisation only done in dual core mode

See merge request idf/esp-idf!2196
2018-04-10 18:17:42 +08:00
bf4184a049 fix i2s mix result and error code 2018-04-10 12:04:05 +08:00
212222a9e0 esp32/bt/driver: support static allocation of FreeRTOS queues used by ISR routine
Support static allocation of FreeRTOS queues used by ISR routine in WiFi/BT/esp_timer/driver etc
2018-04-09 13:39:31 +08:00
6d3f81aa77 pm: fix initialisation only done in dual core mode
Introduced in 9377d4ac. Accidentally put the new code block under an
2018-04-08 14:08:31 +08:00
489e98cfb7 Merge branch 'bugfix/heap_fragmentation_on_split_v30' into 'release/v3.0'
heap: Try to merge tail with next block when splitting  (v3.0 backport)

See merge request idf/esp-idf!2178
2018-04-08 13:42:38 +08:00
8d0d7972f3 test: use SSC_BLE_WIFI to test NVS cases 2018-04-03 19:23:32 +08:00
e6acfedd3c Merge branch 'feature/build_ssc_in_multiple_ci_jobs' into 'master'
CI: support build SSC in multiple jobs

See merge request idf/esp-idf!1622

(cherry picked from commit 595ddfd825)

493a9266 CI: support build SSC in multiple jobs
48e3e3ef test: change SSC binary path
2018-04-03 19:18:15 +08:00
0f5cae0218 heap: Change test_multi_heap_on_host multi-config to bash script not Makefile
Hopefully fix some CI building issues with parallel builds.
2018-04-03 16:35:47 +10:00
712bd1d773 Try to merge tail with next block when splitting
When splitting a memory block, check if the next block is free.
If it is, then just extend it upwards instead of creating a new block.
This fixes a bug where when shrinking existing allocations would result in irreversible free space fragmentation.

When testing on the host, test all the poisoning configurations.
2018-04-03 16:35:47 +10:00
4e36ede3bf Merge branch 'feature/i2s_add_expand_function' into 'release/v3.0'
Add a new i2s feature to expand the original i2s width

See merge request idf/esp-idf!2174
2018-04-02 21:51:14 +08:00
2f2aa41ea7 Merge branch 'bugfix/btdm_slow_interrupt_reaction_for_v3.0' into 'release/v3.0'
Bugfix/btdm slow interrupt reaction for v3.0

See merge request idf/esp-idf!2159
2018-04-02 20:04:52 +08:00
089438139d Merge branch 'bugfix/some_wifi_bugs_for_v3.0' into 'release/v3.0'
Bugfix/some wifi bugs for v3.0

See merge request idf/esp-idf!2168
2018-04-02 16:34:09 +08:00
e468a105d8 Merge branch 'cherry-pick-f46ad1fe' into 'release/v3.0'
Merge branch 'bugfix/btdm_fix_get_PID_key_error' into 'release/v3.0'

See merge request idf/esp-idf!2169
2018-04-02 16:12:26 +08:00
894ddea353 Merge branch 'cherry-pick-8eaae966' into 'release/v3.0'
Merge branch 'bugfix/flash_mapp' into 'release/v3.0'

See merge request idf/esp-idf!2170
2018-04-02 16:12:05 +08:00
fed3c3ebf0 Add a new i2s feature to expand the original i2s width 2018-04-02 05:24:38 +00:00
f8515688cb Merge branch 'bugfix/i2c_bugfix_for_v3.0' into 'release/v3.0'
driver(i2c): fix i2c bugs for release/v3.0

See merge request idf/esp-idf!2152
2018-03-31 17:12:55 +08:00
b9dab23437 component/bt : fix interrupt slow reaction cause assert(interrupt wdt)
Some application lock interrupt(portENTER_CRITICAL) too long time,
it will cause bluetooth cannot react interrupt in time, then t will
cause some assert, assert info following:
1. ld_acl.c 1900
2. ld_fm.c 340
3. other assert reference to this.
2018-03-31 06:52:00 +00:00
5632385d5f component/bt : add bluetooth controller library compile version 2018-03-31 06:52:00 +00:00
cfcb22fe16 Merge branch 'bugfix/btdm_fix_get_PID_key_error' into 'master'
Component/bt: fix get PID key error

See merge request idf/esp-idf!2156

(cherry picked from commit f46ad1fec8)

109a93bf Component/bt: fix get PID key error
2018-03-31 06:51:31 +00:00
d6e3943233 Merge branch 'bugfix/flash_mapp' into 'master'
spi_flash: add api to get valid mmu table pages number

See merge request idf/esp-idf!2070

(cherry picked from commit 8eaae96658)

75550315 add api get valid mmu table pages number
fa687743 spi_flash:
49a236da fix CI failed when flash chip size if 2MBytes
2018-03-31 06:51:08 +00:00
b563219f93 Fix some wifi bugs
1. Do not filter out TKIP MIC ERR packet
2. Modify response retry counter from 32 to 5
3. support enrollee feature in APSTA mode
2018-03-31 06:50:15 +00:00
d881fcd380 Merge branch 'bugfix/btdm_modify_open_API_params' into 'release/v3.0'
Component/bt: modify open API params for v3.0

See merge request idf/esp-idf!2166
2018-03-30 19:41:31 +08:00
058a38a141 Component/bt: fix connect fail when remote addr type is random 2018-03-30 17:10:56 +08:00
ffe6af44c1 Merge branch 'cherry-pick-6ffd089c' into 'release/v3.0'
Merge branch 'bugfix/btdm_fix_no_set_rand_addr_event_callback' into 'release/v3.0'

See merge request idf/esp-idf!2163
2018-03-30 16:52:23 +08:00
1fca253a65 Merge branch 'bugfix/btdm_fix_no_set_rand_addr_event_callback' into 'master'
Component/bt: fix no set rand add callback

See merge request idf/esp-idf!2140

(cherry picked from commit 6ffd089c97)

aa236809 Component/bt: fix no set rand add callback event
2018-03-30 16:05:43 +08:00
486ff50eac Merge branch 'cherry-pick-e84df7a2' into 'release/v3.0'
Merge branch 'bugfix/btdm_fix_strncpy_error_in_blufi' into 'release/v3.0'

See merge request idf/esp-idf!2158
2018-03-30 15:58:59 +08:00
cf69dfa458 Merge branch 'cherry-pick-b26ab188' into 'release/v3.0'
Merge branch 'bugfix/btdm_fix_service_change_event_param_error' into 'release/v3.0'

See merge request idf/esp-idf!2161
2018-03-30 15:53:51 +08:00
501640514a Merge branch 'bugfix/btdm_xQueueGenericSend_assertion_3.0' into 'release/v3.0'
component/bt: Fix xQueueGenericSend assertion in release/v3.0

See merge request idf/esp-idf!2160
2018-03-30 15:51:53 +08:00
a80e687f8c Merge branch 'bugfix/btdm_fix_service_change_event_param_error' into 'master'
Component/bt: fix service change event params error

See merge request idf/esp-idf!2150

(cherry picked from commit b26ab188af)

f5d58142 Component/bt: fix service change event params error
2018-03-30 14:57:24 +08:00
bc90b89e2b component/bt: Fix xQueueGenericSend assertion in release/v3.0 2018-03-30 14:53:27 +08:00
a1cc202b70 Merge branch 'bugfix/no_link_key_notify_on_repair_for_v3.0' into 'release/v3.0'
component/bt: bugfix for no link key notification event on repairing for…

See merge request idf/esp-idf!2134
2018-03-30 14:26:35 +08:00
062ba57d0f Merge branch 'bugfix/btdm_fix_strncpy_error_in_blufi' into 'master'
Component/bt: fix strncpy error in blufi

See merge request idf/esp-idf!2141

(cherry picked from commit e84df7a27d)

6a942046 Component/bt: fix strncp error in blufi
2018-03-30 14:15:03 +08:00
14baac302f driver(i2c):Fixed i2c bug for release/v3.0 2018-03-29 14:03:04 +08:00
af211fcf0c component/bt: bugfix for no link key notification event on repairing for initiating side of simple_pairing
In response to: https://github.com/espressif/esp-idf/issues/1275
2018-03-27 15:49:52 +08:00
5ee7233b5b Merge branch 'bugfix/btdm_fix_error_when_close_SMP' into 'release/v3.0'
Component/bt: fix build error when close SMP for v3.0

See merge request idf/esp-idf!2108
2018-03-21 15:33:28 +08:00
48c7afde27 Component/bt: fix build error when close SMP 2018-03-21 13:48:05 +08:00
d3bab0d7f0 Merge branch 'cherry-pick-84788230' into 'release/v3.0'
cherry pick 'bugfix/dfs_rtc_fixes' into 'release/v3.0'

See merge request idf/esp-idf!2107
2018-03-21 13:19:17 +08:00
c9ed467e26 Merge branch 'bugfix/dfs_rtc_fixes' into 'master'
DFS related fixes

See merge request idf/esp-idf!2102

(cherry picked from commit 8478823039)

9377d4ac pm: fix incorrect configuration at startup
7167ad45 pm: improve debug output from esp_pm_dump_locks
1618dbc9 soc/rtc: wait for frequency switch to complete
2018-03-21 12:02:58 +08:00
f0eb023f17 Merge branch 'bugfix/wifi_lwip_set_ip_post_wrong_event_v3.0' into 'release/v3.0'
Fix the bug that incorrect event is posted when setting static ip of softap and ethernet

See merge request idf/esp-idf!2096
2018-03-21 11:45:34 +08:00
8944b90a06 Fix the bug that incorrect event is posted when setting static ip of softap and ethernet 2018-03-21 11:01:32 +08:00
9e4ec90a1e Merge branch 'bugfix/tw18031_lwip_assert' into 'release/v3.0'
cherry pick 'bugfix/redirect_psram_muxes_to_single_mux' into 'release/v3.0'

See merge request idf/esp-idf!2055
2018-03-21 10:22:30 +08:00
e4357d9cf3 Merge branch 'cherry-pick-0f6f762b' into 'release/v3.0'
cherry pick 'bugfix/btdm_add_char_descr_uuid_error' into 'release/v3.0'

See merge request idf/esp-idf!2100
2018-03-21 10:21:54 +08:00
db17ffef00 Merge branch 'cherry-pick-8ab17d7c' into 'release/v3.0'
cherry pick 'bugfix/btdm_avrc_remote_bda_error_when_disconnect' into 'release/v3.0'

See merge request idf/esp-idf!2099
2018-03-20 19:58:24 +08:00
7f2a9f0359 Merge branch 'bugfix/btdm_fix_reconnect_fail_in_smp_v30' into 'release/v3.0'
Component/bt: fix reconnect fail in smp for v3.0

See merge request idf/esp-idf!2075
2018-03-20 18:49:13 +08:00
ecdeea9a85 Merge branch 'bugfix/btdm_add_char_descr_uuid_error' into 'master'
component/bt: Change the char_uuid to descr_uuid in the add descriptor callback params.

See merge request idf/esp-idf!2065

(cherry picked from commit 0f6f762be0)

c802ea84 component/bt: Change the char_uuid to descr_uuid in the add descriptor callback params.
2018-03-20 18:43:59 +08:00
cfce9e1c72 Merge branch 'bugfix/btdm_avrc_remote_bda_error_when_disconnect' into 'master'
component/bt: Fix bug: AVRC remote_bda error when disconnect

See merge request idf/esp-idf!2093

(cherry picked from commit 8ab17d7ccf)

2531975c component/bt: Fix bug: AVRC remote_bda error when disconnect
2018-03-20 18:24:50 +08:00
dfce994b54 Merge branch 'feature/optimize_wifi_tx_v3.0' into 'release/v3.0'
esp32: optimize wifi tx

See merge request idf/esp-idf!2092
2018-03-20 18:22:24 +08:00
1b78dc2deb Merge branch 'cherry-pick-45eb556d' into 'release/v3.0'
cherry pick 'bugfix/wpa2_assert_when_use_sha256_signature' into 'release/v3.0'

See merge request idf/esp-idf!2094
2018-03-20 16:38:13 +08:00
37a4b0e933 esp32: optimize wifi tx
1. Optimize WiFi TX retry counter
2. Optimize WiFi TX timeout
2018-03-20 15:23:47 +08:00
8fab9ffb95 Merge branch 'bugfix/wpa2_assert_when_use_sha256_signature' into 'master'
bugfix of wpa2 assert when use sha256 do signature

See merge request idf/esp-idf!2089

(cherry picked from commit 45eb556ddf)

bc97b0f3 bugfix of wpa2 assert when use sha256 do signature
2018-03-20 15:20:13 +08:00
354137a313 Merge branch 'bugfix/tw19041_esp_wifi_stop_not_return_v3.0' into 'release/v3.0'
esp32: Fix wifi stop never returns issue

See merge request idf/esp-idf!2088
2018-03-20 15:18:17 +08:00
0399c8ecaf esp32: Fix wifi stop never returns issue
Fix esp_wifi_stop never returns issue
2018-03-19 21:06:05 +08:00
a12e7fa638 Merge branch 'bugfix/tw19020_force_1.9V_when_flash_is_80M_v3.0' into 'release/v3.0'
bootloader: force SDIO 1.9V if flash is 80M

See merge request idf/esp-idf!2084
2018-03-19 18:50:47 +08:00
3278f755d2 Merge branch 'bugfix/fix_wpa2_disconnect_assert_issue_v3.0' into 'release/v3.0'
fix the issue that wpa2 assert when disconnect from AP

See merge request idf/esp-idf!2066
2018-03-19 18:24:01 +08:00
30281166b1 bootloader: force SDIO 1.9V if flash is 80M
If the SPI flash frequency is 80M, the voltage of SDIO is 1.9V,
otherwise, it can configured to 1.8V or 1.9V via menuconfig.
2018-03-19 16:45:05 +08:00
9bd227f8c5 Merge branch 'bugfix/btdm_fix_gattc_open_API_v30' into 'release/v3.0'
component/bt: fix gattc open api for v3.0

See merge request idf/esp-idf!2077
2018-03-19 14:27:22 +08:00
80423d638d Merge branch 'bugfix/btdm_fix_eddystone_v30' into 'release/v3.0'
Component/bt: fix eddystone demo error for v3.0

See merge request idf/esp-idf!2076
2018-03-19 14:27:08 +08:00
998e18ed69 Merge branch 'bugfix/multi_connection_performance' into 'release/v3.0'
component/bt : improve multi-connection performance and stability

See merge request idf/esp-idf!2068
2018-03-19 14:05:19 +08:00
d0e553358a Component/bt: fix reconnect fail in smp 2018-03-19 11:15:38 +08:00
0cdb8b4888 Merge branch 'bugfix/btdm_fix_get_attr_value_error_after_prepare_write_v30' into 'release/v3.0'
Component/bt: fix get attr value error after prepare write for v3.0

See merge request idf/esp-idf!2028
2018-03-19 10:48:39 +08:00
c1e4ebf2bc Merge branch 'cherry-pick-db690e3f-2' into 'release/v3.0'
Component/bt: add params check in prefer_conn_params() for v3.0

See merge request idf/esp-idf!2062
2018-03-19 10:47:55 +08:00
71ca4c50b0 Merge branch 'bugfix/btdm_clear_start_stop_adv_callback_when_complete_v30' into 'release/v3.0'
Component/bt: clear start/stop adv callback when complete_v3.0

See merge request idf/esp-idf!2029
2018-03-19 10:47:19 +08:00
56d82dd5ce Merge branch 'cherry-pick-09a30ddf_into_release/v3.0' into 'release/v3.0'
bugfix/Fix BLK3_RESERVED_FLAG register and other minor bugs

See merge request idf/esp-idf!2078
2018-03-18 19:23:03 +08:00
c4a6eef841 bugfix/Fix BLK3_RESERVED_FLAG register and other minor bugs
This commit fixes an incorrect register definition for BLK3_RESERVED_FLAG.
Other bugs include a missing conditional check, and updated comments
on modifying eFuse checking behavior.
2018-03-16 20:56:27 +08:00
zwj
05b5671fc4 component/bt: fix gattc open api 2018-03-16 19:23:31 +08:00
d3646ca59f Component/bt: fix eddystone demo error 2018-03-16 18:28:58 +08:00
0cb7b27f8b Merge branch 'cherry-pick-702b4610-2' into 'release/v3.0'
Component/bt: fix set error params and return callback when start adv for v3.0

See merge request idf/esp-idf!2061
2018-03-15 18:07:19 +08:00
2319e8a0eb Merge branch 'cherry-pick-dc66940f' into 'release/v3.0'
Merge branch 'bugfix/btdm_a2dp_disc_rsn_error_when_as_master' into 'release/v3.0'

See merge request idf/esp-idf!2067
2018-03-15 18:06:00 +08:00
bc12970dde component/bt : improve multi-connection performance and stability 2018-03-15 15:36:53 +08:00
7a863cca7c Merge branch 'cherry-pick-047870fd' into 'release/v3.0'
Merge branch 'bugfix/btdm_string_to_bdaddr_error_when_opening_nano' into 'v3.0'

See merge request idf/esp-idf!2064
2018-03-15 15:34:48 +08:00
9c42b6194e Merge branch 'bugfix/btdm_a2dp_disc_rsn_error_when_as_master' into 'master'
component/bt: Fix bug: a2dp disc_rsn error when as master

See merge request idf/esp-idf!1995

(cherry picked from commit dc66940f82)

f1d3f689 component/bt: Fix bug: a2dp disc_rsn error when as master
2018-03-15 15:28:53 +08:00
3511109b6e Merge branch 'bugfix/btdm_a2dp_cleanup_bug_3.0' into 'release/v3.0'
component/bt: Fix bug of a2dp cleanup bug when connected in v3.0

See merge request idf/esp-idf!2040
2018-03-15 15:04:07 +08:00
acff7e58d2 fix the issue that wpa2 assert when disconnect from AP 2018-03-15 14:42:31 +08:00
0f45323879 Merge branch 'bugfix/btdm_string_to_bdaddr_error_when_opening_nano' into 'master'
component/bt: Fix bug: string_to_bdaddr() error when opening nano

See merge request idf/esp-idf!1981

(cherry picked from commit 047870fd80)

54320d5f component/bt: Fix bug: string_to_bdaddr() error when opening nano
2018-03-15 14:15:31 +08:00
48ea4bc7f4 Merge branch 'bugfix/btdm_add_param_check_in_gap_set_prefer_conn_params' into 'master'
Component/bt: add_params_check_in_prefer_conn_params()

See merge request idf/esp-idf!1944

(cherry picked from commit db690e3f85)

b09d681d Component/bt: add_params_check_in_prefer_conn_params()
2018-03-15 12:07:01 +08:00
69686ae8a9 Merge branch 'bugfix/btdm_fix_set_error_channel_map_in_adv_params' into 'master'
Component/bt: fix set error params and return callback when start adv

See merge request idf/esp-idf!1943

(cherry picked from commit 702b46108c)

4056878c Component/bt: fix set error params and add callback in adv params
2018-03-15 12:04:56 +08:00
28cb5624ef Merge branch 'bugfix/esp_timer_overflow_for_v3_0' into 'release/v3.0'
component/esp32: fix esp_timer bug

See merge request idf/esp-idf!1878
2018-03-15 10:48:15 +08:00
c82adcae1b Merge branch 'bugfix/redirect_psram_muxes_to_single_mux' into 'master'
Fake S32C1I operation for muxes in PSRAM

See merge request idf/esp-idf!1688
2018-03-14 17:51:50 +08:00
c574ad90df component/esp32: fix esp_timer bug
1. fix the bug that cause esp_timer_get_time is not accuracy(the max margin may be 106s).
2. fix the bug that causes esp timer come too early.
2018-03-13 15:03:54 +08:00
1d03398a64 component/bt: Fix bug of a2dp cleanup bug when connected in v3.0 2018-03-12 16:36:11 +08:00
daf1d05576 Merge branch 'cherry-pick-17e8d49f' into 'release/v3.0'
Merge branch 'bugfix/btdm_update_pktLen_have_no_callback' into 'release/v3.0'

See merge request idf/esp-idf!2010
2018-03-09 16:29:35 +08:00
816a98c3ad Merge branch 'bugfix/fix_some_wifi_bugs_v3.0' into 'release/v3.0'
esp32: fix some WiFi bugs

See merge request idf/esp-idf!1987
2018-03-09 16:21:40 +08:00
ebfc47c34b Component/bt: clear start/stop adv callback when complete 2018-03-09 11:14:11 +08:00
681805b6c7 Component/bt: fix get attr value error after prepare write 2018-03-09 11:10:04 +08:00
392b0b89e3 Merge branch 'bugfix/wifi_lwip_close_socket_when_tcp_connecting_v3.0' into 'release/v3.0'
Close socket request will abort tcp write/connect

See merge request idf/esp-idf!1741
2018-03-08 20:28:42 +08:00
229be8c025 esp32: fix some WiFi bugs
1. Fix esp_wifi_deinit causes system crash issue
2. Fix QoS AC map issue
2018-03-06 16:59:24 +08:00
e4fb19000a Merge branch 'bugfix/btdm_update_pktLen_have_no_callback' into 'master'
component/bt: Fix bug:update pktlen have no callback

See merge request idf/esp-idf!1913

(cherry picked from commit 17e8d49f26)

acdad323 component/bt: Fix bug:update pktlen have no callback
2018-03-05 16:15:39 +08:00
0e640c61bd Merge branch 'bugfix/btdm_mem_leak_of_bt_3.0' into 'release/v3.0'
component/bt: Fix mem leak of bt in v3.0

See merge request idf/esp-idf!1925
2018-03-05 16:07:08 +08:00
ce64bcb81f Merge branch 'adc_calibration_release_3.0' into 'release/v3.0'
esp_adc_cal/cherry pick into release 3.0

See merge request idf/esp-idf!1986
2018-03-02 17:19:45 +08:00
5e48c2bfef component/bt: Fix mem leak of bt in v3.0 2018-03-02 03:53:07 +00:00
55c179a599 esp_adc_cal/Add eFuse functionality and update calibration method
This commit updates the esp_adc_cal ocmponent to support eFuse functionality.
The method of calibraiton has also been changed
2018-02-26 21:52:00 +08:00
1181b65f7d Merge branch 'cherry-pick-22dcdce9' into 'release/v3.0'
Merge branch 'bugfix/btdm_scan_result_of_adv_type_wrong' into 'release/v3.0'

See merge request idf/esp-idf!1914
2018-02-24 10:24:17 +08:00
3b116ae0cb Merge branch 'bugfix/btdm_a2dp_task_stack_size_for_v3.0' into 'release/v3.0'
component/bt: make A2DP sink task size configurable through menuconfig

See merge request idf/esp-idf!1890
2018-02-24 10:18:12 +08:00
54b595ed51 Merge branch 'bugfix/btdm_alarm_free_for_v3.0' into 'release/v3.0'
component/bt: free timer resources after using them

See merge request idf/esp-idf!1888
2018-02-24 10:17:15 +08:00
cf2600adef Merge branch 'bugfix/realloc_corruption_bug_v30' into 'release/v3.0'
heap: Fix bug when realloc moves data between heaps (backport to v3.0)

See merge request idf/esp-idf!1934
2018-02-11 13:43:00 +08:00
f7eecfcc67 heap: Fix bug when realloc moves data between heaps
When realloc-ing to a smaller buffer size which ends up allocated in a different heap, the heap
structure is corrupted. This can only happen:

* If heap checking is Comprehensive (meaning buffers are never shrunk in place) and the heap the buffer was originally allocated in is full.
* Calling heap_caps_realloc() to deliberately move a buffer to a different capabilities type, and shrink it at the same time.

Probable fix for https://github.com/espressif/esp-idf/issues/1582
Probably the same issue:
https://www.esp32.com/viewtopic.php?f=2&t=4583
https://www.esp32.com/viewtopic.php?f=13&t=3717
2018-02-09 19:24:37 +08:00
eac9eb36d1 Merge branch 'bugfix/btdm_scan_result_of_adv_type_wrong' into 'master'
component/bt: Fix bug:scan result of adv type is wrong

See merge request idf/esp-idf!1897

(cherry picked from commit 22dcdce949)

79fd3f4f component/bt: Fix bug:scan result of adv type is wrong
2018-02-06 15:53:16 +08:00
ec05f3af8f Merge branch 'bugfix/cjson_171_backport_v30' into 'release/v3.0'
Update cJSON to v1.7.1 (backport to v3.0)

See merge request idf/esp-idf!1907
2018-02-05 22:30:07 +08:00
9bfb2f0cab component/bt: make A2DP sink task size configurable through menuconfig
1. make the A2DP sink task stack size configurable through menuconfig

# Conflicts:
#	components/bt/Kconfig
#	components/bt/bluedroid/api/include/esp_a2dp_api.h
#	components/bt/bluedroid/btc/profile/std/a2dp/btc_a2dp_sink.c
#	components/bt/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c
#	components/bt/bluedroid/osi/include/thread.h
2018-02-05 19:47:58 +08:00
963fa0fd3a Update cJSON to v1.7.1
* Fix buffer overflow issue in cJSON 1.6.0
* Change cJSON structure to git submodule

Closes https://github.com/espressif/esp-idf/issues/1577
2018-02-05 14:52:39 +08:00
8856cc055a Merge branch 'bugfix/btdm_fix_stop_adv_no_callback_when_adv_has_been_stoped_for_v30' into 'release/v3.0'
Component/bt: fix stop adv no callback when adv has been stoped for v3.0

See merge request idf/esp-idf!1857
2018-02-01 20:15:51 +08:00
fab14106c8 component/bt: free timer resources after using them
Bluedroid use a set of timer function pairs such as btu_start_timer/btu_stop_timer, btu_sys_start_timer/btu_sys_stop_timer for use, in a lack of timer release functions. Thus the timers may be exhausted after some event sequence such as repetition of connection/reconnection with different devices. The maximum timer number used in bluedroid is given by ALARM_CBS_NUM which is 30 for now. This bugfix borrowed some update from bluedroid in Andoroid 7.0, which add timer release functions which promote the recycle of timer resources.

# Conflicts:
#	components/bt/bluedroid/stack/btu/btu_task.c
#	components/bt/bluedroid/stack/gatt/gatt_main.c
#	components/bt/bluedroid/stack/rfcomm/port_utils.c
#	components/bt/bluedroid/stack/rfcomm/rfc_utils.c
2018-02-01 13:52:19 +08:00
154294e79f Component/bt: fix stop adv no callback when adv has been stoped 2018-01-31 20:24:02 +08:00
e1d965e4b9 Merge branch 'bugfix/btdm_fix_BT_load_boned_in_smp_for_v30' into 'release/v3.0'
Component/bt: fix bt loads all the bonded devices in smp for v3.0

See merge request idf/esp-idf!1856
2018-01-31 16:45:58 +08:00
673d4679ce Merge branch 'cherry-pick-0f22a53f' into 'release/v3.0'
sysview: fix compilation in 1 core mode, refactor timer choices (cherry-pick for 3.0)

See merge request idf/esp-idf!1873
2018-01-29 22:33:36 +08:00
95f6f88aa7 Merge branch 'bugfix/sysview_timer_1core' into 'master'
sysview: fix compilation in 1 core mode, refactor timer choices

See merge request idf/esp-idf!1822

(cherry picked from commit 0f22a53fc2)

c3d82157 sysview: fix compilation in 1 core mode, refactor timer choices
2018-01-29 17:29:23 +08:00
621794abb5 Component/bt: fix bt load boned in smp 2018-01-26 14:45:36 +08:00
f918cb185d Merge branch 'bugfix/btdm_fix_bonded_device_list_error_after_reboot_v30' into 'release/v3.0'
Component/bt: fix bonded device list error after reboot for v3.0

See merge request !1849
2018-01-26 11:38:19 +08:00
ab22836859 Component/bt: fix bonded device list error after reboot 2018-01-26 02:04:56 +00:00
9539d44158 Merge branch 'cherry-pick-c25be19e' into 'release/v3.0'
Merge branch 'bugfix/multi_ping_crash' into 'release/v3.0'

See merge request !1851
2018-01-25 23:12:56 +08:00
b6b8af498c Merge branch 'bugfix/fix_uart_related_bug' into 'release/v3.0'
driver(uart): merge uart related bugfixes into v3.0

See merge request !1845
2018-01-25 19:34:04 +08:00
194b1324d2 Merge branch 'bugfix/multi_ping_crash' into 'master'
fix(ping): fix crash when multi-ping

See merge request !1768
2018-01-25 19:21:46 +08:00
7a030ff8d6 Merge branch 'cherry-pick-02821571' into 'release/v3.0'
Merge branch 'bugfix/xRingbufferSend_timeout_bug' into 'release/v3.0'

See merge request !1843
2018-01-25 16:13:46 +08:00
d9a0f9d443 Merge branch 'bugfix/wifi_fix_espnow_mem_leak_v3.0' into 'release/v3.0'
fix espnow memory leak

See merge request !1842
2018-01-24 21:44:27 +08:00
3a6be05945 driver(uart):merge branch into v3.0 which fixed three bug related with uart
1. uart fifo reset
    2. uart pattern interrupt
    3. uart buffered_len error.
2018-01-24 21:27:31 +08:00
d1c536258c Merge branch 'bugfix/xRingbufferSend_timeout_bug' into 'master'
bugfix(ringbuffer): Fix ringbuffer_send timeout bug

See merge request !1823
2018-01-24 17:00:24 +08:00
5a1247246c fix espnow memory leak 2018-01-24 16:20:20 +08:00
45758b6be0 Merge branch 'cherry-pick-ce2e4cbc' into 'release/v3.0'
Merge branch 'bugfix/log_hex_buffer_pr1519' into 'release/v3.0'

See merge request !1839
2018-01-24 15:55:46 +08:00
6183de959a Merge branch 'bugfix/wifi_fix_sniffer_rx_misc_data_assert_v3.0' into 'release/v3.0'
Fix the bug that in sniffer mode it asserts when receive misc data at first

See merge request !1833
2018-01-23 22:52:10 +08:00
e9a4eb57b9 Merge branch 'bugfix/log_hex_buffer_pr1519' into 'master'
Fix hexdump comment and array size. See issue #1518.

See merge request !1832
2018-01-23 22:45:55 +08:00
5894e15f6b Merge branch 'bugfix/btdm_classicbt_pscan_assert_for_v3.0' into 'release/v3.0'
component/bt : fix the bug of pscan when interrupt react slowly

See merge request !1835
2018-01-23 22:39:28 +08:00
891c1f4a2b Fix the bug that in sniffer mode it asserts when receive misc data at first.
close github issue#1037 WiFi Promiscuous filter breaks w/
WIFI_PROMIS_FILTER_MASK_ALL and issue#1404
esp_wifi_set_promiscuous_filter set WIFI_PROMIS_FILTER_MASK_ALL error
2018-01-23 19:12:37 +08:00
f5c962d8b2 component/bt : fix the bug of pscan when interrupt react slowly 2018-01-23 14:16:02 +08:00
6aff7125cb Merge branch 'feature/mdns_3.0' into 'release/v3.0'
New mDNS implementation, cherry-pick for 3.0

See merge request !1834
2018-01-23 13:54:28 +08:00
c68fd9d545 mdns: Fix case where service is NULL and that will cause exception 2018-01-22 23:27:24 +08:00
d6c06ed0b5 mdns: Fix issue with some mDNS parsers
Some mDNS parser have issue with zero terminated TXT lists. This fix targets to overcome this issue. Found and tested with jmdns.
2018-01-22 23:27:20 +08:00
8baa6b9d8b Import mDNS changes 2018-01-22 23:27:14 +08:00
3923a2be85 Merge branch 'feature/btdm_ble_spp_docs_for_3.0' into 'release/v3.0'
component/bt: add ble spp readme for 3.0

See merge request !1769
2018-01-17 10:19:43 +08:00
e7dc749e2f Merge branch 'cherry-pick-f0ed4044' into 'release/v3.0'
Merge branch 'bugfix/btdm_pair_fail_with_random_address' into 'master'

See merge request !1819
2018-01-16 19:43:52 +08:00
df93f672e3 Merge branch 'bugfix/btdm_pair_fail_with_random_address' into 'master'
component/bt: Fix bug when pair with random address

See merge request !1784
2018-01-16 18:18:00 +08:00
4a55009f3e Merge branch 'bugfix/fix_rare_ci_example_build_errors' into 'release/v3.0'
cherry-pick fix rare ci example build errors to release v3.0

See merge request !1813
2018-01-16 17:13:08 +08:00
dfcff0a5bf Merge branch 'bugfix/btdm_discon_when_upd_conn_params_in_smp_for_v3.0' into 'release/v3.0'
component/bt: fix disconnect after connection params update in smp for v3.0

See merge request !1805
2018-01-16 16:41:26 +08:00
ff3566e40b Merge branch 'bugfix/btdm_fix_conn_params_update_failed_in_SMP_for_v3.0' into 'release/v3.0'
Component/bt: fix update connection params error in smp for v3.0

See merge request !1809
2018-01-16 16:38:36 +08:00
63eb620d99 CI: Fix an occasional error caused by reordering the commands along with 'tee' in the script 2018-01-16 09:51:34 +08:00
93c18bb2b4 build system: Fix undefined variables
make/project.mk:315: warning: undefined variable `CC'
    make/project.mk:316: warning: undefined variable `LD'
    make/project.mk:317: warning: undefined variable `AR'
    make/project.mk:62: warning: undefined variable `MAKECMDGOALS'
    components/partition_table/Makefile.projbuild:24: warning: undefined variable `quote'
    components/bootloader/Makefile.projbuild:123: warning: undefined variable 'BOOTLOADER_DIGEST_BIN'
    components/bootloader/Makefile.projbuild:123: warning: undefined variable 'SECURE_BOOTLOADER_KEY'
2018-01-16 09:51:08 +08:00
3c6bce1d81 CI: Fix a sporadic bug when building of the examples. Add logs to the artifacts 2018-01-16 09:50:55 +08:00
90b9c42dc0 Merge branch 'bugfix/wifi_cal_real_rx_bcn_time_v3.0' into 'release/v3.0'
Fix two wifi bugs

See merge request !1798
2018-01-15 22:30:54 +08:00
c5f63bf701 Fix two wifi bugs
1. Fix the bug that receiving beacon time is not correct.

2. close github issue#233 esp_wifi_restore() bug.
2018-01-15 20:42:44 +08:00
ced95c7fb0 Component/bt: fix update connection params error in smp for v3.0 2018-01-15 19:55:50 +08:00
309fb23ffc Merge branch 'cherry-pick-c401a74b' into 'release/v3.0'
Merge branch 'bugfix/btdm_aes_encrypt_workaround' into 'master'

See merge request !1800
2018-01-15 18:49:25 +08:00
e9a230c20c Merge branch 'cherry-pick-0cd97cec' into 'release/v3.0'
Merge branch 'bugfix/btdm_error_when_add_device_to_whitelist_twice' into 'master'

See merge request !1799
2018-01-15 18:49:11 +08:00
b0c7f28aed Merge branch 'bugfix/fix_qos_bug_in_11g_mode_v3.0' into 'release/v3.0'
Bugfix/fix qos bug in 11g mode v3.0

See merge request !1790
2018-01-15 18:26:30 +08:00
7bc1e7608c component/bt: fix disconnect after connection params update in smp 2018-01-15 17:12:23 +08:00
449ce1bad9 Merge branch 'bugfix/btdm_aes_encrypt_workaround' into 'master'
component/bt: disable Secure Connections to workaround AES encryption issue

See merge request !1719
2018-01-15 14:47:28 +08:00
424a5e2705 Merge branch 'bugfix/btdm_error_when_add_device_to_whitelist_twice' into 'master'
component/bt: Fix bug when add device to whitelist twice

See merge request !1700
2018-01-15 14:46:13 +08:00
d8f311c980 component/bt: add ble spp readme for 3.0 2018-01-12 15:40:02 +08:00
9b0c252e67 esp32: fix qos bug in 11g mode
Fix qos bug in 11g mode (release/v3.0 - 8e861901)
2018-01-12 14:14:20 +08:00
2a55629556 Merge branch 'feature/toolchain-80-g6c4433a-v30' into 'release/v3.0'
Toolchain: Update to version 1.22.0-80-g6c4433a (v3.0 backport)

See merge request !1772
2018-01-11 21:45:11 +08:00
b523660199 build: Remove explict -lstdc++-psram-workaround
This is now handled internally to the toolchain.
2018-01-11 10:32:28 +11:00
150be549eb Merge branch 'cherry-pick-675844c4' into 'release/v3.0'
Merge branch 'bugfix/assert_in_PSRAM_WIFI' into 'master'

See merge request !1773
2018-01-10 20:58:47 +08:00
10898a33ed Merge branch 'cherry-pick-16391c27' into 'release/v3.0'
Merge branch 'bugfix/full_calibration_will_not_use_init_data' into 'master'

See merge request !1774
2018-01-10 20:58:33 +08:00
dddfc61411 Merge branch 'bugfix/btdm_fix_cant_remove_boned_device_if_its_connected_v30' into 'release/v3.0'
Component/bt: fix can not remove boned device if it is connected for v3.0

See merge request !1770
2018-01-10 20:49:24 +08:00
404a6b3782 Merge branch 'bugfix/full_calibration_will_not_use_init_data' into 'master'
Fix bug that when we do full calibration init data bin is not used

See merge request !1746
2018-01-10 17:02:08 +08:00
29f999361e Merge branch 'bugfix/assert_in_PSRAM_WIFI' into 'master'
bug fix of assert happen in PSRAM

See merge request !1745
2018-01-10 16:48:04 +08:00
32eeac0b12 Toolchain: Update to version 1.22.0-80-g6c4433a
Includes updated prebuilt Windows MSYS2 environment.
2018-01-10 16:41:27 +11:00
7d3e8998d8 Component/bt: fix can not remove boned device if it is connected 2018-01-10 10:46:11 +08:00
e276b98fe4 Merge branch 'bugfix/BLE_SM_Security_Flags_pr1320_v30' into 'release/v3.0'
bt: Fix ble sm security flags (v3.0 backport)

See merge request !1754
2018-01-09 15:49:04 +08:00
de7381b77e Merge branch 'bugfix/btdm_avrc_connect_state_evt_for_v3.0' into 'release/v3.0'
component/bt: add AVRC event for remote features indication

See merge request !1734
2018-01-09 15:39:02 +08:00
645d9b9590 component/bt: add AVRC event for remote features indication
1. remove the feature mask parameter from AVRC connection state event, as the AVCTP connection can be initiated by remote device before service discovery to remote device is performed. \
In this case, AVRCP connection state event may not be reported after connection initated by remote device is established.
2. remove ESP_AVRC_CT_MAX_EVT
3. add more documentations to AVRC APIs
2018-01-08 19:43:54 +08:00
2ad618e068 Merge branch 'bugfix/btdm_standardize_code_3.0' into 'release/v3.0'
component/bt: Standardize code

See merge request !1751
2018-01-08 19:24:26 +08:00
eb408e50c4 n btm_sec_save_le_key() set BTM_SEC_LE_LINK_KEY_KNOWN (and BTM_SEC_LE_LINK_KEY_AUTHED if MITM was used) when process a local Long Term Key (key type BTM_LE_KEY_LENC). This is because these flags share bits with the BTM_SEC_FLAG_LKEY_KNOWN (and BTM_SEC_FLAG_LKEY_AUTHED) flag in btm_api.h. Without this code a link that is encrypted via SM pairing where only the local device exchanges the LTK (peer does not send its LTK) will not allow GATT operations that require encryption (request will be incorrectly rejected with insufficient authentication reason, regardless of if MITM is required).
Merges https://github.com/espressif/esp-idf/pull/1320
2018-01-08 10:37:19 +11:00
60da98ee0b set ble_rsp_key member of structure bte_appl_cfg in function bta_dm_co_ble_set_rsp_key_req (function incorrectly uses ble_init_key member).
Merges https://github.com/espressif/esp-idf/pull/1320
2018-01-08 10:37:18 +11:00
314f6f371c component/bt: Standardize code
Reported from github:
https://github.com/espressif/esp-idf/issues/1402
https://github.com/espressif/esp-idf/issues/1403
2018-01-05 19:31:53 +08:00
6c69d5e6fd Merge branch 'feature/btdm_add_bluetooth_examples_tutorials_v3.0' into 'release/v3.0'
Feature/btdm add bluetooth examples tutorials v3.0

See merge request !1709
2018-01-03 13:06:13 +08:00
90ea0bb7e8 component/bt: change pictures from .pdf to .png 2018-01-03 11:46:02 +08:00
6ba817038c component/bt: Modify docs to be compatible with "Github Standard Markdown" 2018-01-03 11:45:53 +08:00
e54f8a96a0 component/bt: add link of tutorial in README.rst 2018-01-03 11:45:18 +08:00
2f9edfebac component/bt: Add bluetooth example tutorials 2018-01-03 11:45:18 +08:00
27c28eb1e6 Close socket request will abort tcp write/connect
When tcp write/connect is running, close socket request will abort
    it and continue to delete netconn and close tcp. Do not immediately
    return after aborting tcp write/connect. Otherwise, tcp close
    requeset will block and tcp write/connect will crash.
2018-01-03 11:23:57 +08:00
6f339ff7a5 Merge branch 'bugfix/i2c_regression_v30' into 'release/v3.0'
Fix regression in i2c_master_read() which rejected all data lengths (v3.0 backport)

See merge request !1731
2018-01-03 07:27:11 +08:00
2cc07d0c4c Fix regression in i2c_master_read() which rejected all data lenths. 2018-01-02 10:01:23 +11:00
da81b97e17 Merge branch 'bugfix/recompile_with_new_psram_toolchain_v3.0' into 'release/v3.0'
recompile wifi lib with new toolchain 1.22.0-78-g4b87650

See merge request !1729
2017-12-29 18:33:46 +08:00
15e65aad1b Merge branch 'bugfix/build_bt_lib_with_updated_toolchain' into 'release/v3.0'
component/bt: build libbtdm_app.a with updated toolchain for ESP-IDF v3.0

See merge request !1727
2017-12-29 18:26:41 +08:00
281874d380 recompile wifi lib with new toolchain 1.22.0-78-g4b87650 2017-12-29 16:42:05 +08:00
3f3d8746fc component/bt: build libbtdm_app.a with updated toolchain for ESP-IDF v3.0 2017-12-29 15:24:02 +08:00
b278deabdb Merge branch 'bugfix/static_mem_workaround_v30' into 'release/v3.0'
esp32: Change 192KB runtime static limit workaround to a 176KB link time workaround

See merge request !1724
2017-12-29 12:56:39 +08:00
9065498a5a esp32: Change 192KB runtime static limit workaround to a 176KB link time workaround
Turns out some app memory around 0x3ffdc000 is also used by APP CPU.

This is a workaround until code to remove the 176KB limit is committed.
2017-12-29 09:11:50 +11:00
012f5c608d Merge branch 'cherry-pick-13a087a3' into 'release/v3.0'
Merge branch 'bugfix/iperf_example_bugfix' into 'master'

See merge request !1720
2017-12-28 22:07:55 +08:00
c695a4e468 Merge branch 'cherry-pick-566fab02' into 'release/v3.0'
Merge branch 'bugfix/btdm_disconnect_fail_during_pairing' into 'master'

See merge request !1716
2017-12-28 22:07:46 +08:00
755b163d4e Merge branch 'cherry-pick-7d0d2854' into 'release/v3.0'
Merge branch 'bugfix/btdm_error_when_white_list_is_full' into 'master'

See merge request !1715
2017-12-28 22:07:27 +08:00
b19b8702fd Merge branch 'cherry-pick-into-3.0' into 'release/v3.0'
Cherry pick into 3.0

See merge request !1714
2017-12-28 17:58:35 +08:00
bd2ff0613d Merge branch 'bugfix/iperf_example_bugfix' into 'master'
example: some modification about iperf example

See merge request !1603
2017-12-28 10:20:58 +08:00
b6ebbb5662 Merge branch 'bugfix/btdm_disconnect_fail_during_pairing' into 'master'
component/bt: Fix bug of disconnected fail during pairing

See merge request !1672
2017-12-27 18:05:24 +08:00
38d58f1c2e Merge branch 'bugfix/btdm_error_when_white_list_is_full' into 'master'
component/bt: Fix bug of adding device to white list has no callback when while list is full

See merge request !1689
2017-12-27 18:04:25 +08:00
ecc6080117 freertos: prvCheckTasksWaitingTermination bugfix
Bugfix to prevent a self deleting no affinity task's memory from being freed by the
idle task of the other core before the self deleting no affinity task is able to context
switch out.  prvCheckTasksWaitingTermination now checks if the task is still on
pxCurrentTCB before freeing task memory.
2017-12-27 16:54:29 +08:00
e589cad07e Review comments implemented 2017-12-27 16:54:28 +08:00
44764222a5 RMT transmitter and receiver overview pictures 2017-12-27 16:54:28 +08:00
b6ee7f699c Implement review comments 2017-12-27 16:54:28 +08:00
9b57d4aa0d RMT API docs update, new example 2017-12-27 16:54:28 +08:00
60a642b31c A workaround for MSYS2 / Windows system to be able to install 'blockdiag' 2017-12-27 16:54:28 +08:00
48fda0f27b add NACK for the last byte to read 2017-12-27 16:54:27 +08:00
33ca8874d4 Add support for Makefile.componentbuild files 2017-12-27 16:54:27 +08:00
c884931b0b Add .editorconfig file
remove newlinet in binary file

editorconfig style guide

correct format for rst hyperlinks
2017-12-27 16:54:26 +08:00
41baf59287 Fix the clock subsystem so it doesn't undo the weird condition spiram_psram.c jams the enable/reset bits of SPI3 in when 80MHz mode is selected anymore 2017-12-27 16:54:26 +08:00
87f7d1875d esp32: Fix backwards compatibility for pre-v2.1 bootloaders
Older bootloaders don't set RTC_XTAL_FREQ_REG or call rtc_clk_init(),
app needs to pick this up.

Reported at
https://esp32.com/viewtopic.php?f=2&t=3939&p=17836
2017-12-27 16:54:25 +08:00
545c7e5cdd freertos/ringbuf: Added an API xRingbufferCreateNoSplit()
This is a wrapper API for creating a Ring Buffer, which ensures that
the ringbuffer can hold the given number of items, each item being of the
same given length.

Signed-off-by: Piyush Shah <piyush@espressif.com>
2017-12-27 16:54:25 +08:00
ef6fe211b8 freertos/ringbuf: Add an API xRingbufferIsNextItemWrapped()
Useful to check if the next item to receive is wrapped or not.
This is valid only if the ring buffer is initialised with type
RINGBUF_TYPE_ALLOWSPLIT.

This is as per the feature request here:
https://github.com/espressif/esp-idf/issues/806

Signed-off-by: Piyush Shah <piyush@espressif.com>
2017-12-27 16:54:25 +08:00
50637f638f freertos/ringbuf: Add an API xRingbufferGetCurFreeSize() to fetch current free size available
The earlier available API (xRingbufferGetMaxItemSize())just gives
a static max entry value possible for given ring buffer.
There was a feature request for an API which could provide
a real time available buffer size. See below:

https://github.com/espressif/esp-idf/issues/806

Signed-off-by: Piyush Shah <piyush@espressif.com>
2017-12-27 16:54:25 +08:00
c4b861ad65 log: Remove non-static TAG variables 2017-12-27 16:54:24 +08:00
492b926d50 i2c: rx <-> tx typo's, NULLing free'd variable, consistent CRITICAL sects
A couple of typos referencing tx_ring_buf when rx_ring_buf, slv_tx_mux
instead of slv_rx_mux.

Also, I2C_ENTER_CRITICAL()/I2C_EXIT_CRITICAL() usage was not consistent.
Only some of the _set_ functions had them.  Most of the _get_ function
had them?  It is my understanding that they should be wrapped around
writes, not reads? (I think we still need the lock for reading pairs of consistent values)

Also, the ticks_to_wait timeout handling in i2c_master_cmd_begin() would
not handle integer rollover correctly.

Merges https://github.com/espressif/esp-idf/pull/1180
2017-12-27 16:54:24 +08:00
b5f8cf0f03 driver(i2c): corrected timeout range for i2c_set_timeout.
Merges https://github.com/espressif/esp-idf/pull/1353
2017-12-27 16:54:24 +08:00
c4bb528c61 bugfix(i2c): use queue instead of event group for internal commands
Reported from github:
https://github.com/espressif/esp-idf/issues/1312
https://github.com/espressif/esp-idf/issues/1193

Issues:
1. We used to use event group in the driver, which would cause:
    a. longer operation time since the event group are based on FreeRTOS timer.
    b. Operation fails if the timer queue is not long enough.
2. There might be some issue with event group, we will still try to provide a small test code in other branch.

modification:
1. use queue instead of event-bit for internal commands
2. use queue overwrite for cmd_done event
2017-12-27 16:54:23 +08:00
a0bdee0c9c feat(monitor): add pause feature. 2017-12-27 16:54:23 +08:00
c015dd6c41 feat(monitor): add new feature allowing disabling log display. 2017-12-27 16:54:23 +08:00
5afafb0050 fix typo for heap cap free size 2017-12-27 16:54:22 +08:00
ff008d2be3 Linked ESP32 datasheet and regulatory certificates 2017-12-27 16:54:22 +08:00
84bfc96f08 Fixed issues identified during review 2017-12-27 16:54:22 +08:00
0448ee9685 The WROOM and WROVER family of modules is now extended with ESP-WROOM-32D and ESP32-WROOM-32U 2017-12-27 16:54:22 +08:00
42e411dafc bootloader: don't log anything before uart_console_configure is called 2017-12-27 16:54:21 +08:00
fbff8eb95b esp32: fix incorrect clock enable bit name for UART0
Closes https://github.com/espressif/esp-idf/issues/1301
2017-12-27 16:54:21 +08:00
c778951547 fatfs: fix double free in bailout path of esp_vfs_fat_sdmmc_mount
Fixes https://github.com/espressif/esp-idf/issues/1370
2017-12-27 16:54:21 +08:00
a0776b2f21 sdspi: use response timeout passed from upper layer
Previously SDSPI host driver would rely on retry count when waiting for
the card to read or write data. This caused different timeout times
depending on CPU frequency and card clock frequency. In practice, card
performance does not depend on these two factors.
This change uses timeout_ms field of sdmmc_command_t introduced
previously for SDMMC host.

Fixes https://esp32.com/viewtopic.php?f=2&t=3440&p=16037 and similar
issues related to SDSPI timeouts.
2017-12-27 16:54:21 +08:00
ae30d1bc7b fatfs: fix deinit not called for SDSPI host
Closes https://github.com/espressif/esp-idf/issues/1362
2017-12-27 16:54:21 +08:00
28e4162dd2 Resolves: Warning '-s option given but default rule can be matched'. Closes https://github.com/espressif/esp-idf/issues/1338 2017-12-27 16:54:20 +08:00
242f8ea743 docs: add information about execution time of ULP instructions 2017-12-27 16:54:20 +08:00
5c1506f796 ulp: document the need to wait for RTC to be ready for wakeup 2017-12-27 16:54:20 +08:00
103559153f ulp: mention that instructions array must be declared in local scope
Closes https://github.com/espressif/esp-idf/issues/1327
2017-12-27 16:54:20 +08:00
d340088993 docs: add description of ULP I2C instructions 2017-12-27 16:54:20 +08:00
e8fbd6e288 time: rename time source option from FRC to "high-resolution timer"
libc time function now rely on esp_timer_get_time as the source of
high-resolution time, rather than FRC1 timer. Internally, on the ESP32
esp_timer implementation uses FRC2 timer.

- Change help text and labels in Kconfig to use "high-resolution timer"
  instead of FRC1. Keep existing Kconfig option name to be backwards
  compatible.
- Change references to "FRC1" in the source code to "FRC".
2017-12-27 16:54:19 +08:00
50b710d267 newlib/time: fix compilation error when only RTC is used as clock source
Fixes https://github.com/espressif/esp-idf/issues/1245
2017-12-27 16:54:19 +08:00
f4554c81fc vfs/fatfs: use structures with bit fields for FAT date/time
Replace explicit masks and shifts with bit fields when working with FATFS date and time representations. Also zero-initialize remaining members of struct tm.

Fixes https://github.com/espressif/esp-idf/issues/1369.
2017-12-27 16:54:19 +08:00
96be8f2efa vfs/fatfs: fix stat call failing when called for mount point
FATFS does not support f_stat call for drive root. When handling stat
for drive root, don't call f_stat and just return struct st with S_IFDIR
flag set.

Closes #984
2017-12-27 16:54:19 +08:00
033124be14 spiffs: make OBJ_META_LEN configurable, make mtime support optional
- SPIFFS_OBJ_META_LEN can be set in sdkconfig
- mtime support can be enabled in sdkconfig, if META_LENGTH is sufficient
- add test for mtime updates
2017-12-27 16:54:18 +08:00
b4c1bdb11b Unify the time file creation for SPIFFS and SD 2017-12-27 16:54:18 +08:00
acc9b871d1 1. Following https://esp32.com/viewtopic.php?f=14&t=3834 and https://github.com/espressif/esp-idf/issues/1351 updated information regarding selection of the main XTAL frequency. 2. Removed obsolete note about ': not a valid identifier...', as it does not show up anymore with the latests MSYS2 installation. 2017-12-27 16:54:17 +08:00
cb9be8c0c4 bugfix: io setting useless when io_num > 32 2017-12-27 16:54:17 +08:00
8388e1be54 Add #include guards and __cplusplus guards to esp_debug.h
Merges https://github.com/espressif/esp-idf/pull/1358
2017-12-27 16:54:16 +08:00
5960e7419d build system: Add *.cc files to list of file extensions compiled by default
Merges https://github.com/espressif/esp-idf/pull/1318
2017-12-27 16:54:16 +08:00
21912b95f4 Bugfix I_DELAY macro
When compiling

> const ulp_insn_t program[] = {
> I_DELAY(1)
> };

with the xtensa-esp32-elf-g++ compiler i always got the error:

> sorry, unimplemented: non-trivial designated initializers not supported
>
>        };

This was due to the different order in the macro and the struct. The struct has another order of the fields (opcode, unused, cycles) vs (cycles, unused, opcode):
>    struct {
>        uint32_t cycles : 16;       /*!< Number of cycles to sleep */
>        uint32_t unused : 12;       /*!< Unused */
>        uint32_t opcode : 4;        /*!< Opcode (OPCODE_DELAY) */
>    } delay;                        /*!< Format of DELAY instruction */

After updating the order in the macro it is possible to compile with the g++ compiler.

Merges https://github.com/espressif/esp-idf/pull/1310
2017-12-27 16:54:16 +08:00
3085eb7ec6 openssl: add feature check for MBEDTLS_SSL_ALPN
Fixes https://github.com/espressif/esp-idf/issues/1342
2017-12-27 16:54:16 +08:00
8ed44ace4b heap_trace: fix bug in realloc for copying trace record
Closes https://github.com/espressif/esp-idf/issues/1354

Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2017-12-27 16:54:15 +08:00
58accf05cf docs: fix i2s code snippet for interrupt flags setting
Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2017-12-27 16:54:15 +08:00
6f90393f22 docs: link to FreeRTOS APIs from SMP changes documentation 2017-12-27 16:54:14 +08:00
66fe94f816 docs: add FreeRTOS API docs
- Use `code` tags instead of a mix of `<pre></pre>` and
  `@verbatim .. @endverbatim`
- Remove manually added function prototypes from comment blocks
- Remove of grouping (`\defgroup`) — some extra work is needed
  to make groups compatible with the way we auto-generate API
  reference from Doxygen XML files. It's pretty easy to add the
  grouping directives back if/when we implement support for
  Doxygen groups in the later stages of documentation build
  process.
- Hide private APIs under `@cond .. @endcond`
- Convert some comments into Doxygen-compatible ones
- Fix various documentation issues: missing documentation for
  some parameters, mismatch between parameter names in comment
  block and in function prototype.
- Add doxygen comments for functions which didn't have them
  (thread local storage).
- Add [out] param tags where necessary
- Redefine `xTaskCreate` and `xTaskCreateStatic` as inline
  functions instead of macros.
2017-12-27 16:54:14 +08:00
df6adbd5bf freertos/fix SMP bug with Idle task clean up
This commit backports vTaskDelete() behavior from FreeRTOS v9.0.0  which
allows for the immediate freeing of task memory if the task being deleted
is not currently running and not pinned to the other core. This commit also
fixes a bug in prvCheckTasksWaitingTermination which prevented the
Idle Task from cleaning up all tasks awaiting deletion. Each iteration of the Idle
Task should traverse the xTasksWaitingTermination list and clean up all tasks
not pinned to the other core. The previous implementation would cause
prvCheckTasksWaitingTermination to return when encountering a task
pinned to the other core whilst traversing the xTasksWaitingTermination list.

The test case for vTaskDelete() has been updated to test for the bugfix and
backported deletion behavior.
2017-12-27 16:54:14 +08:00
ce3ccc18fa Update cJSON to 1.6.0
* Fixes compilation errors/warnings with gcc 7.2.0

Merges https://github.com/espressif/esp-idf/pull/1163
2017-12-27 16:54:13 +08:00
36d6e4e2c7 Fix compilation errors when using gcc-7.2.0 for the crosstool-ng toolchain
* Change snprintf for strlcat does not complain w/gcc7.2.0 and it is safer, thanks @projectgus
* Use proper quotes for character literals

Merges https://github.com/espressif/esp-idf/pull/1163
2017-12-27 16:54:13 +08:00
a4d45a0a4d spi_flash: Add option to log warnings if (spuriously) writing zero bits to ones
Won't work for SPIFFS, maybe some other implementations?
2017-12-27 16:54:12 +08:00
38170d465c spi_flash: Add option to verify all writes by reading back data
Helpful when debugging SPI flash hardware related issues.

TW15203
2017-12-27 16:54:12 +08:00
ccea4a0f8f windows: Allow "make menuconfig" to work if ming32 gcc is also installed
Closes https://github.com/espressif/esp-idf/issues/1296
2017-12-27 16:54:12 +08:00
954c0981d8 Merge branch 'refactor/btdm_spp_client_demo' into 'release/v3.0'
component/bt: refactor spp client demo

See merge request !1697
2017-12-27 11:46:15 +08:00
de79de1c26 Merge branch 'bugfix/btdm_modify_code_format_and_comments_v3.0' into 'release/v3.0'
Component/bt: modify code format and comments_v3.0

See merge request !1693
2017-12-25 14:30:50 +08:00
194e1835c2 Component/bt: modify code format and comments 2017-12-22 19:50:51 +08:00
17ac80867b Merge branch 'bugfix/btdm_fix_memory_leak_for_SMP_V3.0' into 'release/v3.0'
component/bt: fix memory leak in SMP_V3.0

See merge request !1691
2017-12-22 14:34:44 +08:00
05605920ae Merge branch 'bugfix/esp_timer_overflow_bugs' into 'release/v3.0'
esp_timer:fix three bugs about timer get and timer alarm where overflow is not correct

See merge request !1663
2017-12-20 13:31:41 +08:00
121e5a7847 Merge branch 'feature/eth_set_mac_addr_for_3.0' into 'release/v3.0'
emac:add set_eth_mac api

See merge request !1692
2017-12-20 13:31:22 +08:00
031ab556a9 component/bt: fix memory leak in SMP
- fix memory leak in smp
- fix log error in config_parse
2017-12-20 10:28:04 +08:00
4837f93968 esp_timer:fix three bugs about timer get and timer alarm where overflow is not correct 2017-12-19 20:07:45 +08:00
717b1697df Merge branch 'bugfix/fix_some_wifi_bugs_v3.0' into 'release/v3.0'
Fix some wifi bugs

See merge request !1679
2017-12-19 17:42:19 +08:00
b5942dc400 Merge branch 'bugfix/btdm_send_data_length_req_after_read_feature_complete_for_V3.0' into 'release/v3.0'
component/bt: send data length req after read feature complete for v3.0

See merge request !1665
2017-12-19 17:38:45 +08:00
72d4de442a Merge branch 'bugfix/btdm_mem_release_for_v3_0' into 'release/v3.0'
component/bt : fix btdm mem release cause 0x3ffbbb28-0x3ffbdb28 add to region but should not.

See merge request !1662
2017-12-19 17:24:47 +08:00
485e254719 Merge branch 'bugfix/btdm_optimiz_adv_cb_func_for_3_0' into 'release/v3.0'
Bugfix/btdm optimiz adv cb func

See merge request !1681
2017-12-19 17:24:09 +08:00
0ebae99ab0 Merge branch 'bugfix/windows_10_idf_monitor_redux_v30' into 'release/v3.0'
idf_monitor: Fix Windows 10 bug in cases where second console write also fails (v3.0 backport)

See merge request !1676
2017-12-18 06:43:17 +08:00
7e488b0c6b component/bt: Optimized broadcast callback function, send the callback function to the application after the controller confirms receipt of the broadcast start.
1. optimiz the ble stop adv callback function.
2. added the osi_mutex_unlock in the bta_gattc_wait4_service_change_ccc_cback function when the p_timer_param == NULL ||  p_conn == NULL.
2017-12-15 18:17:02 +08:00
3a4cf72f30 Fix some wifi bugs
1. change first scanning channel to adjust different country code.

2. fix a bug that system crashes when station disconnects from AP.
2017-12-15 17:56:30 +08:00
710e69feca emac:add set_eth_mac api 2017-12-15 17:15:53 +08:00
6e0f905761 idf_monitor: Fix Windows 10 bug in cases where second console write also fails
Although in my tests the second write always passes, people have reported
different results.

Closes https://github.com/espressif/esp-idf/issues/1136 (again)
2017-12-15 16:59:36 +11:00
489f5efbd1 component/bt : fix btdm mem release cause 0x3ffbbb28-0x3ffbdb28 add to region but should not.
1. fix the bug. Modify the condition that esp_bt_controller_mem_release() shoud be only called before esp_bt_controller_init() or after esp_bt_controller_deinit()
2. modify the example to use esp_bt_controller_mem_release()
2017-12-13 11:37:31 +08:00
3a70e61477 Component/bt: send data length request by host after read feature complete 2017-12-12 20:02:36 +08:00
043ef32651 component/btdm : change bt.h name to esp_bt.h to form the name prefix 2017-12-08 20:56:43 +08:00
eae3b45170 LEDC Driver: Added back original definitions of 'duty_resolution' and 'clock_divider'. This update is to provide backward compatibility with ESP-IDF 2.1. 2017-12-07 20:52:54 +08:00
a1c79bbc7b Pin descriptions, overview diagram and board dimensions carried over from ESP32-PICO-KIT_Datasheet_EN.pdf. The datasheet looks redundant and will not be used. 2017-12-07 20:52:09 +08:00
cc46b5054a when netconn created directly,netconn_delete() will not call netconn_free(),
which will lead to memory leak

Closes https://github.com/espressif/esp-idf/issues/784
2017-12-07 20:51:37 +08:00
22489d7021 Merge branch 'bugfix/wdt_periph_enable' into 'master'
watchdogs: make sure timer group peripherals are enabled

See merge request !1623
2017-12-01 22:06:43 +08:00
c44487143d Merge branch 'bugfix/btdm_connect_stable_optimiz' into 'master'
component/bt: Optimiz the ble connection performance.

See merge request !1618
2017-12-01 21:35:17 +08:00
08048ff76a Merge branch 'feature/btdm_avrc_metadata' into 'master'
Feature/btdm avrc metadata:  implemented AVRCP metadata and notification register commands

See merge request !1624
2017-12-01 20:31:25 +08:00
f58c5b21ec watchdog: increase default INT WDT interval if SPIRAM is used
Running heap_caps_check_integrity for 4MB of PSRAM can take longer than
the default WDT interval, 300ms.
2017-12-01 20:10:26 +08:00
15b6b64c99 watchdog: enable INT WDT unit test 2017-12-01 20:10:26 +08:00
bd1d631134 watchdogs: make sure timer group peripherals are enabled 2017-12-01 20:10:26 +08:00
96f120c0d4 component/bt: Optimiz the ble connection performance. 2017-12-01 20:02:14 +08:00
85fc06e3bb Merge branch 'bugfix/flash_1v8_enable_vddsdio_reg' into 'master'
bootloader: Only apply VDDSDIO 1.8V->1.9V if regulator is enabled

See merge request !1601
2017-12-01 19:34:45 +08:00
96cd6f8626 Merge branch 'bugfix/update_libstdcxx_psram' into 'master'
libstdc++: update the library built with PSRAM workaround

See merge request !1588
2017-12-01 19:34:29 +08:00
c672fc54fd Merge branch 'feature/ledc_more_meaningful_parameter_names' into 'master'
Provided more meaningful parameter names by renaming 'bit_num' to 'duty_resoluti…

See merge request !1440
2017-12-01 19:33:53 +08:00
7702e0f45b Merge branch 'bugfix/btdm_con_discon_test_crash_#16055' into 'master'
component/bt: Fix the bug when write ccc sometimes will lead to repeatedly release the memory.

See merge request !1599
2017-12-01 19:32:39 +08:00
86fa1820b7 component/bt: Add AVRCP medadata attribute support so A2DP can show track title, album, etc.
Merges https://github.com/espressif/esp-idf/pull/1078
2017-12-01 19:28:52 +08:00
1f7e42c0b7 Merge branch 'bugfix/fix_some_wifi_bugs' into 'master'
Fix some wifi lib bugs

See merge request !1626
2017-12-01 19:22:18 +08:00
aece22f763 Merge branch 'bugfix/tw16581_dhcps_default_behaviour_changed' into 'master'
fix the dhcps default behaviour chenged by dns

See merge request !1612
2017-12-01 19:21:26 +08:00
7ec7352534 Merge branch 'bugfix/small_fixes_from_github' into 'master'
Small fixes by users from GitHub

See merge request !1620
2017-12-01 19:21:10 +08:00
58e60401a2 Merge branch 'feature/bt_a2dp_i2s' into 'master'
examples/bluetooth/a2dp_sink: add i2s audio to a2dp_sink example application

See merge request !853
2017-12-01 19:18:50 +08:00
0f2d417a74 Small typo fix
Signed-off-by: krzychb

Merges https://github.com/espressif/esp-idf/pull/1331
2017-12-01 09:06:09 +01:00
866b84b9f8 Typo fix. Closes https://github.com/espressif/esp-idf/issue/1323 2017-12-01 09:06:08 +01:00
aaa17b8740 Fix some wifi lib bugs
1. Add a hide API for station to receive and process probe request
frame.

    2. Fix an issue that wifi/bt coexistence crashes in PSRAM version.

    3. Fix an issue that the API for clearing vendor ie can not work.

    4. Fix an issue that wifi stop and reboot leads watchdog.
2017-12-01 15:00:49 +08:00
af63ca1522 Merge branch 'bugfix/pthread_local_storage_spinlock' into 'master'
pthreads: Remove potentially blocking mutex from idle task cleanup path

See merge request !1621
2017-12-01 14:42:29 +08:00
4da239e824 Merge branch 'feature/btdm_optimize_gatt_server_service_table_demo' into 'master'
component/bt: optimize gatt_server_service_table demo

See merge request !1479
2017-12-01 12:25:42 +08:00
015233d2dc Merge branch 'bugfix/btdm_mem_leak_lead_to_WDT_#16592' into 'master'
compoent/bt: Fix the bug when do the BLE pressure test will lead to memory leak will appear WDT.

See merge request !1610
2017-12-01 12:24:04 +08:00
89407a5770 pthread: Use spinlock not semaphore mutex to protect TLS key list 2017-12-01 14:28:07 +11:00
a0992ad442 component/bt: Remove the p_tle->param reset to 0 when free the p_timer_param pointer. 2017-11-30 16:15:22 +08:00
5b243b1d01 component/bt: Added the mutex lock protect the ccc free when disconnect. 2017-11-30 02:45:26 -05:00
582b731c23 Merge branch 'bugfix/active_scan' into 'master'
component/bt : fix actvie scan cannot send scan_req in a certain case

See merge request !1608
2017-11-30 15:06:20 +08:00
cc600bd517 Merge branch 'bugfix/fix_lwip_macros' into 'master'
lwip: Change socket API macros to static-inline

See merge request !1614
2017-11-30 10:28:20 +08:00
1c0543fb17 lwip: Change socket API macros to static-inline 2017-11-29 11:42:14 +05:30
6228d0c409 Merge branch 'bugfix/esp_timer_profiling' into 'master'
esp_timer: fix for deletion of timer in a callback, add docs

See merge request !1607
2017-11-29 12:32:38 +08:00
f0547d58e4 esp_timer: add documentation, expose profiling option in Kconfig 2017-11-29 11:44:46 +08:00
6e7eb3c776 esp_timer: fix for the case when timer is deleted in callback
Timer callback can delete the timer. If CONFIG_ESP_TIMER_PROFILING was
enabled, this caused an access to invalid (freed) memory.
This fix adds a pointer to track the timer while executing the callback.
This is needed so that we can check if callback deletes the timer,
in which case we won't try updating profiling counters for this timer
after the callback is done.
2017-11-29 11:44:46 +08:00
7353307ca5 component/bt: reset the p_cmd_list pointer after release the mem. 2017-11-29 10:50:03 +08:00
1d5389668b Merge branch 'feature/dhcp_server_options_menuconfig' into 'master'
dhcpserver: Option to change lease time multiplier and number of max

See merge request !1595
2017-11-29 07:07:09 +08:00
59931cd63b component/bt : fix actvie scan cannot send scan_req in a certain case 2017-11-28 20:11:40 +08:00
e315d7ca08 fix the dhcps default behaviour chenged by dns
Closes https://github.com/espressif/esp-idf/issues/1285
2017-11-28 16:39:00 +08:00
5b9131cc60 compoent/bt: Fix the bug when do the BLE pressure test will lead to memory leak will appear WDT. 2017-11-28 15:43:33 +08:00
626ad5f577 dhcpserver: Option to change lease time multiplier and number of max
stations connected to it.

Merges: https://github.com/espressif/esp-idf/pull/1206
2017-11-28 15:58:03 +11:00
0554bc59a2 Merge branch 'bugfix/tw16551_buffer_overflow' into 'master'
fix buffer overflow

See merge request !1605
2017-11-27 22:18:58 +08:00
a83fbd3364 Merge branch 'bugfix/tw16287_tcp_send_succeed_after_station_disconnect' into 'master'
In STA mode, tcp_send cannot catch err after disconnect station

See merge request !1540
2017-11-27 21:30:46 +08:00
886047fb46 Merge branch 'bugfix/TW16564_tcp_connect/disconnect_crash' into 'master'
fix tcp connect/disconnect carsh

See merge request !1598
2017-11-27 21:30:11 +08:00
7980255498 Merge branch 'bugfix/btdm_scan_lead_to_conn_error' into 'master'
component/bt: Fixed the bug when stop scan if not set back the scan params will …

See merge request !1590
2017-11-27 21:21:13 +08:00
768bbcd8aa fix buffer overflow in ipc.c 2017-11-27 18:47:40 +08:00
9e530fd063 Merge branch 'bugfix/allow_external_stack' into 'master'
freertos: fix a bug for incorrect check of allow-external-stack

See merge request !1596
2017-11-27 16:31:27 +08:00
067c0e1ffe Merge branch 'bugfix/cpp_unit_tests_not_executed_by_ci' into 'master'
CI: fix C++ unit test cases not executed by CI

See merge request !1589
2017-11-27 12:48:12 +08:00
0b644ee515 fix tcp connect/disconnect carsh 2017-11-27 10:18:58 +08:00
fccc30d2d5 bootloader: Only apply VDDSDIO 1.8V->1.9V if regulator is enabled
Fixes bug if regulator is disabled via efuse.
2017-11-27 10:33:41 +11:00
75ff6dce15 Merge branch 'docs/esp_ipc' into 'master'
docs/ipc documentation

See merge request !1584
2017-11-27 07:24:37 +08:00
5e7478a055 Merge branch 'bugfix/ledc_fade_scale' into 'master'
driver(LEDC): add scale value check in ledc_set_fade API

See merge request !1583
2017-11-27 07:23:19 +08:00
7683bdbce2 Merge branch 'bugfix/monitor_windows10_crash' into 'master'
monitor: Fix Windows 10 crash since Fall Creators Update

See merge request !1567
2017-11-27 07:22:44 +08:00
c71318ce88 component/bt: Fix the bug when write ccc sometimes will lead to repeatedly release the memory. 2017-11-25 05:06:14 -05:00
4c13b2f391 docs/ipc documentation
This commit updates doxygen comments in the IPC header files and adds an rst
docs page.
2017-11-24 15:31:28 +08:00
e7743d090d freertos: fix a bug for incorrect check of allow-external-stack 2017-11-24 09:53:47 +05:30
02304ad83e Merge branch 'feature/freertos_backported_functions' into 'master'
freertos/backport and test v9.0.0 functions

See merge request !1515
2017-11-24 08:49:59 +08:00
e5b2c1cf4c Merge branch 'bugfix/btdm_corret_bt_h_comment' into 'master'
component/bt: Correct the ESP_BLE_PWR_TYPE_CONN_HDL0-9 comment in the bt.h file t…

See merge request !1570
2017-11-24 00:14:14 +08:00
082f5716c6 Merge branch 'feature/enable_disable_ampdu_rx_tx_independently' into 'master'
Feature/enable disable ampdu rx tx independently

See merge request !1560
2017-11-23 22:22:43 +08:00
177c92f15e component/bt: Change the code format. 2017-11-23 06:42:04 -05:00
2458d15d2d component/bt: recovery the scan parameter to the controller before start scan. 2017-11-23 06:36:00 -05:00
b553c925b1 bugfix: while scale equals 0 will cause crash 2017-11-23 17:56:18 +08:00
dd371289aa CI: fix C++ unit test cases not executed by CI 2017-11-23 17:14:23 +08:00
f14699068d component/bt: Fixed the bug when stop scan if not set back the scan params will lead to connection request sent the empty packet to the peer device. 2017-11-23 03:54:29 -05:00
983ec73413 libstdc++: update the library built with PSRAM workaround 2017-11-23 15:34:23 +08:00
c1d101dd41 freertos/backport and test v9.0.0 functions
This commit backports the following features from FreeRTOS v9.0.0
- uxSemaphoreGetCount()
- vTimerSetTimerId(), xTimerGetPeriod(), xTimerGetExpiryTime()
- xTimerCreateStatic()
- xEventGroupCreateStatic()
- uxSemaphoreGetCount()

Functions backported previously
- xTaskCreateStatic()
- xQueueCreateStatic()
- xSemaphoreCreateBinaryStatic(), xSemaphoreCreateCountingStatic()
- xSemaphoreCreateMutexStatic(), xSemaphoreCreateRecursiveMutexStatic()
- pcQueueGetName()
- vTaskSetThreadLocalStoragePointer()
- pvTaskGetThreadLocalStoragePointer()

Unit tests were also written for the functions above (except for pcQueueGetName
which is tested in a separate Queue Registry MR). The original tlsp and del cb test case
was deleted and integrated into the test cases of this MR.
2017-11-23 14:18:09 +08:00
e43ac33b7c Merge branch 'bugfix/aws_iot_nvs_no_init' into 'master'
aws_iot: fix aws_iot examples without NVS initialization

See merge request !1581
2017-11-23 13:19:21 +08:00
2f62a62d28 Merge branch 'feature/toolchain_update' into 'master'
toolchain: update to 1.22.0-75-gbaf03c2

See merge request !1577
2017-11-23 13:02:57 +08:00
b669b415e6 Merge branch 'feature/cxx_exceptions_emg_pool' into 'master'
esp32: Adds C++ exceptions emergency pool size menuconfig option

See merge request !1561
2017-11-23 13:02:49 +08:00
2eac553062 Merge branch 'feature/pthread_key_and_cond_var_support' into 'master'
pthread: Added support for pthread condition variables

See merge request !1387
2017-11-23 13:02:40 +08:00
9a09292487 ci: increase number of example build jobs 2017-11-23 12:02:41 +08:00
edb2400742 pthread: Added support for pthread condition variables
This is required for std::condition_variable support

Signed-off-by: Amey Inamdar <amey.inamdar@gmail.com>
2017-11-23 11:26:51 +08:00
7df96718a2 esp32: Adds C++ exceptions emergency pool size menuconfig option 2017-11-23 06:14:11 +03:00
3f6a8f1430 esp32: add options to disable/enable TX/RX AMPDU independently
Make menuconfig can disable/enable TX/RX AMPDU independently
2017-11-23 09:42:31 +08:00
4d34251ff3 windows: Update precompiled env link & toolchain in setup script 2017-11-23 11:55:23 +11:00
597ce3b800 Merge branch 'bugfix/ringbuf_buflen_bugfix' into 'master'
Bugfix/ringbuf buflen bugfix

See merge request !1562
2017-11-22 22:30:11 +08:00
61ead8fb96 Merge branch 'bugfix/ota_example_http_request' into 'master'
ota example: Send a valid HTTP/1.0 request

See merge request !1566
2017-11-22 22:27:10 +08:00
c237c5c966 Merge branch 'bugfix/gpio_disable_api' into 'master'
driver: GPIO can be disabled by calling  gpio_set_direction

See merge request !1575
2017-11-22 22:26:54 +08:00
cf47012111 Merge branch 'feature/prs_from_github' into 'master'
PRs from Github

See merge request !1578
2017-11-22 22:26:40 +08:00
5fe91ae7cd Merge branch 'bugfix/cpp_guards' into 'master'
Add C++ guards to freertos/ringbuf.h, heap headers

See merge request !1552
2017-11-22 22:26:26 +08:00
ada33fe3dd Add GPIO input and output disable option 2017-11-22 15:00:27 +08:00
4b3997cfbb aws_iot: fix aws_iot examples without NVS initialization
WiFi used to initialise nvs automatically, but it doesn't now.
see more info: https://github.com/espressif/esp-idf/issues/624

Closes #624
2017-11-22 13:02:55 +08:00
08be5213db Merge branch 'bugfix/uxportcompare_check_addr_range' into 'master'
portmacro: add assert to check address validity in uxPortCompareSet

See merge request !1519
2017-11-22 11:44:09 +08:00
3607b404c0 Merge branch 'feature/lwip_socket_pcb_num_config' into 'master'
lwip: Expose number of active socket limits in menuconfig

See merge request !1433
2017-11-22 11:36:55 +08:00
4ce68f6163 lwip: Expose number of active socket limits in menuconfig 2017-11-22 14:10:08 +11:00
157371effb Set GPIO-mode for MDC and MDIO pins
Merges #1127
2017-11-22 11:01:43 +08:00
08ba79cc2b return old handler from esp_log_set_vprintf()
Merges #1286
2017-11-22 11:01:43 +08:00
cf768380b1 soc: Remove redefinition of MCU_SEL_M
Signed-off-by: Vitor Massaru Iha <vitor@massaru.org>

Merges #1290
2017-11-22 11:01:42 +08:00
969911b7c2 freertos: enabled use of pxTaskGetStackStart and cleaned up it's implementation
Merges #1298
2017-11-22 11:01:42 +08:00
4332a2c4bc Merge branch 'bugfix/cxx-exceptions-missing-stubs' into 'master'
cxx_exceptions: Add missing stubs for cxx exceptions with exceptions disabled

See merge request !1574
2017-11-22 09:26:24 +08:00
a556e1c782 heap: Add C++ header guards to heap headers
Closes https://github.com/espressif/esp-idf/issues/1195
2017-11-22 10:08:50 +11:00
0b48d5978e ringbuf.h: Add anti name-mangling definition
When using CPP and C combination this particular file threw error on linking.

Merges https://github.com/espressif/esp-idf/pull/1249

(Amended to add INC_FREERTOS_H guard, comment on #endif)
2017-11-22 10:08:15 +11:00
4f33339c1d test_ringbuf: Add tests for arbitrary length ring buffer
This will test the ring buffer for buffer length that is not
a multiple of 4

Signed-off-by: Piyush Shah <piyush@espressif.com>
2017-11-21 17:18:54 +05:30
7dd9c4f57f ringbuf: Fixes to header files for better understanding
1. Usage of this module required applications to include additional
files. What files to include is not very intuitive. Instead, it is
better for the header file itself to include other files as required.
2. Even though it may seem logical, it is better to explicitly mention
that an item needs to be "Returned" after a Receive

Signed-off-by: Piyush Shah <piyush@espressif.com>
2017-11-21 17:16:04 +05:30
62f44e45df ringbuf: Bugfixes for managing arbitrary sizes of ring buffer
It was observed that if the ring buffer size provided by application
is not a multiple of 4, some checks were failing (as read_ptr and write_ptr
could shoot beyond the ring buffer boundary), thereby causing asserts.
Simply wrapping around the pointers for such cases fixes the issue.

Moreover, because of the logic for maintaining 4-byte boundary,
it was also possible that a wrap-around occurred for some data,
even when the actual size remaining was sufficient for it.
Eg. Buffer available: 34, data size: 34, 4-byte aligned size: 36
Since the logic compares against 36, it writes 34 bytes and does a
wraparound. But since all 34 bytes are already written, there is
nothing to write after wrapping. It is better to just re-set the
write pointer to the dtart of ring buffer in such cases.

Tested send/receive for various arbitrary sizes of data and for
arbitrary sizes of ring buffer.

Alternative Solutions:
1) Allow only sizes which are multiples of 4, and return error otherwise.
Appropriate code and documentation change would be required
2) Allow arbitrary sizes, but internally add upto 3 bytes to make
the total size a multiple of 4

Signed-off-by: Piyush Shah <piyush@espressif.com>
2017-11-21 17:15:53 +05:30
0f503dee50 toolchain: update to 1.22.0-75-gbaf03c2
- enable condition variable support in gthread
- add provisions to allow emergency exception pool size to be configured
2017-11-21 19:30:52 +08:00
6e1453e864 Merge branch 'feature/bot' into 'master'
CI: support customize test with @bot

See merge request !1502
2017-11-21 18:43:56 +08:00
78ed138453 cxx_exceptions: Add missing stubs for cxx exceptions with exceptions
disabled

The misssing stubs get pulled in from the toolchain's libstdc++ also
causing to pull in defined stubs. This results in redefinition of
symbols. Fixing it by simply adding the missing stubs when exceptions
are disabled.

Signed-off-by: Amey Inamdar <amey.inamdar@gmail.com>
2017-11-21 12:41:49 +05:30
46673bb6f1 Merge branch 'bugfix/rtc_apll_disable' into 'master'
soc/rtc: don't power down BIAS_I2C along with APLL if other PLL is used

See merge request !1568
2017-11-21 12:13:07 +08:00
d135a017f4 Merge branch 'bugfix/ut_startup_time' into 'master'
By default, don't print test menu in unit-test-app

See merge request !1565
2017-11-21 12:12:46 +08:00
dc994e9c88 ota example: Send a valid HTTP/1.0 request
Was sending an invalid HTTP/1.1 request which many web servers rejected.

Thanks @chegawara for pointing this out on IRC.

Ref:
https://github.com/espressif/esp-idf/issues/231#issuecomment-300287523
2017-11-21 09:02:58 +11:00
93c75b4978 Merge branch 'bugfix/update_BOD_voltages' into 'master'
esp32/Update brownout voltages

See merge request !1520
2017-11-21 05:37:55 +08:00
729e0c2544 component/bt: Correct the SP_BLE_PWR_TYPE_CONN_HDL0-9 comment in the bt.h file to ESP_BLE_PWR_TYPE_CONN_HDL0-8 2017-11-20 08:05:35 -05:00
2eae440646 unit-test-app: reduce startup delay, clean up 2017-11-20 17:51:27 +08:00
81f806e676 test: change initial condition of unit test:
now UT App will not print test menu by default. it will print a prompt
to indicate it's ready. we can check this prompt instead of delay.
2017-11-20 17:51:27 +08:00
5117364c13 unit-test-app: don't print the list of tests by default
This reduces unit-test-app startup time when there are a lot of tests
included, speeding up unit tests in CI.
2017-11-20 17:51:27 +08:00
024e4c4337 Merge branch 'feature/openssl_cn_hostname_verification' into 'master'
openssl: Add CN hostname verification

See merge request !1554
2017-11-20 15:59:15 +08:00
18f4696371 Merge branch 'bugfix/pthread_test_mem_leaks' into 'master'
pthread: Fixes memory leaks and stack overflow in tests

See merge request !1563
2017-11-20 15:58:53 +08:00
4b8f55aadf Merge branch 'bugfix/minor_fixes_github' into 'master'
Minor fixes from github

See merge request !1555
2017-11-20 15:58:34 +08:00
3369f15fa3 soc/rtc: don't power down BIAS_I2C along with APLL if other PLL is used
If enable == false, and SOC_CLK_SEL == PLL, the code would would
erroneously set RTC_CNTL_BIAS_I2C_FORCE_PD. This change fixes the logic.
2017-11-20 15:27:16 +08:00
9fbcc6f922 In STA mode, tcp_send cannot catch err after disconnect station 2017-11-20 15:19:19 +08:00
19598fa6d3 monitor: Fix Windows 10 crash since Fall Creators Update
Closes https://github.com/espressif/esp-idf/issues/1136
2017-11-20 17:47:43 +11:00
ae1f1e9b84 openssl wrapper: introduce X509_VERIFY_PARAM_set/clear_hostflags
This defines the OpenSSL X509_CHECK_FLAG_...s and the set/clear
accessors.  Since none of them are supported, the set / clear
accessor currently always does nothing and returns error.

This call is often part of the generic openssl user code to
set up certificate verification.  This patch allows it to
compile for ESP32 and decide at runtime what to do about
unsupported flags.

Merges https://github.com/espressif/esp-idf/pull/980
2017-11-20 16:25:57 +11:00
4395f7c94e Merge branch 'feature/spi_flash_lock_recursive' into 'master'
spi_flash: Expose recursive op_lock for atomic multi-part flash operations

See merge request !1556
2017-11-20 13:24:41 +08:00
effc6c6d0d openssl wrapper: introduce X509_VERIFY_PARAM_set1_host
This lets the user code set the mbedtls hostname using the standard OpenSSL
X509_VERIFY_PARAM_set1_host() API semantics.

The API takes an X509_VERIFY_PARAM pointer.  We use the fact that is
a composed member of the SSL struct to derive the SSL pointer.

The X509_VERIFY_PARAM_set1_host() is unusual in that it can accept a
NUL terminated C string as usual, or a nonterminated pointer + length.
This implementation converts the latter to the former if given, before
using it.

This is enough for user code to get the openssl wrapper to make
mbedtls confirm the CN on the peer cert belongs to the hostname used
to reach it, by doing, eg

	X509_VERIFY_PARAM_set1_host(SSL_get0_param(myssl), myhostname, 0);

Merges https://github.com/espressif/esp-idf/pull/980
2017-11-20 16:24:06 +11:00
0f02a38262 openssl wrapper: introduce SSL_get0_param
This adds the standard OpenSSL api to get a pointer to the SSL struct's
X509_VERIFY_PARAM.  We need this for the OpenSSL api to set the peer
hostname introduced in the next patch.

Part of https://github.com/espressif/esp-idf/pull/980
2017-11-20 16:23:18 +11:00
4b8c90bce0 doc: Unify the two sections about the "dialout" group on Linux
An addition to https://github.com/espressif/esp-idf/pull/1158
2017-11-20 16:10:38 +11:00
05dd46cd72 udp_perf/tcp_perf examples: Erase NVS if no more free pages
Follows same pattern as other examples.

Amendment to https://github.com/espressif/esp-idf/pull/1279
2017-11-20 16:07:52 +11:00
3b84c1e8fa fixed broken udp_perf example by adding nvs_flash
Merges https://github.com/espressif/esp-idf/pull/1279
2017-11-20 16:07:00 +11:00
0dea8bca46 fixed broken tcp_perf example by adding nvs_flash 2017-11-20 16:06:59 +11:00
f54e99008d spi: Add ESP_ERR_NO_MEM to spi_device_queue_trans() documentation
Ref https://github.com/espressif/esp-idf/pull/1243#issuecomment-343103414
2017-11-20 16:06:59 +11:00
7a924bd85a spi_flash: Expose an accessor the current SPI flash guard functions
Change places which uses g_flash_guard_default_ops to use this. Probably exact same data, but a bit
cleaner.
2017-11-20 15:54:31 +11:00
e72e5a9706 spi_flash: Make spi_flash op_lock/op_unlock recursive
Allows chaining of multiple flash operations as an atomic operation.
2017-11-20 15:54:31 +11:00
91ccf588d1 esp32/Update brownout voltages
This commit updates the voltages of each brownout level in Kconfig.
Note that there is some variation of brownout voltage between each chip.
2017-11-20 12:26:13 +08:00
1fbd3ffac8 Merge branch 'feature/fatfs_r013a' into 'master'
fatfs: update to R0.13a

See merge request !1524
2017-11-20 10:16:39 +08:00
148130066f Merge branch 'feature/esp32_stack_protector' into 'master'
esp32: Adds Stack Smashing Protection Feature

See merge request !1537
2017-11-20 10:16:15 +08:00
9f7d632b74 Merge branch 'bugfix/spi_master_cs' into 'master'
fix(spi_master): fix the CS pin issue with GPIO 0.

See merge request !1536
2017-11-20 10:15:44 +08:00
7ce945a9de pthread: Fixes memory leaks and stack overflow in tests
Also this commit replaces FreeRTOS list used for pthread internals
with simple one from rom/queue.h
2017-11-17 16:57:33 +03:00
692a890232 esp32: Adds Stack Smashing Protection Feature
These changes add posibility to enable GCC stack protector via menuconfig
for all source files in project.
2017-11-17 12:08:36 +03:00
02573a8dc9 fix(spi_master): release temporary memory when queue new trans timeout. 2017-11-17 12:15:19 +08:00
13d38f10ee test(spi): internal connection test master with slave for address and command field. 2017-11-17 12:15:19 +08:00
57e1d47ad7 fix(spi_master): fix the CS pin issue with GPIO 0.
Closes #909
2017-11-17 12:15:19 +08:00
842292523f fix(spi_slave): add interrupt free into bus free process. 2017-11-17 12:14:40 +08:00
31711b5ac7 SPI: Document TIMEOUT return values
`spi_device_queue_trans` and `spi_device_get_trans_result` can return `ESP_ERR_TIMEOUT` – but this had not been documented.

Merges https://github.com/espressif/esp-idf/pull/1243
2017-11-17 10:50:54 +11:00
ad8ebe5b63 Update spp_client_demo.c
Merges https://github.com/espressif/esp-idf/pull/1229
2017-11-17 10:49:51 +11:00
4da90f09e7 freertos: minor issue in documentation snippet of queue.
taskYIELD was used in ISR context, but portYIELD_FROM_ISR should instead.

Merges https://github.com/espressif/esp-idf/pull/1187
2017-11-17 10:44:19 +11:00
17b4973d47 docs: Improved documentation for /dev/ttyUSB0 issues
Improved documentation for /dev/ttyUSB0 issues.  This occurred in Ubuntu, but I'm sure is applies to most distributions.

Merges https://github.com/espressif/esp-idf/pull/1158
2017-11-17 10:43:02 +11:00
0c40b2ec9d test: collect performance for esp-timer / spinlock 2017-11-16 17:48:48 +08:00
879160de8c test: collect example https_request binary size 2017-11-16 17:48:30 +08:00
9395a702ef test: check and collect performance via CI 2017-11-16 17:48:30 +08:00
7e8c2a9c00 Merge branch 'bugfix/newlib_strptime' into 'master'
newlib: Add strptime(), qsort_r(), nanf() to libc & libc_nano

See merge request !1547
2017-11-16 17:40:27 +08:00
c03d12b9e5 Merge branch 'bugfix/btdm_delete_gattc_cache_write' into 'master'
component/bt: delete gattc cache write operation

See merge request !1543
2017-11-16 17:39:22 +08:00
af367452b0 Merge branch 'bugfix/rebind_pcb_when_ip_changed' into 'master'
lwip: rebind UDP/TCP pcb to valid ip address when ip is changed

See merge request !1535
2017-11-16 17:28:06 +08:00
88e1a374a0 Merge branch 'bugfix/fix_airkiss_macro_typo' into 'master'
Fix an airkiss macro error

See merge request !1532
2017-11-16 17:25:45 +08:00
7bd8133639 component/bt: delete api bta_gattc_cache_write 2017-11-16 16:40:18 +08:00
7d20e4e422 newlib: Remove out of date libc_discard.list 2017-11-16 17:43:05 +11:00
239ac0e17b newlib: Add strptime(), qsort_r(), nanf() to libc & libc_nano
These functions were discarded but not provided in ROM.

Generated from commit 8ad0aa7d6 in newlib script repo. Didn't rebuild most of libc/libc_nano,
only appended the missing object files to the existing archives (should save some git churn).
2017-11-16 17:35:18 +11:00
2d148cd34b Merge branch 'bugfix/heap_region_add' into 'master'
component/heap : fix heap_region_add check bug

See merge request !1523
2017-11-16 13:45:10 +08:00
5789a8a6e9 component/bt: delete gattc cache write operation 2017-11-16 11:18:17 +08:00
e7a9ddcf72 component/heap : fix heap_region_add check bug 2017-11-16 11:10:13 +08:00
eef595501c Fix an airkiss macro error 2017-11-15 21:44:12 +08:00
209280e328 Merge branch 'bugfix/scan_example_cosmetic_fixes' into 'master'
Bugfix/Wi-Fi scan example cosmetic fixes

See merge request !1539
2017-11-15 21:19:24 +08:00
affde01b4c wifi_scan_example: Comments improved for readability
Rephrased the example's description to make it easier to understand
and made other grammatical fixes.

Signed-off-by: Piyush Shah <piyush@espressif.com>
2017-11-15 15:02:31 +05:30
371c66f188 wifi_scan_example: Indentation Fixes
- Trailing white spaces removed
- Re-formatted switch-case

Basic indentation fixes were done using tools/format.sh and switch-case
formatting was done manually (to identify different levels for "switch"
and "case")

Signed-off-by: Piyush Shah <piyush@espressif.com>
2017-11-15 15:01:11 +05:30
095d163050 lwip: rebind UDP/TCP pcb to valid ip address when ip is changed
This change fix the issue UDP/TCP pcb failed to rebind to correct ip address when ip is changed
2017-11-15 16:15:24 +08:00
ee3224bed2 Component/bt: optimize gatt_server_service_table demo 2017-11-15 15:26:53 +08:00
d488bb7bac Provided more meaningful parameter names by renaming 'bit_num' to 'duty_resolution' and 'div_num' to 'clock_divider' 2017-11-15 08:08:12 +01:00
b83792f504 Merge branch 'doc/esp_wifi_types' into 'master'
docs: Add esp_wifi_types.h items to wifi API reference

See merge request !1320
2017-11-15 15:03:02 +08:00
da141a2c7e Merge branch 'bugfix/touch_pad_register_mismatch' into 'master'
Bugfix/touch pad register mismatch

See merge request !1469
2017-11-15 14:52:13 +08:00
c6d25dd9cc Merge branch 'features/http2_demo' into 'master'
HTTP2 Client Demo

See merge request !1475
2017-11-15 14:51:51 +08:00
21d95eae2d Merge branch 'bugfix/tw16355' into 'master'
fix(tw16355): examples/protocols/coap_client(server)

See merge request !1531
2017-11-15 14:51:41 +08:00
fac2e78bfe Merge branch 'bugfix/emac_rx_process' into 'master'
component/emac: fix process rx err

See merge request !1529
2017-11-15 14:51:33 +08:00
a4f9dfc6a4 Merge branch 'bugfix/queue_registry_test' into 'master'
unit tests: fix queue registry test

See merge request !1528
2017-11-15 14:51:18 +08:00
c40dc36814 docs: Remove internal header esp_wifi_crypto_types.h from documentation 2017-11-15 17:40:38 +11:00
9a96c8379e docs: Add introduction section for WiFi, replace boilerplate 2017-11-15 17:40:38 +11:00
beba74ff61 docs: Add esp_wifi_types.h descriptions 2017-11-15 17:40:38 +11:00
a4cf094fd7 Merge branch 'bugfix/component_depends' into 'master'
build system: Fix COMPONENT_DEPENDS

See merge request !1530
2017-11-15 13:53:26 +08:00
b37e5d64b8 freertos: port: add check for portMUX address validity
Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2017-11-15 11:16:45 +05:30
6a02a58347 fix(tw16355): examples/protocols/coap_client(server)
fix coap example can not work properly
2017-11-15 11:58:19 +08:00
d46dcaf9e5 component/emac: fix process rx err 2017-11-15 11:04:32 +08:00
ec9d93f4fc Merge branch 'bugfix/btdm_gattc_command_queue_fix' into 'master'
Bugfix/btdm gattc command queue fix

See merge request !1317
2017-11-15 10:54:02 +08:00
957b97720a Merge branch 'bugfix/update_wifi_lib_for_some_fixes' into 'master'
esp32: update wifi lib to fix some wifi bugs

See merge request !1525
2017-11-15 10:12:39 +08:00
8b56345e44 unit tests: fix queue registry test
In the queue registry test, start_sem is given twice to let both tasks
start the test. Each task takes start_sem, does some work, gives done_sem,
and goes on to wait for start_sem again.
It may happen that one task can grab start_sem, add queues to the
registry, give done_sem, then grab start_sem again, delete the queues
from the registry, and give done_sem again. At this point, main test
task takes done_sem twice and proceeds to verify that queues have been
added to the registry. But in fact, the first task has already deleted
its queues from the registry, and the second one might not have added
the queues yet. This causes test to fail.

This changes the test to use separate start semaphores for each task,
to avoid the race condition.
2017-11-14 23:53:08 +08:00
41272c5b94 Merge branch 'bugfix/btdm_modify_logs' into 'master'
component/bt: modify some log

See merge request !1485
2017-11-14 21:13:00 +08:00
a2194ec665 Merge branch 'bugfix/btdm_remove_redundant_open_evt_for_same_app' into 'master'
component/bt: remove redundant open evt while calling gattc_open twice in the same app_id

See merge request !1526
2017-11-14 21:12:05 +08:00
ef2c370a30 Merge branch 'bugfix/btdm_no_ind_ack_for_server_only' into 'master'
component/bt: fix not send indication confirm in case of server only

See merge request !1522
2017-11-14 21:09:26 +08:00
3554d190ff esp32: update wifi lib to fix some wifi bugs
1. Fix resend eapol cause crash issue
2. Don't asser the system when the channel is in 14
2017-11-14 20:45:33 +08:00
9e90baf5a0 Merge branch 'bugfix/tw15564_fix_socket_close_crash' into 'master'
Bugfix/tw15564 fix socket close crash

See merge request !1496
2017-11-14 20:40:39 +08:00
b07a5f03cf component/bt: Change the gattc prepare write callback params. 2017-11-14 07:00:45 -05:00
3c33807689 Merge branch 'feature/freeRTOS_make_debug_functions_configurable' into 'master'
FreeRTOS/make Queue Registry and Run Time Stats configurable

See merge request !1480
2017-11-14 19:41:50 +08:00
7200b2cc11 bugfix(touch): registers of touchpad 8 and 9 are mismatched
1. All the registers of touch sensor 8 and 9 are mismatched except the ‘dac’ field in touch register of RTC IO
2. To swap the index for sensor 8 and 9 in APIs.
2017-11-14 18:47:56 +08:00
2a4af8b83c component/bt: remove redundant open evt while calling gattc_open twice in the same app_id 2017-11-14 17:11:34 +08:00
d1853dbbc0 FreeRTOS/make Queue Registry and Run Time Stats configurable
This commit makes the configQUEUE_REGISTRY_SIZE and
configGENERATE_RUN_TIME_STATS configurable in menuconfig.

- configQUEUE_REGISTRY_SIZE can now be set in menuconfig.
- The functions vQueueAddToRegistry() and vQueueUnregisterQueue() were made
  SMP compatbile
- pcQueueGetName() was backported from FreeRTOS v9.0.0
- Added test case for Queue Registry functions

- configGENERATE_RUN_TIME_STATS can now be enabled in menuconfig. CCOUNT or
  esp_timer can be selected as the FreeRTOS run time clock in menuconfig as
  well, although CCOUNT will overflow quickly.
- Run time stats collection (in vTaskSwitchContext) and generation (in
  uxTaskGetSystemState) have been made SMP compatible. Therefore
  vTaskGetRunTimeStats() now displays the run time usage of each task as a
  percentage of total runtime of both CPUs

Squash
2017-11-14 15:50:31 +08:00
8e180f6155 fatfs: update to R0.13a
- Remove ASCII-only configuration, CP437 is used instead
- Add dynamic code page configuration

See components/fatfs/src/00history.txt for FATFS changelog.
2017-11-14 12:57:55 +08:00
1d13b58c62 component/bt: Added the queue event when the gattc command is full. 2017-11-13 22:44:27 -05:00
38b287593c component/bt: fix not send indication confirm in case of server only 2017-11-14 11:43:57 +08:00
09d2791cfd Merge branch 'feature/spi_variable_len' into 'master'
feat(spi_master): add new feature allow use variable command and address field length for the same device.

See merge request !1322
2017-11-14 00:08:50 +08:00
31d0c8eec5 Merge branch 'feature/emac_apll' into 'master'
feat(emac): add support for emac to use internal (APLL) clock outputs.

See merge request !1518
2017-11-14 00:07:35 +08:00
5404252e80 Merge branch 'bugfix/uart_fifo_bug_workaround' into 'master'
bugfix(uart): workaround for uart fifo reset issue

See merge request !1499
2017-11-13 17:46:42 +08:00
3726cd39ab Merge branch 'bugfix/examples_ulp_gpio15' into 'master'
examples/ulp: disable pullup on GPIO15 to reduce current

See merge request !1486
2017-11-13 17:34:12 +08:00
4052803e16 bugfix(uart): workaround for uart fifo reset issue
Reported from github:
https://github.com/espressif/esp-idf/issues/1219
https://github.com/espressif/esp-idf/issues/1202

After providing a simple code to digital team, they confirmed that this is a hardware bug.

Root cause:
The fifo reset signal is incorrectly connected
If we want to reset tx fifo of UART2, we have to set txfifo_rst bit of both UART1 and UART2
If we want to reset rx fifo of UART2, we have to set rxfifo_rst bit of both UART1 and UART2

Workaround:
we don't use fifo rst bit in driver.

Documentation:
Digital team would update TRM and give more explanation about this issue.
2017-11-13 15:23:00 +08:00
2be5e73090 rebase the origin to the local 2017-11-13 02:20:02 -05:00
8352eb6fa2 component/bt: Added the prepare write check. 2017-11-13 02:12:33 -05:00
f324458b6a feat(emac): add support for emac to use internal (APLL) clock outputs. 2017-11-13 14:18:58 +08:00
48ca949fd4 lwip: fix socket close crash issue
When lwip_close free the socket resource (netconn etc), any work
related to these resource (netconn etc) must be aborted.
2017-11-13 06:00:52 +00:00
e64b9ecaf4 Merge branch 'bugfix/ut_only_test_app_core_sleep_on_dual_core' into 'master'
test: only test app core sleep on dual core

See merge request !1517
2017-11-13 13:35:07 +08:00
004c391591 Merge branch 'feature/adjust_task_stack_size_according_to_nano' into 'master'
esp32/lwip: adjust task stack size according 'nano' print

See merge request !1510
2017-11-13 11:18:20 +08:00
36692dbac7 docs: Add esp_wifi_types.h items to wifi API reference
Previously only items defined esp_wifi.h in esp_wifi_crypto_types.h
were including in documentation reference.
2017-11-10 11:00:44 -08:00
bd9c5d9adc Merge branch 'feature/fatfs_kconfig_options' into 'master'
fatfs: expose some configuration values in Kconfig

See merge request !1415
2017-11-11 02:48:15 +08:00
4468825028 Merge branch 'bugfix/TW#16106_esp_heap_trace.h_C++_include_guards' into 'master'
freertos/add C++ include guards for esp_heap_caps.h

See merge request !1516
2017-11-11 02:47:10 +08:00
be405d69d8 test: ut only test app core reset on dual core 2017-11-10 17:53:59 +08:00
e24ea6207b Merge branch 'bugfix/btdm_osi_alarm' into 'master'
component/bt: use esp_timer instead of FreeRTOS timer to implement osi_alarm in bluedroid

See merge request !1506
2017-11-10 15:34:11 +08:00
b8694eeeb9 Merge branch 'bugfix/tw16339_sta_cant_connect_ap_in_channel_14' into 'master'
Bugfix/tw16339 sta cant connect ap in channel 14

See merge request !1514
2017-11-10 15:31:19 +08:00
b1d13ded1a test: only test app core sleep on dual core 2017-11-10 13:26:11 +08:00
fff482acd9 freertos/add C++ include guards for esp_heap_caps.h 2017-11-10 12:01:30 +08:00
53273172fe component/bt: modify the implementation and interface of osi_alarm module
1. use esp_timer instead of FreeRTOS timer to implement osi_alarm in bluedroid
2. Remove two APIs: osi_alarm_now() and osi_alarm_time_diff() and modify the hci layer logic that use them
3. Implement osi_alarm_get_remaining_ms()
4. Move the definition of struct alarm_t in source file "alarm.c"
5. Add definition of module error code
2017-11-10 11:53:55 +08:00
7632c6a80c Merge branch 'test/UT_reset_check' into 'master'
Test/ut reset check

See merge request !1086
2017-11-10 11:30:46 +08:00
3eedf3ed18 Merge branch 'bugfix/to_docs_from_github' into 'master'
Documentation bugfixes from the github

See merge request !1501
2017-11-10 11:13:25 +08:00
d1f6030921 Merge branch 'bugfix/from_github' into 'master'
Bug fixes from Github

See merge request !1487
2017-11-10 11:13:04 +08:00
cfe1f4724c Merge branch 'bugfix/cas_for_pthread_once' into 'master'
pthread: Fix pthread_once to use atomic compare and set

See merge request !1497
2017-11-10 11:12:46 +08:00
2041ba9add esp32: fix station can't connect esp32 softap in channel 14
Channel 14 only supports HT20 while ESP32 softap channel 14 is HT40, fix it.
2017-11-10 10:55:08 +08:00
8e04b86153 Merge branch 'bugfix/tg_wdt_reboot_uart_garbage' into 'master'
bootloader: wait for UART FIFO to be empty before switching frequency

See merge request !1511
2017-11-09 17:14:13 +08:00
772824d478 Merge branch 'bugfix/core_voltage_80m_flash' into 'master'
soc/rtc: raise core voltage when 80MHz flash frequency is used

See merge request !1508
2017-11-09 15:35:12 +08:00
ee43527108 compoent/bt: Modify bta_gattc_utils.c The value pointer copy is overwritten when a write event occurs. 2017-11-09 14:47:11 +08:00
e6b2c19eea component/bt: Fix the write value not store in the queue command bug. 2017-11-09 14:47:11 +08:00
68833fe94c component/bt: Change the bta_gattc_pop_command_to_send function to static. 2017-11-09 14:47:11 +08:00
0ae5320f50 component/bt: Added the gattc command queue support. 2017-11-09 14:47:11 +08:00
7a27e3c74d component/bt: added the queue to store the gattc commands. 2017-11-09 14:47:11 +08:00
1ceef12238 compoent/bt: Modify bta_gattc_utils.c The value pointer copy is overwritten when a write event occurs. 2017-11-09 01:44:16 -05:00
4033a4bcda Merge branch 'feature/docs_update_i2c_api' into 'master'
I2C API documenation update

See merge request !1404
2017-11-09 14:10:41 +08:00
afa9a85396 bootloader: wait for UART FIFO to be empty before switching frequency 2017-11-09 13:17:58 +08:00
bb4838314c doc: Add internal links for chapters and fix typos
Used 'git grep -i -E "see *\`[^\`]+\`[^_]"' to find the invalid links
2017-11-09 11:45:13 +08:00
710055025e esp32/lwip: adjust task stack size according 'nano' print
1. Adjust tcpip/main/event/timer task stack size according 'nano' print
2. If 'nano' print is disabled the task stack size reduces 512 bytes
2017-11-09 10:09:42 +08:00
60f954448c I2C API documenation update 2017-11-08 23:38:29 +01:00
f22c681c1c soc/rtc: raise core voltage when 80MHz flash frequency is used
To achieve reliable operation with GD flash at 80MHz, need to raise
core voltage.
This causes the following current consumption increase:

At 80MHz: from 29mA to 33mA
At 160MHz: from 41mA to 47mA

Test conditions: 2 cores running code from IRAM, remaining peripherals
clock gated.
2017-11-08 21:13:02 +08:00
37169f0f10 Merge branch 'feature/illustrations_with_blockdiag' into 'master'
Implement ‘blockdiag - simple block-diagram image generator’ to illustrate docum…

See merge request !1495
2017-11-08 18:54:28 +08:00
793ea56204 Merge branch 'bugfix/fail_to_scan_all_matched_ap' into 'master'
Wifi: bugfix/fail_to_scan_all_matched_ap

See merge request !1493
2017-11-08 17:39:29 +08:00
8ca40818eb component/bt: Fix the write value not store in the queue command bug. 2017-11-08 04:23:12 -05:00
27c1fc52ba Added .command_timeout_ms = 0 to SDSPI_HOST_DEFAULT() too 2017-11-08 12:52:50 +08:00
c6f7a38536 CI: support customize test with @bot 2017-11-08 11:36:16 +08:00
9cee2f9558 Linked API reference of 'Application Level Tracing' with description in the 'API Guides' 2017-11-07 20:27:19 +01:00
264315ab81 Fix markdown and format of GPIO example README
Fixed headers so they work (requires space between hash and text) and have a sensible structure and removed trailing spaces.

Signed-off-by: krzychb
2017-11-07 20:27:10 +01:00
05c4a76202 Fix reference to partition table documentation
… and link to it.

Signed-off-by: krzychb
2017-11-07 20:26:46 +01:00
a106dc183d Clean up documentation of esp_wifi_set_country
Signed-off-by: krzychb
2017-11-07 20:26:22 +01:00
3a1521f965 Implement ‘blockdiag - simple block-diagram image generator’ to illustrate documentation with block diagrams, sequence diagrams, activity diagrams and logical network diagrams 2017-11-07 18:17:53 +01:00
d78ba789cf Merge branch 'feature/unit-tests-psram' into 'master'
unit tests: add psram configuration

See merge request !1488
2017-11-07 20:11:54 +08:00
dfe4e68cc3 Merge branch 'bugfix/btdm_lib_update_for_psram' into 'master'
component/bt: update toolchain and add compile options to build libbtdm_app.a to support PSRAM

See merge request !1491
2017-11-07 20:01:14 +08:00
5f9ac5fadb Merge branch 'doc/freertos_port_comments' into 'master'
freertos: Update comments in "port" section (portMUX/etc)

See merge request !1431
2017-11-07 19:31:21 +08:00
744896bde2 Merge branch 'bugfix/hardware_mpi_sign' into 'master'
hwcrypto mpi: Fix losing sign when multiplying by -1 (github PR)

Contribution from github: https://github.com/espressif/esp-idf/pull/1181/

See merge request !1471
2017-11-07 19:30:31 +08:00
158ecdcfd5 pthread: Fix pthread_once to use atomic compare and set
Earlier recursive mutex was being used for this but since
SCOMPARE1 is already being saved/restored during context
switch, atomic compare and set can be used for this.

Signed-off-by: Mahavir Jain <mahavir@espressif.com>
2017-11-07 14:28:43 +05:30
016a49f8e3 component/bt: update toolchain and add compile options to build libbtdm_app.a to support PSRAM 2017-11-07 16:08:47 +08:00
f80824a2d8 test: support test for UT cases expect to reset 2017-11-07 12:19:39 +08:00
1613044aef Merge branch 'bugfix/restart_reconfigure_flash_pins' into 'master'
esp32: reconfigure SPI flash pins in esp_restart

See merge request !1492
2017-11-07 12:08:52 +08:00
a45e9c806d Merge branch 'bugfix/new_task_watchdog_API_false_trigger' into 'master'
feat/New Task Watchdog API

See merge request !1380
2017-11-07 10:43:56 +08:00
777c90789d Merge branch 'feature/FreeRTOS_SMP_unit_tests' into 'master'
feature: Add unit tests for freertos untested functions

See merge request !1308
2017-11-07 10:39:51 +08:00
092e99c05d Wifi: bugfix/fail_to_scan_all_matched_ap
fail to scan all matched ap in fast scan mode
2017-11-06 21:31:45 +08:00
5f6be9b4ce esp32: reconfigure SPI flash pins in esp_restart 2017-11-06 16:44:26 +08:00
637ba2e8bb freertos: Test untested functions
Test cases were added for the following functions
- xTaskNotify(), xTaskNotifyGive(), xTaskNotifyFromISR(), vTaskNotifyGiveFromISR(),
- xTaskNotifyWait(), ulTaskNotifyTake()
- vTaskDelayUntil()

The following function was made smp compatible and tested as well
- eTaskGetState()
2017-11-06 15:31:01 +08:00
3ace8416b5 [examples] Create HTTP2 example with http2.golang.org
Intention is to partition the demo into multiple files, so that the
main program is quite easy to follow.
1. connectlib.c: For any URL parsing and TCP connection related stuff
2. sh2lib.c: Convenience functions for HTTP2+TLS. The goal here is to
   expose a simpler API than nghttp2. If most usecases end up being
   served with this library, it could potentially be moved into a separate
   component
2017-11-06 09:43:03 +05:30
6b420b2452 unit tests: add psram configuration 2017-11-06 11:23:15 +08:00
20ccec1061 Disable all UART CLKs that are not console 2017-11-03 19:03:00 +08:00
dec4a868d0 examples/ulp: disable pullup on GPIO15 to reduce current
Also increase sampling frequency in ulp_adc example and update READMEs.

Fixes https://github.com/espressif/esp-idf/issues/1108
2017-11-03 18:56:31 +08:00
d72bef02e9 Added .command_timeout_ms = 0 to SDMMC_HOST_DEFAULT() in components/driver/include/driver/sdmmc_host.h 2017-11-03 17:15:44 +08:00
6e24566186 components/mdns: wrong Message compression detect
Old behavior assumes message compressed when any of 2 most significant bits are set,
But in fact Message compressed only when both those bits are set to 1.

Also maximal label length should be 63 bytes.
2017-11-03 16:52:22 +08:00
5827fd8c71 idf_monitor: Fixed a bug where pressing a key that doesn't encode into
a proper ASCII character, terminated the monitor with an exception
2017-11-03 16:47:30 +08:00
8712fd3ccf Update esp_err.h
Renamed the internal rc to __err_rc to avoid clashes with local variables.
This code would not do the expected thing with the original ESP_ERROR_CHECK macro:

esp_err_t my_func(esp_err_t x)
{
  assert(x == 23);
}

esp_err_t rc = 23; //some value that is important fo the user
ESP_ERROR_CHECK(my_func(rc));

The macro will expand to:
esp_err_t rc = (my_func(rc));

And the code will assert, as my_func will receive a random value - whatever is in the internal macro rc temp variable. This is due to the C weirdness of allowing this code:

int x = x; //x has a random value.
2017-11-03 16:45:28 +08:00
a0cedb1f44 Fix type conversion error in components/lwip/api/pppapi.c
Pointer tcpip_api_call *m  should be converted to pppapi_msg* instead of pppapi_msg_msg*
in pppapi_do_ppp_set_default(), pppapi_do_ppp_free() and so on.

It solve this issue https://github.com/espressif/esp-idf/pull/1028
so there is no need to patch ip4.c because now netif_defauilt is setted correctly.
Also it prevents memory corruption when pppapi_free() is called.
2017-11-03 16:42:56 +08:00
58b411a5fe fix makefile for multiple source files 2017-11-03 16:40:15 +08:00
9a96187655 Component/bt: modify some log 2017-11-02 19:45:13 +08:00
9d63e1da4a New Task Watchdog API (Revert of Revert)
This commit reverts the revert on the new task watchdog API. It also
fixes the following bug which caused the reversion.

- sdkconfig TASK_WDT_TIMEOUT_S has been reverted from the unit of ms back to the
unit of seconds. Fixes bug where projects using the new API without rebuilding sdkconfig
would cause the old default value of 5 to be interpreted in ms.

This commit also adds the following features to the task watchdog

- Updated idle hook registration to be compatible with dual core hooks

- Updated dual core hooks to support deregistration for cpu

- Legacy mode has been removed and esp_task_wdt_feed() is now replaced by
  esp_task_wdt_reset().  esp_task_wdt_feed() is deprecated

- Idle hooks to reset are now registered/deregistered when the idle tasks are
  added/deleted from the Task Watchdog instead of at Task Watchdog init/deinit

- Updated example
2017-11-02 16:47:51 +08:00
b65f47c586 [openssl] Add support for SNI (sending the hostname) 2017-10-31 16:57:38 +05:30
3420baa01b [openssl] Add support for defining ALPN protocols 2017-10-31 16:57:38 +05:30
de61c096a1 Fix COMPONENT_DEPENDS 2017-10-31 17:29:20 +09:00
0330ec270a feat(spi_master): add new feature allow use variable command and address field length for the same device.
Closes #654
2017-10-30 19:33:41 +08:00
5405255928 Fix losing sign when multiplying by -1 2017-10-28 03:47:00 +03:00
b10e1a92b6 freertos: Update comments in "port" section (portMUX/etc)
Some comments had fallen out of date.
2017-10-20 11:17:44 +08:00
07c44d7f01 fatfs: expose some configuration values in Kconfig
- _FS_TINY: disables per-file caches
- _FS_TIMEOUT: locking timeout for concurrent access
- _FS_LOCK: prevents operations which are not allowed on open files

Also sets _MAX_SS based on sector size configured for wear_levelling.
This reduces memory usage of FATFS if wear_levelling is using 512 byte
sectors.
2017-10-17 18:43:46 +08:00
14fe6e9bbb merge from master 2017-10-16 14:19:29 +07:00
e02ff1ed89 component/bt: Change the bta_gattc_pop_command_to_send function to static. 2017-10-10 03:12:00 -04:00
3d3bcd6275 component/bt: Added the gattc command queue support. 2017-09-30 13:59:14 +08:00
fb93a59619 component/bt: added the queue to store the gattc commands. 2017-09-30 13:59:14 +08:00
527 changed files with 44712 additions and 42662 deletions

34
.editorconfig Normal file
View File

@ -0,0 +1,34 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[{*.md,*.rst}]
trim_trailing_whitespace = false
[{Makefile,*.mk,*.bat}]
indent_style = tab
indent_size = 2
[*/freertos/**]
indent_style = tab
indent_size = 4
[{*/freertos/**.S,**/FreeRTOSConfig.h}]
indent_style = space
indent_size = 4
[*.pem]
insert_final_newline = false
[*.py]
max_line_length = 119

View File

@ -26,8 +26,16 @@ variables:
# IDF environment
IDF_PATH: "$CI_PROJECT_DIR"
APPLY_BOT_FILTER_SCRIPT: "$CI_PROJECT_DIR/tools/ci/apply_bot_filter.py"
CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py"
# before each job, we need to check if this job is filtered by bot stage/job filter
.apply_bot_filter: &apply_bot_filter
python $APPLY_BOT_FILTER_SCRIPT || exit 0
before_script:
# apply bot filter in before script
- *apply_bot_filter
# add gitlab ssh key
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
@ -46,11 +54,15 @@ before_script:
.do_nothing_before:
before_script: &do_nothing_before
# apply bot filter in before script
- *apply_bot_filter
- echo "Not setting up GitLab key, not fetching submodules"
- source tools/ci/configure_ci_environment.sh
.add_gitlab_key_before:
before_script: &add_gitlab_key_before
# apply bot filter in before script
- *apply_bot_filter
- echo "Not fetching submodules"
- source tools/ci/configure_ci_environment.sh
# add gitlab ssh key
@ -75,7 +87,7 @@ build_template_app:
# Try to use the same branch name for esp-idf-template that we're
# using on esp-idf. If it doesn't exist then just stick to the default
# branch
- git checkout ${CI_COMMIT_REF_NAME} || echo "Using esp-idf-template default branch..."
- python $CHECKOUT_REF_SCRIPT esp-idf-template
# Test debug build (default)
- make all V=1
# Now test release build
@ -97,17 +109,29 @@ build_template_app:
BATCH_BUILD: "1"
V: "0"
build_ssc:
.build_ssc_template: &build_ssc_template
<<: *build_template
artifacts:
paths:
- SSC/ssc_bin
expire_in: 6 mos
expire_in: 1 mos
variables:
SSC_CONFIG_FOLDER: "$CI_PROJECT_DIR/SSC/configs/ESP32_IDF"
script:
- git clone $SSC_REPOSITORY
- cd SSC
- git checkout ${CI_COMMIT_REF_NAME} || echo "Using SSC default branch..."
- MAKEFLAGS= ./gen_misc_ng.sh
- python $CHECKOUT_REF_SCRIPT SSC
- MAKEFLAGS= ./ci_build_ssc.sh "${CI_JOB_NAME}" "${IDF_PATH}/.gitlab-ci.yml"
# don't forget to add to dependency to test_template when adding new build_ssc jobs
build_ssc_00:
<<: *build_ssc_template
build_ssc_01:
<<: *build_ssc_template
build_ssc_02:
<<: *build_ssc_template
build_esp_idf_tests:
<<: *build_template
@ -129,15 +153,18 @@ build_esp_idf_tests:
.build_examples_template: &build_examples_template
<<: *build_template
artifacts:
when: always
paths:
- build_examples/*/*/*/build/*.bin
- build_examples/*/*/*/build/*.elf
- build_examples/*/*/*/build/*.map
- build_examples/*/*/*/build/download.config
- build_examples/*/*/*/build/bootloader/*.bin
- $LOG_PATH
expire_in: 1 week
variables:
IDF_CI_BUILD: "1"
LOG_PATH: "$CI_PROJECT_DIR/log_examples"
script:
# it's not possible to build 100% out-of-tree and have the "artifacts"
# mechanism work, but this is the next best thing
@ -145,6 +172,7 @@ build_esp_idf_tests:
- mkdir build_examples
- cd build_examples
# build some of examples
- mkdir -p ${LOG_PATH}
- ${IDF_PATH}/tools/ci/build_examples.sh "${CI_JOB_NAME}"
build_examples_00:
@ -168,6 +196,10 @@ build_examples_05:
build_examples_06:
<<: *build_examples_template
build_examples_07:
<<: *build_examples_template
build_docs:
stage: build
image: $CI_DOCKER_REGISTRY/esp32-ci-env
@ -230,7 +262,7 @@ test_multi_heap_on_host:
- wl_host_test
script:
- cd components/heap/test_multi_heap_host
- make test
- ./test_all_configs.sh
test_build_system:
stage: test
@ -281,6 +313,7 @@ test_report:
# clone test bench
- git clone $GITLAB_SSH_SERVER/yinling/auto_test_script.git
- cd auto_test_script
- python $CHECKOUT_REF_SCRIPT auto_test_script
# generate report
- TEST_RESULT=Pass
- python CITestReport.py -l $LOG_PATH -t $TEST_CASE_FILE_PATH -p $REPORT_PATH -r $RESULT_PATH -a $ARTIFACTS_PATH -m $MODULE_UPDATE_FILE || TEST_RESULT=Fail
@ -421,7 +454,7 @@ assign_test:
EXAMPLE_CONFIG_OUTPUT_PATH: "$CI_PROJECT_DIR/examples/test_configs"
artifacts:
paths:
- test_bins
- $OUTPUT_BIN_PATH
- components/idf_test/*/CIConfigs
- components/idf_test/*/TC.sqlite
- $EXAMPLE_CONFIG_OUTPUT_PATH
@ -438,11 +471,11 @@ assign_test:
# clone test script to assign tests
- git clone $TEST_SCRIPT_REPOSITORY
- cd auto_test_script
- git checkout ${CI_COMMIT_REF_NAME} || echo "Using default branch..."
- python $CHECKOUT_REF_SCRIPT auto_test_script
# assign unit test cases
- python CIAssignTestCases.py -t $IDF_PATH/components/idf_test/unit_test -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/test_bins
# assgin integration test cases
- python CIAssignTestCases.py -t $IDF_PATH/components/idf_test/integration_test -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/test_bins
- python CIAssignTestCases.py -t $IDF_PATH/components/idf_test/integration_test -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/SSC/ssc_bin
.example_test_template: &example_test_template
stage: test
@ -483,6 +516,9 @@ assign_test:
allow_failure: true
dependencies:
- assign_test
- build_ssc_00
- build_ssc_01
- build_ssc_02
artifacts:
when: always
paths:
@ -500,10 +536,12 @@ assign_test:
- test -e $CONFIG_FILE || exit 0
# clone local test env configs
- git clone $TEST_ENV_CONFIG_REPOSITORY
- cd ci-test-runner-configs
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs
# clone test bench
- git clone $TEST_SCRIPT_REPOSITORY
- cd auto_test_script
- git checkout ${CI_COMMIT_REF_NAME} || echo "Using default branch..."
- python $CHECKOUT_REF_SCRIPT auto_test_script
# run test
- python CIRunner.py -l "$LOG_PATH/$CI_JOB_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH -m $MODULE_UPDATE_FILE
@ -533,6 +571,8 @@ nvs_compatible_test:
script:
# clone local test env configs
- git clone $TEST_ENV_CONFIG_REPOSITORY
- cd ci-test-runner-configs
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs
# clone test bench
- git clone $TEST_SCRIPT_REPOSITORY
- cd auto_test_script
@ -604,6 +644,13 @@ UT_001_08:
- UT_T1_1
- UT_default
UT_001_09:
<<: *unit_test_template
tags:
- ESP32_IDF
- UT_T1_1
- UT_default
UT_002_01:
<<: *unit_test_template
tags:
@ -660,6 +707,13 @@ UT_002_08:
- UT_T1_1
- UT_release
UT_002_09:
<<: *unit_test_template
tags:
- ESP32_IDF
- UT_T1_1
- UT_release
UT_003_01:
<<: *unit_test_template
tags:
@ -716,6 +770,76 @@ UT_003_08:
- UT_T1_1
- UT_single_core
UT_003_09:
<<: *unit_test_template
tags:
- ESP32_IDF
- UT_T1_1
- UT_single_core
UT_004_01:
<<: *unit_test_template
tags:
- ESP32_IDF
- UT_T1_1
- UT_psram
UT_004_02:
<<: *unit_test_template
tags:
- ESP32_IDF
- UT_T1_1
- UT_psram
UT_004_03:
<<: *unit_test_template
tags:
- ESP32_IDF
- UT_T1_1
- UT_psram
UT_004_04:
<<: *unit_test_template
tags:
- ESP32_IDF
- UT_T1_1
- UT_psram
UT_004_05:
<<: *unit_test_template
tags:
- ESP32_IDF
- UT_T1_SDMODE
- UT_psram
UT_004_06:
<<: *unit_test_template
tags:
- ESP32_IDF
- UT_T1_SPIMODE
- UT_psram
UT_004_07:
<<: *unit_test_template
tags:
- ESP32_IDF
- UT_T1_1
- UT_psram
UT_004_08:
<<: *unit_test_template
tags:
- ESP32_IDF
- UT_T1_1
- UT_psram
UT_004_09:
<<: *unit_test_template
tags:
- ESP32_IDF
- UT_T1_1
- UT_psram
IT_001_01:
<<: *test_template
tags:

4
.gitmodules vendored
View File

@ -33,3 +33,7 @@
[submodule "components/spiffs/spiffs"]
path = components/spiffs/spiffs
url = https://github.com/pellepl/spiffs.git
[submodule "components/json/cJSON"]
path = components/json/cJSON
url = https://github.com/DaveGamble/cJSON.git

49
Kconfig
View File

@ -93,7 +93,7 @@ config OPTIMIZATION_ASSERTIONS_DISABLED
endchoice # assertions
config CXX_EXCEPTIONS
menuconfig CXX_EXCEPTIONS
bool "Enable C++ exceptions"
default n
help
@ -102,8 +102,51 @@ config CXX_EXCEPTIONS
Disabling this option disables C++ exception support in all compiled files, and any libstdc++ code which throws
an exception will abort instead.
Enabling this option currently adds an additional 20KB of heap overhead, and 4KB of additional heap is allocated
the first time an exception is thrown in user code.
Enabling this option currently adds an additional ~500 bytes of heap overhead
when an exception is thrown in user code for the first time.
config CXX_EXCEPTIONS_EMG_POOL_SIZE
int "Emergency Pool Size"
default 0
depends on CXX_EXCEPTIONS
help
Size (in bytes) of the emergency memory pool for C++ exceptions. This pool will be used to allocate
memory for thrown exceptions when there is not enough memory on the heap.
choice STACK_CHECK_MODE
prompt "Stack smashing protection mode"
default STACK_CHECK_NONE
help
Stack smashing protection mode. Emit extra code to check for buffer overflows, such as stack
smashing attacks. This is done by adding a guard variable to functions with vulnerable objects.
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.
Modes have the following impact on code performance and coverage:
- performance: NORMAL > STRONG > OVERALL
- coverage: NORMAL < STRONG < OVERALL
config STACK_CHECK_NONE
bool "None"
config STACK_CHECK_NORM
bool "Normal"
config STACK_CHECK_STRONG
bool "Strong"
config STACK_CHECK_ALL
bool "Overall"
endchoice
config STACK_CHECK
bool
default !STACK_CHECK_NONE
help
Stack smashing protection.
endmenu # Compiler Options

View File

@ -96,7 +96,7 @@ The simplest way to use the partition table is to `make menuconfig` and choose o
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/partition-tables.rst` file.
For more details about partition tables and how to create custom variations, view the [`docs/api-guides/partition-tables.rst`](docs/api-guides/partition-tables.rst) file.
## Erasing Flash

View File

@ -64,33 +64,37 @@ config SYSVIEW_ENABLE
Enables supporrt for SEGGER SystemView tracing functionality.
choice SYSVIEW_TS_SOURCE
prompt "ESP32 timer to use as SystemView timestamp source"
prompt "Timer to use as timestamp source"
depends on SYSVIEW_ENABLE
default SYSVIEW_TS_SOURCE_TIMER_00
default SYSVIEW_TS_SOURCE_CCOUNT if FREERTOS_UNICORE && !PM_ENABLE
default SYSVIEW_TS_SOURCE_TIMER_00 if !FREERTOS_UNICORE && !PM_ENABLE
default SYSVIEW_TS_SOURCE_ESP_TIMER if PM_ENABLE
help
SystemView needs to use a hardware timer as the source of timestamps
when tracing
This option selects HW timer for it.
when tracing. This option selects the timer for it.
config SYSVIEW_TS_SOURCE_CCOUNT
bool "CPU cycle counter (CCOUNT)"
depends on FREERTOS_UNICORE && !PM_ENABLE
config SYSVIEW_TS_SOURCE_TIMER_00
bool "Timer 0, Group 0"
help
Select this to use timer 0 of group 0
depends on !PM_ENABLE
config SYSVIEW_TS_SOURCE_TIMER_01
bool "Timer 1, Group 0"
help
Select this to use timer 1 of group 0
depends on !PM_ENABLE
config SYSVIEW_TS_SOURCE_TIMER_10
bool "Timer 0, Group 1"
help
Select this to use timer 0 of group 1
depends on !PM_ENABLE
config SYSVIEW_TS_SOURCE_TIMER_11
bool "Timer 1, Group 1"
help
Select this to use timer 1 of group 1
depends on !PM_ENABLE
config SYSVIEW_TS_SOURCE_ESP_TIMER
bool "esp_timer high resolution timer"
endchoice

View File

@ -64,9 +64,6 @@ Revision: $Rev: 3734 $
#include "freertos/FreeRTOS.h"
#include "SEGGER_SYSVIEW.h"
#include "rom/ets_sys.h"
#if CONFIG_FREERTOS_UNICORE == 0
#include "driver/timer.h"
#endif
#include "esp_app_trace.h"
#include "esp_app_trace_util.h"
#include "esp_intr_alloc.h"
@ -86,10 +83,49 @@ extern const SEGGER_SYSVIEW_OS_API SYSVIEW_X_OS_TraceAPI;
// The target device name
#define SYSVIEW_DEVICE_NAME "ESP32"
// Determine which timer to use as timestamp source
#if CONFIG_SYSVIEW_TS_SOURCE_CCOUNT
#define TS_USE_CCOUNT 1
#elif CONFIG_SYSVIEW_TS_SOURCE_ESP_TIMER
#define TS_USE_ESP_TIMER 1
#else
#define TS_USE_TIMERGROUP 1
#endif
#if TS_USE_TIMERGROUP
#include "driver/timer.h"
// Timer group timer divisor
#define SYSVIEW_TIMER_DIV 2
// Frequency of the timestamp.
#define SYSVIEW_TIMESTAMP_FREQ (esp_clk_apb_freq() / SYSVIEW_TIMER_DIV)
// Timer ID and group ID
#if defined(CONFIG_SYSVIEW_TS_SOURCE_TIMER_00) || defined(CONFIG_SYSVIEW_TS_SOURCE_TIMER_01)
#define TS_TIMER_ID 0
#else
#define TS_TIMER_ID 1
#endif // TIMER_00 || TIMER_01
#if defined(CONFIG_SYSVIEW_TS_SOURCE_TIMER_00) || defined(CONFIG_SYSVIEW_TS_SOURCE_TIMER_10)
#define TS_TIMER_GROUP 0
#else
#define TS_TIMER_GROUP 1
#endif // TIMER_00 || TIMER_10
#endif // TS_USE_TIMERGROUP
#if TS_USE_ESP_TIMER
// esp_timer provides 1us resolution
#define SYSVIEW_TIMESTAMP_FREQ (1000000)
#endif // TS_USE_ESP_TIMER
#if TS_USE_CCOUNT
// CCOUNT is incremented at CPU frequency
#define SYSVIEW_TIMESTAMP_FREQ (CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ * 1000000)
#endif // TS_USE_CCOUNT
// System Frequency.
#define SYSVIEW_CPU_FREQ (esp_clk_cpu_freq())
@ -103,11 +139,8 @@ extern const SEGGER_SYSVIEW_OS_API SYSVIEW_X_OS_TraceAPI;
#define SYSTICK_INTR_ID (ETS_INTERNAL_TIMER1_INTR_SOURCE+ETS_INTERNAL_INTR_SOURCE_OFF)
#endif
static timer_idx_t s_ts_timer_idx;
static timer_group_t s_ts_timer_group;
// SystemView is single core specific: it implies that SEGGER_SYSVIEW_LOCK()
// disables IRQs (disables rescheduling globaly). So we can not use finite timeouts for locks and return error
// disables IRQs (disables rescheduling globally). So we can not use finite timeouts for locks and return error
// in case of expiration, because error will not be handled and SEGGER's code will go further implying that
// everything is fine, so for multi-core env we have to wait on underlying lock forever
#define SEGGER_LOCK_WAIT_TMO ESP_APPTRACE_TMO_INFINITE
@ -213,35 +246,24 @@ static void _cbSendSystemDesc(void) {
*/
static void SEGGER_SYSVIEW_TS_Init()
{
timer_config_t config;
#if CONFIG_SYSVIEW_TS_SOURCE_TIMER_00
s_ts_timer_group = TIMER_GROUP_0;
s_ts_timer_idx = TIMER_0;
#endif
#if CONFIG_SYSVIEW_TS_SOURCE_TIMER_01
s_ts_timer_group = TIMER_GROUP_0;
s_ts_timer_idx = TIMER_1;
#endif
#if CONFIG_SYSVIEW_TS_SOURCE_TIMER_10
s_ts_timer_group = TIMER_GROUP_1;
s_ts_timer_idx = TIMER_0;
#endif
#if CONFIG_SYSVIEW_TS_SOURCE_TIMER_11
s_ts_timer_group = TIMER_GROUP_1;
s_ts_timer_idx = TIMER_1;
#endif
config.alarm_en = 0;
config.auto_reload = 0;
config.counter_dir = TIMER_COUNT_UP;
config.divider = SYSVIEW_TIMER_DIV;
config.counter_en = 0;
/*Configure timer*/
timer_init(s_ts_timer_group, s_ts_timer_idx, &config);
/*Load counter value */
timer_set_counter_value(s_ts_timer_group, s_ts_timer_idx, 0x00000000ULL);
/*Enable timer interrupt*/
timer_start(s_ts_timer_group, s_ts_timer_idx);
/* We only need to initialize something if we use Timer Group.
* esp_timer and ccount can be used as is.
*/
#if TS_USE_TIMERGROUP
timer_config_t config = {
.alarm_en = 0,
.auto_reload = 0,
.counter_dir = TIMER_COUNT_UP,
.divider = SYSVIEW_TIMER_DIV,
.counter_en = 0
};
/* Configure timer */
timer_init(TS_TIMER_GROUP, TS_TIMER_ID, &config);
/* Load counter value */
timer_set_counter_value(TS_TIMER_GROUP, TS_TIMER_ID, 0x00000000ULL);
/* Start counting */
timer_start(TS_TIMER_GROUP, TS_TIMER_ID);
#endif // TS_USE_TIMERGROUP
}
void SEGGER_SYSVIEW_Conf(void) {
@ -296,12 +318,14 @@ void SEGGER_SYSVIEW_Conf(void) {
U32 SEGGER_SYSVIEW_X_GetTimestamp()
{
#if CONFIG_FREERTOS_UNICORE == 0
#if TS_USE_TIMERGROUP
uint64_t ts = 0;
timer_get_counter_value(s_ts_timer_group, s_ts_timer_idx, &ts);
return (U32)ts; // return lower part of counter value
#else
timer_get_counter_value(TS_TIMER_GROUP, TS_TIMER_ID, &ts);
return (U32) ts; // return lower part of counter value
#elif TS_USE_CCOUNT
return portGET_RUN_TIME_COUNTER_VALUE();
#elif TS_USE_ESP_TIMER
return (U32) esp_timer_get_time(); // return lower part of counter value
#endif
}

View File

@ -43,15 +43,24 @@ config BOOTLOADER_SPI_WP_PIN
The default value (GPIO 7) is correct for WP pin on ESP32-D2WD integrated flash.
config BOOTLOADER_VDDSDIO_BOOST
bool "Increase VDDSDIO LDO voltage to 1.9V"
default y
choice BOOTLOADER_VDDSDIO_BOOST
bool "VDDSDIO LDO voltage"
default BOOTLOADER_VDDSDIO_BOOST_1_9V
help
If this option is enabled, and VDDSDIO LDO is set to 1.8V (using EFUSE
or MTDI bootstrapping pin), bootloader will change LDO settings to
output 1.9V instead. This helps prevent flash chip from browning out
during flash programming operations.
For 3.3V flash, this option has no effect.
This option has no effect if VDDSDIO is set to 3.3V, or if the internal
VDDSDIO regulator is disabled via efuse.
config BOOTLOADER_VDDSDIO_BOOST_1_8V
bool "1.8V"
depends on !ESPTOOLPY_FLASHFREQ_80M
config BOOTLOADER_VDDSDIO_BOOST_1_9V
bool "1.9V"
endchoice
endmenu # Bootloader

View File

@ -121,4 +121,6 @@ endif
bootloader-clean: $(SDKCONFIG_MAKEFILE)
$(BOOTLOADER_MAKE) app-clean
ifdef CONFIG_SECURE_BOOTLOADER_REFLASHABLE
rm -f $(SECURE_BOOTLOADER_KEY) $(BOOTLOADER_DIGEST_BIN)
endif

View File

@ -10,6 +10,10 @@ PROJECT_NAME := bootloader
COMPONENTS := esptool_py bootloader_support log spi_flash micro-ecc soc main
# Clear C and CXX from top level project
CFLAGS =
CXXFLAGS =
#We cannot include the esp32 component directly but we need its includes.
CFLAGS += -I $(IDF_PATH)/components/esp32/include

View File

@ -48,6 +48,7 @@
#include "bootloader_flash.h"
#include "bootloader_random.h"
#include "bootloader_config.h"
#include "bootloader_clock.h"
#include "flash_qio_mode.h"
@ -75,7 +76,6 @@ static void set_cache_and_start_app(uint32_t drom_addr,
static void update_flash_config(const esp_image_header_t* pfhdr);
static void vddsdio_configure();
static void flash_gpio_configure();
static void clock_configure(void);
static void uart_console_configure(void);
static void wdt_reset_check(void);
@ -447,7 +447,7 @@ void bootloader_main()
{
vddsdio_configure();
flash_gpio_configure();
clock_configure();
bootloader_clock_configure();
uart_console_configure();
wdt_reset_check();
ESP_LOGI(TAG, "ESP-IDF %s 2nd stage bootloader", IDF_VER);
@ -743,14 +743,13 @@ static void print_flash_info(const esp_image_header_t* phdr)
static void vddsdio_configure()
{
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
if (cfg.tieh == 0) { // 1.8V is used
if (cfg.enable == 1 && cfg.tieh == 0) { // VDDSDIO regulator is enabled @ 1.8V
cfg.drefh = 3;
cfg.drefm = 3;
cfg.drefl = 3;
cfg.force = 1;
cfg.enable = 1;
rtc_vddsdio_set_config(cfg);
ets_delay_us(10); // wait for regulator to become stable
}
@ -797,24 +796,20 @@ static void IRAM_ATTR flash_gpio_configure()
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5) {
// For ESP32D2WD the SPI pins are already configured
ESP_LOGI(TAG, "Detected ESP32D2WD");
//flash clock signal should come from IO MUX.
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2) {
// For ESP32PICOD2 the SPI pins are already configured
ESP_LOGI(TAG, "Detected ESP32PICOD2");
//flash clock signal should come from IO MUX.
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) {
// For ESP32PICOD4 the SPI pins are already configured
ESP_LOGI(TAG, "Detected ESP32PICOD4");
//flash clock signal should come from IO MUX.
// flash clock signal should come from IO MUX.
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
} else {
ESP_LOGI(TAG, "Detected ESP32");
const uint32_t spiconfig = ets_efuse_get_spiconfig();
if (spiconfig == EFUSE_SPICONFIG_SPI_DEFAULTS) {
gpio_matrix_out(FLASH_CS_IO, SPICS0_OUT_IDX, 0, 0);
@ -840,39 +835,6 @@ static void IRAM_ATTR flash_gpio_configure()
}
}
static void clock_configure(void)
{
/* Set CPU to 80MHz. Keep other clocks unmodified. */
rtc_cpu_freq_t cpu_freq = RTC_CPU_FREQ_80M;
/* On ESP32 rev 0, switching to 80MHz if clock was previously set to
* 240 MHz may cause the chip to lock up (see section 3.5 of the errata
* document). For rev. 0, switch to 240 instead if it was chosen in
* menuconfig.
*/
uint32_t chip_ver_reg = REG_READ(EFUSE_BLK0_RDATA3_REG);
if ((chip_ver_reg & EFUSE_RD_CHIP_VER_REV1_M) == 0 &&
CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ == 240) {
cpu_freq = RTC_CPU_FREQ_240M;
}
rtc_clk_config_t clk_cfg = RTC_CLK_CONFIG_DEFAULT();
clk_cfg.xtal_freq = CONFIG_ESP32_XTAL_FREQ;
clk_cfg.cpu_freq = cpu_freq;
clk_cfg.slow_freq = rtc_clk_slow_freq_get();
clk_cfg.fast_freq = rtc_clk_fast_freq_get();
rtc_clk_init(clk_cfg);
/* As a slight optimization, if 32k XTAL was enabled in sdkconfig, we enable
* it here. Usually it needs some time to start up, so we amortize at least
* part of the start up time by enabling 32k XTAL early.
* App startup code will wait until the oscillator has started up.
*/
#ifdef CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL
if (!rtc_clk_32k_enabled()) {
rtc_clk_32k_bootstrap();
}
#endif
}
static void uart_console_configure(void)
{
@ -885,8 +847,7 @@ static void uart_console_configure(void)
uartAttach();
ets_install_uart_printf();
// ROM bootloader may have put a lot of text into UART0 FIFO.
// Wait for it to be printed.
// Wait for UART FIFO to be empty.
uart_tx_wait_idle(0);
#if CONFIG_CONSOLE_UART_CUSTOM

View File

@ -0,0 +1,21 @@
// Copyright 2017 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
/** @brief Configure clocks for early boot
*
* Called by bootloader, or by the app if the bootloader version is old (pre v2.1).
*/
void bootloader_clock_configure(void);

View File

@ -0,0 +1,61 @@
// Copyright 2017 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.
#include "rom/uart.h"
#include "rom/rtc.h"
#include "soc/soc.h"
#include "soc/rtc.h"
#include "soc/dport_reg.h"
#include "soc/efuse_reg.h"
#include "soc/rtc_cntl_reg.h"
void bootloader_clock_configure()
{
// ROM bootloader may have put a lot of text into UART0 FIFO.
// Wait for it to be printed.
// This is not needed on power on reset, when ROM bootloader is running at
// 40 MHz. But in case of TG WDT reset, CPU may still be running at >80 MHZ,
// and will be done with the bootloader much earlier than UART FIFO is empty.
uart_tx_wait_idle(0);
/* Set CPU to 80MHz. Keep other clocks unmodified. */
rtc_cpu_freq_t cpu_freq = RTC_CPU_FREQ_80M;
/* On ESP32 rev 0, switching to 80MHz if clock was previously set to
* 240 MHz may cause the chip to lock up (see section 3.5 of the errata
* document). For rev. 0, switch to 240 instead if it was chosen in
* menuconfig.
*/
uint32_t chip_ver_reg = REG_READ(EFUSE_BLK0_RDATA3_REG);
if ((chip_ver_reg & EFUSE_RD_CHIP_VER_REV1_M) == 0 &&
CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ == 240) {
cpu_freq = RTC_CPU_FREQ_240M;
}
rtc_clk_config_t clk_cfg = RTC_CLK_CONFIG_DEFAULT();
clk_cfg.xtal_freq = CONFIG_ESP32_XTAL_FREQ;
clk_cfg.cpu_freq = cpu_freq;
clk_cfg.slow_freq = rtc_clk_slow_freq_get();
clk_cfg.fast_freq = rtc_clk_fast_freq_get();
rtc_clk_init(clk_cfg);
/* As a slight optimization, if 32k XTAL was enabled in sdkconfig, we enable
* it here. Usually it needs some time to start up, so we amortize at least
* part of the start up time by enabling 32k XTAL early.
* App startup code will wait until the oscillator has started up.
*/
#ifdef CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL
if (!rtc_clk_32k_enabled()) {
rtc_clk_32k_bootstrap();
}
#endif
}

View File

@ -23,7 +23,7 @@
*/
static const char *TAG = "bootloader_mmap";
static spi_flash_mmap_memory_t map;
static spi_flash_mmap_handle_t map;
const void *bootloader_mmap(uint32_t src_addr, uint32_t size)
{
@ -36,7 +36,8 @@ const void *bootloader_mmap(uint32_t src_addr, uint32_t size)
size += (src_addr - src_page);
esp_err_t err = spi_flash_mmap(src_page, size, SPI_FLASH_MMAP_DATA, &result, &map);
if (err != ESP_OK) {
result = NULL;
ESP_LOGE(TAG, "spi_flash_mmap failed: 0x%x", err);
return NULL;
}
return (void *)((intptr_t)result + (src_addr - src_page));
}

View File

@ -25,8 +25,6 @@
#include "esp_system.h"
#endif
const char *TAG = "boot_rng";
void bootloader_fill_random(void *buffer, size_t length)
{
uint8_t *buffer_bytes = (uint8_t *)buffer;

View File

@ -19,6 +19,7 @@
#include <esp_image_format.h>
#include <esp_secure_boot.h>
#include <esp_log.h>
#include <esp_spi_flash.h>
#include <bootloader_flash.h>
#include <bootloader_random.h>
#include <bootloader_sha.h>
@ -33,6 +34,9 @@ static const char *TAG = "esp_image";
/* Headroom to ensure between stack SP (at time of checking) and data loaded from flash */
#define STACK_LOAD_HEADROOM 32768
/* Mmap source address mask */
#define MMAP_ALIGNED_MASK 0x0000FFFF
#ifdef BOOTLOADER_BUILD
/* 64 bits of random data to obfuscate loaded RAM with, until verification is complete
(Means loaded code isn't executable until after the secure boot check.)
@ -48,6 +52,9 @@ static bool should_map(uint32_t load_addr);
/* Load or verify a segment */
static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segment_header_t *header, bool silent, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum);
/* split segment and verify if data_len is too long */
static esp_err_t process_segment_data(intptr_t load_addr, uint32_t data_addr, uint32_t data_len, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum);
/* Verify the main image header */
static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t *image, bool silent);
@ -291,7 +298,36 @@ static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segme
}
}
}
#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);
uint32_t offset_page = 0;
while (data_len >= free_page_count * SPI_FLASH_MMU_PAGE_SIZE) {
offset_page = ((data_addr & MMAP_ALIGNED_MASK) != 0)?1:0;
err = process_segment_data(load_addr, data_addr, (free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE, do_load, sha_handle, checksum);
if (err != ESP_OK) {
return err;
}
data_addr += (free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE;
data_len -= (free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE;
}
#endif
err = process_segment_data(load_addr, data_addr, data_len, do_load, sha_handle, checksum);
if (err != ESP_OK) {
return err;
}
return ESP_OK;
err:
if (err == ESP_OK) {
err = ESP_ERR_IMAGE_INVALID;
}
return err;
}
static esp_err_t process_segment_data(intptr_t load_addr, uint32_t data_addr, uint32_t data_len, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum)
{
const uint32_t *data = (const uint32_t *)bootloader_mmap(data_addr, data_len);
if(!data) {
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed",
@ -332,12 +368,6 @@ static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segme
bootloader_munmap(data);
return ESP_OK;
err:
if (err == ESP_OK) {
err = ESP_ERR_IMAGE_INVALID;
}
return err;
}
static esp_err_t verify_segment_header(int index, const esp_image_segment_header_t *segment, uint32_t segment_data_offs, bool silent)

View File

@ -113,6 +113,13 @@ config CLASSIC_BT_ENABLED
help
For now this option needs "SMP_ENABLE" to be set to yes
config A2DP_SINK_TASK_STACK_SIZE
int "A2DP sink (audio stream decoding) task stack size"
depends on CLASSIC_BT_ENABLED
default 2048
help
This affects the stack size of A2DP sink task which invokes the data callback function.
config GATTS_ENABLE
bool "Include GATT server module(GATTS)"
depends on BLUEDROID_ENABLED

View File

@ -27,7 +27,7 @@ esp_err_t esp_avrc_ct_register_callback(esp_avrc_ct_cb_t callback)
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (callback == NULL) {
return ESP_FAIL;
}
@ -43,7 +43,7 @@ esp_err_t esp_avrc_ct_init(void)
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_AVRC;
msg.act = BTC_AVRC_CTRL_API_INIT_EVT;
@ -60,7 +60,7 @@ esp_err_t esp_avrc_ct_deinit(void)
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_AVRC;
msg.act = BTC_AVRC_CTRL_API_DEINIT_EVT;
@ -70,12 +70,97 @@ esp_err_t esp_avrc_ct_deinit(void)
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}
esp_err_t esp_avrc_ct_send_set_player_value_cmd(uint8_t tl, uint8_t attr_id, uint8_t value_id)
{
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (tl >= 16 || attr_id > ESP_AVRC_PS_MAX_ATTR - 1) {
return ESP_FAIL;
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_AVRC;
msg.act = BTC_AVRC_CTRL_API_SET_PLAYER_SETTING_EVT;
btc_avrc_args_t arg;
memset(&arg, 0, sizeof(btc_avrc_args_t));
arg.ps_cmd.tl = tl;
arg.ps_cmd.attr_id = attr_id;
arg.ps_cmd.value_id = value_id;
/* Switch to BTC context */
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_avrc_args_t), NULL);
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}
esp_err_t esp_avrc_ct_send_register_notification_cmd(uint8_t tl, uint8_t event_id, uint32_t event_parameter)
{
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (tl >= 16 || event_id > ESP_AVRC_RN_MAX_EVT - 1) {
return ESP_FAIL;
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_AVRC;
msg.act = BTC_AVRC_NOTIFY_API_SND_REG_NOTIFY_EVT;
btc_avrc_args_t arg;
memset(&arg, 0, sizeof(btc_avrc_args_t));
arg.rn_cmd.tl = tl;
arg.rn_cmd.event_id = event_id;
arg.rn_cmd.event_parameter = event_parameter;
/* Switch to BTC context */
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_avrc_args_t), NULL);
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}
esp_err_t esp_avrc_ct_send_metadata_cmd(uint8_t tl, uint8_t attr_mask)
{
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (tl >= 16) {
return ESP_FAIL;
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_AVRC;
msg.act = BTC_AVRC_STATUS_API_SND_META_EVT;
btc_avrc_args_t arg;
memset(&arg, 0, sizeof(btc_avrc_args_t));
arg.md_cmd.tl = tl;
arg.md_cmd.attr_mask = attr_mask;
/* Switch to BTC context */
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_avrc_args_t), NULL);
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
}
esp_err_t esp_avrc_ct_send_passthrough_cmd(uint8_t tl, uint8_t key_code, uint8_t key_state)
{
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
return ESP_ERR_INVALID_STATE;
}
if (tl >= 16 || key_state > ESP_AVRC_PT_CMD_STATE_RELEASED) {
return ESP_FAIL;
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_AVRC;
@ -87,7 +172,7 @@ esp_err_t esp_avrc_ct_send_passthrough_cmd(uint8_t tl, uint8_t key_code, uint8_t
arg.pt_cmd.tl = tl;
arg.pt_cmd.key_code = key_code;
arg.pt_cmd.key_state = key_state;
/* Switch to BTC context */
bt_status_t stat = btc_transfer_context(&msg, &arg, sizeof(btc_avrc_args_t), NULL);
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;

View File

@ -16,7 +16,7 @@
#include "esp_bt_main.h"
#include "btc_task.h"
#include "btc_main.h"
#include "bt.h"
#include "esp_bt.h"
#include "future.h"
#include "allocator.h"

View File

@ -240,7 +240,8 @@ esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr,
if (ESP_BLE_IS_VALID_PARAM(min_conn_int, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) &&
ESP_BLE_IS_VALID_PARAM(max_conn_int, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) &&
ESP_BLE_IS_VALID_PARAM(supervision_tout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) &&
(slave_latency <= ESP_BLE_CONN_LATENCY_MAX || slave_latency == ESP_BLE_CONN_PARAM_UNDEF)) {
(slave_latency <= ESP_BLE_CONN_LATENCY_MAX || slave_latency == ESP_BLE_CONN_PARAM_UNDEF) &&
((supervision_tout * 10) >= ((1 + slave_latency) * ((max_conn_int * 5) >> 1))) && min_conn_int <= max_conn_int) {
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;

View File

@ -67,7 +67,7 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, bool is_direct)
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct)
{
btc_msg_t msg;
btc_ble_gattc_args_t arg;
@ -79,6 +79,7 @@ esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, b
msg.act = BTC_GATTC_ACT_OPEN;
arg.open.gattc_if = gattc_if;
memcpy(arg.open.remote_bda, remote_bda, ESP_BD_ADDR_LEN);
arg.open.remote_addr_type = remote_addr_type;
arg.open.is_direct = is_direct;
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);

View File

@ -138,9 +138,10 @@ esp_err_t esp_a2d_register_callback(esp_a2d_cb_t callback);
/**
* @brief Register A2DP sink data output function; For now the output is PCM data stream decoded
* from SBC format. This function should be called only after esp_bluedroid_enable()
* completes successfully
*
* from SBC format. This function should be called only after esp_bluedroid_enable()
* completes successfully, used only by A2DP sink. The callback is invoked in the context
* of A2DP sink task whose stack size is configurable through menuconfig
*
* @param[in] callback: A2DP data callback function
*
* @return

View File

@ -40,7 +40,9 @@ typedef enum {
ESP_AVRC_PT_CMD_STOP = 0x45, /*!< stop */
ESP_AVRC_PT_CMD_PAUSE = 0x46, /*!< pause */
ESP_AVRC_PT_CMD_FORWARD = 0x4B, /*!< forward */
ESP_AVRC_PT_CMD_BACKWARD = 0x4C /*!< backward */
ESP_AVRC_PT_CMD_BACKWARD = 0x4C, /*!< backward */
ESP_AVRC_PT_CMD_REWIND = 0x48, /*!< rewind */
ESP_AVRC_PT_CMD_FAST_FORWARD = 0x49 /*!< fast forward */
} esp_avrc_pt_cmd_t;
/// AVRC passthrough command state
@ -53,9 +55,73 @@ typedef enum {
typedef enum {
ESP_AVRC_CT_CONNECTION_STATE_EVT = 0, /*!< connection state changed event */
ESP_AVRC_CT_PASSTHROUGH_RSP_EVT = 1, /*!< passthrough response event */
ESP_AVRC_CT_MAX_EVT
ESP_AVRC_CT_METADATA_RSP_EVT = 2, /*!< metadata response event */
ESP_AVRC_CT_PLAY_STATUS_RSP_EVT = 3, /*!< play status response event */
ESP_AVRC_CT_CHANGE_NOTIFY_EVT = 4, /*!< notification event */
ESP_AVRC_CT_REMOTE_FEATURES_EVT = 5, /*!< feature of remote device indication event */
} esp_avrc_ct_cb_event_t;
/// AVRC metadata attribute mask
typedef enum {
ESP_AVRC_MD_ATTR_TITLE = 0x1, /*!< title of the playing track */
ESP_AVRC_MD_ATTR_ARTIST = 0x2, /*!< track artist */
ESP_AVRC_MD_ATTR_ALBUM = 0x4, /*!< album name */
ESP_AVRC_MD_ATTR_TRACK_NUM = 0x8, /*!< track position on the album */
ESP_AVRC_MD_ATTR_NUM_TRACKS = 0x10, /*!< number of tracks on the album */
ESP_AVRC_MD_ATTR_GENRE = 0x20, /*!< track genre */
ESP_AVRC_MD_ATTR_PLAYING_TIME = 0x40 /*!< total album playing time in miliseconds */
} esp_avrc_md_attr_mask_t;
/// AVRC event notification ids
typedef enum {
ESP_AVRC_RN_PLAY_STATUS_CHANGE = 0x01, /*!< track status change, eg. from playing to paused */
ESP_AVRC_RN_TRACK_CHANGE = 0x02, /*!< new track is loaded */
ESP_AVRC_RN_TRACK_REACHED_END = 0x03, /*!< current track reached end */
ESP_AVRC_RN_TRACK_REACHED_START = 0x04, /*!< current track reached start position */
ESP_AVRC_RN_PLAY_POS_CHANGED = 0x05, /*!< track playing position changed */
ESP_AVRC_RN_BATTERY_STATUS_CHANGE = 0x06, /*!< battery status changed */
ESP_AVRC_RN_SYSTEM_STATUS_CHANGE = 0x07, /*!< system status changed */
ESP_AVRC_RN_APP_SETTING_CHANGE = 0x08, /*!< application settings changed */
ESP_AVRC_RN_MAX_EVT
} esp_avrc_rn_event_ids_t;
/// AVRC player setting ids
typedef enum {
ESP_AVRC_PS_EQUALIZER = 0x01, /*!< equalizer, on or off */
ESP_AVRC_PS_REPEAT_MODE = 0x02, /*!< repeat mode */
ESP_AVRC_PS_SHUFFLE_MODE = 0x03, /*!< shuffle mode */
ESP_AVRC_PS_SCAN_MODE = 0x04, /*!< scan mode on or off */
ESP_AVRC_PS_MAX_ATTR
} esp_avrc_ps_attr_ids_t;
/// AVRC equalizer modes
typedef enum {
ESP_AVRC_PS_EQUALIZER_OFF = 0x1, /*!< equalizer OFF */
ESP_AVRC_PS_EQUALIZER_ON = 0x2 /*!< equalizer ON */
} esp_avrc_ps_eq_value_ids_t;
/// AVRC repeat modes
typedef enum {
ESP_AVRC_PS_REPEAT_OFF = 0x1, /*!< repeat mode off */
ESP_AVRC_PS_REPEAT_SINGLE = 0x2, /*!< single track repeat */
ESP_AVRC_PS_REPEAT_GROUP = 0x3 /*!< group repeat */
} esp_avrc_ps_rpt_value_ids_t;
/// AVRC shuffle modes
typedef enum {
ESP_AVRC_PS_SHUFFLE_OFF = 0x1, /*<! shuffle off */
ESP_AVRC_PS_SHUFFLE_ALL = 0x2, /*<! all trackes shuffle */
ESP_AVRC_PS_SHUFFLE_GROUP = 0x3 /*<! group shuffle */
} esp_avrc_ps_shf_value_ids_t;
/// AVRC scan modes
typedef enum {
ESP_AVRC_PS_SCAN_OFF = 0x1, /*!< scan off */
ESP_AVRC_PS_SCAN_ALL = 0x2, /*!< all tracks scan */
ESP_AVRC_PS_SCAN_GROUP = 0x3 /*!< group scan */
} esp_avrc_ps_scn_value_ids_t;
/// AVRC controller callback parameters
typedef union {
/**
@ -63,10 +129,9 @@ typedef union {
*/
struct avrc_ct_conn_stat_param {
bool connected; /*!< whether AVRC connection is set up */
uint32_t feat_mask; /*!< AVRC feature mask of remote device */
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
} conn_stat; /*!< AVRC connection status */
/**
* @brief ESP_AVRC_CT_PASSTHROUGH_RSP_EVT
*/
@ -75,6 +140,32 @@ typedef union {
uint8_t key_code; /*!< passthrough command code */
uint8_t key_state; /*!< 0 for PRESSED, 1 for RELEASED */
} psth_rsp; /*!< passthrough command response */
/**
* @brief ESP_AVRC_CT_METADATA_RSP_EVT
*/
struct avrc_ct_meta_rsp_param {
uint8_t attr_id; /*!< id of metadata attribute */
uint8_t *attr_text; /*!< attribute itself */
int attr_length; /*!< attribute character length */
} meta_rsp; /*!< metadata attributes response */
/**
* @brief ESP_AVRC_CT_CHANGE_NOTIFY_EVT
*/
struct avrc_ct_change_notify_param {
uint8_t event_id; /*!< id of AVRC event notification */
uint32_t event_parameter; /*!< event notification parameter */
} change_ntf; /*!< notifications */
/**
* @brief ESP_AVRC_CT_REMOTE_FEATURES_EVT
*/
struct avrc_ct_rmt_feats_param {
uint32_t feat_mask; /*!< AVRC feature mask of remote device */
esp_bd_addr_t remote_bda; /*!< remote bluetooth device address */
} rmt_feats; /*!< AVRC features discovered from remote SDP server */
} esp_avrc_ct_cb_param_t;
@ -88,9 +179,9 @@ typedef void (* esp_avrc_ct_cb_t)(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_p
/**
* @brief Register application callbacks to AVRCP module; for now only AVRCP Controller
* role is supported. This function should be called after esp_bluedroid_enable()
* role is supported. This function should be called after esp_bluedroid_enable()
* completes successfully
*
*
* @param[in] callback: AVRCP controller callback function
*
* @return
@ -107,7 +198,7 @@ esp_err_t esp_avrc_ct_register_callback(esp_avrc_ct_cb_t callback);
* @brief Initialize the bluetooth AVRCP controller module, This function should be called
* after esp_bluedroid_enable() completes successfully
*
* @return
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
@ -121,13 +212,57 @@ esp_err_t esp_avrc_ct_init(void);
* @brief De-initialize AVRCP controller module. This function should be called after
* after esp_bluedroid_enable() completes successfully
*
* @return
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*/
esp_err_t esp_avrc_ct_deinit(void);
/**
*
* @brief Send player application settings command to AVRCP target. This function should be called
* after ESP_AVRC_CT_CONNECTION_STATE_EVT is received and AVRCP connection is established.
*
* @param[in] tl : transaction label, 0 to 15, consecutive commands should use different values.
* @param[in] attr_id : player application setting attribute IDs from one of esp_avrc_ps_attr_ids_t
* @param[in] value_id : attribute value defined for the specific player application setting attribute
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*/
esp_err_t esp_avrc_ct_send_set_player_value_cmd(uint8_t tl, uint8_t attr_id, uint8_t value_id);
/**
* @brief Send register notification command to AVRCP target, This function should be called after
* ESP_AVRC_CT_CONNECTION_STATE_EVT is received and AVRCP connection is established
*
* @param[in] tl : transaction label, 0 to 15, consecutive commands should use different values.
* @param[in] event_id : id of events, e.g. ESP_AVRC_RN_PLAY_STATUS_CHANGE, ESP_AVRC_RN_TRACK_CHANGE, etc.
* @param[in] event_parameter : special parameters, eg. playback interval for ESP_AVRC_RN_PLAY_POS_CHANGED
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*/
esp_err_t esp_avrc_ct_send_register_notification_cmd(uint8_t tl, uint8_t event_id, uint32_t event_parameter);
/**
* @brief Send metadata command to AVRCP target, This function should be called after
* ESP_AVRC_CT_CONNECTION_STATE_EVT is received and AVRCP connection is established
*
* @param[in] tl : transaction label, 0 to 15, consecutive commands should use different values.
* @param[in] attr_mask : mask of attributes, e.g. ESP_AVRC_MD_ATTR_ID_TITLE | ESP_AVRC_MD_ATTR_ID_ARTIST.
*
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others
*/
esp_err_t esp_avrc_ct_send_metadata_cmd(uint8_t tl, uint8_t attr_mask);
/**
* @brief Send passthrough command to AVRCP target, This function should be called after
@ -138,7 +273,7 @@ esp_err_t esp_avrc_ct_deinit(void);
* @param[in] key_state : passthrough command key state, ESP_AVRC_PT_CMD_STATE_PRESSED or
* ESP_AVRC_PT_CMD_STATE_RELEASED
*
* @return
* @return
* - ESP_OK: success
* - ESP_INVALID_STATE: if bluetooth stack is not yet enabled
* - ESP_FAIL: others

View File

@ -51,6 +51,7 @@ typedef enum {
ESP_BT_STATUS_PEER_LE_DATA_LEN_UNSUPPORTED, /* relate to BTM_PEER_LE_DATA_LEN_UNSUPPORTED in btm_api.h */
ESP_BT_STATUS_CONTROL_LE_DATA_LEN_UNSUPPORTED,/* relate to BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED in btm_api.h */
ESP_BT_STATUS_ERR_ILLEGAL_PARAMETER_FMT, /* relate to HCI_ERR_ILLEGAL_PARAMETER_FMT in hcidefs.h */
ESP_BT_STATUS_MEMORY_FULL, /* relate to BT_STATUS_MEMORY_FULL in bt_def.h */
} esp_bt_status_t;

View File

@ -97,9 +97,11 @@ typedef enum {
ESP_GAP_BLE_CLEAR_BOND_DEV_COMPLETE_EVT, /*!< When clear the bond device clear complete, the event comes */
ESP_GAP_BLE_GET_BOND_DEV_COMPLETE_EVT, /*!< When get the bond device list complete, the event comes */
ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT, /*!< When read the rssi complete, the event comes */
ESP_GAP_BLE_ADD_WHITELIST_COMPLETE_EVT, /*!< When add or remove whitelist complete, the event comes */
ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT, /*!< When add or remove whitelist complete, the event comes */
ESP_GAP_BLE_EVT_MAX,
} esp_gap_ble_cb_event_t;
/// This is the old name, just for backwards compatibility
#define ESP_GAP_BLE_ADD_WHITELIST_COMPLETE_EVT ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT
/// Advertising data maximum length
#define ESP_BLE_ADV_DATA_LEN_MAX 31
@ -239,7 +241,7 @@ typedef struct {
uint8_t flag; /*!< Advertising flag of discovery mode, see BLE_ADV_DATA_FLAG detail */
} esp_ble_adv_data_t;
/// Ble scan type
/// Ble scan type
typedef enum {
BLE_SCAN_TYPE_PASSIVE = 0x0, /*!< Passive scan */
BLE_SCAN_TYPE_ACTIVE = 0x1, /*!< Active scan */
@ -249,7 +251,7 @@ typedef enum {
typedef enum {
BLE_SCAN_FILTER_ALLOW_ALL = 0x0, /*!< Accept all :
1. advertisement packets except directed advertising packets not addressed to this device (default). */
BLE_SCAN_FILTER_ALLOW_ONLY_WLST = 0x1, /*!< Accept only :
BLE_SCAN_FILTER_ALLOW_ONLY_WLST = 0x1, /*!< Accept only :
1. advertisement packets from devices where the advertisers address is in the White list.
2. Directed advertising packets which are not addressed for this device shall be ignored. */
BLE_SCAN_FILTER_ALLOW_UND_RPA_DIR = 0x2, /*!< Accept all :
@ -312,7 +314,7 @@ typedef struct
} esp_ble_penc_keys_t; /*!< The key type*/
/**
* @brief BLE CSRK keys
* @brief BLE CSRK keys
*/
typedef struct
{
@ -322,7 +324,7 @@ typedef struct
} esp_ble_pcsrk_keys_t; /*!< The pcsrk key type */
/**
* @brief BLE pid keys
* @brief BLE pid keys
*/
typedef struct
{
@ -354,7 +356,7 @@ typedef struct
} esp_ble_lcsrk_keys; /*!< The csrk key type */
/**
* @brief Structure associated with ESP_KEY_NOTIF_EVT
* @brief Structure associated with ESP_KEY_NOTIF_EVT
*/
typedef struct
{
@ -476,7 +478,7 @@ typedef enum {
typedef enum{
ESP_BLE_WHITELIST_REMOVE = 0X00, /*!< remove mac from whitelist */
ESP_BLE_WHITELIST_ADD = 0X01, /*!< add address to whitelist */
}esp_ble_wl_opration;
}esp_ble_wl_opration_t;
/**
* @brief Gap callback parameters union
*/
@ -486,7 +488,7 @@ typedef union {
*/
struct ble_adv_data_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate the set advertising data operation success status */
} adv_data_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT */
} adv_data_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT
*/
@ -520,7 +522,7 @@ typedef union {
*/
struct ble_adv_data_raw_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate the set raw advertising data operation success status */
} adv_data_raw_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT */
} adv_data_raw_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT
*/
@ -616,12 +618,12 @@ typedef union {
esp_bd_addr_t remote_addr; /*!< The remote device address */
} read_rssi_cmpl; /*!< Event parameter of ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_ADD_WHITELIST_COMPLETE_EVT
* @brief ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT
*/
struct ble_add_whitelist_cmpl_evt_param {
struct ble_update_whitelist_cmpl_evt_param {
esp_bt_status_t status; /*!< Indicate the add or remove whitelist operation success status */
esp_ble_wl_opration wl_opration; /*!< The value is ESP_BLE_WHITELIST_ADD if add address to whitelist operation success, ESP_BLE_WHITELIST_REMOVE if remove address from the whitelist operation success */
} add_whitelist_cmpl; /*!< Event parameter of ESP_GAP_BLE_ADD_WHITELIST_COMPLETE_EVT */
esp_ble_wl_opration_t wl_opration; /*!< The value is ESP_BLE_WHITELIST_ADD if add address to whitelist operation success, ESP_BLE_WHITELIST_REMOVE if remove address from the whitelist operation success */
} update_whitelist_cmpl; /*!< Event parameter of ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT */
} esp_ble_gap_cb_param_t;
/**
@ -983,7 +985,7 @@ int esp_ble_get_bond_device_num(void);
* Suggest that dev_num value equal to esp_ble_get_bond_device_num().
*
* @param[out] dev_list: an array(buffer) of `esp_ble_bond_dev_t` type. Use for storing the bonded devices address.
* The dev_list should be allocated by who call this API.
* The dev_list should be allocated by who call this API.
* @return - ESP_OK : success
* - other : failed
*

View File

@ -64,6 +64,7 @@ typedef enum {
ESP_GATTC_CONNECT_EVT = 40, /*!< When the ble physical connection is set up, the event comes */
ESP_GATTC_DISCONNECT_EVT = 41, /*!< When the ble physical connection disconnected, the event comes */
ESP_GATTC_READ_MUTIPLE_EVT = 42, /*!< When the ble characteristic or descriptor mutiple complete, the event comes */
ESP_GATTC_QUEUE_FULL_EVT = 43, /*!< When the gattc command queue full, the event comes */
} esp_gattc_cb_event_t;
@ -145,6 +146,7 @@ typedef union {
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
uint16_t handle; /*!< The Characteristic or descriptor handle */
uint16_t offset; /*!< The prepare write offset, this value is valid only when prepare write */
} write; /*!< Gatt client callback param of ESP_GATTC_WRITE_DESCR_EVT */
/**
@ -214,6 +216,15 @@ typedef union {
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
} disconnect; /*!< Gatt client callback param of ESP_GATTC_DISCONNECT_EVT */
/**
* @brief ESP_GATTC_QUEUE_FULL_EVT
*/
struct gattc_queue_full_evt_param {
esp_gatt_status_t status; /*!< Operation status */
uint16_t conn_id; /*!< Connection id */
bool is_full; /*!< The gattc command queue is full or not */
} queue_full; /*!< Gatt client callback param of ESP_GATTC_QUEUE_FULL_EVT */
} esp_ble_gattc_cb_param_t; /*!< GATT client callback parameter union type */
/**
@ -272,6 +283,7 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if);
*
* @param[in] gattc_if: Gatt client access interface.
* @param[in] remote_bda: remote device bluetooth device address.
* @param[in] remote_addr_type: remote device bluetooth device the address type.
* @param[in] is_direct: direct connection or background auto connection
*
* @return
@ -279,7 +291,7 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if);
* - other: failed
*
*/
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, bool is_direct);
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct);
/**

View File

@ -162,7 +162,7 @@ typedef union {
esp_gatt_status_t status; /*!< Operation status */
uint16_t attr_handle; /*!< Descriptor attribute handle */
uint16_t service_handle; /*!< Service attribute handle */
esp_bt_uuid_t char_uuid; /*!< Characteristic uuid */
esp_bt_uuid_t descr_uuid; /*!< Characteristic descriptor uuid */
} add_char_descr; /*!< Gatt server callback param of ESP_GATTS_ADD_CHAR_DESCR_EVT */
/**

View File

@ -514,6 +514,9 @@ static void bta_av_proc_stream_evt(UINT8 handle, BD_ADDR bd_addr, UINT8 event, t
p_msg->disc_rsn = p_data->hdr.err_param;
break;
*/
case AVDT_DISCONNECT_IND_EVT:
p_msg->hdr.offset = p_data->hdr.err_param;
break;
default:
break;
}

View File

@ -529,6 +529,7 @@ void bta_av_rc_opened(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
bdcpy(rc_open.peer_addr, p_data->rc_conn_chg.peer_addr);
rc_open.peer_features = p_cb->rcb[i].peer_features;
rc_open.sdp_disc_done = TRUE;
rc_open.status = BTA_AV_SUCCESS;
APPL_TRACE_DEBUG("local features:x%x peer_features:x%x", p_cb->features,
rc_open.peer_features);
@ -536,6 +537,7 @@ void bta_av_rc_opened(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
/* we have not done SDP on peer RC capabilities.
* peer must have initiated the RC connection */
rc_open.peer_features = BTA_AV_FEAT_RCCT;
rc_open.sdp_disc_done = FALSE;
bta_av_rc_disc(disc);
}
(*p_cb->p_cback)(BTA_AV_RC_OPEN_EVT, (tBTA_AV *) &rc_open);
@ -1266,6 +1268,11 @@ void bta_av_disable(tBTA_AV_CB *p_cb, tBTA_AV_DATA *p_data)
hdr.layer_specific = xx + 1;
bta_av_api_deregister((tBTA_AV_DATA *)&hdr);
}
bta_sys_free_timer(&p_cb->sig_tmr);
memset(&p_cb->sig_tmr, 0, sizeof(TIMER_LIST_ENT));
bta_sys_free_timer(&p_cb->acp_sig_tmr);
memset(&p_cb->acp_sig_tmr, 0, sizeof(TIMER_LIST_ENT));
}
/*******************************************************************************
@ -1610,6 +1617,7 @@ void bta_av_rc_disc_done(tBTA_AV_DATA *p_data)
p_scb->use_rc = FALSE;
bdcpy(rc_open.peer_addr, p_scb->peer_addr);
rc_open.peer_features = 0;
rc_open.sdp_disc_done = FALSE;
rc_open.status = BTA_AV_FAIL_SDP;
(*p_cb->p_cback)(BTA_AV_RC_OPEN_EVT, (tBTA_AV *) &rc_open);
}
@ -1839,6 +1847,8 @@ void bta_av_dereg_comp(tBTA_AV_DATA *p_data)
/* make sure that the timer is not active */
bta_sys_stop_timer(&p_scb->timer);
list_free(p_scb->a2d_list);
p_scb->a2d_list = NULL;
utl_freebuf((void **)&p_cb->p_scb[p_scb->hdi]);
}

View File

@ -1237,9 +1237,10 @@ BOOLEAN bta_av_hdl_event(BT_HDR *p_msg)
bta_av_sm_execute(&bta_av_cb, p_msg->event, (tBTA_AV_DATA *) p_msg);
} else {
APPL_TRACE_VERBOSE("handle=0x%x\n", p_msg->layer_specific);
tBTA_AV_SCB *p_scb = bta_av_hndl_to_scb(p_msg->layer_specific);
p_scb->disc_rsn = p_msg->offset;
/* stream state machine events */
bta_av_ssm_execute( bta_av_hndl_to_scb(p_msg->layer_specific),
p_msg->event, (tBTA_AV_DATA *) p_msg);
bta_av_ssm_execute(p_scb, p_msg->event, (tBTA_AV_DATA *) p_msg);
}
return TRUE;
}

View File

@ -282,6 +282,47 @@ void bta_dm_enable(tBTA_DM_MSG *p_data)
}
}
/*******************************************************************************
*
* Function bta_dm_init_cb
*
* Description Initializes the bta_dm_cb control block
*
*
* Returns void
*
******************************************************************************/
void bta_dm_init_cb(void)
{
memset(&bta_dm_cb, 0, sizeof(bta_dm_cb));
}
/*******************************************************************************
*
* Function bta_dm_deinit_cb
*
* Description De-initializes the bta_dm_cb control block
*
*
* Returns void
*
******************************************************************************/
void bta_dm_deinit_cb(void)
{
bta_sys_free_timer(&bta_dm_cb.disable_timer);
#if ( BTA_EIR_CANNED_UUID_LIST != TRUE )
bta_sys_free_timer(&bta_dm_cb.app_ready_timer);
#endif
#if BTM_SSR_INCLUDED == TRUE
for (size_t i = 0; i < BTA_DM_NUM_PM_TIMER; i++) {
for (size_t j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++) {
bta_sys_free_timer(&bta_dm_cb.pm_timer[i].timer[j]);
}
}
#endif
memset(&bta_dm_cb, 0, sizeof(bta_dm_cb));
}
/*******************************************************************************
**
** Function bta_dm_sys_hw_cback
@ -318,7 +359,15 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
}
/* reinitialize the control block */
memset(&bta_dm_cb, 0, sizeof(bta_dm_cb));
bta_dm_deinit_cb();
bta_sys_free_timer(&bta_dm_search_cb.search_timer);
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
bta_sys_free_timer(&bta_dm_search_cb.gatt_close_timer);
#endif
#endif
memset(&bta_dm_search_cb, 0x00, sizeof(bta_dm_search_cb));
/* unregister from SYS */
bta_sys_hw_unregister( BTA_SYS_HW_BLUETOOTH );
@ -332,11 +381,18 @@ static void bta_dm_sys_hw_cback( tBTA_SYS_HW_EVT status )
/* save security callback */
temp_cback = bta_dm_cb.p_sec_cback;
/* make sure the control block is properly initialized */
memset(&bta_dm_cb, 0, sizeof(bta_dm_cb));
bta_dm_init_cb();
/* and retrieve the callback */
bta_dm_cb.p_sec_cback = temp_cback;
bta_dm_cb.is_bta_dm_active = TRUE;
bta_sys_free_timer(&bta_dm_search_cb.search_timer);
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE)
bta_sys_free_timer(&bta_dm_search_cb.gatt_close_timer);
#endif
#endif
/* hw is ready, go on with BTA DM initialization */
memset(&bta_dm_search_cb, 0x00, sizeof(bta_dm_search_cb));
#if (BTM_SSR_INCLUDED == TRUE)
@ -2595,7 +2651,7 @@ static UINT8 bta_dm_authorize_cback (BD_ADDR bd_addr, DEV_CLASS dev_class, BD_NA
return BTM_NOT_AUTHORIZED;
}
}
@ -3284,7 +3340,7 @@ void bta_dm_acl_change(tBTA_DM_MSG *p_data)
}
bdcpy(conn.link_down.bd_addr, p_bda);
conn.link_down.status = (UINT8) btm_get_acl_disc_reason_code();
conn.link_down.reason = (UINT8) btm_get_acl_disc_reason_code();
if ( bta_dm_cb.p_sec_cback ) {
bta_dm_cb.p_sec_cback(BTA_DM_LINK_DOWN_EVT, &conn);
if ( issue_unpair_cb ) {
@ -4101,6 +4157,8 @@ void bta_dm_set_encryption (tBTA_DM_MSG *p_data)
== BTM_CMD_STARTED) {
bta_dm_cb.device_list.peer_device[i].p_encrypt_cback = p_data->set_encryption.p_callback;
}
}else{
APPL_TRACE_ERROR("%s, not find peer_bdaddr or peer_bdaddr connection state error", __func__);
}
}
#endif ///SMP_INCLUDED == TRUE
@ -4130,6 +4188,8 @@ static void bta_dm_observe_results_cb (tBTM_INQ_RESULTS *p_inq, UINT8 *p_eir)
result.inq_res.flag = p_inq->flag;
result.inq_res.adv_data_len = p_inq->adv_data_len;
result.inq_res.scan_rsp_len = p_inq->scan_rsp_len;
memcpy(result.inq_res.dev_class, p_inq->dev_class, sizeof(DEV_CLASS));
result.inq_res.ble_evt_type = p_inq->ble_evt_type;
/* application will parse EIR to find out remote device name */
result.inq_res.p_eir = p_eir;
@ -4286,7 +4346,7 @@ static UINT8 bta_dm_ble_smp_cback (tBTM_LE_EVT event, BD_ADDR bda, tBTM_LE_EVT_D
} else {
sec_event.auth_cmpl.success = TRUE;
if (!p_data->complt.smp_over_br) {
}
}
@ -4571,14 +4631,18 @@ void bta_dm_ble_disconnect (tBTA_DM_MSG *p_data)
*******************************************************************************/
void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data)
{
BOOLEAN set_flag = false;
tBTM_STATUS status = BTM_SET_STATIC_RAND_ADDR_FAIL;
if (p_data->set_addr.addr_type != BLE_ADDR_RANDOM) {
APPL_TRACE_ERROR("Invalid random adress type = %d\n", p_data->set_addr.addr_type);
if(p_data->set_addr.p_set_rand_addr_cback) {
(*p_data->set_addr.p_set_rand_addr_cback)(status);
}
return;
}
//send the setting random address to BTM layer
if ((set_flag = BTM_BleSetRandAddress(p_data->set_addr.address) != TRUE)){
APPL_TRACE_ERROR("%s,set random address fail.", __func__);
status = BTM_BleSetRandAddress(p_data->set_addr.address);
if(p_data->set_addr.p_set_rand_addr_cback) {
(*p_data->set_addr.p_set_rand_addr_cback)(status);
}
}
@ -4729,20 +4793,17 @@ void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data)
*******************************************************************************/
void bta_dm_ble_set_adv_params_all (tBTA_DM_MSG *p_data)
{
tBTA_STATUS status = BTA_FAILURE;
if (BTM_BleSetAdvParamsStartAdv(p_data->ble_set_adv_params_all.adv_int_min,
p_data->ble_set_adv_params_all.adv_int_max,
p_data->ble_set_adv_params_all.adv_type,
p_data->ble_set_adv_params_all.addr_type_own,
p_data->ble_set_adv_params_all.p_dir_bda,
p_data->ble_set_adv_params_all.channel_map,
p_data->ble_set_adv_params_all.adv_filter_policy) == BTM_SUCCESS) {
status = BTA_SUCCESS;
}
if (p_data->ble_set_adv_params_all.p_start_adv_cback) {
(*p_data->ble_set_adv_params_all.p_start_adv_cback)(status);
p_data->ble_set_adv_params_all.adv_filter_policy,
p_data->ble_set_adv_params_all.p_start_adv_cback) == BTM_SUCCESS) {
APPL_TRACE_DEBUG("%s(), success to start ble adv.", __func__);
} else {
APPL_TRACE_ERROR("%s(), fail to start ble adv.", __func__);
}
}
@ -4851,25 +4912,26 @@ void bta_dm_ble_set_scan_rsp_raw (tBTA_DM_MSG *p_data)
void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data)
{
tACL_CONN *p_acl_cb = btm_bda_to_acl(p_data->ble_set_data_length.remote_bda, BT_TRANSPORT_LE);
if (p_acl_cb == NULL) {
APPL_TRACE_ERROR("%s error: Invalid connection remote_bda.", __func__);
return;
} else {
p_acl_cb->p_set_pkt_data_cback = p_data->ble_set_data_length.p_set_pkt_data_cback;
}
UINT8 status = BTM_SetBleDataLength(p_data->ble_set_data_length.remote_bda,
p_data->ble_set_data_length.tx_data_length);
if (status != BTM_SUCCESS) {
APPL_TRACE_ERROR("%s failed\n", __FUNCTION__);
if (p_data->ble_set_data_length.p_set_pkt_data_cback) {
if (p_acl_cb->data_length_params.tx_len == 0){
uint16_t length = controller_get_interface()->get_acl_data_size_ble();
p_acl_cb->data_length_params.rx_len = length;
p_acl_cb->data_length_params.tx_len = length;
}
(*p_data->ble_set_data_length.p_set_pkt_data_cback)(status, &p_acl_cb->data_length_params);
}
if (p_acl_cb == NULL) {
APPL_TRACE_ERROR("%s error: Invalid connection remote_bda.", __func__);
return;
} else {
p_acl_cb->p_set_pkt_data_cback = p_data->ble_set_data_length.p_set_pkt_data_cback;
}
UINT8 status = BTM_SetBleDataLength(p_data->ble_set_data_length.remote_bda,
p_data->ble_set_data_length.tx_data_length);
if (status != BTM_SUCCESS) {
APPL_TRACE_ERROR("%s failed\n", __FUNCTION__);
}
if (p_data->ble_set_data_length.p_set_pkt_data_cback) {
if (p_acl_cb->data_length_params.tx_len == 0){
uint16_t length = controller_get_interface()->get_acl_data_size_ble();
p_acl_cb->data_length_params.rx_len = length;
p_acl_cb->data_length_params.tx_len = length;
}
(*p_data->ble_set_data_length.p_set_pkt_data_cback)(status, &p_acl_cb->data_length_params);
}
}
/*******************************************************************************
@ -4886,15 +4948,13 @@ void bta_dm_ble_broadcast (tBTA_DM_MSG *p_data)
tBTM_STATUS status = 0;
BOOLEAN start = p_data->ble_observe.start;
status = BTM_BleBroadcast(start);
status = BTM_BleBroadcast(start, p_data->ble_observe.p_stop_adv_cback);
if (p_data->ble_observe.p_stop_adv_cback){
if (status != BTM_SUCCESS){
APPL_TRACE_WARNING("%s, %s, status=0x%x\n", __func__,\
(start == TRUE) ? "start adv failed" : "stop adv failed", status);
}
status = (status == BTM_SUCCESS ? BTA_SUCCESS : BTA_FAILURE);
p_data->ble_observe.p_stop_adv_cback(status);
}
}
@ -5347,7 +5407,7 @@ static void bta_ble_energy_info_cmpl(tBTM_BLE_TX_TIME_MS tx_time,
if (BTA_SUCCESS == st) {
ctrl_state = bta_dm_pm_obtain_controller_state();
}
#endif
#endif
if (bta_dm_cb.p_energy_info_cback) {
bta_dm_cb.p_energy_info_cback(tx_time, rx_time, idle_time, energy_used, ctrl_state, st);
}
@ -5581,7 +5641,8 @@ void btm_dm_start_gatt_discovery (BD_ADDR bd_addr)
bta_sys_stop_timer(&bta_dm_search_cb.gatt_close_timer);
btm_dm_start_disc_gatt_services(bta_dm_search_cb.conn_id);
} else {
BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, TRUE, BTA_GATT_TRANSPORT_LE);
//TODO need to add addr_type in future
BTA_GATTC_Open(bta_dm_search_cb.client_if, bd_addr, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE);
}
}
#endif /* #if (GATTC_INCLUDED == TRUE) */

View File

@ -2284,12 +2284,12 @@ extern void BTA_DmBleStopAdvertising(void)
** Description This function set the random address for the APP
**
** Parameters rand_addr: the random address whith should be setting
**
** p_set_rand_addr_cback: complete callback
** Returns void
**
**
*******************************************************************************/
extern void BTA_DmSetRandAddress(BD_ADDR rand_addr)
extern void BTA_DmSetRandAddress(BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *p_set_rand_addr_cback)
{
tBTA_DM_APT_SET_DEV_ADDR *p_msg;
APPL_TRACE_API("set the random address ");
@ -2298,6 +2298,7 @@ extern void BTA_DmSetRandAddress(BD_ADDR rand_addr)
memcpy(p_msg->address, rand_addr, BD_ADDR_LEN);
p_msg->hdr.event = BTA_DM_API_SET_RAND_ADDR_EVT;
p_msg->addr_type = BLE_ADDR_RANDOM;
p_msg->p_set_rand_addr_cback = p_set_rand_addr_cback;
//start sent the msg to the bta system control moudle
bta_sys_sendmsg(p_msg);
}

View File

@ -532,6 +532,7 @@ typedef struct {
BT_HDR hdr;
tBLE_ADDR_TYPE addr_type;
BD_ADDR address;
tBTA_SET_RAND_ADDR_CBACK *p_set_rand_addr_cback;
} tBTA_DM_APT_SET_DEV_ADDR;
/* set adv parameter for BLE advertising */

View File

@ -34,6 +34,7 @@
#include "l2c_int.h"
#include "gatt_int.h"
#include "allocator.h"
#include "mutex.h"
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
#include "bta_hh_int.h"
@ -59,6 +60,7 @@ static void bta_gattc_cmpl_cback(UINT16 conn_id, tGATTC_OPTYPE op, tGATT_STATUS
static void bta_gattc_cmpl_sendmsg(UINT16 conn_id, tGATTC_OPTYPE op,
tBTA_GATT_STATUS status,
tGATT_CL_COMPLETE *p_data);
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);
@ -124,8 +126,10 @@ static void bta_gattc_enable(tBTA_GATTC_CB *p_cb)
/* initialize control block */
memset(&bta_gattc_cb, 0, sizeof(tBTA_GATTC_CB));
p_cb->state = BTA_GATTC_STATE_ENABLED;
// Create a write ccc mutex when the gatt client enable
osi_mutex_new(&bta_gattc_cb.write_ccc_mutex);
} else {
APPL_TRACE_DEBUG("GATTC is arelady enabled");
APPL_TRACE_DEBUG("GATTC is already enabled");
}
}
@ -150,6 +154,8 @@ void bta_gattc_disable(tBTA_GATTC_CB *p_cb)
APPL_TRACE_ERROR("not enabled or disable in pogress");
return;
}
// Free the write ccc mutex when the gatt client disable
osi_mutex_free(&bta_gattc_cb.write_ccc_mutex);
for (i = 0; i < BTA_GATTC_CL_MAX; i ++) {
if (p_cb->cl_rcb[i].in_use) {
@ -487,9 +493,14 @@ void bta_gattc_open_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
{
tBTA_GATTC_DATA gattc_data;
BOOLEAN found_app = FALSE;
tGATT_TCB *p_tcb = gatt_find_tcb_by_addr(p_data->api_conn.remote_bda, BT_TRANSPORT_LE);
if(p_tcb && p_clcb && p_data) {
found_app = gatt_find_specific_app_in_hold_link(p_tcb, p_clcb->p_rcb->client_if);
}
/* open/hold a connection */
if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda,
if (!GATT_Connect(p_clcb->p_rcb->client_if, p_data->api_conn.remote_bda, p_data->api_conn.remote_addr_type,
TRUE, p_data->api_conn.transport)) {
APPL_TRACE_ERROR("Connection open failure");
@ -501,7 +512,7 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
&p_clcb->bta_conn_id,
p_data->api_conn.transport)) {
gattc_data.int_conn.hdr.layer_specific = p_clcb->bta_conn_id;
gattc_data.int_conn.already_connect = found_app;
bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_CONN_EVT, &gattc_data);
}
/* else wait for the callback event */
@ -525,7 +536,7 @@ void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg
if (bta_gattc_mark_bg_conn(p_data->client_if, p_data->remote_bda, TRUE, FALSE)) {
/* always call open to hold a connection */
if (!GATT_Connect(p_data->client_if, p_data->remote_bda, FALSE, p_data->transport)) {
if (!GATT_Connect(p_data->client_if, p_data->remote_bda, p_data->remote_addr_type, FALSE, p_data->transport)) {
uint8_t *bda = (uint8_t *)p_data->remote_bda;
status = BTA_GATT_ERROR;
APPL_TRACE_ERROR("%s unable to connect to remote bd_addr:%02x:%02x:%02x:%02x:%02x:%02x",
@ -666,14 +677,14 @@ void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
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 */
} else { /* cache is building */
p_clcb->p_srcb->state = BTA_GATTC_SERV_DISC;
/* cache load failure, start discovery */
bta_gattc_start_discover(p_clcb, NULL);
}
} else { /* cache is building */
p_clcb->state = BTA_GATTC_DISCOVER_ST;
}
} else { /* cache is building */
p_clcb->state = BTA_GATTC_DISCOVER_ST;
}
} else {
/* a pending service handle change indication */
if (p_clcb->p_srcb->srvc_hdl_chg) {
@ -688,9 +699,14 @@ void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
if (p_clcb->transport == BTA_TRANSPORT_BR_EDR) {
bta_sys_conn_open(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda);
}
tBTA_GATT_STATUS status = BTA_GATT_OK;
if (p_data && p_data->int_conn.already_connect) {
//clear already_connect
p_data->int_conn.already_connect = FALSE;
status = BTA_GATT_ALREADY_OPEN;
}
bta_gattc_send_open_cback(p_clcb->p_rcb,
BTA_GATT_OK,
status,
p_clcb->bda,
p_clcb->bta_conn_id,
p_clcb->transport,
@ -916,6 +932,7 @@ void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
/* Dequeue the data, if it was enqueued */
if (p_clcb->p_q_cmd == p_data) {
p_clcb->p_q_cmd = NULL;
bta_gattc_pop_command_to_send(p_clcb);
}
bta_gattc_cmpl_sendmsg(p_clcb->bta_conn_id, GATTC_OPTYPE_CONFIG, status, NULL);
@ -1012,7 +1029,6 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
}
if (p_clcb->p_srcb && p_clcb->p_srcb->p_srvc_list) {
/* release pending attribute list buffer */
APPL_TRACE_DEBUG("+++++++++++++++++++++++++++++++++++++++++++++++++++++++= %p", p_clcb->p_srcb->p_srvc_list);
osi_free(p_clcb->p_srcb->p_srvc_list);
p_clcb->p_srcb->p_srvc_list = NULL;
//osi_free_and_reset((void **)&p_clcb->p_srcb->p_srvc_list);
@ -1034,11 +1050,9 @@ void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
* referenced by p_clcb->p_q_cmd
*/
if (p_q_cmd != p_clcb->p_q_cmd) {
APPL_TRACE_DEBUG("====================================================================");
osi_free(p_q_cmd);
p_q_cmd = NULL;
}
//osi_free_and_reset((void **)&p_q_cmd);
}
}
/*******************************************************************************
@ -1067,6 +1081,7 @@ void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
/* Dequeue the data, if it was enqueued */
if (p_clcb->p_q_cmd == p_data) {
p_clcb->p_q_cmd = NULL;
bta_gattc_pop_command_to_send(p_clcb);
}
bta_gattc_cmpl_sendmsg(p_clcb->bta_conn_id, GATTC_OPTYPE_READ, status, NULL);
@ -1102,6 +1117,7 @@ void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
/* Dequeue the data, if it was enqueued */
if (p_clcb->p_q_cmd == p_data) {
p_clcb->p_q_cmd = NULL;
bta_gattc_pop_command_to_send(p_clcb);
}
bta_gattc_cmpl_sendmsg(p_clcb->bta_conn_id, GATTC_OPTYPE_READ, status, NULL);
@ -1142,6 +1158,7 @@ void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
/* Dequeue the data, if it was enqueued */
if (p_clcb->p_q_cmd == p_data) {
p_clcb->p_q_cmd = NULL;
bta_gattc_pop_command_to_send(p_clcb);
}
bta_gattc_cmpl_sendmsg(p_clcb->bta_conn_id, GATTC_OPTYPE_WRITE, status, NULL);
@ -1166,6 +1183,7 @@ void bta_gattc_execute(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
/* Dequeue the data, if it was enqueued */
if (p_clcb->p_q_cmd == p_data) {
p_clcb->p_q_cmd = NULL;
bta_gattc_pop_command_to_send(p_clcb);
}
bta_gattc_cmpl_sendmsg(p_clcb->bta_conn_id, GATTC_OPTYPE_EXE_WRITE, status, NULL);
@ -1232,9 +1250,9 @@ void bta_gattc_read_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
event = p_clcb->p_q_cmd->api_read_multi.cmpl_evt;
}
cb_data.read.conn_id = p_clcb->bta_conn_id;
osi_free(p_clcb->p_q_cmd);
p_clcb->p_q_cmd = NULL;
//osi_free_and_reset((void **)&p_clcb->p_q_cmd);
//free the command data store in the queue.
bta_gattc_free_command_data(p_clcb);
bta_gattc_pop_command_to_send(p_clcb);
/* read complete, callback */
( *p_clcb->p_rcb->p_cback)(event, (tBTA_GATTC *)&cb_data);
@ -1265,9 +1283,9 @@ void bta_gattc_write_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
} else {
event = p_clcb->p_q_cmd->api_write.cmpl_evt;
}
osi_free(p_clcb->p_q_cmd);
p_clcb->p_q_cmd = NULL;
//osi_free_and_reset((void **)&p_clcb->p_q_cmd);
//free the command data store in the queue.
bta_gattc_free_command_data(p_clcb);
bta_gattc_pop_command_to_send(p_clcb);
cb_data.write.conn_id = p_clcb->bta_conn_id;
/* write complete, callback */
( *p_clcb->p_rcb->p_cback)(event, (tBTA_GATTC *)&cb_data);
@ -1285,9 +1303,9 @@ void bta_gattc_write_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
void bta_gattc_exec_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
{
tBTA_GATTC cb_data;
osi_free(p_clcb->p_q_cmd);
p_clcb->p_q_cmd = NULL;
//osi_free_and_reset((void **)&p_clcb->p_q_cmd);
//free the command data store in the queue.
bta_gattc_free_command_data(p_clcb);
bta_gattc_pop_command_to_send(p_clcb);
p_clcb->status = BTA_GATT_OK;
/* execute complete, callback */
@ -1310,10 +1328,9 @@ void bta_gattc_exec_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
void bta_gattc_cfg_mtu_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_OP_CMPL *p_data)
{
tBTA_GATTC cb_data;
osi_free(p_clcb->p_q_cmd);
p_clcb->p_q_cmd = NULL;
//osi_free_and_reset((void **)&p_clcb->p_q_cmd);
//free the command data store in the queue.
bta_gattc_free_command_data(p_clcb);
bta_gattc_pop_command_to_send(p_clcb);
if (p_data->p_cmpl && p_data->status == BTA_GATT_OK) {
p_clcb->p_srcb->mtu = p_data->p_cmpl->mtu;
@ -1456,6 +1473,78 @@ void bta_gattc_q_cmd(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
{
bta_gattc_enqueue(p_clcb, p_data);
}
/*******************************************************************************
**
** Function bta_gattc_pop_command_to_send
**
** Description dequeue a command into control block.
** Check if there has command pending in the command queue or not,
** if there has command pending in the command queue, sent it to the state machine to decision
** should be sent it to the remote device or not.
**
** Returns None.
**
*******************************************************************************/
static void bta_gattc_pop_command_to_send(tBTA_GATTC_CLCB *p_clcb)
{
if (!list_is_empty(p_clcb->p_cmd_list)) {
list_node_t *node = list_begin(p_clcb->p_cmd_list);
tBTA_GATTC_DATA *p_data = (tBTA_GATTC_DATA *)list_node(node);
if (p_data != NULL) {
/* execute pending operation of link block still present */
if (l2cu_find_lcb_by_bd_addr(p_clcb->p_srcb->server_bda, BT_TRANSPORT_LE) != NULL) {
// The data to be sent to the gattc state machine for processing
if(bta_gattc_sm_execute(p_clcb, p_data->hdr.event, p_data)) {
list_remove(p_clcb->p_cmd_list, (void *)p_data);
}
if (p_clcb->is_full) {
tBTA_GATTC cb_data = {0};
p_clcb->is_full = FALSE;
cb_data.status = GATT_SUCCESS;
cb_data.queue_full.conn_id = p_clcb->bta_conn_id;
cb_data.queue_full.is_full = FALSE;
if (p_clcb->p_rcb->p_cback != NULL) {
( *p_clcb->p_rcb->p_cback)(BTA_GATTC_QUEUE_FULL_EVT, (tBTA_GATTC *)&cb_data);
}
}
}
}
}
}
/*******************************************************************************
**
** Function bta_gattc_free_command_data
**
** Description free the command data into control block.
**
** Returns None.
**
*******************************************************************************/
void bta_gattc_free_command_data(tBTA_GATTC_CLCB *p_clcb)
{
assert(p_clcb->p_cmd_list);
//Check the list is empty or not.
if (!list_is_empty(p_clcb->p_cmd_list)) {
/* Traversal the command queue, check the p_q_cmd is point to the queue data or not, if the p_q_cmd point to the
command queue,should remove it from the list */
for (list_node_t *node = list_begin(p_clcb->p_cmd_list); node != list_end(p_clcb->p_cmd_list);
node = list_next(node)) {
tBTA_GATTC_DATA *p_data = (tBTA_GATTC_DATA *)list_node(node);
if (p_data == p_clcb->p_q_cmd) {
list_remove(p_clcb->p_cmd_list, (void *)p_data);
p_clcb->p_q_cmd = NULL;
return;
}
}
osi_free(p_clcb->p_q_cmd);
p_clcb->p_q_cmd = NULL;
} else {
osi_free(p_clcb->p_q_cmd);
p_clcb->p_q_cmd = NULL;
}
}
/*******************************************************************************
**
@ -1563,9 +1652,16 @@ static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id,
else if ((transport == BT_TRANSPORT_LE) && (connected == FALSE) && (p_conn != NULL)){
p_conn->service_change_ccc_written = FALSE;
if (p_conn->ccc_timer_used == TRUE){
osi_free((void *)p_conn->service_change_ccc_timer.param);
assert(bta_gattc_cb.write_ccc_mutex != NULL);
osi_mutex_lock(&bta_gattc_cb.write_ccc_mutex, OSI_MUTEX_MAX_TIMEOUT);
if (p_conn->service_change_ccc_timer.param != 0) {
osi_free((void *)p_conn->service_change_ccc_timer.param);
p_conn->service_change_ccc_timer.param = (TIMER_PARAM_TYPE)0;
}
bta_sys_stop_timer(&(p_conn->service_change_ccc_timer));
p_conn->ccc_timer_used = FALSE;
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
}
}
@ -1741,7 +1837,10 @@ BOOLEAN bta_gattc_process_srvc_chg_ind(UINT16 conn_id,
}
/* notify applicationf or service change */
if (p_clrcb->p_cback != NULL) {
(* p_clrcb->p_cback)(BTA_GATTC_SRVC_CHG_EVT, (tBTA_GATTC *)p_srcb->server_bda);
tBTA_GATTC_SERVICE_CHANGE srvc_chg= {0};
memcpy(srvc_chg.remote_bda, p_srcb->server_bda, sizeof(BD_ADDR));
srvc_chg.conn_id = conn_id;
(* p_clrcb->p_cback)(BTA_GATTC_SRVC_CHG_EVT, (tBTA_GATTC *)&srvc_chg);
}
}
@ -2084,8 +2183,8 @@ void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg)
UNUSED(p_cb);
cb_data.reg_oper.client_if = p_msg->api_listen.client_if;
cb_data.reg_oper.status = BTM_BleBroadcast(p_msg->api_listen.start);
cb_data.reg_oper.status = BTM_BleBroadcast(p_msg->api_listen.start, NULL);
//TODO need modify callback if used
if (p_clreg && p_clreg->p_cback) {
(*p_clreg->p_cback)(BTA_GATTC_LISTEN_EVT, &cb_data);
}
@ -2266,9 +2365,14 @@ static void bta_gattc_wait4_service_change_ccc_cback (TIMER_LIST_ENT *p_tle)
BOOLEAN start_ccc_timer = FALSE;
UINT32 new_timeout;
assert(bta_gattc_cb.write_ccc_mutex != NULL);
osi_mutex_lock(&bta_gattc_cb.write_ccc_mutex, OSI_MUTEX_MAX_TIMEOUT);
tBTA_GATTC_WAIT_CCC_TIMER *p_timer_param = (tBTA_GATTC_WAIT_CCC_TIMER*) p_tle->param;
p_tle->param = (TIMER_PARAM_TYPE)0;
if (p_timer_param == NULL){
APPL_TRACE_ERROR("p_timer_param is NULL in %s\n", __func__);
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
return;
}
@ -2276,6 +2380,7 @@ static void bta_gattc_wait4_service_change_ccc_cback (TIMER_LIST_ENT *p_tle)
if (p_conn == NULL){
APPL_TRACE_ERROR("p_conn is NULL in %s\n", __func__);
osi_free(p_timer_param);
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
return;
}
@ -2307,6 +2412,7 @@ static void bta_gattc_wait4_service_change_ccc_cback (TIMER_LIST_ENT *p_tle)
}
osi_free(p_timer_param);
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
}
#endif

View File

@ -135,13 +135,14 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if)
**
** Parameters client_if: server interface.
** remote_bda: remote device BD address.
** remote_addr_type: remote device BD address type.
** is_direct: direct connection or background auto connection
** transport: Transport to be used for GATT connection (BREDR/LE)
**
** Returns void
**
*******************************************************************************/
void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type,
BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport)
{
tBTA_GATTC_API_OPEN *p_buf;
@ -152,6 +153,7 @@ void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
p_buf->client_if = client_if;
p_buf->is_direct = is_direct;
p_buf->transport = transport;
p_buf->remote_addr_type = remote_addr_type;
memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN);
@ -829,7 +831,7 @@ tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
if ( p_clreg->notif_reg[i].in_use &&
!memcmp(p_clreg->notif_reg[i].remote_bda, bda, BD_ADDR_LEN) &&
p_clreg->notif_reg[i].handle == handle) {
APPL_TRACE_WARNING("notification already registered");
APPL_TRACE_DEBUG("notification already registered");
status = BTA_GATT_OK;
break;
}

View File

@ -43,7 +43,6 @@
#define LOG_TAG "bt_bta_gattc"
// #include "osi/include/log.h"
static void bta_gattc_cache_write(BD_ADDR server_bda, UINT16 num_attr, tBTA_GATTC_NV_ATTR *attr);
static void bta_gattc_char_dscpt_disc_cmpl(UINT16 conn_id, tBTA_GATTC_SERV *p_srvc_cb);
extern void bta_to_btif_uuid(bt_uuid_t *p_dest, tBT_UUID *p_src);
static size_t bta_gattc_get_db_size_with_type(list_t *services,
@ -1967,7 +1966,7 @@ void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id)
}
}
bta_gattc_cache_write(p_srvc_cb->server_bda, db_size, nv_attr);
/* TODO: Gattc cache write/read need to be added in IDF 3.1*/
osi_free(nv_attr);
}
@ -2036,52 +2035,6 @@ done:
return success;
}
/*******************************************************************************
**
** Function bta_gattc_cache_write
**
** Description This callout function is executed by GATT when a server cache
** is available to save.
**
** Parameter server_bda: server bd address of this cache belongs to
** num_attr: number of attribute to be save.
** attr: pointer to the list of attributes to save.
** Returns
**
*******************************************************************************/
static void bta_gattc_cache_write(BD_ADDR server_bda, UINT16 num_attr,
tBTA_GATTC_NV_ATTR *attr)
{
char fname[255] = {0};
bta_gattc_generate_cache_file_name(fname, server_bda);
FILE *fd = fopen(fname, "wb");
if (!fd) {
APPL_TRACE_ERROR("%s: can't open GATT cache file for writing: %s", __func__, fname);
return;
}
UINT16 cache_ver = GATT_CACHE_VERSION;
if (fwrite(&cache_ver, sizeof(UINT16), 1, fd) != 1) {
APPL_TRACE_DEBUG("%s: can't write GATT cache version: %s", __func__, fname);
fclose(fd);
return;
}
if (fwrite(&num_attr, sizeof(UINT16), 1, fd) != 1) {
APPL_TRACE_DEBUG("%s: can't write GATT cache attribute count: %s", __func__, fname);
fclose(fd);
return;
}
if (fwrite(attr, sizeof(tBTA_GATTC_NV_ATTR), num_attr, fd) != num_attr) {
APPL_TRACE_DEBUG("%s: can't write GATT cache attributes: %s", __func__, fname);
fclose(fd);
return;
}
fclose(fd);
}
/*******************************************************************************
**
** Function bta_gattc_cache_reset

View File

@ -182,7 +182,7 @@ static const UINT8 bta_gattc_st_connected[][BTA_GATTC_NUM_COLS] = {
/* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_READ_MULTI, BTA_GATTC_CONN_ST},
/* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
/* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
/* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_CONN_ST},
/* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_START_DISCOVER, BTA_GATTC_DISCOVER_ST},
/* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
/* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_OP_CMPL, BTA_GATTC_CONN_ST},

View File

@ -48,6 +48,8 @@ static const UINT8 base_uuid[LEN_UUID_128] = {0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x0
static const BD_ADDR dummy_bda = {0, 0, 0, 0, 0, 0};
#define GATTC_COMMAND_QUEUE_SIZE_MAX 30
/*******************************************************************************
**
** Function bta_gatt_convert_uuid16_to_uuid128
@ -230,7 +232,9 @@ tBTA_GATTC_CLCB *bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bd
bdcpy(p_clcb->bda, remote_bda);
p_clcb->p_rcb = bta_gattc_cl_get_regcb(client_if);
if (p_clcb->p_cmd_list == NULL) {
p_clcb->p_cmd_list = list_new(osi_free_func);
}
if ((p_clcb->p_srcb = bta_gattc_find_srcb(remote_bda)) == NULL) {
p_clcb->p_srcb = bta_gattc_srcb_alloc(remote_bda);
}
@ -305,6 +309,10 @@ void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb)
}
osi_free(p_clcb->p_q_cmd);
p_clcb->p_q_cmd = NULL;
// don't forget to clear the command queue before dealloc the clcb.
list_clear(p_clcb->p_cmd_list);
osi_free((void *)p_clcb->p_cmd_list);
p_clcb->p_cmd_list = NULL;
//osi_free_and_reset((void **)&p_clcb->p_q_cmd);
memset(p_clcb, 0, sizeof(tBTA_GATTC_CLCB));
} else {
@ -421,6 +429,24 @@ tBTA_GATTC_SERV *bta_gattc_srcb_alloc(BD_ADDR bda)
}
return p_tcb;
}
static BOOLEAN bta_gattc_has_prepare_command_in_queue(tBTA_GATTC_CLCB *p_clcb)
{
assert(p_clcb != NULL);
for(list_node_t *sn = list_begin(p_clcb->p_cmd_list);
sn != list_end(p_clcb->p_cmd_list); sn = list_next(sn)) {
tBTA_GATTC_DATA *cmd_data = (tBTA_GATTC_DATA *)list_node(sn);
if (cmd_data != NULL && ((cmd_data->hdr.event == BTA_GATTC_API_WRITE_EVT &&
cmd_data->api_write.write_type == BTA_GATTC_WRITE_PREPARE) ||
cmd_data->hdr.event == BTA_GATTC_API_EXEC_EVT)) {
return TRUE;
}
}
return FALSE;
}
/*******************************************************************************
**
** Function bta_gattc_enqueue
@ -432,15 +458,70 @@ tBTA_GATTC_SERV *bta_gattc_srcb_alloc(BD_ADDR bda)
*******************************************************************************/
BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
{
tBTA_GATTC cb_data = {0};
if (p_clcb->p_q_cmd == NULL)
{
if (p_clcb->p_q_cmd == NULL) {
p_clcb->p_q_cmd = p_data;
return TRUE;
} else if ((p_data->hdr.event == BTA_GATTC_API_WRITE_EVT &&
p_data->api_write.write_type == BTA_GATTC_WRITE_PREPARE) &&
((p_clcb->p_q_cmd->hdr.event == BTA_GATTC_API_WRITE_EVT &&
p_clcb->p_q_cmd->api_write.write_type == BTA_GATTC_WRITE_PREPARE) ||
bta_gattc_has_prepare_command_in_queue(p_clcb))) {
APPL_TRACE_DEBUG("%s(), prepare offset = %d", __func__, p_data->api_write.offset);
cb_data.write.status = BTA_GATT_CONGESTED;
cb_data.write.handle = p_data->api_write.handle;
cb_data.write.conn_id = p_clcb->bta_conn_id;
cb_data.write.offset = p_data->api_write.offset;
/* write complete, callback */
if (p_clcb->p_rcb->p_cback != NULL) {
( *p_clcb->p_rcb->p_cback)(BTA_GATTC_PREP_WRITE_EVT, (tBTA_GATTC *)&cb_data);
}
return FALSE;
}
else if (p_clcb->p_cmd_list) {
UINT16 len = 0;
tBTA_GATTC_DATA *cmd_data = NULL;
if (list_length(p_clcb->p_cmd_list) >= GATTC_COMMAND_QUEUE_SIZE_MAX) {
APPL_TRACE_ERROR("%s(), the gattc command queue is full.", __func__);
cb_data.status = GATT_BUSY;
cb_data.queue_full.conn_id = p_clcb->bta_conn_id;
cb_data.queue_full.is_full = TRUE;
p_clcb->is_full = TRUE;
if (p_clcb->p_rcb->p_cback != NULL) {
( *p_clcb->p_rcb->p_cback)(BTA_GATTC_QUEUE_FULL_EVT, (tBTA_GATTC *)&cb_data);
}
return FALSE;
}
if (p_data->hdr.event == BTA_GATTC_API_WRITE_EVT) {
len = p_data->api_write.len;
if ((cmd_data = (tBTA_GATTC_DATA *)osi_malloc(sizeof(tBTA_GATTC_DATA) + len)) != NULL) {
memset(cmd_data, 0, sizeof(tBTA_GATTC_DATA) + len);
memcpy(cmd_data, p_data, sizeof(tBTA_GATTC_DATA));
cmd_data->api_write.p_value = (UINT8 *)(cmd_data + 1);
memcpy(cmd_data->api_write.p_value, p_data->api_write.p_value, len);
} else {
APPL_TRACE_ERROR("%s(), line = %d, alloc fail, no memery.", __func__, __LINE__);
return FALSE;
}
} else {
if ((cmd_data = (tBTA_GATTC_DATA *)osi_malloc(sizeof(tBTA_GATTC_DATA))) != NULL) {
memset(cmd_data, 0, sizeof(tBTA_GATTC_DATA));
memcpy(cmd_data, p_data, sizeof(tBTA_GATTC_DATA));
} else {
APPL_TRACE_ERROR("%s(), line = %d, alloc fail, no memery.", __func__, __LINE__);
return FALSE;
}
}
//store the command to the command list.
list_append(p_clcb->p_cmd_list, (void *)cmd_data);
return FALSE;
}
APPL_TRACE_ERROR ("%s: already has a pending command!!", __func__);
/* skip the callback now. ----- need to send callback ? */
return FALSE;
}
@ -628,6 +709,7 @@ void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status
BD_ADDR remote_bda, UINT16 conn_id,
tBTA_TRANSPORT transport, UINT16 mtu)
{
tBTA_GATTC cb_data;
if (p_clreg->p_cback) {
@ -781,6 +863,10 @@ BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda)
if (p_conn != NULL) {
p_conn->in_use = FALSE;
memset(p_conn->remote_bda, 0, BD_ADDR_LEN);
osi_mutex_lock(&bta_gattc_cb.write_ccc_mutex, OSI_MUTEX_MAX_TIMEOUT);
bta_sys_free_timer(&p_conn->service_change_ccc_timer);
p_conn->ccc_timer_used = FALSE;
osi_mutex_unlock(&bta_gattc_cb.write_ccc_mutex);
return TRUE;
}
return FALSE;

View File

@ -420,7 +420,7 @@ void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
p_msg->api_add_char.perm,
p_msg->api_add_char.property, p_attr_val, p_control);
cb_data.add_result.server_if = p_rcb->gatt_if;
cb_data.add_result.service_id = p_msg->api_add_incl_srvc.hdr.layer_specific;
cb_data.add_result.service_id = p_msg->api_add_char.hdr.layer_specific;
cb_data.add_result.attr_id = attr_id;
// btla-specific ++
memcpy(&cb_data.add_result.char_uuid, &p_msg->api_add_char.char_uuid, sizeof(tBT_UUID));
@ -470,7 +470,7 @@ void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_
p_control);
cb_data.add_result.server_if = p_rcb->gatt_if;
cb_data.add_result.service_id = p_msg->api_add_incl_srvc.hdr.layer_specific;
cb_data.add_result.service_id = p_msg->api_add_char_descr.hdr.layer_specific;
cb_data.add_result.attr_id = attr_id;
// btla-specific ++
memcpy(&cb_data.add_result.char_uuid, &p_msg->api_add_char_descr.descr_uuid, sizeof(tBT_UUID));
@ -729,7 +729,7 @@ void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
if ((p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_open.server_if)) != NULL) {
/* should always get the connection ID */
if (GATT_Connect(p_rcb->gatt_if, p_msg->api_open.remote_bda,
if (GATT_Connect(p_rcb->gatt_if, p_msg->api_open.remote_bda, BLE_ADDR_UNKNOWN_TYPE,
p_msg->api_open.is_direct, p_msg->api_open.transport)) {
status = BTA_GATT_OK;

View File

@ -334,7 +334,7 @@ void bta_hh_le_open_conn(tBTA_HH_DEV_CB *p_cb, BD_ADDR remote_bda)
bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = p_cb->index;
p_cb->in_use = TRUE;
BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, TRUE, BTA_GATT_TRANSPORT_LE);
BTA_GATTC_Open(bta_hh_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BTA_GATT_TRANSPORT_LE);
}
/*******************************************************************************
@ -2600,7 +2600,7 @@ static void bta_hh_le_add_dev_bg_conn(tBTA_HH_DEV_CB *p_cb, BOOLEAN check_bond)
if (/*p_cb->dscp_info.flag & BTA_HH_LE_NORMAL_CONN &&*/
!p_cb->in_bg_conn && to_add) {
/* add device into BG connection to accept remote initiated connection */
BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, FALSE, BTA_GATT_TRANSPORT_LE);
BTA_GATTC_Open(bta_hh_cb.gatt_if, p_cb->addr, BLE_ADDR_UNKNOWN_TYPE, FALSE, BTA_GATT_TRANSPORT_LE);
p_cb->in_bg_conn = TRUE;
BTA_DmBleSetBgConnType(BTA_DM_BLE_CONN_AUTO, NULL);

View File

@ -400,12 +400,17 @@ typedef struct {
typedef void (tBTA_SET_ADV_DATA_CMPL_CBACK) (tBTA_STATUS status);
typedef void (tBTA_START_ADV_CMPL_CBACK) (tBTA_STATUS status);
typedef tBTM_START_ADV_CMPL_CBACK tBTA_START_ADV_CMPL_CBACK;
typedef tBTM_START_STOP_ADV_CMPL_CBACK tBTA_START_STOP_ADV_CMPL_CBACK;
typedef tBTM_ADD_WHITELIST_CBACK tBTA_ADD_WHITELIST_CBACK;
typedef tBTM_SET_PKT_DATA_LENGTH_CBACK tBTA_SET_PKT_DATA_LENGTH_CBACK;
typedef tBTM_SET_RAND_ADDR_CBACK tBTA_SET_RAND_ADDR_CBACK;
typedef tBTM_SET_LOCAL_PRIVACY_CBACK tBTA_SET_LOCAL_PRIVACY_CBACK;
typedef tBTM_CMPL_CB tBTA_CMPL_CB;
@ -782,6 +787,7 @@ typedef struct {
typedef struct {
BD_ADDR bd_addr; /* BD address peer device. */
UINT8 status; /* connection open/closed */
UINT8 reason; /* link down reason */
BOOLEAN is_removed; /* TRUE if device is removed when link is down */
#if BLE_INCLUDED == TRUE
tBTA_TRANSPORT link_type;
@ -2056,7 +2062,7 @@ extern void BTA_DmBleScan(BOOLEAN start, UINT32 duration,
extern void BTA_DmBleStopAdvertising(void);
extern void BTA_DmSetRandAddress(BD_ADDR rand_addr);
extern void BTA_DmSetRandAddress(BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *p_set_rand_addr_cback);
#endif

View File

@ -375,6 +375,7 @@ typedef struct {
/* data associated with BTA_AV_RC_OPEN_EVT */
typedef struct {
UINT8 rc_handle;
BOOLEAN sdp_disc_done;
tBTA_AV_FEAT peer_features;
BD_ADDR peer_addr;
tBTA_AV_STATUS status;

View File

@ -182,11 +182,14 @@ typedef UINT8 tBTA_GATT_STATUS;
#define BTA_GATTC_CONNECT_EVT 35 /* GATTC CONNECT event */
#define BTA_GATTC_DISCONNECT_EVT 36 /* GATTC DISCONNECT event */
#define BTA_GATTC_READ_MUTIPLE_EVT 37 /* GATTC Read mutiple event */
#define BTA_GATTC_QUEUE_FULL_EVT 38 /* GATTC queue full event */
typedef UINT8 tBTA_GATTC_EVT;
typedef tGATT_IF tBTA_GATTC_IF;
typedef UINT8 tBTA_ADDR_TYPE;
typedef struct {
UINT16 unit; /* as UUIUD defined by SIG */
UINT16 descr; /* as UUID as defined by SIG */
@ -298,6 +301,7 @@ typedef struct {
UINT16 conn_id;
tBTA_GATT_STATUS status;
UINT16 handle;
UINT16 offset;
}tBTA_GATTC_WRITE;
typedef struct {
@ -354,6 +358,12 @@ typedef struct {
BOOLEAN congested; /* congestion indicator */
} tBTA_GATTC_CONGEST;
typedef struct {
tBTA_GATT_STATUS status;
UINT16 conn_id;
BOOLEAN is_full;
} tBTA_GATTC_QUEUE_FULL;
typedef struct {
tBTA_GATT_STATUS status;
tBTA_GATTC_IF client_if;
@ -379,26 +389,30 @@ typedef struct {
BD_ADDR remote_bda;
} tBTA_GATTC_DISCONNECT;
typedef struct {
UINT16 conn_id;
BD_ADDR remote_bda;
} tBTA_GATTC_SERVICE_CHANGE;
typedef union {
tBTA_GATT_STATUS status;
tBTA_GATTC_SEARCH_CMPL search_cmpl; /* discovery complete */
tBTA_GATTC_SRVC_RES srvc_res; /* discovery result */
tBTA_GATTC_REG reg_oper; /* registration data */
tBTA_GATTC_SEARCH_CMPL search_cmpl; /* discovery complete */
tBTA_GATTC_SRVC_RES srvc_res; /* discovery result */
tBTA_GATTC_REG reg_oper; /* registration data */
tBTA_GATTC_OPEN open;
tBTA_GATTC_CONNECT connect;
tBTA_GATTC_CLOSE close;
tBTA_GATTC_DISCONNECT disconnect;
tBTA_GATTC_READ read; /* read attribute/descriptor data */
tBTA_GATTC_WRITE write; /* write complete data */
tBTA_GATTC_EXEC_CMPL exec_cmpl; /* execute complete */
tBTA_GATTC_NOTIFY notify; /* notification/indication event data */
tBTA_GATTC_READ read; /* read attribute/descriptor data */
tBTA_GATTC_WRITE write; /* write complete data */
tBTA_GATTC_EXEC_CMPL exec_cmpl; /* execute complete */
tBTA_GATTC_NOTIFY notify; /* notification/indication event data */
tBTA_GATTC_ENC_CMPL_CB enc_cmpl;
BD_ADDR remote_bda; /* service change event */
tBTA_GATTC_CFG_MTU cfg_mtu; /* configure MTU operation */
tBTA_GATTC_CONGEST congest;
tBTA_GATTC_QUEUE_FULL queue_full;
tBTA_GATTC_SERVICE_CHANGE srvc_chg; /* service change event */
} tBTA_GATTC;
/* GATTC enable callback function */
@ -728,13 +742,14 @@ extern void BTA_GATTC_AppDeregister (tBTA_GATTC_IF client_if);
**
** Parameters client_if: server interface.
** remote_bda: remote device BD address.
** remote_addr_type: remote device BD address type.
** is_direct: direct connection or background auto connection
**
** Returns void
**
*******************************************************************************/
extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport);
extern void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_ADDR_TYPE remote_addr_type,
BOOLEAN is_direct, tBTA_GATT_TRANSPORT transport);
/*******************************************************************************
**

View File

@ -30,6 +30,7 @@
#include "bta_gattc_ci.h"
#include "bta_gattc_co.h"
#include "fixed_queue.h"
#include "mutex.h"
/*****************************************************************************
** Constants and data types
@ -115,6 +116,7 @@ typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_INT_DEREG;
typedef struct {
BT_HDR hdr;
BD_ADDR remote_bda;
tBTA_ADDR_TYPE remote_addr_type;
tBTA_GATTC_IF client_if;
BOOLEAN is_direct;
tBTA_TRANSPORT transport;
@ -191,6 +193,7 @@ typedef struct {
UINT8 role;
tBT_TRANSPORT transport;
tGATT_DISCONN_REASON reason;
BOOLEAN already_connect;
} tBTA_GATTC_INT_CONN;
typedef struct {
@ -310,7 +313,8 @@ typedef struct {
tBTA_GATTC_RCB *p_rcb; /* pointer to the registration CB */
tBTA_GATTC_SERV *p_srcb; /* server cache CB */
tBTA_GATTC_DATA *p_q_cmd; /* command in queue waiting for execution */
list_t *p_cmd_list; /* The list to store the command to be sent */
BOOLEAN is_full; /* The gattc command queue is full or not */
#define BTA_GATTC_NO_SCHEDULE 0
#define BTA_GATTC_DISC_WAITING 0x01
#define BTA_GATTC_REQ_WAITING 0x10
@ -356,8 +360,8 @@ enum {
};
typedef struct {
UINT8 state;
UINT8 state;
osi_mutex_t write_ccc_mutex;
tBTA_GATTC_CONN conn_track[BTA_GATTC_CONN_MAX];
tBTA_GATTC_BG_TCK bg_track[BTA_GATTC_KNOWN_SR_MAX];
tBTA_GATTC_RCB cl_rcb[BTA_GATTC_CL_MAX];
@ -425,6 +429,7 @@ extern void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_q_cmd(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_free_command_data(tBTA_GATTC_CLCB *p_clcb);
extern void bta_gattc_search(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);

View File

@ -224,6 +224,7 @@ extern UINT16 bta_sys_get_sys_features(void);
extern void bta_sys_sendmsg(void *p_msg);
extern void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms);
extern void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle);
extern void bta_sys_free_timer(TIMER_LIST_ENT *p_tle);
extern void bta_sys_disable(tBTA_SYS_HW_MODULE module);
extern UINT32 bta_sys_get_remaining_ticks(TIMER_LIST_ENT *p_target_tle);

View File

@ -652,6 +652,28 @@ void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle)
osi_alarm_cancel(alarm);
}
/*******************************************************************************
**
** Function bta_sys_free_timer
**
** Description Stop and free a BTA timer.
**
** Returns void
**
*******************************************************************************/
void bta_sys_free_timer(TIMER_LIST_ENT *p_tle)
{
assert(p_tle != NULL);
osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
if (alarm == NULL) {
LOG_DEBUG("%s expected alarm was not in bta alarm hash map.", __func__);
return;
}
osi_alarm_cancel(alarm);
hash_map_erase(bta_alarm_hash_map, p_tle);
}
/*******************************************************************************
**
** Function bta_sys_disable

View File

@ -23,8 +23,13 @@
#if (SMP_INCLUDED == TRUE)
//the maximum nubmer of bonded devices
#define BONED_DEVICES_MAX_COUNT (BTM_SEC_MAX_DEVICE_RECORDS)
static void _btc_storage_save(void)
{
uint16_t addr_section_count = 0;
const btc_config_section_iter_t *need_remove_iter = NULL;
const btc_config_section_iter_t *iter = btc_config_section_begin();
while (iter != btc_config_section_end()) {
@ -48,10 +53,25 @@ static void _btc_storage_save(void)
btc_config_remove_section(section);
continue;
}
if(addr_section_count == BONED_DEVICES_MAX_COUNT) {
need_remove_iter = iter;
}
addr_section_count ++;
iter = btc_config_section_next(iter);
}
/*exceeded the maximum nubmer of bonded devices, delete them */
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)) {
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);
}
}
btc_config_flush();
}
@ -764,7 +784,10 @@ bt_status_t btc_storage_get_bonded_ble_devices_list(esp_ble_bond_dev_t *bond_dev
//resolve the peer device irk
if (_btc_storage_get_ble_bonding_key(&bd_addr, BTM_LE_KEY_PID, buffer, sizeof(tBTM_LE_PID_KEYS)) == BT_STATUS_SUCCESS) {
bond_dev->bond_key.key_mask |= ESP_BLE_ID_KEY_MASK;
memcpy(&bond_dev->bond_key.pid_key, buffer, sizeof(tBTM_LE_PID_KEYS));
tBTM_LE_PID_KEYS *pid_key = (tBTM_LE_PID_KEYS *) buffer;
memcpy(&bond_dev->bond_key.pid_key.irk, pid_key->irk, BT_OCTET16_LEN);
bond_dev->bond_key.pid_key.addr_type = pid_key->addr_type;
memcpy(&bond_dev->bond_key.pid_key.static_addr, pid_key->static_addr, sizeof(BD_ADDR));
}
//serch for the next bond device
bond_dev++;

View File

@ -247,12 +247,6 @@ static void btc_dm_ble_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
if (btc_storage_get_remote_addr_type(&bdaddr, &addr_type) != BT_STATUS_SUCCESS) {
btc_storage_set_remote_addr_type(&bdaddr, p_auth_cmpl->addr_type, true);
}
/* check the irk has been save in the flash or not, if the irk has already save, means that the peer device has bonding
before. */
if(pairing_cb.ble.is_pid_key_rcvd) {
btc_storage_compare_address_key_value(&bdaddr, BTM_LE_KEY_PID,
(void *)&pairing_cb.ble.pid_key, sizeof(tBTM_LE_PID_KEYS));
}
btc_dm_save_ble_bonding_keys();
} else {
/*Map the HCI fail reason to bt status */
@ -432,8 +426,8 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
switch (msg->act) {
case BTA_DM_ENABLE_EVT: {
btc_clear_services_mask();
btc_storage_load_bonded_devices();
#if (SMP_INCLUDED == TRUE)
btc_storage_load_bonded_devices();
//load the bonding device to the btm layer
btc_storage_load_bonded_ble_devices();
#endif ///SMP_INCLUDED == TRUE

View File

@ -57,8 +57,8 @@ static void btc_init_bluetooth(void)
osi_alarm_create_mux();
osi_alarm_init();
bte_main_boot_entry(btc_init_callback);
btc_config_init();
#if (SMP_INCLUDED)
btc_config_init();
//load the ble local key whitch has been store in the flash
btc_dm_load_ble_local_keys();
#endif /* #if (SMP_INCLUDED) */
@ -68,7 +68,9 @@ static void btc_init_bluetooth(void)
static void btc_deinit_bluetooth(void)
{
bte_main_shutdown();
#if (SMP_INCLUDED)
btc_config_clean_up();
#endif
osi_alarm_deinit();
osi_alarm_delete_mux();
future_ready(*btc_main_get_future_p(BTC_MAIN_DEINIT_FUTURE), FUTURE_SUCCESS);

View File

@ -141,9 +141,12 @@ int btc_init(void)
{
xBtcQueue = xQueueCreate(BTC_TASK_QUEUE_LEN, sizeof(btc_msg_t));
xTaskCreatePinnedToCore(btc_task, "Btc_task", BTC_TASK_STACK_SIZE, NULL, BTC_TASK_PRIO, &xBtcTaskHandle, BTC_TASK_PINNED_TO_CORE);
if (xBtcTaskHandle == NULL || xBtcQueue == 0){
return BT_STATUS_NOMEM;
}
btc_gap_callback_init();
/* TODO: initial the profile_tab */
return BT_STATUS_SUCCESS;
}

View File

@ -1002,8 +1002,6 @@ static void btc_a2d_sink_deinit(void)
{
LOG_DEBUG("%s\n", __FUNCTION__);
btc_a2dp_stop_media_task();
btc_dm_disable_service(BTA_A2DP_SOURCE_SERVICE_ID);
#if (BTA_AV_SINK_INCLUDED == TRUE)
btc_dm_disable_service(BTA_A2DP_SINK_SERVICE_ID);
@ -1012,6 +1010,8 @@ static void btc_a2d_sink_deinit(void)
/* Also shut down the AV state machine */
btc_sm_shutdown(btc_av_cb.sm_handle);
btc_av_cb.sm_handle = NULL;
btc_a2dp_stop_media_task();
}
/*******************************************************************************
@ -1120,7 +1120,7 @@ bt_status_t btc_av_execute_service(BOOLEAN b_enable)
* auto-suspend av streaming on AG events(SCO or Call). The suspend shall
* be initiated by the app/audioflinger layers */
BTA_AvEnable(BTA_SEC_AUTHENTICATE, (BTA_AV_FEAT_NO_SCO_SSPD)
// | BTA_AV_FEAT_RCTG | BTA_AV_FEAT_METADATA | BTA_AV_FEAT_VENDOR
| 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);

View File

@ -52,6 +52,8 @@
#include "bt_utils.h"
#include "esp_a2dp_api.h"
#include "mutex.h"
#include "future.h"
#include <assert.h>
// #if (BTA_AV_SINK_INCLUDED == TRUE)
#include "oi_codec_sbc.h"
@ -162,6 +164,7 @@ static void btc_media_thread_cleanup(UNUSED_ATTR void *context);
static tBTC_MEDIA_CB btc_media_cb;
static int media_task_running = MEDIA_TASK_STATE_OFF;
static future_t *media_task_future = NULL;
static fixed_queue_t *btc_media_cmd_msg_queue = NULL;
static xTaskHandle xBtcMediaTaskHandle = NULL;
static QueueHandle_t xBtcMediaDataQueue = NULL;
@ -272,13 +275,13 @@ bool btc_a2dp_start_media_task(void)
APPL_TRACE_EVENT("## A2DP START MEDIA THREAD ##");
xBtcMediaQueueSet = xQueueCreateSet(BTC_MEDIA_TASK_QUEUE_SET_LEN);
xBtcMediaQueueSet = xQueueCreateSet(BTC_A2DP_SINK_TASK_QUEUE_SET_LEN);
configASSERT(xBtcMediaQueueSet);
xBtcMediaDataQueue = xQueueCreate(BTC_MEDIA_DATA_QUEUE_LEN, sizeof(void *));
xBtcMediaDataQueue = xQueueCreate(BTC_A2DP_SINK_DATA_QUEUE_LEN, sizeof(void *));
configASSERT(xBtcMediaDataQueue);
xQueueAddToSet(xBtcMediaDataQueue, xBtcMediaQueueSet);
xBtcMediaCtrlQueue = xQueueCreate(BTC_MEDIA_CTRL_QUEUE_LEN, sizeof(void *));
xBtcMediaCtrlQueue = xQueueCreate(BTC_A2DP_SINK_CTRL_QUEUE_LEN, sizeof(void *));
configASSERT(xBtcMediaCtrlQueue);
xQueueAddToSet(xBtcMediaCtrlQueue, xBtcMediaQueueSet);
@ -286,7 +289,7 @@ bool btc_a2dp_start_media_task(void)
goto error_exit;
}
xTaskCreatePinnedToCore(btc_media_task_handler, "BtcMediaT\n", 2048, NULL, configMAX_PRIORITIES - 3, &xBtcMediaTaskHandle, 0);
xTaskCreatePinnedToCore(btc_media_task_handler, BTC_A2DP_SINK_TASK_NAME, BTC_A2DP_SINK_TASK_STACK_SIZE, NULL, BTC_A2DP_SINK_TASK_PRIO, &xBtcMediaTaskHandle, BTC_A2DP_SINK_TASK_PINNED_TO_CORE);
if (xBtcMediaTaskHandle == NULL) {
goto error_exit;
}
@ -319,6 +322,11 @@ error_exit:;
xBtcMediaCtrlQueue = NULL;
}
if (xBtcMediaQueueSet) {
vQueueDelete(xBtcMediaQueueSet);
xBtcMediaQueueSet = NULL;
}
fixed_queue_free(btc_media_cmd_msg_queue, NULL);
btc_media_cmd_msg_queue = NULL;
return false;
@ -329,8 +337,13 @@ void btc_a2dp_stop_media_task(void)
APPL_TRACE_EVENT("## A2DP STOP MEDIA THREAD ##\n");
// Exit thread
media_task_running = MEDIA_TASK_STATE_SHUTTING_DOWN;
media_task_future = future_new();
assert(media_task_future);
btc_media_ctrl_post(SIG_MEDIA_TASK_CLEAN_UP);
// TODO: wait until CLEAN up is done, then do task delete
future_await(media_task_future);
media_task_future = NULL;
vTaskDelete(xBtcMediaTaskHandle);
xBtcMediaTaskHandle = NULL;
@ -340,6 +353,9 @@ void btc_a2dp_stop_media_task(void)
vQueueDelete(xBtcMediaCtrlQueue);
xBtcMediaCtrlQueue = NULL;
vQueueDelete(xBtcMediaQueueSet);
xBtcMediaQueueSet = NULL;
fixed_queue_free(btc_media_cmd_msg_queue, NULL);
btc_media_cmd_msg_queue = NULL;
}
@ -527,6 +543,10 @@ static void btc_media_task_avk_data_ready(UNUSED_ATTR void *context)
}
while ((p_msg = (tBT_SBC_HDR *)fixed_queue_try_peek_first(btc_media_cb.RxSbcQ)) != NULL ) {
if (media_task_running != MEDIA_TASK_STATE_ON){
return;
}
btc_media_task_handle_inc_media(p_msg);
p_msg = (tBT_SBC_HDR *)fixed_queue_try_dequeue(btc_media_cb.RxSbcQ);
if ( p_msg == NULL ) {
@ -552,14 +572,13 @@ static void btc_media_thread_init(UNUSED_ATTR void *context)
static void btc_media_thread_cleanup(UNUSED_ATTR void *context)
{
/* make sure no channels are restarted while shutting down */
media_task_running = MEDIA_TASK_STATE_SHUTTING_DOWN;
btc_media_cb.data_channel_open = FALSE;
/* Clear media task flag */
media_task_running = MEDIA_TASK_STATE_OFF;
fixed_queue_free(btc_media_cb.RxSbcQ, osi_free_func);
future_ready(media_task_future, NULL);
}
/*******************************************************************************
@ -894,6 +913,10 @@ UINT8 btc_media_sink_enque_buf(BT_HDR *p_pkt)
{
tBT_SBC_HDR *p_msg;
if (media_task_running != MEDIA_TASK_STATE_ON){
return 0;
}
if (btc_media_cb.rx_flush == TRUE) { /* Flush enabled, do not enque*/
return fixed_queue_length(btc_media_cb.RxSbcQ);
}

View File

@ -31,6 +31,7 @@
#include "btc_manage.h"
#include "esp_avrc_api.h"
#include "mutex.h"
#include "allocator.h"
#if BTC_AV_INCLUDED
@ -96,6 +97,7 @@ rc_device_t device;
static void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open);
static void handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close);
static void handle_rc_passthrough_rsp ( tBTA_AV_REMOTE_RSP *p_remote_rsp);
static void handle_rc_metadata_rsp ( tBTA_AV_META_MSG *p_remote_rsp);
/*****************************************************************************
** Static variables
@ -118,30 +120,11 @@ static inline void btc_avrc_ct_cb_to_app(esp_avrc_ct_cb_event_t event, esp_avrc_
static void handle_rc_features(void)
{
btrc_remote_features_t rc_features = BTRC_FEAT_NONE;
bt_bdaddr_t rc_addr;
bdcpy(rc_addr.address, btc_rc_vb.rc_addr);
// TODO(eisenbach): If devices need to be blacklisted for absolute
// volume, it should be added to device/include/interop_database.h
// For now, everything goes... If blacklisting is necessary, exclude
// the following bit here:
// btc_rc_vb.rc_features &= ~BTA_AV_FEAT_ADV_CTRL;
if (btc_rc_vb.rc_features & BTA_AV_FEAT_BROWSE) {
rc_features |= BTRC_FEAT_BROWSE;
}
if ( (btc_rc_vb.rc_features & BTA_AV_FEAT_ADV_CTRL) &&
(btc_rc_vb.rc_features & BTA_AV_FEAT_RCTG)) {
rc_features |= BTRC_FEAT_ABSOLUTE_VOLUME;
}
if (btc_rc_vb.rc_features & BTA_AV_FEAT_METADATA) {
rc_features |= BTRC_FEAT_METADATA;
}
LOG_DEBUG("%s: rc_features=0x%x", __FUNCTION__, rc_features);
esp_avrc_ct_cb_param_t param;
memset(&param, 0, sizeof(esp_avrc_ct_cb_param_t));
param.rmt_feats.feat_mask = btc_rc_vb.rc_features;
memcpy(param.rmt_feats.remote_bda, btc_rc_vb.rc_addr, sizeof(esp_bd_addr_t));
btc_avrc_ct_cb_to_app(ESP_AVRC_CT_REMOTE_FEATURES_EVT, &param);
}
@ -156,9 +139,7 @@ static void handle_rc_features(void)
static void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open)
{
LOG_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_open->rc_handle);
#if (AVRC_CTLR_INCLUDED == TRUE)
bt_bdaddr_t rc_addr;
#endif
if (p_rc_open->status == BTA_AV_SUCCESS) {
//check if already some RC is connected
@ -180,22 +161,18 @@ static void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open)
btc_rc_vb.rc_connected = TRUE;
btc_rc_vb.rc_handle = p_rc_open->rc_handle;
bdcpy(rc_addr.address, btc_rc_vb.rc_addr);
esp_avrc_ct_cb_param_t param;
memset(&param, 0, sizeof(esp_avrc_ct_cb_param_t));
param.conn_stat.connected = true;
memcpy(param.conn_stat.remote_bda, &rc_addr, sizeof(esp_bd_addr_t));
btc_avrc_ct_cb_to_app(ESP_AVRC_CT_CONNECTION_STATE_EVT, &param);
/* on locally initiated connection we will get remote features as part of connect */
if (btc_rc_vb.rc_features != 0) {
if (p_rc_open->sdp_disc_done == TRUE) {
handle_rc_features();
}
#if (AVRC_CTLR_INCLUDED == TRUE)
bdcpy(rc_addr.address, btc_rc_vb.rc_addr);
/* report connection state if device is AVRCP target */
if (btc_rc_vb.rc_features & BTA_AV_FEAT_RCTG) {
esp_avrc_ct_cb_param_t param;
memset(&param, 0, sizeof(esp_avrc_ct_cb_param_t));
param.conn_stat.connected = true;
param.conn_stat.feat_mask = btc_rc_vb.rc_features;
memcpy(param.conn_stat.remote_bda, &rc_addr, sizeof(esp_bd_addr_t));
btc_avrc_ct_cb_to_app(ESP_AVRC_CT_CONNECTION_STATE_EVT, &param);
}
#endif
} else {
LOG_ERROR("%s Connect failed with error code: %d",
__FUNCTION__, p_rc_open->status);
@ -213,10 +190,8 @@ static void handle_rc_connect (tBTA_AV_RC_OPEN *p_rc_open)
***************************************************************************/
static void handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close)
{
#if (AVRC_CTLR_INCLUDED == TRUE)
bt_bdaddr_t rc_addr;
tBTA_AV_FEAT features;
#endif
LOG_DEBUG("%s: rc_handle: %d", __FUNCTION__, p_rc_close->rc_handle);
if ((p_rc_close->rc_handle != btc_rc_vb.rc_handle)
&& (bdcmp(btc_rc_vb.rc_addr, p_rc_close->peer_addr))) {
@ -226,27 +201,102 @@ static void handle_rc_disconnect (tBTA_AV_RC_CLOSE *p_rc_close)
btc_rc_vb.rc_handle = 0;
btc_rc_vb.rc_connected = FALSE;
memset(btc_rc_vb.rc_addr, 0, sizeof(BD_ADDR));
memcpy(btc_rc_vb.rc_addr, p_rc_close->peer_addr, sizeof(BD_ADDR));
memset(btc_rc_vb.rc_notif, 0, sizeof(btc_rc_vb.rc_notif));
#if (AVRC_CTLR_INCLUDED == TRUE)
features = btc_rc_vb.rc_features;
#endif
btc_rc_vb.rc_features = 0;
btc_rc_vb.rc_vol_label = MAX_LABEL;
btc_rc_vb.rc_volume = MAX_VOLUME;
#if (AVRC_CTLR_INCLUDED == TRUE)
bdcpy(rc_addr.address, btc_rc_vb.rc_addr);
#endif
memset(btc_rc_vb.rc_addr, 0, sizeof(BD_ADDR));
#if (AVRC_CTLR_INCLUDED == TRUE)
/* report connection state if device is AVRCP target */
if (features & BTA_AV_FEAT_RCTG) {
esp_avrc_ct_cb_param_t param;
memset(&param, 0, sizeof(esp_avrc_ct_cb_param_t));
param.conn_stat.connected = false;
memcpy(param.conn_stat.remote_bda, &rc_addr, sizeof(esp_bd_addr_t));
btc_avrc_ct_cb_to_app(ESP_AVRC_CT_CONNECTION_STATE_EVT, &param);
/* report connection state */
esp_avrc_ct_cb_param_t param;
memset(&param, 0, sizeof(esp_avrc_ct_cb_param_t));
param.conn_stat.connected = false;
memcpy(param.conn_stat.remote_bda, &rc_addr, sizeof(esp_bd_addr_t));
btc_avrc_ct_cb_to_app(ESP_AVRC_CT_CONNECTION_STATE_EVT, &param);
}
static void handle_rc_attributes_rsp ( tAVRC_MSG_VENDOR *vendor_msg)
{
uint8_t attr_count = vendor_msg->p_vendor_data[4];
int attr_index = 5;
int attr_length = 0;
uint32_t attr_id = 0;
//Check if there are any attributes
if (attr_count < 1) {
return;
}
esp_avrc_ct_cb_param_t param[attr_count];
memset(&param[0], 0, sizeof(esp_avrc_ct_cb_param_t) * attr_count);
for (int i = 0; i < attr_count; i++) {
attr_length = (int) vendor_msg->p_vendor_data[7 + attr_index] | vendor_msg->p_vendor_data[6 + attr_index] << 8;
//Received attribute text is not null terminated, so it's useful to know it's length
param[i].meta_rsp.attr_length = attr_length;
param[i].meta_rsp.attr_text = &vendor_msg->p_vendor_data[8 + attr_index];
attr_id = vendor_msg->p_vendor_data[3 + attr_index] |
vendor_msg->p_vendor_data[2 + attr_index] << 8 | vendor_msg->p_vendor_data[1 + attr_index] << 16 |
vendor_msg->p_vendor_data[attr_index] << 24;
//Convert to mask id
param[i].meta_rsp.attr_id = (1 << (attr_id - 1));
btc_avrc_ct_cb_to_app(ESP_AVRC_CT_METADATA_RSP_EVT, &param[i]);
attr_index += (int) vendor_msg->p_vendor_data[7 + attr_index] + 8;
}
}
static void handle_rc_notification_rsp ( tAVRC_MSG_VENDOR *vendor_msg)
{
esp_avrc_ct_cb_param_t param;
param.change_ntf.event_id = vendor_msg->p_vendor_data[4];
param.change_ntf.event_parameter = vendor_msg->p_vendor_data[5] << 24 | vendor_msg->p_vendor_data[6] << 16 |
vendor_msg->p_vendor_data[7] << 8 | vendor_msg->p_vendor_data[8];
btc_avrc_ct_cb_to_app(ESP_AVRC_CT_CHANGE_NOTIFY_EVT, &param);
}
/***************************************************************************
* Function handle_rc_metadata_rsp
*
* - Argument: tBTA_AV_META_MSG metadata command response
*
* - Description: Vendor metadata response handler
*
***************************************************************************/
static void handle_rc_metadata_rsp ( tBTA_AV_META_MSG *p_remote_rsp)
{
#if (AVRC_METADATA_INCLUDED == TRUE)
tAVRC_MSG *avrc_msg = p_remote_rsp->p_msg;
tAVRC_MSG_VENDOR *vendor_msg = &avrc_msg->vendor;
//Check what type of metadata was received
switch (vendor_msg->hdr.ctype) {
case AVRC_RSP_CHANGED:
if (vendor_msg->p_vendor_data[0] == AVRC_PDU_REGISTER_NOTIFICATION) {
handle_rc_notification_rsp(vendor_msg);
}
break;
case AVRC_RSP_IMPL_STBL:
if (vendor_msg->p_vendor_data[0] == AVRC_PDU_GET_ELEMENT_ATTR) {
handle_rc_attributes_rsp(vendor_msg);
}
break;
}
#else
LOG_ERROR("%s AVRCP metadata is not enabled", __FUNCTION__);
#endif
}
@ -326,8 +376,12 @@ void btc_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data)
}
break;
case BTA_AV_META_MSG_EVT: {
handle_rc_metadata_rsp(&(p_data->meta_msg));
}
break;
// below events are not handled for now
case BTA_AV_META_MSG_EVT:
case BTA_AV_REMOTE_CMD_EVT:
default:
LOG_DEBUG("Unhandled RC event : 0x%x", event);
@ -390,13 +444,124 @@ static void btc_avrc_ct_deinit(void)
LOG_INFO("## %s ## completed", __FUNCTION__);
}
static bt_status_t btc_avrc_ct_send_set_player_value_cmd(uint8_t tl, uint8_t attr_id, uint8_t value_id)
{
tAVRC_STS status = BT_STATUS_UNSUPPORTED;
#if (AVRC_METADATA_INCLUDED == TRUE)
CHECK_ESP_RC_CONNECTED;
tAVRC_COMMAND avrc_cmd = {0};
BT_HDR *p_msg = NULL;
tAVRC_APP_SETTING values = {0};
values.attr_id = attr_id;
values.attr_val = value_id;
avrc_cmd.set_app_val.opcode = AVRC_OP_VENDOR;
avrc_cmd.set_app_val.status = AVRC_STS_NO_ERROR;
avrc_cmd.set_app_val.num_val = 1;
avrc_cmd.set_app_val.p_vals = &values;
avrc_cmd.set_app_val.pdu = AVRC_PDU_SET_PLAYER_APP_VALUE;
status = AVRC_BldCommand(&avrc_cmd, &p_msg);
if (status == AVRC_STS_NO_ERROR) {
if (btc_rc_vb.rc_features & BTA_AV_FEAT_METADATA) {
BTA_AvMetaCmd(btc_rc_vb.rc_handle, tl, BTA_AV_CMD_CTRL, p_msg);
status = BT_STATUS_SUCCESS;
} else {
status = BT_STATUS_FAIL;
LOG_DEBUG("%s: feature not supported", __FUNCTION__);
}
}
#else
LOG_DEBUG("%s: feature not enabled", __FUNCTION__);
#endif
return status;
}
static bt_status_t btc_avrc_ct_send_register_notification_cmd(uint8_t tl, uint8_t event_id, uint32_t event_parameter)
{
tAVRC_STS status = BT_STATUS_UNSUPPORTED;
#if (AVRC_METADATA_INCLUDED == TRUE)
CHECK_ESP_RC_CONNECTED;
tAVRC_COMMAND avrc_cmd = {0};
BT_HDR *p_msg = NULL;
avrc_cmd.reg_notif.opcode = AVRC_OP_VENDOR;
avrc_cmd.reg_notif.status = AVRC_STS_NO_ERROR;
avrc_cmd.reg_notif.event_id = event_id;
avrc_cmd.reg_notif.param = event_parameter;
avrc_cmd.reg_notif.pdu = AVRC_PDU_REGISTER_NOTIFICATION;
status = AVRC_BldCommand(&avrc_cmd, &p_msg);
if (status == AVRC_STS_NO_ERROR) {
if (btc_rc_vb.rc_features & BTA_AV_FEAT_METADATA) {
BTA_AvMetaCmd(btc_rc_vb.rc_handle, tl, AVRC_CMD_NOTIF, p_msg);
status = BT_STATUS_SUCCESS;
} else {
status = BT_STATUS_FAIL;
LOG_DEBUG("%s: feature not supported", __FUNCTION__);
}
}
#else
LOG_DEBUG("%s: feature not enabled", __FUNCTION__);
#endif
return status;
}
static bt_status_t btc_avrc_ct_send_metadata_cmd (uint8_t tl, uint8_t attr_mask)
{
tAVRC_STS status = BT_STATUS_UNSUPPORTED;
#if (AVRC_METADATA_INCLUDED == TRUE)
CHECK_ESP_RC_CONNECTED;
uint32_t index = 0;
tAVRC_COMMAND avrc_cmd = {0};
BT_HDR *p_msg = NULL;
avrc_cmd.get_elem_attrs.opcode = AVRC_OP_VENDOR;
avrc_cmd.get_elem_attrs.status = AVRC_STS_NO_ERROR;
avrc_cmd.get_elem_attrs.pdu = AVRC_PDU_GET_ELEMENT_ATTR;
for (int count = 0; count < AVRC_MAX_ELEM_ATTR_SIZE; count++) {
if ((attr_mask & (1 << count)) > 0) {
avrc_cmd.get_elem_attrs.attrs[index] = count + 1;
index++;
}
}
avrc_cmd.get_elem_attrs.num_attr = index;
status = AVRC_BldCommand(&avrc_cmd, &p_msg);
if (status == AVRC_STS_NO_ERROR) {
if (btc_rc_vb.rc_features & BTA_AV_FEAT_METADATA) {
BTA_AvMetaCmd(btc_rc_vb.rc_handle, tl, AVRC_CMD_STATUS, p_msg);
status = BT_STATUS_SUCCESS;
} else {
status = BT_STATUS_FAIL;
LOG_DEBUG("%s: feature not supported", __FUNCTION__);
}
}
#else
LOG_DEBUG("%s: feature not enabled", __FUNCTION__);
#endif
return status;
}
static bt_status_t btc_avrc_ct_send_passthrough_cmd(uint8_t tl, uint8_t key_code, uint8_t key_state)
{
tAVRC_STS status = BT_STATUS_UNSUPPORTED;
if (tl >= 16 ||
key_state > ESP_AVRC_PT_CMD_STATE_RELEASED) {
return ESP_ERR_INVALID_ARG;
}
#if (AVRC_CTLR_INCLUDED == TRUE)
CHECK_ESP_RC_CONNECTED;
LOG_DEBUG("%s: key-code: %d, key-state: %d", __FUNCTION__,
@ -436,6 +601,18 @@ void btc_avrc_call_handler(btc_msg_t *msg)
// todo: callback to application
break;
}
case BTC_AVRC_STATUS_API_SND_META_EVT: {
btc_avrc_ct_send_metadata_cmd(arg->md_cmd.tl, arg->md_cmd.attr_mask);
break;
}
case BTC_AVRC_NOTIFY_API_SND_REG_NOTIFY_EVT: {
btc_avrc_ct_send_register_notification_cmd(arg->rn_cmd.tl, arg->rn_cmd.event_id, arg->rn_cmd.event_parameter);
break;
}
case BTC_AVRC_CTRL_API_SET_PLAYER_SETTING_EVT: {
btc_avrc_ct_send_set_player_value_cmd(arg->ps_cmd.tl, arg->ps_cmd.attr_id, arg->ps_cmd.value_id);
break;
}
default:
LOG_WARN("%s : unhandled event: %d\n", __FUNCTION__, msg->act);
}

View File

@ -115,6 +115,9 @@ static esp_bt_status_t btc_hci_to_esp_status(uint8_t hci_status)
case HCI_SUCCESS:
esp_status = ESP_BT_STATUS_SUCCESS;
break;
case HCI_ERR_ESP_VENDOR_FAIL:
esp_status = ESP_BT_STATUS_FAIL;
break;
case HCI_ERR_HOST_TIMEOUT:
esp_status = ESP_BT_STATUS_TIMEOUT;
break;
@ -130,6 +133,9 @@ static esp_bt_status_t btc_hci_to_esp_status(uint8_t hci_status)
case HCI_ERR_ILLEGAL_PARAMETER_FMT:
esp_status = ESP_BT_STATUS_ERR_ILLEGAL_PARAMETER_FMT;
break;
case HCI_ERR_MEMORY_FULL:
esp_status = ESP_BT_STATUS_MEMORY_FULL;
break;
default:
esp_status = ESP_BT_STATUS_FAIL;
break;
@ -166,6 +172,12 @@ static esp_bt_status_t btc_btm_status_to_esp_status (uint8_t btm_status)
case BTM_SET_PRIVACY_FAIL:
esp_status = ESP_BT_STATUS_FAIL;
break;
case BTM_INVALID_STATIC_RAND_ADDR:
esp_status = ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR;
break;
case BTM_SET_STATIC_RAND_ADDR_FAIL:
esp_status = ESP_BT_STATUS_FAIL;
break;
default:
esp_status = ESP_BT_STATUS_FAIL;
break;
@ -438,7 +450,7 @@ static void btc_ble_set_scan_rsp_data_raw(uint8_t *raw_scan_rsp, uint32_t raw_sc
BTA_DmBleSetScanRspRaw(raw_scan_rsp, raw_scan_rsp_len, p_scan_rsp_data_cback);
}
static void btc_start_adv_callback(tBTA_STATUS status)
static void btc_start_adv_callback(uint8_t status)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
@ -447,7 +459,7 @@ static void btc_start_adv_callback(tBTA_STATUS status)
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_ADV_START_COMPLETE_EVT;
param.adv_start_cmpl.status = status;
param.adv_start_cmpl.status = btc_hci_to_esp_status(status);
ret = btc_transfer_context(&msg, &param,
sizeof(esp_ble_gap_cb_param_t), NULL);
@ -457,7 +469,7 @@ static void btc_start_adv_callback(tBTA_STATUS status)
}
}
static void btc_stop_adv_callback(tBTA_STATUS status)
static void btc_stop_adv_callback(uint8_t status)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
@ -466,7 +478,7 @@ static void btc_stop_adv_callback(tBTA_STATUS status)
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_ADV_STOP_COMPLETE_EVT;
param.adv_stop_cmpl.status = status;
param.adv_stop_cmpl.status = btc_hci_to_esp_status(status);
ret = btc_transfer_context(&msg, &param,
sizeof(esp_ble_gap_cb_param_t), NULL);
@ -479,24 +491,36 @@ static void btc_stop_adv_callback(tBTA_STATUS status)
static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params, tBTA_START_ADV_CMPL_CBACK start_adv_cback)
{
tBLE_BD_ADDR peer_addr;
esp_bt_status_t status = ESP_BT_STATUS_SUCCESS;
if (!BLE_ISVALID_PARAM(ble_adv_params->adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) ||
!BLE_ISVALID_PARAM(ble_adv_params->adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX)) {
status = ESP_BT_STATUS_PARM_INVALID;
LOG_ERROR("Invalid advertisting interval parameters.\n");
return ;
}
if ((ble_adv_params->adv_type < ADV_TYPE_IND) &&
if ((ble_adv_params->adv_type < ADV_TYPE_IND) ||
(ble_adv_params->adv_type > ADV_TYPE_DIRECT_IND_LOW) ) {
status = ESP_BT_STATUS_PARM_INVALID;
LOG_ERROR("Invalid advertisting type parameters.\n");
return;
}
if ((ble_adv_params->adv_filter_policy < ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY) &&
if ((ble_adv_params->adv_filter_policy < ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY) ||
(ble_adv_params->adv_filter_policy > ADV_FILTER_ALLOW_SCAN_WLST_CON_WLST) ) {
status = ESP_BT_STATUS_PARM_INVALID;
LOG_ERROR("Invalid advertisting type parameters.\n");
}
if((ble_adv_params->channel_map | ADV_CHNL_ALL) != ADV_CHNL_ALL || ble_adv_params->channel_map == 0) {
status = ESP_BT_STATUS_PARM_INVALID;
LOG_ERROR("Invalid advertisting channel map parameters.\n");
}
if(status != ESP_BT_STATUS_SUCCESS) {
if(start_adv_cback) {
start_adv_cback(status);
}
return;
}
LOG_DEBUG("API_Ble_AppStartAdvertising\n");
memcpy(peer_addr.bda, ble_adv_params->peer_addr, ESP_BD_ADDR_LEN);
@ -546,8 +570,8 @@ static void btc_ble_set_scan_params(esp_ble_scan_params_t *scan_params, tBLE_SCA
scan_params->own_addr_type,
scan_param_setup_cback);
} else {
btc_scan_params_callback(ESP_DEFAULT_GATT_IF, BTM_ILLEGAL_VALUE);
}
btc_scan_params_callback(ESP_DEFAULT_GATT_IF, BTM_ILLEGAL_VALUE);
}
}
static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
@ -566,7 +590,7 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data
param.scan_rst.dev_type = p_data->inq_res.device_type;
param.scan_rst.rssi = p_data->inq_res.rssi;
param.scan_rst.ble_addr_type = p_data->inq_res.ble_addr_type;
param.scan_rst.ble_evt_type = p_data->inq_res.ble_evt_type;
param.scan_rst.ble_evt_type = p_data->inq_res.ble_evt_type;
param.scan_rst.flag = p_data->inq_res.flag;
param.scan_rst.num_resps = 1;
param.scan_rst.adv_data_len = p_data->inq_res.adv_data_len;
@ -601,7 +625,7 @@ static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data
btc_transfer_context(&msg, &param, sizeof(esp_ble_gap_cb_param_t), NULL);
}
static void btc_start_scan_callback(tBTA_STATUS status)
static void btc_start_scan_callback(uint8_t status)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
@ -688,9 +712,9 @@ static void btc_add_whitelist_complete_callback(UINT8 status, tBTM_WL_OPERATION
btc_msg_t msg;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_ADD_WHITELIST_COMPLETE_EVT;
param.add_whitelist_cmpl.status = btc_hci_to_esp_status(status);
param.add_whitelist_cmpl.wl_opration = wl_opration;
msg.act = ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT;
param.update_whitelist_cmpl.status = btc_hci_to_esp_status(status);
param.update_whitelist_cmpl.wl_opration = wl_opration;
ret = btc_transfer_context(&msg, &param,
sizeof(esp_ble_gap_cb_param_t), NULL);
@ -699,6 +723,24 @@ static void btc_add_whitelist_complete_callback(UINT8 status, tBTM_WL_OPERATION
}
}
static void btc_set_rand_addr_callback(UINT8 status)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg;
param.set_rand_addr_cmpl.status = btc_btm_status_to_esp_status(status); //todo status
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT;
ret = btc_transfer_context(&msg, &param,
sizeof(esp_ble_gap_cb_param_t), NULL);
if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
static void btc_set_local_privacy_callback(UINT8 status)
{
esp_ble_gap_cb_param_t param;
@ -806,13 +848,8 @@ static void btc_ble_set_pkt_data_len(BD_ADDR remote_device, uint16_t tx_data_len
BTA_DmBleSetDataLength(remote_device, tx_data_length, p_set_pkt_data_cback);
}
static void btc_ble_set_rand_addr (BD_ADDR rand_addr)
static void btc_ble_set_rand_addr (BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *p_set_rand_addr_cback)
{
esp_ble_gap_cb_param_t param;
bt_status_t ret;
btc_msg_t msg;
param.set_rand_addr_cmpl.status = ESP_BT_STATUS_SUCCESS;
if (rand_addr != NULL) {
/*
A static address is a 48-bit randomly generated address and shall meet the following requirements:
@ -827,25 +864,15 @@ static void btc_ble_set_rand_addr (BD_ADDR rand_addr)
if((rand_addr[0] & BT_STATIC_RAND_ADDR_MASK) == BT_STATIC_RAND_ADDR_MASK
&& memcmp(invalid_rand_addr_a, rand_addr, BD_ADDR_LEN) != 0
&& memcmp(invalid_rand_addr_b, rand_addr, BD_ADDR_LEN) != 0){
BTA_DmSetRandAddress(rand_addr);
BTA_DmSetRandAddress(rand_addr, btc_set_rand_addr_callback);
} else {
param.set_rand_addr_cmpl.status = ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR;
btc_set_rand_addr_callback(BTM_INVALID_STATIC_RAND_ADDR);
LOG_ERROR("Invalid random address, the high bit should be 0b11, all bits of the random part shall not be to 1 or 0");
}
} else {
param.set_rand_addr_cmpl.status = ESP_BT_STATUS_INVALID_STATIC_RAND_ADDR;
btc_set_rand_addr_callback(BTM_INVALID_STATIC_RAND_ADDR);
LOG_ERROR("Invalid random addressm, the address value is NULL");
}
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_GAP_BLE;
msg.act = ESP_GAP_BLE_SET_STATIC_RAND_ADDR_EVT;
ret = btc_transfer_context(&msg, &param,
sizeof(esp_ble_gap_cb_param_t), NULL);
if (ret != BT_STATUS_SUCCESS) {
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
}
}
static void btc_ble_config_local_privacy(bool privacy_enable, tBTA_SET_LOCAL_PRIVACY_CBACK *set_local_privacy_cback)
@ -1042,12 +1069,12 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
case BTC_GAP_BLE_ACT_SET_RAND_ADDRESS: {
BD_ADDR bd_addr;
memcpy(bd_addr, arg->set_rand_addr.rand_addr, sizeof(BD_ADDR));
btc_ble_set_rand_addr(bd_addr);
btc_ble_set_rand_addr(bd_addr, btc_set_rand_addr_callback);
break;
}
case BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY:
btc_ble_config_local_privacy(arg->cfg_local_privacy.privacy_enable, btc_set_local_privacy_callback);
break;
break;
case BTC_GAP_BLE_ACT_UPDATE_WHITE_LIST:
BTA_DmUpdateWhiteList(arg->update_white_list.add_remove, arg->update_white_list.remote_bda, btc_add_whitelist_complete_callback);
break;
@ -1113,12 +1140,12 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
STREAM_TO_UINT8(key_size, arg->set_security_param.value);
bta_dm_co_ble_set_max_key_size(key_size);
break;
}
}
default:
break;
}
break;
}
}
case BTC_GAP_BLE_SECURITY_RSP_EVT: {
BD_ADDR bd_addr;
tBTA_DM_BLE_SEC_GRANT res = arg->sec_rsp.accept ? BTA_DM_SEC_GRANTED : BTA_DM_SEC_PAIR_NOT_SPT;

View File

@ -196,7 +196,7 @@ static void btc_gattc_app_unregister(btc_ble_gattc_args_t *arg)
static void btc_gattc_open(btc_ble_gattc_args_t *arg)
{
tBTA_GATT_TRANSPORT transport = BTA_GATT_TRANSPORT_LE;
BTA_GATTC_Open(arg->open.gattc_if, arg->open.remote_bda, arg->open.is_direct, transport);
BTA_GATTC_Open(arg->open.gattc_if, arg->open.remote_bda, arg->open.remote_addr_type, arg->open.is_direct, transport);
}
static void btc_gattc_close(btc_ble_gattc_args_t *arg)
@ -253,7 +253,7 @@ static void btc_gattc_fill_gatt_db_conversion(uint16_t count, uint16_t num, esp_
}
case ESP_GATT_DB_DESCRIPTOR: {
esp_gattc_descr_elem_t *descr_result = (esp_gattc_descr_elem_t *)result;
for (int i = 0; i < (num - offset); i++) {
for (int i = 0; i < db_size; i++) {
descr_result->handle = db[offset + i].attribute_handle;
btc128_to_bta_uuid(&bta_uuid, db[offset + i].uuid.uu);
bta_to_btc_uuid(&descr_result->uuid, &bta_uuid);
@ -770,6 +770,7 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
param.write.conn_id = BTC_GATT_GET_CONN_ID(write->conn_id);
param.write.status = write->status;
param.write.handle = write->handle;
param.write.offset = write->offset;
btc_gattc_cb_to_app(ret_evt, gattc_if, &param);
break;
}
@ -913,8 +914,19 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
break;
}
case BTA_GATTC_SRVC_CHG_EVT: {
memcpy(param.srvc_chg.remote_bda, arg->remote_bda, sizeof(esp_bd_addr_t));
btc_gattc_cb_to_app(ESP_GATTC_SRVC_CHG_EVT, ESP_GATT_IF_NONE, &param);
tBTA_GATTC_SERVICE_CHANGE *srvc_change = &arg->srvc_chg;
gattc_if = BTC_GATT_GET_GATT_IF(srvc_change->conn_id);
memcpy(param.srvc_chg.remote_bda, srvc_change->remote_bda, sizeof(esp_bd_addr_t));
btc_gattc_cb_to_app(ESP_GATTC_SRVC_CHG_EVT, gattc_if, &param);
break;
}
case BTA_GATTC_QUEUE_FULL_EVT: {
tBTA_GATTC_QUEUE_FULL *queue_full = &arg->queue_full;
gattc_if = BTC_GATT_GET_GATT_IF(queue_full->conn_id);
param.queue_full.conn_id = BTC_GATT_GET_CONN_ID(queue_full->conn_id);
param.queue_full.status = arg->status;
param.queue_full.is_full = queue_full->is_full;
btc_gattc_cb_to_app(ESP_GATTC_QUEUE_FULL_EVT, gattc_if, &param);
break;
}
default:

View File

@ -832,7 +832,7 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
param.add_char_descr.status = p_data->add_result.status;
param.add_char_descr.attr_handle = p_data->add_result.attr_id;
param.add_char_descr.service_handle = p_data->add_result.service_id;
bta_to_btc_uuid(&param.add_char_descr.char_uuid, &p_data->add_result.char_uuid);
bta_to_btc_uuid(&param.add_char_descr.descr_uuid, &p_data->add_result.char_uuid);
btc_gatts_cb_to_app(ESP_GATTS_ADD_CHAR_DESCR_EVT, gatts_if, &param);
break;

View File

@ -28,18 +28,14 @@
#define BTC_AVRC_TGT_INCLUDED FALSE
#endif
/* Macros */
typedef enum {
BTRC_FEAT_NONE = 0x00, /* AVRCP 1.0 */
BTRC_FEAT_METADATA = 0x01, /* AVRCP 1.3 */
BTRC_FEAT_ABSOLUTE_VOLUME = 0x02, /* Supports TG role and volume sync */
BTRC_FEAT_BROWSE = 0x04, /* AVRCP 1.4 and up, with Browsing support */
} btrc_remote_features_t;
typedef enum {
BTC_AVRC_CTRL_API_INIT_EVT = 0,
BTC_AVRC_CTRL_API_DEINIT_EVT,
BTC_AVRC_CTRL_API_SND_PTCMD_EVT
BTC_AVRC_CTRL_API_SND_PTCMD_EVT,
BTC_AVRC_STATUS_API_SND_META_EVT,
BTC_AVRC_STATUS_API_SND_PLAY_STATUS_EVT,
BTC_AVRC_NOTIFY_API_SND_REG_NOTIFY_EVT,
BTC_AVRC_CTRL_API_SET_PLAYER_SETTING_EVT
} btc_avrc_act_t;
typedef struct {
@ -48,14 +44,29 @@ typedef struct {
uint8_t key_state;
} pt_cmd_t;
typedef struct {
uint8_t tl;
uint8_t attr_mask;
} md_cmd_t;
typedef struct {
uint8_t tl;
uint8_t event_id;
uint32_t event_parameter;
} rn_cmd_t;
typedef struct {
uint8_t tl;
uint8_t attr_id;
uint8_t value_id;
} ps_cmd_t;
/* btc_avrc_args_t */
typedef union {
// BTC_AVRC_CTRL_API_SND_PT_CMD_EVT
struct {
uint8_t tl;
uint8_t key_code;
uint8_t key_state;
} pt_cmd;
pt_cmd_t pt_cmd;
md_cmd_t md_cmd;
rn_cmd_t rn_cmd;
ps_cmd_t ps_cmd;
} btc_avrc_args_t;
/** BT-RC Controller callback structure. */

View File

@ -54,6 +54,7 @@ typedef union {
struct open_arg {
esp_gatt_if_t gattc_if;
esp_bd_addr_t remote_bda;
esp_ble_addr_type_t remote_addr_type;
bool is_direct;
} open;
//BTC_GATTC_ACT_CLOSE,

View File

@ -102,10 +102,13 @@ bool string_to_bdaddr(const char *string, bt_bdaddr_t *addr)
bt_bdaddr_t new_addr;
uint8_t *ptr = new_addr.address;
bool ret = sscanf(string, "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
&ptr[0], &ptr[1], &ptr[2], &ptr[3], &ptr[4], &ptr[5]) == 6;
uint32_t ptr_32[6];
bool ret = sscanf(string, "%02x:%02x:%02x:%02x:%02x:%02x",
&ptr_32[0], &ptr_32[1], &ptr_32[2], &ptr_32[3], &ptr_32[4], &ptr_32[5]) == 6;
if (ret) {
for (uint8_t i = 0; i < 6; i++){
ptr[i] = (uint8_t) ptr_32[i];
}
memcpy(addr, &new_addr, sizeof(bt_bdaddr_t));
}

View File

@ -492,7 +492,7 @@ void bta_dm_co_ble_set_rsp_key_req(UINT8 rsp_key)
{
#if (SMP_INCLUDED == TRUE)
rsp_key &= 0x0f; // 4~7bit reservd, only used the 0~3bit
bte_appl_cfg.ble_init_key &= rsp_key;
bte_appl_cfg.ble_resp_key &= rsp_key;
#endif ///SMP_INCLUDED == TRUE
}

View File

@ -66,6 +66,7 @@ static uint8_t ble_resolving_list_max_size;
static uint8_t ble_supported_states[BLE_SUPPORTED_STATES_SIZE];
static bt_device_features_t features_ble;
static uint16_t ble_suggested_default_data_length;
static uint16_t ble_suggested_default_data_txtime;
static bool readable;
static bool ble_supported;
@ -228,7 +229,8 @@ static void start_up(void)
response = AWAIT_COMMAND(packet_factory->make_ble_read_suggested_default_data_length());
packet_parser->parse_ble_read_suggested_default_data_length_response(
response,
&ble_suggested_default_data_length);
&ble_suggested_default_data_length,
&ble_suggested_default_data_txtime);
}
// Set the ble event mask next
@ -404,6 +406,13 @@ static uint16_t get_ble_suggested_default_data_length(void)
return ble_suggested_default_data_length;
}
static uint16_t get_ble_suggested_default_data_txtime(void)
{
assert(readable);
assert(ble_supported);
return ble_suggested_default_data_txtime;
}
static uint16_t get_acl_buffer_count_classic(void)
{
assert(readable);
@ -472,6 +481,7 @@ static const controller_t interface = {
get_acl_packet_size_classic,
get_acl_packet_size_ble,
get_ble_suggested_default_data_length,
get_ble_suggested_default_data_txtime,
get_acl_buffer_count_classic,
get_acl_buffer_count_ble,

View File

@ -69,6 +69,7 @@ typedef struct controller_t {
uint16_t (*get_acl_packet_size_ble)(void);
uint16_t (*get_ble_default_data_packet_length)(void);
uint16_t (*get_ble_default_data_packet_txtime)(void);
// Get the number of acl packets the controller can buffer.
uint16_t (*get_acl_buffer_count_classic)(void);

View File

@ -25,7 +25,7 @@
#include "hci_internals.h"
#include "hci_layer.h"
#include "thread.h"
#include "bt.h"
#include "esp_bt.h"
#define HCI_HAL_SERIAL_BUFFER_SIZE 1026
#define HCI_BLE_EVENT 0x3e

View File

@ -16,7 +16,7 @@
*
******************************************************************************/
#include <string.h>
#include "bt.h"
#include "esp_bt.h"
#include "bt_defs.h"
#include "bt_trace.h"
#include "hcidefs.h"
@ -40,7 +40,6 @@ typedef struct {
command_complete_cb complete_callback;
command_status_cb status_callback;
void *context;
uint32_t sent_time;
BT_HDR *command;
} waiting_command_t;
@ -90,9 +89,7 @@ static void hci_layer_deinit_env(void);
static void hci_host_thread_handler(void *arg);
static void event_command_ready(fixed_queue_t *queue);
static void event_packet_ready(fixed_queue_t *queue);
static void restart_comamnd_waiting_response_timer(
command_waiting_response_t *cmd_wait_q,
bool tigger_by_sending_command);
static void restart_command_waiting_response_timer(command_waiting_response_t *cmd_wait_q);
static void command_timed_out(void *context);
static void hal_says_packet_ready(BT_HDR *packet);
static bool filter_incoming_event(BT_HDR *packet);
@ -330,8 +327,7 @@ static void event_command_ready(fixed_queue_t *queue)
// Send it off
packet_fragmenter->fragment_and_dispatch(wait_entry->command);
wait_entry->sent_time = osi_alarm_now();
restart_comamnd_waiting_response_timer(cmd_wait_q, true);
restart_command_waiting_response_timer(cmd_wait_q);
}
static void event_packet_ready(fixed_queue_t *queue)
@ -377,41 +373,18 @@ static void fragmenter_transmit_finished(BT_HDR *packet, bool all_fragments_sent
}
}
static void restart_comamnd_waiting_response_timer(
command_waiting_response_t *cmd_wait_q,
bool tigger_by_sending_command)
static void restart_command_waiting_response_timer(command_waiting_response_t *cmd_wait_q)
{
uint32_t timeout;
waiting_command_t *wait_entry;
if (!cmd_wait_q) {
return;
}
osi_mutex_lock(&cmd_wait_q->commands_pending_response_lock, OSI_MUTEX_MAX_TIMEOUT);
if (cmd_wait_q->timer_is_set) {
if (tigger_by_sending_command) {
return;
}
//Cancel Previous command timeout timer setted when sending command
osi_alarm_cancel(cmd_wait_q->command_response_timer);
cmd_wait_q->timer_is_set = false;
}
osi_mutex_lock(&cmd_wait_q->commands_pending_response_lock, OSI_MUTEX_MAX_TIMEOUT);
wait_entry = (list_is_empty(cmd_wait_q->commands_pending_response) ?
NULL : list_front(cmd_wait_q->commands_pending_response));
osi_mutex_unlock(&cmd_wait_q->commands_pending_response_lock);
if (wait_entry == NULL) {
return;
if (!list_is_empty(cmd_wait_q->commands_pending_response)) {
osi_alarm_set(cmd_wait_q->command_response_timer, COMMAND_PENDING_TIMEOUT);
cmd_wait_q->timer_is_set = true;
}
timeout = osi_alarm_time_diff(osi_alarm_now(), wait_entry->sent_time);
timeout = osi_alarm_time_diff(COMMAND_PENDING_TIMEOUT, timeout);
timeout = (timeout <= COMMAND_PENDING_TIMEOUT) ? timeout : COMMAND_PENDING_TIMEOUT;
cmd_wait_q->timer_is_set = true;
osi_alarm_set(cmd_wait_q->command_response_timer, timeout);
osi_mutex_unlock(&cmd_wait_q->commands_pending_response_lock);
}
static void command_timed_out(void *context)
@ -493,7 +466,7 @@ static bool filter_incoming_event(BT_HDR *packet)
return false;
intercepted:
restart_comamnd_waiting_response_timer(&hci_host_env.cmd_waiting_q, false);
restart_command_waiting_response_timer(&hci_host_env.cmd_waiting_q);
/*Tell HCI Host Task to continue TX Pending commands*/
if (hci_host_env.command_credits &&

View File

@ -183,12 +183,13 @@ static void parse_ble_read_resolving_list_size_response(
static void parse_ble_read_suggested_default_data_length_response(
BT_HDR *response,
uint16_t *ble_default_packet_length_ptr)
uint16_t *ble_default_packet_length_ptr,
uint16_t *ble_default_packet_txtime_ptr)
{
uint8_t *stream = read_command_complete_header(response, HCI_BLE_READ_DEFAULT_DATA_LENGTH, 2 /* bytes after */);
STREAM_TO_UINT8(*ble_default_packet_length_ptr, stream);
STREAM_TO_UINT16(*ble_default_packet_length_ptr, stream);
STREAM_TO_UINT16(*ble_default_packet_txtime_ptr, stream);
buffer_allocator->free(response);
}

View File

@ -90,7 +90,8 @@ typedef struct {
void (*parse_ble_read_suggested_default_data_length_response)(
BT_HDR *response,
uint16_t *ble_default_packet_length_ptr
uint16_t *ble_default_packet_length_ptr,
uint16_t *ble_default_packet_txtime_ptr
);
} hci_packet_parser_t;

View File

@ -90,6 +90,7 @@ typedef enum {
BT_STATUS_UNACCEPT_CONN_INTERVAL,
BT_STATUS_PARAM_OUT_OF_RANGE,
BT_STATUS_TIMEOUT,
BT_STATUS_MEMORY_FULL,
} bt_status_t;
#ifndef CPU_LITTLE_ENDIAN

View File

@ -647,7 +647,8 @@
/* 4.1/4.2 secure connections feature */
#ifndef SC_MODE_INCLUDED
#define SC_MODE_INCLUDED TRUE
// Disable AES-CCM (BT 4.1) for BT Classic to workaround controller AES issue. E0 encryption (BT 4.0) will be used.
#define SC_MODE_INCLUDED FALSE
#endif
/* Used for conformance testing ONLY */

View File

@ -23,22 +23,18 @@
#include "alarm.h"
#include "allocator.h"
#include "list.h"
#include "thread.h"
#include "freertos/FreeRTOSConfig.h"
#include "freertos/xtensa_api.h"
#include "rom/ets_sys.h"
#include "esp_timer.h"
#include "btc_task.h"
#include "btc_alarm.h"
#include "mutex.h"
#include "time.h"
#define RTC_TIMER_TICKS_TO_MS(ticks) (((ticks/625)<<1) + (ticks-(ticks/625)*625)/312)
#define BT_ALARM_START_WAIT_TICKS 100
#define BT_ALARM_STOP_WAIT_TICKS 100
#define BT_ALARM_FREE_WAIT_TICKS 100
#define BT_ALARM_CHG_PERIOD_WAIT_TICKS 100
typedef struct alarm_t {
/* timer id point to here */
esp_timer_handle_t alarm_hdl;
osi_alarm_callback_t cb;
void *cb_data;
int64_t deadline_us;
} osi_alarm_t;
enum {
ALARM_STATE_IDLE,
@ -50,7 +46,7 @@ static int alarm_state;
static struct alarm_t alarm_cbs[ALARM_CBS_NUM];
static int alarm_free(osi_alarm_t *alarm);
static osi_alarm_err_t alarm_free(osi_alarm_t *alarm);
int osi_alarm_create_mux(void)
{
@ -71,11 +67,11 @@ int osi_alarm_delete_mux(void)
osi_mutex_free(&alarm_mutex);
return 0;
}
void osi_alarm_init(void)
{
assert(alarm_mutex != NULL);
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
if (alarm_state != ALARM_STATE_IDLE) {
LOG_WARN("%s, invalid state %d\n", __func__, alarm_state);
@ -83,7 +79,7 @@ void osi_alarm_init(void)
}
memset(alarm_cbs, 0x00, sizeof(alarm_cbs));
alarm_state = ALARM_STATE_OPEN;
end:
osi_mutex_unlock(&alarm_mutex);
}
@ -91,13 +87,13 @@ end:
void osi_alarm_deinit(void)
{
assert(alarm_mutex != NULL);
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
if (alarm_state != ALARM_STATE_OPEN) {
LOG_WARN("%s, invalid state %d\n", __func__, alarm_state);
goto end;
}
for (int i = 0; i < ALARM_CBS_NUM; i++) {
if (alarm_cbs[i].alarm_hdl != NULL) {
alarm_free(&alarm_cbs[i]);
@ -123,17 +119,13 @@ static struct alarm_t *alarm_cbs_lookfor_available(void)
return NULL;
}
static void alarm_cb_handler(TimerHandle_t xTimer)
static void alarm_cb_handler(struct alarm_t *alarm)
{
struct alarm_t *alarm;
if (!xTimer) {
LOG_ERROR("TimerName: NULL\n");
LOG_DEBUG("TimerID %p\n", alarm);
if (alarm_state != ALARM_STATE_OPEN) {
LOG_WARN("%s, invalid state %d\n", __func__, alarm_state);
return;
}
alarm = pvTimerGetTimerID(xTimer);
LOG_DEBUG("TimerID %p, Name %s\n", alarm, pcTimerGetTimerName(xTimer));
btc_msg_t msg;
btc_alarm_args_t arg;
msg.sig = BTC_SIG_API_CALL;
@ -143,19 +135,19 @@ static void alarm_cb_handler(TimerHandle_t xTimer)
btc_transfer_context(&msg, &arg, sizeof(btc_alarm_args_t), NULL);
}
osi_alarm_t *osi_alarm_new(char *alarm_name, osi_alarm_callback_t callback, void *data, period_ms_t timer_expire)
osi_alarm_t *osi_alarm_new(const char *alarm_name, osi_alarm_callback_t callback, void *data, period_ms_t timer_expire)
{
assert(alarm_mutex != NULL);
struct alarm_t *timer_id = NULL;
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
if (alarm_state != ALARM_STATE_OPEN) {
LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state);
timer_id = NULL;
goto end;
}
timer_id = alarm_cbs_lookfor_available();
if (!timer_id) {
@ -164,161 +156,134 @@ osi_alarm_t *osi_alarm_new(char *alarm_name, osi_alarm_callback_t callback, void
goto end;
}
if (timer_expire == 0) {
timer_expire = 1000;
}
esp_timer_create_args_t tca;
tca.callback = (esp_timer_cb_t)alarm_cb_handler;
tca.arg = timer_id;
tca.dispatch_method = ESP_TIMER_TASK;
tca.name = alarm_name;
TimerHandle_t t = xTimerCreate(alarm_name, timer_expire / portTICK_PERIOD_MS, pdFALSE, timer_id, alarm_cb_handler);
if (!t) {
LOG_ERROR("%s failed to create timer\n", __func__);
timer_id->cb = callback;
timer_id->cb_data = data;
timer_id->deadline_us = 0;
esp_err_t stat = esp_timer_create(&tca, &timer_id->alarm_hdl);
if (stat != ESP_OK) {
LOG_ERROR("%s failed to create timer, err 0x%x\n", __func__, stat);
timer_id = NULL;
goto end;
}
timer_id->alarm_hdl = t;
timer_id->cb = callback;
timer_id->cb_data = data;
end:
osi_mutex_unlock(&alarm_mutex);
return timer_id;
}
static int alarm_free(osi_alarm_t *alarm)
static osi_alarm_err_t alarm_free(osi_alarm_t *alarm)
{
if (!alarm || alarm->alarm_hdl == NULL) {
LOG_ERROR("%s null\n", __func__);
return -1;
return OSI_ALARM_ERR_INVALID_ARG;
}
if (xTimerDelete(alarm->alarm_hdl, BT_ALARM_FREE_WAIT_TICKS) != pdPASS) {
LOG_ERROR("%s alarm delete error\n", __func__);
return -2;
esp_timer_stop(alarm->alarm_hdl);
esp_err_t stat = esp_timer_delete(alarm->alarm_hdl);
if (stat != ESP_OK) {
LOG_ERROR("%s failed to delete timer, err 0x%x\n", __func__, stat);
return OSI_ALARM_ERR_FAIL;
}
memset(alarm, 0, sizeof(osi_alarm_t));
return 0;
return OSI_ALARM_ERR_PASS;
}
int osi_alarm_free(osi_alarm_t *alarm)
void osi_alarm_free(osi_alarm_t *alarm)
{
assert(alarm_mutex != NULL);
int ret = 0;
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
if (alarm_state != ALARM_STATE_OPEN) {
LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state);
ret = -3;
goto end;
}
alarm_free(alarm);
end:
osi_mutex_unlock(&alarm_mutex);
return ret;
return;
}
int osi_alarm_set(osi_alarm_t *alarm, period_ms_t timeout)
osi_alarm_err_t osi_alarm_set(osi_alarm_t *alarm, period_ms_t timeout)
{
assert(alarm_mutex != NULL);
int ret = 0;
osi_alarm_err_t ret = OSI_ALARM_ERR_PASS;
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
if (alarm_state != ALARM_STATE_OPEN) {
LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state);
ret = -3;
goto end;
}
if (!alarm || alarm->alarm_hdl == NULL) {
LOG_ERROR("%s null\n", __func__);
ret = -1;
goto end;
}
if (xTimerChangePeriod(alarm->alarm_hdl, timeout / portTICK_PERIOD_MS, BT_ALARM_CHG_PERIOD_WAIT_TICKS) != pdPASS) {
LOG_ERROR("%s chg period error\n", __func__);
ret = -2;
ret = OSI_ALARM_ERR_INVALID_STATE;
goto end;
}
if (xTimerStart(alarm->alarm_hdl, BT_ALARM_START_WAIT_TICKS) != pdPASS) {
LOG_ERROR("%s start error\n", __func__);
ret = -2;
if (!alarm || alarm->alarm_hdl == NULL) {
LOG_ERROR("%s null\n", __func__);
ret = OSI_ALARM_ERR_INVALID_ARG;
goto end;
}
int64_t timeout_us = 1000 * (int64_t)timeout;
esp_err_t stat = esp_timer_start_once(alarm->alarm_hdl, (uint64_t)timeout_us);
if (stat != ESP_OK) {
LOG_ERROR("%s failed to start timer, err 0x%x\n", __func__, stat);
ret = OSI_ALARM_ERR_FAIL;
goto end;
}
alarm->deadline_us = timeout_us + esp_timer_get_time();
end:
osi_mutex_unlock(&alarm_mutex);
return ret;
}
int osi_alarm_cancel(osi_alarm_t *alarm)
osi_alarm_err_t osi_alarm_cancel(osi_alarm_t *alarm)
{
int ret = 0;
int ret = OSI_ALARM_ERR_PASS;
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
if (alarm_state != ALARM_STATE_OPEN) {
LOG_ERROR("%s, invalid state %d\n", __func__, alarm_state);
ret = -3;
ret = OSI_ALARM_ERR_INVALID_STATE;
goto end;
}
if (!alarm || alarm->alarm_hdl == NULL) {
LOG_ERROR("%s null\n", __func__);
ret = -1;
ret = OSI_ALARM_ERR_INVALID_ARG;
goto end;
}
if (xTimerStop(alarm->alarm_hdl, BT_ALARM_STOP_WAIT_TICKS) != pdPASS) {
LOG_ERROR("%s failed to stop timer\n", __func__);
ret = -2;
esp_err_t stat = esp_timer_stop(alarm->alarm_hdl);
if (stat != ESP_OK) {
LOG_DEBUG("%s failed to stop timer, err 0x%x\n", __func__, stat);
ret = OSI_ALARM_ERR_FAIL;
goto end;
}
end:
osi_mutex_unlock(&alarm_mutex);
return ret;
}
static uint32_t alarm_current_tick(void)
{
return xTaskGetTickCount();
}
// todo: this is not accurate
// max return value: 0xffffffff / 312 = 13765920 = 0xD20D20
period_ms_t osi_alarm_now(void)
{
return RTC_TIMER_TICKS_TO_MS((alarm_current_tick()));
}
period_ms_t osi_alarm_get_remaining_ms(const osi_alarm_t *alarm)
{
/* TODO: use FreeRTOS timer.c implement ??? */
return 0xffffffff;
}
assert(alarm_mutex != NULL);
int64_t dt_us = 0;
// pre-condition: 0 <= t1, t2 <= 0xD20D20
// return value: 0<= ret <=0XD20D20
period_ms_t osi_alarm_time_diff(period_ms_t t1, period_ms_t t2)
{
#define MAX_ALARM_TIME_MS (0xD20D20)
int32_t diff = (int32_t)(t1) - (int32_t)(t2);
if (diff < 0) {
diff += MAX_ALARM_TIME_MS;
}
return (period_ms_t)diff;
osi_mutex_lock(&alarm_mutex, OSI_MUTEX_MAX_TIMEOUT);
dt_us = alarm->deadline_us - esp_timer_get_time();
osi_mutex_unlock(&alarm_mutex);
return (dt_us > 0) ? (period_ms_t)(dt_us / 1000) : 0;
}
uint32_t osi_time_get_os_boottime_ms(void)
{
return RTC_TIMER_TICKS_TO_MS((alarm_current_tick()));
return (uint32_t)(esp_timer_get_time() / 1000);
}
void osi_delay_ms(uint32_t ms)
{
vTaskDelay(ms / portTICK_PERIOD_MS);
}

View File

@ -28,8 +28,9 @@
#include "list.h"
#include "bt_trace.h"
#define CONFIG_FILE_MAX_SIZE (2048)
#define CONFIG_KEY "bt_cfg_key"
#define CONFIG_FILE_MAX_SIZE (1536)//1.5k
#define CONFIG_FILE_DEFAULE_LENGTH (2048)
#define CONFIG_KEY "bt_cfg_key"
typedef struct {
char *key;
char *value;
@ -134,7 +135,7 @@ bool config_has_key(const config_t *config, const char *section, const char *key
}
bool config_has_key_in_section(config_t *config, char *key, char *key_value)
{
{
LOG_DEBUG("key = %s, value = %s", key, key_value);
for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); node = list_next(node)) {
const section_t *section = (const section_t *)list_node(node);
@ -302,6 +303,78 @@ const char *config_section_name(const config_section_node_t *node)
return section->name;
}
static int get_config_size(const config_t *config)
{
assert(config != NULL);
int w_len = 0, total_size = 0;
for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); node = list_next(node)) {
const section_t *section = (const section_t *)list_node(node);
w_len = strlen(section->name) + strlen("[]\n");// format "[section->name]\n"
total_size += w_len;
for (const list_node_t *enode = list_begin(section->entries); enode != list_end(section->entries); enode = list_next(enode)) {
const entry_t *entry = (const entry_t *)list_node(enode);
w_len = strlen(entry->key) + strlen(entry->value) + strlen(" = \n");// format "entry->key = entry->value\n"
total_size += w_len;
}
// Only add a separating newline if there are more sections.
if (list_next(node) != list_end(config->sections)) {
total_size ++; //'\n'
} else {
break;
}
}
total_size ++; //'\0'
return total_size;
}
static int get_config_size_from_flash(nvs_handle fp)
{
assert(fp != 0);
esp_err_t err;
char *keyname = osi_calloc(sizeof(CONFIG_KEY) + 1);
if (!keyname){
LOG_ERROR("%s, malloc error\n", __func__);
return 0;
}
size_t length = CONFIG_FILE_DEFAULE_LENGTH;
size_t total_length = 0;
uint16_t i = 0;
snprintf(keyname, sizeof(CONFIG_KEY) + 1, "%s%d", CONFIG_KEY, 0);
err = nvs_get_blob(fp, keyname, NULL, &length);
if (err == ESP_ERR_NVS_NOT_FOUND) {
osi_free(keyname);
return 0;
}
if (err != ESP_OK) {
LOG_ERROR("%s, error %d\n", __func__, err);
osi_free(keyname);
return 0;
}
total_length += length;
while (length == CONFIG_FILE_MAX_SIZE) {
length = CONFIG_FILE_DEFAULE_LENGTH;
snprintf(keyname, sizeof(CONFIG_KEY) + 1, "%s%d", CONFIG_KEY, ++i);
err = nvs_get_blob(fp, keyname, NULL, &length);
if (err == ESP_ERR_NVS_NOT_FOUND) {
break;
}
if (err != ESP_OK) {
LOG_ERROR("%s, error %d\n", __func__, err);
osi_free(keyname);
return 0;
}
total_length += length;
}
osi_free(keyname);
return total_length;
}
bool config_save(const config_t *config, const char *filename)
{
assert(config != NULL);
@ -312,8 +385,10 @@ bool config_save(const config_t *config, const char *filename)
int err_code = 0;
nvs_handle fp;
char *line = osi_calloc(1024);
char *buf = osi_calloc(CONFIG_FILE_MAX_SIZE);
if (!line || !buf) {
char *keyname = osi_calloc(sizeof(CONFIG_KEY) + 1);
int config_size = get_config_size(config);
char *buf = osi_calloc(config_size + 100);
if (!line || !buf || !keyname) {
err_code |= 0x01;
goto error;
}
@ -333,45 +408,53 @@ bool config_save(const config_t *config, const char *filename)
const section_t *section = (const section_t *)list_node(node);
w_cnt = snprintf(line, 1024, "[%s]\n", section->name);
LOG_DEBUG("section name: %s, w_cnt + w_cnt_total = %d\n", section->name, w_cnt + w_cnt_total);
if (w_cnt + w_cnt_total < CONFIG_FILE_MAX_SIZE) {
memcpy(buf + w_cnt_total, line, w_cnt);
w_cnt_total += w_cnt;
} else {
break;
}
memcpy(buf + w_cnt_total, line, w_cnt);
w_cnt_total += w_cnt;
for (const list_node_t *enode = list_begin(section->entries); enode != list_end(section->entries); enode = list_next(enode)) {
const entry_t *entry = (const entry_t *)list_node(enode);
LOG_DEBUG("(key, val): (%s, %s)\n", entry->key, entry->value);
w_cnt = snprintf(line, 1024, "%s = %s\n", entry->key, entry->value);
LOG_DEBUG("%s, w_cnt + w_cnt_total = %d", __func__, w_cnt + w_cnt_total);
if (w_cnt + w_cnt_total < CONFIG_FILE_MAX_SIZE) {
memcpy(buf + w_cnt_total, line, w_cnt);
w_cnt_total += w_cnt;
} else {
break;
}
memcpy(buf + w_cnt_total, line, w_cnt);
w_cnt_total += w_cnt;
}
// Only add a separating newline if there are more sections.
if (list_next(node) != list_end(config->sections)) {
if (1 + w_cnt_total < CONFIG_FILE_MAX_SIZE) {
buf[w_cnt_total] = '\n';
w_cnt_total += 1;
}
buf[w_cnt_total] = '\n';
w_cnt_total += 1;
} else {
break;
}
}
buf[w_cnt_total] = '\0';
err = nvs_set_blob(fp, CONFIG_KEY, buf, w_cnt_total);
if (err != ESP_OK) {
nvs_close(fp);
err_code |= 0x04;
goto error;
if (w_cnt_total < CONFIG_FILE_MAX_SIZE) {
snprintf(keyname, sizeof(CONFIG_KEY)+1, "%s%d", CONFIG_KEY, 0);
err = nvs_set_blob(fp, keyname, buf, w_cnt_total);
if (err != ESP_OK) {
nvs_close(fp);
err_code |= 0x04;
goto error;
}
}else {
uint count = (w_cnt_total / CONFIG_FILE_MAX_SIZE);
for (int i = 0; i <= count; i++)
{
snprintf(keyname, sizeof(CONFIG_KEY)+1, "%s%d", CONFIG_KEY, i);
if (i == count) {
err = nvs_set_blob(fp, keyname, buf + i*CONFIG_FILE_MAX_SIZE, w_cnt_total - i*CONFIG_FILE_MAX_SIZE);
LOG_DEBUG("save keyname = %s, i = %d, %d\n", keyname, i, w_cnt_total - i*CONFIG_FILE_MAX_SIZE);
}else {
err = nvs_set_blob(fp, keyname, buf + i*CONFIG_FILE_MAX_SIZE, CONFIG_FILE_MAX_SIZE);
LOG_DEBUG("save keyname = %s, i = %d, %d\n", keyname, i, CONFIG_FILE_MAX_SIZE);
}
if (err != ESP_OK) {
nvs_close(fp);
err_code |= 0x04;
goto error;
}
}
}
err = nvs_commit(fp);
@ -384,6 +467,7 @@ bool config_save(const config_t *config, const char *filename)
nvs_close(fp);
osi_free(line);
osi_free(buf);
osi_free(keyname);
return true;
error:
@ -393,6 +477,9 @@ error:
if (line) {
osi_free(line);
}
if (keyname) {
osi_free(keyname);
}
if (err_code) {
LOG_ERROR("%s, err_code: 0x%x\n", __func__, err_code);
}
@ -423,29 +510,50 @@ static void config_parse(nvs_handle fp, config_t *config)
assert(fp != 0);
assert(config != NULL);
esp_err_t err;
int line_num = 0;
int err_code = 0;
uint16_t i = 0;
size_t length = CONFIG_FILE_DEFAULE_LENGTH;
size_t total_length = 0;
char *line = osi_calloc(1024);
char *section = osi_calloc(1024);
char *buf = osi_calloc(CONFIG_FILE_MAX_SIZE);
if (!line || !section || !buf) {
char *keyname = osi_calloc(sizeof(CONFIG_KEY) + 1);
int buf_size = get_config_size_from_flash(fp);
char *buf = osi_calloc(buf_size + 100);
if (!line || !section || !buf || !keyname) {
err_code |= 0x01;
goto error;
}
esp_err_t err;
size_t length = CONFIG_FILE_MAX_SIZE;
err = nvs_get_blob(fp, CONFIG_KEY, buf, &length);
snprintf(keyname, sizeof(CONFIG_KEY)+1, "%s%d", CONFIG_KEY, 0);
err = nvs_get_blob(fp, keyname, buf, &length);
if (err == ESP_ERR_NVS_NOT_FOUND) {
goto error;
}
if (err != ESP_OK) {
err_code |= 0x02;
goto error;
}
total_length += length;
while (length == CONFIG_FILE_MAX_SIZE) {
length = CONFIG_FILE_DEFAULE_LENGTH;
snprintf(keyname, sizeof(CONFIG_KEY) + 1, "%s%d", CONFIG_KEY, ++i);
err = nvs_get_blob(fp, keyname, buf + CONFIG_FILE_MAX_SIZE * i, &length);
if (err == ESP_ERR_NVS_NOT_FOUND) {
break;
}
if (err != ESP_OK) {
err_code |= 0x02;
goto error;
}
total_length += length;
}
char *p_line_end;
char *p_line_bgn = buf;
strcpy(section, CONFIG_DEFAULT_SECTION);
while ( (p_line_bgn < buf + length - 1) && (p_line_end = strchr(p_line_bgn, '\n'))) {
while ( (p_line_bgn < buf + total_length - 1) && (p_line_end = strchr(p_line_bgn, '\n'))) {
// get one line
int line_len = p_line_end - p_line_bgn;
@ -493,6 +601,9 @@ error:
if (section) {
osi_free(section);
}
if (keyname) {
osi_free(keyname);
}
if (err_code) {
LOG_ERROR("%s returned with err code: %d\n", __func__, err_code);
}

View File

@ -20,20 +20,21 @@
#define _ALARM_H_
#include <stdint.h>
#include <freertos/FreeRTOS.h>
#include <freertos/timers.h>
#include "esp_timer.h"
typedef uint32_t period_ms_t;
typedef void (*osi_alarm_callback_t)(void *data);
typedef struct alarm_t osi_alarm_t;
typedef uint64_t period_ms_t;
typedef esp_timer_cb_t osi_alarm_callback_t;
typedef enum {
OSI_ALARM_ERR_PASS = 0,
OSI_ALARM_ERR_FAIL = -1,
OSI_ALARM_ERR_INVALID_ARG = -2,
OSI_ALARM_ERR_INVALID_STATE = -3,
} osi_alarm_err_t;
#define ALARM_CBS_NUM 30
#define ALARM_ID_BASE 1000
typedef struct alarm_t {
/* timer id point to here */
TimerHandle_t alarm_hdl;
osi_alarm_callback_t cb;
void *cb_data;
} osi_alarm_t;
int osi_alarm_create_mux(void);
int osi_alarm_delete_mux(void);
@ -42,27 +43,25 @@ void osi_alarm_deinit(void);
// Creates a new alarm object. The returned object must be freed by calling
// |alarm_free|. Returns NULL on failure.
osi_alarm_t *osi_alarm_new(char *alarm_name, osi_alarm_callback_t callback, void *data, period_ms_t timer_expire);
osi_alarm_t *osi_alarm_new(const char *alarm_name, osi_alarm_callback_t callback, void *data, period_ms_t timer_expire);
// Frees an alarm object created by |alarm_new|. |alarm| may be NULL. If the
// alarm is pending, it will be cancelled. It is not safe to call |alarm_free|
// from inside the callback of |alarm|.
int osi_alarm_free(osi_alarm_t *alarm);
void osi_alarm_free(osi_alarm_t *alarm);
// Sets an alarm to fire |cb| after the given |deadline|. Note that |deadline| is the
// number of milliseconds relative to the current time. |data| is a context variable
// for the callback and may be NULL. |cb| will be called back in the context of an
// unspecified thread (i.e. it will not be called back in the same thread as the caller).
// |alarm| and |cb| may not be NULL.
int osi_alarm_set(osi_alarm_t *alarm, period_ms_t timeout);
osi_alarm_err_t osi_alarm_set(osi_alarm_t *alarm, period_ms_t timeout);
// This function cancels the |alarm| if it was previously set. When this call
// returns, the caller has a guarantee that the callback is not in progress and
// will not be called if it hasn't already been called. This function is idempotent.
// |alarm| may not be NULL.
int osi_alarm_cancel(osi_alarm_t *alarm);
period_ms_t osi_alarm_now(void);
osi_alarm_err_t osi_alarm_cancel(osi_alarm_t *alarm);
// Figure out how much time until next expiration.
// Returns 0 if not armed. |alarm| may not be NULL.
@ -72,10 +71,6 @@ period_ms_t osi_alarm_get_remaining_ms(const osi_alarm_t *alarm);
// Alarm-related state cleanup
//void alarm_cleanup(void);
// Compute time difference (t1-t2) considering tick counter wrap
// t1 and t2 should be no greater than the time of MAX ticks
period_ms_t osi_alarm_time_diff(period_ms_t t1, period_ms_t t2);
uint32_t osi_time_get_os_boottime_ms(void);
#endif /*_ALARM_H_*/

View File

@ -83,13 +83,14 @@ typedef enum {
#define BTC_TASK_PRIO (configMAX_PRIORITIES - 6)
#define BTC_TASK_QUEUE_LEN 60
#define BTC_MEDIA_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE)
#define BTC_MEDIA_TASK_STACK_SIZE (CONFIG_BTC_TASK_STACK_SIZE + BT_TASK_EXTRA_STACK_SIZE)
#define BTC_MEDIA_TASK_NAME "BtcMediaT"
#define BTC_MEDIA_TASK_PRIO (configMAX_PRIORITIES - 3)
#define BTC_MEDIA_DATA_QUEUE_LEN (1)
#define BTC_MEDIA_CTRL_QUEUE_LEN (5)
#define BTC_MEDIA_TASK_QUEUE_SET_LEN (BTC_MEDIA_DATA_QUEUE_LEN + BTC_MEDIA_CTRL_QUEUE_LEN)
#define BTC_A2DP_SINK_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE)
#define BTC_A2DP_SINK_TASK_STACK_SIZE (CONFIG_A2DP_SINK_TASK_STACK_SIZE + BT_TASK_EXTRA_STACK_SIZE) // by menuconfig
#define BTC_A2DP_SINK_TASK_NAME "BtA2dSinkT"
#define BTC_A2DP_SINK_TASK_PRIO (configMAX_PRIORITIES - 3)
#define BTC_A2DP_SINK_DATA_QUEUE_LEN (1)
#define BTC_A2DP_SINK_CTRL_QUEUE_LEN (5)
#define BTC_A2DP_SINK_TASK_QUEUE_SET_LEN (BTC_A2DP_SINK_DATA_QUEUE_LEN + BTC_A2DP_SINK_CTRL_QUEUE_LEN)
#define TASK_POST_NON_BLOCKING (0)
#define TASK_POST_BLOCKING (portMAX_DELAY)

View File

@ -407,7 +407,7 @@ void avdt_ccb_dealloc(tAVDT_CCB *p_ccb, tAVDT_CCB_EVT *p_data)
UNUSED(p_data);
AVDT_TRACE_DEBUG("avdt_ccb_dealloc %d\n", avdt_ccb_to_idx(p_ccb));
btu_stop_timer(&p_ccb->timer_entry);
btu_free_timer(&p_ccb->timer_entry);
fixed_queue_free(p_ccb->cmd_q, NULL);
fixed_queue_free(p_ccb->rsp_q, NULL);
memset(p_ccb, 0, sizeof(tAVDT_CCB));

View File

@ -644,7 +644,7 @@ void avdt_scb_dealloc(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data)
UNUSED(p_data);
AVDT_TRACE_DEBUG("avdt_scb_dealloc hdl=%d\n", avdt_scb_to_hdl(p_scb));
btu_stop_timer(&p_scb->timer_entry);
btu_free_timer(&p_scb->timer_entry);
#if AVDT_MULTIPLEXING == TRUE
/* free fragments we're holding, if any; it shouldn't happen */

View File

@ -98,7 +98,7 @@ static tAVRC_STS avrc_bld_set_abs_volume_cmd (tAVRC_SET_VOLUME_CMD *p_cmd, BT_HD
** Otherwise, the error code.
**
*******************************************************************************/
static tAVRC_STS avrc_bld_vol_change_notfn(BT_HDR *p_pkt)
static tAVRC_STS avrc_bld_register_change_notfn(UINT8 event_id, UINT32 event_parameter, BT_HDR *p_pkt)
{
UINT8 *p_data, *p_start;
@ -109,8 +109,8 @@ static tAVRC_STS avrc_bld_vol_change_notfn(BT_HDR *p_pkt)
p_data = p_start + 2; /* pdu + rsvd */
/* add fixed length 5 -*/
UINT16_TO_BE_STREAM(p_data, 5);
UINT8_TO_BE_STREAM(p_data, AVRC_EVT_VOLUME_CHANGE);
UINT32_TO_BE_STREAM(p_data, 0);
UINT8_TO_BE_STREAM(p_data, event_id);
UINT32_TO_BE_STREAM(p_data, event_parameter);
p_pkt->len = (p_data - p_start);
return AVRC_STS_NO_ERROR;
}
@ -132,8 +132,7 @@ static BT_HDR *avrc_bld_init_cmd_buffer(tAVRC_COMMAND *p_cmd)
AVRC_TRACE_API("avrc_bld_init_cmd_buffer: pdu=%x, opcode=%x", p_cmd->pdu, opcode);
UINT16 offset = 0;
switch (opcode)
{
switch (opcode) {
case AVRC_OP_PASS_THRU:
offset = AVRC_MSG_PASS_THRU_OFFSET;
break;
@ -148,7 +147,7 @@ static BT_HDR *avrc_bld_init_cmd_buffer(tAVRC_COMMAND *p_cmd)
if (p_pkt) {
UINT8 *p_data, *p_start;
p_pkt->layer_specific = AVCT_DATA_CTRL;
p_pkt->layer_specific = AVCT_DATA_CTRL;
p_pkt->event = opcode;
p_pkt->offset = offset;
p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
@ -175,6 +174,69 @@ static BT_HDR *avrc_bld_init_cmd_buffer(tAVRC_COMMAND *p_cmd)
return p_pkt;
}
/*******************************************************************************
**
** Function avrc_bld_set_player_value_cmd
**
** Description This function builds the Set Player Application Value command.
**
** Returns AVRC_STS_NO_ERROR, if the command is built successfully
** Otherwise, the error code.
**
*******************************************************************************/
static tAVRC_STS avrc_bld_set_player_value_cmd(tAVRC_SET_APP_VALUE_CMD *p_cmd, BT_HDR *p_pkt)
{
UINT8 *p_data, *p_start;
/* get the existing length, if any, and also the num attributes */
p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
p_data = p_start + 2; /* pdu + rsvd */
/* add length */
UINT16_TO_BE_STREAM(p_data, 3);
/* Number of attributes */
UINT8_TO_BE_STREAM(p_data, 1);
UINT8_TO_BE_STREAM(p_data, p_cmd->p_vals->attr_id);
UINT8_TO_BE_STREAM(p_data, p_cmd->p_vals->attr_val);
p_pkt->len = (p_data - p_start);
return AVRC_STS_NO_ERROR;
}
/*******************************************************************************
**
** Function avrc_bld_get_element_attr_cmd
**
** Description This function builds the Get Element Attribute command.
**
** Returns AVRC_STS_NO_ERROR, if the command is built successfully
** Otherwise, the error code.
**
*******************************************************************************/
static tAVRC_STS avrc_bld_get_element_attr_cmd (tAVRC_GET_ELEM_ATTRS_CMD *p_cmd, BT_HDR *p_pkt)
{
int i;
UINT8 *p_data, *p_start;
AVRC_TRACE_API("avrc_bld_get_element_attr_cmd num_attr: %d", p_cmd->num_attr);
/* get the existing length, if any, and also the num attributes */
p_start = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
p_data = p_start + 2; /* pdu + rsvd */
/* add length */
UINT16_TO_BE_STREAM(p_data, 8 + 1 /* id + attr count */ + p_cmd->num_attr * sizeof(UINT32));
/* Identifier 0x0 (PLAYING) */
UINT64_TO_BE_STREAM(p_data, (UINT64)(0));
/* Attribute count */
UINT8_TO_BE_STREAM(p_data, p_cmd->num_attr);
for (i = 0; i < p_cmd->num_attr; i++) {
AVRC_TRACE_API("avrc_bld_get_element_attr_cmd attr_id: %d", p_cmd->attrs[i]);
UINT32_TO_BE_STREAM(p_data, p_cmd->attrs[i]);
}
p_pkt->len = (p_data - p_start);
return AVRC_STS_NO_ERROR;
}
/*******************************************************************************
**
** Function AVRC_BldCommand
@ -223,14 +285,17 @@ tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt)
break;
#endif
case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */
#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
if (AVRC_EVT_VOLUME_CHANGE == p_cmd->reg_notif.event_id) {
status = avrc_bld_vol_change_notfn(p_pkt);
}
#endif
case AVRC_PDU_SET_PLAYER_APP_VALUE: /* 0x14 */
status = avrc_bld_set_player_value_cmd(&p_cmd->set_app_val, p_pkt);
break;
case AVRC_PDU_GET_ELEMENT_ATTR: /* 0x20 */
status = avrc_bld_get_element_attr_cmd(&p_cmd->get_elem_attrs, p_pkt);
break;
case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */
status = avrc_bld_register_change_notfn(p_cmd->reg_notif.event_id, p_cmd->reg_notif.param, p_pkt);
break;
}
if (alloc && (status != AVRC_STS_NO_ERROR) ) {

View File

@ -906,6 +906,11 @@ void btm_read_remote_version_complete (UINT8 *p)
}
#if BLE_INCLUDED == TRUE
if (p_acl_cb->transport == BT_TRANSPORT_LE) {
if (HCI_LE_DATA_LEN_EXT_SUPPORTED(p_acl_cb->peer_le_features)) {
uint16_t data_length = controller_get_interface()->get_ble_default_data_packet_length();
uint16_t data_txtime = controller_get_interface()->get_ble_default_data_packet_txtime();
btsnd_hcic_ble_set_data_length(p_acl_cb->hci_handle, data_length, data_txtime);
}
l2cble_notify_le_connection (p_acl_cb->remote_addr);
}
#endif
@ -2073,7 +2078,7 @@ void BTM_BleGetWhiteListSize(uint16_t *length)
{
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
if (p_cb->white_list_avail_size == 0) {
BTM_TRACE_ERROR("%s Whitelist full.", __func__);
BTM_TRACE_DEBUG("%s Whitelist full.", __func__);
}
*length = p_cb->white_list_avail_size;
return;

View File

@ -180,11 +180,7 @@ BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key, tBTM_LE_
#if (BLE_PRIVACY_SPT == TRUE)
if (key_type == BTM_LE_KEY_PID || key_type == BTM_LE_KEY_LID) {
/* It will cause that scanner doesn't send scan request to advertiser
* which has sent IRK to us and we have stored the IRK in controller.
* It is a design problem of hardware. The temporal solution is not to
* send the key to the controller and then resolve the random address in host. */
//btm_ble_resolving_list_load_dev (p_dev_rec);
btm_ble_resolving_list_load_dev (p_dev_rec);
}
#endif
@ -609,18 +605,23 @@ void BTM_ReadDevInfo (BD_ADDR remote_bda, tBT_DEVICE_TYPE *p_dev_type, tBLE_ADDR
{
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (remote_bda);
tBTM_INQ_INFO *p_inq_info = BTM_InqDbRead(remote_bda);
tBLE_ADDR_TYPE temp_addr_type = (*p_addr_type);
*p_addr_type = BLE_ADDR_PUBLIC;
if (!p_dev_rec) {
if (!p_dev_rec) {
*p_dev_type = BT_DEVICE_TYPE_BREDR;
/* Check with the BT manager if details about remote device are known */
if (p_inq_info != NULL) {
*p_dev_type = p_inq_info->results.device_type ;
*p_addr_type = p_inq_info->results.ble_addr_type;
} else {
/* unknown device, assume BR/EDR */
BTM_TRACE_DEBUG ("btm_find_dev_type - unknown device, BR/EDR assumed");
if(temp_addr_type <= BLE_ADDR_TYPE_MAX) {
*p_addr_type = temp_addr_type;
} else {
/* unknown device, assume BR/EDR */
BTM_TRACE_DEBUG ("btm_find_dev_type - unknown device, BR/EDR assumed");
}
}
} else { /* there is a security device record exisitng */
/* new inquiry result, overwrite device type in security device record */
@ -665,6 +666,7 @@ BOOLEAN BTM_ReadConnectedTransportAddress(BD_ADDR remote_bda, tBT_TRANSPORT tran
/* if no device can be located, return */
if (p_dev_rec == NULL) {
memset(remote_bda, 0, BD_ADDR_LEN);
return FALSE;
}
@ -812,7 +814,7 @@ tBTM_STATUS BTM_SetBleDataLength(BD_ADDR bd_addr, UINT16 tx_pdu_length)
}
if (!HCI_LE_DATA_LEN_EXT_SUPPORTED(p_acl->peer_le_features)) {
BTM_TRACE_DEBUG("%s failed, peer does not support request", __FUNCTION__);
BTM_TRACE_ERROR("%s failed, peer does not support request", __FUNCTION__);
return BTM_PEER_LE_DATA_LEN_UNSUPPORTED;
}
@ -1221,6 +1223,14 @@ void btm_sec_save_le_key(BD_ADDR bd_addr, tBTM_LE_KEY_TYPE key_type, tBTM_LE_KEY
p_rec->ble.keys.key_size = p_keys->lenc_key.key_size;
p_rec->ble.key_type |= BTM_LE_KEY_LENC;
/* Set that link key is known since this shares field with BTM_SEC_FLAG_LKEY_KNOWN flag in btm_api.h*/
p_rec->sec_flags |= BTM_SEC_LE_LINK_KEY_KNOWN;
if ( p_keys->pcsrk_key.sec_level == SMP_SEC_AUTHENTICATED) {
p_rec->sec_flags |= BTM_SEC_LE_LINK_KEY_AUTHED;
} else {
p_rec->sec_flags &= ~BTM_SEC_LE_LINK_KEY_AUTHED;
}
BTM_TRACE_DEBUG("BTM_LE_KEY_LENC key_type=0x%x DIV=0x%x key_size=0x%x sec_level=0x%x",
p_rec->ble.key_type,
p_rec->ble.keys.div,
@ -1907,7 +1917,17 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced)
/* possiblly receive connection complete with resolvable random on
slave role while the device has been paired */
if (!match && role == HCI_ROLE_SLAVE && BTM_BLE_IS_RESOLVE_BDA(bda)) {
/* It will cause that scanner doesn't send scan request to advertiser
* which has sent IRK to us and we have stored the IRK in controller.
* It is a design problem of hardware. The temporal solution is not to
* send the key to the controller and then resolve the random address in host.
* so we need send the real address information to controller to connect.
* Once the connection is successful, resolve device address whether it is
* slave or master*/
/* if (!match && role == HCI_ROLE_SLAVE && BTM_BLE_IS_RESOLVE_BDA(bda)) { */
if (!match && BTM_BLE_IS_RESOLVE_BDA(bda)) {
// save the enhanced value to used in btm_ble_resolve_random_addr_on_conn_cmpl func.
temp_enhanced = enhanced;
btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_on_conn_cmpl, p_data);
@ -1922,7 +1942,14 @@ void btm_ble_conn_complete(UINT8 *p, UINT16 evt_len, BOOLEAN enhanced)
handle = HCID_GET_HANDLE (handle);
btm_ble_connected(bda, handle, HCI_ENCRYPT_MODE_DISABLED, role, bda_type, match);
if(role == HCI_ROLE_SLAVE) {
//clear p_cb->state, controller will stop adv when ble connected.
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
if(p_cb) {
p_cb->adv_mode = BTM_BLE_ADV_DISABLE;
p_cb->state = BTM_BLE_STOP_ADV;
}
}
l2cble_conn_comp (handle, role, bda, bda_type, conn_interval,
conn_latency, conn_timeout);
@ -2066,11 +2093,7 @@ UINT8 btm_proc_smp_cback(tSMP_EVT event, BD_ADDR bd_addr, tSMP_EVT_DATA *p_data)
p_dev_rec->sec_state = BTM_SEC_STATE_IDLE;
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
/* add all bonded device into resolving list if IRK is available*/
/* It will cause that scanner doesn't send scan request to advertiser
* which has sent IRK to us and we have stored the IRK in controller.
* It is a design problem of hardware. The temporal solution is not to
* send the key to the controller and then resolve the random address in host. */
//btm_ble_resolving_list_load_dev(p_dev_rec);
btm_ble_resolving_list_load_dev(p_dev_rec);
#endif
}

View File

@ -596,7 +596,12 @@ void btm_ble_refresh_local_resolvable_private_addr(BD_ADDR pseudo_addr,
BD_ADDR dummy_bda = {0};
if (p != NULL) {
if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
/*
* Temporary solutions for pair with random address:
* use BLE_ADDR_RANDOM when adverting with random adress or in privacy mode
* We will do futher work here
*/
if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE || btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM) {
p->conn_addr_type = BLE_ADDR_RANDOM;
if (memcmp(local_rpa, dummy_bda, BD_ADDR_LEN)) {
memcpy(p->conn_addr, local_rpa, BD_ADDR_LEN);

View File

@ -69,7 +69,7 @@ static void background_connections_lazy_init()
}
}
static void background_connection_add(bt_bdaddr_t *address)
static BOOLEAN background_connection_add(bt_bdaddr_t *address)
{
assert(address);
background_connections_lazy_init();
@ -78,14 +78,17 @@ static void background_connection_add(bt_bdaddr_t *address)
connection = osi_calloc(sizeof(background_connection_t));
connection->address = *address;
hash_map_set(background_connections, &(connection->address), connection);
return TRUE;
}
return FALSE;
}
static void background_connection_remove(bt_bdaddr_t *address)
static BOOLEAN background_connection_remove(bt_bdaddr_t *address)
{
if (address && background_connections) {
hash_map_erase(background_connections, address);
return hash_map_erase(background_connections, address);
}
return FALSE;
}
static void background_connections_clear()
@ -259,20 +262,36 @@ BOOLEAN btm_update_dev_to_white_list(BOOLEAN to_add, BD_ADDR bd_addr, tBTM_ADD_W
tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb;
if (to_add && p_cb->white_list_avail_size == 0) {
BTM_TRACE_DEBUG("%s Whitelist full, unable to add device", __func__);
BTM_TRACE_ERROR("%s Whitelist full, unable to add device", __func__);
if (add_wl_cb){
add_wl_cb(HCI_ERR_MEMORY_FULL,to_add);
}
return FALSE;
}
if (add_wl_cb){
//save add whitelist complete callback
p_cb->add_wl_cb = add_wl_cb;
}
if (to_add) {
/* added the bd_addr to the connection hash map queue */
background_connection_add((bt_bdaddr_t *)bd_addr);
if(!background_connection_add((bt_bdaddr_t *)bd_addr)) {
/* if the bd_addr already exist in whitelist, just callback return TRUE */
if (add_wl_cb){
add_wl_cb(HCI_SUCCESS,to_add);
}
return TRUE;
}
} else {
/* remove the bd_addr to the connection hash map queue */
background_connection_remove((bt_bdaddr_t *)bd_addr);
if(!background_connection_remove((bt_bdaddr_t *)bd_addr)){
/* if the bd_addr don't exist in whitelist, just callback return TRUE */
if (add_wl_cb){
add_wl_cb(HCI_SUCCESS,to_add);
}
return TRUE;
}
}
if (add_wl_cb){
//save add whitelist complete callback
p_cb->add_wl_cb = add_wl_cb;
}
/* stop the auto connect */
btm_suspend_wl_activity(p_cb->wl_state);
@ -552,7 +571,7 @@ void btm_ble_initiate_select_conn(BD_ADDR bda)
BTM_TRACE_EVENT ("btm_ble_initiate_select_conn");
/* use direct connection procedure to initiate connection */
if (!L2CA_ConnectFixedChnl(L2CAP_ATT_CID, bda)) {
if (!L2CA_ConnectFixedChnl(L2CAP_ATT_CID, bda, BLE_ADDR_UNKNOWN_TYPE)) {
BTM_TRACE_ERROR("btm_ble_initiate_select_conn failed");
}
}

View File

@ -467,20 +467,6 @@ tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
/* enable resolving list */
btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN);
#endif
// if not set scan params, set defalult scan params
if (!p_inq->scan_params_set)
{
/* allow config of scan type */
p_inq->scan_type = BTM_BLE_SCAN_MODE_ACTI;
p_inq->scan_interval = BTM_BLE_GAP_DISC_SCAN_INT;
p_inq->scan_window = BTM_BLE_GAP_DISC_SCAN_WIN;
p_inq->sfp = BTM_BLE_DEFAULT_SFP;
p_inq->scan_params_set = TRUE;
btsnd_hcic_ble_set_scan_params(p_inq->scan_type, p_inq->scan_interval,
p_inq->scan_window,
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type,
p_inq->sfp);
}
p_inq->scan_duplicate_filter = BTM_BLE_DUPLICATE_DISABLE;
status = btm_ble_start_scan();
}
@ -515,7 +501,7 @@ tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration,
** Returns status.
**
*******************************************************************************/
tBTM_STATUS BTM_BleBroadcast(BOOLEAN start)
tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cback)
{
tBTM_STATUS status = BTM_NO_RESOURCES;
tBTM_LE_RANDOM_CB *p_addr_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
@ -531,7 +517,13 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start)
evt_type = p_cb->scan_rsp ? BTM_BLE_CONNECT_EVT : BTM_BLE_NON_CONNECT_EVT;
}
#endif
// if adv state is BTM_BLE_ADV_PENDING, return immediately
if (p_cb->state == BTM_BLE_ADV_PENDING) {
if (p_stop_adv_cback) {
(*p_stop_adv_cback)(HCI_ERR_ILLEGAL_COMMAND);
}
return BTM_BUSY;
}
if (start && p_cb->adv_mode == BTM_BLE_ADV_DISABLE) {
/* update adv params */
if (!btsnd_hcic_ble_write_adv_params ((UINT16)(p_cb->adv_interval_min ? p_cb->adv_interval_min :
@ -552,15 +544,22 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start)
}
status = btm_ble_start_adv ();
} else if (!start) {
} else if (!start && p_cb->adv_mode == BTM_BLE_ADV_ENABLE) {
//save the stop adv callback to the BTM env.
p_cb->p_stop_adv_cb = p_stop_adv_cback;
status = btm_ble_stop_adv();
#if BLE_PRIVACY_SPT == TRUE
btm_ble_disable_resolving_list(BTM_BLE_RL_ADV, TRUE);
#endif
} else {
status = BTM_WRONG_MODE;
BTM_TRACE_ERROR("Can not %s Broadcast, device %s in Broadcast mode",
(start ? "Start" : "Stop"), (start ? "already" : "not"));
/*
1. start adv when adv has already started (not used)
2. stop adv shen adv has already stoped
*/
status = BTM_SUCCESS;
if (p_stop_adv_cback) {
(*p_stop_adv_cback)(status);
}
}
return status;
}
@ -748,6 +747,30 @@ BOOLEAN BTM_BleConfigPrivacy(BOOLEAN privacy_mode, tBTM_SET_LOCAL_PRIVACY_CBACK
if (!controller_get_interface()->supports_ble()) {
return FALSE;
}
/*
* Temporary solutions for pair with random address:
* can't set privacy when advertising, scaning or using static random address
* We will do futher work here
*/
if (p_cb->privacy_mode == BTM_PRIVACY_NONE
&& random_cb->own_addr_type == BLE_ADDR_RANDOM) {
BTM_TRACE_ERROR("Have set random adress, can't set privacy ");
if (random_cb && random_cb->set_local_privacy_cback){
(*random_cb->set_local_privacy_cback)(BTM_SET_PRIVACY_FAIL);
random_cb->set_local_privacy_cback = NULL;
}
return FALSE;
}
if (!(p_cb->inq_var.state == BTM_BLE_STOP_SCAN || p_cb->inq_var.state == BTM_BLE_STOP_ADV || p_cb->inq_var.state == BTM_BLE_IDLE)) {
BTM_TRACE_ERROR("Advertising or scaning now, can't set privacy ");
if (random_cb && random_cb->set_local_privacy_cback){
(*random_cb->set_local_privacy_cback)(BTM_SET_PRIVACY_FAIL);
random_cb->set_local_privacy_cback = NULL;
}
return FALSE;
}
#if (defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE && GATTS_INCLUDED == TRUE)
uint8_t addr_resolution = 0;
#endif /* defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE && GATTS_INCLUDED == TRUE */
@ -1166,7 +1189,7 @@ tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max,
*******************************************************************************/
tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max, UINT8 adv_type,
tBLE_ADDR_TYPE own_bda_type, tBLE_BD_ADDR *p_dir_bda,
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp)
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp, tBTM_START_ADV_CMPL_CBACK *adv_cb)
{
tBTM_LE_RANDOM_CB *p_addr_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb;
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
@ -1177,8 +1200,25 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
return BTM_ILLEGAL_VALUE;
}
/*
* Temporary solutions for pair with random address:
* can't set advertising with BLE_ADDR_PUBLIC when having set random adress or in privacy mode
* We will do futher work here
*/
if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM && own_bda_type == BLE_ADDR_PUBLIC) {
BTM_TRACE_ERROR ("own_addr_type is BLE_ADDR_RANDOM but use BLE_ADDR_PUBLIC\n");
if(adv_cb) {
(* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL);
}
return BTM_ILLEGAL_VALUE;
}
if (!BTM_BLE_ISVALID_PARAM(adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) ||
!BTM_BLE_ISVALID_PARAM(adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX)) {
BTM_TRACE_ERROR ("adv_int_min or adv_int_max is invalid\n");
if(adv_cb) {
(* adv_cb)(HCI_ERR_ESP_VENDOR_FAIL);
}
return BTM_ILLEGAL_VALUE;
}
@ -1196,14 +1236,30 @@ tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max,
p_addr_cb->own_addr_type = own_bda_type;
p_cb->evt_type = adv_type;
p_cb->afp = afp;
p_cb->p_adv_cb = adv_cb;
if (p_dir_bda) {
memcpy(&p_cb->direct_bda, p_dir_bda, sizeof(tBLE_BD_ADDR));
}
BTM_TRACE_EVENT ("update params for an active adv\n");
btm_ble_stop_adv();
// if adv state is BTM_BLE_ADV_PENDING, return immediately
if (p_cb->state == BTM_BLE_ADV_PENDING) {
if (p_cb->p_adv_cb) {
(*p_cb->p_adv_cb)(HCI_ERR_ILLEGAL_COMMAND);
}
return BTM_BUSY;
}
/* host will stop adv first and then start adv again if adv has already started
it will get callback twice.
*/
if (p_cb->adv_mode == BTM_BLE_ADV_ENABLE) {
p_cb->adv_callback_twice = TRUE;
}
tBTM_STATUS status = btm_ble_stop_adv();
if (status != BTM_SUCCESS) {
p_cb->adv_callback_twice = FALSE;
}
/* update adv params */
btsnd_hcic_ble_write_adv_params (adv_int_min,
@ -1326,6 +1382,19 @@ void BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32
return;
}
/*
* Temporary solutions for pair with random address:
* can't set scan with BLE_ADDR_PUBLIC when having set random adress or in privacy mode
* We will do futher work here
*/
if (btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type == BLE_ADDR_RANDOM && addr_type_own == BLE_ADDR_PUBLIC) {
BTM_TRACE_ERROR ("own_addr_type is BLE_ADDR_RANDOM but use BLE_ADDR_PUBLIC\n");
if (scan_setup_status_cback != NULL) {
scan_setup_status_cback(client_if, BTM_ILLEGAL_VALUE);
}
return;
}
/* If not supporting extended scan support, use the older range for checking */
if (btm_cb.cmn_ble_vsc_cb.extended_scan_support == 0) {
max_scan_interval = BTM_BLE_SCAN_INT_MAX;
@ -1504,16 +1573,35 @@ tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len)
** Returns void
**
*******************************************************************************/
BOOLEAN BTM_BleSetRandAddress(BD_ADDR rand_addr)
tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr)
{
BOOLEAN set_flag = false;
if (rand_addr == NULL)
return set_flag;
return BTM_SET_STATIC_RAND_ADDR_FAIL;
/*
* Temporary solutions for pair with random address:
* can't set rand address when advertising, scaning or in privacy mode
* We will do futher work here
*/
#if BLE_PRIVACY_SPT == TRUE
if (btm_cb.ble_ctr_cb.privacy_mode != BTM_PRIVACY_NONE) {
BTM_TRACE_ERROR("privacy_mode is not BTM_PRIVACY_NONE ");
return BTM_SET_STATIC_RAND_ADDR_FAIL;
}
#endif
if (!(btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_STOP_SCAN || btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_STOP_ADV || btm_cb.ble_ctr_cb.inq_var.state == BTM_BLE_IDLE)) {
BTM_TRACE_ERROR("Advertising or scaning now, can't set randaddress %d", btm_cb.ble_ctr_cb.inq_var.state);
return BTM_SET_STATIC_RAND_ADDR_FAIL;
}
memcpy(btm_cb.ble_ctr_cb.addr_mgnt_cb.private_addr, rand_addr, BD_ADDR_LEN);
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type = BLE_ADDR_RANDOM;
//send the set random address to the controller
set_flag = btsnd_hcic_ble_set_random_addr(rand_addr);
return set_flag;
if(btsnd_hcic_ble_set_random_addr(rand_addr)) {
return BTM_SUCCESS;
} else {
return BTM_SET_STATIC_RAND_ADDR_FAIL;
}
}
/*******************************************************************************
@ -2918,6 +3006,8 @@ void btm_ble_process_adv_pkt (UINT8 *p_data)
UINT8 data_len;
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
BOOLEAN match = FALSE;
BD_ADDR temp_bda;
UINT8 temp_addr_type = 0;
#endif
/* Only process the results if the inquiry is still active */
@ -2936,6 +3026,9 @@ void btm_ble_process_adv_pkt (UINT8 *p_data)
//BTM_TRACE_ERROR("btm_ble_process_adv_pkt:bda= %0x:%0x:%0x:%0x:%0x:%0x\n",
// bda[0],bda[1],bda[2],bda[3],bda[4],bda[5]);
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
temp_addr_type = addr_type;
memcpy(temp_bda, bda, BD_ADDR_LEN);
/* map address to security record */
match = btm_identity_addr_to_random_pseudo(bda, &addr_type, FALSE);
@ -2946,8 +3039,16 @@ void btm_ble_process_adv_pkt (UINT8 *p_data)
btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_on_adv, p_data);
} else
#endif
btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, p);
btm_ble_process_adv_pkt_cont(bda, addr_type, evt_type, p);
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
//save current adv addr information if p_dev_rec!= NULL
tBTM_SEC_DEV_REC *p_dev_rec = btm_find_dev (bda);
if(p_dev_rec) {
p_dev_rec->ble.current_addr_type = temp_addr_type;
memcpy(p_dev_rec->ble.current_addr, temp_bda, BD_ADDR_LEN);
p_dev_rec->ble.current_addr_valid = true;
}
#endif
STREAM_TO_UINT8(data_len, p);
/* Advance to the next event data_len + rssi byte */
@ -3061,6 +3162,25 @@ static void btm_ble_process_adv_pkt_cont(BD_ADDR bda, UINT8 addr_type, UINT8 evt
}
}
static void btm_ble_recover_scan_params(void)
{
tBTM_BLE_INQ_CB *p_inq = &btm_cb.ble_ctr_cb.inq_var;
if (p_inq->scan_params_set) {
/// set back the scan params to the controller after stop the scan
btsnd_hcic_ble_set_scan_params(p_inq->scan_type, p_inq->scan_interval,
p_inq->scan_window,
btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type,
p_inq->sfp);
} else {
/// set the default value if the scan params not set yet
btm_update_scanner_filter_policy(SP_ADV_ALL);
btm_cb.ble_ctr_cb.wl_state &= ~BTM_BLE_WL_SCAN;
}
}
/*******************************************************************************
**
** Function btm_ble_start_scan
@ -3074,7 +3194,8 @@ tBTM_STATUS btm_ble_start_scan(void)
{
tBTM_BLE_INQ_CB *p_inq = &btm_cb.ble_ctr_cb.inq_var;
tBTM_STATUS status = BTM_CMD_STARTED;
// recoverly the scan parameters to the controller before start scan
btm_ble_recover_scan_params();
/* start scan, disable duplicate filtering */
if (!btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_ENABLE, p_inq->scan_duplicate_filter)) {
status = BTM_NO_RESOURCES;
@ -3192,7 +3313,6 @@ static void btm_ble_stop_discover(void)
{
tBTM_BLE_CB *p_ble_cb = & btm_cb.ble_ctr_cb;
tBTM_CMPL_CB *p_scan_cb = p_ble_cb->p_scan_cmpl_cb;
btu_stop_timer (&p_ble_cb->scan_timer_ent);
p_ble_cb->scan_activity &= ~BTM_LE_DISCOVER_ACTIVE;
@ -3206,6 +3326,8 @@ static void btm_ble_stop_discover(void)
btm_cb.ble_ctr_cb.inq_var.state = BTM_BLE_STOP_SCAN;
/* stop discovery now */
btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_DISABLE, BTM_BLE_DUPLICATE_ENABLE);
// recoverly the scan parameters to the controller after stop scan
btm_ble_recover_scan_params();
}
if (p_scan_cb) {
@ -3287,13 +3409,13 @@ tBTM_STATUS btm_ble_start_adv(void)
#endif
if (p_cb->afp != AP_SCAN_CONN_ALL) {
//find the device in the btm dev buffer and write it to the controller white list
btm_execute_wl_dev_operation();
btm_execute_wl_dev_operation();
btm_cb.ble_ctr_cb.wl_state |= BTM_BLE_WL_ADV;
}
if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_ENABLE)) {
p_cb->adv_mode = BTM_BLE_ADV_ENABLE;
p_cb->state = BTM_BLE_ADVERTISING;
p_cb->state = BTM_BLE_ADV_PENDING;
btm_ble_adv_states_operation(btm_ble_set_topology_mask, p_cb->evt_type);
rt = BTM_SUCCESS;
BTM_TRACE_EVENT ("BTM_SUCCESS\n");
@ -3322,7 +3444,7 @@ tBTM_STATUS btm_ble_stop_adv(void)
if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_DISABLE)) {
p_cb->fast_adv_on = FALSE;
p_cb->adv_mode = BTM_BLE_ADV_DISABLE;
p_cb->state = BTM_BLE_STOP_ADV;
p_cb->state = BTM_BLE_ADV_PENDING;
btm_cb.ble_ctr_cb.wl_state &= ~BTM_BLE_WL_ADV;
/* clear all adv states */
@ -3462,9 +3584,13 @@ void btm_ble_read_remote_features_complete(UINT8 *p)
if (p_acl_cb->link_role == HCI_ROLE_MASTER){
btsnd_hcic_rmt_ver_req (p_acl_cb->hci_handle);
}
else{
if (p_acl_cb->transport == BT_TRANSPORT_LE) {
if (HCI_LE_DATA_LEN_EXT_SUPPORTED(p_acl_cb->peer_le_features)) {
uint16_t data_length = controller_get_interface()->get_ble_default_data_packet_length();
uint16_t data_txtime = controller_get_interface()->get_ble_default_data_packet_txtime();
btsnd_hcic_ble_set_data_length(p_acl_cb->hci_handle, data_length, data_txtime);
}
l2cble_notify_le_connection (p_acl_cb->remote_addr);
}
}
@ -3488,7 +3614,30 @@ void btm_ble_read_remote_features_complete(UINT8 *p)
void btm_ble_write_adv_enable_complete(UINT8 *p)
{
tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var;
UINT8 status = *p;
// callback to the APP after receive the adv complete from the controller.
if (p_cb->p_adv_cb && p_cb->adv_mode == BTM_BLE_ADV_ENABLE) {
if (p_cb->adv_callback_twice) {
p_cb->adv_callback_twice = FALSE;
}else {
p_cb->state = BTM_BLE_ADVERTISING;
(*p_cb->p_adv_cb)(status);
p_cb->p_adv_cb = NULL;
}
} else if (p_cb->p_stop_adv_cb && p_cb->adv_mode == BTM_BLE_ADV_DISABLE) {
p_cb->state = BTM_BLE_STOP_ADV;
(*p_cb->p_stop_adv_cb)(status);
p_cb->p_stop_adv_cb = NULL;
}else {
// p_cb->p_adv_cb is NULL or p_cb->p_stop_adv_cb is NULL
if (p_cb->adv_mode == BTM_BLE_ADV_ENABLE) {
p_cb->state = BTM_BLE_ADVERTISING;
}else {
p_cb->state = BTM_BLE_STOP_ADV;
}
p_cb->adv_callback_twice = FALSE;
}
/* if write adv enable/disbale not succeed */
if (*p != HCI_SUCCESS) {
/* toggle back the adv mode */
@ -3630,6 +3779,9 @@ void btm_ble_init (void)
BTM_TRACE_DEBUG("%s", __func__);
btu_free_timer(&p_cb->obs_timer_ent);
btu_free_timer(&p_cb->scan_timer_ent);
btu_free_timer(&p_cb->inq_var.fast_adv_timer);
memset(p_cb, 0, sizeof(tBTM_BLE_CB));
memset(&(btm_cb.cmn_ble_vsc_cb), 0 , sizeof(tBTM_BLE_VSC_CB));
btm_cb.cmn_ble_vsc_cb.values_read = FALSE;

View File

@ -765,18 +765,22 @@ BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec)
btm_ble_update_resolving_list(p_dev_rec->bd_addr, TRUE);
if (controller_get_interface()->supports_ble_privacy()) {
BD_ADDR dummy_bda = {0};
UINT8 *peer_irk = p_dev_rec->ble.keys.irk;
UINT8 *local_irk = btm_cb.devcb.id_keys.irk;
if (memcmp(p_dev_rec->ble.static_addr, dummy_bda, BD_ADDR_LEN) == 0) {
memcpy(p_dev_rec->ble.static_addr, p_dev_rec->bd_addr, BD_ADDR_LEN);
p_dev_rec->ble.static_addr_type = p_dev_rec->ble.ble_addr_type;
}
/* It will cause that scanner doesn't send scan request to advertiser
* which has sent IRK to us and we have stored the IRK in controller.
* It is a design problem of hardware. The temporal solution is not to
* send the key to the controller and then resolve the random address in host. */
/*
BTM_TRACE_DEBUG("%s:adding device to controller resolving list\n", __func__);
// use identical IRK for now
UINT8 *peer_irk = p_dev_rec->ble.keys.irk;
UINT8 *local_irk = btm_cb.devcb.id_keys.irk;
//use identical IRK for now
rt = btsnd_hcic_ble_add_device_resolving_list(p_dev_rec->ble.static_addr_type,
p_dev_rec->ble.static_addr, peer_irk, local_irk);
p_dev_rec->ble.static_addr, peer_irk, local_irk);
*/
} else {
UINT8 param[40] = {0};
UINT8 *p = param;
@ -807,7 +811,7 @@ BOOLEAN btm_ble_resolving_list_load_dev(tBTM_SEC_DEV_REC *p_dev_rec)
}
}
} else {
BTM_TRACE_ERROR("Device already in Resolving list\n");
BTM_TRACE_DEBUG("Device already in Resolving list\n");
rt = TRUE;
}
} else {

View File

@ -533,7 +533,7 @@ void btm_read_local_name_complete (UINT8 *p, UINT16 evt_len)
UINT8 status;
UNUSED(evt_len);
btu_stop_timer (&btm_cb.devcb.rln_timer);
btu_free_timer (&btm_cb.devcb.rln_timer);
/* If there was a callback address for read local name, call it */
btm_cb.devcb.p_rln_cmpl_cb = NULL;

View File

@ -1359,6 +1359,12 @@ void btm_inq_db_init (void)
#if 0 /* cleared in btm_init; put back in if called from anywhere else! */
memset (&btm_cb.btm_inq_vars, 0, sizeof (tBTM_INQUIRY_VAR_ST));
#endif
btu_free_timer(&btm_cb.btm_inq_vars.rmt_name_timer_ent);
memset(&btm_cb.btm_inq_vars.rmt_name_timer_ent, 0, sizeof(TIMER_LIST_ENT));
btu_free_timer(&btm_cb.btm_inq_vars.inq_timer_ent);
memset(&btm_cb.btm_inq_vars.inq_timer_ent, 0, sizeof(TIMER_LIST_ENT));
btm_cb.btm_inq_vars.no_inc_ssp = BTM_NO_SSP_ON_INQUIRY;
}

View File

@ -2763,7 +2763,9 @@ void btm_sec_check_pending_reqs (void)
/* Now, re-submit anything in the mux queue */
bq = btm_cb.sec_pending_q;
btm_cb.sec_pending_q = fixed_queue_new(SIZE_MAX);
if (!btm_cb.sec_pending_q) {
btm_cb.sec_pending_q = fixed_queue_new(SIZE_MAX);
}
while ((p_e = (tBTM_SEC_QUEUE_ENTRY *)fixed_queue_try_dequeue(bq)) != NULL) {
/* Check that the ACL is still up before starting security procedures */

View File

@ -498,6 +498,32 @@ void btu_stop_timer(TIMER_LIST_ENT *p_tle)
osi_alarm_cancel(alarm);
}
/*******************************************************************************
**
** Function btu_free_timer
**
** Description Stop and free a timer.
**
** Returns void
**
*******************************************************************************/
void btu_free_timer(TIMER_LIST_ENT *p_tle)
{
assert(p_tle != NULL);
p_tle->in_use = FALSE;
// Get the alarm for the timer list entry.
osi_alarm_t *alarm = hash_map_get(btu_general_alarm_hash_map, p_tle);
if (alarm == NULL) {
LOG_DEBUG("%s Unable to find expected alarm in hashmap", __func__);
return;
}
osi_alarm_cancel(alarm);
hash_map_erase(btu_general_alarm_hash_map, p_tle);
}
#if defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0)
/*******************************************************************************
**
@ -585,6 +611,23 @@ void btu_stop_quick_timer(TIMER_LIST_ENT *p_tle)
}
osi_alarm_cancel(alarm);
}
void btu_free_quick_timer(TIMER_LIST_ENT *p_tle)
{
assert(p_tle != NULL);
p_tle->in_use = FALSE;
// Get the alarm for the timer list entry.
osi_alarm_t *alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_tle);
if (alarm == NULL) {
LOG_DEBUG("%s Unable to find expected alarm in hashmap", __func__);
return;
}
osi_alarm_cancel(alarm);
hash_map_erase(btu_l2cap_alarm_hash_map, p_tle);
}
#endif /* defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0) */
void btu_oneshot_alarm_cb(void *data)

View File

@ -694,7 +694,7 @@ BOOLEAN gap_ble_accept_cl_operation(BD_ADDR peer_bda, UINT16 uuid, tGAP_BLE_CMPL
}
/* hold the link here */
if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, TRUE, BT_TRANSPORT_LE)) {
if (!GATT_Connect(gap_cb.gatt_if, p_clcb->bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, BT_TRANSPORT_LE)) {
return started;
}

View File

@ -1337,12 +1337,13 @@ void GATT_StartIf (tGATT_IF gatt_if)
**
** Parameters gatt_if: applicaiton interface
** bd_addr: peer device address.
** bd_addr_type: peer device address type.
** is_direct: is a direct conenection or a background auto connection
**
** Returns TRUE if connection started; FALSE if connection start failure.
**
*******************************************************************************/
BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, BOOLEAN is_direct, tBT_TRANSPORT transport)
BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, BOOLEAN is_direct, tBT_TRANSPORT transport)
{
tGATT_REG *p_reg;
BOOLEAN status = FALSE;
@ -1356,7 +1357,7 @@ BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, BOOLEAN is_direct, tBT_
}
if (is_direct) {
status = gatt_act_connect (p_reg, bd_addr, transport);
status = gatt_act_connect (p_reg, bd_addr, bd_addr_type, transport);
} else {
if (transport == BT_TRANSPORT_LE) {
status = gatt_update_auto_connect_dev(gatt_if, TRUE, bd_addr, TRUE);

View File

@ -494,7 +494,7 @@ void GATT_ConfigServiceChangeCCC (BD_ADDR remote_bda, BOOLEAN enable, tBT_TRANSP
p_clcb->connected = TRUE;
}
/* hold the link here */
GATT_Connect(gatt_cb.gatt_if, remote_bda, TRUE, transport);
GATT_Connect(gatt_cb.gatt_if, remote_bda, BLE_ADDR_UNKNOWN_TYPE, TRUE, transport);
p_clcb->ccc_stage = GATT_SVC_CHANGED_CONNECTING;
if (!p_clcb->connected) {

View File

@ -586,7 +586,7 @@ void gatt_process_prep_write_rsp (tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT8 op
tGATT_VALUE value = {0};
UINT8 *p = p_data;
GATT_TRACE_ERROR("value resp op_code = %s len = %d", gatt_dbg_op_name(op_code), len);
GATT_TRACE_DEBUG("value resp op_code = %s len = %d", gatt_dbg_op_name(op_code), len);
if (len < GATT_PREP_WRITE_RSP_MIN_LEN) {
GATT_TRACE_ERROR("illegal prepare write response length, discard");
@ -988,8 +988,10 @@ void gatt_process_mtu_rsp(tGATT_TCB *p_tcb, tGATT_CLCB *p_clcb, UINT16 len, UINT
p_tcb->payload_size = mtu;
}
}
l2cble_set_fixed_channel_tx_data_length(p_tcb->peer_bda, L2CAP_ATT_CID, p_tcb->payload_size);
/* host will set packet data length to 251 automatically if remote device support set packet data length,
so l2cble_set_fixed_channel_tx_data_length() is not necessary.
l2cble_set_fixed_channel_tx_data_length(p_tcb->peer_bda, L2CAP_ATT_CID, p_tcb->payload_size);
*/
gatt_end_operation(p_clcb, status, NULL);
}
/*******************************************************************************

View File

@ -172,6 +172,12 @@ void gatt_free(void)
fixed_queue_free(gatt_cb.tcb[i].pending_ind_q, NULL);
gatt_cb.tcb[i].pending_ind_q = NULL;
btu_free_timer(&gatt_cb.tcb[i].conf_timer_ent);
memset(&gatt_cb.tcb[i].conf_timer_ent, 0, sizeof(TIMER_LIST_ENT));
btu_free_timer(&gatt_cb.tcb[i].ind_ack_timer_ent);
memset(&gatt_cb.tcb[i].ind_ack_timer_ent, 0, sizeof(TIMER_LIST_ENT));
fixed_queue_free(gatt_cb.tcb[i].sr_cmd.multi_rsp_q, NULL);
gatt_cb.tcb[i].sr_cmd.multi_rsp_q = NULL;
}
@ -189,11 +195,11 @@ void gatt_free(void)
** Description This function is called to initiate a connection to a peer device.
**
** Parameter rem_bda: remote device address to connect to.
**
** bd_addr_type: emote device address type.
** Returns TRUE if connection is started, otherwise return FALSE.
**
*******************************************************************************/
BOOLEAN gatt_connect (BD_ADDR rem_bda, tGATT_TCB *p_tcb, tBT_TRANSPORT transport)
BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p_tcb, tBT_TRANSPORT transport)
{
BOOLEAN gatt_ret = FALSE;
@ -203,7 +209,7 @@ BOOLEAN gatt_connect (BD_ADDR rem_bda, tGATT_TCB *p_tcb, tBT_TRANSPORT transport
if (transport == BT_TRANSPORT_LE) {
p_tcb->att_lcid = L2CAP_ATT_CID;
gatt_ret = L2CA_ConnectFixedChnl (L2CAP_ATT_CID, rem_bda);
gatt_ret = L2CA_ConnectFixedChnl (L2CAP_ATT_CID, rem_bda, bd_addr_type);
#if (CLASSIC_BT_INCLUDED == TRUE)
} else {
if ((p_tcb->att_lcid = L2CA_ConnectReq(BT_PSM_ATT, rem_bda)) != 0) {
@ -348,7 +354,7 @@ void gatt_update_app_use_link_flag (tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN
** Returns void.
**
*******************************************************************************/
BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBT_TRANSPORT transport)
BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, tBT_TRANSPORT transport)
{
BOOLEAN ret = FALSE;
tGATT_TCB *p_tcb;
@ -361,7 +367,7 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBT_TRANSPORT trans
/* before link down, another app try to open a GATT connection */
if (st == GATT_CH_OPEN && gatt_num_apps_hold_link(p_tcb) == 0 &&
transport == BT_TRANSPORT_LE ) {
if (!gatt_connect(bd_addr, p_tcb, transport)) {
if (!gatt_connect(bd_addr, bd_addr_type, p_tcb, transport)) {
ret = FALSE;
}
} else if (st == GATT_CH_CLOSING) {
@ -370,7 +376,7 @@ BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBT_TRANSPORT trans
}
} else {
if ((p_tcb = gatt_allocate_tcb_by_bdaddr(bd_addr, transport)) != NULL) {
if (!gatt_connect(bd_addr, p_tcb, transport)) {
if (!gatt_connect(bd_addr, bd_addr_type, p_tcb, transport)) {
GATT_TRACE_ERROR("gatt_connect failed");
fixed_queue_free(p_tcb->pending_enc_clcb, NULL);
fixed_queue_free(p_tcb->pending_ind_q, NULL);

View File

@ -359,6 +359,7 @@ void gatt_process_exec_write_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
tGATT_IF gatt_if;
UINT16 conn_id;
UINT16 queue_num = 0;
BOOLEAN is_first = TRUE;
BOOLEAN is_prepare_write_valid = FALSE;
BOOLEAN is_need_dequeue_sr_cmd = FALSE;
tGATT_PREPARE_WRITE_RECORD *prepare_record = NULL;
@ -420,6 +421,11 @@ void gatt_process_exec_write_req (tGATT_TCB *p_tcb, UINT8 op_code, UINT16 len, U
queue_data = fixed_queue_dequeue(prepare_record->queue);
if (is_prepare_write_valid){
if((queue_data->p_attr->p_value != NULL) && (queue_data->p_attr->p_value->attr_val.attr_val != NULL)){
if(is_first) {
//clear attr_val.attr_len before handle prepare write data
queue_data->p_attr->p_value->attr_val.attr_len = 0;
is_first = FALSE;
}
memcpy(queue_data->p_attr->p_value->attr_val.attr_val+queue_data->offset, queue_data->value, queue_data->len);
//don't forget to increase the attribute value length in the gatts database.
queue_data->p_attr->p_value->attr_val.attr_len += queue_data->len;
@ -949,7 +955,10 @@ static void gatts_process_mtu_req (tGATT_TCB *p_tcb, UINT16 len, UINT8 *p_data)
p_tcb->payload_size = mtu;
}
l2cble_set_fixed_channel_tx_data_length(p_tcb->peer_bda, L2CAP_ATT_CID, p_tcb->payload_size);
/* host will set packet data length to 251 automatically if remote device support set packet data length,
so l2cble_set_fixed_channel_tx_data_length() is not necessary.
l2cble_set_fixed_channel_tx_data_length(p_tcb->peer_bda, L2CAP_ATT_CID, p_tcb->payload_size);
*/
if ((p_buf = attp_build_sr_msg(p_tcb, GATT_RSP_MTU, (tGATT_SR_MSG *) &p_tcb->payload_size)) != NULL) {
attp_send_sr_msg (p_tcb, p_buf);

View File

@ -861,7 +861,7 @@ tGATTS_SRV_CHG *gatt_is_bda_in_the_srv_chg_clt_list (BD_ADDR bda)
list_t *list = fixed_queue_get_list(gatt_cb.srv_chg_clt_q);
for (const list_node_t *node = list_begin(list); node != list_end(list);
node = list_next(node)) {
tGATTS_SRV_CHG *p_buf = (tGATTS_SRV_CHG *)list_node(node);
p_buf = (tGATTS_SRV_CHG *)list_node(node);
if (!memcmp( bda, p_buf->bda, BD_ADDR_LEN)) {
GATT_TRACE_DEBUG("bda is in the srv chg clt list");
break;
@ -1255,7 +1255,7 @@ void gatt_start_ind_ack_timer(tGATT_TCB *p_tcb)
p_tcb->ind_ack_timer_ent.param = (TIMER_PARAM_TYPE)p_tcb;
/* start notification cache timer */
btu_start_timer (&p_tcb->ind_ack_timer_ent, BTU_TTYPE_ATT_WAIT_FOR_IND_ACK,
GATT_WAIT_FOR_RSP_TOUT);
GATT_WAIT_FOR_IND_ACK_TOUT);
}
/*******************************************************************************
@ -1683,6 +1683,7 @@ tGATT_CLCB *gatt_clcb_alloc (UINT16 conn_id)
void gatt_clcb_dealloc (tGATT_CLCB *p_clcb)
{
if (p_clcb && p_clcb->in_use) {
btu_free_timer(&p_clcb->rsp_timer_ent);
memset(p_clcb, 0, sizeof(tGATT_CLCB));
}
}
@ -1997,6 +1998,29 @@ BOOLEAN gatt_find_app_hold_link(tGATT_TCB *p_tcb, UINT8 start_idx, UINT8 *p_foun
return found;
}
/*******************************************************************************
**
** Function gatt_find_specific_app_in_hold_link
**
** Description find the specific applicaiton that is holding the specified link
**
** Returns Boolean
**
*******************************************************************************/
BOOLEAN gatt_find_specific_app_in_hold_link(tGATT_TCB *p_tcb, tGATT_IF p_gatt_if)
{
UINT8 i;
BOOLEAN found = FALSE;
for (i = 0; i < GATT_MAX_APPS; i ++) {
if (p_tcb->app_hold_link[i] && p_tcb->app_hold_link[i] == p_gatt_if) {
found = TRUE;
break;
}
}
return found;
}
/*******************************************************************************
**
** Function gatt_cmd_enq
@ -2211,8 +2235,8 @@ void gatt_cleanup_upon_disc(BD_ADDR bda, UINT16 reason, tBT_TRANSPORT transport)
}
}
btu_stop_timer (&p_tcb->ind_ack_timer_ent);
btu_stop_timer (&p_tcb->conf_timer_ent);
btu_free_timer (&p_tcb->ind_ack_timer_ent);
btu_free_timer (&p_tcb->conf_timer_ent);
gatt_free_pending_ind(p_tcb);
gatt_free_pending_enc_queue(p_tcb);
gatt_free_pending_prepare_write_queue(p_tcb);

View File

@ -80,6 +80,7 @@ typedef UINT8 tGATT_SEC_ACTION;
#define GATT_WAIT_FOR_RSP_TOUT 30
#define GATT_WAIT_FOR_DISC_RSP_TOUT 5
#define GATT_REQ_RETRY_LIMIT 2
#define GATT_WAIT_FOR_IND_ACK_TOUT 5
/* characteristic descriptor type */
#define GATT_DESCR_EXT_DSCPTOR 1 /* Characteristic Extended Properties */
@ -571,8 +572,8 @@ extern void gatt_free(void);
/* from gatt_main.c */
extern BOOLEAN gatt_disconnect (tGATT_TCB *p_tcb);
extern BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBT_TRANSPORT transport);
extern BOOLEAN gatt_connect (BD_ADDR rem_bda, tGATT_TCB *p_tcb, tBT_TRANSPORT transport);
extern BOOLEAN gatt_act_connect (tGATT_REG *p_reg, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, tBT_TRANSPORT transport);
extern BOOLEAN gatt_connect (BD_ADDR rem_bda, tBLE_ADDR_TYPE bd_addr_type, tGATT_TCB *p_tcb, tBT_TRANSPORT transport);
extern void gatt_data_process (tGATT_TCB *p_tcb, BT_HDR *p_buf);
extern void gatt_update_app_use_link_flag ( tGATT_IF gatt_if, tGATT_TCB *p_tcb, BOOLEAN is_add, BOOLEAN check_acl_link);
@ -681,6 +682,7 @@ extern void gatt_sr_update_cback_cnt(tGATT_TCB *p_tcb, tGATT_IF gatt_if, BOOLEAN
extern void gatt_sr_update_prep_cnt(tGATT_TCB *p_tcb, tGATT_IF gatt_if, BOOLEAN is_inc, BOOLEAN is_reset_first);
extern BOOLEAN gatt_find_app_hold_link(tGATT_TCB *p_tcb, UINT8 start_idx, UINT8 *p_found_idx, tGATT_IF *p_gatt_if);
extern BOOLEAN gatt_find_specific_app_in_hold_link(tGATT_TCB *p_tcb, tGATT_IF p_gatt_if);
extern UINT8 gatt_num_apps_hold_link(tGATT_TCB *p_tcb);
extern UINT8 gatt_num_clcb_by_bd_addr(BD_ADDR bda);
extern tGATT_TCB *gatt_find_tcb_by_cid(UINT16 lcid);

View File

@ -276,6 +276,7 @@ typedef struct {
/********************************************************************************
** Macros to get and put bytes to and from a stream (Big Endian format)
*/
#define UINT64_TO_BE_STREAM(p, u64) {*(p)++ = (UINT8)((u64) >> 56); *(p)++ = (UINT8)((u64) >> 48); *(p)++ = (UINT8)((u64) >> 40); *(p)++ = (UINT8)((u64) >> 32); *(p)++ = (UINT8)((u64) >> 24); *(p)++ = (UINT8)((u64) >> 16); *(p)++ = (UINT8)((u64) >> 8); *(p)++ = (UINT8)(u64); }
#define UINT32_TO_BE_STREAM(p, u32) {*(p)++ = (UINT8)((u32) >> 24); *(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)(u32); }
#define UINT24_TO_BE_STREAM(p, u24) {*(p)++ = (UINT8)((u24) >> 16); *(p)++ = (UINT8)((u24) >> 8); *(p)++ = (UINT8)(u24);}
#define UINT16_TO_BE_STREAM(p, u16) {*(p)++ = (UINT8)((u16) >> 8); *(p)++ = (UINT8)(u16);}
@ -498,6 +499,8 @@ typedef struct {
#define BLE_ADDR_RANDOM 0x01
#define BLE_ADDR_PUBLIC_ID 0x02
#define BLE_ADDR_RANDOM_ID 0x03
#define BLE_ADDR_TYPE_MAX BLE_ADDR_RANDOM_ID
#define BLE_ADDR_UNKNOWN_TYPE 0XFF
typedef UINT8 tBLE_ADDR_TYPE;
#define BLE_ADDR_TYPE_MASK (BLE_ADDR_RANDOM | BLE_ADDR_PUBLIC)

View File

@ -72,6 +72,8 @@ enum {
BTM_CONTROL_LE_DATA_LEN_UNSUPPORTED,/* 22 controller setting data length is unsupported*/
BTM_SET_PRIVACY_SUCCESS, /* 23 enable/disable local privacy success */
BTM_SET_PRIVACY_FAIL, /* 24 enable/disable local privacy failed*/
BTM_SET_STATIC_RAND_ADDR_FAIL, /* 25 Command failed */
BTM_INVALID_STATIC_RAND_ADDR, /* 26 invalid static rand addr */
};
typedef uint8_t tBTM_STATUS;
@ -182,6 +184,8 @@ typedef void (tBTM_UPDATE_CONN_PARAM_CBACK) (UINT8 status, BD_ADDR bd_addr, tBTM
typedef void (tBTM_SET_PKT_DATA_LENGTH_CBACK) (UINT8 status, tBTM_LE_SET_PKT_DATA_LENGTH_PARAMS *data_length_params);
typedef void (tBTM_SET_RAND_ADDR_CBACK) (UINT8 status);
typedef void (tBTM_ADD_WHITELIST_CBACK) (UINT8 status, tBTM_WL_OPERATION wl_opration);
typedef void (tBTM_SET_LOCAL_PRIVACY_CBACK) (UINT8 status);

View File

@ -852,6 +852,11 @@ typedef void (*tBLE_SCAN_PARAM_SETUP_CBACK)(tGATT_IF client_if, tBTM_STATUS stat
tBTM_BLE_SCAN_SETUP_CBACK bta_ble_scan_setup_cb;
typedef void (tBTM_START_ADV_CMPL_CBACK) (UINT8 status);
typedef void (tBTM_START_STOP_ADV_CMPL_CBACK) (UINT8 status);
/*****************************************************************************
** EXTERNAL FUNCTION DECLARATIONS
*****************************************************************************/
@ -943,7 +948,7 @@ tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max,
*******************************************************************************/
tBTM_STATUS BTM_BleSetAdvParamsStartAdv(UINT16 adv_int_min, UINT16 adv_int_max, UINT8 adv_type,
tBLE_ADDR_TYPE own_bda_type, tBLE_BD_ADDR *p_dir_bda,
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp);
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP afp, tBTM_START_ADV_CMPL_CBACK *adv_cb);
/*******************************************************************************
@ -977,7 +982,7 @@ tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask,
tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len);
BOOLEAN BTM_BleSetRandAddress(BD_ADDR rand_addr);
tBTM_STATUS BTM_BleSetRandAddress(BD_ADDR rand_addr);
/*******************************************************************************
@ -1610,7 +1615,7 @@ BOOLEAN BTM_ReadConnectedTransportAddress(BD_ADDR remote_bda,
**
*******************************************************************************/
//extern
tBTM_STATUS BTM_BleBroadcast(BOOLEAN start);
tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cback);
/*******************************************************************************
**

View File

@ -104,6 +104,7 @@ typedef UINT8 tBTM_BLE_SEC_REQ_ACT;
#define BTM_VSC_CHIP_CAPABILITY_M_VERSION 95
typedef enum {
BTM_BLE_IDLE,
BTM_BLE_SCANNING,
BTM_BLE_SCAN_PENDING,
BTM_BLE_STOP_SCAN,
@ -147,8 +148,10 @@ typedef struct {
UINT16 adv_interval_max;
tBTM_BLE_AFP afp; /* advertising filter policy */
tBTM_BLE_SFP sfp; /* scanning filter policy */
tBTM_START_ADV_CMPL_CBACK *p_adv_cb;
tBTM_START_STOP_ADV_CMPL_CBACK *p_stop_adv_cb;
tBLE_ADDR_TYPE adv_addr_type;
BOOLEAN adv_callback_twice;
UINT8 evt_type;
UINT8 adv_mode;
tBLE_BD_ADDR direct_bda;
@ -319,7 +322,6 @@ typedef struct {
UINT32 scan_int;
UINT32 scan_win;
tBTM_BLE_SEL_CBACK *p_select_cback;
/* white list information */
UINT8 white_list_avail_size;
tBTM_ADD_WHITELIST_CBACK *add_wl_cb;

View File

@ -486,6 +486,11 @@ typedef struct {
tBTM_LE_KEY_TYPE key_type; /* bit mask of valid key types in record */
tBTM_SEC_BLE_KEYS keys; /* LE device security info in slave rode */
#endif
#if (BLE_PRIVACY_SPT == TRUE)
tBLE_ADDR_TYPE current_addr_type; /* current adv addr type*/
BD_ADDR current_addr; /* current adv addr*/
bool current_addr_valid; /* current addr info is valid or not*/
#endif
} tBTM_SEC_BLE;

View File

@ -234,6 +234,7 @@ extern const BD_ADDR BT_BD_ANY;
*/
void btu_start_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
void btu_stop_timer (TIMER_LIST_ENT *p_tle);
void btu_free_timer (TIMER_LIST_ENT *p_tle);
void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle);
@ -245,6 +246,7 @@ void btu_uipc_rx_cback(BT_HDR *p_msg);
#if defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0)
void btu_start_quick_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
void btu_stop_quick_timer (TIMER_LIST_ENT *p_tle);
void btu_free_quick_timer (TIMER_LIST_ENT *p_tle);
void btu_process_quick_timer_evt (void);
#endif

View File

@ -1097,13 +1097,14 @@ extern void GATT_StartIf (tGATT_IF gatt_if);
**
** Parameters gatt_if: applicaiton interface
** bd_addr: peer device address.
** bd_addr_type: peer device address type.
** is_direct: is a direct conenection or a background auto connection
** transport : Physical transport for GATT connection (BR/EDR or LE)
**
** Returns TRUE if connection started; FALSE if connection start failure.
**
*******************************************************************************/
extern BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr,
extern BOOLEAN GATT_Connect (tGATT_IF gatt_if, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type,
BOOLEAN is_direct, tBT_TRANSPORT transport);

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